@balena/pinejs 19.7.1 → 19.7.2-build-esm-ce2a147ed7533c40f456b27f17ac4e559a0f9da8-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.
- package/.pinejs-cache.json +1 -1
- package/.versionbot/CHANGELOG.yml +21 -1
- package/CHANGELOG.md +5 -0
- package/{Gruntfile.ts → Gruntfile.cts} +9 -22
- package/VERSION +1 -1
- package/bin/abstract-sql-compiler.js +1 -1
- package/bin/odata-compiler.js +1 -1
- package/bin/sbvr-compiler.js +1 -1
- package/build/{browser.ts → browser.cts} +1 -1
- package/build/{config.ts → config.cts} +5 -1
- package/build/{module.ts → module.cts} +1 -1
- package/build/{server.ts → server.cts} +1 -1
- package/out/bin/abstract-sql-compiler.js +17 -19
- package/out/bin/abstract-sql-compiler.js.map +1 -1
- package/out/bin/odata-compiler.js +19 -21
- package/out/bin/odata-compiler.js.map +1 -1
- package/out/bin/sbvr-compiler.js +19 -54
- package/out/bin/sbvr-compiler.js.map +1 -1
- package/out/bin/utils.d.ts +3 -3
- package/out/bin/utils.js +16 -53
- package/out/bin/utils.js.map +1 -1
- package/out/config-loader/config-loader.d.ts +6 -6
- package/out/config-loader/config-loader.js +23 -63
- package/out/config-loader/config-loader.js.map +1 -1
- package/out/config-loader/env.d.ts +1 -1
- package/out/config-loader/env.js +24 -66
- package/out/config-loader/env.js.map +1 -1
- package/out/data-server/sbvr-server.d.ts +3 -3
- package/out/data-server/sbvr-server.js +5 -42
- package/out/data-server/sbvr-server.js.map +1 -1
- package/out/database-layer/db.d.ts +3 -3
- package/out/database-layer/db.js +37 -83
- package/out/database-layer/db.js.map +1 -1
- package/out/express-emulator/express.js.map +1 -1
- package/out/extended-sbvr-parser/extended-sbvr-parser.js +8 -11
- package/out/extended-sbvr-parser/extended-sbvr-parser.js.map +1 -1
- package/out/http-transactions/transactions.d.ts +2 -2
- package/out/http-transactions/transactions.js +4 -4
- package/out/http-transactions/transactions.js.map +1 -1
- package/out/migrator/async.d.ts +2 -2
- package/out/migrator/async.js +20 -60
- package/out/migrator/async.js.map +1 -1
- package/out/migrator/migrations.js +1 -2
- package/out/migrator/sync.d.ts +6 -6
- package/out/migrator/sync.js +20 -61
- package/out/migrator/sync.js.map +1 -1
- package/out/migrator/utils.d.ts +4 -4
- package/out/migrator/utils.js +42 -97
- package/out/migrator/utils.js.map +1 -1
- package/out/odata-metadata/odata-metadata-generator.js +7 -14
- package/out/odata-metadata/odata-metadata-generator.js.map +1 -1
- package/out/passport-pinejs/mount-login-router.d.ts +1 -1
- package/out/passport-pinejs/mount-login-router.js +4 -41
- package/out/passport-pinejs/mount-login-router.js.map +1 -1
- package/out/passport-pinejs/passport-pinejs.d.ts +1 -1
- package/out/passport-pinejs/passport-pinejs.js +11 -46
- package/out/passport-pinejs/passport-pinejs.js.map +1 -1
- package/out/pinejs-session-store/pinejs-session-store.d.ts +1 -1
- package/out/pinejs-session-store/pinejs-session-store.js +11 -48
- package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
- package/out/sbvr-api/abstract-sql.d.ts +2 -2
- package/out/sbvr-api/abstract-sql.js +22 -65
- package/out/sbvr-api/abstract-sql.js.map +1 -1
- package/out/sbvr-api/cached-compile.js +8 -15
- package/out/sbvr-api/cached-compile.js.map +1 -1
- package/out/sbvr-api/common-types.js +1 -2
- package/out/sbvr-api/control-flow.d.ts +1 -1
- package/out/sbvr-api/control-flow.js +12 -25
- package/out/sbvr-api/control-flow.js.map +1 -1
- package/out/sbvr-api/dev.js +1 -2
- package/out/sbvr-api/errors.d.ts +1 -1
- package/out/sbvr-api/errors.js +47 -95
- package/out/sbvr-api/errors.js.map +1 -1
- package/out/sbvr-api/express-extension.d.ts +2 -2
- package/out/sbvr-api/express-extension.js +1 -2
- package/out/sbvr-api/hooks.d.ts +4 -4
- package/out/sbvr-api/hooks.js +23 -35
- package/out/sbvr-api/hooks.js.map +1 -1
- package/out/sbvr-api/odata-response.d.ts +2 -2
- package/out/sbvr-api/odata-response.js +19 -29
- package/out/sbvr-api/odata-response.js.map +1 -1
- package/out/sbvr-api/permissions.d.ts +8 -8
- package/out/sbvr-api/permissions.js +106 -159
- package/out/sbvr-api/permissions.js.map +1 -1
- package/out/sbvr-api/sbvr-utils.d.ts +38 -16
- package/out/sbvr-api/sbvr-utils.js +222 -285
- package/out/sbvr-api/sbvr-utils.js.map +1 -1
- package/out/sbvr-api/translations.d.ts +1 -1
- package/out/sbvr-api/translations.js +10 -17
- package/out/sbvr-api/translations.js.map +1 -1
- package/out/sbvr-api/uri-parser.d.ts +6 -6
- package/out/sbvr-api/uri-parser.js +39 -84
- package/out/sbvr-api/uri-parser.js.map +1 -1
- package/out/sbvr-api/user.js +1 -2
- package/out/server-glue/global-ext.d.ts +0 -3
- package/out/server-glue/module.d.ts +15 -15
- package/out/server-glue/module.js +20 -59
- package/out/server-glue/module.js.map +1 -1
- package/out/server-glue/sbvr-loader.d.ts +2 -1
- package/out/server-glue/sbvr-loader.js +4 -11
- package/out/server-glue/sbvr-loader.js.map +1 -1
- package/out/server-glue/server.d.ts +2 -2
- package/out/server-glue/server.js +17 -59
- package/out/server-glue/server.js.map +1 -1
- package/out/tasks/common.d.ts +1 -1
- package/out/tasks/common.js +3 -9
- package/out/tasks/common.js.map +1 -1
- package/out/tasks/index.d.ts +8 -8
- package/out/tasks/index.js +25 -63
- package/out/tasks/index.js.map +1 -1
- package/out/tasks/tasks.js +1 -2
- package/out/tasks/worker.d.ts +3 -3
- package/out/tasks/worker.js +14 -51
- package/out/tasks/worker.js.map +1 -1
- package/out/webresource-handler/handlers/NoopHandler.d.ts +1 -1
- package/out/webresource-handler/handlers/NoopHandler.js +1 -5
- package/out/webresource-handler/handlers/NoopHandler.js.map +1 -1
- package/out/webresource-handler/handlers/S3Handler.d.ts +1 -1
- package/out/webresource-handler/handlers/S3Handler.js +17 -24
- package/out/webresource-handler/handlers/S3Handler.js.map +1 -1
- package/out/webresource-handler/handlers/index.d.ts +2 -2
- package/out/webresource-handler/handlers/index.js +2 -18
- package/out/webresource-handler/handlers/index.js.map +1 -1
- package/out/webresource-handler/index.d.ts +1 -1
- package/out/webresource-handler/index.js +35 -85
- package/out/webresource-handler/index.js.map +1 -1
- package/package.json +10 -10
- package/src/bin/abstract-sql-compiler.ts +3 -3
- package/src/bin/odata-compiler.ts +3 -3
- package/src/bin/sbvr-compiler.ts +2 -2
- package/src/bin/utils.ts +20 -15
- package/src/config-loader/config-loader.ts +11 -11
- package/src/config-loader/env.ts +3 -3
- package/src/data-server/sbvr-server.ts +4 -4
- package/src/database-layer/db.ts +18 -11
- package/src/extended-sbvr-parser/extended-sbvr-parser.ts +5 -5
- package/src/http-transactions/transactions.js +4 -4
- package/src/migrator/async.ts +5 -5
- package/src/migrator/sync.ts +8 -8
- package/src/migrator/utils.ts +7 -7
- package/src/odata-metadata/odata-metadata-generator.ts +3 -2
- package/src/passport-pinejs/mount-login-router.ts +3 -3
- package/src/passport-pinejs/passport-pinejs.ts +3 -3
- package/src/pinejs-session-store/pinejs-session-store.ts +4 -4
- package/src/sbvr-api/abstract-sql.ts +5 -5
- package/src/sbvr-api/cached-compile.ts +1 -1
- package/src/sbvr-api/control-flow.ts +1 -1
- package/src/sbvr-api/errors.ts +1 -1
- package/src/sbvr-api/express-extension.ts +2 -2
- package/src/sbvr-api/hooks.ts +5 -5
- package/src/sbvr-api/odata-response.ts +8 -4
- package/src/sbvr-api/permissions.ts +17 -17
- package/src/sbvr-api/sbvr-utils.ts +37 -31
- package/src/sbvr-api/translations.ts +1 -1
- package/src/sbvr-api/uri-parser.ts +9 -9
- package/src/server-glue/global-ext.d.ts +0 -3
- package/src/server-glue/module.ts +19 -19
- package/src/server-glue/sbvr-loader.ts +15 -27
- package/src/server-glue/server.ts +13 -24
- package/src/tasks/common.ts +1 -1
- package/src/tasks/index.ts +14 -14
- package/src/tasks/worker.ts +8 -8
- package/src/webresource-handler/handlers/NoopHandler.ts +5 -1
- package/src/webresource-handler/handlers/S3Handler.ts +1 -1
- package/src/webresource-handler/handlers/index.ts +2 -2
- package/src/webresource-handler/index.ts +8 -8
- package/tsconfig.dev.json +4 -2
- package/tsconfig.json +1 -1
- package/typings/lf-to-abstract-sql.d.ts +2 -2
- package/typings/memoizee.d.ts +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import type AuthModel from './user';
|
1
|
+
import type AuthModel from './user.js';
|
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';
|
17
|
+
import './express-extension.js';
|
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';
|
25
|
-
import type { ApiKey, User } from '../sbvr-api/sbvr-utils';
|
26
|
-
import type { AnyObject, Dictionary } from './common-types';
|
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';
|
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
|
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';
|
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';
|
43
43
|
import {
|
44
44
|
BadRequestError,
|
45
45
|
PermissionError,
|
46
46
|
PermissionParsingError,
|
47
|
-
} from './errors';
|
47
|
+
} from './errors.js';
|
48
48
|
import {
|
49
49
|
memoizedGetOData2AbstractSQL,
|
50
50
|
memoizedParseOdata,
|
51
51
|
metadataEndpoints,
|
52
52
|
type ODataRequest,
|
53
|
-
} from './uri-parser';
|
54
|
-
import memoizeWeak from 'memoizee/weak';
|
55
|
-
import type { Config } from '../config-loader/config-loader';
|
53
|
+
} from './uri-parser.js';
|
54
|
+
import memoizeWeak from 'memoizee/weak.js';
|
55
|
+
import type { Config } from '../config-loader/config-loader.js';
|
56
56
|
import type { ODataOptions } from 'pinejs-client-core';
|
57
|
-
import type { Permission } from './user';
|
58
|
-
import {
|
57
|
+
import type { Permission } from './user.js';
|
58
|
+
import { importSBVR } from '../server-glue/sbvr-loader.js';
|
59
59
|
|
60
|
-
const userModel =
|
60
|
+
const userModel = await importSBVR('./user.sbvr', import.meta);
|
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' {
|
1782
|
+
declare module './sbvr-utils.js' {
|
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';
|
3
|
-
import type { Model } from '../config-loader/config-loader';
|
4
|
-
import type { AnyObject, RequiredField } from './common-types';
|
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';
|
5
5
|
import type {
|
6
6
|
PickDeferred,
|
7
7
|
Resource,
|
@@ -21,12 +21,14 @@ declare global {
|
|
21
21
|
import _ from 'lodash';
|
22
22
|
|
23
23
|
import type { TypedError } from 'typed-error';
|
24
|
-
import { cachedCompile } from './cached-compile';
|
24
|
+
import { cachedCompile } from './cached-compile.js';
|
25
25
|
|
26
26
|
type LFModel = any[];
|
27
27
|
import * as AbstractSQLCompiler from '@balena/abstract-sql-compiler';
|
28
|
-
import
|
29
|
-
|
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';
|
30
32
|
|
31
33
|
import {
|
32
34
|
type ODataBinds,
|
@@ -34,21 +36,22 @@ import {
|
|
34
36
|
sqlNameToODataName,
|
35
37
|
type SupportedMethod,
|
36
38
|
} from '@balena/odata-to-abstract-sql';
|
37
|
-
import sbvrTypes from '@balena/sbvr-types';
|
38
|
-
|
39
|
+
import $sbvrTypes from '@balena/sbvr-types';
|
40
|
+
const { default: sbvrTypes } = $sbvrTypes;
|
41
|
+
import deepFreeze from 'deep-freeze';
|
39
42
|
import type { ODataOptions, Params } from 'pinejs-client-core';
|
40
43
|
import { PinejsClientCore, type PromiseResultTypes } from 'pinejs-client-core';
|
41
44
|
|
42
|
-
import { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser';
|
45
|
+
import { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser.js';
|
43
46
|
|
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 {
|
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';
|
48
51
|
|
49
|
-
import type DevModel from './dev';
|
50
|
-
const devModel =
|
51
|
-
import * as permissions from './permissions';
|
52
|
+
import type DevModel from './dev.js';
|
53
|
+
const devModel = await importSBVR('./dev.sbvr', import.meta);
|
54
|
+
import * as permissions from './permissions.js';
|
52
55
|
import {
|
53
56
|
BadRequestError,
|
54
57
|
ConflictError,
|
@@ -63,9 +66,9 @@ import {
|
|
63
66
|
statusCodeToError,
|
64
67
|
TranslationError,
|
65
68
|
UnauthorizedError,
|
66
|
-
} from './errors';
|
67
|
-
import * as uriParser from './uri-parser';
|
68
|
-
export type { ODataRequest } from './uri-parser';
|
69
|
+
} from './errors.js';
|
70
|
+
import * as uriParser from './uri-parser.js';
|
71
|
+
export type { ODataRequest } from './uri-parser.js';
|
69
72
|
import {
|
70
73
|
type HookReq,
|
71
74
|
type HookArgs,
|
@@ -73,7 +76,7 @@ import {
|
|
73
76
|
getHooks,
|
74
77
|
runHooks,
|
75
78
|
type InstantiatedHooks,
|
76
|
-
} from './hooks';
|
79
|
+
} from './hooks.js';
|
77
80
|
export {
|
78
81
|
type HookReq,
|
79
82
|
type HookArgs,
|
@@ -81,30 +84,33 @@ export {
|
|
81
84
|
type Hooks,
|
82
85
|
addPureHook,
|
83
86
|
addSideEffectHook,
|
84
|
-
} from './hooks';
|
87
|
+
} from './hooks.js';
|
85
88
|
|
86
|
-
import memoizeWeak from 'memoizee/weak';
|
87
|
-
import * as controlFlow from './control-flow';
|
89
|
+
import memoizeWeak from 'memoizee/weak.js';
|
90
|
+
import * as controlFlow from './control-flow.js';
|
88
91
|
|
89
92
|
export let db = undefined as any as Db.Database;
|
90
93
|
|
91
94
|
export { sbvrTypes };
|
92
95
|
|
93
|
-
import
|
94
|
-
|
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
|
+
|
95
101
|
import {
|
96
102
|
compileRequest,
|
97
103
|
getAndCheckBindValues,
|
98
104
|
isRuleAffected,
|
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';
|
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';
|
104
110
|
import {
|
105
111
|
type MigrationExecutionResult,
|
106
112
|
setExecutedMigrations,
|
107
|
-
} from '../migrator/utils';
|
113
|
+
} from '../migrator/utils.js';
|
108
114
|
|
109
115
|
const LF2AbstractSQLTranslator = LF2AbstractSQL.createTranslator(sbvrTypes);
|
110
116
|
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';
|
17
|
+
import type { Dictionary } from './common-types.js';
|
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';
|
9
|
-
import type { InstantiatedHooks } from './hooks';
|
10
|
-
import type { AnyObject } from './common-types';
|
8
|
+
import type { Tx } from '../database-layer/db.js';
|
9
|
+
import type { InstantiatedHooks } from './hooks.js';
|
10
|
+
import type { AnyObject } from './common-types.js';
|
11
11
|
|
12
|
-
import
|
12
|
+
import 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';
|
16
|
+
import memoizeWeak from 'memoizee/weak.js';
|
17
17
|
|
18
|
-
export { BadRequestError, ParsingError, TranslationError } from './errors';
|
18
|
+
export { BadRequestError, ParsingError, TranslationError } from './errors.js';
|
19
19
|
import deepFreeze from 'deep-freeze';
|
20
|
-
import * as env from '../config-loader/env';
|
20
|
+
import * as env from '../config-loader/env.js';
|
21
21
|
import {
|
22
22
|
BadRequestError,
|
23
23
|
ParsingError,
|
24
24
|
PermissionError,
|
25
25
|
TranslationError,
|
26
|
-
} from './errors';
|
27
|
-
import * as sbvrUtils from './sbvr-utils';
|
26
|
+
} from './errors.js';
|
27
|
+
import * as sbvrUtils from './sbvr-utils.js';
|
28
28
|
|
29
29
|
export type OdataBinds = ODataBinds;
|
30
30
|
|
@@ -1,27 +1,27 @@
|
|
1
1
|
import type * as Express from 'express';
|
2
2
|
|
3
|
-
import './sbvr-loader';
|
3
|
+
import './sbvr-loader.js';
|
4
4
|
|
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';
|
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';
|
10
10
|
|
11
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
|
12
|
-
import { PINEJS_ADVISORY_LOCK } from '../config-loader/env';
|
11
|
+
import * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
|
12
|
+
import { PINEJS_ADVISORY_LOCK } from '../config-loader/env.js';
|
13
13
|
|
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';
|
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';
|
25
25
|
export type { configLoader as ConfigLoader };
|
26
26
|
export type { migratorUtils as Migrator };
|
27
27
|
|
@@ -1,35 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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'));
|
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');
|
22
11
|
}
|
23
12
|
|
24
13
|
/**
|
25
14
|
*
|
26
15
|
* @param filePath The module to load
|
27
|
-
* @param parentUrl Use `
|
16
|
+
* @param parentUrl Use `import.meta.url`
|
28
17
|
* @returns The sbvr file contents
|
29
18
|
*/
|
30
|
-
export function
|
31
|
-
return
|
32
|
-
|
33
|
-
|
34
|
-
);
|
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');
|
35
23
|
}
|
@@ -1,18 +1,9 @@
|
|
1
|
-
import
|
2
|
-
|
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';
|
1
|
+
import * as Pinejs from './module.js';
|
2
|
+
export { sbvrUtils, PinejsSessionStore } from './module.js';
|
9
3
|
|
10
|
-
|
11
|
-
export { sbvrUtils, PinejsSessionStore } from './module';
|
4
|
+
export { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser.js';
|
12
5
|
|
13
|
-
|
14
|
-
|
15
|
-
import { mountLoginRouter } from '../passport-pinejs/mount-login-router';
|
6
|
+
import { mountLoginRouter } from '../passport-pinejs/mount-login-router.js';
|
16
7
|
|
17
8
|
import express from 'express';
|
18
9
|
|
@@ -27,20 +18,18 @@ switch (app.get('env')) {
|
|
27
18
|
}
|
28
19
|
|
29
20
|
if (!process.browser) {
|
30
|
-
|
31
|
-
const
|
32
|
-
const
|
33
|
-
const
|
34
|
-
const
|
35
|
-
const
|
36
|
-
const
|
37
|
-
const
|
38
|
-
const expressSession: typeof ExpressSession = require('express-session');
|
39
|
-
/* eslint-enable @typescript-eslint/no-var-requires */
|
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');
|
40
29
|
|
41
30
|
app.use(compression());
|
42
31
|
|
43
|
-
const root = process.argv[2] ||
|
32
|
+
const root = process.argv[2] || import.meta.dirname;
|
44
33
|
app.use('/', serveStatic(path.join(root, 'static')));
|
45
34
|
|
46
35
|
app.use(cookieParser());
|
package/src/tasks/common.ts
CHANGED
package/src/tasks/index.ts
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
import type { Schema } from 'ajv';
|
2
|
-
import
|
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';
|
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';
|
12
12
|
import type { FromSchema } from 'json-schema-to-ts';
|
13
|
-
import {
|
13
|
+
import { importSBVR } from '../server-glue/sbvr-loader.js';
|
14
14
|
|
15
|
-
export type * from './tasks';
|
15
|
+
export type * from './tasks.js';
|
16
16
|
|
17
|
-
const modelText =
|
17
|
+
const modelText = await importSBVR('./tasks.sbvr', import.meta);
|
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' {
|
28
|
+
declare module '../sbvr-api/sbvr-utils.js' {
|
29
29
|
export interface API {
|
30
30
|
[apiRoot]: PinejsClient<TasksModel>;
|
31
31
|
}
|
package/src/tasks/worker.ts
CHANGED
@@ -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';
|
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';
|
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';
|
12
12
|
|
13
13
|
interface TaskArgs<T = AnyObject> {
|
14
14
|
api: PinejsClient;
|
@@ -1,5 +1,9 @@
|
|
1
1
|
import type { WebResourceType as WebResource } from '@balena/sbvr-types';
|
2
|
-
import type {
|
2
|
+
import type {
|
3
|
+
IncomingFile,
|
4
|
+
UploadResponse,
|
5
|
+
WebResourceHandler,
|
6
|
+
} from '../index.js';
|
3
7
|
|
4
8
|
export class NoopHandler implements WebResourceHandler {
|
5
9
|
public async handleFile(resource: IncomingFile): Promise<UploadResponse> {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from './NoopHandler';
|
2
|
-
export * from './S3Handler';
|
1
|
+
export * from './NoopHandler.js';
|
2
|
+
export * from './S3Handler.js';
|
@@ -1,21 +1,21 @@
|
|
1
1
|
import type * as Express from 'express';
|
2
2
|
import busboy from 'busboy';
|
3
3
|
import type * as stream from 'node:stream';
|
4
|
-
import * as uriParser from '../sbvr-api/uri-parser';
|
5
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
|
6
|
-
import type { HookArgs } from '../sbvr-api/hooks';
|
7
|
-
import { getApiRoot, getModel } from '../sbvr-api/sbvr-utils';
|
8
|
-
import { checkPermissions } from '../sbvr-api/permissions';
|
9
|
-
import { NoopHandler } from './handlers/NoopHandler';
|
4
|
+
import * as uriParser from '../sbvr-api/uri-parser.js';
|
5
|
+
import * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
|
6
|
+
import type { HookArgs } from '../sbvr-api/hooks.js';
|
7
|
+
import { getApiRoot, getModel } from '../sbvr-api/sbvr-utils.js';
|
8
|
+
import { checkPermissions } from '../sbvr-api/permissions.js';
|
9
|
+
import { NoopHandler } from './handlers/NoopHandler.js';
|
10
10
|
import {
|
11
11
|
odataNameToSqlName,
|
12
12
|
sqlNameToODataName,
|
13
13
|
} from '@balena/odata-to-abstract-sql';
|
14
|
-
import { errors, permissions } from '../server-glue/module';
|
14
|
+
import { errors, permissions } from '../server-glue/module.js';
|
15
15
|
import type { WebResourceType as WebResource } from '@balena/sbvr-types';
|
16
16
|
import { TypedError } from 'typed-error';
|
17
17
|
|
18
|
-
export * from './handlers';
|
18
|
+
export * from './handlers/index.js';
|
19
19
|
|
20
20
|
export interface IncomingFile {
|
21
21
|
fieldname: string;
|
package/tsconfig.dev.json
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"extends": "./tsconfig.json",
|
3
3
|
"compilerOptions": {
|
4
|
-
"rootDir": "."
|
4
|
+
"rootDir": ".",
|
5
|
+
"allowImportingTsExtensions": true
|
5
6
|
},
|
6
7
|
"include": [
|
7
8
|
"build/**/*",
|
9
|
+
"bin/**/*",
|
8
10
|
"src/**/*",
|
9
11
|
"test/**/*",
|
10
12
|
"typings/**/*.d.ts",
|
11
|
-
"Gruntfile.
|
13
|
+
"Gruntfile.cts"
|
12
14
|
]
|
13
15
|
}
|
package/tsconfig.json
CHANGED
@@ -5,7 +5,7 @@ declare module '@balena/lf-to-abstract-sql' {
|
|
5
5
|
export const LF2AbstractSQL: {
|
6
6
|
createInstance: () => {
|
7
7
|
match: (lfModel: LFModel, rule: 'Process') => AbstractSqlModel;
|
8
|
-
addTypes: (types: typeof sbvrTypes) => void;
|
8
|
+
addTypes: (types: typeof sbvrTypes.default) => void;
|
9
9
|
reset: () => void;
|
10
10
|
};
|
11
11
|
};
|
@@ -14,6 +14,6 @@ declare module '@balena/lf-to-abstract-sql' {
|
|
14
14
|
_extend(obj: object): typeof LF2AbstractSQLPrep;
|
15
15
|
};
|
16
16
|
export const createTranslator: (
|
17
|
-
types: typeof sbvrTypes,
|
17
|
+
types: typeof sbvrTypes.default,
|
18
18
|
) => (lfModel: LFModel, rule: 'Process') => AbstractSqlModel;
|
19
19
|
}
|
package/typings/memoizee.d.ts
CHANGED