@elevasis/ui 2.38.2 → 2.39.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 (76) hide show
  1. package/dist/{CoreAuthKitInner-QC62UHTZ.js → CoreAuthKitInner-PSTKG4B3.js} +3 -1
  2. package/dist/api/index.js +4 -2
  3. package/dist/app/index.d.ts +12 -0
  4. package/dist/app/index.js +16 -13
  5. package/dist/auth/context.d.ts +7 -1
  6. package/dist/auth/index.d.ts +80 -74
  7. package/dist/auth/index.js +10 -7
  8. package/dist/charts/index.js +13 -10
  9. package/dist/{chunk-KJ3QUBNU.js → chunk-2FTX4WO2.js} +2 -2
  10. package/dist/{chunk-C6BDBZRO.js → chunk-2XBCYJS3.js} +2 -1
  11. package/dist/{chunk-533DUEQY.js → chunk-6DO4PE3O.js} +1 -1
  12. package/dist/{chunk-I53EX4VU.js → chunk-AIP3GC2N.js} +1 -1
  13. package/dist/{chunk-P34FFSOX.js → chunk-AVQPF7PE.js} +2 -1
  14. package/dist/{chunk-YGUNUIME.js → chunk-D3EWFGLF.js} +5 -4
  15. package/dist/{chunk-566XWGPP.js → chunk-FZIPSE3S.js} +53 -611
  16. package/dist/{chunk-M7Q4UBRY.js → chunk-GTTMOKIB.js} +1 -1
  17. package/dist/{chunk-Y3JQBSKQ.js → chunk-IOSJHARH.js} +1 -1
  18. package/dist/{chunk-JXVNHVK7.js → chunk-K7E352VG.js} +1 -1
  19. package/dist/{chunk-OPKXEGE4.js → chunk-MEOXQKW6.js} +297 -182
  20. package/dist/chunk-MQZE7SUI.js +9 -0
  21. package/dist/{chunk-4UCAUBOL.js → chunk-MWRFFGOH.js} +2 -2
  22. package/dist/{chunk-7GQFIWP4.js → chunk-N4IO4CQO.js} +3 -3
  23. package/dist/chunk-PE3FAAW3.js +622 -0
  24. package/dist/chunk-PFPM654Z.js +801 -0
  25. package/dist/{chunk-BEVGBPHW.js → chunk-PRMWQA5R.js} +11 -10
  26. package/dist/{chunk-JBWJ6WHZ.js → chunk-SJHM4WDG.js} +1 -1
  27. package/dist/chunk-TVTSASST.js +28 -0
  28. package/dist/{chunk-2Q2JQSQO.js → chunk-W2SFTXMT.js} +1 -1
  29. package/dist/{chunk-AUB3T7OY.js → chunk-ZPRCGNZT.js} +5 -5
  30. package/dist/components/index.d.ts +12 -0
  31. package/dist/components/index.js +19 -16
  32. package/dist/components/navigation/index.js +4 -3
  33. package/dist/features/auth/index.js +20 -17
  34. package/dist/features/clients/index.js +19 -16
  35. package/dist/features/crm/index.js +19 -16
  36. package/dist/features/dashboard/index.d.ts +12 -0
  37. package/dist/features/dashboard/index.js +19 -16
  38. package/dist/features/delivery/index.js +19 -16
  39. package/dist/features/knowledge/index.js +4 -3
  40. package/dist/features/lead-gen/index.d.ts +58 -12
  41. package/dist/features/lead-gen/index.js +19 -16
  42. package/dist/features/monitoring/index.js +19 -16
  43. package/dist/features/monitoring/requests/index.js +19 -16
  44. package/dist/features/notes/index.js +6 -4
  45. package/dist/features/operations/index.d.ts +12 -0
  46. package/dist/features/operations/index.js +19 -16
  47. package/dist/features/settings/index.js +19 -16
  48. package/dist/hooks/access/index.js +9 -6
  49. package/dist/hooks/delivery/index.js +19 -16
  50. package/dist/hooks/index.d.ts +260 -203
  51. package/dist/hooks/index.js +19 -16
  52. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +12 -0
  53. package/dist/hooks/published.d.ts +260 -203
  54. package/dist/hooks/published.js +19 -16
  55. package/dist/hooks/user-notes/index.js +4 -2
  56. package/dist/index.d.ts +141 -84
  57. package/dist/index.js +19 -16
  58. package/dist/initialization/index.js +6 -4
  59. package/dist/knowledge/index.d.ts +12 -0
  60. package/dist/knowledge/index.js +5 -4
  61. package/dist/organization/index.d.ts +44 -10
  62. package/dist/organization/index.js +19 -16
  63. package/dist/profile/index.js +4 -2
  64. package/dist/provider/ElevasisServiceContext.d.ts +13 -4
  65. package/dist/provider/ElevasisServiceContext.js +3 -1
  66. package/dist/provider/index.d.ts +25 -4
  67. package/dist/provider/index.js +15 -12
  68. package/dist/provider/published.d.ts +25 -4
  69. package/dist/provider/published.js +14 -11
  70. package/dist/test-utils/index.d.ts +13 -4
  71. package/dist/test-utils/index.js +6 -3
  72. package/dist/types/index.d.ts +12 -0
  73. package/dist/utils/index.d.ts +12 -0
  74. package/dist/utils/index.js +3 -1
  75. package/package.json +5 -5
  76. package/dist/chunk-X66MVMZT.js +0 -373
