@balena/pinejs 17.3.5-build-renovate-major-12-commander-2ecca03282c3dabd3d662399d3d850038e82927d-1 → 17.3.5-build-update-deps-7db9e00544f240c3c250c89951ef061b672c3182-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 +501 -6
- package/CHANGELOG.md +211 -2
- package/out/bin/utils.js.map +1 -1
- package/out/database-layer/db.js +8 -4
- package/out/database-layer/db.js.map +1 -1
- package/out/express-emulator/express.js +2 -5
- package/out/express-emulator/express.js.map +1 -1
- package/out/passport-pinejs/mount-login-router.js +1 -3
- package/out/passport-pinejs/mount-login-router.js.map +1 -1
- package/out/passport-pinejs/passport-pinejs.js +11 -8
- package/out/passport-pinejs/passport-pinejs.js.map +1 -1
- package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
- package/out/sbvr-api/abstract-sql.js.map +1 -1
- package/out/sbvr-api/hooks.js +3 -1
- package/out/sbvr-api/hooks.js.map +1 -1
- package/out/sbvr-api/permissions.js +3 -1
- package/out/sbvr-api/permissions.js.map +1 -1
- package/out/sbvr-api/sbvr-utils.js +4 -2
- package/out/sbvr-api/sbvr-utils.js.map +1 -1
- package/out/sbvr-api/translations.js +1 -1
- package/out/sbvr-api/translations.js.map +1 -1
- package/out/sbvr-api/uri-parser.js +2 -2
- package/out/sbvr-api/uri-parser.js.map +1 -1
- package/out/webresource-handler/index.js +2 -1
- package/out/webresource-handler/index.js.map +1 -1
- package/package.json +21 -21
- package/src/bin/utils.ts +1 -1
- package/src/database-layer/db.ts +13 -9
- package/src/express-emulator/express.js +2 -5
- package/src/passport-pinejs/mount-login-router.ts +1 -5
- package/src/passport-pinejs/passport-pinejs.ts +4 -2
- package/src/pinejs-session-store/pinejs-session-store.ts +1 -1
- package/src/sbvr-api/abstract-sql.ts +1 -1
- package/src/sbvr-api/hooks.ts +5 -3
- package/src/sbvr-api/permissions.ts +5 -10
- package/src/sbvr-api/sbvr-utils.ts +8 -6
- package/src/sbvr-api/translations.ts +1 -1
- package/src/sbvr-api/uri-parser.ts +2 -2
- package/src/webresource-handler/index.ts +2 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@balena/pinejs",
|
3
|
-
"version": "17.3.5-build-
|
3
|
+
"version": "17.3.5-build-update-deps-7db9e00544f240c3c250c89951ef061b672c3182-1",
|
4
4
|
"main": "out/server-glue/module",
|
5
5
|
"type": "commonjs",
|
6
6
|
"repository": "git@github.com:balena-io/pinejs.git",
|
@@ -23,17 +23,17 @@
|
|
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 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
|
-
"
|
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 && 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": {
|
30
30
|
"@balena/abstract-sql-compiler": "^9.2.0",
|
31
|
-
"@balena/abstract-sql-to-typescript": "^3.
|
31
|
+
"@balena/abstract-sql-to-typescript": "^3.3.1",
|
32
32
|
"@balena/env-parsing": "^1.1.12",
|
33
33
|
"@balena/lf-to-abstract-sql": "^5.0.2",
|
34
34
|
"@balena/odata-parser": "^3.0.8",
|
35
35
|
"@balena/odata-to-abstract-sql": "^6.2.7",
|
36
|
-
"@balena/sbvr-parser": "^1.4.
|
36
|
+
"@balena/sbvr-parser": "^1.4.6",
|
37
37
|
"@balena/sbvr-types": "^7.1.3",
|
38
38
|
"@types/body-parser": "^1.19.5",
|
39
39
|
"@types/compression": "^1.7.5",
|
@@ -41,12 +41,12 @@
|
|
41
41
|
"@types/deep-freeze": "^0.1.5",
|
42
42
|
"@types/express": "^4.17.21",
|
43
43
|
"@types/express-session": "^1.18.0",
|
44
|
-
"@types/lodash": "^4.17.
|
44
|
+
"@types/lodash": "^4.17.7",
|
45
45
|
"@types/memoizee": "^0.4.11",
|
46
46
|
"@types/method-override": "^0.0.35",
|
47
47
|
"@types/multer": "^1.4.11",
|
48
48
|
"@types/mysql": "^2.15.26",
|
49
|
-
"@types/node": "^20.14.
|
49
|
+
"@types/node": "^20.14.13",
|
50
50
|
"@types/passport": "^1.0.16",
|
51
51
|
"@types/passport-local": "^1.0.38",
|
52
52
|
"@types/passport-strategy": "^0.2.38",
|
@@ -54,34 +54,34 @@
|
|
54
54
|
"@types/randomstring": "^1.3.0",
|
55
55
|
"@types/websql": "^0.0.30",
|
56
56
|
"busboy": "^1.6.0",
|
57
|
-
"commander": "^
|
57
|
+
"commander": "^11.1.0",
|
58
58
|
"deep-freeze": "^0.0.1",
|
59
59
|
"eventemitter3": "^5.0.1",
|
60
60
|
"express-session": "^1.18.0",
|
61
61
|
"lodash": "^4.17.21",
|
62
62
|
"memoizee": "^0.4.17",
|
63
|
-
"pinejs-client-core": "^6.15.
|
63
|
+
"pinejs-client-core": "^6.15.10",
|
64
64
|
"randomstring": "^1.3.0",
|
65
65
|
"typed-error": "^3.2.2"
|
66
66
|
},
|
67
67
|
"devDependencies": {
|
68
|
-
"@balena/lint": "^8.
|
68
|
+
"@balena/lint": "^8.2.7",
|
69
69
|
"@faker-js/faker": "^8.4.1",
|
70
70
|
"@types/busboy": "^1.5.4",
|
71
71
|
"@types/chai": "^4.3.16",
|
72
72
|
"@types/chai-as-promised": "^7.1.8",
|
73
73
|
"@types/grunt": "^0.4.31",
|
74
|
-
"@types/mocha": "^10.0.
|
74
|
+
"@types/mocha": "^10.0.7",
|
75
75
|
"@types/on-finished": "^2.3.4",
|
76
76
|
"@types/request": "^2.48.12",
|
77
77
|
"@types/supertest": "^6.0.2",
|
78
78
|
"@types/terser-webpack-plugin": "^5.2.0",
|
79
79
|
"@types/type-is": "^1.6.6",
|
80
80
|
"@types/webpack": "^5.28.5",
|
81
|
-
"chai": "^4.
|
81
|
+
"chai": "^4.5.0",
|
82
82
|
"grunt": "^1.6.1",
|
83
83
|
"grunt-check-dependencies": "^1.0.0",
|
84
|
-
"grunt-cli": "^1.
|
84
|
+
"grunt-cli": "^1.5.0",
|
85
85
|
"grunt-contrib-clean": "^2.0.1",
|
86
86
|
"grunt-contrib-concat": "^2.1.0",
|
87
87
|
"grunt-contrib-copy": "^1.0.0",
|
@@ -90,12 +90,12 @@
|
|
90
90
|
"grunt-text-replace": "^0.4.0",
|
91
91
|
"grunt-ts": "^6.0.0-beta.22",
|
92
92
|
"grunt-webpack": "^6.0.0",
|
93
|
-
"husky": "^9.
|
93
|
+
"husky": "^9.1.4",
|
94
94
|
"lint-staged": "^15.2.7",
|
95
95
|
"load-grunt-tasks": "^5.1.0",
|
96
|
-
"mocha": "^10.
|
96
|
+
"mocha": "^10.7.0",
|
97
97
|
"on-finished": "^2.4.1",
|
98
|
-
"pinejs-client-supertest": "^2.
|
98
|
+
"pinejs-client-supertest": "^2.1.1",
|
99
99
|
"raw-loader": "^4.0.2",
|
100
100
|
"request": "^2.88.2",
|
101
101
|
"require-npm4-to-publish": "^1.0.0",
|
@@ -103,14 +103,14 @@
|
|
103
103
|
"terser-webpack-plugin": "^5.3.10",
|
104
104
|
"ts-loader": "^9.5.1",
|
105
105
|
"ts-node": "^10.9.2",
|
106
|
-
"typescript": "^5.5.
|
107
|
-
"webpack": "^5.
|
106
|
+
"typescript": "^5.5.4",
|
107
|
+
"webpack": "^5.93.0",
|
108
108
|
"webpack-dev-server": "^4.15.2"
|
109
109
|
},
|
110
110
|
"optionalDependencies": {
|
111
|
-
"@aws-sdk/client-s3": "^3.
|
112
|
-
"@aws-sdk/lib-storage": "^3.
|
113
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
111
|
+
"@aws-sdk/client-s3": "^3.621.0",
|
112
|
+
"@aws-sdk/lib-storage": "^3.621.0",
|
113
|
+
"@aws-sdk/s3-request-presigner": "^3.621.0",
|
114
114
|
"bcrypt": "^5.1.1",
|
115
115
|
"body-parser": "^1.20.2",
|
116
116
|
"compression": "^1.7.4",
|
@@ -146,6 +146,6 @@
|
|
146
146
|
"recursive": true
|
147
147
|
},
|
148
148
|
"versionist": {
|
149
|
-
"publishedAt": "2024-07-
|
149
|
+
"publishedAt": "2024-07-31T17:38:43.051Z"
|
150
150
|
}
|
151
151
|
}
|
package/src/bin/utils.ts
CHANGED
@@ -92,7 +92,7 @@ export const getAbstractSqlModelFromFile = (
|
|
92
92
|
}
|
93
93
|
const configModel = getConfigModel(fileContents, modelName);
|
94
94
|
if ('abstractSql' in configModel && configModel.abstractSql != null) {
|
95
|
-
return configModel.abstractSql
|
95
|
+
return configModel.abstractSql;
|
96
96
|
} else if ('modelText' in configModel && configModel.modelText != null) {
|
97
97
|
seModel = configModel.modelText;
|
98
98
|
} else if ('modelFile' in configModel && configModel.modelFile != null) {
|
package/src/database-layer/db.ts
CHANGED
@@ -423,7 +423,7 @@ export abstract class Tx {
|
|
423
423
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
424
424
|
_namespaceKey: string,
|
425
425
|
_key: number,
|
426
|
-
_blocking
|
426
|
+
_blocking = true,
|
427
427
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
428
428
|
): Promise<boolean> {
|
429
429
|
throw new Error(
|
@@ -663,7 +663,7 @@ if (maybePg != null) {
|
|
663
663
|
public override async getTxLevelLock(
|
664
664
|
namespaceKey: string,
|
665
665
|
key: number,
|
666
|
-
blocking
|
666
|
+
blocking = true,
|
667
667
|
) {
|
668
668
|
validateTransactionLockParameter(key, 'key');
|
669
669
|
const namespaceId = transactionLockNamespaceMap[namespaceKey];
|
@@ -693,7 +693,7 @@ if (maybePg != null) {
|
|
693
693
|
}
|
694
694
|
}
|
695
695
|
|
696
|
-
public async tableList(extraWhereClause
|
696
|
+
public async tableList(extraWhereClause = '') {
|
697
697
|
if (extraWhereClause !== '') {
|
698
698
|
extraWhereClause = 'WHERE ' + extraWhereClause;
|
699
699
|
}
|
@@ -811,7 +811,7 @@ if (maybeMysql != null) {
|
|
811
811
|
await promise;
|
812
812
|
}
|
813
813
|
|
814
|
-
public async tableList(extraWhereClause
|
814
|
+
public async tableList(extraWhereClause = '') {
|
815
815
|
if (extraWhereClause !== '') {
|
816
816
|
extraWhereClause = ' WHERE ' + extraWhereClause;
|
817
817
|
}
|
@@ -834,14 +834,18 @@ if (maybeMysql != null) {
|
|
834
834
|
executeSql: atomicExecuteSql,
|
835
835
|
transaction: createTransaction(async (stackTraceErr, timeoutMS) => {
|
836
836
|
const client = await getConnectionAsync();
|
837
|
-
const close = () =>
|
837
|
+
const close = () => {
|
838
|
+
client.release();
|
839
|
+
};
|
838
840
|
const tx = new MySqlTx(client, close, false, stackTraceErr, timeoutMS);
|
839
841
|
void tx.executeSql('START TRANSACTION;');
|
840
842
|
return tx;
|
841
843
|
}),
|
842
844
|
readTransaction: createTransaction(async (stackTraceErr, timeoutMS) => {
|
843
845
|
const client = await getConnectionAsync();
|
844
|
-
const close = () =>
|
846
|
+
const close = () => {
|
847
|
+
client.release();
|
848
|
+
};
|
845
849
|
const tx = new MySqlTx(client, close, false, stackTraceErr, timeoutMS);
|
846
850
|
void tx.executeSql('START TRANSACTION READ ONLY;');
|
847
851
|
return tx.asReadOnly();
|
@@ -926,14 +930,14 @@ if (typeof window !== 'undefined' && window.openDatabase != null) {
|
|
926
930
|
}
|
927
931
|
|
928
932
|
protected async _rollback(): Promise<void> {
|
929
|
-
|
933
|
+
await this.tx.rollback();
|
930
934
|
}
|
931
935
|
|
932
936
|
protected async _commit() {
|
933
937
|
this.tx.commit();
|
934
938
|
}
|
935
939
|
|
936
|
-
public async tableList(extraWhereClause
|
940
|
+
public async tableList(extraWhereClause = '') {
|
937
941
|
if (extraWhereClause !== '') {
|
938
942
|
extraWhereClause = ' AND ' + extraWhereClause;
|
939
943
|
}
|
@@ -987,7 +991,7 @@ if (typeof window !== 'undefined' && window.openDatabase != null) {
|
|
987
991
|
}
|
988
992
|
|
989
993
|
public async rollback(): Promise<void> {
|
990
|
-
|
994
|
+
await new Promise<void>((resolve) => {
|
991
995
|
const successCallback: SQLStatementCallback = () => {
|
992
996
|
resolve();
|
993
997
|
throw new Error('Rollback');
|
@@ -80,7 +80,7 @@ const app = (function () {
|
|
80
80
|
},
|
81
81
|
};
|
82
82
|
console.log(method, uri, body);
|
83
|
-
if (uri.
|
83
|
+
if (uri.endsWith('/')) {
|
84
84
|
uri = uri.slice(0, uri.length - 1);
|
85
85
|
}
|
86
86
|
uri = uri.toLowerCase();
|
@@ -142,10 +142,7 @@ const app = (function () {
|
|
142
142
|
const checkMethodHandlers = () => {
|
143
143
|
i++;
|
144
144
|
if (i < methodHandlers.length) {
|
145
|
-
if (
|
146
|
-
uri.slice(0, methodHandlers[i].match.length) ===
|
147
|
-
methodHandlers[i].match
|
148
|
-
) {
|
145
|
+
if (uri.startsWith(methodHandlers[i].match)) {
|
149
146
|
j = -1;
|
150
147
|
// Reset params that may have been added on previous routes that failed in middleware
|
151
148
|
req.params = {};
|
@@ -12,11 +12,7 @@ export const mountLoginRouter = async (
|
|
12
12
|
configLoader.loadConfig(PinejsSessionStore.config),
|
13
13
|
]);
|
14
14
|
|
15
|
-
if (
|
16
|
-
typeof process === 'undefined' ||
|
17
|
-
process == null ||
|
18
|
-
!process.env.DISABLE_DEFAULT_AUTH
|
19
|
-
) {
|
15
|
+
if (typeof process === 'undefined' || !process?.env.DISABLE_DEFAULT_AUTH) {
|
20
16
|
expressApp.post(
|
21
17
|
'/login',
|
22
18
|
passportPinejs.login((err, user, req, res) => {
|
@@ -68,7 +68,8 @@ const setup: ConfigLoader.SetupFunction = (app: Express.Application) => {
|
|
68
68
|
logout = (req, _res, next) => {
|
69
69
|
req.logout((error) => {
|
70
70
|
if (error) {
|
71
|
-
|
71
|
+
next(error);
|
72
|
+
return;
|
72
73
|
}
|
73
74
|
next();
|
74
75
|
});
|
@@ -83,7 +84,7 @@ const setup: ConfigLoader.SetupFunction = (app: Express.Application) => {
|
|
83
84
|
next();
|
84
85
|
});
|
85
86
|
|
86
|
-
login = (fn) => (req, res, next) =>
|
87
|
+
login = (fn) => (req, res, next) => {
|
87
88
|
checkPassword(req.body.username, req.body.password, (err, user) => {
|
88
89
|
if (user) {
|
89
90
|
loggedIn = true;
|
@@ -91,6 +92,7 @@ const setup: ConfigLoader.SetupFunction = (app: Express.Application) => {
|
|
91
92
|
}
|
92
93
|
fn(err, user, req, res, next);
|
93
94
|
});
|
95
|
+
};
|
94
96
|
|
95
97
|
logout = (req, _res, next) => {
|
96
98
|
delete req.user;
|
@@ -77,7 +77,7 @@ export const getAndCheckBindValues = async (
|
|
77
77
|
const sqlModelTables = sbvrUtils.getAbstractSqlModel(request).tables;
|
78
78
|
return await Promise.all(
|
79
79
|
bindings.map(async (binding) => {
|
80
|
-
let fieldName
|
80
|
+
let fieldName = '';
|
81
81
|
let field: { dataType: string };
|
82
82
|
let value: any;
|
83
83
|
if (binding[0] === 'Bind') {
|
package/src/sbvr-api/hooks.ts
CHANGED
@@ -101,7 +101,7 @@ class Hook<T extends HookFn> {
|
|
101
101
|
|
102
102
|
class SideEffectHook<T extends HookFn> extends Hook<T> {
|
103
103
|
private rollbackFns: RollbackAction[] = [];
|
104
|
-
private rolledBack
|
104
|
+
private rolledBack = false;
|
105
105
|
|
106
106
|
public registerRollback(fn: RollbackAction): void {
|
107
107
|
if (this.rolledBack) {
|
@@ -243,7 +243,9 @@ export const getHooks = (
|
|
243
243
|
),
|
244
244
|
);
|
245
245
|
};
|
246
|
-
getHooks.clear = () =>
|
246
|
+
getHooks.clear = () => {
|
247
|
+
getMethodHooks.clear();
|
248
|
+
};
|
247
249
|
|
248
250
|
interface VocabHooks {
|
249
251
|
[resourceName: string]: HookBlueprints;
|
@@ -339,7 +341,7 @@ export const addHook = <Vocab extends string>(
|
|
339
341
|
const hook = hooks[hookType];
|
340
342
|
resourceHooks[hookType] ??= [];
|
341
343
|
if (hook != null) {
|
342
|
-
resourceHooks[hookType]
|
344
|
+
resourceHooks[hookType].push(hook);
|
343
345
|
}
|
344
346
|
}
|
345
347
|
|
@@ -334,12 +334,7 @@ const getPermissionsLookup = env.createCache(
|
|
334
334
|
permissionsLookup[target] = true;
|
335
335
|
} else if (permissionsLookup[target] !== true) {
|
336
336
|
permissionsLookup[target] ??= [];
|
337
|
-
(
|
338
|
-
permissionsLookup[target] as Exclude<
|
339
|
-
PermissionLookup[typeof target],
|
340
|
-
true
|
341
|
-
>
|
342
|
-
).push(condition);
|
337
|
+
permissionsLookup[target].push(condition);
|
343
338
|
}
|
344
339
|
}
|
345
340
|
// Ensure there are no duplicate conditions as applying both would be wasteful
|
@@ -946,7 +941,7 @@ const rewriteRelationships = (
|
|
946
941
|
);
|
947
942
|
|
948
943
|
const newRelationships = _.cloneDeep(relationships);
|
949
|
-
_.forOwn(newRelationships, (value, name) =>
|
944
|
+
_.forOwn(newRelationships, (value, name) => {
|
950
945
|
rewriteRelationship(
|
951
946
|
value,
|
952
947
|
name,
|
@@ -954,8 +949,8 @@ const rewriteRelationships = (
|
|
954
949
|
permissionsLookup,
|
955
950
|
vocabulary,
|
956
951
|
odata2AbstractSQL,
|
957
|
-
)
|
958
|
-
);
|
952
|
+
);
|
953
|
+
});
|
959
954
|
|
960
955
|
return newRelationships;
|
961
956
|
};
|
@@ -1640,7 +1635,7 @@ const getReqPermissions = async (
|
|
1640
1635
|
if (req.user?.permissions != null) {
|
1641
1636
|
addActorPermissions(req.user.actor, req.user.permissions);
|
1642
1637
|
} else if (req.apiKey?.permissions != null) {
|
1643
|
-
addActorPermissions(req.apiKey.actor
|
1638
|
+
addActorPermissions(req.apiKey.actor, req.apiKey.permissions);
|
1644
1639
|
}
|
1645
1640
|
|
1646
1641
|
return getPermissionsLookup(actorPermissions, guestPermissions);
|
@@ -209,7 +209,7 @@ const memoizedResolveNavigationResource = memoizeWeak(
|
|
209
209
|
const mapping = _.get(
|
210
210
|
abstractSqlModel.relationships[resolvedResourceName],
|
211
211
|
navigation,
|
212
|
-
)
|
212
|
+
);
|
213
213
|
if (mapping == null) {
|
214
214
|
throw new Error(
|
215
215
|
`Cannot navigate from '${resourceName}' to '${navigationName}'`,
|
@@ -701,7 +701,7 @@ export const executeModels = async (
|
|
701
701
|
compiledModels.map(async (model: CompiledModel) => {
|
702
702
|
const updateModel = async (modelType: keyof CompiledModel) => {
|
703
703
|
if (model[modelType] == null) {
|
704
|
-
|
704
|
+
await api.dev.delete({
|
705
705
|
resource: 'model',
|
706
706
|
passthrough: {
|
707
707
|
tx,
|
@@ -714,6 +714,7 @@ export const executeModels = async (
|
|
714
714
|
},
|
715
715
|
},
|
716
716
|
});
|
717
|
+
return;
|
717
718
|
}
|
718
719
|
const result = await api.dev.get({
|
719
720
|
resource: 'model',
|
@@ -1054,7 +1055,7 @@ export class PinejsClient<
|
|
1054
1055
|
url: NonNullable<Params<T>['url']>;
|
1055
1056
|
} & Params<T>,
|
1056
1057
|
): Promise<AnyObject>;
|
1057
|
-
public post(params: Params
|
1058
|
+
public post(params: Params): Promise<AnyObject> {
|
1058
1059
|
return super.post(params as Parameters<PinejsClient['post']>[0]);
|
1059
1060
|
}
|
1060
1061
|
}
|
@@ -1458,7 +1459,8 @@ export const getApiRoot = (req: Express.Request): string | undefined => {
|
|
1458
1459
|
export const handleODataRequest: Express.Handler = async (req, res, next) => {
|
1459
1460
|
const apiRoot = getApiRoot(req);
|
1460
1461
|
if (apiRoot == null || models[apiRoot] == null) {
|
1461
|
-
|
1462
|
+
next('route');
|
1463
|
+
return;
|
1462
1464
|
}
|
1463
1465
|
|
1464
1466
|
try {
|
@@ -1521,7 +1523,7 @@ export const handleHttpErrors = (
|
|
1521
1523
|
return false;
|
1522
1524
|
};
|
1523
1525
|
const handleResponse = (res: Express.Response, response: Response): void => {
|
1524
|
-
const { body, headers, statusCode } = response
|
1526
|
+
const { body, headers, statusCode } = response;
|
1525
1527
|
res.set(headers);
|
1526
1528
|
res.status(statusCode);
|
1527
1529
|
if (!body) {
|
@@ -1751,7 +1753,7 @@ const runQuery = async (
|
|
1751
1753
|
tx: Db.Tx,
|
1752
1754
|
request: uriParser.ODataRequest,
|
1753
1755
|
queryIndex?: number,
|
1754
|
-
addReturning
|
1756
|
+
addReturning = false,
|
1755
1757
|
): Promise<Db.Result> => {
|
1756
1758
|
const { vocabulary } = request;
|
1757
1759
|
let { sqlQuery } = request;
|
@@ -208,7 +208,7 @@ export const translateAbstractSqlModel = (
|
|
208
208
|
const { $toResource, ...definition } = translationDefinition;
|
209
209
|
const hasToResource = typeof $toResource === 'string';
|
210
210
|
if (hasToResource) {
|
211
|
-
resourceRenames[key] =
|
211
|
+
resourceRenames[key] = $toResource;
|
212
212
|
}
|
213
213
|
const toResource = hasToResource ? $toResource : `${key}$${toVersion}`;
|
214
214
|
// TODO: Should this use the toAbstractSqlModel?
|
@@ -282,7 +282,7 @@ export function parseOData(
|
|
282
282
|
// We sort the CS set once, we must assure that requests which reference
|
283
283
|
// other requests in the changeset are placed last. Once they are sorted
|
284
284
|
// Map will guarantee retrival of results in insertion order
|
285
|
-
const sortedCS = _.sortBy(b.changeSet, (el) => el.url
|
285
|
+
const sortedCS = _.sortBy(b.changeSet, (el) => !el.url.startsWith('/'));
|
286
286
|
const csReferences = new Map<
|
287
287
|
ParsedODataRequest['id'],
|
288
288
|
ParsedODataRequest
|
@@ -338,7 +338,7 @@ const parseODataChangeset = (
|
|
338
338
|
let apiRoot: string;
|
339
339
|
let url;
|
340
340
|
|
341
|
-
if (b.url
|
341
|
+
if (b.url.startsWith('/')) {
|
342
342
|
({ url, apiRoot } = splitApiRoot(b.url));
|
343
343
|
odata = memoizedParseOdata(url);
|
344
344
|
defer = false;
|
@@ -116,7 +116,8 @@ export const getUploaderMiddlware = (
|
|
116
116
|
): Express.RequestHandler => {
|
117
117
|
return (req, res, next) => {
|
118
118
|
if (!req.is('multipart')) {
|
119
|
-
|
119
|
+
next();
|
120
|
+
return;
|
120
121
|
}
|
121
122
|
const uploadedFilePaths: string[] = [];
|
122
123
|
const completeUploads: Array<Promise<void>> = [];
|