@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
package/dist/form.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ import { z } from 'zod';
2
+ import type { FormFieldMapTarget, FormFieldType, FormOptionValueType, FormStatus } from './values.ts';
3
+ import type { RecordTimestamps } from './wire.ts';
4
+ /**
5
+ * Wire and write shapes for `/v1/forms`, the embeddable inbound capture from
6
+ * [`forms.md`](../../../forms.md).
7
+ *
8
+ * Fields come back nested inside their form rather than as their own resource.
9
+ * A form without its fields cannot be rendered or validated, so every caller
10
+ * that wants one wants both, and the ordering is the form's rather than a
11
+ * property of any single field.
12
+ */
13
+ /**
14
+ * A select choice. `key` is the identifier: it is what a stored answer holds and
15
+ * what a submit is checked against, so the display `value` is free to change.
16
+ */
17
+ export interface FormFieldOption {
18
+ readonly key: string;
19
+ /** What the embed shows in the dropdown. */
20
+ readonly value: string;
21
+ readonly valueType: FormOptionValueType;
22
+ }
23
+ export interface FormField {
24
+ readonly id: string;
25
+ readonly label: string;
26
+ readonly type: FormFieldType;
27
+ readonly required: boolean;
28
+ readonly mapTo: FormFieldMapTarget;
29
+ /** Empty for every type but `select`. */
30
+ readonly options: readonly FormFieldOption[];
31
+ readonly placeholder: string | null;
32
+ /** Position in the form, contiguous from 0. The server renumbers on every write. */
33
+ readonly sortOrder: number;
34
+ }
35
+ export interface Form extends RecordTimestamps {
36
+ readonly id: string;
37
+ readonly name: string;
38
+ readonly description: string | null;
39
+ readonly status: FormStatus;
40
+ readonly fields: readonly FormField[];
41
+ readonly thankYouMessage: string;
42
+ readonly createDeal: boolean;
43
+ /** Null means the deal pipeline's default stage is used at submit time. */
44
+ readonly dealStageId: string | null;
45
+ /** Expands `{{company.name}}` and `{{person.name}}`. Null when `createDeal` is off. */
46
+ readonly dealNameTemplate: string | null;
47
+ /**
48
+ * The handle the public submit and embed endpoints resolve a workspace from.
49
+ * Globally unique, and the only credential those endpoints take.
50
+ */
51
+ readonly publicKey: string;
52
+ }
53
+ export declare const formSchema: z.ZodType<Form, unknown>;
54
+ export interface FormFieldOptionInput {
55
+ readonly key: string;
56
+ readonly value: string;
57
+ readonly valueType?: FormOptionValueType;
58
+ }
59
+ /**
60
+ * A field as it is written.
61
+ *
62
+ * There is no id: a write replaces the whole field list, so the server assigns
63
+ * ids and positions from the array's order. Editing one field means sending the
64
+ * list back with that field changed, which is also what a drag-reorder sends.
65
+ */
66
+ export interface FormFieldInput {
67
+ readonly label: string;
68
+ readonly type: FormFieldType;
69
+ readonly required?: boolean;
70
+ readonly mapTo: FormFieldMapTarget;
71
+ readonly options?: readonly FormFieldOptionInput[];
72
+ readonly placeholder?: string | null;
73
+ }
74
+ export interface CreateFormInput {
75
+ readonly name: string;
76
+ readonly description?: string | null;
77
+ readonly status?: FormStatus;
78
+ readonly fields: readonly FormFieldInput[];
79
+ readonly thankYouMessage?: string;
80
+ readonly createDeal?: boolean;
81
+ readonly dealStageId?: string | null;
82
+ readonly dealNameTemplate?: string | null;
83
+ }
84
+ /** `fields` is absent or the whole list; there is no per-field patch. */
85
+ export interface FormInput {
86
+ readonly name?: string;
87
+ readonly description?: string | null;
88
+ readonly status?: FormStatus;
89
+ readonly fields?: readonly FormFieldInput[];
90
+ readonly thankYouMessage?: string;
91
+ readonly createDeal?: boolean;
92
+ readonly dealStageId?: string | null;
93
+ readonly dealNameTemplate?: string | null;
94
+ }
95
+ export declare function createFormBody(input: CreateFormInput): Record<string, unknown>;
96
+ export declare function formBody(input: FormInput): Record<string, unknown>;
97
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1C;AAED,yEAAyE;AACzE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;IAC3C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1C;AAeD,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAW9E;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWlE"}
package/dist/form.js ADDED
@@ -0,0 +1,98 @@
1
+ import { z } from 'zod';
2
+ import { FORM_FIELD_MAP_TARGETS, FORM_FIELD_TYPES, FORM_OPTION_VALUE_TYPES, FORM_STATUSES, } from './values.js';
3
+ import { definedFields, idSchema, recordTimestamps } from './wire.js';
4
+ const formFieldOptionSchema = z
5
+ .object({
6
+ key: z.string(),
7
+ value: z.string(),
8
+ value_type: z.enum(FORM_OPTION_VALUE_TYPES),
9
+ })
10
+ .transform((wire) => ({
11
+ key: wire.key,
12
+ value: wire.value,
13
+ valueType: wire.value_type,
14
+ }));
15
+ const formFieldSchema = z
16
+ .object({
17
+ id: idSchema,
18
+ label: z.string(),
19
+ type: z.enum(FORM_FIELD_TYPES),
20
+ required: z.boolean(),
21
+ map_to: z.enum(FORM_FIELD_MAP_TARGETS),
22
+ options: z.array(formFieldOptionSchema),
23
+ placeholder: z.string().nullable(),
24
+ sort_order: z.number().int(),
25
+ })
26
+ .transform((wire) => ({
27
+ id: wire.id,
28
+ label: wire.label,
29
+ type: wire.type,
30
+ required: wire.required,
31
+ mapTo: wire.map_to,
32
+ options: wire.options,
33
+ placeholder: wire.placeholder,
34
+ sortOrder: wire.sort_order,
35
+ }));
36
+ export const formSchema = z
37
+ .object({
38
+ id: idSchema,
39
+ name: z.string(),
40
+ description: z.string().nullable(),
41
+ status: z.enum(FORM_STATUSES),
42
+ fields: z.array(formFieldSchema),
43
+ thank_you_message: z.string(),
44
+ create_deal: z.boolean(),
45
+ deal_stage_id: idSchema.nullable(),
46
+ deal_name_template: z.string().nullable(),
47
+ public_key: z.string(),
48
+ ...recordTimestamps,
49
+ })
50
+ .transform((wire) => ({
51
+ id: wire.id,
52
+ name: wire.name,
53
+ description: wire.description,
54
+ status: wire.status,
55
+ fields: wire.fields,
56
+ thankYouMessage: wire.thank_you_message,
57
+ createDeal: wire.create_deal,
58
+ dealStageId: wire.deal_stage_id,
59
+ dealNameTemplate: wire.deal_name_template,
60
+ publicKey: wire.public_key,
61
+ createdAt: wire.created_at,
62
+ updatedAt: wire.updated_at,
63
+ }));
64
+ function fieldBody(field) {
65
+ return definedFields({
66
+ label: field.label,
67
+ type: field.type,
68
+ required: field.required,
69
+ map_to: field.mapTo,
70
+ options: field.options?.map((option) => definedFields({ key: option.key, value: option.value, value_type: option.valueType })),
71
+ placeholder: field.placeholder,
72
+ });
73
+ }
74
+ export function createFormBody(input) {
75
+ return definedFields({
76
+ name: input.name,
77
+ description: input.description,
78
+ status: input.status,
79
+ fields: input.fields.map(fieldBody),
80
+ thank_you_message: input.thankYouMessage,
81
+ create_deal: input.createDeal,
82
+ deal_stage_id: input.dealStageId,
83
+ deal_name_template: input.dealNameTemplate,
84
+ });
85
+ }
86
+ export function formBody(input) {
87
+ return definedFields({
88
+ name: input.name,
89
+ description: input.description,
90
+ status: input.status,
91
+ fields: input.fields?.map(fieldBody),
92
+ thank_you_message: input.thankYouMessage,
93
+ create_deal: input.createDeal,
94
+ deal_stage_id: input.dealStageId,
95
+ deal_name_template: input.dealNameTemplate,
96
+ });
97
+ }
98
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,GACd,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAwDrE,MAAM,qBAAqB,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC;CAC5C,CAAC;KACD,SAAS,CACR,CAAC,IAAI,EAAmB,EAAE,CAAC,CAAC;IAC1B,GAAG,EAAE,IAAI,CAAC,GAAG;IACb,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,SAAS,EAAE,IAAI,CAAC,UAAU;CAC3B,CAAC,CACH,CAAA;AAEH,MAAM,eAAe,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,EAAE,EAAE,QAAQ;IACZ,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAq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CAAC,gBAAgB;KAC3C,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAgB;IACvC,OAAO,aAAa,CAAC;QACnB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,CAAC;QACpC,iBAAiB,EAAE,KAAK,CAAC,eAAe;QACxC,WAAW,EAAE,KAAK,CAAC,UAAU;QAC7B,aAAa,EAAE,KAAK,CAAC,WAAW;QAChC,kBAAkB,EAAE,KAAK,CAAC,gBAAgB;KAC3C,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Wire shape for `/v1/forms/:id/submissions`, and for what the public submit
4
+ * endpoint answers with.
5
+ *
6
+ * Read-only over the API: a submission is evidence of what arrived, so there is
7
+ * no create body here (the public endpoint takes an answer map, not a
8
+ * submission) and no update at all.
9
+ */
10
+ export interface FormSubmission {
11
+ readonly id: string;
12
+ readonly formId: string;
13
+ readonly submittedAt: Date;
14
+ /** Field id to the answer given: a select option's `key`, or free text. */
15
+ readonly answers: Readonly<Record<string, string>>;
16
+ /**
17
+ * What the submit created or matched. Each is null when the rule did not
18
+ * apply, and each becomes null again if that record is later deleted: the
19
+ * submission outlives what it produced.
20
+ */
21
+ readonly personId: string | null;
22
+ readonly companyId: string | null;
23
+ readonly positionId: string | null;
24
+ readonly dealId: string | null;
25
+ readonly createdAt: Date;
26
+ }
27
+ export declare const formSubmissionSchema: z.ZodType<FormSubmission, unknown>;
28
+ /**
29
+ * What the public submit endpoint answers with.
30
+ *
31
+ * Smaller than the stored submission, as `forms.md` specifies: the ids it
32
+ * produced, and nothing else. The caller is a stranger's browser, and echoing
33
+ * back the answers it just sent would tell it nothing it does not have.
34
+ */
35
+ export interface FormSubmitResult {
36
+ readonly id: string;
37
+ readonly formId: string;
38
+ readonly submittedAt: Date;
39
+ readonly personId: string;
40
+ readonly companyId: string | null;
41
+ readonly positionId: string | null;
42
+ readonly dealId: string | null;
43
+ /** The form's configured confirmation, so an embed can render it without a second request. */
44
+ readonly thankYouMessage: string;
45
+ }
46
+ export declare const formSubmitResultSchema: z.ZodType<FormSubmitResult, unknown>;
47
+ //# sourceMappingURL=formSubmission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formSubmission.d.ts","sourceRoot":"","sources":["../src/formSubmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAA;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAClD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CACzB;AAED,eAAO,MAAM,oBAAoB,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAwBjE,CAAA;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,8FAA8F;IAC9F,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACjC;AAED,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAsBrE,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import { idSchema, timestampSchema } from './wire.js';
3
+ export const formSubmissionSchema = z
4
+ .object({
5
+ id: idSchema,
6
+ form_id: idSchema,
7
+ submitted_at: timestampSchema,
8
+ answers: z.record(z.string(), z.string()),
9
+ person_id: idSchema.nullable(),
10
+ company_id: idSchema.nullable(),
11
+ position_id: idSchema.nullable(),
12
+ deal_id: idSchema.nullable(),
13
+ created_at: timestampSchema,
14
+ })
15
+ .transform((wire) => ({
16
+ id: wire.id,
17
+ formId: wire.form_id,
18
+ submittedAt: wire.submitted_at,
19
+ answers: wire.answers,
20
+ personId: wire.person_id,
21
+ companyId: wire.company_id,
22
+ positionId: wire.position_id,
23
+ dealId: wire.deal_id,
24
+ createdAt: wire.created_at,
25
+ }));
26
+ export const formSubmitResultSchema = z
27
+ .object({
28
+ id: idSchema,
29
+ form_id: idSchema,
30
+ submitted_at: timestampSchema,
31
+ person_id: idSchema,
32
+ company_id: idSchema.nullable(),
33
+ position_id: idSchema.nullable(),
34
+ deal_id: idSchema.nullable(),
35
+ thank_you_message: z.string(),
36
+ })
37
+ .transform((wire) => ({
38
+ id: wire.id,
39
+ formId: wire.form_id,
40
+ submittedAt: wire.submitted_at,
41
+ personId: wire.person_id,
42
+ companyId: wire.company_id,
43
+ positionId: wire.position_id,
44
+ dealId: wire.deal_id,
45
+ thankYouMessage: wire.thank_you_message,
46
+ }));
47
+ //# sourceMappingURL=formSubmission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formSubmission.js","sourceRoot":"","sources":["../src/formSubmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AA6BrD,MAAM,CAAC,MAAM,oBAAoB,GAAuC,CAAC;KACtE,MAAM,CAAC;IACN,EAAE,EAAE,QAAQ;IACZ,OAAO,EAAE,QAAQ;IACjB,YAAY,EAAE,eAAe;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACzC,SAAS,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAC9B,UAAU,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAC/B,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAC5B,UAAU,EAAE,eAAe;CAC5B,CAAC;KACD,SAAS,CACR,CAAC,IAAI,EAAkB,EAAE,CAAC,CAAC;IACzB,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,MAAM,EAAE,IAAI,CAAC,OAAO;IACpB,WAAW,EAAE,IAAI,CAAC,YAAY;IAC9B,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,QAAQ,EAAE,IAAI,CAAC,SAAS;IACxB,SAAS,EAAE,IAAI,CAAC,UAAU;IAC1B,UAAU,EAAE,IAAI,CAAC,WAAW;IAC5B,MAAM,EAAE,IAAI,CAAC,OAAO;IACpB,SAAS,EAAE,IAAI,CAAC,UAAU;CAC3B,CAAC,CACH,CAAA;AAqBH,MAAM,CAAC,MAAM,sBAAsB,GAAyC,CAAC;KAC1E,MAAM,CAAC;IACN,EAAE,EAAE,QAAQ;IACZ,OAAO,EAAE,QAAQ;IACjB,YAAY,EAAE,eAAe;IAC7B,SAAS,EAAE,QAAQ;IACnB,UAAU,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAC/B,WAAW,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAAE;IAC5B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;CAC9B,CAAC;KACD,SAAS,CACR,CAAC,IAAI,EAAoB,EAAE,CAAC,CAAC;IAC3B,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,MAAM,EAAE,IAAI,CAAC,OAAO;IACpB,WAAW,EAAE,IAAI,CAAC,YAAY;IAC9B,QAAQ,EAAE,IAAI,CAAC,SAAS;IACxB,SAAS,EAAE,IAAI,CAAC,UAAU;IAC1B,UAAU,EAAE,IAAI,CAAC,WAAW;IAC5B,MAAM,EAAE,IAAI,CAAC,OAAO;IACpB,eAAe,EAAE,IAAI,CAAC,iBAAiB;CACxC,CAAC,CACH,CAAA"}
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import type { RecordTimestamps } from './wire.ts';
3
+ /**
4
+ * Wire and write shapes for `/v1/handbook_pages`, the workspace's nested
5
+ * markdown handbook.
6
+ *
7
+ * The response is flat: `parentId` and `sortOrder` are the tree, and the caller
8
+ * rebuilds it. `sortOrder` positions a page among its siblings only, so it is
9
+ * meaningless across the whole set and the list is not sorted by it.
10
+ *
11
+ * `updatedBy` is a workspace member id, not a user id, and is null when no
12
+ * member was behind the write (a workspace API key). Resolving it to a name is
13
+ * the caller's job, as with a note's author.
14
+ */
15
+ /** Top-level pages are 0, so `MAX_DEPTH` of 4 allows five levels. Mirrors the server's cap. */
16
+ export declare const MAX_HANDBOOK_DEPTH = 4;
17
+ export interface HandbookPage extends RecordTimestamps {
18
+ readonly id: string;
19
+ readonly title: string;
20
+ /** The stable handle agent tasks name pages by. It does not follow the title. */
21
+ readonly slug: string;
22
+ readonly parentId: string | null;
23
+ readonly sortOrder: number;
24
+ readonly body: string;
25
+ readonly updatedBy: string | null;
26
+ }
27
+ export declare const handbookPageSchema: z.ZodType<HandbookPage, unknown>;
28
+ export interface CreateHandbookPageInput {
29
+ readonly title: string;
30
+ /** Absent means empty: a page is created before it is written. */
31
+ readonly body?: string;
32
+ /** Absent means derived from the title, with a numeric suffix if that is taken. */
33
+ readonly slug?: string;
34
+ /** Absent or null puts the page at the top level. */
35
+ readonly parentId?: string | null;
36
+ }
37
+ export declare function createHandbookPageBody(input: CreateHandbookPageInput): Record<string, unknown>;
38
+ /**
39
+ * `parentId` and `sortOrder` are the move; the rest is the edit. A drag sends
40
+ * both halves of the move together, because landing somewhere new is a parent
41
+ * and a position at once.
42
+ */
43
+ export interface HandbookPageInput {
44
+ readonly title?: string;
45
+ readonly body?: string;
46
+ readonly slug?: string;
47
+ /** Null lifts the page to the top level. */
48
+ readonly parentId?: string | null;
49
+ readonly sortOrder?: number;
50
+ }
51
+ export declare function handbookPageBody(input: HandbookPageInput): Record<string, unknown>;
52
+ //# sourceMappingURL=handbookPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handbookPage.d.ts","sourceRoot":"","sources":["../src/handbookPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD;;;;;;;;;;;GAWG;AAEH,+FAA+F;AAC/F,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC;AAED,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAuB7D,CAAA;AAEH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,mFAAmF;IACnF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO9F;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQlF"}
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ import { definedFields, idSchema, recordTimestamps } from './wire.js';
3
+ /**
4
+ * Wire and write shapes for `/v1/handbook_pages`, the workspace's nested
5
+ * markdown handbook.
6
+ *
7
+ * The response is flat: `parentId` and `sortOrder` are the tree, and the caller
8
+ * rebuilds it. `sortOrder` positions a page among its siblings only, so it is
9
+ * meaningless across the whole set and the list is not sorted by it.
10
+ *
11
+ * `updatedBy` is a workspace member id, not a user id, and is null when no
12
+ * member was behind the write (a workspace API key). Resolving it to a name is
13
+ * the caller's job, as with a note's author.
14
+ */
15
+ /** Top-level pages are 0, so `MAX_DEPTH` of 4 allows five levels. Mirrors the server's cap. */
16
+ export const MAX_HANDBOOK_DEPTH = 4;
17
+ export const handbookPageSchema = z
18
+ .object({
19
+ id: idSchema,
20
+ title: z.string(),
21
+ slug: z.string(),
22
+ parent_id: idSchema.nullable(),
23
+ sort_order: z.number().int(),
24
+ body: z.string(),
25
+ updated_by: idSchema.nullable(),
26
+ ...recordTimestamps,
27
+ })
28
+ .transform((wire) => ({
29
+ id: wire.id,
30
+ title: wire.title,
31
+ slug: wire.slug,
32
+ parentId: wire.parent_id,
33
+ sortOrder: wire.sort_order,
34
+ body: wire.body,
35
+ updatedBy: wire.updated_by,
36
+ createdAt: wire.created_at,
37
+ updatedAt: wire.updated_at,
38
+ }));
39
+ export function createHandbookPageBody(input) {
40
+ return definedFields({
41
+ title: input.title,
42
+ body: input.body,
43
+ slug: input.slug,
44
+ parent_id: input.parentId,
45
+ });
46
+ }
47
+ export function handbookPageBody(input) {
48
+ return definedFields({
49
+ title: input.title,
50
+ body: input.body,
51
+ slug: input.slug,
52
+ parent_id: input.parentId,
53
+ sort_order: input.sortOrder,
54
+ });
55
+ }
56
+ //# sourceMappingURL=handbookPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handbookPage.js","sourceRoot":"","sources":["../src/handbookPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAGrE;;;;;;;;;;;GAWG;AAEH,+FAA+F;AAC/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAanC,MAAM,CAAC,MAAM,kBAAkB,GAAqC,CAAC;KAClE,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SAAS;KAC5B,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,143 @@
1
+ import { z } from 'zod';
2
+ import type { RecordTimestamps } from './wire.ts';
3
+ /**
4
+ * Wire shapes and shared catalogues for `/v1/import` and `/v1/export`, per
5
+ * `import-export.md`.
6
+ *
7
+ * The column catalogue lives here rather than in the server module because both
8
+ * ends need it: the server validates a row against it, and the browser renders
9
+ * the mapping table from it. The source presets do not, so they stay server-side
10
+ * — a caller sends a `column_map` and never has to know how one was derived.
11
+ */
12
+ export declare const IMPORT_SOURCES: readonly ['custom', 'hubspot', 'salesforce'];
13
+ export declare const IMPORT_OBJECTS: readonly ['companies', 'people', 'positions', 'deals'];
14
+ export declare const IMPORT_CONFLICT_MODES: readonly ['skip', 'update'];
15
+ /**
16
+ * `pending → validating → ready | failed → committing → completed | failed`.
17
+ *
18
+ * `pending` is the moment between the row insert and the dry run starting. A
19
+ * synchronous job passes through it inside one request and is never observed
20
+ * there; an asynchronous one can be.
21
+ */
22
+ export declare const IMPORT_JOB_STATUSES: readonly ['pending', 'validating', 'ready', 'committing', 'completed', 'failed'];
23
+ /**
24
+ * What a dry run forecasts for a row, and what a commit records against it.
25
+ *
26
+ * `pending` is a row that has been stored but not yet planned, which is what
27
+ * every row of an asynchronous job is until its validation pass reaches it. The
28
+ * counts only ever hold the four settled actions.
29
+ */
30
+ export declare const IMPORT_ROW_ACTIONS: readonly ['pending', 'create', 'update', 'skip', 'error'];
31
+ export type ImportSource = (typeof IMPORT_SOURCES)[number];
32
+ export type ImportObject = (typeof IMPORT_OBJECTS)[number];
33
+ export type ImportConflictMode = (typeof IMPORT_CONFLICT_MODES)[number];
34
+ export type ImportJobStatus = (typeof IMPORT_JOB_STATUSES)[number];
35
+ export type ImportRowAction = (typeof IMPORT_ROW_ACTIONS)[number];
36
+ /** A row that has been planned. What a dry run and a commit both write back. */
37
+ export type SettledRowAction = Exclude<ImportRowAction, 'pending'>;
38
+ /** Limits from `import-export.md`. Placeholders until billing exists. */
39
+ export declare const MAX_IMPORT_FILE_BYTES: number;
40
+ export declare const MAX_IMPORT_ROWS = 10000;
41
+ /**
42
+ * Above this many rows a job validates and commits in the background, and the
43
+ * request answers `202` with the job in a transient status. The caller polls
44
+ * `GET /v1/import/jobs/{id}`.
45
+ */
46
+ export declare const SYNC_IMPORT_ROWS = 500;
47
+ /** Mapped rows returned with a job, so a caller can check the mapping before committing. */
48
+ export declare const IMPORT_PREVIEW_ROWS = 5;
49
+ /**
50
+ * Row errors carried on the job body. `counts.error` is the true total, so a
51
+ * truncated list is visible rather than mistaken for the whole story.
52
+ */
53
+ export declare const IMPORT_REPORTED_ERRORS = 50;
54
+ export declare const OBJECT_LABELS: Readonly<Record<ImportObject, string>>;
55
+ export declare const SOURCE_LABELS: Readonly<Record<ImportSource, string>>;
56
+ export declare const CONFLICT_MODE_LABELS: Readonly<Record<ImportConflictMode, string>>;
57
+ export interface CsvColumn {
58
+ /** The Kelpie CSV header, and the key a `column_map` is keyed by. */
59
+ readonly key: string;
60
+ readonly label: string;
61
+ readonly required: boolean;
62
+ }
63
+ /**
64
+ * The canonical Kelpie CSV columns per object (`import-export.md`).
65
+ *
66
+ * Order is the header order of an export and of a template, so a file Kelpie
67
+ * wrote maps onto itself by exact header match with no preset involved.
68
+ *
69
+ * Job title is absent from Person on purpose: it lives on Position, which is
70
+ * what the contact title in a HubSpot or Salesforce export maps to.
71
+ */
72
+ export declare const OBJECT_COLUMNS: Readonly<Record<ImportObject, readonly CsvColumn[]>>;
73
+ /** Columns whose value is a pipe-separated list (`a|b|c`), per `import-export.md`. */
74
+ export declare const LIST_COLUMNS: ReadonlySet<string>;
75
+ export interface MatchKeyOption {
76
+ /** The `match_key` a request sends. Composite keys join their columns with `|`. */
77
+ readonly id: string;
78
+ readonly label: string;
79
+ /** Kelpie columns the key is built from. Every one must be mapped and non-empty. */
80
+ readonly columns: readonly string[];
81
+ }
82
+ /** Selectable match keys per object. The first of each list is the default. */
83
+ export declare const MATCH_KEYS: Readonly<Record<ImportObject, readonly MatchKeyOption[]>>;
84
+ export declare function defaultMatchKeyId(object: ImportObject): string;
85
+ /** @returns The named key, or undefined when no such key exists for this object. */
86
+ export declare function findMatchKey(object: ImportObject, matchKeyId: string): MatchKeyOption | undefined;
87
+ /**
88
+ * Kelpie columns a job must have mapped: the object's required ones plus every
89
+ * column the chosen match key is built from.
90
+ */
91
+ export declare function requiredColumns(object: ImportObject, matchKey: MatchKeyOption): readonly string[];
92
+ export interface ImportRowError {
93
+ /** The line in the file, counting the header as line 1. */
94
+ readonly row: number;
95
+ readonly field: string;
96
+ readonly message: string;
97
+ }
98
+ export interface ImportCounts {
99
+ readonly total: number;
100
+ readonly create: number;
101
+ readonly update: number;
102
+ readonly skip: number;
103
+ readonly error: number;
104
+ }
105
+ /** A mapped row as Kelpie read it, for checking a column map before committing. */
106
+ export interface ImportPreviewRow {
107
+ readonly row: number;
108
+ readonly action: ImportRowAction;
109
+ /** Kelpie column → value, for the mapped columns only. */
110
+ readonly values: Readonly<Record<string, string>>;
111
+ }
112
+ /**
113
+ * A `column_map`: Kelpie column → source header, or null to ignore the column.
114
+ *
115
+ * A key absent from the map means the same as null. Both are the ordinary way to
116
+ * say a file has no such column.
117
+ */
118
+ export type ImportColumnMap = Readonly<Record<string, string | null>>;
119
+ export interface ImportJob extends RecordTimestamps {
120
+ readonly id: string;
121
+ readonly source: ImportSource;
122
+ readonly object: ImportObject;
123
+ readonly status: ImportJobStatus;
124
+ readonly conflictMode: ImportConflictMode;
125
+ readonly matchKey: string;
126
+ readonly columnMap: ImportColumnMap;
127
+ /** The headers as they appeared in the uploaded file, in file order. */
128
+ readonly sourceHeaders: readonly string[];
129
+ readonly fileName: string | null;
130
+ readonly counts: ImportCounts;
131
+ /** At most `IMPORT_REPORTED_ERRORS`. `counts.error` is the true number of failing rows. */
132
+ readonly errors: readonly ImportRowError[];
133
+ readonly preview: readonly ImportPreviewRow[];
134
+ }
135
+ /**
136
+ * `workspace_id` is not on this body, unlike the sample in `import-export.md`.
137
+ * `api.md` makes the workspace implicit on every endpoint and no other resource
138
+ * returns it; one that did would be the odd one out for no gain.
139
+ */
140
+ export declare const importJobSchema: z.ZodType<ImportJob, unknown>;
141
+ /** Statuses a job will not move on from without another request. */
142
+ export declare function isImportJobSettled(status: ImportJobStatus): boolean;
143
+ //# sourceMappingURL=importExport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importExport.d.ts","sourceRoot":"","sources":["../src/importExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD;;;;;;;;GAQG;AAEH,eAAO,MAAM,cAAc,YAAI,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAU,CAAA;AAC1E,eAAO,MAAM,cAAc,YAAI,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,CAAU,CAAA;AACpF,eAAO,MAAM,qBAAqB,YAAI,MAAM,EAAE,QAAQ,CAAU,CAAA;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,YAC9B,SAAS,EACT,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,EACX,QAAQ,CACA,CAAA;AAEV;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,YAAI,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAU,CAAA;AAE3F,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAC1D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAC1D,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAA;AACvE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AA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