@elevasis/ui 2.40.1 → 2.41.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 (92) hide show
  1. package/dist/api/index.js +4 -6
  2. package/dist/app/index.css +384 -0
  3. package/dist/app/index.d.ts +108 -0
  4. package/dist/app/index.js +17 -27
  5. package/dist/auth/index.css +659 -0
  6. package/dist/auth/index.js +19 -6
  7. package/dist/charts/index.css +533 -0
  8. package/dist/charts/index.js +18 -15
  9. package/dist/{chunk-RXH4D6TY.js → chunk-5M4HSHQ5.js} +631 -2
  10. package/dist/{chunk-TE4P6OSJ.js → chunk-7FJI76OH.js} +1 -1
  11. package/dist/chunk-GMXGDO3I.js +244 -0
  12. package/dist/{chunk-CXY7FMUM.js → chunk-GUKY77FJ.js} +50 -4
  13. package/dist/{chunk-5JYKCULK.js → chunk-NZ2F5RQ4.js} +44 -2
  14. package/dist/{chunk-WF7CONXF.js → chunk-OJJK27GC.js} +658 -6
  15. package/dist/{chunk-RX6RSKWC.js → chunk-QDXTIQT4.js} +29255 -18312
  16. package/dist/{chunk-73EWE2EW.js → chunk-V5HWC5EW.js} +1 -1
  17. package/dist/components/chat/index.js +1 -2
  18. package/dist/components/index.css +149 -149
  19. package/dist/components/index.js +13 -37
  20. package/dist/components/navigation/index.css +659 -0
  21. package/dist/components/navigation/index.js +25 -4
  22. package/dist/features/auth/index.js +14 -38
  23. package/dist/features/clients/index.css +149 -149
  24. package/dist/features/clients/index.js +13 -37
  25. package/dist/features/crm/index.js +13 -37
  26. package/dist/features/dashboard/index.js +13 -37
  27. package/dist/features/delivery/index.js +13 -37
  28. package/dist/features/knowledge/index.css +659 -0
  29. package/dist/features/knowledge/index.js +25 -248
  30. package/dist/features/lead-gen/index.d.ts +81 -0
  31. package/dist/features/lead-gen/index.js +13 -37
  32. package/dist/features/monitoring/index.js +13 -37
  33. package/dist/features/monitoring/requests/index.d.ts +69 -7
  34. package/dist/features/monitoring/requests/index.js +32 -41
  35. package/dist/features/operations/index.d.ts +79 -0
  36. package/dist/features/operations/index.js +13 -37
  37. package/dist/features/seo/index.js +1 -4
  38. package/dist/features/settings/index.js +13 -37
  39. package/dist/hooks/access/index.css +659 -0
  40. package/dist/hooks/access/index.js +19 -5
  41. package/dist/hooks/delivery/index.js +13 -37
  42. package/dist/hooks/index.d.ts +18 -6
  43. package/dist/hooks/index.js +13 -37
  44. package/dist/hooks/published.d.ts +18 -6
  45. package/dist/hooks/published.js +13 -37
  46. package/dist/index.d.ts +151 -7
  47. package/dist/index.js +14 -38
  48. package/dist/initialization/index.js +1 -1
  49. package/dist/knowledge/index.css +659 -0
  50. package/dist/knowledge/index.d.ts +81 -0
  51. package/dist/knowledge/index.js +25 -15
  52. package/dist/layout/index.css +659 -0
  53. package/dist/layout/index.d.ts +18 -2
  54. package/dist/layout/index.js +24 -7
  55. package/dist/organization/index.js +13 -37
  56. package/dist/provider/index.css +384 -0
  57. package/dist/provider/index.d.ts +120 -1
  58. package/dist/provider/index.js +18 -22
  59. package/dist/provider/published.css +533 -0
  60. package/dist/provider/published.d.ts +121 -2
  61. package/dist/provider/published.js +18 -17
  62. package/dist/test-utils/index.js +4 -6
  63. package/dist/theme/index.js +2 -5
  64. package/dist/theme/presets/index.js +1 -2
  65. package/dist/utils/index.js +1 -3
  66. package/package.json +3 -3
  67. package/dist/chunk-3KMDHCAR.js +0 -52
  68. package/dist/chunk-4DRI3G36.js +0 -1016
  69. package/dist/chunk-5EYJ2GIN.js +0 -122
  70. package/dist/chunk-66U7JOWV.js +0 -425
  71. package/dist/chunk-6D4LCJ52.js +0 -10
  72. package/dist/chunk-6EV47QQW.js +0 -340
  73. package/dist/chunk-6ROXVZ3L.js +0 -9
  74. package/dist/chunk-7MTWRSUZ.js +0 -357
  75. package/dist/chunk-7PHY5ONQ.js +0 -85
  76. package/dist/chunk-B2DZLPDL.js +0 -39
  77. package/dist/chunk-CLDCYJQT.js +0 -1
  78. package/dist/chunk-CTJBPF3Z.js +0 -734
  79. package/dist/chunk-DT3QYZVU.js +0 -23
  80. package/dist/chunk-IIMU5YAJ.js +0 -53
  81. package/dist/chunk-IUQAP4IO.js +0 -2131
  82. package/dist/chunk-J3FLIZY4.js +0 -423
  83. package/dist/chunk-K7GKKETO.js +0 -3157
  84. package/dist/chunk-L7GXUSCV.js +0 -215
  85. package/dist/chunk-LJDYY3XB.js +0 -133
  86. package/dist/chunk-NYBEU5TE.js +0 -118
  87. package/dist/chunk-RH5VWWSC.js +0 -624
  88. package/dist/chunk-SJNIOGVX.js +0 -112
  89. package/dist/chunk-TYRUKGGD.js +0 -46
  90. package/dist/chunk-WLOQ4IBG.js +0 -654
  91. package/dist/chunk-X4WBGKJQ.js +0 -138
  92. package/dist/chunk-X7D6SUKR.js +0 -1234
