@fanfare-io/fanfare-sdk-contracts 0.11.0 → 0.13.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.
package/README.md CHANGED
@@ -17,6 +17,16 @@ npm install @fanfare-io/fanfare-sdk-contracts
17
17
  - [Website](https://www.fanfare.io)
18
18
  - [Source & issues](https://github.com/fanfare-io/fanfare-sdk)
19
19
 
20
+ ## Response schema compatibility
21
+
22
+ Choose the Valibot object mode based on the compatibility contract of the payload:
23
+
24
+ - `v.strictObject` rejects unknown keys. Use it only for deliberately closed contracts, and document why additive server fields must be rejected.
25
+ - `v.object` validates known fields and strips unknown keys. Use it when callers should remain compatible with additive fields but should not receive them.
26
+ - `v.looseObject` validates known fields and preserves unknown keys. Use it when forward-compatible fields must survive validation.
27
+
28
+ This choice is made per endpoint and may differ between a response root and its nested objects. SDK response parsing validates server payloads at runtime, so tightening a nested object can turn an otherwise additive server change into a client-visible validation failure. Treat such changes as coordinated contract changes rather than incidental schema cleanup.
29
+
20
30
  ## License
21
31
 
22
32
  [Apache-2.0](./LICENSE)
package/dist/auction.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare const AuctionBidderStateResponseSchema: v.LooseObjectSchema<{
6
6
  readonly winningBidAmount: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
7
7
  readonly bidCount: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
8
8
  readonly admissionGrant: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
9
+ readonly degraded: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
9
10
  }, undefined>;
10
11
  export type AuctionBidderStateResponse = InferOutput<typeof AuctionBidderStateResponseSchema>;
11
12
  export declare const AuctionHighestBidResponseSchema: v.LooseObjectSchema<{
package/dist/auction.js CHANGED
@@ -1,17 +1,21 @@
1
- import * as t from "valibot";
2
- const n = t.string(), o = t.pipe(n, t.regex(/^\d{1,12}(\.\d{1,8})?$/)), e = t.picklist(["NOT_BID", "BIDDING", "WINNING", "OUTBID", "WON", "LOST"]), s = t.looseObject({
3
- status: e,
4
- lastBidAmount: t.nullish(o),
5
- winningBidAmount: t.optional(o),
6
- bidCount: t.optional(t.number()),
7
- admissionGrant: t.optional(n)
8
- }), a = t.looseObject({
9
- amount: o
10
- }), i = t.looseObject({
11
- amount: o,
12
- timestamp: n,
13
- isHighest: t.boolean()
14
- }), c = t.array(i);
1
+ import * as o from "valibot";
2
+ const e = o.string(), t = o.pipe(e, o.regex(/^\d{1,12}(\.\d{1,8})?$/)), n = o.picklist(["NOT_BID", "BIDDING", "WINNING", "OUTBID", "WON", "LOST"]), s = o.looseObject({
3
+ status: n,
4
+ lastBidAmount: o.nullish(t),
5
+ winningBidAmount: o.optional(t),
6
+ bidCount: o.optional(o.number()),
7
+ admissionGrant: o.optional(e),
8
+ // The bid is committed, but a post-commit effect (event fan-out, credential mint) did not
9
+ // complete on this request. The standing is authoritative; a later status read reconciles
10
+ // whatever the effect would have projected.
11
+ degraded: o.optional(o.boolean())
12
+ }), a = o.looseObject({
13
+ amount: t
14
+ }), i = o.looseObject({
15
+ amount: t,
16
+ timestamp: e,
17
+ isHighest: o.boolean()
18
+ }), c = o.array(i);
15
19
  export {
16
20
  i as AuctionBidHistoryItemResponseSchema,
17
21
  c as AuctionBidHistoryResponseSchema,
@@ -0,0 +1,168 @@
1
+ import { DistributionType, SequenceOutcomeType } from './consumer-me';
2
+ /**
3
+ * Name of the DOM `CustomEvent` dispatched whenever the journey's projected
4
+ * state changes.
5
+ *
6
+ * One event name covers the whole journey: granted and ended are phase edges
7
+ * within it, not separate events.
8
+ */
9
+ export declare const FANFARE_STATE_CHANGE_EVENT: "fanfare:state-change";
10
+ /**
11
+ * Version of the {@link FanfareStateChangeDetail} payload.
12
+ *
13
+ * Bumped only on a breaking payload change; additive fields leave it alone.
14
+ * Consumers compare `detail.version === 1` and ignore versions they do not
15
+ * recognise.
16
+ */
17
+ export declare const BRIDGE_EVENT_VERSION = 1;
18
+ /** Fields every payload arm carries, whatever the journey stage. */
19
+ interface FanfareStateChangeBase {
20
+ /** Payload version; compare against `1` and ignore unrecognised versions. */
21
+ version: number;
22
+ /** Experience the payload describes; the attribution key across shadow roots. */
23
+ experienceId: string;
24
+ }
25
+ /** The journey exists and has not started routing. */
26
+ export interface FanfareReadyDetail extends FanfareStateChangeBase {
27
+ /** Journey stage discriminator. */
28
+ stage: "ready";
29
+ }
30
+ /** The journey is resolving which sequence the consumer belongs to. */
31
+ export interface FanfareRoutingDetail extends FanfareStateChangeBase {
32
+ /** Journey stage discriminator. */
33
+ stage: "routing";
34
+ }
35
+ /** The journey is held behind a gate the consumer has not cleared. */
36
+ export interface FanfareGatedDetail extends FanfareStateChangeBase {
37
+ /** Journey stage discriminator. */
38
+ stage: "gated";
39
+ }
40
+ /** The routed sequence offers nothing for this consumer; no mechanism is reported. */
41
+ export interface FanfareUnavailableDetail extends FanfareStateChangeBase {
42
+ /** Journey stage discriminator. */
43
+ stage: "routed";
44
+ /** Sequence phase discriminator. */
45
+ phase: "unavailable";
46
+ }
47
+ /** The routed sequence has not opened yet. */
48
+ export interface FanfareScheduledDetail extends FanfareStateChangeBase {
49
+ /** Journey stage discriminator. */
50
+ stage: "routed";
51
+ /** Sequence phase discriminator. */
52
+ phase: "scheduled";
53
+ /** Distribution mechanism of the routed sequence. */
54
+ mechanism?: DistributionType;
55
+ }
56
+ /** The routed sequence is open and the consumer may enter. */
57
+ export interface FanfareEnterableDetail extends FanfareStateChangeBase {
58
+ /** Journey stage discriminator. */
59
+ stage: "routed";
60
+ /** Sequence phase discriminator. */
61
+ phase: "enterable";
62
+ /** Distribution mechanism of the routed sequence. */
63
+ mechanism?: DistributionType;
64
+ }
65
+ /**
66
+ * The consumer is participating in a queue.
67
+ *
68
+ * The only arm carrying `position`: queue is the sole mechanism whose consumer
69
+ * state reports one.
70
+ */
71
+ export interface FanfareQueueParticipatingDetail extends FanfareStateChangeBase {
72
+ /** Journey stage discriminator. */
73
+ stage: "routed";
74
+ /** Sequence phase discriminator. */
75
+ phase: "participating";
76
+ /** Distribution mechanism discriminator. */
77
+ mechanism: "queue";
78
+ /** Live queue position, when the server reports one. Event-carried only — never stamped. */
79
+ position?: number;
80
+ }
81
+ /** The consumer is participating in a sequence whose mechanism reports no position. */
82
+ export interface FanfareParticipatingDetail extends FanfareStateChangeBase {
83
+ /** Journey stage discriminator. */
84
+ stage: "routed";
85
+ /** Sequence phase discriminator. */
86
+ phase: "participating";
87
+ /** Distribution mechanism of the routed sequence. */
88
+ mechanism?: Exclude<DistributionType, "queue">;
89
+ }
90
+ /** The sequence has closed and is resolving its outcome. */
91
+ export interface FanfareSettlingDetail extends FanfareStateChangeBase {
92
+ /** Journey stage discriminator. */
93
+ stage: "routed";
94
+ /** Sequence phase discriminator. */
95
+ phase: "settling";
96
+ /** Distribution mechanism of the routed sequence. */
97
+ mechanism?: DistributionType;
98
+ }
99
+ /** The consumer holds a reservation and must complete checkout before it expires. */
100
+ export interface FanfareReservedDetail extends FanfareStateChangeBase {
101
+ /** Journey stage discriminator. */
102
+ stage: "routed";
103
+ /** Sequence phase discriminator. */
104
+ phase: "reserved";
105
+ /** Distribution mechanism of the routed sequence. */
106
+ mechanism?: DistributionType;
107
+ /**
108
+ * Reservation expiry as epoch milliseconds.
109
+ *
110
+ * Absent — rather than `NaN`, `0` or `null` — whenever the server sent a
111
+ * value that could not be parsed into a timestamp.
112
+ */
113
+ expiresAt?: number;
114
+ }
115
+ /** The consumer has been admitted and holds a grant. */
116
+ export interface FanfareGrantedDetail extends FanfareStateChangeBase {
117
+ /** Journey stage discriminator. */
118
+ stage: "routed";
119
+ /** Sequence phase discriminator. */
120
+ phase: "granted";
121
+ /** Distribution mechanism of the routed sequence. */
122
+ mechanism?: DistributionType;
123
+ /**
124
+ * Grant expiry as epoch milliseconds.
125
+ *
126
+ * Absent — rather than `NaN`, `0` or `null` — whenever the server sent a
127
+ * value that could not be parsed into a timestamp.
128
+ */
129
+ expiresAt?: number;
130
+ }
131
+ /** The sequence is terminal for this consumer. */
132
+ export interface FanfareEndedDetail extends FanfareStateChangeBase {
133
+ /** Journey stage discriminator. */
134
+ stage: "routed";
135
+ /** Sequence phase discriminator. */
136
+ phase: "ended";
137
+ /** Distribution mechanism of the routed sequence. */
138
+ mechanism?: DistributionType;
139
+ /**
140
+ * Terminal outcome; the only arm that carries one.
141
+ *
142
+ * Carries the outcome type alone: the type is a closed picklist, while any
143
+ * accompanying qualifier is unbounded free text that a caller can supply, and
144
+ * this payload reaches every script on the page.
145
+ */
146
+ outcome: {
147
+ /** Terminal outcome type. */
148
+ type: SequenceOutcomeType;
149
+ };
150
+ }
151
+ /**
152
+ * `detail` of a {@link FANFARE_STATE_CHANGE_EVENT} event.
153
+ *
154
+ * Discriminated on `stage`, and within `routed` on `phase`, so a field only
155
+ * exists where it is meaningful: `outcome` on the ended arm, `expiresAt` on the
156
+ * granted and reserved arms, `position` on the participating queue arm. There
157
+ * is no arm for the absence of a journey — a payload is only ever built from a
158
+ * journey that exists.
159
+ */
160
+ export type FanfareStateChangeDetail = FanfareReadyDetail | FanfareRoutingDetail | FanfareGatedDetail | FanfareUnavailableDetail | FanfareScheduledDetail | FanfareEnterableDetail | FanfareQueueParticipatingDetail | FanfareParticipatingDetail | FanfareSettlingDetail | FanfareReservedDetail | FanfareGrantedDetail | FanfareEndedDetail;
161
+ /**
162
+ * The DOM event carrying a {@link FanfareStateChangeDetail}.
163
+ *
164
+ * Used to narrow inside a listener — `(e as FanfareStateChangeEvent).detail` —
165
+ * because no global event-map augmentation ships with this package.
166
+ */
167
+ export type FanfareStateChangeEvent = CustomEvent<FanfareStateChangeDetail>;
168
+ export {};
package/dist/bridge.js ADDED
@@ -0,0 +1,5 @@
1
+ const E = "fanfare:state-change", t = 1;
2
+ export {
3
+ t as BRIDGE_EVENT_VERSION,
4
+ E as FANFARE_STATE_CHANGE_EVENT
5
+ };
@@ -0,0 +1,177 @@
1
+ import { InferInput, InferOutput } from 'valibot';
2
+ import * as v from "valibot";
3
+ export declare const MoneyStringSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.number">]>;
4
+ export declare const CurrencyCodeSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.pattern">]>;
5
+ /**
6
+ * How Fanfare handles payment for a distribution's winners.
7
+ *
8
+ * Omitted (or `undefined` on the wire) means `"merchant"` — the default: the
9
+ * merchant's own checkout collects payment after admission, outside Fanfare's purview.
10
+ */
11
+ export declare const DistributionCheckoutMode: {
12
+ readonly MERCHANT: "merchant";
13
+ readonly PRE_AUTH: "pre_auth";
14
+ readonly POST_WIN: "post_win";
15
+ };
16
+ export declare const DistributionCheckoutModes: readonly ["merchant", "pre_auth", "post_win"];
17
+ export type DistributionCheckoutMode = (typeof DistributionCheckoutModes)[number];
18
+ export declare const DistributionCheckoutModeSchema: v.PicklistSchema<readonly ["merchant", "pre_auth", "post_win"], undefined>;
19
+ /**
20
+ * Who executes the payment leg for a distribution. Orthogonal to `DistributionCheckoutMode`,
21
+ * which says WHEN settlement happens relative to winning; this says WHO moves the money.
22
+ * Fanfare's own processor is the only value today. A processor that hands the consumer off to
23
+ * an external checkout adds a value here and an arm to every discriminated union keyed on it —
24
+ * processor-specific fields are never hoisted alongside another processor's.
25
+ */
26
+ export declare const CheckoutProcessor: {
27
+ readonly INTERNAL: "internal";
28
+ };
29
+ export declare const CheckoutProcessors: readonly ["internal"];
30
+ export type CheckoutProcessor = (typeof CheckoutProcessors)[number];
31
+ export declare const CheckoutProcessorSchema: v.PicklistSchema<readonly ["internal"], undefined>;
32
+ /**
33
+ * What the client must do to finish a payment the processor paused (a bank authentication
34
+ * challenge). Discriminated by processor: the `internal` arm carries the payment-intent client
35
+ * secret the browser hands to Stripe.js; another processor would carry its own hand-off shape.
36
+ * Never flatten an arm's fields onto a carrier — callers narrow on `processor` first.
37
+ */
38
+ export declare const CheckoutNextActionSchema: v.VariantSchema<"processor", [v.ObjectSchema<{
39
+ readonly processor: v.LiteralSchema<"internal", undefined>;
40
+ readonly clientSecret: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
41
+ }, undefined>], undefined>;
42
+ export type CheckoutNextAction = InferOutput<typeof CheckoutNextActionSchema>;
43
+ /**
44
+ * The client-side configuration Fanfare's internal processor needs in the browser: the
45
+ * publishable key that identifies the platform account, and the connected account a Connect
46
+ * direct charge runs on when one applies.
47
+ *
48
+ * The processor discriminator is the affordance's own `processor` field and the distribution's
49
+ * checkout mode — never this block's presence: on a checkout-capable arm an absent block can
50
+ * only mean the configuration read failed, and the client must render retryable payment
51
+ * unavailability, not infer a different processor. A merchant-mode view carries no payment
52
+ * affordance at all. Nothing here is a secret: a publishable key and an account id are client-visible by
53
+ * design. No secret key, no client secret, and no payment-intent id ever belongs in this block.
54
+ */
55
+ export declare const PaymentProviderConfigSchema: v.ObjectSchema<{
56
+ readonly publishableKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
57
+ readonly stripeAccount: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
58
+ }, undefined>;
59
+ export type PaymentProviderConfig = InferOutput<typeof PaymentProviderConfigSchema>;
60
+ /**
61
+ * Alternative body a `pre_auth` distribution-entry call returns when the processor paused the
62
+ * authorization pending an out-of-band action. Entry is fail-closed: this response means the
63
+ * consumer is NOT in the distribution. Completing the action and re-submitting the same entry
64
+ * call resolves it; entry authorization is idempotent per (organization, consumer, distribution).
65
+ */
66
+ export declare const DistributionEntryRequiresActionSchema: v.ObjectSchema<{
67
+ readonly outcome: v.LiteralSchema<"requires_action", undefined>;
68
+ readonly nextAction: v.VariantSchema<"processor", [v.ObjectSchema<{
69
+ readonly processor: v.LiteralSchema<"internal", undefined>;
70
+ readonly clientSecret: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
71
+ }, undefined>], undefined>;
72
+ }, undefined>;
73
+ export type DistributionEntryRequiresAction = InferOutput<typeof DistributionEntryRequiresActionSchema>;
74
+ export declare const PaymentInputSchema: v.VariantSchema<"type", [v.ObjectSchema<{
75
+ readonly type: v.LiteralSchema<"saved", undefined>;
76
+ readonly paymentMethodId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
77
+ }, undefined>, v.ObjectSchema<{
78
+ readonly type: v.LiteralSchema<"new", undefined>;
79
+ readonly stripePaymentMethodId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
80
+ }, undefined>], undefined>;
81
+ export type PaymentInput = InferInput<typeof PaymentInputSchema>;
82
+ export declare const PaymentMethodSummarySchema: v.ObjectSchema<{
83
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
84
+ readonly brand: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
85
+ readonly last4: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 4, undefined>]>;
86
+ readonly expiryMonth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 12, undefined>]>;
87
+ readonly expiryYear: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 2000, undefined>]>;
88
+ readonly isDefault: v.BooleanSchema<undefined>;
89
+ }, undefined>;
90
+ export type PaymentMethodSummary = InferOutput<typeof PaymentMethodSummarySchema>;
91
+ /**
92
+ * Fanfare's receipt for a payment it captured directly (`pre_auth`/`post_win` modes).
93
+ * Carried on the successful sequence variant so the consumer surface can render a receipt
94
+ * without a second round-trip. `amount` stays a string — money is never a float on the wire.
95
+ */
96
+ export declare const FanfareCheckoutResultSchema: v.ObjectSchema<{
97
+ readonly orderId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
98
+ readonly amount: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.number">]>;
99
+ readonly currencyCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.pattern">]>;
100
+ readonly paymentMethodLast4: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 4, undefined>]>, undefined>;
101
+ readonly paymentMethodBrand: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
102
+ }, undefined>;
103
+ export type FanfareCheckoutResult = InferOutput<typeof FanfareCheckoutResultSchema>;
104
+ export declare const ReservationCheckoutOutcomes: readonly ["completed", "requires_action"];
105
+ export type ReservationCheckoutOutcome = (typeof ReservationCheckoutOutcomes)[number];
106
+ /**
107
+ * A reservation checkout that finished: the payment settled and produced an order. The order
108
+ * reference IS the outcome — paying a post-win window ends the journey rather than issuing
109
+ * admission, so there is deliberately no credential here to mint or to carry.
110
+ */
111
+ export declare const ReservationCheckoutCompletedSchema: v.ObjectSchema<{
112
+ readonly outcome: v.LiteralSchema<"completed", undefined>;
113
+ readonly checkout: v.ObjectSchema<{
114
+ readonly orderId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
115
+ readonly amount: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.number">]>;
116
+ readonly currencyCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.pattern">]>;
117
+ readonly paymentMethodLast4: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 4, undefined>]>, undefined>;
118
+ readonly paymentMethodBrand: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
119
+ }, undefined>;
120
+ }, undefined>;
121
+ export type ReservationCheckoutCompleted = InferOutput<typeof ReservationCheckoutCompletedSchema>;
122
+ /**
123
+ * A reservation checkout the processor paused pending an out-of-band action. The reservation is
124
+ * still live and still owns its own deadline; completing the action and re-submitting the SAME
125
+ * confirm resolves it — the server is idempotent, so a retry never produces a second order.
126
+ */
127
+ export declare const ReservationCheckoutRequiresActionSchema: v.ObjectSchema<{
128
+ readonly outcome: v.LiteralSchema<"requires_action", undefined>;
129
+ readonly nextAction: v.VariantSchema<"processor", [v.ObjectSchema<{
130
+ readonly processor: v.LiteralSchema<"internal", undefined>;
131
+ readonly clientSecret: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
132
+ }, undefined>], undefined>;
133
+ }, undefined>;
134
+ export type ReservationCheckoutRequiresAction = InferOutput<typeof ReservationCheckoutRequiresActionSchema>;
135
+ /** Response to confirming checkout on a `post_win` reservation, discriminated on `outcome`. */
136
+ export declare const ReservationCheckoutResponseSchema: v.VariantSchema<"outcome", [v.ObjectSchema<{
137
+ readonly outcome: v.LiteralSchema<"completed", undefined>;
138
+ readonly checkout: v.ObjectSchema<{
139
+ readonly orderId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
140
+ readonly amount: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.number">]>;
141
+ readonly currencyCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "validation.pattern">]>;
142
+ readonly paymentMethodLast4: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 4, undefined>]>, undefined>;
143
+ readonly paymentMethodBrand: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
144
+ }, undefined>;
145
+ }, undefined>, v.ObjectSchema<{
146
+ readonly outcome: v.LiteralSchema<"requires_action", undefined>;
147
+ readonly nextAction: v.VariantSchema<"processor", [v.ObjectSchema<{
148
+ readonly processor: v.LiteralSchema<"internal", undefined>;
149
+ readonly clientSecret: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
150
+ }, undefined>], undefined>;
151
+ }, undefined>], undefined>;
152
+ export type ReservationCheckoutResponse = InferOutput<typeof ReservationCheckoutResponseSchema>;
153
+ export declare const PaymentMethodsListResponseSchema: v.ObjectSchema<{
154
+ readonly paymentMethods: v.ArraySchema<v.ObjectSchema<{
155
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
156
+ readonly brand: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
157
+ readonly last4: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 4, undefined>]>;
158
+ readonly expiryMonth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 12, undefined>]>;
159
+ readonly expiryYear: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 2000, undefined>]>;
160
+ readonly isDefault: v.BooleanSchema<undefined>;
161
+ }, undefined>, undefined>;
162
+ }, undefined>;
163
+ export type PaymentMethodsListResponse = InferOutput<typeof PaymentMethodsListResponseSchema>;
164
+ export declare const AddPaymentMethodRequestSchema: v.ObjectSchema<{
165
+ readonly stripePaymentMethodId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
166
+ }, undefined>;
167
+ export type AddPaymentMethodRequest = InferInput<typeof AddPaymentMethodRequestSchema>;
168
+ /** Response to adding a payment method — reuses {@link PaymentMethodSummarySchema} directly. */
169
+ export declare const AddPaymentMethodResponseSchema: v.ObjectSchema<{
170
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
171
+ readonly brand: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
172
+ readonly last4: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.LengthAction<string, 4, undefined>]>;
173
+ readonly expiryMonth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 12, undefined>]>;
174
+ readonly expiryYear: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 2000, undefined>]>;
175
+ readonly isDefault: v.BooleanSchema<undefined>;
176
+ }, undefined>;
177
+ export type AddPaymentMethodResponse = InferOutput<typeof AddPaymentMethodResponseSchema>;
@@ -0,0 +1,81 @@
1
+ import * as e from "valibot";
2
+ const t = e.string(), a = e.pipe(t, e.regex(/^\d{1,12}(\.\d{1,8})?$/, "validation.number")), r = e.pipe(t, e.regex(/^[A-Z]{3}$/, "validation.pattern")), o = {
3
+ MERCHANT: "merchant",
4
+ PRE_AUTH: "pre_auth",
5
+ POST_WIN: "post_win"
6
+ }, s = [
7
+ o.MERCHANT,
8
+ o.PRE_AUTH,
9
+ o.POST_WIN
10
+ ], d = e.picklist(s), n = {
11
+ INTERNAL: "internal"
12
+ }, p = [n.INTERNAL], l = e.picklist(p), i = e.variant("processor", [
13
+ e.object({
14
+ processor: e.literal(n.INTERNAL),
15
+ clientSecret: e.pipe(t, e.minLength(1))
16
+ })
17
+ ]), y = e.object({
18
+ publishableKey: e.pipe(t, e.minLength(1)),
19
+ stripeAccount: e.optional(e.pipe(t, e.minLength(1)))
20
+ }), S = e.object({
21
+ outcome: e.literal("requires_action"),
22
+ nextAction: i
23
+ }), b = e.variant("type", [
24
+ e.object({
25
+ type: e.literal("saved"),
26
+ paymentMethodId: e.pipe(t, e.minLength(1))
27
+ }),
28
+ e.object({
29
+ type: e.literal("new"),
30
+ stripePaymentMethodId: e.pipe(t, e.minLength(1))
31
+ })
32
+ ]), c = e.object({
33
+ id: e.pipe(t, e.minLength(1)),
34
+ brand: e.pipe(t, e.minLength(1)),
35
+ last4: e.pipe(t, e.length(4)),
36
+ expiryMonth: e.pipe(e.number(), e.integer(), e.minValue(1), e.maxValue(12)),
37
+ expiryYear: e.pipe(e.number(), e.integer(), e.minValue(2e3)),
38
+ isDefault: e.boolean()
39
+ }), m = e.object({
40
+ orderId: e.pipe(t, e.minLength(1)),
41
+ amount: a,
42
+ currencyCode: r,
43
+ paymentMethodLast4: e.optional(e.pipe(t, e.length(4))),
44
+ paymentMethodBrand: e.optional(e.pipe(t, e.minLength(1)))
45
+ }), g = ["completed", "requires_action"], h = e.object({
46
+ outcome: e.literal("completed"),
47
+ checkout: m
48
+ }), u = e.object({
49
+ outcome: e.literal("requires_action"),
50
+ nextAction: i
51
+ }), C = e.variant("outcome", [
52
+ h,
53
+ u
54
+ ]), R = e.object({
55
+ paymentMethods: e.array(c)
56
+ }), M = e.object({
57
+ stripePaymentMethodId: e.pipe(t, e.minLength(1))
58
+ }), A = c;
59
+ export {
60
+ M as AddPaymentMethodRequestSchema,
61
+ A as AddPaymentMethodResponseSchema,
62
+ i as CheckoutNextActionSchema,
63
+ n as CheckoutProcessor,
64
+ l as CheckoutProcessorSchema,
65
+ p as CheckoutProcessors,
66
+ r as CurrencyCodeSchema,
67
+ o as DistributionCheckoutMode,
68
+ d as DistributionCheckoutModeSchema,
69
+ s as DistributionCheckoutModes,
70
+ S as DistributionEntryRequiresActionSchema,
71
+ m as FanfareCheckoutResultSchema,
72
+ a as MoneyStringSchema,
73
+ b as PaymentInputSchema,
74
+ c as PaymentMethodSummarySchema,
75
+ R as PaymentMethodsListResponseSchema,
76
+ y as PaymentProviderConfigSchema,
77
+ h as ReservationCheckoutCompletedSchema,
78
+ g as ReservationCheckoutOutcomes,
79
+ u as ReservationCheckoutRequiresActionSchema,
80
+ C as ReservationCheckoutResponseSchema
81
+ };