@balena/pinejs 15.0.0-delete-state-default-user-permissions-8b5de27c634f2e7581f0bcf3600066d2fe4bbf40 → 15.0.0-deprecate-node12-8a99d72ae66d7708293afc56c5d7eb19b39081cd

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/.resinci.yml +0 -1
  2. package/.versionbot/CHANGELOG.yml +158 -9
  3. package/CHANGELOG.md +57 -2
  4. package/out/bin/utils.js +1 -1
  5. package/out/bin/utils.js.map +1 -1
  6. package/out/config-loader/config-loader.d.ts +1 -1
  7. package/out/config-loader/config-loader.js +10 -28
  8. package/out/config-loader/config-loader.js.map +1 -1
  9. package/out/data-server/sbvr-server.js +8 -8
  10. package/out/data-server/sbvr-server.js.map +1 -1
  11. package/out/database-layer/db.d.ts +1 -1
  12. package/out/database-layer/db.js +3 -3
  13. package/out/database-layer/db.js.map +1 -1
  14. package/out/express-emulator/express.js +1 -1
  15. package/out/express-emulator/express.js.map +1 -1
  16. package/out/http-transactions/transactions.js +4 -4
  17. package/out/http-transactions/transactions.js.map +1 -1
  18. package/out/migrator/sync.js +6 -6
  19. package/out/migrator/sync.js.map +1 -1
  20. package/out/migrator/utils.d.ts +2 -2
  21. package/out/migrator/utils.js +16 -17
  22. package/out/migrator/utils.js.map +1 -1
  23. package/out/odata-metadata/odata-metadata-generator.js +6 -9
  24. package/out/odata-metadata/odata-metadata-generator.js.map +1 -1
  25. package/out/passport-pinejs/passport-pinejs.js +1 -1
  26. package/out/passport-pinejs/passport-pinejs.js.map +1 -1
  27. package/out/pinejs-session-store/pinejs-session-store.js +1 -1
  28. package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
  29. package/out/sbvr-api/abstract-sql.d.ts +1 -1
  30. package/out/sbvr-api/abstract-sql.js.map +1 -1
  31. package/out/sbvr-api/control-flow.js.map +1 -1
  32. package/out/sbvr-api/hooks.d.ts +6 -3
  33. package/out/sbvr-api/hooks.js +3 -3
  34. package/out/sbvr-api/hooks.js.map +1 -1
  35. package/out/sbvr-api/odata-response.js +5 -5
  36. package/out/sbvr-api/odata-response.js.map +1 -1
  37. package/out/sbvr-api/permissions.js +25 -20
  38. package/out/sbvr-api/permissions.js.map +1 -1
  39. package/out/sbvr-api/sbvr-utils.d.ts +4 -3
  40. package/out/sbvr-api/sbvr-utils.js +68 -45
  41. package/out/sbvr-api/sbvr-utils.js.map +1 -1
  42. package/out/sbvr-api/uri-parser.d.ts +13 -11
  43. package/out/sbvr-api/uri-parser.js +4 -4
  44. package/out/sbvr-api/uri-parser.js.map +1 -1
  45. package/out/server-glue/module.js.map +1 -1
  46. package/package.json +13 -13
  47. package/src/bin/utils.ts +1 -1
  48. package/src/config-loader/config-loader.ts +15 -35
  49. package/src/data-server/sbvr-server.js +8 -8
  50. package/src/database-layer/db.ts +11 -11
  51. package/src/express-emulator/express.js +1 -1
  52. package/src/http-transactions/transactions.js +4 -4
  53. package/src/migrator/sync.ts +9 -11
  54. package/src/migrator/utils.ts +18 -24
  55. package/src/odata-metadata/odata-metadata-generator.ts +8 -11
  56. package/src/sbvr-api/abstract-sql.ts +6 -3
  57. package/src/sbvr-api/control-flow.ts +2 -2
  58. package/src/sbvr-api/hooks.ts +18 -8
  59. package/src/sbvr-api/odata-response.ts +4 -4
  60. package/src/sbvr-api/permissions.ts +42 -36
  61. package/src/sbvr-api/sbvr-utils.ts +118 -55
  62. package/src/sbvr-api/uri-parser.ts +29 -21
  63. package/src/server-glue/module.ts +1 -1
  64. package/tsconfig.json +1 -3
  65. package/typings/lf-to-abstract-sql.d.ts +6 -9
