@balena/abstract-sql-compiler 10.5.0-build-joshbwlng-date-trunc-51521852f16d12fdcd22b51d24bf6a2cea3247e3-1 → 11.0.0-build-11-x-db9cd30f6ec498e5293df9e060f5531cd960b1cc-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.versionbot/CHANGELOG.yml +24 -15
  2. package/CHANGELOG.md +4 -6
  3. package/out/AbstractSQLCompiler.d.ts +7 -6
  4. package/out/AbstractSQLCompiler.js +45 -57
  5. package/out/AbstractSQLCompiler.js.map +1 -1
  6. package/out/AbstractSQLOptimiser.d.ts +1 -1
  7. package/out/AbstractSQLOptimiser.js +9 -56
  8. package/out/AbstractSQLOptimiser.js.map +1 -1
  9. package/out/AbstractSQLRules2SQL.d.ts +2 -2
  10. package/out/AbstractSQLRules2SQL.js +208 -231
  11. package/out/AbstractSQLRules2SQL.js.map +1 -1
  12. package/out/AbstractSQLSchemaOptimiser.d.ts +2 -2
  13. package/out/AbstractSQLSchemaOptimiser.js +14 -21
  14. package/out/AbstractSQLSchemaOptimiser.js.map +1 -1
  15. package/out/referenced-fields.d.ts +1 -1
  16. package/out/referenced-fields.js +17 -24
  17. package/out/referenced-fields.js.map +1 -1
  18. package/package.json +4 -4
  19. package/src/AbstractSQLCompiler.ts +23 -18
  20. package/src/AbstractSQLOptimiser.ts +7 -22
  21. package/src/AbstractSQLRules2SQL.ts +8 -13
  22. package/src/AbstractSQLSchemaOptimiser.ts +6 -5
  23. package/src/referenced-fields.ts +4 -4
  24. package/test/abstract-sql/aggregate-json.ts +1 -1
  25. package/test/abstract-sql/aggregate.ts +25 -10
  26. package/test/abstract-sql/and-or-boolean-optimisations.ts +1 -1
  27. package/test/abstract-sql/case-when-else.ts +5 -2
  28. package/test/abstract-sql/cast.ts +1 -1
  29. package/test/abstract-sql/coalesce.ts +1 -1
  30. package/test/abstract-sql/comparisons.ts +1 -1
  31. package/test/abstract-sql/dates.ts +10 -27
  32. package/test/abstract-sql/duration.ts +1 -1
  33. package/test/abstract-sql/empty-query-optimisations.ts +2 -2
  34. package/test/abstract-sql/functions_wrapper.ts +1 -1
  35. package/test/abstract-sql/get-referenced-fields.ts +1 -1
  36. package/test/abstract-sql/get-rule-referenced-fields.ts +1 -1
  37. package/test/abstract-sql/insert-query.ts +1 -1
  38. package/test/abstract-sql/is-distinct.ts +1 -1
  39. package/test/abstract-sql/joins.ts +1 -1
  40. package/test/abstract-sql/json.ts +1 -1
  41. package/test/abstract-sql/math.ts +1 -1
  42. package/test/abstract-sql/nested-in-optimisations.ts +1 -1
  43. package/test/abstract-sql/not-not-optimisations.ts +1 -1
  44. package/test/abstract-sql/schema-checks.ts +1 -1
  45. package/test/abstract-sql/schema-informative-reference.ts +1 -1
  46. package/test/abstract-sql/schema-rule-optimization.ts +1 -1
  47. package/test/abstract-sql/schema-rule-to-check.ts +1 -1
  48. package/test/abstract-sql/schema-views.ts +37 -2
  49. package/test/abstract-sql/test.ts +1 -1
  50. package/test/abstract-sql/text.ts +1 -1
  51. package/test/odata/expand.ts +3 -3
  52. package/test/odata/filterby.ts +8 -4
  53. package/test/odata/orderby.ts +2 -2
  54. package/test/odata/paging.ts +2 -2
  55. package/test/odata/resource_parsing.ts +5 -5
  56. package/test/odata/select.ts +2 -2
  57. package/test/odata/stress.ts +2 -2
  58. package/test/odata/test.ts +24 -20
  59. package/test/sbvr/pilots.ts +3 -3
  60. package/test/sbvr/reference-type.ts +3 -3
  61. package/test/sbvr/test.ts +12 -10
