@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
package/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "@balena/pinejs",
|
3
|
-
"version": "19.7.2-build-
|
4
|
-
"main": "out/server-glue/module
|
5
|
-
"type": "
|
3
|
+
"version": "19.7.2-build-update-deps-a909ee054f395de407ec4e1275fd0f5b7514fe29-1",
|
4
|
+
"main": "out/server-glue/module",
|
5
|
+
"type": "commonjs",
|
6
6
|
"repository": "git@github.com:balena-io/pinejs.git",
|
7
7
|
"license": "Apache-2.0",
|
8
8
|
"bin": {
|
@@ -13,17 +13,17 @@
|
|
13
13
|
"scripts": {
|
14
14
|
"prepublish": "require-npm4-to-publish",
|
15
15
|
"prepare": "node -e \"try { (await import('husky')).default() } catch (e) { if (e.code !== 'ERR_MODULE_NOT_FOUND') throw e }\" --input-type module && npm run build",
|
16
|
-
"build": "grunt
|
17
|
-
"webpack-browser": "grunt
|
18
|
-
"webpack-module": "grunt
|
19
|
-
"webpack-server": "grunt
|
16
|
+
"build": "grunt build",
|
17
|
+
"webpack-browser": "grunt browser",
|
18
|
+
"webpack-module": "grunt module",
|
19
|
+
"webpack-server": "grunt server",
|
20
20
|
"webpack-build": "npm run webpack-browser && npm run webpack-module && npm run webpack-server",
|
21
|
-
"lint": "balena-lint -t tsconfig.dev.json -e js -e ts src build typings Gruntfile.
|
21
|
+
"lint": "balena-lint -t tsconfig.dev.json -e js -e ts src build typings Gruntfile.ts && npx tsc --project tsconfig.dev.json --noEmit",
|
22
22
|
"test": "npm run lint && npm run build && npm run webpack-build && npm run test:compose && npm run test:generated-types",
|
23
23
|
"test:compose": "trap 'docker compose -f docker-compose.npm-test.yml down ; echo Stopped ; exit 0' INT; docker compose -f docker-compose.npm-test.yml up -d && sleep 2 && DATABASE_URL=postgres://docker:docker@localhost:5431/postgres PINEJS_WEBRESOURCE_MAXFILESIZE=1000000000 S3_ENDPOINT=http://localhost:43680 S3_ACCESS_KEY=USERNAME S3_SECRET_KEY=PASSWORD S3_STORAGE_ADAPTER_BUCKET=balena-pine-web-resources S3_REGION=us-east-1 PINEJS_QUEUE_CONCURRENCY=1 TZ=UTC npm run mocha",
|
24
24
|
"test:generated-types": "npm run generate-types && git diff --exit-code ./src/sbvr-api/user.ts ./src/migrator/migrations.ts ./src/sbvr-api/dev.ts",
|
25
25
|
"mocha": "TS_NODE_FILES=true mocha",
|
26
|
-
"lint-fix": "balena-lint -t tsconfig.dev.json -e js -e ts --fix src test build typings Gruntfile.
|
26
|
+
"lint-fix": "balena-lint -t tsconfig.dev.json -e js -e ts --fix src test build typings Gruntfile.ts",
|
27
27
|
"generate-types": "node ./bin/sbvr-compiler.js generate-types ./src/sbvr-api/user.sbvr ./src/sbvr-api/user.ts && node ./bin/sbvr-compiler.js generate-types ./src/migrator/migrations.sbvr ./src/migrator/migrations.ts && node ./bin/sbvr-compiler.js generate-types ./src/sbvr-api/dev.sbvr ./src/sbvr-api/dev.ts && node ./bin/sbvr-compiler.js generate-types ./src/tasks/tasks.sbvr ./src/tasks/tasks.ts && balena-lint -t tsconfig.dev.json --fix ./src/sbvr-api/user.ts ./src/migrator/migrations.ts ./src/sbvr-api/dev.ts"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
@@ -32,22 +32,22 @@
|
|
32
32
|
"@balena/env-parsing": "^1.2.0",
|
33
33
|
"@balena/lf-to-abstract-sql": "^5.0.3",
|
34
34
|
"@balena/odata-parser": "^3.1.2",
|
35
|
-
"@balena/odata-to-abstract-sql": "^7.0.
|
35
|
+
"@balena/odata-to-abstract-sql": "^7.0.1",
|
36
36
|
"@balena/sbvr-parser": "^1.4.6",
|
37
37
|
"@balena/sbvr-types": "^9.1.0",
|
38
38
|
"@types/body-parser": "^1.19.5",
|
39
39
|
"@types/compression": "^1.7.5",
|
40
|
-
"@types/cookie-parser": "^1.4.
|
40
|
+
"@types/cookie-parser": "^1.4.8",
|
41
41
|
"@types/deep-freeze": "^0.1.5",
|
42
42
|
"@types/express": "^4.17.21",
|
43
|
-
"@types/express-session": "^1.18.
|
44
|
-
"@types/lodash": "^4.17.
|
43
|
+
"@types/express-session": "^1.18.1",
|
44
|
+
"@types/lodash": "^4.17.13",
|
45
45
|
"@types/memoizee": "^0.4.11",
|
46
|
-
"@types/method-override": "^0.0
|
46
|
+
"@types/method-override": "^3.0.0",
|
47
47
|
"@types/multer": "^1.4.12",
|
48
48
|
"@types/mysql": "^2.15.26",
|
49
|
-
"@types/node": "^20.
|
50
|
-
"@types/passport": "^1.0.
|
49
|
+
"@types/node": "^20.17.11",
|
50
|
+
"@types/passport": "^1.0.17",
|
51
51
|
"@types/passport-local": "^1.0.38",
|
52
52
|
"@types/passport-strategy": "^0.2.38",
|
53
53
|
"@types/pg": "^8.11.10",
|
@@ -63,17 +63,17 @@
|
|
63
63
|
"json-schema-to-ts": "3.1.1",
|
64
64
|
"lodash": "^4.17.21",
|
65
65
|
"memoizee": "^0.4.17",
|
66
|
-
"pinejs-client-core": "^8.1.
|
66
|
+
"pinejs-client-core": "^8.1.2",
|
67
67
|
"randomstring": "^1.3.0",
|
68
68
|
"typed-error": "^3.2.2"
|
69
69
|
},
|
70
70
|
"devDependencies": {
|
71
71
|
"@balena/lint": "^8.2.8",
|
72
|
-
"@faker-js/faker": "^9.0
|
72
|
+
"@faker-js/faker": "^9.3.0",
|
73
73
|
"@types/busboy": "^1.5.4",
|
74
74
|
"@types/chai": "^4.3.20",
|
75
75
|
"@types/grunt": "^0.4.31",
|
76
|
-
"@types/mocha": "^10.0.
|
76
|
+
"@types/mocha": "^10.0.10",
|
77
77
|
"@types/on-finished": "^2.3.4",
|
78
78
|
"@types/request": "^2.48.12",
|
79
79
|
"@types/supertest": "^6.0.2",
|
@@ -91,37 +91,37 @@
|
|
91
91
|
"grunt-text-replace": "^0.4.0",
|
92
92
|
"grunt-ts": "^6.0.0-beta.22",
|
93
93
|
"grunt-webpack": "^7.0.0",
|
94
|
-
"husky": "^9.1.
|
95
|
-
"lint-staged": "^15.
|
94
|
+
"husky": "^9.1.7",
|
95
|
+
"lint-staged": "^15.3.0",
|
96
96
|
"load-grunt-tasks": "^5.1.0",
|
97
|
-
"mocha": "^
|
97
|
+
"mocha": "^11.0.1",
|
98
98
|
"on-finished": "^2.4.1",
|
99
99
|
"pinejs-client-supertest": "^3.0.1",
|
100
100
|
"raw-loader": "^4.0.2",
|
101
101
|
"request": "^2.88.2",
|
102
102
|
"require-npm4-to-publish": "^1.0.0",
|
103
103
|
"supertest": "^7.0.0",
|
104
|
-
"terser-webpack-plugin": "^5.3.
|
104
|
+
"terser-webpack-plugin": "^5.3.11",
|
105
105
|
"ts-loader": "^9.5.1",
|
106
106
|
"ts-node": "^10.9.2",
|
107
107
|
"typescript": "^5.7.2",
|
108
|
-
"webpack": "^5.
|
109
|
-
"webpack-dev-server": "^5.
|
108
|
+
"webpack": "^5.97.1",
|
109
|
+
"webpack-dev-server": "^5.2.0"
|
110
110
|
},
|
111
111
|
"optionalDependencies": {
|
112
|
-
"@aws-sdk/client-s3": "^3.
|
113
|
-
"@aws-sdk/lib-storage": "^3.
|
114
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
112
|
+
"@aws-sdk/client-s3": "^3.717.0",
|
113
|
+
"@aws-sdk/lib-storage": "^3.717.0",
|
114
|
+
"@aws-sdk/s3-request-presigner": "^3.717.0",
|
115
115
|
"bcrypt": "^5.1.1",
|
116
116
|
"body-parser": "^1.20.3",
|
117
|
-
"compression": "^1.7.
|
117
|
+
"compression": "^1.7.5",
|
118
118
|
"cookie-parser": "^1.4.7",
|
119
|
-
"express": "^4.21.
|
119
|
+
"express": "^4.21.2",
|
120
120
|
"method-override": "^3.0.0",
|
121
121
|
"mysql": "^2.18.1",
|
122
122
|
"passport": "^0.7.0",
|
123
123
|
"passport-local": "^1.0.0",
|
124
|
-
"pg": "^8.13.
|
124
|
+
"pg": "^8.13.1",
|
125
125
|
"pg-connection-string": "^2.7.0",
|
126
126
|
"serve-static": "^1.16.2"
|
127
127
|
},
|
@@ -141,12 +141,12 @@
|
|
141
141
|
"extension": [
|
142
142
|
".test.ts"
|
143
143
|
],
|
144
|
-
"
|
144
|
+
"require": "ts-node/register/transpile-only",
|
145
145
|
"exit": true,
|
146
146
|
"timeout": 60000,
|
147
147
|
"recursive": true
|
148
148
|
},
|
149
149
|
"versionist": {
|
150
|
-
"publishedAt": "2025-01-
|
150
|
+
"publishedAt": "2025-01-02T16:35:56.859Z"
|
151
151
|
}
|
152
152
|
}
|
@@ -3,13 +3,13 @@ import {
|
|
3
3
|
version,
|
4
4
|
writeAll,
|
5
5
|
writeSqlModel,
|
6
|
-
} from './utils
|
6
|
+
} from './utils';
|
7
7
|
|
8
8
|
import { program } from 'commander';
|
9
9
|
|
10
10
|
const runCompile = async (inputFile: string, outputFile?: string) => {
|
11
11
|
const { generateSqlModel } = await import('../sbvr-api/sbvr-utils.js');
|
12
|
-
const abstractSql =
|
12
|
+
const abstractSql = getAbstractSqlModelFromFile(
|
13
13
|
inputFile,
|
14
14
|
program.opts().model,
|
15
15
|
);
|
@@ -28,7 +28,7 @@ const generateTypes = async (
|
|
28
28
|
const { abstractSqlToTypescriptTypes } = await import(
|
29
29
|
'@balena/abstract-sql-to-typescript/generate'
|
30
30
|
);
|
31
|
-
const abstractSql =
|
31
|
+
const abstractSql = getAbstractSqlModelFromFile(
|
32
32
|
inputFile,
|
33
33
|
program.opts().model,
|
34
34
|
);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getAbstractSqlModelFromFile, version, writeAll } from './utils
|
1
|
+
import { getAbstractSqlModelFromFile, version, writeAll } from './utils';
|
2
2
|
import type {
|
3
3
|
AbstractSqlModel,
|
4
4
|
SqlResult,
|
@@ -44,7 +44,7 @@ const translateOData = async (
|
|
44
44
|
outputFile?: string,
|
45
45
|
) => {
|
46
46
|
const request = await generateAbstractSqlQuery(
|
47
|
-
|
47
|
+
getAbstractSqlModelFromFile(modelFile, program.opts().model),
|
48
48
|
odata,
|
49
49
|
);
|
50
50
|
const json = JSON.stringify(request.abstractSqlQuery, null, 2);
|
@@ -68,7 +68,7 @@ const compileOData = async (
|
|
68
68
|
outputFile?: string,
|
69
69
|
) => {
|
70
70
|
const translatedRequest = await generateAbstractSqlQuery(
|
71
|
-
|
71
|
+
getAbstractSqlModelFromFile(modelFile, program.opts().model),
|
72
72
|
odata,
|
73
73
|
);
|
74
74
|
const { compileRequest } = await import('../sbvr-api/abstract-sql.js');
|
package/src/bin/sbvr-compiler.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { version, writeAll, writeSqlModel } from './utils
|
1
|
+
import { version, writeAll, writeSqlModel } from './utils';
|
2
2
|
import { program } from 'commander';
|
3
|
-
import fs from 'fs';
|
3
|
+
import * as fs from 'fs';
|
4
4
|
|
5
5
|
const getSE = (inputFile: string) => fs.readFileSync(inputFile, 'utf8');
|
6
6
|
|
package/src/bin/utils.ts
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
process.env.PINEJS_CACHE_FILE =
|
2
|
-
process.env.PINEJS_CACHE_FILE ||
|
3
|
-
fileURLToPath(new URL('.pinejs-cache.json', import.meta.url));
|
2
|
+
process.env.PINEJS_CACHE_FILE || __dirname + '/.pinejs-cache.json';
|
4
3
|
|
5
4
|
import type { SqlModel } from '@balena/abstract-sql-compiler';
|
6
|
-
import type { Config, Model } from '../config-loader/config-loader
|
5
|
+
import type { Config, Model } from '../config-loader/config-loader';
|
6
|
+
import type * as SbvrUtils from '../sbvr-api/sbvr-utils';
|
7
7
|
import type { AbstractSqlModel } from '@balena/abstract-sql-compiler';
|
8
8
|
|
9
|
-
import fs from 'fs';
|
10
|
-
import path from 'path';
|
11
|
-
import '../server-glue/sbvr-loader
|
12
|
-
import { fileURLToPath } from 'url';
|
13
|
-
import { loadSBVR } from '../server-glue/sbvr-loader.js';
|
9
|
+
import * as fs from 'fs';
|
10
|
+
import * as path from 'path';
|
11
|
+
import '../server-glue/sbvr-loader';
|
14
12
|
|
15
|
-
export { version } from '../config-loader/env
|
13
|
+
export { version } from '../config-loader/env';
|
16
14
|
|
17
15
|
export const writeAll = (output: string, outputFile?: string): void => {
|
18
16
|
if (outputFile) {
|
@@ -70,21 +68,15 @@ const getConfigModel = (
|
|
70
68
|
return fileContents;
|
71
69
|
};
|
72
70
|
|
73
|
-
export const getAbstractSqlModelFromFile =
|
71
|
+
export const getAbstractSqlModelFromFile = (
|
74
72
|
modelFile: string,
|
75
73
|
modelName: string | undefined,
|
76
|
-
):
|
74
|
+
): AbstractSqlModel => {
|
77
75
|
let fileContents: string | Model | AbstractSqlModel | Config;
|
78
76
|
try {
|
79
|
-
fileContents =
|
77
|
+
fileContents = require(path.resolve(modelFile));
|
80
78
|
} catch {
|
81
|
-
fileContents =
|
82
|
-
try {
|
83
|
-
// Try to parse the file as JSON
|
84
|
-
fileContents = JSON.parse(fileContents);
|
85
|
-
} catch {
|
86
|
-
// Ignore error as it's likely just a text sbvr file
|
87
|
-
}
|
79
|
+
fileContents = fs.readFileSync(require.resolve(modelFile), 'utf8');
|
88
80
|
}
|
89
81
|
let seModel: string;
|
90
82
|
if (fileContents == null) {
|
@@ -102,16 +94,16 @@ export const getAbstractSqlModelFromFile = async (
|
|
102
94
|
} else if ('modelText' in configModel && configModel.modelText != null) {
|
103
95
|
seModel = configModel.modelText;
|
104
96
|
} else if ('modelFile' in configModel && configModel.modelFile != null) {
|
105
|
-
seModel =
|
97
|
+
seModel = fs.readFileSync(require.resolve(configModel.modelFile), 'utf8');
|
106
98
|
} else {
|
107
99
|
throw new Error('Unrecognized config file');
|
108
100
|
}
|
109
101
|
} else {
|
110
102
|
throw new Error('Unrecognized config file');
|
111
103
|
}
|
112
|
-
const { generateLfModel, generateAbstractSqlModel } =
|
113
|
-
|
114
|
-
|
104
|
+
const { generateLfModel, generateAbstractSqlModel } =
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
106
|
+
require('../sbvr-api/sbvr-utils') as typeof SbvrUtils;
|
115
107
|
let lfModel;
|
116
108
|
try {
|
117
109
|
lfModel = generateLfModel(seModel);
|
@@ -3,13 +3,13 @@ import type {
|
|
3
3
|
AbstractSqlModel,
|
4
4
|
Definition,
|
5
5
|
} from '@balena/abstract-sql-compiler';
|
6
|
-
import type { Database } from '../database-layer/db
|
6
|
+
import type { Database } from '../database-layer/db';
|
7
7
|
import type {
|
8
8
|
AnyObject,
|
9
9
|
Dictionary,
|
10
10
|
RequiredField,
|
11
11
|
Resolvable,
|
12
|
-
} from '../sbvr-api/common-types
|
12
|
+
} from '../sbvr-api/common-types';
|
13
13
|
|
14
14
|
import {
|
15
15
|
type Migration,
|
@@ -18,23 +18,23 @@ import {
|
|
18
18
|
MigrationCategories,
|
19
19
|
isSyncMigration,
|
20
20
|
isAsyncMigration,
|
21
|
-
} from '../migrator/utils
|
21
|
+
} from '../migrator/utils';
|
22
22
|
|
23
|
-
import fs from 'fs';
|
23
|
+
import * as fs from 'fs';
|
24
24
|
import _ from 'lodash';
|
25
|
-
import path from 'path';
|
25
|
+
import * as path from 'path';
|
26
26
|
|
27
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils
|
27
|
+
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
|
28
28
|
|
29
|
-
import * as permissions from '../sbvr-api/permissions
|
29
|
+
import * as permissions from '../sbvr-api/permissions';
|
30
30
|
import {
|
31
31
|
getDefaultHandler,
|
32
32
|
getUploaderMiddlware,
|
33
33
|
type WebResourceHandler,
|
34
34
|
setupUploadHooks,
|
35
35
|
setupWebresourceHandler,
|
36
|
-
} from '../webresource-handler
|
37
|
-
import type { AliasValidNodeType } from '../sbvr-api/translations
|
36
|
+
} from '../webresource-handler';
|
37
|
+
import type { AliasValidNodeType } from '../sbvr-api/translations';
|
38
38
|
|
39
39
|
export type SetupFunction = (
|
40
40
|
app: Express.Application,
|
@@ -256,7 +256,7 @@ export const setup = (app: Express.Application) => {
|
|
256
256
|
let customCode: SetupFunction;
|
257
257
|
if (typeof model.customServerCode === 'string') {
|
258
258
|
try {
|
259
|
-
customCode = (
|
259
|
+
customCode = nodeRequire(model.customServerCode).setup;
|
260
260
|
} catch (e: any) {
|
261
261
|
e.message = `Error loading custom server code: '${e.message}'`;
|
262
262
|
throw e;
|
@@ -291,7 +291,7 @@ export const setup = (app: Express.Application) => {
|
|
291
291
|
let root: string;
|
292
292
|
let configObj: Config;
|
293
293
|
if (config == null) {
|
294
|
-
root = path.resolve(process.argv[2]) ||
|
294
|
+
root = path.resolve(process.argv[2]) || __dirname;
|
295
295
|
configObj = await loadConfigFile(path.join(root, 'config.json'));
|
296
296
|
} else if (typeof config === 'string') {
|
297
297
|
root = path.dirname(config);
|
package/src/config-loader/env.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import
|
1
|
+
import * as fs from 'fs';
|
2
2
|
export const { version } = JSON.parse(
|
3
|
-
|
3
|
+
fs.readFileSync(require.resolve('../../package.json'), 'utf8'),
|
4
4
|
);
|
5
5
|
|
6
6
|
const { PINEJS_DEBUG } = process.env;
|
@@ -56,7 +56,7 @@ export const cache = {
|
|
56
56
|
|
57
57
|
import { boolVar, intVar } from '@balena/env-parsing';
|
58
58
|
import memoize from 'memoizee';
|
59
|
-
import memoizeWeak from 'memoizee/weak
|
59
|
+
import memoizeWeak from 'memoizee/weak';
|
60
60
|
export const createCache = <T extends (...args: any[]) => any>(
|
61
61
|
cacheName: keyof typeof cache,
|
62
62
|
fn: T,
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import * as permissions from '../sbvr-api/permissions
|
2
|
-
import type { Resolvable } from '../sbvr-api/common-types
|
1
|
+
import * as permissions from '../sbvr-api/permissions';
|
2
|
+
import type { Resolvable } from '../sbvr-api/common-types';
|
3
3
|
import type { Handler } from 'express';
|
4
|
-
import type { Config, SetupFunction } from '../config-loader/config-loader
|
5
|
-
import type { Tx } from '../database-layer/db
|
4
|
+
import type { Config, SetupFunction } from '../config-loader/config-loader';
|
5
|
+
import type { Tx } from '../database-layer/db';
|
6
6
|
|
7
7
|
const uiModel = `\
|
8
8
|
Vocabulary: ui
|
package/src/database-layer/db.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
/// <references types="websql"/>
|
2
|
-
import type Mysql from 'mysql';
|
3
|
-
import type Pg from 'pg';
|
4
|
-
import type PgConnectionString from 'pg-connection-string';
|
5
|
-
import type { Dictionary, Resolvable } from '../sbvr-api/common-types
|
2
|
+
import type * as Mysql from 'mysql';
|
3
|
+
import type * as Pg from 'pg';
|
4
|
+
import type * as PgConnectionString from 'pg-connection-string';
|
5
|
+
import type { Dictionary, Resolvable } from '../sbvr-api/common-types';
|
6
6
|
|
7
7
|
import { Engines } from '@balena/abstract-sql-compiler';
|
8
8
|
import { EventEmitter } from 'eventemitter3';
|
9
9
|
import _ from 'lodash';
|
10
10
|
import { TypedError } from 'typed-error';
|
11
|
-
import * as env from '../config-loader/env
|
12
|
-
import { fromCallback, timeout } from '../sbvr-api/control-flow
|
11
|
+
import * as env from '../config-loader/env';
|
12
|
+
import { fromCallback, timeout } from '../sbvr-api/control-flow';
|
13
13
|
|
14
14
|
export const metrics = new EventEmitter();
|
15
15
|
|
@@ -487,10 +487,8 @@ const createTransaction = (createFunc: CreateTransactionFn): TransactionFn => {
|
|
487
487
|
};
|
488
488
|
|
489
489
|
let maybePg: typeof Pg | undefined;
|
490
|
-
let maybePgConnectionString: typeof PgConnectionString | undefined;
|
491
490
|
try {
|
492
|
-
maybePg = (
|
493
|
-
maybePgConnectionString = (await import('pg-connection-string')).default;
|
491
|
+
maybePg = require('pg');
|
494
492
|
} catch {
|
495
493
|
// Ignore errors
|
496
494
|
}
|
@@ -545,15 +543,10 @@ if (maybePg != null) {
|
|
545
543
|
let pool: Pg.Pool;
|
546
544
|
let replica: Pg.Pool;
|
547
545
|
if (typeof connectString === 'string') {
|
548
|
-
|
549
|
-
|
550
|
-
'pg-connection-string is required for string connection strings',
|
551
|
-
);
|
552
|
-
}
|
546
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
547
|
+
const pgConnectionString: typeof PgConnectionString = require('pg-connection-string');
|
553
548
|
// We have to cast because of the use of null vs undefined
|
554
|
-
const config =
|
555
|
-
connectString,
|
556
|
-
) as Pg.PoolConfig;
|
549
|
+
const config = pgConnectionString.parse(connectString) as Pg.PoolConfig;
|
557
550
|
pool = initPool(config);
|
558
551
|
} else {
|
559
552
|
const config = connectString;
|
@@ -735,7 +728,7 @@ if (maybePg != null) {
|
|
735
728
|
|
736
729
|
let maybeMysql: typeof Mysql | undefined;
|
737
730
|
try {
|
738
|
-
maybeMysql = (
|
731
|
+
maybeMysql = require('mysql');
|
739
732
|
} catch {
|
740
733
|
// Ignore errors
|
741
734
|
}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { SBVRParser } from '@balena/sbvr-parser';
|
2
|
-
import {
|
3
|
-
import
|
4
|
-
import { version } from '../config-loader/env
|
2
|
+
import { requireSBVR } from '../server-glue/sbvr-loader';
|
3
|
+
import { version as sbvrParserVersion } from '@balena/sbvr-parser/package.json';
|
4
|
+
import { version } from '../config-loader/env';
|
5
5
|
|
6
|
-
const Types =
|
6
|
+
const Types = requireSBVR('@balena/sbvr-types/Type.sbvr', require);
|
7
7
|
|
8
8
|
export const ExtendedSBVRParser = SBVRParser._extend({
|
9
9
|
initialize() {
|
@@ -13,5 +13,5 @@ export const ExtendedSBVRParser = SBVRParser._extend({
|
|
13
13
|
this.AddBuiltInVocab(Types);
|
14
14
|
return this;
|
15
15
|
},
|
16
|
-
version:
|
16
|
+
version: sbvrParserVersion + '+' + version,
|
17
17
|
});
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { odataNameToSqlName } from '@balena/odata-to-abstract-sql';
|
2
|
-
import {
|
3
|
-
const transactionModel =
|
2
|
+
import { requireSBVR } from '../server-glue/sbvr-loader';
|
3
|
+
const transactionModel = requireSBVR('./transaction.sbvr', require);
|
4
4
|
|
5
|
-
/** @type {import('../config-loader/config-loader
|
5
|
+
/** @type {import('../config-loader/config-loader').Config} */
|
6
6
|
export const config = {
|
7
7
|
models: [
|
8
8
|
{
|
@@ -53,7 +53,7 @@ ADD COLUMN IF NOT EXISTS "modified at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT N
|
|
53
53
|
/** @type {(modelName: string) => void} */
|
54
54
|
export let addModelHooks;
|
55
55
|
|
56
|
-
/** @type { import('../config-loader/config-loader
|
56
|
+
/** @type { import('../config-loader/config-loader').SetupFunction } */
|
57
57
|
export function setup(app, sbvrUtils) {
|
58
58
|
addModelHooks = (modelName) => {
|
59
59
|
// TODO: Add checks on POST/PATCH requests as well.
|
package/src/migrator/async.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import type { Tx } from '../database-layer/db
|
2
|
-
import type { Model } from '../config-loader/config-loader
|
1
|
+
import type { Tx } from '../database-layer/db';
|
2
|
+
import type { Model } from '../config-loader/config-loader';
|
3
3
|
|
4
4
|
import _ from 'lodash';
|
5
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils
|
5
|
+
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
|
6
6
|
|
7
7
|
type ApiRootModel = Model & { apiRoot: string };
|
8
8
|
|
@@ -24,8 +24,8 @@ import {
|
|
24
24
|
filterAndSortPendingMigrations,
|
25
25
|
type MigrationStatus,
|
26
26
|
type BaseAsyncMigration,
|
27
|
-
} from './utils
|
28
|
-
import { booleanToEnabledString } from '../config-loader/env
|
27
|
+
} from './utils';
|
28
|
+
import { booleanToEnabledString } from '../config-loader/env';
|
29
29
|
|
30
30
|
export const run = async (tx: Tx, model: ApiRootModel): Promise<void> => {
|
31
31
|
const { migrations } = model;
|
package/src/migrator/sync.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type MigrationsModel from './migrations
|
1
|
+
import type MigrationsModel from './migrations';
|
2
2
|
import {
|
3
3
|
type MigrationTuple,
|
4
4
|
MigrationError,
|
@@ -9,15 +9,15 @@ import {
|
|
9
9
|
type RunnableMigrations,
|
10
10
|
filterAndSortPendingMigrations,
|
11
11
|
getRunnableSyncMigrations,
|
12
|
-
} from './utils
|
13
|
-
import type { Tx } from '../database-layer/db
|
14
|
-
import type { Config, Model } from '../config-loader/config-loader
|
12
|
+
} from './utils';
|
13
|
+
import type { Tx } from '../database-layer/db';
|
14
|
+
import type { Config, Model } from '../config-loader/config-loader';
|
15
15
|
|
16
16
|
import _ from 'lodash';
|
17
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils
|
18
|
-
import {
|
17
|
+
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
|
18
|
+
import { requireSBVR } from '../server-glue/sbvr-loader';
|
19
19
|
|
20
|
-
const migrationsModel =
|
20
|
+
const migrationsModel = requireSBVR('./migrations.sbvr', require);
|
21
21
|
|
22
22
|
type ApiRootModel = Model & { apiRoot: string };
|
23
23
|
|
@@ -137,7 +137,7 @@ const executeMigration = async (
|
|
137
137
|
}
|
138
138
|
};
|
139
139
|
|
140
|
-
declare module '../sbvr-api/sbvr-utils
|
140
|
+
declare module '../sbvr-api/sbvr-utils' {
|
141
141
|
export interface API {
|
142
142
|
[migrationModelConfig.apiRoot]: PinejsClient<MigrationsModel>;
|
143
143
|
}
|
package/src/migrator/utils.ts
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
import type { Result, Tx } from '../database-layer/db
|
2
|
-
import type { Resolvable } from '../sbvr-api/common-types
|
1
|
+
import type { Result, Tx } from '../database-layer/db';
|
2
|
+
import type { Resolvable } from '../sbvr-api/common-types';
|
3
3
|
|
4
4
|
import { createHash } from 'crypto';
|
5
5
|
import { Engines } from '@balena/abstract-sql-compiler';
|
6
6
|
import _ from 'lodash';
|
7
7
|
import { TypedError } from 'typed-error';
|
8
|
-
import { migrator as migratorEnv } from '../config-loader/env
|
9
|
-
export { migrator as migratorEnv } from '../config-loader/env
|
10
|
-
import { PINEJS_ADVISORY_LOCK } from '../config-loader/env
|
11
|
-
import { delay } from '../sbvr-api/control-flow
|
8
|
+
import { migrator as migratorEnv } from '../config-loader/env';
|
9
|
+
export { migrator as migratorEnv } from '../config-loader/env';
|
10
|
+
import { PINEJS_ADVISORY_LOCK } from '../config-loader/env';
|
11
|
+
import { delay } from '../sbvr-api/control-flow';
|
12
12
|
|
13
|
-
import * as sbvrUtils from '../sbvr-api/sbvr-utils
|
13
|
+
import * as sbvrUtils from '../sbvr-api/sbvr-utils';
|
14
14
|
export enum MigrationCategories {
|
15
15
|
'sync' = 'sync',
|
16
16
|
'async' = 'async',
|
@@ -3,9 +3,8 @@ import type {
|
|
3
3
|
AbstractSqlTable,
|
4
4
|
} from '@balena/abstract-sql-compiler';
|
5
5
|
|
6
|
-
import
|
7
|
-
import {
|
8
|
-
import { version } from '../config-loader/env.js';
|
6
|
+
import sbvrTypes, { type SbvrType } from '@balena/sbvr-types';
|
7
|
+
import { version } from '../config-loader/env';
|
9
8
|
|
10
9
|
const getResourceName = (resourceName: string): string =>
|
11
10
|
resourceName
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import * as passportPinejs from './passport-pinejs
|
1
|
+
import * as passportPinejs from './passport-pinejs';
|
2
2
|
import type { Express } from 'express';
|
3
|
-
import { PinejsSessionStore } from '../pinejs-session-store/pinejs-session-store
|
4
|
-
import type { setup } from '../config-loader/config-loader
|
3
|
+
import { PinejsSessionStore } from '../pinejs-session-store/pinejs-session-store';
|
4
|
+
import type { setup } from '../config-loader/config-loader';
|
5
5
|
|
6
6
|
export const mountLoginRouter = async (
|
7
7
|
configLoader: ReturnType<typeof setup>,
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type * as Express from 'express';
|
2
2
|
import type * as Passport from 'passport';
|
3
3
|
import type * as PassportLocal from 'passport-local';
|
4
|
-
import type * as ConfigLoader from '../config-loader/config-loader
|
5
|
-
import type { User } from '../sbvr-api/sbvr-utils
|
4
|
+
import type * as ConfigLoader from '../config-loader/config-loader';
|
5
|
+
import type { User } from '../sbvr-api/sbvr-utils';
|
6
6
|
|
7
|
-
import * as permissions from '../sbvr-api/permissions
|
7
|
+
import * as permissions from '../sbvr-api/permissions';
|
8
8
|
|
9
9
|
// Returns a middleware that will handle logging in using `username` and `password` body properties
|
10
10
|
export let login: (
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import type { Config } from '../config-loader/config-loader
|
2
|
-
import type { AnyObject } from '../sbvr-api/common-types
|
1
|
+
import type { Config } from '../config-loader/config-loader';
|
2
|
+
import type { AnyObject } from '../sbvr-api/common-types';
|
3
3
|
|
4
4
|
import { Store } from 'express-session';
|
5
|
-
import * as permissions from '../sbvr-api/permissions
|
6
|
-
import { api } from '../sbvr-api/sbvr-utils
|
5
|
+
import * as permissions from '../sbvr-api/permissions';
|
6
|
+
import { api } from '../sbvr-api/sbvr-utils';
|
7
7
|
|
8
8
|
export { Store };
|
9
9
|
|