@elevasis/core 0.21.0 → 0.22.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 +416 -6
- package/dist/index.js +240 -15
- package/dist/knowledge/index.d.ts +97 -1
- package/dist/organization-model/index.d.ts +416 -6
- package/dist/organization-model/index.js +240 -15
- package/dist/test-utils/index.d.ts +216 -1
- package/dist/test-utils/index.js +230 -14
- package/package.json +3 -3
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +495 -302
- package/src/auth/multi-tenancy/permissions.ts +20 -8
- package/src/business/README.md +2 -2
- package/src/business/acquisition/api-schemas.test.ts +173 -0
- package/src/business/acquisition/api-schemas.ts +125 -7
- package/src/business/acquisition/index.ts +12 -0
- package/src/business/clients/api-schemas.test.ts +115 -0
- package/src/business/clients/api-schemas.ts +158 -0
- package/src/business/clients/index.ts +1 -0
- package/src/business/deals/api-schemas.ts +8 -0
- package/src/business/index.ts +5 -2
- package/src/business/projects/types.ts +19 -0
- package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -8
- package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -12
- package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -3
- package/src/execution/engine/agent/core/types.ts +25 -15
- package/src/execution/engine/agent/index.ts +6 -4
- package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -18
- package/src/execution/engine/index.ts +3 -0
- package/src/execution/engine/workflow/types.ts +7 -0
- package/src/organization-model/README.md +10 -3
- package/src/organization-model/__tests__/defaults.test.ts +6 -0
- package/src/organization-model/__tests__/domains/resources.test.ts +188 -0
- package/src/organization-model/__tests__/domains/roles.test.ts +402 -347
- package/src/organization-model/__tests__/domains/systems.test.ts +193 -0
- package/src/organization-model/__tests__/knowledge.test.ts +39 -0
- package/src/organization-model/__tests__/resolve.test.ts +1 -1
- package/src/organization-model/defaults.ts +24 -3
- package/src/organization-model/domains/knowledge.ts +3 -2
- package/src/organization-model/domains/resources.ts +88 -0
- package/src/organization-model/domains/roles.ts +93 -55
- package/src/organization-model/domains/systems.ts +46 -0
- package/src/organization-model/icons.ts +1 -0
- package/src/organization-model/index.ts +2 -0
- package/src/organization-model/organization-model.mdx +33 -14
- package/src/organization-model/published.ts +52 -1
- package/src/organization-model/schema.ts +121 -0
- package/src/organization-model/types.ts +46 -1
- package/src/platform/api/types.ts +38 -35
- package/src/platform/registry/__tests__/resource-registry.test.ts +2051 -2005
- package/src/platform/registry/__tests__/validation.test.ts +1343 -1086
- package/src/platform/registry/index.ts +14 -0
- package/src/platform/registry/resource-registry.ts +40 -2
- package/src/platform/registry/serialization.ts +241 -202
- package/src/platform/registry/serialized-types.ts +1 -0
- package/src/platform/registry/types.ts +411 -361
- package/src/platform/registry/validation.ts +743 -513
- package/src/projects/api-schemas.ts +290 -267
- package/src/reference/_generated/contracts.md +495 -302
- package/src/reference/glossary.md +8 -3
- package/src/supabase/database.types.ts +121 -0
|
@@ -6,13 +6,18 @@
|
|
|
6
6
|
* - API middleware (via requireOrganizationPermission(key))
|
|
7
7
|
* - UI hooks (via useOrganizationPermissions().hasPermission(key))
|
|
8
8
|
*
|
|
9
|
-
* The DB table `org_rol_permissions` mirrors this constant.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* The DB table `org_rol_permissions` mirrors this constant. There is no
|
|
10
|
+
* runtime reconciler; parity is enforced two ways:
|
|
11
|
+
* 1. Each migration that adds/removes/modifies a permission must INSERT
|
|
12
|
+
* (or UPDATE / DELETE) the corresponding `org_rol_permissions` row in
|
|
13
|
+
* the same transaction.
|
|
14
|
+
* 2. `apps/api/src/auth/multi-tenancy/__tests__/permissions-catalog-sync.integration.test.ts`
|
|
15
|
+
* asserts the TS catalog and the DB rows agree; CI fails on drift.
|
|
12
16
|
*
|
|
13
17
|
* Adding a permission:
|
|
14
18
|
* 1. Add an entry below.
|
|
15
|
-
* 2. Add a row to the migration
|
|
19
|
+
* 2. Add a row to the migration (INSERT INTO org_rol_permissions ...) in
|
|
20
|
+
* the same transaction as any policies/grants that reference the key.
|
|
16
21
|
* 3. Reference it in RLS / middleware as needed.
|
|
17
22
|
* 4. Optionally grant it to one or more system roles in org_rol_grants.
|
|
18
23
|
*
|
|
@@ -30,15 +35,17 @@ export const PERMISSIONS = {
|
|
|
30
35
|
OPERATIONS_READ: 'operations.read',
|
|
31
36
|
OPERATIONS_MANAGE: 'operations.manage',
|
|
32
37
|
ACQUISITION_MANAGE: 'acquisition.manage',
|
|
33
|
-
PROJECTS_MANAGE: 'projects.manage'
|
|
38
|
+
PROJECTS_MANAGE: 'projects.manage',
|
|
39
|
+
CLIENTS_MANAGE: 'clients.manage'
|
|
34
40
|
} as const
|
|
35
41
|
|
|
36
42
|
export type PermissionKey = (typeof PERMISSIONS)[keyof typeof PERMISSIONS]
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
|
-
* Static metadata for each permission. Mirrored into org_rol_permissions
|
|
40
|
-
*
|
|
41
|
-
*
|
|
45
|
+
* Static metadata for each permission. Mirrored into org_rol_permissions by
|
|
46
|
+
* a migration `INSERT` in the same transaction as any change to this catalog.
|
|
47
|
+
* is_org_grantable=false means the permission is reserved to system roles
|
|
48
|
+
* only — custom roles cannot include it (privilege-escalation guard).
|
|
42
49
|
*/
|
|
43
50
|
export interface PermissionDescriptor {
|
|
44
51
|
key: PermissionKey
|
|
@@ -97,6 +104,11 @@ export const PERMISSION_CATALOG: readonly PermissionDescriptor[] = [
|
|
|
97
104
|
key: 'projects.manage',
|
|
98
105
|
description: 'Create, update, and delete project records (prj_projects, prj_milestones, prj_tasks, prj_notes)',
|
|
99
106
|
isOrgGrantable: false
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: 'clients.manage',
|
|
110
|
+
description: 'Create, update, and delete client hub records (clients, clt_* satellites)',
|
|
111
|
+
isOrgGrantable: false
|
|
100
112
|
}
|
|
101
113
|
] as const
|
|
102
114
|
|
package/src/business/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Published base entity contracts for the Elevasis platform. Each entity ships as a TypeScript interface, a matching Zod schema, and an inferred `Input` type, generic over a `<TMeta>` extension slot.
|
|
4
4
|
|
|
5
|
-
External projects extend these in `
|
|
5
|
+
External projects extend these in `core/types/entities.ts` to attach project-specific metadata while keeping the canonical shape stable.
|
|
6
6
|
|
|
7
7
|
## Published Exports
|
|
8
8
|
|
|
@@ -49,4 +49,4 @@ export type Deal = BaseDeal
|
|
|
49
49
|
|
|
50
50
|
The full pattern is documented in the SDK scaffold bundle: `node_modules/@elevasis/sdk/reference/scaffold/recipes/extend-a-base-entity.md`.
|
|
51
51
|
|
|
52
|
-
The canonical template demo lives at `external/_template/
|
|
52
|
+
The canonical template demo lives at `external/_template/core/types/entities.ts`.
|
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
AddCompaniesToListRequestSchema,
|
|
11
11
|
AddContactsToListRequestSchema,
|
|
12
12
|
AcqArtifactOwnerKindSchema,
|
|
13
|
+
AcqListDetailResponseSchema,
|
|
13
14
|
AcqContactResponseSchema,
|
|
14
15
|
AcqContactStatusSchema,
|
|
15
16
|
AcqEmailValidSchema,
|
|
16
17
|
AcqListResponseSchema,
|
|
18
|
+
AcqListStatusResponseSchema,
|
|
17
19
|
BuildPlanSnapshotSchema,
|
|
18
20
|
CreateArtifactRequestSchema,
|
|
19
21
|
CreateCompanyRequestSchema,
|
|
@@ -32,12 +34,14 @@ import {
|
|
|
32
34
|
DealTaskResponseSchema,
|
|
33
35
|
ExecuteActionRequestSchema,
|
|
34
36
|
IcpRubricSchema,
|
|
37
|
+
GetListQuerySchema,
|
|
35
38
|
ListArtifactsQuerySchema,
|
|
36
39
|
ListCompaniesQuerySchema,
|
|
37
40
|
ListContactsQuerySchema,
|
|
38
41
|
ListDealsQuerySchema,
|
|
39
42
|
ListDealTasksDueQuerySchema,
|
|
40
43
|
ListMembersQuerySchema,
|
|
44
|
+
ListReadQuerySchema,
|
|
41
45
|
ListRecordsQuerySchema,
|
|
42
46
|
ListStatusSchema,
|
|
43
47
|
PipelineStageSchema,
|
|
@@ -857,6 +861,24 @@ describe('DealDetailResponseSchema (forward-compat)', () => {
|
|
|
857
861
|
expect(DealDetailResponseSchema.safeParse(withContact).success).toBe(true)
|
|
858
862
|
})
|
|
859
863
|
|
|
864
|
+
it('accepts thin client lineage refs on deal detail responses', () => {
|
|
865
|
+
expect(
|
|
866
|
+
DealDetailResponseSchema.safeParse({
|
|
867
|
+
...baseDeal,
|
|
868
|
+
client_id: VALID_UUID,
|
|
869
|
+
lineage: {
|
|
870
|
+
list: null,
|
|
871
|
+
projects: [],
|
|
872
|
+
client: {
|
|
873
|
+
id: VALID_UUID,
|
|
874
|
+
name: 'Acme Client',
|
|
875
|
+
status: 'active'
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}).success
|
|
879
|
+
).toBe(true)
|
|
880
|
+
})
|
|
881
|
+
|
|
860
882
|
it('accepts extra unknown fields at top level (not strict)', () => {
|
|
861
883
|
expect(DealDetailResponseSchema.safeParse({ ...baseDeal, futureField: 'value' }).success).toBe(true)
|
|
862
884
|
})
|
|
@@ -1602,6 +1624,67 @@ describe('ListMembersQuerySchema', () => {
|
|
|
1602
1624
|
})
|
|
1603
1625
|
})
|
|
1604
1626
|
|
|
1627
|
+
// ---------------------------------------------------------------------------
|
|
1628
|
+
// ListReadQuerySchema
|
|
1629
|
+
// ---------------------------------------------------------------------------
|
|
1630
|
+
|
|
1631
|
+
describe('ListReadQuerySchema', () => {
|
|
1632
|
+
it('accepts SDK list filters and coerces pagination', () => {
|
|
1633
|
+
const result = ListReadQuerySchema.safeParse({
|
|
1634
|
+
status: 'launched',
|
|
1635
|
+
batch: 'batch-2026-05',
|
|
1636
|
+
vertical: 'veterinary',
|
|
1637
|
+
limit: '25',
|
|
1638
|
+
offset: '50'
|
|
1639
|
+
})
|
|
1640
|
+
|
|
1641
|
+
expect(result.success).toBe(true)
|
|
1642
|
+
if (result.success) {
|
|
1643
|
+
expect(result.data).toMatchObject({ limit: 25, offset: 50 })
|
|
1644
|
+
}
|
|
1645
|
+
})
|
|
1646
|
+
|
|
1647
|
+
it('keeps pagination optional for backward-compatible list reads', () => {
|
|
1648
|
+
expect(ListReadQuerySchema.safeParse({}).success).toBe(true)
|
|
1649
|
+
})
|
|
1650
|
+
|
|
1651
|
+
it('rejects unknown fields (strict mode)', () => {
|
|
1652
|
+
expect(ListReadQuerySchema.safeParse({ includeDeals: true }).success).toBe(false)
|
|
1653
|
+
})
|
|
1654
|
+
})
|
|
1655
|
+
|
|
1656
|
+
// ---------------------------------------------------------------------------
|
|
1657
|
+
// GetListQuerySchema
|
|
1658
|
+
// ---------------------------------------------------------------------------
|
|
1659
|
+
|
|
1660
|
+
describe('GetListQuerySchema', () => {
|
|
1661
|
+
it('defaults to thin deal refs and omits progress unless requested', () => {
|
|
1662
|
+
const result = GetListQuerySchema.safeParse({})
|
|
1663
|
+
|
|
1664
|
+
expect(result.success).toBe(true)
|
|
1665
|
+
if (result.success) {
|
|
1666
|
+
expect(result.data).toEqual({ includeDeals: true, includeProgress: false, dealLimit: 25 })
|
|
1667
|
+
}
|
|
1668
|
+
})
|
|
1669
|
+
|
|
1670
|
+
it('coerces boolean include flags from query strings', () => {
|
|
1671
|
+
const result = GetListQuerySchema.safeParse({
|
|
1672
|
+
includeDeals: 'false',
|
|
1673
|
+
includeProgress: 'true',
|
|
1674
|
+
dealLimit: '10'
|
|
1675
|
+
})
|
|
1676
|
+
|
|
1677
|
+
expect(result.success).toBe(true)
|
|
1678
|
+
if (result.success) {
|
|
1679
|
+
expect(result.data).toEqual({ includeDeals: false, includeProgress: true, dealLimit: 10 })
|
|
1680
|
+
}
|
|
1681
|
+
})
|
|
1682
|
+
|
|
1683
|
+
it('rejects unknown fields (strict mode)', () => {
|
|
1684
|
+
expect(GetListQuerySchema.safeParse({ depth: 2 }).success).toBe(false)
|
|
1685
|
+
})
|
|
1686
|
+
})
|
|
1687
|
+
|
|
1605
1688
|
// ---------------------------------------------------------------------------
|
|
1606
1689
|
// ListRecordsQuerySchema
|
|
1607
1690
|
// ---------------------------------------------------------------------------
|
|
@@ -1657,6 +1740,96 @@ describe('AcqListResponseSchema (forward-compat)', () => {
|
|
|
1657
1740
|
})
|
|
1658
1741
|
})
|
|
1659
1742
|
|
|
1743
|
+
// ---------------------------------------------------------------------------
|
|
1744
|
+
// AcqListDetailResponseSchema
|
|
1745
|
+
// ---------------------------------------------------------------------------
|
|
1746
|
+
|
|
1747
|
+
describe('AcqListDetailResponseSchema', () => {
|
|
1748
|
+
const baseList = {
|
|
1749
|
+
id: VALID_UUID,
|
|
1750
|
+
organizationId: VALID_UUID,
|
|
1751
|
+
name: 'Test List',
|
|
1752
|
+
description: null,
|
|
1753
|
+
batchIds: [],
|
|
1754
|
+
instantlyCampaignId: null,
|
|
1755
|
+
status: 'draft' as const,
|
|
1756
|
+
metadata: {},
|
|
1757
|
+
launchedAt: null,
|
|
1758
|
+
completedAt: null,
|
|
1759
|
+
createdAt: ISO_TS,
|
|
1760
|
+
scrapingConfig: {},
|
|
1761
|
+
icp: {},
|
|
1762
|
+
pipelineConfig: {}
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
it('accepts thin lineage deal refs on list detail responses', () => {
|
|
1766
|
+
expect(
|
|
1767
|
+
AcqListDetailResponseSchema.safeParse({
|
|
1768
|
+
...baseList,
|
|
1769
|
+
lineage: {
|
|
1770
|
+
deals: {
|
|
1771
|
+
total: 1,
|
|
1772
|
+
refs: [
|
|
1773
|
+
{
|
|
1774
|
+
id: VALID_UUID,
|
|
1775
|
+
contactEmail: 'lead@example.com',
|
|
1776
|
+
stageKey: 'proposal',
|
|
1777
|
+
stateKey: null,
|
|
1778
|
+
sourceType: 'outreach',
|
|
1779
|
+
lastActivityAt: ISO_TS
|
|
1780
|
+
}
|
|
1781
|
+
],
|
|
1782
|
+
truncated: false
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}).success
|
|
1786
|
+
).toBe(true)
|
|
1787
|
+
})
|
|
1788
|
+
|
|
1789
|
+
it('accepts optional progress on list detail responses', () => {
|
|
1790
|
+
expect(
|
|
1791
|
+
AcqListDetailResponseSchema.safeParse({
|
|
1792
|
+
...baseList,
|
|
1793
|
+
progress: {
|
|
1794
|
+
totalMembers: 0,
|
|
1795
|
+
totalCompanies: 0,
|
|
1796
|
+
byCompanyStage: {},
|
|
1797
|
+
byContactStage: {}
|
|
1798
|
+
}
|
|
1799
|
+
}).success
|
|
1800
|
+
).toBe(true)
|
|
1801
|
+
})
|
|
1802
|
+
})
|
|
1803
|
+
|
|
1804
|
+
// ---------------------------------------------------------------------------
|
|
1805
|
+
// AcqListStatusResponseSchema
|
|
1806
|
+
// ---------------------------------------------------------------------------
|
|
1807
|
+
|
|
1808
|
+
describe('AcqListStatusResponseSchema', () => {
|
|
1809
|
+
it('accepts a portfolio summary across acquisition lists', () => {
|
|
1810
|
+
expect(
|
|
1811
|
+
AcqListStatusResponseSchema.safeParse({
|
|
1812
|
+
totalLists: 1,
|
|
1813
|
+
totalCompanies: 10,
|
|
1814
|
+
totalContacts: 5,
|
|
1815
|
+
totalDeals: 2,
|
|
1816
|
+
byStatus: { launched: 1 },
|
|
1817
|
+
lists: [
|
|
1818
|
+
{
|
|
1819
|
+
listId: VALID_UUID,
|
|
1820
|
+
name: 'Pipeline',
|
|
1821
|
+
status: 'launched',
|
|
1822
|
+
totalCompanies: 10,
|
|
1823
|
+
totalContacts: 5,
|
|
1824
|
+
totalDeals: 2,
|
|
1825
|
+
createdAt: ISO_TS
|
|
1826
|
+
}
|
|
1827
|
+
]
|
|
1828
|
+
}).success
|
|
1829
|
+
).toBe(true)
|
|
1830
|
+
})
|
|
1831
|
+
})
|
|
1832
|
+
|
|
1660
1833
|
// ---------------------------------------------------------------------------
|
|
1661
1834
|
// AcqContactResponseSchema (forward-compat)
|
|
1662
1835
|
// ---------------------------------------------------------------------------
|
|
@@ -84,6 +84,9 @@ export const DealTaskIdParamsSchema = z.object({
|
|
|
84
84
|
export const ListDealsQuerySchema = z
|
|
85
85
|
.object({
|
|
86
86
|
stage: DealStageSchema.optional(),
|
|
87
|
+
list: UuidSchema.optional(),
|
|
88
|
+
batch: z.string().trim().min(1).max(255).optional(),
|
|
89
|
+
staleSince: z.string().datetime().optional(),
|
|
87
90
|
search: z.string().optional(),
|
|
88
91
|
limit: z.coerce.number().int().positive().default(50),
|
|
89
92
|
offset: z.coerce.number().int().min(0).default(0)
|
|
@@ -215,6 +218,7 @@ export const DealListItemSchema = z.object({
|
|
|
215
218
|
// acq_deals columns
|
|
216
219
|
id: z.string(),
|
|
217
220
|
organization_id: z.string(),
|
|
221
|
+
client_id: z.string().nullable().optional(),
|
|
218
222
|
contact_id: z.string().nullable(),
|
|
219
223
|
contact_email: z.string(),
|
|
220
224
|
pipeline_key: z.string(),
|
|
@@ -304,12 +308,39 @@ export const DealConversationSchema = z.object({
|
|
|
304
308
|
messages: z.array(ConversationMessageSchema)
|
|
305
309
|
})
|
|
306
310
|
|
|
311
|
+
export const DealLineageListRefSchema = z.object({
|
|
312
|
+
id: z.string(),
|
|
313
|
+
name: z.string(),
|
|
314
|
+
status: z.string()
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
export const DealLineageProjectRefSchema = z.object({
|
|
318
|
+
id: z.string(),
|
|
319
|
+
name: z.string(),
|
|
320
|
+
kind: z.string(),
|
|
321
|
+
status: z.string(),
|
|
322
|
+
updatedAt: z.string()
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
export const DealLineageClientRefSchema = z.object({
|
|
326
|
+
id: z.string(),
|
|
327
|
+
name: z.string(),
|
|
328
|
+
status: z.string()
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
export const DealLineageSchema = z.object({
|
|
332
|
+
list: DealLineageListRefSchema.nullable(),
|
|
333
|
+
projects: z.array(DealLineageProjectRefSchema),
|
|
334
|
+
client: DealLineageClientRefSchema.nullable()
|
|
335
|
+
})
|
|
336
|
+
|
|
307
337
|
/**
|
|
308
338
|
* Deal detail shape — currently the same as a list item (full joined record).
|
|
309
339
|
* Additive fields keep existing DealListItem callers compatible.
|
|
310
340
|
*/
|
|
311
341
|
export const DealDetailResponseSchema = DealListItemSchema.extend({
|
|
312
|
-
conversation: DealConversationSchema
|
|
342
|
+
conversation: DealConversationSchema,
|
|
343
|
+
lineage: DealLineageSchema.optional()
|
|
313
344
|
})
|
|
314
345
|
|
|
315
346
|
/**
|
|
@@ -382,6 +413,10 @@ export const DealSchemas = {
|
|
|
382
413
|
DealSummaryResponse: DealSummaryResponseSchema,
|
|
383
414
|
DealLookupResponse: DealLookupResponseSchema,
|
|
384
415
|
ConversationMessage: ConversationMessageSchema,
|
|
416
|
+
DealLineageListRef: DealLineageListRefSchema,
|
|
417
|
+
DealLineageProjectRef: DealLineageProjectRefSchema,
|
|
418
|
+
DealLineageClientRef: DealLineageClientRefSchema,
|
|
419
|
+
DealLineage: DealLineageSchema,
|
|
385
420
|
DealDetailResponse: DealDetailResponseSchema,
|
|
386
421
|
DealNoteResponse: DealNoteResponseSchema,
|
|
387
422
|
DealNoteListResponse: DealNoteListResponseSchema,
|
|
@@ -415,6 +450,10 @@ export type DealSummaryResponse = z.infer<typeof DealSummaryResponseSchema>
|
|
|
415
450
|
export type DealLookupItem = z.infer<typeof DealLookupItemSchema>
|
|
416
451
|
export type DealLookupResponse = z.infer<typeof DealLookupResponseSchema>
|
|
417
452
|
export type ConversationMessage = z.infer<typeof ConversationMessageSchema>
|
|
453
|
+
export type DealLineageListRef = z.infer<typeof DealLineageListRefSchema>
|
|
454
|
+
export type DealLineageProjectRef = z.infer<typeof DealLineageProjectRefSchema>
|
|
455
|
+
export type DealLineageClientRef = z.infer<typeof DealLineageClientRefSchema>
|
|
456
|
+
export type DealLineage = z.infer<typeof DealLineageSchema>
|
|
418
457
|
export type DealDetailResponse = z.infer<typeof DealDetailResponseSchema>
|
|
419
458
|
export type DealNoteResponse = z.infer<typeof DealNoteResponseSchema>
|
|
420
459
|
export type DealNoteListResponse = z.infer<typeof DealNoteListResponseSchema>
|
|
@@ -732,6 +771,30 @@ export const ListTelemetryResponseSchema = ListTelemetrySchema
|
|
|
732
771
|
|
|
733
772
|
export const ListTelemetryListResponseSchema = z.array(ListTelemetrySchema)
|
|
734
773
|
|
|
774
|
+
const QueryBooleanSchema = z.preprocess((value) => {
|
|
775
|
+
if (value === 'true' || value === '1' || value === true) return true
|
|
776
|
+
if (value === 'false' || value === '0' || value === false) return false
|
|
777
|
+
return value
|
|
778
|
+
}, z.boolean())
|
|
779
|
+
|
|
780
|
+
export const ListReadQuerySchema = z
|
|
781
|
+
.object({
|
|
782
|
+
status: ListStatusSchema.optional(),
|
|
783
|
+
batch: z.string().trim().min(1).max(255).optional(),
|
|
784
|
+
vertical: z.string().trim().min(1).max(255).optional(),
|
|
785
|
+
limit: z.coerce.number().int().min(1).max(500).optional(),
|
|
786
|
+
offset: z.coerce.number().int().min(0).optional()
|
|
787
|
+
})
|
|
788
|
+
.strict()
|
|
789
|
+
|
|
790
|
+
export const GetListQuerySchema = z
|
|
791
|
+
.object({
|
|
792
|
+
includeDeals: QueryBooleanSchema.default(true),
|
|
793
|
+
includeProgress: QueryBooleanSchema.default(false),
|
|
794
|
+
dealLimit: z.coerce.number().int().min(0).max(100).default(25)
|
|
795
|
+
})
|
|
796
|
+
.strict()
|
|
797
|
+
|
|
735
798
|
/**
|
|
736
799
|
* Per-stage progress aggregate for a single pipeline stage.
|
|
737
800
|
* `attempted` counts terminal statuses, including success, no-result, skipped,
|
|
@@ -761,6 +824,47 @@ export const ListProgressResponseSchema = z.object({
|
|
|
761
824
|
byContactStage: z.record(z.string(), ListStageProgressSchema)
|
|
762
825
|
})
|
|
763
826
|
|
|
827
|
+
export const AcqListDealRefSchema = z.object({
|
|
828
|
+
id: z.string(),
|
|
829
|
+
contactEmail: z.string(),
|
|
830
|
+
stageKey: z.string().nullable(),
|
|
831
|
+
stateKey: z.string().nullable(),
|
|
832
|
+
sourceType: z.string().nullable(),
|
|
833
|
+
lastActivityAt: z.string()
|
|
834
|
+
})
|
|
835
|
+
|
|
836
|
+
export const AcqListLineageSchema = z.object({
|
|
837
|
+
deals: z.object({
|
|
838
|
+
total: z.number().int().min(0),
|
|
839
|
+
refs: z.array(AcqListDealRefSchema),
|
|
840
|
+
truncated: z.boolean()
|
|
841
|
+
})
|
|
842
|
+
})
|
|
843
|
+
|
|
844
|
+
export const AcqListDetailResponseSchema = AcqListResponseSchema.extend({
|
|
845
|
+
lineage: AcqListLineageSchema.optional(),
|
|
846
|
+
progress: ListProgressResponseSchema.optional()
|
|
847
|
+
})
|
|
848
|
+
|
|
849
|
+
export const AcqListStatusListItemSchema = z.object({
|
|
850
|
+
listId: z.string(),
|
|
851
|
+
name: z.string(),
|
|
852
|
+
status: ListStatusSchema,
|
|
853
|
+
totalCompanies: z.number().int().min(0),
|
|
854
|
+
totalContacts: z.number().int().min(0),
|
|
855
|
+
totalDeals: z.number().int().min(0),
|
|
856
|
+
createdAt: z.string()
|
|
857
|
+
})
|
|
858
|
+
|
|
859
|
+
export const AcqListStatusResponseSchema = z.object({
|
|
860
|
+
totalLists: z.number().int().min(0),
|
|
861
|
+
totalCompanies: z.number().int().min(0),
|
|
862
|
+
totalContacts: z.number().int().min(0),
|
|
863
|
+
totalDeals: z.number().int().min(0),
|
|
864
|
+
byStatus: z.record(z.string(), z.number().int().min(0)),
|
|
865
|
+
lists: z.array(AcqListStatusListItemSchema)
|
|
866
|
+
})
|
|
867
|
+
|
|
764
868
|
/**
|
|
765
869
|
* Row from acq_list_executions joined with the execution summary,
|
|
766
870
|
* shaped for the /lists/:id/executions response.
|
|
@@ -781,12 +885,6 @@ export const ListExecutionsResponseSchema = z.array(ListExecutionSummarySchema)
|
|
|
781
885
|
// Company / Contact API Schemas
|
|
782
886
|
// ---------------------------------------------------------------------------
|
|
783
887
|
|
|
784
|
-
const QueryBooleanSchema = z.preprocess((value) => {
|
|
785
|
-
if (value === 'true' || value === '1' || value === true) return true
|
|
786
|
-
if (value === 'false' || value === '0' || value === false) return false
|
|
787
|
-
return value
|
|
788
|
-
}, z.boolean())
|
|
789
|
-
|
|
790
888
|
export const AcqCompanyStatusSchema = z.enum(['active', 'invalid'])
|
|
791
889
|
export const AcqContactStatusSchema = z.enum(['active', 'invalid'])
|
|
792
890
|
export const AcqEmailValidSchema = z.enum(['VALID', 'INVALID', 'RISKY', 'UNKNOWN'])
|
|
@@ -831,6 +929,7 @@ export const ListContactsQuerySchema = z
|
|
|
831
929
|
export const CreateCompanyRequestSchema = z
|
|
832
930
|
.object({
|
|
833
931
|
name: z.string().trim().min(1).max(255),
|
|
932
|
+
clientId: UuidSchema.nullable().optional(),
|
|
834
933
|
domain: z.string().trim().min(1).max(255).optional(),
|
|
835
934
|
linkedinUrl: z.string().trim().url().optional(),
|
|
836
935
|
website: z.string().trim().url().optional(),
|
|
@@ -849,6 +948,7 @@ export const CreateCompanyRequestSchema = z
|
|
|
849
948
|
export const UpdateCompanyRequestSchema = z
|
|
850
949
|
.object({
|
|
851
950
|
name: z.string().trim().min(1).max(255).optional(),
|
|
951
|
+
clientId: UuidSchema.nullable().optional(),
|
|
852
952
|
domain: z.string().trim().min(1).max(255).optional(),
|
|
853
953
|
linkedinUrl: z.string().trim().url().optional(),
|
|
854
954
|
website: z.string().trim().url().optional(),
|
|
@@ -870,6 +970,7 @@ export const UpdateCompanyRequestSchema = z
|
|
|
870
970
|
.refine(
|
|
871
971
|
(data) =>
|
|
872
972
|
data.name !== undefined ||
|
|
973
|
+
data.clientId !== undefined ||
|
|
873
974
|
data.domain !== undefined ||
|
|
874
975
|
data.linkedinUrl !== undefined ||
|
|
875
976
|
data.website !== undefined ||
|
|
@@ -894,6 +995,7 @@ export const UpdateCompanyRequestSchema = z
|
|
|
894
995
|
export const CreateContactRequestSchema = z
|
|
895
996
|
.object({
|
|
896
997
|
email: z.string().trim().email(),
|
|
998
|
+
clientId: UuidSchema.nullable().optional(),
|
|
897
999
|
companyId: UuidSchema.optional(),
|
|
898
1000
|
firstName: z.string().trim().min(1).max(255).optional(),
|
|
899
1001
|
lastName: z.string().trim().min(1).max(255).optional(),
|
|
@@ -909,6 +1011,7 @@ export const CreateContactRequestSchema = z
|
|
|
909
1011
|
export const UpdateContactRequestSchema = z
|
|
910
1012
|
.object({
|
|
911
1013
|
companyId: UuidSchema.optional(),
|
|
1014
|
+
clientId: UuidSchema.nullable().optional(),
|
|
912
1015
|
emailValid: AcqEmailValidSchema.optional(),
|
|
913
1016
|
firstName: z.string().trim().min(1).max(255).optional(),
|
|
914
1017
|
lastName: z.string().trim().min(1).max(255).optional(),
|
|
@@ -926,6 +1029,7 @@ export const UpdateContactRequestSchema = z
|
|
|
926
1029
|
.refine(
|
|
927
1030
|
(data) =>
|
|
928
1031
|
data.companyId !== undefined ||
|
|
1032
|
+
data.clientId !== undefined ||
|
|
929
1033
|
data.emailValid !== undefined ||
|
|
930
1034
|
data.firstName !== undefined ||
|
|
931
1035
|
data.lastName !== undefined ||
|
|
@@ -946,6 +1050,7 @@ export const UpdateContactRequestSchema = z
|
|
|
946
1050
|
export const AcqCompanyResponseSchema = z.object({
|
|
947
1051
|
id: z.string(),
|
|
948
1052
|
organizationId: z.string(),
|
|
1053
|
+
clientId: z.string().nullable().optional(),
|
|
949
1054
|
name: z.string(),
|
|
950
1055
|
domain: z.string().nullable(),
|
|
951
1056
|
linkedinUrl: z.string().nullable(),
|
|
@@ -996,6 +1101,7 @@ export const AcqContactCompanySummarySchema = z.object({
|
|
|
996
1101
|
export const AcqContactResponseSchema = z.object({
|
|
997
1102
|
id: z.string(),
|
|
998
1103
|
organizationId: z.string(),
|
|
1104
|
+
clientId: z.string().nullable().optional(),
|
|
999
1105
|
companyId: z.string().nullable(),
|
|
1000
1106
|
email: z.string(),
|
|
1001
1107
|
emailValid: AcqEmailValidSchema.nullable(),
|
|
@@ -1297,6 +1403,8 @@ export const AcqListSchemas = {
|
|
|
1297
1403
|
ListTelemetry: ListTelemetrySchema,
|
|
1298
1404
|
|
|
1299
1405
|
// Requests
|
|
1406
|
+
ListReadQuery: ListReadQuerySchema,
|
|
1407
|
+
GetListQuery: GetListQuerySchema,
|
|
1300
1408
|
CreateListRequest: CreateListRequestSchema,
|
|
1301
1409
|
UpdateListRequest: UpdateListRequestSchema,
|
|
1302
1410
|
UpdateListStatusRequest: UpdateListStatusRequestSchema,
|
|
@@ -1308,7 +1416,11 @@ export const AcqListSchemas = {
|
|
|
1308
1416
|
|
|
1309
1417
|
// Responses
|
|
1310
1418
|
AcqListResponse: AcqListResponseSchema,
|
|
1419
|
+
AcqListDetailResponse: AcqListDetailResponseSchema,
|
|
1311
1420
|
AcqListListResponse: AcqListListResponseSchema,
|
|
1421
|
+
AcqListDealRef: AcqListDealRefSchema,
|
|
1422
|
+
AcqListLineage: AcqListLineageSchema,
|
|
1423
|
+
AcqListStatusResponse: AcqListStatusResponseSchema,
|
|
1312
1424
|
ListTelemetryResponse: ListTelemetryResponseSchema,
|
|
1313
1425
|
ListTelemetryListResponse: ListTelemetryListResponseSchema,
|
|
1314
1426
|
ListExecutionsResponse: ListExecutionsResponseSchema,
|
|
@@ -1387,6 +1499,8 @@ export type ProcessingStageStatus = z.infer<typeof ProcessingStageStatusSchema>
|
|
|
1387
1499
|
export type ListStageCountsInput = z.infer<typeof ListStageCountsSchema>['stageCounts']
|
|
1388
1500
|
export type ListTelemetryInput = z.infer<typeof ListTelemetrySchema>
|
|
1389
1501
|
export type ListIdParams = z.infer<typeof ListIdParamsSchema>
|
|
1502
|
+
export type ListReadQuery = z.infer<typeof ListReadQuerySchema>
|
|
1503
|
+
export type GetListQuery = z.infer<typeof GetListQuerySchema>
|
|
1390
1504
|
export type CreateListRequest = z.infer<typeof CreateListRequestSchema>
|
|
1391
1505
|
export type UpdateListRequest = z.infer<typeof UpdateListRequestSchema>
|
|
1392
1506
|
export type UpdateListStatusRequest = z.infer<typeof UpdateListStatusRequestSchema>
|
|
@@ -1396,7 +1510,11 @@ export type RemoveCompaniesFromListRequest = z.infer<typeof RemoveCompaniesFromL
|
|
|
1396
1510
|
export type AddContactsToListRequest = z.infer<typeof AddContactsToListRequestSchema>
|
|
1397
1511
|
export type RecordListExecutionRequest = z.infer<typeof RecordListExecutionRequestSchema>
|
|
1398
1512
|
export type AcqListResponse = z.infer<typeof AcqListResponseSchema>
|
|
1513
|
+
export type AcqListDetailResponse = z.infer<typeof AcqListDetailResponseSchema>
|
|
1399
1514
|
export type AcqListListResponse = z.infer<typeof AcqListListResponseSchema>
|
|
1515
|
+
export type AcqListDealRef = z.infer<typeof AcqListDealRefSchema>
|
|
1516
|
+
export type AcqListLineage = z.infer<typeof AcqListLineageSchema>
|
|
1517
|
+
export type AcqListStatusResponse = z.infer<typeof AcqListStatusResponseSchema>
|
|
1400
1518
|
export type ListTelemetryResponse = z.infer<typeof ListTelemetryResponseSchema>
|
|
1401
1519
|
export type ListTelemetryListResponse = z.infer<typeof ListTelemetryListResponseSchema>
|
|
1402
1520
|
export type ListExecutionSummaryInput = z.infer<typeof ListExecutionSummarySchema>
|
|
@@ -61,6 +61,8 @@ export {
|
|
|
61
61
|
ListStageCountsSchema,
|
|
62
62
|
ListTelemetrySchema,
|
|
63
63
|
ListIdParamsSchema,
|
|
64
|
+
ListReadQuerySchema,
|
|
65
|
+
GetListQuerySchema,
|
|
64
66
|
CreateListRequestSchema,
|
|
65
67
|
UpdateListRequestSchema,
|
|
66
68
|
UpdateListStatusRequestSchema,
|
|
@@ -70,7 +72,11 @@ export {
|
|
|
70
72
|
AddContactsToListRequestSchema,
|
|
71
73
|
RecordListExecutionRequestSchema,
|
|
72
74
|
AcqListResponseSchema,
|
|
75
|
+
AcqListDetailResponseSchema,
|
|
73
76
|
AcqListListResponseSchema,
|
|
77
|
+
AcqListDealRefSchema,
|
|
78
|
+
AcqListLineageSchema,
|
|
79
|
+
AcqListStatusResponseSchema,
|
|
74
80
|
ListTelemetryResponseSchema,
|
|
75
81
|
ListTelemetryListResponseSchema,
|
|
76
82
|
ListExecutionSummarySchema,
|
|
@@ -144,6 +150,8 @@ export {
|
|
|
144
150
|
type ListStageCountsInput,
|
|
145
151
|
type ListTelemetryInput,
|
|
146
152
|
type ListIdParams,
|
|
153
|
+
type ListReadQuery,
|
|
154
|
+
type GetListQuery,
|
|
147
155
|
type CreateListRequest,
|
|
148
156
|
type UpdateListRequest,
|
|
149
157
|
type UpdateListStatusRequest,
|
|
@@ -153,7 +161,11 @@ export {
|
|
|
153
161
|
type AddContactsToListRequest,
|
|
154
162
|
type RecordListExecutionRequest,
|
|
155
163
|
type AcqListResponse,
|
|
164
|
+
type AcqListDetailResponse,
|
|
156
165
|
type AcqListListResponse,
|
|
166
|
+
type AcqListDealRef,
|
|
167
|
+
type AcqListLineage,
|
|
168
|
+
type AcqListStatusResponse,
|
|
157
169
|
type ListTelemetryResponse,
|
|
158
170
|
type ListTelemetryListResponse,
|
|
159
171
|
type ListExecutionSummaryInput,
|