@alytegen/sdk 0.6.0 → 0.8.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/dist/types.d.ts CHANGED
@@ -6,6 +6,19 @@ export type Scheme = 'visa' | 'mastercard' | 'amex';
6
6
  export type TierKind = 'general' | 'seated';
7
7
  export type FeeBearer = 'buyer' | 'merchant';
8
8
  export type * from './inventoryTypes.js';
9
+ export type { BasketLineInput, ReserveBasketInput, ReservationStatus, ReservationLine, Reservation, BasketQuoteLine, BasketQuote, ConfirmReservationInput, ConfirmReservationOutcome } from './baskets.js';
10
+ export type TierRole = 'primary' | 'addon';
11
+ /** A server-enforced add-on rule. Qualifying parent tickets must be in the same event and basket. */
12
+ export interface TierLinkRule {
13
+ parentScope: 'any_primary_in_event' | 'specific_tiers';
14
+ parentTierIds?: string[];
15
+ scaling: 'per_basket' | 'per_parent_unit';
16
+ minQty?: number;
17
+ maxQty?: number;
18
+ minPerParent?: number;
19
+ maxPerParent?: number;
20
+ parentGroupSize?: number;
21
+ }
9
22
  export interface Merchant {
10
23
  id: string;
11
24
  name: string;
@@ -29,6 +42,35 @@ export interface EventItem {
29
42
  title: string;
30
43
  /** ISO-8601 start time. */
31
44
  startsAt: string;
45
+ /** Per-customer ticket limit on this event, when set. */
46
+ purchaseLimit?: {
47
+ maxPerCustomer: number;
48
+ maxHeldPerCustomer?: number;
49
+ };
50
+ }
51
+ /** Per-event customer ticket limit record (`GET/PUT /v1/integration/events/:id/purchase-limit`). */
52
+ export interface PurchaseLimit {
53
+ eventId: string;
54
+ merchantId: string;
55
+ maxPerCustomer: number;
56
+ maxHeldPerCustomer?: number;
57
+ /** Whether queued purchases count toward the limit while waiting; null when not chosen, which counts. */
58
+ countWaitingWatches: boolean | null;
59
+ revision: number;
60
+ updatedBy?: string;
61
+ updatedAt: string;
62
+ }
63
+ /** How an event's per-customer ticket limit recognises customers and how many tickets it covers. */
64
+ export interface PurchaseLimitReadiness {
65
+ identifiers: string[];
66
+ ticketsCounted: number;
67
+ ticketsNotCounted: number;
68
+ }
69
+ /** Body for `AlyteMerchant.setEventPurchaseLimit`. Whole numbers only (`1..1000`); PUT replaces the whole limit. */
70
+ export interface SetPurchaseLimitInput {
71
+ maxPerCustomer: number;
72
+ maxHeldPerCustomer?: number;
73
+ countWaitingWatches?: boolean;
32
74
  }
33
75
  export interface Tier {
34
76
  id: string;
@@ -41,6 +83,11 @@ export interface Tier {
41
83
  availableCount?: number;
42
84
  /** When present, availability comes from this shared pool. Restock the pool. */
43
85
  poolId?: string;
86
+ role?: TierRole;
87
+ category?: string;
88
+ categoryLabel?: string;
89
+ countsTowardPartySize?: boolean;
90
+ linkRule?: TierLinkRule;
44
91
  maxQtyPerPurchase?: number;
45
92
  sellable?: boolean;
46
93
  onSaleStart?: string;
@@ -58,6 +105,11 @@ export interface DiscoveredTier extends Tier {
58
105
  authorizeUrl?: string;
59
106
  }
60
107
  export interface DiscoveredEvent extends EventItem {
108
+ /** Pinned venue display metadata. Null = unknown; absent on older servers. */
109
+ location?: {
110
+ name: string;
111
+ timeZone: string;
112
+ } | null;
61
113
  tiers: DiscoveredTier[];
62
114
  }
63
115
  /** A price snapshot locked at quote time; the charge must match it. */
@@ -93,7 +145,25 @@ export interface Hold {
93
145
  requestedQuantity?: number;
94
146
  partialReason?: string;
95
147
  }
148
+ /** Verified purchase authentication facts; never an assertion of liability shift. */
149
+ export type PurchaseAuthentication = ({
150
+ provider: 'stripe';
151
+ paymentIntentId: string;
152
+ chargeId?: string;
153
+ } | {
154
+ provider: 'adyen';
155
+ pspReference: string;
156
+ }) & {
157
+ result: string;
158
+ flow?: string;
159
+ version?: string;
160
+ eci?: string;
161
+ transactionId?: string;
162
+ observedAt: string;
163
+ };
96
164
  export interface PaymentResult {
165
+ purchaseId?: string;
166
+ authentication?: PurchaseAuthentication;
97
167
  intentId: string;
98
168
  status: string;
99
169
  psp?: string;
@@ -102,9 +172,20 @@ export interface PaymentResult {
102
172
  [k: string]: unknown;
103
173
  }
104
174
  export type ConfirmOutcome = {
175
+ status: 'payment_pending';
176
+ result: PaymentResult;
177
+ holdStatus: 'reconcile';
178
+ } | {
105
179
  status: 'settled';
106
180
  result: PaymentResult;
107
181
  holdStatus: string;
182
+ } | {
183
+ status: 'sca_required';
184
+ purchaseId: string;
185
+ challenge: {
186
+ expiresAt: string;
187
+ };
188
+ holdStatus: 'reconcile';
108
189
  } | {
109
190
  status: 'sca_required';
110
191
  challenge: {
@@ -188,5 +269,12 @@ export interface MerchantInsights {
188
269
  failed: number;
189
270
  cancelled: number;
190
271
  expired: number;
272
+ /** Why queued requests wait, as the dispatcher last decided. Absent on older servers. */
273
+ waiting?: {
274
+ stock: number;
275
+ whole_party: number;
276
+ price_target: number;
277
+ access_window: number;
278
+ };
191
279
  }>;
192
280
  }
@@ -0,0 +1,28 @@
1
+ /** Reserve, quote and release a basket without charging.
2
+ * ALYTE_BASE_URL=… ALYTE_AGENT_TOKEN=… ADULT_TIER_ID=… CHILD_TIER_ID=… npx tsx agent-basket.ts
3
+ * Requires catalog:read + payments:read + payments:write and a covering mandate.
4
+ */
5
+ import { AlyteAgent, type ConfirmReservationOutcome } from '@alytegen/sdk';
6
+
7
+ const agent = new AlyteAgent({ baseUrl: process.env.ALYTE_BASE_URL!, token: process.env.ALYTE_AGENT_TOKEN! });
8
+ const reservation = await agent.reserveBasket({ lines: [
9
+ { tierId: process.env.ADULT_TIER_ID!, quantity: 2 },
10
+ { tierId: process.env.CHILD_TIER_ID!, quantity: 1 },
11
+ ], scheme: 'visa', geo: 'DE' });
12
+ const quote = await agent.quoteReservation(reservation.id);
13
+ console.log({ reservationId: reservation.id, quoteId: quote.id, lines: quote.lines,
14
+ chargeMinor: quote.chargeMinor, currency: quote.currency, expiresAt: reservation.expiresAt });
15
+
16
+ // A real application persists the reservation, quote, instrument and idempotency
17
+ // key before calling confirmReservation. This example stops before any charge.
18
+ await agent.releaseReservation(reservation.id);
19
+
20
+ /** Interpret confirmation or resolveBasketSca results without treating an uncertain
21
+ * payment as a decline. Only an authorized, confirmed basket may be fulfilled. */
22
+ export function purchaseState(outcome: ConfirmReservationOutcome): 'paid' | 'challenge' | 'refused' | 'pending' {
23
+ if (outcome.status === 'sca_required') return 'challenge';
24
+ if (outcome.status === 'sca_failed') return 'refused';
25
+ if (outcome.status === 'payment_pending' || outcome.reservationStatus === 'reconcile') return 'pending';
26
+ if (outcome.result.status === 'authorized' && outcome.reservationStatus === 'confirmed') return 'paid';
27
+ return outcome.result.status === 'declined' ? 'refused' : 'pending';
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alytegen/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Alyte client SDK \u2014 merchant integration (catalog, PSP links, buyer sessions, payments visibility) and the agent buy path (discover \u2192 quote \u2192 hold \u2192 confirm).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",