@elevasis/core 0.5.0 → 0.6.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 +427 -42
- package/dist/index.js +589 -47
- package/dist/organization-model/index.d.ts +427 -42
- package/dist/organization-model/index.js +589 -47
- package/package.json +3 -3
- package/src/__tests__/template-foundations-compatibility.test.ts +2 -2
- package/src/business/acquisition/types.ts +2 -0
- package/src/commands/queue/types/task.ts +3 -3
- package/src/execution/engine/index.ts +8 -0
- package/src/execution/engine/tools/registry.ts +26 -24
- package/src/execution/engine/tools/tool-maps.ts +13 -9
- package/src/execution/engine/workflow/types.ts +2 -3
- package/src/organization-model/README.md +16 -12
- package/src/organization-model/__tests__/defaults.test.ts +175 -0
- package/src/organization-model/__tests__/domains/customers.test.ts +295 -0
- package/src/organization-model/__tests__/domains/goals.test.ts +479 -0
- package/src/organization-model/__tests__/domains/identity.test.ts +278 -0
- package/src/organization-model/__tests__/domains/navigation.test.ts +212 -0
- package/src/organization-model/__tests__/domains/offerings.test.ts +419 -0
- package/src/organization-model/__tests__/domains/operations.test.ts +203 -0
- package/src/organization-model/__tests__/domains/resource-mappings.test.ts +362 -0
- package/src/organization-model/__tests__/domains/roles.test.ts +347 -0
- package/src/organization-model/__tests__/domains/statuses.test.ts +243 -0
- package/src/organization-model/__tests__/foundation.test.ts +3 -3
- package/src/organization-model/__tests__/resolve.test.ts +447 -3
- package/src/organization-model/__tests__/schema.test.ts +407 -0
- package/src/organization-model/contracts.ts +5 -5
- package/src/organization-model/defaults.ts +39 -16
- package/src/organization-model/domains/customers.ts +75 -0
- package/src/organization-model/domains/goals.ts +80 -0
- package/src/organization-model/domains/identity.ts +87 -0
- package/src/organization-model/domains/navigation.ts +43 -4
- package/src/organization-model/domains/offerings.ts +66 -0
- package/src/organization-model/domains/operations.ts +85 -0
- package/src/organization-model/domains/{delivery.ts → projects.ts} +6 -6
- package/src/organization-model/domains/{lead-gen.ts → prospecting.ts} +5 -5
- package/src/organization-model/domains/roles.ts +55 -0
- package/src/organization-model/domains/sales.ts +94 -0
- package/src/organization-model/domains/shared.ts +30 -1
- package/src/organization-model/domains/statuses.ts +130 -0
- package/src/organization-model/index.ts +3 -3
- package/src/organization-model/organization-graph.mdx +1 -0
- package/src/organization-model/organization-model.mdx +84 -19
- package/src/organization-model/published.ts +53 -8
- package/src/organization-model/schema.ts +67 -7
- package/src/organization-model/types.ts +31 -7
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/types.ts +1 -1
- package/src/projects/api-schemas.ts +1 -0
- package/src/reference/_generated/contracts.md +116 -8
- package/src/reference/glossary.md +25 -4
- package/src/requests/__tests__/api-schemas.test.ts +277 -0
- package/src/requests/api-schemas.ts +83 -0
- package/src/requests/index.ts +1 -0
- package/src/supabase/database.types.ts +88 -0
- package/src/organization-model/domains/crm.ts +0 -46
- /package/src/business/{delivery → projects}/index.ts +0 -0
- /package/src/business/{delivery → projects}/types.ts +0 -0
- /package/src/business/{crm → sales}/api-schemas.ts +0 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { DEFAULT_ORGANIZATION_MODEL_BRANDING } from '../domains/branding'
|
|
3
|
+
import { DEFAULT_ORGANIZATION_MODEL_SALES } from '../domains/sales'
|
|
4
|
+
import { DEFAULT_ORGANIZATION_MODEL_PROJECTS } from '../domains/projects'
|
|
5
|
+
import { DEFAULT_ORGANIZATION_MODEL_PROSPECTING } from '../domains/prospecting'
|
|
6
|
+
import { OrganizationModelSchema } from '../schema'
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Minimal valid fixture builders
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
function makeFeature(id: string, surfaceIds: string[] = [], resourceIds: string[] = []) {
|
|
13
|
+
return {
|
|
14
|
+
id,
|
|
15
|
+
label: id,
|
|
16
|
+
enabled: true,
|
|
17
|
+
entityIds: [],
|
|
18
|
+
surfaceIds,
|
|
19
|
+
resourceIds,
|
|
20
|
+
capabilityIds: []
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function makeSurface(id: string, featureIds: string[] = [], resourceIds: string[] = []) {
|
|
25
|
+
return {
|
|
26
|
+
id,
|
|
27
|
+
label: id,
|
|
28
|
+
path: `/${id}`,
|
|
29
|
+
surfaceType: 'page' as const,
|
|
30
|
+
featureIds,
|
|
31
|
+
entityIds: [],
|
|
32
|
+
resourceIds,
|
|
33
|
+
capabilityIds: []
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function makeGroup(id: string, surfaceIds: string[] = []) {
|
|
38
|
+
return { id, label: id, placement: 'primary' as const, surfaceIds }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function makeResourceMapping(id: string, resourceId: string, featureIds: string[] = [], surfaceIds: string[] = []) {
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
label: id,
|
|
45
|
+
resourceId,
|
|
46
|
+
resourceType: 'workflow' as const,
|
|
47
|
+
featureIds,
|
|
48
|
+
entityIds: [],
|
|
49
|
+
surfaceIds,
|
|
50
|
+
capabilityIds: []
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A minimal model that satisfies all base-schema field requirements.
|
|
56
|
+
* The crm/leadGen/delivery fields use the official defaults so the schema
|
|
57
|
+
* layer validates cleanly, leaving superRefine as the only concern.
|
|
58
|
+
*/
|
|
59
|
+
function makeMinimalModel(
|
|
60
|
+
navOverride: { defaultSurfaceId?: string; surfaces?: unknown[]; groups?: unknown[] } = {},
|
|
61
|
+
extras: { features?: unknown[]; resourceMappings?: unknown[] } = {}
|
|
62
|
+
) {
|
|
63
|
+
return {
|
|
64
|
+
version: 1 as const,
|
|
65
|
+
features: extras.features ?? [],
|
|
66
|
+
branding: DEFAULT_ORGANIZATION_MODEL_BRANDING,
|
|
67
|
+
navigation: {
|
|
68
|
+
defaultSurfaceId: navOverride.defaultSurfaceId,
|
|
69
|
+
surfaces: navOverride.surfaces ?? [],
|
|
70
|
+
groups: navOverride.groups ?? []
|
|
71
|
+
},
|
|
72
|
+
sales: DEFAULT_ORGANIZATION_MODEL_SALES,
|
|
73
|
+
prospecting: DEFAULT_ORGANIZATION_MODEL_PROSPECTING,
|
|
74
|
+
projects: DEFAULT_ORGANIZATION_MODEL_PROJECTS,
|
|
75
|
+
resourceMappings: extras.resourceMappings ?? []
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Helper: collect all Zod issue messages from a failed parse
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
function getIssueMessages(data: unknown): string[] {
|
|
84
|
+
const result = OrganizationModelSchema.safeParse(data)
|
|
85
|
+
if (result.success) return []
|
|
86
|
+
return result.error.issues.map((i) => i.message)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Group 1: Bidirectional feature <-> surface refs
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
describe('bidirectional feature <-> surface refs', () => {
|
|
94
|
+
it('passes when feature and surface correctly reference each other', () => {
|
|
95
|
+
const model = makeMinimalModel(
|
|
96
|
+
{ surfaces: [makeSurface('crm.pipeline', ['crm'])], groups: [] },
|
|
97
|
+
{ features: [makeFeature('crm', ['crm.pipeline'])] }
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('throws when feature references a surface that does not exist', () => {
|
|
104
|
+
const model = makeMinimalModel(
|
|
105
|
+
{ surfaces: [], groups: [] },
|
|
106
|
+
{ features: [makeFeature('crm', ['nonexistent-surface'])] }
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const messages = getIssueMessages(model)
|
|
110
|
+
expect(messages.some((m) => m.includes('references unknown surface'))).toBe(true)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('throws when feature references a surface that does not include the feature', () => {
|
|
114
|
+
// Surface exists but its featureIds does not contain 'crm'
|
|
115
|
+
const model = makeMinimalModel(
|
|
116
|
+
{ surfaces: [makeSurface('crm.pipeline', [] /* featureIds omits 'crm' */)], groups: [] },
|
|
117
|
+
{ features: [makeFeature('crm', ['crm.pipeline'])] }
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
const messages = getIssueMessages(model)
|
|
121
|
+
expect(messages.some((m) => m.includes('does not include feature'))).toBe(true)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('throws when surface references a feature that does not exist', () => {
|
|
125
|
+
const model = makeMinimalModel(
|
|
126
|
+
{ surfaces: [makeSurface('crm.pipeline', ['nonexistent-feature'])], groups: [] },
|
|
127
|
+
{ features: [] }
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
const messages = getIssueMessages(model)
|
|
131
|
+
expect(messages.some((m) => m.includes('references unknown feature'))).toBe(true)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('throws when surface references a feature that does not include the surface', () => {
|
|
135
|
+
// Feature exists but its surfaceIds does not contain 'crm.pipeline'
|
|
136
|
+
const model = makeMinimalModel(
|
|
137
|
+
{ surfaces: [makeSurface('crm.pipeline', ['crm'])], groups: [] },
|
|
138
|
+
{ features: [makeFeature('crm', [] /* surfaceIds omits 'crm.pipeline' */)] }
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
const messages = getIssueMessages(model)
|
|
142
|
+
expect(messages.some((m) => m.includes('does not include surface'))).toBe(true)
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Group 2: Duplicate ID detection
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
describe('duplicate ID detection', () => {
|
|
151
|
+
it('throws on duplicate feature IDs', () => {
|
|
152
|
+
const model = makeMinimalModel({ surfaces: [], groups: [] }, { features: [makeFeature('crm'), makeFeature('crm')] })
|
|
153
|
+
|
|
154
|
+
const messages = getIssueMessages(model)
|
|
155
|
+
expect(messages.some((m) => m.includes('Feature id "crm" must be unique'))).toBe(true)
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
it('throws on duplicate surface IDs', () => {
|
|
159
|
+
const model = makeMinimalModel({
|
|
160
|
+
surfaces: [makeSurface('home'), makeSurface('home')],
|
|
161
|
+
groups: []
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
const messages = getIssueMessages(model)
|
|
165
|
+
expect(messages.some((m) => m.includes('Surface id "home" must be unique'))).toBe(true)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('throws on duplicate navigation group IDs', () => {
|
|
169
|
+
const model = makeMinimalModel({
|
|
170
|
+
surfaces: [],
|
|
171
|
+
groups: [makeGroup('primary'), makeGroup('primary')]
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
const messages = getIssueMessages(model)
|
|
175
|
+
expect(messages.some((m) => m.includes('Navigation group id "primary" must be unique'))).toBe(true)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it('throws on duplicate resource mapping IDs', () => {
|
|
179
|
+
const model = makeMinimalModel(
|
|
180
|
+
{ surfaces: [], groups: [] },
|
|
181
|
+
{ resourceMappings: [makeResourceMapping('rm-1', 'res-a'), makeResourceMapping('rm-1', 'res-b')] }
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
const messages = getIssueMessages(model)
|
|
185
|
+
expect(messages.some((m) => m.includes('Resource mapping id "rm-1" must be unique'))).toBe(true)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('throws on duplicate resource mapping resourceIds', () => {
|
|
189
|
+
const model = makeMinimalModel(
|
|
190
|
+
{ surfaces: [], groups: [] },
|
|
191
|
+
{
|
|
192
|
+
resourceMappings: [
|
|
193
|
+
makeResourceMapping('rm-1', 'shared-resource'),
|
|
194
|
+
makeResourceMapping('rm-2', 'shared-resource')
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
const messages = getIssueMessages(model)
|
|
200
|
+
expect(messages.some((m) => m.includes('resourceId "shared-resource" must be unique'))).toBe(true)
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
it('passes when all IDs are unique across all collections', () => {
|
|
204
|
+
const model = makeMinimalModel(
|
|
205
|
+
{
|
|
206
|
+
surfaces: [makeSurface('surf-1'), makeSurface('surf-2')],
|
|
207
|
+
groups: [makeGroup('grp-1'), makeGroup('grp-2')]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
features: [makeFeature('feat-a'), makeFeature('feat-b')],
|
|
211
|
+
resourceMappings: [makeResourceMapping('rm-1', 'res-x'), makeResourceMapping('rm-2', 'res-y')]
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
// Group 3: defaultSurfaceId correctness
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
|
|
223
|
+
describe('defaultSurfaceId correctness', () => {
|
|
224
|
+
it('passes when defaultSurfaceId points at a declared surface', () => {
|
|
225
|
+
const model = makeMinimalModel(
|
|
226
|
+
{
|
|
227
|
+
defaultSurfaceId: 'crm.pipeline',
|
|
228
|
+
surfaces: [makeSurface('crm.pipeline', ['crm'])],
|
|
229
|
+
groups: []
|
|
230
|
+
},
|
|
231
|
+
{ features: [makeFeature('crm', ['crm.pipeline'])] }
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it('throws when defaultSurfaceId references a surface that does not exist', () => {
|
|
238
|
+
const model = makeMinimalModel({
|
|
239
|
+
defaultSurfaceId: 'nonexistent',
|
|
240
|
+
surfaces: [],
|
|
241
|
+
groups: []
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
const messages = getIssueMessages(model)
|
|
245
|
+
expect(messages.some((m) => m.includes('must reference a declared navigation surface'))).toBe(true)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('passes when defaultSurfaceId is absent (undefined)', () => {
|
|
249
|
+
// NOTE: The falsy guard in schema.ts (line 69) skips the check entirely when
|
|
250
|
+
// defaultSurfaceId is undefined. This is current behavior — documented here.
|
|
251
|
+
const model = makeMinimalModel({ surfaces: [], groups: [] })
|
|
252
|
+
|
|
253
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
254
|
+
})
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
// Group 4: Resource-mapping feature <-> surface cross-refs
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
|
|
261
|
+
describe('resource-mapping feature <-> surface cross-refs', () => {
|
|
262
|
+
it('passes with a fully consistent resource mapping', () => {
|
|
263
|
+
const model = makeMinimalModel(
|
|
264
|
+
{ surfaces: [makeSurface('crm.pipeline', ['crm'], ['workflow-a'])], groups: [] },
|
|
265
|
+
{
|
|
266
|
+
features: [makeFeature('crm', ['crm.pipeline'], ['workflow-a'])],
|
|
267
|
+
resourceMappings: [makeResourceMapping('rm-1', 'workflow-a', ['crm'], ['crm.pipeline'])]
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
it('throws when resource mapping references a feature that does not exist', () => {
|
|
275
|
+
const model = makeMinimalModel(
|
|
276
|
+
{ surfaces: [], groups: [] },
|
|
277
|
+
{ resourceMappings: [makeResourceMapping('rm-1', 'res-a', ['nonexistent-feature'])] }
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
const messages = getIssueMessages(model)
|
|
281
|
+
expect(messages.some((m) => m.includes('references unknown feature'))).toBe(true)
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
it('throws when resource mapping references a surface that does not exist', () => {
|
|
285
|
+
const model = makeMinimalModel(
|
|
286
|
+
{ surfaces: [], groups: [] },
|
|
287
|
+
{ resourceMappings: [makeResourceMapping('rm-1', 'res-a', [], ['nonexistent-surface'])] }
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
const messages = getIssueMessages(model)
|
|
291
|
+
expect(messages.some((m) => m.includes('references unknown surface'))).toBe(true)
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
it('throws when feature resourceId ref exists but mapping does not back-reference the feature', () => {
|
|
295
|
+
// Resource mapping exists for 'workflow-a', feature lists it, but mapping.featureIds is empty
|
|
296
|
+
const model = makeMinimalModel(
|
|
297
|
+
{ surfaces: [], groups: [] },
|
|
298
|
+
{
|
|
299
|
+
features: [makeFeature('crm', [], ['workflow-a'])],
|
|
300
|
+
resourceMappings: [makeResourceMapping('rm-1', 'workflow-a', [] /* missing 'crm' */)]
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
const messages = getIssueMessages(model)
|
|
305
|
+
// Feature side: "does not include resource"; ResourceMapping side: the feature is missing
|
|
306
|
+
expect(
|
|
307
|
+
messages.some((m) => m.includes('does not include resource') || m.includes('does not include feature'))
|
|
308
|
+
).toBe(true)
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
it('throws when surface resourceId ref exists but mapping does not back-reference the surface', () => {
|
|
312
|
+
// Resource mapping exists for 'workflow-b', surface lists it, but mapping.surfaceIds is empty
|
|
313
|
+
const model = makeMinimalModel(
|
|
314
|
+
{ surfaces: [makeSurface('home', [], ['workflow-b'])], groups: [] },
|
|
315
|
+
{ resourceMappings: [makeResourceMapping('rm-2', 'workflow-b', [], [] /* missing 'home' */)] }
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
const messages = getIssueMessages(model)
|
|
319
|
+
expect(
|
|
320
|
+
messages.some((m) => m.includes('does not include resource') || m.includes('does not include surface'))
|
|
321
|
+
).toBe(true)
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('throws when feature references a resourceId that has no matching resource mapping', () => {
|
|
325
|
+
const model = makeMinimalModel(
|
|
326
|
+
{ surfaces: [], groups: [] },
|
|
327
|
+
{
|
|
328
|
+
features: [makeFeature('crm', [], ['unknown-resource'])],
|
|
329
|
+
resourceMappings: []
|
|
330
|
+
}
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
const messages = getIssueMessages(model)
|
|
334
|
+
expect(messages.some((m) => m.includes('references unknown resource'))).toBe(true)
|
|
335
|
+
})
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
// Group 5: Null / undefined behavior in ref fields
|
|
340
|
+
// ---------------------------------------------------------------------------
|
|
341
|
+
|
|
342
|
+
describe('null/undefined behavior in ref fields', () => {
|
|
343
|
+
it('treats missing surfaceIds as empty array via Zod default — no superRefine errors', () => {
|
|
344
|
+
// ReferenceIdsSchema defaults to []; omitting surfaceIds is safe — nothing to iterate
|
|
345
|
+
const model = makeMinimalModel(
|
|
346
|
+
{ surfaces: [], groups: [] },
|
|
347
|
+
{
|
|
348
|
+
features: [
|
|
349
|
+
{
|
|
350
|
+
id: 'crm',
|
|
351
|
+
label: 'CRM',
|
|
352
|
+
enabled: true,
|
|
353
|
+
entityIds: [],
|
|
354
|
+
// surfaceIds intentionally omitted — Zod fills in []
|
|
355
|
+
resourceIds: [],
|
|
356
|
+
capabilityIds: []
|
|
357
|
+
}
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
it('treats missing featureIds on a surface as empty array — no superRefine errors', () => {
|
|
366
|
+
const model = makeMinimalModel({
|
|
367
|
+
surfaces: [
|
|
368
|
+
{
|
|
369
|
+
id: 'home',
|
|
370
|
+
label: 'Home',
|
|
371
|
+
path: '/home',
|
|
372
|
+
surfaceType: 'page' as const,
|
|
373
|
+
// featureIds intentionally omitted — Zod fills in []
|
|
374
|
+
entityIds: [],
|
|
375
|
+
resourceIds: [],
|
|
376
|
+
capabilityIds: []
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
groups: []
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
expect(() => OrganizationModelSchema.parse(model)).not.toThrow()
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it('rejects explicit null for surfaceIds — Zod type error before superRefine runs', () => {
|
|
386
|
+
// null is not assignable to an array; the base schema rejects it before superRefine executes
|
|
387
|
+
const model = makeMinimalModel(
|
|
388
|
+
{ surfaces: [], groups: [] },
|
|
389
|
+
{
|
|
390
|
+
features: [
|
|
391
|
+
{
|
|
392
|
+
id: 'crm',
|
|
393
|
+
label: 'CRM',
|
|
394
|
+
enabled: true,
|
|
395
|
+
entityIds: [],
|
|
396
|
+
surfaceIds: null,
|
|
397
|
+
resourceIds: [],
|
|
398
|
+
capabilityIds: []
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
const result = OrganizationModelSchema.safeParse(model)
|
|
405
|
+
expect(result.success).toBe(false)
|
|
406
|
+
})
|
|
407
|
+
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export const PROJECTS_FEATURE_ID = 'projects' as const
|
|
2
2
|
export const PROJECTS_INDEX_SURFACE_ID = 'projects.index' as const
|
|
3
|
-
export const
|
|
3
|
+
export const PROJECTS_VIEW_CAPABILITY_ID = 'delivery.projects.view' as const
|
|
4
4
|
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
5
|
+
export const SALES_FEATURE_ID = 'crm' as const
|
|
6
|
+
export const PROSPECTING_FEATURE_ID = 'lead-gen' as const
|
|
7
7
|
export const OPERATIONS_FEATURE_ID = 'operations' as const
|
|
8
8
|
export const MONITORING_FEATURE_ID = 'monitoring' as const
|
|
9
9
|
export const SETTINGS_FEATURE_ID = 'settings' as const
|
|
10
10
|
export const SEO_FEATURE_ID = 'seo' as const
|
|
11
11
|
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
12
|
+
export const SALES_PIPELINE_SURFACE_ID = 'crm.pipeline' as const
|
|
13
|
+
export const PROSPECTING_LISTS_SURFACE_ID = 'lead-gen.lists' as const
|
|
14
14
|
export const OPERATIONS_ORGANIZATION_GRAPH_SURFACE_ID = 'operations.organization-graph' as const
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { OrganizationModel } from './types'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
SALES_FEATURE_ID,
|
|
4
|
+
SALES_PIPELINE_SURFACE_ID,
|
|
5
|
+
PROJECTS_VIEW_CAPABILITY_ID,
|
|
6
|
+
PROSPECTING_FEATURE_ID,
|
|
7
|
+
PROSPECTING_LISTS_SURFACE_ID,
|
|
8
8
|
MONITORING_FEATURE_ID,
|
|
9
9
|
OPERATIONS_FEATURE_ID,
|
|
10
10
|
OPERATIONS_ORGANIZATION_GRAPH_SURFACE_ID,
|
|
@@ -14,33 +14,40 @@ import {
|
|
|
14
14
|
SEO_FEATURE_ID
|
|
15
15
|
} from './contracts'
|
|
16
16
|
import { DEFAULT_ORGANIZATION_MODEL_BRANDING } from './domains/branding'
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { DEFAULT_ORGANIZATION_MODEL_IDENTITY } from './domains/identity'
|
|
18
|
+
import { DEFAULT_ORGANIZATION_MODEL_CUSTOMERS } from './domains/customers'
|
|
19
|
+
import { DEFAULT_ORGANIZATION_MODEL_OFFERINGS } from './domains/offerings'
|
|
20
|
+
import { DEFAULT_ORGANIZATION_MODEL_SALES } from './domains/sales'
|
|
21
|
+
import { DEFAULT_ORGANIZATION_MODEL_PROJECTS } from './domains/projects'
|
|
22
|
+
import { DEFAULT_ORGANIZATION_MODEL_PROSPECTING } from './domains/prospecting'
|
|
20
23
|
import { DEFAULT_ORGANIZATION_MODEL_NAVIGATION } from './domains/navigation'
|
|
24
|
+
import { DEFAULT_ORGANIZATION_MODEL_OPERATIONS } from './domains/operations'
|
|
25
|
+
import { DEFAULT_ORGANIZATION_MODEL_ROLES } from './domains/roles'
|
|
26
|
+
import { DEFAULT_ORGANIZATION_MODEL_GOALS } from './domains/goals'
|
|
27
|
+
import { DEFAULT_ORGANIZATION_MODEL_STATUSES } from './domains/statuses'
|
|
21
28
|
|
|
22
29
|
export const DEFAULT_ORGANIZATION_MODEL: OrganizationModel = {
|
|
23
30
|
version: 1,
|
|
24
31
|
features: [
|
|
25
32
|
{
|
|
26
|
-
id:
|
|
33
|
+
id: SALES_FEATURE_ID,
|
|
27
34
|
label: 'CRM',
|
|
28
35
|
description: 'Relationship pipeline and deal management',
|
|
29
36
|
enabled: true,
|
|
30
37
|
color: 'blue',
|
|
31
38
|
entityIds: ['crm.deal'],
|
|
32
|
-
surfaceIds: [
|
|
39
|
+
surfaceIds: [SALES_PIPELINE_SURFACE_ID],
|
|
33
40
|
resourceIds: [],
|
|
34
41
|
capabilityIds: ['crm.pipeline.manage']
|
|
35
42
|
},
|
|
36
43
|
{
|
|
37
|
-
id:
|
|
44
|
+
id: PROSPECTING_FEATURE_ID,
|
|
38
45
|
label: 'Lead Gen',
|
|
39
46
|
description: 'Prospecting, qualification, and outreach preparation',
|
|
40
47
|
enabled: true,
|
|
41
48
|
color: 'cyan',
|
|
42
49
|
entityIds: ['leadgen.list', 'leadgen.company', 'leadgen.contact'],
|
|
43
|
-
surfaceIds: [
|
|
50
|
+
surfaceIds: [PROSPECTING_LISTS_SURFACE_ID],
|
|
44
51
|
resourceIds: [],
|
|
45
52
|
capabilityIds: ['leadgen.lists.manage']
|
|
46
53
|
},
|
|
@@ -53,7 +60,7 @@ export const DEFAULT_ORGANIZATION_MODEL: OrganizationModel = {
|
|
|
53
60
|
entityIds: ['delivery.project', 'delivery.milestone', 'delivery.task'],
|
|
54
61
|
surfaceIds: [PROJECTS_INDEX_SURFACE_ID],
|
|
55
62
|
resourceIds: [],
|
|
56
|
-
capabilityIds: [
|
|
63
|
+
capabilityIds: [PROJECTS_VIEW_CAPABILITY_ID]
|
|
57
64
|
},
|
|
58
65
|
{
|
|
59
66
|
id: OPERATIONS_FEATURE_ID,
|
|
@@ -106,6 +113,15 @@ export const DEFAULT_ORGANIZATION_MODEL: OrganizationModel = {
|
|
|
106
113
|
resourceIds: [],
|
|
107
114
|
capabilityIds: []
|
|
108
115
|
},
|
|
116
|
+
{
|
|
117
|
+
id: 'submitted-requests',
|
|
118
|
+
label: 'Submitted Requests',
|
|
119
|
+
enabled: true,
|
|
120
|
+
entityIds: ['reported_request'],
|
|
121
|
+
surfaceIds: ['submitted-requests.list', 'submitted-requests.detail'],
|
|
122
|
+
resourceIds: [],
|
|
123
|
+
capabilityIds: []
|
|
124
|
+
},
|
|
109
125
|
{
|
|
110
126
|
id: SEO_FEATURE_ID,
|
|
111
127
|
label: 'SEO',
|
|
@@ -118,8 +134,15 @@ export const DEFAULT_ORGANIZATION_MODEL: OrganizationModel = {
|
|
|
118
134
|
],
|
|
119
135
|
branding: DEFAULT_ORGANIZATION_MODEL_BRANDING,
|
|
120
136
|
navigation: DEFAULT_ORGANIZATION_MODEL_NAVIGATION,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
sales: DEFAULT_ORGANIZATION_MODEL_SALES,
|
|
138
|
+
prospecting: DEFAULT_ORGANIZATION_MODEL_PROSPECTING,
|
|
139
|
+
projects: DEFAULT_ORGANIZATION_MODEL_PROJECTS,
|
|
140
|
+
identity: DEFAULT_ORGANIZATION_MODEL_IDENTITY,
|
|
141
|
+
customers: DEFAULT_ORGANIZATION_MODEL_CUSTOMERS,
|
|
142
|
+
offerings: DEFAULT_ORGANIZATION_MODEL_OFFERINGS,
|
|
143
|
+
roles: DEFAULT_ORGANIZATION_MODEL_ROLES,
|
|
144
|
+
goals: DEFAULT_ORGANIZATION_MODEL_GOALS,
|
|
145
|
+
statuses: DEFAULT_ORGANIZATION_MODEL_STATUSES,
|
|
146
|
+
operations: DEFAULT_ORGANIZATION_MODEL_OPERATIONS,
|
|
124
147
|
resourceMappings: []
|
|
125
148
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Firmographics — optional demographic/firmographic filters that describe the
|
|
5
|
+
// target customer segment's organizational profile. All fields are optional so
|
|
6
|
+
// a segment can declare only the axes relevant to targeting.
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export const FirmographicsSchema = z.object({
|
|
10
|
+
/** Industry vertical (e.g. "Marketing Agency", "Legal", "Real Estate"). */
|
|
11
|
+
industry: z.string().trim().max(200).optional(),
|
|
12
|
+
/**
|
|
13
|
+
* Company headcount band (e.g. "1–10", "11–50", "51–200", "200+").
|
|
14
|
+
* Free-form string to accommodate any band notation.
|
|
15
|
+
*/
|
|
16
|
+
companySize: z.string().trim().max(100).optional(),
|
|
17
|
+
/**
|
|
18
|
+
* Primary geographic region the segment operates in or is targeted from
|
|
19
|
+
* (e.g. "North America", "Europe", "Global").
|
|
20
|
+
*/
|
|
21
|
+
region: z.string().trim().max(200).optional()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Customer segment schema — one entry per distinct buyer archetype.
|
|
26
|
+
// Modeled after Value Proposition Canvas (BMC / VPC) and Business Model Canvas
|
|
27
|
+
// customer-segment language. Fields use plain English throughout.
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
export const CustomerSegmentSchema = z.object({
|
|
31
|
+
/** Stable unique identifier for the segment (e.g. "segment-smb-agencies"). */
|
|
32
|
+
id: z.string().trim().min(1).max(100),
|
|
33
|
+
/** Human-readable name shown to agents and in UI (e.g. "SMB Marketing Agencies"). */
|
|
34
|
+
name: z.string().trim().max(200).default(''),
|
|
35
|
+
/** One or two sentences describing who this segment is. */
|
|
36
|
+
description: z.string().trim().max(2000).default(''),
|
|
37
|
+
/**
|
|
38
|
+
* The primary job(s) this segment is trying to get done — the goal they hire
|
|
39
|
+
* a product/service to accomplish. Plain-language narrative or bullet list.
|
|
40
|
+
*/
|
|
41
|
+
jobsToBeDone: z.string().trim().max(2000).default(''),
|
|
42
|
+
/**
|
|
43
|
+
* Pains — frustrations, obstacles, and risks the segment experiences
|
|
44
|
+
* when trying to accomplish their jobs-to-be-done.
|
|
45
|
+
*/
|
|
46
|
+
pains: z.array(z.string().trim().max(500)).default([]),
|
|
47
|
+
/**
|
|
48
|
+
* Gains — outcomes and benefits the segment desires; positive motivators
|
|
49
|
+
* beyond merely resolving pains.
|
|
50
|
+
*/
|
|
51
|
+
gains: z.array(z.string().trim().max(500)).default([]),
|
|
52
|
+
/** Firmographic profile for targeting and filtering. */
|
|
53
|
+
firmographics: FirmographicsSchema.default({}),
|
|
54
|
+
/**
|
|
55
|
+
* Value proposition — one or two sentences stating why this organization's
|
|
56
|
+
* offering is uniquely suited for this segment's needs.
|
|
57
|
+
*/
|
|
58
|
+
valueProp: z.string().trim().max(2000).default('')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Customers domain schema — a collection of customer segments.
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
export const CustomersDomainSchema = z.object({
|
|
66
|
+
segments: z.array(CustomerSegmentSchema).default([])
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Seed — empty by default; adapters populate with real segment definitions.
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
export const DEFAULT_ORGANIZATION_MODEL_CUSTOMERS: z.infer<typeof CustomersDomainSchema> = {
|
|
74
|
+
segments: []
|
|
75
|
+
}
|