@balena/pinejs 19.7.2-build-esm-36f468424324d7ef7578ae401fc681c9f8f63e03-3 → 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.
Files changed (168) hide show
  1. package/.versionbot/CHANGELOG.yml +3 -3
  2. package/CHANGELOG.md +1 -1
  3. package/{Gruntfile.cts → Gruntfile.ts} +22 -9
  4. package/bin/abstract-sql-compiler.js +1 -1
  5. package/bin/odata-compiler.js +1 -1
  6. package/bin/sbvr-compiler.js +1 -1
  7. package/build/{browser.cts → browser.ts} +1 -1
  8. package/build/{config.cts → config.ts} +1 -5
  9. package/build/{module.cts → module.ts} +1 -1
  10. package/build/{server.cts → server.ts} +1 -1
  11. package/out/bin/abstract-sql-compiler.js +19 -17
  12. package/out/bin/abstract-sql-compiler.js.map +1 -1
  13. package/out/bin/odata-compiler.js +21 -19
  14. package/out/bin/odata-compiler.js.map +1 -1
  15. package/out/bin/sbvr-compiler.js +54 -19
  16. package/out/bin/sbvr-compiler.js.map +1 -1
  17. package/out/bin/utils.d.ts +3 -3
  18. package/out/bin/utils.js +53 -21
  19. package/out/bin/utils.js.map +1 -1
  20. package/out/config-loader/config-loader.d.ts +7 -7
  21. package/out/config-loader/config-loader.js +63 -23
  22. package/out/config-loader/config-loader.js.map +1 -1
  23. package/out/config-loader/env.d.ts +1 -1
  24. package/out/config-loader/env.js +66 -24
  25. package/out/config-loader/env.js.map +1 -1
  26. package/out/data-server/sbvr-server.d.ts +3 -3
  27. package/out/data-server/sbvr-server.js +42 -5
  28. package/out/data-server/sbvr-server.js.map +1 -1
  29. package/out/database-layer/db.d.ts +3 -3
  30. package/out/database-layer/db.js +83 -37
  31. package/out/database-layer/db.js.map +1 -1
  32. package/out/express-emulator/express.js.map +1 -1
  33. package/out/extended-sbvr-parser/extended-sbvr-parser.js +11 -8
  34. package/out/extended-sbvr-parser/extended-sbvr-parser.js.map +1 -1
  35. package/out/http-transactions/transactions.d.ts +2 -2
  36. package/out/http-transactions/transactions.js +4 -4
  37. package/out/http-transactions/transactions.js.map +1 -1
  38. package/out/migrator/async.d.ts +2 -2
  39. package/out/migrator/async.js +60 -20
  40. package/out/migrator/async.js.map +1 -1
  41. package/out/migrator/migrations.js +2 -1
  42. package/out/migrator/sync.d.ts +6 -6
  43. package/out/migrator/sync.js +61 -20
  44. package/out/migrator/sync.js.map +1 -1
  45. package/out/migrator/utils.d.ts +4 -4
  46. package/out/migrator/utils.js +97 -42
  47. package/out/migrator/utils.js.map +1 -1
  48. package/out/odata-metadata/odata-metadata-generator.js +14 -7
  49. package/out/odata-metadata/odata-metadata-generator.js.map +1 -1
  50. package/out/passport-pinejs/mount-login-router.d.ts +1 -1
  51. package/out/passport-pinejs/mount-login-router.js +41 -4
  52. package/out/passport-pinejs/mount-login-router.js.map +1 -1
  53. package/out/passport-pinejs/passport-pinejs.d.ts +3 -3
  54. package/out/passport-pinejs/passport-pinejs.js +46 -11
  55. package/out/passport-pinejs/passport-pinejs.js.map +1 -1
  56. package/out/pinejs-session-store/pinejs-session-store.d.ts +1 -1
  57. package/out/pinejs-session-store/pinejs-session-store.js +48 -11
  58. package/out/pinejs-session-store/pinejs-session-store.js.map +1 -1
  59. package/out/sbvr-api/abstract-sql.d.ts +3 -3
  60. package/out/sbvr-api/abstract-sql.js +65 -22
  61. package/out/sbvr-api/abstract-sql.js.map +1 -1
  62. package/out/sbvr-api/cached-compile.js +15 -8
  63. package/out/sbvr-api/cached-compile.js.map +1 -1
  64. package/out/sbvr-api/common-types.js +2 -1
  65. package/out/sbvr-api/control-flow.d.ts +1 -1
  66. package/out/sbvr-api/control-flow.js +25 -12
  67. package/out/sbvr-api/control-flow.js.map +1 -1
  68. package/out/sbvr-api/dev.js +2 -1
  69. package/out/sbvr-api/errors.d.ts +1 -1
  70. package/out/sbvr-api/errors.js +95 -47
  71. package/out/sbvr-api/errors.js.map +1 -1
  72. package/out/sbvr-api/express-extension.d.ts +2 -2
  73. package/out/sbvr-api/express-extension.js +2 -1
  74. package/out/sbvr-api/hooks.d.ts +4 -4
  75. package/out/sbvr-api/hooks.js +35 -23
  76. package/out/sbvr-api/hooks.js.map +1 -1
  77. package/out/sbvr-api/odata-response.d.ts +2 -2
  78. package/out/sbvr-api/odata-response.js +29 -19
  79. package/out/sbvr-api/odata-response.js.map +1 -1
  80. package/out/sbvr-api/permissions.d.ts +9 -9
  81. package/out/sbvr-api/permissions.js +159 -106
  82. package/out/sbvr-api/permissions.js.map +1 -1
  83. package/out/sbvr-api/sbvr-utils.d.ts +18 -40
  84. package/out/sbvr-api/sbvr-utils.js +285 -222
  85. package/out/sbvr-api/sbvr-utils.js.map +1 -1
  86. package/out/sbvr-api/translations.d.ts +1 -1
  87. package/out/sbvr-api/translations.js +17 -10
  88. package/out/sbvr-api/translations.js.map +1 -1
  89. package/out/sbvr-api/uri-parser.d.ts +7 -7
  90. package/out/sbvr-api/uri-parser.js +84 -39
  91. package/out/sbvr-api/uri-parser.js.map +1 -1
  92. package/out/sbvr-api/user.js +2 -1
  93. package/out/server-glue/global-ext.d.ts +3 -0
  94. package/out/server-glue/module.d.ts +16 -16
  95. package/out/server-glue/module.js +59 -20
  96. package/out/server-glue/module.js.map +1 -1
  97. package/out/server-glue/sbvr-loader.d.ts +1 -2
  98. package/out/server-glue/sbvr-loader.js +11 -4
  99. package/out/server-glue/sbvr-loader.js.map +1 -1
  100. package/out/server-glue/server.d.ts +2 -2
  101. package/out/server-glue/server.js +59 -17
  102. package/out/server-glue/server.js.map +1 -1
  103. package/out/tasks/common.d.ts +1 -1
  104. package/out/tasks/common.js +9 -3
  105. package/out/tasks/common.js.map +1 -1
  106. package/out/tasks/index.d.ts +8 -8
  107. package/out/tasks/index.js +63 -25
  108. package/out/tasks/index.js.map +1 -1
  109. package/out/tasks/tasks.js +2 -1
  110. package/out/tasks/worker.d.ts +3 -3
  111. package/out/tasks/worker.js +51 -14
  112. package/out/tasks/worker.js.map +1 -1
  113. package/out/webresource-handler/handlers/NoopHandler.d.ts +1 -1
  114. package/out/webresource-handler/handlers/NoopHandler.js +5 -1
  115. package/out/webresource-handler/handlers/NoopHandler.js.map +1 -1
  116. package/out/webresource-handler/handlers/S3Handler.d.ts +1 -1
  117. package/out/webresource-handler/handlers/S3Handler.js +24 -17
  118. package/out/webresource-handler/handlers/S3Handler.js.map +1 -1
  119. package/out/webresource-handler/handlers/index.d.ts +2 -2
  120. package/out/webresource-handler/handlers/index.js +18 -2
  121. package/out/webresource-handler/handlers/index.js.map +1 -1
  122. package/out/webresource-handler/index.d.ts +3 -3
  123. package/out/webresource-handler/index.js +85 -35
  124. package/out/webresource-handler/index.js.map +1 -1
  125. package/package.json +33 -33
  126. package/src/bin/abstract-sql-compiler.ts +3 -3
  127. package/src/bin/odata-compiler.ts +3 -3
  128. package/src/bin/sbvr-compiler.ts +2 -2
  129. package/src/bin/utils.ts +15 -23
  130. package/src/config-loader/config-loader.ts +12 -12
  131. package/src/config-loader/env.ts +3 -3
  132. package/src/data-server/sbvr-server.ts +4 -4
  133. package/src/database-layer/db.ts +11 -18
  134. package/src/extended-sbvr-parser/extended-sbvr-parser.ts +5 -5
  135. package/src/http-transactions/transactions.js +4 -4
  136. package/src/migrator/async.ts +5 -5
  137. package/src/migrator/sync.ts +8 -8
  138. package/src/migrator/utils.ts +7 -7
  139. package/src/odata-metadata/odata-metadata-generator.ts +2 -3
  140. package/src/passport-pinejs/mount-login-router.ts +3 -3
  141. package/src/passport-pinejs/passport-pinejs.ts +6 -6
  142. package/src/pinejs-session-store/pinejs-session-store.ts +4 -4
  143. package/src/sbvr-api/abstract-sql.ts +6 -6
  144. package/src/sbvr-api/cached-compile.ts +2 -2
  145. package/src/sbvr-api/control-flow.ts +1 -1
  146. package/src/sbvr-api/errors.ts +1 -1
  147. package/src/sbvr-api/express-extension.ts +2 -2
  148. package/src/sbvr-api/hooks.ts +5 -5
  149. package/src/sbvr-api/odata-response.ts +4 -8
  150. package/src/sbvr-api/permissions.ts +19 -19
  151. package/src/sbvr-api/sbvr-utils.ts +33 -39
  152. package/src/sbvr-api/translations.ts +1 -1
  153. package/src/sbvr-api/uri-parser.ts +10 -10
  154. package/src/server-glue/global-ext.d.ts +3 -0
  155. package/src/server-glue/module.ts +20 -20
  156. package/src/server-glue/sbvr-loader.ts +27 -15
  157. package/src/server-glue/server.ts +24 -13
  158. package/src/tasks/common.ts +1 -1
  159. package/src/tasks/index.ts +14 -14
  160. package/src/tasks/worker.ts +8 -8
  161. package/src/webresource-handler/handlers/NoopHandler.ts +1 -5
  162. package/src/webresource-handler/handlers/S3Handler.ts +1 -1
  163. package/src/webresource-handler/handlers/index.ts +2 -2
  164. package/src/webresource-handler/index.ts +10 -10
  165. package/tsconfig.dev.json +2 -4
  166. package/tsconfig.json +1 -1
  167. package/typings/lf-to-abstract-sql.d.ts +2 -2
  168. package/typings/memoizee.d.ts +2 -2