@@ -1,8 +1,8 @@
1
+ import { OntologyScopeSchema, OntologyIdSchema, DEFAULT_ONTOLOGY_SCOPE, compileOrganizationOntology, listResolvedOntologyRecords, listAllSystems, defineDomainRecord, ontologyGraphNodeId, parseOntologyId, getAllProspectingStages, getAllPipelines, getAllProjectStatuses, getLeadGenStageCatalog, getAllBuildTemplates } from './chunk-PE3FAAW3.js';
1
2
  import { IconMail, IconSend, IconFileText, IconClock, IconArrowUp, IconMessageCircle, IconRocket, IconEye, IconEdit, IconAlertTriangle, IconRefresh, IconX, IconCheck, IconShieldLock, IconActivity, IconTopologyStar3, IconApps, IconBriefcase, IconBuilding, IconBolt, IconSearch, IconChartBar, IconUsers, IconInfoCircle, IconDatabase, IconGitBranch, IconDashboard, IconBuildingStore, IconUser, IconPlug, IconBrain, IconTargetArrow, IconBook, IconLayoutGrid, IconArchive, IconSettings, IconTool, IconCalendar } from '@tabler/icons-react';
2
3
  import { jsx } from 'react/jsx-runtime';
3
4
  import { z } from 'zod';
4
5
 
5
- // src/icons/registry.tsx
6
6
  var DEFAULT_SEMANTIC_ICON_REGISTRY = {
7
7
  // Navigation / app areas
8
8
  dashboard: IconDashboard,
@@ -143,475 +143,6 @@ function SemanticIcon({
143
143
  }
144
144
  );
145
145
  }
