@dalmore/api-contracts 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/contracts/clients/index.d.ts +19 -0
  2. package/index.mjs +4 -1
  3. package/package.json +4 -4
  4. package/src/common/types/account-contact.types.ts +0 -98
  5. package/src/common/types/account-detail.types.ts +0 -27
  6. package/src/common/types/account-integration.types.ts +0 -143
  7. package/src/common/types/account-manager.types.ts +0 -124
  8. package/src/common/types/account.types.ts +0 -296
  9. package/src/common/types/activity.types.ts +0 -274
  10. package/src/common/types/address.spec.ts +0 -203
  11. package/src/common/types/address.types.ts +0 -41
  12. package/src/common/types/aic.types.ts +0 -246
  13. package/src/common/types/aml.types.ts +0 -18
  14. package/src/common/types/api-key-logs.types.ts +0 -66
  15. package/src/common/types/api-keys.types.ts +0 -69
  16. package/src/common/types/asset.types.ts +0 -338
  17. package/src/common/types/auth.types.ts +0 -370
  18. package/src/common/types/batch-jobs.types.ts +0 -151
  19. package/src/common/types/bonus-tier.types.ts +0 -147
  20. package/src/common/types/cart.types.ts +0 -18
  21. package/src/common/types/checklist-items.types.ts +0 -70
  22. package/src/common/types/checklist.types.ts +0 -97
  23. package/src/common/types/common.types.spec.ts +0 -336
  24. package/src/common/types/common.types.ts +0 -1520
  25. package/src/common/types/comply-advantage-api.types.ts +0 -316
  26. package/src/common/types/comply-advantage.types.ts +0 -25
  27. package/src/common/types/contact-us.types.ts +0 -107
  28. package/src/common/types/contract-helpers.ts +0 -205
  29. package/src/common/types/countries.types.ts +0 -375
  30. package/src/common/types/covered-person.types.ts +0 -274
  31. package/src/common/types/dashboard.types.ts +0 -799
  32. package/src/common/types/data-record.types.ts +0 -325
  33. package/src/common/types/data-room.types.ts +0 -242
  34. package/src/common/types/default-theme-config.types.ts +0 -87
  35. package/src/common/types/disbursement-adjustment.types.ts +0 -32
  36. package/src/common/types/disbursement-approval-user.types.ts +0 -100
  37. package/src/common/types/disbursement-review.types.ts +0 -110
  38. package/src/common/types/disbursement-transaction.types.ts +0 -72
  39. package/src/common/types/disbursements.types.ts +0 -310
  40. package/src/common/types/domain-filter.types.ts +0 -55
  41. package/src/common/types/email-theme.types.ts +0 -442
  42. package/src/common/types/entity.types.ts +0 -15
  43. package/src/common/types/error-responses.types.ts +0 -135
  44. package/src/common/types/escrow-account.types.ts +0 -104
  45. package/src/common/types/exchange-api-key.types.ts +0 -121
  46. package/src/common/types/exchange-import.types.ts +0 -36
  47. package/src/common/types/exchange-provider.types.ts +0 -329
  48. package/src/common/types/file.types.ts +0 -461
  49. package/src/common/types/files.types.spec.ts +0 -154
  50. package/src/common/types/health.types.ts +0 -29
  51. package/src/common/types/index.ts +0 -48
  52. package/src/common/types/individuals.types.ts +0 -554
  53. package/src/common/types/investor-account.types.ts +0 -1239
  54. package/src/common/types/investorAccountIdSchema.type.ts +0 -0
  55. package/src/common/types/investors-offering.types.ts +0 -65
  56. package/src/common/types/invite.types.ts +0 -133
  57. package/src/common/types/issuer-bank-account.types.ts +0 -107
  58. package/src/common/types/issuer-offering.types.ts +0 -306
  59. package/src/common/types/issuer-payment-method.types.spec.ts +0 -612
  60. package/src/common/types/issuer-payment-method.types.ts +0 -341
  61. package/src/common/types/issuer.types.ts +0 -312
  62. package/src/common/types/job-item.types.ts +0 -119
  63. package/src/common/types/jobs.types.ts +0 -171
  64. package/src/common/types/kyb.types.ts +0 -53
  65. package/src/common/types/kyc.types.ts +0 -188
  66. package/src/common/types/legal-entity.types.ts +0 -185
  67. package/src/common/types/login-history.types.ts +0 -46
  68. package/src/common/types/mail-template.types.ts +0 -436
  69. package/src/common/types/north-cap-integration.types.ts +0 -190
  70. package/src/common/types/note.types.ts +0 -109
  71. package/src/common/types/notification.types.ts +0 -58
  72. package/src/common/types/notion-api.types.ts +0 -374
  73. package/src/common/types/notion-database.types.ts +0 -125
  74. package/src/common/types/notion-page.types.ts +0 -267
  75. package/src/common/types/offering-reports.types.ts +0 -153
  76. package/src/common/types/offering-submission.types.ts +0 -314
  77. package/src/common/types/offering.types.spec.ts +0 -91
  78. package/src/common/types/offering.types.ts +0 -590
  79. package/src/common/types/page-revision.types.ts +0 -86
  80. package/src/common/types/page.types.ts +0 -436
  81. package/src/common/types/password.type.ts +0 -15
  82. package/src/common/types/payment-methods.types.ts +0 -298
  83. package/src/common/types/phone.spec.ts +0 -76
  84. package/src/common/types/phone.type.ts +0 -27
  85. package/src/common/types/portfolio.types.ts +0 -50
  86. package/src/common/types/privacy-policy-and-tos.types.ts +0 -231
  87. package/src/common/types/queue.types.ts +0 -112
  88. package/src/common/types/registered-reps.types.ts +0 -25
  89. package/src/common/types/rejection-reasons.types.ts +0 -56
  90. package/src/common/types/reminder-config.types.ts +0 -40
  91. package/src/common/types/review.types.ts +0 -133
  92. package/src/common/types/role.types.ts +0 -26
  93. package/src/common/types/secondary-customer.types.ts +0 -66
  94. package/src/common/types/secondary-issuer.types.ts +0 -50
  95. package/src/common/types/secondary-order.types.ts +0 -58
  96. package/src/common/types/secondary-security.types.ts +0 -60
  97. package/src/common/types/secondary-trade.entity.ts +0 -16
  98. package/src/common/types/secondary-trade.types.ts +0 -95
  99. package/src/common/types/secure-request.types.ts +0 -68
  100. package/src/common/types/signer.types.ts +0 -651
  101. package/src/common/types/site-link.types.spec.ts +0 -134
  102. package/src/common/types/site-link.types.ts +0 -166
  103. package/src/common/types/site-settings.types.ts +0 -726
  104. package/src/common/types/site.types.ts +0 -270
  105. package/src/common/types/sms.types.ts +0 -30
  106. package/src/common/types/state-machine.types.ts +0 -177
  107. package/src/common/types/states.types.ts +0 -163
  108. package/src/common/types/subdoc-preview.types.ts +0 -35
  109. package/src/common/types/task.types.ts +0 -258
  110. package/src/common/types/trade-adjustment.type.ts +0 -33
  111. package/src/common/types/trade-line-item.type.ts +0 -132
  112. package/src/common/types/trade.types.ts +0 -929
  113. package/src/common/types/transaction.types.ts +0 -198
  114. package/src/common/types/trusted-contact.types.ts +0 -122
  115. package/src/common/types/typography.types.ts +0 -75
  116. package/src/common/types/user-manual.types.ts +0 -290
  117. package/src/common/types/user-setting.types.ts +0 -133
  118. package/src/common/types/user.types.ts +0 -320
  119. package/src/common/types/webhook.types.ts +0 -588
  120. package/src/common/types/zip.type.ts +0 -36
  121. package/src/contracts/clients/accounts/index.ts +0 -61
  122. package/src/contracts/clients/aic/index.ts +0 -59
  123. package/src/contracts/clients/api-key-logs/index.ts +0 -53
  124. package/src/contracts/clients/api-keys/index.ts +0 -73
  125. package/src/contracts/clients/assets/index.ts +0 -102
  126. package/src/contracts/clients/auth/index.ts +0 -50
  127. package/src/contracts/clients/files/index.ts +0 -166
  128. package/src/contracts/clients/files-public/index.ts +0 -166
  129. package/src/contracts/clients/index.ts +0 -44
  130. package/src/contracts/clients/individuals/index.ts +0 -93
  131. package/src/contracts/clients/investor-accounts/index.ts +0 -93
  132. package/src/contracts/clients/issuers/index.ts +0 -94
  133. package/src/contracts/clients/legal-entities/index.ts +0 -93
  134. package/src/contracts/clients/offerings/index.ts +0 -117
  135. package/src/contracts/clients/secure-requests/index.ts +0 -34
  136. package/src/contracts/clients/sites/index.ts +0 -56
  137. package/src/contracts/clients/trades/index.ts +0 -122
