@alytegen/sdk 0.5.0 → 0.7.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/QUICKSTART.md CHANGED
@@ -31,6 +31,14 @@ const { tier } = await alyte.createTier({ eventId: event.id, title: 'GA', priceM
31
31
 
32
32
  Money is **integer minor units** everywhere (`4900` = €49.00). Floats are refused.
33
33
 
34
+ SDK 0.7.0 also includes `alyte.accessRules` and `alyte.memberships` for
35
+ merchant-controlled early access: save a draft, preview, schedule or cancel, and attest or
36
+ revoke membership. They require a server at or after sandbox revision `alyte-sandbox-00133-v77`.
37
+ See [the access-rule workflow](./README.md#access-rules-and-membership)
38
+ for request identities, explicit-offset windows and revision checks.
39
+ Membership uses the `buyerId` returned by `buyerSessions.mint`; retain its mapping to
40
+ your own customer ID rather than passing your internal customer ID to `memberships.upsert`.
41
+
34
42
  ## Plugging in YOUR auth + user database (required for buyer flows)
35
43
 
36
44
  Your customers already have accounts with you — Alyte does not replace that.
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.7.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,117 @@ 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
+
94
+ ## Access rules and membership
95
+
96
+ Available since SDK 0.7.0; requires a server at or after sandbox revision
97
+ `alyte-sandbox-00133-v77`. Use a backend credential with `merchant:read` and
98
+ `merchant:write`. The console exposes the same flow to account owners.
99
+
100
+ An access rule grants an early window before a tier's general-sale opening. Create a
101
+ draft, review its current impact, then schedule it:
102
+
103
+ ```ts
104
+ const { program } = await alyte.memberships.createProgram(merchant.id, {
105
+ requestId: crypto.randomUUID(), name: 'Members', levels: ['Gold', 'Platinum'],
106
+ });
107
+ const { rule } = await alyte.accessRules.createDraft(merchant.id, {
108
+ requestId: crypto.randomUUID(), offerId: tier.id, name: 'Member presale',
109
+ audience: { kind: 'membership', programId: program.id, levels: ['Gold', 'Platinum'] },
110
+ opensAt: '2027-05-01T09:00:00+01:00',
111
+ closesAt: '2027-05-01T10:00:00+01:00', // must end by the tier's general-sale opening
112
+ });
113
+ const preview = await alyte.accessRules.preview(merchant.id, rule.id);
114
+ // Show preview.impact, preview.timeZone and the window to the operator for review.
115
+ const publication = {
116
+ requestId: crypto.randomUUID(), expectedRevision: rule.revision, previewId: preview.id,
117
+ };
118
+ // Persist publication before dispatch; reuse exactly this input after an uncertain response.
119
+ const scheduled = await alyte.accessRules.schedule(merchant.id, rule.id, publication);
120
+ ```
121
+
122
+ Persist **each** mutation's request UUID and input before dispatch. Exact replays are safe;
123
+ changed input requires a new UUID. `access_conflict` means refresh and review again.
124
+ Drafts remain inactive. To cancel, call `preview(shopId, ruleId, 'cancel')`, then
125
+ `cancel` with that preview ID, the current rule revision and a new request UUID.
126
+ Published rules cannot be edited.
127
+
128
+ The merchant supplies verified membership for the **Alyte buyer ID** returned as
129
+ `buyerId` by `buyerSessions.mint`. Store a mapping from your authenticated customer's
130
+ internal ID to this returned value, scoped to the Alyte account. Passing your own customer
131
+ ID directly will not match the buyer's Alyte agent. Obtain the identity during your existing
132
+ signed-in hand-off; never derive or guess it from an email address.
133
+
134
+ ```ts
135
+ const session = await alyte.buyerSessions.mint({
136
+ merchantId: merchant.id, email: user.email,
137
+ });
138
+ const evidence = {
139
+ requestId: crypto.randomUUID(), sourceRevision: 1, level: 'Gold',
140
+ validFrom: '2027-01-01T00:00:00Z', validUntil: '2028-01-01T00:00:00Z',
141
+ evidenceRef: 'membership-system:record-123', revoked: false,
142
+ };
143
+ await alyte.memberships.upsert(merchant.id, program.id, session.buyerId, evidence);
144
+ // Revoke using a new requestId, a strictly greater sourceRevision, and revoked: true.
145
+ ```
146
+
147
+ Levels are explicit, with no implied hierarchy. Membership does not grant payment permission.
148
+ Other audiences are `{ kind: 'everyone' }` and
149
+ `{ kind: 'scheme', schemes: ['amex'] }`; card eligibility uses the actual saved instrument.
150
+ Issuer claims and free-text loyalty claims are not accepted. All times require explicit offsets.
151
+ Impact counts are observations of access, not stock forecasts or guaranteed queue positions.
152
+
153
+ Deleting an offer archives its rules in the read API. `accessRules.list` omits them, so
154
+ they do not consume the active list's limit. `accessRules.get` still returns their historical
155
+ definition and revision with `status: 'archived'`; archived rules cannot be edited or published.
156
+
46
157
  ## Hand a signed-in customer to their agent
47
158
 
48
159
  Your users already have accounts with you. Your server attests one of them and redirects;
@@ -103,7 +214,12 @@ the buyer's mandate said no: surface it, don't retry.
103
214
 
104
215
  ## Current API and console capabilities
105
216
 
106
- SDK **0.5.0** types the merchant-attested mint (`merchantAttested: true`), alongside the browser
217
+ SDK **0.7.0** adds merchant-controlled early access: `accessRules` (`list`, `get`,
218
+ `createDraft`, `updateDraft`, `preview`, `schedule`, `cancel`) and `memberships`
219
+ (`createProgram`, `upsert`). **0.6.0** added inventory management: shared pools (`createPool`, `listPools`, `updatePool`),
220
+ optional venue locations with pinned versions (`createLocation`, `listLocations`, `updateLocation`,
221
+ `getSlot`, `setSlotLocation`, `createEvent({ location })`) and a read-only `inventoryCatalog`
222
+ observation. **0.5.0** typed the merchant-attested mint (`merchantAttested: true`), alongside the browser
107
223
  entry point and the typed tier-create restrictions (`onSaleStart`, `onSaleEnd`, `maxQtyPerPurchase`,
108
224
  `sellable`, `allowedGeos`, `allowedSchemes` — put them in the initial `createTier` call so a
109
225
  scheduled tier is never briefly on sale).
@@ -0,0 +1,106 @@
1
+ import type { Transport } from './http.js';
2
+ export type AccessAudience = {
3
+ kind: 'everyone';
4
+ } | {
5
+ kind: 'membership';
6
+ programId: string;
7
+ levels: string[];
8
+ } | {
9
+ kind: 'scheme';
10
+ schemes: Array<'visa' | 'mastercard' | 'amex'>;
11
+ };
12
+ export interface AccessDraftInput {
13
+ requestId: string;
14
+ offerId: string;
15
+ name: string;
16
+ audience?: AccessAudience;
17
+ opensAt?: string;
18
+ closesAt?: string;
19
+ }
20
+ export interface AccessRule extends Omit<AccessDraftInput, 'requestId'> {
21
+ id: string;
22
+ revision: number;
23
+ status: 'draft' | 'scheduled' | 'cancelled' | 'archived';
24
+ }
25
+ export interface MembershipProgram {
26
+ id: string;
27
+ name: string;
28
+ levels: string[];
29
+ }
30
+ export interface AccessPreview {
31
+ id: string;
32
+ rule: AccessRule;
33
+ action: 'schedule' | 'cancel';
34
+ expiresAt: string;
35
+ observedAt: string;
36
+ impact: {
37
+ total: number;
38
+ earlier: number;
39
+ later: number;
40
+ unchanged: number;
41
+ };
42
+ timeZone: string;
43
+ generalSaleAt: string | null;
44
+ }
45
+ export interface AccessCommitInput {
46
+ requestId: string;
47
+ expectedRevision: number;
48
+ previewId: string;
49
+ }
50
+ export interface MembershipEvidence {
51
+ requestId: string;
52
+ sourceRevision: number;
53
+ level: string;
54
+ validFrom: string;
55
+ validUntil: string;
56
+ evidenceRef: string;
57
+ revoked: boolean;
58
+ }
59
+ /** Backend-only merchant access control. Save each request UUID before dispatch and
60
+ * reuse it only for the exact same operation. No mutation is retried automatically. */
61
+ export declare class MerchantAccessRules {
62
+ private readonly t;
63
+ constructor(t: Transport);
64
+ list(shop: string): Promise<{
65
+ rules: AccessRule[];
66
+ programs: MembershipProgram[];
67
+ }>;
68
+ get(shop: string, id: string): Promise<{
69
+ rule: AccessRule;
70
+ }>;
71
+ createDraft(shop: string, input: AccessDraftInput): Promise<{
72
+ rule: AccessRule;
73
+ }>;
74
+ updateDraft(shop: string, id: string, input: AccessDraftInput & {
75
+ expectedRevision: number;
76
+ }): Promise<{
77
+ rule: AccessRule;
78
+ }>;
79
+ preview(shop: string, id: string, action?: 'schedule' | 'cancel'): Promise<AccessPreview>;
80
+ schedule(shop: string, id: string, input: AccessCommitInput): Promise<{
81
+ rule: AccessRule;
82
+ }>;
83
+ cancel(shop: string, id: string, input: AccessCommitInput): Promise<{
84
+ rule: AccessRule;
85
+ }>;
86
+ }
87
+ /** A merchant attests membership in its own program, not payment permission. */
88
+ export declare class MerchantMemberships {
89
+ private readonly t;
90
+ constructor(t: Transport);
91
+ createProgram(shop: string, input: {
92
+ requestId: string;
93
+ name: string;
94
+ levels: string[];
95
+ }): Promise<{
96
+ program: MembershipProgram;
97
+ }>;
98
+ upsert(shop: string, programId: string, buyerId: string, input: MembershipEvidence): Promise<{
99
+ membership: {
100
+ programId: string;
101
+ buyerId: string;
102
+ sourceRevision: number;
103
+ revoked: boolean;
104
+ };
105
+ }>;
106
+ }
package/dist/access.js ADDED
@@ -0,0 +1,27 @@
1
+ const base = (shop) => `/v1/integration/merchants/${encodeURIComponent(shop)}/access`;
2
+ /** Backend-only merchant access control. Save each request UUID before dispatch and
3
+ * reuse it only for the exact same operation. No mutation is retried automatically. */
4
+ export class MerchantAccessRules {
5
+ t;
6
+ constructor(t) {
7
+ this.t = t;
8
+ }
9
+ list(shop) { return this.t.request('GET', base(shop)); }
10
+ get(shop, id) { return this.t.request('GET', `${base(shop)}/rules/${encodeURIComponent(id)}`); }
11
+ createDraft(shop, input) { return this.t.request('POST', `${base(shop)}/rules`, input); }
12
+ updateDraft(shop, id, input) { return this.t.request('PUT', `${base(shop)}/rules/${encodeURIComponent(id)}`, input); }
13
+ preview(shop, id, action = 'schedule') { return this.t.request('POST', `${base(shop)}/rules/${encodeURIComponent(id)}/preview`, { action }); }
14
+ schedule(shop, id, input) { return this.t.request('POST', `${base(shop)}/rules/${encodeURIComponent(id)}/schedule`, input); }
15
+ cancel(shop, id, input) { return this.t.request('POST', `${base(shop)}/rules/${encodeURIComponent(id)}/cancel`, input); }
16
+ }
17
+ /** A merchant attests membership in its own program, not payment permission. */
18
+ export class MerchantMemberships {
19
+ t;
20
+ constructor(t) {
21
+ this.t = t;
22
+ }
23
+ createProgram(shop, input) { return this.t.request('POST', `${base(shop)}/programs`, input); }
24
+ upsert(shop, programId, buyerId, input) {
25
+ return this.t.request('PUT', `${base(shop)}/programs/${encodeURIComponent(programId)}/members/${encodeURIComponent(buyerId)}`, input);
26
+ }
27
+ }
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
  }
package/dist/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export { AlyteApiError, type ClientOptions } from './http.js';
4
4
  export { verifyWebhookSignature } from './webhookVerify.js';
5
5
  export { handleWebhook, createWebhookHandler, type AlyteEventEnvelope, type PaymentSettled, type WatchFailed, type WebhookTest, type PurchaseHandlers, type OnPurchaseOptions, type WebhookResult, } from './onPurchase.js';
6
6
  export type * from './types.js';
7
+ export type { AccessAudience, AccessDraftInput, AccessRule, AccessPreview, AccessCommitInput, MembershipProgram, MembershipEvidence } from './access.js';
@@ -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,6 @@
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 { MerchantAccessRules, MerchantMemberships } from './access.js';
3
+ import type { BuyerSessionMint, CatalogMerchant, Merchant, EventItem, MerchantPspLink, Tier, TierKind, FeeBearer, Scheme, PaymentRow, WebhookEndpoint, MerchantInsights, InventoryCatalog, InventoryLocation, InventoryLocationBinding, InventoryOccurrence, InventoryPool } from './types.js';
3
4
  /**
4
5
  * Merchant integration client — drives the `/v1/integration/*` surface with a
5
6
  * console-minted API token (`merchant:read` / `merchant:write` scopes; `merchant:admin` for
@@ -14,6 +15,8 @@ import type { BuyerSessionMint, CatalogMerchant, Merchant, EventItem, MerchantPs
14
15
  */
15
16
  export declare class AlyteMerchant {
16
17
  private readonly t;
18
+ readonly accessRules: MerchantAccessRules;
19
+ readonly memberships: MerchantMemberships;
17
20
  constructor(opts: ClientOptions);
18
21
  /** Your tenant's full catalog: shops → events → tiers (with restriction fields). */
19
22
  catalog(): Promise<{
@@ -44,10 +47,15 @@ export declare class AlyteMerchant {
44
47
  }): Promise<{
45
48
  merchant: Merchant;
46
49
  }>;
50
+ /** Optional location is metadata owned by this shop; the merchant may operate it. */
47
51
  createEvent(input: {
48
52
  merchantId: string;
49
53
  title: string;
50
54
  startsAt: string;
55
+ location?: {
56
+ id: string;
57
+ expectedRevision: number;
58
+ };
51
59
  }): Promise<{
52
60
  event: EventItem;
53
61
  }>;
@@ -59,6 +67,8 @@ export declare class AlyteMerchant {
59
67
  currency: string;
60
68
  kind: TierKind;
61
69
  availableCount?: number;
70
+ /** Shared counter; omit availableCount when attaching a pool. */
71
+ poolId?: string | null;
62
72
  maxQtyPerPurchase?: number | null;
63
73
  sellable?: boolean;
64
74
  onSaleStart?: string | null;
@@ -71,6 +81,9 @@ export declare class AlyteMerchant {
71
81
  updateTier(tierId: string, patch: {
72
82
  priceMinor?: number;
73
83
  availableCount?: number;
84
+ poolId?: string | null;
85
+ /** Guard sale-window edits against a concurrent location-binding change. */
86
+ expectedOccurrenceRevision?: number;
74
87
  maxQtyPerPurchase?: number | null;
75
88
  sellable?: boolean;
76
89
  onSaleStart?: string | null;
@@ -86,6 +99,55 @@ export declare class AlyteMerchant {
86
99
  deleteEvent(eventId: string): Promise<{
87
100
  ok: boolean;
88
101
  }>;
102
+ /** Observed stock and base prices for one shop; not a reserved or quoted offer.
103
+ * Read scope does not grant writes. A read/write key can also manage this inventory.
104
+ * Fails with catalog_too_large if any source relation exceeds 2,000 rows. */
105
+ inventoryCatalog(merchantId: string): Promise<{
106
+ catalog: InventoryCatalog;
107
+ }>;
108
+ listLocations(merchantId: string): Promise<{
109
+ locations: InventoryLocation[];
110
+ }>;
111
+ createLocation(merchantId: string, input: {
112
+ name: string;
113
+ timeZone: string;
114
+ }): Promise<{
115
+ location: InventoryLocation;
116
+ }>;
117
+ /** Existing occurrences keep their pinned version until explicitly rebound. */
118
+ updateLocation(merchantId: string, locationId: string, input: {
119
+ name: string;
120
+ timeZone: string;
121
+ expectedRevision: number;
122
+ }): Promise<{
123
+ location: InventoryLocation;
124
+ }>;
125
+ getSlot(merchantId: string, slotId: string): Promise<{
126
+ slot: InventoryOccurrence;
127
+ }>;
128
+ /** Metadata only; does not change the occurrence's start instant or inventory. */
129
+ setSlotLocation(merchantId: string, slotId: string, input: InventoryLocationBinding): Promise<{
130
+ slot: InventoryOccurrence;
131
+ }>;
132
+ createPool(input: {
133
+ merchantId: string;
134
+ eventId?: string | null;
135
+ title: string;
136
+ capacity: number;
137
+ }): Promise<{
138
+ pool: InventoryPool;
139
+ }>;
140
+ listPools(merchantId: string): Promise<{
141
+ pools: InventoryPool[];
142
+ }>;
143
+ /** availableCount sets remaining units, not an increment; capacity must cover holds. */
144
+ updatePool(poolId: string, patch: {
145
+ title?: string;
146
+ capacity?: number;
147
+ availableCount?: number;
148
+ }): Promise<{
149
+ pool: InventoryPool;
150
+ }>;
89
151
  listPsps(merchantId: string): Promise<{
90
152
  psps: MerchantPspLink[];
91
153
  }>;
package/dist/merchant.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Transport } from './http.js';
2
+ import { MerchantAccessRules, MerchantMemberships } from './access.js';
2
3
  /**
3
4
  * Merchant integration client — drives the `/v1/integration/*` surface with a
4
5
  * console-minted API token (`merchant:read` / `merchant:write` scopes; `merchant:admin` for
@@ -13,8 +14,12 @@ import { Transport } from './http.js';
13
14
  */
14
15
  export class AlyteMerchant {
15
16
  t;
17
+ accessRules;
18
+ memberships;
16
19
  constructor(opts) {
17
20
  this.t = new Transport(opts);
21
+ this.accessRules = new MerchantAccessRules(this.t);
22
+ this.memberships = new MerchantMemberships(this.t);
18
23
  }
19
24
  /** Your tenant's full catalog: shops → events → tiers (with restriction fields). */
20
25
  catalog() {
@@ -32,6 +37,7 @@ export class AlyteMerchant {
32
37
  updateShopDiscovery(merchantId, input) {
33
38
  return this.t.request('PATCH', `/v1/integration/merchants/${encodeURIComponent(merchantId)}`, input);
34
39
  }
40
+ /** Optional location is metadata owned by this shop; the merchant may operate it. */
35
41
  createEvent(input) {
36
42
  return this.t.request('POST', '/v1/integration/events', input);
37
43
  }
@@ -48,6 +54,39 @@ export class AlyteMerchant {
48
54
  deleteEvent(eventId) {
49
55
  return this.t.request('DELETE', `/v1/integration/events/${encodeURIComponent(eventId)}`);
50
56
  }
57
+ /** Observed stock and base prices for one shop; not a reserved or quoted offer.
58
+ * Read scope does not grant writes. A read/write key can also manage this inventory.
59
+ * Fails with catalog_too_large if any source relation exceeds 2,000 rows. */
60
+ inventoryCatalog(merchantId) {
61
+ return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/inventory`);
62
+ }
63
+ listLocations(merchantId) {
64
+ return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/locations`);
65
+ }
66
+ createLocation(merchantId, input) {
67
+ return this.t.request('POST', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/locations`, input);
68
+ }
69
+ /** Existing occurrences keep their pinned version until explicitly rebound. */
70
+ updateLocation(merchantId, locationId, input) {
71
+ return this.t.request('PATCH', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/locations/${encodeURIComponent(locationId)}`, input);
72
+ }
73
+ getSlot(merchantId, slotId) {
74
+ return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/slots/${encodeURIComponent(slotId)}`);
75
+ }
76
+ /** Metadata only; does not change the occurrence's start instant or inventory. */
77
+ setSlotLocation(merchantId, slotId, input) {
78
+ return this.t.request('PUT', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/slots/${encodeURIComponent(slotId)}/location`, input);
79
+ }
80
+ createPool(input) {
81
+ return this.t.request('POST', '/v1/integration/pools', input);
82
+ }
83
+ listPools(merchantId) {
84
+ return this.t.request('GET', `/v1/integration/pools?merchantId=${encodeURIComponent(merchantId)}`);
85
+ }
86
+ /** availableCount sets remaining units, not an increment; capacity must cover holds. */
87
+ updatePool(poolId, patch) {
88
+ return this.t.request('PATCH', `/v1/integration/pools/${encodeURIComponent(poolId)}`, patch);
89
+ }
51
90
  listPsps(merchantId) {
52
91
  return this.t.request('GET', `/v1/integration/merchants/${encodeURIComponent(merchantId)}/psps`);
53
92
  }
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;
@@ -55,6 +58,11 @@ export interface DiscoveredTier extends Tier {
55
58
  authorizeUrl?: string;
56
59
  }
57
60
  export interface DiscoveredEvent extends EventItem {
61
+ /** Pinned venue display metadata. Null = unknown; absent on older servers. */
62
+ location?: {
63
+ name: string;
64
+ timeZone: string;
65
+ } | null;
58
66
  tiers: DiscoveredTier[];
59
67
  }
60
68
  /** A price snapshot locked at quote time; the charge must match it. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alytegen/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.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",