@@ -1,28 +1,70 @@
1
- import './express-extension.js';
2
- import { isBindReference, odataNameToSqlName, sqlNameToODataName, } from '@balena/odata-to-abstract-sql';
3
- import ODataParser from '@balena/odata-parser';
4
- import _ from 'lodash';
5
- import memoize from 'memoizee';
6
- import randomstring from 'randomstring';
7
- import * as env from '../config-loader/env.js';
8
- import * as sbvrUtils from '../sbvr-api/sbvr-utils.js';
9
- import { addPureHook, addHook } from './hooks.js';
10
- import { BadRequestError, PermissionError, PermissionParsingError, } from './errors.js';
11
- import { memoizedGetOData2AbstractSQL, memoizedParseOdata, metadataEndpoints, } from './uri-parser.js';
12
- import memoizeWeak from 'memoizee/weak.js';
13
- import { importSBVR } from '../server-glue/sbvr-loader.js';
14
- const userModel = await importSBVR('./user.sbvr', import.meta);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.config = exports.addPermissions = exports.checkPermissionsMiddleware = exports.checkPermissions = exports.apiKeyMiddleware = exports.customApiKeyMiddleware = exports.resolveApiKey = exports.authorizationMiddleware = exports.customAuthorizationMiddleware = exports.canAccess = exports.resolveAuthHeader = exports.checkApiKey = exports.getApiKeyPermissions = exports.getUserPermissions = exports.checkPassword = exports.rootRead = exports.root = exports.PermissionParsingError = exports.PermissionError = void 0;
40
+ exports.nestedCheck = nestedCheck;
41
+ exports.setup = setup;
42
+ require("./express-extension");
43
+ const odata_to_abstract_sql_1 = require("@balena/odata-to-abstract-sql");
44
+ const ODataParser = __importStar(require("@balena/odata-parser"));
45
+ const lodash_1 = __importDefault(require("lodash"));
46
+ const memoizee_1 = __importDefault(require("memoizee"));
47
+ const randomstring = __importStar(require("randomstring"));
48
+ const env = __importStar(require("../config-loader/env"));
49
+ const sbvrUtils = __importStar(require("../sbvr-api/sbvr-utils"));
50
+ const hooks_1 = require("./hooks");
51
+ const errors_1 = require("./errors");
52
+ Object.defineProperty(exports, "PermissionError", { enumerable: true, get: function () { return errors_1.PermissionError; } });
53
+ Object.defineProperty(exports, "PermissionParsingError", { enumerable: true, get: function () { return errors_1.PermissionParsingError; } });
54
+ const uri_parser_1 = require("./uri-parser");
55
+ const weak_1 = __importDefault(require("memoizee/weak"));
56
+ const sbvr_loader_1 = require("../server-glue/sbvr-loader");
57
+ const userModel = (0, sbvr_loader_1.requireSBVR)('./user.sbvr', require);
15
58
  const DEFAULT_ACTOR_BIND = '@__ACTOR_ID';