@@ -1,588 +0,0 @@
1
- import { z } from 'zod';
2
- import { PersonaStatus } from './common.types';
3
-
4
- export const WebhookReceived = z.object({
5
- received: z.boolean(),
6
- });
7
- export type WebhookReceived = z.infer<typeof WebhookReceived>;
8
-
9
- // https://docs.stripe.com/api/events/object
10
- export const StripeWebhookEvent = z.object({
11
- id: z.string().nullable().optional(),
12
- object: z.string().nullable().optional(),
13
- account: z.string().nullable().optional(),
14
- api_version: z.string().nullable().optional(),
15
- created: z.number().nullable().optional(),
16
- data: z
17
- .object({
18
- object: z
19
- .object({
20
- id: z.string().nullable().optional(),
21
- object: z.string().nullable().optional(),
22
- application: z.string().nullable().optional(),
23
- automatic_payment_methods: z
24
- .object({
25
- allow_redirects: z.string().nullable().optional(),
26
- enabled: z.boolean().nullable().optional(),
27
- })
28
- .nullable()
29
- .optional(),
30
- cancellation_reason: z.string().nullable().optional(),
31
- client_secret: z.string().nullable().optional(),
32
- created: z.number().nullable().optional(),
33
- customer: z.string().nullable().optional(),
34
- description: z.string().nullable().optional(),
35
- flow_directions: z.string().nullable().optional(),
36
- last_setup_error: z.object({}).nullable().optional(),
37
- latest_attempt: z.string().nullable().optional(),
38
- livemode: z.boolean().nullable().optional(),
39
- mandate: z.string().nullable().optional(),
40
- metadata: z.record(z.any()).nullable().optional(),
41
- next_action: z.string().nullable().optional(),
42
- on_behalf_of: z.string().nullable().optional(),
43
- payment_method: z.string().nullable().optional(),
44
- payment_method_options: z
45
- .object({
46
- acss_debit: z
47
- .object({
48
- currency: z.string().nullable().optional(),
49
- mandate_options: z
50
- .object({
51
- interval_description: z.string().nullable().optional(),
52
- payment_schedule: z.string().nullable().optional(),
53
- transaction_type: z.string().nullable().optional(),
54
- })
55
- .nullable()
56
- .optional(),
57
- verification_method: z.string().nullable().optional(),
58
- })
59
- .nullable()
60
- .optional(),
61
- card: z
62
- .object({
63
- installments: z.any().nullable().optional(),
64
- mandate_options: z.any().nullable().optional(),
65
- network: z.string().nullable().optional(),
66
- request_three_d_secure: z.string().nullable().optional(),
67
- })
68
- .nullable()
69
- .optional(),
70
- link: z
71
- .object({
72
- persistent_token: z.string().nullable().optional(),
73
- })
74
- .nullable()
75
- .optional(),
76
- us_bank_account: z
77
- .object({
78
- financial_connections: z
79
- .object({
80
- permissions: z.array(z.string()).nullable().optional(),
81
- prefetch: z.array(z.string()).nullable().optional(),
82
- })
83
- .nullable()
84
- .optional(),
85
- mandate_options: z.record(z.any()).nullable().optional(),
86
- verification_method: z.string().nullable().optional(),
87
- })
88
- .nullable()
89
- .optional(),
90
- })
91
- .nullable()
92
- .optional(),
93
- payment_method_types: z.array(z.string()).nullable().optional(),
94
- single_use_mandate: z.string().nullable().optional(),
95
- status: z.string().nullable().optional(),
96
- usage: z.string().nullable().optional(),
97
- amount: z.number().nullable().optional(),
98
- amount_capturable: z.number().nullable().optional(),
99
- amount_details: z.record(z.any()).nullable().optional(),
100
- amount_received: z.number().nullable().optional(),
101
- application_fee_amount: z.number().nullable().optional(),
102
- canceled_at: z.number().nullable().optional(),
103
- capture_method: z.string().nullable().optional(),
104
- confirmation_method: z.string().nullable().optional(),
105
- currency: z.string().nullable().optional(),
106
- invoice: z.string().nullable().optional(),
107
- last_payment_error: z.record(z.any()).nullable().optional(),
108
- latest_charge: z.string().nullable().optional(),
109
- payment_method_configuration_details: z
110
- .object({
111
- id: z.string().nullable().optional(),
112
- parent: z.string().nullable().optional(),
113
- })
114
- .nullable()
115
- .optional(),
116
- processing: z.record(z.any()).nullable().optional(),
117
- receipt_email: z.string().nullable().optional(),
118
- review: z.string().nullable().optional(),
119
- setup_future_usage: z.string().nullable().optional(),
120
- shipping: z.record(z.any()).nullable().optional(),
121
- source: z.string().nullable().optional(),
122
- statement_descriptor: z.string().nullable().optional(),
123
- statement_descriptor_suffix: z.string().nullable().optional(),
124
- transfer_data: z.record(z.any()).nullable().optional(),
125
- transfer_group: z.string().nullable().optional(),
126
- })
127
- .nullable()
128
- .optional(),
129
- })
130
- .nullable()
131
- .optional(),
132
- livemode: z.boolean().nullable().optional(),
133
- pending_webhooks: z.number().nullable().optional(),
134
- request: z
135
- .object({
136
- id: z.string().nullable().optional(),
137
- idempotency_key: z.string().nullable().optional(),
138
- })
139
- .nullable()
140
- .optional(),
141
- type: z.string().nullable().optional(),
142
- context: z.string().nullable().optional(),
143
- });
144
- export type StripeWebhookEvent = z.infer<typeof StripeWebhookEvent>;
145
-
146
- /**
147
- * BoldSign webhook event structure
148
- * @see https://developers.boldsign.com/webhooks/sample-event-data/?region=us
149
- *
150
- * Event types include:
151
- * - Signed: When a signer completes signing
152
- * - Declined: When a signer declines to sign
153
- * - SenderIdentityVerified: When a sender identity is verified
154
- * - SenderIdentityDenied: When a sender identity is denied
155
- * - SenderIdentityRevoked: When a sender identity is revoked
156
- * - SenderIdentityDeleted: When a sender identity is deleted
157
- */
158
- export const BoldsignWebhookEvent = z.object({
159
- event: z.object({
160
- id: z.string().optional(),
161
- eventType: z.string(),
162
- created: z.number().optional(),
163
- clientId: z.string().optional(),
164
- environment: z.string().optional(),
165
- }),
166
- data: z.object({
167
- object: z.string().optional(),
168
- documentId: z.string().optional(),
169
- messageTitle: z.string().optional(),
170
- documentDescription: z.string().optional(),
171
- status: z.string().optional(),
172
- email: z.string().optional(), // For SenderIdentity events
173
- senderDetail: z
174
- .object({
175
- name: z.string().optional(),
176
- emailAddress: z.string().optional(),
177
- })
178
- .optional(),
179
- signerDetails: z
180
- .array(
181
- z.object({
182
- signerName: z.string().optional(),
183
- signerRole: z.string().optional(),
184
- signerEmail: z.string().optional(),
185
- status: z.string().optional(),
186
- signerOrder: z.number().optional(),
187
- formFields: z
188
- .array(
189
- z.object({
190
- id: z.string().optional(),
191
- name: z.string().optional(),
192
- fieldType: z.string().optional(),
193
- value: z.any().optional(),
194
- isRequired: z.boolean().optional(),
195
- }),
196
- )
197
- .optional(),
198
- }),
199
- )
200
- .optional(),
201
- metaData: z.record(z.string(), z.any()).optional(),
202
- }),
203
- });
204
- export type BoldsignWebhookEvent = z.infer<typeof BoldsignWebhookEvent>;
205
-
206
- /**
207
- * Sample event data:
208
- * https://docs.withpersona.com/docs/webhooks
209
- * We are only interested in the inquiry and inquiry session events
210
- * because we subscribe only to inquiry events
211
- * https://docs.withpersona.com/docs/events
212
- */
213
- const fieldValueSchema = z.object({
214
- type: z.string(),
215
- value: z.any().optional(),
216
- });
217
-
218
- const behaviorsSchema = z.object({
219
- 'autofill-cancels': z.number().nullable().optional(),
220
- 'autofill-starts': z.number().nullable().optional(),
221
- 'completion-time': z.number().nullable().optional(),
222
- 'devtools-open': z.boolean().nullable().optional(),
223
- 'distraction-events': z.number().nullable().optional(),
224
- 'hesitation-baseline': z.number().nullable().optional(),
225
- 'hesitation-count': z.number().nullable().optional(),
226
- 'hesitation-percentage': z.number().nullable().optional(),
227
- 'hesitation-time': z.number().nullable().optional(),
228
- 'request-spoof-attempts': z.number().nullable().optional(),
229
- 'shortcut-copies': z.number().nullable().optional(),
230
- 'shortcut-pastes': z.number().nullable().optional(),
231
- 'user-agent-spoof-attempts': z.number().nullable().optional(),
232
- 'behavior-threat-level': z.string().nullable().optional(),
233
- });
234
-
235
- const relationshipDataSchema = z.object({
236
- type: z.string(),
237
- id: z.string(),
238
- });
239
-
240
- const relationshipSchema = z.object({
241
- data: z.union([relationshipDataSchema, z.null()]),
242
- });
243
-
244
- const inquiryAttributesSchema = z
245
- .object({
246
- behaviors: behaviorsSchema.optional(),
247
- fields: z.record(fieldValueSchema).optional(),
248
- status: z.nativeEnum(PersonaStatus),
249
- 'reference-id': z.string().nullable().optional(),
250
- note: z.string().nullable().optional(),
251
- creator: z.string().nullable().optional(),
252
- 'reviewer-comment': z.string().nullable().optional(),
253
- 'created-at': z.string().datetime().nullable().optional(),
254
- 'started-at': z.string().datetime().nullable().optional(),
255
- 'expires-at': z.string().datetime().nullable().optional(),
256
- 'completed-at': z.string().datetime().nullable().optional(),
257
- 'failed-at': z.string().datetime().nullable().optional(),
258
- 'marked-for-review-at': z.string().datetime().nullable().optional(),
259
- 'decisioned-at': z.string().datetime().nullable().optional(),
260
- 'expired-at': z.string().datetime().nullable().optional(),
261
- 'redacted-at': z.string().datetime().nullable().optional(),
262
- 'updated-at': z.string().datetime().nullable().optional(),
263
- 'previous-step-name': z.string().nullable().optional(),
264
- 'next-step-name': z.string().nullable().optional(),
265
- 'name-first': z.string().nullable().optional(),
266
- 'name-middle': z.string().nullable().optional(),
267
- 'name-last': z.string().nullable().optional(),
268
- birthdate: z.string().nullable().optional(),
269
- 'address-street-1': z.string().nullable().optional(),
270
- 'address-street-2': z.string().nullable().optional(),
271
- 'address-city': z.string().nullable().optional(),
272
- 'address-subdivision': z.string().nullable().optional(),
273
- 'address-subdivision-abbr': z.string().nullable().optional(),
274
- 'address-postal-code': z.string().nullable().optional(),
275
- 'address-postal-code-abbr': z.string().nullable().optional(),
276
- 'social-security-number': z.string().nullable().optional(),
277
- 'identification-number': z.string().nullable().optional(),
278
- 'email-address': z.string().nullable().optional(),
279
- 'phone-number': z.string().nullable().optional(),
280
- tags: z.array(z.string()).nullable().optional(),
281
- })
282
- .passthrough();
283
-
284
- const accountFieldsSchema = z.object({
285
- name: z.object({
286
- type: z.string(),
287
- value: z.object({
288
- first: fieldValueSchema,
289
- middle: fieldValueSchema,
290
- last: fieldValueSchema,
291
- }),
292
- }),
293
- address: z.object({
294
- type: z.string(),
295
- value: z.object({
296
- street_1: fieldValueSchema,
297
- street_2: fieldValueSchema,
298
- city: fieldValueSchema,
299
- subdivision: fieldValueSchema,
300
- postal_code: fieldValueSchema,
301
- country_code: fieldValueSchema,
302
- }),
303
- }),
304
- identification_numbers: z.object({
305
- type: z.string(),
306
- value: z.array(z.any()),
307
- }),
308
- birthdate: fieldValueSchema,
309
- phone_number: fieldValueSchema,
310
- email_address: fieldValueSchema,
311
- selfie_photo: fieldValueSchema,
312
- });
313
-
314
- const accountSchema = z.object({
315
- type: z.string(),
316
- id: z.string(),
317
- attributes: z.object({
318
- 'reference-id': z.string().optional(),
319
- 'created-at': z.string().datetime().optional(),
320
- 'updated-at': z.string().datetime().optional(),
321
- 'redacted-at': z.string().datetime().optional(),
322
- 'account-type-name': z.string().optional(),
323
- fields: accountFieldsSchema,
324
- 'name-first': z.string().optional(),
325
- 'name-middle': z.string().optional(),
326
- 'name-last': z.string().optional(),
327
- 'social-security-number': z.string().optional(),
328
- 'address-street-1': z.string().optional(),
329
- 'address-street-2': z.string().optional(),
330
- 'address-city': z.string().optional(),
331
- 'address-subdivision': z.string().optional(),
332
- 'address-postal-code': z.string().optional(),
333
- 'country-code': z.string().optional(),
334
- birthdate: z.string().optional(),
335
- 'phone-number': z.string().optional(),
336
- 'email-address': z.string().optional(),
337
- tags: z.array(z.string()).optional(),
338
- 'identification-numbers': z.record(z.any()).optional(),
339
- }),
340
- relationships: z.object({
341
- 'account-type': relationshipSchema.optional(),
342
- }),
343
- });
344
-
345
- const inquiryRelationshipsSchema = z.object({
346
- account: relationshipSchema.optional(),
347
- template: relationshipSchema.optional(),
348
- 'inquiry-template': relationshipSchema.optional(),
349
- 'inquiry-template-version': relationshipSchema.optional(),
350
- transaction: relationshipSchema.optional(),
351
- reviewer: relationshipSchema.optional(),
352
- reports: z.object({ data: z.array(z.any()) }).optional(),
353
- verifications: z.object({ data: z.array(z.any()) }).optional(),
354
- sessions: z.object({ data: z.array(z.any()) }).optional(),
355
- documents: z.object({ data: z.array(z.any()) }).optional(),
356
- selfies: z.object({ data: z.array(z.any()) }).optional(),
357
- });
358
-
359
- const inquirySchema = z.object({
360
- type: z.string(),
361
- id: z.string(),
362
- attributes: inquiryAttributesSchema.optional(),
363
- relationships: inquiryRelationshipsSchema.partial().optional(),
364
- });
365
-
366
- const inquiryTemplateSchema = z.object({
367
- type: z.literal('inquiry-template'),
368
- id: z.string(),
369
- attributes: z.object({
370
- status: z.string(),
371
- name: z.string(),
372
- }),
373
- relationships: z.object({
374
- 'latest-published-version': relationshipSchema.optional(),
375
- }),
376
- });
377
-
378
- const genericIncludedItemSchema = z.object({
379
- type: z.string(),
380
- id: z.string(),
381
- attributes: z.record(z.any()).optional(),
382
- relationships: z.record(z.any()).optional(),
383
- });
384
-
385
- const userSchema = z.object({
386
- type: z.string(),
387
- id: z.string(),
388
- attributes: z.record(z.any()).optional(),
389
- relationships: z.record(z.any()).optional(),
390
- });
391
-
392
- const inquiryTemplateVersionSchema = z.object({
393
- type: z.literal('inquiry-template-version'),
394
- id: z.string(),
395
- attributes: z.object({
396
- 'name-display': z.string().optional(),
397
- status: z.string().optional(),
398
- 'enabled-locales': z.array(z.string()).optional(),
399
- 'created-at': z.string().datetime().optional(),
400
- 'updated-at': z.string().datetime().optional(),
401
- 'published-at': z.string().datetime().optional(),
402
- theme: z.record(z.any()).optional(),
403
- }),
404
- relationships: z.object({
405
- 'inquiry-template': relationshipSchema,
406
- }),
407
- });
408
-
409
- // Schemas for Government ID Verification for Persona
410
- //https://docs.withpersona.com/reference/retrieve-a-government-id-verification
411
- const photoUrlSchema = z
412
- .object({
413
- page: z.string().optional(),
414
- url: z.string().url().optional(),
415
- 'normalized-url': z.string().url().optional(),
416
- 'original-urls': z.array(z.string().url()).optional(),
417
- 'byte-size': z.number().optional(),
418
- })
419
- .optional();
420
- export type PhotoUrlSchema = z.infer<typeof photoUrlSchema>;
421
-
422
- const NormalizedPhotoUrlSchema = z
423
- .object({
424
- page: z.string().optional(),
425
- url: z.string().url().optional(),
426
- normalizedUrl: z.string().url().optional(),
427
- originalUrls: z.array(z.string().url()).optional(),
428
- byteSize: z.number().optional(),
429
- })
430
- .optional();
431
- export type NormalizedPhotoUrlSchema = z.infer<typeof NormalizedPhotoUrlSchema>;
432
-
433
- // Selfie photo schema
434
- const selfiePhotoSchema = z
435
- .object({
436
- url: z.string().url().optional(),
437
- 'byte-size': z.number().optional(),
438
- })
439
- .optional();
440
-
441
- // Attributes schema
442
- export const attributesSchema = z
443
- .object({
444
- status: z.string().optional(),
445
- 'created-at': z.string().datetime().optional(),
446
- 'created-at-ts': z.number().int().optional(),
447
- 'submitted-at': z.string().datetime().optional(),
448
- 'submitted-at-ts': z.number().int().optional(),
449
- 'completed-at': z.string().datetime().optional(),
450
- 'completed-at-ts': z.number().int().optional(),
451
- 'country-code': z.string().optional(),
452
- checks: z.array(z.unknown()).optional(),
453
- 'entity-confidence-score': z.number().optional(),
454
- 'entity-confidence-reasons': z.array(z.string()).optional(),
455
- 'front-photo-url': z.string().url().optional(),
456
- 'back-photo-url': z.null().optional(),
457
- 'photo-urls': z.array(photoUrlSchema).optional(),
458
- 'selfie-photo': selfiePhotoSchema.optional(),
459
- 'selfie-photo-url': z.string().url().optional(),
460
- 'video-url': z.null().optional(),
461
- 'id-class': z.string().optional(),
462
- 'capture-method': z.string().optional(),
463
- 'name-first': z.string().optional(),
464
- 'name-middle': z.string().optional(),
465
- 'name-last': z.string().optional(),
466
- 'name-suffix': z.null().optional(),
467
- birthdate: z.string().optional(),
468
- 'address-street-1': z.string().optional(),
469
- 'address-street-2': z.null().optional(),
470
- 'address-city': z.string().optional(),
471
- 'address-subdivision': z.string().optional(),
472
- 'address-postal-code': z.string().optional(),
473
- 'issuing-authority': z.null().optional(),
474
- 'issuing-subdivision': z.string().optional(),
475
- nationality: z.null().optional(),
476
- 'document-number': z.null().optional(),
477
- 'visa-status': z.null().optional(),
478
- 'issue-date': z.string().optional(),
479
- 'expiration-date': z.string().optional(),
480
- designations: z.array(z.unknown()).optional(),
481
- birthplace: z.null().optional(),
482
- endorsements: z.null().optional(),
483
- height: z.null().optional(),
484
- sex: z.null().optional(),
485
- restrictions: z.null().optional(),
486
- 'vehicle-class': z.null().optional(),
487
- 'identification-number': z.string().optional(),
488
- 'from-reusable-persona': z.boolean().optional(),
489
- })
490
- .optional();
491
-
492
- export type AttributesSchema = z.infer<typeof attributesSchema>;
493
-
494
- // Relationship with data schema
495
- const relationshipWithDataSchema = z
496
- .object({
497
- data: relationshipDataSchema.optional(),
498
- })
499
- .optional();
500
-
501
- // Relationship with null data schema
502
- const relationshipWithNullDataSchema = z
503
- .object({
504
- data: z.null().optional(),
505
- })
506
- .optional();
507
-
508
- // Relationships schema
509
- const relationshipsSchema = z
510
- .object({
511
- inquiry: relationshipWithDataSchema.optional(),
512
- template: relationshipWithNullDataSchema.optional(),
513
- 'inquiry-template-version': relationshipWithDataSchema.optional(),
514
- 'inquiry-template': relationshipWithDataSchema.optional(),
515
- transaction: relationshipWithNullDataSchema.optional(),
516
- 'verification-template': relationshipWithDataSchema.optional(),
517
- 'verification-template-version': relationshipWithDataSchema.optional(),
518
- document: relationshipWithDataSchema.optional(),
519
- })
520
- .optional();
521
-
522
- // Verification Data schema
523
- const verificationDataSchema = z
524
- .object({
525
- type: z.string().optional(),
526
- id: z.string().optional(),
527
- attributes: attributesSchema.optional(),
528
- relationships: relationshipsSchema.optional(),
529
- })
530
- .optional();
531
- export type VerificationDataSchema = z.infer<typeof verificationDataSchema>;
532
-
533
- export const PersonaWebhookEvent = z.object({
534
- data: z.object({
535
- type: z.string(),
536
- id: z.string(),
537
- attributes: z.object({
538
- name: z.enum([
539
- 'inquiry.created',
540
- 'inquiry.started',
541
- 'inquiry.expired',
542
- 'inquiry.completed',
543
- 'inquiry.failed',
544
- 'inquiry.marked-for-review',
545
- 'inquiry.approved',
546
- 'inquiry.declined',
547
- 'inquiry.redacted',
548
- 'inquiry.transitioned',
549
- 'inquiry-session.started',
550
- 'inquiry-session.expired',
551
- 'inquiry-session.canceled',
552
- 'inquiry.reusable-persona-created',
553
- 'inquiry.reusable-persona-updated',
554
- 'inquiry.reusable-persona-deleted',
555
- 'inquiry-template-version.created',
556
- 'inquiry-template-version.updated',
557
- 'inquiry-template-version.deleted',
558
- 'inquiry-template-version.published',
559
- ]),
560
- payload: z.object({
561
- data: inquirySchema,
562
- included: z.array(
563
- z.union([
564
- inquirySchema,
565
- accountSchema,
566
- inquiryTemplateSchema,
567
- inquiryTemplateVersionSchema,
568
- verificationDataSchema,
569
- genericIncludedItemSchema,
570
- userSchema,
571
- ]),
572
- ),
573
- }),
574
- 'created-at': z.string().datetime(),
575
- }),
576
- }),
577
- });
578
-
579
- export type PersonaWebhookEvent = z.infer<typeof PersonaWebhookEvent>;
580
-
581
- // Root schema
582
- const PersonsGovernmentIdVerification = z.object({
583
- data: verificationDataSchema.optional(),
584
- });
585
-
586
- export type PersonsGovernmentIdVerification = z.infer<
587
- typeof PersonsGovernmentIdVerification
588
- >;
@@ -1,36 +0,0 @@
1
- import { z } from 'zod';
2
- import { validateCanadaZipCode, validateUSZipCode } from './contract-helpers';
3
- import { CountryCode, CountryEnumSchema } from './countries.types';
4
-
5
- export function refineAddressZip(
6
- country: string | undefined | null,
7
- zip: string | undefined | null,
8
- ) {
9
- return country === CountryCode['US']
10
- ? !zip || validateUSZipCode(zip)
11
- : country === CountryCode['CA']
12
- ? !zip || validateCanadaZipCode(zip) // it's optional, so if nullish, it's valid
13
- : z.string().min(2).max(10).nullable().optional().safeParse(zip).success;
14
- }
15
-
16
- export const ZipSchema = z.string();
17
-
18
- export const CountryZipSchema = z
19
- .object({
20
- country: CountryEnumSchema.nullable().optional(),
21
- zip: ZipSchema.nullable().optional(),
22
- })
23
- .refine(({ zip, country }) => refineAddressZip(country, zip), {
24
- message:
25
- 'zip value is not valid, it shall follow the US(12345 or 12345-6789), CANADA(A1A 1A1) format! it shall be a string for other states',
26
- });
27
-
28
- export const RequiredCountryZipSchema = z
29
- .object({
30
- country: CountryEnumSchema,
31
- zip: ZipSchema,
32
- })
33
- .refine(({ zip, country }) => refineAddressZip(country, zip), {
34
- message:
35
- 'zip value is not valid, it shall follow the US(12345 or 12345-6789), CANADA(A1A 1A1) format! it shall be a string for other states',
36
- });
@@ -1,61 +0,0 @@
1
- import { initContract } from '@ts-rest/core';
2
- import {
3
- ForbiddenError,
4
- IPaginatedAccount,
5
- NotFoundError,
6
- PaginationOptionsZod,
7
- UnauthorizedError,
8
- AccountFiltersZod,
9
- AccountsIncludeQuery,
10
- AccountZod,
11
- accountIdSchema,
12
- InternalError,
13
- } from '../../../common/types';
14
- import { z } from 'zod';
15
-
16
- const c = initContract();
17
-
18
- export const accountsContract = c.router(
19
- {
20
- getAccount: {
21
- summary: 'Get account by id',
22
- method: 'GET',
23
- path: '/:id',
24
- metadata: {
25
- auth: true,
26
- },
27
- query: z.object({}).merge(AccountsIncludeQuery),
28
- pathParams: z.object({
29
- id: accountIdSchema,
30
- }),
31
- responses: {
32
- 200: AccountZod,
33
- 401: UnauthorizedError,
34
- 403: ForbiddenError,
35
- 404: NotFoundError,
36
- 500: InternalError,
37
- },
38
- },
39
- getAccounts: {
40
- summary: 'Get accounts',
41
- method: 'GET',
42
- path: '',
43
- metadata: {
44
- auth: true,
45
- },
46
- query:
47
- PaginationOptionsZod.merge(AccountFiltersZod).merge(
48
- AccountsIncludeQuery,
49
- ),
50
- responses: {
51
- 200: IPaginatedAccount,
52
- 401: UnauthorizedError,
53
- 403: ForbiddenError,
54
- 500: InternalError,
55
- },
56
- },
57
- },
58
- {
59
- pathPrefix: 'accounts',
60
- },
61
- );