@kelpie/schemas 0.1.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.
Files changed (158) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +33 -0
  3. package/dist/account.d.ts +79 -0
  4. package/dist/account.d.ts.map +1 -0
  5. package/dist/account.js +66 -0
  6. package/dist/account.js.map +1 -0
  7. package/dist/activity.d.ts +23 -0
  8. package/dist/activity.d.ts.map +1 -0
  9. package/dist/activity.js +27 -0
  10. package/dist/activity.js.map +1 -0
  11. package/dist/agentTask.d.ts +97 -0
  12. package/dist/agentTask.d.ts.map +1 -0
  13. package/dist/agentTask.js +127 -0
  14. package/dist/agentTask.js.map +1 -0
  15. package/dist/candidate.d.ts +39 -0
  16. package/dist/candidate.d.ts.map +1 -0
  17. package/dist/candidate.js +40 -0
  18. package/dist/candidate.js.map +1 -0
  19. package/dist/company.d.ts +38 -0
  20. package/dist/company.d.ts.map +1 -0
  21. package/dist/company.js +57 -0
  22. package/dist/company.js.map +1 -0
  23. package/dist/dashboard.d.ts +112 -0
  24. package/dist/dashboard.d.ts.map +1 -0
  25. package/dist/dashboard.js +165 -0
  26. package/dist/dashboard.js.map +1 -0
  27. package/dist/deal.d.ts +40 -0
  28. package/dist/deal.d.ts.map +1 -0
  29. package/dist/deal.js +59 -0
  30. package/dist/deal.js.map +1 -0
  31. package/dist/decision.d.ts +46 -0
  32. package/dist/decision.d.ts.map +1 -0
  33. package/dist/decision.js +48 -0
  34. package/dist/decision.js.map +1 -0
  35. package/dist/form.d.ts +97 -0
  36. package/dist/form.d.ts.map +1 -0
  37. package/dist/form.js +98 -0
  38. package/dist/form.js.map +1 -0
  39. package/dist/formSubmission.d.ts +47 -0
  40. package/dist/formSubmission.d.ts.map +1 -0
  41. package/dist/formSubmission.js +47 -0
  42. package/dist/formSubmission.js.map +1 -0
  43. package/dist/handbookPage.d.ts +52 -0
  44. package/dist/handbookPage.d.ts.map +1 -0
  45. package/dist/handbookPage.js +56 -0
  46. package/dist/handbookPage.js.map +1 -0
  47. package/dist/importExport.d.ts +143 -0
  48. package/dist/importExport.d.ts.map +1 -0
  49. package/dist/importExport.js +239 -0
  50. package/dist/importExport.js.map +1 -0
  51. package/dist/index.d.ts +75 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +45 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/invite.d.ts +35 -0
  56. package/dist/invite.d.ts.map +1 -0
  57. package/dist/invite.js +31 -0
  58. package/dist/invite.js.map +1 -0
  59. package/dist/mcpTool.d.ts +26 -0
  60. package/dist/mcpTool.d.ts.map +1 -0
  61. package/dist/mcpTool.js +13 -0
  62. package/dist/mcpTool.js.map +1 -0
  63. package/dist/member.d.ts +26 -0
  64. package/dist/member.d.ts.map +1 -0
  65. package/dist/member.js +24 -0
  66. package/dist/member.js.map +1 -0
  67. package/dist/moduleSetting.d.ts +19 -0
  68. package/dist/moduleSetting.d.ts.map +1 -0
  69. package/dist/moduleSetting.js +16 -0
  70. package/dist/moduleSetting.js.map +1 -0
  71. package/dist/note.d.ts +34 -0
  72. package/dist/note.d.ts.map +1 -0
  73. package/dist/note.js +35 -0
  74. package/dist/note.js.map +1 -0
  75. package/dist/opportunity.d.ts +30 -0
  76. package/dist/opportunity.d.ts.map +1 -0
  77. package/dist/opportunity.js +41 -0
  78. package/dist/opportunity.js.map +1 -0
  79. package/dist/partnership.d.ts +36 -0
  80. package/dist/partnership.d.ts.map +1 -0
  81. package/dist/partnership.js +50 -0
  82. package/dist/partnership.js.map +1 -0
  83. package/dist/person.d.ts +45 -0
  84. package/dist/person.d.ts.map +1 -0
  85. package/dist/person.js +60 -0
  86. package/dist/person.js.map +1 -0
  87. package/dist/pipelineStage.d.ts +29 -0
  88. package/dist/pipelineStage.d.ts.map +1 -0
  89. package/dist/pipelineStage.js +38 -0
  90. package/dist/pipelineStage.js.map +1 -0
  91. package/dist/planItem.d.ts +43 -0
  92. package/dist/planItem.d.ts.map +1 -0
  93. package/dist/planItem.js +44 -0
  94. package/dist/planItem.js.map +1 -0
  95. package/dist/position.d.ts +22 -0
  96. package/dist/position.d.ts.map +1 -0
  97. package/dist/position.js +25 -0
  98. package/dist/position.js.map +1 -0
  99. package/dist/raise.d.ts +38 -0
  100. package/dist/raise.d.ts.map +1 -0
  101. package/dist/raise.js +53 -0
  102. package/dist/raise.js.map +1 -0
  103. package/dist/role.d.ts +21 -0
  104. package/dist/role.d.ts.map +1 -0
  105. package/dist/role.js +21 -0
  106. package/dist/role.js.map +1 -0
  107. package/dist/search.d.ts +41 -0
  108. package/dist/search.d.ts.map +1 -0
  109. package/dist/search.js +41 -0
  110. package/dist/search.js.map +1 -0
  111. package/dist/session.d.ts +92 -0
  112. package/dist/session.d.ts.map +1 -0
  113. package/dist/session.js +67 -0
  114. package/dist/session.js.map +1 -0
  115. package/dist/values.d.ts +216 -0
  116. package/dist/values.d.ts.map +1 -0
  117. package/dist/values.js +329 -0
  118. package/dist/values.js.map +1 -0
  119. package/dist/webhook.d.ts +85 -0
  120. package/dist/webhook.d.ts.map +1 -0
  121. package/dist/webhook.js +75 -0
  122. package/dist/webhook.js.map +1 -0
  123. package/dist/wire.d.ts +40 -0
  124. package/dist/wire.d.ts.map +1 -0
  125. package/dist/wire.js +40 -0
  126. package/dist/wire.js.map +1 -0
  127. package/package.json +51 -0
  128. package/src/account.ts +149 -0
  129. package/src/activity.ts +52 -0
  130. package/src/agentTask.ts +254 -0
  131. package/src/candidate.ts +83 -0
  132. package/src/company.ts +98 -0
  133. package/src/dashboard.ts +307 -0
  134. package/src/deal.ts +102 -0
  135. package/src/decision.ts +106 -0
  136. package/src/form.ts +217 -0
  137. package/src/formSubmission.ts +99 -0
  138. package/src/handbookPage.ts +99 -0
  139. package/src/importExport.ts +339 -0
  140. package/src/index.ts +324 -0
  141. package/src/invite.ts +69 -0
  142. package/src/mcpTool.ts +32 -0
  143. package/src/member.ts +53 -0
  144. package/src/moduleSetting.ts +37 -0
  145. package/src/note.ts +73 -0
  146. package/src/opportunity.ts +74 -0
  147. package/src/partnership.ts +89 -0
  148. package/src/person.ts +116 -0
  149. package/src/pipelineStage.ts +71 -0
  150. package/src/planItem.ts +91 -0
  151. package/src/position.ts +50 -0
  152. package/src/raise.ts +94 -0
  153. package/src/role.ts +45 -0
  154. package/src/search.ts +86 -0
  155. package/src/session.ts +177 -0
  156. package/src/values.ts +427 -0
  157. package/src/webhook.ts +164 -0
  158. package/src/wire.ts +51 -0
