@saasicat/ui-vue 0.3.0 → 0.5.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 (109) hide show
  1. package/README.md +47 -4
  2. package/dist/action-registry-CQ2wL3R-.d.cts +85 -0
  3. package/dist/action-registry-CQ2wL3R-.d.ts +85 -0
  4. package/dist/chunk-3YP2ZAOD.js +63 -0
  5. package/dist/chunk-EH7TOD4H.js +718 -0
  6. package/dist/chunk-LVGUSD3T.js +26 -0
  7. package/dist/client/index.cjs +785 -0
  8. package/dist/client/index.d.cts +295 -0
  9. package/dist/client/index.d.ts +295 -0
  10. package/dist/client/index.js +52 -0
  11. package/dist/index.cjs +787 -834
  12. package/dist/index.d.cts +267 -841
  13. package/dist/index.d.ts +267 -841
  14. package/dist/index.js +284 -1059
  15. package/dist/quasar/index.cjs +159 -0
  16. package/dist/quasar/index.d.cts +86 -0
  17. package/dist/quasar/index.d.ts +86 -0
  18. package/dist/quasar/index.js +91 -0
  19. package/dist/ui-notify-COUzXEQ4.d.ts +178 -0
  20. package/dist/ui-notify-D_eAAwRh.d.cts +178 -0
  21. package/package.json +23 -3
  22. package/src/client/index.ts +25 -0
  23. package/src/components/FeatureGate.vue +1 -1
  24. package/src/components/plan/PlanCycleToggle.vue +1 -1
  25. package/src/components/plan/PlanGrid.vue +2 -2
  26. package/src/components/plan/PriceSummary.vue +1 -1
  27. package/src/components/plan/PromoCodeInput.vue +1 -1
  28. package/src/components/plan/PublicBundleGrid.vue +1 -1
  29. package/src/index.ts +82 -79
  30. package/src/pages-standard/AdminLayout.vue +2 -2
  31. package/src/pages-standard/DashboardPage.vue +2 -2
  32. package/src/pages-standard/EmailHistoryPage.vue +9 -13
  33. package/src/pages-standard/MarketingCatalogPage.vue +5 -5
  34. package/src/pages-standard/PilotsPage.vue +9 -13
  35. package/src/pages-standard/PlanVersionsPage.vue +2 -2
  36. package/src/pages-standard/PlansPage.vue +2 -2
  37. package/src/pages-standard/PlatformEmailPage.vue +7 -5
  38. package/src/pages-standard/PromoCodesPage.vue +8 -22
  39. package/src/pages-standard/SuperAdminLoginPage.vue +3 -3
  40. package/src/pages-standard/SuperAdminSetupWizard.vue +2 -2
  41. package/src/pages-standard/TenantDetailPage.vue +4 -4
  42. package/src/pages-standard/TenantsPage.vue +3 -3
  43. package/src/pages-standard/UsersPage.vue +6 -12
  44. package/src/pages-standard/plan-versions/PlanVersionHeader.vue +1 -1
  45. package/src/pages-standard/plan-versions/PlanVersionsAudit.vue +1 -1
  46. package/src/pages-standard/plan-versions/PlanVersionsDiff.vue +1 -1
  47. package/src/pages-standard/plan-versions/PlanVersionsList.vue +1 -1
  48. package/src/pages-standard/plan-versions/PlanVersionsMatrix.vue +1 -1
  49. package/src/pages-standard/plan-versions/PlanVersionsTimeline.vue +1 -1
  50. package/src/pages-tenant/MySubscriptionBundlesPage.vue +1 -1
  51. package/src/pages-tenant/OnboardingConfigurator.vue +3 -3
  52. package/src/pages-tenant/PackageSnapshotPanel.vue +1 -1
  53. package/src/pages-tenant/PlanChangeWizard.vue +2 -2
  54. package/src/pages-tenant/TenantPlanSection.vue +3 -3
  55. package/src/pages-tenant/tenant-plan-section/BundlePreviewDialog.vue +1 -1
  56. package/src/pages-tenant/tenant-plan-section/TenantBundleStore.vue +2 -2
  57. package/src/pages-tenant/tenant-plan-section/TenantPlanCardHeader.vue +1 -1
  58. package/src/pages-tenant/tenant-plan-section/TenantUsageGrid.vue +1 -1
  59. package/src/quasar/create-super-admin-app.ts +173 -0
  60. package/src/quasar/index.ts +11 -0
  61. package/src/quasar/notify.ts +30 -0
  62. package/src/{manifest-store-factory.ts → vue/manifest-store-factory.ts} +1 -1
  63. package/src/{platform-loaders.ts → vue/platform-loaders.ts} +4 -4
  64. package/src/{project-page-host.ts → vue/project-page-host.ts} +1 -1
  65. package/src/{create-super-admin-app.ts → vue/super-admin-context.ts} +20 -139
  66. package/src/vue/ui-notify.ts +30 -0
  67. package/src/{use-actions.ts → vue/use-actions.ts} +1 -1
  68. package/src/{use-api-list.ts → vue/use-api-list.ts} +1 -1
  69. package/src/{use-batch-columns.ts → vue/use-batch-columns.ts} +1 -1
  70. package/src/{use-bulk-publish.ts → vue/use-bulk-publish.ts} +1 -1
  71. package/src/{use-bundle-versions-map.ts → vue/use-bundle-versions-map.ts} +1 -1
  72. package/src/{use-bundles.ts → vue/use-bundles.ts} +1 -1
  73. package/src/{use-business-types.ts → vue/use-business-types.ts} +1 -1
  74. package/src/{use-catalog-entries.ts → vue/use-catalog-entries.ts} +1 -1
  75. package/src/{use-discovery.ts → vue/use-discovery.ts} +1 -1
  76. package/src/{use-entitlement.ts → vue/use-entitlement.ts} +1 -1
  77. package/src/{use-live-plan-versions.ts → vue/use-live-plan-versions.ts} +1 -1
  78. package/src/{use-manifest.ts → vue/use-manifest.ts} +1 -1
  79. package/src/{use-marketing-projections.ts → vue/use-marketing-projections.ts} +1 -1
  80. package/src/{use-nav.ts → vue/use-nav.ts} +1 -1
  81. package/src/{use-plans.ts → vue/use-plans.ts} +1 -1
  82. package/src/{use-promotions.ts → vue/use-promotions.ts} +1 -1
  83. package/src/{use-public-boot.ts → vue/use-public-boot.ts} +1 -1
  84. package/src/{use-super-admin-context.ts → vue/use-super-admin-context.ts} +2 -2
  85. package/src/{use-tenant-action-flow.ts → vue/use-tenant-action-flow.ts} +1 -1
  86. package/src/{use-tenant-billing-catalog.ts → vue/use-tenant-billing-catalog.ts} +2 -2
  87. package/src/{use-tenant-billing.ts → vue/use-tenant-billing.ts} +2 -2
  88. package/src/{use-tenant-manifest.ts → vue/use-tenant-manifest.ts} +1 -1
  89. package/src/{use-tenant-subscription-bundles.ts → vue/use-tenant-subscription-bundles.ts} +1 -1
  90. package/dist/testing-e2e/admin-pages-suite.d.cts +0 -37
  91. package/dist/testing-e2e/admin-pages-suite.d.ts +0 -37
  92. /package/src/{action-registry.ts → client/action-registry.ts} +0 -0
  93. /package/src/{batch-column-fetcher.ts → client/batch-column-fetcher.ts} +0 -0
  94. /package/src/{boot-loader.ts → client/boot-loader.ts} +0 -0
  95. /package/src/{http-json.ts → client/http-json.ts} +0 -0
  96. /package/src/{manifest-loader.ts → client/manifest-loader.ts} +0 -0
  97. /package/src/{nav-builder.ts → client/nav-builder.ts} +0 -0
  98. /package/src/{plan-versions-catalog.ts → client/plan-versions-catalog.ts} +0 -0
  99. /package/src/{types.ts → client/types.ts} +0 -0
  100. /package/src/{version.ts → client/version.ts} +0 -0
  101. /package/src/{create-admin-routes.ts → vue/create-admin-routes.ts} +0 -0
  102. /package/src/{entitlement-provider.ts → vue/entitlement-provider.ts} +0 -0
  103. /package/src/{feature-router-guard.ts → vue/feature-router-guard.ts} +0 -0
  104. /package/src/{use-audit-entries.ts → vue/use-audit-entries.ts} +0 -0
  105. /package/src/{use-plan-editor.ts → vue/use-plan-editor.ts} +0 -0
  106. /package/src/{use-plan-versions.ts → vue/use-plan-versions.ts} +0 -0
  107. /package/src/{use-platform-tenant-actions.ts → vue/use-platform-tenant-actions.ts} +0 -0
  108. /package/src/{use-subscription-draft.ts → vue/use-subscription-draft.ts} +0 -0
  109. /package/src/{use-tenants.ts → vue/use-tenants.ts} +0 -0
