@ophelio/sdk 0.3.1 → 0.3.2

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
@@ -154,26 +154,27 @@ member roles, pricing groups, sales channels, entitlements, plans and
154
154
 
155
155
  Everything reachable with an API key is covered:
156
156
 
157
- | Namespace | Methods |
158
- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
159
- | `admit` | `check({ card })` |
160
- | `members` | `sync({ since? })`, `get(id)`, `listEntitlements(id, { type? })`, `update(id, ...)`, `remove(id)`, `setPrimary(id)`, `reissueCard(id, { note? })` |
161
- | `memberships` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `cancel(id, ...)`, `uncancel(id)`, `renew(id, ...)`, `upgrade(id, ...)`, `downgrade(id, ...)`, `listMembers(id)`, `addMember(id, ...)`, `listScheduledChanges(id, params?)`, `cancelScheduledChange(id, changeId)`, `listTransactions(id, params?)`, `listTermTransactions(id, termId, params?)`, `createTransaction(id, ...)` |
162
- | `customers` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listMemberships(id, params?)` — `list`/`get` accept `view: 'full'` to include `membership_summary` |
163
- | `entitlements` | `redeem(...)`, `recordUsage(...)`, `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
164
- | `plans` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listBillingOptions(id)`, `createBillingOption(id, ...)`, `listEntitlements(id)`, `createEntitlement(id, ...)`, `listPlanLinks(id)`, `createPlanLink(id, ...)`, `listPricingGroupMappings(id)`, `createPricingGroupMapping(id, ...)` |
165
- | `billingOptions` | `list()`, `get(id)`, `update(id, ...)`, `delete(id)`, `listSalesChannels(id)`, `createSalesChannelLink(id, ...)` |
166
- | `memberRoles` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
167
- | `pricingGroups` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
168
- | `salesChannels` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
169
- | `targetCodes` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` — `update` takes `display_name` / `description` only; `code` is immutable |
170
- | `calendars` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listRules(id, params?)`, `createRule(id, ...)` |
171
- | `calendarRules` | `get(id)`, `update(id, ...)`, `delete(id)` |
172
- | `planEntitlements` | `get(id)`, `update(id, ...)`, `delete(id)` |
173
- | `planLinks` | `delete(id)` |
174
- | `planPricingGroupMappings` | `delete(id)` |
175
- | `billingOptionSalesChannels` | `delete(id)` |
176
- | `webhookSubscriptions` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listDeliveries(id, params?)` |
157
+ | Namespace | Methods |
158
+ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
159
+ | `admit` | `check({ card })` |
160
+ | `members` | `sync({ since? })`, `get(id)`, `listEntitlements(id, { type? })`, `update(id, ...)`, `remove(id)`, `setPrimary(id)`, `reissueCard(id, { note? })` |
161
+ | `memberships` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `cancel(id, ...)`, `uncancel(id)`, `renew(id, ...)`, `upgrade(id, ...)`, `downgrade(id, ...)`, `listMembers(id)`, `addMember(id, ...)`, `listScheduledChanges(id, params?)`, `cancelScheduledChange(id, changeId)`, `listTransactions(id, params?)`, `listTermTransactions(id, termId, params?)`, `createTransaction(id, ...)` |
162
+ | `customers` | `list(params?)`, `get(id, params?)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listMemberships(id, params?)` — `list`/`get` accept `view: 'full'` to include `membership_summary` |
163
+ | `entitlements` | `redeem(...)`, `recordUsage(...)`, `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
164
+ | `plans` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listBillingOptions(id)`, `createBillingOption(id, ...)`, `listEntitlements(id)`, `createEntitlement(id, ...)`, `listPlanLinks(id)`, `createPlanLink(id, ...)`, `listPricingGroupMappings(id)`, `createPricingGroupMapping(id, ...)` |
165
+ | `billingOptions` | `list()`, `get(id)`, `update(id, ...)`, `delete(id)`, `listSalesChannels(id)`, `createSalesChannelLink(id, ...)` |
166
+ | `memberRoles` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
167
+ | `pricingGroups` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
168
+ | `salesChannels` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` |
169
+ | `targetCodes` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)` — `update` takes `display_name` / `description` only; `code` is immutable |
170
+ | `calendars` | `list(params?)`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listRules(id, params?)`, `createRule(id, ...)` |
171
+ | `calendarRules` | `get(id)`, `update(id, ...)`, `delete(id)` |
172
+ | `planEntitlements` | `get(id)`, `update(id, ...)`, `delete(id)`, `listAvailabilities(id, params?)`, `createAvailability(id, ...)` |
173
+ | `planEntitlementAvailabilities` | `get(id)`, `update(id, ...)`, `delete(id)` |
174
+ | `planLinks` | `delete(id)` |
175
+ | `planPricingGroupMappings` | `delete(id)` |
176
+ | `billingOptionSalesChannels` | `delete(id)` |
177
+ | `webhookSubscriptions` | `list()`, `get(id)`, `create(...)`, `update(id, ...)`, `delete(id)`, `listDeliveries(id, params?)` |
177
178
 
178
179
  Every method accepts a trailing `options` argument: `{ signal?, headers? }`
179
180
  (plus `idempotencyKey?` on the idempotency-keyed mutations: `memberships.create`
@@ -232,3 +233,24 @@ await ophelio.targetCodes.update(venue.id, { display_name: 'Venue A (west)' })
232
233
 
233
234
  To correct a genuine typo, create the right code, repoint whatever uses it, and
234
235
  delete the old one.
236
+
237
+ ### Plan entitlement availabilities
238
+
239
+ An availability row says when and where one plan entitlement applies: a
240
+ `calendar_id` (null means any date) and `targets`, a set of registered target
241
+ codes (an empty array means anywhere).
242
+
243
+ ```ts
244
+ await ophelio.planEntitlements.createAvailability(planEntitlement.id, {
245
+ calendar_id: peak.id,
246
+ targets: ['venue_a'],
247
+ })
248
+ ```
249
+
250
+ Rows **OR**, and the absence of rows is judged **per plan entitlement**: a plan
251
+ entitlement with no rows at all is unrestricted, never restricted to nothing.
252
+ Every code in `targets` must already exist in the project's target code
253
+ vocabulary — an unregistered one is rejected, never registered on the fly.
254
+
255
+ Availability rows can be authored today but nothing reads them yet, so they do
256
+ not restrict admission.
package/dist/index.cjs CHANGED
@@ -126,6 +126,21 @@ const DEFAULT_MAX_RETRIES = 2;
126
126
  function resolveIdempotencyKey(idempotencyKey) {
127
127
  return idempotencyKey?.trim() || crypto.randomUUID();
128
128
  }
129
+ /**
130
+ * Serialises query parameters into a search string.
131
+ *
132
+ * `undefined` drops the parameter entirely. An empty array does not: it emits
133
+ * the bare key (`?status=`), because "filter by nothing" and "do not filter"
134
+ * are different requests and the API distinguishes them.
135
+ */
136
+ function serialiseQuery(query) {
137
+ const search = new URLSearchParams();
138
+ for (const [key, value] of Object.entries(query ?? {})) {
139
+ if (value === void 0) continue;
140
+ search.set(key, Array.isArray(value) ? value.join(",") : value);
141
+ }
142
+ return search.toString();
143
+ }
129
144
  var Transport = class {
130
145
  apiKey;
131
146
  baseUrl;
@@ -180,9 +195,7 @@ var Transport = class {
180
195
  throw lastError;
181
196
  }
182
197
  buildUrl(params) {
183
- const search = new URLSearchParams();
184
- for (const [key, value] of Object.entries(params.query ?? {})) if (value !== void 0) search.set(key, value);
185
- const queryString = search.toString();
198
+ const queryString = serialiseQuery(params.query);
186
199
  return `${this.baseUrl}${params.path}${queryString ? `?${queryString}` : ""}`;
187
200
  }
188
201
  buildHeaders(params) {
@@ -918,6 +931,45 @@ var MembershipsResource = class extends APIResource {
918
931
  }
919
932
  };
920
933
  //#endregion
934
+ //#region src/resources/plan-entitlement-availabilities.ts
935
+ /**
936
+ * An availability row says when and where one plan entitlement applies: a
937
+ * calendar (null = any date) and a set of registered target codes (empty =
938
+ * anywhere). Rows OR, and a plan entitlement with no rows at all is
939
+ * unrestricted.
940
+ *
941
+ * Rows are created and listed through their plan entitlement
942
+ * (`ophelio.planEntitlements.createAvailability` / `listAvailabilities`); this
943
+ * resource addresses an individual row.
944
+ */
945
+ var PlanEntitlementAvailabilitiesResource = class extends APIResource {
946
+ get(id, options) {
947
+ return this.transport.request({
948
+ method: "GET",
949
+ path: `/api/v1/plan-entitlement-availabilities/${encodeURIComponent(id)}`,
950
+ retryable: true,
951
+ options
952
+ });
953
+ }
954
+ update(id, params, options) {
955
+ return this.transport.request({
956
+ method: "PATCH",
957
+ path: `/api/v1/plan-entitlement-availabilities/${encodeURIComponent(id)}`,
958
+ body: params,
959
+ retryable: false,
960
+ options
961
+ });
962
+ }
963
+ async delete(id, options) {
964
+ await this.transport.request({
965
+ method: "DELETE",
966
+ path: `/api/v1/plan-entitlement-availabilities/${encodeURIComponent(id)}`,
967
+ retryable: false,
968
+ options
969
+ });
970
+ }
971
+ };
972
+ //#endregion
921
973
  //#region src/resources/plan-entitlements.ts
922
974
  var PlanEntitlementsResource = class extends APIResource {
923
975
  get(id, options) {
@@ -946,6 +998,29 @@ var PlanEntitlementsResource = class extends APIResource {
946
998
  options
947
999
  });
948
1000
  }
1001
+ async listAvailabilities(id, params, options) {
1002
+ const response = await this.transport.request({
1003
+ method: "GET",
1004
+ path: `/api/v1/plan-entitlements/${encodeURIComponent(id)}/availabilities`,
1005
+ query: pageQuery(params),
1006
+ retryable: true,
1007
+ options
1008
+ });
1009
+ return {
1010
+ items: response.availabilities,
1011
+ next_page_token: response.next_page_token,
1012
+ total_size: response.total_size
1013
+ };
1014
+ }
1015
+ createAvailability(id, params, options) {
1016
+ return this.transport.request({
1017
+ method: "POST",
1018
+ path: `/api/v1/plan-entitlements/${encodeURIComponent(id)}/availabilities`,
1019
+ body: params,
1020
+ retryable: false,
1021
+ options
1022
+ });
1023
+ }
949
1024
  };
950
1025
  //#endregion
951
1026
  //#region src/resources/plan-links.ts
@@ -1376,6 +1451,7 @@ var Ophelio = class Ophelio {
1376
1451
  calendars;
1377
1452
  calendarRules;
1378
1453
  planEntitlements;
1454
+ planEntitlementAvailabilities;
1379
1455
  planLinks;
1380
1456
  planPricingGroupMappings;
1381
1457
  billingOptionSalesChannels;
@@ -1402,6 +1478,7 @@ var Ophelio = class Ophelio {
1402
1478
  this.calendars = new CalendarsResource(transport);
1403
1479
  this.calendarRules = new CalendarRulesResource(transport);
1404
1480
  this.planEntitlements = new PlanEntitlementsResource(transport);
1481
+ this.planEntitlementAvailabilities = new PlanEntitlementAvailabilitiesResource(transport);
1405
1482
  this.planLinks = new PlanLinksResource(transport);
1406
1483
  this.planPricingGroupMappings = new PlanPricingGroupMappingsResource(transport);
1407
1484
  this.billingOptionSalesChannels = new BillingOptionSalesChannelsResource(transport);
package/dist/index.d.cts CHANGED
@@ -27,10 +27,15 @@ interface IdempotentRequestOptions extends RequestOptions {
27
27
  */
28
28
  idempotencyKey?: string;
29
29
  }
30
+ /**
31
+ * A query parameter value. An array is multi-valued: it goes on the wire
32
+ * comma-separated (`?status=pending,failed`), the form the API parses.
33
+ */
34
+ type QueryValue = string | string[] | undefined;
30
35
  interface RequestParams {
31
36
  method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
32
37
  path: string;
33
- query?: Record<string, string | undefined>;
38
+ query?: Record<string, QueryValue>;
34
39
  body?: unknown;
35
40
  idempotencyKey?: string;
36
41
  /**
@@ -446,6 +451,38 @@ interface paths {
446
451
  patch: operations["PlanEntitlementsController_update"];
447
452
  trace?: never;
448
453
  };
454
+ "/api/v1/plan-entitlements/{id}/availabilities": {
455
+ parameters: {
456
+ query?: never;
457
+ header?: never;
458
+ path?: never;
459
+ cookie?: never;
460
+ };
461
+ get: operations["PlanEntitlementsController_listAvailabilities"];
462
+ put?: never;
463
+ post: operations["PlanEntitlementsController_createAvailability"];
464
+ delete?: never;
465
+ options?: never;
466
+ head?: never;
467
+ patch?: never;
468
+ trace?: never;
469
+ };
470
+ "/api/v1/plan-entitlement-availabilities/{id}": {
471
+ parameters: {
472
+ query?: never;
473
+ header?: never;
474
+ path?: never;
475
+ cookie?: never;
476
+ };
477
+ get: operations["PlanEntitlementAvailabilitiesController_get"];
478
+ put?: never;
479
+ post?: never;
480
+ delete: operations["PlanEntitlementAvailabilitiesController_delete"];
481
+ options?: never;
482
+ head?: never;
483
+ patch: operations["PlanEntitlementAvailabilitiesController_update"];
484
+ trace?: never;
485
+ };
449
486
  "/api/v1/plan-pricing-group-mappings/{id}": {
450
487
  parameters: {
451
488
  query?: never;
@@ -1274,12 +1311,27 @@ interface components {
1274
1311
  create_time: string; /** Format: date-time */
1275
1312
  update_time: string;
1276
1313
  };
1314
+ PlanEntitlementAvailability: {
1315
+ /** @description Calendar the row is restricted to. Null means the row places no date restriction. */calendar_id: string | null;
1316
+ /**
1317
+ * @description Registered target codes the row is restricted to. An empty array means anywhere.
1318
+ * @example [
1319
+ * "venue_a"
1320
+ * ]
1321
+ */
1322
+ targets: string[];
1323
+ id: string;
1324
+ plan_entitlement_id: string; /** Format: date-time */
1325
+ create_time: string; /** Format: date-time */
1326
+ update_time: string;
1327
+ };
1277
1328
  PlanEntitlementDefinition: {
1278
1329
  code: string; /** @enum {string} */
1279
1330
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1280
1331
  display_name: string;
1281
1332
  };
1282
1333
  PlanEntitlement: {
1334
+ /** @description When and where the entitlement applies. Rows are alternatives: the entitlement matches if any one of them does. An empty array means it is unrestricted. */availabilities: components["schemas"]["PlanEntitlementAvailability"][];
1283
1335
  id: string;
1284
1336
  plan_id: string;
1285
1337
  entitlement_id: string;
@@ -1383,12 +1435,58 @@ interface components {
1383
1435
  early_access_days: number;
1384
1436
  active_during_grace: boolean;
1385
1437
  };
1438
+ ListPlanEntitlementAvailabilitiesResponse: {
1439
+ /**
1440
+ * @description Opaque token for the next page; empty string on the last page.
1441
+ * @example
1442
+ */
1443
+ next_page_token: string;
1444
+ /**
1445
+ * @description Total number of results across all pages.
1446
+ * @example 42
1447
+ */
1448
+ total_size: number;
1449
+ availabilities: components["schemas"]["PlanEntitlementAvailability"][];
1450
+ };
1451
+ CreatePlanEntitlementAvailabilityDto: {
1452
+ /**
1453
+ * @description Registered target codes the row is restricted to. Omit or send an empty
1454
+ * array for anywhere. Every code must already exist in the project's target
1455
+ * code vocabulary.
1456
+ * @example [
1457
+ * "venue_a"
1458
+ * ]
1459
+ */
1460
+ targets?: string[];
1461
+ /**
1462
+ * Format: uuid
1463
+ * @description Calendar the row is restricted to. Omit or send null for a row that places
1464
+ * no date restriction.
1465
+ */
1466
+ calendar_id?: string | null;
1467
+ };
1468
+ UpdatePlanEntitlementAvailabilityDto: {
1469
+ /**
1470
+ * @description Registered target codes the row is restricted to. Omit or send an empty
1471
+ * array for anywhere. Every code must already exist in the project's target
1472
+ * code vocabulary.
1473
+ * @example [
1474
+ * "venue_a"
1475
+ * ]
1476
+ */
1477
+ targets?: string[];
1478
+ /**
1479
+ * Format: uuid
1480
+ * @description Calendar the row is restricted to. Omit or send null for a row that places
1481
+ * no date restriction.
1482
+ */
1483
+ calendar_id?: string | null;
1484
+ };
1386
1485
  Entitlement: {
1387
1486
  id: string;
1388
1487
  code: string;
1389
1488
  display_name: string; /** @enum {string} */
1390
1489
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1391
- target: string | null;
1392
1490
  description: string | null; /** Format: date-time */
1393
1491
  create_time: string; /** Format: date-time */
1394
1492
  update_time: string;
@@ -1434,13 +1532,11 @@ interface components {
1434
1532
  code: string;
1435
1533
  display_name: string; /** @enum {string} */
1436
1534
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1437
- target: string;
1438
1535
  description: string;
1439
1536
  };
1440
1537
  UpdateEntitlementDto: {
1441
1538
  code: string;
1442
1539
  display_name: string;
1443
- target: string;
1444
1540
  description: string;
1445
1541
  };
1446
1542
  SyncMember: {
@@ -1484,7 +1580,6 @@ interface components {
1484
1580
  MemberEntitlement: {
1485
1581
  code: string; /** @enum {string} */
1486
1582
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1487
- target: string | null;
1488
1583
  display_name: string;
1489
1584
  plan_entitlement_id: string;
1490
1585
  discount_percentage: number | null;
@@ -1627,6 +1722,11 @@ interface components {
1627
1722
  description: string;
1628
1723
  };
1629
1724
  Calendar: {
1725
+ /**
1726
+ * @description How many plan entitlements restrict availability to this calendar. Populated only when `view=full`.
1727
+ * @example 3
1728
+ */
1729
+ plan_entitlement_count?: number;
1630
1730
  id: string; /** @description Stable identifier for the calendar, unique within a project. */
1631
1731
  code: string; /** @description Human-readable name, e.g. "Peak 2026". */
1632
1732
  display_name: string;
@@ -1994,6 +2094,11 @@ interface components {
1994
2094
  */
1995
2095
  code: string; /** @example Venue A */
1996
2096
  display_name: string;
2097
+ /**
2098
+ * @description How many plan entitlements restrict availability to this target. Populated only when `view=full`.
2099
+ * @example 3
2100
+ */
2101
+ plan_entitlement_count?: number;
1997
2102
  id: string;
1998
2103
  description: string | null; /** Format: date-time */
1999
2104
  create_time: string; /** Format: date-time */
@@ -3121,6 +3226,168 @@ interface operations {
3121
3226
  };
3122
3227
  };
3123
3228
  };
3229
+ PlanEntitlementsController_listAvailabilities: {
3230
+ parameters: {
3231
+ query?: {
3232
+ page_size?: number;
3233
+ page_token?: string;
3234
+ };
3235
+ header?: never;
3236
+ path?: never;
3237
+ cookie?: never;
3238
+ };
3239
+ requestBody?: never;
3240
+ responses: {
3241
+ 200: {
3242
+ headers: {
3243
+ [name: string]: unknown;
3244
+ };
3245
+ content: {
3246
+ "application/json": components["schemas"]["ListPlanEntitlementAvailabilitiesResponse"];
3247
+ };
3248
+ };
3249
+ 404: {
3250
+ headers: {
3251
+ [name: string]: unknown;
3252
+ };
3253
+ content: {
3254
+ "application/json": components["schemas"]["ErrorResponse"];
3255
+ };
3256
+ };
3257
+ };
3258
+ };
3259
+ PlanEntitlementsController_createAvailability: {
3260
+ parameters: {
3261
+ query?: never;
3262
+ header?: never;
3263
+ path?: never;
3264
+ cookie?: never;
3265
+ };
3266
+ requestBody: {
3267
+ content: {
3268
+ "application/json": components["schemas"]["CreatePlanEntitlementAvailabilityDto"];
3269
+ };
3270
+ };
3271
+ responses: {
3272
+ 201: {
3273
+ headers: {
3274
+ [name: string]: unknown;
3275
+ };
3276
+ content: {
3277
+ "application/json": components["schemas"]["PlanEntitlementAvailability"];
3278
+ };
3279
+ };
3280
+ 400: {
3281
+ headers: {
3282
+ [name: string]: unknown;
3283
+ };
3284
+ content: {
3285
+ "application/json": components["schemas"]["ErrorResponse"];
3286
+ };
3287
+ };
3288
+ 404: {
3289
+ headers: {
3290
+ [name: string]: unknown;
3291
+ };
3292
+ content: {
3293
+ "application/json": components["schemas"]["ErrorResponse"];
3294
+ };
3295
+ };
3296
+ };
3297
+ };
3298
+ PlanEntitlementAvailabilitiesController_get: {
3299
+ parameters: {
3300
+ query?: never;
3301
+ header?: never;
3302
+ path?: never;
3303
+ cookie?: never;
3304
+ };
3305
+ requestBody?: never;
3306
+ responses: {
3307
+ 200: {
3308
+ headers: {
3309
+ [name: string]: unknown;
3310
+ };
3311
+ content: {
3312
+ "application/json": components["schemas"]["PlanEntitlementAvailability"];
3313
+ };
3314
+ };
3315
+ 404: {
3316
+ headers: {
3317
+ [name: string]: unknown;
3318
+ };
3319
+ content: {
3320
+ "application/json": components["schemas"]["ErrorResponse"];
3321
+ };
3322
+ };
3323
+ };
3324
+ };
3325
+ PlanEntitlementAvailabilitiesController_delete: {
3326
+ parameters: {
3327
+ query?: never;
3328
+ header?: never;
3329
+ path?: never;
3330
+ cookie?: never;
3331
+ };
3332
+ requestBody?: never;
3333
+ responses: {
3334
+ 200: {
3335
+ headers: {
3336
+ [name: string]: unknown;
3337
+ };
3338
+ content: {
3339
+ "application/json": Record<string, never>;
3340
+ };
3341
+ };
3342
+ 404: {
3343
+ headers: {
3344
+ [name: string]: unknown;
3345
+ };
3346
+ content: {
3347
+ "application/json": components["schemas"]["ErrorResponse"];
3348
+ };
3349
+ };
3350
+ };
3351
+ };
3352
+ PlanEntitlementAvailabilitiesController_update: {
3353
+ parameters: {
3354
+ query?: never;
3355
+ header?: never;
3356
+ path?: never;
3357
+ cookie?: never;
3358
+ };
3359
+ requestBody: {
3360
+ content: {
3361
+ "application/json": components["schemas"]["UpdatePlanEntitlementAvailabilityDto"];
3362
+ };
3363
+ };
3364
+ responses: {
3365
+ 200: {
3366
+ headers: {
3367
+ [name: string]: unknown;
3368
+ };
3369
+ content: {
3370
+ "application/json": components["schemas"]["PlanEntitlementAvailability"];
3371
+ };
3372
+ };
3373
+ 400: {
3374
+ headers: {
3375
+ [name: string]: unknown;
3376
+ };
3377
+ content: {
3378
+ "application/json": components["schemas"]["ErrorResponse"];
3379
+ };
3380
+ };
3381
+ 404: {
3382
+ headers: {
3383
+ [name: string]: unknown;
3384
+ };
3385
+ content: {
3386
+ "application/json": components["schemas"]["ErrorResponse"];
3387
+ };
3388
+ };
3389
+ };
3390
+ };
3124
3391
  PlanPricingGroupMappingsController_delete: {
3125
3392
  parameters: {
3126
3393
  query?: never;
@@ -4008,7 +4275,8 @@ interface operations {
4008
4275
  parameters: {
4009
4276
  query?: {
4010
4277
  page_size?: number;
4011
- page_token?: string;
4278
+ page_token?: string; /** @description Response detail level; `full` populates `plan_entitlement_count`. */
4279
+ view?: "basic" | "full";
4012
4280
  };
4013
4281
  header?: never;
4014
4282
  path?: never;
@@ -4059,7 +4327,9 @@ interface operations {
4059
4327
  };
4060
4328
  CalendarsController_get: {
4061
4329
  parameters: {
4062
- query?: never;
4330
+ query?: {
4331
+ /** @description Response detail level; `full` populates `plan_entitlement_count`. */view?: "basic" | "full";
4332
+ };
4063
4333
  header?: never;
4064
4334
  path?: never;
4065
4335
  cookie?: never;
@@ -4992,7 +5262,8 @@ interface operations {
4992
5262
  parameters: {
4993
5263
  query?: {
4994
5264
  page_size?: number;
4995
- page_token?: string;
5265
+ page_token?: string; /** @description Response detail level; `full` populates `plan_entitlement_count`. */
5266
+ view?: "basic" | "full";
4996
5267
  };
4997
5268
  header?: never;
4998
5269
  path?: never;
@@ -5051,7 +5322,9 @@ interface operations {
5051
5322
  };
5052
5323
  TargetCodesController_get: {
5053
5324
  parameters: {
5054
- query?: never;
5325
+ query?: {
5326
+ /** @description Response detail level; `full` populates `plan_entitlement_count`. */view?: "basic" | "full";
5327
+ };
5055
5328
  header?: never;
5056
5329
  path?: never;
5057
5330
  cookie?: never;
@@ -5297,6 +5570,7 @@ type Member = Schemas['Member'];
5297
5570
  type SyncMember = Schemas['SyncMember'];
5298
5571
  type MemberEntitlement = Schemas['MemberEntitlement'];
5299
5572
  type PlanEntitlement = Schemas['PlanEntitlement'];
5573
+ type PlanEntitlementAvailability = Schemas['PlanEntitlementAvailability'];
5300
5574
  type Transaction = Schemas['Transaction'];
5301
5575
  type EntitlementUsage = Schemas['EntitlementUsage'];
5302
5576
  type AdmitResult = Schemas['AdmitResult'];
@@ -5363,6 +5637,8 @@ type UpdateEntitlementParams = Schemas['UpdateEntitlementDto'];
5363
5637
  type CreatePlanLinkParams = Schemas['CreatePlanLinkDto'];
5364
5638
  type CreatePlanEntitlementParams = Schemas['CreatePlanEntitlementDto'];
5365
5639
  type UpdatePlanEntitlementParams = Schemas['UpdatePlanEntitlementDto'];
5640
+ type CreatePlanEntitlementAvailabilityParams = Schemas['CreatePlanEntitlementAvailabilityDto'];
5641
+ type UpdatePlanEntitlementAvailabilityParams = Schemas['UpdatePlanEntitlementAvailabilityDto'];
5366
5642
  type CreatePlanPricingGroupMappingParams = Schemas['CreatePlanPricingGroupMappingDto'];
5367
5643
  type CreateBillingOptionSalesChannelParams = Schemas['CreateBillingOptionSalesChannelDto'];
5368
5644
  type CreateWebhookSubscriptionParams = Schemas['CreateWebhookSubscriptionDto'];
@@ -5569,12 +5845,31 @@ declare class MembershipsResource extends APIResource {
5569
5845
  listTermTransactions(id: string, termId: string, params?: PageParams, options?: RequestOptions): Promise<Page<Transaction>>;
5570
5846
  }
5571
5847
  //#endregion
5848
+ //#region src/resources/plan-entitlement-availabilities.d.ts
5849
+ /**
5850
+ * An availability row says when and where one plan entitlement applies: a
5851
+ * calendar (null = any date) and a set of registered target codes (empty =
5852
+ * anywhere). Rows OR, and a plan entitlement with no rows at all is
5853
+ * unrestricted.
5854
+ *
5855
+ * Rows are created and listed through their plan entitlement
5856
+ * (`ophelio.planEntitlements.createAvailability` / `listAvailabilities`); this
5857
+ * resource addresses an individual row.
5858
+ */
5859
+ declare class PlanEntitlementAvailabilitiesResource extends APIResource {
5860
+ get(id: string, options?: RequestOptions): Promise<PlanEntitlementAvailability>;
5861
+ update(id: string, params: UpdatePlanEntitlementAvailabilityParams, options?: RequestOptions): Promise<PlanEntitlementAvailability>;
5862
+ delete(id: string, options?: RequestOptions): Promise<void>;
5863
+ }
5864
+ //#endregion
5572
5865
  //#region src/resources/plan-entitlements.d.ts
5573
5866
  declare class PlanEntitlementsResource extends APIResource {
5574
5867
  get(id: string, options?: RequestOptions): Promise<PlanEntitlement>;
5575
5868
  update(id: string, params: UpdatePlanEntitlementParams, options?: RequestOptions): Promise<PlanEntitlement>;
5576
5869
  /** Detach an entitlement from its plan. Attach via plans.createEntitlement(). */
5577
5870
  delete(id: string, options?: RequestOptions): Promise<void>;
5871
+ listAvailabilities(id: string, params?: PageParams, options?: RequestOptions): Promise<Page<PlanEntitlementAvailability>>;
5872
+ createAvailability(id: string, params: CreatePlanEntitlementAvailabilityParams, options?: RequestOptions): Promise<PlanEntitlementAvailability>;
5578
5873
  }
5579
5874
  //#endregion
5580
5875
  //#region src/resources/plan-links.d.ts
@@ -5728,6 +6023,7 @@ declare class Ophelio {
5728
6023
  readonly calendars: CalendarsResource;
5729
6024
  readonly calendarRules: CalendarRulesResource;
5730
6025
  readonly planEntitlements: PlanEntitlementsResource;
6026
+ readonly planEntitlementAvailabilities: PlanEntitlementAvailabilitiesResource;
5731
6027
  readonly planLinks: PlanLinksResource;
5732
6028
  readonly planPricingGroupMappings: PlanPricingGroupMappingsResource;
5733
6029
  readonly billingOptionSalesChannels: BillingOptionSalesChannelsResource;
@@ -5810,4 +6106,4 @@ declare function paginate<T>(fetchPage: (params: PageParams) => Promise<Page<T>>
5810
6106
  */
5811
6107
  declare function collect<T>(fetchPage: (params: PageParams) => Promise<Page<T>>, params?: PageParams): Promise<T[]>;
5812
6108
  //#endregion
5813
- export { AddMemberParams, AdmitResult, AlreadyExistsError, BillingOption, BillingOptionSalesChannel, Calendar, CalendarRule, CancelMembershipParams, CreateBillingOptionParams, CreateBillingOptionSalesChannelParams, CreateCalendarParams, CreateCalendarRuleParams, CreateCustomerParams, CreateEntitlementParams, CreateMemberRoleParams, CreateMembershipParams, CreatePlanEntitlementParams, CreatePlanLinkParams, CreatePlanParams, CreatePlanPricingGroupMappingParams, CreatePricingGroupParams, CreateSalesChannelParams, CreateTargetCodeParams, CreateTransactionParams, CreateWebhookSubscriptionParams, Customer, CustomerMembershipSummary, CustomerView, DEFAULT_BASE_URL, Entitlement, EntitlementType, EntitlementUsage, type IdempotentRequestOptions, InternalError, InvalidArgumentError, Member, MemberEntitlement, MemberRole, MemberSyncResponse, Membership, MembershipTerm, NotFoundError, Ophelio, OphelioConnectionError, OphelioError, type OphelioOptions, OphelioTimeoutError, type OphelioWebhookEvent, Page, PageParams, PermissionDeniedError, Plan, PlanChangeParams, PlanChangeResult, PlanEntitlement, PlanLink, PlanLinkView, PlanPricingGroupMapping, PricingGroup, RecordUsageParams, RedeemEntitlementParams, RedeemEntitlementResponse, ReissueCardParams, RenewMembershipParams, type RequestOptions, ResourceExhaustedError, SalesChannel, ScheduledChange, SyncMember, TargetCode, Transaction, UnauthenticatedError, UnavailableError, UnimplementedError, UpdateBillingOptionParams, UpdateCalendarParams, UpdateCalendarRuleParams, UpdateCustomerParams, UpdateEntitlementParams, UpdateMemberParams, UpdateMemberRoleParams, UpdateMembershipParams, UpdatePlanEntitlementParams, UpdatePlanParams, UpdatePricingGroupParams, UpdateSalesChannelParams, UpdateTargetCodeParams, UpdateWebhookSubscriptionParams, WEBHOOK_EVENT_CODES, WebhookDelivery, type WebhookEventCode, WebhookSignatureVerificationError, WebhookSubscription, collect, type components, constructEvent, type operations, paginate, type paths, verifyWebhookSignature };
6109
+ export { AddMemberParams, AdmitResult, AlreadyExistsError, BillingOption, BillingOptionSalesChannel, Calendar, CalendarRule, CancelMembershipParams, CreateBillingOptionParams, CreateBillingOptionSalesChannelParams, CreateCalendarParams, CreateCalendarRuleParams, CreateCustomerParams, CreateEntitlementParams, CreateMemberRoleParams, CreateMembershipParams, CreatePlanEntitlementAvailabilityParams, CreatePlanEntitlementParams, CreatePlanLinkParams, CreatePlanParams, CreatePlanPricingGroupMappingParams, CreatePricingGroupParams, CreateSalesChannelParams, CreateTargetCodeParams, CreateTransactionParams, CreateWebhookSubscriptionParams, Customer, CustomerMembershipSummary, CustomerView, DEFAULT_BASE_URL, Entitlement, EntitlementType, EntitlementUsage, type IdempotentRequestOptions, InternalError, InvalidArgumentError, Member, MemberEntitlement, MemberRole, MemberSyncResponse, Membership, MembershipTerm, NotFoundError, Ophelio, OphelioConnectionError, OphelioError, type OphelioOptions, OphelioTimeoutError, type OphelioWebhookEvent, Page, PageParams, PermissionDeniedError, Plan, PlanChangeParams, PlanChangeResult, PlanEntitlement, PlanEntitlementAvailability, PlanLink, PlanLinkView, PlanPricingGroupMapping, PricingGroup, RecordUsageParams, RedeemEntitlementParams, RedeemEntitlementResponse, ReissueCardParams, RenewMembershipParams, type RequestOptions, ResourceExhaustedError, SalesChannel, ScheduledChange, SyncMember, TargetCode, Transaction, UnauthenticatedError, UnavailableError, UnimplementedError, UpdateBillingOptionParams, UpdateCalendarParams, UpdateCalendarRuleParams, UpdateCustomerParams, UpdateEntitlementParams, UpdateMemberParams, UpdateMemberRoleParams, UpdateMembershipParams, UpdatePlanEntitlementAvailabilityParams, UpdatePlanEntitlementParams, UpdatePlanParams, UpdatePricingGroupParams, UpdateSalesChannelParams, UpdateTargetCodeParams, UpdateWebhookSubscriptionParams, WEBHOOK_EVENT_CODES, WebhookDelivery, type WebhookEventCode, WebhookSignatureVerificationError, WebhookSubscription, collect, type components, constructEvent, type operations, paginate, type paths, verifyWebhookSignature };
package/dist/index.d.mts CHANGED
@@ -27,10 +27,15 @@ interface IdempotentRequestOptions extends RequestOptions {
27
27
  */
28
28
  idempotencyKey?: string;
29
29
  }
30
+ /**
31
+ * A query parameter value. An array is multi-valued: it goes on the wire
32
+ * comma-separated (`?status=pending,failed`), the form the API parses.
33
+ */
34
+ type QueryValue = string | string[] | undefined;
30
35
  interface RequestParams {
31
36
  method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
32
37
  path: string;
33
- query?: Record<string, string | undefined>;
38
+ query?: Record<string, QueryValue>;
34
39
  body?: unknown;
35
40
  idempotencyKey?: string;
36
41
  /**
@@ -446,6 +451,38 @@ interface paths {
446
451
  patch: operations["PlanEntitlementsController_update"];
447
452
  trace?: never;
448
453
  };
454
+ "/api/v1/plan-entitlements/{id}/availabilities": {
455
+ parameters: {
456
+ query?: never;
457
+ header?: never;
458
+ path?: never;
459
+ cookie?: never;
460
+ };
461
+ get: operations["PlanEntitlementsController_listAvailabilities"];
462
+ put?: never;
463
+ post: operations["PlanEntitlementsController_createAvailability"];
464
+ delete?: never;
465
+ options?: never;
466
+ head?: never;
467
+ patch?: never;
468
+ trace?: never;
469
+ };
470
+ "/api/v1/plan-entitlement-availabilities/{id}": {
471
+ parameters: {
472
+ query?: never;
473
+ header?: never;
474
+ path?: never;
475
+ cookie?: never;
476
+ };
477
+ get: operations["PlanEntitlementAvailabilitiesController_get"];
478
+ put?: never;
479
+ post?: never;
480
+ delete: operations["PlanEntitlementAvailabilitiesController_delete"];
481
+ options?: never;
482
+ head?: never;
483
+ patch: operations["PlanEntitlementAvailabilitiesController_update"];
484
+ trace?: never;
485
+ };
449
486
  "/api/v1/plan-pricing-group-mappings/{id}": {
450
487
  parameters: {
451
488
  query?: never;
@@ -1274,12 +1311,27 @@ interface components {
1274
1311
  create_time: string; /** Format: date-time */
1275
1312
  update_time: string;
1276
1313
  };
1314
+ PlanEntitlementAvailability: {
1315
+ /** @description Calendar the row is restricted to. Null means the row places no date restriction. */calendar_id: string | null;
1316
+ /**
1317
+ * @description Registered target codes the row is restricted to. An empty array means anywhere.
1318
+ * @example [
1319
+ * "venue_a"
1320
+ * ]
1321
+ */
1322
+ targets: string[];
1323
+ id: string;
1324
+ plan_entitlement_id: string; /** Format: date-time */
1325
+ create_time: string; /** Format: date-time */
1326
+ update_time: string;
1327
+ };
1277
1328
  PlanEntitlementDefinition: {
1278
1329
  code: string; /** @enum {string} */
1279
1330
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1280
1331
  display_name: string;
1281
1332
  };
1282
1333
  PlanEntitlement: {
1334
+ /** @description When and where the entitlement applies. Rows are alternatives: the entitlement matches if any one of them does. An empty array means it is unrestricted. */availabilities: components["schemas"]["PlanEntitlementAvailability"][];
1283
1335
  id: string;
1284
1336
  plan_id: string;
1285
1337
  entitlement_id: string;
@@ -1383,12 +1435,58 @@ interface components {
1383
1435
  early_access_days: number;
1384
1436
  active_during_grace: boolean;
1385
1437
  };
1438
+ ListPlanEntitlementAvailabilitiesResponse: {
1439
+ /**
1440
+ * @description Opaque token for the next page; empty string on the last page.
1441
+ * @example
1442
+ */
1443
+ next_page_token: string;
1444
+ /**
1445
+ * @description Total number of results across all pages.
1446
+ * @example 42
1447
+ */
1448
+ total_size: number;
1449
+ availabilities: components["schemas"]["PlanEntitlementAvailability"][];
1450
+ };
1451
+ CreatePlanEntitlementAvailabilityDto: {
1452
+ /**
1453
+ * @description Registered target codes the row is restricted to. Omit or send an empty
1454
+ * array for anywhere. Every code must already exist in the project's target
1455
+ * code vocabulary.
1456
+ * @example [
1457
+ * "venue_a"
1458
+ * ]
1459
+ */
1460
+ targets?: string[];
1461
+ /**
1462
+ * Format: uuid
1463
+ * @description Calendar the row is restricted to. Omit or send null for a row that places
1464
+ * no date restriction.
1465
+ */
1466
+ calendar_id?: string | null;
1467
+ };
1468
+ UpdatePlanEntitlementAvailabilityDto: {
1469
+ /**
1470
+ * @description Registered target codes the row is restricted to. Omit or send an empty
1471
+ * array for anywhere. Every code must already exist in the project's target
1472
+ * code vocabulary.
1473
+ * @example [
1474
+ * "venue_a"
1475
+ * ]
1476
+ */
1477
+ targets?: string[];
1478
+ /**
1479
+ * Format: uuid
1480
+ * @description Calendar the row is restricted to. Omit or send null for a row that places
1481
+ * no date restriction.
1482
+ */
1483
+ calendar_id?: string | null;
1484
+ };
1386
1485
  Entitlement: {
1387
1486
  id: string;
1388
1487
  code: string;
1389
1488
  display_name: string; /** @enum {string} */
1390
1489
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1391
- target: string | null;
1392
1490
  description: string | null; /** Format: date-time */
1393
1491
  create_time: string; /** Format: date-time */
1394
1492
  update_time: string;
@@ -1434,13 +1532,11 @@ interface components {
1434
1532
  code: string;
1435
1533
  display_name: string; /** @enum {string} */
1436
1534
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1437
- target: string;
1438
1535
  description: string;
1439
1536
  };
1440
1537
  UpdateEntitlementDto: {
1441
1538
  code: string;
1442
1539
  display_name: string;
1443
- target: string;
1444
1540
  description: string;
1445
1541
  };
1446
1542
  SyncMember: {
@@ -1484,7 +1580,6 @@ interface components {
1484
1580
  MemberEntitlement: {
1485
1581
  code: string; /** @enum {string} */
1486
1582
  type: "discount" | "early_access" | "free_entry" | "guest_pass";
1487
- target: string | null;
1488
1583
  display_name: string;
1489
1584
  plan_entitlement_id: string;
1490
1585
  discount_percentage: number | null;
@@ -1627,6 +1722,11 @@ interface components {
1627
1722
  description: string;
1628
1723
  };
1629
1724
  Calendar: {
1725
+ /**
1726
+ * @description How many plan entitlements restrict availability to this calendar. Populated only when `view=full`.
1727
+ * @example 3
1728
+ */
1729
+ plan_entitlement_count?: number;
1630
1730
  id: string; /** @description Stable identifier for the calendar, unique within a project. */
1631
1731
  code: string; /** @description Human-readable name, e.g. "Peak 2026". */
1632
1732
  display_name: string;
@@ -1994,6 +2094,11 @@ interface components {
1994
2094
  */
1995
2095
  code: string; /** @example Venue A */
1996
2096
  display_name: string;
2097
+ /**
2098
+ * @description How many plan entitlements restrict availability to this target. Populated only when `view=full`.
2099
+ * @example 3
2100
+ */
2101
+ plan_entitlement_count?: number;
1997
2102
  id: string;
1998
2103
  description: string | null; /** Format: date-time */
1999
2104
  create_time: string; /** Format: date-time */
@@ -3121,6 +3226,168 @@ interface operations {
3121
3226
  };
3122
3227
  };
3123
3228
  };
3229
+ PlanEntitlementsController_listAvailabilities: {
3230
+ parameters: {
3231
+ query?: {
3232
+ page_size?: number;
3233
+ page_token?: string;
3234
+ };
3235
+ header?: never;
3236
+ path?: never;
3237
+ cookie?: never;
3238
+ };
3239
+ requestBody?: never;
3240
+ responses: {
3241
+ 200: {
3242
+ headers: {
3243
+ [name: string]: unknown;
3244
+ };
3245
+ content: {
3246
+ "application/json": components["schemas"]["ListPlanEntitlementAvailabilitiesResponse"];
3247
+ };
3248
+ };
3249
+ 404: {
3250
+ headers: {
3251
+ [name: string]: unknown;
3252
+ };
3253
+ content: {
3254
+ "application/json": components["schemas"]["ErrorResponse"];
3255
+ };
3256
+ };
3257
+ };
3258
+ };
3259
+ PlanEntitlementsController_createAvailability: {
3260
+ parameters: {
3261
+ query?: never;
3262
+ header?: never;
3263
+ path?: never;
3264
+ cookie?: never;
3265
+ };
3266
+ requestBody: {
3267
+ content: {
3268
+ "application/json": components["schemas"]["CreatePlanEntitlementAvailabilityDto"];
3269
+ };
3270
+ };
3271
+ responses: {
3272
+ 201: {
3273
+ headers: {
3274
+ [name: string]: unknown;
3275
+ };
3276
+ content: {
3277
+ "application/json": components["schemas"]["PlanEntitlementAvailability"];
3278
+ };
3279
+ };
3280
+ 400: {
3281
+ headers: {
3282
+ [name: string]: unknown;
3283
+ };
3284
+ content: {
3285
+ "application/json": components["schemas"]["ErrorResponse"];
3286
+ };
3287
+ };
3288
+ 404: {
3289
+ headers: {
3290
+ [name: string]: unknown;
3291
+ };
3292
+ content: {
3293
+ "application/json": components["schemas"]["ErrorResponse"];
3294
+ };
3295
+ };
3296
+ };
3297
+ };
3298
+ PlanEntitlementAvailabilitiesController_get: {
3299
+ parameters: {
3300
+ query?: never;
3301
+ header?: never;
3302
+ path?: never;
3303
+ cookie?: never;
3304
+ };
3305
+ requestBody?: never;
3306
+ responses: {
3307
+ 200: {
3308
+ headers: {
3309
+ [name: string]: unknown;
3310
+ };
3311
+ content: {
3312
+ "application/json": components["schemas"]["PlanEntitlementAvailability"];
3313
+ };
3314
+ };
3315
+ 404: {
3316
+ headers: {
3317
+ [name: string]: unknown;
3318
+ };
3319
+ content: {
3320
+ "application/json": components["schemas"]["ErrorResponse"];
3321
+ };
3322
+ };
3323
+ };
3324
+ };
3325
+ PlanEntitlementAvailabilitiesController_delete: {
3326
+ parameters: {
3327
+ query?: never;
3328
+ header?: never;
3329
+ path?: never;
3330
+ cookie?: never;
3331
+ };
3332
+ requestBody?: never;
3333
+ responses: {
3334
+ 200: {
3335
+ headers: {
3336
+ [name: string]: unknown;
3337
+ };
3338
+ content: {
3339
+ "application/json": Record<string, never>;
3340
+ };
3341
+ };
3342
+ 404: {
3343
+ headers: {
3344
+ [name: string]: unknown;
3345
+ };
3346
+ content: {
3347
+ "application/json": components["schemas"]["ErrorResponse"];
3348
+ };
3349
+ };
3350
+ };
3351
+ };
3352
+ PlanEntitlementAvailabilitiesController_update: {
3353
+ parameters: {
3354
+ query?: never;
3355
+ header?: never;
3356
+ path?: never;
3357
+ cookie?: never;
3358
+ };
3359
+ requestBody: {
3360
+ content: {
3361
+ "application/json": components["schemas"]["UpdatePlanEntitlementAvailabilityDto"];
3362
+ };
3363
+ };
3364
+ responses: {
3365
+ 200: {
3366
+ headers: {
3367
+ [name: string]: unknown;
3368
+ };
3369
+ content: {
3370
+ "application/json": components["schemas"]["PlanEntitlementAvailability"];
3371
+ };
3372
+ };
3373
+ 400: {
3374
+ headers: {
3375
+ [name: string]: unknown;
3376
+ };
3377
+ content: {
3378
+ "application/json": components["schemas"]["ErrorResponse"];
3379
+ };
3380
+ };
3381
+ 404: {
3382
+ headers: {
3383
+ [name: string]: unknown;
3384
+ };
3385
+ content: {
3386
+ "application/json": components["schemas"]["ErrorResponse"];
3387
+ };
3388
+ };
3389
+ };
3390
+ };
3124
3391
  PlanPricingGroupMappingsController_delete: {
3125
3392
  parameters: {
3126
3393
  query?: never;
@@ -4008,7 +4275,8 @@ interface operations {
4008
4275
  parameters: {
4009
4276
  query?: {
4010
4277
  page_size?: number;
4011
- page_token?: string;
4278
+ page_token?: string; /** @description Response detail level; `full` populates `plan_entitlement_count`. */
4279
+ view?: "basic" | "full";
4012
4280
  };
4013
4281
  header?: never;
4014
4282
  path?: never;
@@ -4059,7 +4327,9 @@ interface operations {
4059
4327
  };
4060
4328
  CalendarsController_get: {
4061
4329
  parameters: {
4062
- query?: never;
4330
+ query?: {
4331
+ /** @description Response detail level; `full` populates `plan_entitlement_count`. */view?: "basic" | "full";
4332
+ };
4063
4333
  header?: never;
4064
4334
  path?: never;
4065
4335
  cookie?: never;
@@ -4992,7 +5262,8 @@ interface operations {
4992
5262
  parameters: {
4993
5263
  query?: {
4994
5264
  page_size?: number;
4995
- page_token?: string;
5265
+ page_token?: string; /** @description Response detail level; `full` populates `plan_entitlement_count`. */
5266
+ view?: "basic" | "full";
4996
5267
  };
4997
5268
  header?: never;
4998
5269
  path?: never;
@@ -5051,7 +5322,9 @@ interface operations {
5051
5322
  };
5052
5323
  TargetCodesController_get: {
5053
5324
  parameters: {
5054
- query?: never;
5325
+ query?: {
5326
+ /** @description Response detail level; `full` populates `plan_entitlement_count`. */view?: "basic" | "full";
5327
+ };
5055
5328
  header?: never;
5056
5329
  path?: never;
5057
5330
  cookie?: never;
@@ -5297,6 +5570,7 @@ type Member = Schemas['Member'];
5297
5570
  type SyncMember = Schemas['SyncMember'];
5298
5571
  type MemberEntitlement = Schemas['MemberEntitlement'];
5299
5572
  type PlanEntitlement = Schemas['PlanEntitlement'];
5573
+ type PlanEntitlementAvailability = Schemas['PlanEntitlementAvailability'];
5300
5574
  type Transaction = Schemas['Transaction'];
5301
5575
  type EntitlementUsage = Schemas['EntitlementUsage'];
5302
5576
  type AdmitResult = Schemas['AdmitResult'];
@@ -5363,6 +5637,8 @@ type UpdateEntitlementParams = Schemas['UpdateEntitlementDto'];
5363
5637
  type CreatePlanLinkParams = Schemas['CreatePlanLinkDto'];
5364
5638
  type CreatePlanEntitlementParams = Schemas['CreatePlanEntitlementDto'];
5365
5639
  type UpdatePlanEntitlementParams = Schemas['UpdatePlanEntitlementDto'];
5640
+ type CreatePlanEntitlementAvailabilityParams = Schemas['CreatePlanEntitlementAvailabilityDto'];
5641
+ type UpdatePlanEntitlementAvailabilityParams = Schemas['UpdatePlanEntitlementAvailabilityDto'];
5366
5642
  type CreatePlanPricingGroupMappingParams = Schemas['CreatePlanPricingGroupMappingDto'];
5367
5643
  type CreateBillingOptionSalesChannelParams = Schemas['CreateBillingOptionSalesChannelDto'];
5368
5644
  type CreateWebhookSubscriptionParams = Schemas['CreateWebhookSubscriptionDto'];
@@ -5569,12 +5845,31 @@ declare class MembershipsResource extends APIResource {
5569
5845
  listTermTransactions(id: string, termId: string, params?: PageParams, options?: RequestOptions): Promise<Page<Transaction>>;
5570
5846
  }
5571
5847
  //#endregion
5848
+ //#region src/resources/plan-entitlement-availabilities.d.ts
5849
+ /**
5850
+ * An availability row says when and where one plan entitlement applies: a
5851
+ * calendar (null = any date) and a set of registered target codes (empty =
5852
+ * anywhere). Rows OR, and a plan entitlement with no rows at all is
5853
+ * unrestricted.
5854
+ *
5855
+ * Rows are created and listed through their plan entitlement
5856
+ * (`ophelio.planEntitlements.createAvailability` / `listAvailabilities`); this
5857
+ * resource addresses an individual row.
5858
+ */
5859
+ declare class PlanEntitlementAvailabilitiesResource extends APIResource {
5860
+ get(id: string, options?: RequestOptions): Promise<PlanEntitlementAvailability>;
5861
+ update(id: string, params: UpdatePlanEntitlementAvailabilityParams, options?: RequestOptions): Promise<PlanEntitlementAvailability>;
5862
+ delete(id: string, options?: RequestOptions): Promise<void>;
5863
+ }
5864
+ //#endregion
5572
5865
  //#region src/resources/plan-entitlements.d.ts
5573
5866
  declare class PlanEntitlementsResource extends APIResource {
5574
5867
  get(id: string, options?: RequestOptions): Promise<PlanEntitlement>;
5575
5868
  update(id: string, params: UpdatePlanEntitlementParams, options?: RequestOptions): Promise<PlanEntitlement>;
5576
5869
  /** Detach an entitlement from its plan. Attach via plans.createEntitlement(). */
5577
5870
  delete(id: string, options?: RequestOptions): Promise<void>;
5871
+ listAvailabilities(id: string, params?: PageParams, options?: RequestOptions): Promise<Page<PlanEntitlementAvailability>>;
5872
+ createAvailability(id: string, params: CreatePlanEntitlementAvailabilityParams, options?: RequestOptions): Promise<PlanEntitlementAvailability>;
5578
5873
  }
5579
5874
  //#endregion
5580
5875
  //#region src/resources/plan-links.d.ts
@@ -5728,6 +6023,7 @@ declare class Ophelio {
5728
6023
  readonly calendars: CalendarsResource;
5729
6024
  readonly calendarRules: CalendarRulesResource;
5730
6025
  readonly planEntitlements: PlanEntitlementsResource;
6026
+ readonly planEntitlementAvailabilities: PlanEntitlementAvailabilitiesResource;
5731
6027
  readonly planLinks: PlanLinksResource;
5732
6028
  readonly planPricingGroupMappings: PlanPricingGroupMappingsResource;
5733
6029
  readonly billingOptionSalesChannels: BillingOptionSalesChannelsResource;
@@ -5810,4 +6106,4 @@ declare function paginate<T>(fetchPage: (params: PageParams) => Promise<Page<T>>
5810
6106
  */
5811
6107
  declare function collect<T>(fetchPage: (params: PageParams) => Promise<Page<T>>, params?: PageParams): Promise<T[]>;
5812
6108
  //#endregion
5813
- export { AddMemberParams, AdmitResult, AlreadyExistsError, BillingOption, BillingOptionSalesChannel, Calendar, CalendarRule, CancelMembershipParams, CreateBillingOptionParams, CreateBillingOptionSalesChannelParams, CreateCalendarParams, CreateCalendarRuleParams, CreateCustomerParams, CreateEntitlementParams, CreateMemberRoleParams, CreateMembershipParams, CreatePlanEntitlementParams, CreatePlanLinkParams, CreatePlanParams, CreatePlanPricingGroupMappingParams, CreatePricingGroupParams, CreateSalesChannelParams, CreateTargetCodeParams, CreateTransactionParams, CreateWebhookSubscriptionParams, Customer, CustomerMembershipSummary, CustomerView, DEFAULT_BASE_URL, Entitlement, EntitlementType, EntitlementUsage, type IdempotentRequestOptions, InternalError, InvalidArgumentError, Member, MemberEntitlement, MemberRole, MemberSyncResponse, Membership, MembershipTerm, NotFoundError, Ophelio, OphelioConnectionError, OphelioError, type OphelioOptions, OphelioTimeoutError, type OphelioWebhookEvent, Page, PageParams, PermissionDeniedError, Plan, PlanChangeParams, PlanChangeResult, PlanEntitlement, PlanLink, PlanLinkView, PlanPricingGroupMapping, PricingGroup, RecordUsageParams, RedeemEntitlementParams, RedeemEntitlementResponse, ReissueCardParams, RenewMembershipParams, type RequestOptions, ResourceExhaustedError, SalesChannel, ScheduledChange, SyncMember, TargetCode, Transaction, UnauthenticatedError, UnavailableError, UnimplementedError, UpdateBillingOptionParams, UpdateCalendarParams, UpdateCalendarRuleParams, UpdateCustomerParams, UpdateEntitlementParams, UpdateMemberParams, UpdateMemberRoleParams, UpdateMembershipParams, UpdatePlanEntitlementParams, UpdatePlanParams, UpdatePricingGroupParams, UpdateSalesChannelParams, UpdateTargetCodeParams, UpdateWebhookSubscriptionParams, WEBHOOK_EVENT_CODES, WebhookDelivery, type WebhookEventCode, WebhookSignatureVerificationError, WebhookSubscription, collect, type components, constructEvent, type operations, paginate, type paths, verifyWebhookSignature };
6109
+ export { AddMemberParams, AdmitResult, AlreadyExistsError, BillingOption, BillingOptionSalesChannel, Calendar, CalendarRule, CancelMembershipParams, CreateBillingOptionParams, CreateBillingOptionSalesChannelParams, CreateCalendarParams, CreateCalendarRuleParams, CreateCustomerParams, CreateEntitlementParams, CreateMemberRoleParams, CreateMembershipParams, CreatePlanEntitlementAvailabilityParams, CreatePlanEntitlementParams, CreatePlanLinkParams, CreatePlanParams, CreatePlanPricingGroupMappingParams, CreatePricingGroupParams, CreateSalesChannelParams, CreateTargetCodeParams, CreateTransactionParams, CreateWebhookSubscriptionParams, Customer, CustomerMembershipSummary, CustomerView, DEFAULT_BASE_URL, Entitlement, EntitlementType, EntitlementUsage, type IdempotentRequestOptions, InternalError, InvalidArgumentError, Member, MemberEntitlement, MemberRole, MemberSyncResponse, Membership, MembershipTerm, NotFoundError, Ophelio, OphelioConnectionError, OphelioError, type OphelioOptions, OphelioTimeoutError, type OphelioWebhookEvent, Page, PageParams, PermissionDeniedError, Plan, PlanChangeParams, PlanChangeResult, PlanEntitlement, PlanEntitlementAvailability, PlanLink, PlanLinkView, PlanPricingGroupMapping, PricingGroup, RecordUsageParams, RedeemEntitlementParams, RedeemEntitlementResponse, ReissueCardParams, RenewMembershipParams, type RequestOptions, ResourceExhaustedError, SalesChannel, ScheduledChange, SyncMember, TargetCode, Transaction, UnauthenticatedError, UnavailableError, UnimplementedError, UpdateBillingOptionParams, UpdateCalendarParams, UpdateCalendarRuleParams, UpdateCustomerParams, UpdateEntitlementParams, UpdateMemberParams, UpdateMemberRoleParams, UpdateMembershipParams, UpdatePlanEntitlementAvailabilityParams, UpdatePlanEntitlementParams, UpdatePlanParams, UpdatePricingGroupParams, UpdateSalesChannelParams, UpdateTargetCodeParams, UpdateWebhookSubscriptionParams, WEBHOOK_EVENT_CODES, WebhookDelivery, type WebhookEventCode, WebhookSignatureVerificationError, WebhookSubscription, collect, type components, constructEvent, type operations, paginate, type paths, verifyWebhookSignature };
package/dist/index.mjs CHANGED
@@ -125,6 +125,21 @@ const DEFAULT_MAX_RETRIES = 2;
125
125
  function resolveIdempotencyKey(idempotencyKey) {
126
126
  return idempotencyKey?.trim() || crypto.randomUUID();
127
127
  }
128
+ /**
129
+ * Serialises query parameters into a search string.
130
+ *
131
+ * `undefined` drops the parameter entirely. An empty array does not: it emits
132
+ * the bare key (`?status=`), because "filter by nothing" and "do not filter"
133
+ * are different requests and the API distinguishes them.
134
+ */
135
+ function serialiseQuery(query) {
136
+ const search = new URLSearchParams();
137
+ for (const [key, value] of Object.entries(query ?? {})) {
138
+ if (value === void 0) continue;
139
+ search.set(key, Array.isArray(value) ? value.join(",") : value);
140
+ }
141
+ return search.toString();
142
+ }
128
143
  var Transport = class {
129
144
  apiKey;
130
145
  baseUrl;
@@ -179,9 +194,7 @@ var Transport = class {
179
194
  throw lastError;
180
195
  }
181
196
  buildUrl(params) {
182
- const search = new URLSearchParams();
183
- for (const [key, value] of Object.entries(params.query ?? {})) if (value !== void 0) search.set(key, value);
184
- const queryString = search.toString();
197
+ const queryString = serialiseQuery(params.query);
185
198
  return `${this.baseUrl}${params.path}${queryString ? `?${queryString}` : ""}`;
186
199
  }
187
200
  buildHeaders(params) {
@@ -917,6 +930,45 @@ var MembershipsResource = class extends APIResource {
917
930
  }
918
931
  };
919
932
  //#endregion
933
+ //#region src/resources/plan-entitlement-availabilities.ts
934
+ /**
935
+ * An availability row says when and where one plan entitlement applies: a
936
+ * calendar (null = any date) and a set of registered target codes (empty =
937
+ * anywhere). Rows OR, and a plan entitlement with no rows at all is
938
+ * unrestricted.
939
+ *
940
+ * Rows are created and listed through their plan entitlement
941
+ * (`ophelio.planEntitlements.createAvailability` / `listAvailabilities`); this
942
+ * resource addresses an individual row.
943
+ */
944
+ var PlanEntitlementAvailabilitiesResource = class extends APIResource {
945
+ get(id, options) {
946
+ return this.transport.request({
947
+ method: "GET",
948
+ path: `/api/v1/plan-entitlement-availabilities/${encodeURIComponent(id)}`,
949
+ retryable: true,
950
+ options
951
+ });
952
+ }
953
+ update(id, params, options) {
954
+ return this.transport.request({
955
+ method: "PATCH",
956
+ path: `/api/v1/plan-entitlement-availabilities/${encodeURIComponent(id)}`,
957
+ body: params,
958
+ retryable: false,
959
+ options
960
+ });
961
+ }
962
+ async delete(id, options) {
963
+ await this.transport.request({
964
+ method: "DELETE",
965
+ path: `/api/v1/plan-entitlement-availabilities/${encodeURIComponent(id)}`,
966
+ retryable: false,
967
+ options
968
+ });
969
+ }
970
+ };
971
+ //#endregion
920
972
  //#region src/resources/plan-entitlements.ts
921
973
  var PlanEntitlementsResource = class extends APIResource {
922
974
  get(id, options) {
@@ -945,6 +997,29 @@ var PlanEntitlementsResource = class extends APIResource {
945
997
  options
946
998
  });
947
999
  }
1000
+ async listAvailabilities(id, params, options) {
1001
+ const response = await this.transport.request({
1002
+ method: "GET",
1003
+ path: `/api/v1/plan-entitlements/${encodeURIComponent(id)}/availabilities`,
1004
+ query: pageQuery(params),
1005
+ retryable: true,
1006
+ options
1007
+ });
1008
+ return {
1009
+ items: response.availabilities,
1010
+ next_page_token: response.next_page_token,
1011
+ total_size: response.total_size
1012
+ };
1013
+ }
1014
+ createAvailability(id, params, options) {
1015
+ return this.transport.request({
1016
+ method: "POST",
1017
+ path: `/api/v1/plan-entitlements/${encodeURIComponent(id)}/availabilities`,
1018
+ body: params,
1019
+ retryable: false,
1020
+ options
1021
+ });
1022
+ }
948
1023
  };
949
1024
  //#endregion
950
1025
  //#region src/resources/plan-links.ts
@@ -1375,6 +1450,7 @@ var Ophelio = class Ophelio {
1375
1450
  calendars;
1376
1451
  calendarRules;
1377
1452
  planEntitlements;
1453
+ planEntitlementAvailabilities;
1378
1454
  planLinks;
1379
1455
  planPricingGroupMappings;
1380
1456
  billingOptionSalesChannels;
@@ -1401,6 +1477,7 @@ var Ophelio = class Ophelio {
1401
1477
  this.calendars = new CalendarsResource(transport);
1402
1478
  this.calendarRules = new CalendarRulesResource(transport);
1403
1479
  this.planEntitlements = new PlanEntitlementsResource(transport);
1480
+ this.planEntitlementAvailabilities = new PlanEntitlementAvailabilitiesResource(transport);
1404
1481
  this.planLinks = new PlanLinksResource(transport);
1405
1482
  this.planPricingGroupMappings = new PlanPricingGroupMappingsResource(transport);
1406
1483
  this.billingOptionSalesChannels = new BillingOptionSalesChannelsResource(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ophelio/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Official JavaScript / TypeScript SDK for the Ophel.io membership & entitlement API.",
5
5
  "license": "MIT",
6
6
  "author": "Ophel.io",