@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.
- package/.versionbot/CHANGELOG.yml +3 -3
- package/CHANGELOG.md +1 -1
- package/{Gruntfile.cts → Gruntfile.ts} +22 -9
- 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.cts → browser.ts} +1 -1
- package/build/{config.cts → config.ts} +1 -5
- package/build/{module.cts → module.ts} +1 -1
- package/build/{server.cts → server.ts} +1 -1
- package/out/bin/abstract-sql-compiler.js +19 -17
- package/out/bin/abstract-sql-compiler.js.map +1 -1
- package/out/bin/odata-compiler.js +21 -19
- package/out/bin/odata-compiler.js.map +1 -1
- package/out/bin/sbvr-compiler.js +54 -19
- package/out/bin/sbvr-compiler.js.map +1 -1
- package/out/bin/utils.d.ts +3 -3
- package/out/bin/utils.js +53 -21
- 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 +63 -23
- 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 +66 -24
- 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 +42 -5
- 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 +83 -37
- 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 +11 -8
- 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 +60 -20
- package/out/migrator/async.js.map +1 -1
- package/out/migrator/migrations.js +2 -1
- package/out/migrator/sync.d.ts +6 -6
- package/out/migrator/sync.js +61 -20
- package/out/migrator/sync.js.map +1 -1
- package/out/migrator/utils.d.ts +4 -4
- package/out/migrator/utils.js +97 -42
- package/out/migrator/utils.js.map +1 -1
- package/out/odata-metadata/odata-metadata-generator.js +14 -7
- 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 +41 -4
- 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 +46 -11
- 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 +48 -11
- 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 +65 -22
- package/out/sbvr-api/abstract-sql.js.map +1 -1
- package/out/sbvr-api/cached-compile.js +15 -8
- package/out/sbvr-api/cached-compile.js.map +1 -1
- package/out/sbvr-api/common-types.js +2 -1
- package/out/sbvr-api/control-flow.d.ts +1 -1
- package/out/sbvr-api/control-flow.js +25 -12
- package/out/sbvr-api/control-flow.js.map +1 -1
- package/out/sbvr-api/dev.js +2 -1
- package/out/sbvr-api/errors.d.ts +1 -1
- package/out/sbvr-api/errors.js +95 -47
- 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 +2 -1
- package/out/sbvr-api/hooks.d.ts +4 -4
- package/out/sbvr-api/hooks.js +35 -23
- 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 +29 -19
- 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 +159 -106
- package/out/sbvr-api/permissions.js.map +1 -1
- package/out/sbvr-api/sbvr-utils.d.ts +16 -38
- package/out/sbvr-api/sbvr-utils.js +285 -222
- 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 +17 -10
- 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 +84 -39
- package/out/sbvr-api/uri-parser.js.map +1 -1
- package/out/sbvr-api/user.js +2 -1
- package/out/server-glue/global-ext.d.ts +3 -0
- package/out/server-glue/module.d.ts +15 -15
- package/out/server-glue/module.js +59 -20
- package/out/server-glue/module.js.map +1 -1
- package/out/server-glue/sbvr-loader.d.ts +1 -2
- package/out/server-glue/sbvr-loader.js +11 -4
- 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 +59 -17
- package/out/server-glue/server.js.map +1 -1
- package/out/tasks/common.d.ts +1 -1
- package/out/tasks/common.js +9 -3
- package/out/tasks/common.js.map +1 -1
- package/out/tasks/index.d.ts +8 -8
- package/out/tasks/index.js +63 -25
- package/out/tasks/index.js.map +1 -1
- package/out/tasks/tasks.js +2 -1
- package/out/tasks/worker.d.ts +3 -3
- package/out/tasks/worker.js +51 -14
- 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 +5 -1
- 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 +24 -17
- 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 +18 -2
- 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 +85 -35
- package/out/webresource-handler/index.js.map +1 -1
- package/package.json +33 -33
- 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 +15 -23
- 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 +11 -18
- 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 +2 -3
- 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 +4 -8
- package/src/sbvr-api/permissions.ts +17 -17
- package/src/sbvr-api/sbvr-utils.ts +31 -37
- 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 +3 -0
- package/src/server-glue/module.ts +19 -19
- package/src/server-glue/sbvr-loader.ts +27 -15
- package/src/server-glue/server.ts +24 -13
- 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 +1 -5
- 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 +2 -4
- package/tsconfig.json +1 -1
- package/typings/lf-to-abstract-sql.d.ts +2 -2
- 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
|
10
|
+
import deepFreeze = require('deep-freeze');
|
11
11
|
import memoize from 'memoizee';
|
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
|
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) =>
|
package/src/sbvr-api/errors.ts
CHANGED
@@ -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
|
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
|
14
|
+
apiKey?: import('./sbvr-utils').ApiKey;
|
15
15
|
}
|
16
16
|
}
|
17
17
|
}
|
package/src/sbvr-api/hooks.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
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
|
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
|
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
|
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
|
21
|
+
import type { Result, Row } from '../database-layer/db';
|
22
22
|
|
23
23
|
import { sqlNameToODataName } from '@balena/odata-to-abstract-sql';
|
24
|
-
import
|
24
|
+
import sbvrTypes, { type SbvrType } from '@balena/sbvr-types';
|
25
25
|
import _ from 'lodash';
|
26
|
-
import {
|
27
|
-
|
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
|
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
|
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
|
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';
|
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
|
41
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils
|
42
|
-
import { type HookReq, addPureHook, addHook } from './hooks
|
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
|
47
|
+
} from './errors';
|
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';
|
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
|
58
|
-
import {
|
57
|
+
import type { Permission } from './user';
|
58
|
+
import { requireSBVR } from '../server-glue/sbvr-loader';
|
59
59
|
|
60
|
-
const userModel =
|
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
|
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
|
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';
|
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
|
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
|
29
|
-
|
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
|
40
|
-
|
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
|
42
|
+
import { ExtendedSBVRParser } from '../extended-sbvr-parser/extended-sbvr-parser';
|
46
43
|
|
47
|
-
import * as asyncMigrator from '../migrator/async
|
48
|
-
import * as syncMigrator from '../migrator/sync
|
49
|
-
import { generateODataMetadata } from '../odata-metadata/odata-metadata-generator
|
50
|
-
import {
|
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
|
53
|
-
const devModel =
|
54
|
-
import * as permissions from './permissions
|
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
|
70
|
-
import * as uriParser from './uri-parser
|
71
|
-
export type { ODataRequest } from './uri-parser
|
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
|
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
|
84
|
+
} from './hooks';
|
88
85
|
|
89
|
-
import memoizeWeak from 'memoizee/weak
|
90
|
-
import * as controlFlow from './control-flow
|
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
|
97
|
-
|
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
|
106
|
-
export { resolveOdataBind } from './abstract-sql
|
107
|
-
import * as odataResponse from './odata-response
|
108
|
-
import { env } from '../server-glue/module
|
109
|
-
import { translateAbstractSqlModel } from './translations
|
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
|
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
|
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
|
9
|
-
import type { InstantiatedHooks } from './hooks
|
10
|
-
import type { AnyObject } from './common-types
|
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
|
16
|
+
import memoizeWeak from 'memoizee/weak';
|
17
17
|
|
18
|
-
export { BadRequestError, ParsingError, TranslationError } from './errors
|
18
|
+
export { BadRequestError, ParsingError, TranslationError } from './errors';
|
19
19
|
import deepFreeze from 'deep-freeze';
|
20
|
-
import * as env from '../config-loader/env
|
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
|
27
|
-
import * as sbvrUtils from './sbvr-utils
|
26
|
+
} from './errors';
|
27
|
+
import * as sbvrUtils from './sbvr-utils';
|
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';
|
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';
|
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
|
12
|
-
import { PINEJS_ADVISORY_LOCK } from '../config-loader/env
|
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
|
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';
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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 `
|
27
|
+
* @param parentUrl Use `require`
|
17
28
|
* @returns The sbvr file contents
|
18
29
|
*/
|
19
|
-
export
|
20
|
-
return
|
21
|
-
|
22
|
-
|
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
|
2
|
-
|
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
|
-
|
10
|
+
import * as Pinejs from './module';
|
11
|
+
export { sbvrUtils, PinejsSessionStore } from './module';
|
5
12
|
|
6
|
-
|
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
|
-
|
22
|
-
const
|
23
|
-
const
|
24
|
-
const
|
25
|
-
const
|
26
|
-
const
|
27
|
-
const
|
28
|
-
const
|
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] ||
|
43
|
+
const root = process.argv[2] || __dirname;
|
33
44
|
app.use('/', serveStatic(path.join(root, 'static')));
|
34
45
|
|
35
46
|
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 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
|
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 {
|
13
|
+
import { requireSBVR } from '../server-glue/sbvr-loader';
|
14
14
|
|
15
|
-
export type * from './tasks
|
15
|
+
export type * from './tasks';
|
16
16
|
|
17
|
-
const modelText =
|
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
|
28
|
+
declare module '../sbvr-api/sbvr-utils' {
|
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';
|
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> {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from './NoopHandler
|
2
|
-
export * from './S3Handler
|
1
|
+
export * from './NoopHandler';
|
2
|
+
export * from './S3Handler';
|