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