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