@balena/pinejs 19.7.2-build-esm-debc5e08e09b78ba96aec7ee219676236007e113-1 → 19.7.2-build-update-deps-a909ee054f395de407ec4e1275fd0f5b7514fe29-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 (168) hide show
  1. package/.versionbot/CHANGELOG.yml +3 -3
  2. package/CHANGELOG.md +1 -1
  3. package/{Gruntfile.cts → Gruntfile.ts} +22 -9
  4. package/bin/abstract-sql-compiler.js +1 -1
  5. package/bin/odata-compiler.js +1 -1
  6. package/bin/sbvr-compiler.js +1 -1
  7. package/build/{browser.cts → browser.ts} +1 -1
  8. package/build/{config.cts → config.ts} +1 -5
  9. package/build/{module.cts → module.ts} +1 -1
  10. package/build/{server.cts → server.ts} +1 -1
  11. package/out/bin/abstract-sql-compiler.js +19 -17
  12. package/out/bin/abstract-sql-compiler.js.map +1 -1
  13. package/out/bin/odata-compiler.js +21 -19
  14. package/out/bin/odata-compiler.js.map +1 -1
  15. package/out/bin/sbvr-compiler.js +54 -19
  16. package/out/bin/sbvr-compiler.js.map +1 -1
  17. package/out/bin/utils.d.ts +3 -3
  18. package/out/bin/utils.js +53 -21
  19. package/out/bin/utils.js.map +1 -1
  20. package/out/config-loader/config-loader.d.ts +6 -6
  21. package/out/config-loader/config-loader.js +63 -23
  22. package/out/config-loader/config-loader.js.map +1 -1
  23. package/out/config-loader/env.d.ts +1 -1
  24. package/out/config-loader/env.js +66 -24
  25. package/out/config-loader/env.js.map +1 -1
  26. package/out/data-server/sbvr-server.d.ts +3 -3
  27. package/out/data-server/sbvr-server.js +42 -5
  28. package/out/data-server/sbvr-server.js.map +1 -1
  29. package/out/database-layer/db.d.ts +3 -3
  30. package/out/database-layer/db.js +83 -37
  31. package/out/database-layer/db.js.map +1 -1
  32. package/out/express-emulator/express.js.map +1 -1
  33. package/out/extended-sbvr-parser/extended-sbvr-parser.js +11 -8
  34. package/out/extended-sbvr-parser/extended-sbvr-parser.js.map +1 -1
  35. package/out/http-transactions/transactions.d.ts +2 -2
  36. package/out/http-transactions/transactions.js +4 -4
  37. package/out/http-transactions/transactions.js.map +1 -1
  38. package/out/migrator/async.d.ts +2 -2
  39. package/out/migrator/async.js +60 -20
  40. package/out/migrator/async.js.map +1 -1
  41. package/out/migrator/migrations.js +2 -1
  42. package/out/migrator/sync.d.ts +6 -6
  43. package/out/migrator/sync.js +61 -20
  44. package/out/migrator/sync.js.map +1 -1
  45. package/out/migrator/utils.d.ts +4 -4
  46. package/out/migrator/utils.js +97 -42
  47. package/out/migrator/utils.js.map +1 -1
  48. package/out/odata-metadata/odata-metadata-generator.js +14 -7
  49. package/out/odata-metadata/odata-metadata-generator.js.map +1 -1
  50. package/out/passport-pinejs/mount-login-router.d.ts +1 -1
  51. package/out/passport-pinejs/mount-login-router.js +41 -4
  52. package/out/passport-pinejs/mount-login-router.js.map +1 -1
  53. package/out/passport-pinejs/passport-pinejs.d.ts +1 -1
  54. package/out/passport-pinejs/passport-pinejs.js +46 -11
  55. package/out/passport-pinejs/passport-pinejs.js.map +1 -1
  56. package/out/pinejs-session-store/pinejs-session-store.d.ts +1 -1
  57. package/out/pinejs-session-store/pinejs-session-store.js +48 -11
  58. package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
  59. package/out/sbvr-api/abstract-sql.d.ts +2 -2
  60. package/out/sbvr-api/abstract-sql.js +65 -22
  61. package/out/sbvr-api/abstract-sql.js.map +1 -1
  62. package/out/sbvr-api/cached-compile.js +15 -8
  63. package/out/sbvr-api/cached-compile.js.map +1 -1
  64. package/out/sbvr-api/common-types.js +2 -1
  65. package/out/sbvr-api/control-flow.d.ts +1 -1
  66. package/out/sbvr-api/control-flow.js +25 -12
  67. package/out/sbvr-api/control-flow.js.map +1 -1
  68. package/out/sbvr-api/dev.js +2 -1
  69. package/out/sbvr-api/errors.d.ts +1 -1
  70. package/out/sbvr-api/errors.js +95 -47
  71. package/out/sbvr-api/errors.js.map +1 -1
  72. package/out/sbvr-api/express-extension.d.ts +2 -2
  73. package/out/sbvr-api/express-extension.js +2 -1
  74. package/out/sbvr-api/hooks.d.ts +4 -4
  75. package/out/sbvr-api/hooks.js +35 -23
  76. package/out/sbvr-api/hooks.js.map +1 -1
  77. package/out/sbvr-api/odata-response.d.ts +2 -2
  78. package/out/sbvr-api/odata-response.js +29 -19
  79. package/out/sbvr-api/odata-response.js.map +1 -1
  80. package/out/sbvr-api/permissions.d.ts +8 -8
  81. package/out/sbvr-api/permissions.js +159 -106
  82. package/out/sbvr-api/permissions.js.map +1 -1
  83. package/out/sbvr-api/sbvr-utils.d.ts +16 -38
  84. package/out/sbvr-api/sbvr-utils.js +285 -222
  85. package/out/sbvr-api/sbvr-utils.js.map +1 -1
  86. package/out/sbvr-api/translations.d.ts +1 -1
  87. package/out/sbvr-api/translations.js +17 -10
  88. package/out/sbvr-api/translations.js.map +1 -1
  89. package/out/sbvr-api/uri-parser.d.ts +6 -6
  90. package/out/sbvr-api/uri-parser.js +84 -39
  91. package/out/sbvr-api/uri-parser.js.map +1 -1
  92. package/out/sbvr-api/user.js +2 -1
  93. package/out/server-glue/global-ext.d.ts +3 -0
  94. package/out/server-glue/module.d.ts +15 -15
  95. package/out/server-glue/module.js +59 -20
  96. package/out/server-glue/module.js.map +1 -1
  97. package/out/server-glue/sbvr-loader.d.ts +1 -2
  98. package/out/server-glue/sbvr-loader.js +11 -4
  99. package/out/server-glue/sbvr-loader.js.map +1 -1
  100. package/out/server-glue/server.d.ts +2 -2
  101. package/out/server-glue/server.js +59 -17
  102. package/out/server-glue/server.js.map +1 -1
  103. package/out/tasks/common.d.ts +1 -1
  104. package/out/tasks/common.js +9 -3
  105. package/out/tasks/common.js.map +1 -1
  106. package/out/tasks/index.d.ts +8 -8
  107. package/out/tasks/index.js +63 -25
  108. package/out/tasks/index.js.map +1 -1
  109. package/out/tasks/tasks.js +2 -1
  110. package/out/tasks/worker.d.ts +3 -3
  111. package/out/tasks/worker.js +51 -14
  112. package/out/tasks/worker.js.map +1 -1
  113. package/out/webresource-handler/handlers/NoopHandler.d.ts +1 -1
  114. package/out/webresource-handler/handlers/NoopHandler.js +5 -1
  115. package/out/webresource-handler/handlers/NoopHandler.js.map +1 -1
  116. package/out/webresource-handler/handlers/S3Handler.d.ts +1 -1
  117. package/out/webresource-handler/handlers/S3Handler.js +24 -17
  118. package/out/webresource-handler/handlers/S3Handler.js.map +1 -1
  119. package/out/webresource-handler/handlers/index.d.ts +2 -2
  120. package/out/webresource-handler/handlers/index.js +18 -2
  121. package/out/webresource-handler/handlers/index.js.map +1 -1
  122. package/out/webresource-handler/index.d.ts +1 -1
  123. package/out/webresource-handler/index.js +85 -35
  124. package/out/webresource-handler/index.js.map +1 -1
  125. package/package.json +33 -33
  126. package/src/bin/abstract-sql-compiler.ts +3 -3
  127. package/src/bin/odata-compiler.ts +3 -3
  128. package/src/bin/sbvr-compiler.ts +2 -2
  129. package/src/bin/utils.ts +15 -23
  130. package/src/config-loader/config-loader.ts +11 -11
  131. package/src/config-loader/env.ts +3 -3
  132. package/src/data-server/sbvr-server.ts +4 -4
  133. package/src/database-layer/db.ts +11 -18
  134. package/src/extended-sbvr-parser/extended-sbvr-parser.ts +5 -5
  135. package/src/http-transactions/transactions.js +4 -4
  136. package/src/migrator/async.ts +5 -5
  137. package/src/migrator/sync.ts +8 -8
  138. package/src/migrator/utils.ts +7 -7
  139. package/src/odata-metadata/odata-metadata-generator.ts +2 -3
  140. package/src/passport-pinejs/mount-login-router.ts +3 -3
  141. package/src/passport-pinejs/passport-pinejs.ts +3 -3
  142. package/src/pinejs-session-store/pinejs-session-store.ts +4 -4
  143. package/src/sbvr-api/abstract-sql.ts +5 -5
  144. package/src/sbvr-api/cached-compile.ts +1 -1
  145. package/src/sbvr-api/control-flow.ts +1 -1
  146. package/src/sbvr-api/errors.ts +1 -1
  147. package/src/sbvr-api/express-extension.ts +2 -2
  148. package/src/sbvr-api/hooks.ts +5 -5
  149. package/src/sbvr-api/odata-response.ts +4 -8
  150. package/src/sbvr-api/permissions.ts +17 -17
  151. package/src/sbvr-api/sbvr-utils.ts +31 -37
  152. package/src/sbvr-api/translations.ts +1 -1
  153. package/src/sbvr-api/uri-parser.ts +9 -9
  154. package/src/server-glue/global-ext.d.ts +3 -0
  155. package/src/server-glue/module.ts +19 -19
  156. package/src/server-glue/sbvr-loader.ts +27 -15
  157. package/src/server-glue/server.ts +24 -13
  158. package/src/tasks/common.ts +1 -1
  159. package/src/tasks/index.ts +14 -14
  160. package/src/tasks/worker.ts +8 -8
  161. package/src/webresource-handler/handlers/NoopHandler.ts +1 -5
  162. package/src/webresource-handler/handlers/S3Handler.ts +1 -1
  163. package/src/webresource-handler/handlers/index.ts +2 -2
  164. package/src/webresource-handler/index.ts +8 -8
  165. package/tsconfig.dev.json +2 -4
  166. package/tsconfig.json +1 -1
  167. package/typings/lf-to-abstract-sql.d.ts +2 -2
  168. package/typings/memoizee.d.ts +1 -1
