@elevasis/core 0.47.0 → 0.48.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.
@@ -1538,6 +1538,7 @@ interface OrganizationGraph {
1538
1538
  * @param systemId - The dotted system id (e.g. `sales.crm`).
1539
1539
  */
1540
1540
  declare function bySystem(graph: OrganizationGraph, systemId: string, knowledgeNodes: OrgKnowledgeNode[]): OrgKnowledgeNode[];
1541
+ declare function byOntology(graph: OrganizationGraph, ontologyId: string, knowledgeNodes: OrgKnowledgeNode[]): OrgKnowledgeNode[];
1541
1542
  /**
1542
1543
  * Returns all knowledge nodes whose `kind` matches the given kind.
1543
1544
  *
@@ -1745,5 +1746,5 @@ declare function formatKnowledgeInvocationLabel(invocation: OrganizationModelAct
1745
1746
  declare function resolveKnowledgeInvocationNeighbors(model: OrganizationModel, id: string): KnowledgeInvocationNeighborsResult | undefined;
1746
1747
  declare function formatKnowledgeInvocationNeighbors(result: KnowledgeInvocationNeighborsResult): string;
1747
1748
 
1748
- export { OM_SEARCH_HIT_KINDS, byKind, byOwner, bySystem, formatIdsOnly, formatJson, formatKnowledgeInvocationLabel, formatKnowledgeInvocationNeighbors, formatKnowledgeResourcesList, formatKnowledgeRolesList, formatKnowledgeSystemsList, formatText, governedBy, governs, normalizeKnowledgeNodeId, parseKnowledgeSearchKinds, parseKnowledgeSearchLimit, parsePath, resolveKnowledgeInvocationNeighbors };
1749
+ export { OM_SEARCH_HIT_KINDS, byKind, byOntology, byOwner, bySystem, formatIdsOnly, formatJson, formatKnowledgeInvocationLabel, formatKnowledgeInvocationNeighbors, formatKnowledgeResourcesList, formatKnowledgeRolesList, formatKnowledgeSystemsList, formatText, governedBy, governs, normalizeKnowledgeNodeId, parseKnowledgeSearchKinds, parseKnowledgeSearchLimit, parsePath, resolveKnowledgeInvocationNeighbors };
1749
1750
  export type { KnowledgeInvocationNeighborsResult, KnowledgeInvocationSource, KnowledgeJsonEnvelope, KnowledgeMount, OmSearchHitKind, ParsedKnowledgePath };
@@ -140,6 +140,22 @@ function bySystem(graph, systemId, knowledgeNodes) {
140
140
  }
141
141
  return knowledgeNodes.filter((n) => matchingOmIds.has(n.id));
142
142
  }
143
+ function byOntology(graph, ontologyId, knowledgeNodes) {
144
+ const targetGraphNodeId = toTargetGraphNodeId(ontologyId);
145
+ const governingKnowledgeNodeIds = /* @__PURE__ */ new Set();
146
+ for (const edge of graph.edges) {
147
+ if (edge.kind === "governs" && edge.targetId === targetGraphNodeId && edge.sourceId.startsWith("knowledge:")) {
148
+ governingKnowledgeNodeIds.add(edge.sourceId);
149
+ }
150
+ }
151
+ const sourceIdMap = buildKnowledgeSourceIdMap(graph);
152
+ const matchingOmIds = /* @__PURE__ */ new Set();
153
+ for (const graphNodeId of governingKnowledgeNodeIds) {
154
+ const omId = sourceIdMap.get(graphNodeId);
155
+ if (omId) matchingOmIds.add(omId);
156
+ }
157
+ return knowledgeNodes.filter((n) => matchingOmIds.has(n.id));
158
+ }
143
159
  function byKind(_graph, kind, knowledgeNodes) {
144
160
  return knowledgeNodes.filter((n) => n.kind === kind);
145
161
  }
@@ -433,4 +449,4 @@ function formatKnowledgeInvocationNeighbors(result) {
433
449
  return lines.join("\n");
434
450
  }
435
451
 
436
- export { OM_SEARCH_HIT_KINDS, byKind, byOwner, bySystem, formatIdsOnly, formatJson, formatKnowledgeInvocationLabel, formatKnowledgeInvocationNeighbors, formatKnowledgeResourcesList, formatKnowledgeRolesList, formatKnowledgeSystemsList, formatText, governedBy, governs, normalizeKnowledgeNodeId, parseKnowledgeSearchKinds, parseKnowledgeSearchLimit, parsePath, resolveKnowledgeInvocationNeighbors };
452
+ export { OM_SEARCH_HIT_KINDS, byKind, byOntology, byOwner, bySystem, formatIdsOnly, formatJson, formatKnowledgeInvocationLabel, formatKnowledgeInvocationNeighbors, formatKnowledgeResourcesList, formatKnowledgeRolesList, formatKnowledgeSystemsList, formatText, governedBy, governs, normalizeKnowledgeNodeId, parseKnowledgeSearchKinds, parseKnowledgeSearchLimit, parsePath, resolveKnowledgeInvocationNeighbors };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevasis/core",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "license": "MIT",
5
5
  "description": "Minimal shared constants across Elevasis monorepo",
6
6
  "sideEffects": false,
@@ -45,8 +45,8 @@
45
45
  "rollup-plugin-dts": "^6.3.0",
46
46
  "tsup": "^8.0.0",
47
47
  "typescript": "5.9.2",
48
- "@repo/eslint-config": "0.0.0",
49
- "@repo/typescript-config": "0.0.0"
48
+ "@repo/typescript-config": "0.0.0",
49
+ "@repo/eslint-config": "0.0.0"
50
50
  },
51
51
  "dependencies": {
52
52
  "@anthropic-ai/sdk": "^0.62.0",
@@ -1,6 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import { bySystem, byOntology, byKind, byOwner, governs, governedBy, parsePath, omSearch, omDescribe } from '../queries'
3
3
  import { byOntology as publicByOntology } from '../index'
4
+ import { byOntology as publishedByOntology } from '../published'
4
5
  import { formatText, formatJson, formatIdsOnly, formatOmSearchHits, formatOmDescribe } from '../format'
5
6
  import type { OrganizationGraph } from '../../organization-model/graph/types'
6
7
  import type { OrgKnowledgeNode } from '../../organization-model/domains/knowledge'
@@ -259,6 +260,13 @@ describe('byOntology', () => {
259
260
  'knowledge.playbook-d'
260
261
  ])
261
262
  })
263
+
264
+ it('is exported from the published knowledge API', () => {
265
+ expect(publishedByOntology).toBe(byOntology)
266
+ expect(publishedByOntology(GRAPH, 'sales.crm:object/deal', NODES).map((node) => node.id)).toEqual([
267
+ 'knowledge.playbook-d'
268
+ ])
269
+ })
262
270
  })
263
271
 
264
272
  // ---------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- export { bySystem, byKind, byOwner, governs, governedBy, parsePath } from './queries'
1
+ export { bySystem, byOntology, byKind, byOwner, governs, governedBy, parsePath } from './queries'
2
2
  export type { KnowledgeMount, ParsedKnowledgePath, OmSearchHitKind } from './queries'
3
3
 
4
4
  export { formatText, formatJson, formatIdsOnly } from './format'