@terreno/admin-backend 57.0.0-beta.1 → 57.1.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.
Files changed (43) hide show
  1. package/README.md +3 -0
  2. package/dist/adminApp.d.ts +11 -4
  3. package/dist/adminApp.js +859 -263
  4. package/dist/adminConfigIdentity.d.ts +16 -0
  5. package/dist/adminConfigIdentity.js +100 -0
  6. package/dist/adminTextSearch.d.ts +17 -0
  7. package/dist/adminTextSearch.js +117 -0
  8. package/dist/adminUiV2.js +1 -1
  9. package/dist/aggregateAdmin.d.ts +20 -0
  10. package/dist/aggregateAdmin.js +275 -0
  11. package/dist/documentStorageApp.d.ts +3 -1
  12. package/dist/documentStorageApp.js +20 -42
  13. package/dist/filterParser.d.ts +11 -0
  14. package/dist/filterParser.js +260 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/index.js +15 -1
  17. package/dist/legacy.d.ts +9 -0
  18. package/dist/legacy.js +61 -0
  19. package/dist/resolvedAdminModel.d.ts +23 -0
  20. package/dist/resolvedAdminModel.js +130 -0
  21. package/dist/routePath.d.ts +2 -0
  22. package/dist/routePath.js +18 -0
  23. package/package.json +4 -3
  24. package/src/adminApp.models.test.ts +894 -1
  25. package/src/adminApp.test.ts +35 -1
  26. package/src/adminApp.ts +599 -98
  27. package/src/adminConfigIdentity.test.ts +56 -0
  28. package/src/adminConfigIdentity.ts +87 -0
  29. package/src/adminTextSearch.test.ts +73 -0
  30. package/src/adminTextSearch.ts +74 -0
  31. package/src/adminUiV2.test.ts +1 -0
  32. package/src/adminUiV2.ts +1 -1
  33. package/src/aggregateAdmin.test.ts +220 -0
  34. package/src/aggregateAdmin.ts +206 -0
  35. package/src/documentStorageApp.test.ts +11 -0
  36. package/src/documentStorageApp.ts +20 -39
  37. package/src/filterParser.test.ts +68 -0
  38. package/src/filterParser.ts +229 -0
  39. package/src/index.ts +35 -0
  40. package/src/legacy.test.ts +34 -0
  41. package/src/legacy.ts +63 -0
  42. package/src/resolvedAdminModel.ts +114 -0
  43. package/src/routePath.ts +14 -0
