@balena/pinejs 17.0.0-build-v17-a23172f0d3c5aa4169ebb0f29d4939508c9074cf-2 → 17.0.0-build-17-x-74b0e8403edbd7922c684e3ce19bdb42ac41846b-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 +2297 -11
- package/CHANGELOG.md +860 -4
- package/out/bin/abstract-sql-compiler.js +1 -1
- package/out/bin/abstract-sql-compiler.js.map +1 -1
- package/out/bin/sbvr-compiler.js +1 -1
- package/out/bin/sbvr-compiler.js.map +1 -1
- package/out/database-layer/db.js +30 -19
- package/out/database-layer/db.js.map +1 -1
- package/out/http-transactions/transactions.js +2 -2
- package/out/http-transactions/transactions.js.map +1 -1
- package/out/migrator/async.js +8 -9
- package/out/migrator/async.js.map +1 -1
- package/out/migrator/sync.js +6 -6
- package/out/migrator/sync.js.map +1 -1
- package/out/pinejs-session-store/pinejs-session-store.js +103 -108
- package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
- package/out/sbvr-api/abstract-sql.js +1 -1
- package/out/sbvr-api/abstract-sql.js.map +1 -1
- package/out/sbvr-api/errors.js +3 -0
- package/out/sbvr-api/errors.js.map +1 -1
- package/out/sbvr-api/hooks.js +4 -5
- package/out/sbvr-api/hooks.js.map +1 -1
- package/out/sbvr-api/permissions.js +3 -3
- package/out/sbvr-api/permissions.js.map +1 -1
- package/out/sbvr-api/sbvr-utils.d.ts +5 -12
- package/out/sbvr-api/sbvr-utils.js +16 -15
- package/out/sbvr-api/sbvr-utils.js.map +1 -1
- package/out/sbvr-api/uri-parser.js +1 -1
- package/out/sbvr-api/uri-parser.js.map +1 -1
- package/out/webresource-handler/handlers/NoopHandler.d.ts +1 -3
- package/out/webresource-handler/handlers/NoopHandler.js +0 -6
- package/out/webresource-handler/handlers/NoopHandler.js.map +1 -1
- package/out/webresource-handler/handlers/S3Handler.d.ts +28 -0
- package/out/webresource-handler/handlers/S3Handler.js +104 -0
- package/out/webresource-handler/handlers/S3Handler.js.map +1 -0
- package/out/webresource-handler/handlers/index.d.ts +1 -0
- package/out/webresource-handler/handlers/index.js +1 -0
- package/out/webresource-handler/handlers/index.js.map +1 -1
- package/out/webresource-handler/index.d.ts +7 -25
- package/out/webresource-handler/index.js +18 -4
- package/out/webresource-handler/index.js.map +1 -1
- package/package.json +40 -39
- package/src/bin/abstract-sql-compiler.ts +1 -1
- package/src/bin/sbvr-compiler.ts +1 -1
- package/src/http-transactions/transactions.js +2 -2
- package/src/migrator/async.ts +10 -11
- package/src/migrator/sync.ts +6 -6
- package/src/sbvr-api/abstract-sql.ts +1 -1
- package/src/sbvr-api/permissions.ts +3 -3
- package/src/sbvr-api/sbvr-utils.ts +21 -30
- package/src/sbvr-api/uri-parser.ts +1 -1
- package/src/webresource-handler/handlers/NoopHandler.ts +1 -14
- package/src/webresource-handler/handlers/S3Handler.ts +143 -0
- package/src/webresource-handler/handlers/index.ts +1 -0
- package/src/webresource-handler/index.ts +21 -41
- package/tsconfig.json +1 -1
@@ -2,7 +2,7 @@
|
|
2
2
|
import type * as Express from 'express';
|
3
3
|
import type * as stream from 'node:stream';
|
4
4
|
import type { WebResourceType as WebResource } from '@balena/sbvr-types';
|
5
|
-
import
|
5
|
+
import { TypedError } from 'typed-error';
|
6
6
|
export * from './handlers';
|
7
7
|
export interface IncomingFile {
|
8
8
|
fieldname: string;
|
@@ -15,34 +15,16 @@ export interface UploadResponse {
|
|
15
15
|
size: number;
|
16
16
|
filename: string;
|
17
17
|
}
|
18
|
-
export interface BeginMultipartUploadPayload {
|
19
|
-
filename: string;
|
20
|
-
content_type: string;
|
21
|
-
size: number;
|
22
|
-
chunk_size: number;
|
23
|
-
}
|
24
|
-
export interface UploadPart {
|
25
|
-
url: string;
|
26
|
-
chunkSize: number;
|
27
|
-
partNumber: number;
|
28
|
-
}
|
29
|
-
export interface BeginMultipartUploadHandlerResponse {
|
30
|
-
uploadParts: UploadPart[];
|
31
|
-
fileKey: string;
|
32
|
-
uploadId: string;
|
33
|
-
}
|
34
|
-
export interface CommitMultipartUploadPayload {
|
35
|
-
fileKey: string;
|
36
|
-
uploadId: string;
|
37
|
-
filename: string;
|
38
|
-
providerCommitData?: AnyObject;
|
39
|
-
}
|
40
18
|
export interface WebResourceHandler {
|
41
19
|
handleFile: (resource: IncomingFile) => Promise<UploadResponse>;
|
42
20
|
removeFile: (fileReference: string) => Promise<void>;
|
43
21
|
onPreRespond: (webResource: WebResource) => Promise<WebResource>;
|
44
|
-
|
45
|
-
|
22
|
+
}
|
23
|
+
export declare class WebResourceError extends TypedError {
|
24
|
+
}
|
25
|
+
export declare class FileSizeExceededError extends WebResourceError {
|
26
|
+
name: string;
|
27
|
+
constructor(maxSize: number);
|
46
28
|
}
|
47
29
|
export declare const setupWebresourceHandler: (handler: WebResourceHandler) => void;
|
48
30
|
export declare const getWebresourceHandler: () => WebResourceHandler | undefined;
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
30
30
|
};
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
32
|
-
exports.setupUploadHooks = exports.getDefaultHandler = exports.normalizeHref = exports.getUploaderMiddlware = exports.getWebresourceHandler = exports.setupWebresourceHandler = void 0;
|
32
|
+
exports.setupUploadHooks = exports.getDefaultHandler = exports.normalizeHref = exports.getUploaderMiddlware = exports.getWebresourceHandler = exports.setupWebresourceHandler = exports.FileSizeExceededError = exports.WebResourceError = void 0;
|
33
33
|
const busboy_1 = __importDefault(require("busboy"));
|
34
34
|
const uriParser = __importStar(require("../sbvr-api/uri-parser"));
|
35
35
|
const sbvrUtils = __importStar(require("../sbvr-api/sbvr-utils"));
|
@@ -38,10 +38,21 @@ const permissions_1 = require("../sbvr-api/permissions");
|
|
38
38
|
const NoopHandler_1 = require("./handlers/NoopHandler");
|
39
39
|
const odata_to_abstract_sql_1 = require("@balena/odata-to-abstract-sql");
|
40
40
|
const module_1 = require("../server-glue/module");
|
41
|
+
const typed_error_1 = require("typed-error");
|
41
42
|
__exportStar(require("./handlers"), exports);
|
43
|
+
class WebResourceError extends typed_error_1.TypedError {
|
44
|
+
}
|
45
|
+
exports.WebResourceError = WebResourceError;
|
46
|
+
class FileSizeExceededError extends WebResourceError {
|
47
|
+
name = 'FileSizeExceededError';
|
48
|
+
constructor(maxSize) {
|
49
|
+
super(`File size exceeded the limit of ${maxSize} bytes.`);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
exports.FileSizeExceededError = FileSizeExceededError;
|
42
53
|
const getLogger = (vocab) => {
|
43
54
|
if (vocab) {
|
44
|
-
return sbvrUtils.
|
55
|
+
return sbvrUtils.logger[vocab] ?? console;
|
45
56
|
}
|
46
57
|
return console;
|
47
58
|
};
|
@@ -150,8 +161,11 @@ const getUploaderMiddlware = (handler) => {
|
|
150
161
|
}
|
151
162
|
catch (err) {
|
152
163
|
await clearFiles();
|
153
|
-
|
154
|
-
|
164
|
+
if (err instanceof FileSizeExceededError) {
|
165
|
+
return sbvrUtils.handleHttpErrors(req, res, new module_1.errors.BadRequestError(err.message));
|
166
|
+
}
|
167
|
+
getLogger((0, sbvr_utils_1.getApiRoot)(req)).error('Error uploading file', err);
|
168
|
+
next(err);
|
155
169
|
}
|
156
170
|
});
|
157
171
|
bb.on('error', async (err) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/webresource-handler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAA4B;AAE5B,kEAAoD;AACpD,kEAAoD;AAEpD,uDAA8D;AAC9D,yDAA2D;AAC3D,wDAAqD;AACrD,yEAGuC;AACvC,kDAA4D;AAI5D,6CAA2B;AA2D3B,MAAM,SAAS,GAAG,CAAC,KAAc,EAAW,EAAE;IAC7C,IAAI,KAAK,EAAE,CAAC;QACX,OAAO,SAA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O,GAAG,EAAE,CAAC;QACd,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC;AACF,CAAC,CAAC;AAEK,MAAM,iBAAiB,GAAG,GAAuB,EAAE;IACzD,OAAO,IAAI,yBAAW,EAAE,CAAC;AAC1B,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,gBAAgB,GAAG,CAC/B,OAA2B,EAC3B,OAAe,EACf,YAAoB,EACnB,EAAE;IACH,SAAS,CAAC,WAAW,CACpB,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,yBAAyB,CAAC,OAAO,CAAC,CAClC,CAAC;IAEF,SAAS,CAAC,WAAW,CACpB,OAAO,EACP,OAAO,EACP,YAAY,EAEZ,yBAAyB,CAAC,OAAO,CAAC,CAClC,CAAC;IAEF,SAAS,CAAC,WAAW,CACpB,MAAM,EACN,OAAO,EACP,YAAY,EACZ,yBAAyB,CAAC,OAAO,CAAC,CAClC,CAAC;AACH,CAAC,CAAC;AA1BW,QAAA,gBAAgB,oBA0B3B"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@balena/pinejs",
|
3
|
-
"version": "17.0.0-build-
|
3
|
+
"version": "17.0.0-build-17-x-74b0e8403edbd7922c684e3ce19bdb42ac41846b-1",
|
4
4
|
"main": "out/server-glue/module",
|
5
5
|
"type": "commonjs",
|
6
6
|
"repository": "git@github.com:balena-io/pinejs.git",
|
@@ -20,55 +20,53 @@
|
|
20
20
|
"webpack-build": "npm run webpack-browser && npm run webpack-module && npm run webpack-server",
|
21
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",
|
23
|
-
"test:compose": "trap 'docker compose -f docker-compose.npm-test.yml down ; echo Stopped ; exit 0'
|
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 npm run mocha",
|
24
24
|
"mocha": "TS_NODE_FILES=true mocha",
|
25
25
|
"prettify": "balena-lint -t tsconfig.dev.json -e js -e ts --fix src test build typings Gruntfile.ts"
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
|
-
"@balena/abstract-sql-compiler": "^9.1.
|
29
|
-
"@balena/abstract-sql-to-typescript": "^
|
30
|
-
"@balena/env-parsing": "^1.1.
|
31
|
-
"@balena/lf-to-abstract-sql": "^5.0.
|
32
|
-
"@balena/odata-parser": "^3.0.
|
33
|
-
"@balena/odata-to-abstract-sql": "^6.2.
|
34
|
-
"@balena/sbvr-parser": "^1.4.
|
35
|
-
"@balena/sbvr-types": "^7.0
|
28
|
+
"@balena/abstract-sql-compiler": "^9.1.4",
|
29
|
+
"@balena/abstract-sql-to-typescript": "^3.0.2",
|
30
|
+
"@balena/env-parsing": "^1.1.12",
|
31
|
+
"@balena/lf-to-abstract-sql": "^5.0.2",
|
32
|
+
"@balena/odata-parser": "^3.0.7",
|
33
|
+
"@balena/odata-to-abstract-sql": "^6.2.7",
|
34
|
+
"@balena/sbvr-parser": "^1.4.4",
|
35
|
+
"@balena/sbvr-types": "^7.1.0",
|
36
36
|
"@types/body-parser": "^1.19.5",
|
37
37
|
"@types/compression": "^1.7.5",
|
38
|
-
"@types/cookie-parser": "^1.4.
|
38
|
+
"@types/cookie-parser": "^1.4.7",
|
39
39
|
"@types/deep-freeze": "^0.1.5",
|
40
40
|
"@types/express": "^4.17.21",
|
41
|
-
"@types/express-session": "^1.
|
42
|
-
"@types/lodash": "^4.
|
41
|
+
"@types/express-session": "^1.18.0",
|
42
|
+
"@types/lodash": "^4.17.1",
|
43
43
|
"@types/memoizee": "^0.4.11",
|
44
44
|
"@types/method-override": "^0.0.35",
|
45
45
|
"@types/multer": "^1.4.11",
|
46
|
-
"@types/mysql": "^2.15.
|
47
|
-
"@types/node": "^20.
|
46
|
+
"@types/mysql": "^2.15.26",
|
47
|
+
"@types/node": "^20.12.10",
|
48
48
|
"@types/passport": "^1.0.16",
|
49
49
|
"@types/passport-local": "^1.0.38",
|
50
50
|
"@types/passport-strategy": "^0.2.38",
|
51
|
-
"@types/pg": "^8.
|
52
|
-
"@types/randomstring": "^1.
|
51
|
+
"@types/pg": "^8.11.6",
|
52
|
+
"@types/randomstring": "^1.3.0",
|
53
53
|
"@types/websql": "^0.0.30",
|
54
54
|
"busboy": "^1.6.0",
|
55
55
|
"commander": "^11.1.0",
|
56
56
|
"deep-freeze": "^0.0.1",
|
57
57
|
"eventemitter3": "^5.0.1",
|
58
|
-
"express-session": "^1.
|
58
|
+
"express-session": "^1.18.0",
|
59
59
|
"lodash": "^4.17.21",
|
60
60
|
"memoizee": "^0.4.15",
|
61
|
-
"pinejs-client-core": "^6.14.
|
61
|
+
"pinejs-client-core": "^6.14.4",
|
62
62
|
"randomstring": "^1.3.0",
|
63
63
|
"typed-error": "^3.2.2"
|
64
64
|
},
|
65
65
|
"devDependencies": {
|
66
|
-
"@
|
67
|
-
"@
|
68
|
-
"@
|
69
|
-
"@
|
70
|
-
"@types/busboy": "^1.5.3",
|
71
|
-
"@types/chai": "^4.3.11",
|
66
|
+
"@balena/lint": "^8.0.2",
|
67
|
+
"@faker-js/faker": "^8.4.1",
|
68
|
+
"@types/busboy": "^1.5.4",
|
69
|
+
"@types/chai": "^4.3.16",
|
72
70
|
"@types/chai-as-promised": "^7.1.8",
|
73
71
|
"@types/grunt": "^0.4.31",
|
74
72
|
"@types/mocha": "^10.0.6",
|
@@ -90,40 +88,43 @@
|
|
90
88
|
"grunt-text-replace": "^0.4.0",
|
91
89
|
"grunt-ts": "^6.0.0-beta.22",
|
92
90
|
"grunt-webpack": "^6.0.0",
|
93
|
-
"husky": "^9.0.
|
94
|
-
"lint-staged": "^15.2.
|
91
|
+
"husky": "^9.0.11",
|
92
|
+
"lint-staged": "^15.2.2",
|
95
93
|
"load-grunt-tasks": "^5.1.0",
|
96
|
-
"mocha": "^10.
|
94
|
+
"mocha": "^10.4.0",
|
97
95
|
"on-finished": "^2.4.1",
|
98
|
-
"pinejs-client-supertest": "^2.0.
|
96
|
+
"pinejs-client-supertest": "^2.0.3",
|
99
97
|
"raw-loader": "^4.0.2",
|
100
98
|
"request": "^2.88.2",
|
101
99
|
"require-npm4-to-publish": "^1.0.0",
|
102
|
-
"supertest": "^
|
100
|
+
"supertest": "^7.0.0",
|
103
101
|
"terser-webpack-plugin": "^5.3.10",
|
104
102
|
"ts-loader": "^9.5.1",
|
105
103
|
"ts-node": "^10.9.2",
|
106
|
-
"typescript": "^5.
|
107
|
-
"webpack": "^5.
|
108
|
-
"webpack-dev-server": "^4.15.
|
104
|
+
"typescript": "^5.4.5",
|
105
|
+
"webpack": "^5.91.0",
|
106
|
+
"webpack-dev-server": "^4.15.2"
|
109
107
|
},
|
110
108
|
"optionalDependencies": {
|
109
|
+
"@aws-sdk/client-s3": "^3.569.0",
|
110
|
+
"@aws-sdk/lib-storage": "^3.569.0",
|
111
|
+
"@aws-sdk/s3-request-presigner": "^3.569.0",
|
111
112
|
"bcrypt": "^5.1.1",
|
112
113
|
"body-parser": "^1.20.2",
|
113
114
|
"compression": "^1.7.4",
|
114
115
|
"cookie-parser": "^1.4.6",
|
115
|
-
"express": "^4.
|
116
|
+
"express": "^4.19.2",
|
116
117
|
"method-override": "^3.0.0",
|
117
118
|
"mysql": "^2.18.1",
|
118
119
|
"passport": "^0.7.0",
|
119
120
|
"passport-local": "^1.0.0",
|
120
|
-
"pg": "^8.11.
|
121
|
-
"pg-connection-string": "^2.6.
|
121
|
+
"pg": "^8.11.5",
|
122
|
+
"pg-connection-string": "^2.6.4",
|
122
123
|
"serve-static": "^1.15.0"
|
123
124
|
},
|
124
125
|
"engines": {
|
125
|
-
"node": ">=
|
126
|
-
"npm": ">=
|
126
|
+
"node": ">=20.14.0",
|
127
|
+
"npm": ">=10.7.0"
|
127
128
|
},
|
128
129
|
"lint-staged": {
|
129
130
|
"*.js": [
|
@@ -143,6 +144,6 @@
|
|
143
144
|
"recursive": true
|
144
145
|
},
|
145
146
|
"versionist": {
|
146
|
-
"publishedAt": "2024-
|
147
|
+
"publishedAt": "2024-06-04T15:19:23.285Z"
|
147
148
|
}
|
148
149
|
}
|
@@ -17,7 +17,7 @@ const runCompile = async (inputFile: string, outputFile?: string) => {
|
|
17
17
|
|
18
18
|
const generateTypes = async (inputFile: string, outputFile?: string) => {
|
19
19
|
const { abstractSqlToTypescriptTypes } = await import(
|
20
|
-
'@balena/abstract-sql-to-typescript'
|
20
|
+
'@balena/abstract-sql-to-typescript/generate'
|
21
21
|
);
|
22
22
|
const abstractSql = getAbstractSqlModelFromFile(inputFile);
|
23
23
|
const types = abstractSqlToTypescriptTypes(abstractSql);
|
package/src/bin/sbvr-compiler.ts
CHANGED
@@ -42,7 +42,7 @@ const generateTypes = async (inputFile: string, outputFile?: string) => {
|
|
42
42
|
program.opts().engine,
|
43
43
|
);
|
44
44
|
const { abstractSqlToTypescriptTypes } = await import(
|
45
|
-
'@balena/abstract-sql-to-typescript'
|
45
|
+
'@balena/abstract-sql-to-typescript/generate'
|
46
46
|
);
|
47
47
|
const types = abstractSqlToTypescriptTypes(models.abstractSql);
|
48
48
|
|
@@ -61,7 +61,7 @@ export function setup(app, sbvrUtils) {
|
|
61
61
|
sbvrUtils.addPureHook('PUT', modelName, 'all', {
|
62
62
|
async PRERUN({ tx, request }) {
|
63
63
|
const vocab = request.vocabulary;
|
64
|
-
const
|
64
|
+
const log = sbvrUtils.logger[vocab];
|
65
65
|
const id = sbvrUtils.getID(vocab, request);
|
66
66
|
let result;
|
67
67
|
try {
|
@@ -77,7 +77,7 @@ SELECT NOT EXISTS(
|
|
77
77
|
[request.resourceName, id],
|
78
78
|
);
|
79
79
|
} catch (/** @type any */ err) {
|
80
|
-
|
80
|
+
log.error('Unable to check resource locks', err);
|
81
81
|
throw new Error('Unable to check resource locks');
|
82
82
|
}
|
83
83
|
if ([false, 0, '0'].includes(result.rows[0].result)) {
|
package/src/migrator/async.ts
CHANGED
@@ -28,7 +28,7 @@ import {
|
|
28
28
|
import { booleanToEnabledString } from '../config-loader/env';
|
29
29
|
|
30
30
|
// log the startup condition of the async migration
|
31
|
-
(sbvrUtils.
|
31
|
+
(sbvrUtils.logger?.migrations?.info ?? console.info)(
|
32
32
|
`Async migration execution is ${booleanToEnabledString(
|
33
33
|
migratorEnv.asyncMigrationIsEnabled,
|
34
34
|
)}`,
|
@@ -153,7 +153,7 @@ const $run = async (
|
|
153
153
|
(await tx.executeSql(asyncMigrationSqlStatement)).rowsAffected;
|
154
154
|
} else {
|
155
155
|
// don't break the async migration b/c of one migration fails
|
156
|
-
(sbvrUtils.
|
156
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
157
157
|
`Invalid migration object: ${JSON.stringify(migration, null, 2)}`,
|
158
158
|
);
|
159
159
|
continue;
|
@@ -170,7 +170,7 @@ const $run = async (
|
|
170
170
|
asyncRunnerMigratorFn = async (tx: Tx) =>
|
171
171
|
(await tx.executeSql(migration)).rowsAffected;
|
172
172
|
} else {
|
173
|
-
(sbvrUtils.
|
173
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
174
174
|
`Invalid async migration object: ${JSON.stringify(migration, null, 2)}`,
|
175
175
|
);
|
176
176
|
continue;
|
@@ -210,7 +210,7 @@ const $run = async (
|
|
210
210
|
if (!migrationState) {
|
211
211
|
// migration status is unclear stop the migrator
|
212
212
|
// or migration should stop
|
213
|
-
(sbvrUtils.
|
213
|
+
(sbvrUtils.logger.migrations?.info ?? console.info)(
|
214
214
|
`stopping async migration due to missing migration status: ${key}`,
|
215
215
|
);
|
216
216
|
return false;
|
@@ -246,7 +246,7 @@ const $run = async (
|
|
246
246
|
}
|
247
247
|
} catch (err) {
|
248
248
|
(
|
249
|
-
sbvrUtils.
|
249
|
+
sbvrUtils.logger.migrations?.error ??
|
250
250
|
console.error
|
251
251
|
)(
|
252
252
|
`error rolling back pending async migration tx on mgmt tx end/rollback: ${key}: ${err}`,
|
@@ -280,14 +280,13 @@ const $run = async (
|
|
280
280
|
initMigrationState.errorThreshold ===
|
281
281
|
0
|
282
282
|
) {
|
283
|
-
(
|
284
|
-
|
285
|
-
|
286
|
-
)(`${key}: ${err.name} ${err.message}`);
|
283
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
284
|
+
`${key}: ${err.name} ${err.message}`,
|
285
|
+
);
|
287
286
|
migrationState.is_backing_off = true;
|
288
287
|
}
|
289
288
|
} else {
|
290
|
-
(sbvrUtils.
|
289
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
291
290
|
`async migration error unknown: ${key}: ${err}`,
|
292
291
|
);
|
293
292
|
}
|
@@ -312,7 +311,7 @@ const $run = async (
|
|
312
311
|
setTimeout(asyncRunner, initMigrationState.delayMS);
|
313
312
|
}
|
314
313
|
} catch (err) {
|
315
|
-
(sbvrUtils.
|
314
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
316
315
|
`error running async migration: ${key}: ${err}`,
|
317
316
|
);
|
318
317
|
setTimeout(asyncRunner, initMigrationState.backoffDelayMS);
|
package/src/migrator/sync.ts
CHANGED
@@ -29,7 +29,7 @@ export const postRun = async (tx: Tx, model: ApiRootModel): Promise<void> => {
|
|
29
29
|
const modelName = model.apiRoot;
|
30
30
|
const modelIsNew = await sbvrUtils.isModelNew(tx, modelName);
|
31
31
|
if (modelIsNew) {
|
32
|
-
(sbvrUtils.
|
32
|
+
(sbvrUtils.logger.migrations?.info ?? console.info)(
|
33
33
|
`First time executing '${modelName}', running init script`,
|
34
34
|
);
|
35
35
|
|
@@ -37,7 +37,7 @@ export const postRun = async (tx: Tx, model: ApiRootModel): Promise<void> => {
|
|
37
37
|
try {
|
38
38
|
await tx.executeSql(initSql);
|
39
39
|
} catch (err: any) {
|
40
|
-
(sbvrUtils.
|
40
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
41
41
|
`initSql execution error ${err} `,
|
42
42
|
);
|
43
43
|
throw new MigrationError(err);
|
@@ -69,7 +69,7 @@ const $run = async (
|
|
69
69
|
// to make changes that can't be automatically applied
|
70
70
|
const modelIsNew = await sbvrUtils.isModelNew(tx, modelName);
|
71
71
|
if (modelIsNew) {
|
72
|
-
(sbvrUtils.
|
72
|
+
(sbvrUtils.logger.migrations?.info ?? console.info)(
|
73
73
|
`First time model '${modelName}' has executed, skipping migrations`,
|
74
74
|
);
|
75
75
|
return await setExecutedMigrations(tx, modelName, Object.keys(migrations));
|
@@ -94,7 +94,7 @@ const $run = async (
|
|
94
94
|
...newlyExecutedMigrations,
|
95
95
|
]);
|
96
96
|
} catch (err: any) {
|
97
|
-
(sbvrUtils.
|
97
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
98
98
|
`Failed to executed synchronous migrations from api root model ${err}`,
|
99
99
|
);
|
100
100
|
throw new MigrationError(err);
|
@@ -111,7 +111,7 @@ const executeMigrations = async (
|
|
111
111
|
await executeMigration(tx, migration);
|
112
112
|
}
|
113
113
|
} catch (err: any) {
|
114
|
-
(sbvrUtils.
|
114
|
+
(sbvrUtils.logger.migrations?.error ?? console.error)(
|
115
115
|
'Error while executing migrations, rolled back',
|
116
116
|
);
|
117
117
|
throw new MigrationError(err);
|
@@ -123,7 +123,7 @@ const executeMigration = async (
|
|
123
123
|
tx: Tx,
|
124
124
|
[key, migration]: MigrationTuple,
|
125
125
|
): Promise<void> => {
|
126
|
-
(sbvrUtils.
|
126
|
+
(sbvrUtils.logger.migrations?.info ?? console.info)(
|
127
127
|
`Running migration ${JSON.stringify(key)}`,
|
128
128
|
);
|
129
129
|
|
@@ -49,7 +49,7 @@ export const compileRequest = (request: ODataRequest) => {
|
|
49
49
|
request.sqlQuery = sqlQuery;
|
50
50
|
request.modifiedFields = modifiedFields;
|
51
51
|
} catch (err: any) {
|
52
|
-
sbvrUtils.
|
52
|
+
sbvrUtils.logger[request.vocabulary].error(
|
53
53
|
'Failed to compile abstract sql: ',
|
54
54
|
request.abstractSqlQuery,
|
55
55
|
err,
|
@@ -1268,7 +1268,7 @@ export const getUserPermissions = async (
|
|
1268
1268
|
try {
|
1269
1269
|
return await $getUserPermissions(userId, tx);
|
1270
1270
|
} catch (err: any) {
|
1271
|
-
sbvrUtils.
|
1271
|
+
sbvrUtils.logger.Auth.error('Error loading user permissions', err);
|
1272
1272
|
throw err;
|
1273
1273
|
}
|
1274
1274
|
};
|
@@ -1396,7 +1396,7 @@ export const getApiKeyPermissions = async (
|
|
1396
1396
|
try {
|
1397
1397
|
return await $getApiKeyPermissions(apiKey, tx);
|
1398
1398
|
} catch (err: any) {
|
1399
|
-
sbvrUtils.
|
1399
|
+
sbvrUtils.logger.Auth.error('Error loading api key permissions', err);
|
1400
1400
|
throw err;
|
1401
1401
|
}
|
1402
1402
|
};
|
@@ -1577,7 +1577,7 @@ export const checkPermissionsMiddleware =
|
|
1577
1577
|
);
|
1578
1578
|
}
|
1579
1579
|
} catch (err: any) {
|
1580
|
-
sbvrUtils.
|
1580
|
+
sbvrUtils.logger.Auth.error('Error checking permissions', err);
|
1581
1581
|
res.status(503).end();
|
1582
1582
|
}
|
1583
1583
|
};
|
@@ -671,20 +671,20 @@ export const executeModels = async (
|
|
671
671
|
await validateModel(tx, apiRoot);
|
672
672
|
}
|
673
673
|
|
674
|
-
|
675
|
-
|
676
|
-
|
674
|
+
api[apiRoot] = new PinejsClient('/' + apiRoot + '/');
|
675
|
+
|
676
|
+
logger[apiRoot] = { ...console };
|
677
677
|
if (model.logging != null) {
|
678
678
|
const defaultSetting = model.logging?.default ?? true;
|
679
|
-
const
|
679
|
+
const log = logger[apiRoot];
|
680
680
|
for (const k of Object.keys(model.logging)) {
|
681
681
|
const key = k as keyof Console;
|
682
682
|
if (
|
683
683
|
key !== 'Console' &&
|
684
|
-
typeof
|
684
|
+
typeof log[key] === 'function' &&
|
685
685
|
!(model.logging?.[key] ?? defaultSetting)
|
686
686
|
) {
|
687
|
-
|
687
|
+
log[key] = _.noop;
|
688
688
|
}
|
689
689
|
}
|
690
690
|
}
|
@@ -856,7 +856,7 @@ export const runRule = (() => {
|
|
856
856
|
translator.addTypes(sbvrTypes);
|
857
857
|
return async (vocab: string, rule: string) => {
|
858
858
|
const seModel = models[vocab].se;
|
859
|
-
const
|
859
|
+
const log = logger[vocab];
|
860
860
|
let lfModel: LFModel;
|
861
861
|
let slfModel: LFModel;
|
862
862
|
let abstractSqlModel: AbstractSQLCompiler.AbstractSqlModel;
|
@@ -867,7 +867,7 @@ export const runRule = (() => {
|
|
867
867
|
'Process',
|
868
868
|
);
|
869
869
|
} catch (e) {
|
870
|
-
|
870
|
+
log.error('Error parsing rule', rule, e);
|
871
871
|
throw new Error(`Error parsing rule'${rule}': ${e}`);
|
872
872
|
}
|
873
873
|
|
@@ -881,7 +881,7 @@ export const runRule = (() => {
|
|
881
881
|
translator.reset();
|
882
882
|
abstractSqlModel = translator.match(slfModel, 'Process');
|
883
883
|
} catch (e) {
|
884
|
-
|
884
|
+
log.error('Error compiling rule', rule, e);
|
885
885
|
throw new Error(`Error compiling rule '${rule}': ${e}`);
|
886
886
|
}
|
887
887
|
|
@@ -992,16 +992,7 @@ export const runRule = (() => {
|
|
992
992
|
};
|
993
993
|
})();
|
994
994
|
|
995
|
-
export
|
996
|
-
req?: {
|
997
|
-
user?: User;
|
998
|
-
};
|
999
|
-
tx?: Db.Tx;
|
1000
|
-
};
|
1001
|
-
|
1002
|
-
export class PinejsClient extends PinejsClientCore<PinejsClient> {
|
1003
|
-
// @ts-expect-error This is actually assigned by `super` so it is always declared but that isn't detected here
|
1004
|
-
public passthrough: Passthrough;
|
995
|
+
export class PinejsClient extends PinejsClientCore {
|
1005
996
|
public async _request({
|
1006
997
|
method,
|
1007
998
|
url,
|
@@ -1021,11 +1012,11 @@ export class PinejsClient extends PinejsClientCore<PinejsClient> {
|
|
1021
1012
|
}
|
1022
1013
|
}
|
1023
1014
|
|
1024
|
-
export type LoggingClient = PinejsClient & {
|
1025
|
-
logger: Console;
|
1026
|
-
};
|
1027
1015
|
export const api: {
|
1028
|
-
[vocab: string]:
|
1016
|
+
[vocab: string]: PinejsClient;
|
1017
|
+
} = {};
|
1018
|
+
export const logger: {
|
1019
|
+
[vocab: string]: Console;
|
1029
1020
|
} = {};
|
1030
1021
|
|
1031
1022
|
// We default to guest only permissions if no req object is passed in
|
@@ -1224,7 +1215,7 @@ export const getModel = (vocabulary: string) => {
|
|
1224
1215
|
|
1225
1216
|
const runODataRequest = (req: Express.Request, vocabulary: string) => {
|
1226
1217
|
if (env.DEBUG) {
|
1227
|
-
|
1218
|
+
logger[vocabulary].log('Parsing', req.method, req.url);
|
1228
1219
|
}
|
1229
1220
|
|
1230
1221
|
// Get the hooks for the current method/vocabulary as we know it,
|
@@ -1535,10 +1526,10 @@ const runRequest = async (
|
|
1535
1526
|
tx: Db.Tx,
|
1536
1527
|
request: uriParser.ODataRequest,
|
1537
1528
|
): Promise<Response> => {
|
1538
|
-
const
|
1529
|
+
const log = logger[request.vocabulary];
|
1539
1530
|
|
1540
1531
|
if (env.DEBUG) {
|
1541
|
-
|
1532
|
+
log.log('Running', req.method, req.url);
|
1542
1533
|
}
|
1543
1534
|
let result: Db.Result | number | undefined;
|
1544
1535
|
|
@@ -1566,7 +1557,7 @@ const runRequest = async (
|
|
1566
1557
|
} catch (err: any) {
|
1567
1558
|
if (err instanceof db.DatabaseError) {
|
1568
1559
|
prettifyConstraintError(err, request);
|
1569
|
-
|
1560
|
+
log.error(err);
|
1570
1561
|
// Override the error message so we don't leak any internal db info
|
1571
1562
|
err.message = 'Database error';
|
1572
1563
|
throw err;
|
@@ -1580,7 +1571,7 @@ const runRequest = async (
|
|
1580
1571
|
err instanceof TypeError ||
|
1581
1572
|
err instanceof URIError
|
1582
1573
|
) {
|
1583
|
-
|
1574
|
+
log.error(err);
|
1584
1575
|
throw new InternalRequestError();
|
1585
1576
|
}
|
1586
1577
|
throw err;
|
@@ -1740,7 +1731,7 @@ const runQuery = async (
|
|
1740
1731
|
);
|
1741
1732
|
|
1742
1733
|
if (env.DEBUG) {
|
1743
|
-
|
1734
|
+
logger[vocabulary].log(query, values);
|
1744
1735
|
}
|
1745
1736
|
|
1746
1737
|
// We only add the returning clause if it's been requested and `affectedIds` hasn't been populated yet
|
@@ -1848,7 +1839,7 @@ const respondPost = async (
|
|
1848
1839
|
id,
|
1849
1840
|
);
|
1850
1841
|
if (env.DEBUG) {
|
1851
|
-
|
1842
|
+
logger[vocab].log('Insert ID: ', request.resourceName, id);
|
1852
1843
|
}
|
1853
1844
|
|
1854
1845
|
let result: AnyObject = { d: [{ id }] };
|
@@ -421,7 +421,7 @@ export const translateUri = <
|
|
421
421
|
request.values = new Proxy(request.values, {
|
422
422
|
set: (obj: ODataRequest['values'], prop: string, value) => {
|
423
423
|
if (!Object.prototype.hasOwnProperty.call(obj, prop)) {
|
424
|
-
sbvrUtils.
|
424
|
+
sbvrUtils.logger[request.vocabulary].warn(
|
425
425
|
`Assigning a new request.values property '${prop}' however it will be ignored`,
|
426
426
|
);
|
427
427
|
}
|