@elevasis/core 0.24.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +239 -86
- package/dist/index.js +474 -1346
- package/dist/knowledge/index.d.ts +57 -39
- package/dist/knowledge/index.js +1 -1
- package/dist/organization-model/index.d.ts +239 -86
- package/dist/organization-model/index.js +474 -1346
- package/dist/test-utils/index.d.ts +24 -31
- package/dist/test-utils/index.js +76 -1238
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +108 -96
- package/src/business/acquisition/api-schemas.test.ts +70 -77
- package/src/business/acquisition/api-schemas.ts +21 -42
- package/src/business/acquisition/derive-actions.test.ts +11 -21
- package/src/business/acquisition/derive-actions.ts +61 -14
- package/src/business/acquisition/ontology-validation.ts +4 -4
- package/src/business/acquisition/types.ts +7 -8
- package/src/execution/engine/llm/adapters/__tests__/openrouter.integration.test.ts +10 -10
- package/src/knowledge/__tests__/queries.test.ts +960 -546
- package/src/knowledge/format.ts +322 -100
- package/src/knowledge/index.ts +18 -5
- package/src/knowledge/queries.ts +1004 -240
- package/src/organization-model/__tests__/content-kinds-registry.test.ts +35 -210
- package/src/organization-model/__tests__/defaults.test.ts +4 -4
- package/src/organization-model/__tests__/deprecate-helpers.test.ts +71 -0
- package/src/organization-model/__tests__/domains/actions.test.ts +12 -36
- package/src/organization-model/__tests__/domains/offerings.test.ts +13 -6
- package/src/organization-model/__tests__/domains/resources.test.ts +497 -350
- package/src/organization-model/__tests__/domains/systems.test.ts +6 -7
- package/src/organization-model/__tests__/flatten-additive-merge.test.ts +68 -80
- package/src/organization-model/__tests__/foundation.test.ts +81 -14
- package/src/organization-model/__tests__/graph.test.ts +662 -694
- package/src/organization-model/__tests__/knowledge.test.ts +31 -17
- package/src/organization-model/__tests__/lookup-helpers.test.ts +128 -438
- package/src/organization-model/__tests__/migration-helpers.test.ts +362 -591
- package/src/organization-model/__tests__/prospecting-ssot.test.ts +68 -103
- package/src/organization-model/__tests__/published-zero-leak.test.ts +17 -0
- package/src/organization-model/__tests__/recursive-system-schema.test.ts +159 -532
- package/src/organization-model/__tests__/resolve.test.ts +88 -49
- package/src/organization-model/__tests__/scaffolders.test.ts +93 -0
- package/src/organization-model/__tests__/schema.test.ts +65 -56
- package/src/organization-model/catalogs/lead-gen.ts +0 -103
- package/src/organization-model/defaults.ts +17 -702
- package/src/organization-model/domains/actions.ts +116 -333
- package/src/organization-model/domains/knowledge.ts +15 -7
- package/src/organization-model/domains/projects.ts +4 -4
- package/src/organization-model/domains/prospecting.ts +405 -395
- package/src/organization-model/domains/resources.ts +206 -135
- package/src/organization-model/domains/sales.ts +5 -5
- package/src/organization-model/domains/systems.ts +8 -23
- package/src/organization-model/graph/build.ts +223 -294
- package/src/organization-model/graph/schema.ts +2 -3
- package/src/organization-model/graph/types.ts +12 -14
- package/src/organization-model/helpers.ts +120 -141
- package/src/organization-model/icons.ts +1 -0
- package/src/organization-model/index.ts +107 -126
- package/src/organization-model/migration-helpers.ts +211 -249
- package/src/organization-model/ontology.ts +0 -60
- package/src/organization-model/organization-graph.mdx +4 -5
- package/src/organization-model/organization-model.mdx +1 -1
- package/src/organization-model/published.ts +251 -228
- package/src/organization-model/resolve.ts +4 -5
- package/src/organization-model/scaffolders/helpers.ts +84 -0
- package/src/organization-model/scaffolders/index.ts +19 -0
- package/src/organization-model/scaffolders/scaffoldKnowledgeNode.ts +48 -0
- package/src/organization-model/scaffolders/scaffoldOntologyRecord.ts +38 -0
- package/src/organization-model/scaffolders/scaffoldResource.ts +59 -0
- package/src/organization-model/scaffolders/scaffoldSystem.ts +110 -0
- package/src/organization-model/scaffolders/types.ts +81 -0
- package/src/organization-model/schema.ts +610 -704
- package/src/organization-model/types.ts +167 -161
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/__tests__/validation.test.ts +23 -0
- package/src/platform/registry/validation.ts +13 -2
- package/src/reference/_generated/contracts.md +108 -96
- package/src/reference/glossary.md +71 -69
- package/src/organization-model/content-kinds/config.ts +0 -36
- package/src/organization-model/content-kinds/index.ts +0 -78
- package/src/organization-model/content-kinds/pipeline.ts +0 -68
- package/src/organization-model/content-kinds/registry.ts +0 -44
- package/src/organization-model/content-kinds/status.ts +0 -71
- package/src/organization-model/content-kinds/template.ts +0 -83
- package/src/organization-model/content-kinds/types.ts +0 -117
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { CRM_ACTION_ENTRIES } from '@repo/core/organization-model'
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
3
2
|
import type { AcqDealRow } from './types'
|
|
4
3
|
import type { Action, ActionDef } from './derive-actions'
|
|
5
4
|
import { DEFAULT_CRM_ACTIONS, SendReplyActionPayloadSchema, deriveActions } from './derive-actions'
|
|
6
|
-
import { getCrmActionMetadata } from './ontology-validation'
|
|
7
5
|
|
|
8
6
|
// ---------------------------------------------------------------------------
|
|
9
7
|
// Fixture builder
|
|
@@ -96,28 +94,20 @@ describe('DEFAULT_CRM_ACTIONS static contract', () => {
|
|
|
96
94
|
expect(unique.size).toBe(keys.length)
|
|
97
95
|
})
|
|
98
96
|
|
|
99
|
-
it('derives promoted CRM runtime metadata from
|
|
97
|
+
it('derives promoted CRM runtime metadata from the local runtime contract', () => {
|
|
100
98
|
const sendReply = DEFAULT_CRM_ACTIONS.find((a) => a.key === 'send_reply')
|
|
101
|
-
const metadata = CRM_ACTION_ENTRIES['send_reply']
|
|
102
|
-
const ontologyMetadata = getCrmActionMetadata('send_reply')
|
|
103
99
|
|
|
104
100
|
expect(sendReply).toBeDefined()
|
|
105
|
-
expect(sendReply?.
|
|
106
|
-
expect(sendReply?.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
expect(sendReply?.label).toBe('Send Reply')
|
|
102
|
+
expect(sendReply?.workflowId).toBe('crm-send-reply-workflow')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('keeps mark_no_show as a runtime-only CRM action', () => {
|
|
106
|
+
const markNoShow = DEFAULT_CRM_ACTIONS.find((a) => a.key === 'mark_no_show')
|
|
107
|
+
|
|
108
|
+
expect(markNoShow).toBeDefined()
|
|
109
|
+
expect(markNoShow?.workflowId).toBe('mark_no_show-workflow')
|
|
113
110
|
})
|
|
114
|
-
|
|
115
|
-
it('keeps mark_no_show as a runtime-only CRM action', () => {
|
|
116
|
-
const markNoShow = DEFAULT_CRM_ACTIONS.find((a) => a.key === 'mark_no_show')
|
|
117
|
-
|
|
118
|
-
expect(markNoShow).toBeDefined()
|
|
119
|
-
expect(CRM_ACTION_ENTRIES['mark_no_show']).toBeUndefined()
|
|
120
|
-
})
|
|
121
111
|
})
|
|
122
112
|
|
|
123
113
|
// ---------------------------------------------------------------------------
|
|
@@ -4,9 +4,8 @@ import {
|
|
|
4
4
|
CRM_DISCOVERY_LINK_SENT_STATE,
|
|
5
5
|
CRM_DISCOVERY_NUDGING_STATE,
|
|
6
6
|
CRM_DISCOVERY_REPLIED_STATE
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../organization-model/domains/sales'
|
|
8
8
|
import { getDealOwnership, type DealOwnership } from './deal-ownership'
|
|
9
|
-
import { getCrmActionMetadata } from './ontology-validation'
|
|
10
9
|
import type { AcqDealRow } from './types'
|
|
11
10
|
|
|
12
11
|
export interface Action {
|
|
@@ -34,21 +33,69 @@ export const SendReplyActionPayloadSchema = z
|
|
|
34
33
|
})
|
|
35
34
|
.strict()
|
|
36
35
|
|
|
37
|
-
type CrmActionRuntimeDef = Pick<ActionDef, 'isAvailableFor' | 'payloadSchema'>
|
|
38
|
-
|
|
36
|
+
type CrmActionRuntimeDef = Pick<ActionDef, 'isAvailableFor' | 'payloadSchema'>
|
|
37
|
+
|
|
38
|
+
const CRM_RUNTIME_ACTION_METADATA: Record<string, Pick<ActionDef, 'key' | 'label' | 'workflowId'>> = {
|
|
39
|
+
move_to_proposal: {
|
|
40
|
+
key: 'move_to_proposal',
|
|
41
|
+
label: 'Move to Proposal',
|
|
42
|
+
workflowId: 'move_to_proposal-workflow'
|
|
43
|
+
},
|
|
44
|
+
move_to_closing: {
|
|
45
|
+
key: 'move_to_closing',
|
|
46
|
+
label: 'Move to Closing',
|
|
47
|
+
workflowId: 'move_to_closing-workflow'
|
|
48
|
+
},
|
|
49
|
+
move_to_closed_won: {
|
|
50
|
+
key: 'move_to_closed_won',
|
|
51
|
+
label: 'Close Won',
|
|
52
|
+
workflowId: 'move_to_closed_won-workflow'
|
|
53
|
+
},
|
|
54
|
+
move_to_closed_lost: {
|
|
55
|
+
key: 'move_to_closed_lost',
|
|
56
|
+
label: 'Close Lost',
|
|
57
|
+
workflowId: 'move_to_closed_lost-workflow'
|
|
58
|
+
},
|
|
59
|
+
move_to_nurturing: {
|
|
60
|
+
key: 'move_to_nurturing',
|
|
61
|
+
label: 'Move to Nurturing',
|
|
62
|
+
workflowId: 'move_to_nurturing-workflow'
|
|
63
|
+
},
|
|
64
|
+
send_reply: {
|
|
65
|
+
key: 'send_reply',
|
|
66
|
+
label: 'Send Reply',
|
|
67
|
+
workflowId: 'crm-send-reply-workflow'
|
|
68
|
+
},
|
|
69
|
+
send_link: {
|
|
70
|
+
key: 'send_link',
|
|
71
|
+
label: 'Send Booking Link',
|
|
72
|
+
workflowId: 'crm-send-booking-link-workflow'
|
|
73
|
+
},
|
|
74
|
+
send_nudge: {
|
|
75
|
+
key: 'send_nudge',
|
|
76
|
+
label: 'Send Nudge',
|
|
77
|
+
workflowId: 'crm-send-nudge-workflow'
|
|
78
|
+
},
|
|
79
|
+
rebook: {
|
|
80
|
+
key: 'rebook',
|
|
81
|
+
label: 'Rebook',
|
|
82
|
+
workflowId: 'crm-rebook-workflow'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
39
86
|
function crmAction(actionId: string, runtime: CrmActionRuntimeDef): ActionDef {
|
|
40
|
-
const metadata =
|
|
41
|
-
if (!metadata?.
|
|
87
|
+
const metadata = CRM_RUNTIME_ACTION_METADATA[actionId]
|
|
88
|
+
if (!metadata?.workflowId) {
|
|
42
89
|
throw new Error(`CRM action metadata for "${actionId}" must define resourceId`)
|
|
43
90
|
}
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
key: metadata.
|
|
47
|
-
label: metadata.label,
|
|
48
|
-
workflowId: metadata.
|
|
49
|
-
...runtime
|
|
50
|
-
}
|
|
51
|
-
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
key: metadata.key,
|
|
94
|
+
label: metadata.label,
|
|
95
|
+
workflowId: metadata.workflowId,
|
|
96
|
+
...runtime
|
|
97
|
+
}
|
|
98
|
+
}
|
|
52
99
|
|
|
53
100
|
export const DEFAULT_CRM_ACTIONS: ActionDef[] = [
|
|
54
101
|
crmAction('move_to_proposal', {
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
import type { OrganizationModel } from '../../organization-model/types'
|
|
12
12
|
import {
|
|
13
13
|
CRM_PIPELINE_DEFINITION,
|
|
14
|
-
LEAD_GEN_STAGE_CATALOG,
|
|
15
14
|
type LeadGenStageCatalogEntry,
|
|
16
15
|
type StatefulStateDefinition
|
|
17
16
|
} from '../../organization-model/domains/sales'
|
|
17
|
+
import { getLeadGenStageCatalog } from '../../organization-model/migration-helpers'
|
|
18
18
|
|
|
19
19
|
export const CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
20
20
|
scope: 'sales.crm',
|
|
@@ -73,14 +73,14 @@ function createCrmPipelineCatalog(): OntologyCatalogType {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function createLeadGenStageCatalog(): OntologyCatalogType {
|
|
76
|
+
function createLeadGenStageCatalog(model: OrganizationModel): OntologyCatalogType {
|
|
77
77
|
return {
|
|
78
78
|
id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
|
|
79
79
|
label: 'Lead Gen Processing Stages',
|
|
80
80
|
ownerSystemId: 'sales.lead-gen',
|
|
81
81
|
kind: 'processing-stage-catalog',
|
|
82
82
|
entries: Object.fromEntries(
|
|
83
|
-
Object.entries(
|
|
83
|
+
Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
|
|
84
84
|
key,
|
|
85
85
|
{
|
|
86
86
|
...entry
|
|
@@ -103,7 +103,7 @@ function mergeBridgeCatalogs(model: OrganizationModel): OrganizationModel {
|
|
|
103
103
|
bridgeCatalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID] = createCrmPipelineCatalog()
|
|
104
104
|
}
|
|
105
105
|
if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === undefined) {
|
|
106
|
-
bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog()
|
|
106
|
+
bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if (Object.keys(bridgeCatalogTypes).length === 0) return model
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Database } from '../../supabase/database.types'
|
|
2
|
-
import type {
|
|
3
|
-
ActionRegistry,
|
|
4
|
-
CredentialRequirement,
|
|
5
|
-
RecordColumnConfig
|
|
6
|
-
} from '../../organization-model/domains/prospecting'
|
|
7
|
-
import type {
|
|
8
|
-
import type { PipelineStage, ProcessingStageStatus } from './api-schemas'
|
|
2
|
+
import type {
|
|
3
|
+
ActionRegistry,
|
|
4
|
+
CredentialRequirement,
|
|
5
|
+
RecordColumnConfig
|
|
6
|
+
} from '../../organization-model/domains/prospecting'
|
|
7
|
+
import type { PipelineStage, ProcessingStageStatus } from './api-schemas'
|
|
9
8
|
|
|
10
9
|
// =============================================================================
|
|
11
10
|
// Supabase-Generated Types (Re-exported from database.types)
|
|
@@ -55,7 +54,7 @@ export interface WebPost {
|
|
|
55
54
|
aiInsight?: string
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
export type LeadGenStageKey =
|
|
57
|
+
export type LeadGenStageKey = string
|
|
59
58
|
export type LeadGenActionKey = ActionRegistry[number]['id']
|
|
60
59
|
|
|
61
60
|
export interface ProcessingStateEntry {
|
|
@@ -20,8 +20,8 @@ import { createLLMAdapter } from '../server/adapter-factory'
|
|
|
20
20
|
import type { ModelConfig } from '../../model-info'
|
|
21
21
|
import type { LLMGenerateRequest } from '../../types'
|
|
22
22
|
|
|
23
|
-
// Skip
|
|
24
|
-
const SKIP_TESTS = !process.env.OPENROUTER_API_KEY
|
|
23
|
+
// Skip by default: real OpenRouter model behavior can change independently of this repo.
|
|
24
|
+
const SKIP_TESTS = process.env.RUN_OPENROUTER_INTEGRATION !== 'true' || !process.env.OPENROUTER_API_KEY
|
|
25
25
|
|
|
26
26
|
describe.skipIf(SKIP_TESTS)('OpenRouter Adapter Integration', () => {
|
|
27
27
|
let apiKey: string
|
|
@@ -47,14 +47,14 @@ describe.skipIf(SKIP_TESTS)('OpenRouter Adapter Integration', () => {
|
|
|
47
47
|
maxOutputTokens: 500
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
describe('
|
|
51
|
-
it('generates structured output with accurate token counts', async () => {
|
|
52
|
-
const config: ModelConfig = {
|
|
53
|
-
provider: 'openrouter',
|
|
54
|
-
model: 'openrouter/
|
|
55
|
-
apiKey,
|
|
56
|
-
temperature: 0.7,
|
|
57
|
-
maxOutputTokens: 500
|
|
50
|
+
describe('OpenRouter hosted model', () => {
|
|
51
|
+
it('generates structured output with accurate token counts', async () => {
|
|
52
|
+
const config: ModelConfig = {
|
|
53
|
+
provider: 'openrouter',
|
|
54
|
+
model: 'openrouter/z-ai/glm-5',
|
|
55
|
+
apiKey,
|
|
56
|
+
temperature: 0.7,
|
|
57
|
+
maxOutputTokens: 500
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const adapter = createLLMAdapter(config)
|