@slotchain/sdk 1.3.0 → 1.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.cjs.js CHANGED
@@ -740,11 +740,27 @@ var SlotClient = class {
740
740
  return response.data;
741
741
  }
742
742
  /**
743
- * Create a new slot
743
+ * Create a new slot.
744
744
  * POST /api/v1/slots
745
- *
746
- * @param data - Slot creation data (tenant_id, name required)
745
+ *
746
+ * Accepts any subset of `Slot` fields. For new integrations, prefer the
747
+ * exported `CreateSlotInput` type which documents the recommended shape
748
+ * and will become the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
749
+ *
750
+ * New fields available as of v1.4:
751
+ * - `starts_at` — ISO 8601 datetime when the slot opens
752
+ * - `ends_at` — ISO 8601 datetime when the slot closes (omit for open-ended slots)
753
+ * - `metadata` — term enrichment bag (term_name, season, half_term_start,
754
+ * half_term_end, capacity); see `SlotMetadata` type
755
+ *
756
+ * @param data - Slot creation data
747
757
  * @returns Created slot
758
+ *
759
+ * @example
760
+ * // Recommended — opt into stricter typing now:
761
+ * import { CreateSlotInput } from '@slotly/sdk';
762
+ * const input: CreateSlotInput = { name: 'Autumn Term', tenant_id: '...', starts_at: '...' };
763
+ * sdk.slots.create(input);
748
764
  */
749
765
  async create(data) {
750
766
  const response = await this.client.post(
@@ -754,11 +770,17 @@ var SlotClient = class {
754
770
  return response.data;
755
771
  }
756
772
  /**
757
- * Update slot by ID
773
+ * Update slot by ID.
758
774
  * PUT /api/v1/slots/:id
759
- *
760
- * @param id - Slot ID
761
- * @param data - Slot update data
775
+ *
776
+ * Accepts any subset of `Slot` fields. For new integrations, prefer the
777
+ * exported `UpdateSlotInput` type it will become the enforced signature
778
+ * in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
779
+ *
780
+ * New fields available as of v1.4: `starts_at`, `ends_at`, `metadata`.
781
+ *
782
+ * @param id - Slot ID
783
+ * @param data - Fields to update
762
784
  * @returns Updated slot
763
785
  */
764
786
  async update(id, data) {
@@ -788,6 +810,13 @@ var SlotClient = class {
788
810
  * @param slots - Array of slots to create
789
811
  * @returns Created slots
790
812
  */
813
+ /**
814
+ * Bulk create slots.
815
+ * POST /api/v1/slots/bulk
816
+ *
817
+ * For new integrations, prefer passing `CreateSlotInput[]` — it will become
818
+ * the enforced signature in v2.0 (see SLOT_TYPE_UPGRADE_PLAN.md).
819
+ */
791
820
  async bulkCreate(slots) {
792
821
  const response = await this.client.post(
793
822
  "/api/v1/slots/bulk",
@@ -796,11 +825,14 @@ var SlotClient = class {
796
825
  return response.data;
797
826
  }
798
827
  /**
799
- * Mark slot as available/unavailable
800
- * Note: Use update() method with status or other fields
828
+ * Mark slot as available (live) or unavailable (archived).
829
+ *
830
+ * Note: previous versions sent 'active'/'inactive' which were not valid DB
831
+ * enum values. Fixed in v1.4 to use 'live'/'archived' — the only valid
832
+ * non-draft statuses. If you need 'draft', use update() directly.
801
833
  */
802
834
  async setAvailability(id, available) {
803
- return this.update(id, { status: available ? "active" : "inactive" });
835
+ return this.update(id, { status: available ? "live" : "archived" });
804
836
  }
805
837
  /**
806
838
  * Get all active services for a slot with their items
@@ -1562,6 +1594,40 @@ var DocumentClient = class {
1562
1594
  }
1563
1595
  };
1564
1596
 
1597
+ // src/clients/notices-client.ts
1598
+ var NoticesClient = class {
1599
+ constructor(client) {
1600
+ this.base = "/api/v1/notices";
1601
+ this.client = client;
1602
+ }
1603
+ /**
1604
+ * List active notices for a tenant.
1605
+ * Returns only notices where visible_until > activeAt (default: now).
1606
+ */
1607
+ async list(options) {
1608
+ const response = await this.client.get(this.base, {
1609
+ params: {
1610
+ tenant_id: options.tenantId,
1611
+ active_at: options.activeAt,
1612
+ slot_id: options.slotId,
1613
+ types: options.types?.join(",")
1614
+ }
1615
+ });
1616
+ return response.data;
1617
+ }
1618
+ /**
1619
+ * Get a single notice by its slot_moment id.
1620
+ */
1621
+ async getById(id, tenantId) {
1622
+ const response = await this.client.get(`${this.base}/${id}`, {
1623
+ params: { tenant_id: tenantId }
1624
+ });
1625
+ const { data } = response.data;
1626
+ if (!data) throw new Error(`Notice ${id} not found`);
1627
+ return data;
1628
+ }
1629
+ };
1630
+
1565
1631
  // src/errors.ts
1566
1632
  var SlotlyApiError = class _SlotlyApiError extends Error {
1567
1633
  constructor(code, message, statusCode, details) {
@@ -1895,7 +1961,8 @@ var useSlotly = (options) => {
1895
1961
  notification: new NotificationClient(client),
1896
1962
  dataQuality: new DataQualityClient(client),
1897
1963
  organization: new OrganizationClient(client),
1898
- document: new DocumentClient(client)
1964
+ document: new DocumentClient(client),
1965
+ notices: new NoticesClient(client)
1899
1966
  };
1900
1967
  };
1901
1968
  var index_default = useSlotly;