@terreno/admin-backend 57.4.0 → 57.6.0

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.
@@ -1,63 +1,16 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
2
  Object.defineProperty(exports, "__esModule", { value: true });
50
3
  exports.resolvedModelFromAdminConfig = void 0;
51
- var enrichAdminListFilters_1 = require("./enrichAdminListFilters");
52
- var routePath_1 = require("./routePath");
53
- var adminPermissionsToModelPermissions = function (permissions) {
4
+ const enrichAdminListFilters_1 = require("./enrichAdminListFilters");
5
+ const routePath_1 = require("./routePath");
6
+ const adminPermissionsToModelPermissions = (permissions) => {
54
7
  if (!permissions) {
55
8
  return undefined;
56
9
  }
57
- var has = function (methods) {
10
+ const has = (methods) => {
58
11
  return methods != null && methods.length > 0;
59
12
  };
60
- var mapped = {};
13
+ const mapped = {};
61
14
  if (permissions.create !== undefined) {
62
15
  mapped.create = has(permissions.create);
63
16
  }
@@ -69,38 +22,29 @@ var adminPermissionsToModelPermissions = function (permissions) {
69
22
  }
70
23
  return mapped;
71
24
  };
72
- var adminFilterToQueryFilter = function (adminFilter) {
25
+ const adminFilterToQueryFilter = (adminFilter) => {
73
26
  if (!adminFilter) {
74
27
  return undefined;
75
28
  }
76
- return function (user, query) { return __awaiter(void 0, void 0, void 0, function () {
77
- var stubReq, scoped;
78
- return __generator(this, function (_a) {
79
- switch (_a.label) {
80
- case 0:
81
- stubReq = { user: user };
82
- return [4 /*yield*/, adminFilter(stubReq)];
83
- case 1:
84
- scoped = _a.sent();
85
- return [2 /*return*/, __assign(__assign({}, (query !== null && query !== void 0 ? query : {})), scoped)];
86
- }
87
- });
88
- }); };
29
+ return async (user, query) => {
30
+ const stubReq = { user };
31
+ const scoped = await adminFilter(stubReq);
32
+ return { ...(query ?? {}), ...scoped };
33
+ };
89
34
  };
90
- var resolvedModelFromAdminConfig = function (_a) {
91
- var admin = _a.admin, model = _a.model, populatePaths = _a.populatePaths, queryFilter = _a.queryFilter, registrationPath = _a.registrationPath, routePath = _a.routePath, source = _a.source, sourceLabel = _a.sourceLabel;
92
- var normalizedPath = (0, routePath_1.normalizeAdminRoutePath)(routePath);
93
- var defaultSort = Array.isArray(admin.defaultSort)
35
+ const resolvedModelFromAdminConfig = ({ admin, model, populatePaths, queryFilter, registrationPath, routePath, source, sourceLabel, }) => {
36
+ const normalizedPath = (0, routePath_1.normalizeAdminRoutePath)(routePath);
37
+ const defaultSort = Array.isArray(admin.defaultSort)
94
38
  ? admin.defaultSort.join(" ")
95
39
  : admin.defaultSort;
96
- var mergedQueryFilter = queryFilter !== null && queryFilter !== void 0 ? queryFilter : adminFilterToQueryFilter(admin.adminFilter);
40
+ const mergedQueryFilter = queryFilter ?? adminFilterToQueryFilter(admin.adminFilter);
97
41
  return {
98
42
  actions: admin.actions,
99
- admin: admin,
43
+ admin,
100
44
  adminAccess: admin.adminAccess,
101
45
  autocompleteFields: admin.autocompleteFields,
102
46
  bulkPatchAllowlist: admin.bulkPatchAllowlist,
103
- defaultSort: defaultSort,
47
+ defaultSort,
104
48
  displayName: admin.displayName,
105
49
  excludeFields: admin.excludeFields,
106
50
  fieldOrder: admin.fieldOrder,
@@ -113,20 +57,20 @@ var resolvedModelFromAdminConfig = function (_a) {
113
57
  listDisplay: admin.listDisplay,
114
58
  listDisplayLinks: admin.listDisplayLinks,
115
59
  listFields: admin.listFields,
116
- model: model,
60
+ model,
117
61
  pageSize: admin.pageSize,
118
62
  permissions: adminPermissionsToModelPermissions(admin.adminPermissions),
119
- populatePaths: populatePaths,
63
+ populatePaths,
120
64
  queryFilter: mergedQueryFilter,
121
65
  readonlyFields: admin.readonlyFields,
122
66
  realtime: admin.realtime,
123
67
  recordTitleField: admin.recordTitleField,
124
- registrationPath: registrationPath,
68
+ registrationPath,
125
69
  routePath: normalizedPath,
126
70
  searchFields: admin.searchFields,
127
71
  sortableFields: admin.sortableFields,
128
- source: source,
129
- sourceLabel: sourceLabel,
72
+ source,
73
+ sourceLabel,
130
74
  };
131
75
  };
132
76
  exports.resolvedModelFromAdminConfig = resolvedModelFromAdminConfig;
package/dist/routePath.js CHANGED
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeAdminRoutePath = void 0;
4
4
  /** Normalize admin model route paths for collision detection (`/users` and `/users/` match). */
5
- var normalizeAdminRoutePath = function (routePath) {
5
+ const normalizeAdminRoutePath = (routePath) => {
6
6
  if (!routePath) {
7
7
  return "/";
8
8
  }
9
- var path = routePath.trim();
9
+ let path = routePath.trim();
10
10
  if (!path.startsWith("/")) {
11
- path = "/".concat(path);
11
+ path = `/${path}`;
12
12
  }
13
13
  if (path.length > 1 && path.endsWith("/")) {
14
14
  path = path.replace(/\/+$/, "");