@timbro/invoices 0.9.0-next.1 → 0.9.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.
Files changed (37) hide show
  1. package/README.md +19 -0
  2. package/dist/admin.d.ts +2 -2
  3. package/dist/admin.d.ts.map +1 -1
  4. package/dist/admin.js +1 -1
  5. package/dist/generated/hosted/sdk.gen.js +1 -1
  6. package/dist/generated/hosted/types.gen.d.ts +2 -2
  7. package/dist/generated/hosted/types.gen.d.ts.map +1 -1
  8. package/dist/generated/hosted/zod-response.gen.d.ts +4007 -0
  9. package/dist/generated/hosted/zod-response.gen.d.ts.map +1 -0
  10. package/dist/generated/hosted/zod-response.gen.js +1967 -0
  11. package/dist/generated/hosted/zod.gen.d.ts +3 -0
  12. package/dist/generated/hosted/zod.gen.d.ts.map +1 -1
  13. package/dist/generated/hosted/zod.gen.js +3 -0
  14. package/dist/generated/sdk.gen.js +1 -1
  15. package/dist/generated/zod-response.gen.d.ts +87940 -0
  16. package/dist/generated/zod-response.gen.d.ts.map +1 -0
  17. package/dist/generated/zod-response.gen.js +4946 -0
  18. package/dist/generated-problem.js +1 -1
  19. package/dist/index.d.ts +2 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -0
  22. package/dist/invoice-receipt.d.ts.map +1 -1
  23. package/dist/invoice-receipt.js +2 -1
  24. package/dist/invoice.d.ts +2 -2
  25. package/dist/invoice.d.ts.map +1 -1
  26. package/dist/invoice.js +1 -1
  27. package/dist/source-connection-activation.d.ts.map +1 -1
  28. package/dist/source-connection-activation.js +2 -1
  29. package/dist/timbro-client.d.ts +2 -2
  30. package/dist/timbro-client.d.ts.map +1 -1
  31. package/dist/webhook-event.d.ts +4680 -1983
  32. package/dist/webhook-event.d.ts.map +1 -1
  33. package/dist/webhook-event.js +27 -1
  34. package/dist/webhook-verification.d.ts +4 -2
  35. package/dist/webhook-verification.d.ts.map +1 -1
  36. package/dist/webhook-verification.js +4 -2
  37. package/package.json +6 -2
