Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Update @balena/abstract-sql-compiler from 9.1.4 to 9.2.0
Update @balena/lf-to-abstract-sql from 5.0.1 to 5.0.2
Update @balena/odata-parser from 3.0.3 to 3.0.8
Update @balena/sbvr-parser from 1.4.3 to 1.4.6
Update @balena/sbvr-types from 7.0.1 to 7.1.3

Change-type: patch
  • Loading branch information
Page- committed Aug 26, 2024
1 parent 522ae49 commit 5bb0469
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 43 deletions.
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "@balena/odata-to-abstract-sql",
"version": "6.2.7",
"description": "A consumer of the OData parser, written in OMeta",
"type": "commonjs",
"main": "out/odata-to-abstract-sql.js",
"scripts": {
"lint": "balena-lint -e js -e ts src test && tsc --noEmit && tsc --noEmit --project tsconfig.js.json",
"prettify": "balena-lint -e js -e ts --fix src test",
"lint-fix": "balena-lint -e js -e ts --fix src test",
"pretest": "npm run prepare",
"test": "mocha && npm run lint",
"prepublish": "require-npm4-to-publish",
Expand All @@ -15,31 +16,31 @@
"author": "",
"license": "BSD",
"dependencies": {
"@balena/abstract-sql-compiler": "^9.1.4",
"@balena/odata-parser": "^3.0.3",
"@types/lodash": "^4.14.202",
"@balena/abstract-sql-compiler": "^9.2.0",
"@balena/odata-parser": "^3.0.8",
"@types/lodash": "^4.17.7",
"@types/memoizee": "^0.4.11",
"@types/string-hash": "^1.1.3",
"lodash": "^4.17.21",
"memoizee": "^0.4.15",
"memoizee": "^0.4.17",
"string-hash": "^1.1.3"
},
"devDependencies": {
"@balena/lf-to-abstract-sql": "^5.0.1",
"@balena/lint": "^8.0.0",
"@balena/sbvr-parser": "^1.4.3",
"@balena/sbvr-types": "^7.0.1",
"@types/chai": "^4.3.11",
"@balena/lf-to-abstract-sql": "^5.0.2",
"@balena/lint": "^8.2.7",
"@balena/sbvr-parser": "^1.4.6",
"@balena/sbvr-types": "^7.1.3",
"@types/chai": "^4.3.18",
"@types/chai-things": "0.0.38",
"@types/mocha": "^10.0.6",
"chai": "^4.4.1",
"@types/mocha": "^10.0.7",
"chai": "^4.5.0",
"chai-things": "~0.2.0",
"husky": "^9.0.0",
"lint-staged": "^15.2.0",
"mocha": "^10.2.0",
"husky": "^9.1.5",
"lint-staged": "^15.2.9",
"mocha": "^10.7.3",
"require-npm4-to-publish": "^1.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.5.4"
},
"mocha": {
"reporter": "spec",
Expand Down
33 changes: 15 additions & 18 deletions src/odata-to-abstract-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const containsQueryOption = (opts?: object): boolean => {
return false;
}
for (const key in opts) {
if (key[0] === '$') {
if (key.startsWith('$')) {
return true;
}
}
Expand Down Expand Up @@ -274,7 +274,7 @@ const modifyAbstractSql = <
export const rewriteBinds = (
definition: ModernDefinition,
existingBinds: ODataBinds,
inc: number = 0,
inc = 0,
): void => {
const { binds } = definition;
if (binds == null || binds.length === 0) {
Expand Down Expand Up @@ -338,7 +338,7 @@ export class OData2AbstractSQL {
public extraBindVars = [] as unknown as ODataBinds;
private resourceAliases: Dictionary<AliasedResource> = {};
public defaultResource: Resource | undefined;
public bindVarsLength: number = 0;
public bindVarsLength = 0;
private checkAlias: (alias: string) => string;
private alreadyComputedFields: AlreadyComputedFieldsLookup = {};

Expand Down Expand Up @@ -738,7 +738,7 @@ export class OData2AbstractSQL {
path: ODataQuery,
resource: AliasedResource,
bodyKeys: string[],
): BooleanTypeNodes | void {
): BooleanTypeNodes | undefined {
const { key } = path;
if (key != null) {
if (method === 'PUT' || method === 'PUT-INSERT' || method === 'POST') {
Expand Down Expand Up @@ -938,7 +938,7 @@ export class OData2AbstractSQL {
}
resource[resourceMappingsProp] = resourceMappings;
}
return resource[resourceMappingsProp]!;
return resource[resourceMappingsProp];
}
ResolveRelationship(resource: string | Resource, relationship: string) {
let resourceName;
Expand All @@ -962,7 +962,7 @@ export class OData2AbstractSQL {
.flatMap((sqlName) => this.Synonym(sqlName).split('-'))
.value();
const relationshipMapping = _.get(resourceRelations, relationshipPath);
if (!relationshipMapping || !relationshipMapping.$) {
if (!relationshipMapping?.$) {
throw new SyntaxError(
`Could not resolve relationship mapping from '${resourceName}' to '${relationshipPath}'`,
);
Expand All @@ -978,11 +978,7 @@ export class OData2AbstractSQL {
let odataFieldNames: Array<
Parameters<OData2AbstractSQL['AliasSelectField']>
>;
if (
path.options &&
path.options.$select &&
path.options.$select.properties
) {
if (path.options?.$select?.properties) {
this.AddExtraFroms(query, resource, path.options.$select.properties);
odataFieldNames = path.options.$select.properties.map((prop: any) => {
const field = this.Property(prop) as {
Expand Down Expand Up @@ -1016,7 +1012,7 @@ export class OData2AbstractSQL {
alias: string = fieldName,
// Setting this flag to true will ignore the lookup for alreadyComputedFields
// and will compile the computed Field statement into the abstract SQL statement regardless
forceCompilingComputedField: boolean = false,
forceCompilingComputedField = false,
):
| ReferencedFieldNode
| AliasNode<ReferencedFieldNode>
Expand Down Expand Up @@ -1527,7 +1523,7 @@ export class OData2AbstractSQL {
if (expand.property) {
this.Expands(expandResource, nestedExpandQuery, [expand.property]);
}
if (expand.options && expand.options.$expand) {
if (expand.options?.$expand) {
this.Expands(
expandResource,
nestedExpandQuery,
Expand Down Expand Up @@ -1611,16 +1607,17 @@ export class OData2AbstractSQL {
// TODO: try removing
try {
if (Array.isArray(match)) {
match.forEach((v) => this.AddExtraFroms(query, parentResource, v));
match.forEach((v) => {
this.AddExtraFroms(query, parentResource, v);
});
} else {
let nextProp = match;
let prop;
while (
// tslint:disable-next-line:no-conditional-assignment
(prop = nextProp) &&
prop.name &&
prop.property &&
prop.property.name
prop.property?.name
) {
nextProp = prop.property;
const resourceAlias = this.resourceAliases[prop.name];
Expand All @@ -1634,7 +1631,7 @@ export class OData2AbstractSQL {
);
}
}
if (nextProp && nextProp.args) {
if (nextProp?.args) {
this.AddExtraFroms(query, parentResource, prop.args);
}
}
Expand Down Expand Up @@ -1693,7 +1690,7 @@ export class OData2AbstractSQL {
resource: Resource,
extraBindVars: ODataBinds,
bindVarsLength: number,
bypassDefinition: boolean = false,
bypassDefinition = false,
tableAlias?: string,
isModifyOperation?: boolean,
): FromTypeNodes {
Expand Down
6 changes: 3 additions & 3 deletions test/chai-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ chai.use(function ($chai, utils) {
utils.addMethod(assertionPrototype, 'groupby', multiBodyClause('GroupBy'));
utils.addMethod(assertionPrototype, 'where', bodyClause('Where'));
utils.addMethod(assertionPrototype, 'limit', bodyClause('Limit'));
return utils.addMethod(assertionPrototype, 'offset', bodyClause('Offset'));
utils.addMethod(assertionPrototype, 'offset', bodyClause('Offset'));
});

const generateClientModel = function (input) {
Expand Down Expand Up @@ -160,7 +160,7 @@ export function operandToAbstractSQLFactory(
if (operand === 'null') {
return ['Null'];
}
if (operand.charAt(0) === '(') {
if (operand.startsWith('(')) {
return operand
.slice(1, -1)
.split(',')
Expand All @@ -174,7 +174,7 @@ export function operandToAbstractSQLFactory(
});
}

if (operand.charAt(0) === "'") {
if (operand.startsWith("'")) {
binds.push([
'Text',
decodeURIComponent(operand.slice(1, operand.length - 1)),
Expand Down
18 changes: 12 additions & 6 deletions test/filterby.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,19 @@ run(function () {
);

test(`/pilot?$filter=${odata}`, 'POST', { name: 'Peter' }, (result) =>
it(`should insert pilot where '${odata}'`, () => insertTest(result)),
it(`should insert pilot where '${odata}'`, () => {
insertTest(result);
}),
);

test(`/pilot?$filter=${odata}`, 'PUT', { name: 'Peter' }, (result) =>
describe(`should select from pilot where '${odata}'`, function () {
it('should be an upsert', () => {
expect(result).to.be.a.query.that.upserts;
});
it('that inserts', () => insertTest(result[1]));
it('that inserts', () => {
insertTest(result[1]);
});
return it('and updates', () =>
expect(result[2])
.to.be.a.query.that.updates.fields(
Expand Down Expand Up @@ -725,9 +729,9 @@ run([['Number', 1]], function () {
];

test('/pilot(1)?$filter=' + odata, 'POST', { name }, (result) =>
it('should insert into pilot where "' + odata + '"', () =>
insertTest(result),
),
it('should insert into pilot where "' + odata + '"', () => {
insertTest(result);
}),
);

test('/pilot(1)?$filter=' + odata, 'PATCH', { name }, (result) =>
Expand All @@ -744,7 +748,9 @@ run([['Number', 1]], function () {
describe('should upsert the pilot with id 1', function () {
it('should be an upsert', () =>
expect(result).to.be.a.query.that.upserts);
it('that inserts', () => insertTest(result[1]));
it('that inserts', () => {
insertTest(result[1]);
});
return it('and updates', () => {
expect(result[2])
.to.be.a.query.that.updates.fields(
Expand Down

0 comments on commit 5bb0469

Please sign in to comment.