@@ -7,12 +7,12 @@ import {
7
7
  odataNameToSqlName,
8
8
  isBindReference,
9
9
  } from '@balena/odata-to-abstract-sql';
10
- import deepFreeze from 'deep-freeze';
10
+ import deepFreeze = require('deep-freeze');
11
11
  import memoize from 'memoizee';
12
- import * as env from '../config-loader/env.js';
13
- import { BadRequestError, SqlCompilationError } from './errors.js';
14
- import * as sbvrUtils from './sbvr-utils.js';
15
- import type { ODataRequest } from './uri-parser.js';
12
+ import * as env from '../config-loader/env';
13
+ import { BadRequestError, SqlCompilationError } from './errors';
14
+ import * as sbvrUtils from './sbvr-utils';
15
+ import type { ODataRequest } from './uri-parser';
16
16
 
17
17
  const getMemoizedCompileRule = memoize(
18
18
  (engine: AbstractSQLCompiler.Engines) =>
@@ -12,7 +12,7 @@ let cache: null | {
12
12
  } = null;
13
13
  let fs: undefined | typeof Fs;
14
14
  try {
15
- fs = await import('fs');
15
+ fs = require('fs');
16
16
  } catch {
17
17
  // Ignore error
18
18
  }
@@ -1,4 +1,4 @@
1
- import type { Resolvable } from './common-types.js';
1
+ import type { Resolvable } from './common-types';
2
2
 
3
3
  import _ from 'lodash';
4
4
  import { TypedError } from 'typed-error';
@@ -1,4 +1,4 @@
1
- import type { AnyObject, Tail } from './common-types.js';
1
+ import type { AnyObject, Tail } from './common-types';
2
2
 
3
3
  import { TypedError } from 'typed-error';
4
4
 
@@ -3,7 +3,7 @@
3
3
  declare global {
4
4
  // eslint-disable-next-line @typescript-eslint/no-namespace
5
5
  namespace Express {
6
- type PineUser = import('./sbvr-utils.js').User;
6
+ type PineUser = import('./sbvr-utils').User;
7
7
 
8
8
  // Augment Express.User to include the props of our PineUser.
9
9
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -11,7 +11,7 @@ declare global {
11
11
 
12
12
  interface Request {
13
13
  user?: User;
14
- apiKey?: import('./sbvr-utils.js').ApiKey;
14
+ apiKey?: import('./sbvr-utils').ApiKey;
15
15
  }
16
16
  }
17
17
  }
@@ -1,12 +1,12 @@
1
- import type { OptionalField, Resolvable } from './common-types.js';
2
- import type { Result, Tx } from '../database-layer/db.js';
3
- import type { ODataRequest, ParsedODataRequest } from './uri-parser.js';
1
+ import type { OptionalField, Resolvable } from './common-types';
2
+ import type { Result, Tx } from '../database-layer/db';
3
+ import type { ODataRequest, ParsedODataRequest } from './uri-parser';
4
4
  import type { AnyObject } from 'pinejs-client-core';
5
5
  import type { TypedError } from 'typed-error';
6
6
  import type { SupportedMethod } from '@balena/odata-to-abstract-sql';
7
7
 
8
8
  import _ from 'lodash';
9
- import { settleMapSeries } from './control-flow.js';
9
+ import { settleMapSeries } from './control-flow';
10
10
  import memoize from 'memoizee';
11
11
  import {
12
12
  type User,
@@ -15,7 +15,7 @@ import {
15
15
  getAbstractSqlModel,
16
16
  api,
17
17
  type Response,
18
- } from './sbvr-utils.js';
18
+ } from './sbvr-utils';
19
19
 
20
20
  export interface HookReq {
21
21
  user?: User;
@@ -18,17 +18,13 @@ declare module '@balena/abstract-sql-compiler' {
18
18
  }
19
19
  }
20
20
 
21
- import type { Result, Row } from '../database-layer/db.js';
21
+ import type { Result, Row } from '../database-layer/db';
22
22
 
23
23
  import { sqlNameToODataName } from '@balena/odata-to-abstract-sql';
24
- import type { SbvrType } from '@balena/sbvr-types';
24
+ import sbvrTypes, { type SbvrType } from '@balena/sbvr-types';
25
25
  import _ from 'lodash';
26
- import {
27
- sbvrTypes,
28
- resolveNavigationResource,
29
- resolveSynonym,
30
- } from './sbvr-utils.js';
31
- import { getWebresourceHandler } from '../webresource-handler/index.js';
26
+ import { resolveNavigationResource, resolveSynonym } from './sbvr-utils';
27
+ import { getWebresourceHandler } from '../webresource-handler';
32
28
 
33
29
  const checkForExpansion = async (
34
30
  vocab: string,
@@ -1,4 +1,4 @@
1
- import type AuthModel from './user.js';
1
+ import type AuthModel from './user';
2
2
  import type {
3
3
  AbstractSqlModel,
4
4
  AbstractSqlQuery,
@@ -14,16 +14,16 @@ import type {
14
14
  SelectNode,
15
15
  SelectQueryNode,
16
16
  } from '@balena/abstract-sql-compiler';
17
- import './express-extension.js';
17
+ import './express-extension';
18
18
  import type * as Express from 'express';
19
19
  import type {
20
20
  ODataBinds,
21
21
  ODataQuery,
22
22
  SupportedMethod,
23
23
  } from '@balena/odata-parser';
24
- import type { Tx } from '../database-layer/db.js';
25
- import type { ApiKey, User } from '../sbvr-api/sbvr-utils.js';
26
- import type { AnyObject, Dictionary } from './common-types.js';
24
+ import type { Tx } from '../database-layer/db';
25
+ import type { ApiKey, User } from '../sbvr-api/sbvr-utils';
26
+ import type { AnyObject, Dictionary } from './common-types';
27
27
 
28
28
  import {
29
29
  isBindReference,
@@ -36,28 +36,28 @@ import * as ODataParser from '@balena/odata-parser';
36
36
 
37
37
  import _ from 'lodash';
38
38
  import memoize from 'memoizee';
39
- import randomstring from 'randomstring';
40
- import * as env from '../config-loader/env.js';
41
- import * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
42
- import { type HookReq, addPureHook, addHook } from './hooks.js';
39
+ import * as randomstring from 'randomstring';
40
+ import * as env from '../config-loader/env';
41
+ import * as sbvrUtils from '../sbvr-api/sbvr-utils';
42
+ import { type HookReq, addPureHook, addHook } from './hooks';
43
43
  import {
44
44
  BadRequestError,
45
45
  PermissionError,
46
46
  PermissionParsingError,
47
- } from './errors.js';
47
+ } from './errors';
48
48
  import {
49
49
  memoizedGetOData2AbstractSQL,
50
50
  memoizedParseOdata,
51
51
  metadataEndpoints,
52
52
  type ODataRequest,
53
- } from './uri-parser.js';
54
- import memoizeWeak from 'memoizee/weak.js';
55
- import type { Config } from '../config-loader/config-loader.js';
53
+ } from './uri-parser';
54
+ import memoizeWeak from 'memoizee/weak';
55
+ import type { Config } from '../config-loader/config-loader';
56
56
  import type { ODataOptions } from 'pinejs-client-core';
57
- import type { Permission } from './user.js';
58
- import { importSBVR } from '../server-glue/sbvr-loader.js';
57
+ import type { Permission } from './user';
58
+ import { requireSBVR } from '../server-glue/sbvr-loader';
59
59
 
60
- const userModel = await importSBVR('./user.sbvr', import.meta);
60
+ const userModel = requireSBVR('./user.sbvr', require);
61
61
 
62
62
  const DEFAULT_ACTOR_BIND = '@__ACTOR_ID';
63
63
  const DEFAULT_ACTOR_BIND_REGEX = new RegExp(
@@ -1779,7 +1779,7 @@ export const addPermissions = async (
1779
1779
  }
1780
1780
  };
1781
1781
 
1782
- declare module './sbvr-utils.js' {
1782
+ declare module './sbvr-utils' {
1783
1783
  export interface API {
1784
1784
  [authModelConfig.apiRoot]: PinejsClient<AuthModel>;
1785
1785
  }
@@ -1,7 +1,7 @@
1
1
  import type * as Express from 'express';
2
- import type * as Db from '../database-layer/db.js';
3
- import type { Model } from '../config-loader/config-loader.js';
4
- import type { AnyObject, RequiredField } from './common-types.js';
2
+ import type * as Db from '../database-layer/db';
3
+ import type { Model } from '../config-loader/config-loader';
4
+ import type { AnyObject, RequiredField } from './common-types';
5
5
  import type {
6
6
  PickDeferred,
7
7
  Resource,
@@ -21,14 +21,12 @@ declare global {
21
21
  import _ from 'lodash';
22
22
 
23
23
  import type { TypedError } from 'typed-error';
24
- import { cachedCompile } from './cached-compile.js';
24
+ import { cachedCompile } from './cached-compile';
25
25
 
26
26
  type LFModel = any[];
27
27
  import * as AbstractSQLCompiler from '@balena/abstract-sql-compiler';
28
- import AbstractSqlCompilerPackage from '@balena/abstract-sql-compiler/package.json' with { type: 'json' };
29
- const { version: AbstractSQLCompilerVersion } = AbstractSqlCompilerPackage;
30
-
31
- import LF2AbstractSQL from '@balena/lf-to-abstract-sql';
28
+ import { version as AbstractSQLCompilerVersion } from '@balena/abstract-sql-compiler/package.json';
29
+ import * as LF2AbstractSQL from '@balena/lf-to-abstract-sql';
32
30
 
33
31
  import {
34
32
  type ODataBinds,
@@ -36,22 +34,21 @@ import {
36
34
  sqlNameToODataName,
37
35
  type SupportedMethod,
38
36
  } from '@balena/odata-to-abstract-sql';
39
- import $sbvrTypes from '@balena/sbvr-types';
40
- const { default: sbvrTypes } = $sbvrTypes;
41
- import deepFreeze from 'deep-freeze';
37
+ import sbvrTypes from '@balena/sbvr-types';
38
+ import deepFreeze = require('deep-freeze');
42
39
  import type { ODataOptions, Params } from 'pinejs-client-core';
43
40
  import { PinejsClientCore, type PromiseResultTypes } from 'pinejs-client-core';
44
41
 
45
- import { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser.js';
42
+ import { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser';
46
43
 
47
- import * as asyncMigrator from '../migrator/async.js';
48
- import * as syncMigrator from '../migrator/sync.js';
49
- import { generateODataMetadata } from '../odata-metadata/odata-metadata-generator.js';
50
- import { importSBVR } from '../server-glue/sbvr-loader.js';
44
+ import * as asyncMigrator from '../migrator/async';
45
+ import * as syncMigrator from '../migrator/sync';
46
+ import { generateODataMetadata } from '../odata-metadata/odata-metadata-generator';
47
+ import { requireSBVR } from '../server-glue/sbvr-loader';
51
48
 
52
- import type DevModel from './dev.js';
53
- const devModel = await importSBVR('./dev.sbvr', import.meta);
54
- import * as permissions from './permissions.js';
49
+ import type DevModel from './dev';
50
+ const devModel = requireSBVR('./dev.sbvr', require);
51
+ import * as permissions from './permissions';
55
52
  import {
56
53
  BadRequestError,
57
54
  ConflictError,
@@ -66,9 +63,9 @@ import {
66
63
  statusCodeToError,
67
64
  TranslationError,
68
65
  UnauthorizedError,
69
- } from './errors.js';
70
- import * as uriParser from './uri-parser.js';
71
- export type { ODataRequest } from './uri-parser.js';
66
+ } from './errors';
67
+ import * as uriParser from './uri-parser';
68
+ export type { ODataRequest } from './uri-parser';
72
69
  import {
73
70
  type HookReq,
74
71
  type HookArgs,
@@ -76,7 +73,7 @@ import {
76
73
  getHooks,
77
74
  runHooks,
78
75
  type InstantiatedHooks,
79
- } from './hooks.js';
76
+ } from './hooks';
80
77
  export {
81
78
  type HookReq,
82
79
  type HookArgs,
@@ -84,33 +81,30 @@ export {
84
81
  type Hooks,
85
82
  addPureHook,
86
83
  addSideEffectHook,
87
- } from './hooks.js';
84
+ } from './hooks';
88
85
 
89
- import memoizeWeak from 'memoizee/weak.js';
90
- import * as controlFlow from './control-flow.js';
86
+ import memoizeWeak from 'memoizee/weak';
87
+ import * as controlFlow from './control-flow';
91
88
 
92
89
  export let db = undefined as any as Db.Database;
93
90
 
94
91
  export { sbvrTypes };
95
92
 
96
- import LF2AbstractSQLPackage from '@balena/lf-to-abstract-sql/package.json' with { type: 'json' };
97
- const { version: LF2AbstractSQLVersion } = LF2AbstractSQLPackage;
98
- import SbvrTypesPackage from '@balena/sbvr-types/package.json' with { type: 'json' };
99
- const { version: sbvrTypesVersion } = SbvrTypesPackage;
100
-
93
+ import { version as LF2AbstractSQLVersion } from '@balena/lf-to-abstract-sql/package.json';
94
+ import { version as sbvrTypesVersion } from '@balena/sbvr-types/package.json';
101
95
  import {
102
96
  compileRequest,
103
97
  getAndCheckBindValues,
104
98
  isRuleAffected,
105
- } from './abstract-sql.js';
106
- export { resolveOdataBind } from './abstract-sql.js';
107
- import * as odataResponse from './odata-response.js';
108
- import { env } from '../server-glue/module.js';
109
- import { translateAbstractSqlModel } from './translations.js';
99
+ } from './abstract-sql';
100
+ export { resolveOdataBind } from './abstract-sql';
101
+ import * as odataResponse from './odata-response';
102
+ import { env } from '../server-glue/module';
103
+ import { translateAbstractSqlModel } from './translations';
110
104
  import {
111
105
  type MigrationExecutionResult,
112
106
  setExecutedMigrations,
113
- } from '../migrator/utils.js';
107
+ } from '../migrator/utils';
114
108
 
115
109
  const LF2AbstractSQLTranslator = LF2AbstractSQL.createTranslator(sbvrTypes);
116
110
  const LF2AbstractSQLTranslatorVersion = `${LF2AbstractSQLVersion}+${sbvrTypesVersion}`;
@@ -14,7 +14,7 @@ import type {
14
14
  UnknownTypeNodes,
15
15
  NullNode,
16
16
  } from '@balena/abstract-sql-compiler';
17
- import type { Dictionary } from './common-types.js';
17
+ import type { Dictionary } from './common-types';
18
18
 
19
19
  export type AliasValidNodeType =
20
20
  | ReferencedFieldNode
@@ -5,26 +5,26 @@ import type {
5
5
  ODataQuery,
6
6
  SupportedMethod,
7
7
  } from '@balena/odata-parser';
8
- import type { Tx } from '../database-layer/db.js';
9
- import type { InstantiatedHooks } from './hooks.js';
10
- import type { AnyObject } from './common-types.js';
8
+ import type { Tx } from '../database-layer/db';
9
+ import type { InstantiatedHooks } from './hooks';
10
+ import type { AnyObject } from './common-types';
11
11
 
12
- import ODataParser from '@balena/odata-parser';
12
+ import * as ODataParser from '@balena/odata-parser';
13
13
  export const SyntaxError = ODataParser.SyntaxError;
14
14
  import { OData2AbstractSQL } from '@balena/odata-to-abstract-sql';
15
15
  import _ from 'lodash';
16
- import memoizeWeak from 'memoizee/weak.js';
16
+ import memoizeWeak from 'memoizee/weak';
17
17
 
18
- export { BadRequestError, ParsingError, TranslationError } from './errors.js';
18
+ export { BadRequestError, ParsingError, TranslationError } from './errors';
19
19
  import deepFreeze from 'deep-freeze';
20
- import * as env from '../config-loader/env.js';
20
+ import * as env from '../config-loader/env';
21
21
  import {
22
22
  BadRequestError,
23
23
  ParsingError,
24
24
  PermissionError,
25
25
  TranslationError,
26
- } from './errors.js';
27
- import * as sbvrUtils from './sbvr-utils.js';
26
+ } from './errors';
27
+ import * as sbvrUtils from './sbvr-utils';
28
28
 
29
29
  export type OdataBinds = ODataBinds;
30
30
 
@@ -5,4 +5,7 @@ declare namespace NodeJS {
5
5
  export interface Process {
6
6
  browser: boolean;
7
7
  }
8
+ export interface Global {
9
+ nodeRequire: NodeRequire;
10
+ }
8
11
  }
@@ -1,27 +1,27 @@
1
1
  import type * as Express from 'express';
2
2
 
3
- import './sbvr-loader.js';
3
+ import './sbvr-loader';
4
4
 
5
- import * as dbModule from '../database-layer/db.js';
6
- import * as configLoader from '../config-loader/config-loader.js';
7
- import * as migrator from '../migrator/sync.js';
8
- import type * as migratorUtils from '../migrator/utils.js';
9
- import * as tasks from '../tasks/index.js';
5
+ import * as dbModule from '../database-layer/db';
6
+ import * as configLoader from '../config-loader/config-loader';
7
+ import * as migrator from '../migrator/sync';
8
+ import type * as migratorUtils from '../migrator/utils';
9
+ import * as tasks from '../tasks';
10
10
 
11
- import * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
12
- import { PINEJS_ADVISORY_LOCK } from '../config-loader/env.js';
11
+ import * as sbvrUtils from '../sbvr-api/sbvr-utils';
12
+ import { PINEJS_ADVISORY_LOCK } from '../config-loader/env';
13
13
 
14
- export * as dbModule from '../database-layer/db.js';
15
- export { PinejsSessionStore } from '../pinejs-session-store/pinejs-session-store.js';
16
- export { mountLoginRouter } from '../passport-pinejs/mount-login-router.js';
17
- export * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
18
- export * as permissions from '../sbvr-api/permissions.js';
19
- export * as errors from '../sbvr-api/errors.js';
20
- export * as env from '../config-loader/env.js';
21
- export * as types from '../sbvr-api/common-types.js';
22
- export * as hooks from '../sbvr-api/hooks.js';
23
- export * as tasks from '../tasks/index.js';
24
- export * as webResourceHandler from '../webresource-handler/index.js';
14
+ export * as dbModule from '../database-layer/db';
15
+ export { PinejsSessionStore } from '../pinejs-session-store/pinejs-session-store';
16
+ export { mountLoginRouter } from '../passport-pinejs/mount-login-router';
17
+ export * as sbvrUtils from '../sbvr-api/sbvr-utils';
18
+ export * as permissions from '../sbvr-api/permissions';
19
+ export * as errors from '../sbvr-api/errors';
20
+ export * as env from '../config-loader/env';
21
+ export * as types from '../sbvr-api/common-types';
22
+ export * as hooks from '../sbvr-api/hooks';
23
+ export * as tasks from '../tasks';
24
+ export * as webResourceHandler from '../webresource-handler';
25
25
  export type { configLoader as ConfigLoader };
26
26
  export type { migratorUtils as Migrator };
27
27
 
@@ -1,23 +1,35 @@
1
- /**
2
- *
3
- * @param filePath The module to load
4
- * @param parentUrl Use import.meta.url
5
- * @returns
6
- */
7
- export async function loadSBVR(filePath: string, meta: ImportMeta) {
8
- return await (
9
- await import('fs')
10
- ).promises.readFile(new URL(meta.resolve(filePath)), 'utf8');
1
+ import type * as Fs from 'fs';
2
+
3
+ if (!process.browser) {
4
+ if (typeof nodeRequire === 'undefined' || nodeRequire == null) {
5
+ // `nodeRequire` is a special variable we use to bypass webpack's resolving of `require`
6
+ // statements on build for the cases where we need to always use the nodejs require, eg
7
+ // in the config-loader which dynamically loads code at runtime, and for adding custom
8
+ // filetype handlers - it works by being replaced with `require` after the webpack build
9
+ // finishes.
10
+ // In the case of `nodeRequire` being undefined it means we're being run in a nodejs
11
+ // environment directly, without a webpack build, and have to manually create it as an
12
+ // alias for the nodejs require so that things continue to work.
13
+
14
+ // Alias require as nodeRequire for the config-loader hack.
15
+ global.nodeRequire = require;
16
+ }
17
+ // Register a .sbvr loader
18
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
19
+ const fs: typeof Fs = require('fs');
20
+ nodeRequire.extensions['.sbvr'] = (module: NodeModule, filename: string) =>
21
+ (module.exports = fs.readFileSync(filename, 'utf8'));
11
22
  }
12
23
 
13
24
  /**
14
25
  *
15
26
  * @param filePath The module to load
16
- * @param parentUrl Use `import.meta.url`
27
+ * @param parentUrl Use `require`
17
28
  * @returns The sbvr file contents
18
29
  */
19
- export async function importSBVR(filePath: string, meta: ImportMeta) {
20
- return await (
21
- await import('fs')
22
- ).promises.readFile(new URL(meta.resolve(filePath)), 'utf8');
30
+ export function requireSBVR(filePath: string, require: NodeRequire) {
31
+ return (require('fs') as typeof import('fs')).readFileSync(
32
+ require.resolve(filePath),
33
+ 'utf8',
34
+ );
23
35
  }
@@ -1,9 +1,18 @@
1
- import * as Pinejs from './module.js';
2
- export { sbvrUtils, PinejsSessionStore } from './module.js';
1
+ import type BodyParser from 'body-parser';
2
+ import type Compression from 'compression';
3
+ import type CookieParser from 'cookie-parser';
4
+ import type ExpressSession from 'express-session';
5
+ import type MethodOverride from 'method-override';
6
+ import type * as Passport from 'passport';
7
+ import type * as Path from 'path';
8
+ import type ServeStatic from 'serve-static';
3
9
 
4
- export { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser.js';
10
+ import * as Pinejs from './module';
11
+ export { sbvrUtils, PinejsSessionStore } from './module';
5
12
 
6
- import { mountLoginRouter } from '../passport-pinejs/mount-login-router.js';
13
+ export { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser';
14
+
15
+ import { mountLoginRouter } from '../passport-pinejs/mount-login-router';
7
16
 
8
17
  import express from 'express';
9
18
 
@@ -18,18 +27,20 @@ switch (app.get('env')) {
18
27
  }
19
28
 
20
29
  if (!process.browser) {
21
- const { default: passport } = await import('passport');
22
- const { default: path } = await import('path');
23
- const { default: compression } = await import('compression');
24
- const { default: serveStatic } = await import('serve-static');
25
- const { default: cookieParser } = await import('cookie-parser');
26
- const { default: bodyParser } = await import('body-parser');
27
- const { default: methodOverride } = await import('method-override');
28
- const { default: expressSession } = await import('express-session');
30
+ /* eslint-disable @typescript-eslint/no-var-requires */
31
+ const passport: typeof Passport = require('passport');
32
+ const path: typeof Path = require('path');
33
+ const compression: typeof Compression = require('compression');
34
+ const serveStatic: typeof ServeStatic = require('serve-static');
35
+ const cookieParser: typeof CookieParser = require('cookie-parser');
36
+ const bodyParser: typeof BodyParser = require('body-parser');
37
+ const methodOverride: typeof MethodOverride = require('method-override');
38
+ const expressSession: typeof ExpressSession = require('express-session');
39
+ /* eslint-enable @typescript-eslint/no-var-requires */
29
40
 
30
41
  app.use(compression());
31
42
 
32
- const root = process.argv[2] || import.meta.dirname;
43
+ const root = process.argv[2] || __dirname;
33
44
  app.use('/', serveStatic(path.join(root, 'static')));
34
45
 
35
46
  app.use(cookieParser());
@@ -3,4 +3,4 @@ import Ajv from 'ajv';
3
3
  // Root path for the tasks API
4
4
  export const apiRoot = 'tasks';
5
5
 
6
- export const ajv = new Ajv.default();
6
+ export const ajv = new Ajv();
@@ -1,20 +1,20 @@
1
1
  import type { Schema } from 'ajv';
2
- import cronParser from 'cron-parser';
3
- import { tasks as tasksEnv } from '../config-loader/env.js';
4
- import { addPureHook } from '../sbvr-api/hooks.js';
5
- import * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
6
- import type { ConfigLoader } from '../server-glue/module.js';
7
- import { ajv, apiRoot } from './common.js';
8
- import type { TaskHandler } from './worker.js';
9
- import { Worker } from './worker.js';
10
- import type TasksModel from './tasks.js';
11
- import type { Task } from './tasks.js';
2
+ import * as cronParser from 'cron-parser';
3
+ import { tasks as tasksEnv } from '../config-loader/env';
4
+ import { addPureHook } from '../sbvr-api/hooks';
5
+ import * as sbvrUtils from '../sbvr-api/sbvr-utils';
6
+ import type { ConfigLoader } from '../server-glue/module';
7
+ import { ajv, apiRoot } from './common';
8
+ import type { TaskHandler } from './worker';
9
+ import { Worker } from './worker';
10
+ import type TasksModel from './tasks';
11
+ import type { Task } from './tasks';
12
12
  import type { FromSchema } from 'json-schema-to-ts';
13
- import { importSBVR } from '../server-glue/sbvr-loader.js';
13
+ import { requireSBVR } from '../server-glue/sbvr-loader';
14
14
 
15
- export type * from './tasks.js';
15
+ export type * from './tasks';
16
16
 
17
- const modelText = await importSBVR('./tasks.sbvr', import.meta);
17
+ const modelText = requireSBVR('./tasks.sbvr', require);
18
18
 
19
19
  // Create index for polling tasks table
20
20
  const initSql = `
@@ -25,7 +25,7 @@ CREATE INDEX IF NOT EXISTS idx_task_poll ON task USING btree (
25
25
  ) WHERE status = 'queued';
26
26
  `;
27
27
 
28
- declare module '../sbvr-api/sbvr-utils.js' {
28
+ declare module '../sbvr-api/sbvr-utils' {
29
29
  export interface API {
30
30
  [apiRoot]: PinejsClient<TasksModel>;
31
31
  }
@@ -1,14 +1,14 @@
1
1
  import type { ValidateFunction } from 'ajv';
2
2
  import { setTimeout } from 'node:timers/promises';
3
3
  import type { AnyObject } from 'pinejs-client-core';
4
- import { tasks as tasksEnv } from '../config-loader/env.js';
5
- import type * as Db from '../database-layer/db.js';
6
- import * as permissions from '../sbvr-api/permissions.js';
7
- import { PinejsClient } from '../sbvr-api/sbvr-utils.js';
8
- import { sbvrUtils } from '../server-glue/module.js';
9
- import { ajv } from './common.js';
10
- import type { Task } from './tasks.js';
11
- import type TasksModel from './tasks.js';
4
+ import { tasks as tasksEnv } from '../config-loader/env';
5
+ import type * as Db from '../database-layer/db';
6
+ import * as permissions from '../sbvr-api/permissions';
7
+ import { PinejsClient } from '../sbvr-api/sbvr-utils';
8
+ import { sbvrUtils } from '../server-glue/module';
9
+ import { ajv } from './common';
10
+ import type { Task } from './tasks';
11
+ import type TasksModel from './tasks';
12
12
 
13
13
  interface TaskArgs<T = AnyObject> {
14
14
  api: PinejsClient;
@@ -1,9 +1,5 @@
1
1
  import type { WebResourceType as WebResource } from '@balena/sbvr-types';
2
- import type {
3
- IncomingFile,
4
- UploadResponse,
5
- WebResourceHandler,
6
- } from '../index.js';
2
+ import type { IncomingFile, UploadResponse, WebResourceHandler } from '..';
7
3
 
8
4
  export class NoopHandler implements WebResourceHandler {
9
5
  public async handleFile(resource: IncomingFile): Promise<UploadResponse> {
@@ -5,7 +5,7 @@ import {
5
5
  type UploadResponse,
6
6
  WebResourceError,
7
7
  type WebResourceHandler,
8
- } from '../index.js';
8
+ } from '..';
9
9
  import {
10
10
  S3Client,
11
11
  type S3ClientConfig,
@@ -1,2 +1,2 @@
1
- export * from './NoopHandler.js';
2
- export * from './S3Handler.js';
1
+ export * from './NoopHandler';
2
+ export * from './S3Handler';