@@ -1,12 +1,12 @@
1
- import type { ExpectationFailFn, ExpectationSuccessFn } from './test';
2
- import test from './test';
1
+ import type { ExpectationFailFn, ExpectationSuccessFn } from './test.js';
2
+ import test from './test.js';
3
3
  import {
4
4
  pilotFields,
5
5
  aliasFields,
6
6
  aliasLicenceFields,
7
7
  aliasPlaneFields,
8
8
  aliasPilotCanFlyPlaneFields,
9
- } from './fields';
9
+ } from './fields.js';
10
10
  import _ from 'lodash';
11
11
 
12
12
  type TestFn = (
@@ -4,16 +4,20 @@
4
4
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
5
5
  */
6
6
  import { expect } from 'chai';
7
- import type { ExpectationSuccessFn } from './test';
8
- import test, { clientModel } from './test';
7
+ import type { ExpectationSuccessFn } from './test.js';
8
+ import test, { clientModel } from './test.js';
9
9
  import _ from 'lodash';
10
10
  import { odataNameToSqlName } from '@balena/odata-to-abstract-sql';
11
- import { pilotFields, teamFields, aliasPilotCanFlyPlaneFields } from './fields';
11
+ import {
12
+ pilotFields,
13
+ teamFields,
14
+ aliasPilotCanFlyPlaneFields,
15
+ } from './fields.js';
12
16
  import type {
13
17
  Binding,
14
18
  DurationNode,
15
19
  SqlResult,
16
- } from '../../src/AbstractSQLCompiler';
20
+ } from '../../out/AbstractSQLCompiler.js';
17
21
 
18
22
  const pilotFieldsStr = pilotFields.join(', ');
19
23
  const aliasPilotCanFlyPlaneFieldsStr = aliasPilotCanFlyPlaneFields.join(', ');
@@ -1,5 +1,5 @@
1
- import test from './test';
2
- import { pilotFields } from './fields';
1
+ import test from './test.js';
2
+ import { pilotFields } from './fields.js';
3
3
  const pilotFieldsStr = pilotFields.join(', ');
4
4
 
