@odla-ai/crm 0.8.0 → 0.9.1
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/chunk-7LH3WGSU.js +1279 -0
- package/dist/chunk-7LH3WGSU.js.map +1 -0
- package/dist/client-CMYE9fpt.d.ts +566 -0
- package/dist/gallery/index.d.ts +17 -0
- package/dist/gallery/index.js +1080 -0
- package/dist/gallery/index.js.map +1 -0
- package/dist/index.cjs +28 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/ui/index.d.ts +1 -565
- package/dist/ui/index.js +20 -1255
- package/dist/ui/index.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
/** Generic promoted columns a type's custom fields can claim for indexed
|
|
2
|
+
* sort/filter: four strings, three numbers, two dates. Slots are per-type
|
|
3
|
+
* virtual — every slot query is ANDed with `type`, so "person.n1" and
|
|
4
|
+
* "company.n1" can mean different fields. */
|
|
5
|
+
declare const CRM_SLOTS: readonly ["s1", "s2", "s3", "s4", "n1", "n2", "n3", "d1", "d2"];
|
|
6
|
+
/** One generic promoted column a field can claim. */
|
|
7
|
+
type CrmSlot = (typeof CRM_SLOTS)[number];
|
|
8
|
+
/** Consent state of a contact channel (see `applyConsentEvent`). */
|
|
9
|
+
declare const CONSENT_STATES: readonly ["subscribed", "unsubscribed", "bounced", "suppressed"];
|
|
10
|
+
/** A contact channel's consent standing. */
|
|
11
|
+
type ConsentState = (typeof CONSENT_STATES)[number];
|
|
12
|
+
/** Denormalized per-record contactability, folded from the primary email
|
|
13
|
+
* channel so list views can filter/sort on it: `none` = no email channel. */
|
|
14
|
+
declare const EMAIL_STATUSES: readonly ["ok", "unsubscribed", "bounced", "suppressed", "none"];
|
|
15
|
+
/** The record-level contactability fold. */
|
|
16
|
+
type EmailStatus = (typeof EMAIL_STATUSES)[number];
|
|
17
|
+
/** Activity kinds; `task` rows additionally carry status/dueAt/waitingOn. */
|
|
18
|
+
declare const ACTIVITY_KINDS: readonly ["note", "task", "call", "meeting", "stage_change", "system"];
|
|
19
|
+
/** What kind of feed entry an activity row is. */
|
|
20
|
+
type ActivityKind = (typeof ACTIVITY_KINDS)[number];
|
|
21
|
+
/** Task lifecycle for `kind: "task"` activities. */
|
|
22
|
+
declare const TASK_STATUSES: readonly ["open", "waiting", "done"];
|
|
23
|
+
/** Where a follow-up task stands. */
|
|
24
|
+
type TaskStatus = (typeof TASK_STATUSES)[number];
|
|
25
|
+
|
|
26
|
+
/** Wire-shape attribute value kinds odla-db stores. */
|
|
27
|
+
type AttrType = "string" | "number" | "boolean" | "date" | "json";
|
|
28
|
+
/** One serialized attribute: its type and index/uniqueness flags. */
|
|
29
|
+
interface SerializedAttr {
|
|
30
|
+
type: AttrType;
|
|
31
|
+
unique: boolean;
|
|
32
|
+
indexed: boolean;
|
|
33
|
+
optional: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** One serialized namespace: its attribute map. */
|
|
36
|
+
interface SerializedEntity {
|
|
37
|
+
attrs: Record<string, SerializedAttr>;
|
|
38
|
+
}
|
|
39
|
+
/** One end of a serialized schema link. */
|
|
40
|
+
interface SerializedLinkEnd {
|
|
41
|
+
on: string;
|
|
42
|
+
has: "one" | "many";
|
|
43
|
+
label: string;
|
|
44
|
+
}
|
|
45
|
+
/** A serialized schema link (unused by crm — relations are rows). */
|
|
46
|
+
interface SerializedLink {
|
|
47
|
+
forward: SerializedLinkEnd;
|
|
48
|
+
reverse: SerializedLinkEnd;
|
|
49
|
+
}
|
|
50
|
+
/** The wire-shape schema POSTed to `/app/:id/schema`. */
|
|
51
|
+
interface SerializedSchema {
|
|
52
|
+
entities: Record<string, SerializedEntity>;
|
|
53
|
+
links: Record<string, SerializedLink>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Per-namespace CEL rule strings (missing action = deny). */
|
|
57
|
+
interface CrmRule {
|
|
58
|
+
view?: string;
|
|
59
|
+
create?: string;
|
|
60
|
+
update?: string;
|
|
61
|
+
delete?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Namespace → rule set, as installed at `/app/:id/admin/rules`. */
|
|
64
|
+
type CrmRules = Record<string, CrmRule>;
|
|
65
|
+
|
|
66
|
+
/** A CEL expression over `values`, e.g. `values.country == "US"`. */
|
|
67
|
+
type FieldCondition = string;
|
|
68
|
+
|
|
69
|
+
/** Scalar values odla-db attrs and where-clauses accept. */
|
|
70
|
+
type CrmScalar = string | number | boolean | null;
|
|
71
|
+
/** Attr payload of one op. Typed `any` on purpose: the real odla-db
|
|
72
|
+
* `transact` constrains attrs to its own `Value` type, and `any` is the one
|
|
73
|
+
* shape assignable in both directions with no cast. */
|
|
74
|
+
type CrmAttrs = Record<string, any>;
|
|
75
|
+
/** One CRM record of any configured type. Custom field values live complete
|
|
76
|
+
* in `fields`; slot columns (`s1`…`d2`) are an index mirror of the fields the
|
|
77
|
+
* type config promoted. */
|
|
78
|
+
interface CrmRecord {
|
|
79
|
+
id: string;
|
|
80
|
+
type: string;
|
|
81
|
+
name: string;
|
|
82
|
+
primaryEmail?: string;
|
|
83
|
+
stage?: string;
|
|
84
|
+
stageIndex?: number;
|
|
85
|
+
stageChangedAt?: number;
|
|
86
|
+
rank?: number;
|
|
87
|
+
score?: number;
|
|
88
|
+
ownerId?: string;
|
|
89
|
+
emailStatus?: EmailStatus;
|
|
90
|
+
clerkUserId?: string;
|
|
91
|
+
stripeCustomerId?: string;
|
|
92
|
+
subscriptionId?: string;
|
|
93
|
+
billingStatus?: string;
|
|
94
|
+
renewalAt?: number;
|
|
95
|
+
mrr?: number;
|
|
96
|
+
s1?: string;
|
|
97
|
+
s2?: string;
|
|
98
|
+
s3?: string;
|
|
99
|
+
s4?: string;
|
|
100
|
+
n1?: number;
|
|
101
|
+
n2?: number;
|
|
102
|
+
n3?: number;
|
|
103
|
+
d1?: number;
|
|
104
|
+
d2?: number;
|
|
105
|
+
fields: Record<string, unknown>;
|
|
106
|
+
searchText: string;
|
|
107
|
+
archived: boolean;
|
|
108
|
+
createdAt: number;
|
|
109
|
+
updatedAt: number;
|
|
110
|
+
archivedAt?: number;
|
|
111
|
+
}
|
|
112
|
+
/** A tag join row (`recordId:tag` natural key) — cohorts + provenance. */
|
|
113
|
+
interface CrmTag {
|
|
114
|
+
id: string;
|
|
115
|
+
key: string;
|
|
116
|
+
recordId: string;
|
|
117
|
+
tag: string;
|
|
118
|
+
createdAt: number;
|
|
119
|
+
}
|
|
120
|
+
/** A record↔record relation row with its config-declared label. */
|
|
121
|
+
interface CrmLink {
|
|
122
|
+
id: string;
|
|
123
|
+
key: string;
|
|
124
|
+
fromId: string;
|
|
125
|
+
toId: string;
|
|
126
|
+
relation: string;
|
|
127
|
+
createdAt: number;
|
|
128
|
+
}
|
|
129
|
+
/** A feed entry: note/call/meeting, follow-up task, or stage-change audit. */
|
|
130
|
+
interface CrmActivity {
|
|
131
|
+
id: string;
|
|
132
|
+
recordId: string;
|
|
133
|
+
kind: ActivityKind;
|
|
134
|
+
body: string;
|
|
135
|
+
status?: TaskStatus;
|
|
136
|
+
dueAt?: number;
|
|
137
|
+
waitingOn?: string;
|
|
138
|
+
assigneeId?: string;
|
|
139
|
+
authorId: string;
|
|
140
|
+
createdAt: number;
|
|
141
|
+
completedAt?: number;
|
|
142
|
+
meta?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
/** A consent-bearing contact channel (email/phone) of one record. */
|
|
145
|
+
interface CrmContactChannel {
|
|
146
|
+
id: string;
|
|
147
|
+
key: string;
|
|
148
|
+
recordId: string;
|
|
149
|
+
kind: "email" | "phone";
|
|
150
|
+
value: string;
|
|
151
|
+
isPrimary: boolean;
|
|
152
|
+
consent: ConsentState;
|
|
153
|
+
consentAt: number;
|
|
154
|
+
consentSource?: string;
|
|
155
|
+
unsubscribeToken: string;
|
|
156
|
+
createdAt: number;
|
|
157
|
+
}
|
|
158
|
+
/** A saved list question: filters + sort + columns, personal or shared. */
|
|
159
|
+
interface CrmView {
|
|
160
|
+
id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
type: string;
|
|
163
|
+
ownerId?: string;
|
|
164
|
+
shared: boolean;
|
|
165
|
+
filters: Record<string, unknown>;
|
|
166
|
+
sort: {
|
|
167
|
+
field: string;
|
|
168
|
+
dir: "asc" | "desc";
|
|
169
|
+
} | null;
|
|
170
|
+
columns: string[];
|
|
171
|
+
createdAt: number;
|
|
172
|
+
updatedAt: number;
|
|
173
|
+
}
|
|
174
|
+
/** One owner-editable template stored on the config row. The template CLASS
|
|
175
|
+
* (transactional vs marketing) is code config (`defineCrm` templates), not
|
|
176
|
+
* data — an owner edit can't reclassify a send past the consent gate. */
|
|
177
|
+
interface StoredTemplate {
|
|
178
|
+
subject: string;
|
|
179
|
+
text: string;
|
|
180
|
+
enabled: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** The runtime-editable crm_config singleton as read back. */
|
|
183
|
+
interface CrmConfigRow {
|
|
184
|
+
id: string;
|
|
185
|
+
key: string;
|
|
186
|
+
notificationEmail?: string;
|
|
187
|
+
replyTo?: string;
|
|
188
|
+
debugEmail?: string;
|
|
189
|
+
emailTemplates: Record<string, StoredTemplate>;
|
|
190
|
+
settings: Record<string, unknown>;
|
|
191
|
+
updatedAt: number;
|
|
192
|
+
}
|
|
193
|
+
/** Structured upstream identity for a record received from another app. */
|
|
194
|
+
interface CrmRecordOrigin {
|
|
195
|
+
id: string;
|
|
196
|
+
key: string;
|
|
197
|
+
recordId: string;
|
|
198
|
+
sourceId: string;
|
|
199
|
+
sourceRecordId: string;
|
|
200
|
+
sourceUrl?: string;
|
|
201
|
+
payloadVersion: number;
|
|
202
|
+
firstReceivedAt: number;
|
|
203
|
+
lastReceivedAt: number;
|
|
204
|
+
}
|
|
205
|
+
/** Latest delivery state for one local record → remote target edge. */
|
|
206
|
+
interface CrmRecordDelivery {
|
|
207
|
+
id: string;
|
|
208
|
+
key: string;
|
|
209
|
+
recordId: string;
|
|
210
|
+
targetId: string;
|
|
211
|
+
remoteRecordId?: string;
|
|
212
|
+
status: "delivered" | "failed";
|
|
213
|
+
attempts: number;
|
|
214
|
+
payloadVersion: number;
|
|
215
|
+
lastAttemptAt: number;
|
|
216
|
+
deliveredAt?: number;
|
|
217
|
+
error?: string;
|
|
218
|
+
}
|
|
219
|
+
/** Outcome of validating + coercing input for a type (see `prepare`). On
|
|
220
|
+
* success, `attrs` are the columns to WRITE (never null — odla-db rejects null
|
|
221
|
+
* on a typed scalar) and `retract` names the slots/promoted columns to CLEAR
|
|
222
|
+
* because their field went empty (populated only on update; empty on create,
|
|
223
|
+
* where there is nothing to clear). */
|
|
224
|
+
type PreparedWrite = {
|
|
225
|
+
ok: true;
|
|
226
|
+
attrs: CrmAttrs;
|
|
227
|
+
retract: string[];
|
|
228
|
+
} | {
|
|
229
|
+
ok: false;
|
|
230
|
+
errors: Record<string, string>;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/** Value kinds a custom field can hold. `email`/`url`/`enum` are validated
|
|
234
|
+
* strings; `date` accepts epoch ms or ISO strings and stores epoch ms. */
|
|
235
|
+
type FieldType = "string" | "number" | "boolean" | "date" | "email" | "url" | "enum" | "json";
|
|
236
|
+
/** One custom field of a record type: value kind, validation, slot promotion. */
|
|
237
|
+
interface FieldDef {
|
|
238
|
+
type: FieldType;
|
|
239
|
+
label?: string;
|
|
240
|
+
required?: boolean;
|
|
241
|
+
/** Allowed values — `enum` fields only. */
|
|
242
|
+
options?: readonly string[];
|
|
243
|
+
/** Promote to an indexed slot column for server-side sort/filter. String-ish
|
|
244
|
+
* fields take `s1`–`s4`, numbers `n1`–`n3`, dates `d1`–`d2`. */
|
|
245
|
+
slot?: CrmSlot;
|
|
246
|
+
/** Include in the FTS haystack. Defaults to true for string-ish fields. */
|
|
247
|
+
search?: boolean;
|
|
248
|
+
/** Show this field only while the CEL condition holds, e.g.
|
|
249
|
+
* `values.country == "US"`. Absent means always visible. */
|
|
250
|
+
visibleWhen?: FieldCondition;
|
|
251
|
+
/** Demand a value only while the CEL condition holds. Absent falls back to
|
|
252
|
+
* `required`. A hidden field is never required. */
|
|
253
|
+
requiredWhen?: FieldCondition;
|
|
254
|
+
}
|
|
255
|
+
/** One pipeline stage; declaration order is the sort order (`stageIndex`). */
|
|
256
|
+
interface StageDef {
|
|
257
|
+
id: string;
|
|
258
|
+
label?: string;
|
|
259
|
+
/** Terminal stages have no outgoing transitions unless `transitions`
|
|
260
|
+
* explicitly declares some. */
|
|
261
|
+
terminal?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/** A type's stage machine: ordered stages, allowed edges, gates. */
|
|
264
|
+
interface PipelineDef {
|
|
265
|
+
stages: readonly StageDef[];
|
|
266
|
+
/** Allowed edges per stage id. A stage with no entry accepts any move
|
|
267
|
+
* (unless terminal). */
|
|
268
|
+
transitions?: Record<string, readonly string[]>;
|
|
269
|
+
/** Per-target-stage gate: return an error string to block, null to allow. */
|
|
270
|
+
gates?: Record<string, (record: CrmRecord) => string | null>;
|
|
271
|
+
}
|
|
272
|
+
/** Opt-in built-in concerns for a type (identity/billing/email/rank). */
|
|
273
|
+
interface TypeFacets {
|
|
274
|
+
identity?: boolean;
|
|
275
|
+
billing?: boolean;
|
|
276
|
+
email?: boolean;
|
|
277
|
+
rank?: "manual" | "score" | "both";
|
|
278
|
+
}
|
|
279
|
+
/** One record type: its fields, pipeline, facets, and hooks. */
|
|
280
|
+
interface TypeDef {
|
|
281
|
+
label: string;
|
|
282
|
+
labelPlural?: string;
|
|
283
|
+
/** Optional admin collection group. Hosts can keep people and portfolio
|
|
284
|
+
* records in separate workspaces without moving either outside the CRM. */
|
|
285
|
+
workspace?: string;
|
|
286
|
+
/** Field mapped to the promoted `name` column. Default `"name"`. */
|
|
287
|
+
nameField?: string;
|
|
288
|
+
/** `email`-typed field mapped to `primaryEmail` (lowercased) and backed by
|
|
289
|
+
* a consent-bearing contact channel. */
|
|
290
|
+
emailField?: string;
|
|
291
|
+
fields: Record<string, FieldDef>;
|
|
292
|
+
pipeline?: PipelineDef;
|
|
293
|
+
facets?: TypeFacets;
|
|
294
|
+
/** Computes the record's `score` column (rank facet "score"/"both"). */
|
|
295
|
+
scorer?: (record: CrmRecord) => number;
|
|
296
|
+
/** Post-commit hooks per target stage id — e.g. S&S "approved" promotes the
|
|
297
|
+
* member's Clerk role. Fired by the route layer AFTER the stage write. */
|
|
298
|
+
onTransition?: Record<string, (record: CrmRecord) => void | Promise<void>>;
|
|
299
|
+
}
|
|
300
|
+
/** A typed record↔record relation (e.g. person works_at company). */
|
|
301
|
+
interface RelationDef {
|
|
302
|
+
from: string;
|
|
303
|
+
to: string;
|
|
304
|
+
label: string;
|
|
305
|
+
reverseLabel?: string;
|
|
306
|
+
}
|
|
307
|
+
/** Declares a template's contract in code: its variables and its consent
|
|
308
|
+
* CLASS. Subject/body/enabled live on the data row (owner-editable). */
|
|
309
|
+
interface TemplateSpec {
|
|
310
|
+
vars: readonly string[];
|
|
311
|
+
class: "transactional" | "marketing";
|
|
312
|
+
defaults?: {
|
|
313
|
+
subject: string;
|
|
314
|
+
text: string;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/** The whole app-level CRM configuration `defineCrm` validates. */
|
|
318
|
+
interface CrmConfig {
|
|
319
|
+
types: Record<string, TypeDef>;
|
|
320
|
+
relations?: Record<string, RelationDef>;
|
|
321
|
+
templates?: Record<string, TemplateSpec>;
|
|
322
|
+
}
|
|
323
|
+
/** The resolved engine `defineCrm` returns: static schema/rules plus the
|
|
324
|
+
* config-aware operations the route factory and ops modules run on. */
|
|
325
|
+
interface Crm {
|
|
326
|
+
config: CrmConfig;
|
|
327
|
+
schema: SerializedSchema;
|
|
328
|
+
rules: CrmRules;
|
|
329
|
+
type(name: string): TypeDef;
|
|
330
|
+
prepare(type: string, input: Record<string, unknown>, existing?: CrmRecord): PreparedWrite;
|
|
331
|
+
canTransition(type: string, record: CrmRecord, to: string): string | null;
|
|
332
|
+
initialStage(type: string): string | undefined;
|
|
333
|
+
stageIndex(type: string, stage: string): number;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Comparison filter for one slotted custom field. */
|
|
337
|
+
interface FieldFilter {
|
|
338
|
+
eq?: CrmScalar;
|
|
339
|
+
in?: CrmScalar[];
|
|
340
|
+
gte?: number | string;
|
|
341
|
+
lte?: number | string;
|
|
342
|
+
}
|
|
343
|
+
/** The serializable filter set (also the saved-view `filters` payload). */
|
|
344
|
+
interface ViewFilters {
|
|
345
|
+
search?: string;
|
|
346
|
+
stage?: string[];
|
|
347
|
+
emailStatus?: string[];
|
|
348
|
+
billingStatus?: string[];
|
|
349
|
+
ownerId?: string;
|
|
350
|
+
/** Exact tag — resolved to record ids first (join rows). */
|
|
351
|
+
tag?: string;
|
|
352
|
+
/** Include archived records (default: live only). */
|
|
353
|
+
archived?: boolean;
|
|
354
|
+
/** Slotted-field predicates, keyed by config field name. */
|
|
355
|
+
fields?: Record<string, FieldFilter>;
|
|
356
|
+
}
|
|
357
|
+
/** One-field sort (odla-db orders on exactly one indexed field). */
|
|
358
|
+
interface CrmSort {
|
|
359
|
+
field: string;
|
|
360
|
+
dir: "asc" | "desc";
|
|
361
|
+
}
|
|
362
|
+
/** Everything a list window can ask for: filters + sort + paging. */
|
|
363
|
+
interface CrmListParams extends ViewFilters {
|
|
364
|
+
type: string;
|
|
365
|
+
sort?: CrmSort;
|
|
366
|
+
limit?: number;
|
|
367
|
+
offset?: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/** The serializable definition of a saved view. */
|
|
371
|
+
interface ViewSpec {
|
|
372
|
+
name: string;
|
|
373
|
+
type: string;
|
|
374
|
+
filters: ViewFilters;
|
|
375
|
+
sort: CrmSort | null;
|
|
376
|
+
columns: string[];
|
|
377
|
+
shared: boolean;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** Partial config update; explicit null clears an address. */
|
|
381
|
+
interface ConfigPatch {
|
|
382
|
+
notificationEmail?: string | null;
|
|
383
|
+
replyTo?: string | null;
|
|
384
|
+
debugEmail?: string | null;
|
|
385
|
+
emailTemplates?: Record<string, Partial<StoredTemplate>>;
|
|
386
|
+
settings?: Record<string, unknown>;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** Tile counts for one record type. */
|
|
390
|
+
interface TypeSummary {
|
|
391
|
+
type: string;
|
|
392
|
+
total: number;
|
|
393
|
+
/** Live records per pipeline stage (types with a pipeline). */
|
|
394
|
+
stages: Record<string, number>;
|
|
395
|
+
/** Open + waiting follow-up tasks across all records. */
|
|
396
|
+
openTasks: number;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Where the routes live and how to authenticate against them. */
|
|
400
|
+
interface CrmClientOptions {
|
|
401
|
+
/** Origin of the host worker, e.g. "" (same-origin) or a full URL. */
|
|
402
|
+
baseUrl?: string;
|
|
403
|
+
/** Route mount point. Default "/api/crm". */
|
|
404
|
+
basePath?: string;
|
|
405
|
+
fetch?: typeof globalThis.fetch;
|
|
406
|
+
/** Per-request auth headers (called each request — tokens rotate). */
|
|
407
|
+
headers?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
408
|
+
}
|
|
409
|
+
/** A record composed with its tags, channels, and links. */
|
|
410
|
+
interface RecordDetail {
|
|
411
|
+
record: CrmRecord;
|
|
412
|
+
tags: CrmTag[];
|
|
413
|
+
channels: CrmContactChannel[];
|
|
414
|
+
links: CrmLink[];
|
|
415
|
+
/** Structured upstream identities; absent only from pre-upgrade custom APIs. */
|
|
416
|
+
origins?: CrmRecordOrigin[];
|
|
417
|
+
/** Latest outbound state per target; absent only from pre-upgrade custom APIs. */
|
|
418
|
+
deliveries?: CrmRecordDelivery[];
|
|
419
|
+
}
|
|
420
|
+
/** One list window plus the total matching count. */
|
|
421
|
+
interface RecordPage {
|
|
422
|
+
records: CrmRecord[];
|
|
423
|
+
total: number;
|
|
424
|
+
limit: number;
|
|
425
|
+
offset: number;
|
|
426
|
+
}
|
|
427
|
+
/** Typed access to every crm route. Methods reject with
|
|
428
|
+
* {@link CrmClientError} on non-2xx responses. */
|
|
429
|
+
declare class CrmClient {
|
|
430
|
+
private readonly base;
|
|
431
|
+
private readonly doFetch;
|
|
432
|
+
private readonly headers?;
|
|
433
|
+
constructor(options?: CrmClientOptions);
|
|
434
|
+
private request;
|
|
435
|
+
listRecords(params: CrmListParams): Promise<RecordPage>;
|
|
436
|
+
getRecord(id: string): Promise<RecordDetail>;
|
|
437
|
+
createRecord(body: {
|
|
438
|
+
type: string;
|
|
439
|
+
input: Record<string, unknown>;
|
|
440
|
+
ownerId?: string;
|
|
441
|
+
stage?: string;
|
|
442
|
+
mutationId?: string;
|
|
443
|
+
}): Promise<{
|
|
444
|
+
id: string;
|
|
445
|
+
duplicate: boolean;
|
|
446
|
+
record: CrmRecord;
|
|
447
|
+
}>;
|
|
448
|
+
updateRecord(id: string, body: {
|
|
449
|
+
input?: Record<string, unknown>;
|
|
450
|
+
ownerId?: string | null;
|
|
451
|
+
mutationId?: string;
|
|
452
|
+
}): Promise<{
|
|
453
|
+
record: CrmRecord;
|
|
454
|
+
duplicate: boolean;
|
|
455
|
+
}>;
|
|
456
|
+
setArchived(id: string, archived: boolean): Promise<{
|
|
457
|
+
duplicate: boolean;
|
|
458
|
+
}>;
|
|
459
|
+
setStage(id: string, to: string, mutationId?: string): Promise<{
|
|
460
|
+
record: CrmRecord;
|
|
461
|
+
from: string | null;
|
|
462
|
+
duplicate: boolean;
|
|
463
|
+
hookError?: string;
|
|
464
|
+
}>;
|
|
465
|
+
setRank(id: string, body: {
|
|
466
|
+
beforeId?: string;
|
|
467
|
+
afterId?: string;
|
|
468
|
+
}): Promise<{
|
|
469
|
+
rank: number;
|
|
470
|
+
rebalanceNeeded: boolean;
|
|
471
|
+
}>;
|
|
472
|
+
addTag(id: string, tag: string): Promise<{
|
|
473
|
+
tag: string;
|
|
474
|
+
duplicate: boolean;
|
|
475
|
+
}>;
|
|
476
|
+
removeTag(id: string, tag: string): Promise<{
|
|
477
|
+
duplicate: boolean;
|
|
478
|
+
}>;
|
|
479
|
+
setLink(id: string, body: {
|
|
480
|
+
relation: string;
|
|
481
|
+
toId: string;
|
|
482
|
+
remove?: boolean;
|
|
483
|
+
}): Promise<{
|
|
484
|
+
duplicate: boolean;
|
|
485
|
+
}>;
|
|
486
|
+
linkIdentity(id: string, email?: string): Promise<{
|
|
487
|
+
linked: boolean;
|
|
488
|
+
clerkUserId?: string;
|
|
489
|
+
}>;
|
|
490
|
+
sendEmail(id: string, body: {
|
|
491
|
+
templateId: string;
|
|
492
|
+
vars?: Record<string, string>;
|
|
493
|
+
dedupeKey?: string;
|
|
494
|
+
channelId?: string;
|
|
495
|
+
force?: boolean;
|
|
496
|
+
}): Promise<{
|
|
497
|
+
sent: boolean;
|
|
498
|
+
reason?: string;
|
|
499
|
+
}>;
|
|
500
|
+
listActivities(recordId: string, opts?: {
|
|
501
|
+
kind?: string;
|
|
502
|
+
limit?: number;
|
|
503
|
+
}): Promise<{
|
|
504
|
+
activities: CrmActivity[];
|
|
505
|
+
}>;
|
|
506
|
+
addActivity(recordId: string, body: {
|
|
507
|
+
kind: string;
|
|
508
|
+
body: string;
|
|
509
|
+
dueAt?: number;
|
|
510
|
+
assigneeId?: string;
|
|
511
|
+
waitingOn?: string;
|
|
512
|
+
}): Promise<{
|
|
513
|
+
id: string;
|
|
514
|
+
duplicate: boolean;
|
|
515
|
+
}>;
|
|
516
|
+
updateTask(id: string, body: {
|
|
517
|
+
status?: string;
|
|
518
|
+
dueAt?: number | null;
|
|
519
|
+
assigneeId?: string | null;
|
|
520
|
+
waitingOn?: string | null;
|
|
521
|
+
body?: string;
|
|
522
|
+
}): Promise<{
|
|
523
|
+
activity: CrmActivity;
|
|
524
|
+
duplicate: boolean;
|
|
525
|
+
}>;
|
|
526
|
+
listTasks(opts?: {
|
|
527
|
+
assigneeId?: string;
|
|
528
|
+
status?: string[];
|
|
529
|
+
limit?: number;
|
|
530
|
+
}): Promise<{
|
|
531
|
+
tasks: CrmActivity[];
|
|
532
|
+
}>;
|
|
533
|
+
listViews(type?: string): Promise<{
|
|
534
|
+
views: CrmView[];
|
|
535
|
+
}>;
|
|
536
|
+
saveView(spec: ViewSpec): Promise<{
|
|
537
|
+
id: string;
|
|
538
|
+
duplicate: boolean;
|
|
539
|
+
}>;
|
|
540
|
+
updateView(id: string, spec: Partial<ViewSpec>): Promise<{
|
|
541
|
+
view: CrmView;
|
|
542
|
+
duplicate: boolean;
|
|
543
|
+
}>;
|
|
544
|
+
deleteView(id: string): Promise<{
|
|
545
|
+
duplicate: boolean;
|
|
546
|
+
}>;
|
|
547
|
+
summary(type: string): Promise<TypeSummary>;
|
|
548
|
+
getConfig(): Promise<{
|
|
549
|
+
config: CrmConfigRow | null;
|
|
550
|
+
}>;
|
|
551
|
+
saveConfig(patch: ConfigPatch): Promise<{
|
|
552
|
+
config: CrmConfigRow;
|
|
553
|
+
duplicate: boolean;
|
|
554
|
+
}>;
|
|
555
|
+
emailLog(opts?: {
|
|
556
|
+
recordId?: string;
|
|
557
|
+
limit?: number;
|
|
558
|
+
}): Promise<{
|
|
559
|
+
log: Record<string, unknown>[];
|
|
560
|
+
}>;
|
|
561
|
+
rebalance(type: string): Promise<{
|
|
562
|
+
count: number;
|
|
563
|
+
}>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export { CrmClient as C, type RecordPage as R, type ViewFilters as V, type Crm as a, type CrmListParams as b, type CrmSort as c, type RecordDetail as d, type CrmRecord as e, type CrmView as f, type CrmTag as g, type CrmContactChannel as h, type CrmActivity as i };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GalleryEntry } from '@odla-ai/ui/gallery';
|
|
2
|
+
import { C as CrmClient, a as Crm } from '../client-CMYE9fpt.js';
|
|
3
|
+
|
|
4
|
+
/** One isolated world per call — two demos on the same page never share a
|
|
5
|
+
* mutation. */
|
|
6
|
+
declare function demoFetch(): typeof globalThis.fetch;
|
|
7
|
+
/** A CrmClient wired to its own in-memory world. */
|
|
8
|
+
declare const demoClient: () => CrmClient;
|
|
9
|
+
|
|
10
|
+
/** Two types, one pipeline, one relation — the smallest config that still
|
|
11
|
+
* exercises stage chips, enum filters, and the identity/email facets. */
|
|
12
|
+
declare const demoCrm: Crm;
|
|
13
|
+
|
|
14
|
+
/** Every CRM demo, console first — the surface people come here to see. */
|
|
15
|
+
declare const CRM_GALLERY: GalleryEntry[];
|
|
16
|
+
|
|
17
|
+
export { CRM_GALLERY, demoClient, demoCrm, demoFetch };
|