order3000 1.0.2 → 1.2.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/client.cjs +162 -0
- package/dist/client.d.cts +521 -9
- package/dist/client.d.mts +521 -9
- package/dist/client.mjs +162 -0
- package/dist/schemas.cjs +470 -5
- package/dist/schemas.d.cts +389 -26
- package/dist/schemas.d.mts +389 -26
- package/dist/schemas.mjs +470 -5
- package/package.json +4 -6
package/dist/client.mjs
CHANGED
|
@@ -169,6 +169,71 @@ class BaseResource {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
class AdsResource extends BaseResource {
|
|
173
|
+
constructor(tokenManager, baseUrl) {
|
|
174
|
+
super(tokenManager, baseUrl, "/ads");
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* List the venue's ads, ordered by `createdAt`. Optionally filter by
|
|
178
|
+
* `ownerEntityType` (e.g. `event`), `ownerEntityId`, or `channel` (e.g.
|
|
179
|
+
* `google`). Each ad carries its paste-ready Google Search Ad `content`
|
|
180
|
+
* document and lifecycle `status`.
|
|
181
|
+
*/
|
|
182
|
+
async list(options) {
|
|
183
|
+
const params = new URLSearchParams();
|
|
184
|
+
if (options?.ownerEntityType) {
|
|
185
|
+
params.set("ownerEntityType", options.ownerEntityType);
|
|
186
|
+
}
|
|
187
|
+
if (options?.ownerEntityId) {
|
|
188
|
+
params.set("ownerEntityId", options.ownerEntityId);
|
|
189
|
+
}
|
|
190
|
+
if (options?.channel) {
|
|
191
|
+
params.set("channel", options.channel);
|
|
192
|
+
}
|
|
193
|
+
const qs = params.toString();
|
|
194
|
+
const path = qs ? `?${qs}` : "";
|
|
195
|
+
return this.request("GET", path);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Fetch a single ad by id within the active venue. Ads have no accessor
|
|
199
|
+
* — the lookup is always by uuid. Returns the full row including the
|
|
200
|
+
* `content` document and `status`.
|
|
201
|
+
*/
|
|
202
|
+
async get(adId) {
|
|
203
|
+
return this.request("GET", `/${encodeURIComponent(adId)}`);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Create a new ad for a polymorphic owner entity (an event today). Copy
|
|
207
|
+
* + status take the DB defaults (empty content, `draft`) and are
|
|
208
|
+
* populated later via {@link patch}. Returns the created ad.
|
|
209
|
+
*/
|
|
210
|
+
async create(body) {
|
|
211
|
+
return this.request("POST", "", body);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Partial-update an ad by id. Pass `content` to write paste-ready Google
|
|
215
|
+
* Responsive Search Ad copy (the char-limit + count validation is the
|
|
216
|
+
* self-heal contract) and/or `status` to move the ad through its
|
|
217
|
+
* lifecycle. Returns the resulting ad.
|
|
218
|
+
*/
|
|
219
|
+
async patch(adId, body) {
|
|
220
|
+
return this.request(
|
|
221
|
+
"PATCH",
|
|
222
|
+
`/${encodeURIComponent(adId)}`,
|
|
223
|
+
body
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Permanently delete an ad by id. Returns the deleted ad row.
|
|
228
|
+
*/
|
|
229
|
+
async delete(adId) {
|
|
230
|
+
return this.request(
|
|
231
|
+
"DELETE",
|
|
232
|
+
`/${encodeURIComponent(adId)}`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
172
237
|
class AreasResource extends BaseResource {
|
|
173
238
|
constructor(tokenManager, baseUrl) {
|
|
174
239
|
super(tokenManager, baseUrl, "/areas");
|
|
@@ -319,6 +384,34 @@ class ArticlesResource extends BaseResource {
|
|
|
319
384
|
}
|
|
320
385
|
}
|
|
321
386
|
|
|
387
|
+
class AssetsResource extends BaseResource {
|
|
388
|
+
constructor(tokenManager, baseUrl) {
|
|
389
|
+
super(tokenManager, baseUrl, "/assets");
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* List a venue's ACTIVE assets carrying `tag`, ordered by `sortIndex`.
|
|
393
|
+
*
|
|
394
|
+
* A binding-agnostic query on the central `assets` table — an asset is
|
|
395
|
+
* returned regardless of whether it is bound to a ritual, dish, beverage,
|
|
396
|
+
* event, or is standalone. Each asset carries its resolved Supabase
|
|
397
|
+
* `publicUrl`.
|
|
398
|
+
*
|
|
399
|
+
* @param options - `tag` (required) + optional `type` filter
|
|
400
|
+
* @returns Array of assets with public URLs
|
|
401
|
+
*/
|
|
402
|
+
async list(options) {
|
|
403
|
+
const queryParams = new URLSearchParams();
|
|
404
|
+
queryParams.set("tag", options.tag);
|
|
405
|
+
if (options.type) {
|
|
406
|
+
queryParams.set("type", options.type);
|
|
407
|
+
}
|
|
408
|
+
return this.request(
|
|
409
|
+
"GET",
|
|
410
|
+
`?${queryParams.toString()}`
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
322
415
|
class BasketsResource extends BaseResource {
|
|
323
416
|
constructor(tokenManager, baseUrl) {
|
|
324
417
|
super(tokenManager, baseUrl, "/baskets");
|
|
@@ -475,6 +568,71 @@ class EventsResource extends BaseResource {
|
|
|
475
568
|
if (!options?.expand?.length) return "";
|
|
476
569
|
return `?expand=${options.expand.join(",")}`;
|
|
477
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Partial-update an event by id or accessor. Every body field is
|
|
573
|
+
* optional; locale-keyed fields (`name`, `description`) merge at the
|
|
574
|
+
* locale level — `{ name: { en: 'Brunch' } }` updates `en` without
|
|
575
|
+
* touching `de`. Pass a `schedule` object to update timing, or
|
|
576
|
+
* `ritualAccessor` to (re)link a ritual (`null` detaches). Returns the
|
|
577
|
+
* resulting event with its schedule.
|
|
578
|
+
*/
|
|
579
|
+
async patch(idOrAccessor, body) {
|
|
580
|
+
return this.request(
|
|
581
|
+
"PATCH",
|
|
582
|
+
`/${encodeURIComponent(idOrAccessor)}`,
|
|
583
|
+
body
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Permanently delete an event by id or accessor. Returns the deleted
|
|
588
|
+
* event row.
|
|
589
|
+
*/
|
|
590
|
+
async delete(idOrAccessor) {
|
|
591
|
+
return this.request(
|
|
592
|
+
"DELETE",
|
|
593
|
+
`/${encodeURIComponent(idOrAccessor)}`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* List the posters attached to an event. Convenience over
|
|
598
|
+
* `getByAccessor(idOrAccessor, { expand: ['posters'] })` — returns the
|
|
599
|
+
* `posters[]` array (empty when the event has none).
|
|
600
|
+
*/
|
|
601
|
+
async listPosters(idOrAccessor) {
|
|
602
|
+
const event = await this.getByAccessor(idOrAccessor, {
|
|
603
|
+
expand: ["posters"]
|
|
604
|
+
});
|
|
605
|
+
return event.posters ?? [];
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Upload a poster image for an event. The SDK builds the multipart
|
|
609
|
+
* body internally — pass a Buffer/Uint8Array, the original filename,
|
|
610
|
+
* and the MIME type. The asset is stored and linked to the event via
|
|
611
|
+
* `event_assets`; returns the new asset and its public URL.
|
|
612
|
+
*/
|
|
613
|
+
async uploadPoster(idOrAccessor, file) {
|
|
614
|
+
const form = new FormData();
|
|
615
|
+
form.append(
|
|
616
|
+
"file",
|
|
617
|
+
new Blob([new Uint8Array(file.data)], { type: file.contentType }),
|
|
618
|
+
file.filename
|
|
619
|
+
);
|
|
620
|
+
return this.requestMultipart(
|
|
621
|
+
"POST",
|
|
622
|
+
`/${encodeURIComponent(idOrAccessor)}/posters`,
|
|
623
|
+
form
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Remove a poster from an event. Deletes the asset (storage object +
|
|
628
|
+
* DB row + `event_assets` link). Returns `{ success: true }`.
|
|
629
|
+
*/
|
|
630
|
+
async removePoster(idOrAccessor, assetId) {
|
|
631
|
+
return this.request(
|
|
632
|
+
"DELETE",
|
|
633
|
+
`/${encodeURIComponent(idOrAccessor)}/posters/${encodeURIComponent(assetId)}`
|
|
634
|
+
);
|
|
635
|
+
}
|
|
478
636
|
}
|
|
479
637
|
|
|
480
638
|
class MenusResource extends BaseResource {
|
|
@@ -1244,8 +1402,10 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
1244
1402
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1245
1403
|
class O3KClient {
|
|
1246
1404
|
constructor(config) {
|
|
1405
|
+
__publicField(this, "ads");
|
|
1247
1406
|
__publicField(this, "areas");
|
|
1248
1407
|
__publicField(this, "articles");
|
|
1408
|
+
__publicField(this, "assets");
|
|
1249
1409
|
__publicField(this, "baskets");
|
|
1250
1410
|
__publicField(this, "events");
|
|
1251
1411
|
__publicField(this, "menus");
|
|
@@ -1266,8 +1426,10 @@ class O3KClient {
|
|
|
1266
1426
|
tokenUrl,
|
|
1267
1427
|
config.venueId
|
|
1268
1428
|
);
|
|
1429
|
+
this.ads = new AdsResource(this.tokenManager, this.baseUrl);
|
|
1269
1430
|
this.areas = new AreasResource(this.tokenManager, this.baseUrl);
|
|
1270
1431
|
this.articles = new ArticlesResource(this.tokenManager, this.baseUrl);
|
|
1432
|
+
this.assets = new AssetsResource(this.tokenManager, this.baseUrl);
|
|
1271
1433
|
this.baskets = new BasketsResource(this.tokenManager, this.baseUrl);
|
|
1272
1434
|
this.events = new EventsResource(this.tokenManager, this.baseUrl);
|
|
1273
1435
|
this.menus = new MenusResource(this.tokenManager, this.baseUrl);
|