@elevasis/core 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1326 -552
- package/dist/index.js +869 -154
- package/dist/knowledge/index.d.ts +487 -209
- package/dist/knowledge/index.js +104 -1
- package/dist/organization-model/index.d.ts +1326 -552
- package/dist/organization-model/index.js +869 -154
- package/dist/test-utils/index.d.ts +357 -72
- package/dist/test-utils/index.js +795 -142
- package/package.json +5 -5
- package/src/README.md +14 -14
- package/src/__tests__/publish.test.ts +24 -24
- package/src/__tests__/template-core-compatibility.test.ts +9 -12
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +2102 -2096
- package/src/_gen/__tests__/scaffold-contracts.test.ts +30 -30
- package/src/auth/multi-tenancy/credentials/__tests__/encryption.test.ts +217 -217
- package/src/auth/multi-tenancy/credentials/server/encryption.ts +69 -69
- package/src/auth/multi-tenancy/credentials/server/kek-loader.ts +37 -37
- package/src/auth/multi-tenancy/index.ts +26 -26
- package/src/auth/multi-tenancy/invitations/api-schemas.ts +104 -104
- package/src/auth/multi-tenancy/memberships/api-schemas.ts +143 -143
- package/src/auth/multi-tenancy/memberships/index.ts +26 -26
- package/src/auth/multi-tenancy/memberships/membership.ts +130 -130
- package/src/auth/multi-tenancy/organizations/__tests__/api-schemas.test.ts +194 -194
- package/src/auth/multi-tenancy/organizations/api-schemas.ts +136 -136
- package/src/auth/multi-tenancy/permissions.test.ts +42 -42
- package/src/auth/multi-tenancy/permissions.ts +123 -123
- package/src/auth/multi-tenancy/role-management/api-schemas.ts +78 -78
- package/src/auth/multi-tenancy/role-management/index.ts +16 -16
- package/src/auth/multi-tenancy/theme-presets.ts +45 -45
- package/src/auth/multi-tenancy/types.ts +57 -57
- package/src/auth/multi-tenancy/users/api-schemas.ts +165 -165
- package/src/business/README.md +2 -2
- package/src/business/acquisition/activity-events.test.ts +250 -250
- package/src/business/acquisition/activity-events.ts +93 -93
- package/src/business/acquisition/api-schemas.test.ts +1883 -1843
- package/src/business/acquisition/api-schemas.ts +1492 -1497
- package/src/business/acquisition/build-templates.test.ts +240 -240
- package/src/business/acquisition/build-templates.ts +98 -98
- package/src/business/acquisition/crm-next-action.test.ts +262 -262
- package/src/business/acquisition/crm-next-action.ts +220 -220
- package/src/business/acquisition/crm-priority.test.ts +216 -216
- package/src/business/acquisition/crm-priority.ts +349 -349
- package/src/business/acquisition/crm-state-actions.test.ts +153 -153
- package/src/business/acquisition/deal-ownership.test.ts +351 -351
- package/src/business/acquisition/deal-ownership.ts +120 -120
- package/src/business/acquisition/derive-actions.test.ts +129 -104
- package/src/business/acquisition/derive-actions.ts +74 -84
- package/src/business/acquisition/index.ts +171 -170
- package/src/business/acquisition/ontology-validation.ts +309 -0
- package/src/business/acquisition/stateful.ts +30 -30
- package/src/business/acquisition/types.ts +396 -396
- package/src/business/clients/api-schemas.test.ts +115 -115
- package/src/business/clients/api-schemas.ts +158 -158
- package/src/business/clients/index.ts +1 -1
- package/src/business/crm/api-schemas.ts +40 -40
- package/src/business/crm/index.ts +1 -1
- package/src/business/deals/api-schemas.ts +87 -87
- package/src/business/deals/index.ts +1 -1
- package/src/business/index.ts +5 -5
- package/src/business/projects/types.ts +144 -144
- package/src/commands/queue/types/task.ts +15 -15
- package/src/execution/core/runner-types.ts +61 -61
- package/src/execution/core/sse-executions.ts +7 -7
- package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -10
- package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -16
- package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -4
- package/src/execution/engine/agent/core/types.ts +25 -25
- package/src/execution/engine/agent/index.ts +6 -6
- package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -24
- package/src/execution/engine/index.ts +443 -443
- package/src/execution/engine/tools/integration/server/adapters/apify/__tests__/apify-run-actor.integration.test.ts +298 -298
- package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.test.ts +55 -55
- package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.ts +107 -107
- package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.test.ts +48 -48
- package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.ts +99 -99
- package/src/execution/engine/tools/integration/server/adapters/apollo/index.ts +1 -1
- package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +363 -363
- package/src/execution/engine/tools/integration/server/adapters/attio/fetch/get-record/index.test.ts +162 -162
- package/src/execution/engine/tools/integration/server/adapters/attio/fetch/list-records/index.test.ts +316 -316
- package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.test.ts +18 -18
- package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.ts +194 -194
- package/src/execution/engine/tools/integration/server/adapters/clickup/index.ts +7 -7
- package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-adapter.ts +204 -204
- package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-tools.ts +105 -105
- package/src/execution/engine/tools/integration/server/adapters/google-calendar/google-calendar-adapter.ts +428 -428
- package/src/execution/engine/tools/integration/server/adapters/google-calendar/index.ts +2 -2
- package/src/execution/engine/tools/integration/server/adapters/google-sheets/__tests__/google-sheets.integration.test.ts +261 -261
- package/src/execution/engine/tools/integration/server/adapters/instantly/instantly-tools.ts +1474 -1474
- package/src/execution/engine/tools/integration/server/adapters/millionverifier/millionverifier-tools.ts +103 -103
- package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.test.ts +88 -88
- package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.ts +141 -141
- package/src/execution/engine/tools/integration/server/adapters/resend/fetch/utils/types.ts +76 -76
- package/src/execution/engine/tools/integration/server/adapters/signature-api/signature-api-tools.ts +182 -182
- package/src/execution/engine/tools/integration/server/adapters/stripe/stripe-tools.ts +310 -310
- package/src/execution/engine/tools/integration/service.test.ts +239 -239
- package/src/execution/engine/tools/integration/service.ts +172 -172
- package/src/execution/engine/tools/integration/tool.ts +255 -255
- package/src/execution/engine/tools/lead-service-types.ts +1005 -1005
- package/src/execution/engine/tools/messages.ts +43 -43
- package/src/execution/engine/tools/platform/acquisition/company-tools.ts +7 -7
- package/src/execution/engine/tools/platform/acquisition/contact-tools.ts +6 -6
- package/src/execution/engine/tools/platform/acquisition/list-tools.ts +6 -6
- package/src/execution/engine/tools/platform/acquisition/types.ts +280 -280
- package/src/execution/engine/tools/platform/email/types.ts +97 -97
- package/src/execution/engine/tools/registry.ts +704 -704
- package/src/execution/engine/tools/tool-maps.ts +831 -831
- package/src/execution/engine/tools/types.ts +234 -234
- package/src/execution/engine/workflow/types.ts +202 -202
- package/src/execution/external/__tests__/api-schemas.test.ts +127 -127
- package/src/execution/external/api-schemas.ts +40 -40
- package/src/execution/external/index.ts +1 -1
- package/src/index.ts +18 -18
- package/src/integrations/credentials/__tests__/api-schemas.test.ts +420 -420
- package/src/integrations/credentials/api-schemas.ts +146 -146
- package/src/integrations/credentials/schemas.ts +200 -200
- package/src/integrations/oauth/__tests__/provider-registry.test.ts +7 -7
- package/src/integrations/oauth/provider-registry.ts +74 -74
- package/src/integrations/oauth/server/credentials.ts +43 -43
- package/src/integrations/webhook-endpoints/__tests__/api-schemas.test.ts +327 -327
- package/src/integrations/webhook-endpoints/api-schemas.ts +103 -103
- package/src/integrations/webhook-endpoints/types.ts +58 -58
- package/src/knowledge/README.md +32 -32
- package/src/knowledge/__tests__/queries.test.ts +626 -535
- package/src/knowledge/format.ts +99 -99
- package/src/knowledge/index.ts +5 -5
- package/src/knowledge/published.ts +5 -5
- package/src/knowledge/queries.ts +269 -218
- package/src/operations/activities/api-schemas.ts +80 -80
- package/src/operations/activities/types.ts +64 -64
- package/src/organization-model/README.md +149 -149
- package/src/organization-model/__tests__/content-kinds-registry.test.ts +210 -210
- package/src/organization-model/__tests__/defaults.test.ts +168 -168
- package/src/organization-model/__tests__/domains/actions.test.ts +78 -56
- package/src/organization-model/__tests__/domains/customers.test.ts +299 -299
- package/src/organization-model/__tests__/domains/entities.test.ts +56 -56
- package/src/organization-model/__tests__/domains/goals.test.ts +493 -493
- package/src/organization-model/__tests__/domains/identity.test.ts +280 -280
- package/src/organization-model/__tests__/domains/navigation.test.ts +268 -268
- package/src/organization-model/__tests__/domains/offerings.test.ts +414 -414
- package/src/organization-model/__tests__/domains/policies.test.ts +323 -323
- package/src/organization-model/__tests__/domains/resource-mappings.test.ts +293 -293
- package/src/organization-model/__tests__/domains/resources.test.ts +382 -283
- package/src/organization-model/__tests__/domains/roles.test.ts +463 -463
- package/src/organization-model/__tests__/domains/statuses.test.ts +246 -246
- package/src/organization-model/__tests__/domains/systems.test.ts +209 -209
- package/src/organization-model/__tests__/flatten-additive-merge.test.ts +362 -361
- package/src/organization-model/__tests__/foundation.test.ts +77 -77
- package/src/organization-model/__tests__/get-resources-for-system.test.ts +144 -144
- package/src/organization-model/__tests__/graph.test.ts +1246 -887
- package/src/organization-model/__tests__/icons.test.ts +10 -1
- package/src/organization-model/__tests__/knowledge.test.ts +251 -15
- package/src/organization-model/__tests__/lookup-helpers.test.ts +438 -438
- package/src/organization-model/__tests__/migration-helpers.test.ts +591 -591
- package/src/organization-model/__tests__/prospecting-ssot.test.ts +103 -103
- package/src/organization-model/__tests__/recursive-system-schema.test.ts +535 -506
- package/src/organization-model/__tests__/resolve.test.ts +274 -164
- package/src/organization-model/__tests__/schema.test.ts +834 -301
- package/src/organization-model/__tests__/surface-projection.test.ts +284 -284
- package/src/organization-model/catalogs/lead-gen.ts +144 -144
- package/src/organization-model/content-kinds/config.ts +36 -36
- package/src/organization-model/content-kinds/index.ts +76 -72
- package/src/organization-model/content-kinds/pipeline.ts +68 -68
- package/src/organization-model/content-kinds/registry.ts +44 -44
- package/src/organization-model/content-kinds/status.ts +71 -71
- package/src/organization-model/content-kinds/template.ts +83 -83
- package/src/organization-model/content-kinds/types.ts +117 -117
- package/src/organization-model/contracts.ts +27 -27
- package/src/organization-model/defaults.ts +40 -50
- package/src/organization-model/domains/actions.ts +333 -239
- package/src/organization-model/domains/customers.ts +78 -78
- package/src/organization-model/domains/entities.ts +144 -144
- package/src/organization-model/domains/goals.ts +83 -83
- package/src/organization-model/domains/knowledge.ts +117 -101
- package/src/organization-model/domains/navigation.ts +139 -139
- package/src/organization-model/domains/offerings.ts +71 -71
- package/src/organization-model/domains/policies.ts +102 -102
- package/src/organization-model/domains/projects.ts +14 -14
- package/src/organization-model/domains/prospecting.ts +395 -395
- package/src/organization-model/domains/resources.ts +167 -132
- package/src/organization-model/domains/roles.ts +96 -96
- package/src/organization-model/domains/sales.test.ts +218 -218
- package/src/organization-model/domains/sales.ts +380 -380
- package/src/organization-model/domains/shared.ts +63 -63
- package/src/organization-model/domains/statuses.ts +339 -339
- package/src/organization-model/domains/systems.ts +217 -172
- package/src/organization-model/foundation.ts +75 -75
- package/src/organization-model/graph/build.ts +1016 -888
- package/src/organization-model/graph/index.ts +4 -4
- package/src/organization-model/graph/link.ts +10 -10
- package/src/organization-model/graph/schema.ts +76 -70
- package/src/organization-model/graph/types.ts +73 -67
- package/src/organization-model/helpers.ts +289 -241
- package/src/organization-model/icons.ts +78 -66
- package/src/organization-model/index.ts +130 -128
- package/src/organization-model/migration-helpers.ts +247 -244
- package/src/organization-model/ontology.ts +661 -0
- package/src/organization-model/organization-graph.mdx +110 -90
- package/src/organization-model/organization-model.mdx +226 -219
- package/src/organization-model/published.ts +289 -235
- package/src/organization-model/resolve.ts +146 -91
- package/src/organization-model/schema.ts +790 -671
- package/src/organization-model/surface-projection.ts +212 -212
- package/src/organization-model/types.ts +177 -167
- package/src/platform/api/types.ts +38 -38
- package/src/platform/constants/versions.ts +3 -3
- package/src/platform/index.ts +23 -23
- package/src/platform/registry/__tests__/command-view.test.ts +10 -10
- package/src/platform/registry/__tests__/resource-link.test.ts +35 -35
- package/src/platform/registry/__tests__/resource-registry.integration.test.ts +20 -20
- package/src/platform/registry/__tests__/resource-registry.nested-systems.test.ts +245 -245
- package/src/platform/registry/__tests__/resource-registry.test.ts +2053 -2053
- package/src/platform/registry/__tests__/validation.test.ts +1347 -1347
- package/src/platform/registry/command-view.ts +10 -10
- package/src/platform/registry/index.ts +103 -103
- package/src/platform/registry/resource-link.ts +32 -32
- package/src/platform/registry/resource-registry.ts +890 -890
- package/src/platform/registry/serialization.ts +295 -295
- package/src/platform/registry/serialized-types.ts +166 -166
- package/src/platform/registry/stats-types.ts +68 -68
- package/src/platform/registry/types.ts +425 -425
- package/src/platform/registry/validation.ts +745 -745
- package/src/platform/utils/__tests__/validation.test.ts +1084 -1084
- package/src/platform/utils/validation.ts +425 -425
- package/src/projects/api-schemas.test.ts +39 -39
- package/src/projects/api-schemas.ts +291 -291
- package/src/reference/_generated/contracts.md +2101 -2096
- package/src/reference/glossary.md +76 -76
- package/src/scaffold-registry/__tests__/index.test.ts +206 -206
- package/src/scaffold-registry/__tests__/schema.test.ts +166 -166
- package/src/scaffold-registry/index.ts +392 -392
- package/src/scaffold-registry/schema.ts +243 -243
- package/src/server.ts +289 -289
- package/src/supabase/database.types.ts +3153 -3153
- package/src/test-utils/README.md +37 -37
- package/src/test-utils/entities.ts +108 -108
- package/src/test-utils/fixtures/memberships.ts +82 -82
- package/src/test-utils/index.ts +12 -12
- package/src/test-utils/organization-model.ts +65 -65
- package/src/test-utils/published.ts +6 -6
- package/src/test-utils/rls/RLSTestContext.ts +588 -588
- package/src/test-utils/test-utils.test.ts +44 -44
package/dist/index.js
CHANGED
|
@@ -1,6 +1,410 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
// src/organization-model/
|
|
3
|
+
// src/organization-model/ontology.ts
|
|
4
|
+
var OntologyKindSchema = z.enum([
|
|
5
|
+
"object",
|
|
6
|
+
"link",
|
|
7
|
+
"action",
|
|
8
|
+
"catalog",
|
|
9
|
+
"event",
|
|
10
|
+
"interface",
|
|
11
|
+
"value-type",
|
|
12
|
+
"property",
|
|
13
|
+
"group",
|
|
14
|
+
"surface"
|
|
15
|
+
]);
|
|
16
|
+
var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
|
|
17
|
+
var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
|
|
18
|
+
var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
|
|
19
|
+
var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
|
|
20
|
+
var OntologyIdSchema = z.string().trim().min(1).max(300).regex(
|
|
21
|
+
ONTOLOGY_ID_REGEX,
|
|
22
|
+
"Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
|
|
23
|
+
);
|
|
24
|
+
function parseOntologyId(id) {
|
|
25
|
+
const normalized = OntologyIdSchema.parse(id);
|
|
26
|
+
const match = ONTOLOGY_ID_REGEX.exec(normalized);
|
|
27
|
+
if (match === null) {
|
|
28
|
+
throw new Error(`Invalid ontology ID "${id}"`);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
id: normalized,
|
|
32
|
+
scope: match[1],
|
|
33
|
+
kind: match[2],
|
|
34
|
+
localId: match[3],
|
|
35
|
+
isGlobal: match[1] === "global"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function formatOntologyId(input) {
|
|
39
|
+
return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
|
|
40
|
+
}
|
|
41
|
+
var OntologyReferenceListSchema = z.array(OntologyIdSchema).default([]).optional();
|
|
42
|
+
var OntologyRecordBaseSchema = z.object({
|
|
43
|
+
id: OntologyIdSchema,
|
|
44
|
+
label: z.string().trim().min(1).max(160).optional(),
|
|
45
|
+
description: z.string().trim().min(1).max(2e3).optional(),
|
|
46
|
+
ownerSystemId: z.string().trim().min(1).max(200).optional(),
|
|
47
|
+
aliases: z.array(OntologyIdSchema).optional()
|
|
48
|
+
}).passthrough();
|
|
49
|
+
var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
|
|
50
|
+
properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
|
|
51
|
+
storage: z.record(z.string(), z.unknown()).optional()
|
|
52
|
+
});
|
|
53
|
+
var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
|
|
54
|
+
from: OntologyIdSchema,
|
|
55
|
+
to: OntologyIdSchema,
|
|
56
|
+
cardinality: z.string().trim().min(1).max(80).optional(),
|
|
57
|
+
via: z.string().trim().min(1).max(255).optional()
|
|
58
|
+
});
|
|
59
|
+
var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
|
|
60
|
+
actsOn: OntologyReferenceListSchema,
|
|
61
|
+
input: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
|
|
62
|
+
effects: z.array(z.record(z.string(), z.unknown())).optional()
|
|
63
|
+
});
|
|
64
|
+
var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
|
|
65
|
+
kind: z.string().trim().min(1).max(120).optional(),
|
|
66
|
+
appliesTo: OntologyIdSchema.optional(),
|
|
67
|
+
entries: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
68
|
+
});
|
|
69
|
+
var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
|
|
70
|
+
payload: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
71
|
+
});
|
|
72
|
+
var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
|
|
73
|
+
properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
74
|
+
});
|
|
75
|
+
var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
|
|
76
|
+
primitive: z.string().trim().min(1).max(120).optional()
|
|
77
|
+
});
|
|
78
|
+
var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
|
|
79
|
+
valueType: OntologyIdSchema.optional(),
|
|
80
|
+
searchable: z.boolean().optional(),
|
|
81
|
+
pii: z.boolean().optional()
|
|
82
|
+
});
|
|
83
|
+
var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
|
|
84
|
+
members: OntologyReferenceListSchema
|
|
85
|
+
});
|
|
86
|
+
var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
|
|
87
|
+
route: z.string().trim().min(1).max(500).optional()
|
|
88
|
+
});
|
|
89
|
+
var OntologyScopeSchema = z.object({
|
|
90
|
+
objectTypes: z.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
|
|
91
|
+
linkTypes: z.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
|
|
92
|
+
actionTypes: z.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
|
|
93
|
+
catalogTypes: z.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
|
|
94
|
+
eventTypes: z.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
|
|
95
|
+
interfaceTypes: z.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
|
|
96
|
+
valueTypes: z.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
|
|
97
|
+
sharedProperties: z.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
|
|
98
|
+
groups: z.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
|
|
99
|
+
surfaces: z.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
|
|
100
|
+
}).default({});
|
|
101
|
+
var DEFAULT_ONTOLOGY_SCOPE = {
|
|
102
|
+
valueTypes: {
|
|
103
|
+
"global:value-type/uuid": {
|
|
104
|
+
id: "global:value-type/uuid",
|
|
105
|
+
label: "UUID",
|
|
106
|
+
primitive: "string"
|
|
107
|
+
},
|
|
108
|
+
"global:value-type/text": {
|
|
109
|
+
id: "global:value-type/text",
|
|
110
|
+
label: "Text",
|
|
111
|
+
primitive: "string"
|
|
112
|
+
},
|
|
113
|
+
"global:value-type/url": {
|
|
114
|
+
id: "global:value-type/url",
|
|
115
|
+
label: "URL",
|
|
116
|
+
primitive: "string"
|
|
117
|
+
},
|
|
118
|
+
"global:value-type/email": {
|
|
119
|
+
id: "global:value-type/email",
|
|
120
|
+
label: "Email",
|
|
121
|
+
primitive: "string"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var SCOPE_KIND = {
|
|
126
|
+
objectTypes: "object",
|
|
127
|
+
linkTypes: "link",
|
|
128
|
+
actionTypes: "action",
|
|
129
|
+
catalogTypes: "catalog",
|
|
130
|
+
eventTypes: "event",
|
|
131
|
+
interfaceTypes: "interface",
|
|
132
|
+
valueTypes: "value-type",
|
|
133
|
+
sharedProperties: "property",
|
|
134
|
+
groups: "group",
|
|
135
|
+
surfaces: "surface"
|
|
136
|
+
};
|
|
137
|
+
var SCOPE_KEYS = Object.keys(SCOPE_KIND);
|
|
138
|
+
function ontologyGraphNodeId(id) {
|
|
139
|
+
return `ontology:${OntologyIdSchema.parse(id)}`;
|
|
140
|
+
}
|
|
141
|
+
function ontologyIdFromGraphNodeId(nodeId) {
|
|
142
|
+
if (!nodeId.startsWith("ontology:")) return void 0;
|
|
143
|
+
const result = OntologyIdSchema.safeParse(nodeId.slice("ontology:".length));
|
|
144
|
+
return result.success ? result.data : void 0;
|
|
145
|
+
}
|
|
146
|
+
function isOntologyGraphNodeId(nodeId) {
|
|
147
|
+
return ontologyIdFromGraphNodeId(nodeId) !== void 0;
|
|
148
|
+
}
|
|
149
|
+
function listResolvedOntologyRecords(index) {
|
|
150
|
+
return SCOPE_KEYS.flatMap((scopeKey) => {
|
|
151
|
+
const kind = SCOPE_KIND[scopeKey];
|
|
152
|
+
return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record]) => ({
|
|
153
|
+
id,
|
|
154
|
+
kind,
|
|
155
|
+
record
|
|
156
|
+
}));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function originFromContext(context) {
|
|
160
|
+
return {
|
|
161
|
+
kind: context.kind,
|
|
162
|
+
source: context.source,
|
|
163
|
+
path: context.path,
|
|
164
|
+
...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
|
|
165
|
+
...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function createEmptyIndex() {
|
|
169
|
+
return {
|
|
170
|
+
objectTypes: {},
|
|
171
|
+
linkTypes: {},
|
|
172
|
+
actionTypes: {},
|
|
173
|
+
catalogTypes: {},
|
|
174
|
+
eventTypes: {},
|
|
175
|
+
interfaceTypes: {},
|
|
176
|
+
valueTypes: {},
|
|
177
|
+
sharedProperties: {},
|
|
178
|
+
groups: {},
|
|
179
|
+
surfaces: {}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function sortResolvedOntologyIndex(index) {
|
|
183
|
+
const sorted = createEmptyIndex();
|
|
184
|
+
for (const scopeKey of SCOPE_KEYS) {
|
|
185
|
+
const target = sorted[scopeKey];
|
|
186
|
+
for (const [id, record] of Object.entries(index[scopeKey]).sort(
|
|
187
|
+
([leftId], [rightId]) => leftId.localeCompare(rightId)
|
|
188
|
+
)) {
|
|
189
|
+
target[id] = record;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return sorted;
|
|
193
|
+
}
|
|
194
|
+
function childSystemsOf(system) {
|
|
195
|
+
return system.systems ?? system.subsystems ?? {};
|
|
196
|
+
}
|
|
197
|
+
function addRecord(index, diagnostics, sourcesById, scopeKey, record, context) {
|
|
198
|
+
let parsed;
|
|
199
|
+
try {
|
|
200
|
+
parsed = parseOntologyId(record.id);
|
|
201
|
+
} catch {
|
|
202
|
+
diagnostics.push({
|
|
203
|
+
code: "invalid_ontology_id",
|
|
204
|
+
message: `Invalid ontology ID "${record.id}" from ${context.source} at ${context.path.join(".")}`,
|
|
205
|
+
id: record.id,
|
|
206
|
+
path: context.path,
|
|
207
|
+
source: context.source,
|
|
208
|
+
origin: originFromContext(context)
|
|
209
|
+
});
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const expectedKind = SCOPE_KIND[scopeKey];
|
|
213
|
+
if (parsed.kind !== expectedKind) {
|
|
214
|
+
diagnostics.push({
|
|
215
|
+
code: "ontology_kind_mismatch",
|
|
216
|
+
message: `Ontology ID "${record.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
|
|
217
|
+
id: record.id,
|
|
218
|
+
path: context.path,
|
|
219
|
+
source: context.source,
|
|
220
|
+
origin: originFromContext(context)
|
|
221
|
+
});
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const existing = sourcesById.get(parsed.id);
|
|
225
|
+
if (existing !== void 0) {
|
|
226
|
+
diagnostics.push({
|
|
227
|
+
code: "duplicate_ontology_id",
|
|
228
|
+
message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
|
|
229
|
+
id: parsed.id,
|
|
230
|
+
path: context.path,
|
|
231
|
+
source: context.source,
|
|
232
|
+
origin: originFromContext(context),
|
|
233
|
+
existingSource: existing.source,
|
|
234
|
+
existingOrigin: originFromContext(existing)
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
sourcesById.set(parsed.id, context);
|
|
239
|
+
index[scopeKey][parsed.id] = {
|
|
240
|
+
...record,
|
|
241
|
+
origin: originFromContext(context)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function addScope(index, diagnostics, sourcesById, scope, source, path) {
|
|
245
|
+
if (scope === void 0) return;
|
|
246
|
+
for (const scopeKey of SCOPE_KEYS) {
|
|
247
|
+
const records = scope[scopeKey] ?? {};
|
|
248
|
+
for (const [key, record] of Object.entries(records)) {
|
|
249
|
+
addRecord(index, diagnostics, sourcesById, scopeKey, record, {
|
|
250
|
+
source,
|
|
251
|
+
path: [...path, scopeKey, key],
|
|
252
|
+
kind: "authored",
|
|
253
|
+
systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function legacyObjectId(entity) {
|
|
259
|
+
return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
|
|
260
|
+
}
|
|
261
|
+
function legacyActionOwner(action, entities) {
|
|
262
|
+
const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
|
|
263
|
+
if (firstAffectedEntityId !== void 0) {
|
|
264
|
+
return entities[firstAffectedEntityId].ownedBySystemId;
|
|
265
|
+
}
|
|
266
|
+
if (typeof action.scope === "object") {
|
|
267
|
+
return action.scope.domain;
|
|
268
|
+
}
|
|
269
|
+
return "global";
|
|
270
|
+
}
|
|
271
|
+
function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
|
|
272
|
+
for (const entity of Object.values(entities)) {
|
|
273
|
+
const objectType = {
|
|
274
|
+
id: legacyObjectId(entity),
|
|
275
|
+
label: entity.label,
|
|
276
|
+
description: entity.description,
|
|
277
|
+
ownerSystemId: entity.ownedBySystemId,
|
|
278
|
+
...entity.table !== void 0 ? {
|
|
279
|
+
storage: {
|
|
280
|
+
kind: "table",
|
|
281
|
+
table: entity.table
|
|
282
|
+
}
|
|
283
|
+
} : {},
|
|
284
|
+
legacyEntityId: entity.id,
|
|
285
|
+
...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
|
|
286
|
+
...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
|
|
287
|
+
};
|
|
288
|
+
addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
|
|
289
|
+
source: "legacy.entities",
|
|
290
|
+
path: ["entities", entity.id],
|
|
291
|
+
kind: "projected",
|
|
292
|
+
systemPath: entity.ownedBySystemId,
|
|
293
|
+
legacyId: entity.id
|
|
294
|
+
});
|
|
295
|
+
entity.links?.forEach((link, linkIndex) => {
|
|
296
|
+
const targetEntity = entities[link.toEntity];
|
|
297
|
+
if (targetEntity === void 0) return;
|
|
298
|
+
const linkType = {
|
|
299
|
+
id: formatOntologyId({
|
|
300
|
+
scope: entity.ownedBySystemId,
|
|
301
|
+
kind: "link",
|
|
302
|
+
localId: `${entity.id}-${link.toEntity}-${linkIndex}`
|
|
303
|
+
}),
|
|
304
|
+
label: link.label ?? link.kind,
|
|
305
|
+
ownerSystemId: entity.ownedBySystemId,
|
|
306
|
+
from: legacyObjectId(entity),
|
|
307
|
+
to: legacyObjectId(targetEntity),
|
|
308
|
+
cardinality: link.kind,
|
|
309
|
+
...link.via !== void 0 ? { via: link.via } : {},
|
|
310
|
+
legacyEntityId: entity.id
|
|
311
|
+
};
|
|
312
|
+
addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
|
|
313
|
+
source: "legacy.entities.links",
|
|
314
|
+
path: ["entities", entity.id, "links", linkIndex],
|
|
315
|
+
kind: "projected",
|
|
316
|
+
systemPath: entity.ownedBySystemId,
|
|
317
|
+
legacyId: `${entity.id}.links.${linkIndex}`
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
|
|
323
|
+
for (const action of Object.values(actions)) {
|
|
324
|
+
const ownerSystemId = legacyActionOwner(action, entities);
|
|
325
|
+
const actionType = {
|
|
326
|
+
id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
|
|
327
|
+
label: action.label,
|
|
328
|
+
description: action.description,
|
|
329
|
+
ownerSystemId,
|
|
330
|
+
actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
|
|
331
|
+
...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
|
|
332
|
+
...action.invocations !== void 0 ? { invocations: action.invocations } : {},
|
|
333
|
+
...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
|
|
334
|
+
legacyActionId: action.id
|
|
335
|
+
};
|
|
336
|
+
addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
|
|
337
|
+
source: "legacy.actions",
|
|
338
|
+
path: ["actions", action.id],
|
|
339
|
+
kind: "projected",
|
|
340
|
+
systemPath: ownerSystemId,
|
|
341
|
+
legacyId: action.id
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, schemaPath) {
|
|
346
|
+
const content = system.content ?? {};
|
|
347
|
+
for (const [localId, node] of Object.entries(content)) {
|
|
348
|
+
if (node.kind !== "schema") continue;
|
|
349
|
+
const entries = Object.fromEntries(
|
|
350
|
+
Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
|
|
351
|
+
entryId,
|
|
352
|
+
{
|
|
353
|
+
label: candidate.label ?? entryId,
|
|
354
|
+
type: candidate.type,
|
|
355
|
+
...candidate.description !== void 0 ? { description: candidate.description } : {},
|
|
356
|
+
...candidate.data !== void 0 ? candidate.data : {}
|
|
357
|
+
}
|
|
358
|
+
])
|
|
359
|
+
);
|
|
360
|
+
const catalogType = {
|
|
361
|
+
id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
|
|
362
|
+
label: node.label ?? localId,
|
|
363
|
+
description: node.description,
|
|
364
|
+
ownerSystemId: systemPath,
|
|
365
|
+
kind: node.type,
|
|
366
|
+
...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
|
|
367
|
+
...Object.keys(entries).length > 0 ? { entries } : {},
|
|
368
|
+
...node.data !== void 0 ? { data: node.data } : {},
|
|
369
|
+
legacyContentId: `${systemPath}:${localId}`
|
|
370
|
+
};
|
|
371
|
+
addRecord(index, diagnostics, sourcesById, "catalogTypes", catalogType, {
|
|
372
|
+
source: "legacy.system.content",
|
|
373
|
+
path: [...schemaPath, "content", localId],
|
|
374
|
+
kind: "projected",
|
|
375
|
+
systemPath,
|
|
376
|
+
legacyId: `${systemPath}:${localId}`
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
|
|
381
|
+
for (const [key, system] of Object.entries(systems)) {
|
|
382
|
+
const systemPath = prefix ? `${prefix}.${key}` : key;
|
|
383
|
+
const currentPath = [...schemaPath, key];
|
|
384
|
+
addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
|
|
385
|
+
...currentPath,
|
|
386
|
+
"ontology"
|
|
387
|
+
]);
|
|
388
|
+
addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, currentPath);
|
|
389
|
+
addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
|
|
390
|
+
...currentPath,
|
|
391
|
+
system.systems !== void 0 ? "systems" : "subsystems"
|
|
392
|
+
]);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function compileOrganizationOntology(model) {
|
|
396
|
+
const ontology = createEmptyIndex();
|
|
397
|
+
const diagnostics = [];
|
|
398
|
+
const sourcesById = /* @__PURE__ */ new Map();
|
|
399
|
+
addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
|
|
400
|
+
addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
|
|
401
|
+
addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
|
|
402
|
+
addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
|
|
403
|
+
return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
|
|
404
|
+
}
|
|
405
|
+
function getOntologyDiagnostics(model) {
|
|
406
|
+
return compileOrganizationOntology(model).diagnostics;
|
|
407
|
+
}
|
|
4
408
|
|
|
5
409
|
// src/organization-model/content-kinds/registry.ts
|
|
6
410
|
function defineContentType(def) {
|
|
@@ -186,73 +590,78 @@ function lookupContentType(kind, type) {
|
|
|
186
590
|
return CONTENT_KIND_REGISTRY[key];
|
|
187
591
|
}
|
|
188
592
|
var ORGANIZATION_MODEL_ICON_TOKENS = [
|
|
189
|
-
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
"
|
|
206
|
-
|
|
207
|
-
"
|
|
208
|
-
"
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
|
|
218
|
-
"
|
|
219
|
-
"
|
|
220
|
-
"
|
|
221
|
-
|
|
222
|
-
"
|
|
223
|
-
"
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
-
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"
|
|
232
|
-
"
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"
|
|
236
|
-
"
|
|
237
|
-
"
|
|
238
|
-
"
|
|
239
|
-
"
|
|
240
|
-
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
"
|
|
244
|
-
"
|
|
245
|
-
"
|
|
246
|
-
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
"
|
|
250
|
-
"
|
|
251
|
-
"
|
|
252
|
-
"
|
|
253
|
-
"
|
|
593
|
+
// Navigation / app areas
|
|
594
|
+
"dashboard",
|
|
595
|
+
"calendar",
|
|
596
|
+
"sales",
|
|
597
|
+
"crm",
|
|
598
|
+
"lead-gen",
|
|
599
|
+
"projects",
|
|
600
|
+
"operations",
|
|
601
|
+
"monitoring",
|
|
602
|
+
"knowledge",
|
|
603
|
+
"settings",
|
|
604
|
+
"admin",
|
|
605
|
+
"archive",
|
|
606
|
+
"business",
|
|
607
|
+
"finance",
|
|
608
|
+
"platform",
|
|
609
|
+
"seo",
|
|
610
|
+
// Knowledge kinds
|
|
611
|
+
"playbook",
|
|
612
|
+
"strategy",
|
|
613
|
+
"reference",
|
|
614
|
+
// Resource kinds
|
|
615
|
+
"agent",
|
|
616
|
+
"workflow",
|
|
617
|
+
"integration",
|
|
618
|
+
"database",
|
|
619
|
+
"user",
|
|
620
|
+
"team",
|
|
621
|
+
// Integration specifics
|
|
622
|
+
"gmail",
|
|
623
|
+
"google-sheets",
|
|
624
|
+
"attio",
|
|
625
|
+
// Surface / UI views
|
|
626
|
+
"overview",
|
|
627
|
+
"command-view",
|
|
628
|
+
"command-queue",
|
|
629
|
+
"pipeline",
|
|
630
|
+
"lists",
|
|
631
|
+
"resources",
|
|
632
|
+
// Actions
|
|
633
|
+
"approve",
|
|
634
|
+
"reject",
|
|
635
|
+
"retry",
|
|
636
|
+
"edit",
|
|
637
|
+
"view",
|
|
638
|
+
"launch",
|
|
639
|
+
"message",
|
|
640
|
+
"escalate",
|
|
641
|
+
"promote",
|
|
642
|
+
"submit",
|
|
643
|
+
"email",
|
|
644
|
+
// Status
|
|
645
|
+
"success",
|
|
646
|
+
"error",
|
|
647
|
+
"warning",
|
|
648
|
+
"info",
|
|
649
|
+
"pending",
|
|
650
|
+
// OM / UI group icons
|
|
651
|
+
"bolt",
|
|
652
|
+
"building",
|
|
653
|
+
"briefcase",
|
|
654
|
+
"apps",
|
|
655
|
+
"graph",
|
|
656
|
+
"shield",
|
|
657
|
+
"users",
|
|
658
|
+
"chart-bar",
|
|
659
|
+
"search"
|
|
254
660
|
];
|
|
255
|
-
var CustomIconTokenSchema = z.string().trim().max(80).regex(
|
|
661
|
+
var CustomIconTokenSchema = z.string().trim().max(80).regex(
|
|
662
|
+
/^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
|
|
663
|
+
'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
|
|
664
|
+
);
|
|
256
665
|
var OrganizationModelBuiltinIconTokenSchema = z.enum(ORGANIZATION_MODEL_ICON_TOKENS);
|
|
257
666
|
var OrganizationModelIconTokenSchema = z.union([
|
|
258
667
|
OrganizationModelBuiltinIconTokenSchema,
|
|
@@ -860,7 +1269,99 @@ var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
|
|
|
860
1269
|
return [parsed.id, parsed];
|
|
861
1270
|
})
|
|
862
1271
|
);
|
|
863
|
-
var
|
|
1272
|
+
var CRM_ACTION_ENTRY_INPUTS = [
|
|
1273
|
+
{
|
|
1274
|
+
id: "send_reply",
|
|
1275
|
+
order: 210,
|
|
1276
|
+
label: "Send Reply",
|
|
1277
|
+
description: "Send a contextual reply for an active CRM deal.",
|
|
1278
|
+
scope: { domain: "sales" },
|
|
1279
|
+
resourceId: "crm-send-reply-workflow",
|
|
1280
|
+
affects: ["crm.deal"]
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
id: "send_link",
|
|
1284
|
+
order: 220,
|
|
1285
|
+
label: "Send Booking Link",
|
|
1286
|
+
description: "Send a booking link to move a deal toward a scheduled call.",
|
|
1287
|
+
scope: { domain: "sales" },
|
|
1288
|
+
resourceId: "crm-send-booking-link-workflow",
|
|
1289
|
+
affects: ["crm.deal"]
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
id: "send_nudge",
|
|
1293
|
+
order: 230,
|
|
1294
|
+
label: "Send Nudge",
|
|
1295
|
+
description: "Send a follow-up nudge for a stalled CRM deal.",
|
|
1296
|
+
scope: { domain: "sales" },
|
|
1297
|
+
resourceId: "crm-send-nudge-workflow",
|
|
1298
|
+
affects: ["crm.deal"]
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
id: "rebook",
|
|
1302
|
+
order: 240,
|
|
1303
|
+
label: "Rebook",
|
|
1304
|
+
description: "Rebook a missed or rescheduled CRM appointment.",
|
|
1305
|
+
scope: { domain: "sales" },
|
|
1306
|
+
resourceId: "crm-rebook-workflow",
|
|
1307
|
+
affects: ["crm.deal"]
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
id: "move_to_proposal",
|
|
1311
|
+
order: 250,
|
|
1312
|
+
label: "Move to Proposal",
|
|
1313
|
+
description: "Advance a qualified CRM deal into the proposal stage.",
|
|
1314
|
+
scope: { domain: "sales" },
|
|
1315
|
+
resourceId: "move_to_proposal-workflow",
|
|
1316
|
+
affects: ["crm.deal"]
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
id: "move_to_closing",
|
|
1320
|
+
order: 260,
|
|
1321
|
+
label: "Move to Closing",
|
|
1322
|
+
description: "Advance a proposal-stage CRM deal into closing.",
|
|
1323
|
+
scope: { domain: "sales" },
|
|
1324
|
+
resourceId: "move_to_closing-workflow",
|
|
1325
|
+
affects: ["crm.deal"]
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
id: "move_to_closed_won",
|
|
1329
|
+
order: 270,
|
|
1330
|
+
label: "Close Won",
|
|
1331
|
+
description: "Mark a CRM deal as closed won.",
|
|
1332
|
+
scope: { domain: "sales" },
|
|
1333
|
+
resourceId: "move_to_closed_won-workflow",
|
|
1334
|
+
affects: ["crm.deal"]
|
|
1335
|
+
},
|
|
1336
|
+
{
|
|
1337
|
+
id: "move_to_closed_lost",
|
|
1338
|
+
order: 280,
|
|
1339
|
+
label: "Close Lost",
|
|
1340
|
+
description: "Mark a CRM deal as closed lost.",
|
|
1341
|
+
scope: { domain: "sales" },
|
|
1342
|
+
resourceId: "move_to_closed_lost-workflow",
|
|
1343
|
+
affects: ["crm.deal"]
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
id: "move_to_nurturing",
|
|
1347
|
+
order: 290,
|
|
1348
|
+
label: "Move to Nurturing",
|
|
1349
|
+
description: "Move a CRM deal into nurturing for future follow-up.",
|
|
1350
|
+
scope: { domain: "sales" },
|
|
1351
|
+
resourceId: "move_to_nurturing-workflow",
|
|
1352
|
+
affects: ["crm.deal"]
|
|
1353
|
+
}
|
|
1354
|
+
];
|
|
1355
|
+
var CRM_ACTION_ENTRIES = Object.fromEntries(
|
|
1356
|
+
CRM_ACTION_ENTRY_INPUTS.map((action) => {
|
|
1357
|
+
const parsed = ActionSchema.parse(action);
|
|
1358
|
+
return [parsed.id, parsed];
|
|
1359
|
+
})
|
|
1360
|
+
);
|
|
1361
|
+
var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
|
|
1362
|
+
...LEAD_GEN_ACTION_ENTRIES,
|
|
1363
|
+
...CRM_ACTION_ENTRIES
|
|
1364
|
+
};
|
|
864
1365
|
function findOrganizationActionById(id, actions = DEFAULT_ORGANIZATION_MODEL_ACTIONS) {
|
|
865
1366
|
return actions[id];
|
|
866
1367
|
}
|
|
@@ -886,6 +1387,17 @@ var SystemUiSchema = z.object({
|
|
|
886
1387
|
icon: IconNameSchema.optional(),
|
|
887
1388
|
order: z.number().int().optional()
|
|
888
1389
|
});
|
|
1390
|
+
var JsonValueSchema = z.lazy(
|
|
1391
|
+
() => z.union([
|
|
1392
|
+
z.string(),
|
|
1393
|
+
z.number(),
|
|
1394
|
+
z.boolean(),
|
|
1395
|
+
z.null(),
|
|
1396
|
+
z.array(JsonValueSchema),
|
|
1397
|
+
z.record(z.string(), JsonValueSchema)
|
|
1398
|
+
])
|
|
1399
|
+
);
|
|
1400
|
+
var SystemConfigSchema = z.record(z.string().trim().min(1).max(200), JsonValueSchema).default({}).optional();
|
|
889
1401
|
var SystemEntrySchema = z.object({
|
|
890
1402
|
/** Stable tenant-defined system id (e.g. "sys.lead-gen" or "sales.crm"). */
|
|
891
1403
|
id: SystemIdSchema,
|
|
@@ -931,11 +1443,21 @@ var SystemEntrySchema = z.object({
|
|
|
931
1443
|
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
932
1444
|
order: z.number(),
|
|
933
1445
|
/**
|
|
934
|
-
* System-
|
|
935
|
-
*
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1446
|
+
* System-local JSON settings and defaults. Strongly typed OM fields,
|
|
1447
|
+
* secrets, credentials, and runtime state stay outside this bucket.
|
|
1448
|
+
*/
|
|
1449
|
+
config: SystemConfigSchema,
|
|
1450
|
+
/**
|
|
1451
|
+
* System-owned ontology declarations. `systems` is now the canonical child
|
|
1452
|
+
* key; this scope holds the object, action, catalog, link, event, and
|
|
1453
|
+
* shared contract records owned by this system.
|
|
1454
|
+
*/
|
|
1455
|
+
ontology: OntologyScopeSchema.optional(),
|
|
1456
|
+
/**
|
|
1457
|
+
* @deprecated Compatibility-only bridge for old tenant content nodes and
|
|
1458
|
+
* migration readers. New schema/catalog authoring belongs in ontology;
|
|
1459
|
+
* new system-local settings belong in config. Bridge nodes are keyed by
|
|
1460
|
+
* local NodeId and may still project to content-node:* graph IDs.
|
|
939
1461
|
*/
|
|
940
1462
|
content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
|
|
941
1463
|
/**
|
|
@@ -945,14 +1467,17 @@ var SystemEntrySchema = z.object({
|
|
|
945
1467
|
* Per Phase 4: `id` and `parentSystemId` fields will be removed in favour of
|
|
946
1468
|
* position-derived paths. Both still exist on this schema for backward compat.
|
|
947
1469
|
*/
|
|
1470
|
+
systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
|
|
1471
|
+
/** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
|
|
948
1472
|
subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
|
|
949
1473
|
}).refine((system) => system.label !== void 0 || system.title !== void 0, {
|
|
950
1474
|
path: ["label"],
|
|
951
1475
|
message: "System must provide label or title"
|
|
952
1476
|
}).transform((system) => {
|
|
953
|
-
|
|
1477
|
+
const normalizedSystem = system.systems !== void 0 && system.subsystems === void 0 ? { ...system, subsystems: system.systems } : system;
|
|
1478
|
+
if (normalizedSystem.status === void 0) return normalizedSystem;
|
|
954
1479
|
console.warn("[organization-model] System.status is deprecated; use System.lifecycle instead.");
|
|
955
|
-
return
|
|
1480
|
+
return normalizedSystem.lifecycle === void 0 ? { ...normalizedSystem, lifecycle: normalizedSystem.status } : normalizedSystem;
|
|
956
1481
|
});
|
|
957
1482
|
var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
958
1483
|
message: "Each system entry id must match its map key"
|
|
@@ -964,6 +1489,7 @@ var ResourceKindSchema = z.enum(["workflow", "agent", "integration", "script"]).
|
|
|
964
1489
|
var ResourceGovernanceStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
|
|
965
1490
|
var AgentKindSchema = z.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
|
|
966
1491
|
var ScriptResourceLanguageSchema = z.enum(["shell", "sql", "typescript", "python"]).meta({ label: "Language" });
|
|
1492
|
+
var CodeReferenceRoleSchema = z.enum(["entrypoint", "handler", "schema", "test", "docs", "config"]).meta({ label: "Code reference role", color: "blue" });
|
|
967
1493
|
var ResourceIdSchema = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
|
|
968
1494
|
var EventIdSchema = z.string().trim().min(1).max(300).regex(
|
|
969
1495
|
/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*:[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
|
|
@@ -981,6 +1507,19 @@ var EventDescriptorSchema = EventEmissionDescriptorSchema.extend({
|
|
|
981
1507
|
ownerId: z.union([ResourceIdSchema, ModelIdSchema]),
|
|
982
1508
|
ownerKind: z.enum(["resource", "entity"]).meta({ label: "Owner kind" })
|
|
983
1509
|
});
|
|
1510
|
+
var ResourceOntologyBindingSchema = z.object({
|
|
1511
|
+
implements: z.array(OntologyIdSchema).optional(),
|
|
1512
|
+
reads: z.array(OntologyIdSchema).optional(),
|
|
1513
|
+
writes: z.array(OntologyIdSchema).optional(),
|
|
1514
|
+
usesCatalogs: z.array(OntologyIdSchema).optional(),
|
|
1515
|
+
emits: z.array(OntologyIdSchema).optional()
|
|
1516
|
+
});
|
|
1517
|
+
var CodeReferenceSchema = z.object({
|
|
1518
|
+
path: z.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
|
|
1519
|
+
role: CodeReferenceRoleSchema,
|
|
1520
|
+
symbol: z.string().trim().min(1).max(200).optional(),
|
|
1521
|
+
description: z.string().trim().min(1).max(300).optional()
|
|
1522
|
+
});
|
|
984
1523
|
var ResourceEntryBaseSchema = z.object({
|
|
985
1524
|
/** Canonical resource id; runtime resourceId derives from this value. */
|
|
986
1525
|
id: ResourceIdSchema,
|
|
@@ -990,7 +1529,15 @@ var ResourceEntryBaseSchema = z.object({
|
|
|
990
1529
|
systemPath: SystemPathSchema.meta({ ref: "system" }),
|
|
991
1530
|
/** Optional role responsible for maintaining this resource. */
|
|
992
1531
|
ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
|
|
993
|
-
status: ResourceGovernanceStatusSchema
|
|
1532
|
+
status: ResourceGovernanceStatusSchema,
|
|
1533
|
+
/**
|
|
1534
|
+
* Ontology contract bindings for the semantic work this resource performs.
|
|
1535
|
+
* `emits` stays nested here so top-level resource emits descriptors remain
|
|
1536
|
+
* compatible with graph event projection during the bridge.
|
|
1537
|
+
*/
|
|
1538
|
+
ontology: ResourceOntologyBindingSchema.optional(),
|
|
1539
|
+
/** Repo-relative implementation breadcrumbs for agents and operators. */
|
|
1540
|
+
codeRefs: z.array(CodeReferenceSchema).default([])
|
|
994
1541
|
});
|
|
995
1542
|
var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
996
1543
|
kind: z.literal("workflow"),
|
|
@@ -1155,19 +1702,29 @@ var KnowledgeTargetKindSchema = z.enum([
|
|
|
1155
1702
|
"goal",
|
|
1156
1703
|
"customer-segment",
|
|
1157
1704
|
"offering",
|
|
1705
|
+
"ontology",
|
|
1158
1706
|
// D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
|
|
1159
1707
|
"content-node"
|
|
1160
1708
|
]).meta({ label: "Target kind" });
|
|
1161
1709
|
var KnowledgeTargetRefSchema = z.object({
|
|
1162
1710
|
kind: KnowledgeTargetKindSchema,
|
|
1163
|
-
// D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'
|
|
1164
|
-
//
|
|
1165
|
-
//
|
|
1166
|
-
// OrganizationModelSchema.superRefine (knowledgeTargetExists).
|
|
1711
|
+
// D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
|
|
1712
|
+
// Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
|
|
1713
|
+
// Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
|
|
1167
1714
|
id: z.string().trim().min(1).max(300)
|
|
1715
|
+
}).superRefine((target, ctx) => {
|
|
1716
|
+
if (target.kind !== "ontology") return;
|
|
1717
|
+
const result = OntologyIdSchema.safeParse(target.id);
|
|
1718
|
+
if (!result.success) {
|
|
1719
|
+
ctx.addIssue({
|
|
1720
|
+
code: z.ZodIssueCode.custom,
|
|
1721
|
+
path: ["id"],
|
|
1722
|
+
message: "Ontology knowledge targets must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1168
1725
|
});
|
|
1169
1726
|
var LegacyKnowledgeLinkSchema = z.object({
|
|
1170
|
-
nodeId: NodeIdStringSchema
|
|
1727
|
+
nodeId: z.union([NodeIdStringSchema, z.templateLiteral(["ontology:", OntologyIdSchema])])
|
|
1171
1728
|
});
|
|
1172
1729
|
var CanonicalKnowledgeLinkSchema = z.object({
|
|
1173
1730
|
target: KnowledgeTargetRefSchema
|
|
@@ -1198,6 +1755,8 @@ var OrgKnowledgeNodeSchema = z.object({
|
|
|
1198
1755
|
icon: IconNameSchema.optional(),
|
|
1199
1756
|
/** Canonical documentation URL when body content is a local summary. */
|
|
1200
1757
|
externalUrl: z.string().trim().url().max(500).optional(),
|
|
1758
|
+
/** Optional generated source file path for local MDX-backed knowledge nodes. */
|
|
1759
|
+
sourceFilePath: z.string().trim().min(1).max(500).optional(),
|
|
1201
1760
|
/** Raw MDX string. Phase 2 will introduce a structured block format. */
|
|
1202
1761
|
body: z.string().trim().min(1),
|
|
1203
1762
|
/**
|
|
@@ -1298,6 +1857,7 @@ var OrganizationModelDomainKeySchema = z.enum([
|
|
|
1298
1857
|
"roles",
|
|
1299
1858
|
"goals",
|
|
1300
1859
|
"systems",
|
|
1860
|
+
"ontology",
|
|
1301
1861
|
"resources",
|
|
1302
1862
|
"actions",
|
|
1303
1863
|
"entities",
|
|
@@ -1316,6 +1876,7 @@ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
|
|
|
1316
1876
|
roles: { version: 1, lastModified: "2026-05-10" },
|
|
1317
1877
|
goals: { version: 1, lastModified: "2026-05-10" },
|
|
1318
1878
|
systems: { version: 1, lastModified: "2026-05-10" },
|
|
1879
|
+
ontology: { version: 1, lastModified: "2026-05-14" },
|
|
1319
1880
|
resources: { version: 1, lastModified: "2026-05-10" },
|
|
1320
1881
|
actions: { version: 1, lastModified: "2026-05-10" },
|
|
1321
1882
|
entities: { version: 1, lastModified: "2026-05-10" },
|
|
@@ -1330,6 +1891,7 @@ var OrganizationModelDomainMetadataByDomainSchema = z.object({
|
|
|
1330
1891
|
roles: OrganizationModelDomainMetadataSchema,
|
|
1331
1892
|
goals: OrganizationModelDomainMetadataSchema,
|
|
1332
1893
|
systems: OrganizationModelDomainMetadataSchema,
|
|
1894
|
+
ontology: OrganizationModelDomainMetadataSchema,
|
|
1333
1895
|
resources: OrganizationModelDomainMetadataSchema,
|
|
1334
1896
|
actions: OrganizationModelDomainMetadataSchema,
|
|
1335
1897
|
entities: OrganizationModelDomainMetadataSchema,
|
|
@@ -1347,6 +1909,7 @@ var OrganizationModelSchemaBase = z.object({
|
|
|
1347
1909
|
roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
|
|
1348
1910
|
goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
|
|
1349
1911
|
systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
|
|
1912
|
+
ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
|
|
1350
1913
|
resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
|
|
1351
1914
|
actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
|
|
1352
1915
|
entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
|
|
@@ -1374,13 +1937,16 @@ function asRoleHolderArray(heldBy) {
|
|
|
1374
1937
|
function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
|
|
1375
1938
|
if (knowledgeKind === "reference") return true;
|
|
1376
1939
|
if (knowledgeKind === "playbook") {
|
|
1377
|
-
return ["system", "resource", "stage", "action"].includes(targetKind);
|
|
1940
|
+
return ["system", "resource", "stage", "action", "ontology"].includes(targetKind);
|
|
1378
1941
|
}
|
|
1379
1942
|
if (knowledgeKind === "strategy") {
|
|
1380
|
-
return ["system", "goal", "offering", "customer-segment"].includes(targetKind);
|
|
1943
|
+
return ["system", "goal", "offering", "customer-segment", "ontology"].includes(targetKind);
|
|
1381
1944
|
}
|
|
1382
1945
|
return false;
|
|
1383
1946
|
}
|
|
1947
|
+
function isRecord(value) {
|
|
1948
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1949
|
+
}
|
|
1384
1950
|
var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
|
|
1385
1951
|
function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
|
|
1386
1952
|
const result = [];
|
|
@@ -1388,8 +1954,11 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1388
1954
|
const path = prefix ? `${prefix}.${key}` : key;
|
|
1389
1955
|
const currentSchemaPath = [...schemaPath, key];
|
|
1390
1956
|
result.push({ path, schemaPath: currentSchemaPath, system });
|
|
1391
|
-
|
|
1392
|
-
|
|
1957
|
+
const childSystems = system.systems ?? system.subsystems;
|
|
1958
|
+
if (childSystems !== void 0) {
|
|
1959
|
+
result.push(
|
|
1960
|
+
...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
|
|
1961
|
+
);
|
|
1393
1962
|
}
|
|
1394
1963
|
}
|
|
1395
1964
|
return result;
|
|
@@ -1409,7 +1978,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1409
1978
|
`System "${system.id}" references unknown parent "${system.parentSystemId}"`
|
|
1410
1979
|
);
|
|
1411
1980
|
}
|
|
1412
|
-
const hasChildren = Object.keys(system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
|
|
1981
|
+
const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
|
|
1413
1982
|
const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
|
|
1414
1983
|
if (contributesRoutePath) {
|
|
1415
1984
|
const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
|
|
@@ -1425,7 +1994,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1425
1994
|
}
|
|
1426
1995
|
}
|
|
1427
1996
|
if (hasChildren && isLifecycleEnabled(system.lifecycle, system.enabled)) {
|
|
1428
|
-
const hasEnabledDescendant = Object.values(system.subsystems ?? {}).some(
|
|
1997
|
+
const hasEnabledDescendant = Object.values(system.systems ?? system.subsystems ?? {}).some(
|
|
1429
1998
|
(candidate) => isLifecycleEnabled(candidate.lifecycle, candidate.enabled)
|
|
1430
1999
|
) || allSystems.some(
|
|
1431
2000
|
(candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
|
|
@@ -1670,6 +2239,60 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1670
2239
|
const stageIds = /* @__PURE__ */ new Set();
|
|
1671
2240
|
const actionIds = new Set(Object.keys(model.actions));
|
|
1672
2241
|
const offeringsById = new Map(Object.entries(model.offerings));
|
|
2242
|
+
const ontologyCompilation = compileOrganizationOntology(model);
|
|
2243
|
+
const ontologyIndexByKind = {
|
|
2244
|
+
object: ontologyCompilation.ontology.objectTypes,
|
|
2245
|
+
link: ontologyCompilation.ontology.linkTypes,
|
|
2246
|
+
action: ontologyCompilation.ontology.actionTypes,
|
|
2247
|
+
catalog: ontologyCompilation.ontology.catalogTypes,
|
|
2248
|
+
event: ontologyCompilation.ontology.eventTypes,
|
|
2249
|
+
interface: ontologyCompilation.ontology.interfaceTypes,
|
|
2250
|
+
"value-type": ontologyCompilation.ontology.valueTypes,
|
|
2251
|
+
property: ontologyCompilation.ontology.sharedProperties,
|
|
2252
|
+
group: ontologyCompilation.ontology.groups,
|
|
2253
|
+
surface: ontologyCompilation.ontology.surfaces
|
|
2254
|
+
};
|
|
2255
|
+
const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
|
|
2256
|
+
const ontologyReferenceKeyKinds = {
|
|
2257
|
+
valueType: "value-type",
|
|
2258
|
+
catalogType: "catalog",
|
|
2259
|
+
objectType: "object",
|
|
2260
|
+
eventType: "event",
|
|
2261
|
+
actionType: "action",
|
|
2262
|
+
linkType: "link",
|
|
2263
|
+
interfaceType: "interface",
|
|
2264
|
+
propertyType: "property",
|
|
2265
|
+
groupType: "group",
|
|
2266
|
+
surfaceType: "surface",
|
|
2267
|
+
stepCatalog: "catalog"
|
|
2268
|
+
};
|
|
2269
|
+
function validateKnownOntologyReferences(ownerId, value, path, seen = /* @__PURE__ */ new WeakSet()) {
|
|
2270
|
+
if (Array.isArray(value)) {
|
|
2271
|
+
value.forEach((entry, index) => validateKnownOntologyReferences(ownerId, entry, [...path, index], seen));
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2274
|
+
if (!isRecord(value)) return;
|
|
2275
|
+
if (seen.has(value)) return;
|
|
2276
|
+
seen.add(value);
|
|
2277
|
+
Object.entries(value).forEach(([key, entry]) => {
|
|
2278
|
+
const expectedKind = ontologyReferenceKeyKinds[key];
|
|
2279
|
+
if (expectedKind !== void 0) {
|
|
2280
|
+
if (typeof entry !== "string") {
|
|
2281
|
+
addIssue(ctx, [...path, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
|
|
2282
|
+
} else if (ontologyIndexByKind[expectedKind][entry] === void 0) {
|
|
2283
|
+
addIssue(
|
|
2284
|
+
ctx,
|
|
2285
|
+
[...path, key],
|
|
2286
|
+
`Ontology record "${ownerId}" ${key} references unknown ${expectedKind} ontology ID "${entry}"`
|
|
2287
|
+
);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
validateKnownOntologyReferences(ownerId, entry, [...path, key], seen);
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
for (const { id, record } of listResolvedOntologyRecords(ontologyCompilation.ontology)) {
|
|
2294
|
+
validateKnownOntologyReferences(id, record, record.origin.path);
|
|
2295
|
+
}
|
|
1673
2296
|
Object.values(model.policies).forEach((policy) => {
|
|
1674
2297
|
policy.appliesTo.systemIds.forEach((systemId, systemIndex) => {
|
|
1675
2298
|
if (!systemsById.has(systemId)) {
|
|
@@ -1723,6 +2346,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1723
2346
|
if (kind === "goal") return goalsById.has(id);
|
|
1724
2347
|
if (kind === "customer-segment") return segmentsById.has(id);
|
|
1725
2348
|
if (kind === "offering") return offeringsById.has(id);
|
|
2349
|
+
if (kind === "ontology") return ontologyIds.has(id);
|
|
1726
2350
|
return false;
|
|
1727
2351
|
}
|
|
1728
2352
|
Object.entries(model.knowledge).forEach(([nodeId, node]) => {
|
|
@@ -1766,6 +2390,26 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1766
2390
|
);
|
|
1767
2391
|
}
|
|
1768
2392
|
});
|
|
2393
|
+
function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
|
|
2394
|
+
ids?.forEach((ontologyId, ontologyIndex) => {
|
|
2395
|
+
if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
|
|
2396
|
+
addIssue(
|
|
2397
|
+
ctx,
|
|
2398
|
+
["resources", resourceId, "ontology", bindingKey, ontologyIndex],
|
|
2399
|
+
`Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
Object.values(model.resources).forEach((resource) => {
|
|
2405
|
+
const binding = resource.ontology;
|
|
2406
|
+
if (binding === void 0) return;
|
|
2407
|
+
validateResourceOntologyBinding(resource.id, "implements", "action", binding.implements);
|
|
2408
|
+
validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
|
|
2409
|
+
validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
|
|
2410
|
+
validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
|
|
2411
|
+
validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
|
|
2412
|
+
});
|
|
1769
2413
|
Object.values(model.roles).forEach((role) => {
|
|
1770
2414
|
if (role.heldBy === void 0) return;
|
|
1771
2415
|
asRoleHolderArray(role.heldBy).forEach((holder, holderIndex) => {
|
|
@@ -1800,11 +2444,13 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1800
2444
|
});
|
|
1801
2445
|
});
|
|
1802
2446
|
function validateSystemContent(system, systemPath) {
|
|
2447
|
+
const childSystems = system.systems ?? system.subsystems;
|
|
2448
|
+
const childKey = system.systems !== void 0 ? "systems" : "subsystems";
|
|
1803
2449
|
const content = system.content;
|
|
1804
2450
|
if (content === void 0 || Object.keys(content).length === 0) {
|
|
1805
|
-
if (
|
|
1806
|
-
Object.entries(
|
|
1807
|
-
validateSystemContent(child, [...systemPath,
|
|
2451
|
+
if (childSystems !== void 0) {
|
|
2452
|
+
Object.entries(childSystems).forEach(([childLocalId, child]) => {
|
|
2453
|
+
validateSystemContent(child, [...systemPath, childKey, childLocalId]);
|
|
1808
2454
|
});
|
|
1809
2455
|
}
|
|
1810
2456
|
return;
|
|
@@ -1860,15 +2506,18 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
1860
2506
|
}
|
|
1861
2507
|
}
|
|
1862
2508
|
});
|
|
1863
|
-
if (
|
|
1864
|
-
Object.entries(
|
|
1865
|
-
validateSystemContent(child, [...systemPath,
|
|
2509
|
+
if (childSystems !== void 0) {
|
|
2510
|
+
Object.entries(childSystems).forEach(([childLocalId, child]) => {
|
|
2511
|
+
validateSystemContent(child, [...systemPath, childKey, childLocalId]);
|
|
1866
2512
|
});
|
|
1867
2513
|
}
|
|
1868
2514
|
}
|
|
1869
2515
|
Object.entries(model.systems).forEach(([systemKey, system]) => {
|
|
1870
2516
|
validateSystemContent(system, ["systems", systemKey]);
|
|
1871
2517
|
});
|
|
2518
|
+
for (const diagnostic of ontologyCompilation.diagnostics) {
|
|
2519
|
+
addIssue(ctx, diagnostic.path, diagnostic.message);
|
|
2520
|
+
}
|
|
1872
2521
|
});
|
|
1873
2522
|
var OrganizationGraphNodeKindSchema = z.enum([
|
|
1874
2523
|
"organization",
|
|
@@ -1887,6 +2536,7 @@ var OrganizationGraphNodeKindSchema = z.enum([
|
|
|
1887
2536
|
"surface",
|
|
1888
2537
|
"navigation-group",
|
|
1889
2538
|
// Phase 3 preview — Phase 4 populates via graph projection of system.content entries.
|
|
2539
|
+
"ontology",
|
|
1890
2540
|
"content-node"
|
|
1891
2541
|
]);
|
|
1892
2542
|
var OrganizationGraphEdgeKindSchema = z.enum([
|
|
@@ -1901,23 +2551,28 @@ var OrganizationGraphEdgeKindSchema = z.enum([
|
|
|
1901
2551
|
"originates_from",
|
|
1902
2552
|
"triggers",
|
|
1903
2553
|
"applies_to",
|
|
1904
|
-
"effects"
|
|
2554
|
+
"effects",
|
|
2555
|
+
"implements",
|
|
2556
|
+
"reads",
|
|
2557
|
+
"writes",
|
|
2558
|
+
"uses_catalog"
|
|
1905
2559
|
]);
|
|
1906
2560
|
var OrganizationGraphNodeSchema = z.object({
|
|
1907
|
-
id: z.string().trim().min(1).max(
|
|
2561
|
+
id: z.string().trim().min(1).max(400),
|
|
1908
2562
|
kind: OrganizationGraphNodeKindSchema,
|
|
1909
2563
|
label: LabelSchema,
|
|
1910
|
-
sourceId: z.string().trim().min(1).max(
|
|
2564
|
+
sourceId: z.string().trim().min(1).max(400).optional(),
|
|
1911
2565
|
description: DescriptionSchema.optional(),
|
|
1912
2566
|
icon: IconNameSchema.optional(),
|
|
1913
2567
|
enabled: z.boolean().optional(),
|
|
2568
|
+
ontologyKind: z.string().trim().min(1).max(80).optional(),
|
|
1914
2569
|
resourceType: z.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint", "script"]).optional()
|
|
1915
2570
|
});
|
|
1916
2571
|
var OrganizationGraphEdgeSchema = z.object({
|
|
1917
|
-
id: z.string().trim().min(1).max(
|
|
2572
|
+
id: z.string().trim().min(1).max(900),
|
|
1918
2573
|
kind: OrganizationGraphEdgeKindSchema,
|
|
1919
|
-
sourceId: z.string().trim().min(1).max(
|
|
1920
|
-
targetId: z.string().trim().min(1).max(
|
|
2574
|
+
sourceId: z.string().trim().min(1).max(400),
|
|
2575
|
+
targetId: z.string().trim().min(1).max(400),
|
|
1921
2576
|
label: z.string().trim().min(1).max(120).optional(),
|
|
1922
2577
|
relationshipType: z.enum(["triggers", "uses", "approval"]).optional()
|
|
1923
2578
|
});
|
|
@@ -1973,14 +2628,14 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
1973
2628
|
label: "Dashboard",
|
|
1974
2629
|
path: "/",
|
|
1975
2630
|
surfaceType: "dashboard",
|
|
1976
|
-
icon: "
|
|
2631
|
+
icon: "dashboard",
|
|
1977
2632
|
order: 10,
|
|
1978
2633
|
targets: { systems: ["dashboard"] }
|
|
1979
2634
|
},
|
|
1980
2635
|
business: {
|
|
1981
2636
|
type: "group",
|
|
1982
2637
|
label: "Business",
|
|
1983
|
-
icon: "
|
|
2638
|
+
icon: "business",
|
|
1984
2639
|
order: 20,
|
|
1985
2640
|
children: {
|
|
1986
2641
|
sales: {
|
|
@@ -1988,7 +2643,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
1988
2643
|
label: "Sales",
|
|
1989
2644
|
path: "/sales",
|
|
1990
2645
|
surfaceType: "page",
|
|
1991
|
-
icon: "
|
|
2646
|
+
icon: "sales",
|
|
1992
2647
|
order: 10,
|
|
1993
2648
|
targets: { systems: ["sales"] }
|
|
1994
2649
|
},
|
|
@@ -1997,7 +2652,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
1997
2652
|
label: "Clients",
|
|
1998
2653
|
path: "/clients",
|
|
1999
2654
|
surfaceType: "list",
|
|
2000
|
-
icon: "
|
|
2655
|
+
icon: "projects",
|
|
2001
2656
|
order: 20,
|
|
2002
2657
|
targets: { systems: ["clients"] }
|
|
2003
2658
|
},
|
|
@@ -2006,7 +2661,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
2006
2661
|
label: "Projects",
|
|
2007
2662
|
path: "/projects",
|
|
2008
2663
|
surfaceType: "page",
|
|
2009
|
-
icon: "
|
|
2664
|
+
icon: "projects",
|
|
2010
2665
|
order: 30,
|
|
2011
2666
|
targets: { systems: ["projects"] }
|
|
2012
2667
|
}
|
|
@@ -2015,7 +2670,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
2015
2670
|
operations: {
|
|
2016
2671
|
type: "group",
|
|
2017
2672
|
label: "Operations",
|
|
2018
|
-
icon: "
|
|
2673
|
+
icon: "operations",
|
|
2019
2674
|
order: 30,
|
|
2020
2675
|
children: {
|
|
2021
2676
|
"operations-overview": {
|
|
@@ -2063,7 +2718,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
2063
2718
|
monitoring: {
|
|
2064
2719
|
type: "group",
|
|
2065
2720
|
label: "Monitoring",
|
|
2066
|
-
icon: "
|
|
2721
|
+
icon: "monitoring",
|
|
2067
2722
|
order: 40,
|
|
2068
2723
|
children: {
|
|
2069
2724
|
"monitoring-overview": {
|
|
@@ -2125,36 +2780,19 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
2125
2780
|
}
|
|
2126
2781
|
},
|
|
2127
2782
|
knowledge: {
|
|
2128
|
-
type: "
|
|
2129
|
-
label: "Knowledge",
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
type: "surface",
|
|
2135
|
-
label: "Knowledge Base",
|
|
2136
|
-
path: "/knowledge",
|
|
2137
|
-
surfaceType: "page",
|
|
2138
|
-
order: 10,
|
|
2139
|
-
targets: { systems: ["knowledge.base"] }
|
|
2140
|
-
},
|
|
2141
|
-
"knowledge-command-view": {
|
|
2142
|
-
type: "surface",
|
|
2143
|
-
label: "Command View",
|
|
2144
|
-
path: "/knowledge/command-view",
|
|
2145
|
-
surfaceType: "graph",
|
|
2146
|
-
order: 20,
|
|
2147
|
-
targets: { systems: ["knowledge.command-view"] },
|
|
2148
|
-
devOnly: true
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2783
|
+
type: "surface",
|
|
2784
|
+
label: "Knowledge Base",
|
|
2785
|
+
path: "/knowledge",
|
|
2786
|
+
surfaceType: "page",
|
|
2787
|
+
icon: "knowledge",
|
|
2788
|
+
order: 50
|
|
2151
2789
|
}
|
|
2152
2790
|
},
|
|
2153
2791
|
bottom: {
|
|
2154
2792
|
settings: {
|
|
2155
2793
|
type: "group",
|
|
2156
2794
|
label: "Settings",
|
|
2157
|
-
icon: "
|
|
2795
|
+
icon: "settings",
|
|
2158
2796
|
order: 10,
|
|
2159
2797
|
children: {
|
|
2160
2798
|
"settings-account": {
|
|
@@ -2226,7 +2864,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION2 = {
|
|
|
2226
2864
|
admin: {
|
|
2227
2865
|
type: "group",
|
|
2228
2866
|
label: "Admin",
|
|
2229
|
-
icon: "
|
|
2867
|
+
icon: "admin",
|
|
2230
2868
|
order: 20,
|
|
2231
2869
|
children: {
|
|
2232
2870
|
"admin-dashboard": {
|
|
@@ -2306,7 +2944,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2306
2944
|
enabled: true,
|
|
2307
2945
|
lifecycle: "active",
|
|
2308
2946
|
path: "/",
|
|
2309
|
-
icon: "
|
|
2947
|
+
icon: "dashboard"
|
|
2310
2948
|
},
|
|
2311
2949
|
platform: {
|
|
2312
2950
|
id: "platform",
|
|
@@ -2316,7 +2954,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2316
2954
|
enabled: true,
|
|
2317
2955
|
lifecycle: "active",
|
|
2318
2956
|
color: "cyan",
|
|
2319
|
-
icon: "
|
|
2957
|
+
icon: "platform"
|
|
2320
2958
|
},
|
|
2321
2959
|
finance: {
|
|
2322
2960
|
id: "finance",
|
|
@@ -2326,7 +2964,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2326
2964
|
enabled: true,
|
|
2327
2965
|
lifecycle: "active",
|
|
2328
2966
|
color: "green",
|
|
2329
|
-
icon: "
|
|
2967
|
+
icon: "finance"
|
|
2330
2968
|
},
|
|
2331
2969
|
sales: {
|
|
2332
2970
|
id: "sales",
|
|
@@ -2336,7 +2974,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2336
2974
|
enabled: true,
|
|
2337
2975
|
lifecycle: "active",
|
|
2338
2976
|
color: "blue",
|
|
2339
|
-
icon: "
|
|
2977
|
+
icon: "sales",
|
|
2340
2978
|
path: "/sales"
|
|
2341
2979
|
},
|
|
2342
2980
|
"sales.crm": {
|
|
@@ -2346,8 +2984,12 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2346
2984
|
description: "Relationship pipeline and deal management",
|
|
2347
2985
|
enabled: true,
|
|
2348
2986
|
lifecycle: "active",
|
|
2987
|
+
actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
|
|
2988
|
+
actionId: action.id,
|
|
2989
|
+
intent: "exposes"
|
|
2990
|
+
})),
|
|
2349
2991
|
color: "blue",
|
|
2350
|
-
icon: "
|
|
2992
|
+
icon: "crm",
|
|
2351
2993
|
path: "/crm"
|
|
2352
2994
|
},
|
|
2353
2995
|
"sales.lead-gen": {
|
|
@@ -2357,12 +2999,12 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2357
2999
|
description: "Prospecting, qualification, and outreach preparation",
|
|
2358
3000
|
enabled: true,
|
|
2359
3001
|
lifecycle: "active",
|
|
2360
|
-
actions: Object.values(
|
|
3002
|
+
actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
|
|
2361
3003
|
actionId: action.id,
|
|
2362
3004
|
intent: "exposes"
|
|
2363
3005
|
})),
|
|
2364
3006
|
color: "cyan",
|
|
2365
|
-
icon: "
|
|
3007
|
+
icon: "lead-gen",
|
|
2366
3008
|
path: "/lead-gen"
|
|
2367
3009
|
},
|
|
2368
3010
|
projects: {
|
|
@@ -2373,7 +3015,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2373
3015
|
enabled: true,
|
|
2374
3016
|
lifecycle: "active",
|
|
2375
3017
|
color: "orange",
|
|
2376
|
-
icon: "
|
|
3018
|
+
icon: "projects",
|
|
2377
3019
|
path: "/projects"
|
|
2378
3020
|
},
|
|
2379
3021
|
clients: {
|
|
@@ -2384,7 +3026,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2384
3026
|
enabled: true,
|
|
2385
3027
|
lifecycle: "active",
|
|
2386
3028
|
color: "orange",
|
|
2387
|
-
icon: "
|
|
3029
|
+
icon: "projects",
|
|
2388
3030
|
path: "/clients"
|
|
2389
3031
|
},
|
|
2390
3032
|
operations: {
|
|
@@ -2395,7 +3037,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2395
3037
|
enabled: true,
|
|
2396
3038
|
lifecycle: "active",
|
|
2397
3039
|
color: "violet",
|
|
2398
|
-
icon: "
|
|
3040
|
+
icon: "operations"
|
|
2399
3041
|
},
|
|
2400
3042
|
"knowledge.command-view": {
|
|
2401
3043
|
id: "knowledge.command-view",
|
|
@@ -2461,7 +3103,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2461
3103
|
enabled: true,
|
|
2462
3104
|
lifecycle: "active",
|
|
2463
3105
|
path: "/monitoring/calendar",
|
|
2464
|
-
icon: "
|
|
3106
|
+
icon: "calendar"
|
|
2465
3107
|
},
|
|
2466
3108
|
"monitoring.activity-log": {
|
|
2467
3109
|
id: "monitoring.activity-log",
|
|
@@ -2517,7 +3159,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2517
3159
|
label: "Settings",
|
|
2518
3160
|
enabled: true,
|
|
2519
3161
|
lifecycle: "active",
|
|
2520
|
-
icon: "
|
|
3162
|
+
icon: "settings"
|
|
2521
3163
|
},
|
|
2522
3164
|
"settings.account": {
|
|
2523
3165
|
id: "settings.account",
|
|
@@ -2590,7 +3232,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2590
3232
|
enabled: true,
|
|
2591
3233
|
lifecycle: "active",
|
|
2592
3234
|
path: "/admin",
|
|
2593
|
-
icon: "
|
|
3235
|
+
icon: "admin",
|
|
2594
3236
|
requiresAdmin: true
|
|
2595
3237
|
},
|
|
2596
3238
|
"admin.system-health": {
|
|
@@ -2640,7 +3282,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2640
3282
|
enabled: true,
|
|
2641
3283
|
lifecycle: "active",
|
|
2642
3284
|
path: "/archive",
|
|
2643
|
-
icon: "
|
|
3285
|
+
icon: "archive",
|
|
2644
3286
|
devOnly: true
|
|
2645
3287
|
},
|
|
2646
3288
|
"archive.agent-chat": {
|
|
@@ -2675,7 +3317,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2675
3317
|
enabled: true,
|
|
2676
3318
|
lifecycle: "active",
|
|
2677
3319
|
color: "teal",
|
|
2678
|
-
icon: "
|
|
3320
|
+
icon: "knowledge"
|
|
2679
3321
|
},
|
|
2680
3322
|
"knowledge.base": {
|
|
2681
3323
|
id: "knowledge.base",
|
|
@@ -2686,11 +3328,13 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
2686
3328
|
path: "/knowledge"
|
|
2687
3329
|
}
|
|
2688
3330
|
},
|
|
3331
|
+
ontology: DEFAULT_ONTOLOGY_SCOPE,
|
|
2689
3332
|
resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
|
|
2690
3333
|
actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
|
|
2691
3334
|
entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
|
|
2692
3335
|
policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
|
|
2693
|
-
// Phase 4 (D1): statuses top-level field removed; status
|
|
3336
|
+
// Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
|
|
3337
|
+
// still project from System.content, but primary authoring belongs in ontology.
|
|
2694
3338
|
knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
|
|
2695
3339
|
};
|
|
2696
3340
|
var StatusSemanticClassSchema = z.enum([
|
|
@@ -3091,25 +3735,89 @@ var LEAD_GEN_STAGE_CATALOG = {
|
|
|
3091
3735
|
};
|
|
3092
3736
|
|
|
3093
3737
|
// src/organization-model/helpers.ts
|
|
3738
|
+
function childSystemsOf2(system) {
|
|
3739
|
+
return system.systems ?? system.subsystems ?? {};
|
|
3740
|
+
}
|
|
3741
|
+
function getSystem(model, path) {
|
|
3742
|
+
const segments = path.split(".");
|
|
3743
|
+
let current = model.systems;
|
|
3744
|
+
let node;
|
|
3745
|
+
for (const seg of segments) {
|
|
3746
|
+
node = current[seg];
|
|
3747
|
+
if (node === void 0) return void 0;
|
|
3748
|
+
current = childSystemsOf2(node);
|
|
3749
|
+
}
|
|
3750
|
+
return node;
|
|
3751
|
+
}
|
|
3094
3752
|
function listAllSystems(model) {
|
|
3095
3753
|
const results = [];
|
|
3096
3754
|
function walk(map, prefix) {
|
|
3097
3755
|
for (const [localId, system] of Object.entries(map)) {
|
|
3098
3756
|
const fullPath = prefix ? `${prefix}.${localId}` : localId;
|
|
3099
3757
|
results.push({ path: fullPath, system });
|
|
3100
|
-
|
|
3101
|
-
|
|
3758
|
+
const childSystems = childSystemsOf2(system);
|
|
3759
|
+
if (Object.keys(childSystems).length > 0) {
|
|
3760
|
+
walk(childSystems, fullPath);
|
|
3102
3761
|
}
|
|
3103
3762
|
}
|
|
3104
3763
|
}
|
|
3105
3764
|
walk(model.systems, "");
|
|
3106
3765
|
return results;
|
|
3107
3766
|
}
|
|
3767
|
+
function isPlainJsonObject(value) {
|
|
3768
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3769
|
+
}
|
|
3770
|
+
function mergeJsonConfig(base, override) {
|
|
3771
|
+
const result = { ...base };
|
|
3772
|
+
for (const [key, value] of Object.entries(override)) {
|
|
3773
|
+
const existing = result[key];
|
|
3774
|
+
result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
|
|
3775
|
+
}
|
|
3776
|
+
return result;
|
|
3777
|
+
}
|
|
3778
|
+
function resolveSystemConfig(model, path) {
|
|
3779
|
+
const system = getSystem(model, path);
|
|
3780
|
+
if (system === void 0) return {};
|
|
3781
|
+
let resolved = {};
|
|
3782
|
+
for (const node of Object.values(system.content ?? {})) {
|
|
3783
|
+
if (node.kind !== "config" || node.type !== "kv") continue;
|
|
3784
|
+
const entries = node.data?.entries;
|
|
3785
|
+
if (isPlainJsonObject(entries)) {
|
|
3786
|
+
resolved = mergeJsonConfig(resolved, entries);
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
return mergeJsonConfig(resolved, system.config ?? {});
|
|
3790
|
+
}
|
|
3108
3791
|
|
|
3109
3792
|
// src/organization-model/resolve.ts
|
|
3110
3793
|
function isPlainObject(value) {
|
|
3111
3794
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3112
3795
|
}
|
|
3796
|
+
function collectNestedSystemPaths(systems, prefix = "") {
|
|
3797
|
+
const paths = /* @__PURE__ */ new Set();
|
|
3798
|
+
for (const [key, value] of Object.entries(systems)) {
|
|
3799
|
+
if (!isPlainObject(value)) continue;
|
|
3800
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
3801
|
+
for (const childKey of ["systems", "subsystems"]) {
|
|
3802
|
+
const childSystems = value[childKey];
|
|
3803
|
+
if (!isPlainObject(childSystems)) continue;
|
|
3804
|
+
for (const childPath of collectNestedSystemPaths(childSystems, path)) {
|
|
3805
|
+
paths.add(childPath);
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
if (prefix !== "") {
|
|
3809
|
+
paths.add(path);
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
return paths;
|
|
3813
|
+
}
|
|
3814
|
+
function pruneFlatSystemDescendantCollisions(base, override) {
|
|
3815
|
+
const result = { ...base };
|
|
3816
|
+
for (const nestedPath of collectNestedSystemPaths(override)) {
|
|
3817
|
+
delete result[nestedPath];
|
|
3818
|
+
}
|
|
3819
|
+
return result;
|
|
3820
|
+
}
|
|
3113
3821
|
function deepMerge(base, override) {
|
|
3114
3822
|
if (override === void 0) {
|
|
3115
3823
|
return base;
|
|
@@ -3124,6 +3832,10 @@ function deepMerge(base, override) {
|
|
|
3124
3832
|
for (const [key, value] of Object.entries(override)) {
|
|
3125
3833
|
if (value === void 0) continue;
|
|
3126
3834
|
const existing = result[key];
|
|
3835
|
+
if (key === "systems" && isPlainObject(existing) && isPlainObject(value)) {
|
|
3836
|
+
result[key] = deepMerge(pruneFlatSystemDescendantCollisions(existing, value), value);
|
|
3837
|
+
continue;
|
|
3838
|
+
}
|
|
3127
3839
|
result[key] = isPlainObject(existing) && isPlainObject(value) ? deepMerge(existing, value) : value;
|
|
3128
3840
|
}
|
|
3129
3841
|
return result;
|
|
@@ -3131,12 +3843,14 @@ function deepMerge(base, override) {
|
|
|
3131
3843
|
function defineOrganizationModel(model) {
|
|
3132
3844
|
return model;
|
|
3133
3845
|
}
|
|
3134
|
-
function resolveOrganizationModel(override,
|
|
3135
|
-
const
|
|
3846
|
+
function resolveOrganizationModel(override, organizationIdOrOptions, options) {
|
|
3847
|
+
const resolvedOptions = typeof organizationIdOrOptions === "object" ? organizationIdOrOptions : options;
|
|
3848
|
+
const mergeDefaults = resolvedOptions?.mergeDefaults ?? true;
|
|
3849
|
+
const merged = mergeDefaults ? deepMerge(DEFAULT_ORGANIZATION_MODEL, override) : override ?? {};
|
|
3136
3850
|
return OrganizationModelSchema.parse(merged);
|
|
3137
3851
|
}
|
|
3138
3852
|
function resolveOrganizationModelWithResources(override, organizationId) {
|
|
3139
|
-
const model = resolveOrganizationModel(override);
|
|
3853
|
+
const model = resolveOrganizationModel(override, organizationId);
|
|
3140
3854
|
const byPath = /* @__PURE__ */ new Map();
|
|
3141
3855
|
for (const resource of Object.values(model.resources ?? {})) {
|
|
3142
3856
|
const existing = byPath.get(resource.systemPath);
|
|
@@ -3149,7 +3863,8 @@ function resolveOrganizationModelWithResources(override, organizationId) {
|
|
|
3149
3863
|
const enrichedSystems = {};
|
|
3150
3864
|
for (const { path, system } of listAllSystems(model)) {
|
|
3151
3865
|
const resources = byPath.get(path) ?? byPath.get(system.id);
|
|
3152
|
-
|
|
3866
|
+
const config = resolveSystemConfig(model, path);
|
|
3867
|
+
enrichedSystems[path] = resources !== void 0 ? { ...system, id: path, config, resources } : { ...system, id: path, config };
|
|
3153
3868
|
}
|
|
3154
3869
|
return { ...model, systems: enrichedSystems };
|
|
3155
3870
|
}
|
|
@@ -3263,4 +3978,4 @@ function createFoundationOrganizationModel(override) {
|
|
|
3263
3978
|
};
|
|
3264
3979
|
}
|
|
3265
3980
|
|
|
3266
|
-
export { ActionIdSchema, ActionInvocationKindSchema, ActionInvocationSchema, ActionRefSchema, ActionSchema, ActionScopeSchema, ActionsDomainSchema, AgentKindSchema, AgentResourceEntrySchema, AgentRoleHolderSchema, ApiEndpointInvocationSchema, CustomerSegmentSchema, CustomersDomainSchema, DEFAULT_ORGANIZATION_MODEL, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_CUSTOMERS, DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, DEFAULT_ORGANIZATION_MODEL_ENTITIES, DEFAULT_ORGANIZATION_MODEL_GOALS, DEFAULT_ORGANIZATION_MODEL_NAVIGATION, DEFAULT_ORGANIZATION_MODEL_OFFERINGS, DEFAULT_ORGANIZATION_MODEL_POLICIES, DEFAULT_ORGANIZATION_MODEL_RESOURCES, DEFAULT_ORGANIZATION_MODEL_ROLES, DEFAULT_ORGANIZATION_MODEL_STATUSES, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, EntitiesDomainSchema, EntityIdSchema, EntityLinkKindSchema, EntityLinkSchema, EntitySchema, EventDescriptorSchema, EventEmissionDescriptorSchema, EventIdSchema, FirmographicsSchema, GoalsDomainSchema, HumanRoleHolderSchema, IconNameSchema, IntegrationResourceEntrySchema, KNOWLEDGE_FEATURE_ID, KNOWLEDGE_SYSTEM_ID, KeyResultSchema, KnowledgeDomainSchema, KnowledgeLinkSchema, KnowledgeTargetKindSchema, KnowledgeTargetRefSchema, LEAD_GEN_ACTION_ENTRIES, LEAD_GEN_STAGE_CATALOG, LinkSchema, MONITORING_FEATURE_ID, MONITORING_SYSTEM_ID, McpToolInvocationSchema, NavigationGroupSchema, NodeIdPathSchema, NodeIdStringSchema, OPERATIONS_COMMAND_VIEW_SURFACE_ID, OPERATIONS_FEATURE_ID, OPERATIONS_SYSTEM_ID, ORGANIZATION_MODEL_ICON_TOKENS, ObjectiveSchema, OfferingsDomainSchema, OrgKnowledgeKindSchema, OrgKnowledgeNodeSchema, OrganizationModelBuiltinIconTokenSchema, OrganizationModelDomainKeySchema, OrganizationModelDomainMetadataByDomainSchema, OrganizationModelDomainMetadataSchema, OrganizationModelIconTokenSchema, OrganizationModelNavigationSchema, OrganizationModelSchema, PROJECTS_FEATURE_ID, PROJECTS_INDEX_SURFACE_ID, PROJECTS_SYSTEM_ID, PROJECTS_VIEW_ACTION_ID, PROSPECTING_FEATURE_ID, PROSPECTING_LISTS_SURFACE_ID, PROSPECTING_SYSTEM_ID, PoliciesDomainSchema, PolicyApplicabilitySchema, PolicyEffectSchema, PolicyIdSchema, PolicyPredicateSchema, PolicySchema, PolicyTriggerSchema, PricingModelSchema, ProductSchema, ResourceEntrySchema, ResourceGovernanceStatusSchema, ResourceIdSchema, ResourceKindSchema, ResourcesDomainSchema, RoleHolderSchema, RoleHoldersSchema, RoleIdSchema, RoleSchema, RolesDomainSchema, SALES_FEATURE_ID, SALES_PIPELINE_SURFACE_ID, SALES_SYSTEM_ID, SEO_FEATURE_ID, SEO_SYSTEM_ID, SETTINGS_FEATURE_ID, SETTINGS_ROLES_SURFACE_ID, SETTINGS_SYSTEM_ID, ScriptExecutionInvocationSchema, ScriptResourceEntrySchema, ScriptResourceLanguageSchema, ScriptResourceSourceSchema, SidebarNavigationSchema, SidebarNodeSchema, SidebarSectionSchema, SidebarSurfaceTargetsSchema, SlashCommandInvocationSchema, StatusEntrySchema, StatusSemanticClassSchema, StatusesDomainSchema, SurfaceDefinitionSchema, SurfaceTypeSchema, SystemEntrySchema, SystemIdSchema, SystemKindSchema, SystemLifecycleSchema, SystemPathSchema, SystemStatusSchema, SystemUiSchema, SystemsDomainSchema, TeamRoleHolderSchema, TechStackEntrySchema, UiPositionSchema, WorkflowResourceEntrySchema, createFoundationOrganizationModel, defineOrganizationModel, defineResource, defineResources, findOrganizationActionById, getSortedSidebarEntries, resolveOrganizationModel, resolveOrganizationModelWithResources };
|
|
3981
|
+
export { ActionIdSchema, ActionInvocationKindSchema, ActionInvocationSchema, ActionRefSchema, ActionSchema, ActionScopeSchema, ActionsDomainSchema, AgentKindSchema, AgentResourceEntrySchema, AgentRoleHolderSchema, ApiEndpointInvocationSchema, CRM_ACTION_ENTRIES, CodeReferenceRoleSchema, CodeReferenceSchema, CustomerSegmentSchema, CustomersDomainSchema, DEFAULT_ONTOLOGY_SCOPE, DEFAULT_ORGANIZATION_MODEL, DEFAULT_ORGANIZATION_MODEL_ACTIONS, DEFAULT_ORGANIZATION_MODEL_CUSTOMERS, DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, DEFAULT_ORGANIZATION_MODEL_ENTITIES, DEFAULT_ORGANIZATION_MODEL_GOALS, DEFAULT_ORGANIZATION_MODEL_NAVIGATION, DEFAULT_ORGANIZATION_MODEL_OFFERINGS, DEFAULT_ORGANIZATION_MODEL_POLICIES, DEFAULT_ORGANIZATION_MODEL_RESOURCES, DEFAULT_ORGANIZATION_MODEL_ROLES, DEFAULT_ORGANIZATION_MODEL_STATUSES, DEFAULT_ORGANIZATION_MODEL_SYSTEMS, EntitiesDomainSchema, EntityIdSchema, EntityLinkKindSchema, EntityLinkSchema, EntitySchema, EventDescriptorSchema, EventEmissionDescriptorSchema, EventIdSchema, FirmographicsSchema, GoalsDomainSchema, HumanRoleHolderSchema, IconNameSchema, IntegrationResourceEntrySchema, KNOWLEDGE_FEATURE_ID, KNOWLEDGE_SYSTEM_ID, KeyResultSchema, KnowledgeDomainSchema, KnowledgeLinkSchema, KnowledgeTargetKindSchema, KnowledgeTargetRefSchema, LEAD_GEN_ACTION_ENTRIES, LEAD_GEN_STAGE_CATALOG, LinkSchema, MONITORING_FEATURE_ID, MONITORING_SYSTEM_ID, McpToolInvocationSchema, NavigationGroupSchema, NodeIdPathSchema, NodeIdStringSchema, OPERATIONS_COMMAND_VIEW_SURFACE_ID, OPERATIONS_FEATURE_ID, OPERATIONS_SYSTEM_ID, ORGANIZATION_MODEL_ICON_TOKENS, ObjectiveSchema, OfferingsDomainSchema, OntologyActionTypeSchema, OntologyCatalogTypeSchema, OntologyEventTypeSchema, OntologyGroupSchema, OntologyIdSchema, OntologyInterfaceTypeSchema, OntologyKindSchema, OntologyLinkTypeSchema, OntologyObjectTypeSchema, OntologyScopeSchema, OntologySharedPropertySchema, OntologySurfaceTypeSchema, OntologyValueTypeSchema, OrgKnowledgeKindSchema, OrgKnowledgeNodeSchema, OrganizationModelBuiltinIconTokenSchema, OrganizationModelDomainKeySchema, OrganizationModelDomainMetadataByDomainSchema, OrganizationModelDomainMetadataSchema, OrganizationModelIconTokenSchema, OrganizationModelNavigationSchema, OrganizationModelSchema, PROJECTS_FEATURE_ID, PROJECTS_INDEX_SURFACE_ID, PROJECTS_SYSTEM_ID, PROJECTS_VIEW_ACTION_ID, PROSPECTING_FEATURE_ID, PROSPECTING_LISTS_SURFACE_ID, PROSPECTING_SYSTEM_ID, PoliciesDomainSchema, PolicyApplicabilitySchema, PolicyEffectSchema, PolicyIdSchema, PolicyPredicateSchema, PolicySchema, PolicyTriggerSchema, PricingModelSchema, ProductSchema, ResourceEntrySchema, ResourceGovernanceStatusSchema, ResourceIdSchema, ResourceKindSchema, ResourceOntologyBindingSchema, ResourcesDomainSchema, RoleHolderSchema, RoleHoldersSchema, RoleIdSchema, RoleSchema, RolesDomainSchema, SALES_FEATURE_ID, SALES_PIPELINE_SURFACE_ID, SALES_SYSTEM_ID, SEO_FEATURE_ID, SEO_SYSTEM_ID, SETTINGS_FEATURE_ID, SETTINGS_ROLES_SURFACE_ID, SETTINGS_SYSTEM_ID, ScriptExecutionInvocationSchema, ScriptResourceEntrySchema, ScriptResourceLanguageSchema, ScriptResourceSourceSchema, SidebarNavigationSchema, SidebarNodeSchema, SidebarSectionSchema, SidebarSurfaceTargetsSchema, SlashCommandInvocationSchema, StatusEntrySchema, StatusSemanticClassSchema, StatusesDomainSchema, SurfaceDefinitionSchema, SurfaceTypeSchema, SystemEntrySchema, SystemIdSchema, SystemKindSchema, SystemLifecycleSchema, SystemPathSchema, SystemStatusSchema, SystemUiSchema, SystemsDomainSchema, TeamRoleHolderSchema, TechStackEntrySchema, UiPositionSchema, WorkflowResourceEntrySchema, compileOrganizationOntology, createFoundationOrganizationModel, defineOrganizationModel, defineResource, defineResources, findOrganizationActionById, formatOntologyId, getOntologyDiagnostics, getSortedSidebarEntries, isOntologyGraphNodeId, listResolvedOntologyRecords, ontologyGraphNodeId, ontologyIdFromGraphNodeId, parseOntologyId, resolveOrganizationModel, resolveOrganizationModelWithResources };
|