@@ -0,0 +1,718 @@
1
+ import {
2
+ defaultHttpClient,
3
+ defaultKvStore
4
+ } from "./chunk-LVGUSD3T.js";
5
+
6
+ // src/client/version.ts
7
+ var ADMIN_UI_VERSION = "1.2.0";
8
+
9
+ // src/client/http-json.ts
10
+ var HttpJsonError = class extends Error {
11
+ constructor(status, code) {
12
+ super(code ?? `HTTP ${status}`);
13
+ this.status = status;
14
+ this.code = code;
15
+ this.name = "HttpJsonError";
16
+ }
17
+ status;
18
+ code;
19
+ };
20
+ async function extractCode(res) {
21
+ try {
22
+ const body = await res.json();
23
+ return typeof body?.code === "string" ? body.code : void 0;
24
+ } catch {
25
+ return void 0;
26
+ }
27
+ }
28
+ function trimTrailingSlashes(url) {
29
+ let end = url.length;
30
+ while (end > 0 && url[end - 1] === "/") end--;
31
+ return url.slice(0, end);
32
+ }
33
+ async function getJson(http, url) {
34
+ const res = await http(url);
35
+ if (res.status < 200 || res.status >= 300) {
36
+ throw new HttpJsonError(res.status, await extractCode(res));
37
+ }
38
+ return await res.json();
39
+ }
40
+ async function postJson(http, url, body) {
41
+ const res = await http(url, {
42
+ method: "POST",
43
+ headers: { "Content-Type": "application/json" },
44
+ body: JSON.stringify(body)
45
+ });
46
+ if (res.status < 200 || res.status >= 300) {
47
+ throw new HttpJsonError(res.status, await extractCode(res));
48
+ }
49
+ return await res.json();
50
+ }
51
+
52
+ // src/client/boot-loader.ts
53
+ var BootLoadError = class extends Error {
54
+ constructor(status, message) {
55
+ super(message);
56
+ this.status = status;
57
+ this.name = "BootLoadError";
58
+ }
59
+ status;
60
+ };
61
+ var BootLoader = class {
62
+ endpoint;
63
+ http;
64
+ constructor(options) {
65
+ if (!options?.endpoint) {
66
+ throw new Error(
67
+ 'BootLoader: `endpoint` ist Pflicht (z. B. "/api/admin/boot" oder "/api/v1/admin/boot"). Plattform hat keinen Default, weil Apps unterschiedliche globalPrefix-Konventionen haben.'
68
+ );
69
+ }
70
+ this.endpoint = options.endpoint;
71
+ this.http = options.http ?? defaultHttpClient();
72
+ }
73
+ async load() {
74
+ const res = await this.http(this.endpoint);
75
+ if (res.status !== 200) {
76
+ throw new BootLoadError(res.status, `Boot-Endpunkt antwortete HTTP ${res.status}`);
77
+ }
78
+ return await res.json();
79
+ }
80
+ };
81
+
82
+ // src/client/manifest-loader.ts
83
+ var ManifestLoadError = class extends Error {
84
+ constructor(status, message) {
85
+ super(message);
86
+ this.status = status;
87
+ this.name = "ManifestLoadError";
88
+ }
89
+ status;
90
+ };
91
+ var ManifestLoader = class {
92
+ endpoint;
93
+ http;
94
+ storage;
95
+ bodyKey;
96
+ etagKey;
97
+ getAuthToken;
98
+ constructor(options) {
99
+ if (!options?.endpoint) {
100
+ throw new Error(
101
+ 'ManifestLoader: `endpoint` ist Pflicht (z. B. "/api/admin/manifest" oder "/api/v1/admin/manifest"). Plattform hat keinen Default, weil Apps unterschiedliche globalPrefix-Konventionen haben.'
102
+ );
103
+ }
104
+ this.endpoint = options.endpoint;
105
+ this.http = options.http ?? defaultHttpClient();
106
+ this.storage = options.storage ?? defaultKvStore();
107
+ const prefix = options.storageKeyPrefix ?? "";
108
+ this.bodyKey = `${prefix}manifest:body`;
109
+ this.etagKey = `${prefix}manifest:etag`;
110
+ this.getAuthToken = options.getAuthToken;
111
+ }
112
+ /**
113
+ * Loads the current manifest. On a cache hit (304) the cached
114
+ * body is returned — otherwise the fresh server body.
115
+ */
116
+ async load() {
117
+ const cachedEtag = this.storage.get(this.etagKey);
118
+ const headers = {};
119
+ const token = this.getAuthToken?.();
120
+ if (token) headers.Authorization = `Bearer ${token}`;
121
+ if (cachedEtag) headers["If-None-Match"] = cachedEtag;
122
+ const res = await this.http(this.endpoint, { method: "GET", headers });
123
+ if (res.status === 304) {
124
+ const cachedBody = this.readCachedBody();
125
+ if (!cachedBody) {
126
+ throw new ManifestLoadError(
127
+ 304,
128
+ "Server lieferte 304, aber Cache-Body fehlt \u2014 bitte clearCache() + reload"
129
+ );
130
+ }
131
+ return cachedBody.body;
132
+ }
133
+ if (res.status !== 200) {
134
+ throw new ManifestLoadError(
135
+ res.status,
136
+ `Manifest-Endpunkt antwortete HTTP ${res.status}`
137
+ );
138
+ }
139
+ const body = await res.json();
140
+ const etag = res.headers.get("ETag") ?? res.headers.get("etag");
141
+ if (etag) {
142
+ this.storage.set(this.etagKey, etag);
143
+ this.storage.set(this.bodyKey, JSON.stringify(body));
144
+ }
145
+ return body;
146
+ }
147
+ /** Reads the cached manifest body from storage; null if absent. */
148
+ readCachedBody() {
149
+ const etag = this.storage.get(this.etagKey);
150
+ const bodyStr = this.storage.get(this.bodyKey);
151
+ if (!etag || !bodyStr) return null;
152
+ try {
153
+ return { etag, body: JSON.parse(bodyStr) };
154
+ } catch {
155
+ return null;
156
+ }
157
+ }
158
+ /** Clears the cache — e.g. on logout or after `manifest reload`. */
159
+ clearCache() {
160
+ this.storage.remove(this.etagKey);
161
+ this.storage.remove(this.bodyKey);
162
+ }
163
+ };
164
+
165
+ // src/client/nav-builder.ts
166
+ var DEFAULT_STANDARD_PAGE_ROUTES = {
167
+ dashboard: "/admin/dashboard",
168
+ tenants: "/admin/tenants",
169
+ subscriptions: "/admin/subscriptions",
170
+ promoCodes: "/admin/promo-codes",
171
+ plans: "/admin/plans",
172
+ planVersions: "/admin/plan-versions",
173
+ audit: "/admin/audit",
174
+ users: "/admin/users",
175
+ pilots: "/admin/pilots",
176
+ discovery: "/admin/discovery",
177
+ bundles: "/admin/bundles",
178
+ businessTypes: "/admin/business-types",
179
+ marketingCatalog: "/admin/marketing-catalog",
180
+ platformEmail: "/admin/platform-email",
181
+ platformEmailHistory: "/admin/platform-email-history"
182
+ };
183
+ var DEFAULT_LABELS = {
184
+ dashboard: "Dashboard",
185
+ tenants: "Mandanten",
186
+ subscriptions: "Abonnements",
187
+ promoCodes: "Promo-Codes",
188
+ plans: "Pl\xE4ne & Versionen",
189
+ planVersions: "Plan-Versionen",
190
+ audit: "Audit-Log",
191
+ users: "Benutzer",
192
+ pilots: "Piloten",
193
+ discovery: "Discovery",
194
+ bundles: "Bundles",
195
+ businessTypes: "Gesch\xE4ftstypen",
196
+ marketingCatalog: "Marketing-Catalog",
197
+ platformEmail: "Plattform-E-Mail",
198
+ platformEmailHistory: "E-Mail-Verlauf"
199
+ };
200
+ var DEFAULT_ICONS = {
201
+ dashboard: "dashboard",
202
+ tenants: "business",
203
+ subscriptions: "card_membership",
204
+ promoCodes: "local_activity",
205
+ plans: "workspace_premium",
206
+ planVersions: "history_edu",
207
+ audit: "history",
208
+ users: "people",
209
+ pilots: "flight_takeoff",
210
+ discovery: "travel_explore",
211
+ bundles: "inventory_2",
212
+ businessTypes: "category",
213
+ marketingCatalog: "campaign",
214
+ platformEmail: "mail",
215
+ platformEmailHistory: "mark_email_read"
216
+ };
217
+ var DEFAULT_NAV_SECTIONS = {
218
+ dashboard: "\xDCbersicht",
219
+ discovery: "Produktkatalog",
220
+ businessTypes: "Produktkatalog",
221
+ bundles: "Produktkatalog",
222
+ plans: "Produktkatalog",
223
+ planVersions: "Produktkatalog",
224
+ marketingCatalog: "Produktkatalog",
225
+ promoCodes: "Produktkatalog",
226
+ tenants: "Kunden",
227
+ subscriptions: "Kunden",
228
+ users: "Kunden",
229
+ pilots: "Kunden",
230
+ audit: "System",
231
+ platformEmail: "System",
232
+ platformEmailHistory: "System"
233
+ };
234
+ var DEFAULT_SECTION_ORDER = [
235
+ "\xDCbersicht",
236
+ "Produktkatalog",
237
+ "Kunden",
238
+ "System"
239
+ ];
240
+ function buildRoutes(manifest, options = {}) {
241
+ const routes = [];
242
+ const capabilities = manifest.capabilities ?? {};
243
+ const standard = manifest.navigation?.standardPages ?? {};
244
+ const overrideRoutes = { ...DEFAULT_STANDARD_PAGE_ROUTES, ...options.standardPageRoutes };
245
+ const overrideLabels = { ...DEFAULT_LABELS, ...options.standardPageLabels };
246
+ const overrideIcons = { ...DEFAULT_ICONS, ...options.standardPageIcons };
247
+ const overrideNavSection = { ...DEFAULT_NAV_SECTIONS, ...options.standardPageNavSection };
248
+ for (const key of Object.keys(standard)) {
249
+ const def = standard[key];
250
+ if (!def?.enabled) continue;
251
+ const cap = def.requiredCapability ?? null;
252
+ if (cap && capabilities[cap] !== true) continue;
253
+ routes.push({
254
+ id: key,
255
+ path: overrideRoutes[key],
256
+ label: overrideLabels[key],
257
+ icon: overrideIcons[key],
258
+ navSection: overrideNavSection[key],
259
+ componentKey: `platform-${key}`,
260
+ requiredCapability: cap,
261
+ isStandard: true
262
+ });
263
+ }
264
+ const projectPages = manifest.navigation?.projectPages ?? [];
265
+ const exts = options.availableExtensions;
266
+ for (const p of projectPages) {
267
+ const cap = p.requiredCapability ?? null;
268
+ if (cap && capabilities[cap] !== true) continue;
269
+ if (exts && !exts.has(p.componentKey)) continue;
270
+ routes.push({
271
+ id: p.id,
272
+ path: p.route,
273
+ label: p.label,
274
+ icon: p.icon,
275
+ navSection: p.navSection,
276
+ componentKey: p.componentKey,
277
+ requiredCapability: cap,
278
+ isStandard: false,
279
+ prefetchOnIdle: p.prefetchOnIdle
280
+ });
281
+ }
282
+ return routes;
283
+ }
284
+ function buildSidebar(routes, sectionOrder = DEFAULT_SECTION_ORDER) {
285
+ const bySection = /* @__PURE__ */ new Map();
286
+ for (const r of routes) {
287
+ const section = r.navSection ?? null;
288
+ const list = bySection.get(section) ?? [];
289
+ list.push({ id: r.id, path: r.path, label: r.label, icon: r.icon });
290
+ bySection.set(section, list);
291
+ }
292
+ const sections = [];
293
+ if (bySection.has(null)) {
294
+ sections.push({ section: null, items: bySection.get(null) });
295
+ }
296
+ const ordered = /* @__PURE__ */ new Set();
297
+ for (const name of sectionOrder) {
298
+ if (bySection.has(name)) {
299
+ sections.push({ section: name, items: bySection.get(name) });
300
+ ordered.add(name);
301
+ }
302
+ }
303
+ const remaining = [...bySection.entries()].filter(([s]) => s !== null && !ordered.has(s)).sort((a, b) => a[0].localeCompare(b[0]));
304
+ for (const [section, items] of remaining) {
305
+ sections.push({ section, items });
306
+ }
307
+ return sections;
308
+ }
309
+ function resolveExtension(componentKey, extensions) {
310
+ return extensions[componentKey] ?? null;
311
+ }
312
+
313
+ // src/client/action-registry.ts
314
+ var MissingHandlerError = class extends Error {
315
+ constructor(actionKey) {
316
+ super(
317
+ `Kein Handler f\xFCr actionKey "${actionKey}" registriert. Konsument-Shell muss \`actions["${actionKey}"]\` bereitstellen.`
318
+ );
319
+ this.name = "MissingHandlerError";
320
+ }
321
+ };
322
+ var ActionDefNotInManifestError = class extends Error {
323
+ constructor(actionKey) {
324
+ super(
325
+ `actionKey "${actionKey}" ist im Manifest nicht deklariert. Bitte als TenantAction in einer ManifestContribution registrieren.`
326
+ );
327
+ this.name = "ActionDefNotInManifestError";
328
+ }
329
+ };
330
+ var ActionRegistry = class {
331
+ defs = /* @__PURE__ */ new Map();
332
+ handlers = /* @__PURE__ */ new Map();
333
+ constructor(manifest, handlers = {}) {
334
+ for (const def of manifest.tenants?.actions ?? []) {
335
+ this.defs.set(def.actionKey, def);
336
+ }
337
+ for (const [key, handler] of Object.entries(handlers)) {
338
+ this.handlers.set(key, handler);
339
+ }
340
+ }
341
+ /**
342
+ * Registers a handler after the fact (e.g. when consumer code loads
343
+ * lazily). Throws `ActionDefNotInManifestError` if the `actionKey` is not
344
+ * declared in the manifest — prevents dead registrations.
345
+ */
346
+ register(actionKey, handler) {
347
+ if (!this.defs.has(actionKey)) {
348
+ throw new ActionDefNotInManifestError(actionKey);
349
+ }
350
+ this.handlers.set(actionKey, handler);
351
+ }
352
+ /**
353
+ * Returns the `{def, handler}` pair. Throws if the key is missing from
354
+ * the manifest or no handler is registered. The shell's UI layer calls
355
+ * the method, checks `def.requiresMfa` / `def.confirmType` for the
356
+ * pre-flow, and then calls `handler(input)`.
357
+ */
358
+ get(actionKey) {
359
+ const def = this.defs.get(actionKey);
360
+ if (!def) throw new ActionDefNotInManifestError(actionKey);
361
+ const handler = this.handlers.get(actionKey);
362
+ if (!handler) throw new MissingHandlerError(actionKey);
363
+ return { def, handler };
364
+ }
365
+ /**
366
+ * Convenience: `get(key).handler(input)`. UI convenience for actions
367
+ * that need neither MFA nor confirm.
368
+ */
369
+ async dispatch(actionKey, input) {
370
+ return this.get(actionKey).handler(input);
371
+ }
372
+ /**
373
+ * List of actionKeys that are declared in the manifest but have no
374
+ * handler. Consumers use this in a doctor check to detect drift between
375
+ * the manifest and the shell build.
376
+ */
377
+ listOrphanedDefs() {
378
+ return [...this.defs.keys()].filter((k) => !this.handlers.has(k));
379
+ }
380
+ /**
381
+ * List of registered handlers that are missing from the manifest. Drift
382
+ * in the other direction.
383
+ */
384
+ listOrphanedHandlers() {
385
+ return [...this.handlers.keys()].filter((k) => !this.defs.has(k));
386
+ }
387
+ };
388
+
389
+ // src/client/batch-column-fetcher.ts
390
+ var BatchColumnDriftError = class extends Error {
391
+ constructor(column, reason) {
392
+ super(`Spalte "${column.key}": ${reason}`);
393
+ this.column = column;
394
+ this.name = "BatchColumnDriftError";
395
+ }
396
+ column;
397
+ };
398
+ var BatchColumnFetcher = class {
399
+ http;
400
+ paramStyle;
401
+ getAuthToken;
402
+ constructor(options = {}) {
403
+ this.http = options.http ?? defaultHttpClient();
404
+ this.paramStyle = options.paramStyle ?? "comma";
405
+ this.getAuthToken = options.getAuthToken;
406
+ }
407
+ /**
408
+ * Loads the data for all columns declared in the manifest in parallel
409
+ * (one request per column, all `tenantIds` in the batch). Columns without
410
+ * a satisfied capability are ignored.
411
+ */
412
+ async fetchAll(manifest, tenantIds) {
413
+ if (tenantIds.length === 0) return {};
414
+ const cols = this.eligibleColumns(manifest);
415
+ const results = await Promise.all(
416
+ cols.map(
417
+ (col) => this.fetchOne(col, tenantIds).then((data) => [col.key, data])
418
+ )
419
+ );
420
+ const out = {};
421
+ for (const [key, data] of results) out[key] = data;
422
+ return out;
423
+ }
424
+ /** Fetch a single column (consumers may also use this directly). */
425
+ async fetchOne(column, tenantIds) {
426
+ this.validateBatchEndpoint(column);
427
+ if (tenantIds.length === 0) return {};
428
+ const url = this.buildUrl(column.endpoint, tenantIds);
429
+ const headers = {};
430
+ const token = this.getAuthToken?.();
431
+ if (token) headers.Authorization = `Bearer ${token}`;
432
+ const res = await this.http(url, { method: "GET", headers });
433
+ if (res.status !== 200) {
434
+ throw new Error(
435
+ `Spalte "${column.key}" \u2014 Endpoint ${column.endpoint} antwortete HTTP ${res.status}`
436
+ );
437
+ }
438
+ const body = await res.json();
439
+ return body;
440
+ }
441
+ /**
442
+ * Column drift against the manifest. Consumers use this for CI smoke
443
+ * tests of the manifest-vs-shell build.
444
+ */
445
+ listDriftIssues(manifest) {
446
+ const issues = [];
447
+ for (const col of manifest.tenants?.columns ?? []) {
448
+ try {
449
+ this.validateBatchEndpoint(col);
450
+ } catch (err) {
451
+ if (err instanceof BatchColumnDriftError) issues.push(err);
452
+ }
453
+ }
454
+ return issues;
455
+ }
456
+ /**
457
+ * Which columns have a satisfied `requiredCapability`? Manifest =
458
+ * discovery, so a local check is enough.
459
+ */
460
+ eligibleColumns(manifest) {
461
+ const caps = manifest.capabilities ?? {};
462
+ return (manifest.tenants?.columns ?? []).filter((col) => {
463
+ if (!col.requiredCapability) return true;
464
+ return caps[col.requiredCapability] === true;
465
+ });
466
+ }
467
+ validateBatchEndpoint(col) {
468
+ if (!col.endpoint || col.endpoint.trim().length === 0) {
469
+ throw new BatchColumnDriftError(col, "endpoint ist leer");
470
+ }
471
+ if (col.endpoint.includes("{slug}") || col.endpoint.includes("{tenantId}")) {
472
+ throw new BatchColumnDriftError(
473
+ col,
474
+ "endpoint enth\xE4lt per-Tenant-Placeholder ({slug}/{tenantId}). Spalten-Endpoints m\xFCssen batchf\xE4hig sein \u2014 bitte Backend auf `?tenantIds=...`-Parameter umstellen."
475
+ );
476
+ }
477
+ }
478
+ buildUrl(endpoint, tenantIds) {
479
+ const sep = endpoint.includes("?") ? "&" : "?";
480
+ if (this.paramStyle === "comma") {
481
+ const enc = tenantIds.map(encodeURIComponent).join(",");
482
+ return `${endpoint}${sep}tenantIds=${enc}`;
483
+ }
484
+ const params = tenantIds.map((id) => `tenantIds=${encodeURIComponent(id)}`).join("&");
485
+ return `${endpoint}${sep}${params}`;
486
+ }
487
+ };
488
+
489
+ // src/client/plan-versions-catalog.ts
490
+ var dec = (s) => Number(s);
491
+ function extractQuotas(p) {
492
+ if (p.quotas && Object.keys(p.quotas).length > 0) {
493
+ return { ...p.quotas };
494
+ }
495
+ const out = {};
496
+ if (typeof p.maxUsers === "number") out.users = p.maxUsers;
497
+ if (typeof p.maxVehicles === "number") out.vehicles = p.maxVehicles;
498
+ if (typeof p.maxStorageGb === "number") out.storageGb = p.maxStorageGb;
499
+ return out;
500
+ }
501
+ var sortByPublishedDesc = (rows) => [...rows].sort((a, b) => {
502
+ const at = a.publishedAt ? Date.parse(a.publishedAt) : Number.POSITIVE_INFINITY;
503
+ const bt = b.publishedAt ? Date.parse(b.publishedAt) : Number.POSITIVE_INFINITY;
504
+ if (at !== bt) return bt - at;
505
+ return b.version - a.version;
506
+ });
507
+ function findLiveAt(rows, asOfMs) {
508
+ const candidates = rows.filter((r) => {
509
+ if (r.publishedAt === null) return false;
510
+ if (Date.parse(r.publishedAt) > asOfMs) return false;
511
+ if (r.supersededAt !== null && Date.parse(r.supersededAt) <= asOfMs) return false;
512
+ return true;
513
+ });
514
+ if (candidates.length === 0) return null;
515
+ return [...candidates].sort((a, b) => b.version - a.version)[0] ?? null;
516
+ }
517
+ function findCurrentLive(rows) {
518
+ return rows.find((r) => r.publishedAt !== null && r.supersededAt === null) ?? null;
519
+ }
520
+ function findDraft(rows) {
521
+ return rows.find((r) => r.publishedAt === null) ?? null;
522
+ }
523
+ function groupBy(rows, keyOf) {
524
+ const out = /* @__PURE__ */ new Map();
525
+ for (const r of rows) {
526
+ const k = keyOf(r);
527
+ const list = out.get(k) ?? [];
528
+ list.push(r);
529
+ out.set(k, list);
530
+ }
531
+ return out;
532
+ }
533
+ function resolvePlan(source, liveBase) {
534
+ const quotas = extractQuotas(source);
535
+ return {
536
+ source,
537
+ liveBase,
538
+ isDraft: source.publishedAt === null,
539
+ planId: source.planId,
540
+ features: source.features,
541
+ quotas,
542
+ monthlyNet: dec(source.monthlyNet),
543
+ yearlyNet: dec(source.yearlyNet),
544
+ marketed: source.marketed,
545
+ version: source.version,
546
+ maxUsers: quotas.users,
547
+ maxVehicles: quotas.vehicles,
548
+ maxStorageGb: quotas.storageGb
549
+ };
550
+ }
551
+ function dateLabelDe(iso) {
552
+ return new Date(iso).toLocaleDateString("de-DE", {
553
+ day: "2-digit",
554
+ month: "short",
555
+ year: "numeric"
556
+ });
557
+ }
558
+ function buildDraftsSnapshot(data, sortPlansFn) {
559
+ const planByKey = groupBy(data.planVersions, (r) => r.planId);
560
+ const plans = [];
561
+ for (const [, rows] of planByKey) {
562
+ const draft = findDraft(rows);
563
+ const live = findCurrentLive(rows);
564
+ if (draft) plans.push(resolvePlan(draft, live));
565
+ else if (live) plans.push(resolvePlan(live, null));
566
+ }
567
+ const draftCount = plans.filter((p) => p.isDraft).length;
568
+ return {
569
+ id: "drafts",
570
+ kind: "drafts",
571
+ status: "DRAFT",
572
+ label: "Arbeitsstand",
573
+ title: draftCount === 0 ? "Keine offenen Drafts" : `${draftCount} offene${draftCount === 1 ? "r" : ""} Draft${draftCount === 1 ? "" : "s"} bereit f\xFCr Publish`,
574
+ description: draftCount === 0 ? "Lege einen Draft an, um Limits, Preise oder Features zu \xE4ndern. Drafts sind ohne MFA editierbar und werden erst beim Publish wirksam." : "Diese Tabelle zeigt, wie der Catalog nach Publish aller Drafts aussehen w\xFCrde. Bestehende Mandanten bleiben auf der vorherigen Version, bis sie aktiv migriert werden.",
575
+ asOf: null,
576
+ createdAt: null,
577
+ publishedAt: null,
578
+ authorEmail: null,
579
+ plans: sortPlansFn(plans),
580
+ draftCount,
581
+ regressionCount: 0
582
+ };
583
+ }
584
+ function buildActiveSnapshot(data, sortPlansFn) {
585
+ const planByKey = groupBy(data.planVersions, (r) => r.planId);
586
+ const plans = [];
587
+ for (const [, rows] of planByKey) {
588
+ const live = findCurrentLive(rows);
589
+ if (live) plans.push(resolvePlan(live, null));
590
+ }
591
+ if (plans.length === 0) return null;
592
+ const publishedDates = plans.map((p) => p.source.publishedAt).filter((t) => t !== null).sort();
593
+ const latestPublished = publishedDates[publishedDates.length - 1];
594
+ return {
595
+ id: "active",
596
+ kind: "active",
597
+ status: "ACTIVE",
598
+ label: "Aktuell",
599
+ title: "Live-Catalog",
600
+ description: "Diese Plan-Versionen sind aktuell f\xFCr neue Onboardings und f\xFCr Renewals nach Stichtag aktiv.",
601
+ asOf: latestPublished ?? null,
602
+ createdAt: null,
603
+ publishedAt: latestPublished ?? null,
604
+ authorEmail: null,
605
+ plans: sortPlansFn(plans),
606
+ draftCount: 0,
607
+ regressionCount: 0
608
+ };
609
+ }
610
+ function buildHistoricalSnapshots(data, sortPlansFn) {
611
+ const allPublishedAt = /* @__PURE__ */ new Set();
612
+ for (const r of data.planVersions) if (r.publishedAt) allPublishedAt.add(r.publishedAt);
613
+ if (allPublishedAt.size === 0) return [];
614
+ const planByKey = groupBy(data.planVersions, (r) => r.planId);
615
+ const liveTimestamps = /* @__PURE__ */ new Set();
616
+ for (const rows of planByKey.values()) {
617
+ const live = findCurrentLive(rows);
618
+ if (live?.publishedAt) liveTimestamps.add(live.publishedAt);
619
+ }
620
+ const liveSorted = [...liveTimestamps].sort();
621
+ const latestLive = liveSorted[liveSorted.length - 1];
622
+ const sortedDesc = [...allPublishedAt].sort((a, b) => Date.parse(b) - Date.parse(a));
623
+ const out = [];
624
+ for (const ts of sortedDesc) {
625
+ if (latestLive && Date.parse(ts) >= Date.parse(latestLive)) continue;
626
+ const tMs = Date.parse(ts) + 1;
627
+ const plans = [];
628
+ for (const [, rows] of planByKey) {
629
+ const live = findLiveAt(rows, tMs);
630
+ if (live) plans.push(resolvePlan(live, null));
631
+ }
632
+ if (plans.length === 0) continue;
633
+ const publishedAtThisEvent = data.planVersions.filter((r) => r.publishedAt === ts);
634
+ const regressionCount = publishedAtThisEvent.filter((r) => !r.nonRegressive).length;
635
+ const author = publishedAtThisEvent[0]?.publishedByUserId ?? null;
636
+ out.push({
637
+ id: `hist-${ts}`,
638
+ kind: "historical",
639
+ status: "ARCHIVED",
640
+ label: dateLabelDe(ts),
641
+ title: summarizeEvent(publishedAtThisEvent),
642
+ description: detailEvent(publishedAtThisEvent),
643
+ asOf: ts,
644
+ createdAt: ts,
645
+ publishedAt: ts,
646
+ authorEmail: author,
647
+ plans: sortPlansFn(plans),
648
+ draftCount: 0,
649
+ regressionCount
650
+ });
651
+ }
652
+ return out;
653
+ }
654
+ function summarizeEvent(rows) {
655
+ if (rows.length === 0) return "Publish-Event";
656
+ if (rows.length === 1) {
657
+ const r = rows[0];
658
+ return `${r.planId} v${r.version} publiziert`;
659
+ }
660
+ return `${rows.length} Versionen publiziert`;
661
+ }
662
+ function detailEvent(rows) {
663
+ if (rows.length === 0) return "";
664
+ const note = rows[0]?.changeNote ?? "";
665
+ return note.length > 0 ? note : "Snapshot rekonstruiert aus per-Entity-Versionen.";
666
+ }
667
+ function sortPlansBy(order) {
668
+ if (!order || order.length === 0) {
669
+ return (rows) => [...rows].sort((a, b) => a.planId.localeCompare(b.planId));
670
+ }
671
+ const idx = {};
672
+ for (let i = 0; i < order.length; i++) idx[order[i]] = i;
673
+ return (rows) => [...rows].sort((a, b) => {
674
+ const ai = idx[a.planId] ?? Number.POSITIVE_INFINITY;
675
+ const bi = idx[b.planId] ?? Number.POSITIVE_INFINITY;
676
+ if (ai !== bi) return ai - bi;
677
+ return a.planId.localeCompare(b.planId);
678
+ });
679
+ }
680
+ function buildSnapshots(data, options = {}) {
681
+ const sortPlansFn = sortPlansBy(options.planSortOrder);
682
+ const drafts = buildDraftsSnapshot(data, sortPlansFn);
683
+ const active = buildActiveSnapshot(data, sortPlansFn);
684
+ const historical = buildHistoricalSnapshots(data, sortPlansFn);
685
+ const out = [drafts];
686
+ if (active) out.push(active);
687
+ out.push(...historical);
688
+ return out;
689
+ }
690
+ function listOpenDrafts(data) {
691
+ return {
692
+ plans: sortByPublishedDesc(data.planVersions).filter((r) => r.publishedAt === null)
693
+ };
694
+ }
695
+
696
+ export {
697
+ ADMIN_UI_VERSION,
698
+ HttpJsonError,
699
+ trimTrailingSlashes,
700
+ getJson,
701
+ postJson,
702
+ BootLoadError,
703
+ BootLoader,
704
+ ManifestLoadError,
705
+ ManifestLoader,
706
+ DEFAULT_STANDARD_PAGE_ROUTES,
707
+ DEFAULT_SECTION_ORDER,
708
+ buildRoutes,
709
+ buildSidebar,
710
+ resolveExtension,
711
+ MissingHandlerError,
712
+ ActionDefNotInManifestError,
713
+ ActionRegistry,
714
+ BatchColumnDriftError,
715
+ BatchColumnFetcher,
716
+ buildSnapshots,
717
+ listOpenDrafts
718
+ };