@ophelio/sdk 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -247,12 +247,30 @@ function pageQuery(params) {
247
247
  //#endregion
248
248
  //#region src/resources/admit.ts
249
249
  var AdmitResource = class extends APIResource {
250
- /** Gate admission check: `GET /admit?card=<cardId>`. */
250
+ /**
251
+ * Gate admission check: `GET /admit?card=<cardId>`.
252
+ *
253
+ * `targets` names the venue, zone, shop or gate the request is being made
254
+ * at, and is the context the entitlements are judged in — a benefit
255
+ * restricted to somewhere else drops out of `entitlements`. Three states,
256
+ * and they are answered differently: omit it and every target restriction
257
+ * is treated as satisfied; pass `[]` and only benefits valid anywhere
258
+ * survive; pass codes and a benefit needs one of them. Read
259
+ * `target_context_applied` on the result to tell the first apart from the
260
+ * other two.
261
+ *
262
+ * Codes are matched exactly, so send them back verbatim from
263
+ * `targetCodes.list()` — an unregistered or miscased code is refused with
264
+ * a 400 rather than quietly ignored.
265
+ */
251
266
  check(params, options) {
252
267
  return this.transport.request({
253
268
  method: "GET",
254
269
  path: "/api/v1/admit",
255
- query: { card: params.card },
270
+ query: {
271
+ card: params.card,
272
+ targets: params.targets
273
+ },
256
274
  retryable: true,
257
275
  options
258
276
  });
@@ -328,7 +346,7 @@ var BillingOptionsResource = class extends APIResource {
328
346
  //#endregion
329
347
  //#region src/resources/calendar-rules.ts
330
348
  /**
331
- * A calendar rule is one row of a calendar's date vocabulary. Conditions AND
349
+ * A calendar rule is one row of a calendar's set of dates. Conditions AND
332
350
  * within a rule and rules OR across a calendar, so "weekends in August" is a
333
351
  * single rule rather than two.
334
352
  *
@@ -366,17 +384,24 @@ var CalendarRulesResource = class extends APIResource {
366
384
  //#endregion
367
385
  //#region src/resources/calendars.ts
368
386
  /**
369
- * Calendars are named, reusable date vocabularies ("Peak 2026", "Weekends").
387
+ * Calendars are named, reusable sets of dates ("Peak 2026", "Weekends").
370
388
  * The dates themselves live in the rules attached to them.
371
389
  *
372
390
  * A calendar containing no rules is valid for **all** dates, not none.
373
391
  */
374
392
  var CalendarsResource = class extends APIResource {
393
+ /**
394
+ * Pass `view: 'full'` to include `plan_entitlement_count` on every
395
+ * calendar.
396
+ */
375
397
  async list(params, options) {
376
398
  const response = await this.transport.request({
377
399
  method: "GET",
378
400
  path: "/api/v1/calendars",
379
- query: pageQuery(params),
401
+ query: {
402
+ ...pageQuery(params),
403
+ ...params?.view ? { view: params.view } : {}
404
+ },
380
405
  retryable: true,
381
406
  options
382
407
  });
@@ -386,10 +411,14 @@ var CalendarsResource = class extends APIResource {
386
411
  total_size: response.total_size
387
412
  };
388
413
  }
389
- get(id, options) {
414
+ /**
415
+ * Pass `view: 'full'` to include `plan_entitlement_count`.
416
+ */
417
+ get(id, params = {}, options) {
390
418
  return this.transport.request({
391
419
  method: "GET",
392
420
  path: `/api/v1/calendars/${encodeURIComponent(id)}`,
421
+ query: params.view ? { view: params.view } : void 0,
393
422
  retryable: true,
394
423
  options
395
424
  });
@@ -542,6 +571,14 @@ var EntitlementsResource = class extends APIResource {
542
571
  /**
543
572
  * Fire-and-forget batch usage reporting (one row per member). Idempotent
544
573
  * per (key, member). Returns the recorded usage rows.
574
+ *
575
+ * `target` is the single registered code for the venue, zone, shop or gate
576
+ * the usage happened at — one event, one place, which is why it is
577
+ * singular here where the reads take `targets`. It is both the context the
578
+ * entitlement is judged in and a column on the row that comes back, so it
579
+ * is queryable in a way the free-form `context` is not. It is part of the
580
+ * idempotency fingerprint: a replay of the same key at a different target
581
+ * is refused rather than silently returning the original row.
545
582
  */
546
583
  async recordUsage(params, options = {}) {
547
584
  const { idempotencyKey, ...requestOptions } = options;
@@ -667,11 +704,29 @@ var MembersResource = class extends APIResource {
667
704
  options
668
705
  });
669
706
  }
707
+ /**
708
+ * The entitlements a member can use right now.
709
+ *
710
+ * `targets` filters the result down to the benefits valid at the venue,
711
+ * zone, shop or gate it names — the same codes `admit.check` takes, but
712
+ * read as a filter here rather than as the context a gate decision is made
713
+ * in. Three states: omit it and nothing is filtered by target; pass `[]`
714
+ * and only benefits valid anywhere come back; pass codes and a benefit
715
+ * needs one of them. Codes are matched exactly, so send them back verbatim
716
+ * from `targetCodes.list()` — an unregistered one is refused with a 400.
717
+ *
718
+ * Each entitlement carries `valid_on` and `valid_at` when something
719
+ * restricts it by date or by target; both list only what it matched, never
720
+ * what it failed.
721
+ */
670
722
  async listEntitlements(id, params = {}, options) {
671
723
  return (await this.transport.request({
672
724
  method: "GET",
673
725
  path: `/api/v1/members/${encodeURIComponent(id)}/entitlements`,
674
- query: { type: params.type },
726
+ query: {
727
+ type: params.type,
728
+ targets: params.targets
729
+ },
675
730
  retryable: true,
676
731
  options
677
732
  })).entitlements;
@@ -1256,16 +1311,23 @@ var SalesChannelsResource = class extends APIResource {
1256
1311
  //#endregion
1257
1312
  //#region src/resources/target-codes.ts
1258
1313
  /**
1259
- * The registered vocabulary of locations a gate can report (`venue_a`,
1260
- * `coffee_shop`). Codes are matched exactly — list them and send values back
1261
- * verbatim rather than constructing or case-folding them.
1314
+ * The registered code for each venue, zone, shop or gate a request can name
1315
+ * (`venue_a`, `coffee_shop`). Codes are matched exactly — list them and send
1316
+ * values back verbatim rather than constructing or case-folding them.
1262
1317
  */
1263
1318
  var TargetCodesResource = class extends APIResource {
1319
+ /**
1320
+ * Pass `view: 'full'` to include `plan_entitlement_count` on every target
1321
+ * code.
1322
+ */
1264
1323
  async list(params, options) {
1265
1324
  const response = await this.transport.request({
1266
1325
  method: "GET",
1267
1326
  path: "/api/v1/target-codes",
1268
- query: pageQuery(params),
1327
+ query: {
1328
+ ...pageQuery(params),
1329
+ ...params?.view ? { view: params.view } : {}
1330
+ },
1269
1331
  retryable: true,
1270
1332
  options
1271
1333
  });
@@ -1275,10 +1337,14 @@ var TargetCodesResource = class extends APIResource {
1275
1337
  total_size: response.total_size
1276
1338
  };
1277
1339
  }
1278
- get(id, options) {
1340
+ /**
1341
+ * Pass `view: 'full'` to include `plan_entitlement_count`.
1342
+ */
1343
+ get(id, params = {}, options) {
1279
1344
  return this.transport.request({
1280
1345
  method: "GET",
1281
1346
  path: `/api/v1/target-codes/${encodeURIComponent(id)}`,
1347
+ query: params.view ? { view: params.view } : void 0,
1282
1348
  retryable: true,
1283
1349
  options
1284
1350
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ophelio/sdk",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "Official JavaScript / TypeScript SDK for the Ophel.io membership & entitlement API.",
5
5
  "license": "MIT",
6
6
  "author": "Ophel.io",