@@ -0,0 +1,1967 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ // Response validators derived from zod.gen.ts by scripts/response-validators.mjs.
3
+ import * as z from "zod";
4
+ function propertyCount(value) {
5
+ return typeof value === "object" && value !== null ? Object.keys(value).length : 0;
6
+ }
7
+ function lenientUnion(options) {
8
+ return z.any().transform((value, context) => {
9
+ const matches = [];
10
+ const failures = [];
11
+ for (const option of options) {
12
+ const result = option.safeParse(value);
13
+ if (result.success) {
14
+ matches.push(result.data);
15
+ }
16
+ else {
17
+ failures.push(result.error.issues);
18
+ }
19
+ }
20
+ const [first, ...rest] = matches;
21
+ if (matches.length === 0) {
22
+ context.issues.push({ code: "invalid_union", errors: failures, input: value });
23
+ return z.NEVER;
24
+ }
25
+ return rest.reduce((best, match) => (propertyCount(match) > propertyCount(best) ? match : best), first);
26
+ });
27
+ }
28
+ /**
29
+ * MerchantBusinessFiscalSetupUnavailable
30
+ */
31
+ export const zMerchantBusinessFiscalSetupUnavailable = z.object({
32
+ status: z.literal("unavailable"),
33
+ cause: z.literal("timbro_unreachable"),
34
+ });
35
+ /**
36
+ * MerchantBusinessFiscalBinding
37
+ *
38
+ * The Timbro Organization, Legal issuer, Source connection, and webhook.
39
+ */
40
+ export const zMerchantBusinessFiscalBinding = lenientUnion([
41
+ z.object({
42
+ status: z.literal("unbound"),
43
+ }),
44
+ z.object({
45
+ status: z.literal("provisioning"),
46
+ }),
47
+ z.object({
48
+ status: z.literal("bound"),
49
+ webhookSecret: lenientUnion([z.literal("sealed"), z.literal("pending")]),
50
+ }),
51
+ z.object({
52
+ status: z.literal("failed"),
53
+ }),
54
+ z.object({
55
+ status: z.literal("conflict"),
56
+ }),
57
+ ]);
58
+ /**
59
+ * MerchantBusinessLegalIssuer
60
+ *
61
+ * Whether Timbro holds every profile field the hosted Legal issuer requires.
62
+ */
63
+ export const zMerchantBusinessLegalIssuer = lenientUnion([
64
+ z.object({
65
+ status: z.literal("missing"),
66
+ }),
67
+ z.object({
68
+ status: z.literal("incomplete"),
69
+ }),
70
+ z.object({
71
+ status: z.literal("complete"),
72
+ }),
73
+ ]);
74
+ /**
75
+ * MerchantBusinessSigningCertificate
76
+ *
77
+ * The certificate Timbro's custody holds for the Legal issuer.
78
+ */
79
+ export const zMerchantBusinessSigningCertificate = lenientUnion([
80
+ z.object({
81
+ status: z.literal("missing"),
82
+ }),
83
+ z.object({
84
+ status: z.literal("active"),
85
+ sha256: z.string().regex(/^[0-9a-f]{64}$/),
86
+ signerSerialNumber: z.string().refine((text) => Array.from(text).length >= 1),
87
+ notBefore: z.iso.datetime(),
88
+ notAfter: z.iso.datetime(),
89
+ }),
90
+ ]);
91
+ /**
92
+ * MerchantBusinessFiscalSetupAvailable
93
+ */
94
+ export const zMerchantBusinessFiscalSetupAvailable = z.object({
95
+ status: z.literal("available"),
96
+ binding: zMerchantBusinessFiscalBinding,
97
+ legalIssuer: zMerchantBusinessLegalIssuer,
98
+ signingCertificate: zMerchantBusinessSigningCertificate,
99
+ testFiscalDocument: lenientUnion([
100
+ z.object({
101
+ status: z.literal("not_sent"),
102
+ }),
103
+ z.object({
104
+ status: z.literal("processing"),
105
+ id: z.string().refine((text) => Array.from(text).length >= 1),
106
+ documentType: lenientUnion([
107
+ z.literal("31"),
108
+ z.literal("32"),
109
+ z.literal("33"),
110
+ z.literal("34"),
111
+ z.literal("41"),
112
+ z.literal("43"),
113
+ z.literal("44"),
114
+ z.literal("45"),
115
+ z.literal("46"),
116
+ z.literal("47"),
117
+ ]),
118
+ }),
119
+ z.object({
120
+ status: z.literal("accepted"),
121
+ id: z.string().refine((text) => Array.from(text).length >= 1),
122
+ documentType: lenientUnion([
123
+ z.literal("31"),
124
+ z.literal("32"),
125
+ z.literal("33"),
126
+ z.literal("34"),
127
+ z.literal("41"),
128
+ z.literal("43"),
129
+ z.literal("44"),
130
+ z.literal("45"),
131
+ z.literal("46"),
132
+ z.literal("47"),
133
+ ]),
134
+ }),
135
+ z.object({
136
+ status: z.literal("rejected"),
137
+ id: z.string().refine((text) => Array.from(text).length >= 1),
138
+ documentType: lenientUnion([
139
+ z.literal("31"),
140
+ z.literal("32"),
141
+ z.literal("33"),
142
+ z.literal("34"),
143
+ z.literal("41"),
144
+ z.literal("43"),
145
+ z.literal("44"),
146
+ z.literal("45"),
147
+ z.literal("46"),
148
+ z.literal("47"),
149
+ ]),
150
+ reason: lenientUnion([z.literal("timbro_rejected"), z.literal("authority_rejected")]),
151
+ messages: z.array(z.string()),
152
+ }),
153
+ z.object({
154
+ status: z.literal("operator_required"),
155
+ id: z.string().refine((text) => Array.from(text).length >= 1),
156
+ documentType: lenientUnion([
157
+ z.literal("31"),
158
+ z.literal("32"),
159
+ z.literal("33"),
160
+ z.literal("34"),
161
+ z.literal("41"),
162
+ z.literal("43"),
163
+ z.literal("44"),
164
+ z.literal("45"),
165
+ z.literal("46"),
166
+ z.literal("47"),
167
+ ]),
168
+ }),
169
+ ]),
170
+ });
171
+ /**
172
+ * MerchantBusinessFiscalSetup
173
+ *
174
+ * Timbro's view of electronic invoicing provisioning, or why it cannot be read.
175
+ */
176
+ export const zMerchantBusinessFiscalSetup = lenientUnion([
177
+ zMerchantBusinessFiscalSetupUnavailable,
178
+ zMerchantBusinessFiscalSetupAvailable,
179
+ ]);
180
+ /**
181
+ * MerchantBusinessLiveFiscalSetupAvailable
182
+ */
183
+ export const zMerchantBusinessLiveFiscalSetupAvailable = z.object({
184
+ status: z.literal("available"),
185
+ binding: zMerchantBusinessFiscalBinding,
186
+ legalIssuer: zMerchantBusinessLegalIssuer,
187
+ signingCertificate: zMerchantBusinessSigningCertificate,
188
+ });
189
+ /**
190
+ * MerchantBusinessLiveFiscalSetup
191
+ *
192
+ * Production binding and custody facts. These do not establish DGII production qualification.
193
+ */
194
+ export const zMerchantBusinessLiveFiscalSetup = lenientUnion([
195
+ zMerchantBusinessFiscalSetupUnavailable,
196
+ zMerchantBusinessLiveFiscalSetupAvailable,
197
+ ]);
198
+ /**
199
+ * Problem
200
+ *
201
+ * RFC 9457 problem details. Every failure of this API is one of these, and each operation narrows `code` to the subset it can emit.
202
+ */
203
+ export const zProblem = z.object({
204
+ code: z.enum([
205
+ "merchant_authentication_unavailable",
206
+ "platform_test_profile_unavailable",
207
+ "merchant_fiscal_binding_unavailable",
208
+ "merchant_fiscal_setup_unavailable",
209
+ "merchant_contact_email_confirmation_required",
210
+ "merchant_service_scope_required",
211
+ "merchant_business_address_required",
212
+ "merchant_business_contact_required",
213
+ "merchant_business_location_official_codes_required",
214
+ "merchant_business_details_invalid",
215
+ "merchant_current_payment_methods_required",
216
+ "merchant_current_sales_channels_required",
217
+ "merchant_existing_card_service_not_applicable",
218
+ "merchant_existing_card_service_other_provider_name_invalid",
219
+ "merchant_existing_card_service_other_provider_name_not_allowed",
220
+ "merchant_existing_card_service_other_provider_name_required",
221
+ "merchant_existing_card_service_providers_exclusive_choice",
222
+ "merchant_existing_card_service_providers_required",
223
+ "merchant_existing_card_service_required",
224
+ "merchant_location_catalog_changed",
225
+ "merchant_location_catalog_unavailable",
226
+ "merchant_location_selection_invalid",
227
+ "merchant_payment_methods_not_applicable",
228
+ "merchant_sales_channels_exclusive_choice",
229
+ "merchant_sales_channels_not_applicable",
230
+ "merchant_business_type_not_applicable",
231
+ "merchant_charge_timing_not_applicable",
232
+ "merchant_charge_timing_required",
233
+ "merchant_payment_methods_exclusive_choice",
234
+ "merchant_session_missing",
235
+ "merchant_guest_notice_acceptance_required",
236
+ "merchant_workspace_organization_required",
237
+ "merchant_onboarding_revision_conflict",
238
+ "merchant_checkout_policy_revision_conflict",
239
+ "merchant_business_already_claimed",
240
+ "merchant_business_attachment_conflict",
241
+ "merchant_business_identity_required",
242
+ "merchant_business_not_member",
243
+ "merchant_business_revision_conflict",
244
+ "merchant_business_capabilities_required",
245
+ "merchant_fiscal_setup_incomplete",
246
+ "merchant_payment_setup_assessment_incomplete",
247
+ "merchant_certificate_conflict",
248
+ "merchant_test_fiscal_document_blocked",
249
+ "merchant_dgii_assistance_not_applicable",
250
+ "merchant_dgii_assistance_notes_invalid",
251
+ "parameter_missing",
252
+ "parameter_invalid",
253
+ "provider_not_available",
254
+ "currency_not_supported",
255
+ "amount_below_minimum",
256
+ "amount_above_maximum",
257
+ "checkout_reference_invalid",
258
+ "checkout_reference_expired",
259
+ "fiscal_buyer_tax_id_invalid",
260
+ "fiscal_lines_required",
261
+ "payment_split_invalid",
262
+ "submission_token_invalid",
263
+ "submission_token_expired",
264
+ "request_body_malformed",
265
+ "collection_cursor_invalid",
266
+ "webhook_replay_scope_invalid",
267
+ "api_key_missing",
268
+ "api_key_invalid",
269
+ "checkout_token_invalid",
270
+ "checkout_token_expired",
271
+ "payer_session_missing",
272
+ "operation_not_permitted",
273
+ "invoice_delivery_not_permitted",
274
+ "journey_scope_mismatch",
275
+ "journey_report_timeout",
276
+ "merchant_fiscal_binding_conflict",
277
+ "live_mode_not_enabled",
278
+ "origin_not_allowed",
279
+ "payer_step_up_required",
280
+ "certificate_handoff_person_mismatch",
281
+ "route_not_found",
282
+ "api_key_not_found",
283
+ "payment_not_found",
284
+ "payment_reference_conflict",
285
+ "refund_reference_conflict",
286
+ "payment_reference_invalid",
287
+ "refund_reference_invalid",
288
+ "payment_tax_required",
289
+ "payment_tax_invalid",
290
+ "payment_items_invalid",
291
+ "payment_totals_mismatch",
292
+ "payment_invoice_item_fields_required",
293
+ "payments_contract_migration_required",
294
+ "merchant_payments_api_paused",
295
+ "refund_not_found",
296
+ "refund_invoice_not_ready",
297
+ "refund_invoice_not_accepted",
298
+ "refund_invoice_mismatch",
299
+ "refund_invoice_conflict",
300
+ "payment_part_not_found",
301
+ "payment_split_not_found",
302
+ "fiscal_document_not_found",
303
+ "merchant_account_not_found",
304
+ "merchant_account_card_capability_not_found",
305
+ "merchant_business_not_found",
306
+ "agent_client_not_found",
307
+ "connected_agent_not_found",
308
+ "certificate_handoff_not_found",
309
+ "webhook_endpoint_not_found",
310
+ "webhook_event_not_found",
311
+ "three_ds_not_found",
312
+ "payer_not_found",
313
+ "saved_card_not_found",
314
+ "payer_credential_not_found",
315
+ "payer_purchase_not_found",
316
+ "payer_fiscal_profile_not_found",
317
+ "idempotency_key_reused",
318
+ "idempotency_request_in_progress",
319
+ "idempotency_key_expired",
320
+ "api_key_retired",
321
+ "payment_method_already_in_progress",
322
+ "payment_not_payable",
323
+ "refund_not_allowed",
324
+ "refund_already_exists",
325
+ "payment_awaiting_verification",
326
+ "payment_attempt_invalid",
327
+ "payment_attempt_mismatch",
328
+ "payment_attempt_stale",
329
+ "payment_method_mismatch",
330
+ "provider_response_invalid",
331
+ "decline_not_retryable",
332
+ "checkout_window_closed",
333
+ "payment_not_editable",
334
+ "payment_cancel_not_allowed",
335
+ "payment_cancellation_pending",
336
+ "invoicing_locked",
337
+ "source_identity_conflict",
338
+ "refund_source_identity_conflict",
339
+ "refund_payment_not_captured",
340
+ "refund_exceeds_captured",
341
+ "refund_allocation_not_found",
342
+ "refund_allocation_conflict",
343
+ "refund_allocation_ledger_unavailable",
344
+ "fiscal_buyer_required",
345
+ "fiscal_artifact_not_ready",
346
+ "payment_invoice_not_ready",
347
+ "payment_invoice_not_allowed",
348
+ "invoice_reference_stale",
349
+ "fiscal_delivery_not_ready",
350
+ "payment_split_not_allowed",
351
+ "payment_split_exists",
352
+ "payment_split_locked",
353
+ "payment_split_not_capturable",
354
+ "payment_split_not_expired",
355
+ "payment_split_not_renewable",
356
+ "payment_split_complete",
357
+ "payment_split_part_required",
358
+ "payment_part_not_payable",
359
+ "webhook_endpoint_deleted",
360
+ "webhook_endpoint_suspended",
361
+ "three_ds_binding_mismatch",
362
+ "payer_enrollment_unavailable",
363
+ "payer_claim_unavailable",
364
+ "payer_claim_conflict",
365
+ "payer_claim_proof_invalid",
366
+ "payer_delivery_address_unavailable",
367
+ "payer_fiscal_profile_unavailable",
368
+ "certificate_handoff_used",
369
+ "receipt_retention_elapsed",
370
+ "certificate_handoff_expired",
371
+ "request_body_too_large",
372
+ "unsupported_media_type",
373
+ "merchant_account_not_ready",
374
+ "merchant_checkout_policy_invalid",
375
+ "merchant_account_provider_mismatch",
376
+ "merchant_account_identity_mismatch",
377
+ "merchant_profile_incomplete",
378
+ "payment_description_required",
379
+ "sale_amount_invalid",
380
+ "credential_storage_unavailable",
381
+ "refund_credentials_unavailable",
382
+ "refund_provider_unavailable",
383
+ "refund_provider_reference_unavailable",
384
+ "provider_not_eligible",
385
+ "no_eligible_provider",
386
+ "currency_not_supported_by_provider",
387
+ "currency_not_supported_for_fiscal_document",
388
+ "fiscal_total_mismatch",
389
+ "fiscal_line_total_invalid",
390
+ "fiscal_line_legal_tip_invalid",
391
+ "fiscal_document_kind_not_allowed",
392
+ "fiscal_document_kind_unsupported",
393
+ "fiscal_government_eligibility_required",
394
+ "fiscal_government_eligibility_not_allowed",
395
+ "certificate_p12_password_invalid",
396
+ "certificate_pkcs12_invalid",
397
+ "certificate_expired",
398
+ "certificate_not_yet_valid",
399
+ "certificate_archive_not_supported",
400
+ "certificate_not_supported",
401
+ "taxpayer_unregistered",
402
+ "taxpayer_inactive",
403
+ "voluntary_tip_currency_mismatch",
404
+ "voluntary_tip_not_allowed_for_split",
405
+ "voluntary_tip_not_available",
406
+ "voluntary_tip_exceeds_maximum",
407
+ "refund_tip_amount_invalid",
408
+ "refund_tip_allocation_unknown",
409
+ "refund_amount_invalid",
410
+ "refund_currency_mismatch",
411
+ "payer_fiscal_profile_invalid",
412
+ "rate_limit_exceeded",
413
+ "internal_error",
414
+ "provider_unavailable",
415
+ "provider_rejected_request",
416
+ "taxpayer_directory_unavailable",
417
+ "fiscal_artifact_retrieval_unavailable",
418
+ "fiscal_delivery_unavailable",
419
+ "journey_marks_unavailable",
420
+ "contact_request_delivery_unavailable",
421
+ "unauthenticated",
422
+ "invalid_login",
423
+ "email_already_registered",
424
+ "organization_slug_taken",
425
+ "organization_not_found",
426
+ "hosted_tenant_conflict",
427
+ "insufficient_role",
428
+ "service_role_not_permitted",
429
+ "invalid_fiscal_identity",
430
+ "invalid_certificate_custody_signer_identity",
431
+ "custody_certificate_malformed",
432
+ "custody_certificate_not_yet_valid",
433
+ "custody_certificate_expired",
434
+ "custody_p12_work_limit_exceeded",
435
+ "custody_signature_algorithm_unsupported",
436
+ "custody_certificate_trust_profile_unsupported",
437
+ "custody_certificate_chain_untrusted",
438
+ "custody_certificate_purpose_unsupported",
439
+ "legal_issuer_already_registered",
440
+ "onboarding_legal_issuer_identity_conflict",
441
+ "legal_issuer_profile_incomplete",
442
+ "legal_issuer_not_found",
443
+ "invitation_invalid",
444
+ "invitation_expired",
445
+ "already_a_member",
446
+ "environment_not_active",
447
+ "certificate_custody_binding_not_found",
448
+ "certificate_custody_binding_conflict",
449
+ "certificate_custody_certificate_version_not_active",
450
+ "source_connection_not_found",
451
+ "source_connection_not_connected",
452
+ "source_provider_unavailable",
453
+ "source_provider_authorization_required",
454
+ "source_provider_installation_disabled",
455
+ "source_provider_installation_removed",
456
+ "source_provider_scope_insufficient",
457
+ "source_provider_target_access_removed",
458
+ "source_provider_throttled",
459
+ "source_provider_outcome_unknown",
460
+ "source_provider_authorization_not_found",
461
+ "source_provider_authorization_conflict",
462
+ "source_provider_installation_request_invalid",
463
+ "source_provider_installation_request_expired",
464
+ "source_provider_installation_callback_replayed",
465
+ "source_connection_creation_conflict",
466
+ "source_connection_activation_conflict",
467
+ "source_connection_activation_verification_rejected",
468
+ "delegated_authorization_verifier_forbidden",
469
+ "invalid_credential",
470
+ "credential_revoked",
471
+ "issuer_not_authorized",
472
+ "missing_idempotency_key",
473
+ "invalid_idempotency_key",
474
+ "request_too_large",
475
+ "request_body_timeout",
476
+ "malformed_json",
477
+ "invalid_request",
478
+ "invalid_collection_query",
479
+ "invalid_collection_cursor",
480
+ "document_type_not_enabled",
481
+ "fiscal_intent_rejected",
482
+ "idempotency_key_conflict",
483
+ "fiscal_number_already_used",
484
+ "fiscal_number_authorization_changed",
485
+ "fiscal_number_authorization_source_record_conflict",
486
+ "source_version_stale",
487
+ "source_predecessor_conflict",
488
+ "source_history_requires_reconciliation",
489
+ "source_content_conflict",
490
+ "source_action_conflict",
491
+ "source_command_conflict",
492
+ "invoice_reference_conflict",
493
+ "invoice_totals_mismatch",
494
+ "printed_representation_profile_conflict",
495
+ "source_record_already_fiscalized",
496
+ "source_operation_pending",
497
+ "source_outcome_unknown",
498
+ "authority_rejected_replacement",
499
+ "correction_target_unsettled",
500
+ "unsupported_printed_representation_profile",
501
+ "affected_fiscal_operation_unsupported",
502
+ "fiscal_issuance_blocked",
503
+ "fiscal_operation_not_found",
504
+ "invoice_not_found",
505
+ "fiscal_artifact_not_found",
506
+ "fiscal_artifact_unverified",
507
+ "fiscal_artifact_unavailable",
508
+ "invoice_receipt_not_found",
509
+ "invoice_receipt_not_ready",
510
+ "invoice_receipt_unavailable",
511
+ "fiscal_delivery_not_found",
512
+ "fiscal_delivery_outcome_conflict",
513
+ "webhook_endpoint_registration_conflict",
514
+ "invalid_replay_scope",
515
+ "webhook_destination_not_allowed",
516
+ "unsigned_document_schema_invalid",
517
+ "signed_document_schema_invalid",
518
+ "custody_unavailable",
519
+ "received_document_not_found",
520
+ "commercial_response_motive_invalid",
521
+ "commercial_response_decision_conflict",
522
+ "method_not_allowed",
523
+ ]),
524
+ detail: z.string().optional(),
525
+ invoiceId: z.string().optional(),
526
+ issuanceBlockers: z
527
+ .array(z.enum([
528
+ "invalid_request",
529
+ "unsupported_protocol",
530
+ "unsupported_rules_version",
531
+ "invalid_resolved_facts",
532
+ "numbering_verifier_missing",
533
+ "numbering_mode_not_enabled",
534
+ "document_type_not_recognized",
535
+ "authorization_missing",
536
+ "authorization_not_observed_on_effective_date",
537
+ "authorization_suspended",
538
+ "authorization_cancelled",
539
+ "authorization_superseded",
540
+ "authorization_exhausted",
541
+ "authorization_conflicting",
542
+ "authorization_document_type_mismatch",
543
+ "central_assignment_requires_verified_authorization",
544
+ "authorization_expired",
545
+ "authorization_range_overlap",
546
+ "fiscal_number_capacity_exhausted",
547
+ "invalid_fiscal_number",
548
+ "fiscal_number_outside_authorized_range",
549
+ "fiscal_number_before_verified_floor",
550
+ "sequence_expiration_mismatch",
551
+ ]))
552
+ .optional(),
553
+ problems: z
554
+ .array(z.object({
555
+ code: z.string(),
556
+ message: z.string(),
557
+ path: z.string(),
558
+ }))
559
+ .optional(),
560
+ requestId: z.string(),
561
+ status: z.int().gte(400).lte(599),
562
+ title: z.string(),
563
+ type: z.enum(["about:blank"]),
564
+ });
565
+ /**
566
+ * MerchantBusiness
567
+ *
568
+ * The business the credential selects, its capabilities, and the requirements that remain.
569
+ */
570
+ export const zRetrieveBusinessResponse = z.object({
571
+ object: z.literal("merchant_business"),
572
+ id: z.string().regex(/^mbiz_[0-9a-hjkmnp-tv-z]{24,}$/),
573
+ rnc: z.string().regex(/^[0-9]{9}$/),
574
+ legalName: z.string().refine((text) => Array.from(text).length >= 1),
575
+ revision: z.int().gte(0),
576
+ capabilities: z.object({
577
+ payments: z.object({
578
+ requested: z.boolean(),
579
+ test: z.object({
580
+ status: lenientUnion([
581
+ z.literal("active"),
582
+ z.literal("pending"),
583
+ z.literal("inactive"),
584
+ z.literal("unavailable"),
585
+ ]),
586
+ }),
587
+ live: z.object({
588
+ status: lenientUnion([
589
+ z.literal("active"),
590
+ z.literal("pending"),
591
+ z.literal("inactive"),
592
+ z.literal("unavailable"),
593
+ ]),
594
+ }),
595
+ }),
596
+ invoices: z.object({
597
+ requested: z.boolean(),
598
+ test: z.object({
599
+ status: lenientUnion([
600
+ z.literal("active"),
601
+ z.literal("pending"),
602
+ z.literal("inactive"),
603
+ z.literal("unavailable"),
604
+ ]),
605
+ }),
606
+ live: z.object({
607
+ status: lenientUnion([
608
+ z.literal("active"),
609
+ z.literal("pending"),
610
+ z.literal("inactive"),
611
+ z.literal("unavailable"),
612
+ ]),
613
+ }),
614
+ }),
615
+ }),
616
+ fiscalDetails: z.object({
617
+ commercialName: z.string().nullable(),
618
+ address: z.string().nullable(),
619
+ location: z
620
+ .object({
621
+ placeId: z
622
+ .string()
623
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
624
+ catalogReleaseId: z.string().regex(/^dr_[A-Za-z0-9._-]+$/),
625
+ municipalityCode: z
626
+ .string()
627
+ .regex(/^[0-9]{6}$/)
628
+ .nullable(),
629
+ name: z
630
+ .string()
631
+ .refine((text) => Array.from(text).length >= 1)
632
+ .refine((text) => Array.from(text).length <= 160),
633
+ kind: lenientUnion([
634
+ z.literal("country"),
635
+ z.literal("region"),
636
+ z.literal("national_district"),
637
+ z.literal("province"),
638
+ z.literal("municipality"),
639
+ z.literal("municipal_district"),
640
+ z.literal("urban_zone"),
641
+ z.literal("section"),
642
+ z.literal("barrio"),
643
+ z.literal("paraje"),
644
+ z.literal("subbarrio"),
645
+ ]),
646
+ qualityStatus: lenientUnion([
647
+ z.literal("verified"),
648
+ z.literal("provisional"),
649
+ z.literal("conflicted"),
650
+ ]),
651
+ ancestors: z
652
+ .array(z.object({
653
+ placeId: z
654
+ .string()
655
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
656
+ name: z
657
+ .string()
658
+ .refine((text) => Array.from(text).length >= 1)
659
+ .refine((text) => Array.from(text).length <= 160),
660
+ kind: lenientUnion([
661
+ z.literal("country"),
662
+ z.literal("region"),
663
+ z.literal("national_district"),
664
+ z.literal("province"),
665
+ z.literal("municipality"),
666
+ z.literal("municipal_district"),
667
+ z.literal("urban_zone"),
668
+ z.literal("section"),
669
+ z.literal("barrio"),
670
+ z.literal("paraje"),
671
+ z.literal("subbarrio"),
672
+ ]),
673
+ qualityStatus: lenientUnion([
674
+ z.literal("verified"),
675
+ z.literal("provisional"),
676
+ z.literal("conflicted"),
677
+ ]),
678
+ }))
679
+ .max(32),
680
+ })
681
+ .nullable(),
682
+ phone: z.string().nullable(),
683
+ email: z.string().nullable(),
684
+ defaultIncomeType: z.string().nullable(),
685
+ }),
686
+ paymentsProfile: z
687
+ .object({
688
+ displayName: z
689
+ .string()
690
+ .refine((text) => Array.from(text).length >= 1)
691
+ .refine((text) => Array.from(text).length <= 80)
692
+ .regex(/\S/),
693
+ statementDescriptor: z
694
+ .string()
695
+ .refine((text) => Array.from(text).length >= 1)
696
+ .refine((text) => Array.from(text).length <= 22)
697
+ .regex(/\S/),
698
+ permanentAddress: z.object({
699
+ line1: z
700
+ .string()
701
+ .refine((text) => Array.from(text).length >= 1)
702
+ .refine((text) => Array.from(text).length <= 160)
703
+ .regex(/\S/),
704
+ line2: z
705
+ .string()
706
+ .refine((text) => Array.from(text).length >= 1)
707
+ .refine((text) => Array.from(text).length <= 160)
708
+ .regex(/\S/)
709
+ .optional(),
710
+ city: z
711
+ .string()
712
+ .refine((text) => Array.from(text).length >= 1)
713
+ .refine((text) => Array.from(text).length <= 80)
714
+ .regex(/\S/),
715
+ province: z
716
+ .string()
717
+ .refine((text) => Array.from(text).length >= 1)
718
+ .refine((text) => Array.from(text).length <= 80)
719
+ .regex(/\S/)
720
+ .optional(),
721
+ postalCode: z
722
+ .string()
723
+ .refine((text) => Array.from(text).length >= 1)
724
+ .refine((text) => Array.from(text).length <= 20)
725
+ .regex(/\S/)
726
+ .optional(),
727
+ countryCode: z.string().regex(/^[A-Z]{2}$/),
728
+ }),
729
+ supportEmail: z.email().refine((text) => Array.from(text).length <= 254),
730
+ supportPhone: z.string().regex(/^\+[1-9][0-9]{7,14}$/),
731
+ deliveryPolicy: lenientUnion([
732
+ z.object({
733
+ kind: z.literal("not_offered"),
734
+ }),
735
+ z.object({
736
+ kind: z.literal("merchant_managed"),
737
+ summary: z
738
+ .string()
739
+ .refine((text) => Array.from(text).length >= 1)
740
+ .refine((text) => Array.from(text).length <= 160)
741
+ .regex(/\S/),
742
+ url: z
743
+ .url()
744
+ .refine((text) => Array.from(text).length <= 2048)
745
+ .regex(/^https?:\/\//)
746
+ .optional(),
747
+ }),
748
+ ]),
749
+ })
750
+ .nullable(),
751
+ invoicing: z.object({
752
+ test: zMerchantBusinessFiscalSetup,
753
+ live: zMerchantBusinessLiveFiscalSetup,
754
+ }),
755
+ requirements: z.array(z.object({
756
+ code: lenientUnion([
757
+ z.literal("capabilities_required"),
758
+ z.literal("commercial_name_required"),
759
+ z.literal("address_required"),
760
+ z.literal("location_required"),
761
+ z.literal("phone_required"),
762
+ z.literal("default_income_type_required"),
763
+ z.literal("contact_email_verification_required"),
764
+ z.literal("fiscal_details_rejected"),
765
+ z.literal("taxpayer_registration_required"),
766
+ z.literal("signing_certificate_required"),
767
+ z.literal("signing_certificate_expiring"),
768
+ z.literal("test_fiscal_document_rejected"),
769
+ z.literal("test_fiscal_document_pending"),
770
+ z.literal("test_fiscal_document_send_pending"),
771
+ z.literal("fiscal_binding_pending"),
772
+ z.literal("legal_issuer_sync_pending"),
773
+ z.literal("fiscal_setup_unavailable"),
774
+ z.literal("fiscal_binding_conflict"),
775
+ z.literal("fiscal_issuer_rejected"),
776
+ z.literal("test_fiscal_document_operator_required"),
777
+ z.literal("payments_profile_required"),
778
+ z.literal("test_payments_unavailable"),
779
+ z.literal("merchant_account_required"),
780
+ z.literal("merchant_account_disabled"),
781
+ z.literal("active_credential_required"),
782
+ z.literal("credential_material_invalid"),
783
+ z.literal("test_live_mode_mismatch"),
784
+ z.literal("callback_configuration_failed"),
785
+ z.literal("callback_configuration_required"),
786
+ z.literal("connectivity_check_failed"),
787
+ z.literal("connectivity_check_required"),
788
+ z.literal("provider_qualification_failed"),
789
+ z.literal("provider_qualification_required"),
790
+ z.literal("provider_adapter_unavailable"),
791
+ ]),
792
+ owner: lenientUnion([
793
+ z.literal("merchant"),
794
+ z.literal("dgii"),
795
+ z.literal("timbro"),
796
+ z.literal("provider"),
797
+ z.literal("operator"),
798
+ ]),
799
+ blocks: z.array(lenientUnion([z.literal("payments"), z.literal("invoices")])).max(2),
800
+ mode: lenientUnion([z.literal("test"), z.literal("live")]).optional(),
801
+ field: z.string().optional(),
802
+ errors: z
803
+ .array(z.object({
804
+ code: z.string(),
805
+ message: z.string(),
806
+ }))
807
+ .min(1)
808
+ .optional(),
809
+ })),
810
+ onboardingUrl: z.url(),
811
+ });
812
+ /**
813
+ * MerchantBusinessUpdateRequest
814
+ *
815
+ * Each member the request carries replaces that member of the business.
816
+ */
817
+ export const zUpdateBusinessResponse = z.object({
818
+ object: z.literal("merchant_business"),
819
+ id: z.string().regex(/^mbiz_[0-9a-hjkmnp-tv-z]{24,}$/),
820
+ rnc: z.string().regex(/^[0-9]{9}$/),
821
+ legalName: z.string().refine((text) => Array.from(text).length >= 1),
822
+ revision: z.int().gte(0),
823
+ capabilities: z.object({
824
+ payments: z.object({
825
+ requested: z.boolean(),
826
+ test: z.object({
827
+ status: lenientUnion([
828
+ z.literal("active"),
829
+ z.literal("pending"),
830
+ z.literal("inactive"),
831
+ z.literal("unavailable"),
832
+ ]),
833
+ }),
834
+ live: z.object({
835
+ status: lenientUnion([
836
+ z.literal("active"),
837
+ z.literal("pending"),
838
+ z.literal("inactive"),
839
+ z.literal("unavailable"),
840
+ ]),
841
+ }),
842
+ }),
843
+ invoices: z.object({
844
+ requested: z.boolean(),
845
+ test: z.object({
846
+ status: lenientUnion([
847
+ z.literal("active"),
848
+ z.literal("pending"),
849
+ z.literal("inactive"),
850
+ z.literal("unavailable"),
851
+ ]),
852
+ }),
853
+ live: z.object({
854
+ status: lenientUnion([
855
+ z.literal("active"),
856
+ z.literal("pending"),
857
+ z.literal("inactive"),
858
+ z.literal("unavailable"),
859
+ ]),
860
+ }),
861
+ }),
862
+ }),
863
+ fiscalDetails: z.object({
864
+ commercialName: z.string().nullable(),
865
+ address: z.string().nullable(),
866
+ location: z
867
+ .object({
868
+ placeId: z
869
+ .string()
870
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
871
+ catalogReleaseId: z.string().regex(/^dr_[A-Za-z0-9._-]+$/),
872
+ municipalityCode: z
873
+ .string()
874
+ .regex(/^[0-9]{6}$/)
875
+ .nullable(),
876
+ name: z
877
+ .string()
878
+ .refine((text) => Array.from(text).length >= 1)
879
+ .refine((text) => Array.from(text).length <= 160),
880
+ kind: lenientUnion([
881
+ z.literal("country"),
882
+ z.literal("region"),
883
+ z.literal("national_district"),
884
+ z.literal("province"),
885
+ z.literal("municipality"),
886
+ z.literal("municipal_district"),
887
+ z.literal("urban_zone"),
888
+ z.literal("section"),
889
+ z.literal("barrio"),
890
+ z.literal("paraje"),
891
+ z.literal("subbarrio"),
892
+ ]),
893
+ qualityStatus: lenientUnion([
894
+ z.literal("verified"),
895
+ z.literal("provisional"),
896
+ z.literal("conflicted"),
897
+ ]),
898
+ ancestors: z
899
+ .array(z.object({
900
+ placeId: z
901
+ .string()
902
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
903
+ name: z
904
+ .string()
905
+ .refine((text) => Array.from(text).length >= 1)
906
+ .refine((text) => Array.from(text).length <= 160),
907
+ kind: lenientUnion([
908
+ z.literal("country"),
909
+ z.literal("region"),
910
+ z.literal("national_district"),
911
+ z.literal("province"),
912
+ z.literal("municipality"),
913
+ z.literal("municipal_district"),
914
+ z.literal("urban_zone"),
915
+ z.literal("section"),
916
+ z.literal("barrio"),
917
+ z.literal("paraje"),
918
+ z.literal("subbarrio"),
919
+ ]),
920
+ qualityStatus: lenientUnion([
921
+ z.literal("verified"),
922
+ z.literal("provisional"),
923
+ z.literal("conflicted"),
924
+ ]),
925
+ }))
926
+ .max(32),
927
+ })
928
+ .nullable(),
929
+ phone: z.string().nullable(),
930
+ email: z.string().nullable(),
931
+ defaultIncomeType: z.string().nullable(),
932
+ }),
933
+ paymentsProfile: z
934
+ .object({
935
+ displayName: z
936
+ .string()
937
+ .refine((text) => Array.from(text).length >= 1)
938
+ .refine((text) => Array.from(text).length <= 80)
939
+ .regex(/\S/),
940
+ statementDescriptor: z
941
+ .string()
942
+ .refine((text) => Array.from(text).length >= 1)
943
+ .refine((text) => Array.from(text).length <= 22)
944
+ .regex(/\S/),
945
+ permanentAddress: z.object({
946
+ line1: z
947
+ .string()
948
+ .refine((text) => Array.from(text).length >= 1)
949
+ .refine((text) => Array.from(text).length <= 160)
950
+ .regex(/\S/),
951
+ line2: z
952
+ .string()
953
+ .refine((text) => Array.from(text).length >= 1)
954
+ .refine((text) => Array.from(text).length <= 160)
955
+ .regex(/\S/)
956
+ .optional(),
957
+ city: z
958
+ .string()
959
+ .refine((text) => Array.from(text).length >= 1)
960
+ .refine((text) => Array.from(text).length <= 80)
961
+ .regex(/\S/),
962
+ province: z
963
+ .string()
964
+ .refine((text) => Array.from(text).length >= 1)
965
+ .refine((text) => Array.from(text).length <= 80)
966
+ .regex(/\S/)
967
+ .optional(),
968
+ postalCode: z
969
+ .string()
970
+ .refine((text) => Array.from(text).length >= 1)
971
+ .refine((text) => Array.from(text).length <= 20)
972
+ .regex(/\S/)
973
+ .optional(),
974
+ countryCode: z.string().regex(/^[A-Z]{2}$/),
975
+ }),
976
+ supportEmail: z.email().refine((text) => Array.from(text).length <= 254),
977
+ supportPhone: z.string().regex(/^\+[1-9][0-9]{7,14}$/),
978
+ deliveryPolicy: lenientUnion([
979
+ z.object({
980
+ kind: z.literal("not_offered"),
981
+ }),
982
+ z.object({
983
+ kind: z.literal("merchant_managed"),
984
+ summary: z
985
+ .string()
986
+ .refine((text) => Array.from(text).length >= 1)
987
+ .refine((text) => Array.from(text).length <= 160)
988
+ .regex(/\S/),
989
+ url: z
990
+ .url()
991
+ .refine((text) => Array.from(text).length <= 2048)
992
+ .regex(/^https?:\/\//)
993
+ .optional(),
994
+ }),
995
+ ]),
996
+ })
997
+ .nullable(),
998
+ invoicing: z.object({
999
+ test: zMerchantBusinessFiscalSetup,
1000
+ live: zMerchantBusinessLiveFiscalSetup,
1001
+ }),
1002
+ requirements: z.array(z.object({
1003
+ code: lenientUnion([
1004
+ z.literal("capabilities_required"),
1005
+ z.literal("commercial_name_required"),
1006
+ z.literal("address_required"),
1007
+ z.literal("location_required"),
1008
+ z.literal("phone_required"),
1009
+ z.literal("default_income_type_required"),
1010
+ z.literal("contact_email_verification_required"),
1011
+ z.literal("fiscal_details_rejected"),
1012
+ z.literal("taxpayer_registration_required"),
1013
+ z.literal("signing_certificate_required"),
1014
+ z.literal("signing_certificate_expiring"),
1015
+ z.literal("test_fiscal_document_rejected"),
1016
+ z.literal("test_fiscal_document_pending"),
1017
+ z.literal("test_fiscal_document_send_pending"),
1018
+ z.literal("fiscal_binding_pending"),
1019
+ z.literal("legal_issuer_sync_pending"),
1020
+ z.literal("fiscal_setup_unavailable"),
1021
+ z.literal("fiscal_binding_conflict"),
1022
+ z.literal("fiscal_issuer_rejected"),
1023
+ z.literal("test_fiscal_document_operator_required"),
1024
+ z.literal("payments_profile_required"),
1025
+ z.literal("test_payments_unavailable"),
1026
+ z.literal("merchant_account_required"),
1027
+ z.literal("merchant_account_disabled"),
1028
+ z.literal("active_credential_required"),
1029
+ z.literal("credential_material_invalid"),
1030
+ z.literal("test_live_mode_mismatch"),
1031
+ z.literal("callback_configuration_failed"),
1032
+ z.literal("callback_configuration_required"),
1033
+ z.literal("connectivity_check_failed"),
1034
+ z.literal("connectivity_check_required"),
1035
+ z.literal("provider_qualification_failed"),
1036
+ z.literal("provider_qualification_required"),
1037
+ z.literal("provider_adapter_unavailable"),
1038
+ ]),
1039
+ owner: lenientUnion([
1040
+ z.literal("merchant"),
1041
+ z.literal("dgii"),
1042
+ z.literal("timbro"),
1043
+ z.literal("provider"),
1044
+ z.literal("operator"),
1045
+ ]),
1046
+ blocks: z.array(lenientUnion([z.literal("payments"), z.literal("invoices")])).max(2),
1047
+ mode: lenientUnion([z.literal("test"), z.literal("live")]).optional(),
1048
+ field: z.string().optional(),
1049
+ errors: z
1050
+ .array(z.object({
1051
+ code: z.string(),
1052
+ message: z.string(),
1053
+ }))
1054
+ .min(1)
1055
+ .optional(),
1056
+ })),
1057
+ onboardingUrl: z.url(),
1058
+ });
1059
+ /**
1060
+ * MerchantBusinessConfigureInvoicingRequest
1061
+ */
1062
+ export const zConfigureInvoicingResponse = z.object({
1063
+ object: z.literal("merchant_business_invoicing_setup"),
1064
+ mode: lenientUnion([z.literal("test"), z.literal("live")]),
1065
+ });
1066
+ /**
1067
+ * MerchantBusinessSigningCertificateRequest
1068
+ */
1069
+ export const zImportSigningCertificateResponse = z.object({
1070
+ object: z.literal("merchant_business"),
1071
+ id: z.string().regex(/^mbiz_[0-9a-hjkmnp-tv-z]{24,}$/),
1072
+ rnc: z.string().regex(/^[0-9]{9}$/),
1073
+ legalName: z.string().refine((text) => Array.from(text).length >= 1),
1074
+ revision: z.int().gte(0),
1075
+ capabilities: z.object({
1076
+ payments: z.object({
1077
+ requested: z.boolean(),
1078
+ test: z.object({
1079
+ status: lenientUnion([
1080
+ z.literal("active"),
1081
+ z.literal("pending"),
1082
+ z.literal("inactive"),
1083
+ z.literal("unavailable"),
1084
+ ]),
1085
+ }),
1086
+ live: z.object({
1087
+ status: lenientUnion([
1088
+ z.literal("active"),
1089
+ z.literal("pending"),
1090
+ z.literal("inactive"),
1091
+ z.literal("unavailable"),
1092
+ ]),
1093
+ }),
1094
+ }),
1095
+ invoices: z.object({
1096
+ requested: z.boolean(),
1097
+ test: z.object({
1098
+ status: lenientUnion([
1099
+ z.literal("active"),
1100
+ z.literal("pending"),
1101
+ z.literal("inactive"),
1102
+ z.literal("unavailable"),
1103
+ ]),
1104
+ }),
1105
+ live: z.object({
1106
+ status: lenientUnion([
1107
+ z.literal("active"),
1108
+ z.literal("pending"),
1109
+ z.literal("inactive"),
1110
+ z.literal("unavailable"),
1111
+ ]),
1112
+ }),
1113
+ }),
1114
+ }),
1115
+ fiscalDetails: z.object({
1116
+ commercialName: z.string().nullable(),
1117
+ address: z.string().nullable(),
1118
+ location: z
1119
+ .object({
1120
+ placeId: z
1121
+ .string()
1122
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
1123
+ catalogReleaseId: z.string().regex(/^dr_[A-Za-z0-9._-]+$/),
1124
+ municipalityCode: z
1125
+ .string()
1126
+ .regex(/^[0-9]{6}$/)
1127
+ .nullable(),
1128
+ name: z
1129
+ .string()
1130
+ .refine((text) => Array.from(text).length >= 1)
1131
+ .refine((text) => Array.from(text).length <= 160),
1132
+ kind: lenientUnion([
1133
+ z.literal("country"),
1134
+ z.literal("region"),
1135
+ z.literal("national_district"),
1136
+ z.literal("province"),
1137
+ z.literal("municipality"),
1138
+ z.literal("municipal_district"),
1139
+ z.literal("urban_zone"),
1140
+ z.literal("section"),
1141
+ z.literal("barrio"),
1142
+ z.literal("paraje"),
1143
+ z.literal("subbarrio"),
1144
+ ]),
1145
+ qualityStatus: lenientUnion([
1146
+ z.literal("verified"),
1147
+ z.literal("provisional"),
1148
+ z.literal("conflicted"),
1149
+ ]),
1150
+ ancestors: z
1151
+ .array(z.object({
1152
+ placeId: z
1153
+ .string()
1154
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
1155
+ name: z
1156
+ .string()
1157
+ .refine((text) => Array.from(text).length >= 1)
1158
+ .refine((text) => Array.from(text).length <= 160),
1159
+ kind: lenientUnion([
1160
+ z.literal("country"),
1161
+ z.literal("region"),
1162
+ z.literal("national_district"),
1163
+ z.literal("province"),
1164
+ z.literal("municipality"),
1165
+ z.literal("municipal_district"),
1166
+ z.literal("urban_zone"),
1167
+ z.literal("section"),
1168
+ z.literal("barrio"),
1169
+ z.literal("paraje"),
1170
+ z.literal("subbarrio"),
1171
+ ]),
1172
+ qualityStatus: lenientUnion([
1173
+ z.literal("verified"),
1174
+ z.literal("provisional"),
1175
+ z.literal("conflicted"),
1176
+ ]),
1177
+ }))
1178
+ .max(32),
1179
+ })
1180
+ .nullable(),
1181
+ phone: z.string().nullable(),
1182
+ email: z.string().nullable(),
1183
+ defaultIncomeType: z.string().nullable(),
1184
+ }),
1185
+ paymentsProfile: z
1186
+ .object({
1187
+ displayName: z
1188
+ .string()
1189
+ .refine((text) => Array.from(text).length >= 1)
1190
+ .refine((text) => Array.from(text).length <= 80)
1191
+ .regex(/\S/),
1192
+ statementDescriptor: z
1193
+ .string()
1194
+ .refine((text) => Array.from(text).length >= 1)
1195
+ .refine((text) => Array.from(text).length <= 22)
1196
+ .regex(/\S/),
1197
+ permanentAddress: z.object({
1198
+ line1: z
1199
+ .string()
1200
+ .refine((text) => Array.from(text).length >= 1)
1201
+ .refine((text) => Array.from(text).length <= 160)
1202
+ .regex(/\S/),
1203
+ line2: z
1204
+ .string()
1205
+ .refine((text) => Array.from(text).length >= 1)
1206
+ .refine((text) => Array.from(text).length <= 160)
1207
+ .regex(/\S/)
1208
+ .optional(),
1209
+ city: z
1210
+ .string()
1211
+ .refine((text) => Array.from(text).length >= 1)
1212
+ .refine((text) => Array.from(text).length <= 80)
1213
+ .regex(/\S/),
1214
+ province: z
1215
+ .string()
1216
+ .refine((text) => Array.from(text).length >= 1)
1217
+ .refine((text) => Array.from(text).length <= 80)
1218
+ .regex(/\S/)
1219
+ .optional(),
1220
+ postalCode: z
1221
+ .string()
1222
+ .refine((text) => Array.from(text).length >= 1)
1223
+ .refine((text) => Array.from(text).length <= 20)
1224
+ .regex(/\S/)
1225
+ .optional(),
1226
+ countryCode: z.string().regex(/^[A-Z]{2}$/),
1227
+ }),
1228
+ supportEmail: z.email().refine((text) => Array.from(text).length <= 254),
1229
+ supportPhone: z.string().regex(/^\+[1-9][0-9]{7,14}$/),
1230
+ deliveryPolicy: lenientUnion([
1231
+ z.object({
1232
+ kind: z.literal("not_offered"),
1233
+ }),
1234
+ z.object({
1235
+ kind: z.literal("merchant_managed"),
1236
+ summary: z
1237
+ .string()
1238
+ .refine((text) => Array.from(text).length >= 1)
1239
+ .refine((text) => Array.from(text).length <= 160)
1240
+ .regex(/\S/),
1241
+ url: z
1242
+ .url()
1243
+ .refine((text) => Array.from(text).length <= 2048)
1244
+ .regex(/^https?:\/\//)
1245
+ .optional(),
1246
+ }),
1247
+ ]),
1248
+ })
1249
+ .nullable(),
1250
+ invoicing: z.object({
1251
+ test: zMerchantBusinessFiscalSetup,
1252
+ live: zMerchantBusinessLiveFiscalSetup,
1253
+ }),
1254
+ requirements: z.array(z.object({
1255
+ code: lenientUnion([
1256
+ z.literal("capabilities_required"),
1257
+ z.literal("commercial_name_required"),
1258
+ z.literal("address_required"),
1259
+ z.literal("location_required"),
1260
+ z.literal("phone_required"),
1261
+ z.literal("default_income_type_required"),
1262
+ z.literal("contact_email_verification_required"),
1263
+ z.literal("fiscal_details_rejected"),
1264
+ z.literal("taxpayer_registration_required"),
1265
+ z.literal("signing_certificate_required"),
1266
+ z.literal("signing_certificate_expiring"),
1267
+ z.literal("test_fiscal_document_rejected"),
1268
+ z.literal("test_fiscal_document_pending"),
1269
+ z.literal("test_fiscal_document_send_pending"),
1270
+ z.literal("fiscal_binding_pending"),
1271
+ z.literal("legal_issuer_sync_pending"),
1272
+ z.literal("fiscal_setup_unavailable"),
1273
+ z.literal("fiscal_binding_conflict"),
1274
+ z.literal("fiscal_issuer_rejected"),
1275
+ z.literal("test_fiscal_document_operator_required"),
1276
+ z.literal("payments_profile_required"),
1277
+ z.literal("test_payments_unavailable"),
1278
+ z.literal("merchant_account_required"),
1279
+ z.literal("merchant_account_disabled"),
1280
+ z.literal("active_credential_required"),
1281
+ z.literal("credential_material_invalid"),
1282
+ z.literal("test_live_mode_mismatch"),
1283
+ z.literal("callback_configuration_failed"),
1284
+ z.literal("callback_configuration_required"),
1285
+ z.literal("connectivity_check_failed"),
1286
+ z.literal("connectivity_check_required"),
1287
+ z.literal("provider_qualification_failed"),
1288
+ z.literal("provider_qualification_required"),
1289
+ z.literal("provider_adapter_unavailable"),
1290
+ ]),
1291
+ owner: lenientUnion([
1292
+ z.literal("merchant"),
1293
+ z.literal("dgii"),
1294
+ z.literal("timbro"),
1295
+ z.literal("provider"),
1296
+ z.literal("operator"),
1297
+ ]),
1298
+ blocks: z.array(lenientUnion([z.literal("payments"), z.literal("invoices")])).max(2),
1299
+ mode: lenientUnion([z.literal("test"), z.literal("live")]).optional(),
1300
+ field: z.string().optional(),
1301
+ errors: z
1302
+ .array(z.object({
1303
+ code: z.string(),
1304
+ message: z.string(),
1305
+ }))
1306
+ .min(1)
1307
+ .optional(),
1308
+ })),
1309
+ onboardingUrl: z.url(),
1310
+ });
1311
+ /**
1312
+ * MerchantBusinessTestFiscalDocumentRequest
1313
+ */
1314
+ export const zIssueTestInvoiceResponse = lenientUnion([
1315
+ z.object({
1316
+ object: z.literal("merchant_business"),
1317
+ id: z.string().regex(/^mbiz_[0-9a-hjkmnp-tv-z]{24,}$/),
1318
+ rnc: z.string().regex(/^[0-9]{9}$/),
1319
+ legalName: z.string().refine((text) => Array.from(text).length >= 1),
1320
+ revision: z.int().gte(0),
1321
+ capabilities: z.object({
1322
+ payments: z.object({
1323
+ requested: z.boolean(),
1324
+ test: z.object({
1325
+ status: lenientUnion([
1326
+ z.literal("active"),
1327
+ z.literal("pending"),
1328
+ z.literal("inactive"),
1329
+ z.literal("unavailable"),
1330
+ ]),
1331
+ }),
1332
+ live: z.object({
1333
+ status: lenientUnion([
1334
+ z.literal("active"),
1335
+ z.literal("pending"),
1336
+ z.literal("inactive"),
1337
+ z.literal("unavailable"),
1338
+ ]),
1339
+ }),
1340
+ }),
1341
+ invoices: z.object({
1342
+ requested: z.boolean(),
1343
+ test: z.object({
1344
+ status: lenientUnion([
1345
+ z.literal("active"),
1346
+ z.literal("pending"),
1347
+ z.literal("inactive"),
1348
+ z.literal("unavailable"),
1349
+ ]),
1350
+ }),
1351
+ live: z.object({
1352
+ status: lenientUnion([
1353
+ z.literal("active"),
1354
+ z.literal("pending"),
1355
+ z.literal("inactive"),
1356
+ z.literal("unavailable"),
1357
+ ]),
1358
+ }),
1359
+ }),
1360
+ }),
1361
+ fiscalDetails: z.object({
1362
+ commercialName: z.string().nullable(),
1363
+ address: z.string().nullable(),
1364
+ location: z
1365
+ .object({
1366
+ placeId: z
1367
+ .string()
1368
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
1369
+ catalogReleaseId: z.string().regex(/^dr_[A-Za-z0-9._-]+$/),
1370
+ municipalityCode: z
1371
+ .string()
1372
+ .regex(/^[0-9]{6}$/)
1373
+ .nullable(),
1374
+ name: z
1375
+ .string()
1376
+ .refine((text) => Array.from(text).length >= 1)
1377
+ .refine((text) => Array.from(text).length <= 160),
1378
+ kind: lenientUnion([
1379
+ z.literal("country"),
1380
+ z.literal("region"),
1381
+ z.literal("national_district"),
1382
+ z.literal("province"),
1383
+ z.literal("municipality"),
1384
+ z.literal("municipal_district"),
1385
+ z.literal("urban_zone"),
1386
+ z.literal("section"),
1387
+ z.literal("barrio"),
1388
+ z.literal("paraje"),
1389
+ z.literal("subbarrio"),
1390
+ ]),
1391
+ qualityStatus: lenientUnion([
1392
+ z.literal("verified"),
1393
+ z.literal("provisional"),
1394
+ z.literal("conflicted"),
1395
+ ]),
1396
+ ancestors: z
1397
+ .array(z.object({
1398
+ placeId: z
1399
+ .string()
1400
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
1401
+ name: z
1402
+ .string()
1403
+ .refine((text) => Array.from(text).length >= 1)
1404
+ .refine((text) => Array.from(text).length <= 160),
1405
+ kind: lenientUnion([
1406
+ z.literal("country"),
1407
+ z.literal("region"),
1408
+ z.literal("national_district"),
1409
+ z.literal("province"),
1410
+ z.literal("municipality"),
1411
+ z.literal("municipal_district"),
1412
+ z.literal("urban_zone"),
1413
+ z.literal("section"),
1414
+ z.literal("barrio"),
1415
+ z.literal("paraje"),
1416
+ z.literal("subbarrio"),
1417
+ ]),
1418
+ qualityStatus: lenientUnion([
1419
+ z.literal("verified"),
1420
+ z.literal("provisional"),
1421
+ z.literal("conflicted"),
1422
+ ]),
1423
+ }))
1424
+ .max(32),
1425
+ })
1426
+ .nullable(),
1427
+ phone: z.string().nullable(),
1428
+ email: z.string().nullable(),
1429
+ defaultIncomeType: z.string().nullable(),
1430
+ }),
1431
+ paymentsProfile: z
1432
+ .object({
1433
+ displayName: z
1434
+ .string()
1435
+ .refine((text) => Array.from(text).length >= 1)
1436
+ .refine((text) => Array.from(text).length <= 80)
1437
+ .regex(/\S/),
1438
+ statementDescriptor: z
1439
+ .string()
1440
+ .refine((text) => Array.from(text).length >= 1)
1441
+ .refine((text) => Array.from(text).length <= 22)
1442
+ .regex(/\S/),
1443
+ permanentAddress: z.object({
1444
+ line1: z
1445
+ .string()
1446
+ .refine((text) => Array.from(text).length >= 1)
1447
+ .refine((text) => Array.from(text).length <= 160)
1448
+ .regex(/\S/),
1449
+ line2: z
1450
+ .string()
1451
+ .refine((text) => Array.from(text).length >= 1)
1452
+ .refine((text) => Array.from(text).length <= 160)
1453
+ .regex(/\S/)
1454
+ .optional(),
1455
+ city: z
1456
+ .string()
1457
+ .refine((text) => Array.from(text).length >= 1)
1458
+ .refine((text) => Array.from(text).length <= 80)
1459
+ .regex(/\S/),
1460
+ province: z
1461
+ .string()
1462
+ .refine((text) => Array.from(text).length >= 1)
1463
+ .refine((text) => Array.from(text).length <= 80)
1464
+ .regex(/\S/)
1465
+ .optional(),
1466
+ postalCode: z
1467
+ .string()
1468
+ .refine((text) => Array.from(text).length >= 1)
1469
+ .refine((text) => Array.from(text).length <= 20)
1470
+ .regex(/\S/)
1471
+ .optional(),
1472
+ countryCode: z.string().regex(/^[A-Z]{2}$/),
1473
+ }),
1474
+ supportEmail: z.email().refine((text) => Array.from(text).length <= 254),
1475
+ supportPhone: z.string().regex(/^\+[1-9][0-9]{7,14}$/),
1476
+ deliveryPolicy: lenientUnion([
1477
+ z.object({
1478
+ kind: z.literal("not_offered"),
1479
+ }),
1480
+ z.object({
1481
+ kind: z.literal("merchant_managed"),
1482
+ summary: z
1483
+ .string()
1484
+ .refine((text) => Array.from(text).length >= 1)
1485
+ .refine((text) => Array.from(text).length <= 160)
1486
+ .regex(/\S/),
1487
+ url: z
1488
+ .url()
1489
+ .refine((text) => Array.from(text).length <= 2048)
1490
+ .regex(/^https?:\/\//)
1491
+ .optional(),
1492
+ }),
1493
+ ]),
1494
+ })
1495
+ .nullable(),
1496
+ invoicing: z.object({
1497
+ test: zMerchantBusinessFiscalSetup,
1498
+ live: zMerchantBusinessLiveFiscalSetup,
1499
+ }),
1500
+ requirements: z.array(z.object({
1501
+ code: lenientUnion([
1502
+ z.literal("capabilities_required"),
1503
+ z.literal("commercial_name_required"),
1504
+ z.literal("address_required"),
1505
+ z.literal("location_required"),
1506
+ z.literal("phone_required"),
1507
+ z.literal("default_income_type_required"),
1508
+ z.literal("contact_email_verification_required"),
1509
+ z.literal("fiscal_details_rejected"),
1510
+ z.literal("taxpayer_registration_required"),
1511
+ z.literal("signing_certificate_required"),
1512
+ z.literal("signing_certificate_expiring"),
1513
+ z.literal("test_fiscal_document_rejected"),
1514
+ z.literal("test_fiscal_document_pending"),
1515
+ z.literal("test_fiscal_document_send_pending"),
1516
+ z.literal("fiscal_binding_pending"),
1517
+ z.literal("legal_issuer_sync_pending"),
1518
+ z.literal("fiscal_setup_unavailable"),
1519
+ z.literal("fiscal_binding_conflict"),
1520
+ z.literal("fiscal_issuer_rejected"),
1521
+ z.literal("test_fiscal_document_operator_required"),
1522
+ z.literal("payments_profile_required"),
1523
+ z.literal("test_payments_unavailable"),
1524
+ z.literal("merchant_account_required"),
1525
+ z.literal("merchant_account_disabled"),
1526
+ z.literal("active_credential_required"),
1527
+ z.literal("credential_material_invalid"),
1528
+ z.literal("test_live_mode_mismatch"),
1529
+ z.literal("callback_configuration_failed"),
1530
+ z.literal("callback_configuration_required"),
1531
+ z.literal("connectivity_check_failed"),
1532
+ z.literal("connectivity_check_required"),
1533
+ z.literal("provider_qualification_failed"),
1534
+ z.literal("provider_qualification_required"),
1535
+ z.literal("provider_adapter_unavailable"),
1536
+ ]),
1537
+ owner: lenientUnion([
1538
+ z.literal("merchant"),
1539
+ z.literal("dgii"),
1540
+ z.literal("timbro"),
1541
+ z.literal("provider"),
1542
+ z.literal("operator"),
1543
+ ]),
1544
+ blocks: z.array(lenientUnion([z.literal("payments"), z.literal("invoices")])).max(2),
1545
+ mode: lenientUnion([z.literal("test"), z.literal("live")]).optional(),
1546
+ field: z.string().optional(),
1547
+ errors: z
1548
+ .array(z.object({
1549
+ code: z.string(),
1550
+ message: z.string(),
1551
+ }))
1552
+ .min(1)
1553
+ .optional(),
1554
+ })),
1555
+ onboardingUrl: z.url(),
1556
+ }),
1557
+ z.object({
1558
+ object: z.literal("merchant_business"),
1559
+ id: z.string().regex(/^mbiz_[0-9a-hjkmnp-tv-z]{24,}$/),
1560
+ rnc: z.string().regex(/^[0-9]{9}$/),
1561
+ legalName: z.string().refine((text) => Array.from(text).length >= 1),
1562
+ revision: z.int().gte(0),
1563
+ capabilities: z.object({
1564
+ payments: z.object({
1565
+ requested: z.boolean(),
1566
+ test: z.object({
1567
+ status: lenientUnion([
1568
+ z.literal("active"),
1569
+ z.literal("pending"),
1570
+ z.literal("inactive"),
1571
+ z.literal("unavailable"),
1572
+ ]),
1573
+ }),
1574
+ live: z.object({
1575
+ status: lenientUnion([
1576
+ z.literal("active"),
1577
+ z.literal("pending"),
1578
+ z.literal("inactive"),
1579
+ z.literal("unavailable"),
1580
+ ]),
1581
+ }),
1582
+ }),
1583
+ invoices: z.object({
1584
+ requested: z.boolean(),
1585
+ test: z.object({
1586
+ status: lenientUnion([
1587
+ z.literal("active"),
1588
+ z.literal("pending"),
1589
+ z.literal("inactive"),
1590
+ z.literal("unavailable"),
1591
+ ]),
1592
+ }),
1593
+ live: z.object({
1594
+ status: lenientUnion([
1595
+ z.literal("active"),
1596
+ z.literal("pending"),
1597
+ z.literal("inactive"),
1598
+ z.literal("unavailable"),
1599
+ ]),
1600
+ }),
1601
+ }),
1602
+ }),
1603
+ fiscalDetails: z.object({
1604
+ commercialName: z.string().nullable(),
1605
+ address: z.string().nullable(),
1606
+ location: z
1607
+ .object({
1608
+ placeId: z
1609
+ .string()
1610
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
1611
+ catalogReleaseId: z.string().regex(/^dr_[A-Za-z0-9._-]+$/),
1612
+ municipalityCode: z
1613
+ .string()
1614
+ .regex(/^[0-9]{6}$/)
1615
+ .nullable(),
1616
+ name: z
1617
+ .string()
1618
+ .refine((text) => Array.from(text).length >= 1)
1619
+ .refine((text) => Array.from(text).length <= 160),
1620
+ kind: lenientUnion([
1621
+ z.literal("country"),
1622
+ z.literal("region"),
1623
+ z.literal("national_district"),
1624
+ z.literal("province"),
1625
+ z.literal("municipality"),
1626
+ z.literal("municipal_district"),
1627
+ z.literal("urban_zone"),
1628
+ z.literal("section"),
1629
+ z.literal("barrio"),
1630
+ z.literal("paraje"),
1631
+ z.literal("subbarrio"),
1632
+ ]),
1633
+ qualityStatus: lenientUnion([
1634
+ z.literal("verified"),
1635
+ z.literal("provisional"),
1636
+ z.literal("conflicted"),
1637
+ ]),
1638
+ ancestors: z
1639
+ .array(z.object({
1640
+ placeId: z
1641
+ .string()
1642
+ .regex(/^place_[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
1643
+ name: z
1644
+ .string()
1645
+ .refine((text) => Array.from(text).length >= 1)
1646
+ .refine((text) => Array.from(text).length <= 160),
1647
+ kind: lenientUnion([
1648
+ z.literal("country"),
1649
+ z.literal("region"),
1650
+ z.literal("national_district"),
1651
+ z.literal("province"),
1652
+ z.literal("municipality"),
1653
+ z.literal("municipal_district"),
1654
+ z.literal("urban_zone"),
1655
+ z.literal("section"),
1656
+ z.literal("barrio"),
1657
+ z.literal("paraje"),
1658
+ z.literal("subbarrio"),
1659
+ ]),
1660
+ qualityStatus: lenientUnion([
1661
+ z.literal("verified"),
1662
+ z.literal("provisional"),
1663
+ z.literal("conflicted"),
1664
+ ]),
1665
+ }))
1666
+ .max(32),
1667
+ })
1668
+ .nullable(),
1669
+ phone: z.string().nullable(),
1670
+ email: z.string().nullable(),
1671
+ defaultIncomeType: z.string().nullable(),
1672
+ }),
1673
+ paymentsProfile: z
1674
+ .object({
1675
+ displayName: z
1676
+ .string()
1677
+ .refine((text) => Array.from(text).length >= 1)
1678
+ .refine((text) => Array.from(text).length <= 80)
1679
+ .regex(/\S/),
1680
+ statementDescriptor: z
1681
+ .string()
1682
+ .refine((text) => Array.from(text).length >= 1)
1683
+ .refine((text) => Array.from(text).length <= 22)
1684
+ .regex(/\S/),
1685
+ permanentAddress: z.object({
1686
+ line1: z
1687
+ .string()
1688
+ .refine((text) => Array.from(text).length >= 1)
1689
+ .refine((text) => Array.from(text).length <= 160)
1690
+ .regex(/\S/),
1691
+ line2: z
1692
+ .string()
1693
+ .refine((text) => Array.from(text).length >= 1)
1694
+ .refine((text) => Array.from(text).length <= 160)
1695
+ .regex(/\S/)
1696
+ .optional(),
1697
+ city: z
1698
+ .string()
1699
+ .refine((text) => Array.from(text).length >= 1)
1700
+ .refine((text) => Array.from(text).length <= 80)
1701
+ .regex(/\S/),
1702
+ province: z
1703
+ .string()
1704
+ .refine((text) => Array.from(text).length >= 1)
1705
+ .refine((text) => Array.from(text).length <= 80)
1706
+ .regex(/\S/)
1707
+ .optional(),
1708
+ postalCode: z
1709
+ .string()
1710
+ .refine((text) => Array.from(text).length >= 1)
1711
+ .refine((text) => Array.from(text).length <= 20)
1712
+ .regex(/\S/)
1713
+ .optional(),
1714
+ countryCode: z.string().regex(/^[A-Z]{2}$/),
1715
+ }),
1716
+ supportEmail: z.email().refine((text) => Array.from(text).length <= 254),
1717
+ supportPhone: z.string().regex(/^\+[1-9][0-9]{7,14}$/),
1718
+ deliveryPolicy: lenientUnion([
1719
+ z.object({
1720
+ kind: z.literal("not_offered"),
1721
+ }),
1722
+ z.object({
1723
+ kind: z.literal("merchant_managed"),
1724
+ summary: z
1725
+ .string()
1726
+ .refine((text) => Array.from(text).length >= 1)
1727
+ .refine((text) => Array.from(text).length <= 160)
1728
+ .regex(/\S/),
1729
+ url: z
1730
+ .url()
1731
+ .refine((text) => Array.from(text).length <= 2048)
1732
+ .regex(/^https?:\/\//)
1733
+ .optional(),
1734
+ }),
1735
+ ]),
1736
+ })
1737
+ .nullable(),
1738
+ invoicing: z.object({
1739
+ test: zMerchantBusinessFiscalSetup,
1740
+ live: zMerchantBusinessLiveFiscalSetup,
1741
+ }),
1742
+ requirements: z.array(z.object({
1743
+ code: lenientUnion([
1744
+ z.literal("capabilities_required"),
1745
+ z.literal("commercial_name_required"),
1746
+ z.literal("address_required"),
1747
+ z.literal("location_required"),
1748
+ z.literal("phone_required"),
1749
+ z.literal("default_income_type_required"),
1750
+ z.literal("contact_email_verification_required"),
1751
+ z.literal("fiscal_details_rejected"),
1752
+ z.literal("taxpayer_registration_required"),
1753
+ z.literal("signing_certificate_required"),
1754
+ z.literal("signing_certificate_expiring"),
1755
+ z.literal("test_fiscal_document_rejected"),
1756
+ z.literal("test_fiscal_document_pending"),
1757
+ z.literal("test_fiscal_document_send_pending"),
1758
+ z.literal("fiscal_binding_pending"),
1759
+ z.literal("legal_issuer_sync_pending"),
1760
+ z.literal("fiscal_setup_unavailable"),
1761
+ z.literal("fiscal_binding_conflict"),
1762
+ z.literal("fiscal_issuer_rejected"),
1763
+ z.literal("test_fiscal_document_operator_required"),
1764
+ z.literal("payments_profile_required"),
1765
+ z.literal("test_payments_unavailable"),
1766
+ z.literal("merchant_account_required"),
1767
+ z.literal("merchant_account_disabled"),
1768
+ z.literal("active_credential_required"),
1769
+ z.literal("credential_material_invalid"),
1770
+ z.literal("test_live_mode_mismatch"),
1771
+ z.literal("callback_configuration_failed"),
1772
+ z.literal("callback_configuration_required"),
1773
+ z.literal("connectivity_check_failed"),
1774
+ z.literal("connectivity_check_required"),
1775
+ z.literal("provider_qualification_failed"),
1776
+ z.literal("provider_qualification_required"),
1777
+ z.literal("provider_adapter_unavailable"),
1778
+ ]),
1779
+ owner: lenientUnion([
1780
+ z.literal("merchant"),
1781
+ z.literal("dgii"),
1782
+ z.literal("timbro"),
1783
+ z.literal("provider"),
1784
+ z.literal("operator"),
1785
+ ]),
1786
+ blocks: z.array(lenientUnion([z.literal("payments"), z.literal("invoices")])).max(2),
1787
+ mode: lenientUnion([z.literal("test"), z.literal("live")]).optional(),
1788
+ field: z.string().optional(),
1789
+ errors: z
1790
+ .array(z.object({
1791
+ code: z.string(),
1792
+ message: z.string(),
1793
+ }))
1794
+ .min(1)
1795
+ .optional(),
1796
+ })),
1797
+ onboardingUrl: z.url(),
1798
+ }),
1799
+ ]);
1800
+ /**
1801
+ * MerchantBusinessInvoiceKeyRequest
1802
+ */
1803
+ export const zIssueInvoiceKeyResponse = z.object({
1804
+ object: z.literal("merchant_business_invoice_key"),
1805
+ key: z
1806
+ .string()
1807
+ .refine((text) => Array.from(text).length >= 1)
1808
+ .refine((text) => Array.from(text).length <= 512),
1809
+ invoiceOrigin: z.url(),
1810
+ });
1811
+ export const zListWebhookEndpointsResponse = z.object({
1812
+ object: z.literal("list"),
1813
+ data: z.array(z.object({
1814
+ id: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1815
+ object: z.literal("webhook_endpoint"),
1816
+ url: z.url(),
1817
+ enabledEvents: z
1818
+ .array(z
1819
+ .string()
1820
+ .refine((text) => Array.from(text).length >= 1)
1821
+ .refine((text) => Array.from(text).length <= 128))
1822
+ .min(1),
1823
+ status: lenientUnion([z.literal("active"), z.literal("suspended"), z.literal("deleted")]),
1824
+ secretCreatedAt: z.iso.datetime(),
1825
+ previousSecretExpiresAt: z.iso.datetime().nullable(),
1826
+ createdAt: z.iso.datetime(),
1827
+ })),
1828
+ hasMore: z.boolean(),
1829
+ nextCursor: z
1830
+ .string()
1831
+ .refine((text) => Array.from(text).length >= 1)
1832
+ .nullable(),
1833
+ });
1834
+ /**
1835
+ * CreateWebhookEndpointRequest
1836
+ */
1837
+ export const zCreateWebhookEndpointResponse = z.object({
1838
+ id: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1839
+ object: z.literal("webhook_endpoint"),
1840
+ url: z.url(),
1841
+ enabledEvents: z
1842
+ .array(z
1843
+ .string()
1844
+ .refine((text) => Array.from(text).length >= 1)
1845
+ .refine((text) => Array.from(text).length <= 128))
1846
+ .min(1),
1847
+ status: lenientUnion([z.literal("active"), z.literal("suspended"), z.literal("deleted")]),
1848
+ secretCreatedAt: z.iso.datetime(),
1849
+ previousSecretExpiresAt: z.iso.datetime().nullable(),
1850
+ createdAt: z.iso.datetime(),
1851
+ secret: z.string().regex(/^whsec_[A-Za-z0-9+/]+={0,2}$/),
1852
+ });
1853
+ export const zDeleteWebhookEndpointResponse = z.void();
1854
+ export const zRetrieveWebhookEndpointResponse = z.object({
1855
+ id: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1856
+ object: z.literal("webhook_endpoint"),
1857
+ url: z.url(),
1858
+ enabledEvents: z
1859
+ .array(z
1860
+ .string()
1861
+ .refine((text) => Array.from(text).length >= 1)
1862
+ .refine((text) => Array.from(text).length <= 128))
1863
+ .min(1),
1864
+ status: lenientUnion([z.literal("active"), z.literal("suspended"), z.literal("deleted")]),
1865
+ secretCreatedAt: z.iso.datetime(),
1866
+ previousSecretExpiresAt: z.iso.datetime().nullable(),
1867
+ createdAt: z.iso.datetime(),
1868
+ });
1869
+ export const zListWebhookDeliveriesResponse = z.object({
1870
+ object: z.literal("list"),
1871
+ data: z.array(z.object({
1872
+ id: z.string().regex(/^webhook_delivery_[0-9a-hjkmnp-tv-z]{24,}$/),
1873
+ object: z.literal("webhook_delivery"),
1874
+ eventId: lenientUnion([z.string().regex(/^event_[0-9a-hjkmnp-tv-z]{24,}$/), z.uuid()]),
1875
+ eventType: z
1876
+ .string()
1877
+ .refine((text) => Array.from(text).length >= 1)
1878
+ .refine((text) => Array.from(text).length <= 128),
1879
+ state: lenientUnion([
1880
+ z.literal("pending"),
1881
+ z.literal("processing"),
1882
+ z.literal("delivered"),
1883
+ z.literal("dead_lettered"),
1884
+ ]),
1885
+ attemptCount: z.int().gte(0),
1886
+ nextAttemptAt: z.iso.datetime(),
1887
+ lastStatusCode: z.int().nullable(),
1888
+ resultCode: lenientUnion([
1889
+ z.literal("delivered"),
1890
+ z.literal("attempt_budget_exhausted"),
1891
+ z.literal("delivery_deadline_exceeded"),
1892
+ ]).nullable(),
1893
+ lastResponseExcerpt: z
1894
+ .string()
1895
+ .refine((text) => Array.from(text).length <= 256)
1896
+ .nullable(),
1897
+ replayId: z
1898
+ .string()
1899
+ .regex(/^webhook_replay_[0-9a-hjkmnp-tv-z]{24,}$/)
1900
+ .nullable(),
1901
+ occurredAt: z.iso.datetime(),
1902
+ createdAt: z.iso.datetime(),
1903
+ })),
1904
+ hasMore: z.boolean(),
1905
+ nextCursor: z
1906
+ .string()
1907
+ .refine((text) => Array.from(text).length >= 1)
1908
+ .nullable(),
1909
+ });
1910
+ /**
1911
+ * ReplayWebhookEventsRequest
1912
+ *
1913
+ * The events to send again: either up to 100 event ids, or an occurredAfter and occurredBefore window of at most seven days that selects at most 100 events. A body naming both, or an incomplete window, answers webhook_replay_scope_invalid with a pointer at the property at fault.
1914
+ */
1915
+ export const zReplayWebhookEventsResponse = z.object({
1916
+ id: z.string().regex(/^webhook_replay_[0-9a-hjkmnp-tv-z]{24,}$/),
1917
+ object: z.literal("webhook_replay"),
1918
+ webhookEndpointId: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1919
+ deliveryCount: z.int().gte(0).lte(100),
1920
+ createdAt: z.iso.datetime(),
1921
+ });
1922
+ export const zRotateWebhookEndpointSecretResponse = z.object({
1923
+ id: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1924
+ object: z.literal("webhook_endpoint"),
1925
+ url: z.url(),
1926
+ enabledEvents: z
1927
+ .array(z
1928
+ .string()
1929
+ .refine((text) => Array.from(text).length >= 1)
1930
+ .refine((text) => Array.from(text).length <= 128))
1931
+ .min(1),
1932
+ status: lenientUnion([z.literal("active"), z.literal("suspended"), z.literal("deleted")]),
1933
+ secretCreatedAt: z.iso.datetime(),
1934
+ previousSecretExpiresAt: z.iso.datetime().nullable(),
1935
+ createdAt: z.iso.datetime(),
1936
+ secret: z.string().regex(/^whsec_[A-Za-z0-9+/]+={0,2}$/),
1937
+ });
1938
+ export const zSuspendWebhookEndpointResponse = z.object({
1939
+ id: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1940
+ object: z.literal("webhook_endpoint"),
1941
+ url: z.url(),
1942
+ enabledEvents: z
1943
+ .array(z
1944
+ .string()
1945
+ .refine((text) => Array.from(text).length >= 1)
1946
+ .refine((text) => Array.from(text).length <= 128))
1947
+ .min(1),
1948
+ status: lenientUnion([z.literal("active"), z.literal("suspended"), z.literal("deleted")]),
1949
+ secretCreatedAt: z.iso.datetime(),
1950
+ previousSecretExpiresAt: z.iso.datetime().nullable(),
1951
+ createdAt: z.iso.datetime(),
1952
+ });
1953
+ export const zReactivateWebhookEndpointResponse = z.object({
1954
+ id: z.string().regex(/^webhook_endpoint_[0-9a-hjkmnp-tv-z]{24,}$/),
1955
+ object: z.literal("webhook_endpoint"),
1956
+ url: z.url(),
1957
+ enabledEvents: z
1958
+ .array(z
1959
+ .string()
1960
+ .refine((text) => Array.from(text).length >= 1)
1961
+ .refine((text) => Array.from(text).length <= 128))
1962
+ .min(1),
1963
+ status: lenientUnion([z.literal("active"), z.literal("suspended"), z.literal("deleted")]),
1964
+ secretCreatedAt: z.iso.datetime(),
1965
+ previousSecretExpiresAt: z.iso.datetime().nullable(),
1966
+ createdAt: z.iso.datetime(),
1967
+ });