Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@balena/odata-to-abstract-sql

Package Overview
Dependencies
Maintainers
3
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balena/odata-to-abstract-sql - npm Package Compare versions

Comparing version 6.3.0-build-patch-delete-use-db-id-wo-translating-f7e0ab275cf2b108cf8e5a81ac325e1c9f903b82-1 to 6.3.0

2

out/odata-to-abstract-sql.d.ts

@@ -75,3 +75,3 @@ import * as memoize from 'memoizee';

PathSegment(method: InternalSupportedMethod, bodyKeys: string[], path: ODataQuery): Query;
PathKey(method: InternalSupportedMethod, path: ODataQuery, resource: AliasedResource, bodyKeys: string[]): BooleanTypeNodes | void;
PathKey(method: InternalSupportedMethod, path: ODataQuery, resource: AliasedResource, bodyKeys: string[]): BooleanTypeNodes | undefined;
Bind(bind: BindReference, optional: true): BindNode | undefined;

@@ -78,0 +78,0 @@ Bind(bind: BindReference): BindNode;

@@ -45,3 +45,3 @@ "use strict";

for (const key in opts) {
if (key[0] === '$') {
if (key.startsWith('$')) {
return true;

@@ -61,5 +61,2 @@ }

tableOrSubqueryNode = fromNode;
if (!(0, abstract_sql_compiler_1.isTableNode)(tableOrSubqueryNode)) {
throw new Error('');
}
}

@@ -90,3 +87,2 @@ if ((0, abstract_sql_compiler_1.isTableNode)(tableOrSubqueryNode)) {

selectNode.push(['ReferencedField', aliasName, fieldNameAlias]);
return;
};

@@ -483,7 +479,3 @@ class Query {

subQuery.fromResource(this, resource);
subQuery.addNestedFieldSelect(resource.idField, method === 'PATCH'
? '$updateid'
: method === 'DELETE'
? '$deleteid'
: '$upsertid');
subQuery.addNestedFieldSelect(resource.idField, '$modifyid');
if (hasQueryOpts) {

@@ -688,3 +680,3 @@ this.AddQueryOptions(resource, path, subQuery);

const relationshipMapping = _.get(resourceRelations, relationshipPath);
if (!relationshipMapping || !relationshipMapping.$) {
if (!relationshipMapping?.$) {
throw new SyntaxError(`Could not resolve relationship mapping from '${resourceName}' to '${relationshipPath}'`);

@@ -701,5 +693,3 @@ }

let odataFieldNames;
if (path.options &&
path.options.$select &&
path.options.$select.properties) {
if (path.options?.$select?.properties) {
this.AddExtraFroms(query, resource, path.options.$select.properties);

@@ -1125,3 +1115,3 @@ odataFieldNames = path.options.$select.properties.map((prop) => {

}
if (expand.options && expand.options.$expand) {
if (expand.options?.$expand) {
this.Expands(expandResource, nestedExpandQuery, expand.options.$expand.properties);

@@ -1195,3 +1185,5 @@ }

if (Array.isArray(match)) {
match.forEach((v) => this.AddExtraFroms(query, parentResource, v));
match.forEach((v) => {
this.AddExtraFroms(query, parentResource, v);
});
}

@@ -1203,4 +1195,3 @@ else {

prop.name &&
prop.property &&
prop.property.name) {
prop.property?.name) {
nextProp = prop.property;

@@ -1215,3 +1206,3 @@ const resourceAlias = this.resourceAliases[prop.name];

}
if (nextProp && nextProp.args) {
if (nextProp?.args) {
this.AddExtraFroms(query, parentResource, prop.args);

@@ -1218,0 +1209,0 @@ }

{
"name": "@balena/odata-to-abstract-sql",
"version": "6.3.0-build-patch-delete-use-db-id-wo-translating-f7e0ab275cf2b108cf8e5a81ac325e1c9f903b82-1",
"version": "6.3.0",
"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",

@@ -18,27 +19,27 @@ "test": "mocha && npm run lint",

"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"
},

@@ -57,4 +58,4 @@ "mocha": {

"versionist": {
"publishedAt": "2024-08-26T10:30:57.642Z"
"publishedAt": "2024-08-26T16:42:16.123Z"
}
}

@@ -175,3 +175,3 @@ import * as _ from 'lodash';

for (const key in opts) {
if (key[0] === '$') {
if (key.startsWith('$')) {
return true;

@@ -196,5 +196,2 @@ }

tableOrSubqueryNode = fromNode;
if (!isTableNode(tableOrSubqueryNode)) {
throw new Error('');
}
}

@@ -233,3 +230,2 @@ if (isTableNode(tableOrSubqueryNode)) {

selectNode.push(['ReferencedField', aliasName, fieldNameAlias]);
return;
};

@@ -343,3 +339,3 @@

existingBinds: ODataBinds,
inc: number = 0,
inc = 0,
): void => {

@@ -408,3 +404,3 @@ const { binds } = definition;

public defaultResource: Resource | undefined;
public bindVarsLength: number = 0;
public bindVarsLength = 0;
private checkAlias: (alias: string) => string;

@@ -789,10 +785,3 @@ private alreadyComputedFields: AlreadyComputedFieldsLookup = {};

subQuery.fromResource(this, resource);
subQuery.addNestedFieldSelect(
resource.idField,
method === 'PATCH'
? '$updateid'
: method === 'DELETE'
? '$deleteid'
: '$upsertid',
);
subQuery.addNestedFieldSelect(resource.idField, '$modifyid');
if (hasQueryOpts) {

@@ -817,3 +806,3 @@ this.AddQueryOptions(resource, path, subQuery);

bodyKeys: string[],
): BooleanTypeNodes | void {
): BooleanTypeNodes | undefined {
const { key } = path;

@@ -1018,3 +1007,3 @@ if (key != null) {

}
return resource[resourceMappingsProp]!;
return resource[resourceMappingsProp];
}

@@ -1043,3 +1032,3 @@ ResolveRelationship(resource: string | Resource, relationship: string) {

const relationshipMapping = _.get(resourceRelations, relationshipPath);
if (!relationshipMapping || !relationshipMapping.$) {
if (!relationshipMapping?.$) {
throw new SyntaxError(

@@ -1060,7 +1049,3 @@ `Could not resolve relationship mapping from '${resourceName}' to '${relationshipPath}'`,

>;
if (
path.options &&
path.options.$select &&
path.options.$select.properties
) {
if (path.options?.$select?.properties) {
this.AddExtraFroms(query, resource, path.options.$select.properties);

@@ -1099,3 +1084,3 @@ odataFieldNames = path.options.$select.properties.map((prop: any) => {

// and will compile the computed Field statement into the abstract SQL statement regardless
forceCompilingComputedField: boolean = false,
forceCompilingComputedField = false,
):

@@ -1611,3 +1596,3 @@ | ReferencedFieldNode

}
if (expand.options && expand.options.$expand) {
if (expand.options?.$expand) {
this.Expands(

@@ -1696,3 +1681,5 @@ expandResource,

if (Array.isArray(match)) {
match.forEach((v) => this.AddExtraFroms(query, parentResource, v));
match.forEach((v) => {
this.AddExtraFroms(query, parentResource, v);
});
} else {

@@ -1705,4 +1692,3 @@ let nextProp = match;

prop.name &&
prop.property &&
prop.property.name
prop.property?.name
) {

@@ -1721,3 +1707,3 @@ nextProp = prop.property;

}
if (nextProp && nextProp.args) {
if (nextProp?.args) {
this.AddExtraFroms(query, parentResource, prop.args);

@@ -1781,3 +1767,3 @@ }

bindVarsLength: number,
bypassDefinition: boolean = false,
bypassDefinition = false,
tableAlias?: string,

@@ -1784,0 +1770,0 @@ isModifyOperation?: boolean,

@@ -85,3 +85,3 @@ import * as _ from 'lodash';

utils.addMethod(assertionPrototype, 'limit', bodyClause('Limit'));
return utils.addMethod(assertionPrototype, 'offset', bodyClause('Offset'));
utils.addMethod(assertionPrototype, 'offset', bodyClause('Offset'));
});

@@ -164,3 +164,3 @@

}
if (operand.charAt(0) === '(') {
if (operand.startsWith('(')) {
return operand

@@ -179,3 +179,3 @@ .slice(1, -1)

if (operand.charAt(0) === "'") {
if (operand.startsWith("'")) {
binds.push([

@@ -182,0 +182,0 @@ 'Text',

@@ -65,8 +65,2 @@ import { expect } from 'chai';

const methodToWhereClauseIdMap = {
PATCH: '$updateid',
PUT: '$upsertid',
DELETE: '$deleteid',
};
const createExpression = function (lhs, op, rhs) {

@@ -483,6 +477,3 @@ if (lhs === 'not') {

};
const getUpdateWhere = (
/** @type keyof typeof methodToWhereClauseIdMap */ method,
) => [
const updateWhere = [
'In',

@@ -492,12 +483,3 @@ ['ReferencedField', 'pilot', 'id'],

'SelectQuery',
[
'Select',
[
[
'Alias',
['ReferencedField', 'pilot', 'id'],
methodToWhereClauseIdMap[method],
],
],
],
['Select', [['Alias', ['ReferencedField', 'pilot', 'id'], '$modifyid']]],
['From', ['Table', 'pilot']],

@@ -548,3 +530,3 @@ [

.from('pilot')
.where(getUpdateWhere('PATCH'));
.where(updateWhere);
}),

@@ -598,3 +580,3 @@ );

.from('pilot')
.where(getUpdateWhere('PUT'));
.where(updateWhere);
});

@@ -615,3 +597,3 @@ }),

'Select',
[['Alias', ['ReferencedField', 'pilot', 'id'], '$deleteid']],
[['Alias', ['ReferencedField', 'pilot', 'id'], '$modifyid']],
],

@@ -744,6 +726,3 @@ ['From', ['Table', 'pilot']],

};
const getUpdateWhere = (
/** @type keyof typeof methodToWhereClauseIdMap */ method,
) => [
const updateWhere = [
'And',

@@ -758,9 +737,3 @@ ['IsNotDistinctFrom', ['ReferencedField', 'pilot', 'id'], ['Bind', 0]],

'Select',
[
[
'Alias',
['ReferencedField', 'pilot', 'id'],
methodToWhereClauseIdMap[method],
],
],
[['Alias', ['ReferencedField', 'pilot', 'id'], '$modifyid']],
],

@@ -785,3 +758,3 @@ ['From', ['Table', 'pilot']],

.from('pilot')
.where(getUpdateWhere('PATCH'));
.where(updateWhere);
}),

@@ -828,3 +801,3 @@ );

.from('pilot')
.where(getUpdateWhere('PUT'));
.where(updateWhere);
});

@@ -1558,3 +1531,3 @@ }),

'SelectQuery',
['Select', [['ReferencedField', 'copilot', '$updateid']]],
['Select', [['ReferencedField', 'copilot', '$modifyid']]],
[

@@ -1575,3 +1548,3 @@ 'From',

['ReferencedField', 'copilot', 'id'],
'$updateid',
'$modifyid',
],

@@ -1618,3 +1591,3 @@ ],

'SelectQuery',
['Select', [['ReferencedField', 'copilot', '$deleteid']]],
['Select', [['ReferencedField', 'copilot', '$modifyid']]],
[

@@ -1635,3 +1608,3 @@ 'From',

['ReferencedField', 'copilot', 'id'],
'$deleteid',
'$modifyid',
],

@@ -1638,0 +1611,0 @@ ],

@@ -41,3 +41,3 @@ import { expect } from 'chai';

'Select',
[['Alias', ['ReferencedField', 'pilot', 'id'], '$updateid']],
[['Alias', ['ReferencedField', 'pilot', 'id'], '$modifyid']],
],

@@ -61,3 +61,3 @@ ['From', ['Table', 'pilot']],

'Select',
[['Alias', ['ReferencedField', 'pilot', 'id'], '$deleteid']],
[['Alias', ['ReferencedField', 'pilot', 'id'], '$modifyid']],
],

@@ -64,0 +64,0 @@ ['From', ['Table', 'pilot']],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc