@flexprice/sdk 2.1.34 → 2.1.35

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 (121) hide show
  1. package/README.md +39 -3
  2. package/docs/sdk/models/create-customer-request.md +1 -0
  3. package/docs/sdk/models/create-subscription-request.md +1 -0
  4. package/docs/sdk/models/customer-response.md +1 -0
  5. package/docs/sdk/models/customer.md +1 -0
  6. package/docs/sdk/models/fx-conversion-source.md +18 -0
  7. package/docs/sdk/models/fx-conversion.md +21 -0
  8. package/docs/sdk/models/inline-fx-rate.md +17 -0
  9. package/docs/sdk/models/invoice-line-item-response.md +1 -0
  10. package/docs/sdk/models/invoice-response.md +1 -0
  11. package/docs/sdk/models/update-customer-request.md +1 -0
  12. package/docs/sdk/models/update-subscription-line-item-request.md +20 -18
  13. package/docs/sdk/models/update-tenant-address.md +20 -0
  14. package/docs/sdk/models/update-tenant-billing-details.md +18 -0
  15. package/docs/sdk/models/update-tenant-request.md +5 -5
  16. package/esm/hooks/auth-headers.d.ts +4 -0
  17. package/esm/hooks/auth-headers.d.ts.map +1 -0
  18. package/esm/hooks/auth-headers.js +35 -0
  19. package/esm/hooks/auth-headers.js.map +1 -0
  20. package/esm/hooks/registration.d.ts +2 -3
  21. package/esm/hooks/registration.d.ts.map +1 -1
  22. package/esm/hooks/registration.js +4 -4
  23. package/esm/hooks/registration.js.map +1 -1
  24. package/esm/lib/config.d.ts +7 -3
  25. package/esm/lib/config.d.ts.map +1 -1
  26. package/esm/lib/config.js +3 -3
  27. package/esm/lib/config.js.map +1 -1
  28. package/esm/sdk/models/address.d.ts +0 -12
  29. package/esm/sdk/models/address.d.ts.map +1 -1
  30. package/esm/sdk/models/address.js +0 -21
  31. package/esm/sdk/models/address.js.map +1 -1
  32. package/esm/sdk/models/create-customer-request.d.ts +5 -0
  33. package/esm/sdk/models/create-customer-request.d.ts.map +1 -1
  34. package/esm/sdk/models/create-customer-request.js +2 -0
  35. package/esm/sdk/models/create-customer-request.js.map +1 -1
  36. package/esm/sdk/models/create-subscription-request.d.ts +9 -0
  37. package/esm/sdk/models/create-subscription-request.d.ts.map +1 -1
  38. package/esm/sdk/models/create-subscription-request.js +3 -0
  39. package/esm/sdk/models/create-subscription-request.js.map +1 -1
  40. package/esm/sdk/models/customer-response.d.ts +4 -0
  41. package/esm/sdk/models/customer-response.d.ts.map +1 -1
  42. package/esm/sdk/models/customer-response.js +2 -0
  43. package/esm/sdk/models/customer-response.js.map +1 -1
  44. package/esm/sdk/models/customer.d.ts +4 -0
  45. package/esm/sdk/models/customer.d.ts.map +1 -1
  46. package/esm/sdk/models/customer.js +2 -0
  47. package/esm/sdk/models/customer.js.map +1 -1
  48. package/esm/sdk/models/fx-conversion-source.d.ts +13 -0
  49. package/esm/sdk/models/fx-conversion-source.d.ts.map +1 -0
  50. package/esm/sdk/models/fx-conversion-source.js +23 -0
  51. package/esm/sdk/models/fx-conversion-source.js.map +1 -0
  52. package/esm/sdk/models/fx-conversion.d.ts +33 -0
  53. package/esm/sdk/models/fx-conversion.d.ts.map +1 -0
  54. package/esm/sdk/models/fx-conversion.js +30 -0
  55. package/esm/sdk/models/fx-conversion.js.map +1 -0
  56. package/esm/sdk/models/index.d.ts +5 -0
  57. package/esm/sdk/models/index.d.ts.map +1 -1
  58. package/esm/sdk/models/index.js +5 -0
  59. package/esm/sdk/models/index.js.map +1 -1
  60. package/esm/sdk/models/inline-fx-rate.d.ts +16 -0
  61. package/esm/sdk/models/inline-fx-rate.d.ts.map +1 -0
  62. package/esm/sdk/models/inline-fx-rate.js +20 -0
  63. package/esm/sdk/models/inline-fx-rate.js.map +1 -0
  64. package/esm/sdk/models/invoice-line-item-response.d.ts +2 -0
  65. package/esm/sdk/models/invoice-line-item-response.d.ts.map +1 -1
  66. package/esm/sdk/models/invoice-line-item-response.js +3 -0
  67. package/esm/sdk/models/invoice-line-item-response.js.map +1 -1
  68. package/esm/sdk/models/invoice-response.d.ts +2 -0
  69. package/esm/sdk/models/invoice-response.d.ts.map +1 -1
  70. package/esm/sdk/models/invoice-response.js +3 -0
  71. package/esm/sdk/models/invoice-response.js.map +1 -1
  72. package/esm/sdk/models/tenant-billing-details.d.ts +1 -11
  73. package/esm/sdk/models/tenant-billing-details.d.ts.map +1 -1
  74. package/esm/sdk/models/tenant-billing-details.js +1 -15
  75. package/esm/sdk/models/tenant-billing-details.js.map +1 -1
  76. package/esm/sdk/models/update-customer-request.d.ts +5 -0
  77. package/esm/sdk/models/update-customer-request.d.ts.map +1 -1
  78. package/esm/sdk/models/update-customer-request.js +2 -0
  79. package/esm/sdk/models/update-customer-request.js.map +1 -1
  80. package/esm/sdk/models/update-subscription-line-item-request.d.ts +10 -0
  81. package/esm/sdk/models/update-subscription-line-item-request.d.ts.map +1 -1
  82. package/esm/sdk/models/update-subscription-line-item-request.js +4 -0
  83. package/esm/sdk/models/update-subscription-line-item-request.js.map +1 -1
  84. package/esm/sdk/models/update-tenant-address.d.ts +22 -0
  85. package/esm/sdk/models/update-tenant-address.d.ts.map +1 -0
  86. package/esm/sdk/models/update-tenant-address.js +27 -0
  87. package/esm/sdk/models/update-tenant-address.js.map +1 -0
  88. package/esm/sdk/models/update-tenant-billing-details.d.ts +19 -0
  89. package/esm/sdk/models/update-tenant-billing-details.d.ts.map +1 -0
  90. package/esm/sdk/models/update-tenant-billing-details.js +21 -0
  91. package/esm/sdk/models/update-tenant-billing-details.js.map +1 -0
  92. package/esm/sdk/models/update-tenant-request.d.ts +3 -3
  93. package/esm/sdk/models/update-tenant-request.d.ts.map +1 -1
  94. package/esm/sdk/models/update-tenant-request.js +2 -2
  95. package/esm/sdk/models/update-tenant-request.js.map +1 -1
  96. package/esm/types/smart-union.d.ts.map +1 -1
  97. package/esm/types/smart-union.js +13 -8
  98. package/esm/types/smart-union.js.map +1 -1
  99. package/jsr.json +1 -1
  100. package/package.json +1 -1
  101. package/src/hooks/auth-headers.ts +47 -0
  102. package/src/hooks/registration.ts +4 -4
  103. package/src/lib/config.ts +7 -3
  104. package/src/sdk/models/address.ts +0 -35
  105. package/src/sdk/models/create-customer-request.ts +7 -0
  106. package/src/sdk/models/create-subscription-request.ts +15 -0
  107. package/src/sdk/models/customer-response.ts +6 -0
  108. package/src/sdk/models/customer.ts +6 -0
  109. package/src/sdk/models/fx-conversion-source.ts +46 -0
  110. package/src/sdk/models/fx-conversion.ts +72 -0
  111. package/src/sdk/models/index.ts +5 -0
  112. package/src/sdk/models/inline-fx-rate.ts +41 -0
  113. package/src/sdk/models/invoice-line-item-response.ts +4 -0
  114. package/src/sdk/models/invoice-response.ts +4 -0
  115. package/src/sdk/models/tenant-billing-details.ts +1 -38
  116. package/src/sdk/models/update-customer-request.ts +7 -0
  117. package/src/sdk/models/update-subscription-line-item-request.ts +14 -0
  118. package/src/sdk/models/update-tenant-address.ts +58 -0
  119. package/src/sdk/models/update-tenant-billing-details.ts +52 -0
  120. package/src/sdk/models/update-tenant-request.ts +7 -7
  121. package/src/types/smart-union.ts +17 -8
@@ -15,6 +15,7 @@ import {
15
15
  CustomCurrencyLineItem,
16
16
  CustomCurrencyLineItem$inboundSchema,
17
17
  } from "./custom-currency-line-item.js";
18
+ import { FxConversion, FxConversion$inboundSchema } from "./fx-conversion.js";
18
19
  import { SDKValidationError } from "./sdk-validation-error.js";
19
20
  import {
20
21
  SourceUsageItem,
@@ -45,6 +46,7 @@ export type InvoiceLineItemResponse = {
45
46
  entityId?: string | undefined;
46
47
  entityType?: string | undefined;
47
48
  environmentId?: string | undefined;
49
+ fxConversion?: FxConversion | undefined;
48
50
  id?: string | undefined;
49
51
  invoiceId?: string | undefined;
50
52
  /**
@@ -115,6 +117,7 @@ export const InvoiceLineItemResponse$inboundSchema: z.ZodMiniType<
115
117
  entity_id: types.optional(types.string()),
116
118
  entity_type: types.optional(types.string()),
117
119
  environment_id: types.optional(types.string()),
120
+ fx_conversion: types.optional(FxConversion$inboundSchema),
118
121
  id: types.optional(types.string()),
119
122
  invoice_id: types.optional(types.string()),
120
123
  invoice_level_discount: types.optional(types.string()),
@@ -154,6 +157,7 @@ export const InvoiceLineItemResponse$inboundSchema: z.ZodMiniType<
154
157
  "entity_id": "entityId",
155
158
  "entity_type": "entityType",
156
159
  "environment_id": "environmentId",
160
+ "fx_conversion": "fxConversion",
157
161
  "invoice_id": "invoiceId",
158
162
  "invoice_level_discount": "invoiceLevelDiscount",
159
163
  "line_item_discount": "lineItemDiscount",
@@ -23,6 +23,7 @@ import {
23
23
  CustomerResponse,
24
24
  CustomerResponse$inboundSchema,
25
25
  } from "./customer-response.js";
26
+ import { FxConversion, FxConversion$inboundSchema } from "./fx-conversion.js";
26
27
  import {
27
28
  InvoiceLineItemResponse,
28
29
  InvoiceLineItemResponse$inboundSchema,
@@ -124,6 +125,7 @@ export type InvoiceResponse = {
124
125
  * finalized_at is the timestamp when this invoice was finalized and made ready for payment
125
126
  */
126
127
  finalizedAt?: Date | undefined;
128
+ fxConversion?: FxConversion | undefined;
127
129
  /**
128
130
  * id is the unique identifier for this invoice
129
131
  */
@@ -273,6 +275,7 @@ export const InvoiceResponse$inboundSchema: z.ZodMiniType<
273
275
  due_date: types.optional(types.date()),
274
276
  environment_id: types.optional(types.string()),
275
277
  finalized_at: types.optional(types.date()),
278
+ fx_conversion: types.optional(FxConversion$inboundSchema),
276
279
  id: types.optional(types.string()),
277
280
  idempotency_key: types.optional(types.string()),
278
281
  invoice_number: types.optional(types.string()),
@@ -332,6 +335,7 @@ export const InvoiceResponse$inboundSchema: z.ZodMiniType<
332
335
  "due_date": "dueDate",
333
336
  "environment_id": "environmentId",
334
337
  "finalized_at": "finalizedAt",
338
+ "fx_conversion": "fxConversion",
335
339
  "idempotency_key": "idempotencyKey",
336
340
  "invoice_number": "invoiceNumber",
337
341
  "invoice_pdf_url": "invoicePdfUrl",
@@ -7,12 +7,7 @@ import { remap as remap$ } from "../../lib/primitives.js";
7
7
  import { safeParse } from "../../lib/schemas.js";
8
8
  import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import * as types from "../../types/primitives.js";
10
- import {
11
- Address,
12
- Address$inboundSchema,
13
- Address$Outbound,
14
- Address$outboundSchema,
15
- } from "./address.js";
10
+ import { Address, Address$inboundSchema } from "./address.js";
16
11
  import { SDKValidationError } from "./sdk-validation-error.js";
17
12
 
18
13
  export type TenantBillingDetails = {
@@ -39,39 +34,7 @@ export const TenantBillingDetails$inboundSchema: z.ZodMiniType<
39
34
  });
40
35
  }),
