@crmy/shared 0.5.1 → 0.5.5

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/src/types.ts DELETED
@@ -1,577 +0,0 @@
1
- // Copyright 2026 CRMy Contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export type UUID = string;
5
-
6
- export interface Tenant {
7
- id: UUID;
8
- slug: string;
9
- name: string;
10
- plan: string;
11
- settings: Record<string, unknown>;
12
- created_at: string;
13
- updated_at: string;
14
- }
15
-
16
- export interface User {
17
- id: UUID;
18
- tenant_id: UUID;
19
- email: string;
20
- name: string;
21
- role: 'owner' | 'admin' | 'member';
22
- custom_fields: Record<string, unknown>;
23
- created_at: string;
24
- updated_at: string;
25
- }
26
-
27
- export interface Contact {
28
- id: UUID;
29
- tenant_id: UUID;
30
- first_name: string;
31
- last_name: string;
32
- email?: string;
33
- phone?: string;
34
- title?: string;
35
- company_name?: string;
36
- account_id?: UUID;
37
- owner_id?: UUID;
38
- lifecycle_stage: 'lead' | 'prospect' | 'customer' | 'churned';
39
- source?: string;
40
- tags: string[];
41
- custom_fields: Record<string, unknown>;
42
- created_by?: UUID;
43
- created_at: string;
44
- updated_at: string;
45
- }
46
-
47
- export interface Account {
48
- id: UUID;
49
- tenant_id: UUID;
50
- name: string;
51
- domain?: string;
52
- industry?: string;
53
- employee_count?: number;
54
- annual_revenue?: number;
55
- currency_code: string;
56
- website?: string;
57
- parent_id?: UUID;
58
- owner_id?: UUID;
59
- health_score?: number;
60
- tags: string[];
61
- custom_fields: Record<string, unknown>;
62
- created_by?: UUID;
63
- created_at: string;
64
- updated_at: string;
65
- }
66
-
67
- export interface Opportunity {
68
- id: UUID;
69
- tenant_id: UUID;
70
- name: string;
71
- account_id?: UUID;
72
- contact_id?: UUID;
73
- owner_id?: UUID;
74
- stage: 'prospecting' | 'qualification' | 'proposal' | 'negotiation' | 'closed_won' | 'closed_lost';
75
- amount?: number;
76
- currency_code: string;
77
- close_date?: string;
78
- probability?: number;
79
- forecast_cat: 'pipeline' | 'best_case' | 'commit' | 'closed';
80
- description?: string;
81
- lost_reason?: string;
82
- custom_fields: Record<string, unknown>;
83
- created_by?: UUID;
84
- created_at: string;
85
- updated_at: string;
86
- }
87
-
88
- export interface Activity {
89
- id: UUID;
90
- tenant_id: UUID;
91
- type: 'call' | 'email' | 'meeting' | 'note' | 'task';
92
- subject: string;
93
- body?: string;
94
- status: string;
95
- direction?: string;
96
- due_at?: string;
97
- completed_at?: string;
98
- contact_id?: UUID;
99
- account_id?: UUID;
100
- opportunity_id?: UUID;
101
- owner_id?: UUID;
102
- source_agent?: string;
103
- use_case_id?: UUID;
104
- custom_fields: Record<string, unknown>;
105
- created_by?: UUID;
106
- created_at: string;
107
- updated_at: string;
108
- // Context Engine fields (v0.4)
109
- performed_by?: UUID;
110
- subject_type?: 'contact' | 'account' | 'opportunity' | 'use_case';
111
- subject_id?: UUID;
112
- related_type?: 'contact' | 'account' | 'opportunity' | 'use_case';
113
- related_id?: UUID;
114
- detail?: Record<string, unknown>;
115
- occurred_at?: string;
116
- outcome?: string;
117
- }
118
-
119
- export interface HITLRequest {
120
- id: UUID;
121
- tenant_id: UUID;
122
- agent_id: string;
123
- session_id?: string;
124
- action_type: string;
125
- action_summary: string;
126
- action_payload: unknown;
127
- status: 'pending' | 'approved' | 'rejected' | 'expired' | 'auto_approved';
128
- reviewer_id?: UUID;
129
- review_note?: string;
130
- auto_approve_after?: string;
131
- expires_at: string;
132
- created_at: string;
133
- resolved_at?: string;
134
- }
135
-
136
- export interface CrmyEvent {
137
- id: number;
138
- tenant_id: UUID;
139
- event_type: string;
140
- actor_id?: string;
141
- actor_type: 'user' | 'agent' | 'system';
142
- object_type: string;
143
- object_id?: UUID;
144
- before_data?: unknown;
145
- after_data?: unknown;
146
- metadata: Record<string, unknown>;
147
- created_at: string;
148
- }
149
-
150
- export interface ApiKey {
151
- id: UUID;
152
- tenant_id: UUID;
153
- user_id?: UUID;
154
- actor_id?: UUID;
155
- label: string;
156
- scopes: string[];
157
- last_used_at?: string;
158
- expires_at?: string;
159
- created_at: string;
160
- }
161
-
162
- export interface PaginatedResponse<T> {
163
- data: T[];
164
- next_cursor?: string;
165
- total: number;
166
- }
167
-
168
- export interface ActorContext {
169
- tenant_id: UUID;
170
- actor_id: string;
171
- actor_type: 'user' | 'agent' | 'system';
172
- role: 'owner' | 'admin' | 'member';
173
- scopes?: string[];
174
- }
175
-
176
- export interface OperationResult<T> {
177
- data: T;
178
- event_id: number;
179
- }
180
-
181
- // -- v0.2 types --
182
-
183
- export type UseCaseStage =
184
- | 'discovery'
185
- | 'poc'
186
- | 'production'
187
- | 'scaling'
188
- | 'sunset';
189
-
190
- export interface UseCase {
191
- id: UUID;
192
- tenant_id: UUID;
193
- name: string;
194
- description?: string;
195
- account_id: UUID;
196
- opportunity_id?: UUID;
197
- owner_id?: UUID;
198
- stage: UseCaseStage;
199
- unit_label?: string;
200
- consumption_current?: number;
201
- consumption_capacity?: number;
202
- consumption_unit?: string;
203
- attributed_arr?: number;
204
- currency_code: string;
205
- expansion_potential?: number;
206
- health_score?: number;
207
- health_note?: string;
208
- started_at?: string;
209
- target_prod_date?: string;
210
- sunset_date?: string;
211
- tags: string[];
212
- custom_fields: Record<string, unknown>;
213
- created_by?: UUID;
214
- created_at: string;
215
- updated_at: string;
216
- }
217
-
218
- export interface UseCaseContact {
219
- use_case_id: UUID;
220
- contact_id: UUID;
221
- role?: string;
222
- added_at: string;
223
- }
224
-
225
- export interface WebhookEndpoint {
226
- id: UUID;
227
- tenant_id: UUID;
228
- url: string;
229
- secret: string;
230
- events: string[];
231
- active: boolean;
232
- description?: string;
233
- created_at: string;
234
- updated_at: string;
235
- }
236
-
237
- export interface WebhookDelivery {
238
- id: UUID;
239
- endpoint_id: UUID;
240
- event_id: number;
241
- event_type: string;
242
- payload: unknown;
243
- status: 'pending' | 'success' | 'failed';
244
- http_status?: number;
245
- attempt: number;
246
- max_attempts: number;
247
- next_retry_at?: string;
248
- response_body?: string;
249
- created_at: string;
250
- completed_at?: string;
251
- }
252
-
253
- export interface EmailProvider {
254
- id: UUID;
255
- tenant_id: UUID;
256
- name: string;
257
- provider_type: 'smtp' | 'sendgrid' | 'ses';
258
- config: Record<string, unknown>;
259
- from_address: string;
260
- from_name?: string;
261
- active: boolean;
262
- created_at: string;
263
- updated_at: string;
264
- }
265
-
266
- export interface Email {
267
- id: UUID;
268
- tenant_id: UUID;
269
- provider_id?: UUID;
270
- contact_id?: UUID;
271
- account_id?: UUID;
272
- opportunity_id?: UUID;
273
- use_case_id?: UUID;
274
- subject: string;
275
- body_html?: string;
276
- body_text?: string;
277
- from_address: string;
278
- to_address: string;
279
- status: 'draft' | 'pending_approval' | 'approved' | 'sending' | 'sent' | 'failed' | 'rejected';
280
- hitl_request_id?: UUID;
281
- sent_at?: string;
282
- created_by?: UUID;
283
- created_at: string;
284
- updated_at: string;
285
- }
286
-
287
- export interface EmailSequence {
288
- id: UUID;
289
- tenant_id: UUID;
290
- name: string;
291
- description?: string;
292
- steps: EmailSequenceStep[];
293
- active: boolean;
294
- created_by?: UUID;
295
- created_at: string;
296
- updated_at: string;
297
- }
298
-
299
- export interface EmailSequenceStep {
300
- delay_days: number;
301
- subject: string;
302
- body_html?: string;
303
- body_text?: string;
304
- }
305
-
306
- export interface SequenceEnrollment {
307
- id: UUID;
308
- sequence_id: UUID;
309
- contact_id: UUID;
310
- current_step: number;
311
- status: 'active' | 'completed' | 'paused' | 'cancelled';
312
- next_send_at?: string;
313
- created_at: string;
314
- updated_at: string;
315
- }
316
-
317
- export interface CustomFieldDefinition {
318
- id: UUID;
319
- tenant_id: UUID;
320
- object_type: 'contact' | 'account' | 'opportunity' | 'activity' | 'use_case';
321
- field_name: string;
322
- field_type: 'text' | 'number' | 'boolean' | 'date' | 'select' | 'multi_select';
323
- label: string;
324
- description?: string;
325
- required: boolean;
326
- options?: string[];
327
- default_value?: unknown;
328
- sort_order: number;
329
- created_at: string;
330
- updated_at: string;
331
- }
332
-
333
- export interface BulkJob {
334
- id: UUID;
335
- tenant_id: UUID;
336
- operation: 'import' | 'export' | 'update' | 'delete';
337
- object_type: string;
338
- status: 'pending' | 'processing' | 'completed' | 'failed';
339
- total_rows: number;
340
- processed_rows: number;
341
- error_rows: number;
342
- errors?: Record<string, unknown>[];
343
- file_url?: string;
344
- created_by?: UUID;
345
- created_at: string;
346
- completed_at?: string;
347
- }
348
-
349
- // -- v0.3 types --
350
-
351
- export interface Note {
352
- id: UUID;
353
- tenant_id: UUID;
354
- object_type: string;
355
- object_id: UUID;
356
- parent_id?: UUID;
357
- body: string;
358
- visibility: 'internal' | 'external';
359
- mentions: string[];
360
- pinned: boolean;
361
- author_id?: UUID;
362
- author_type: 'user' | 'agent' | 'system';
363
- created_at: string;
364
- updated_at: string;
365
- }
366
-
367
- export type WorkflowActionType =
368
- | 'send_notification'
369
- | 'update_field'
370
- | 'create_activity'
371
- | 'add_tag'
372
- | 'remove_tag'
373
- | 'assign_owner'
374
- | 'create_note'
375
- | 'webhook';
376
-
377
- export interface WorkflowAction {
378
- type: WorkflowActionType;
379
- config: Record<string, unknown>;
380
- }
381
-
382
- export interface Workflow {
383
- id: UUID;
384
- tenant_id: UUID;
385
- name: string;
386
- description?: string;
387
- trigger_event: string;
388
- trigger_filter: Record<string, unknown>;
389
- actions: WorkflowAction[];
390
- is_active: boolean;
391
- run_count: number;
392
- last_run_at?: string;
393
- created_by?: UUID;
394
- created_at: string;
395
- updated_at: string;
396
- }
397
-
398
- export interface WorkflowRun {
399
- id: UUID;
400
- workflow_id: UUID;
401
- event_id?: number;
402
- status: 'running' | 'completed' | 'failed';
403
- actions_run: number;
404
- actions_total: number;
405
- error?: string;
406
- started_at: string;
407
- completed_at?: string;
408
- }
409
-
410
- // -- v0.4 Context Engine types --
411
-
412
- export type SubjectType = 'contact' | 'account' | 'opportunity' | 'use_case';
413
-
414
- export interface Actor {
415
- id: UUID;
416
- tenant_id: UUID;
417
- actor_type: 'human' | 'agent';
418
- display_name: string;
419
- email?: string;
420
- phone?: string;
421
- user_id?: UUID;
422
- role?: string;
423
- agent_identifier?: string;
424
- agent_model?: string;
425
- scopes: string[];
426
- metadata: Record<string, unknown>;
427
- is_active: boolean;
428
- created_at: string;
429
- updated_at: string;
430
- }
431
-
432
- export const AVAILABLE_SCOPES = [
433
- 'read',
434
- 'write',
435
- 'contacts:read',
436
- 'contacts:write',
437
- 'accounts:read',
438
- 'accounts:write',
439
- 'opportunities:read',
440
- 'opportunities:write',
441
- 'activities:read',
442
- 'activities:write',
443
- 'assignments:create',
444
- 'assignments:update',
445
- 'context:read',
446
- 'context:write',
447
- ] as const;
448
-
449
- export type Scope = typeof AVAILABLE_SCOPES[number];
450
-
451
- export interface ContactChannel {
452
- channel_type: 'email' | 'phone' | 'slack' | 'teams' | 'discord' | 'whatsapp' | string;
453
- handle: string;
454
- verified?: boolean;
455
- primary?: boolean;
456
- }
457
-
458
- export type AssignmentStatus =
459
- | 'pending'
460
- | 'accepted'
461
- | 'in_progress'
462
- | 'blocked'
463
- | 'completed'
464
- | 'declined'
465
- | 'cancelled';
466
-
467
- export type AssignmentPriority = 'low' | 'normal' | 'high' | 'urgent';
468
-
469
- export interface Assignment {
470
- id: UUID;
471
- tenant_id: UUID;
472
- title: string;
473
- description?: string;
474
- assignment_type: string;
475
- assigned_by: UUID;
476
- assigned_to: UUID;
477
- subject_type: SubjectType;
478
- subject_id: UUID;
479
- status: AssignmentStatus;
480
- priority: AssignmentPriority;
481
- due_at?: string;
482
- accepted_at?: string;
483
- completed_at?: string;
484
- completed_by_activity_id?: UUID;
485
- context?: string;
486
- metadata: Record<string, unknown>;
487
- created_at: string;
488
- updated_at: string;
489
- }
490
-
491
- export interface ContextEntry {
492
- id: UUID;
493
- tenant_id: UUID;
494
- subject_type: SubjectType;
495
- subject_id: UUID;
496
- context_type: string;
497
- authored_by: UUID;
498
- title?: string;
499
- body: string;
500
- structured_data: Record<string, unknown>;
501
- tags: string[];
502
- confidence?: number;
503
- is_current: boolean;
504
- supersedes_id?: UUID;
505
- source?: string;
506
- source_ref?: string;
507
- source_activity_id?: UUID;
508
- valid_until?: string;
509
- reviewed_at?: string;
510
- created_at: string;
511
- updated_at: string;
512
- }
513
-
514
- // -- v0.4/v0.5 Registry types --
515
-
516
- export interface ActivityTypeRegistryEntry {
517
- type_name: string;
518
- tenant_id: UUID;
519
- label: string;
520
- description?: string;
521
- category: 'outreach' | 'meeting' | 'proposal' | 'contract' | 'internal' | 'lifecycle' | 'handoff';
522
- is_default: boolean;
523
- created_at: string;
524
- }
525
-
526
- export interface ContextTypeRegistryEntry {
527
- type_name: string;
528
- tenant_id: UUID;
529
- label: string;
530
- description?: string;
531
- is_default: boolean;
532
- created_at: string;
533
- }
534
-
535
- // -- Governor limits --
536
-
537
- export interface GovernorLimit {
538
- tenant_id: UUID;
539
- limit_name: string;
540
- limit_value: number;
541
- }
542
-
543
- export const GOVERNOR_DEFAULTS: Record<string, Record<string, number>> = {
544
- solo_agent: {
545
- actors_max: 3,
546
- activities_per_day: 500,
547
- assignments_active: 50,
548
- context_entries_max: 1000,
549
- context_body_max_chars: 10000,
550
- },
551
- pro_agent: {
552
- actors_max: 15,
553
- activities_per_day: 5000,
554
- assignments_active: 500,
555
- context_entries_max: 10000,
556
- context_body_max_chars: 50000,
557
- },
558
- team: {
559
- actors_max: 50,
560
- activities_per_day: 25000,
561
- assignments_active: 2500,
562
- context_entries_max: 50000,
563
- context_body_max_chars: 50000,
564
- },
565
- };
566
-
567
- // -- Briefing types --
568
-
569
- export interface Briefing {
570
- subject: Record<string, unknown>;
571
- subject_type: SubjectType;
572
- related_objects: Record<string, unknown[]>;
573
- activities: Activity[];
574
- open_assignments: Assignment[];
575
- context_entries: Record<string, ContextEntry[]>;
576
- staleness_warnings: ContextEntry[];
577
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src",
6
- "composite": true
7
- },
8
- "include": ["src"]
9
- }