@slotchain/sdk 1.3.0 → 1.4.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 +42 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +105 -8
- package/dist/index.d.ts +105 -8
- package/dist/index.esm.js +42 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/slot-client.ts +44 -10
- package/src/index.ts +3 -0
- package/src/types/api.ts +68 -0
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
|
-
*
|
|
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
|
-
*
|
|
761
|
-
*
|
|
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
|
|
800
|
-
*
|
|
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 ? "
|
|
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
|