@@ -37,20 +37,22 @@ export interface UnparsedRequest {
37
37
  _isChangeSet?: boolean;
38
38
  }
39
39
 
40
- export interface ODataRequest {
40
+ export interface ParsedODataRequest {
41
41
  method: SupportedMethod;
42
42
  url: string;
43
+ vocabulary: string;
44
+ resourceName: string;
45
+ values: AnyObject;
43
46
  odataQuery: ODataQuery;
44
47
  odataBinds: OdataBinds;
45
- values: AnyObject;
48
+ custom: AnyObject;
49
+ id?: number | undefined;
50
+ _defer?: boolean;
51
+ }
52
+ export interface ODataRequest extends ParsedODataRequest {
46
53
  abstractSqlModel?: AbstractSQLCompiler.AbstractSqlModel;
47
54
  abstractSqlQuery?: AbstractSQLCompiler.AbstractSqlQuery;
48
55
  sqlQuery?: AbstractSQLCompiler.SqlResult | AbstractSQLCompiler.SqlResult[];
49
- resourceName: string;
50
- vocabulary: string;
51
- _defer?: boolean;
52
- id?: number | undefined;
53
- custom: AnyObject;
54
56
  tx?: Tx;
55
57
  modifiedFields?: ReturnType<
56
58
  AbstractSQLCompiler.EngineInstance['getModifiedFields']
@@ -58,7 +60,7 @@ export interface ODataRequest {
58
60
  affectedIds?: number[];
59
61
  pendingAffectedIds?: Promise<number[]>;
60
62
  hooks?: InstantiatedHooks;
61
- engine?: AbstractSQLCompiler.Engines;
63
+ engine: AbstractSQLCompiler.Engines;
62
64
  }
63
65
 
64
66
  // Converts a value to its string representation and tries to parse is as an
@@ -96,12 +98,12 @@ export const memoizedParseOdata = (() => {
96
98
  // Try to cache based on parameter aliases if there might be some
97
99
  const parameterAliases = new URLSearchParams();
98
100
  const queryParams = new URLSearchParams(url.slice(queryParamsIndex));
99
- Array.from(queryParams.entries()).forEach(([key, value]) => {
101
+ for (const [key, value] of Array.from(queryParams.entries())) {
100
102
  if (key.startsWith('@')) {
101
103
  parameterAliases.append(key, value);
102
104
  queryParams.delete(key);
103
105
  }
104
- });
106
+ }
105
107
  const parameterAliasesString = parameterAliases.toString();
106
108
  if (parameterAliasesString !== '') {
107
109
  const parsed = _.cloneDeep(
@@ -257,23 +259,26 @@ export const metadataEndpoints = ['$metadata', '$serviceroot'];
257
259
 
258
260
  export async function parseOData(
259
261
  b: UnparsedRequest & { _isChangeSet?: false },
260
- ): Promise<ODataRequest>;
262
+ ): Promise<ParsedODataRequest>;
261
263
  export async function parseOData(
262
264
  b: UnparsedRequest & { _isChangeSet: true },
263
- ): Promise<ODataRequest[]>;
265
+ ): Promise<ParsedODataRequest[]>;
264
266
  export async function parseOData(
265
267
  b: UnparsedRequest,
266
- ): Promise<ODataRequest | ODataRequest[]>;
268
+ ): Promise<ParsedODataRequest | ParsedODataRequest[]>;
267
269
  export async function parseOData(
268
270
  b: UnparsedRequest,
269
- ): Promise<ODataRequest | ODataRequest[]> {
271
+ ): Promise<ParsedODataRequest | ParsedODataRequest[]> {
270
272
  try {
271
273
  if (b._isChangeSet && b.changeSet != null) {
272
274
  // We sort the CS set once, we must assure that requests which reference
273
275
  // other requests in the changeset are placed last. Once they are sorted
274
276
  // Map will guarantee retrival of results in insertion order
275
277
  const sortedCS = _.sortBy(b.changeSet, (el) => el.url[0] !== '/');
276
- const csReferences = new Map<ODataRequest['id'], ODataRequest>();
278
+ const csReferences = new Map<
279
+ ParsedODataRequest['id'],
280
+ ParsedODataRequest
281
+ >();
277
282
  for (const cs of sortedCS) {
278
283
  parseODataChangeset(csReferences, cs);
279
284
  }
@@ -287,14 +292,14 @@ export async function parseOData(
287
292
  url,
288
293
  vocabulary: apiRoot,
289
294
  resourceName: odata.tree.resource,
290
- odataBinds: odata.binds,
291
- odataQuery: odata.tree,
292
295
  values: b.data ?? {},
296
+ odataQuery: odata.tree,
297
+ odataBinds: odata.binds,
293
298
  custom: {},
294
299
  _defer: false,
295
300
  };
296
301
  }
297
- } catch (err) {
302
+ } catch (err: any) {
298
303
  if (err instanceof ODataParser.SyntaxError) {
299
304
  throw new BadRequestError(`Malformed url: '${b.url}'`);
300
305
  }
@@ -307,10 +312,13 @@ export async function parseOData(
307
312
  }
308
313
 
309
314
  const parseODataChangeset = (
310
- csReferences: Map<ODataRequest['id'], ODataRequest>,
315
+ csReferences: Map<ParsedODataRequest['id'], ParsedODataRequest>,
311
316
  b: UnparsedRequest,
312
317
  ): void => {
313
- const contentId: ODataRequest['id'] = mustExtractHeader(b, 'content-id');
318
+ const contentId: ParsedODataRequest['id'] = mustExtractHeader(
319
+ b,
320
+ 'content-id',
321
+ );
314
322
 
315
323
  if (csReferences.has(contentId)) {
316
324
  throw new BadRequestError('Content-Id must be unique inside a changeset');
@@ -341,7 +349,7 @@ const parseODataChangeset = (
341
349
  defer = true;
342
350
  }
343
351
 
344
- const parseResult: ODataRequest = {
352
+ const parseResult: ParsedODataRequest = {
345
353
  method: b.method as SupportedMethod,
346
354
  url,
347
355
  vocabulary: apiRoot,
@@ -73,7 +73,7 @@ export const init = async <T extends string>(
73
73
  await Promise.all(promises);
74
74
 
75
75
  return cfgLoader;
76
- } catch (err) {
76
+ } catch (err: any) {
77
77
  console.error('Error initialising server', err, err.stack);
78
78
  process.exit(1);
79
79
  }
package/tsconfig.json CHANGED
@@ -3,8 +3,6 @@
3
3
  "module": "commonjs",
4
4
  "strict": true,
5
5
  "strictFunctionTypes": false,
6
- "strictPropertyInitialization": false,
7
- "useUnknownInCatchVariables": false,
8
6
  "noImplicitThis": false,
9
7
  "noUnusedParameters": true,
10
8
  "noUnusedLocals": true,
@@ -13,7 +11,7 @@
13
11
  "removeComments": true,
14
12
  "rootDir": "src",
15
13
  "sourceMap": true,
16
- "target": "es2018",
14
+ "target": "es2019",
17
15
  "declaration": true,
18
16
  "skipLibCheck": true,
19
17
  "resolveJsonModule": true,
@@ -1,22 +1,19 @@
1
1
  declare module '@balena/lf-to-abstract-sql' {
2
+ import type sbvrTypes = require('@balena/sbvr-types');
3
+ import type { LFModel } from '@balena/sbvr-parser';
4
+ import type { AbstractSqlModel } from '@balena/abstract-sql-compiler';
2
5
  export const LF2AbstractSQL: {
3
6
  createInstance: () => {
4
- match: (
5
- lfModel: LFModel,
6
- rule: 'Process',
7
- ) => AbstractSQLCompiler.AbstractSqlModel;
7
+ match: (lfModel: LFModel, rule: 'Process') => AbstractSqlModel;
8
8
  addTypes: (types: typeof sbvrTypes) => void;
9
9
  reset: () => void;
10
10
  };
11
11
  };
12
12
  export const LF2AbstractSQLPrep: {
13
13
  match: (lfModel: LFModel, rule: 'Process') => LFModel;
14
- _extend({}): typeof LF2AbstractSQL.LF2AbstractSQLPrep;
14
+ _extend({}): typeof LF2AbstractSQLPrep;
15
15
  };
16
16
  export const createTranslator: (
17
17
  types: typeof sbvrTypes,
18
- ) => (
19
- lfModel: LFModel,
20
- rule: 'Process',
21
- ) => AbstractSQLCompiler.AbstractSqlModel;
18
+ ) => (lfModel: LFModel, rule: 'Process') => AbstractSqlModel;
22
19
  }