@alytegen/sdk 0.5.0 → 0.6.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/BROWSER.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Buyer purchases inside your chat
2
2
 
3
- Available since SDK 0.4.0 with Alyte's Model 1 browser endpoints (0.5.0 types the attested
3
+ Available since SDK 0.4.0 with Alyte's Model 1 browser endpoints (0.5.0 and later type the attested
4
4
  mint). The merchant token stays on your backend. Your chat receives a short-lived bounded
5
5
  buyer bearer. How a permission gets created depends on the session you minted:
6
6
  **merchant-attested** (enabled merchants, within staff-set ceilings) — Alyte's iframe creates
@@ -22,16 +22,15 @@ minting or exchange endpoints themselves.
22
22
  The separately enabled merchant-attested path can grant within staff-set
23
23
  ceilings without the emailed code. Mint that session on your backend with an
24
24
  attest-only key and `merchantAttested: true`, then exchange it and call
25
- `openConsent` as below. Published SDK 0.4.0 lacks the TypeScript mint field;
26
- use the [REST example](https://alyte.mintlify.site/guides/console-api-keys).
25
+ `openConsent` as below. SDK 0.5.0 and later type the mint field
26
+ (`buyerSessions.mint({ merchantId, email, merchantAttested: true })`); the
27
+ [REST example](https://alyte.mintlify.site/guides/console-api-keys) shows the same call without the SDK.
27
28
  The API key never belongs in the browser. Removing staff enablement or revoking
28
29
  the key removes the session's attestation exception.
29
30
 
30
- The proposed emailed-link confirmation flow is not enabled yet. The current
31
- verification-code flow remains in use. `openConsent`'s signature and result
32
- are planned to stay compatible when the new Alyte surfaces ship; 0.4.0 has no
33
- pending-consent client methods.
34
- [Follow availability](https://alyte.mintlify.site/guides/consent-confirmation).
31
+ The emailed-link confirmation flow proposed earlier is withdrawn and will not ship.
32
+ Ordinary sessions confirm the emailed verification code inside Alyte's iframe, and
33
+ the SDK has no pending-consent client methods.
35
34
 
36
35
  ## Register and attest
37
36
 
package/README.md CHANGED
@@ -23,7 +23,7 @@ npm install @alytegen/sdk
23
23
  | `createWebhookHandler` / `verifyWebhookSignature` | webhook secret | your server | signed, at-least-once purchase events with typed dispatch |
24
24
  | `exchangeBuyerSession` / `createBuyerClient` / `openConsent` from `@alytegen/sdk/browser` | bounded buyer bearer | partner browser/chat | isolated consent, then buy/watch/list/revoke within existing authority |
25
25
 
26
- The browser entry is new in 0.4.0. See [the chat integration](./BROWSER.md) for setup,
26
+ The browser entry arrived in 0.4.0; 0.6.0 is the current release. See [the chat integration](./BROWSER.md) for setup,
27
27
  cookie-independent consent, reconnecting and handling uncertain purchases.
28
28
 
29
29
  ## Merchant: onboard in four calls
@@ -43,6 +43,54 @@ const { event } = await alyte.createEvent({ merchantId: merchant.id, title: 'War
43
43
  const { tier } = await alyte.createTier({ eventId: event.id, title: 'GA', priceMinor: 4900, currency: 'EUR', kind: 'general', availableCount: 500 });
44
44
  ```
45
45
 
46
+ ## Inventory management
47
+
48
+ Available since SDK 0.6.0.
49
+
50
+ The merchant can operate the venue and own its inventory. One API credential with
51
+ `merchant:read` and `merchant:write` manages both. A location is optional place and
52
+ time-zone metadata under the shop, not a separate account.
53
+
54
+ ```ts
55
+ const { location } = await alyte.createLocation(merchant.id, {
56
+ name: 'Our theatre', timeZone: 'Europe/London',
57
+ });
58
+ const { event: show } = await alyte.createEvent({
59
+ merchantId: merchant.id, title: 'Evening show', startsAt: '2027-05-01T20:00:00+01:00',
60
+ location: { id: location.id, expectedRevision: location.revision }, // optional
61
+ });
62
+ const { pool } = await alyte.createPool({
63
+ merchantId: merchant.id, eventId: show.id, title: 'General admission', capacity: 100,
64
+ });
65
+ await alyte.createTier({
66
+ eventId: show.id, title: 'Adult', kind: 'general', priceMinor: 2500, currency: 'EUR', poolId: pool.id,
67
+ });
68
+ await alyte.createTier({
69
+ eventId: show.id, title: 'Child', kind: 'general', priceMinor: 1500, currency: 'EUR', poolId: pool.id,
70
+ });
71
+ const { catalog: observation } = await alyte.inventoryCatalog(merchant.id);
72
+ // Both prices draw from one counter. The observation is not a reservation or quote.
73
+ ```
74
+
75
+ Use `listPools` and `updatePool` to inspect or edit shared capacity. `availableCount`
76
+ sets remaining stock; it is not an increment. Omit it when only renaming a pool.
77
+ Pooled tiers cannot be restocked individually, and the server refuses capacity below
78
+ outstanding holds. `updateTier` still controls price, sale windows and sellability.
79
+
80
+ `listLocations`, `updateLocation`, `getSlot` and `setSlotLocation` manage optional
81
+ place metadata. Location changes require the revision you read. Existing occurrences
82
+ keep their pinned location version until explicitly rebound. Rebinding or clearing
83
+ a location does not reschedule the event. Pass `expectedOccurrenceRevision` to
84
+ `updateTier` when a sale-window edit depends on the slot's location; stale edits
85
+ return `commerce_schedule_conflict` and should be refreshed before retrying.
86
+
87
+ `inventoryCatalog` reports current base prices and stock, with no private buyer or
88
+ agent allow-lists. Its disabled generic transaction capabilities describe that
89
+ observation; they do not disable the merchant's stock-management methods. It fails
90
+ with `catalog_too_large` if any source relation exceeds 2,000 rows, including private
91
+ eligibility rows. `listLocations` has a separate 2,000-row bound. Neither returns a
92
+ truncated result.
93
+
46
94
  ## Hand a signed-in customer to their agent
47
95
 
48
96
  Your users already have accounts with you. Your server attests one of them and redirects;
@@ -103,7 +151,10 @@ the buyer's mandate said no: surface it, don't retry.
103
151
 
104
152
  ## Current API and console capabilities
105
153
 
106
- SDK **0.5.0** types the merchant-attested mint (`merchantAttested: true`), alongside the browser
154
+ SDK **0.6.0** adds inventory management: shared pools (`createPool`, `listPools`, `updatePool`),
155
+ optional venue locations with pinned versions (`createLocation`, `listLocations`, `updateLocation`,
156
+ `getSlot`, `setSlotLocation`, `createEvent({ location })`) and a read-only `inventoryCatalog`
157
+ observation. **0.5.0** typed the merchant-attested mint (`merchantAttested: true`), alongside the browser
107
158
  entry point and the typed tier-create restrictions (`onSaleStart`, `onSaleEnd`, `maxQtyPerPurchase`,
108
159
  `sellable`, `allowedGeos`, `allowedSchemes` — put them in the initial `createTier` call so a
109
160
  scheduled tier is never briefly on sale).
package/dist/http.d.ts CHANGED
@@ -19,5 +19,5 @@ export declare class Transport {
19
19
  private readonly token;
20
20
  private readonly fetchImpl;
21
21
  constructor(opts: ClientOptions);
22
- request<T>(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
22
+ request<T>(method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
23
23
  }
@@ -0,0 +1,142 @@
1
+ import type { FeeBearer, Scheme, TierKind } from './types.js';
2
+ /** One capacity counter shared by the merchant's offers. */
3
+ export interface InventoryPool {
4
+ id: string;
5
+ tenantId: string;
6
+ merchantId: string;
7
+ eventId?: string;
8
+ title: string;
9
+ capacity: number;
10
+ availableCount: number;
11
+ authority: 'local';
12
+ createdAt: string;
13
+ }
14
+ /** Optional place metadata owned by a shop, not another merchant or account. */
15
+ export interface InventoryLocation {
16
+ tenantId: string;
17
+ storeId: string;
18
+ id: string;
19
+ revision: number;
20
+ name: string;
21
+ timeZone: string;
22
+ }
23
+ export interface InventoryOccurrence {
24
+ tenantId: string;
25
+ storeId: string;
26
+ id: string;
27
+ kind: 'occurrence';
28
+ source: 'native' | 'ticketing';
29
+ startsAt: string;
30
+ endsAt: string | null;
31
+ /** Versions the location binding, not the event's schedule. */
32
+ metadataRevision: number;
33
+ location: InventoryLocation | null;
34
+ }
35
+ export type InventoryLocationBinding = {
36
+ locationId: string;
37
+ expectedRevision: number;
38
+ expectedLocationRevision: number;
39
+ } | {
40
+ locationId: null;
41
+ expectedRevision: number;
42
+ expectedLocationRevision?: never;
43
+ };
44
+ export interface InventoryRef<K extends string> {
45
+ kind: K;
46
+ id: string;
47
+ tenantId: string;
48
+ storeId: string;
49
+ }
50
+ export type InventorySourceRef = InventoryRef<'ticketing.tier_counter' | 'ticketing.pool' | 'ticketing.seat_set'>;
51
+ /** Current stock/price observation, not a quote, reservation or authorization.
52
+ * The merchant can still manage its inventory through the write methods. */
53
+ export interface InventoryCatalog {
54
+ schemaVersion: 1;
55
+ profile: 'ticketing';
56
+ use: 'inventory_observation';
57
+ tenantId: string;
58
+ storeId: string;
59
+ observedAt: string;
60
+ storePolicy: {
61
+ geo: string;
62
+ currency: string;
63
+ allowedSchemes?: Scheme[];
64
+ feeBearer: FeeBearer;
65
+ taxRateBps: number;
66
+ };
67
+ checkout: {
68
+ mode: 'api' | 'hosted';
69
+ url: string | null;
70
+ };
71
+ /** Generic transaction operations are not implemented. These are not token permissions. */
72
+ capabilities: {
73
+ reserve: false;
74
+ quote: false;
75
+ purchase: false;
76
+ };
77
+ products: Array<{
78
+ ref: InventoryRef<'product'>;
79
+ title: string;
80
+ }>;
81
+ variants: Array<{
82
+ ref: InventoryRef<'variant'>;
83
+ product: InventoryRef<'product'>;
84
+ title: string;
85
+ }>;
86
+ slots: Array<{
87
+ ref: InventoryRef<'slot'>;
88
+ startsAt: string;
89
+ endsAt: string | null;
90
+ timeZone: string | null;
91
+ metadataRevision: number | null;
92
+ location: (InventoryRef<'location'> & {
93
+ revision: number;
94
+ name: string;
95
+ }) | null;
96
+ }>;
97
+ offers: Array<{
98
+ ref: InventoryRef<'offer'>;
99
+ variant: InventoryRef<'variant'>;
100
+ slot: InventoryRef<'slot'>;
101
+ title: string;
102
+ /** Base unit price only; tax/processing fees are resolved by the quote path. */
103
+ price: {
104
+ kind: 'unit_base';
105
+ amountMinor: number;
106
+ currency: string;
107
+ };
108
+ termsVersion: null;
109
+ sellable: boolean;
110
+ quantity: {
111
+ unit: 'item' | 'admission_place';
112
+ maxPerPurchase?: number;
113
+ };
114
+ salesWindow: {
115
+ start?: string;
116
+ end?: string;
117
+ startInclusive: boolean;
118
+ endInclusive: boolean;
119
+ };
120
+ eligibility: {
121
+ principalRestricted: boolean;
122
+ geos?: string[];
123
+ schemes?: Scheme[];
124
+ };
125
+ inventory: {
126
+ source: InventorySourceRef;
127
+ unitsPerItem: number;
128
+ };
129
+ profile: {
130
+ tierKind: TierKind;
131
+ };
132
+ }>;
133
+ inventory: Array<{
134
+ ref: InventorySourceRef;
135
+ availability: {
136
+ state: 'observed';
137
+ units: number;
138
+ } | {
139
+ state: 'unknown';
140
+ };
141
+ }>;
142
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { type ClientOptions } from './http.js';
2
- import type { BuyerSessionMint, CatalogMerchant, Merchant, EventItem, MerchantPspLink, Tier, TierKind, FeeBearer, Scheme, PaymentRow, WebhookEndpoint, MerchantInsights } from './types.js';
2
+ import type { BuyerSessionMint, CatalogMerchant, Merchant, EventItem, MerchantPspLink, Tier, TierKind, FeeBearer, Scheme, PaymentRow, WebhookEndpoint, MerchantInsights, InventoryCatalog, InventoryLocation, InventoryLocationBinding, InventoryOccurrence, InventoryPool } from './types.js';
3
3
  /**
4
4
  * Merchant integration client — drives the `/v1/integration/*` surface with a
5
5
  * console-minted API token (`merchant:read` / `merchant:write` scopes; `merchant:admin` for
@@ -44,10 +44,15 @@ export declare class AlyteMerchant {
44
44
  }): Promise<{
45
45
  merchant: Merchant;
46
46
  }>;
47
+ /** Optional location is metadata owned by this shop; the merchant may operate it. */
47
48
  createEvent(input: {
48
49
  merchantId: string;
49
50
  title: string;
50
51
  startsAt: string;
52
+ location?: {
53
+ id: string;
54
+ expectedRevision: number;
55
+ };
51
56
  }): Promise<{
52
57
  event: EventItem;
53
58
  }>;
@@ -59,6 +64,8 @@ export declare class AlyteMerchant {
59
64
  currency: string;
60
65
  kind: TierKind;
61
66
  availableCount?: number;
67
+ /** Shared counter; omit availableCount when attaching a pool. */
68
+ poolId?: string | null;
62
69
  maxQtyPerPurchase?: number | null;
63
70
  sellable?: boolean;
64
71
  onSaleStart?: string | null;
@@ -71,6 +78,9 @@ export declare class AlyteMerchant {
71
78
  updateTier(tierId: string, patch: {
72
79
  priceMinor?: number;
73
80
  availableCount?: number;
81
+ poolId?: string | null;
82
+ /** Guard sale-window edits against a concurrent location-binding change. */
83
+ expectedOccurrenceRevision?: number;
74
84
  maxQtyPerPurchase?: number | null;
75
85
  sellable?: boolean;
76
86
  onSaleStart?: string | null;
@@ -86,6 +96,55 @@ export declare class AlyteMerchant {
86
96
  deleteEvent(eventId: string): Promise<{
87
97
  ok: boolean;
88
98
  }>;
99
+ /** Observed stock and base prices for one shop; not a reserved or quoted offer.
100
+ * Read scope does not grant writes. A read/write key can also manage this inventory.
101
+ * Fails with catalog_too_large if any source relation exceeds 2,000 rows. */
102
+ inventoryCatalog(merchantId: string): Promise<{
103
+ catalog: InventoryCatalog;
104
+ }>;
105
+ listLocations(merchantId: string): Promise<{
106
+ locations: InventoryLocation[];
107
+ }>;
108
+ createLocation(merchantId: string, input: {
109
+ name: string;
110
+ timeZone: string;
111
+ }): Promise<{
112
+ location: InventoryLocation;
113
+ }>;
114
+ /** Existing occurrences keep their pinned version until explicitly rebound. */
115
+ updateLocation(merchantId: string, locationId: string, input: {
116
+ name: string;
117
+ timeZone: string;
118
+ expectedRevision: number;
119
+ }): Promise<{
120
+ location: InventoryLocation;
121
+ }>;
122
+ getSlot(merchantId: string, slotId: string): Promise<{
123
+ slot: InventoryOccurrence;
124
+ }>;
125
+ /** Metadata only; does not change the occurrence's start instant or inventory. */
126
+ setSlotLocation(merchantId: string, slotId: string, input: InventoryLocationBinding): Promise<{
127
+ slot: InventoryOccurrence;
128
+ }>;
129
+ createPool(input: {
130
+ merchantId: string;
131
+ eventId?: string | null;
132
+ title: string;
133
+ capacity: number;
134
+ }): Promise<{
135
+ pool: InventoryPool;
136
+ }>;
137
+ listPools(merchantId: string): Promise<{
138
+ pools: InventoryPool[];
139
+ }>;
140
+ /** availableCount sets remaining units, not an increment; capacity must cover holds. */
141
+ updatePool(poolId: string, patch: {
142
+ title?: string;
143
+ capacity?: number;
144
+ availableCount?: number;
145
+ }): Promise<{
146
+ pool: InventoryPool;
147
+ }>;
89
148
  listPsps(merchantId: string): Promise<{
90
149
  psps: MerchantPspLink[];
91
150
  }>;
package/dist/merchant.js CHANGED
@@ -32,6 +32,7 @@ export class AlyteMerchant {
32
32
  updateShopDiscovery(merchantId, input) {
33
33
  return this.t.request('PATCH', `/v1/integration/merchants/${encodeURIComponent(merchantId)}`, input);
34
34
  }
35
+ /** Optional location is metadata owned by this shop; the merchant may operate it. */
35
36
  createEvent(input) {
36
37
  return this.t.request('POST', '/v1/integration/events', input);
37
38
  }
@@ -48,6 +49,39 @@ export class AlyteMerchant {
48
49
  deleteEvent(eventId) {
49
50
  return this.t.request('DELETE', `/v1/integration/events/${encodeURIComponent(eventId)}`);
50
51
  }
52
+ /** Observed stock and base prices for one shop; not a reserved or quoted offer.
53
+ * Read scope does not grant writes. A read/write key can also manage this inventory.
54
+ * Fails with catalog_too_large if any source relation exceeds 2,000 rows. */
55
+ inventoryCatalog(merchantId) {
56
+ return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/inventory`);
57
+ }
58
+ listLocations(merchantId) {
59
+ return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/locations`);
60
+ }
61
+ createLocation(merchantId, input) {
62
+ return this.t.request('POST', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/locations`, input);
63
+ }
64
+ /** Existing occurrences keep their pinned version until explicitly rebound. */
65
+ updateLocation(merchantId, locationId, input) {
66
+ return this.t.request('PATCH', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/locations/${encodeURIComponent(locationId)}`, input);
67
+ }
68
+ getSlot(merchantId, slotId) {
69
+ return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/slots/${encodeURIComponent(slotId)}`);
70
+ }
71
+ /** Metadata only; does not change the occurrence's start instant or inventory. */
72
+ setSlotLocation(merchantId, slotId, input) {
73
+ return this.t.request('PUT', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/slots/${encodeURIComponent(slotId)}/location`, input);
74
+ }
75
+ createPool(input) {
76
+ return this.t.request('POST', '/v1/integration/pools', input);
77
+ }
78
+ listPools(merchantId) {
79
+ return this.t.request('GET', `/v1/integration/pools?merchantId=${encodeURIComponent(merchantId)}`);
80
+ }
81
+ /** availableCount sets remaining units, not an increment; capacity must cover holds. */
82
+ updatePool(poolId, patch) {
83
+ return this.t.request('PATCH', `/v1/integration/pools/${encodeURIComponent(poolId)}`, patch);
84
+ }
51
85
  listPsps(merchantId) {
52
86
  return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/psps`);
53
87
  }
package/dist/types.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  export type Scheme = 'visa' | 'mastercard' | 'amex';
6
6
  export type TierKind = 'general' | 'seated';
7
7
  export type FeeBearer = 'buyer' | 'merchant';
8
+ export type * from './inventoryTypes.js';
8
9
  export interface Merchant {
9
10
  id: string;
10
11
  name: string;
@@ -38,6 +39,8 @@ export interface Tier {
38
39
  currency: string;
39
40
  kind: TierKind;
40
41
  availableCount?: number;
42
+ /** When present, availability comes from this shared pool. Restock the pool. */
43
+ poolId?: string;
41
44
  maxQtyPerPurchase?: number;
42
45
  sellable?: boolean;
43
46
  onSaleStart?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alytegen/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.6.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",