@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.
- package/dist/api/index.js +4 -6
- package/dist/app/index.css +384 -0
- package/dist/app/index.d.ts +108 -0
- package/dist/app/index.js +17 -27
- package/dist/auth/index.css +659 -0
- package/dist/auth/index.js +19 -6
- package/dist/charts/index.css +533 -0
- package/dist/charts/index.js +18 -15
- package/dist/{chunk-RXH4D6TY.js → chunk-5M4HSHQ5.js} +631 -2
- package/dist/{chunk-TE4P6OSJ.js → chunk-7FJI76OH.js} +1 -1
- package/dist/chunk-GMXGDO3I.js +244 -0
- package/dist/{chunk-CXY7FMUM.js → chunk-GUKY77FJ.js} +50 -4
- package/dist/{chunk-5JYKCULK.js → chunk-NZ2F5RQ4.js} +44 -2
- package/dist/{chunk-WF7CONXF.js → chunk-OJJK27GC.js} +658 -6
- package/dist/{chunk-RX6RSKWC.js → chunk-QDXTIQT4.js} +29255 -18312
- package/dist/{chunk-73EWE2EW.js → chunk-V5HWC5EW.js} +1 -1
- package/dist/components/chat/index.js +1 -2
- package/dist/components/index.css +149 -149
- package/dist/components/index.js +13 -37
- package/dist/components/navigation/index.css +659 -0
- package/dist/components/navigation/index.js +25 -4
- package/dist/features/auth/index.js +14 -38
- package/dist/features/clients/index.css +149 -149
- package/dist/features/clients/index.js +13 -37
- package/dist/features/crm/index.js +13 -37
- package/dist/features/dashboard/index.js +13 -37
- package/dist/features/delivery/index.js +13 -37
- package/dist/features/knowledge/index.css +659 -0
- package/dist/features/knowledge/index.js +25 -248
- package/dist/features/lead-gen/index.d.ts +81 -0
- package/dist/features/lead-gen/index.js +13 -37
- package/dist/features/monitoring/index.js +13 -37
- package/dist/features/monitoring/requests/index.d.ts +69 -7
- package/dist/features/monitoring/requests/index.js +32 -41
- package/dist/features/operations/index.d.ts +79 -0
- package/dist/features/operations/index.js +13 -37
- package/dist/features/seo/index.js +1 -4
- package/dist/features/settings/index.js +13 -37
- package/dist/hooks/access/index.css +659 -0
- package/dist/hooks/access/index.js +19 -5
- package/dist/hooks/delivery/index.js +13 -37
- package/dist/hooks/index.d.ts +18 -6
- package/dist/hooks/index.js +13 -37
- package/dist/hooks/published.d.ts +18 -6
- package/dist/hooks/published.js +13 -37
- package/dist/index.d.ts +151 -7
- package/dist/index.js +14 -38
- package/dist/initialization/index.js +1 -1
- package/dist/knowledge/index.css +659 -0
- package/dist/knowledge/index.d.ts +81 -0
- package/dist/knowledge/index.js +25 -15
- package/dist/layout/index.css +659 -0
- package/dist/layout/index.d.ts +18 -2
- package/dist/layout/index.js +24 -7
- package/dist/organization/index.js +13 -37
- package/dist/provider/index.css +384 -0
- package/dist/provider/index.d.ts +120 -1
- package/dist/provider/index.js +18 -22
- package/dist/provider/published.css +533 -0
- package/dist/provider/published.d.ts +121 -2
- package/dist/provider/published.js +18 -17
- package/dist/test-utils/index.js +4 -6
- package/dist/theme/index.js +2 -5
- package/dist/theme/presets/index.js +1 -2
- package/dist/utils/index.js +1 -3
- package/package.json +3 -3
- package/dist/chunk-3KMDHCAR.js +0 -52
- package/dist/chunk-4DRI3G36.js +0 -1016
- package/dist/chunk-5EYJ2GIN.js +0 -122
- package/dist/chunk-66U7JOWV.js +0 -425
- package/dist/chunk-6D4LCJ52.js +0 -10
- package/dist/chunk-6EV47QQW.js +0 -340
- package/dist/chunk-6ROXVZ3L.js +0 -9
- package/dist/chunk-7MTWRSUZ.js +0 -357
- package/dist/chunk-7PHY5ONQ.js +0 -85
- package/dist/chunk-B2DZLPDL.js +0 -39
- package/dist/chunk-CLDCYJQT.js +0 -1
- package/dist/chunk-CTJBPF3Z.js +0 -734
- package/dist/chunk-DT3QYZVU.js +0 -23
- package/dist/chunk-IIMU5YAJ.js +0 -53
- package/dist/chunk-IUQAP4IO.js +0 -2131
- package/dist/chunk-J3FLIZY4.js +0 -423
- package/dist/chunk-K7GKKETO.js +0 -3157
- package/dist/chunk-L7GXUSCV.js +0 -215
- package/dist/chunk-LJDYY3XB.js +0 -133
- package/dist/chunk-NYBEU5TE.js +0 -118
- package/dist/chunk-RH5VWWSC.js +0 -624
- package/dist/chunk-SJNIOGVX.js +0 -112
- package/dist/chunk-TYRUKGGD.js +0 -46
- package/dist/chunk-WLOQ4IBG.js +0 -654
- package/dist/chunk-X4WBGKJQ.js +0 -138
- package/dist/chunk-X7D6SUKR.js +0 -1234
package/dist/chunk-RH5VWWSC.js
DELETED
|
@@ -1,624 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
// ../core/src/organization-model/helpers.ts
|
|
4
|
-
function defineDomainRecord(schema, entries) {
|
|
5
|
-
return Object.fromEntries(
|
|
6
|
-
entries.map((entry) => {
|
|
7
|
-
const parsed = schema.parse(entry);
|
|
8
|
-
return [parsed.id, parsed];
|
|
9
|
-
})
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
function childSystemsOf(system) {
|
|
13
|
-
return system.systems ?? system.subsystems ?? {};
|
|
14
|
-
}
|
|
15
|
-
function defaultPathFor(id) {
|
|
16
|
-
return `/${id.replaceAll(".", "/")}`;
|
|
17
|
-
}
|
|
18
|
-
function parentIdOf(id) {
|
|
19
|
-
const index = id.lastIndexOf(".");
|
|
20
|
-
return index === -1 ? void 0 : id.slice(0, index);
|
|
21
|
-
}
|
|
22
|
-
function findById(systems, id) {
|
|
23
|
-
return systems[id];
|
|
24
|
-
}
|
|
25
|
-
function findByPath(systems, path) {
|
|
26
|
-
return Object.values(systems).find((system) => (system.path ?? system.ui?.path ?? defaultPathFor(system.id)) === path);
|
|
27
|
-
}
|
|
28
|
-
function childrenOf(systems, id) {
|
|
29
|
-
const prefix = `${id}.`;
|
|
30
|
-
return Object.values(systems).filter(
|
|
31
|
-
(system) => system.id.startsWith(prefix) && !system.id.slice(prefix.length).includes(".")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
function topLevel(systems) {
|
|
35
|
-
return Object.values(systems).filter((system) => !system.id.includes("."));
|
|
36
|
-
}
|
|
37
|
-
function ancestorsOf(systems, id) {
|
|
38
|
-
const segments = id.split(".");
|
|
39
|
-
const ids = segments.map((_, index) => segments.slice(0, index + 1).join("."));
|
|
40
|
-
return ids.map((ancestorId) => findById(systems, ancestorId)).filter((system) => Boolean(system));
|
|
41
|
-
}
|
|
42
|
-
function parentOf(systems, id) {
|
|
43
|
-
const parentId = parentIdOf(id);
|
|
44
|
-
return parentId ? findById(systems, parentId) : void 0;
|
|
45
|
-
}
|
|
46
|
-
function inheritedValue(systems, id, getValue) {
|
|
47
|
-
return ancestorsOf(systems, id).slice().reverse().map(getValue).find((value) => value !== void 0);
|
|
48
|
-
}
|
|
49
|
-
function requiresAdminFor(systems, id) {
|
|
50
|
-
return inheritedValue(systems, id, (system) => system.requiresAdmin) ?? false;
|
|
51
|
-
}
|
|
52
|
-
function devOnlyFor(systems, id) {
|
|
53
|
-
return inheritedValue(systems, id, (system) => system.devOnly || system.lifecycle === "beta" || void 0) ?? false;
|
|
54
|
-
}
|
|
55
|
-
function getSystem(model, path) {
|
|
56
|
-
const flatMatch = model.systems[path];
|
|
57
|
-
if (flatMatch !== void 0) return flatMatch;
|
|
58
|
-
const segments = path.split(".");
|
|
59
|
-
let current = model.systems;
|
|
60
|
-
let node;
|
|
61
|
-
for (const seg of segments) {
|
|
62
|
-
node = current[seg];
|
|
63
|
-
if (node === void 0) return void 0;
|
|
64
|
-
current = childSystemsOf(node);
|
|
65
|
-
}
|
|
66
|
-
return node;
|
|
67
|
-
}
|
|
68
|
-
function getSystemAncestors(model, path) {
|
|
69
|
-
const flatMatch = model.systems[path];
|
|
70
|
-
if (flatMatch !== void 0) {
|
|
71
|
-
const ancestorIds = path.split(".").map((_, index, segments2) => segments2.slice(0, index + 1).join(".")).slice(0, -1);
|
|
72
|
-
return [
|
|
73
|
-
...ancestorIds.map((ancestorId) => model.systems[ancestorId]).filter((system) => system !== void 0),
|
|
74
|
-
flatMatch
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
const segments = path.split(".");
|
|
78
|
-
const result = [];
|
|
79
|
-
let current = model.systems;
|
|
80
|
-
for (const seg of segments) {
|
|
81
|
-
const node = current[seg];
|
|
82
|
-
if (node === void 0) return [];
|
|
83
|
-
result.push(node);
|
|
84
|
-
current = childSystemsOf(node);
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
function listAllSystems(model) {
|
|
89
|
-
const results = [];
|
|
90
|
-
function walk(map, prefix) {
|
|
91
|
-
for (const [localId2, system] of Object.entries(map)) {
|
|
92
|
-
const fullPath = prefix ? `${prefix}.${localId2}` : localId2;
|
|
93
|
-
results.push({ path: fullPath, system });
|
|
94
|
-
const childSystems = childSystemsOf(system);
|
|
95
|
-
if (Object.keys(childSystems).length > 0) {
|
|
96
|
-
walk(childSystems, fullPath);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
walk(model.systems, "");
|
|
101
|
-
return results;
|
|
102
|
-
}
|
|
103
|
-
function isPlainJsonObject(value) {
|
|
104
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
105
|
-
}
|
|
106
|
-
function mergeJsonConfig(base, override) {
|
|
107
|
-
const result = { ...base };
|
|
108
|
-
for (const [key, value] of Object.entries(override)) {
|
|
109
|
-
const existing = result[key];
|
|
110
|
-
result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
function resolveSystemConfig(model, path) {
|
|
115
|
-
const system = getSystem(model, path);
|
|
116
|
-
if (system === void 0) return {};
|
|
117
|
-
return mergeJsonConfig({}, system.config ?? {});
|
|
118
|
-
}
|
|
119
|
-
function getResourcesForSystem(model, systemPath, options = {}) {
|
|
120
|
-
const { includeDescendants = false } = options;
|
|
121
|
-
const prefix = systemPath + ".";
|
|
122
|
-
return Object.values(model.resources ?? {}).filter(
|
|
123
|
-
(r) => r.systemPath === systemPath || includeDescendants && r.systemPath.startsWith(prefix)
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
var OntologyKindSchema = z.enum([
|
|
127
|
-
"object",
|
|
128
|
-
"link",
|
|
129
|
-
"action",
|
|
130
|
-
"catalog",
|
|
131
|
-
"event",
|
|
132
|
-
"interface",
|
|
133
|
-
"value-type",
|
|
134
|
-
"property",
|
|
135
|
-
"group",
|
|
136
|
-
"surface"
|
|
137
|
-
]);
|
|
138
|
-
var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
|
|
139
|
-
var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
|
|
140
|
-
var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
|
|
141
|
-
var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
|
|
142
|
-
var OntologyIdSchema = z.string().trim().min(1).max(300).regex(
|
|
143
|
-
ONTOLOGY_ID_REGEX,
|
|
144
|
-
"Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
|
|
145
|
-
);
|
|
146
|
-
function parseOntologyId(id) {
|
|
147
|
-
const normalized = OntologyIdSchema.parse(id);
|
|
148
|
-
const match = ONTOLOGY_ID_REGEX.exec(normalized);
|
|
149
|
-
if (match === null) {
|
|
150
|
-
throw new Error(`Invalid ontology ID "${id}"`);
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
id: normalized,
|
|
154
|
-
scope: match[1],
|
|
155
|
-
kind: match[2],
|
|
156
|
-
localId: match[3],
|
|
157
|
-
isGlobal: match[1] === "global"
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function formatOntologyId(input) {
|
|
161
|
-
return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
|
|
162
|
-
}
|
|
163
|
-
var OntologyReferenceListSchema = z.array(OntologyIdSchema).default([]).optional();
|
|
164
|
-
var OntologyRecordBaseSchema = z.object({
|
|
165
|
-
id: OntologyIdSchema,
|
|
166
|
-
label: z.string().trim().min(1).max(160).optional(),
|
|
167
|
-
description: z.string().trim().min(1).max(2e3).optional(),
|
|
168
|
-
ownerSystemId: z.string().trim().min(1).max(200).optional(),
|
|
169
|
-
aliases: z.array(OntologyIdSchema).optional()
|
|
170
|
-
}).passthrough();
|
|
171
|
-
var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
|
|
172
|
-
properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
|
|
173
|
-
storage: z.record(z.string(), z.unknown()).optional()
|
|
174
|
-
});
|
|
175
|
-
var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
|
|
176
|
-
from: OntologyIdSchema,
|
|
177
|
-
to: OntologyIdSchema,
|
|
178
|
-
cardinality: z.string().trim().min(1).max(80).optional(),
|
|
179
|
-
via: z.string().trim().min(1).max(255).optional()
|
|
180
|
-
});
|
|
181
|
-
var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
|
|
182
|
-
actsOn: OntologyReferenceListSchema,
|
|
183
|
-
input: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
|
|
184
|
-
effects: z.array(z.record(z.string(), z.unknown())).optional()
|
|
185
|
-
});
|
|
186
|
-
var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
|
|
187
|
-
kind: z.string().trim().min(1).max(120).optional(),
|
|
188
|
-
appliesTo: OntologyIdSchema.optional(),
|
|
189
|
-
entries: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
190
|
-
});
|
|
191
|
-
var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
|
|
192
|
-
payload: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
193
|
-
});
|
|
194
|
-
var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
|
|
195
|
-
properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
196
|
-
});
|
|
197
|
-
var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
|
|
198
|
-
primitive: z.string().trim().min(1).max(120).optional()
|
|
199
|
-
});
|
|
200
|
-
var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
|
|
201
|
-
valueType: OntologyIdSchema.optional(),
|
|
202
|
-
searchable: z.boolean().optional(),
|
|
203
|
-
pii: z.boolean().optional()
|
|
204
|
-
});
|
|
205
|
-
var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
|
|
206
|
-
members: OntologyReferenceListSchema
|
|
207
|
-
});
|
|
208
|
-
var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
|
|
209
|
-
route: z.string().trim().min(1).max(500).optional()
|
|
210
|
-
});
|
|
211
|
-
var OntologyScopeSchema = z.object({
|
|
212
|
-
objectTypes: z.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
|
|
213
|
-
linkTypes: z.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
|
|
214
|
-
actionTypes: z.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
|
|
215
|
-
catalogTypes: z.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
|
|
216
|
-
eventTypes: z.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
|
|
217
|
-
interfaceTypes: z.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
|
|
218
|
-
valueTypes: z.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
|
|
219
|
-
sharedProperties: z.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
|
|
220
|
-
groups: z.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
|
|
221
|
-
surfaces: z.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
|
|
222
|
-
}).default({});
|
|
223
|
-
var DEFAULT_ONTOLOGY_SCOPE = {
|
|
224
|
-
valueTypes: {
|
|
225
|
-
"global:value-type/uuid": {
|
|
226
|
-
id: "global:value-type/uuid",
|
|
227
|
-
label: "UUID",
|
|
228
|
-
primitive: "string"
|
|
229
|
-
},
|
|
230
|
-
"global:value-type/text": {
|
|
231
|
-
id: "global:value-type/text",
|
|
232
|
-
label: "Text",
|
|
233
|
-
primitive: "string"
|
|
234
|
-
},
|
|
235
|
-
"global:value-type/url": {
|
|
236
|
-
id: "global:value-type/url",
|
|
237
|
-
label: "URL",
|
|
238
|
-
primitive: "string"
|
|
239
|
-
},
|
|
240
|
-
"global:value-type/email": {
|
|
241
|
-
id: "global:value-type/email",
|
|
242
|
-
label: "Email",
|
|
243
|
-
primitive: "string"
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
var SCOPE_KIND = {
|
|
248
|
-
objectTypes: "object",
|
|
249
|
-
linkTypes: "link",
|
|
250
|
-
actionTypes: "action",
|
|
251
|
-
catalogTypes: "catalog",
|
|
252
|
-
eventTypes: "event",
|
|
253
|
-
interfaceTypes: "interface",
|
|
254
|
-
valueTypes: "value-type",
|
|
255
|
-
sharedProperties: "property",
|
|
256
|
-
groups: "group",
|
|
257
|
-
surfaces: "surface"
|
|
258
|
-
};
|
|
259
|
-
var SCOPE_KEYS = Object.keys(SCOPE_KIND);
|
|
260
|
-
function ontologyGraphNodeId(id) {
|
|
261
|
-
return `ontology:${OntologyIdSchema.parse(id)}`;
|
|
262
|
-
}
|
|
263
|
-
function listResolvedOntologyRecords(index) {
|
|
264
|
-
return SCOPE_KEYS.flatMap((scopeKey) => {
|
|
265
|
-
const kind = SCOPE_KIND[scopeKey];
|
|
266
|
-
return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record]) => ({
|
|
267
|
-
id,
|
|
268
|
-
kind,
|
|
269
|
-
record
|
|
270
|
-
}));
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
function originFromContext(context) {
|
|
274
|
-
return {
|
|
275
|
-
kind: context.kind,
|
|
276
|
-
source: context.source,
|
|
277
|
-
path: context.path,
|
|
278
|
-
...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
|
|
279
|
-
...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
function createEmptyIndex() {
|
|
283
|
-
return {
|
|
284
|
-
objectTypes: {},
|
|
285
|
-
linkTypes: {},
|
|
286
|
-
actionTypes: {},
|
|
287
|
-
catalogTypes: {},
|
|
288
|
-
eventTypes: {},
|
|
289
|
-
interfaceTypes: {},
|
|
290
|
-
valueTypes: {},
|
|
291
|
-
sharedProperties: {},
|
|
292
|
-
groups: {},
|
|
293
|
-
surfaces: {}
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
function sortResolvedOntologyIndex(index) {
|
|
297
|
-
const sorted = createEmptyIndex();
|
|
298
|
-
for (const scopeKey of SCOPE_KEYS) {
|
|
299
|
-
const target = sorted[scopeKey];
|
|
300
|
-
for (const [id, record] of Object.entries(index[scopeKey]).sort(
|
|
301
|
-
([leftId], [rightId]) => leftId.localeCompare(rightId)
|
|
302
|
-
)) {
|
|
303
|
-
target[id] = record;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return sorted;
|
|
307
|
-
}
|
|
308
|
-
function childSystemsOf2(system) {
|
|
309
|
-
return system.systems ?? system.subsystems ?? {};
|
|
310
|
-
}
|
|
311
|
-
function addRecord(index, diagnostics, sourcesById, scopeKey, record, context) {
|
|
312
|
-
let parsed;
|
|
313
|
-
try {
|
|
314
|
-
parsed = parseOntologyId(record.id);
|
|
315
|
-
} catch {
|
|
316
|
-
diagnostics.push({
|
|
317
|
-
code: "invalid_ontology_id",
|
|
318
|
-
message: `Invalid ontology ID "${record.id}" from ${context.source} at ${context.path.join(".")}`,
|
|
319
|
-
id: record.id,
|
|
320
|
-
path: context.path,
|
|
321
|
-
source: context.source,
|
|
322
|
-
origin: originFromContext(context)
|
|
323
|
-
});
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
const expectedKind = SCOPE_KIND[scopeKey];
|
|
327
|
-
if (parsed.kind !== expectedKind) {
|
|
328
|
-
diagnostics.push({
|
|
329
|
-
code: "ontology_kind_mismatch",
|
|
330
|
-
message: `Ontology ID "${record.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
|
|
331
|
-
id: record.id,
|
|
332
|
-
path: context.path,
|
|
333
|
-
source: context.source,
|
|
334
|
-
origin: originFromContext(context)
|
|
335
|
-
});
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const existing = sourcesById.get(parsed.id);
|
|
339
|
-
if (existing !== void 0) {
|
|
340
|
-
diagnostics.push({
|
|
341
|
-
code: "duplicate_ontology_id",
|
|
342
|
-
message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
|
|
343
|
-
id: parsed.id,
|
|
344
|
-
path: context.path,
|
|
345
|
-
source: context.source,
|
|
346
|
-
origin: originFromContext(context),
|
|
347
|
-
existingSource: existing.source,
|
|
348
|
-
existingOrigin: originFromContext(existing)
|
|
349
|
-
});
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
sourcesById.set(parsed.id, context);
|
|
353
|
-
index[scopeKey][parsed.id] = {
|
|
354
|
-
...record,
|
|
355
|
-
origin: originFromContext(context)
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function addScope(index, diagnostics, sourcesById, scope, source, path) {
|
|
359
|
-
if (scope === void 0) return;
|
|
360
|
-
for (const scopeKey of SCOPE_KEYS) {
|
|
361
|
-
const records = scope[scopeKey] ?? {};
|
|
362
|
-
for (const [key, record] of Object.entries(records)) {
|
|
363
|
-
addRecord(index, diagnostics, sourcesById, scopeKey, record, {
|
|
364
|
-
source,
|
|
365
|
-
path: [...path, scopeKey, key],
|
|
366
|
-
kind: "authored",
|
|
367
|
-
systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
function legacyObjectId(entity) {
|
|
373
|
-
return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
|
|
374
|
-
}
|
|
375
|
-
function legacyActionOwner(action, entities) {
|
|
376
|
-
const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
|
|
377
|
-
if (firstAffectedEntityId !== void 0) {
|
|
378
|
-
return entities[firstAffectedEntityId].ownedBySystemId;
|
|
379
|
-
}
|
|
380
|
-
if (typeof action.scope === "object") {
|
|
381
|
-
return action.scope.domain;
|
|
382
|
-
}
|
|
383
|
-
return "global";
|
|
384
|
-
}
|
|
385
|
-
function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
|
|
386
|
-
for (const entity of Object.values(entities)) {
|
|
387
|
-
const objectType = {
|
|
388
|
-
id: legacyObjectId(entity),
|
|
389
|
-
label: entity.label,
|
|
390
|
-
description: entity.description,
|
|
391
|
-
ownerSystemId: entity.ownedBySystemId,
|
|
392
|
-
...entity.table !== void 0 ? {
|
|
393
|
-
storage: {
|
|
394
|
-
kind: "table",
|
|
395
|
-
table: entity.table
|
|
396
|
-
}
|
|
397
|
-
} : {},
|
|
398
|
-
...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
|
|
399
|
-
...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
|
|
400
|
-
};
|
|
401
|
-
addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
|
|
402
|
-
source: "legacy.entities",
|
|
403
|
-
path: ["entities", entity.id],
|
|
404
|
-
kind: "projected",
|
|
405
|
-
systemPath: entity.ownedBySystemId,
|
|
406
|
-
legacyId: entity.id
|
|
407
|
-
});
|
|
408
|
-
entity.links?.forEach((link, linkIndex) => {
|
|
409
|
-
const targetEntity = entities[link.toEntity];
|
|
410
|
-
if (targetEntity === void 0) return;
|
|
411
|
-
const linkType = {
|
|
412
|
-
id: formatOntologyId({
|
|
413
|
-
scope: entity.ownedBySystemId,
|
|
414
|
-
kind: "link",
|
|
415
|
-
localId: `${entity.id}-${link.toEntity}-${linkIndex}`
|
|
416
|
-
}),
|
|
417
|
-
label: link.label ?? link.kind,
|
|
418
|
-
ownerSystemId: entity.ownedBySystemId,
|
|
419
|
-
from: legacyObjectId(entity),
|
|
420
|
-
to: legacyObjectId(targetEntity),
|
|
421
|
-
cardinality: link.kind,
|
|
422
|
-
...link.via !== void 0 ? { via: link.via } : {}
|
|
423
|
-
};
|
|
424
|
-
addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
|
|
425
|
-
source: "legacy.entities.links",
|
|
426
|
-
path: ["entities", entity.id, "links", linkIndex],
|
|
427
|
-
kind: "projected",
|
|
428
|
-
systemPath: entity.ownedBySystemId,
|
|
429
|
-
legacyId: `${entity.id}.links.${linkIndex}`
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
|
|
435
|
-
for (const action of Object.values(actions)) {
|
|
436
|
-
const ownerSystemId = legacyActionOwner(action, entities);
|
|
437
|
-
const actionType = {
|
|
438
|
-
id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
|
|
439
|
-
label: action.label,
|
|
440
|
-
description: action.description,
|
|
441
|
-
ownerSystemId,
|
|
442
|
-
actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
|
|
443
|
-
...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
|
|
444
|
-
...action.invocations !== void 0 ? { invocations: action.invocations } : {},
|
|
445
|
-
...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
|
|
446
|
-
legacyActionId: action.id
|
|
447
|
-
};
|
|
448
|
-
addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
|
|
449
|
-
source: "legacy.actions",
|
|
450
|
-
path: ["actions", action.id],
|
|
451
|
-
kind: "projected",
|
|
452
|
-
systemPath: ownerSystemId,
|
|
453
|
-
legacyId: action.id
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
|
|
458
|
-
for (const [key, system] of Object.entries(systems)) {
|
|
459
|
-
const systemPath = prefix ? `${prefix}.${key}` : key;
|
|
460
|
-
const currentPath = [...schemaPath, key];
|
|
461
|
-
addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
|
|
462
|
-
...currentPath,
|
|
463
|
-
"ontology"
|
|
464
|
-
]);
|
|
465
|
-
addSystemScopes(index, diagnostics, sourcesById, childSystemsOf2(system), systemPath, [
|
|
466
|
-
...currentPath,
|
|
467
|
-
system.systems !== void 0 ? "systems" : "subsystems"
|
|
468
|
-
]);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
function compileOrganizationOntology(model) {
|
|
472
|
-
const ontology = createEmptyIndex();
|
|
473
|
-
const diagnostics = [];
|
|
474
|
-
const sourcesById = /* @__PURE__ */ new Map();
|
|
475
|
-
addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
|
|
476
|
-
addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
|
|
477
|
-
addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
|
|
478
|
-
addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
|
|
479
|
-
return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// ../core/src/organization-model/migration-helpers.ts
|
|
483
|
-
function catalogRecords(model) {
|
|
484
|
-
return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
|
|
485
|
-
}
|
|
486
|
-
function localId(id) {
|
|
487
|
-
return parseOntologyId(id).localId;
|
|
488
|
-
}
|
|
489
|
-
function systemScope(id, fallback) {
|
|
490
|
-
return parseOntologyId(id).scope || fallback || "";
|
|
491
|
-
}
|
|
492
|
-
function entriesOf(catalog) {
|
|
493
|
-
return Object.entries(catalog.entries ?? {}).map(([id, value]) => [
|
|
494
|
-
id,
|
|
495
|
-
value && typeof value === "object" && !Array.isArray(value) ? value : {}
|
|
496
|
-
]);
|
|
497
|
-
}
|
|
498
|
-
function stringValue(value) {
|
|
499
|
-
return typeof value === "string" ? value : void 0;
|
|
500
|
-
}
|
|
501
|
-
function stringArray(value) {
|
|
502
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
503
|
-
}
|
|
504
|
-
function numberValue(value, fallback = 0) {
|
|
505
|
-
return typeof value === "number" ? value : fallback;
|
|
506
|
-
}
|
|
507
|
-
function stageFromEntry(entryId, entry) {
|
|
508
|
-
return {
|
|
509
|
-
id: entryId,
|
|
510
|
-
label: stringValue(entry.label) ?? entryId,
|
|
511
|
-
order: numberValue(entry.order),
|
|
512
|
-
semanticClass: stringValue(entry.semanticClass) ?? "open",
|
|
513
|
-
surfaceIds: stringArray(entry.surfaceIds),
|
|
514
|
-
resourceIds: stringArray(entry.resourceIds),
|
|
515
|
-
color: stringValue(entry.color)
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
function appliesToLocalId(catalog) {
|
|
519
|
-
const appliesTo = catalog.appliesTo;
|
|
520
|
-
if (appliesTo === void 0) return void 0;
|
|
521
|
-
return parseOntologyId(appliesTo).localId;
|
|
522
|
-
}
|
|
523
|
-
function appliesToEntityKind(catalog) {
|
|
524
|
-
const id = appliesToLocalId(catalog);
|
|
525
|
-
if (id === "company" || id === "contact" || id === "project" || id === "milestone" || id === "task") return id;
|
|
526
|
-
if (id === "deal") return void 0;
|
|
527
|
-
return void 0;
|
|
528
|
-
}
|
|
529
|
-
function getAllPipelines(model) {
|
|
530
|
-
return catalogRecords(model).filter((catalog) => catalog.kind === "pipeline").map((catalog) => {
|
|
531
|
-
const pipeline = {
|
|
532
|
-
id: localId(catalog.id),
|
|
533
|
-
label: catalog.label ?? localId(catalog.id),
|
|
534
|
-
...catalog.description ? { description: catalog.description } : {},
|
|
535
|
-
entityId: appliesToLocalId(catalog) ?? "",
|
|
536
|
-
stages: entriesOf(catalog).map(([entryId, entry]) => stageFromEntry(entryId, entry)).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id))
|
|
537
|
-
};
|
|
538
|
-
return { systemPath: catalog.ownerSystemId ?? systemScope(catalog.id), pipeline };
|
|
539
|
-
}).sort((a, b) => a.systemPath.localeCompare(b.systemPath) || a.pipeline.id.localeCompare(b.pipeline.id));
|
|
540
|
-
}
|
|
541
|
-
function getAllBuildTemplates(model) {
|
|
542
|
-
const catalogs = catalogRecords(model);
|
|
543
|
-
const stepCatalogs = new Map(
|
|
544
|
-
catalogs.filter((catalog) => catalog.kind === "template-step").map((catalog) => [catalog.id, catalog])
|
|
545
|
-
);
|
|
546
|
-
return catalogs.filter((catalog) => catalog.kind === "template").flatMap(
|
|
547
|
-
(catalog) => entriesOf(catalog).map(([templateId, templateEntry]) => {
|
|
548
|
-
const stepCatalogId = stringValue(templateEntry.stepCatalog);
|
|
549
|
-
const stepCatalog = stepCatalogId !== void 0 ? stepCatalogs.get(stepCatalogId) : void 0;
|
|
550
|
-
const steps = stepCatalog === void 0 ? [] : entriesOf(stepCatalog).sort(
|
|
551
|
-
([leftId, left], [rightId, right]) => numberValue(left.order, Number.MAX_SAFE_INTEGER) - numberValue(right.order, Number.MAX_SAFE_INTEGER) || leftId.localeCompare(rightId)
|
|
552
|
-
);
|
|
553
|
-
return {
|
|
554
|
-
order: numberValue(templateEntry.order, Number.MAX_SAFE_INTEGER),
|
|
555
|
-
template: {
|
|
556
|
-
id: templateId,
|
|
557
|
-
label: stringValue(templateEntry.label) ?? templateId,
|
|
558
|
-
...stringValue(templateEntry.description) ? { description: stringValue(templateEntry.description) } : {},
|
|
559
|
-
...stringValue(templateEntry.color) ? { color: stringValue(templateEntry.color) } : {},
|
|
560
|
-
steps: steps.map(([stepId, step]) => ({
|
|
561
|
-
id: stepId,
|
|
562
|
-
label: stringValue(step.label) ?? stepId,
|
|
563
|
-
...stringValue(step.description) ? { description: stringValue(step.description) } : {},
|
|
564
|
-
...step
|
|
565
|
-
}))
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
})
|
|
569
|
-
).sort((a, b) => a.order - b.order || a.template.id.localeCompare(b.template.id)).map(({ template }) => template);
|
|
570
|
-
}
|
|
571
|
-
function getAllProspectingStages(model, kind) {
|
|
572
|
-
return catalogRecords(model).filter((catalog) => catalog.kind === "stage" && appliesToEntityKind(catalog) === kind).flatMap(
|
|
573
|
-
(catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
|
|
574
|
-
id: entryId,
|
|
575
|
-
label: stringValue(entry.label) ?? entryId,
|
|
576
|
-
order: numberValue(entry.order),
|
|
577
|
-
...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
|
|
578
|
-
...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
|
|
579
|
-
}))
|
|
580
|
-
).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
|
|
581
|
-
}
|
|
582
|
-
function getLeadGenStageCatalog(model) {
|
|
583
|
-
const results = {};
|
|
584
|
-
for (const catalog of catalogRecords(model).filter(
|
|
585
|
-
(record) => record.kind === "stage" && (record.ownerSystemId ?? systemScope(record.id)) === "sales.lead-gen"
|
|
586
|
-
)) {
|
|
587
|
-
const catalogEntity = appliesToEntityKind(catalog);
|
|
588
|
-
if (catalogEntity !== "company" && catalogEntity !== "contact") continue;
|
|
589
|
-
for (const [entryId, entry] of entriesOf(catalog)) {
|
|
590
|
-
const entity = entry.entity === "contact" ? "contact" : entry.entity === "company" ? "company" : catalogEntity;
|
|
591
|
-
const additionalEntities = stringArray(entry.additionalEntities).filter(
|
|
592
|
-
(item) => item === "company" || item === "contact"
|
|
593
|
-
);
|
|
594
|
-
const recordEntity = entry.recordEntity === "company" || entry.recordEntity === "contact" ? entry.recordEntity : void 0;
|
|
595
|
-
const recordStageKey = stringValue(entry.recordStageKey);
|
|
596
|
-
results[entryId] = {
|
|
597
|
-
key: entryId,
|
|
598
|
-
label: stringValue(entry.label) ?? entryId,
|
|
599
|
-
description: stringValue(entry.description) ?? "",
|
|
600
|
-
order: numberValue(entry.order),
|
|
601
|
-
entity,
|
|
602
|
-
...additionalEntities.length > 0 ? { additionalEntities } : {},
|
|
603
|
-
...recordEntity ? { recordEntity } : {},
|
|
604
|
-
...recordStageKey ? { recordStageKey } : {}
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
return Object.fromEntries(
|
|
609
|
-
Object.entries(results).sort(([, a], [, b]) => a.order - b.order || a.key.localeCompare(b.key))
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
function getAllProjectStatuses(model, appliesTo) {
|
|
613
|
-
return catalogRecords(model).filter((catalog) => catalog.kind === "status-flow" && appliesToEntityKind(catalog) === appliesTo).flatMap(
|
|
614
|
-
(catalog) => entriesOf(catalog).map(([entryId, entry]) => ({
|
|
615
|
-
id: entryId,
|
|
616
|
-
label: stringValue(entry.label) ?? entryId,
|
|
617
|
-
order: numberValue(entry.order),
|
|
618
|
-
...stringValue(entry.color) ? { color: stringValue(entry.color) } : {},
|
|
619
|
-
...stringValue(entry.description) ? { description: stringValue(entry.description) } : {}
|
|
620
|
-
}))
|
|
621
|
-
).sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
export { DEFAULT_ONTOLOGY_SCOPE, OntologyIdSchema, OntologyScopeSchema, ancestorsOf, childrenOf, compileOrganizationOntology, defaultPathFor, defineDomainRecord, devOnlyFor, findById, findByPath, formatOntologyId, getAllBuildTemplates, getAllPipelines, getAllProjectStatuses, getAllProspectingStages, getLeadGenStageCatalog, getResourcesForSystem, getSystem, getSystemAncestors, listAllSystems, listResolvedOntologyRecords, ontologyGraphNodeId, parentOf, parseOntologyId, requiresAdminFor, resolveSystemConfig, topLevel };
|