@@ -0,0 +1,16 @@
1
+ import type { AdminModelSource } from "./resolvedAdminModel";
2
+ export interface AdminConfigNameInput {
3
+ modelName: string;
4
+ routePath: string;
5
+ source?: AdminModelSource;
6
+ }
7
+ export declare const slugFromAdminRoutePath: (routePath: string) => string;
8
+ /**
9
+ * UI route keys must be unique even when the same Mongoose model is mounted at
10
+ * two `routePath`s. Keep `modelName` for a singleton (and for the highest-precedence
11
+ * duplicate). Suffix the rest with the route slug.
12
+ */
13
+ export declare const assignUniqueAdminConfigNames: (entries: AdminConfigNameInput[]) => string[];
14
+ export declare const findAdminModelMetaByRoutePath: <T extends {
15
+ routePath: string;
16
+ }>(models: T[], mountedRoutePath: string) => T | undefined;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.findAdminModelMetaByRoutePath = exports.assignUniqueAdminConfigNames = exports.slugFromAdminRoutePath = void 0;
15
+ var SOURCE_RANK = {
16
+ legacy: 0,
17
+ plugin: 1,
18
+ registered: 2,
19
+ };
20
+ var slugFromAdminRoutePath = function (routePath) {
21
+ var trimmed = routePath.replace(/^\/+|\/+$/g, "").replace(/\//g, "-");
22
+ if (!trimmed) {
23
+ return "model";
24
+ }
25
+ return trimmed;
26
+ };
27
+ exports.slugFromAdminRoutePath = slugFromAdminRoutePath;
28
+ var sourceRank = function (source) {
29
+ if (!source) {
30
+ return 0;
31
+ }
32
+ return SOURCE_RANK[source];
33
+ };
34
+ /**
35
+ * UI route keys must be unique even when the same Mongoose model is mounted at
36
+ * two `routePath`s. Keep `modelName` for a singleton (and for the highest-precedence
37
+ * duplicate). Suffix the rest with the route slug.
38
+ */
39
+ var assignUniqueAdminConfigNames = function (entries) {
40
+ var e_1, _a;
41
+ var _b, _c;
42
+ var counts = new Map();
43
+ try {
44
+ for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
45
+ var entry = entries_1_1.value;
46
+ counts.set(entry.modelName, ((_b = counts.get(entry.modelName)) !== null && _b !== void 0 ? _b : 0) + 1);
47
+ }
48
+ }
49
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
50
+ finally {
51
+ try {
52
+ if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
53
+ }
54
+ finally { if (e_1) throw e_1.error; }
55
+ }
56
+ var preferredIndex = new Map();
57
+ for (var index = 0; index < entries.length; index += 1) {
58
+ var entry = entries[index];
59
+ if (!entry || ((_c = counts.get(entry.modelName)) !== null && _c !== void 0 ? _c : 0) <= 1) {
60
+ continue;
61
+ }
62
+ var existing = preferredIndex.get(entry.modelName);
63
+ if (existing === undefined) {
64
+ preferredIndex.set(entry.modelName, index);
65
+ continue;
66
+ }
67
+ var current = entries[existing];
68
+ if (!current) {
69
+ preferredIndex.set(entry.modelName, index);
70
+ continue;
71
+ }
72
+ if (sourceRank(entry.source) > sourceRank(current.source)) {
73
+ preferredIndex.set(entry.modelName, index);
74
+ }
75
+ }
76
+ var used = new Set();
77
+ return entries.map(function (entry, index) {
78
+ var _a;
79
+ var isDuplicate = ((_a = counts.get(entry.modelName)) !== null && _a !== void 0 ? _a : 0) > 1;
80
+ var keepBare = !isDuplicate || preferredIndex.get(entry.modelName) === index;
81
+ var candidate = keepBare
82
+ ? entry.modelName
83
+ : "".concat(entry.modelName, "-").concat((0, exports.slugFromAdminRoutePath)(entry.routePath));
84
+ if (used.has(candidate)) {
85
+ var base = candidate;
86
+ var suffix = 2;
87
+ while (used.has("".concat(base, "-").concat(suffix))) {
88
+ suffix += 1;
89
+ }
90
+ candidate = "".concat(base, "-").concat(suffix);
91
+ }
92
+ used.add(candidate);
93
+ return candidate;
94
+ });
95
+ };
96
+ exports.assignUniqueAdminConfigNames = assignUniqueAdminConfigNames;
97
+ var findAdminModelMetaByRoutePath = function (models, mountedRoutePath) {
98
+ return models.find(function (model) { return model.routePath === mountedRoutePath; });
99
+ };
100
+ exports.findAdminModelMetaByRoutePath = findAdminModelMetaByRoutePath;
@@ -0,0 +1,17 @@
1
+ import mongoose from "mongoose";
2
+ /** List-query param for the admin table search box. */
3
+ export declare const ADMIN_LIST_SEARCH_PARAM = "q";
4
+ export declare const escapeRegexLiteral: (value: string) => string;
5
+ /**
6
+ * Case-insensitive partial match across string `searchFields`, plus ObjectId equality
7
+ * when `q` is a valid id.
8
+ */
9
+ export declare const buildAdminPartialSearchFilter: ({ extraObjectIdFields, model, q, searchFields, }: {
10
+ extraObjectIdFields?: string[];
11
+ model: {
12
+ schema: mongoose.Schema;
13
+ };
14
+ q: string;
15
+ searchFields: string[];
16
+ }) => Record<string, unknown> | undefined;
17
+ export declare const andMongoFilters: (base: Record<string, unknown>, extra: Record<string, unknown> | undefined) => Record<string, unknown>;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
29
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
30
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31
+ if (ar || !(i in from)) {
32
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
33
+ ar[i] = from[i];
34
+ }
35
+ }
36
+ return to.concat(ar || Array.prototype.slice.call(from));
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.andMongoFilters = exports.buildAdminPartialSearchFilter = exports.escapeRegexLiteral = exports.ADMIN_LIST_SEARCH_PARAM = void 0;
43
+ var mongoose_1 = __importDefault(require("mongoose"));
44
+ /** List-query param for the admin table search box. */
45
+ exports.ADMIN_LIST_SEARCH_PARAM = "q";
46
+ var escapeRegexLiteral = function (value) {
47
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48
+ };
49
+ exports.escapeRegexLiteral = escapeRegexLiteral;
50
+ /**
51
+ * Case-insensitive partial match across string `searchFields`, plus ObjectId equality
52
+ * when `q` is a valid id.
53
+ */
54
+ var buildAdminPartialSearchFilter = function (_a) {
55
+ var e_1, _b, _c, e_2, _d, _e;
56
+ var extraObjectIdFields = _a.extraObjectIdFields, model = _a.model, q = _a.q, searchFields = _a.searchFields;
57
+ var trimmed = q.trim();
58
+ if (!trimmed) {
59
+ return undefined;
60
+ }
61
+ var regex = new RegExp((0, exports.escapeRegexLiteral)(trimmed), "i");
62
+ var orConditions = [];
63
+ var seenFields = new Set();
64
+ try {
65
+ for (var searchFields_1 = __values(searchFields), searchFields_1_1 = searchFields_1.next(); !searchFields_1_1.done; searchFields_1_1 = searchFields_1.next()) {
66
+ var field = searchFields_1_1.value;
67
+ if (seenFields.has(field)) {
68
+ continue;
69
+ }
70
+ seenFields.add(field);
71
+ var schemaPath = model.schema.path(field);
72
+ if (schemaPath && schemaPath.instance !== "String") {
73
+ continue;
74
+ }
75
+ orConditions.push((_c = {}, _c[field] = { $regex: regex }, _c));
76
+ }
77
+ }
78
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
79
+ finally {
80
+ try {
81
+ if (searchFields_1_1 && !searchFields_1_1.done && (_b = searchFields_1.return)) _b.call(searchFields_1);
82
+ }
83
+ finally { if (e_1) throw e_1.error; }
84
+ }
85
+ if (mongoose_1.default.isValidObjectId(trimmed)) {
86
+ var objectIdFields = extraObjectIdFields
87
+ ? __spreadArray([], __read(extraObjectIdFields), false) : Object.keys(model.schema.paths).filter(function (key) { var _a; return ((_a = model.schema.path(key)) === null || _a === void 0 ? void 0 : _a.instance) === "ObjectID"; });
88
+ try {
89
+ for (var objectIdFields_1 = __values(objectIdFields), objectIdFields_1_1 = objectIdFields_1.next(); !objectIdFields_1_1.done; objectIdFields_1_1 = objectIdFields_1.next()) {
90
+ var field = objectIdFields_1_1.value;
91
+ orConditions.push((_e = {}, _e[field] = new mongoose_1.default.Types.ObjectId(trimmed), _e));
92
+ }
93
+ }
94
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
95
+ finally {
96
+ try {
97
+ if (objectIdFields_1_1 && !objectIdFields_1_1.done && (_d = objectIdFields_1.return)) _d.call(objectIdFields_1);
98
+ }
99
+ finally { if (e_2) throw e_2.error; }
100
+ }
101
+ }
102
+ if (orConditions.length === 0) {
103
+ return undefined;
104
+ }
105
+ return { $or: orConditions };
106
+ };
107
+ exports.buildAdminPartialSearchFilter = buildAdminPartialSearchFilter;
108
+ var andMongoFilters = function (base, extra) {
109
+ if (!extra) {
110
+ return base;
111
+ }
112
+ if (Object.keys(base).length === 0) {
113
+ return extra;
114
+ }
115
+ return { $and: [base, extra] };
116
+ };
117
+ exports.andMongoFilters = andMongoFilters;
package/dist/adminUiV2.js CHANGED
@@ -96,7 +96,7 @@ exports.normalizeAdminHome = normalizeAdminHome;
96
96
  var buildAdminModelQueryFields = function (config) {
97
97
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
98
98
  var _e, _f, _g;
99
- var fields = new Set(["_id"]);
99
+ var fields = new Set(["_id", "q"]);
100
100
  try {
101
101
  for (var _h = __values(config.listFields), _j = _h.next(); !_j.done; _j = _h.next()) {
102
102
  var name_1 = _j.value;
@@ -0,0 +1,20 @@
1
+ import type { AdminContribution, TerrenoApp } from "@terreno/api";
2
+ import type { AdminCustomScreenConfig, AdminModelConfig, AdminScriptConfig } from "./adminApp";
3
+ import { type ResolvedAdminModel } from "./resolvedAdminModel";
4
+ export interface AggregatedAdminContributions {
5
+ customScreens: AdminCustomScreenConfig[];
6
+ models: ResolvedAdminModel[];
7
+ scripts: AdminScriptConfig[];
8
+ widgetIds: string[];
9
+ }
10
+ export declare const aggregateAdminContributions: ({ legacyModels, pluginContributions, registeredModels, }: {
11
+ legacyModels?: AdminModelConfig[];
12
+ pluginContributions?: AdminContribution[];
13
+ registeredModels?: ResolvedAdminModel[];
14
+ }) => AggregatedAdminContributions;
15
+ export declare const collectRegisteredAdminModels: (terrenoApp?: TerrenoApp) => ResolvedAdminModel[];
16
+ export declare const collectPluginAdminContributions: (terrenoApp?: TerrenoApp) => AdminContribution[];
17
+ export declare const aggregateFromTerrenoApp: ({ legacyModels, terrenoApp, }: {
18
+ legacyModels?: AdminModelConfig[];
19
+ terrenoApp?: TerrenoApp;
20
+ }) => AggregatedAdminContributions;
@@ -0,0 +1,275 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.aggregateFromTerrenoApp = exports.collectPluginAdminContributions = exports.collectRegisteredAdminModels = exports.aggregateAdminContributions = void 0;
40
+ var api_1 = require("@terreno/api");
41
+ var legacy_1 = require("./legacy");
42
+ var resolvedAdminModel_1 = require("./resolvedAdminModel");
43
+ var routePath_1 = require("./routePath");
44
+ var isModelRouterRegistration = function (registration) {
45
+ return registration.__type === "modelRouter";
46
+ };
47
+ var contributionScriptToConfig = function (script) { return ({
48
+ args: script.args,
49
+ description: script.description,
50
+ name: script.name,
51
+ runner: script.runner,
52
+ }); };
53
+ var contributionScreenToConfig = function (screen) { return ({
54
+ displayName: screen.displayName,
55
+ name: screen.name,
56
+ }); };
57
+ var mergeUniqueByName = function (existing, incoming) {
58
+ var e_1, _a;
59
+ var seen = new Set(existing.map(function (item) { return item.name; }));
60
+ var merged = __spreadArray([], __read(existing), false);
61
+ try {
62
+ for (var incoming_1 = __values(incoming), incoming_1_1 = incoming_1.next(); !incoming_1_1.done; incoming_1_1 = incoming_1.next()) {
63
+ var item = incoming_1_1.value;
64
+ if (seen.has(item.name)) {
65
+ continue;
66
+ }
67
+ seen.add(item.name);
68
+ merged.push(item);
69
+ }
70
+ }
71
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
72
+ finally {
73
+ try {
74
+ if (incoming_1_1 && !incoming_1_1.done && (_a = incoming_1.return)) _a.call(incoming_1);
75
+ }
76
+ finally { if (e_1) throw e_1.error; }
77
+ }
78
+ return merged;
79
+ };
80
+ var mergeWidgetIds = function (existing, incoming) {
81
+ var e_2, _a;
82
+ var seen = new Set(existing);
83
+ var merged = __spreadArray([], __read(existing), false);
84
+ try {
85
+ for (var incoming_2 = __values(incoming), incoming_2_1 = incoming_2.next(); !incoming_2_1.done; incoming_2_1 = incoming_2.next()) {
86
+ var widget = incoming_2_1.value;
87
+ if (seen.has(widget.id)) {
88
+ continue;
89
+ }
90
+ seen.add(widget.id);
91
+ merged.push(widget.id);
92
+ }
93
+ }
94
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
95
+ finally {
96
+ try {
97
+ if (incoming_2_1 && !incoming_2_1.done && (_a = incoming_2.return)) _a.call(incoming_2);
98
+ }
99
+ finally { if (e_2) throw e_2.error; }
100
+ }
101
+ return merged;
102
+ };
103
+ var warnShadowed = function (path, incoming, existing) {
104
+ api_1.logger.warn("[admin] routePath \"".concat(path, "\" from ").concat(incoming.source, " (").concat(incoming.sourceLabel, ") overrides ").concat(existing.source, " (").concat(existing.sourceLabel, ")"));
105
+ };
106
+ var aggregateAdminContributions = function (_a) {
107
+ var e_3, _b, e_4, _c, e_5, _d, e_6, _e;
108
+ var _f;
109
+ var _g = _a.legacyModels, legacyModels = _g === void 0 ? [] : _g, _h = _a.pluginContributions, pluginContributions = _h === void 0 ? [] : _h, _j = _a.registeredModels, registeredModels = _j === void 0 ? [] : _j;
110
+ var modelsByPath = new Map();
111
+ var registeredByPath = new Map();
112
+ try {
113
+ for (var legacyModels_1 = __values(legacyModels), legacyModels_1_1 = legacyModels_1.next(); !legacyModels_1_1.done; legacyModels_1_1 = legacyModels_1.next()) {
114
+ var legacy = legacyModels_1_1.value;
115
+ var resolved = (0, legacy_1.convertLegacyModelConfig)(legacy);
116
+ modelsByPath.set(resolved.routePath, resolved);
117
+ }
118
+ }
119
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
120
+ finally {
121
+ try {
122
+ if (legacyModels_1_1 && !legacyModels_1_1.done && (_b = legacyModels_1.return)) _b.call(legacyModels_1);
123
+ }
124
+ finally { if (e_3) throw e_3.error; }
125
+ }
126
+ var customScreens = [];
127
+ var scripts = [];
128
+ var widgetIds = [];
129
+ try {
130
+ for (var pluginContributions_1 = __values(pluginContributions), pluginContributions_1_1 = pluginContributions_1.next(); !pluginContributions_1_1.done; pluginContributions_1_1 = pluginContributions_1.next()) {
131
+ var contribution = pluginContributions_1_1.value;
132
+ if (contribution.homeWidgets) {
133
+ widgetIds = mergeWidgetIds(widgetIds, contribution.homeWidgets);
134
+ }
135
+ if (contribution.customScreens) {
136
+ customScreens = mergeUniqueByName(customScreens, contribution.customScreens.map(contributionScreenToConfig));
137
+ }
138
+ if (contribution.scripts) {
139
+ scripts = mergeUniqueByName(scripts, contribution.scripts.map(contributionScriptToConfig));
140
+ }
141
+ try {
142
+ for (var _k = (e_5 = void 0, __values((_f = contribution.models) !== null && _f !== void 0 ? _f : [])), _l = _k.next(); !_l.done; _l = _k.next()) {
143
+ var modelContribution = _l.value;
144
+ var path = (0, routePath_1.normalizeAdminRoutePath)(modelContribution.routePath);
145
+ var resolved = (0, resolvedAdminModel_1.resolvedModelFromAdminConfig)({
146
+ admin: modelContribution.admin,
147
+ model: modelContribution.model,
148
+ populatePaths: modelContribution.populatePaths,
149
+ queryFilter: undefined,
150
+ routePath: path,
151
+ source: "plugin",
152
+ sourceLabel: modelContribution.admin.displayName,
153
+ });
154
+ var existing = modelsByPath.get(path);
155
+ if (existing) {
156
+ warnShadowed(path, resolved, existing);
157
+ }
158
+ modelsByPath.set(path, resolved);
159
+ }
160
+ }
161
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
162
+ finally {
163
+ try {
164
+ if (_l && !_l.done && (_d = _k.return)) _d.call(_k);
165
+ }
166
+ finally { if (e_5) throw e_5.error; }
167
+ }
168
+ }
169
+ }
170
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
171
+ finally {
172
+ try {
173
+ if (pluginContributions_1_1 && !pluginContributions_1_1.done && (_c = pluginContributions_1.return)) _c.call(pluginContributions_1);
174
+ }
175
+ finally { if (e_4) throw e_4.error; }
176
+ }
177
+ try {
178
+ for (var registeredModels_1 = __values(registeredModels), registeredModels_1_1 = registeredModels_1.next(); !registeredModels_1_1.done; registeredModels_1_1 = registeredModels_1.next()) {
179
+ var registered = registeredModels_1_1.value;
180
+ var path = registered.routePath;
181
+ var existingRegistered = registeredByPath.get(path);
182
+ if (existingRegistered) {
183
+ throw new Error("Duplicate admin modelRouter routePath \"".concat(path, "\" (").concat(existingRegistered.sourceLabel, " and ").concat(registered.sourceLabel, ")"));
184
+ }
185
+ registeredByPath.set(path, registered);
186
+ var existing = modelsByPath.get(path);
187
+ if (existing) {
188
+ warnShadowed(path, registered, existing);
189
+ }
190
+ modelsByPath.set(path, registered);
191
+ }
192
+ }
193
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
194
+ finally {
195
+ try {
196
+ if (registeredModels_1_1 && !registeredModels_1_1.done && (_e = registeredModels_1.return)) _e.call(registeredModels_1);
197
+ }
198
+ finally { if (e_6) throw e_6.error; }
199
+ }
200
+ return {
201
+ customScreens: customScreens,
202
+ models: __spreadArray([], __read(modelsByPath.values()), false),
203
+ scripts: scripts,
204
+ widgetIds: widgetIds,
205
+ };
206
+ };
207
+ exports.aggregateAdminContributions = aggregateAdminContributions;
208
+ var collectRegisteredAdminModels = function (terrenoApp) {
209
+ var e_7, _a;
210
+ if (!terrenoApp) {
211
+ return [];
212
+ }
213
+ var models = [];
214
+ try {
215
+ for (var _b = __values(terrenoApp.getRegistrations()), _c = _b.next(); !_c.done; _c = _b.next()) {
216
+ var registration = _c.value;
217
+ if (!isModelRouterRegistration(registration) || !registration.options.admin) {
218
+ continue;
219
+ }
220
+ models.push((0, resolvedAdminModel_1.resolvedModelFromAdminConfig)({
221
+ admin: registration.options.admin,
222
+ model: registration.model,
223
+ populatePaths: registration.options.populatePaths,
224
+ registrationPath: registration.path,
225
+ routePath: registration.path,
226
+ source: "registered",
227
+ sourceLabel: registration.model.modelName,
228
+ }));
229
+ }
230
+ }
231
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
232
+ finally {
233
+ try {
234
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
235
+ }
236
+ finally { if (e_7) throw e_7.error; }
237
+ }
238
+ return models;
239
+ };
240
+ exports.collectRegisteredAdminModels = collectRegisteredAdminModels;
241
+ var collectPluginAdminContributions = function (terrenoApp) {
242
+ var e_8, _a;
243
+ var _b;
244
+ if (!terrenoApp) {
245
+ return [];
246
+ }
247
+ var contributions = [];
248
+ try {
249
+ for (var _c = __values(terrenoApp.getPlugins()), _d = _c.next(); !_d.done; _d = _c.next()) {
250
+ var plugin = _d.value;
251
+ var contribution = (_b = plugin.adminContribution) === null || _b === void 0 ? void 0 : _b.call(plugin);
252
+ if (contribution) {
253
+ contributions.push(contribution);
254
+ }
255
+ }
256
+ }
257
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
258
+ finally {
259
+ try {
260
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
261
+ }
262
+ finally { if (e_8) throw e_8.error; }
263
+ }
264
+ return contributions;
265
+ };
266
+ exports.collectPluginAdminContributions = collectPluginAdminContributions;
267
+ var aggregateFromTerrenoApp = function (_a) {
268
+ var _b = _a.legacyModels, legacyModels = _b === void 0 ? [] : _b, terrenoApp = _a.terrenoApp;
269
+ return (0, exports.aggregateAdminContributions)({
270
+ legacyModels: legacyModels,
271
+ pluginContributions: (0, exports.collectPluginAdminContributions)(terrenoApp),
272
+ registeredModels: (0, exports.collectRegisteredAdminModels)(terrenoApp),
273
+ });
274
+ };
275
+ exports.aggregateFromTerrenoApp = aggregateFromTerrenoApp;
@@ -1,3 +1,4 @@
1
+ import { type AdminContribution, type TerrenoPlugin } from "@terreno/api";
1
2
  import type express from "express";
2
3
  export interface DocumentStorageOptions {
3
4
  bucketName: string;
@@ -20,10 +21,11 @@ export interface DocumentListResponse {
20
21
  folders: string[];
21
22
  prefix: string;
22
23
  }
23
- export declare class DocumentStorageApp {
24
+ export declare class DocumentStorageApp implements TerrenoPlugin {
24
25
  private options;
25
26
  private storage;
26
27
  constructor(options: DocumentStorageOptions);
28
+ adminContribution(): AdminContribution;
27
29
  private get bucket();
28
30
  private get prefix();
29
31
  private get allowedMimeTypes();