41
36
  );
42
- /** @internal */
43
- export type TenantBillingDetails$Outbound = {
44
- address?: Address$Outbound | undefined;
45
- email?: string | undefined;
46
- help_email?: string | undefined;
47
- phone?: string | undefined;
48
- };
49
-
50
- /** @internal */
51
- export const TenantBillingDetails$outboundSchema: z.ZodMiniType<
52
- TenantBillingDetails$Outbound,
53
- TenantBillingDetails
54
- > = z.pipe(
55
- z.object({
56
- address: z.optional(Address$outboundSchema),
57
- email: z.optional(z.string()),
58
- helpEmail: z.optional(z.string()),
59
- phone: z.optional(z.string()),
60
- }),
61
- z.transform((v) => {
62
- return remap$(v, {
63
- helpEmail: "help_email",
64
- });
65
- }),
66
- );
67
37
 
68
- export function tenantBillingDetailsToJSON(
69
- tenantBillingDetails: TenantBillingDetails,
70
- ): string {
71
- return JSON.stringify(
72
- TenantBillingDetails$outboundSchema.parse(tenantBillingDetails),
73
- );
74
- }
75
38
  export function tenantBillingDetailsFromJSON(
76
39
  jsonString: string,
77
40
  ): SafeParseResult<TenantBillingDetails, SDKValidationError> {
@@ -39,6 +39,10 @@ export type UpdateCustomerRequest = {
39
39
  * address_state is the updated state, province, or region name with maximum 100 characters
40
40
  */
41
41
  addressState?: string | undefined;
42
+ /**
43
+ * billing_currency updates the invoicing currency; send "" to clear it back to the charge currency
44
+ */
45
+ billingCurrency?: string | undefined;
42
46
  /**
43
47
  * contact is the updated contact number for the customer (e.g. phone)
44
48
  */
@@ -80,6 +84,7 @@ export type UpdateCustomerRequest$Outbound = {
80
84
  address_line2?: string | undefined;
81
85
  address_postal_code?: string | undefined;
82
86
  address_state?: string | undefined;
87
+ billing_currency?: string | undefined;
83
88
  contact?: string | undefined;
84
89
  email?: string | undefined;
85
90
  external_id?: string | undefined;
@@ -104,6 +109,7 @@ export const UpdateCustomerRequest$outboundSchema: z.ZodMiniType<
104
109
  addressLine2: z.optional(z.string()),
105
110
  addressPostalCode: z.optional(z.string()),
106
111
  addressState: z.optional(z.string()),
112
+ billingCurrency: z.optional(z.string()),
107
113
  contact: z.optional(z.string()),
108
114
  email: z.optional(z.string()),
109
115
  externalId: z.optional(z.string()),
@@ -123,6 +129,7 @@ export const UpdateCustomerRequest$outboundSchema: z.ZodMiniType<
123
129
  addressLine2: "address_line2",
124
130
  addressPostalCode: "address_postal_code",
125
131
  addressState: "address_state",
132
+ billingCurrency: "billing_currency",
126
133
  externalId: "external_id",
127
134
  integrationEntityMapping: "integration_entity_mapping",
128
135
  taxTreatment: "tax_treatment",
@@ -60,6 +60,14 @@ export type UpdateSubscriptionLineItemRequest = {
60
60
  * Metadata for the new line item
61
61
  */
62
62
  metadata?: { [k: string]: string } | undefined;
63
+ /**
64
+ * PriceUnitAmount is the amount for a CUSTOM price unit price (FLAT_FEE/PACKAGE billing models)
65
+ */
66
+ priceUnitAmount?: string | undefined;
67
+ /**
68
+ * PriceUnitTiers are the tiers for a CUSTOM price unit price (TIERED billing model)
69
+ */
70
+ priceUnitTiers?: Array<CreatePriceTier> | undefined;
63
71
  tierMode?: BillingTier | undefined;
64
72
  /**
65
73
  * Tiers determines the pricing tiers for this line item
@@ -83,6 +91,8 @@ export type UpdateSubscriptionLineItemRequest$Outbound = {
83
91
  commitment_windowed?: boolean | undefined;
84
92
  effective_from?: string | undefined;
85
93
  metadata?: { [k: string]: string } | undefined;
94
+ price_unit_amount?: string | undefined;
95
+ price_unit_tiers?: Array<CreatePriceTier$Outbound> | undefined;
86
96
  tier_mode?: string | undefined;
87
97
  tiers?: Array<CreatePriceTier$Outbound> | undefined;
88
98
  transform_quantity?: PriceTransformQuantity$Outbound | undefined;
@@ -109,6 +119,8 @@ export const UpdateSubscriptionLineItemRequest$outboundSchema: z.ZodMiniType<
109
119
  commitmentWindowed: z.optional(z.boolean()),
110
120
  effectiveFrom: z.optional(z.string()),
111
121
  metadata: z.optional(z.record(z.string(), z.string())),
122
+ priceUnitAmount: z.optional(z.string()),
123
+ priceUnitTiers: z.optional(z.array(CreatePriceTier$outboundSchema)),
112
124
  tierMode: z.optional(BillingTier$outboundSchema),
113
125
  tiers: z.optional(z.array(CreatePriceTier$outboundSchema)),
114
126
  transformQuantity: z.optional(PriceTransformQuantity$outboundSchema),
@@ -126,6 +138,8 @@ export const UpdateSubscriptionLineItemRequest$outboundSchema: z.ZodMiniType<
126
138
  commitmentType: "commitment_type",
127
139
  commitmentWindowed: "commitment_windowed",
128
140
  effectiveFrom: "effective_from",
141
+ priceUnitAmount: "price_unit_amount",
142
+ priceUnitTiers: "price_unit_tiers",
129
143
  tierMode: "tier_mode",
130
144
  transformQuantity: "transform_quantity",
131
145
  });
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+
8
+ export type UpdateTenantAddress = {
9
+ addressCity?: string | undefined;
10
+ addressCountry?: string | undefined;
11
+ addressLine1?: string | undefined;
12
+ addressLine2?: string | undefined;
13
+ addressPostalCode?: string | undefined;
14
+ addressState?: string | undefined;
15
+ };
16
+
17
+ /** @internal */
18
+ export type UpdateTenantAddress$Outbound = {
19
+ address_city?: string | undefined;
20
+ address_country?: string | undefined;
21
+ address_line1?: string | undefined;
22
+ address_line2?: string | undefined;
23
+ address_postal_code?: string | undefined;
24
+ address_state?: string | undefined;
25
+ };
26
+
27
+ /** @internal */
28
+ export const UpdateTenantAddress$outboundSchema: z.ZodMiniType<
29
+ UpdateTenantAddress$Outbound,
30
+ UpdateTenantAddress
31
+ > = z.pipe(
32
+ z.object({
33
+ addressCity: z.optional(z.string()),
34
+ addressCountry: z.optional(z.string()),
35
+ addressLine1: z.optional(z.string()),
36
+ addressLine2: z.optional(z.string()),
37
+ addressPostalCode: z.optional(z.string()),
38
+ addressState: z.optional(z.string()),
39
+ }),
40
+ z.transform((v) => {
41
+ return remap$(v, {
42
+ addressCity: "address_city",
43
+ addressCountry: "address_country",
44
+ addressLine1: "address_line1",
45
+ addressLine2: "address_line2",
46
+ addressPostalCode: "address_postal_code",
47
+ addressState: "address_state",
48
+ });
49
+ }),
50
+ );
51
+
52
+ export function updateTenantAddressToJSON(
53
+ updateTenantAddress: UpdateTenantAddress,
54
+ ): string {
55
+ return JSON.stringify(
56
+ UpdateTenantAddress$outboundSchema.parse(updateTenantAddress),
57
+ );
58
+ }
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import {
8
+ UpdateTenantAddress,
9
+ UpdateTenantAddress$Outbound,
10
+ UpdateTenantAddress$outboundSchema,
11
+ } from "./update-tenant-address.js";
12
+
13
+ export type UpdateTenantBillingDetails = {
14
+ address?: UpdateTenantAddress | undefined;
15
+ email?: string | undefined;
16
+ helpEmail?: string | undefined;
17
+ phone?: string | undefined;
18
+ };
19
+
20
+ /** @internal */
21
+ export type UpdateTenantBillingDetails$Outbound = {
22
+ address?: UpdateTenantAddress$Outbound | undefined;
23
+ email?: string | undefined;
24
+ help_email?: string | undefined;
25
+ phone?: string | undefined;
26
+ };
27
+
28
+ /** @internal */
29
+ export const UpdateTenantBillingDetails$outboundSchema: z.ZodMiniType<
30
+ UpdateTenantBillingDetails$Outbound,
31
+ UpdateTenantBillingDetails
32
+ > = z.pipe(
33
+ z.object({
34
+ address: z.optional(UpdateTenantAddress$outboundSchema),
35
+ email: z.optional(z.string()),
36
+ helpEmail: z.optional(z.string()),
37
+ phone: z.optional(z.string()),
38
+ }),
39
+ z.transform((v) => {
40
+ return remap$(v, {
41
+ helpEmail: "help_email",
42
+ });
43
+ }),
44
+ );
45
+
46
+ export function updateTenantBillingDetailsToJSON(
47
+ updateTenantBillingDetails: UpdateTenantBillingDetails,
48
+ ): string {
49
+ return JSON.stringify(
50
+ UpdateTenantBillingDetails$outboundSchema.parse(updateTenantBillingDetails),
51
+ );
52
+ }
@@ -5,20 +5,20 @@
5
5
  import * as z from "zod/v4-mini";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
7
  import {
8
- TenantBillingDetails,
9
- TenantBillingDetails$Outbound,
10
- TenantBillingDetails$outboundSchema,
11
- } from "./tenant-billing-details.js";
8
+ UpdateTenantBillingDetails,
9
+ UpdateTenantBillingDetails$Outbound,
10
+ UpdateTenantBillingDetails$outboundSchema,
11
+ } from "./update-tenant-billing-details.js";
12
12
 
13
13
  export type UpdateTenantRequest = {
14
- billingDetails?: TenantBillingDetails | undefined;
14
+ billingDetails?: UpdateTenantBillingDetails | undefined;
15
15
  metadata?: { [k: string]: string } | undefined;
16
16
  name?: string | undefined;
17
17
  };
18
18
 
19
19
  /** @internal */
20
20
  export type UpdateTenantRequest$Outbound = {
21
- billing_details?: TenantBillingDetails$Outbound | undefined;
21
+ billing_details?: UpdateTenantBillingDetails$Outbound | undefined;
22
22
  metadata?: { [k: string]: string } | undefined;
23
23
  name?: string | undefined;
24
24
  };
@@ -29,7 +29,7 @@ export const UpdateTenantRequest$outboundSchema: z.ZodMiniType<
29
29
  UpdateTenantRequest
30
30
  > = z.pipe(
31
31
  z.object({
32
- billingDetails: z.optional(TenantBillingDetails$outboundSchema),
32
+ billingDetails: z.optional(UpdateTenantBillingDetails$outboundSchema),
33
33
  metadata: z.optional(z.record(z.string(), z.string())),
34
34
  name: z.optional(z.string()),
35
35
  }),
@@ -31,28 +31,33 @@ export function smartUnion<
31
31
  z.unknown(),
32
32
  z.transform((input, ctx) => {
33
33
  const candidates: Candidate[] = [];
34
- const errors: z.core.$ZodIssue[][] = options.map(() => []);
34
+ const errors: z.core.$ZodRawIssue[][] = [];
35
35
 
36
36
  const parentUnrecognizedCtr = startCountingUnrecognized();
37
37
  const parentZeroDefaultCtr = startCountingDefaultToZeroValue();
38
38
 
39
39
  // Filter out invalid options
40
- for (const [i, option] of options.entries()) {
40
+ for (const option of options) {
41
41
  const unrecognizedCtr = startCountingUnrecognized();
42
42
  const zeroDefaultCtr = startCountingDefaultToZeroValue();
43
- const result = option.safeParse(input);
43
+ const result = option._zod.run({ value: input, issues: [] }, {
44
+ async: false,
45
+ });
46
+ if (result instanceof Promise) {
47
+ throw new z.core.$ZodAsyncError();
48
+ }
44
49
  const inexactCount = unrecognizedCtr.end();
45
50
  const zeroDefaultCount = zeroDefaultCtr.end();
46
- if (result.success) {
51
+ if (result.issues.length === 0) {
47
52
  candidates.push({
48
- data: result.data,
53
+ data: result.value,
49
54
  inexactCount,
50
55
  zeroDefaultCount,
51
56
  fieldCount: -1, // We'll count this later if needed
52
57
  });
53
58
  continue;
54
59
  }
55
- errors[i]!.push(...result.error.issues);
60
+ errors.push(result.issues);
56
61
  }
57
62
 
58
63
  // No valid options
@@ -62,9 +67,13 @@ export function smartUnion<
62
67
  ctx.issues.push({
63
68
  input: input,
64
69
  code: "invalid_union",
65
- errors: errors,
70
+ errors: errors.map(issues =>
71
+ issues.map(issue =>
72
+ z.core.util.finalizeIssue(issue, {}, z.core.config())
73
+ )
74
+ ),
66
75
  });
67
- return z.NEVER;
76
+ return undefined;
68
77
  }
69
78
 
70
79
  let best = candidates[0]!;