5
5
  test('/pilot?$orderby=name', (result, sqlEquals) => {
@@ -1,5 +1,5 @@
1
- import test from './test';
2
- import { pilotFields } from './fields';
1
+ import test from './test.js';
2
+ import { pilotFields } from './fields.js';
3
3
  const pilotFieldsStr = pilotFields.join(', ');
4
4
 
5
5
  test('/pilot?$top=5', 'GET', [['Bind', 0]], (result, sqlEquals) => {
@@ -1,7 +1,7 @@
1
1
  import { expect } from 'chai';
2
- import type { ExpectationSuccessFn } from './test';
3
- import test from './test';
4
- import * as ODataParser from '@balena/odata-parser';
2
+ import type { ExpectationSuccessFn } from './test.js';
3
+ import test from './test.js';
4
+ import ODataParser from '@balena/odata-parser';
5
5
  import {
6
6
  pilotFields,
7
7
  teamFields,
@@ -9,8 +9,8 @@ import {
9
9
  aliasPlaneFields,
10
10
  aliasPilotLicenceFields,
11
11
  aliasLicenceFields,
12
- } from './fields';
13
- import type { SqlResult } from '../../src/AbstractSQLRules2SQL';
12
+ } from './fields.js';
13
+ import type { SqlResult } from '../../out/AbstractSQLCompiler.js';
14
14
  const aliasPilotFields = aliasFields(
15
15
  'plane.pilot-can fly-plane.pilot',
16
16
  pilotFields,
@@ -1,5 +1,5 @@
1
- import test from './test';
2
- import { pilotFields } from './fields';
1
+ import test from './test.js';
2
+ import { pilotFields } from './fields.js';
3
3
  const pilotFieldsStr = pilotFields.join(', ');
4
4
 
5
5
  test('/pilot?$select=name', (result, sqlEquals) => {
@@ -1,6 +1,6 @@
1
- import test from './test';
1
+ import test from './test.js';
2
2
  import _ from 'lodash';
3
- import { pilotFields } from './fields';
3
+ import { pilotFields } from './fields.js';
4
4
  const pilotFieldsStr = pilotFields.join(', ');
5
5
 
6
6
  const filterIDs = _.range(1, 5000);
@@ -1,33 +1,37 @@
1
- import * as fs from 'node:fs';
2
- import * as ODataParser from '@balena/odata-parser';
1
+ import fs from 'node:fs';
2
+ import ODataParser from '@balena/odata-parser';
3
3
  import { OData2AbstractSQL } from '@balena/odata-to-abstract-sql';
4
- const sbvrModel = fs.readFileSync(require.resolve('../model.sbvr'), 'utf8');
4
+ import $sbvrTypes from '@balena/sbvr-types';
5
+ const { default: sbvrTypes } = $sbvrTypes;
6
+ // @ts-expect-error @balena/sbvr-parser doesn't have types
7
+ import { SBVRParser } from '@balena/sbvr-parser';
8
+ // @ts-expect-error @balena/lf-to-abstract-sql doesn't have types
9
+ import LF2AbstractSQL from '@balena/lf-to-abstract-sql';
5
10
 
6
- import * as AbstractSQLCompiler from '../..';
11
+ const sbvrModel = await fs.promises.readFile(
12
+ new URL(import.meta.resolve('../model.sbvr')),
13
+ 'utf8',
14
+ );
15
+ const typeVocab = await fs.promises.readFile(
16
+ new URL(import.meta.resolve('@balena/sbvr-types/Type.sbvr')),
17
+ 'utf8',
18
+ );
19
+
20
+ import * as AbstractSQLCompiler from '../../out/AbstractSQLCompiler.js';
7
21
 
8
22
  import { expect } from 'chai';
9
23
  import _ from 'lodash';
10
24
 
11
25
  const generateClientModel = function (input: string) {
12
- // eslint-disable-next-line @typescript-eslint/no-require-imports
13
- const sbvrTypes = require('@balena/sbvr-types').default;
14
- const typeVocab = fs.readFileSync(
15
- require.resolve('@balena/sbvr-types/Type.sbvr'),
16
- 'utf8',
17
- );
18
-
19
- // eslint-disable-next-line @typescript-eslint/no-require-imports
20
- const SBVRParser = require('@balena/sbvr-parser').SBVRParser.createInstance();
21
- SBVRParser.enableReusingMemoizations(SBVRParser._sideEffectingRules);
22
- SBVRParser.AddCustomAttribute('Database ID Field:');
23
- SBVRParser.AddCustomAttribute('Database Table Name:');
24
- SBVRParser.AddBuiltInVocab(typeVocab);
26
+ const sbvrParser = SBVRParser.createInstance();
27
+ sbvrParser.enableReusingMemoizations(sbvrParser._sideEffectingRules);
28
+ sbvrParser.AddCustomAttribute('Database ID Field:');
29
+ sbvrParser.AddCustomAttribute('Database Table Name:');
30
+ sbvrParser.AddBuiltInVocab(typeVocab);
25
31
 
26
- // eslint-disable-next-line @typescript-eslint/no-require-imports
27
- const LF2AbstractSQL = require('@balena/lf-to-abstract-sql');
28
32
  const LF2AbstractSQLTranslator = LF2AbstractSQL.createTranslator(sbvrTypes);
29
33
 
30
- const lf = SBVRParser.matchAll(input, 'Process');
34
+ const lf = sbvrParser.matchAll(input, 'Process');
31
35
  const abstractSql = LF2AbstractSQLTranslator(lf, 'Process');
32
36
  return abstractSql;
33
37
  };
@@ -1,9 +1,9 @@
1
- import * as fs from 'node:fs';
1
+ import fs from 'node:fs';
2
2
  const typeVocab = fs.readFileSync(
3
- require.resolve('@balena/sbvr-types/Type.sbvr'),
3
+ new URL(import.meta.resolve('@balena/sbvr-types/Type.sbvr')),
4
4
  'utf8',
5
5
  );
6
- import { getTestHelpers } from './test';
6
+ import { getTestHelpers } from './test.js';
7
7
  const test = getTestHelpers(typeVocab);
8
8
 
9
9
  const modifiedAtTrigger = (tableName: string) => `\
@@ -1,8 +1,8 @@
1
- import * as fs from 'node:fs';
2
- import { getTestHelpers } from './test';
1
+ import fs from 'node:fs';
2
+ import { getTestHelpers } from './test.js';
3
3
 
4
4
  const typeVocab = fs.readFileSync(
5
- require.resolve('@balena/sbvr-types/Type.sbvr'),
5
+ new URL(import.meta.resolve('@balena/sbvr-types/Type.sbvr')),
6
6
  'utf8',
7
7
  );
8
8
 
package/test/sbvr/test.ts CHANGED
@@ -1,20 +1,22 @@
1
1
  import _ from 'lodash';
2
- import sbvrTypes from '@balena/sbvr-types';
2
+ import $sbvrTypes from '@balena/sbvr-types';
3
+ const { default: sbvrTypes } = $sbvrTypes;
4
+ // @ts-expect-error @balena/sbvr-parser doesn't have types
5
+ import { SBVRParser } from '@balena/sbvr-parser';
6
+ // @ts-expect-error @balena/lf-to-abstract-sql doesn't have types
7
+ import LF2AbstractSQL from '@balena/lf-to-abstract-sql';
3
8
 
4
9
  import { expect } from 'chai';
5
- import * as AbstractSQLCompiler from '../..';
10
+ import * as AbstractSQLCompiler from '../../out/AbstractSQLCompiler.js';
6
11
 
7
12
  export function getTestHelpers(builtInVocab: string | boolean = false) {
8
- // eslint-disable-next-line @typescript-eslint/no-require-imports
9
- const SBVRParser = require('@balena/sbvr-parser').SBVRParser.createInstance();
10
- SBVRParser.enableReusingMemoizations(SBVRParser._sideEffectingRules);
13
+ const sbvrParser = SBVRParser.createInstance();
14
+ sbvrParser.enableReusingMemoizations(sbvrParser._sideEffectingRules);
11
15
 
12
- // eslint-disable-next-line @typescript-eslint/no-require-imports
13
- const LF2AbstractSQL = require('@balena/lf-to-abstract-sql');
14
16
  const LF2AbstractSQLTranslator = LF2AbstractSQL.createTranslator(sbvrTypes);
15
17
 
16
18
  if (builtInVocab) {
17
- SBVRParser.AddBuiltInVocab(builtInVocab);
19
+ sbvrParser.AddBuiltInVocab(builtInVocab);
18
20
  }
19
21
 
20
22
  let seSoFar = '';
@@ -27,8 +29,8 @@ export function getTestHelpers(builtInVocab: string | boolean = false) {
27
29
  it(input, function () {
28
30
  let result;
29
31
  try {
30
- SBVRParser.reset();
31
- const lf = SBVRParser.matchAll(seSoFar + input, 'Process');
32
+ sbvrParser.reset();
33
+ const lf = sbvrParser.matchAll(seSoFar + input, 'Process');
32
34
  const schema = LF2AbstractSQLTranslator(lf, 'Process');
33
35
  result = AbstractSQLCompiler.postgres.compileSchema(schema);
34
36
  } catch (e: any) {