@fonderie/client 0.1.1 → 0.2.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.
@@ -5,14 +5,19 @@
5
5
  ## @fonderie/client
6
6
 
7
7
  ```ts
8
- new FonderieClient(opts: IFonderieClientOptions): FonderieClient
9
- .auth: AuthClient
10
-
11
8
  interface IFonderieClientOptions {
12
9
  baseUrl: string;
13
10
  accessToken?: string;
14
11
  }
15
12
 
13
+ new FonderieClient(opts: IFonderieClientOptions): FonderieClient
14
+ .auth: AuthClient
15
+ .billing: BillingClient
16
+ .workspaces: WorkspacesClient
17
+ .audit: AuditClient
18
+ .webhooks: WebhooksClient
19
+ .customers: CustomersClient
20
+
16
21
  new FonderieApiError(reason: string, explanation: string, status: number, details?: unknown): FonderieApiError
17
22
  .reason: string
18
23
  .explanation: string
@@ -23,8 +28,58 @@ new FonderieApiError(reason: string, explanation: string, status: number, detail
23
28
  .stack: string
24
29
  .cause: unknown
25
30
 
26
- new AuthClient(http: HttpClient, accessToken?: string | undefined): AuthClient
27
- .phone: PhoneClient
31
+ interface IListAuditEventsInput {
32
+ type?: string;
33
+ actorId?: string;
34
+ from?: Date;
35
+ to?: Date;
36
+ limit?: number;
37
+ cursor?: string;
38
+ }
39
+
40
+ new AuditClient(http: HttpClient, tokens: TokenStore): AuditClient
41
+ .setAccessToken(token: string | undefined): void
42
+ .setWorkspaceId(workspaceId: string | undefined): void
43
+ .listEvents(input?: IListAuditEventsInput): Promise<IApiResponse<IAuditPageResult>>
44
+
45
+ interface IChangePasswordInput {
46
+ currentPassword: string;
47
+ newPassword: string;
48
+ }
49
+
50
+ interface ILoginInput {
51
+ email: string;
52
+ password: string;
53
+ }
54
+
55
+ interface IRegisterInput {
56
+ email: string;
57
+ password: string;
58
+ firstName?: string;
59
+ lastName?: string;
60
+ }
61
+
62
+ interface IResetPasswordInput {
63
+ pin: string;
64
+ password: string;
65
+ }
66
+
67
+ interface IUpdatePreferencesInput {
68
+ locale?: string;
69
+ timezone?: string;
70
+ notifications?: unknown;
71
+ emailDigest?: unknown;
72
+ dateFormat?: unknown;
73
+ timeFormat?: unknown;
74
+ }
75
+
76
+ interface IUpdateProfileInput {
77
+ firstName?: string;
78
+ lastName?: string;
79
+ avatarUrl?: string;
80
+ }
81
+
82
+ new AuthClient(http: HttpClient, tokens: TokenStore): AuthClient
28
83
  .mfa: MfaClient
29
84
  .setAccessToken(token: string | undefined): void
30
85
  .register(input: IRegisterInput): Promise<IApiResponse<IRegisterResult>>
@@ -32,44 +87,352 @@ new AuthClient(http: HttpClient, accessToken?: string | undefined): AuthClient
32
87
  .refreshTokens(refreshToken?: string | undefined): Promise<IApiResponse<IRefreshResult>>
33
88
  .forgotPassword(email: string): Promise<IApiResponse<undefined>>
34
89
  .resetPassword(input: IResetPasswordInput): Promise<IApiResponse<undefined>>
35
- .verifyEmail(pin: string): Promise<IApiResponse<IVerifyEmailResult>>
90
+ .verifyEmail(token: string): Promise<IApiResponse<IVerifyEmailResult>>
36
91
  .logout(refreshToken?: string | undefined): Promise<IApiResponse<undefined>>
37
92
  .sendVerificationEmail(): Promise<IApiResponse<IResendVerificationResult>>
38
93
  .getUser(): Promise<IApiResponse<IMeResult>>
39
- .updateUser(input: IUpdateUserInput): Promise<IApiResponse<IMeResult>>
94
+ .updateProfile(input: IUpdateProfileInput): Promise<IApiResponse<IMeResult>>
95
+ .updatePreferences(input: IUpdatePreferencesInput): Promise<IApiResponse<IMeResult>>
96
+ .updateEmail(email: string): Promise<IApiResponse<unknown>>
97
+ .updatePhone(phone: string): Promise<IApiResponse<unknown>>
98
+ .changePassword(input: IChangePasswordInput): Promise<IApiResponse<undefined>>
99
+ .exportData(): Promise<IApiResponse<unknown>>
40
100
  .deleteUser(): Promise<IApiResponse<undefined>>
41
101
 
42
- interface IRegisterInput {
102
+ interface ICheckoutInput {
103
+ plan: string;
104
+ interval?: 'month' | 'year';
105
+ }
106
+
107
+ interface ICreatePlanInput {
108
+ name: string;
109
+ description?: string | null;
110
+ tier?: number;
111
+ seats?: number | null;
112
+ trialDays?: number;
113
+ monthlyAmount?: number | null;
114
+ monthlyPriceId?: string | null;
115
+ yearlyAmount?: number | null;
116
+ yearlyPriceId?: string | null;
117
+ features?: unknown;
118
+ metadata?: unknown;
119
+ }
120
+
121
+ interface IRecordUsageInput {
122
+ metric: string;
123
+ quantity?: number;
124
+ }
125
+
126
+ type IUpdatePlanInput = Partial<ICreatePlanInput>;
127
+
128
+ new BillingClient(http: HttpClient, tokens: TokenStore): BillingClient
129
+ .setAccessToken(token: string | undefined): void
130
+ .setWorkspaceId(workspaceId: string | undefined): void
131
+ .listPlans(): Promise<IApiResponse<IPlanListResult>>
132
+ .getPlan(planId: string): Promise<IApiResponse<IPlanResult>>
133
+ .createPlan(input: ICreatePlanInput): Promise<IApiResponse<IPlanResult>>
134
+ .updatePlan(planId: string, input: Partial<ICreatePlanInput>): Promise<IApiResponse<IPlanResult>>
135
+ .deletePlan(planId: string): Promise<IApiResponse<undefined>>
136
+ .getSubscription(): Promise<IApiResponse<ISubscriptionResult>>
137
+ .createCheckoutSession(input: ICheckoutInput): Promise<IApiResponse<ICheckoutUrlResult>>
138
+ .createPortalSession(): Promise<IApiResponse<IPortalUrlResult>>
139
+ .recordUsage(input: IRecordUsageInput): Promise<IApiResponse<undefined>>
140
+ .getUsage(metric: string): Promise<IApiResponse<IUsageResult>>
141
+
142
+ interface IConfigAdminClientOptions {
143
+ baseUrl: string;
144
+ adminToken: string;
145
+ }
146
+
147
+ interface IRollbackInput {
148
+ toVersion: number;
149
+ }
150
+
151
+ interface ISetConfigInput {
152
+ value: unknown;
153
+ description?: string;
154
+ ifVersion?: number;
155
+ }
156
+
157
+ interface ISetSecretInput {
158
+ value: string;
159
+ description?: string;
160
+ ifVersion?: number;
161
+ }
162
+
163
+ new ConfigAdminClient(opts: IConfigAdminClientOptions): ConfigAdminClient
164
+ .listConfig(environment?: string | undefined): Promise<IApiResponse<IConfigEntry[]>>
165
+ .getConfig(key: string, environment?: string | undefined): Promise<IApiResponse<IConfigEntry>>
166
+ .setConfig(key: string, input: ISetConfigInput, environment?: string | undefined): Promise<IApiResponse<IConfigEntry>>
167
+ .deleteConfig(key: string, environment?: string | undefined): Promise<IApiResponse<undefined>>
168
+ .listConfigRevisions(key: string, environment?: string | undefined): Promise<IApiResponse<IConfigRevision[]>>
169
+ .rollbackConfig(key: string, input: IRollbackInput, environment?: string | undefined): Promise<IApiResponse<IConfigEntry>>
170
+ .listSecrets(environment?: string | undefined): Promise<IApiResponse<ISecretEntry[]>>
171
+ .getSecret(key: string, environment?: string | undefined): Promise<IApiResponse<ISecretEntry>>
172
+ .setSecret(key: string, input: ISetSecretInput, environment?: string | undefined): Promise<IApiResponse<ISecretEntry>>
173
+ .deleteSecret(key: string, environment?: string | undefined): Promise<IApiResponse<undefined>>
174
+ .listSecretRevisions(key: string, environment?: string | undefined): Promise<IApiResponse<ISecretRevision[]>>
175
+ .rollbackSecret(key: string, input: IRollbackInput, environment?: string | undefined): Promise<IApiResponse<ISecretEntry>>
176
+ .revealSecret(key: string, environment?: string | undefined): Promise<IApiResponse<IRevealSecretResult>>
177
+
178
+ interface ICourierAdminClientOptions {
179
+ baseUrl: string;
180
+ adminToken: string;
181
+ }
182
+
183
+ interface IRollbackTemplateInput {
184
+ toVersion: number;
185
+ }
186
+
187
+ interface ISetTemplateInput {
188
+ text: string;
189
+ subject?: string;
190
+ html?: string;
191
+ active?: boolean;
192
+ ifVersion?: number;
193
+ }
194
+
195
+ new CourierAdminClient(opts: ICourierAdminClientOptions): CourierAdminClient
196
+ .listTemplates(): Promise<IApiResponse<ITemplateEntry[]>>
197
+ .getTemplate(type: string, locale?: string | null | undefined): Promise<IApiResponse<ITemplateEntry>>
198
+ .setTemplate(type: string, input: ISetTemplateInput, locale?: string | null | undefined): Promise<IApiResponse<ITemplateEntry>>
199
+ .deleteTemplate(type: string, locale?: string | null | undefined): Promise<IApiResponse<undefined>>
200
+ .listRevisions(type: string, locale?: string | null | undefined): Promise<IApiResponse<ITemplateRevision[]>>
201
+ .rollback(type: string, input: IRollbackTemplateInput, locale?: string | null | undefined): Promise<IApiResponse<ITemplateEntry>>
202
+
203
+ interface IAddAddressInput {
204
+ countryIso: string;
205
+ zipPostalCode: string;
206
+ subdivision1Iso?: string | null;
207
+ subdivision2Iso?: string | null;
208
+ unit?: string | null;
209
+ line1?: string | null;
210
+ line2?: string | null;
211
+ label?: string;
212
+ isPrimary?: boolean;
213
+ }
214
+
215
+ interface IAddEmailInput {
43
216
  email: string;
44
- password: string;
45
- firstName?: string;
46
- lastName?: string;
217
+ label?: string;
218
+ isPrimary?: boolean;
47
219
  }
48
220
 
49
- interface ILoginInput {
221
+ interface IAddPhoneInput {
222
+ phone: string;
223
+ label?: string;
224
+ isPrimary?: boolean;
225
+ }
226
+
227
+ interface IAddRelationshipInput {
228
+ relatedId: string;
229
+ relationship?: string;
230
+ isPrimary?: boolean;
231
+ }
232
+
233
+ interface IBlacklistCustomerInput {
234
+ reason?: string;
235
+ }
236
+
237
+ interface ICreateCustomerInput {
238
+ type?: CustomerType;
239
+ sex?: CustomerSex;
240
+ firstName?: string | null;
241
+ lastName?: string | null;
242
+ companyName?: string | null;
243
+ avatarUrl?: string | null;
244
+ locale?: string | null;
245
+ referenceCode?: string | null;
246
+ referralCode?: string | null;
247
+ referredByCode?: string | null;
248
+ }
249
+
250
+ interface IGetCustomerInput {
251
+ depth?: 1 | 2;
252
+ }
253
+
254
+ interface IListCustomersInput {
255
+ search?: string;
256
+ blacklisted?: boolean;
257
+ limit?: number;
258
+ offset?: number;
259
+ }
260
+
261
+ type IUpdateCustomerInput = ICreateCustomerInput;
262
+
263
+ new CustomersClient(http: HttpClient, tokens: TokenStore): CustomersClient
264
+ .setAccessToken(token: string | undefined): void
265
+ .setWorkspaceId(workspaceId: string | undefined): void
266
+ .listCustomers(input?: IListCustomersInput): Promise<IApiResponse<ICustomerListResult>>
267
+ .createCustomer(input?: ICreateCustomerInput): Promise<IApiResponse<ICustomerResult>>
268
+ .getCustomer(customerId: string, input?: IGetCustomerInput): Promise<IApiResponse<ICustomerDetailDTO | ICustomerDetailD2DTO>>
269
+ .updateCustomer(customerId: string, input: ICreateCustomerInput): Promise<IApiResponse<ICustomerResult>>
270
+ .deleteCustomer(customerId: string): Promise<IApiResponse<undefined>>
271
+ .blacklistCustomer(customerId: string, input?: IBlacklistCustomerInput): Promise<IApiResponse<undefined>>
272
+ .unblacklistCustomer(customerId: string): Promise<IApiResponse<undefined>>
273
+ .listEmails(customerId: string): Promise<IApiResponse<ICustomerEmailListResult>>
274
+ .addEmail(customerId: string, input: IAddEmailInput): Promise<IApiResponse<ICustomerEmailResult>>
275
+ .updateEmailLabel(customerId: string, emailId: string, label: string): Promise<IApiResponse<ICustomerEmailResult>>
276
+ .setPrimaryEmail(customerId: string, emailId: string): Promise<IApiResponse<undefined>>
277
+ .removeEmail(customerId: string, emailId: string): Promise<IApiResponse<undefined>>
278
+ .listPhones(customerId: string): Promise<IApiResponse<ICustomerPhoneListResult>>
279
+ .addPhone(customerId: string, input: IAddPhoneInput): Promise<IApiResponse<ICustomerPhoneResult>>
280
+ .updatePhoneLabel(customerId: string, phoneId: string, label: string): Promise<IApiResponse<ICustomerPhoneResult>>
281
+ .setPrimaryPhone(customerId: string, phoneId: string): Promise<IApiResponse<undefined>>
282
+ .removePhone(customerId: string, phoneId: string): Promise<IApiResponse<undefined>>
283
+ .listAddresses(customerId: string): Promise<IApiResponse<ICustomerAddressListResult>>
284
+ .addAddress(customerId: string, input: IAddAddressInput): Promise<IApiResponse<ICustomerAddressResult>>
285
+ .updateAddressLabel(customerId: string, addrId: string, label: string): Promise<IApiResponse<ICustomerAddressResult>>
286
+ .setPrimaryAddress(customerId: string, addrId: string): Promise<IApiResponse<undefined>>
287
+ .removeAddress(customerId: string, addrId: string): Promise<IApiResponse<undefined>>
288
+ .listNotes(customerId: string): Promise<IApiResponse<ICustomerNoteListResult>>
289
+ .createNote(customerId: string, body: string): Promise<IApiResponse<ICustomerNoteResult>>
290
+ .updateNote(customerId: string, noteId: string, body: string): Promise<IApiResponse<ICustomerNoteResult>>
291
+ .deleteNote(customerId: string, noteId: string): Promise<IApiResponse<undefined>>
292
+ .listTags(customerId: string): Promise<IApiResponse<ICustomerTagListResult>>
293
+ .addTag(customerId: string, tag: string): Promise<IApiResponse<undefined>>
294
+ .removeTag(customerId: string, tag: string): Promise<IApiResponse<undefined>>
295
+ .listRelationships(customerId: string): Promise<IApiResponse<ICustomerRelationshipListResult>>
296
+ .addRelationship(customerId: string, input: IAddRelationshipInput): Promise<IApiResponse<ICustomerRelationshipResult>>
297
+ .setPrimaryRelationship(customerId: string, relatedId: string): Promise<IApiResponse<undefined>>
298
+ .removeRelationship(customerId: string, relatedId: string): Promise<IApiResponse<undefined>>
299
+ .listLabels(type: CustomerLabelType): Promise<IApiResponse<ICustomerLabelListResult>>
300
+ .removeLabel(labelId: string): Promise<IApiResponse<undefined>>
301
+
302
+ interface ICreateWebhookEndpointInput {
303
+ url: string;
304
+ events?: string[];
305
+ }
306
+
307
+ interface IUpdateWebhookEndpointInput {
308
+ url?: string;
309
+ events?: string[];
310
+ enabled?: boolean;
311
+ }
312
+
313
+ new WebhooksClient(http: HttpClient, tokens: TokenStore): WebhooksClient
314
+ .setAccessToken(token: string | undefined): void
315
+ .setWorkspaceId(workspaceId: string | undefined): void
316
+ .listEndpoints(): Promise<IApiResponse<IWebhookEndpointListResult>>
317
+ .createEndpoint(input: ICreateWebhookEndpointInput): Promise<IApiResponse<IWebhookEndpointCreatedDTO>>
318
+ .getEndpoint(endpointId: string): Promise<IApiResponse<IWebhookEndpointDTO>>
319
+ .updateEndpoint(endpointId: string, input: IUpdateWebhookEndpointInput): Promise<IApiResponse<IWebhookEndpointDTO>>
320
+ .deleteEndpoint(endpointId: string): Promise<undefined>
321
+ .listDeliveries(endpointId: string): Promise<IApiResponse<IWebhookDeliveryListResult>>
322
+ .testEndpoint(endpointId: string): Promise<IApiResponse<ITestWebhookResult>>
323
+
324
+ interface ICreateRoleInput {
325
+ name: string;
326
+ description?: string;
327
+ }
328
+
329
+ interface ICreateWorkspaceInput {
330
+ name: string;
331
+ description?: string;
332
+ type?: string;
333
+ }
334
+
335
+ interface IInviteEntry {
50
336
  email: string;
51
- password: string;
337
+ roleId?: string;
52
338
  }
53
339
 
54
- interface IResetPasswordInput {
55
- resetToken: string;
56
- password: string;
340
+ interface IRolePermission {
341
+ permissionKey: string;
342
+ canCreate: boolean;
343
+ canRead: boolean;
344
+ canUpdate: boolean;
345
+ canDelete: boolean;
57
346
  }
58
347
 
59
- interface IUpdateUserInput {
60
- firstName?: string;
61
- lastName?: string;
62
- phoneNumber?: string;
63
- avatarUrl?: string;
348
+ interface IRolePermissionInput {
349
+ permissionKey: string;
350
+ canCreate?: boolean;
351
+ canRead?: boolean;
352
+ canUpdate?: boolean;
353
+ canDelete?: boolean;
354
+ }
355
+
356
+ interface IRolePermissionsResult {
357
+ permissions: IRolePermission[];
358
+ }
359
+
360
+ interface IUpdateRoleInput {
361
+ name?: string;
362
+ description?: string | null;
363
+ active?: boolean;
364
+ }
365
+
366
+ interface IUpdateSettingsInput {
64
367
  locale?: string;
65
368
  timezone?: string;
66
- preferences?: Record<string, unknown>;
369
+ currency?: string;
370
+ dateFormat?: string;
371
+ timeFormat?: string;
67
372
  }
68
373
 
69
- interface IApiResponse<T = undefined> {
70
- reason: string;
71
- explanation: string;
72
- result: T;
374
+ interface IUpdateWorkspaceInput {
375
+ name?: string;
376
+ description?: string | null;
377
+ motto?: string | null;
378
+ phone?: string | null;
379
+ businessType?: string | null;
380
+ address?: {
381
+ line1?: string;
382
+ line2?: string;
383
+ city?: string;
384
+ state?: string;
385
+ zip?: string;
386
+ country?: string;
387
+ } | null;
388
+ }
389
+
390
+ new WorkspacesClient(http: HttpClient, tokens: TokenStore): WorkspacesClient
391
+ .setAccessToken(token: string | undefined): void
392
+ .setWorkspaceId(workspaceId: string | undefined): void
393
+ .listWorkspaces(): Promise<IApiResponse<IWorkspaceListResult>>
394
+ .createWorkspace(input: ICreateWorkspaceInput): Promise<IApiResponse<IWorkspaceResult>>
395
+ .getWorkspace(id: string): Promise<IApiResponse<IWorkspaceResult>>
396
+ .updateWorkspace(input: IUpdateWorkspaceInput): Promise<IApiResponse<IWorkspaceResult>>
397
+ .archiveWorkspace(): Promise<IApiResponse<undefined>>
398
+ .restoreWorkspace(): Promise<IApiResponse<undefined>>
399
+ .listRoles(): Promise<IApiResponse<IRoleListResult>>
400
+ .createRole(input: ICreateRoleInput): Promise<IApiResponse<IRoleResult>>
401
+ .getRole(roleId: string): Promise<IApiResponse<IRoleResult>>
402
+ .updateRole(roleId: string, input: IUpdateRoleInput): Promise<IApiResponse<IRoleResult>>
403
+ .removeRole(roleId: string): Promise<IApiResponse<undefined>>
404
+ .getRolePermissions(roleId: string): Promise<IApiResponse<IRolePermissionsResult>>
405
+ .setRolePermissions(roleId: string, permissions: IRolePermissionInput[]): Promise<IApiResponse<undefined>>
406
+ .listMembers(): Promise<IApiResponse<IMemberListResult>>
407
+ .removeMember(userId: string): Promise<IApiResponse<undefined>>
408
+ .getMemberRoles(userId: string): Promise<IApiResponse<IRoleListResult>>
409
+ .addMemberRole(userId: string, roleId: string): Promise<IApiResponse<undefined>>
410
+ .removeMemberRole(userId: string, roleId: string): Promise<IApiResponse<undefined>>
411
+ .listInvitations(): Promise<IApiResponse<IInvitationListResult>>
412
+ .invite(entries: IInviteEntry | IInviteEntry[]): Promise<IApiResponse<IInviteResult>>
413
+ .cancelInvitation(inviteId: string): Promise<IApiResponse<undefined>>
414
+ .acceptInvitation(pin: string): Promise<IApiResponse<IAcceptInvitationResult>>
415
+ .getSettings(): Promise<IApiResponse<IWorkspaceSettingsResult>>
416
+ .updateSettings(input: IUpdateSettingsInput): Promise<IApiResponse<IWorkspaceSettingsResult>>
417
+
418
+ type CustomerLabelType = 'phone' | 'email' | 'address';
419
+
420
+ type CustomerSex = 'UNKNOWN' | 'MALE' | 'FEMALE';
421
+
422
+ type CustomerType = 'individual' | 'business';
423
+
424
+ interface IAcceptInvitationResult {
425
+ workspaceId: string;
426
+ }
427
+
428
+ interface IAddressDTO {
429
+ countryIso: string;
430
+ subdivision1Iso: string;
431
+ subdivision2Iso: string;
432
+ zipPostalCode: string;
433
+ unit: string;
434
+ line1: string;
435
+ line2: string;
73
436
  }
74
437
 
75
438
  interface IApiError {
@@ -78,6 +441,411 @@ interface IApiError {
78
441
  details?: unknown;
79
442
  }
80
443
 
444
+ interface IApiResponse<T = undefined> {
445
+ reason: string;
446
+ explanation: string;
447
+ result: T;
448
+ }
449
+
450
+ interface IAuditEventDTO {
451
+ id: string;
452
+ type: string;
453
+ actorId: string | null;
454
+ requestId: string | null;
455
+ payload: Record<string, unknown>;
456
+ createdAt: string;
457
+ }
458
+
459
+ interface IAuditPageResult {
460
+ events: IAuditEventDTO[];
461
+ nextCursor: string | null;
462
+ }
463
+
464
+ interface ICheckoutUrlResult {
465
+ url: string;
466
+ }
467
+
468
+ interface IConfigEntry {
469
+ key: string;
470
+ value: unknown;
471
+ environment: string;
472
+ description: string | null;
473
+ active: boolean;
474
+ version: number;
475
+ updatedBy: string | null;
476
+ updatedAt: string;
477
+ }
478
+
479
+ interface IConfigRevision {
480
+ key: string;
481
+ environment: string;
482
+ value: unknown;
483
+ version: number;
484
+ actor: string | null;
485
+ createdAt: string;
486
+ }
487
+
488
+ interface ICustomerAddressDTO {
489
+ id: string;
490
+ label: string;
491
+ isPrimary: boolean;
492
+ address: IAddressDTO;
493
+ }
494
+
495
+ interface ICustomerAddressListResult {
496
+ addresses: ICustomerAddressDTO[];
497
+ }
498
+
499
+ interface ICustomerAddressResult {
500
+ address: ICustomerAddressDTO;
501
+ }
502
+
503
+ interface ICustomerDetailD2DTO extends Omit<ICustomerDetailDTO, 'relationships'> {
504
+ relationships: ICustomerRelationshipExpandedD2DTO[];
505
+ }
506
+
507
+ interface ICustomerDetailDTO extends ICustomerDTO {
508
+ emails: ICustomerEmailDTO[];
509
+ phones: ICustomerPhoneDTO[];
510
+ addresses: ICustomerAddressDTO[];
511
+ notes: ICustomerNoteDTO[];
512
+ relationships: ICustomerRelationshipExpandedDTO[];
513
+ tags: string[];
514
+ }
515
+
516
+ interface ICustomerDTO {
517
+ id: string;
518
+ type: string;
519
+ sex: CustomerSex;
520
+ firstName: string;
521
+ lastName: string;
522
+ companyName: string;
523
+ avatarUrl: string;
524
+ locale: string;
525
+ referenceCode: string;
526
+ referralCode: string;
527
+ referredBy: string | null;
528
+ blacklisted: {
529
+ status: boolean;
530
+ reason: string | null;
531
+ };
532
+ createdBy: string;
533
+ createdAt: string;
534
+ updatedAt: string;
535
+ }
536
+
537
+ interface ICustomerEmailDTO {
538
+ id: string;
539
+ email: string;
540
+ label: string;
541
+ isPrimary: boolean;
542
+ createdAt: string;
543
+ }
544
+
545
+ interface ICustomerEmailListResult {
546
+ emails: ICustomerEmailDTO[];
547
+ }
548
+
549
+ interface ICustomerEmailResult {
550
+ email: ICustomerEmailDTO;
551
+ }
552
+
553
+ interface ICustomerLabelDTO {
554
+ id: string;
555
+ type: CustomerLabelType;
556
+ value: string;
557
+ createdAt: string;
558
+ }
559
+
560
+ interface ICustomerLabelListResult {
561
+ labels: ICustomerLabelDTO[];
562
+ }
563
+
564
+ interface ICustomerListResult {
565
+ customers: ICustomerDTO[];
566
+ }
567
+
568
+ interface ICustomerNoteDTO {
569
+ id: string;
570
+ authorId: string;
571
+ body: string;
572
+ createdAt: string;
573
+ updatedAt: string;
574
+ }
575
+
576
+ interface ICustomerNoteListResult {
577
+ notes: ICustomerNoteDTO[];
578
+ }
579
+
580
+ interface ICustomerNoteResult {
581
+ note: ICustomerNoteDTO;
582
+ }
583
+
584
+ interface ICustomerPhoneDTO {
585
+ id: string;
586
+ phone: string;
587
+ label: string;
588
+ isPrimary: boolean;
589
+ createdAt: string;
590
+ }
591
+
592
+ interface ICustomerPhoneListResult {
593
+ phones: ICustomerPhoneDTO[];
594
+ }
595
+
596
+ interface ICustomerPhoneResult {
597
+ phone: ICustomerPhoneDTO;
598
+ }
599
+
600
+ interface ICustomerRelationshipDTO {
601
+ id: string;
602
+ relatedId: string;
603
+ relationship: string;
604
+ isPrimary: boolean;
605
+ createdAt: string;
606
+ }
607
+
608
+ type ICustomerRelationshipExpandedD2DTO = ICustomerRelationshipExpandedDTO & {
609
+ relationships: ICustomerRelationshipExpandedDTO[];
610
+ };
611
+
612
+ type ICustomerRelationshipExpandedDTO = Omit<ICustomerShallowDTO, 'id'> & {
613
+ id: string;
614
+ customerId: string;
615
+ relationship: string;
616
+ isPrimary: boolean;
617
+ };
618
+
619
+ interface ICustomerRelationshipListResult {
620
+ relationships: ICustomerRelationshipDTO[];
621
+ }
622
+
623
+ interface ICustomerRelationshipResult {
624
+ relationship: ICustomerRelationshipDTO;
625
+ }
626
+
627
+ interface ICustomerResult {
628
+ customer: ICustomerDTO;
629
+ }
630
+
631
+ interface ICustomerShallowDTO extends ICustomerDTO {
632
+ emails: ICustomerEmailDTO[];
633
+ phones: ICustomerPhoneDTO[];
634
+ addresses: ICustomerAddressDTO[];
635
+ notes: ICustomerNoteDTO[];
636
+ tags: string[];
637
+ }
638
+
639
+ interface ICustomerTagListResult {
640
+ tags: string[];
641
+ }
642
+
643
+ interface IInvitationDTO {
644
+ id: string;
645
+ workspaceId: string;
646
+ email: string;
647
+ roleId: string;
648
+ token: string;
649
+ status: string;
650
+ expiresAt: string;
651
+ createdAt: string;
652
+ }
653
+
654
+ interface IInvitationListResult {
655
+ invitations: IInvitationDTO[];
656
+ }
657
+
658
+ interface IInviteResult {
659
+ invitations: Array<{
660
+ invitationId: string;
661
+ email: string;
662
+ }>;
663
+ }
664
+
665
+ interface ILoginResult {
666
+ tokens: ITokens;
667
+ user: IUserDTO;
668
+ }
669
+
670
+ interface IMemberDTO {
671
+ userId: string;
672
+ workspaceId: string;
673
+ roleId: string;
674
+ roleName: string;
675
+ confirmed: boolean;
676
+ createdAt: string;
677
+ }
678
+
679
+ interface IMemberListResult {
680
+ members: IMemberDTO[];
681
+ }
682
+
683
+ interface IMeResult {
684
+ user: IUserDTO;
685
+ }
686
+
687
+ interface IMfaEnabledResult {
688
+ tokens: ITokens;
689
+ user: IUserDTO;
690
+ }
691
+
692
+ interface IMfaSetupResult {
693
+ secret: string;
694
+ uri: string;
695
+ }
696
+
697
+ interface IPlanDTO {
698
+ id: string;
699
+ planId: string;
700
+ name: string;
701
+ description: string;
702
+ tier: number;
703
+ seats: number | null;
704
+ trialDays: number;
705
+ pricing: {
706
+ monthly: number;
707
+ yearly: number;
708
+ currency: string;
709
+ };
710
+ features: IPlanFeature[];
711
+ metadata: Record<string, unknown>;
712
+ }
713
+
714
+ interface IPlanFeature {
715
+ name: string;
716
+ description: string;
717
+ enabled: boolean;
718
+ limit?: number;
719
+ }
720
+
721
+ interface IPlanListResult {
722
+ plans: IPlanDTO[];
723
+ }
724
+
725
+ interface IPlanResult {
726
+ plan: IPlanDTO;
727
+ }
728
+
729
+ interface IPortalUrlResult {
730
+ url: string;
731
+ }
732
+
733
+ interface IRefreshResult {
734
+ tokens: ITokens;
735
+ }
736
+
737
+ interface IRegisterResult {
738
+ tokens: ITokens;
739
+ user: IUserDTO;
740
+ }
741
+
742
+ interface IResendVerificationResult {
743
+ stat: string;
744
+ message: string;
745
+ data: {
746
+ token: string;
747
+ expiresAt: string;
748
+ email: string;
749
+ };
750
+ }
751
+
752
+ interface IRevealSecretResult {
753
+ value: string;
754
+ }
755
+
756
+ interface IRoleDTO {
757
+ id: string;
758
+ name: string;
759
+ isSystem: boolean;
760
+ active: boolean;
761
+ description: string;
762
+ workspaceId: string;
763
+ }
764
+
765
+ interface IRoleListResult {
766
+ roles: IRoleDTO[];
767
+ }
768
+
769
+ interface IRoleResult {
770
+ role: IRoleDTO;
771
+ }
772
+
773
+ interface ISecretEntry {
774
+ key: string;
775
+ environment: string;
776
+ description: string | null;
777
+ active: boolean;
778
+ version: number;
779
+ updatedBy: string | null;
780
+ updatedAt: string;
781
+ }
782
+
783
+ interface ISecretRevision {
784
+ key: string;
785
+ environment: string;
786
+ version: number;
787
+ actor: string | null;
788
+ createdAt: string;
789
+ }
790
+
791
+ interface ISubscriptionDTO {
792
+ id: string;
793
+ subscriberType: SubscriberType;
794
+ subscriberId: string;
795
+ plan: string;
796
+ interval: string;
797
+ status: string;
798
+ cancelAtPeriodEnd: boolean;
799
+ currentPeriodStart: string | null;
800
+ currentPeriodEnd: string | null;
801
+ trialEndsAt: string | null;
802
+ createdAt: string;
803
+ }
804
+
805
+ interface ISubscriptionResult {
806
+ subscription: ISubscriptionDTO;
807
+ }
808
+
809
+ interface ITemplateEntry {
810
+ type: string;
811
+ locale: string | null;
812
+ subject: string | null;
813
+ html: string | null;
814
+ text: string;
815
+ active: boolean;
816
+ version: number;
817
+ updatedBy: string | null;
818
+ updatedAt: string;
819
+ }
820
+
821
+ interface ITemplateRevision {
822
+ type: string;
823
+ locale: string | null;
824
+ subject: string | null;
825
+ html: string | null;
826
+ text: string;
827
+ version: number;
828
+ actor: string | null;
829
+ createdAt: string;
830
+ }
831
+
832
+ interface ITestWebhookResult {
833
+ status: number | null;
834
+ ok: boolean;
835
+ error?: string;
836
+ }
837
+
838
+ interface ITokens {
839
+ access: string;
840
+ refresh: string;
841
+ }
842
+
843
+ interface IUsageResult {
844
+ metric: string;
845
+ total: number;
846
+ since: string;
847
+ }
848
+
81
849
  interface IUserDTO {
82
850
  id: string;
83
851
  email: string;
@@ -117,51 +885,89 @@ interface IUserSkill {
117
885
  level: string;
118
886
  }
119
887
 
120
- interface ITokens {
121
- access: string;
122
- refresh: string;
888
+ interface IVerifyEmailResult {
889
+ verified: boolean;
890
+ email: string;
123
891
  }
124
892
 
125
- interface IRegisterResult {
126
- tokens: ITokens;
127
- user: IUserDTO;
893
+ interface IWebhookDeliveryDTO {
894
+ id: string;
895
+ eventId: string;
896
+ eventType: string;
897
+ status: string;
898
+ attempts: number;
899
+ responseStatus: number | null;
900
+ deliveredAt: string | null;
901
+ createdAt: string;
128
902
  }
129
903
 
130
- interface ILoginResult {
131
- tokens: ITokens;
132
- user: IUserDTO;
904
+ interface IWebhookDeliveryListResult {
905
+ deliveries: IWebhookDeliveryDTO[];
133
906
  }
134
907
 
135
- interface IRefreshResult {
136
- tokens: ITokens;
908
+ interface IWebhookEndpointCreatedDTO extends IWebhookEndpointDTO {
909
+ secret: string;
137
910
  }
138
911
 
139
- interface IVerifyEmailResult {
140
- verified: boolean;
141
- email: string;
912
+ interface IWebhookEndpointDTO {
913
+ id: string;
914
+ url: string;
915
+ events: string[];
916
+ enabled: boolean;
917
+ createdAt: string;
142
918
  }
143
919
 
144
- interface IResendVerificationResult {
145
- stat: string;
146
- message: string;
147
- data: {
148
- token: string;
149
- expiresAt: string;
150
- email: string;
151
- };
920
+ interface IWebhookEndpointListResult {
921
+ endpoints: IWebhookEndpointDTO[];
152
922
  }
153
923
 
154
- interface IMeResult {
155
- user: IUserDTO;
924
+ interface IWorkspaceAddressDTO {
925
+ line1: string;
926
+ line2: string;
927
+ city: string;
928
+ state: string;
929
+ zip: string;
930
+ country: string;
156
931
  }
157
932
 
158
- interface IMfaSetupResult {
159
- secret: string;
160
- uri: string;
933
+ interface IWorkspaceDTO {
934
+ id: string;
935
+ name: string;
936
+ slug: string;
937
+ type: string;
938
+ description: string;
939
+ motto: string;
940
+ phone: string;
941
+ businessType: string;
942
+ address: IWorkspaceAddressDTO;
943
+ plan: string;
944
+ ownerId: string;
945
+ isPersonal: boolean;
946
+ isArchived: boolean;
947
+ archivedAt: string;
948
+ createdAt: string;
949
+ updatedAt: string;
161
950
  }
162
951
 
163
- interface IMfaEnabledResult {
164
- tokens: ITokens;
165
- user: IUserDTO;
952
+ interface IWorkspaceListResult {
953
+ workspaces: IWorkspaceDTO[];
166
954
  }
955
+
956
+ interface IWorkspaceResult {
957
+ workspace: IWorkspaceDTO;
958
+ }
959
+
960
+ interface IWorkspaceSettingsDTO {
961
+ locale: string;
962
+ timezone: string;
963
+ currency: string;
964
+ dateFormat: string;
965
+ timeFormat: string;
966
+ }
967
+
968
+ interface IWorkspaceSettingsResult {
969
+ settings: IWorkspaceSettingsDTO;
970
+ }
971
+
972
+ type SubscriberType = 'user' | 'workspace';
167
973
  ```