16
- const DEFAULT_ACTOR_BIND_REGEX = new RegExp(_.escapeRegExp(DEFAULT_ACTOR_BIND), 'g');
17
- export { PermissionError, PermissionParsingError };
18
- export const root = {
59
+ const DEFAULT_ACTOR_BIND_REGEX = new RegExp(lodash_1.default.escapeRegExp(DEFAULT_ACTOR_BIND), 'g');
60
+ exports.root = {
19
61
  user: {
20
62
  id: 0,
21
63
  actor: 0,
22
64
  permissions: ['resource.all'],
23
65
  },
24
66
  };
25
- export const rootRead = {
67
+ exports.rootRead = {
26
68
  user: {
27
69
  id: 0,
28
70
  actor: 0,
@@ -57,7 +99,7 @@ const $parsePermissions = env.createCache('parsePermissions', (filter) => {
57
99
  const rewriteODataBinds = ({ tree, extraBinds }, odataBinds) => {
58
100
  const bindsLength = odataBinds.length;
59
101
  odataBinds.push(...extraBinds);
60
- return _.cloneDeepWith(tree, (value) => {
102
+ return lodash_1.default.cloneDeepWith(tree, (value) => {
61
103
  if (value != null) {
62
104
  const bind = value.bind;
63
105
  if (Number.isInteger(bind)) {
@@ -72,7 +114,7 @@ const parsePermissions = (filter, odataBinds) => {
72
114
  };
73
115
  const isAnd = (x) => typeof x === 'object' && 'and' in x;
74
116
  const isOr = (x) => typeof x === 'object' && 'or' in x;
75
- export function nestedCheck(check, stringCallback) {
117
+ function nestedCheck(check, stringCallback) {
76
118
  if (typeof check === 'string') {
77
119
  return stringCallback(check);
78
120
  }
@@ -100,7 +142,7 @@ export function nestedCheck(check, stringCallback) {
100
142
  }
101
143
  if (results.length > 1) {
102
144
  return {
103
- and: _.uniq(results),
145
+ and: lodash_1.default.uniq(results),
104
146
  };
105
147
  }
106
148
  return true;
@@ -138,7 +180,7 @@ export function nestedCheck(check, stringCallback) {
138
180
  }
139
181
  if (results.length > 1) {
140
182
  return {
141
- or: _.uniq(results),
183
+ or: lodash_1.default.uniq(results),
142
184
  };
143
185
  }
144
186
  return false;
@@ -168,13 +210,13 @@ const collapsePermissionFilters = (v) => {
168
210
  return v;
169
211
  };
170
212
  const namespaceRelationships = (relationships, alias) => {
171
- _.forEach(relationships, (relationship, key) => {
213
+ lodash_1.default.forEach(relationships, (relationship, key) => {
172
214
  if (key === '$') {
173
215
  return;
174
216
  }
175
217
  let mapping = relationship.$;
176
218
  if (mapping != null && mapping.length === 2) {
177
- mapping = _.cloneDeep(mapping);
219
+ mapping = lodash_1.default.cloneDeep(mapping);
178
220
  mapping[1][0] = `${mapping[1][0]}$${alias}`;
179
221
  relationships[`${key}$${alias}`] = {
180
222
  $: mapping,
@@ -201,7 +243,7 @@ const getPermissionsLookup = env.createCache('permissionsLookup', (permissions,
201
243
  for (const target of Object.keys(permissionsLookup)) {
202
244
  const conditions = permissionsLookup[target];
203
245
  if (conditions !== true) {
204
- permissionsLookup[target] = _.uniq(conditions);
246
+ permissionsLookup[target] = lodash_1.default.uniq(conditions);
205
247
  }
206
248
  }
207
249
  return permissionsLookup;
@@ -233,7 +275,7 @@ const $checkPermissions = (permissionsLookup, actionList, vocabulary, resourceNa
233
275
  vocabularyResourcePermission = maybeVocabularyResourcePermission;
234
276
  }
235
277
  }
236
- const conditionalPermissions = _.union(resourcePermission, vocabularyPermission, vocabularyResourcePermission);
278
+ const conditionalPermissions = lodash_1.default.union(resourcePermission, vocabularyPermission, vocabularyResourcePermission);
237
279
  if (conditionalPermissions.length === 1) {
238
280
  return conditionalPermissions[0];
239
281
  }
@@ -272,7 +314,7 @@ const rewriteSubPermissionBindings = (filter, counter) => {
272
314
  object.bind = counter + object.bind;
273
315
  }
274
316
  if (Array.isArray(object) || typeof object === 'object') {
275
- _.forEach(object, (v) => {
317
+ lodash_1.default.forEach(object, (v) => {
276
318
  rewrite(v);
277
319
  });
278
320
  }
@@ -295,28 +337,28 @@ const buildODataPermission = (permissionsLookup, actionList, vocabulary, resourc
295
337
  }
296
338
  catch (e) {
297
339
  console.warn('Failed to parse conditional permissions: ', permissionCheck);
298
- throw new PermissionParsingError(e);
340
+ throw new errors_1.PermissionParsingError(e);
299
341
  }
300
342
  });
301
343
  const collapsedPermissionFilters = collapsePermissionFilters(permissionFilters);
302
344
  return collapsedPermissionFilters;
303
345
  };
304
- const constrainedPermissionError = new PermissionError();
346
+ const constrainedPermissionError = new errors_1.PermissionError();
305
347
  const generateConstrainedAbstractSql = (permissionsLookup, actionList, vocabulary, resourceName) => {
306
348
  const abstractSQLModel = sbvrUtils.getAbstractSqlModel({
307
349
  vocabulary,
308
350
  });
309
- const odata = memoizedParseOdata(`/${resourceName}`);
351
+ const odata = (0, uri_parser_1.memoizedParseOdata)(`/${resourceName}`);
310
352
  const collapsedPermissionFilters = buildODataPermission(permissionsLookup, actionList, vocabulary, resourceName, odata);
311
353
  if (collapsePermissionFilters == null) {
312
354
  return;
313
355
  }
314
- _.set(odata, ['tree', 'options', '$filter'], collapsedPermissionFilters);
356
+ lodash_1.default.set(odata, ['tree', 'options', '$filter'], collapsedPermissionFilters);
315
357
  const lambdaAlias = randomstring.generate(20);
316
358
  let inc = 0;
317
359
  const canAccessTrace = [resourceName];
318
360
  const resolveBind = (maybeBind, extraBinds) => {
319
- if (isBindReference(maybeBind)) {
361
+ if ((0, odata_to_abstract_sql_1.isBindReference)(maybeBind)) {
320
362
  const { bind } = maybeBind;
321
363
  if (typeof bind === 'string' || bind < odata.binds.length) {
322
364
  return odata.binds[bind];
@@ -333,7 +375,7 @@ const generateConstrainedAbstractSql = (permissionsLookup, actionList, vocabular
333
375
  const targetResource = this.NavigateResources(this.defaultResource, resolvedProperty.name);
334
376
  const lambdaId = `${lambdaAlias}+${inc}`;
335
377
  inc = inc + 1;
336
- const targetResourceName = sqlNameToODataName(targetResource.resource.name);
378
+ const targetResourceName = (0, odata_to_abstract_sql_1.sqlNameToODataName)(targetResource.resource.name);
337
379
  const traceIndex = canAccessTrace.findIndex((rName) => rName === targetResourceName);
338
380
  if (traceIndex !== -1) {
339
381
  if (canAccessTrace[canAccessTrace.length - 1] !== targetResourceName) {
@@ -358,7 +400,7 @@ const generateConstrainedAbstractSql = (permissionsLookup, actionList, vocabular
358
400
  return this.Property(resolvedProperty);
359
401
  }
360
402
  }
361
- const parentOdata = memoizedParseOdata(`/${targetResourceName}`);
403
+ const parentOdata = (0, uri_parser_1.memoizedParseOdata)(`/${targetResourceName}`);
362
404
  const collapsedParentPermissionFilters = buildODataPermission(permissionsLookup, actionList, vocabulary, targetResourceName, parentOdata);
363
405
  if (collapsedParentPermissionFilters == null) {
364
406
  return ['Equals', ['Boolean', true], ['Boolean', true]];
@@ -379,7 +421,7 @@ const generateConstrainedAbstractSql = (permissionsLookup, actionList, vocabular
379
421
  canAccessTrace.pop();
380
422
  }
381
423
  };
382
- const { tree, extraBindVars } = memoizedGetOData2AbstractSQL(abstractSQLModel).match(odata.tree, 'GET', [], odata.binds.length, {
424
+ const { tree, extraBindVars } = (0, uri_parser_1.memoizedGetOData2AbstractSQL)(abstractSQLModel).match(odata.tree, 'GET', [], odata.binds.length, {
383
425
  canAccess: canAccessFunction,
384
426
  });
385
427
  odata.binds.push(...extraBindVars);
@@ -388,7 +430,7 @@ const generateConstrainedAbstractSql = (permissionsLookup, actionList, vocabular
388
430
  const select = abstractSqlQuery.find((v) => v[0] === 'Select');
389
431
  select[1] = select[1].map((selectField) => {
390
432
  if (selectField[0] === 'Alias') {
391
- const sqlName = odataNameToSqlName(selectField[2]);
433
+ const sqlName = (0, odata_to_abstract_sql_1.odataNameToSqlName)(selectField[2]);
392
434
  const maybeField = selectField[1];
393
435
  if ((maybeField[0] === 'ReferencedField' && maybeField[2] === sqlName) ||
394
436
  (maybeField[0] === 'Field' && maybeField[1] === sqlName)) {
@@ -436,7 +478,7 @@ const deepFreezeExceptDefinition = (obj) => {
436
478
  }
437
479
  }
438
480
  };
439
- const createBypassDefinition = (definition) => _.cloneDeepWith(definition, (abstractSql) => {
481
+ const createBypassDefinition = (definition) => lodash_1.default.cloneDeepWith(definition, (abstractSql) => {
440
482
  if (Array.isArray(abstractSql) &&
441
483
  abstractSql[0] === 'Resource' &&
442
484
  !abstractSql[1].endsWith('$bypass')) {
@@ -445,13 +487,13 @@ const createBypassDefinition = (definition) => _.cloneDeepWith(definition, (abst
445
487
  });
446
488
  const createVersionSpecificPermissionDefinition = ({ abstractSql, ...restDefinition }, permissionsJSON) => {
447
489
  return {
448
- ..._.cloneDeep(restDefinition),
449
- abstractSql: _.cloneDeepWith(abstractSql, (abstractSqlNode) => {
490
+ ...lodash_1.default.cloneDeep(restDefinition),
491
+ abstractSql: lodash_1.default.cloneDeepWith(abstractSql, (abstractSqlNode) => {
450
492
  if (!Array.isArray(abstractSqlNode)) {
451
493
  return;
452
494
  }
453
495
  if (abstractSqlNode[0] === 'Select' || abstractSqlNode[0] === 'Where') {
454
- return _.cloneDeep(abstractSqlNode);
496
+ return lodash_1.default.cloneDeep(abstractSqlNode);
455
497
  }
456
498
  if (abstractSqlNode[0] === 'Resource' &&
457
499
  typeof abstractSqlNode[1] === 'string' &&
@@ -473,10 +515,10 @@ const getAlias = (name) => {
473
515
  }
474
516
  return `permissions${permissionsJSON}`;
475
517
  };
476
- const rewriteRelationship = memoizeWeak((value, name, abstractSqlModel, permissionsLookup, vocabulary, odata2AbstractSQL) => {
477
- let escapedName = sqlNameToODataName(name);
518
+ const rewriteRelationship = (0, weak_1.default)((value, name, abstractSqlModel, permissionsLookup, vocabulary, odata2AbstractSQL) => {
519
+ let escapedName = (0, odata_to_abstract_sql_1.sqlNameToODataName)(name);
478
520
  if (abstractSqlModel.tables[name]) {
479
- escapedName = sqlNameToODataName(abstractSqlModel.tables[name].name);
521
+ escapedName = (0, odata_to_abstract_sql_1.sqlNameToODataName)(abstractSqlModel.tables[name].name);
480
522
  }
481
523
  const rewrite = (object) => {
482
524
  if ('$' in object && Array.isArray(object.$)) {
@@ -489,27 +531,27 @@ const rewriteRelationship = memoizeWeak((value, name, abstractSqlModel, permissi
489
531
  if (possibleTargetResourceName.endsWith('$bypass')) {
490
532
  return;
491
533
  }
492
- const targetResourceEscaped = sqlNameToODataName(abstractSqlModel.tables[possibleTargetResourceName]?.name ??
534
+ const targetResourceEscaped = (0, odata_to_abstract_sql_1.sqlNameToODataName)(abstractSqlModel.tables[possibleTargetResourceName]?.name ??
493
535
  possibleTargetResourceName);
494
536
  if (targetResourceEscaped.includes('$')) {
495
537
  return;
496
538
  }
497
539
  let foundCanAccessLink = false;
498
540
  try {
499
- const odata = memoizedParseOdata(`/${targetResourceEscaped}`);
541
+ const odata = (0, uri_parser_1.memoizedParseOdata)(`/${targetResourceEscaped}`);
500
542
  const collapsedPermissionFilters = buildODataPermission(permissionsLookup, methodPermissions.GET, vocabulary, targetResourceEscaped, odata);
501
543
  if (collapsedPermissionFilters == null) {
502
544
  return;
503
545
  }
504
- _.set(odata, ['tree', 'options', '$filter'], collapsedPermissionFilters);
546
+ lodash_1.default.set(odata, ['tree', 'options', '$filter'], collapsedPermissionFilters);
505
547
  const canAccessFunction = function (property) {
506
548
  delete property.method;
507
549
  if (!this.defaultResource) {
508
550
  throw new Error(`No resource selected in AST.`);
509
551
  }
510
552
  const targetResourceAST = this.NavigateResources(this.defaultResource, property.name);
511
- const targetResourceName = sqlNameToODataName(targetResourceAST.resource.name);
512
- const currentResourceName = sqlNameToODataName(this.defaultResource.name);
553
+ const targetResourceName = (0, odata_to_abstract_sql_1.sqlNameToODataName)(targetResourceAST.resource.name);
554
+ const currentResourceName = (0, odata_to_abstract_sql_1.sqlNameToODataName)(this.defaultResource.name);
513
555
  if (currentResourceName === targetResourceEscaped &&
514
556
  targetResourceName === escapedName) {
515
557
  foundCanAccessLink = true;
@@ -540,7 +582,7 @@ const rewriteRelationship = memoizeWeak((value, name, abstractSqlModel, permissi
540
582
  }
541
583
  }
542
584
  if (Array.isArray(object) || typeof object === 'object') {
543
- _.forEach(object, (v) => {
585
+ lodash_1.default.forEach(object, (v) => {
544
586
  if (typeof v !== 'string') {
545
587
  rewrite(v);
546
588
  }
@@ -553,15 +595,15 @@ const rewriteRelationships = (abstractSqlModel, relationships, permissionsLookup
553
595
  const originalAbstractSQLModel = sbvrUtils.getAbstractSqlModel({
554
596
  vocabulary,
555
597
  });
556
- const odata2AbstractSQL = memoizedGetOData2AbstractSQL(originalAbstractSQLModel);
557
- const newRelationships = _.cloneDeep(relationships);
558
- _.forOwn(newRelationships, (value, name) => {
598
+ const odata2AbstractSQL = (0, uri_parser_1.memoizedGetOData2AbstractSQL)(originalAbstractSQLModel);
599
+ const newRelationships = lodash_1.default.cloneDeep(relationships);
600
+ lodash_1.default.forOwn(newRelationships, (value, name) => {
559
601
  rewriteRelationship(value, name, abstractSqlModel, permissionsLookup, vocabulary, odata2AbstractSQL);
560
602
  });
561
603
  return newRelationships;
562
604
  };
563
- const getBoundConstrainedMemoizer = memoizeWeak((abstractSqlModel) => memoizeWeak((permissionsLookup, vocabulary) => {
564
- const constrainedAbstractSqlModel = _.cloneDeep(abstractSqlModel);
605
+ const getBoundConstrainedMemoizer = (0, weak_1.default)((abstractSqlModel) => (0, weak_1.default)((permissionsLookup, vocabulary) => {
606
+ const constrainedAbstractSqlModel = lodash_1.default.cloneDeep(abstractSqlModel);
565
607
  const origSynonyms = Object.entries(constrainedAbstractSqlModel.synonyms);
566
608
  constrainedAbstractSqlModel.synonyms = new Proxy(constrainedAbstractSqlModel.synonyms, {
567
609
  get(synonyms, permissionSynonym, receiver) {
@@ -582,7 +624,7 @@ const getBoundConstrainedMemoizer = memoizeWeak((abstractSqlModel) => memoizeWea
582
624
  },
583
625
  });
584
626
  const origRelationships = Object.keys(constrainedAbstractSqlModel.relationships);
585
- _.forEach(constrainedAbstractSqlModel.tables, (table, resourceName) => {
627
+ lodash_1.default.forEach(constrainedAbstractSqlModel.tables, (table, resourceName) => {
586
628
  const bypassResourceName = `${resourceName}$bypass`;
587
629
  constrainedAbstractSqlModel.tables[bypassResourceName] = {
588
630
  ...table,
@@ -593,7 +635,7 @@ const getBoundConstrainedMemoizer = memoizeWeak((abstractSqlModel) => memoizeWea
593
635
  constrainedAbstractSqlModel.tables[bypassResourceName].definition =
594
636
  createBypassDefinition(table.definition);
595
637
  const tableDefinition = table.definition;
596
- for (const stringifiedPermission of _.uniq(Object.values(stringifiedMethodPermissions))) {
638
+ for (const stringifiedPermission of lodash_1.default.uniq(Object.values(stringifiedMethodPermissions))) {
597
639
  if (stringifiedPermission === stringifiedMethodPermissions.GET) {
598
640
  continue;
599
641
  }
@@ -630,7 +672,7 @@ const getBoundConstrainedMemoizer = memoizeWeak((abstractSqlModel) => memoizeWea
630
672
  ...table,
631
673
  });
632
674
  permissionsTable.resourceName = permissionResourceName;
633
- onceGetter(permissionsTable, 'definition', () => generateConstrainedAbstractSql(permissionsLookup, permissions, vocabulary, sqlNameToODataName(permissionsTable.modifyName ?? permissionsTable.name)));
675
+ onceGetter(permissionsTable, 'definition', () => generateConstrainedAbstractSql(permissionsLookup, permissions, vocabulary, (0, odata_to_abstract_sql_1.sqlNameToODataName)(permissionsTable.modifyName ?? permissionsTable.name)));
634
676
  return permissionsTable;
635
677
  },
636
678
  });
@@ -661,10 +703,10 @@ const getBoundConstrainedMemoizer = memoizeWeak((abstractSqlModel) => memoizeWea
661
703
  primitive: true,
662
704
  }));
663
705
  const memoizedGetConstrainedModel = (abstractSqlModel, permissionsLookup, vocabulary) => getBoundConstrainedMemoizer(abstractSqlModel)(permissionsLookup, vocabulary);
664
- const getCheckPasswordQuery = _.once(() => sbvrUtils.api.Auth.prepare({
706
+ const getCheckPasswordQuery = lodash_1.default.once(() => sbvrUtils.api.Auth.prepare({
665
707
  resource: 'user',
666
708
  passthrough: {
667
- req: rootRead,
709
+ req: exports.rootRead,
668
710
  },
669
711
  id: {
670
712
  username: { '@': 'username' },
@@ -673,7 +715,7 @@ const getCheckPasswordQuery = _.once(() => sbvrUtils.api.Auth.prepare({
673
715
  $select: ['id', 'actor', 'password'],
674
716
  },
675
717
  }, { username: ['string'] }));
676
- export const checkPassword = async (username, password) => {
718
+ const checkPassword = async (username, password) => {
677
719
  const user = await getCheckPasswordQuery()({
678
720
  username,
679
721
  });
@@ -685,7 +727,7 @@ export const checkPassword = async (username, password) => {
685
727
  throw new Error('Passwords do not match');
686
728
  }
687
729
  const userId = user.id;
688
- const permissions = await getUserPermissions(userId);
730
+ const permissions = await (0, exports.getUserPermissions)(userId);
689
731
  return {
690
732
  id: userId,
691
733
  actor: user.actor.__id,
@@ -693,11 +735,12 @@ export const checkPassword = async (username, password) => {
693
735
  permissions,
694
736
  };
695
737
  };
738
+ exports.checkPassword = checkPassword;
696
739
  const $getUserPermissions = (() => {
697
- const getUserPermissionsQuery = _.once(() => sbvrUtils.api.Auth.prepare({
740
+ const getUserPermissionsQuery = lodash_1.default.once(() => sbvrUtils.api.Auth.prepare({
698
741
  resource: 'permission',
699
742
  passthrough: {
700
- req: rootRead,
743
+ req: exports.rootRead,
701
744
  },
702
745
  options: {
703
746
  $select: 'name',
@@ -775,7 +818,7 @@ const $getUserPermissions = (() => {
775
818
  normalizer: ([userId]) => `${userId}`,
776
819
  });
777
820
  })();
778
- export const getUserPermissions = async (userId, tx) => {
821
+ const getUserPermissions = async (userId, tx) => {
779
822
  if (typeof userId === 'string') {
780
823
  userId = parseInt(userId, 10);
781
824
  }
@@ -790,11 +833,12 @@ export const getUserPermissions = async (userId, tx) => {
790
833
  throw err;
791
834
  }
792
835
  };
836
+ exports.getUserPermissions = getUserPermissions;
793
837
  const $getApiKeyPermissions = (() => {
794
- const getApiKeyPermissionsQuery = _.once(() => sbvrUtils.api.Auth.prepare({
838
+ const getApiKeyPermissionsQuery = lodash_1.default.once(() => sbvrUtils.api.Auth.prepare({
795
839
  resource: 'permission',
796
840
  passthrough: {
797
- req: rootRead,
841
+ req: exports.rootRead,
798
842
  },
799
843
  options: {
800
844
  $select: 'name',
@@ -892,7 +936,7 @@ const $getApiKeyPermissions = (() => {
892
936
  normalizer: ([apiKey]) => apiKey,
893
937
  });
894
938
  })();
895
- export const getApiKeyPermissions = async (apiKey, tx) => {
939
+ const getApiKeyPermissions = async (apiKey, tx) => {
896
940
  if (typeof apiKey !== 'string') {
897
941
  throw new Error('API key has to be a string, got: ' + typeof apiKey);
898
942
  }
@@ -904,11 +948,12 @@ export const getApiKeyPermissions = async (apiKey, tx) => {
904
948
  throw err;
905
949
  }
906
950
  };
951
+ exports.getApiKeyPermissions = getApiKeyPermissions;
907
952
  const getApiKeyActorId = (() => {
908
- const getApiKeyActorIdQuery = _.once(() => sbvrUtils.api.Auth.prepare({
953
+ const getApiKeyActorIdQuery = lodash_1.default.once(() => sbvrUtils.api.Auth.prepare({
909
954
  resource: 'api_key',
910
955
  passthrough: {
911
- req: rootRead,
956
+ req: exports.rootRead,
912
957
  },
913
958
  id: {
914
959
  key: { '@': 'apiKey' },
@@ -923,7 +968,7 @@ const getApiKeyActorId = (() => {
923
968
  },
924
969
  },
925
970
  }, { apiKey: ['string'] }));
926
- const apiActorPermissionError = new PermissionError();
971
+ const apiActorPermissionError = new errors_1.PermissionError();
927
972
  return env.createCache('apiKeyActorId', async (apiKey, tx) => {
928
973
  const apiKeyResult = await getApiKeyActorIdQuery()({
929
974
  apiKey,
@@ -942,8 +987,8 @@ const getApiKeyActorId = (() => {
942
987
  normalizer: ([apiKey]) => apiKey,
943
988
  });
944
989
  })();
945
- export const checkApiKey = async (apiKey, tx) => {
946
- const permissions = await getApiKeyPermissions(apiKey, tx);
990
+ const checkApiKey = async (apiKey, tx) => {
991
+ const permissions = await (0, exports.getApiKeyPermissions)(apiKey, tx);
947
992
  const actor = await getApiKeyActorId(apiKey, tx);
948
993
  return {
949
994
  key: apiKey,
@@ -951,7 +996,8 @@ export const checkApiKey = async (apiKey, tx) => {
951
996
  actor,
952
997
  };
953
998
  };
954
- export const resolveAuthHeader = async (req, expectedScheme = 'Bearer', tx) => {
999
+ exports.checkApiKey = checkApiKey;
1000
+ const resolveAuthHeader = async (req, expectedScheme = 'Bearer', tx) => {
955
1001
  const auth = req.header('Authorization');
956
1002
  if (!auth) {
957
1003
  return;
@@ -964,19 +1010,20 @@ export const resolveAuthHeader = async (req, expectedScheme = 'Bearer', tx) => {
964
1010
  if (scheme.toLowerCase() !== expectedScheme.toLowerCase()) {
965
1011
  return;
966
1012
  }
967
- return await checkApiKey(apiKey, tx);
1013
+ return await (0, exports.checkApiKey)(apiKey, tx);
968
1014
  };
969
- export const canAccess = {
1015
+ exports.resolveAuthHeader = resolveAuthHeader;
1016
+ exports.canAccess = {
970
1017
  $fn: {
971
1018
  $scope: 'Auth',
972
1019
  $method: 'canAccess',
973
1020
  },
974
1021
  };
975
- export const customAuthorizationMiddleware = (expectedScheme = 'Bearer') => {
1022
+ const customAuthorizationMiddleware = (expectedScheme = 'Bearer') => {
976
1023
  expectedScheme = expectedScheme.toLowerCase();
977
1024
  return async (req, _res, next) => {
978
1025
  try {
979
- const apiKey = await resolveAuthHeader(req, expectedScheme);
1026
+ const apiKey = await (0, exports.resolveAuthHeader)(req, expectedScheme);
980
1027
  if (apiKey) {
981
1028
  req.apiKey = apiKey;
982
1029
  }
@@ -986,18 +1033,20 @@ export const customAuthorizationMiddleware = (expectedScheme = 'Bearer') => {
986
1033
  }
987
1034
  };
988
1035
  };
989
- export const authorizationMiddleware = customAuthorizationMiddleware();
990
- export const resolveApiKey = async (req, paramName = 'apikey', tx) => {
1036
+ exports.customAuthorizationMiddleware = customAuthorizationMiddleware;
1037
+ exports.authorizationMiddleware = (0, exports.customAuthorizationMiddleware)();
1038
+ const resolveApiKey = async (req, paramName = 'apikey', tx) => {
991
1039
  const apiKey = req.params[paramName] ?? req.body[paramName] ?? req.query[paramName];
992
1040
  if (apiKey == null) {
993
1041
  return;
994
1042
  }
995
- return await checkApiKey(apiKey, tx);
1043
+ return await (0, exports.checkApiKey)(apiKey, tx);
996
1044
  };
997
- export const customApiKeyMiddleware = (paramName = 'apikey') => {
1045
+ exports.resolveApiKey = resolveApiKey;
1046
+ const customApiKeyMiddleware = (paramName = 'apikey') => {
998
1047
  return async (req, _res, next) => {
999
1048
  try {
1000
- const apiKey = await resolveApiKey(req, paramName);
1049
+ const apiKey = await (0, exports.resolveApiKey)(req, paramName);
1001
1050
  if (apiKey) {
1002
1051
  req.apiKey = apiKey;
1003
1052
  }
@@ -1007,14 +1056,16 @@ export const customApiKeyMiddleware = (paramName = 'apikey') => {
1007
1056
  }
1008
1057
  };
1009
1058
  };
1010
- export const apiKeyMiddleware = customApiKeyMiddleware();
1011
- export const checkPermissions = async (req, actionList, resourceName, vocabulary) => {
1059
+ exports.customApiKeyMiddleware = customApiKeyMiddleware;
1060
+ exports.apiKeyMiddleware = (0, exports.customApiKeyMiddleware)();
1061
+ const checkPermissions = async (req, actionList, resourceName, vocabulary) => {
1012
1062
  const permissionsLookup = await getReqPermissions(req);
1013
1063
  return $checkPermissions(permissionsLookup, actionList, vocabulary, resourceName);
1014
1064
  };
1015
- export const checkPermissionsMiddleware = (action) => async (req, res, next) => {
1065
+ exports.checkPermissions = checkPermissions;
1066
+ const checkPermissionsMiddleware = (action) => async (req, res, next) => {
1016
1067
  try {
1017
- const allowed = await checkPermissions(req, action);
1068
+ const allowed = await (0, exports.checkPermissions)(req, action);
1018
1069
  switch (allowed) {
1019
1070
  case false:
1020
1071
  res.status(401).end();
@@ -1031,12 +1082,13 @@ export const checkPermissionsMiddleware = (action) => async (req, res, next) =>
1031
1082
  res.status(503).end();
1032
1083
  }
1033
1084
  };
1085
+ exports.checkPermissionsMiddleware = checkPermissionsMiddleware;
1034
1086
  let guestPermissionsInitialized = false;
1035
- const getGuestPermissions = memoize(async () => {
1087
+ const getGuestPermissions = (0, memoizee_1.default)(async () => {
1036
1088
  const result = await sbvrUtils.api.Auth.get({
1037
1089
  resource: 'user',
1038
1090
  passthrough: {
1039
- req: rootRead,
1091
+ req: exports.rootRead,
1040
1092
  },
1041
1093
  id: {
1042
1094
  username: 'guest',
@@ -1048,7 +1100,7 @@ const getGuestPermissions = memoize(async () => {
1048
1100
  if (result == null) {
1049
1101
  throw new Error('No guest user');
1050
1102
  }
1051
- const guestPermissions = _.uniq(await getUserPermissions(result.id));
1103
+ const guestPermissions = lodash_1.default.uniq(await (0, exports.getUserPermissions)(result.id));
1052
1104
  if (guestPermissions.some((p) => DEFAULT_ACTOR_BIND_REGEX.test(p))) {
1053
1105
  throw new Error('Guest permissions cannot reference actors');
1054
1106
  }
@@ -1058,7 +1110,7 @@ const getGuestPermissions = memoize(async () => {
1058
1110
  const getReqPermissions = async (req, odataBinds = []) => {
1059
1111
  const guestPermissions = await (async () => {
1060
1112
  if (guestPermissionsInitialized === false &&
1061
- (req.user === root.user || req.user === rootRead.user)) {
1113
+ (req.user === exports.root.user || req.user === exports.rootRead.user)) {
1062
1114
  return [];
1063
1115
  }
1064
1116
  return await getGuestPermissions();
@@ -1076,14 +1128,14 @@ const getReqPermissions = async (req, odataBinds = []) => {
1076
1128
  }
1077
1129
  return getPermissionsLookup(actorPermissions, guestPermissions);
1078
1130
  };
1079
- export const addPermissions = async (req, request) => {
1131
+ const addPermissions = async (req, request) => {
1080
1132
  const { resourceName, odataQuery, odataBinds } = request;
1081
- const vocabulary = _.last(request.translateVersions);
1133
+ const vocabulary = lodash_1.default.last(request.translateVersions);
1082
1134
  let abstractSqlModel = sbvrUtils.getAbstractSqlModel(request);
1083
1135
  let { permissionType } = request;
1084
1136
  if (permissionType == null) {
1085
1137
  const method = request.method.toUpperCase();
1086
- const isMetadataEndpoint = method === 'OPTIONS' || metadataEndpoints.includes(resourceName);
1138
+ const isMetadataEndpoint = method === 'OPTIONS' || uri_parser_1.metadataEndpoints.includes(resourceName);
1087
1139
  if (isMetadataEndpoint) {
1088
1140
  permissionType = 'model';
1089
1141
  }
@@ -1100,11 +1152,12 @@ export const addPermissions = async (req, request) => {
1100
1152
  }
1101
1153
  const permissionsLookup = await getReqPermissions(req, odataBinds);
1102
1154
  request.abstractSqlModel = abstractSqlModel = memoizedGetConstrainedModel(abstractSqlModel, permissionsLookup, vocabulary);
1103
- if (!_.isEqual(permissionType, methodPermissions.GET)) {
1155
+ if (!lodash_1.default.isEqual(permissionType, methodPermissions.GET)) {
1104
1156
  const sqlName = sbvrUtils.resolveSynonym(request);
1105
1157
  odataQuery.resource = `${sqlName}$permissions${JSON.stringify(permissionType)}`;
1106
1158
  }
1107
1159
  };
1160
+ exports.addPermissions = addPermissions;
1108
1161
  const authModelConfig = {
1109
1162
  apiRoot: 'Auth',
1110
1163
  modelText: userModel,
@@ -1144,14 +1197,14 @@ const authModelConfig = {
1144
1197
  `,
1145
1198
  },
1146
1199
  };
1147
- export const config = {
1200
+ exports.config = {
1148
1201
  models: [authModelConfig],
1149
1202
  };
1150
- export function setup() {
1151
- addHook('all', 'all', 'all', {
1203
+ function setup() {
1204
+ (0, hooks_1.addHook)('all', 'all', 'all', {
1152
1205
  sideEffects: false,
1153
1206
  readOnlyTx: true,
1154
- PREPARSE: ({ req }) => apiKeyMiddleware(req),
1207
+ PREPARSE: ({ req }) => (0, exports.apiKeyMiddleware)(req),
1155
1208
  POSTPARSE: async ({ req, request, }) => {
1156
1209
  if (request.abstractSqlQuery != null) {
1157
1210
  return;
@@ -1159,16 +1212,16 @@ export function setup() {
1159
1212
  if (request.method === 'POST' &&
1160
1213
  request.odataQuery.property?.resource === 'canAccess') {
1161
1214
  if (request.odataQuery.key == null) {
1162
- throw new BadRequestError();
1215
+ throw new errors_1.BadRequestError();
1163
1216
  }
1164
1217
  const { action, method } = request.values;
1165
1218
  if ((method == null) === (action == null)) {
1166
- throw new BadRequestError();
1219
+ throw new errors_1.BadRequestError();
1167
1220
  }
1168
1221
  if (method != null) {
1169
1222
  const permissions = methodPermissions[method];
1170
1223
  if (permissions == null) {
1171
- throw new BadRequestError();
1224
+ throw new errors_1.BadRequestError();
1172
1225
  }
1173
1226
  request.permissionType = permissions;
1174
1227
  }
@@ -1193,18 +1246,18 @@ export function setup() {
1193
1246
  request.method = 'GET';
1194
1247
  request.custom.isAction = 'canAccess';
1195
1248
  }
1196
- await addPermissions(req, request);
1249
+ await (0, exports.addPermissions)(req, request);
1197
1250
  },
1198
1251
  PRERESPOND: ({ request, response }) => {
1199
1252
  if (request.custom.isAction === 'canAccess' &&
1200
1253
  (response.body == null ||
1201
1254
  typeof response.body === 'string' ||
1202
- _.isEmpty(response.body?.d))) {
1203
- throw new PermissionError();
1255
+ lodash_1.default.isEmpty(response.body?.d))) {
1256
+ throw new errors_1.PermissionError();
1204
1257
  }
1205
1258
  },
1206
1259
  });
1207
- addPureHook('POST', 'Auth', 'user', {
1260
+ (0, hooks_1.addPureHook)('POST', 'Auth', 'user', {
1208
1261
  POSTPARSE: async ({ request, api }) => {
1209
1262
  const result = await api.post({
1210
1263
  resource: 'actor',
@@ -1213,7 +1266,7 @@ export function setup() {
1213
1266
  request.values.actor = result.id;
1214
1267
  },
1215
1268
  });
1216
- addPureHook('DELETE', 'Auth', 'user', {
1269
+ (0, hooks_1.addPureHook)('DELETE', 'Auth', 'user', {
1217
1270
  POSTRUN: ({ request, api }) => api.delete({
1218
1271
  resource: 'actor',
1219
1272
  id: request.values.actor,