@terreno/admin-backend 57.3.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.
- package/README.md +3 -3
- package/bunfig.toml +9 -1
- package/dist/adminApp.d.ts +20 -2
- package/dist/adminApp.js +1261 -1873
- package/dist/adminConfigIdentity.d.ts +1 -0
- package/dist/adminConfigIdentity.js +27 -50
- package/dist/adminMigrations.d.ts +10 -0
- package/dist/adminMigrations.js +120 -0
- package/dist/adminScriptJob.d.ts +32 -0
- package/dist/adminScriptJob.js +202 -0
- package/dist/adminTextSearch.d.ts +1 -0
- package/dist/adminTextSearch.js +22 -78
- package/dist/adminUiV2.d.ts +2 -0
- package/dist/adminUiV2.js +49 -146
- package/dist/aggregateAdmin.js +104 -227
- package/dist/documentStorageApp.js +184 -325
- package/dist/enrichAdminListFilters.d.ts +7 -0
- package/dist/enrichAdminListFilters.js +26 -0
- package/dist/filterParser.js +230 -183
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/legacy.js +21 -23
- package/dist/resolvedAdminModel.js +23 -78
- package/dist/routePath.js +3 -3
- package/dist/scriptCli.js +161 -307
- package/dist/tests/bunSetup.js +1 -1
- package/package.json +10 -10
- package/src/adminApp.migrations.test.ts +232 -0
- package/src/adminApp.models.test.ts +731 -1
- package/src/adminApp.syncMeta.test.ts +237 -0
- package/src/adminApp.test.ts +92 -0
- package/src/adminApp.ts +373 -130
- package/src/adminConfigIdentity.ts +1 -0
- package/src/adminHttpGoldens.test.ts +337 -0
- package/src/adminMigrations.ts +157 -0
- package/src/adminScriptJob.test.ts +297 -0
- package/src/adminScriptJob.ts +271 -0
- package/src/adminSyncMutationAuthMismatch.test.ts +650 -0
- package/src/adminTextSearch.test.ts +28 -0
- package/src/adminTextSearch.ts +1 -0
- package/src/adminUiV2.ts +2 -0
- package/src/aggregateAdmin.test.ts +125 -0
- package/src/aggregateAdmin.ts +2 -0
- package/src/enrichAdminListFilters.test.ts +44 -0
- package/src/enrichAdminListFilters.ts +29 -0
- package/src/filterParser.test.ts +95 -0
- package/src/filterParser.ts +156 -10
- package/src/index.ts +2 -0
- package/src/legacy.ts +5 -1
- package/src/resolvedAdminModel.ts +2 -1
- package/tsconfig.json +6 -21
package/dist/adminUiV2.js
CHANGED
|
@@ -3,89 +3,45 @@
|
|
|
3
3
|
* Admin UI v2 helpers and constants (Django-parity config contract).
|
|
4
4
|
* @see docs/implementationPlans/admin-ui-v2-django-parity.md
|
|
5
5
|
*/
|
|
6
|
-
var __assign = (this && this.__assign) || function () {
|
|
7
|
-
__assign = Object.assign || function(t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11
|
-
t[p] = s[p];
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
};
|
|
15
|
-
return __assign.apply(this, arguments);
|
|
16
|
-
};
|
|
17
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
-
if (!m) return o;
|
|
20
|
-
var i = m.call(o), r, ar = [], e;
|
|
21
|
-
try {
|
|
22
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
-
}
|
|
24
|
-
catch (error) { e = { error: error }; }
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
-
}
|
|
29
|
-
finally { if (e) throw e.error; }
|
|
30
|
-
}
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
34
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
35
|
-
if (ar || !(i in from)) {
|
|
36
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
37
|
-
ar[i] = from[i];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
41
|
-
};
|
|
42
|
-
var __values = (this && this.__values) || function(o) {
|
|
43
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
44
|
-
if (m) return m.call(o);
|
|
45
|
-
if (o && typeof o.length === "number") return {
|
|
46
|
-
next: function () {
|
|
47
|
-
if (o && i >= o.length) o = void 0;
|
|
48
|
-
return { value: o && o[i++], done: !o };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
52
|
-
};
|
|
53
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
7
|
exports.defaultBulkPatchAllowlistFrom = exports.buildAdminModelQueryFields = exports.normalizeAdminHome = exports.normalizeSidebarRecentLast = exports.SYSTEM_ADMIN_FIELDS = exports.MAX_BULK_PATCH_IDS = exports.ADMIN_SCHEMA_VERSION = void 0;
|
|
55
8
|
exports.ADMIN_SCHEMA_VERSION = 2;
|
|
56
9
|
exports.MAX_BULK_PATCH_IDS = 1000;
|
|
57
10
|
exports.SYSTEM_ADMIN_FIELDS = new Set(["_id", "id", "__v", "created", "updated", "deleted"]);
|
|
58
|
-
|
|
11
|
+
const normalizeSidebarRecentLast = (sidebar) => {
|
|
59
12
|
if (!sidebar || sidebar.length === 0) {
|
|
60
13
|
return sidebar;
|
|
61
14
|
}
|
|
62
15
|
if (!sidebar.includes("recentActivity")) {
|
|
63
16
|
return sidebar;
|
|
64
17
|
}
|
|
65
|
-
|
|
66
|
-
return
|
|
18
|
+
const without = sidebar.filter((id) => id !== "recentActivity");
|
|
19
|
+
return [...without, "recentActivity"];
|
|
67
20
|
};
|
|
68
21
|
exports.normalizeSidebarRecentLast = normalizeSidebarRecentLast;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (home === null || home === void 0 ? void 0 : home.slots) {
|
|
22
|
+
const normalizeAdminHome = (home) => {
|
|
23
|
+
const title = home?.title ?? "Administration";
|
|
24
|
+
if (home?.slots) {
|
|
73
25
|
return {
|
|
74
|
-
slots:
|
|
75
|
-
|
|
26
|
+
slots: {
|
|
27
|
+
...home.slots,
|
|
28
|
+
sidebar: (0, exports.normalizeSidebarRecentLast)(home.slots.sidebar),
|
|
29
|
+
},
|
|
30
|
+
title,
|
|
76
31
|
};
|
|
77
32
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
?
|
|
33
|
+
if (home?.widgets && home.widgets.length > 0) {
|
|
34
|
+
const main = home.widgets.includes("modelsGrid")
|
|
35
|
+
? [...home.widgets]
|
|
36
|
+
: ["modelsGrid", ...home.widgets];
|
|
81
37
|
return {
|
|
82
|
-
slots: { main
|
|
83
|
-
title
|
|
38
|
+
slots: { main },
|
|
39
|
+
title,
|
|
84
40
|
};
|
|
85
41
|
}
|
|
86
42
|
return {
|
|
87
43
|
slots: { main: ["modelsGrid"] },
|
|
88
|
-
title
|
|
44
|
+
title,
|
|
89
45
|
};
|
|
90
46
|
};
|
|
91
47
|
exports.normalizeAdminHome = normalizeAdminHome;
|
|
@@ -93,96 +49,43 @@ exports.normalizeAdminHome = normalizeAdminHome;
|
|
|
93
49
|
* Derives `modelRouter` `queryFields` from admin UI v2 list metadata so changelist
|
|
94
50
|
* filters and sort keys match allowed query parameters on `GET` list routes.
|
|
95
51
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
52
|
+
const buildAdminModelQueryFields = (config) => {
|
|
53
|
+
const fields = new Set(["_id", "q"]);
|
|
54
|
+
for (const name of config.listFields) {
|
|
55
|
+
fields.add(name);
|
|
56
|
+
}
|
|
57
|
+
for (const name of config.listDisplay ?? []) {
|
|
58
|
+
fields.add(name);
|
|
59
|
+
}
|
|
60
|
+
for (const name of config.searchFields ?? []) {
|
|
61
|
+
fields.add(name);
|
|
62
|
+
}
|
|
63
|
+
for (const filter of config.filters ?? []) {
|
|
64
|
+
fields.add(filter.field);
|
|
65
|
+
if (filter.kind === "dateRange") {
|
|
66
|
+
fields.add(`${filter.field}_gte`);
|
|
67
|
+
fields.add(`${filter.field}_lte`);
|
|
110
68
|
}
|
|
111
|
-
finally { if (e_1) throw e_1.error; }
|
|
112
69
|
}
|
|
113
|
-
|
|
114
|
-
for (var _k = __values((_e = config.listDisplay) !== null && _e !== void 0 ? _e : []), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
115
|
-
var name_2 = _l.value;
|
|
116
|
-
fields.add(name_2);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
120
|
-
finally {
|
|
121
|
-
try {
|
|
122
|
-
if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
|
|
123
|
-
}
|
|
124
|
-
finally { if (e_2) throw e_2.error; }
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
for (var _m = __values((_f = config.searchFields) !== null && _f !== void 0 ? _f : []), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
128
|
-
var name_3 = _o.value;
|
|
129
|
-
fields.add(name_3);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
133
|
-
finally {
|
|
134
|
-
try {
|
|
135
|
-
if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
|
|
136
|
-
}
|
|
137
|
-
finally { if (e_3) throw e_3.error; }
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
for (var _p = __values((_g = config.filters) !== null && _g !== void 0 ? _g : []), _q = _p.next(); !_q.done; _q = _p.next()) {
|
|
141
|
-
var filter = _q.value;
|
|
142
|
-
fields.add(filter.field);
|
|
143
|
-
if (filter.kind === "dateRange") {
|
|
144
|
-
fields.add("".concat(filter.field, "_gte"));
|
|
145
|
-
fields.add("".concat(filter.field, "_lte"));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
150
|
-
finally {
|
|
151
|
-
try {
|
|
152
|
-
if (_q && !_q.done && (_d = _p.return)) _d.call(_p);
|
|
153
|
-
}
|
|
154
|
-
finally { if (e_4) throw e_4.error; }
|
|
155
|
-
}
|
|
156
|
-
return __spreadArray([], __read(fields), false);
|
|
70
|
+
return [...fields];
|
|
157
71
|
};
|
|
158
72
|
exports.buildAdminModelQueryFields = buildAdminModelQueryFields;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var field = _c.value;
|
|
165
|
-
if (exports.SYSTEM_ADMIN_FIELDS.has(field)) {
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
if (params.hiddenFieldSet.has(field)) {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (params.readonlyFields.includes(field)) {
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
if (!params.schemaPaths.has(field)) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
out.push(field);
|
|
73
|
+
const defaultBulkPatchAllowlistFrom = (params) => {
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const field of params.listFields) {
|
|
76
|
+
if (exports.SYSTEM_ADMIN_FIELDS.has(field)) {
|
|
77
|
+
continue;
|
|
178
78
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
79
|
+
if (params.hiddenFieldSet.has(field)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (params.readonlyFields.includes(field)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!params.schemaPaths.has(field)) {
|
|
86
|
+
continue;
|
|
184
87
|
}
|
|
185
|
-
|
|
88
|
+
out.push(field);
|
|
186
89
|
}
|
|
187
90
|
return out;
|
|
188
91
|
};
|
package/dist/aggregateAdmin.js
CHANGED
|
@@ -1,277 +1,154 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
var __values = (this && this.__values) || function(o) {
|
|
28
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
-
if (m) return m.call(o);
|
|
30
|
-
if (o && typeof o.length === "number") return {
|
|
31
|
-
next: function () {
|
|
32
|
-
if (o && i >= o.length) o = void 0;
|
|
33
|
-
return { value: o && o[i++], done: !o };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.aggregateFromTerrenoApp = exports.collectPluginAdminContributions = exports.collectRegisteredAdminModels = exports.aggregateAdminContributions = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
4
|
+
const api_1 = require("@terreno/api");
|
|
5
|
+
const legacy_1 = require("./legacy");
|
|
6
|
+
const resolvedAdminModel_1 = require("./resolvedAdminModel");
|
|
7
|
+
const routePath_1 = require("./routePath");
|
|
8
|
+
const isModelRouterRegistration = (registration) => {
|
|
45
9
|
return registration.__type === "modelRouter";
|
|
46
10
|
};
|
|
47
|
-
|
|
11
|
+
const contributionScriptToConfig = (script) => ({
|
|
48
12
|
args: script.args,
|
|
49
13
|
description: script.description,
|
|
50
14
|
name: script.name,
|
|
51
15
|
runner: script.runner,
|
|
52
|
-
});
|
|
53
|
-
|
|
16
|
+
});
|
|
17
|
+
const contributionScreenToConfig = (screen) => ({
|
|
54
18
|
adminAccess: screen.adminAccess,
|
|
55
19
|
displayName: screen.displayName,
|
|
20
|
+
group: screen.group,
|
|
21
|
+
icon: screen.icon,
|
|
56
22
|
name: screen.name,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var item = incoming_1_1.value;
|
|
65
|
-
if (seen.has(item.name)) {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
seen.add(item.name);
|
|
69
|
-
merged.push(item);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
73
|
-
finally {
|
|
74
|
-
try {
|
|
75
|
-
if (incoming_1_1 && !incoming_1_1.done && (_a = incoming_1.return)) _a.call(incoming_1);
|
|
23
|
+
});
|
|
24
|
+
const mergeUniqueByName = (existing, incoming) => {
|
|
25
|
+
const seen = new Set(existing.map((item) => item.name));
|
|
26
|
+
const merged = [...existing];
|
|
27
|
+
for (const item of incoming) {
|
|
28
|
+
if (seen.has(item.name)) {
|
|
29
|
+
continue;
|
|
76
30
|
}
|
|
77
|
-
|
|
31
|
+
seen.add(item.name);
|
|
32
|
+
merged.push(item);
|
|
78
33
|
}
|
|
79
34
|
return merged;
|
|
80
35
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var widget = incoming_2_1.value;
|
|
88
|
-
if (seen.has(widget.id)) {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
seen.add(widget.id);
|
|
92
|
-
merged.push(widget.id);
|
|
36
|
+
const mergeWidgetIds = (existing, incoming) => {
|
|
37
|
+
const seen = new Set(existing);
|
|
38
|
+
const merged = [...existing];
|
|
39
|
+
for (const widget of incoming) {
|
|
40
|
+
if (seen.has(widget.id)) {
|
|
41
|
+
continue;
|
|
93
42
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
finally {
|
|
97
|
-
try {
|
|
98
|
-
if (incoming_2_1 && !incoming_2_1.done && (_a = incoming_2.return)) _a.call(incoming_2);
|
|
99
|
-
}
|
|
100
|
-
finally { if (e_2) throw e_2.error; }
|
|
43
|
+
seen.add(widget.id);
|
|
44
|
+
merged.push(widget.id);
|
|
101
45
|
}
|
|
102
46
|
return merged;
|
|
103
47
|
};
|
|
104
|
-
|
|
105
|
-
api_1.logger.warn(
|
|
48
|
+
const warnShadowed = (path, incoming, existing) => {
|
|
49
|
+
api_1.logger.warn(`[admin] routePath "${path}" from ${incoming.source} (${incoming.sourceLabel}) overrides ${existing.source} (${existing.sourceLabel})`);
|
|
106
50
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (contribution.scripts) {
|
|
140
|
-
scripts = mergeUniqueByName(scripts, contribution.scripts.map(contributionScriptToConfig));
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
for (var _k = (e_5 = void 0, __values((_f = contribution.models) !== null && _f !== void 0 ? _f : [])), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
144
|
-
var modelContribution = _l.value;
|
|
145
|
-
var path = (0, routePath_1.normalizeAdminRoutePath)(modelContribution.routePath);
|
|
146
|
-
var resolved = (0, resolvedAdminModel_1.resolvedModelFromAdminConfig)({
|
|
147
|
-
admin: modelContribution.admin,
|
|
148
|
-
model: modelContribution.model,
|
|
149
|
-
populatePaths: modelContribution.populatePaths,
|
|
150
|
-
queryFilter: undefined,
|
|
151
|
-
routePath: path,
|
|
152
|
-
source: "plugin",
|
|
153
|
-
sourceLabel: modelContribution.admin.displayName,
|
|
154
|
-
});
|
|
155
|
-
var existing = modelsByPath.get(path);
|
|
156
|
-
if (existing) {
|
|
157
|
-
warnShadowed(path, resolved, existing);
|
|
158
|
-
}
|
|
159
|
-
modelsByPath.set(path, resolved);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
163
|
-
finally {
|
|
164
|
-
try {
|
|
165
|
-
if (_l && !_l.done && (_d = _k.return)) _d.call(_k);
|
|
166
|
-
}
|
|
167
|
-
finally { if (e_5) throw e_5.error; }
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
172
|
-
finally {
|
|
173
|
-
try {
|
|
174
|
-
if (pluginContributions_1_1 && !pluginContributions_1_1.done && (_c = pluginContributions_1.return)) _c.call(pluginContributions_1);
|
|
175
|
-
}
|
|
176
|
-
finally { if (e_4) throw e_4.error; }
|
|
177
|
-
}
|
|
178
|
-
try {
|
|
179
|
-
for (var registeredModels_1 = __values(registeredModels), registeredModels_1_1 = registeredModels_1.next(); !registeredModels_1_1.done; registeredModels_1_1 = registeredModels_1.next()) {
|
|
180
|
-
var registered = registeredModels_1_1.value;
|
|
181
|
-
var path = registered.routePath;
|
|
182
|
-
var existingRegistered = registeredByPath.get(path);
|
|
183
|
-
if (existingRegistered) {
|
|
184
|
-
throw new api_1.APIError({
|
|
185
|
-
status: 500,
|
|
186
|
-
title: "Duplicate admin modelRouter routePath \"".concat(path, "\" (").concat(existingRegistered.sourceLabel, " and ").concat(registered.sourceLabel, ")"),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
registeredByPath.set(path, registered);
|
|
190
|
-
var existing = modelsByPath.get(path);
|
|
51
|
+
const aggregateAdminContributions = ({ legacyModels = [], pluginContributions = [], registeredModels = [], }) => {
|
|
52
|
+
const modelsByPath = new Map();
|
|
53
|
+
const registeredByPath = new Map();
|
|
54
|
+
for (const legacy of legacyModels) {
|
|
55
|
+
const resolved = (0, legacy_1.convertLegacyModelConfig)(legacy);
|
|
56
|
+
modelsByPath.set(resolved.routePath, resolved);
|
|
57
|
+
}
|
|
58
|
+
let customScreens = [];
|
|
59
|
+
let scripts = [];
|
|
60
|
+
let widgetIds = [];
|
|
61
|
+
for (const contribution of pluginContributions) {
|
|
62
|
+
if (contribution.homeWidgets) {
|
|
63
|
+
widgetIds = mergeWidgetIds(widgetIds, contribution.homeWidgets);
|
|
64
|
+
}
|
|
65
|
+
if (contribution.customScreens) {
|
|
66
|
+
customScreens = mergeUniqueByName(customScreens, contribution.customScreens.map(contributionScreenToConfig));
|
|
67
|
+
}
|
|
68
|
+
if (contribution.scripts) {
|
|
69
|
+
scripts = mergeUniqueByName(scripts, contribution.scripts.map(contributionScriptToConfig));
|
|
70
|
+
}
|
|
71
|
+
for (const modelContribution of contribution.models ?? []) {
|
|
72
|
+
const path = (0, routePath_1.normalizeAdminRoutePath)(modelContribution.routePath);
|
|
73
|
+
const resolved = (0, resolvedAdminModel_1.resolvedModelFromAdminConfig)({
|
|
74
|
+
admin: modelContribution.admin,
|
|
75
|
+
model: modelContribution.model,
|
|
76
|
+
populatePaths: modelContribution.populatePaths,
|
|
77
|
+
queryFilter: undefined,
|
|
78
|
+
routePath: path,
|
|
79
|
+
source: "plugin",
|
|
80
|
+
sourceLabel: modelContribution.admin.displayName,
|
|
81
|
+
});
|
|
82
|
+
const existing = modelsByPath.get(path);
|
|
191
83
|
if (existing) {
|
|
192
|
-
warnShadowed(path,
|
|
84
|
+
warnShadowed(path, resolved, existing);
|
|
193
85
|
}
|
|
194
|
-
modelsByPath.set(path,
|
|
86
|
+
modelsByPath.set(path, resolved);
|
|
195
87
|
}
|
|
196
88
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
89
|
+
for (const registered of registeredModels) {
|
|
90
|
+
const path = registered.routePath;
|
|
91
|
+
const existingRegistered = registeredByPath.get(path);
|
|
92
|
+
if (existingRegistered) {
|
|
93
|
+
throw new api_1.APIError({
|
|
94
|
+
status: 500,
|
|
95
|
+
title: `Duplicate admin modelRouter routePath "${path}" (${existingRegistered.sourceLabel} and ${registered.sourceLabel})`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
registeredByPath.set(path, registered);
|
|
99
|
+
const existing = modelsByPath.get(path);
|
|
100
|
+
if (existing) {
|
|
101
|
+
warnShadowed(path, registered, existing);
|
|
201
102
|
}
|
|
202
|
-
|
|
103
|
+
modelsByPath.set(path, registered);
|
|
203
104
|
}
|
|
204
105
|
return {
|
|
205
|
-
customScreens
|
|
206
|
-
models:
|
|
207
|
-
scripts
|
|
208
|
-
widgetIds
|
|
106
|
+
customScreens,
|
|
107
|
+
models: [...modelsByPath.values()],
|
|
108
|
+
scripts,
|
|
109
|
+
widgetIds,
|
|
209
110
|
};
|
|
210
111
|
};
|
|
211
112
|
exports.aggregateAdminContributions = aggregateAdminContributions;
|
|
212
|
-
|
|
213
|
-
var e_7, _a;
|
|
113
|
+
const collectRegisteredAdminModels = (terrenoApp) => {
|
|
214
114
|
if (!terrenoApp) {
|
|
215
115
|
return [];
|
|
216
116
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
sourceLabel: registration.model.modelName,
|
|
232
|
-
}));
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
236
|
-
finally {
|
|
237
|
-
try {
|
|
238
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
239
|
-
}
|
|
240
|
-
finally { if (e_7) throw e_7.error; }
|
|
117
|
+
const models = [];
|
|
118
|
+
for (const registration of terrenoApp.getRegistrations()) {
|
|
119
|
+
if (!isModelRouterRegistration(registration) || !registration.options.admin) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
models.push((0, resolvedAdminModel_1.resolvedModelFromAdminConfig)({
|
|
123
|
+
admin: registration.options.admin,
|
|
124
|
+
model: registration.model,
|
|
125
|
+
populatePaths: registration.options.populatePaths,
|
|
126
|
+
registrationPath: registration.path,
|
|
127
|
+
routePath: registration.path,
|
|
128
|
+
source: "registered",
|
|
129
|
+
sourceLabel: registration.model.modelName,
|
|
130
|
+
}));
|
|
241
131
|
}
|
|
242
132
|
return models;
|
|
243
133
|
};
|
|
244
134
|
exports.collectRegisteredAdminModels = collectRegisteredAdminModels;
|
|
245
|
-
|
|
246
|
-
var e_8, _a;
|
|
247
|
-
var _b;
|
|
135
|
+
const collectPluginAdminContributions = (terrenoApp) => {
|
|
248
136
|
if (!terrenoApp) {
|
|
249
137
|
return [];
|
|
250
138
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (contribution) {
|
|
257
|
-
contributions.push(contribution);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
262
|
-
finally {
|
|
263
|
-
try {
|
|
264
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
139
|
+
const contributions = [];
|
|
140
|
+
for (const plugin of terrenoApp.getPlugins()) {
|
|
141
|
+
const contribution = plugin.adminContribution?.();
|
|
142
|
+
if (contribution) {
|
|
143
|
+
contributions.push(contribution);
|
|
265
144
|
}
|
|
266
|
-
finally { if (e_8) throw e_8.error; }
|
|
267
145
|
}
|
|
268
146
|
return contributions;
|
|
269
147
|
};
|
|
270
148
|
exports.collectPluginAdminContributions = collectPluginAdminContributions;
|
|
271
|
-
|
|
272
|
-
var _b = _a.legacyModels, legacyModels = _b === void 0 ? [] : _b, terrenoApp = _a.terrenoApp;
|
|
149
|
+
const aggregateFromTerrenoApp = ({ legacyModels = [], terrenoApp, }) => {
|
|
273
150
|
return (0, exports.aggregateAdminContributions)({
|
|
274
|
-
legacyModels
|
|
151
|
+
legacyModels,
|
|
275
152
|
pluginContributions: (0, exports.collectPluginAdminContributions)(terrenoApp),
|
|
276
153
|
registeredModels: (0, exports.collectRegisteredAdminModels)(terrenoApp),
|
|
277
154
|
});
|