@@ -1,6 +1,6 @@
1
- import { formatOntologyId, getSystem, compileOrganizationOntology, parseOntologyId, getLeadGenStageCatalog } from './chunk-RH5VWWSC.js';
2
1
  import { formatDistanceToNow } from 'date-fns';
3
2
  import { IconUser, IconExternalLink, IconPlug, IconBolt, IconGitBranch, IconBrain } from '@tabler/icons-react';
3
+ import { z } from 'zod';
4
4
 
5
5
  // src/utils/dateFormatters.ts
6
6
  function formatDateTime(dateString) {
@@ -168,6 +168,627 @@ function debounce(fn, wait) {
168
168
  return debounced;
169
169
  }
170
170
 
171
+ // ../core/src/organization-model/helpers.ts
172
+ function defineDomainRecord(schema, entries) {
173
+ return Object.fromEntries(
174
+ entries.map((entry) => {
175
+ const parsed = schema.parse(entry);
176
+ return [parsed.id, parsed];
177
+ })
178
+ );
179
+ }
180
+ function childSystemsOf(system) {
181
+ return system.systems ?? system.subsystems ?? {};
182
+ }
183
+ function defaultPathFor(id) {
184
+ return `/${id.replaceAll(".", "/")}`;
185
+ }
186
+ function parentIdOf(id) {
187
+ const index = id.lastIndexOf(".");
188
+ return index === -1 ? void 0 : id.slice(0, index);
189
+ }
190
+ function findById(systems, id) {
191
+ return systems[id];
192
+ }
193
+ function findByPath(systems, path) {
194
+ return Object.values(systems).find((system) => (system.path ?? system.ui?.path ?? defaultPathFor(system.id)) === path);
195
+ }
196
+ function childrenOf(systems, id) {
197
+ const prefix = `${id}.`;
198
+ return Object.values(systems).filter(
199
+ (system) => system.id.startsWith(prefix) && !system.id.slice(prefix.length).includes(".")
200
+ );
201
+ }
202
+ function topLevel(systems) {
203
+ return Object.values(systems).filter((system) => !system.id.includes("."));
204
+ }
205
+ function ancestorsOf(systems, id) {
206
+ const segments = id.split(".");
207
+ const ids = segments.map((_, index) => segments.slice(0, index + 1).join("."));
208
+ return ids.map((ancestorId) => findById(systems, ancestorId)).filter((system) => Boolean(system));
209
+ }
210
+ function parentOf(systems, id) {
211
+ const parentId = parentIdOf(id);
212
+ return parentId ? findById(systems, parentId) : void 0;
213
+ }
214
+ function inheritedValue(systems, id, getValue) {
215
+ return ancestorsOf(systems, id).slice().reverse().map(getValue).find((value) => value !== void 0);
216
+ }
217
+ function requiresAdminFor(systems, id) {
218
+ return inheritedValue(systems, id, (system) => system.requiresAdmin) ?? false;
219
+ }
220
+ function devOnlyFor(systems, id) {
221
+ return inheritedValue(systems, id, (system) => system.devOnly || system.lifecycle === "beta" || void 0) ?? false;
222
+ }
223
+ function getSystem(model, path) {
224
+ const flatMatch = model.systems[path];
225
+ if (flatMatch !== void 0) return flatMatch;
226
+ const segments = path.split(".");
227
+ let current = model.systems;
228
+ let node;
229
+ for (const seg of segments) {
230
+ node = current[seg];
231
+ if (node === void 0) return void 0;
232
+ current = childSystemsOf(node);
233
+ }
234
+ return node;
235
+ }
236
+ function getSystemAncestors(model, path) {
237
+ const flatMatch = model.systems[path];
238
+ if (flatMatch !== void 0) {
239
+ const ancestorIds = path.split(".").map((_, index, segments2) => segments2.slice(0, index + 1).join(".")).slice(0, -1);
240
+ return [
241
+ ...ancestorIds.map((ancestorId) => model.systems[ancestorId]).filter((system) => system !== void 0),
242
+ flatMatch
243
+ ];
244
+ }
245
+ const segments = path.split(".");
246
+ const result = [];
247
+ let current = model.systems;
248
+ for (const seg of segments) {
249
+ const node = current[seg];
250
+ if (node === void 0) return [];
251
+ result.push(node);
252
+ current = childSystemsOf(node);
253
+ }
254
+ return result;
255
+ }
256
+ function listAllSystems(model) {
257
+ const results = [];
258
+ function walk(map, prefix) {
259
+ for (const [localId2, system] of Object.entries(map)) {
260
+ const fullPath = prefix ? `${prefix}.${localId2}` : localId2;
261
+ results.push({ path: fullPath, system });
262
+ const childSystems = childSystemsOf(system);
263
+ if (Object.keys(childSystems).length > 0) {
264
+ walk(childSystems, fullPath);
265
+ }
266
+ }
267
+ }
268
+ walk(model.systems, "");
269
+ return results;
270
+ }
271
+ function isPlainJsonObject(value) {
272
+ return typeof value === "object" && value !== null && !Array.isArray(value);
273
+ }
274
+ function mergeJsonConfig(base, override) {
275
+ const result = { ...base };
276
+ for (const [key, value] of Object.entries(override)) {
277
+ const existing = result[key];
278
+ result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
279
+ }
280
+ return result;
281
+ }
282
+ function resolveSystemConfig(model, path) {
283
+ const system = getSystem(model, path);
284
+ if (system === void 0) return {};
285
+ return mergeJsonConfig({}, system.config ?? {});
286
+ }
287
+ function getResourcesForSystem(model, systemPath, options = {}) {
288
+ const { includeDescendants = false } = options;
289
+ const prefix = systemPath + ".";
290
+ return Object.values(model.resources ?? {}).filter(
291
+ (r) => r.systemPath === systemPath || includeDescendants && r.systemPath.startsWith(prefix)
292
+ );
293
+ }
294
+ var OntologyKindSchema = z.enum([
295
+ "object",
296
+ "link",
297
+ "action",
298
+ "catalog",
299
+ "event",
300
+ "interface",
301
+ "value-type",
302
+ "property",
303
+ "group",
304
+ "surface"
305
+ ]);
306
+ var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
307
+ var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
308
+ var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
309
+ var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
310
+ var OntologyIdSchema = z.string().trim().min(1).max(300).regex(
311
+ ONTOLOGY_ID_REGEX,
312
+ "Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
313
+ );
314
+ function parseOntologyId(id) {
315
+ const normalized = OntologyIdSchema.parse(id);
316
+ const match = ONTOLOGY_ID_REGEX.exec(normalized);
317
+ if (match === null) {
318
+ throw new Error(`Invalid ontology ID "${id}"`);
319
+ }
320
+ return {
321
+ id: normalized,
322
+ scope: match[1],
323
+ kind: match[2],
324
+ localId: match[3],
325
+ isGlobal: match[1] === "global"
326
+ };
327
+ }
328
+ function formatOntologyId(input) {
329
+ return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
330
+ }
331
+ var OntologyReferenceListSchema = z.array(OntologyIdSchema).default([]).optional();
332
+ var OntologyRecordBaseSchema = z.object({
333
+ id: OntologyIdSchema,
334
+ label: z.string().trim().min(1).max(160).optional(),
335
+ description: z.string().trim().min(1).max(2e3).optional(),
336
+ ownerSystemId: z.string().trim().min(1).max(200).optional(),
337
+ aliases: z.array(OntologyIdSchema).optional()
338
+ }).passthrough();
339
+ var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
340
+ properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
341
+ storage: z.record(z.string(), z.unknown()).optional()
342
+ });
343
+ var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
344
+ from: OntologyIdSchema,
345
+ to: OntologyIdSchema,
346
+ cardinality: z.string().trim().min(1).max(80).optional(),
347
+ via: z.string().trim().min(1).max(255).optional()
348
+ });
349
+ var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
350
+ actsOn: OntologyReferenceListSchema,
351
+ input: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
352
+ effects: z.array(z.record(z.string(), z.unknown())).optional()
353
+ });
354
+ var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
355
+ kind: z.string().trim().min(1).max(120).optional(),
356
+ appliesTo: OntologyIdSchema.optional(),
357
+ entries: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
358
+ });
359
+ var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
360
+ payload: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
361
+ });
362
+ var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
363
+ properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
364
+ });
365
+ var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
366
+ primitive: z.string().trim().min(1).max(120).optional()
367
+ });
368
+ var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
369
+ valueType: OntologyIdSchema.optional(),
370
+ searchable: z.boolean().optional(),
371
+ pii: z.boolean().optional()
372
+ });
373
+ var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
374
+ members: OntologyReferenceListSchema
375
+ });
376
+ var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
377
+ route: z.string().trim().min(1).max(500).optional()
378
+ });
379
+ var OntologyScopeSchema = z.object({
380
+ objectTypes: z.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
381
+ linkTypes: z.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
382
+ actionTypes: z.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
383
+ catalogTypes: z.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
384
+ eventTypes: z.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
385
+ interfaceTypes: z.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
386
+ valueTypes: z.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
387
+ sharedProperties: z.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
388
+ groups: z.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
389
+ surfaces: z.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
390
+ }).default({});
391
+ var DEFAULT_ONTOLOGY_SCOPE = {
392
+ valueTypes: {
393
+ "global:value-type/uuid": {
394
+ id: "global:value-type/uuid",
395
+ label: "UUID",
396
+ primitive: "string"
397
+ },
398
+ "global:value-type/text": {
399
+ id: "global:value-type/text",
400
+ label: "Text",
401
+ primitive: "string"
402
+ },
403
+ "global:value-type/url": {
404
+ id: "global:value-type/url",
405
+ label: "URL",
406
+ primitive: "string"
407
+ },
408
+ "global:value-type/email": {
409
+ id: "global:value-type/email",
410
+ label: "Email",
411
+ primitive: "string"
412
+ }
413
+ }
414
+ };
415
+ var SCOPE_KIND = {
416
+ objectTypes: "object",
417
+ linkTypes: "link",
418
+ actionTypes: "action",
419
+ catalogTypes: "catalog",
420
+ eventTypes: "event",
421
+ interfaceTypes: "interface",
422
+ valueTypes: "value-type",
423
+ sharedProperties: "property",
424
+ groups: "group",
425
+ surfaces: "surface"
426
+ };
427
+ var SCOPE_KEYS = Object.keys(SCOPE_KIND);
428
+ function ontologyGraphNodeId(id) {
429
+ return `ontology:${OntologyIdSchema.parse(id)}`;
430
+ }
431
+ function listResolvedOntologyRecords(index) {
432
+ return SCOPE_KEYS.flatMap((scopeKey) => {
433
+ const kind = SCOPE_KIND[scopeKey];
434
+ return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record]) => ({
435
+ id,
436
+ kind,
437
+ record
438
+ }));
439
+ });
440
+ }
441
+ function originFromContext(context) {
442
+ return {
443
+ kind: context.kind,
444
+ source: context.source,
445
+ path: context.path,
446
+ ...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
447
+ ...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
448
+ };
449
+ }
450
+ function createEmptyIndex() {
451
+ return {
452
+ objectTypes: {},
453
+ linkTypes: {},
454
+ actionTypes: {},
455
+ catalogTypes: {},
456
+ eventTypes: {},
457
+ interfaceTypes: {},
458
+ valueTypes: {},
459
+ sharedProperties: {},
460
+ groups: {},
461
+ surfaces: {}
462
+ };
463
+ }
464
+ function sortResolvedOntologyIndex(index) {
465
+ const sorted = createEmptyIndex();
466
+ for (const scopeKey of SCOPE_KEYS) {
467
+ const target = sorted[scopeKey];
468
+ for (const [id, record] of Object.entries(index[scopeKey]).sort(
469
+ ([leftId], [rightId]) => leftId.localeCompare(rightId)
470
+ )) {
471
+ target[id] = record;
472
+ }
473
+ }
474
+ return sorted;
475
+ }
476
+ function childSystemsOf2(system) {
477
+ return system.systems ?? system.subsystems ?? {};
478
+ }
479
+ function addRecord(index, diagnostics, sourcesById, scopeKey, record, context) {
480
+ let parsed;
481
+ try {
482
+ parsed = parseOntologyId(record.id);
483
+ } catch {
484
+ diagnostics.push({
485
+ code: "invalid_ontology_id",
486
+ message: `Invalid ontology ID "${record.id}" from ${context.source} at ${context.path.join(".")}`,
487
+ id: record.id,
488
+ path: context.path,
489
+ source: context.source,
490
+ origin: originFromContext(context)
491
+ });
492
+ return;
493
+ }
494
+ const expectedKind = SCOPE_KIND[scopeKey];
495
+ if (parsed.kind !== expectedKind) {
496
+ diagnostics.push({
497
+ code: "ontology_kind_mismatch",
498
+ message: `Ontology ID "${record.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
499
+ id: record.id,
500
+ path: context.path,
501
+ source: context.source,
502
+ origin: originFromContext(context)
503
+ });
504
+ return;
505
+ }
506
+ const existing = sourcesById.get(parsed.id);
507
+ if (existing !== void 0) {
508
+ diagnostics.push({
509
+ code: "duplicate_ontology_id",
510
+ message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
511
+ id: parsed.id,
512
+ path: context.path,
513
+ source: context.source,
514
+ origin: originFromContext(context),
515
+ existingSource: existing.source,
516
+ existingOrigin: originFromContext(existing)
517
+ });
518
+ return;
519
+ }
520
+ sourcesById.set(parsed.id, context);
521
+ index[scopeKey][parsed.id] = {
522
+ ...record,
523
+ origin: originFromContext(context)
524
+ };
525
+ }
526
+ function addScope(index, diagnostics, sourcesById, scope, source, path) {
527
+ if (scope === void 0) return;
528
+ for (const scopeKey of SCOPE_KEYS) {
529
+ const records = scope[scopeKey] ?? {};
530
+ for (const [key, record] of Object.entries(records)) {
531
+ addRecord(index, diagnostics, sourcesById, scopeKey, record, {
532
+ source,
533
+ path: [...path, scopeKey, key],
534
+ kind: "authored",
535
+ systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
536
+ });
537
+ }
538
+ }
539
+ }
540
+ function legacyObjectId(entity) {
541
+ return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
542
+ }
543
+ function legacyActionOwner(action, entities) {
544
+ const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
545
+ if (firstAffectedEntityId !== void 0) {
546
+ return entities[firstAffectedEntityId].ownedBySystemId;
547
+ }
548
+ if (typeof action.scope === "object") {
549
+ return action.scope.domain;
550
+ }
551
+ return "global";
552
+ }
553
+ function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
554
+ for (const entity of Object.values(entities)) {
555
+ const objectType = {
556
+ id: legacyObjectId(entity),
557
+ label: entity.label,
558
+ description: entity.description,
559
+ ownerSystemId: entity.ownedBySystemId,
560
+ ...entity.table !== void 0 ? {
561
+ storage: {
562
+ kind: "table",
563
+ table: entity.table
564
+ }
565
+ } : {},
566
+ ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
567
+ ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
568
+ };
569
+ addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
570
+ source: "legacy.entities",
571
+ path: ["entities", entity.id],
572
+ kind: "projected",
573
+ systemPath: entity.ownedBySystemId,
574
+ legacyId: entity.id
575
+ });
576
+ entity.links?.forEach((link, linkIndex) => {
577
+ const targetEntity = entities[link.toEntity];
578
+ if (targetEntity === void 0) return;
579
+ const linkType = {
580
+ id: formatOntologyId({
581
+ scope: entity.ownedBySystemId,
582
+ kind: "link",
583
+ localId: `${entity.id}-${link.toEntity}-${linkIndex}`
584
+ }),
585
+ label: link.label ?? link.kind,
586
+ ownerSystemId: entity.ownedBySystemId,
587
+ from: legacyObjectId(entity),
588
+ to: legacyObjectId(targetEntity),
589
+ cardinality: link.kind,
590
+ ...link.via !== void 0 ? { via: link.via } : {}
591
+ };
592
+ addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
593
+ source: "legacy.entities.links",
594
+ path: ["entities", entity.id, "links", linkIndex],
595
+ kind: "projected",
596
+ systemPath: entity.ownedBySystemId,
597
+ legacyId: `${entity.id}.links.${linkIndex}`
598
+ });
599
+ });
600
+ }
601
+ }
602
+ function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
603
+ for (const action of Object.values(actions)) {
604
+ const ownerSystemId = legacyActionOwner(action, entities);
605
+ const actionType = {
606
+ id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
607
+ label: action.label,
608
+ description: action.description,
609
+ ownerSystemId,
610
+ actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
611
+ ...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
612
+ ...action.invocations !== void 0 ? { invocations: action.invocations } : {},
613
+ ...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
614
+ legacyActionId: action.id
615
+ };
616
+ addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
617
+ source: "legacy.actions",
618
+ path: ["actions", action.id],
619
+ kind: "projected",
620
+ systemPath: ownerSystemId,
621
+ legacyId: action.id
622
+ });
623
+ }
624
+ }
625
+ function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
626
+ for (const [key, system] of Object.entries(systems)) {
627
+ const systemPath = prefix ? `${prefix}.${key}` : key;
628
+ const currentPath = [...schemaPath, key];
629
+ addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
630
+ ...currentPath,
631
+ "ontology"
632
+ ]);
633
+ addSystemScopes(index, diagnostics, sourcesById, childSystemsOf2(system), systemPath, [
634
+ ...currentPath,
635
+ system.systems !== void 0 ? "systems" : "subsystems"
636
+ ]);
637
+ }
638
+ }
639
+ function compileOrganizationOntology(model) {
640
+ const ontology = createEmptyIndex();
641
+ const diagnostics = [];
642
+ const sourcesById = /* @__PURE__ */ new Map();
643
+ addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
644
+ addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
645
+ addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
646
+ addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
647
+ return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
648
+ }
649
+
650
+ // ../core/src/organization-model/migration-helpers.ts
651
+ function catalogRecords(model) {
652
+ return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
653
+ }
654
+ function localId(id) {
655
+ return parseOntologyId(id).localId;
656
+ }
657
+ function systemScope(id, fallback) {
658
+ return parseOntologyId(id).scope || fallback || "";
659
+ }
660
+ function entriesOf(catalog) {
661
+ return Object.entries(catalog.entries ?? {}).map(([id, value]) => [
662
+ id,
663
+ value && typeof value === "object" && !Array.isArray(value) ? value : {}
664
+ ]);
665
+ }
666
+ function stringValue(value) {
667
+ return typeof value === "string" ? value : void 0;
668
+ }
669
+ function stringArray(value) {
670
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
671
+ }
672
+ function numberValue(value, fallback = 0) {
673
+ return typeof value === "number" ? value : fallback;
674
+ }
675
+ function stageFromEntry(entryId, entry) {
676
+ return {
677
+ id: entryId,
678
+ label: stringValue(entry.label) ?? entryId,
679
+ order: numberValue(entry.order),
680
+ semanticClass: stringValue(entry.semanticClass) ?? "open",
681
+ surfaceIds: stringArray(entry.surfaceIds),
682
+ resourceIds: stringArray(entry.resourceIds),
683
+ color: stringValue(entry.color)
684
+ };
685
+ }
686
+ function appliesToLocalId(catalog) {
687
+ const appliesTo = catalog.appliesTo;
688
+ if (appliesTo === void 0) return void 0;
689
+ return parseOntologyId(appliesTo).localId;
690
+ }
691
+ function appliesToEntityKind(catalog) {
692
+ const id = appliesToLocalId(catalog);
693
+ if (id === "company" || id === "contact" || id === "project" || id === "milestone" || id === "task") return id;
694
+ if (id === "deal") return void 0;
695
+ return void 0;
696
+ }
697
+ function getAllPipelines(model) {
698
+ return catalogRecords(model).filter((catalog) => catalog.kind === "pipeline").map((catalog) => {
699
+ const pipeline = {
700
+ id: localId(catalog.id),
701
+ label: catalog.label ?? localId(catalog.id),
702
+ ...catalog.description ? { description: catalog.description } : {},
703
+ entityId: appliesToLocalId(catalog) ?? "",
704
+ stages: entriesOf(catalog).map(([entryId, entry]) => stageFromEntry(entryId, entry)).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
705
+ };
706
+ return { systemPath: catalog.ownerSystemId ?? systemScope(catalog.id), pipeline };
707
+ }).sort((a, b) => a.systemPath.localeCompare(b.systemPath) || a.pipeline.id.localeCompare(b.pipeline.id));
708
+ }
709
+ function getAllBuildTemplates(model) {
710
+ const catalogs = catalogRecords(model);
711
+ const stepCatalogs = new Map(
712
+ catalogs.filter((catalog) => catalog.kind === "template-step").map((catalog) => [catalog.id, catalog])
713
+ );
714
+ return catalogs.filter((catalog) => catalog.kind === "template").flatMap(
715
+ (catalog) => entriesOf(catalog).map(([templateId, templateEntry]) => {
716
+ const stepCatalogId = stringValue(templateEntry.stepCatalog);
717
+ const stepCatalog = stepCatalogId !== void 0 ? stepCatalogs.get(stepCatalogId) : void 0;
718
+ const steps = stepCatalog === void 0 ? [] : entriesOf(stepCatalog).sort(
719
+ ([leftId, left], [rightId, right]) => numberValue(left.order, Number.MAX_SAFE_INTEGER) - numberValue(right.order, Number.MAX_SAFE_INTEGER) || leftId.localeCompare(rightId)
720
+ );
721
+ return {
722
+ order: numberValue(templateEntry.order, Number.MAX_SAFE_INTEGER),
723
+ template: {
724
+ id: templateId,
725
+ label: stringValue(templateEntry.label) ?? templateId,
726
+ ...stringValue(templateEntry.description) ? { description: stringValue(templateEntry.description) } : {},
727
+ ...stringValue(templateEntry.color) ? { color: stringValue(templateEntry.color) } : {},
728
+ steps: steps.map(([stepId, step]) => ({
729
+ id: stepId,
730
+ label: stringValue(step.label) ?? stepId,
731
+ ...stringValue(step.description) ? { description: stringValue(step.description) } : {},
732
+ ...step
733
+ }))
734
+ }
735
+ };
736
+ })
737
+ ).sort((a, b) => a.order - b.order || a.template.id.localeCompare(b.template.id)).map(({ template }) => template);
738
+ }
739
+ function getAllProspectingStages(model, kind) {
740
+ return catalogRecords(model).filter((catalog) => catalog.kind === "stage" && appliesToEntityKind(catalog) === kind).flatMap(
741
+ (catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
742
+ id: entryId,
743
+ label: stringValue(entry.label) ?? entryId,
744
+ order: numberValue(entry.order),
745
+ ...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
746
+ ...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
747
+ }))
748
+ ).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
749
+ }
750
+ function getLeadGenStageCatalog(model) {
751
+ const results = {};
752
+ for (const catalog of catalogRecords(model).filter(
753
+ (record) => record.kind === "stage" && (record.ownerSystemId ?? systemScope(record.id)) === "sales.lead-gen"
754
+ )) {
755
+ const catalogEntity = appliesToEntityKind(catalog);
756
+ if (catalogEntity !== "company" && catalogEntity !== "contact") continue;
757
+ for (const [entryId, entry] of entriesOf(catalog)) {
758
+ const entity = entry.entity === "contact" ? "contact" : entry.entity === "company" ? "company" : catalogEntity;
759
+ const additionalEntities = stringArray(entry.additionalEntities).filter(
760
+ (item) => item === "company" || item === "contact"
761
+ );
762
+ const recordEntity = entry.recordEntity === "company" || entry.recordEntity === "contact" ? entry.recordEntity : void 0;
763
+ const recordStageKey = stringValue(entry.recordStageKey);
764
+ results[entryId] = {
765
+ key: entryId,
766
+ label: stringValue(entry.label) ?? entryId,
767
+ description: stringValue(entry.description) ?? "",
768
+ order: numberValue(entry.order),
769
+ entity,
770
+ ...additionalEntities.length > 0 ? { additionalEntities } : {},
771
+ ...recordEntity ? { recordEntity } : {},
772
+ ...recordStageKey ? { recordStageKey } : {}
773
+ };
774
+ }
775
+ }
776
+ return Object.fromEntries(
777
+ Object.entries(results).sort(([, a], [, b]) => a.order - b.order || a.key.localeCompare(b.key))
778
+ );
779
+ }
780
+ function getAllProjectStatuses(model, appliesTo) {
781
+ return catalogRecords(model).filter((catalog) => catalog.kind === "status-flow" && appliesToEntityKind(catalog) === appliesTo).flatMap(
782
+ (catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
783
+ id: entryId,
784
+ label: stringValue(entry.label) ?? entryId,
785
+ order: numberValue(entry.order),
786
+ ...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
787
+ ...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
788
+ }))
789
+ ).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
790
+ }
791
+
171
792
  // ../core/src/business/acquisition/ontology-validation.ts
172
793
  var LEAD_GEN_API_INTERFACE = {
173
794
  systemPath: "sales.lead-gen",
@@ -710,6 +1331,14 @@ function getResourceIcon(type) {
710
1331
  // src/utils/constants/api.ts
711
1332
  var API_URL = import.meta.env.PROD ? "https://api.elevasis.io" : "http://localhost:5170";
712
1333
 
1334
+ // src/utils/constants/cache.ts
1335
+ var STALE_TIME_MONITORING = 3e4;
1336
+ var STALE_TIME_ADMIN = 6e4;
1337
+ var STALE_TIME_DEFAULT = 3e5;
1338
+ var GC_TIME_SHORT = 3e5;
1339
+ var GC_TIME_MEDIUM = 6e5;
1340
+ var GC_TIME_LONG = 18e5;
1341
+
713
1342
  // src/utils/constants/polling.ts
714
1343
  var REFETCH_INTERVAL_DASHBOARD = 6e4;
715
1344
  var REFETCH_INTERVAL_REALTIME = 3e4;
@@ -798,4 +1427,4 @@ function setupBrowserMocks() {
798
1427
  setupResizeObserver();
799
1428
  }
800
1429
 
801
- export { APIClientError, API_URL, DEBOUNCE_FILTER, DEBOUNCE_SLIDER, LEAD_GEN_API_INTERFACE, LIMIT_ACTIVITY_FEED, OAUTH_FLOW_TIMEOUT, PAGE_SIZE_DEFAULT, REFETCH_INTERVAL_DASHBOARD, REFETCH_INTERVAL_REALTIME, REFETCH_INTERVAL_RUNNING, REFETCH_INTERVAL_RUNNING_FAST, SSE_CLOSE_GRACE_PERIOD, SSE_TOKEN_REFRESH_DELAY, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, computeInterfaceReadiness, debounce, formatBucketTime, formatChartAxisDate, formatDate, formatDateTime, formatErrorMessage, formatRelativeTime, formatTimeAgo, getErrorInfo, getErrorTitle, getResourceColor, getResourceIcon, getTimeRangeDates, getTimeRangeLabel, isAPIClientError, restoreConsole, setupBrowserMocks, suppressKnownWarnings, validateEmail };
1430
+ export { APIClientError, API_URL, DEBOUNCE_FILTER, DEBOUNCE_SLIDER, DEFAULT_ONTOLOGY_SCOPE, GC_TIME_LONG, GC_TIME_MEDIUM, GC_TIME_SHORT, LEAD_GEN_API_INTERFACE, LIMIT_ACTIVITY_FEED, OAUTH_FLOW_TIMEOUT, OntologyIdSchema, OntologyScopeSchema, PAGE_SIZE_DEFAULT, REFETCH_INTERVAL_DASHBOARD, REFETCH_INTERVAL_REALTIME, REFETCH_INTERVAL_RUNNING, REFETCH_INTERVAL_RUNNING_FAST, SSE_CLOSE_GRACE_PERIOD, SSE_TOKEN_REFRESH_DELAY, STALE_TIME_ADMIN, STALE_TIME_DEFAULT, STALE_TIME_MONITORING, WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, ancestorsOf, childrenOf, compileOrganizationOntology, computeInterfaceReadiness, debounce, defaultPathFor, defineDomainRecord, devOnlyFor, findById, findByPath, formatBucketTime, formatChartAxisDate, formatDate, formatDateTime, formatErrorMessage, formatRelativeTime, formatTimeAgo, getAllBuildTemplates, getAllPipelines, getAllProjectStatuses, getAllProspectingStages, getErrorInfo, getErrorTitle, getLeadGenStageCatalog, getResourceColor, getResourceIcon, getResourcesForSystem, getSystem, getSystemAncestors, getTimeRangeDates, getTimeRangeLabel, isAPIClientError, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, parentOf, parseOntologyId, requiresAdminFor, resolveSystemConfig, restoreConsole, setupBrowserMocks, suppressKnownWarnings, topLevel, validateEmail };
@@ -1,5 +1,5 @@
1
- import { APIClientError } from './chunk-RXH4D6TY.js';
2
1
  import { OrganizationContext } from './chunk-DD3CCMCZ.js';
2
+ import { APIClientError } from './chunk-5M4HSHQ5.js';
3
3
  import { createContext, useContext, useMemo, useCallback } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5