@elevasis/core 0.23.0 → 0.24.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/index.d.ts +4343 -2690
- package/dist/index.js +1101 -156
- package/dist/knowledge/index.d.ts +574 -210
- package/dist/knowledge/index.js +104 -1
- package/dist/organization-model/index.d.ts +4343 -2690
- package/dist/organization-model/index.js +1101 -156
- package/dist/test-utils/index.d.ts +483 -109
- package/dist/test-utils/index.js +904 -144
- package/package.json +3 -3
- 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 +2137 -2093
- 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 +195 -197
- 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 +387 -277
- 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__/domains/topology.test.ts +188 -0
- 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 +1312 -862
- 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 +844 -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 +42 -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 +202 -124
- 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/domains/topology.ts +261 -0
- package/src/organization-model/foundation.ts +75 -75
- package/src/organization-model/graph/build.ts +1043 -867
- 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 +75 -68
- package/src/organization-model/graph/types.ts +71 -64
- package/src/organization-model/helpers.ts +289 -241
- package/src/organization-model/icons.ts +78 -66
- package/src/organization-model/index.ts +128 -125
- package/src/organization-model/migration-helpers.ts +247 -244
- package/src/organization-model/ontology.ts +658 -0
- package/src/organization-model/organization-graph.mdx +110 -90
- package/src/organization-model/organization-model.mdx +225 -213
- package/src/organization-model/published.ts +299 -222
- package/src/organization-model/resolve.ts +146 -91
- package/src/organization-model/schema.ts +818 -659
- package/src/organization-model/surface-projection.ts +212 -212
- package/src/organization-model/types.ts +179 -155
- 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 +1444 -1259
- 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 +886 -886
- 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 +876 -684
- 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 +2136 -2093
- 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 +3 -0
- 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
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { bySystem, byKind, byOwner, governs, governedBy, parsePath } from '../queries'
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{ id: '
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { bySystem, byOntology, byKind, byOwner, governs, governedBy, parsePath } from '../queries'
|
|
3
|
+
import { byOntology as publicByOntology } from '../index'
|
|
4
|
+
import { formatText, formatJson, formatIdsOnly } from '../format'
|
|
5
|
+
import type { OrganizationGraph } from '../../organization-model/graph/types'
|
|
6
|
+
import type { OrgKnowledgeNode } from '../../organization-model/domains/knowledge'
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Synthetic fixtures
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Three knowledge nodes covering all three kinds.
|
|
14
|
+
* - playbook-a governs system:sales.crm and system:sales.lead-gen
|
|
15
|
+
* - strategy-b governs system:sales.lead-gen
|
|
16
|
+
* - reference-c has no links (no governs edges)
|
|
17
|
+
* - playbook-d is owned by "role.ops-lead"
|
|
18
|
+
*/
|
|
19
|
+
const NODES: OrgKnowledgeNode[] = [
|
|
20
|
+
{
|
|
21
|
+
id: 'knowledge.playbook-a',
|
|
22
|
+
kind: 'playbook',
|
|
23
|
+
title: 'Playbook A',
|
|
24
|
+
summary: 'Playbook A summary.',
|
|
25
|
+
body: '## Playbook A\n\nContent.',
|
|
26
|
+
links: [{ nodeId: 'system:sales.crm' }, { nodeId: 'system:sales.lead-gen' }],
|
|
27
|
+
ownerIds: [],
|
|
28
|
+
updatedAt: '2026-01-01'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'knowledge.strategy-b',
|
|
32
|
+
kind: 'strategy',
|
|
33
|
+
title: 'Strategy B',
|
|
34
|
+
summary: 'Strategy B summary.',
|
|
35
|
+
body: '## Strategy B\n\nContent.',
|
|
36
|
+
links: [{ nodeId: 'system:sales.lead-gen' }],
|
|
37
|
+
ownerIds: ['role.ops-lead'],
|
|
38
|
+
updatedAt: '2026-01-02'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'knowledge.reference-c',
|
|
42
|
+
kind: 'reference',
|
|
43
|
+
title: 'Reference C',
|
|
44
|
+
summary: 'Reference C summary.',
|
|
45
|
+
body: '## Reference C\n\nContent.',
|
|
46
|
+
links: [],
|
|
47
|
+
ownerIds: [],
|
|
48
|
+
updatedAt: '2026-01-03'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'knowledge.playbook-d',
|
|
52
|
+
kind: 'playbook',
|
|
53
|
+
title: 'Playbook D',
|
|
54
|
+
summary: 'Playbook D summary.',
|
|
55
|
+
body: '## Playbook D\n\nContent.',
|
|
56
|
+
links: [],
|
|
57
|
+
ownerIds: ['role.ops-lead', 'role.ceo'],
|
|
58
|
+
updatedAt: '2026-01-04'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Minimal synthetic OrganizationGraph derived from the above nodes.
|
|
64
|
+
* Graph node IDs follow the convention: `knowledge:<om-node-id>`
|
|
65
|
+
*/
|
|
66
|
+
const GRAPH: OrganizationGraph = {
|
|
67
|
+
version: 1,
|
|
68
|
+
organizationModelVersion: 1,
|
|
69
|
+
nodes: [
|
|
70
|
+
{ id: 'organization-model', kind: 'organization', label: 'Organization Model' },
|
|
71
|
+
{ id: 'system:sales.crm', kind: 'system', label: 'CRM', sourceId: 'sales.crm', systemId: 'sales.crm' },
|
|
71
72
|
{
|
|
72
73
|
id: 'system:sales.lead-gen',
|
|
73
74
|
kind: 'system',
|
|
@@ -76,23 +77,29 @@ const GRAPH: OrganizationGraph = {
|
|
|
76
77
|
systemId: 'sales.lead-gen'
|
|
77
78
|
},
|
|
78
79
|
{
|
|
79
|
-
id: '
|
|
80
|
-
kind: '
|
|
81
|
-
label: '
|
|
82
|
-
sourceId: '
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: 'knowledge:knowledge.strategy-b',
|
|
86
|
-
kind: 'knowledge',
|
|
87
|
-
label: 'Strategy B',
|
|
88
|
-
sourceId: 'knowledge.strategy-b'
|
|
80
|
+
id: 'ontology:sales.crm:object/deal',
|
|
81
|
+
kind: 'ontology',
|
|
82
|
+
label: 'Deal',
|
|
83
|
+
sourceId: 'sales.crm:object/deal'
|
|
89
84
|
},
|
|
90
85
|
{
|
|
91
|
-
id: 'knowledge:knowledge.
|
|
86
|
+
id: 'knowledge:knowledge.playbook-a',
|
|
92
87
|
kind: 'knowledge',
|
|
93
|
-
label: '
|
|
94
|
-
sourceId: 'knowledge.
|
|
95
|
-
},
|
|
88
|
+
label: 'Playbook A',
|
|
89
|
+
sourceId: 'knowledge.playbook-a'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'knowledge:knowledge.strategy-b',
|
|
93
|
+
kind: 'knowledge',
|
|
94
|
+
label: 'Strategy B',
|
|
95
|
+
sourceId: 'knowledge.strategy-b'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'knowledge:knowledge.reference-c',
|
|
99
|
+
kind: 'knowledge',
|
|
100
|
+
label: 'Reference C',
|
|
101
|
+
sourceId: 'knowledge.reference-c'
|
|
102
|
+
},
|
|
96
103
|
{
|
|
97
104
|
id: 'knowledge:knowledge.playbook-d',
|
|
98
105
|
kind: 'knowledge',
|
|
@@ -100,495 +107,579 @@ const GRAPH: OrganizationGraph = {
|
|
|
100
107
|
sourceId: 'knowledge.playbook-d'
|
|
101
108
|
}
|
|
102
109
|
],
|
|
103
|
-
edges: [
|
|
104
|
-
// contains edges (organization -> knowledge nodes)
|
|
105
|
-
{
|
|
106
|
-
id: 'edge:contains:organization-model:knowledge:knowledge.playbook-a',
|
|
107
|
-
kind: 'contains',
|
|
108
|
-
sourceId: 'organization-model',
|
|
109
|
-
targetId: 'knowledge:knowledge.playbook-a'
|
|
110
|
-
},
|
|
110
|
+
edges: [
|
|
111
|
+
// contains edges (organization -> knowledge nodes)
|
|
112
|
+
{
|
|
113
|
+
id: 'edge:contains:organization-model:knowledge:knowledge.playbook-a',
|
|
114
|
+
kind: 'contains',
|
|
115
|
+
sourceId: 'organization-model',
|
|
116
|
+
targetId: 'knowledge:knowledge.playbook-a'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'edge:contains:organization-model:knowledge:knowledge.strategy-b',
|
|
120
|
+
kind: 'contains',
|
|
121
|
+
sourceId: 'organization-model',
|
|
122
|
+
targetId: 'knowledge:knowledge.strategy-b'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'edge:contains:organization-model:knowledge:knowledge.reference-c',
|
|
126
|
+
kind: 'contains',
|
|
127
|
+
sourceId: 'organization-model',
|
|
128
|
+
targetId: 'knowledge:knowledge.reference-c'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'edge:contains:organization-model:knowledge:knowledge.playbook-d',
|
|
132
|
+
kind: 'contains',
|
|
133
|
+
sourceId: 'organization-model',
|
|
134
|
+
targetId: 'knowledge:knowledge.playbook-d'
|
|
135
|
+
},
|
|
136
|
+
// governs edges
|
|
137
|
+
{
|
|
138
|
+
id: 'edge:governs:knowledge:knowledge.playbook-a:system:sales.crm',
|
|
139
|
+
kind: 'governs',
|
|
140
|
+
sourceId: 'knowledge:knowledge.playbook-a',
|
|
141
|
+
targetId: 'system:sales.crm'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'edge:governs:knowledge:knowledge.playbook-a:system:sales.lead-gen',
|
|
145
|
+
kind: 'governs',
|
|
146
|
+
sourceId: 'knowledge:knowledge.playbook-a',
|
|
147
|
+
targetId: 'system:sales.lead-gen'
|
|
148
|
+
},
|
|
111
149
|
{
|
|
112
|
-
id: 'edge:
|
|
113
|
-
kind: 'contains',
|
|
114
|
-
sourceId: 'organization-model',
|
|
115
|
-
targetId: 'knowledge:knowledge.strategy-b'
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: 'edge:contains:organization-model:knowledge:knowledge.reference-c',
|
|
119
|
-
kind: 'contains',
|
|
120
|
-
sourceId: 'organization-model',
|
|
121
|
-
targetId: 'knowledge:knowledge.reference-c'
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: 'edge:contains:organization-model:knowledge:knowledge.playbook-d',
|
|
125
|
-
kind: 'contains',
|
|
126
|
-
sourceId: 'organization-model',
|
|
127
|
-
targetId: 'knowledge:knowledge.playbook-d'
|
|
128
|
-
},
|
|
129
|
-
// governs edges
|
|
130
|
-
{
|
|
131
|
-
id: 'edge:governs:knowledge:knowledge.playbook-a:system:sales.crm',
|
|
132
|
-
kind: 'governs',
|
|
133
|
-
sourceId: 'knowledge:knowledge.playbook-a',
|
|
134
|
-
targetId: 'system:sales.crm'
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
id: 'edge:governs:knowledge:knowledge.playbook-a:system:sales.lead-gen',
|
|
150
|
+
id: 'edge:governs:knowledge:knowledge.strategy-b:system:sales.lead-gen',
|
|
138
151
|
kind: 'governs',
|
|
139
|
-
sourceId: 'knowledge:knowledge.
|
|
152
|
+
sourceId: 'knowledge:knowledge.strategy-b',
|
|
140
153
|
targetId: 'system:sales.lead-gen'
|
|
141
154
|
},
|
|
142
155
|
{
|
|
143
|
-
id: 'edge:governs:knowledge:knowledge.
|
|
156
|
+
id: 'edge:governs:knowledge:knowledge.playbook-d:ontology:sales.crm:object/deal',
|
|
144
157
|
kind: 'governs',
|
|
145
|
-
sourceId: 'knowledge:knowledge.
|
|
146
|
-
targetId: '
|
|
158
|
+
sourceId: 'knowledge:knowledge.playbook-d',
|
|
159
|
+
targetId: 'ontology:sales.crm:object/deal'
|
|
147
160
|
}
|
|
148
161
|
]
|
|
149
162
|
}
|
|
150
|
-
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
// bySystem
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
|
-
|
|
163
|
+
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
// bySystem
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
|
|
155
168
|
describe('bySystem', () => {
|
|
156
|
-
it('returns nodes that have governs edges to the given system', () => {
|
|
157
|
-
const result = bySystem(GRAPH, 'sales.crm', NODES)
|
|
158
|
-
expect(result).toHaveLength(1)
|
|
159
|
-
expect(result[0].id).toBe('knowledge.playbook-a')
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('returns multiple nodes when multiple knowledge nodes govern the same system', () => {
|
|
163
|
-
const result = bySystem(GRAPH, 'sales.lead-gen', NODES)
|
|
164
|
-
const ids = result.map((n) => n.id).sort()
|
|
165
|
-
expect(ids).toEqual(['knowledge.playbook-a', 'knowledge.strategy-b'].sort())
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('returns empty array when no node governs the system', () => {
|
|
169
|
-
const result = bySystem(GRAPH, 'system.does-not-exist', NODES)
|
|
170
|
-
expect(result).toHaveLength(0)
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('returns full OrgKnowledgeNode objects (not just graph stubs)', () => {
|
|
174
|
-
const result = bySystem(GRAPH, 'sales.crm', NODES)
|
|
175
|
-
expect(result[0].body).toBeDefined()
|
|
176
|
-
expect(result[0].links).toBeDefined()
|
|
177
|
-
expect(result[0].ownerIds).toBeDefined()
|
|
169
|
+
it('returns nodes that have governs edges to the given system', () => {
|
|
170
|
+
const result = bySystem(GRAPH, 'sales.crm', NODES)
|
|
171
|
+
expect(result).toHaveLength(1)
|
|
172
|
+
expect(result[0].id).toBe('knowledge.playbook-a')
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('returns multiple nodes when multiple knowledge nodes govern the same system', () => {
|
|
176
|
+
const result = bySystem(GRAPH, 'sales.lead-gen', NODES)
|
|
177
|
+
const ids = result.map((n) => n.id).sort()
|
|
178
|
+
expect(ids).toEqual(['knowledge.playbook-a', 'knowledge.strategy-b'].sort())
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('returns empty array when no node governs the system', () => {
|
|
182
|
+
const result = bySystem(GRAPH, 'system.does-not-exist', NODES)
|
|
183
|
+
expect(result).toHaveLength(0)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('returns full OrgKnowledgeNode objects (not just graph stubs)', () => {
|
|
187
|
+
const result = bySystem(GRAPH, 'sales.crm', NODES)
|
|
188
|
+
expect(result[0].body).toBeDefined()
|
|
189
|
+
expect(result[0].links).toBeDefined()
|
|
190
|
+
expect(result[0].ownerIds).toBeDefined()
|
|
178
191
|
})
|
|
179
192
|
})
|
|
180
193
|
|
|
181
194
|
// ---------------------------------------------------------------------------
|
|
182
|
-
//
|
|
195
|
+
// byOntology
|
|
183
196
|
// ---------------------------------------------------------------------------
|
|
184
197
|
|
|
185
|
-
describe('
|
|
186
|
-
it('returns
|
|
187
|
-
const result =
|
|
188
|
-
expect(result).
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
describe('byOntology', () => {
|
|
199
|
+
it('returns nodes that have governs edges to the given ontology id', () => {
|
|
200
|
+
const result = byOntology(GRAPH, 'sales.crm:object/deal', NODES)
|
|
201
|
+
expect(result.map((node) => node.id)).toEqual(['knowledge.playbook-d'])
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('accepts an ontology graph node id', () => {
|
|
205
|
+
const result = byOntology(GRAPH, 'ontology:sales.crm:object/deal', NODES)
|
|
206
|
+
expect(result.map((node) => node.id)).toEqual(['knowledge.playbook-d'])
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('routes raw ontology ids to ontology graph nodes instead of bridge-era system ids', () => {
|
|
210
|
+
const graph: OrganizationGraph = {
|
|
211
|
+
...GRAPH,
|
|
212
|
+
nodes: [
|
|
213
|
+
...GRAPH.nodes,
|
|
214
|
+
{
|
|
215
|
+
id: 'system:sales.crm:object/deal',
|
|
216
|
+
kind: 'system',
|
|
217
|
+
label: 'Bridge-shaped System',
|
|
218
|
+
sourceId: 'sales.crm:object/deal',
|
|
219
|
+
systemId: 'sales.crm:object/deal'
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: 'knowledge:knowledge.system-shaped',
|
|
223
|
+
kind: 'knowledge',
|
|
224
|
+
label: 'System Shaped',
|
|
225
|
+
sourceId: 'knowledge.system-shaped'
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
edges: [
|
|
229
|
+
...GRAPH.edges,
|
|
230
|
+
{
|
|
231
|
+
id: 'edge:governs:knowledge:knowledge.system-shaped:system:sales.crm:object/deal',
|
|
232
|
+
kind: 'governs',
|
|
233
|
+
sourceId: 'knowledge:knowledge.system-shaped',
|
|
234
|
+
targetId: 'system:sales.crm:object/deal'
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
const nodes: OrgKnowledgeNode[] = [
|
|
239
|
+
...NODES,
|
|
240
|
+
{
|
|
241
|
+
id: 'knowledge.system-shaped',
|
|
242
|
+
kind: 'reference',
|
|
243
|
+
title: 'System Shaped',
|
|
244
|
+
summary: 'Should not match raw ontology lookup.',
|
|
245
|
+
body: 'Body.',
|
|
246
|
+
links: [{ nodeId: 'system:sales.crm:object/deal' }],
|
|
247
|
+
ownerIds: [],
|
|
248
|
+
updatedAt: '2026-05-14'
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
|
|
252
|
+
expect(byOntology(graph, 'sales.crm:object/deal', nodes).map((node) => node.id)).toEqual([
|
|
253
|
+
'knowledge.playbook-d'
|
|
254
|
+
])
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
it('is exported from the public knowledge query API', () => {
|
|
258
|
+
expect(publicByOntology).toBe(byOntology)
|
|
259
|
+
expect(publicByOntology(GRAPH, 'sales.crm:object/deal', NODES).map((node) => node.id)).toEqual([
|
|
260
|
+
'knowledge.playbook-d'
|
|
261
|
+
])
|
|
207
262
|
})
|
|
208
263
|
})
|
|
209
264
|
|
|
210
265
|
// ---------------------------------------------------------------------------
|
|
211
|
-
//
|
|
212
|
-
// ---------------------------------------------------------------------------
|
|
213
|
-
|
|
214
|
-
describe('
|
|
215
|
-
it('returns
|
|
216
|
-
const result =
|
|
217
|
-
|
|
218
|
-
expect(
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
it('returns nodes
|
|
222
|
-
const result =
|
|
223
|
-
expect(result).toHaveLength(1)
|
|
224
|
-
expect(result[0].id).toBe('knowledge.
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
it('returns
|
|
228
|
-
const result =
|
|
229
|
-
expect(result).toHaveLength(
|
|
230
|
-
|
|
266
|
+
// byKind
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
|
|
269
|
+
describe('byKind', () => {
|
|
270
|
+
it('returns all playbook nodes', () => {
|
|
271
|
+
const result = byKind(GRAPH, 'playbook', NODES)
|
|
272
|
+
expect(result).toHaveLength(2)
|
|
273
|
+
expect(result.every((n) => n.kind === 'playbook')).toBe(true)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it('returns strategy nodes', () => {
|
|
277
|
+
const result = byKind(GRAPH, 'strategy', NODES)
|
|
278
|
+
expect(result).toHaveLength(1)
|
|
279
|
+
expect(result[0].id).toBe('knowledge.strategy-b')
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
it('returns reference nodes', () => {
|
|
283
|
+
const result = byKind(GRAPH, 'reference', NODES)
|
|
284
|
+
expect(result).toHaveLength(1)
|
|
285
|
+
expect(result[0].id).toBe('knowledge.reference-c')
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it('returns empty array when no nodes match the kind', () => {
|
|
289
|
+
const result = byKind(GRAPH, 'playbook', [])
|
|
290
|
+
expect(result).toHaveLength(0)
|
|
291
|
+
})
|
|
231
292
|
})
|
|
232
293
|
|
|
233
294
|
// ---------------------------------------------------------------------------
|
|
234
|
-
//
|
|
295
|
+
// byOwner
|
|
235
296
|
// ---------------------------------------------------------------------------
|
|
236
|
-
|
|
237
|
-
describe('
|
|
238
|
-
it('returns
|
|
239
|
-
const result =
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
297
|
+
|
|
298
|
+
describe('byOwner', () => {
|
|
299
|
+
it('returns nodes where ownerIds includes the given owner', () => {
|
|
300
|
+
const result = byOwner(GRAPH, 'role.ops-lead', NODES)
|
|
301
|
+
const ids = result.map((n) => n.id).sort()
|
|
302
|
+
expect(ids).toEqual(['knowledge.playbook-d', 'knowledge.strategy-b'].sort())
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('returns nodes for a second owner', () => {
|
|
306
|
+
const result = byOwner(GRAPH, 'role.ceo', NODES)
|
|
307
|
+
expect(result).toHaveLength(1)
|
|
308
|
+
expect(result[0].id).toBe('knowledge.playbook-d')
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
it('returns empty array when ownerId is not present in any node', () => {
|
|
312
|
+
const result = byOwner(GRAPH, 'role.unknown', NODES)
|
|
313
|
+
expect(result).toHaveLength(0)
|
|
314
|
+
})
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
// ---------------------------------------------------------------------------
|
|
318
|
+
// governs
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
|
|
321
|
+
describe('governs', () => {
|
|
322
|
+
it('returns target graph node IDs for outgoing governs edges (OM node id input)', () => {
|
|
323
|
+
const result = governs(GRAPH, 'knowledge.playbook-a')
|
|
324
|
+
expect(result.sort()).toEqual(['system:sales.crm', 'system:sales.lead-gen'].sort())
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
it('accepts graph node ID format input', () => {
|
|
328
|
+
const result = governs(GRAPH, 'knowledge:knowledge.playbook-a')
|
|
329
|
+
expect(result.sort()).toEqual(['system:sales.crm', 'system:sales.lead-gen'].sort())
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('returns single target for a node with one link', () => {
|
|
333
|
+
const result = governs(GRAPH, 'knowledge.strategy-b')
|
|
334
|
+
expect(result).toEqual(['system:sales.lead-gen'])
|
|
335
|
+
})
|
|
336
|
+
|
|
253
337
|
it('returns empty array for a node with no governs edges', () => {
|
|
254
338
|
const result = governs(GRAPH, 'knowledge.reference-c')
|
|
255
339
|
expect(result).toHaveLength(0)
|
|
256
340
|
})
|
|
257
|
-
|
|
258
|
-
it('returns empty array for an unknown nodeId', () => {
|
|
259
|
-
const result = governs(GRAPH, 'knowledge.does-not-exist')
|
|
260
|
-
expect(result).toHaveLength(0)
|
|
261
|
-
})
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
// ---------------------------------------------------------------------------
|
|
265
|
-
// governedBy
|
|
266
|
-
// ---------------------------------------------------------------------------
|
|
267
|
-
|
|
268
|
-
describe('governedBy', () => {
|
|
269
|
-
it('returns knowledge graph node IDs for incoming governs edges (prefixed system id)', () => {
|
|
270
|
-
const result = governedBy(GRAPH, 'system:sales.lead-gen')
|
|
271
|
-
const sorted = result.sort()
|
|
272
|
-
expect(sorted).toEqual(['knowledge:knowledge.playbook-a', 'knowledge:knowledge.strategy-b'].sort())
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('accepts bare system id (auto-prefixes with system:)', () => {
|
|
276
|
-
const result = governedBy(GRAPH, 'sales.crm')
|
|
277
|
-
expect(result).toEqual(['knowledge:knowledge.playbook-a'])
|
|
278
|
-
})
|
|
279
|
-
|
|
280
|
-
it('returns empty array when no knowledge node governs the target', () => {
|
|
281
|
-
const result = governedBy(GRAPH, 'system:dashboard')
|
|
282
|
-
expect(result).toHaveLength(0)
|
|
283
|
-
})
|
|
284
|
-
|
|
341
|
+
|
|
342
|
+
it('returns empty array for an unknown nodeId', () => {
|
|
343
|
+
const result = governs(GRAPH, 'knowledge.does-not-exist')
|
|
344
|
+
expect(result).toHaveLength(0)
|
|
345
|
+
})
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
// ---------------------------------------------------------------------------
|
|
349
|
+
// governedBy
|
|
350
|
+
// ---------------------------------------------------------------------------
|
|
351
|
+
|
|
352
|
+
describe('governedBy', () => {
|
|
353
|
+
it('returns knowledge graph node IDs for incoming governs edges (prefixed system id)', () => {
|
|
354
|
+
const result = governedBy(GRAPH, 'system:sales.lead-gen')
|
|
355
|
+
const sorted = result.sort()
|
|
356
|
+
expect(sorted).toEqual(['knowledge:knowledge.playbook-a', 'knowledge:knowledge.strategy-b'].sort())
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it('accepts bare system id (auto-prefixes with system:)', () => {
|
|
360
|
+
const result = governedBy(GRAPH, 'sales.crm')
|
|
361
|
+
expect(result).toEqual(['knowledge:knowledge.playbook-a'])
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
it('returns empty array when no knowledge node governs the target', () => {
|
|
365
|
+
const result = governedBy(GRAPH, 'system:dashboard')
|
|
366
|
+
expect(result).toHaveLength(0)
|
|
367
|
+
})
|
|
368
|
+
|
|
285
369
|
it('returns empty array for unknown target node id', () => {
|
|
286
370
|
const result = governedBy(GRAPH, 'system:does-not-exist')
|
|
287
371
|
expect(result).toHaveLength(0)
|
|
288
372
|
})
|
|
289
373
|
})
|
|
290
|
-
|
|
291
|
-
// ---------------------------------------------------------------------------
|
|
292
|
-
// parsePath — happy paths (all five mount axes)
|
|
293
|
-
// ---------------------------------------------------------------------------
|
|
294
|
-
|
|
295
|
-
describe('parsePath — happy paths', () => {
|
|
296
|
-
it('/by-kind/playbook → mount:by-kind args:[playbook]', () => {
|
|
297
|
-
expect(parsePath('/by-kind/playbook')).toEqual({ mount: 'by-kind', args: ['playbook'] })
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
it('/by-kind/strategy → mount:by-kind args:[strategy]', () => {
|
|
301
|
-
expect(parsePath('/by-kind/strategy')).toEqual({ mount: 'by-kind', args: ['strategy'] })
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
it('/by-system/sales.crm → mount:by-system args:[sales.crm]', () => {
|
|
305
|
-
expect(parsePath('/by-system/sales.crm')).toEqual({ mount: 'by-system', args: ['sales.crm'] })
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
it('/by-system/sales/crm (slash-delimited) → mount:by-system args:[sales/crm]', () => {
|
|
309
|
-
// systemId with slashes is joined and passed as-is for the caller to interpret
|
|
310
|
-
expect(parsePath('/by-system/sales/crm')).toEqual({ mount: 'by-system', args: ['sales/crm'] })
|
|
311
|
-
})
|
|
312
|
-
|
|
374
|
+
|
|
375
|
+
// ---------------------------------------------------------------------------
|
|
376
|
+
// parsePath — happy paths (all five mount axes)
|
|
377
|
+
// ---------------------------------------------------------------------------
|
|
378
|
+
|
|
379
|
+
describe('parsePath — happy paths', () => {
|
|
380
|
+
it('/by-kind/playbook → mount:by-kind args:[playbook]', () => {
|
|
381
|
+
expect(parsePath('/by-kind/playbook')).toEqual({ mount: 'by-kind', args: ['playbook'] })
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
it('/by-kind/strategy → mount:by-kind args:[strategy]', () => {
|
|
385
|
+
expect(parsePath('/by-kind/strategy')).toEqual({ mount: 'by-kind', args: ['strategy'] })
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
it('/by-system/sales.crm → mount:by-system args:[sales.crm]', () => {
|
|
389
|
+
expect(parsePath('/by-system/sales.crm')).toEqual({ mount: 'by-system', args: ['sales.crm'] })
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
it('/by-system/sales/crm (slash-delimited) → mount:by-system args:[sales/crm]', () => {
|
|
393
|
+
// systemId with slashes is joined and passed as-is for the caller to interpret
|
|
394
|
+
expect(parsePath('/by-system/sales/crm')).toEqual({ mount: 'by-system', args: ['sales/crm'] })
|
|
395
|
+
})
|
|
396
|
+
|
|
313
397
|
it('/by-owner/role.ops-lead → mount:by-owner args:[role.ops-lead]', () => {
|
|
314
398
|
expect(parsePath('/by-owner/role.ops-lead')).toEqual({ mount: 'by-owner', args: ['role.ops-lead'] })
|
|
315
399
|
})
|
|
316
400
|
|
|
317
|
-
it('/
|
|
318
|
-
expect(parsePath('/
|
|
319
|
-
mount: '
|
|
320
|
-
args: ['
|
|
401
|
+
it('/by-ontology/sales.crm:object/deal → mount:by-ontology args:[sales.crm:object/deal]', () => {
|
|
402
|
+
expect(parsePath('/by-ontology/sales.crm:object/deal')).toEqual({
|
|
403
|
+
mount: 'by-ontology',
|
|
404
|
+
args: ['sales.crm:object/deal']
|
|
321
405
|
})
|
|
322
406
|
})
|
|
323
407
|
|
|
324
|
-
it('/graph/knowledge.outreach-playbook/
|
|
325
|
-
expect(parsePath('/graph/knowledge.outreach-playbook/
|
|
326
|
-
mount: 'graph',
|
|
327
|
-
args: ['knowledge.outreach-playbook', '
|
|
328
|
-
})
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
it('
|
|
332
|
-
expect(parsePath('/knowledge.outreach-playbook')).toEqual({
|
|
333
|
-
mount: '
|
|
334
|
-
args: ['knowledge.outreach-playbook']
|
|
335
|
-
})
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
it('
|
|
339
|
-
expect(parsePath('/
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
//
|
|
400
|
-
//
|
|
401
|
-
it('
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
//
|
|
408
|
-
it('
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
//
|
|
427
|
-
it('
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
expect(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
expect(result.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
expect(result.
|
|
453
|
-
expect(result.args
|
|
454
|
-
})
|
|
455
|
-
|
|
456
|
-
//
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
expect(result.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
expect(
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
//
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
expect(
|
|
490
|
-
})
|
|
491
|
-
|
|
492
|
-
it('includes
|
|
493
|
-
const output = formatText([NODES[0]])
|
|
494
|
-
expect(output).toContain('
|
|
495
|
-
expect(output).toContain('
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
expect(output).toContain('
|
|
503
|
-
})
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
expect(
|
|
587
|
-
})
|
|
588
|
-
|
|
589
|
-
it('returns newline-separated
|
|
590
|
-
const output = formatIdsOnly([
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
408
|
+
it('/graph/knowledge.outreach-playbook/governs → mount:graph args:[knowledge.outreach-playbook,governs]', () => {
|
|
409
|
+
expect(parsePath('/graph/knowledge.outreach-playbook/governs')).toEqual({
|
|
410
|
+
mount: 'graph',
|
|
411
|
+
args: ['knowledge.outreach-playbook', 'governs']
|
|
412
|
+
})
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
it('/graph/knowledge.outreach-playbook/governed-by → mount:graph args:[knowledge.outreach-playbook,governed-by]', () => {
|
|
416
|
+
expect(parsePath('/graph/knowledge.outreach-playbook/governed-by')).toEqual({
|
|
417
|
+
mount: 'graph',
|
|
418
|
+
args: ['knowledge.outreach-playbook', 'governed-by']
|
|
419
|
+
})
|
|
420
|
+
})
|
|
421
|
+
|
|
422
|
+
it('/<nodeId> single segment → mount:node args:[nodeId]', () => {
|
|
423
|
+
expect(parsePath('/knowledge.outreach-playbook')).toEqual({
|
|
424
|
+
mount: 'node',
|
|
425
|
+
args: ['knowledge.outreach-playbook']
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
it('trailing slash is stripped before parsing', () => {
|
|
430
|
+
expect(parsePath('/by-kind/playbook/')).toEqual({ mount: 'by-kind', args: ['playbook'] })
|
|
431
|
+
})
|
|
432
|
+
})
|
|
433
|
+
|
|
434
|
+
// ---------------------------------------------------------------------------
|
|
435
|
+
// parsePath — invalid inputs (5+)
|
|
436
|
+
// ---------------------------------------------------------------------------
|
|
437
|
+
|
|
438
|
+
describe('parsePath — invalid inputs', () => {
|
|
439
|
+
it('throws on empty string', () => {
|
|
440
|
+
expect(() => parsePath('')).toThrow('parsePath: path must be a non-empty string')
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
it('throws when path does not start with /', () => {
|
|
444
|
+
expect(() => parsePath('by-kind/playbook')).toThrow('parsePath: path must start with "/"')
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
it('throws on bare root path "/"', () => {
|
|
448
|
+
expect(() => parsePath('/')).toThrow('parsePath: path resolves to root with no mount')
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
it('throws on /by-system with no systemId argument', () => {
|
|
452
|
+
expect(() => parsePath('/by-system')).toThrow('/by-system requires a systemId argument')
|
|
453
|
+
})
|
|
454
|
+
|
|
455
|
+
it('throws on /by-kind with no kind argument', () => {
|
|
456
|
+
expect(() => parsePath('/by-kind')).toThrow('/by-kind requires a kind argument')
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
it('throws on /by-owner with no ownerId argument', () => {
|
|
460
|
+
expect(() => parsePath('/by-owner')).toThrow('/by-owner requires an ownerId argument')
|
|
461
|
+
})
|
|
462
|
+
|
|
463
|
+
it('throws on /graph with only nodeId (missing verb)', () => {
|
|
464
|
+
expect(() => parsePath('/graph/knowledge.outreach-playbook')).toThrow('/graph requires <nodeId>/<verb>')
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
it('throws on /graph/<nodeId>/<unknown-verb>', () => {
|
|
468
|
+
expect(() => parsePath('/graph/knowledge.outreach-playbook/list')).toThrow(
|
|
469
|
+
'verb must be "governs" or "governed-by"'
|
|
470
|
+
)
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
it('throws on multi-segment path with unrecognized first segment', () => {
|
|
474
|
+
expect(() => parsePath('/unknown-mount/some-arg')).toThrow('unrecognized path pattern')
|
|
475
|
+
})
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
// ---------------------------------------------------------------------------
|
|
479
|
+
// parsePath — edge cases
|
|
480
|
+
// ---------------------------------------------------------------------------
|
|
481
|
+
|
|
482
|
+
describe('parsePath edge cases', () => {
|
|
483
|
+
// Whitespace handling — the parser does NOT trim the incoming string.
|
|
484
|
+
// A path with leading whitespace does not start with '/' so it throws.
|
|
485
|
+
it('throws on path with leading whitespace', () => {
|
|
486
|
+
expect(() => parsePath(' /by-kind/playbook')).toThrow('parsePath: path must start with "/"')
|
|
487
|
+
})
|
|
488
|
+
|
|
489
|
+
// Trailing whitespace becomes part of the last segment (not stripped).
|
|
490
|
+
// The segment is non-empty so parsing proceeds and the whitespace is
|
|
491
|
+
// included verbatim in the returned arg.
|
|
492
|
+
it('preserves trailing whitespace inside the last segment', () => {
|
|
493
|
+
const result = parsePath('/by-kind/playbook ')
|
|
494
|
+
expect(result.mount).toBe('by-kind')
|
|
495
|
+
expect(result.args[0]).toBe('playbook ')
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
// Multiple trailing slashes are all stripped (regex /\/+$/).
|
|
499
|
+
it('strips multiple trailing slashes', () => {
|
|
500
|
+
expect(parsePath('/by-kind/playbook///')).toEqual({ mount: 'by-kind', args: ['playbook'] })
|
|
501
|
+
})
|
|
502
|
+
|
|
503
|
+
// Lone-slash variants — a path of only slashes normalises to an empty
|
|
504
|
+
// segments list and must throw the root-with-no-mount error.
|
|
505
|
+
it('throws on path consisting only of slashes', () => {
|
|
506
|
+
expect(() => parsePath('///')).toThrow('parsePath: path resolves to root with no mount')
|
|
507
|
+
})
|
|
508
|
+
|
|
509
|
+
// Case sensitivity — parsePath does not normalise case.
|
|
510
|
+
// 'Playbook' (capitalised) is passed through as-is to the caller.
|
|
511
|
+
it('preserves node-id case (no case normalisation)', () => {
|
|
512
|
+
// /by-kind takes rest[0] verbatim
|
|
513
|
+
const result = parsePath('/by-kind/Playbook')
|
|
514
|
+
expect(result.args[0]).toBe('Playbook')
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
// system id: dot notation passes through unchanged.
|
|
518
|
+
it('/by-system/sales.crm preserves dot notation', () => {
|
|
519
|
+
expect(parsePath('/by-system/sales.crm')).toEqual({ mount: 'by-system', args: ['sales.crm'] })
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
// system id: slash notation joins rest segments with '/'.
|
|
523
|
+
// The parser does NOT convert slashes to dots — the caller must normalise.
|
|
524
|
+
it('/by-system/sales/crm joins segments with slash (no dot conversion)', () => {
|
|
525
|
+
const result = parsePath('/by-system/sales/crm')
|
|
526
|
+
expect(result.mount).toBe('by-system')
|
|
527
|
+
// args[0] is 'sales/crm', NOT 'sales.crm'
|
|
528
|
+
expect(result.args[0]).toBe('sales/crm')
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
// /by-kind silently ignores extra path segments beyond the kind argument.
|
|
532
|
+
it('/by-kind/playbook/extra silently uses only first kind segment', () => {
|
|
533
|
+
// First segment after 'by-kind' is taken; extra is ignored.
|
|
534
|
+
const result = parsePath('/by-kind/playbook/extra')
|
|
535
|
+
expect(result.mount).toBe('by-kind')
|
|
536
|
+
expect(result.args[0]).toBe('playbook')
|
|
537
|
+
expect(result.args).toHaveLength(1)
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
// /by-owner joins rest with '/' (same behaviour as /by-system).
|
|
541
|
+
it('/by-owner/role.ops-lead/sub joins segments with slash', () => {
|
|
542
|
+
const result = parsePath('/by-owner/role.ops-lead/sub')
|
|
543
|
+
expect(result.mount).toBe('by-owner')
|
|
544
|
+
expect(result.args[0]).toBe('role.ops-lead/sub')
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
// Graph node ID may contain a colon prefix (e.g. knowledge:knowledge.foo).
|
|
548
|
+
// The parser accepts it — the rest before the verb is joined with '/'.
|
|
549
|
+
it('/graph/<prefixed-nodeId>/governs round-trips the prefixed id', () => {
|
|
550
|
+
const result = parsePath('/graph/knowledge:knowledge.test-node/governs')
|
|
551
|
+
expect(result.mount).toBe('graph')
|
|
552
|
+
expect(result.args[0]).toBe('knowledge:knowledge.test-node')
|
|
553
|
+
expect(result.args[1]).toBe('governs')
|
|
554
|
+
})
|
|
555
|
+
|
|
556
|
+
// /graph with no arguments at all (just '/graph').
|
|
557
|
+
it('throws on /graph with no nodeId or verb', () => {
|
|
558
|
+
expect(() => parsePath('/graph')).toThrow('/graph requires <nodeId>/<verb>')
|
|
559
|
+
})
|
|
560
|
+
|
|
561
|
+
// /node mount — single-segment path works for any non-reserved first segment.
|
|
562
|
+
it('single-segment non-reserved path is treated as node mount', () => {
|
|
563
|
+
expect(parsePath('/knowledge.my-doc')).toEqual({ mount: 'node', args: ['knowledge.my-doc'] })
|
|
564
|
+
})
|
|
565
|
+
})
|
|
566
|
+
|
|
567
|
+
// ---------------------------------------------------------------------------
|
|
568
|
+
// formatText
|
|
569
|
+
// ---------------------------------------------------------------------------
|
|
570
|
+
|
|
571
|
+
describe('formatText', () => {
|
|
572
|
+
it('returns "(no results)" for empty array', () => {
|
|
573
|
+
expect(formatText([])).toBe('(no results)')
|
|
574
|
+
})
|
|
575
|
+
|
|
576
|
+
it('includes header row with KIND and ID columns', () => {
|
|
577
|
+
const output = formatText([NODES[0]])
|
|
578
|
+
expect(output).toContain('KIND')
|
|
579
|
+
expect(output).toContain('ID')
|
|
580
|
+
expect(output).toContain('TITLE')
|
|
581
|
+
})
|
|
582
|
+
|
|
583
|
+
it('includes node id and title in output', () => {
|
|
584
|
+
const output = formatText([NODES[0]])
|
|
585
|
+
expect(output).toContain('knowledge.playbook-a')
|
|
586
|
+
expect(output).toContain('Playbook A')
|
|
587
|
+
})
|
|
588
|
+
|
|
589
|
+
it('truncates long summaries', () => {
|
|
590
|
+
const longSummary = 'x'.repeat(200)
|
|
591
|
+
const node: OrgKnowledgeNode = { ...NODES[0], summary: longSummary }
|
|
592
|
+
const output = formatText([node])
|
|
593
|
+
expect(output).toContain('...')
|
|
594
|
+
})
|
|
595
|
+
})
|
|
596
|
+
|
|
597
|
+
// ---------------------------------------------------------------------------
|
|
598
|
+
// formatJson — envelope shape
|
|
599
|
+
// ---------------------------------------------------------------------------
|
|
600
|
+
|
|
601
|
+
describe('formatJson', () => {
|
|
602
|
+
it('returns a JSON string with top-level keys: path, mount, args, results', () => {
|
|
603
|
+
const raw = formatJson({
|
|
604
|
+
path: '/by-kind/playbook',
|
|
605
|
+
parsed: { mount: 'by-kind', args: ['playbook'] },
|
|
606
|
+
results: [NODES[0]]
|
|
607
|
+
})
|
|
608
|
+
const parsed = JSON.parse(raw) as Record<string, unknown>
|
|
609
|
+
expect(Object.keys(parsed).sort()).toEqual(['args', 'mount', 'path', 'results'].sort())
|
|
610
|
+
})
|
|
611
|
+
|
|
612
|
+
it('preserves path in envelope', () => {
|
|
613
|
+
const raw = formatJson({
|
|
614
|
+
path: '/by-kind/playbook',
|
|
615
|
+
parsed: { mount: 'by-kind', args: ['playbook'] },
|
|
616
|
+
results: []
|
|
617
|
+
})
|
|
618
|
+
expect(JSON.parse(raw)).toMatchObject({ path: '/by-kind/playbook' })
|
|
619
|
+
})
|
|
620
|
+
|
|
621
|
+
it('preserves mount in envelope', () => {
|
|
622
|
+
const raw = formatJson({
|
|
623
|
+
path: '/by-kind/strategy',
|
|
624
|
+
parsed: { mount: 'by-kind', args: ['strategy'] },
|
|
625
|
+
results: []
|
|
626
|
+
})
|
|
627
|
+
expect(JSON.parse(raw)).toMatchObject({ mount: 'by-kind' })
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
it('preserves args array in envelope', () => {
|
|
631
|
+
const raw = formatJson({
|
|
632
|
+
path: '/by-system/sales.crm',
|
|
633
|
+
parsed: { mount: 'by-system', args: ['sales.crm'] },
|
|
634
|
+
results: []
|
|
635
|
+
})
|
|
636
|
+
expect(JSON.parse(raw)).toMatchObject({ args: ['sales.crm'] })
|
|
637
|
+
})
|
|
638
|
+
|
|
639
|
+
it('includes results in envelope for string[] (governs/governedBy)', () => {
|
|
640
|
+
const raw = formatJson({
|
|
641
|
+
path: '/graph/knowledge.playbook-a/governs',
|
|
642
|
+
parsed: { mount: 'graph', args: ['knowledge.playbook-a', 'governs'] },
|
|
643
|
+
results: ['system:sales.crm', 'system:sales.lead-gen']
|
|
644
|
+
})
|
|
645
|
+
const parsed = JSON.parse(raw) as { results: string[] }
|
|
646
|
+
expect(parsed.results).toEqual(['system:sales.crm', 'system:sales.lead-gen'])
|
|
647
|
+
})
|
|
648
|
+
|
|
649
|
+
it('envelope is NOT flat { results } — must have path/mount/args siblings', () => {
|
|
650
|
+
const raw = formatJson({
|
|
651
|
+
path: '/by-kind/playbook',
|
|
652
|
+
parsed: { mount: 'by-kind', args: ['playbook'] },
|
|
653
|
+
results: [NODES[0]]
|
|
654
|
+
})
|
|
655
|
+
const parsed = JSON.parse(raw) as Record<string, unknown>
|
|
656
|
+
// Must NOT be flat (only results key)
|
|
657
|
+
expect(parsed).toHaveProperty('path')
|
|
658
|
+
expect(parsed).toHaveProperty('mount')
|
|
659
|
+
expect(parsed).toHaveProperty('args')
|
|
660
|
+
expect(parsed).toHaveProperty('results')
|
|
661
|
+
})
|
|
662
|
+
})
|
|
663
|
+
|
|
664
|
+
// ---------------------------------------------------------------------------
|
|
665
|
+
// formatIdsOnly
|
|
666
|
+
// ---------------------------------------------------------------------------
|
|
667
|
+
|
|
668
|
+
describe('formatIdsOnly', () => {
|
|
669
|
+
it('returns empty string for empty array', () => {
|
|
670
|
+
expect(formatIdsOnly([])).toBe('')
|
|
671
|
+
})
|
|
672
|
+
|
|
673
|
+
it('returns newline-separated ids for OrgKnowledgeNode array', () => {
|
|
674
|
+
const output = formatIdsOnly([NODES[0], NODES[1]])
|
|
675
|
+
const lines = output.split('\n')
|
|
676
|
+
expect(lines).toContain('knowledge.playbook-a')
|
|
677
|
+
expect(lines).toContain('knowledge.strategy-b')
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it('returns newline-separated strings for string[] (governs results)', () => {
|
|
681
|
+
const output = formatIdsOnly(['system:sales.crm', 'system:sales.lead-gen'])
|
|
682
|
+
expect(output).toBe('system:sales.crm\nsystem:sales.lead-gen')
|
|
683
|
+
})
|
|
684
|
+
})
|
|
594
685
|
|