146
-
147
- // ../core/src/organization-model/helpers.ts
148
- function defineDomainRecord(schema, entries) {
149
- return Object.fromEntries(
150
- entries.map((entry) => {
151
- const parsed = schema.parse(entry);
152
- return [parsed.id, parsed];
153
- })
154
- );
155
- }
156
- function childSystemsOf(system) {
157
- return system.systems ?? system.subsystems ?? {};
158
- }
159
- function defaultPathFor(id) {
160
- return `/${id.replaceAll(".", "/")}`;
161
- }
162
- function parentIdOf(id) {
163
- const index = id.lastIndexOf(".");
164
- return index === -1 ? void 0 : id.slice(0, index);
165
- }
166
- function findById(systems, id) {
167
- return systems[id];
168
- }
169
- function findByPath(systems, path) {
170
- return Object.values(systems).find((system) => (system.path ?? system.ui?.path ?? defaultPathFor(system.id)) === path);
171
- }
172
- function childrenOf(systems, id) {
173
- const prefix = `${id}.`;
174
- return Object.values(systems).filter(
175
- (system) => system.id.startsWith(prefix) && !system.id.slice(prefix.length).includes(".")
176
- );
177
- }
178
- function topLevel(systems) {
179
- return Object.values(systems).filter((system) => !system.id.includes("."));
180
- }
181
- function ancestorsOf(systems, id) {
182
- const segments = id.split(".");
183
- const ids = segments.map((_, index) => segments.slice(0, index + 1).join("."));
184
- return ids.map((ancestorId) => findById(systems, ancestorId)).filter((system) => Boolean(system));
185
- }
186
- function parentOf(systems, id) {
187
- const parentId = parentIdOf(id);
188
- return parentId ? findById(systems, parentId) : void 0;
189
- }
190
- function inheritedValue(systems, id, getValue) {
191
- return ancestorsOf(systems, id).slice().reverse().map(getValue).find((value) => value !== void 0);
192
- }
193
- function requiresAdminFor(systems, id) {
194
- return inheritedValue(systems, id, (system) => system.requiresAdmin) ?? false;
195
- }
196
- function devOnlyFor(systems, id) {
197
- return inheritedValue(systems, id, (system) => system.devOnly || system.lifecycle === "beta" || void 0) ?? false;
198
- }
199
- function getSystem(model, path) {
200
- const segments = path.split(".");
201
- let current = model.systems;
202
- let node;
203
- for (const seg of segments) {
204
- node = current[seg];
205
- if (node === void 0) return void 0;
206
- current = childSystemsOf(node);
207
- }
208
- return node;
209
- }
210
- function getSystemAncestors(model, path) {
211
- const segments = path.split(".");
212
- const result = [];
213
- let current = model.systems;
214
- for (const seg of segments) {
215
- const node = current[seg];
216
- if (node === void 0) return [];
217
- result.push(node);
218
- current = childSystemsOf(node);
219
- }
220
- return result;
221
- }
222
- function listAllSystems(model) {
223
- const results = [];
224
- function walk(map, prefix) {
225
- for (const [localId2, system] of Object.entries(map)) {
226
- const fullPath = prefix ? `${prefix}.${localId2}` : localId2;
227
- results.push({ path: fullPath, system });
228
- const childSystems = childSystemsOf(system);
229
- if (Object.keys(childSystems).length > 0) {
230
- walk(childSystems, fullPath);
231
- }
232
- }
233
- }
234
- walk(model.systems, "");
235
- return results;
236
- }
237
- function isPlainJsonObject(value) {
238
- return typeof value === "object" && value !== null && !Array.isArray(value);
239
- }
240
- function mergeJsonConfig(base, override) {
241
- const result = { ...base };
242
- for (const [key, value] of Object.entries(override)) {
243
- const existing = result[key];
244
- result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
245
- }
246
- return result;
247
- }
248
- function resolveSystemConfig(model, path) {
249
- const system = getSystem(model, path);
250
- if (system === void 0) return {};
251
- return mergeJsonConfig({}, system.config ?? {});
252
- }
253
- function getResourcesForSystem(model, systemPath, options = {}) {
254
- const { includeDescendants = false } = options;
255
- const prefix = systemPath + ".";
256
- return Object.values(model.resources ?? {}).filter(
257
- (r) => r.systemPath === systemPath || includeDescendants && r.systemPath.startsWith(prefix)
258
- );
259
- }
260
- var OntologyKindSchema = z.enum([
261
- "object",
262
- "link",
263
- "action",
264
- "catalog",
265
- "event",
266
- "interface",
267
- "value-type",
268
- "property",
269
- "group",
270
- "surface"
271
- ]);
272
- var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
273
- var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
274
- var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
275
- var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
276
- var OntologyIdSchema = z.string().trim().min(1).max(300).regex(
277
- ONTOLOGY_ID_REGEX,
278
- "Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
279
- );
280
- function parseOntologyId(id) {
281
- const normalized = OntologyIdSchema.parse(id);
282
- const match = ONTOLOGY_ID_REGEX.exec(normalized);
283
- if (match === null) {
284
- throw new Error(`Invalid ontology ID "${id}"`);
285
- }
286
- return {
287
- id: normalized,
288
- scope: match[1],
289
- kind: match[2],
290
- localId: match[3],
291
- isGlobal: match[1] === "global"
292
- };
293
- }
294
- function formatOntologyId(input) {
295
- return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
296
- }
297
- var OntologyReferenceListSchema = z.array(OntologyIdSchema).default([]).optional();
298
- var OntologyRecordBaseSchema = z.object({
299
- id: OntologyIdSchema,
300
- label: z.string().trim().min(1).max(160).optional(),
301
- description: z.string().trim().min(1).max(2e3).optional(),
302
- ownerSystemId: z.string().trim().min(1).max(200).optional(),
303
- aliases: z.array(OntologyIdSchema).optional()
304
- }).passthrough();
305
- var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
306
- properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
307
- storage: z.record(z.string(), z.unknown()).optional()
308
- });
309
- var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
310
- from: OntologyIdSchema,
311
- to: OntologyIdSchema,
312
- cardinality: z.string().trim().min(1).max(80).optional(),
313
- via: z.string().trim().min(1).max(255).optional()
314
- });
315
- var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
316
- actsOn: OntologyReferenceListSchema,
317
- input: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
318
- effects: z.array(z.record(z.string(), z.unknown())).optional()
319
- });
320
- var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
321
- kind: z.string().trim().min(1).max(120).optional(),
322
- appliesTo: OntologyIdSchema.optional(),
323
- entries: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
324
- });
325
- var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
326
- payload: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
327
- });
328
- var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
329
- properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
330
- });
331
- var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
332
- primitive: z.string().trim().min(1).max(120).optional()
333
- });
334
- var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
335
- valueType: OntologyIdSchema.optional(),
336
- searchable: z.boolean().optional(),
337
- pii: z.boolean().optional()
338
- });
339
- var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
340
- members: OntologyReferenceListSchema
341
- });
342
- var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
343
- route: z.string().trim().min(1).max(500).optional()
344
- });
345
- var OntologyScopeSchema = z.object({
346
- objectTypes: z.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
347
- linkTypes: z.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
348
- actionTypes: z.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
349
- catalogTypes: z.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
350
- eventTypes: z.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
351
- interfaceTypes: z.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
352
- valueTypes: z.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
353
- sharedProperties: z.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
354
- groups: z.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
355
- surfaces: z.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
356
- }).default({});
357
- var DEFAULT_ONTOLOGY_SCOPE = {
358
- valueTypes: {
359
- "global:value-type/uuid": {
360
- id: "global:value-type/uuid",
361
- label: "UUID",
362
- primitive: "string"
363
- },
364
- "global:value-type/text": {
365
- id: "global:value-type/text",
366
- label: "Text",
367
- primitive: "string"
368
- },
369
- "global:value-type/url": {
370
- id: "global:value-type/url",
371
- label: "URL",
372
- primitive: "string"
373
- },
374
- "global:value-type/email": {
375
- id: "global:value-type/email",
376
- label: "Email",
377
- primitive: "string"
378
- }
379
- }
380
- };
381
- var SCOPE_KIND = {
382
- objectTypes: "object",
383
- linkTypes: "link",
384
- actionTypes: "action",
385
- catalogTypes: "catalog",
386
- eventTypes: "event",
387
- interfaceTypes: "interface",
388
- valueTypes: "value-type",
389
- sharedProperties: "property",
390
- groups: "group",
391
- surfaces: "surface"
392
- };
393
- var SCOPE_KEYS = Object.keys(SCOPE_KIND);
394
- function ontologyGraphNodeId(id) {
395
- return `ontology:${OntologyIdSchema.parse(id)}`;
396
- }
397
- function listResolvedOntologyRecords(index) {
398
- return SCOPE_KEYS.flatMap((scopeKey) => {
399
- const kind = SCOPE_KIND[scopeKey];
400
- return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record]) => ({
401
- id,
402
- kind,
403
- record
404
- }));
405
- });
406
- }
407
- function originFromContext(context) {
408
- return {
409
- kind: context.kind,
410
- source: context.source,
411
- path: context.path,
412
- ...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
413
- ...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
414
- };
415
- }
416
- function createEmptyIndex() {
417
- return {
418
- objectTypes: {},
419
- linkTypes: {},
420
- actionTypes: {},
421
- catalogTypes: {},
422
- eventTypes: {},
423
- interfaceTypes: {},
424
- valueTypes: {},
425
- sharedProperties: {},
426
- groups: {},
427
- surfaces: {}
428
- };
429
- }
430
- function sortResolvedOntologyIndex(index) {
431
- const sorted = createEmptyIndex();
432
- for (const scopeKey of SCOPE_KEYS) {
433
- const target = sorted[scopeKey];
434
- for (const [id, record] of Object.entries(index[scopeKey]).sort(
435
- ([leftId], [rightId]) => leftId.localeCompare(rightId)
436
- )) {
437
- target[id] = record;
438
- }
439
- }
440
- return sorted;
441
- }
442
- function childSystemsOf2(system) {
443
- return system.systems ?? system.subsystems ?? {};
444
- }
445
- function addRecord(index, diagnostics, sourcesById, scopeKey, record, context) {
446
- let parsed;
447
- try {
448
- parsed = parseOntologyId(record.id);
449
- } catch {
450
- diagnostics.push({
451
- code: "invalid_ontology_id",
452
- message: `Invalid ontology ID "${record.id}" from ${context.source} at ${context.path.join(".")}`,
453
- id: record.id,
454
- path: context.path,
455
- source: context.source,
456
- origin: originFromContext(context)
457
- });
458
- return;
459
- }
460
- const expectedKind = SCOPE_KIND[scopeKey];
461
- if (parsed.kind !== expectedKind) {
462
- diagnostics.push({
463
- code: "ontology_kind_mismatch",
464
- message: `Ontology ID "${record.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
465
- id: record.id,
466
- path: context.path,
467
- source: context.source,
468
- origin: originFromContext(context)
469
- });
470
- return;
471
- }
472
- const existing = sourcesById.get(parsed.id);
473
- if (existing !== void 0) {
474
- diagnostics.push({
475
- code: "duplicate_ontology_id",
476
- message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
477
- id: parsed.id,
478
- path: context.path,
479
- source: context.source,
480
- origin: originFromContext(context),
481
- existingSource: existing.source,
482
- existingOrigin: originFromContext(existing)
483
- });
484
- return;
485
- }
486
- sourcesById.set(parsed.id, context);
487
- index[scopeKey][parsed.id] = {
488
- ...record,
489
- origin: originFromContext(context)
490
- };
491
- }
492
- function addScope(index, diagnostics, sourcesById, scope, source, path) {
493
- if (scope === void 0) return;
494
- for (const scopeKey of SCOPE_KEYS) {
495
- const records = scope[scopeKey] ?? {};
496
- for (const [key, record] of Object.entries(records)) {
497
- addRecord(index, diagnostics, sourcesById, scopeKey, record, {
498
- source,
499
- path: [...path, scopeKey, key],
500
- kind: "authored",
501
- systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
502
- });
503
- }
504
- }
505
- }
506
- function legacyObjectId(entity) {
507
- return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
508
- }
509
- function legacyActionOwner(action, entities) {
510
- const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
511
- if (firstAffectedEntityId !== void 0) {
512
- return entities[firstAffectedEntityId].ownedBySystemId;
513
- }
514
- if (typeof action.scope === "object") {
515
- return action.scope.domain;
516
- }
517
- return "global";
518
- }
519
- function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
520
- for (const entity of Object.values(entities)) {
521
- const objectType = {
522
- id: legacyObjectId(entity),
523
- label: entity.label,
524
- description: entity.description,
525
- ownerSystemId: entity.ownedBySystemId,
526
- ...entity.table !== void 0 ? {
527
- storage: {
528
- kind: "table",
529
- table: entity.table
530
- }
531
- } : {},
532
- ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
533
- ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
534
- };
535
- addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
536
- source: "legacy.entities",
537
- path: ["entities", entity.id],
538
- kind: "projected",
539
- systemPath: entity.ownedBySystemId,
540
- legacyId: entity.id
541
- });
542
- entity.links?.forEach((link, linkIndex) => {
543
- const targetEntity = entities[link.toEntity];
544
- if (targetEntity === void 0) return;
545
- const linkType = {
546
- id: formatOntologyId({
547
- scope: entity.ownedBySystemId,
548
- kind: "link",
549
- localId: `${entity.id}-${link.toEntity}-${linkIndex}`
550
- }),
551
- label: link.label ?? link.kind,
552
- ownerSystemId: entity.ownedBySystemId,
553
- from: legacyObjectId(entity),
554
- to: legacyObjectId(targetEntity),
555
- cardinality: link.kind,
556
- ...link.via !== void 0 ? { via: link.via } : {}
557
- };
558
- addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
559
- source: "legacy.entities.links",
560
- path: ["entities", entity.id, "links", linkIndex],
561
- kind: "projected",
562
- systemPath: entity.ownedBySystemId,
563
- legacyId: `${entity.id}.links.${linkIndex}`
564
- });
565
- });
566
- }
567
- }
568
- function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
569
- for (const action of Object.values(actions)) {
570
- const ownerSystemId = legacyActionOwner(action, entities);
571
- const actionType = {
572
- id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
573
- label: action.label,
574
- description: action.description,
575
- ownerSystemId,
576
- actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
577
- ...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
578
- ...action.invocations !== void 0 ? { invocations: action.invocations } : {},
579
- ...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
580
- legacyActionId: action.id
581
- };
582
- addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
583
- source: "legacy.actions",
584
- path: ["actions", action.id],
585
- kind: "projected",
586
- systemPath: ownerSystemId,
587
- legacyId: action.id
588
- });
589
- }
590
- }
591
- function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
592
- for (const [key, system] of Object.entries(systems)) {
593
- const systemPath = prefix ? `${prefix}.${key}` : key;
594
- const currentPath = [...schemaPath, key];
595
- addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
596
- ...currentPath,
597
- "ontology"
598
- ]);
599
- addSystemScopes(index, diagnostics, sourcesById, childSystemsOf2(system), systemPath, [
600
- ...currentPath,
601
- system.systems !== void 0 ? "systems" : "subsystems"
602
- ]);
603
- }
604
- }
605
- function compileOrganizationOntology(model) {
606
- const ontology = createEmptyIndex();
607
- const diagnostics = [];
608
- const sourcesById = /* @__PURE__ */ new Map();
609
- addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
610
- addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
611
- addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
612
- addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
613
- return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
614
- }
615
146
  var ORGANIZATION_MODEL_ICON_TOKENS = [
616
147
  // Navigation / app areas
617
148
  "dashboard",
@@ -847,6 +378,26 @@ var SystemUiSchema = z.object({
847
378
  icon: IconNameSchema.optional(),
848
379
  order: z.number().int().optional()
849
380
  });
381
+ var SystemInterfaceKeySchema = ModelIdSchema;
382
+ var SystemInterfaceLifecycleSchema = z.enum(["draft", "active", "disabled", "deprecated", "archived"]).meta({ label: "System interface lifecycle", color: "teal" });
383
+ var SystemInterfaceReadinessProfileSchema = z.string().trim().min(1).max(200).regex(
384
+ /^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*(?:\.[a-z0-9][a-z0-9-]*)?$/,
385
+ 'Readiness profiles must use dotted lowercase identifiers (e.g. "sales.lead-gen.api")'
386
+ );
387
+ var SystemInterfaceResourceScopeSchema = z.array(ModelIdSchema).default([]);
388
+ var SystemApiInterfaceSchema = z.object({
389
+ lifecycle: SystemInterfaceLifecycleSchema.default("active"),
390
+ readinessProfile: SystemInterfaceReadinessProfileSchema.optional(),
391
+ /**
392
+ * Resource ids that participate in this API interface. This scopes readiness
393
+ * derivation without duplicating authored required/provided contract refs.
394
+ */
395
+ resourceIds: SystemInterfaceResourceScopeSchema.optional()
396
+ }).strict();
397
+ var SystemInterfaceRefSchema = z.object({
398
+ systemPath: SystemPathSchema,
399
+ interfaceKey: SystemInterfaceKeySchema
400
+ }).strict();
850
401
  var JsonValueSchema = z.lazy(
851
402
  () => z.union([
852
403
  z.string(),
@@ -885,6 +436,8 @@ var SystemEntrySchema = z.object({
885
436
  policies: z.array(ModelIdSchema.meta({ ref: "policy" })).default([]).optional(),
886
437
  /** Optional goals this system contributes to. */
887
438
  drivesGoals: z.array(ModelIdSchema.meta({ ref: "goal" })).default([]).optional(),
439
+ /** Thin API runtime-boundary marker. Readiness is derived from scoped resources and topology. */
440
+ apiInterface: SystemApiInterfaceSchema.optional(),
888
441
  /** @deprecated Use lifecycle. Accepted for one publish cycle. */
889
442
  status: SystemStatusSchema.optional(),
890
443
  /** @deprecated Use ui.path. Kept for one-cycle Feature compatibility. */
@@ -1158,146 +711,6 @@ function defineResources(resources) {
1158
711
  );
1159
712
  }
1160
713
 
1161
- // ../core/src/organization-model/migration-helpers.ts
1162
- function catalogRecords(model) {
1163
- return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
1164
- }
1165
- function localId(id) {
1166
- return parseOntologyId(id).localId;
1167
- }
1168
- function systemScope(id, fallback) {
1169
- return parseOntologyId(id).scope || fallback || "";
1170
- }
1171
- function entriesOf(catalog) {
1172
- return Object.entries(catalog.entries ?? {}).map(([id, value]) => [
1173
- id,
1174
- value && typeof value === "object" && !Array.isArray(value) ? value : {}
1175
- ]);
1176
- }
1177
- function stringValue(value) {
1178
- return typeof value === "string" ? value : void 0;
1179
- }
1180
- function stringArray(value) {
1181
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
1182
- }
1183
- function numberValue(value, fallback = 0) {
1184
- return typeof value === "number" ? value : fallback;
1185
- }
1186
- function stageFromEntry(entryId, entry) {
1187
- return {
1188
- id: entryId,
1189
- label: stringValue(entry.label) ?? entryId,
1190
- order: numberValue(entry.order),
1191
- semanticClass: stringValue(entry.semanticClass) ?? "open",
1192
- surfaceIds: stringArray(entry.surfaceIds),
1193
- resourceIds: stringArray(entry.resourceIds),
1194
- color: stringValue(entry.color)
1195
- };
1196
- }
1197
- function appliesToLocalId(catalog) {
1198
- const appliesTo = catalog.appliesTo;
1199
- if (appliesTo === void 0) return void 0;
1200
- return parseOntologyId(appliesTo).localId;
1201
- }
1202
- function appliesToEntityKind(catalog) {
1203
- const id = appliesToLocalId(catalog);
1204
- if (id === "company" || id === "contact" || id === "project" || id === "milestone" || id === "task") return id;
1205
- if (id === "deal") return void 0;
1206
- return void 0;
1207
- }
1208
- function getAllPipelines(model) {
1209
- return catalogRecords(model).filter((catalog) => catalog.kind === "pipeline").map((catalog) => {
1210
- const pipeline = {
1211
- id: localId(catalog.id),
1212
- label: catalog.label ?? localId(catalog.id),
1213
- ...catalog.description ? { description: catalog.description } : {},
1214
- entityId: appliesToLocalId(catalog) ?? "",
1215
- stages: entriesOf(catalog).map(([entryId, entry]) => stageFromEntry(entryId, entry)).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
1216
- };
1217
- return { systemPath: catalog.ownerSystemId ?? systemScope(catalog.id), pipeline };
1218
- }).sort((a, b) => a.systemPath.localeCompare(b.systemPath) || a.pipeline.id.localeCompare(b.pipeline.id));
1219
- }
1220
- function getAllBuildTemplates(model) {
1221
- const catalogs = catalogRecords(model);
1222
- const stepCatalogs = new Map(
1223
- catalogs.filter((catalog) => catalog.kind === "template-step").map((catalog) => [catalog.id, catalog])
1224
- );
1225
- return catalogs.filter((catalog) => catalog.kind === "template").flatMap(
1226
- (catalog) => entriesOf(catalog).map(([templateId, templateEntry]) => {
1227
- const stepCatalogId = stringValue(templateEntry.stepCatalog);
1228
- const stepCatalog = stepCatalogId !== void 0 ? stepCatalogs.get(stepCatalogId) : void 0;
1229
- const steps = stepCatalog === void 0 ? [] : entriesOf(stepCatalog);
1230
- return {
1231
- order: numberValue(templateEntry.order, Number.MAX_SAFE_INTEGER),
1232
- template: {
1233
- id: templateId,
1234
- label: stringValue(templateEntry.label) ?? templateId,
1235
- ...stringValue(templateEntry.description) ? { description: stringValue(templateEntry.description) } : {},
1236
- ...stringValue(templateEntry.color) ? { color: stringValue(templateEntry.color) } : {},
1237
- steps: steps.map(([stepId, step]) => ({
1238
- id: stepId,
1239
- label: stringValue(step.label) ?? stepId,
1240
- ...stringValue(step.description) ? { description: stringValue(step.description) } : {},
1241
- ...step
1242
- }))
1243
- }
1244
- };
1245
- })
1246
- ).sort((a, b) => a.order - b.order || a.template.id.localeCompare(b.template.id)).map(({ template }) => template);
1247
- }
1248
- function getAllProspectingStages(model, kind) {
1249
- return catalogRecords(model).filter((catalog) => catalog.kind === "stage" && appliesToEntityKind(catalog) === kind).flatMap(
1250
- (catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
1251
- id: entryId,
1252
- label: stringValue(entry.label) ?? entryId,
1253
- order: numberValue(entry.order),
1254
- ...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
1255
- ...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
1256
- }))
1257
- ).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
1258
- }
1259
- function getLeadGenStageCatalog(model) {
1260
- const results = {};
1261
- for (const catalog of catalogRecords(model).filter(
1262
- (record) => record.kind === "stage" && (record.ownerSystemId ?? systemScope(record.id)) === "sales.lead-gen"
1263
- )) {
1264
- const catalogEntity = appliesToEntityKind(catalog);
1265
- if (catalogEntity !== "company" && catalogEntity !== "contact") continue;
1266
- for (const [entryId, entry] of entriesOf(catalog)) {
1267
- const entity = entry.entity === "contact" ? "contact" : entry.entity === "company" ? "company" : catalogEntity;
1268
- const additionalEntities = stringArray(entry.additionalEntities).filter(
1269
- (item) => item === "company" || item === "contact"
1270
- );
1271
- const recordEntity = entry.recordEntity === "company" || entry.recordEntity === "contact" ? entry.recordEntity : void 0;
1272
- const recordStageKey = stringValue(entry.recordStageKey);
1273
- results[entryId] = {
1274
- key: entryId,
1275
- label: stringValue(entry.label) ?? entryId,
1276
- description: stringValue(entry.description) ?? "",
1277
- order: numberValue(entry.order),
1278
- entity,
1279
- ...additionalEntities.length > 0 ? { additionalEntities } : {},
1280
- ...recordEntity ? { recordEntity } : {},
1281
- ...recordStageKey ? { recordStageKey } : {}
1282
- };
1283
- }
1284
- }
1285
- return Object.fromEntries(
1286
- Object.entries(results).sort(([, a], [, b]) => a.order - b.order || a.key.localeCompare(b.key))
1287
- );
1288
- }
1289
- function getAllProjectStatuses(model, appliesTo) {
1290
- return catalogRecords(model).filter((catalog) => catalog.kind === "status-flow" && appliesToEntityKind(catalog) === appliesTo).flatMap(
1291
- (catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
1292
- id: entryId,
1293
- label: stringValue(entry.label) ?? entryId,
1294
- order: numberValue(entry.order),
1295
- ...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
1296
- ...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
1297
- }))
1298
- ).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
1299
- }
1300
-
1301
714
  // ../core/src/organization-model/contracts.ts
1302
715
  var PROJECTS_VIEW_ACTION_ID = "delivery.projects.view";
1303
716
  var OrganizationModelBrandingSchema = z.object({
@@ -1599,6 +1012,15 @@ var OmTopologyMetadataSchema = z.record(z.string().trim().min(1).max(120), JsonV
1599
1012
  }
1600
1013
  visit(metadata, []);
1601
1014
  });
1015
+ var OmTopologySystemInterfaceGrantSchema = z.object({
1016
+ consumer: SystemInterfaceRefSchema,
1017
+ provider: SystemInterfaceRefSchema,
1018
+ resourceIds: z.array(ResourceIdSchema).default([]),
1019
+ ontologyIds: z.array(OntologyIdSchema).default([])
1020
+ }).strict();
1021
+ z.object({
1022
+ systemInterfaceGrant: OmTopologySystemInterfaceGrantSchema
1023
+ }).strict();
1602
1024
  var OmTopologyRelationshipSchema = z.object({
1603
1025
  from: OmTopologyNodeRefSchema,
1604
1026
  kind: OmTopologyRelationshipKindSchema,
@@ -2460,6 +1882,26 @@ function refineOrganizationModel(model, ctx) {
2460
1882
  );
2461
1883
  }
2462
1884
  });
1885
+ allSystems.forEach(({ path: systemPath, schemaPath, system }) => {
1886
+ system.apiInterface?.resourceIds?.forEach((resourceId, resourceIndex) => {
1887
+ const resource = resourcesById.get(resourceId);
1888
+ if (resource === void 0) {
1889
+ addIssue(
1890
+ ctx,
1891
+ [...schemaPath, "apiInterface", "resourceIds", resourceIndex],
1892
+ `System Interface "${systemPath}/api" scopes unknown resource "${resourceId}"`
1893
+ );
1894
+ return;
1895
+ }
1896
+ if (resource.systemPath !== systemPath) {
1897
+ addIssue(
1898
+ ctx,
1899
+ [...schemaPath, "apiInterface", "resourceIds", resourceIndex],
1900
+ `System Interface "${systemPath}/api" scopes resource "${resourceId}" from system "${resource.systemPath}"`
1901
+ );
1902
+ }
1903
+ });
1904
+ });
2463
1905
  function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
2464
1906
  const ontologyIds2 = ids === void 0 ? [] : Array.isArray(ids) ? ids : [ids];
2465
1907
  ontologyIds2.forEach((ontologyId, ontologyIndex) => {
@@ -3712,4 +3154,4 @@ function projectOrganizationSurfaces(model) {
3712
3154
  });
3713
3155
  }
3714
3156
 
3715
- export { ActionSchema, AgentResourceEntrySchema, DEFAULT_ORGANIZATION_MODEL, DEFAULT_SEMANTIC_ICON_REGISTRY, EntitySchema, IdentityDomainSchema, IntegrationResourceEntrySchema, OntologyIdSchema, OrgKnowledgeNodeSchema, PROJECTS_VIEW_ACTION_ID, PolicySchema, RoleSchema, ScriptResourceEntrySchema, SemanticIcon, SurfaceDefinitionSchema, SystemEntrySchema, WorkflowResourceEntrySchema, ancestorsOf, buildOrganizationGraph, childrenOf, compileOrganizationOntology, defaultPathFor, defineActions, defineEntities, defineResources, defineTopology, devOnlyFor, extendSemanticIconRegistry, findById, findByPath, getAllBuildTemplates, getLeadGenStageCatalog, getResourcesForSystem, getSemanticIconComponent, getSortedSidebarEntries, getSystem, getSystemAncestors, listAllSystems, ontologyGraphNodeId, parentOf, parseOntologyId, projectOrganizationSurfaces, requiresAdminFor, resolveOrganizationModel, resolveSemanticIconComponent, resolveSystemConfig, topLevel, topologyRef, topologyRelationship };
3157
+ export { ActionSchema, AgentResourceEntrySchema, DEFAULT_ORGANIZATION_MODEL, DEFAULT_SEMANTIC_ICON_REGISTRY, EntitySchema, IdentityDomainSchema, IntegrationResourceEntrySchema, OrgKnowledgeNodeSchema, PROJECTS_VIEW_ACTION_ID, PolicySchema, RoleSchema, ScriptResourceEntrySchema, SemanticIcon, SurfaceDefinitionSchema, SystemEntrySchema, WorkflowResourceEntrySchema, buildOrganizationGraph, defineActions, defineEntities, defineResources, defineTopology, extendSemanticIconRegistry, getSemanticIconComponent, getSortedSidebarEntries, projectOrganizationSurfaces, resolveOrganizationModel, resolveSemanticIconComponent, topologyRef, topologyRelationship };