@@ -0,0 +1,57 @@
1
+ import { z } from 'zod';
2
+ import { ACCOUNT_TYPES, COMPANY_STAGES, ICP_FITS, SIZE_BANDS } from './values.js';
3
+ import { definedFields, idSchema, recordTimestamps } from './wire.js';
4
+ export const companySchema = z
5
+ .object({
6
+ id: idSchema,
7
+ name: z.string(),
8
+ domain: z.string().nullable(),
9
+ industry: z.string().nullable(),
10
+ description: z.string(),
11
+ stage: z.enum(COMPANY_STAGES),
12
+ size_band: z.enum(SIZE_BANDS),
13
+ hq: z.string().nullable(),
14
+ website: z.string().nullable(),
15
+ account_type: z.enum(ACCOUNT_TYPES),
16
+ icp_fit: z.enum(ICP_FITS),
17
+ tech_stack: z.array(z.string()),
18
+ summary: z.string(),
19
+ tags: z.array(z.string()),
20
+ ...recordTimestamps,
21
+ })
22
+ .transform((wire) => ({
23
+ id: wire.id,
24
+ name: wire.name,
25
+ domain: wire.domain,
26
+ industry: wire.industry,
27
+ description: wire.description,
28
+ stage: wire.stage,
29
+ sizeBand: wire.size_band,
30
+ hq: wire.hq,
31
+ website: wire.website,
32
+ accountType: wire.account_type,
33
+ icpFit: wire.icp_fit,
34
+ techStack: wire.tech_stack,
35
+ summary: wire.summary,
36
+ tags: wire.tags,
37
+ createdAt: wire.created_at,
38
+ updatedAt: wire.updated_at,
39
+ }));
40
+ export function companyBody(input) {
41
+ return definedFields({
42
+ name: input.name,
43
+ domain: input.domain,
44
+ industry: input.industry,
45
+ description: input.description,
46
+ stage: input.stage,
47
+ size_band: input.sizeBand,
48
+ hq: input.hq,
49
+ website: input.website,
50
+ account_type: input.accountType,
51
+ icp_fit: input.icpFit,
52
+ tech_stack: input.techStack,
53
+ summary: input.summary,
54
+ tags: input.tags,
55
+ });
56
+ }
57
+ //# sourceMappingURL=company.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company.js","sourceRoot":"","sources":["../src/company.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAsBrE,MAAM,CAAC,MAAM,aAAa,GAAgC,CAAC;KACxD,MAAM,CAAC;IACN,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;IAC7B,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;IAC7B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC;IACnC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAE,CAAC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AAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { z } from 'zod';
2
+ import type { ActivityKind, PipelineKind, PlanItemStatus, RecordTargetType } from './values.ts';
3
+ /**
4
+ * Wire shape for `GET /v1/dashboard`. Read-only, so there is no body builder.
5
+ *
6
+ * One object rather than a list envelope: the workspace home is several
7
+ * questions answered together, and two of them — a contact going cold, a
8
+ * partnership touchpoint at hand — are not questions any resource list asks.
9
+ *
10
+ * Every attention signal is `{ total, items }`. `total` counts every matching
11
+ * row; `items` holds however many the request's `?limit=` allowed. A page
12
+ * showing four rows still reports the true count beside them.
13
+ *
14
+ * Rows that point at another record carry `targetName` already resolved. The
15
+ * dashboard is the one place where every row points somewhere different, so
16
+ * naming them client-side would mean a request per row.
17
+ */
18
+ /** A row naming a record it is not itself. `targetName` is null when the target no longer resolves. */
19
+ export interface TargetRef {
20
+ readonly targetType: RecordTargetType;
21
+ readonly targetId: string;
22
+ readonly targetName: string | null;
23
+ }
24
+ export interface DashboardSignal<Item> {
25
+ readonly total: number;
26
+ readonly items: readonly Item[];
27
+ }
28
+ export interface DashboardPipeline {
29
+ readonly kind: PipelineKind;
30
+ /** Records sitting in a stage the workspace has marked open. */
31
+ readonly open: number;
32
+ }
33
+ /**
34
+ * An open plan item that is late or due inside the week.
35
+ *
36
+ * `targetType` is narrower than a `TargetRef`'s in practice — a plan item only
37
+ * attaches to the four pipelines — but it is decoded against the wider set so
38
+ * one target shape serves every signal here.
39
+ */
40
+ export interface DashboardPlanItem extends TargetRef {
41
+ readonly id: string;
42
+ /** `YYYY-MM-DD`, per `api.md` date-only fields. */
43
+ readonly date: string;
44
+ readonly title: string;
45
+ readonly ownerId: string | null;
46
+ readonly status: PlanItemStatus;
47
+ }
48
+ export interface DashboardTouchpoint {
49
+ readonly id: string;
50
+ readonly name: string;
51
+ readonly companyId: string;
52
+ /** `YYYY-MM-DD`. */
53
+ readonly nextTouchpoint: string;
54
+ /** Whether the date has already passed. Both are in the list, oldest first. */
55
+ readonly overdue: boolean;
56
+ readonly ownerId: string | null;
57
+ readonly summary: string;
58
+ }
59
+ export interface DashboardStaleContact {
60
+ readonly id: string;
61
+ readonly name: string;
62
+ readonly email: string | null;
63
+ readonly lastContactedAt: Date;
64
+ /** Whole days from the last contact to today, both read in the workspace's zone. */
65
+ readonly daysSinceContact: number;
66
+ readonly summary: string;
67
+ }
68
+ export interface DashboardActivity extends TargetRef {
69
+ readonly id: string;
70
+ readonly kind: ActivityKind;
71
+ readonly actorMemberId: string | null;
72
+ readonly actorLabel: string | null;
73
+ readonly action: string;
74
+ readonly detail: string | null;
75
+ readonly createdAt: Date;
76
+ }
77
+ export interface DashboardNote extends TargetRef {
78
+ readonly id: string;
79
+ readonly body: string;
80
+ readonly authorId: string | null;
81
+ readonly pinned: boolean;
82
+ readonly createdAt: Date;
83
+ }
84
+ export interface DashboardDecision extends TargetRef {
85
+ readonly id: string;
86
+ readonly body: string;
87
+ readonly rationale: string | null;
88
+ readonly decidedAt: Date;
89
+ readonly ownerId: string | null;
90
+ readonly dueAt: Date | null;
91
+ }
92
+ export interface Dashboard {
93
+ readonly generatedAt: Date;
94
+ /** The day every signal was measured against, `YYYY-MM-DD`. */
95
+ readonly today: string;
96
+ /** The workspace's IANA zone, which is what fixed `today`. */
97
+ readonly timezone: string;
98
+ /** How long since a contact before it counts as going cold. */
99
+ readonly staleContactDays: number;
100
+ /** How far ahead "due soon" looks. */
101
+ readonly upcomingDays: number;
102
+ readonly pipelines: readonly DashboardPipeline[];
103
+ readonly overduePlanItems: DashboardSignal<DashboardPlanItem>;
104
+ readonly dueSoonPlanItems: DashboardSignal<DashboardPlanItem>;
105
+ readonly partnershipTouchpoints: DashboardSignal<DashboardTouchpoint>;
106
+ readonly staleContacts: DashboardSignal<DashboardStaleContact>;
107
+ readonly recentActivity: readonly DashboardActivity[];
108
+ readonly recentNotes: readonly DashboardNote[];
109
+ readonly recentDecisions: readonly DashboardDecision[];
110
+ }
111
+ export declare const dashboardSchema: z.ZodType<Dashboard, unknown>;
112
+ //# sourceMappingURL=dashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQvB,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAG/F;;;;;;;;;;;;;;GAcG;AAEH,uGAAuG;AACvG,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACnC;AAoBD,MAAM,WAAW,eAAe,CAAC,IAAI;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;CAChC;AAOD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAOD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAChC;AAoBD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAA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AAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAgCvD,CAAA"}
@@ -0,0 +1,165 @@
1
+ import { z } from 'zod';
2
+ import { ACTIVITY_KINDS, PIPELINE_KINDS, PLAN_ITEM_STATUSES, RECORD_TARGET_TYPES, } from './values.js';
3
+ import { idSchema, nullableTimestampSchema, timestampSchema } from './wire.js';
4
+ const targetRef = {
5
+ target_type: z.enum(RECORD_TARGET_TYPES),
6
+ target_id: idSchema,
7
+ target_name: z.string().nullable(),
8
+ };
9
+ function toTargetRef(wire) {
10
+ return {
11
+ targetType: wire.target_type,
12
+ targetId: wire.target_id,
13
+ targetName: wire.target_name,
14
+ };
15
+ }
16
+ /** `{ total, items }` over one item schema. Generic so each signal declares only its row. */
17
+ function signalSchema(item) {
18
+ return z.object({ total: z.number().int(), items: z.array(item) });
19
+ }
20
+ const dashboardPipelineSchema = z.object({
21
+ kind: z.enum(PIPELINE_KINDS),
22
+ open: z.number().int(),
23
+ });
24
+ const dashboardPlanItemSchema = z
25
+ .object({
26
+ ...targetRef,
27
+ id: idSchema,
28
+ date: z.string(),
29
+ title: z.string(),
30
+ owner_id: idSchema.nullable(),
31
+ status: z.enum(PLAN_ITEM_STATUSES),
32
+ })
33
+ .transform((wire) => ({
34
+ ...toTargetRef(wire),
35
+ id: wire.id,
36
+ date: wire.date,
37
+ title: wire.title,
38
+ ownerId: wire.owner_id,
39
+ status: wire.status,
40
+ }));
41
+ const dashboardTouchpointSchema = z
42
+ .object({
43
+ id: idSchema,
44
+ name: z.string(),
45
+ company_id: idSchema,
46
+ next_touchpoint: z.string(),
47
+ overdue: z.boolean(),
48
+ owner_id: idSchema.nullable(),
49
+ summary: z.string(),
50
+ })
51
+ .transform((wire) => ({
52
+ id: wire.id,
53
+ name: wire.name,
54
+ companyId: wire.company_id,
55
+ nextTouchpoint: wire.next_touchpoint,
56
+ overdue: wire.overdue,
57
+ ownerId: wire.owner_id,
58
+ summary: wire.summary,
59
+ }));
60
+ const dashboardStaleContactSchema = z
61
+ .object({
62
+ id: idSchema,
63
+ name: z.string(),
64
+ email: z.string().nullable(),
65
+ last_contacted_at: timestampSchema,
66
+ days_since_contact: z.number().int(),
67
+ summary: z.string(),
68
+ })
69
+ .transform((wire) => ({
70
+ id: wire.id,
71
+ name: wire.name,
72
+ email: wire.email,
73
+ lastContactedAt: wire.last_contacted_at,
74
+ daysSinceContact: wire.days_since_contact,
75
+ summary: wire.summary,
76
+ }));
77
+ const dashboardActivitySchema = z
78
+ .object({
79
+ ...targetRef,
80
+ id: idSchema,
81
+ kind: z.enum(ACTIVITY_KINDS),
82
+ actor_member_id: idSchema.nullable(),
83
+ actor_label: z.string().nullable(),
84
+ action: z.string(),
85
+ detail: z.string().nullable(),
86
+ created_at: timestampSchema,
87
+ })
88
+ .transform((wire) => ({
89
+ ...toTargetRef(wire),
90
+ id: wire.id,
91
+ kind: wire.kind,
92
+ actorMemberId: wire.actor_member_id,
93
+ actorLabel: wire.actor_label,
94
+ action: wire.action,
95
+ detail: wire.detail,
96
+ createdAt: wire.created_at,
97
+ }));
98
+ const dashboardNoteSchema = z
99
+ .object({
100
+ ...targetRef,
101
+ id: idSchema,
102
+ body: z.string(),
103
+ author_id: idSchema.nullable(),
104
+ pinned: z.boolean(),
105
+ created_at: timestampSchema,
106
+ })
107
+ .transform((wire) => ({
108
+ ...toTargetRef(wire),
109
+ id: wire.id,
110
+ body: wire.body,
111
+ authorId: wire.author_id,
112
+ pinned: wire.pinned,
113
+ createdAt: wire.created_at,
114
+ }));
115
+ const dashboardDecisionSchema = z
116
+ .object({
117
+ ...targetRef,
118
+ id: idSchema,
119
+ body: z.string(),
120
+ rationale: z.string().nullable(),
121
+ decided_at: timestampSchema,
122
+ owner_id: idSchema.nullable(),
123
+ due_at: nullableTimestampSchema,
124
+ })
125
+ .transform((wire) => ({
126
+ ...toTargetRef(wire),
127
+ id: wire.id,
128
+ body: wire.body,
129
+ rationale: wire.rationale,
130
+ decidedAt: wire.decided_at,
131
+ ownerId: wire.owner_id,
132
+ dueAt: wire.due_at,
133
+ }));
134
+ export const dashboardSchema = z
135
+ .object({
136
+ generated_at: timestampSchema,
137
+ today: z.string(),
138
+ timezone: z.string(),
139
+ stale_contact_days: z.number().int(),
140
+ upcoming_days: z.number().int(),
141
+ pipelines: z.array(dashboardPipelineSchema),
142
+ overdue_plan_items: signalSchema(dashboardPlanItemSchema),
143
+ due_soon_plan_items: signalSchema(dashboardPlanItemSchema),
144
+ partnership_touchpoints: signalSchema(dashboardTouchpointSchema),
145
+ stale_contacts: signalSchema(dashboardStaleContactSchema),
146
+ recent_activity: z.array(dashboardActivitySchema),
147
+ recent_notes: z.array(dashboardNoteSchema),
148
+ recent_decisions: z.array(dashboardDecisionSchema),
149
+ })
150
+ .transform((wire) => ({
151
+ generatedAt: wire.generated_at,
152
+ today: wire.today,
153
+ timezone: wire.timezone,
154
+ staleContactDays: wire.stale_contact_days,
155
+ upcomingDays: wire.upcoming_days,
156
+ pipelines: wire.pipelines,
157
+ overduePlanItems: wire.overdue_plan_items,
158
+ dueSoonPlanItems: wire.due_soon_plan_items,
159
+ partnershipTouchpoints: wire.partnership_touchpoints,
160
+ staleContacts: wire.stale_contacts,
161
+ recentActivity: wire.recent_activity,
162
+ recentNotes: wire.recent_notes,
163
+ recentDecisions: wire.recent_decisions,
164
+ }));
165
+ //# sourceMappingURL=dashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard.js","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAyB9E,MAAM,SAAS,GAAG;IAChB,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;IACxC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E,YAAY,CAAC,uBAAuB,CAAC;IAC1D,uBAAuB,EAAE,YAAY,CAAC,yBAAyB,CAAC;IAChE,cAAc,EAAE,YAAY,CAAC,2BAA2B,CAAC;IACzD,eAAe,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;IACjD,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;IAC1C,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;CACnD,CAAC;KACD,SAAS,CACR,CAAC,IAAI,EAAa,EAAE,CAAC,CAAC;IACpB,WAAW,EAAE,IAAI,CAAC,YAAY;IAC9B,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,gBAAgB,EAAE,IAAI,CAAC,kBAAkB;IACzC,YAAY,EAAE,IAAI,CAAC,aAAa;IAChC,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,gBAAgB,EAAE,IAAI,CAAC,kBAAkB;IACzC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB;IAC1C,sBAAsB,EAAE,IAAI,CAAC,uBAAuB;IACpD,aAAa,EAAE,IAAI,CAAC,cAAc;IAClC,cAAc,EAAE,IAAI,CAAC,eAAe;IACpC,WAAW,EAAE,IAAI,CAAC,YAAY;IAC9B,eAAe,EAAE,IAAI,CAAC,gBAAgB;CACvC,CAAC,CACH,CAAA"}
package/dist/deal.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ import type { RecordTimestamps } from './wire.ts';
3
+ /** Wire and write shapes for `/v1/deals`. */
4
+ export interface Deal extends RecordTimestamps {
5
+ readonly id: string;
6
+ readonly name: string;
7
+ readonly companyId: string;
8
+ readonly stageId: string;
9
+ readonly valueCents: number | null;
10
+ readonly currency: string | null;
11
+ readonly ownerId: string | null;
12
+ /** `YYYY-MM-DD`, per `api.md` date-only fields. */
13
+ readonly expectedClose: string | null;
14
+ readonly personIds: readonly string[];
15
+ readonly competitors: readonly string[];
16
+ readonly risks: string;
17
+ readonly whyWin: string;
18
+ readonly summary: string;
19
+ readonly tags: readonly string[];
20
+ readonly externalId: string | null;
21
+ }
22
+ export declare const dealSchema: z.ZodType<Deal, unknown>;
23
+ export interface DealInput {
24
+ readonly name?: string;
25
+ readonly companyId?: string;
26
+ readonly stageId?: string;
27
+ readonly valueCents?: number | null;
28
+ readonly currency?: string | null;
29
+ readonly ownerId?: string | null;
30
+ readonly expectedClose?: string | null;
31
+ readonly personIds?: readonly string[];
32
+ readonly competitors?: readonly string[];
33
+ readonly risks?: string;
34
+ readonly whyWin?: string;
35
+ readonly summary?: string;
36
+ readonly tags?: readonly string[];
37
+ readonly externalId?: string | null;
38
+ }
39
+ export declare function dealBody(input: DealInput): Record<string, unknown>;
40
+ //# sourceMappingURL=deal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deal.d.ts","sourceRoot":"","sources":["../src/deal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD,6CAA6C;AAE7C,MAAM,WAAW,IAAK,SAAQ,gBAAgB;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,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,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBlE"}
package/dist/deal.js ADDED
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ import { definedFields, idSchema, recordTimestamps } from './wire.js';
3
+ export const dealSchema = z
4
+ .object({
5
+ id: idSchema,
6
+ name: z.string(),
7
+ company_id: idSchema,
8
+ stage_id: idSchema,
9
+ value_cents: z.number().int().nullable(),
10
+ currency: z.string().nullable(),
11
+ owner_id: idSchema.nullable(),
12
+ expected_close: z.string().nullable(),
13
+ person_ids: z.array(idSchema),
14
+ competitors: z.array(z.string()),
15
+ risks: z.string(),
16
+ why_win: z.string(),
17
+ summary: z.string(),
18
+ tags: z.array(z.string()),
19
+ external_id: z.string().nullable(),
20
+ ...recordTimestamps,
21
+ })
22
+ .transform((wire) => ({
23
+ id: wire.id,
24
+ name: wire.name,
25
+ companyId: wire.company_id,
26
+ stageId: wire.stage_id,
27
+ valueCents: wire.value_cents,
28
+ currency: wire.currency,
29
+ ownerId: wire.owner_id,
30
+ expectedClose: wire.expected_close,
31
+ personIds: wire.person_ids,
32
+ competitors: wire.competitors,
33
+ risks: wire.risks,
34
+ whyWin: wire.why_win,
35
+ summary: wire.summary,
36
+ tags: wire.tags,
37
+ externalId: wire.external_id,
38
+ createdAt: wire.created_at,
39
+ updatedAt: wire.updated_at,
40
+ }));
41
+ export function dealBody(input) {
42
+ return definedFields({
43
+ name: input.name,
44
+ company_id: input.companyId,
45
+ stage_id: input.stageId,
46
+ value_cents: input.valueCents,
47
+ currency: input.currency,
48
+ owner_id: input.ownerId,
49
+ expected_close: input.expectedClose,
50
+ person_ids: input.personIds,
51
+ competitors: input.competitors,
52
+ risks: input.risks,
53
+ why_win: input.whyWin,
54
+ summary: input.summary,
55
+ tags: input.tags,
56
+ external_id: input.externalId,
57
+ });
58
+ }
59
+ //# sourceMappingURL=deal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deal.js","sourceR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AI,CAAC,WAAW;IAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,OAAO,EAAE,IAAI,CAAC,QAAQ;IACtB,aAAa,EAAE,IAAI,CAAC,cAAc;IAClC,SAAS,EAAE,IAAI,CAAC,UAAU;IAC1B,WAAW,EAAE,IAAI,CAAC,WAAW;IAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,MAAM,EAAE,IAAI,CAAC,OAAO;IACpB,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,UAAU,EAAE,IAAI,CAAC,WAAW;IAC5B,SAAS,EAAE,IAAI,CAAC,UAAU;IAC1B,SAAS,EAAE,IAAI,CAAC,UAAU;CAC3B,CAAC,CACH,CAAA;AAmBH,MAAM,UAAU,QAAQ,CAAC,KAAgB;IACvC,OAAO,aAAa,CAAC;QACnB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU,EAAE,KAAK,CAAC,SAAS;QAC3B,QAAQ,EAAE,KAAK,CAAC,OAAO;QACvB,WAAW,EAAE,KAAK,CAAC,UAAU;QAC7B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,OAAO;QACvB,cAAc,EAAE,KAAK,CAAC,aAAa;QACnC,UAAU,EAAE,KAAK,CAAC,SAAS;QAC3B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,MAAM;QACrB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,KAAK,CAAC,UAAU;KAC9B,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import type { RecordTargetType } from './values.ts';
3
+ import type { RecordTimestamps } from './wire.ts';
4
+ /**
5
+ * Wire and write shapes for `/v1/decisions`.
6
+ *
7
+ * A decision is what the workspace decided or promised: a commitment agents
8
+ * must not contradict, kept as a queryable record rather than note text.
9
+ *
10
+ * `ownerId` is a workspace member id, null when nobody carries the commitment.
11
+ * `dueAt` is the optional deadline on it; `decidedAt` is when it was made and is
12
+ * never null.
13
+ */
14
+ export interface Decision extends RecordTimestamps {
15
+ readonly id: string;
16
+ readonly targetType: RecordTargetType;
17
+ readonly targetId: string;
18
+ readonly body: string;
19
+ readonly rationale: string | null;
20
+ readonly decidedAt: Date;
21
+ readonly ownerId: string | null;
22
+ readonly dueAt: Date | null;
23
+ }
24
+ export declare const decisionSchema: z.ZodType<Decision, unknown>;
25
+ export interface CreateDecisionInput {
26
+ readonly targetType: RecordTargetType;
27
+ readonly targetId: string;
28
+ readonly body: string;
29
+ readonly rationale?: string | null;
30
+ /** Absent means now: most decisions are recorded as they are made. */
31
+ readonly decidedAt?: Date;
32
+ /** Absent means the caller; null means nobody carries it. */
33
+ readonly ownerId?: string | null;
34
+ readonly dueAt?: Date | null;
35
+ }
36
+ export declare function createDecisionBody(input: CreateDecisionInput): Record<string, unknown>;
37
+ /** The target never moves: re-filing a decision under another record is a delete and a create. */
38
+ export interface DecisionInput {
39
+ readonly body?: string;
40
+ readonly rationale?: string | null;
41
+ readonly decidedAt?: Date;
42
+ readonly ownerId?: string | null;
43
+ readonly dueAt?: Date | null;
44
+ }
45
+ export declare function decisionBody(input: DecisionInput): Record<string, unknown>;
46
+ //# sourceMappingURL=decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAQnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD;;;;;;;;;GASG;AAEH,MAAM,WAAW,QAAS,SAAQ,gBAAgB;IAChD,QA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AAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAC7B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS1E"}
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ import { RECORD_TARGET_TYPES } from './values.js';
3
+ import { definedFields, idSchema, nullableTimestampSchema, recordTimestamps, timestampSchema, } from './wire.js';
4
+ export const decisionSchema = z
5
+ .object({
6
+ id: idSchema,
7
+ target_type: z.enum(RECORD_TARGET_TYPES),
8
+ target_id: idSchema,
9
+ body: z.string(),
10
+ rationale: z.string().nullable(),
11
+ decided_at: timestampSchema,
12
+ owner_id: idSchema.nullable(),
13
+ due_at: nullableTimestampSchema,
14
+ ...recordTimestamps,
15
+ })
16
+ .transform((wire) => ({
17
+ id: wire.id,
18
+ targetType: wire.target_type,
19
+ targetId: wire.target_id,
20
+ body: wire.body,
21
+ rationale: wire.rationale,
22
+ decidedAt: wire.decided_at,
23
+ ownerId: wire.owner_id,
24
+ dueAt: wire.due_at,
25
+ createdAt: wire.created_at,
26
+ updatedAt: wire.updated_at,
27
+ }));
28
+ export function createDecisionBody(input) {
29
+ return definedFields({
30
+ target_type: input.targetType,
31
+ target_id: input.targetId,
32
+ body: input.body,
33
+ rationale: input.rationale,
34
+ decided_at: input.decidedAt === undefined ? undefined : input.decidedAt.toISOString(),
35
+ owner_id: input.ownerId,
36
+ due_at: input.dueAt === undefined ? undefined : input.dueAt === null ? null : input.dueAt.toISOString(),
37
+ });
38
+ }
39
+ export function decisionBody(input) {
40
+ return definedFields({
41
+ body: input.body,
42
+ rationale: input.rationale,
43
+ decided_at: input.decidedAt === undefined ? undefined : input.decidedAt.toISOString(),
44
+ owner_id: input.ownerId,
45
+ due_at: input.dueAt === undefined ? undefined : input.dueAt === null ? null : input.dueAt.toISOString(),
46
+ });
47
+ }
48
+ //#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