@elevasis/sdk 1.22.0 → 1.22.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/cli.cjs +300 -14
- package/dist/index.d.ts +1217 -220
- package/dist/index.js +386 -12
- package/dist/test-utils/index.d.ts +963 -211
- package/dist/test-utils/index.js +253 -11
- package/dist/worker/index.js +118 -11
- package/package.json +3 -3
- package/reference/claude-config/rules/operations.md +3 -3
- package/reference/claude-config/rules/organization-model.md +11 -5
- package/reference/claude-config/sync-notes/2026-05-14-organization-model-ontology-refactor.md +7 -4
- package/reference/examples/organization-model.ts +26 -2
- package/reference/scaffold/core/organization-model.mdx +16 -11
- package/reference/scaffold/recipes/add-a-feature.md +28 -26
- package/reference/scaffold/recipes/add-a-resource.md +26 -16
- package/reference/scaffold/recipes/customize-organization-model.md +5 -3
- package/reference/scaffold/recipes/extend-lead-gen.md +9 -9
- package/reference/scaffold/recipes/index.md +1 -1
- package/reference/scaffold/reference/contracts.md +45 -7
- package/reference/scaffold/reference/glossary.md +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -37454,7 +37454,6 @@ function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
|
|
|
37454
37454
|
table: entity.table
|
|
37455
37455
|
}
|
|
37456
37456
|
} : {},
|
|
37457
|
-
legacyEntityId: entity.id,
|
|
37458
37457
|
...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
|
|
37459
37458
|
...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
|
|
37460
37459
|
};
|
|
@@ -37479,8 +37478,7 @@ function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
|
|
|
37479
37478
|
from: legacyObjectId(entity),
|
|
37480
37479
|
to: legacyObjectId(targetEntity),
|
|
37481
37480
|
cardinality: link.kind,
|
|
37482
|
-
...link.via !== void 0 ? { via: link.via } : {}
|
|
37483
|
-
legacyEntityId: entity.id
|
|
37481
|
+
...link.via !== void 0 ? { via: link.via } : {}
|
|
37484
37482
|
};
|
|
37485
37483
|
addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
|
|
37486
37484
|
source: "legacy.entities.links",
|
|
@@ -37538,8 +37536,7 @@ function addSystemContentProjections(index, diagnostics, sourcesById, systemPath
|
|
|
37538
37536
|
kind: node.type,
|
|
37539
37537
|
...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
|
|
37540
37538
|
...Object.keys(entries).length > 0 ? { entries } : {},
|
|
37541
|
-
...node.data !== void 0 ? { data: node.data } : {}
|
|
37542
|
-
legacyContentId: `${systemPath}:${localId}`
|
|
37539
|
+
...node.data !== void 0 ? { data: node.data } : {}
|
|
37543
37540
|
};
|
|
37544
37541
|
addRecord(index, diagnostics, sourcesById, "catalogTypes", catalogType, {
|
|
37545
37542
|
source: "legacy.system.content",
|
|
@@ -38114,11 +38111,20 @@ var EventDescriptorSchema = EventEmissionDescriptorSchema.extend({
|
|
|
38114
38111
|
ownerKind: external_exports.enum(["resource", "entity"]).meta({ label: "Owner kind" })
|
|
38115
38112
|
});
|
|
38116
38113
|
var ResourceOntologyBindingSchema = external_exports.object({
|
|
38117
|
-
|
|
38114
|
+
actions: external_exports.array(OntologyIdSchema).optional(),
|
|
38115
|
+
primaryAction: OntologyIdSchema.optional(),
|
|
38118
38116
|
reads: external_exports.array(OntologyIdSchema).optional(),
|
|
38119
38117
|
writes: external_exports.array(OntologyIdSchema).optional(),
|
|
38120
38118
|
usesCatalogs: external_exports.array(OntologyIdSchema).optional(),
|
|
38121
38119
|
emits: external_exports.array(OntologyIdSchema).optional()
|
|
38120
|
+
}).superRefine((binding, ctx) => {
|
|
38121
|
+
if (binding.primaryAction === void 0) return;
|
|
38122
|
+
if (binding.actions?.includes(binding.primaryAction)) return;
|
|
38123
|
+
ctx.addIssue({
|
|
38124
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38125
|
+
path: ["primaryAction"],
|
|
38126
|
+
message: "Resource ontology primaryAction must be included in actions"
|
|
38127
|
+
});
|
|
38122
38128
|
});
|
|
38123
38129
|
var CodeReferenceSchema = external_exports.object({
|
|
38124
38130
|
path: external_exports.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
|
|
@@ -38133,6 +38139,10 @@ var ResourceEntryBaseSchema = external_exports.object({
|
|
|
38133
38139
|
order: external_exports.number().default(0),
|
|
38134
38140
|
/** Required single System membership — value is a dot-separated system path (e.g. "sales.lead-gen"). */
|
|
38135
38141
|
systemPath: SystemPathSchema.meta({ ref: "system" }),
|
|
38142
|
+
/** Executable display title owned by the OM Resource descriptor. */
|
|
38143
|
+
title: LabelSchema.optional(),
|
|
38144
|
+
/** Executable display description owned by the OM Resource descriptor. */
|
|
38145
|
+
description: DescriptionSchema.optional(),
|
|
38136
38146
|
/** Optional role responsible for maintaining this resource. */
|
|
38137
38147
|
ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
|
|
38138
38148
|
status: ResourceGovernanceStatusSchema,
|
|
@@ -38147,8 +38157,6 @@ var ResourceEntryBaseSchema = external_exports.object({
|
|
|
38147
38157
|
});
|
|
38148
38158
|
var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
38149
38159
|
kind: external_exports.literal("workflow"),
|
|
38150
|
-
/** Mirrors WorkflowConfig.actionKey when the runtime workflow has one. */
|
|
38151
|
-
actionKey: external_exports.string().trim().min(1).max(255).optional(),
|
|
38152
38160
|
emits: external_exports.array(EventEmissionDescriptorSchema).optional()
|
|
38153
38161
|
});
|
|
38154
38162
|
var AgentResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
@@ -38373,6 +38381,75 @@ var OrgKnowledgeNodeSchema = external_exports.object({
|
|
|
38373
38381
|
});
|
|
38374
38382
|
var KnowledgeDomainSchema = external_exports.record(ModelIdSchema, OrgKnowledgeNodeSchema).default({});
|
|
38375
38383
|
|
|
38384
|
+
// ../core/src/organization-model/domains/topology.ts
|
|
38385
|
+
var SecretLikeMetadataKeySchema = /(?:secret|password|passwd|token|api[-_]?key|credential|private[-_]?key)/i;
|
|
38386
|
+
var SecretLikeMetadataValueSchema = /(?:sk-[A-Za-z0-9_-]{12,}|pk_live_[A-Za-z0-9_-]{12,}|eyJ[A-Za-z0-9_-]{20,}|-----BEGIN (?:RSA |OPENSSH |EC )?PRIVATE KEY-----)/;
|
|
38387
|
+
var OmTopologyNodeKindSchema = external_exports.enum([
|
|
38388
|
+
"system",
|
|
38389
|
+
"resource",
|
|
38390
|
+
"ontology",
|
|
38391
|
+
"policy",
|
|
38392
|
+
"role",
|
|
38393
|
+
"trigger",
|
|
38394
|
+
"humanCheckpoint",
|
|
38395
|
+
"externalResource"
|
|
38396
|
+
]);
|
|
38397
|
+
var OmTopologyRelationshipKindSchema = external_exports.enum(["triggers", "uses", "approval"]);
|
|
38398
|
+
var OmTopologyNodeRefSchema = external_exports.discriminatedUnion("kind", [
|
|
38399
|
+
external_exports.object({ kind: external_exports.literal("system"), id: ModelIdSchema }),
|
|
38400
|
+
external_exports.object({ kind: external_exports.literal("resource"), id: ResourceIdSchema }),
|
|
38401
|
+
external_exports.object({ kind: external_exports.literal("ontology"), id: OntologyIdSchema }),
|
|
38402
|
+
external_exports.object({ kind: external_exports.literal("policy"), id: ModelIdSchema }),
|
|
38403
|
+
external_exports.object({ kind: external_exports.literal("role"), id: ModelIdSchema }),
|
|
38404
|
+
external_exports.object({ kind: external_exports.literal("trigger"), id: ResourceIdSchema }),
|
|
38405
|
+
external_exports.object({ kind: external_exports.literal("humanCheckpoint"), id: ResourceIdSchema }),
|
|
38406
|
+
external_exports.object({ kind: external_exports.literal("externalResource"), id: ResourceIdSchema })
|
|
38407
|
+
]);
|
|
38408
|
+
var OmTopologyMetadataSchema = external_exports.record(external_exports.string().trim().min(1).max(120), JsonValueSchema).superRefine((metadata, ctx) => {
|
|
38409
|
+
function visit(value, path3) {
|
|
38410
|
+
if (typeof value === "string" && SecretLikeMetadataValueSchema.test(value)) {
|
|
38411
|
+
ctx.addIssue({
|
|
38412
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38413
|
+
path: path3,
|
|
38414
|
+
message: "Topology metadata must not contain secret-like values"
|
|
38415
|
+
});
|
|
38416
|
+
return;
|
|
38417
|
+
}
|
|
38418
|
+
if (Array.isArray(value)) {
|
|
38419
|
+
value.forEach((entry, index) => visit(entry, [...path3, index]));
|
|
38420
|
+
return;
|
|
38421
|
+
}
|
|
38422
|
+
if (typeof value !== "object" || value === null) return;
|
|
38423
|
+
Object.entries(value).forEach(([key, entry]) => {
|
|
38424
|
+
if (SecretLikeMetadataKeySchema.test(key)) {
|
|
38425
|
+
ctx.addIssue({
|
|
38426
|
+
code: external_exports.ZodIssueCode.custom,
|
|
38427
|
+
path: [...path3, key],
|
|
38428
|
+
message: `Topology metadata key "${key}" looks secret-like`
|
|
38429
|
+
});
|
|
38430
|
+
}
|
|
38431
|
+
visit(entry, [...path3, key]);
|
|
38432
|
+
});
|
|
38433
|
+
}
|
|
38434
|
+
visit(metadata, []);
|
|
38435
|
+
});
|
|
38436
|
+
var OmTopologyRelationshipSchema = external_exports.object({
|
|
38437
|
+
from: OmTopologyNodeRefSchema,
|
|
38438
|
+
kind: OmTopologyRelationshipKindSchema,
|
|
38439
|
+
to: OmTopologyNodeRefSchema,
|
|
38440
|
+
systemPath: SystemPathSchema.optional(),
|
|
38441
|
+
required: external_exports.boolean().optional(),
|
|
38442
|
+
metadata: OmTopologyMetadataSchema.optional()
|
|
38443
|
+
});
|
|
38444
|
+
var OmTopologyDomainSchema = external_exports.object({
|
|
38445
|
+
version: external_exports.literal(1).default(1),
|
|
38446
|
+
relationships: external_exports.record(external_exports.string().trim().min(1).max(255), OmTopologyRelationshipSchema).default({})
|
|
38447
|
+
}).default({ version: 1, relationships: {} });
|
|
38448
|
+
var DEFAULT_ORGANIZATION_MODEL_TOPOLOGY = {
|
|
38449
|
+
version: 1,
|
|
38450
|
+
relationships: {}
|
|
38451
|
+
};
|
|
38452
|
+
|
|
38376
38453
|
// ../core/src/organization-model/domains/policies.ts
|
|
38377
38454
|
var PolicyIdSchema = ModelIdSchema;
|
|
38378
38455
|
var PolicyApplicabilitySchema = external_exports.object({
|
|
@@ -38463,6 +38540,7 @@ var OrganizationModelDomainKeySchema = external_exports.enum([
|
|
|
38463
38540
|
"systems",
|
|
38464
38541
|
"ontology",
|
|
38465
38542
|
"resources",
|
|
38543
|
+
"topology",
|
|
38466
38544
|
"actions",
|
|
38467
38545
|
"entities",
|
|
38468
38546
|
"policies",
|
|
@@ -38482,6 +38560,7 @@ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
|
|
|
38482
38560
|
systems: { version: 1, lastModified: "2026-05-10" },
|
|
38483
38561
|
ontology: { version: 1, lastModified: "2026-05-14" },
|
|
38484
38562
|
resources: { version: 1, lastModified: "2026-05-10" },
|
|
38563
|
+
topology: { version: 1, lastModified: "2026-05-14" },
|
|
38485
38564
|
actions: { version: 1, lastModified: "2026-05-10" },
|
|
38486
38565
|
entities: { version: 1, lastModified: "2026-05-10" },
|
|
38487
38566
|
policies: { version: 1, lastModified: "2026-05-10" },
|
|
@@ -38497,6 +38576,7 @@ var OrganizationModelDomainMetadataByDomainSchema = external_exports.object({
|
|
|
38497
38576
|
systems: OrganizationModelDomainMetadataSchema,
|
|
38498
38577
|
ontology: OrganizationModelDomainMetadataSchema,
|
|
38499
38578
|
resources: OrganizationModelDomainMetadataSchema,
|
|
38579
|
+
topology: OrganizationModelDomainMetadataSchema,
|
|
38500
38580
|
actions: OrganizationModelDomainMetadataSchema,
|
|
38501
38581
|
entities: OrganizationModelDomainMetadataSchema,
|
|
38502
38582
|
policies: OrganizationModelDomainMetadataSchema,
|
|
@@ -38515,6 +38595,7 @@ var OrganizationModelSchemaBase = external_exports.object({
|
|
|
38515
38595
|
systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
|
|
38516
38596
|
ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
|
|
38517
38597
|
resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
|
|
38598
|
+
topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
|
|
38518
38599
|
actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
|
|
38519
38600
|
entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
|
|
38520
38601
|
policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
|
|
@@ -38857,6 +38938,26 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
38857
38938
|
surface: ontologyCompilation.ontology.surfaces
|
|
38858
38939
|
};
|
|
38859
38940
|
const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
|
|
38941
|
+
function topologyTargetExists(ref) {
|
|
38942
|
+
if (ref.kind === "system") return systemsById.has(ref.id);
|
|
38943
|
+
if (ref.kind === "resource") return resourcesById.has(ref.id);
|
|
38944
|
+
if (ref.kind === "ontology") return ontologyIds.has(ref.id);
|
|
38945
|
+
if (ref.kind === "policy") return policiesById.has(ref.id);
|
|
38946
|
+
if (ref.kind === "role") return rolesById.has(ref.id);
|
|
38947
|
+
return true;
|
|
38948
|
+
}
|
|
38949
|
+
Object.entries(model.topology.relationships).forEach(([relationshipId, relationship]) => {
|
|
38950
|
+
;
|
|
38951
|
+
["from", "to"].forEach((side) => {
|
|
38952
|
+
const ref = relationship[side];
|
|
38953
|
+
if (topologyTargetExists(ref)) return;
|
|
38954
|
+
addIssue(
|
|
38955
|
+
ctx,
|
|
38956
|
+
["topology", "relationships", relationshipId, side],
|
|
38957
|
+
`Topology relationship "${relationshipId}" ${side} references unknown ${ref.kind} "${ref.id}"`
|
|
38958
|
+
);
|
|
38959
|
+
});
|
|
38960
|
+
});
|
|
38860
38961
|
const ontologyReferenceKeyKinds = {
|
|
38861
38962
|
valueType: "value-type",
|
|
38862
38963
|
catalogType: "catalog",
|
|
@@ -38995,11 +39096,18 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
38995
39096
|
}
|
|
38996
39097
|
});
|
|
38997
39098
|
function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
|
|
38998
|
-
ids
|
|
39099
|
+
const ontologyIds2 = ids === void 0 ? [] : Array.isArray(ids) ? ids : [ids];
|
|
39100
|
+
ontologyIds2.forEach((ontologyId, ontologyIndex) => {
|
|
38999
39101
|
if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
|
|
39000
39102
|
addIssue(
|
|
39001
39103
|
ctx,
|
|
39002
|
-
[
|
|
39104
|
+
[
|
|
39105
|
+
"resources",
|
|
39106
|
+
resourceId,
|
|
39107
|
+
"ontology",
|
|
39108
|
+
bindingKey,
|
|
39109
|
+
...Array.isArray(ids) ? [ontologyIndex] : []
|
|
39110
|
+
],
|
|
39003
39111
|
`Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
|
|
39004
39112
|
);
|
|
39005
39113
|
}
|
|
@@ -39008,7 +39116,8 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
|
|
|
39008
39116
|
Object.values(model.resources).forEach((resource) => {
|
|
39009
39117
|
const binding = resource.ontology;
|
|
39010
39118
|
if (binding === void 0) return;
|
|
39011
|
-
validateResourceOntologyBinding(resource.id, "
|
|
39119
|
+
validateResourceOntologyBinding(resource.id, "actions", "action", binding.actions);
|
|
39120
|
+
validateResourceOntologyBinding(resource.id, "primaryAction", "action", binding.primaryAction);
|
|
39012
39121
|
validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
|
|
39013
39122
|
validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
|
|
39014
39123
|
validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
|
|
@@ -39156,9 +39265,10 @@ var OrganizationGraphEdgeKindSchema = external_exports.enum([
|
|
|
39156
39265
|
"emits",
|
|
39157
39266
|
"originates_from",
|
|
39158
39267
|
"triggers",
|
|
39268
|
+
"approval",
|
|
39159
39269
|
"applies_to",
|
|
39160
39270
|
"effects",
|
|
39161
|
-
"
|
|
39271
|
+
"actions",
|
|
39162
39272
|
"reads",
|
|
39163
39273
|
"writes",
|
|
39164
39274
|
"uses_catalog"
|
|
@@ -39526,6 +39636,120 @@ function getRuntimeResources(resources) {
|
|
|
39526
39636
|
}))
|
|
39527
39637
|
];
|
|
39528
39638
|
}
|
|
39639
|
+
function hasOntologySources(organizationModel) {
|
|
39640
|
+
return organizationModel.ontology !== void 0 || organizationModel.entities !== void 0 || organizationModel.actions !== void 0 || Object.values(organizationModel.systems ?? {}).some(systemHasOntologySource);
|
|
39641
|
+
}
|
|
39642
|
+
function systemHasOntologySource(system) {
|
|
39643
|
+
if (system.ontology !== void 0 || system.content !== void 0 && Object.keys(system.content).length > 0) return true;
|
|
39644
|
+
return Object.values(system.systems ?? system.subsystems ?? {}).some(systemHasOntologySource);
|
|
39645
|
+
}
|
|
39646
|
+
function ontologyIndexForKind(index, kind) {
|
|
39647
|
+
switch (kind) {
|
|
39648
|
+
case "object":
|
|
39649
|
+
return index.objectTypes;
|
|
39650
|
+
case "link":
|
|
39651
|
+
return index.linkTypes;
|
|
39652
|
+
case "action":
|
|
39653
|
+
return index.actionTypes;
|
|
39654
|
+
case "catalog":
|
|
39655
|
+
return index.catalogTypes;
|
|
39656
|
+
case "event":
|
|
39657
|
+
return index.eventTypes;
|
|
39658
|
+
case "interface":
|
|
39659
|
+
return index.interfaceTypes;
|
|
39660
|
+
case "value-type":
|
|
39661
|
+
return index.valueTypes;
|
|
39662
|
+
case "property":
|
|
39663
|
+
return index.sharedProperties;
|
|
39664
|
+
case "group":
|
|
39665
|
+
return index.groups;
|
|
39666
|
+
case "surface":
|
|
39667
|
+
return index.surfaces;
|
|
39668
|
+
}
|
|
39669
|
+
}
|
|
39670
|
+
function sameJson(left, right) {
|
|
39671
|
+
return JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
|
|
39672
|
+
}
|
|
39673
|
+
function addOntologyBindingIssues(issues, orgName, resource, ontologyIndex) {
|
|
39674
|
+
const binding = resource.ontology;
|
|
39675
|
+
if (binding === void 0) return;
|
|
39676
|
+
if ((resource.kind === "workflow" || resource.kind === "agent") && (binding.actions?.length ?? 0) === 0) {
|
|
39677
|
+
addGovernanceIssue(
|
|
39678
|
+
issues,
|
|
39679
|
+
"missing-ontology-actions",
|
|
39680
|
+
orgName,
|
|
39681
|
+
resource.id,
|
|
39682
|
+
`[${orgName}] Resource '${resource.id}' declares ontology bindings but no ontology actions.`
|
|
39683
|
+
);
|
|
39684
|
+
}
|
|
39685
|
+
if (binding.primaryAction !== void 0 && !binding.actions?.includes(binding.primaryAction)) {
|
|
39686
|
+
addGovernanceIssue(
|
|
39687
|
+
issues,
|
|
39688
|
+
"primary-action-mismatch",
|
|
39689
|
+
orgName,
|
|
39690
|
+
resource.id,
|
|
39691
|
+
`[${orgName}] Resource '${resource.id}' primaryAction '${binding.primaryAction}' must be included in ontology.actions.`
|
|
39692
|
+
);
|
|
39693
|
+
}
|
|
39694
|
+
if (ontologyIndex === void 0) return;
|
|
39695
|
+
const validateRefs = (bindingKey, expectedKind, refs) => {
|
|
39696
|
+
const values = refs === void 0 ? [] : Array.isArray(refs) ? refs : [refs];
|
|
39697
|
+
const index = ontologyIndexForKind(ontologyIndex, expectedKind);
|
|
39698
|
+
for (const ref of values) {
|
|
39699
|
+
if (index[ref] !== void 0) continue;
|
|
39700
|
+
addGovernanceIssue(
|
|
39701
|
+
issues,
|
|
39702
|
+
"ontology-reference-missing",
|
|
39703
|
+
orgName,
|
|
39704
|
+
resource.id,
|
|
39705
|
+
`[${orgName}] Resource '${resource.id}' ontology.${bindingKey} references missing ${expectedKind} ontology record '${ref}'.`
|
|
39706
|
+
);
|
|
39707
|
+
}
|
|
39708
|
+
};
|
|
39709
|
+
validateRefs("actions", "action", binding.actions);
|
|
39710
|
+
validateRefs("primaryAction", "action", binding.primaryAction);
|
|
39711
|
+
validateRefs("reads", "object", binding.reads);
|
|
39712
|
+
validateRefs("writes", "object", binding.writes);
|
|
39713
|
+
validateRefs("usesCatalogs", "catalog", binding.usesCatalogs);
|
|
39714
|
+
validateRefs("emits", "event", binding.emits);
|
|
39715
|
+
}
|
|
39716
|
+
function addTopologyIssues(issues, orgName, deployment, organizationModel, systemsById, omResourcesById, ontologyIndex) {
|
|
39717
|
+
const relationships = organizationModel.topology?.relationships;
|
|
39718
|
+
if (relationships === void 0) return;
|
|
39719
|
+
const rolesById = new Set(Object.keys(organizationModel.roles ?? {}));
|
|
39720
|
+
const policiesById = new Set(Object.keys(organizationModel.policies ?? {}));
|
|
39721
|
+
const triggerIds = new Set(deployment.triggers?.map((trigger) => trigger.resourceId) ?? []);
|
|
39722
|
+
const humanCheckpointIds = new Set(deployment.humanCheckpoints?.map((checkpoint) => checkpoint.resourceId) ?? []);
|
|
39723
|
+
const externalResourceIds = new Set(deployment.externalResources?.map((external) => external.resourceId) ?? []);
|
|
39724
|
+
const topologyRefExists = (ref) => {
|
|
39725
|
+
if (ref.kind === "system") return systemsById.has(ref.id);
|
|
39726
|
+
if (ref.kind === "resource") return omResourcesById.has(ref.id);
|
|
39727
|
+
if (ref.kind === "policy") return policiesById.has(ref.id);
|
|
39728
|
+
if (ref.kind === "role") return rolesById.has(ref.id);
|
|
39729
|
+
if (ref.kind === "trigger") return triggerIds.has(ref.id);
|
|
39730
|
+
if (ref.kind === "humanCheckpoint") return humanCheckpointIds.has(ref.id);
|
|
39731
|
+
if (ref.kind === "externalResource") return externalResourceIds.has(ref.id);
|
|
39732
|
+
if (ref.kind === "ontology") {
|
|
39733
|
+
if (ontologyIndex === void 0) return true;
|
|
39734
|
+
return Object.values(ontologyIndex).some((records) => records[ref.id] !== void 0);
|
|
39735
|
+
}
|
|
39736
|
+
return false;
|
|
39737
|
+
};
|
|
39738
|
+
for (const [relationshipId, relationship] of Object.entries(relationships)) {
|
|
39739
|
+
;
|
|
39740
|
+
["from", "to"].forEach((side) => {
|
|
39741
|
+
const ref = relationship[side];
|
|
39742
|
+
if (topologyRefExists(ref)) return;
|
|
39743
|
+
addGovernanceIssue(
|
|
39744
|
+
issues,
|
|
39745
|
+
"topology-reference-missing",
|
|
39746
|
+
orgName,
|
|
39747
|
+
ref.id,
|
|
39748
|
+
`[${orgName}] Topology relationship '${relationshipId}' ${side} references missing ${ref.kind} '${ref.id}'.`
|
|
39749
|
+
);
|
|
39750
|
+
});
|
|
39751
|
+
}
|
|
39752
|
+
}
|
|
39529
39753
|
function validateResourceGovernance(orgName, deployment, organizationModel = deployment.organizationModel, options = {}) {
|
|
39530
39754
|
const mode = getResourceValidatorMode(options.mode);
|
|
39531
39755
|
const omResourcesMap = organizationModel?.resources;
|
|
@@ -39541,6 +39765,17 @@ function validateResourceGovernance(orgName, deployment, organizationModel = dep
|
|
|
39541
39765
|
const omResourcesById = new Map(activeOmResources.map((resource) => [resource.id, resource]));
|
|
39542
39766
|
const runtimeResources = getRuntimeResources(deployment);
|
|
39543
39767
|
const runtimeResourcesById = new Map(runtimeResources.map((resource) => [resource.resourceId, resource]));
|
|
39768
|
+
const ontologyCompilation = hasOntologySources(organizationModel) ? compileOrganizationOntology(organizationModel) : void 0;
|
|
39769
|
+
const ontologyIndex = ontologyCompilation?.ontology;
|
|
39770
|
+
for (const diagnostic of ontologyCompilation?.diagnostics ?? []) {
|
|
39771
|
+
addGovernanceIssue(
|
|
39772
|
+
issues,
|
|
39773
|
+
"ontology-reference-missing",
|
|
39774
|
+
orgName,
|
|
39775
|
+
diagnostic.id,
|
|
39776
|
+
`[${orgName}] ${diagnostic.message}`
|
|
39777
|
+
);
|
|
39778
|
+
}
|
|
39544
39779
|
for (const resource of activeOmResources) {
|
|
39545
39780
|
if (!systemsById.has(resource.systemPath)) {
|
|
39546
39781
|
addGovernanceIssue(
|
|
@@ -39580,6 +39815,16 @@ function validateResourceGovernance(orgName, deployment, organizationModel = dep
|
|
|
39580
39815
|
`[${orgName}] Resource '${resource.id}' system mismatch: code descriptor has '${runtimeResource.descriptor.systemPath}', OM has '${resource.systemPath}'.`
|
|
39581
39816
|
);
|
|
39582
39817
|
}
|
|
39818
|
+
if (runtimeResource.descriptor && !sameJson(runtimeResource.descriptor.ontology, resource.ontology)) {
|
|
39819
|
+
addGovernanceIssue(
|
|
39820
|
+
issues,
|
|
39821
|
+
"descriptor-mismatch",
|
|
39822
|
+
orgName,
|
|
39823
|
+
resource.id,
|
|
39824
|
+
`[${orgName}] Resource '${resource.id}' ontology descriptor mismatch between code and OM.`
|
|
39825
|
+
);
|
|
39826
|
+
}
|
|
39827
|
+
addOntologyBindingIssues(issues, orgName, resource, ontologyIndex);
|
|
39583
39828
|
}
|
|
39584
39829
|
for (const runtimeResource of runtimeResources) {
|
|
39585
39830
|
const omResource = omResourcesById.get(runtimeResource.resourceId);
|
|
@@ -39621,6 +39866,7 @@ function validateResourceGovernance(orgName, deployment, organizationModel = dep
|
|
|
39621
39866
|
);
|
|
39622
39867
|
}
|
|
39623
39868
|
}
|
|
39869
|
+
addTopologyIssues(issues, orgName, deployment, organizationModel, systemsById, omResourcesById, ontologyIndex);
|
|
39624
39870
|
emitGovernanceIssues(issues, mode, options.onWarning);
|
|
39625
39871
|
return {
|
|
39626
39872
|
valid: issues.length === 0,
|
|
@@ -43871,6 +44117,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
|
|
|
43871
44117
|
},
|
|
43872
44118
|
ontology: DEFAULT_ONTOLOGY_SCOPE,
|
|
43873
44119
|
resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
|
|
44120
|
+
topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
|
|
43874
44121
|
actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
|
|
43875
44122
|
entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
|
|
43876
44123
|
policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
|
|
@@ -44165,6 +44412,32 @@ function buildOrganizationGraph(input) {
|
|
|
44165
44412
|
}
|
|
44166
44413
|
const validSystemRefs = new Set(systemPathByRef.keys());
|
|
44167
44414
|
const systemNodeId = (systemRef) => nodeId("system", systemPathByRef.get(systemRef) ?? systemRef);
|
|
44415
|
+
function topologyNodeId(ref) {
|
|
44416
|
+
if (ref.kind === "system") return systemNodeId(ref.id);
|
|
44417
|
+
if (ref.kind === "resource") return nodeId("resource", ref.id);
|
|
44418
|
+
if (ref.kind === "ontology") return ontologyGraphNodeId(ref.id);
|
|
44419
|
+
if (ref.kind === "policy") return nodeId("policy", ref.id);
|
|
44420
|
+
if (ref.kind === "role") return nodeId("role", ref.id);
|
|
44421
|
+
return nodeId("resource", ref.id);
|
|
44422
|
+
}
|
|
44423
|
+
function ensureTopologyNode(ref) {
|
|
44424
|
+
const id = topologyNodeId(ref);
|
|
44425
|
+
if (nodeIds.has(id)) return id;
|
|
44426
|
+
if (ref.kind === "resource") {
|
|
44427
|
+
ensureResourceNode(nodes, nodeIds, resourceNodesById, ref.id);
|
|
44428
|
+
return id;
|
|
44429
|
+
}
|
|
44430
|
+
if (ref.kind === "trigger" || ref.kind === "humanCheckpoint" || ref.kind === "externalResource") {
|
|
44431
|
+
pushUniqueNode(nodes, nodeIds, {
|
|
44432
|
+
id,
|
|
44433
|
+
kind: "resource",
|
|
44434
|
+
label: ref.id,
|
|
44435
|
+
sourceId: ref.id,
|
|
44436
|
+
resourceType: ref.kind === "trigger" ? "trigger" : ref.kind === "humanCheckpoint" ? "human_checkpoint" : "external"
|
|
44437
|
+
});
|
|
44438
|
+
}
|
|
44439
|
+
return id;
|
|
44440
|
+
}
|
|
44168
44441
|
for (const { path: path3, system } of systemsWithPaths.sort((a, b) => a.path.localeCompare(b.path))) {
|
|
44169
44442
|
const id = nodeId("system", path3);
|
|
44170
44443
|
pushUniqueNode(nodes, nodeIds, {
|
|
@@ -44480,7 +44753,7 @@ function buildOrganizationGraph(input) {
|
|
|
44480
44753
|
targetId: resourceNode.id
|
|
44481
44754
|
});
|
|
44482
44755
|
}
|
|
44483
|
-
pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "
|
|
44756
|
+
pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "actions", resource.ontology?.actions);
|
|
44484
44757
|
pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "reads", resource.ontology?.reads);
|
|
44485
44758
|
pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "writes", resource.ontology?.writes);
|
|
44486
44759
|
pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "uses_catalog", resource.ontology?.usesCatalogs);
|
|
@@ -44614,6 +44887,19 @@ function buildOrganizationGraph(input) {
|
|
|
44614
44887
|
}
|
|
44615
44888
|
}
|
|
44616
44889
|
}
|
|
44890
|
+
for (const [relationshipId, relationship] of Object.entries(organizationModel.topology.relationships).sort(
|
|
44891
|
+
([a], [b]) => a.localeCompare(b)
|
|
44892
|
+
)) {
|
|
44893
|
+
const sourceId = ensureTopologyNode(relationship.from);
|
|
44894
|
+
const targetId = ensureTopologyNode(relationship.to);
|
|
44895
|
+
pushUniqueEdge(edges, edgeIds, {
|
|
44896
|
+
id: edgeId(relationship.kind, sourceId, targetId, `topology-${relationshipId}`),
|
|
44897
|
+
kind: relationship.kind,
|
|
44898
|
+
sourceId,
|
|
44899
|
+
targetId,
|
|
44900
|
+
relationshipType: relationship.kind
|
|
44901
|
+
});
|
|
44902
|
+
}
|
|
44617
44903
|
for (const segment of Object.values(organizationModel.customers).sort(
|
|
44618
44904
|
(a, b) => a.order - b.order || a.id.localeCompare(b.id)
|
|
44619
44905
|
)) {
|
|
@@ -45048,7 +45334,7 @@ function wrapAction(commandName, fn) {
|
|
|
45048
45334
|
// package.json
|
|
45049
45335
|
var package_default = {
|
|
45050
45336
|
name: "@elevasis/sdk",
|
|
45051
|
-
version: "1.22.
|
|
45337
|
+
version: "1.22.1",
|
|
45052
45338
|
description: "SDK for building Elevasis organization resources",
|
|
45053
45339
|
type: "module",
|
|
45054
45340
|
bin: {
|