order3000 0.20.0 → 0.22.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 +145 -0
- package/dist/client.d.cts +218 -9
- package/dist/client.d.mts +218 -9
- package/dist/client.mjs +145 -0
- package/dist/schemas.cjs +16 -2
- package/dist/schemas.d.cts +355 -44
- package/dist/schemas.d.mts +355 -44
- package/dist/schemas.mjs +16 -2
- package/package.json +3 -3
package/dist/client.d.mts
CHANGED
|
@@ -50,7 +50,14 @@ declare abstract class BaseResource {
|
|
|
50
50
|
protected readonly baseUrl: string;
|
|
51
51
|
protected readonly resourcePath: string;
|
|
52
52
|
constructor(tokenManager: TokenManager, baseUrl: string, resourcePath: string);
|
|
53
|
-
protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown, cacheOptions?: RequestCacheOptions): Promise<T>;
|
|
53
|
+
protected request<T>(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, data?: unknown, cacheOptions?: RequestCacheOptions): Promise<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Multipart counterpart to `request`. Skips the JSON Content-Type
|
|
56
|
+
* default — `fetch` sets `multipart/form-data; boundary=…`
|
|
57
|
+
* automatically when the body is a `FormData`. Use for binary uploads
|
|
58
|
+
* (e.g. article feature image).
|
|
59
|
+
*/
|
|
60
|
+
protected requestMultipart<T>(method: 'POST' | 'PATCH' | 'PUT', path: string, formData: FormData): Promise<T>;
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
interface components {
|
|
@@ -218,9 +225,24 @@ interface components {
|
|
|
218
225
|
createdAt: string | null;
|
|
219
226
|
updatedAt: string | null;
|
|
220
227
|
};
|
|
228
|
+
/**
|
|
229
|
+
* FeatureImage
|
|
230
|
+
* @description An article's resolved feature image. `caption` / `alt` are per-locale TipTap docs (PATCH accepts plain strings — server normalises).
|
|
231
|
+
*/
|
|
232
|
+
FeatureImage: {
|
|
233
|
+
id: string;
|
|
234
|
+
publicUrl: string | null;
|
|
235
|
+
locale: string;
|
|
236
|
+
caption: {
|
|
237
|
+
[key: string]: unknown;
|
|
238
|
+
} | null;
|
|
239
|
+
alt: {
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
} | null;
|
|
242
|
+
};
|
|
221
243
|
/**
|
|
222
244
|
* Article
|
|
223
|
-
* @description A venue's article. `content` is a TipTap JSON document; treat it as opaque on the wire.
|
|
245
|
+
* @description A venue's article. `content` is a TipTap JSON document; treat it as opaque on the wire. `featureImage` is resolved per-locale with a fallback to the venue's primary locale.
|
|
224
246
|
*/
|
|
225
247
|
Article: {
|
|
226
248
|
id: string;
|
|
@@ -234,21 +256,115 @@ interface components {
|
|
|
234
256
|
};
|
|
235
257
|
excerpt: {
|
|
236
258
|
[key: string]: string;
|
|
237
|
-
};
|
|
259
|
+
} | null;
|
|
238
260
|
content: {
|
|
239
261
|
[key: string]: unknown;
|
|
240
|
-
};
|
|
262
|
+
} | null;
|
|
241
263
|
tags: string[];
|
|
242
|
-
featuredImageId: string | null;
|
|
243
264
|
isActive: boolean;
|
|
244
265
|
isFeatured: boolean;
|
|
245
266
|
priority: number;
|
|
246
|
-
publishedAt:
|
|
247
|
-
createdAt:
|
|
248
|
-
updatedAt:
|
|
267
|
+
publishedAt: unknown;
|
|
268
|
+
createdAt: unknown;
|
|
269
|
+
updatedAt: unknown;
|
|
270
|
+
featureImage: components["schemas"]["FeatureImage"] | null;
|
|
249
271
|
};
|
|
250
272
|
/** ListArticlesResponse */
|
|
251
273
|
ListArticlesResponse: components["schemas"]["Article"][];
|
|
274
|
+
/**
|
|
275
|
+
* GetArticleResponse
|
|
276
|
+
* @description A venue's article. `content` is a TipTap JSON document; treat it as opaque on the wire. `featureImage` is resolved per-locale with a fallback to the venue's primary locale.
|
|
277
|
+
*/
|
|
278
|
+
GetArticleResponse: {
|
|
279
|
+
id: string;
|
|
280
|
+
venueId: string;
|
|
281
|
+
accessor: string;
|
|
282
|
+
slug: {
|
|
283
|
+
[key: string]: string;
|
|
284
|
+
};
|
|
285
|
+
title: {
|
|
286
|
+
[key: string]: string;
|
|
287
|
+
};
|
|
288
|
+
excerpt: {
|
|
289
|
+
[key: string]: string;
|
|
290
|
+
} | null;
|
|
291
|
+
content: {
|
|
292
|
+
[key: string]: unknown;
|
|
293
|
+
} | null;
|
|
294
|
+
tags: string[];
|
|
295
|
+
isActive: boolean;
|
|
296
|
+
isFeatured: boolean;
|
|
297
|
+
priority: number;
|
|
298
|
+
publishedAt: unknown;
|
|
299
|
+
createdAt: unknown;
|
|
300
|
+
updatedAt: unknown;
|
|
301
|
+
featureImage: components["schemas"]["FeatureImage"] | null;
|
|
302
|
+
};
|
|
303
|
+
/** PatchArticleRequest */
|
|
304
|
+
PatchArticleRequest: {
|
|
305
|
+
slug?: {
|
|
306
|
+
[key: string]: string;
|
|
307
|
+
};
|
|
308
|
+
title?: {
|
|
309
|
+
[key: string]: string;
|
|
310
|
+
};
|
|
311
|
+
excerpt?: {
|
|
312
|
+
[key: string]: string;
|
|
313
|
+
};
|
|
314
|
+
content?: {
|
|
315
|
+
[key: string]: unknown;
|
|
316
|
+
};
|
|
317
|
+
tags?: string[];
|
|
318
|
+
isActive?: boolean;
|
|
319
|
+
isFeatured?: boolean;
|
|
320
|
+
priority?: number;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* PatchArticleResponse
|
|
324
|
+
* @description A venue's article. `content` is a TipTap JSON document; treat it as opaque on the wire. `featureImage` is resolved per-locale with a fallback to the venue's primary locale.
|
|
325
|
+
*/
|
|
326
|
+
PatchArticleResponse: {
|
|
327
|
+
id: string;
|
|
328
|
+
venueId: string;
|
|
329
|
+
accessor: string;
|
|
330
|
+
slug: {
|
|
331
|
+
[key: string]: string;
|
|
332
|
+
};
|
|
333
|
+
title: {
|
|
334
|
+
[key: string]: string;
|
|
335
|
+
};
|
|
336
|
+
excerpt: {
|
|
337
|
+
[key: string]: string;
|
|
338
|
+
} | null;
|
|
339
|
+
content: {
|
|
340
|
+
[key: string]: unknown;
|
|
341
|
+
} | null;
|
|
342
|
+
tags: string[];
|
|
343
|
+
isActive: boolean;
|
|
344
|
+
isFeatured: boolean;
|
|
345
|
+
priority: number;
|
|
346
|
+
publishedAt: unknown;
|
|
347
|
+
createdAt: unknown;
|
|
348
|
+
updatedAt: unknown;
|
|
349
|
+
featureImage: components["schemas"]["FeatureImage"] | null;
|
|
350
|
+
};
|
|
351
|
+
/** UploadFeatureImageRequest */
|
|
352
|
+
UploadFeatureImageRequest: {
|
|
353
|
+
/** @description Image file (multipart/form-data field) */
|
|
354
|
+
file: unknown;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* PatchFeatureImageRequest
|
|
358
|
+
* @description Locale-keyed merge of the asset-side `caption` and `alt` records. Each locale value may be a plain string OR a TipTap doc; strings are wrapped server-side. Setting `en` does not touch `de`.
|
|
359
|
+
*/
|
|
360
|
+
PatchFeatureImageRequest: {
|
|
361
|
+
caption?: {
|
|
362
|
+
[key: string]: unknown;
|
|
363
|
+
};
|
|
364
|
+
alt?: {
|
|
365
|
+
[key: string]: unknown;
|
|
366
|
+
};
|
|
367
|
+
};
|
|
252
368
|
/**
|
|
253
369
|
* AddToBasketRequest
|
|
254
370
|
* @description Add an item to the shopping basket
|
|
@@ -1097,6 +1213,23 @@ interface components {
|
|
|
1097
1213
|
teamOrderId: string;
|
|
1098
1214
|
deliveryAddressId: string;
|
|
1099
1215
|
};
|
|
1216
|
+
/**
|
|
1217
|
+
* GetVenueResponse
|
|
1218
|
+
* @description A venue. The public API exposes only the minimal id + accessor + naming + locale fields the CLI's `venues use` / `auth whoami` consume.
|
|
1219
|
+
*/
|
|
1220
|
+
GetVenueResponse: {
|
|
1221
|
+
id: string;
|
|
1222
|
+
accessor: string;
|
|
1223
|
+
officialName: string;
|
|
1224
|
+
legalName: string;
|
|
1225
|
+
shortName: string;
|
|
1226
|
+
brandName: string;
|
|
1227
|
+
primaryLocale: string;
|
|
1228
|
+
supportedLocales: string[];
|
|
1229
|
+
timezone: string;
|
|
1230
|
+
createdAt: unknown;
|
|
1231
|
+
updatedAt: unknown;
|
|
1232
|
+
};
|
|
1100
1233
|
};
|
|
1101
1234
|
responses: never;
|
|
1102
1235
|
parameters: never;
|
|
@@ -1110,6 +1243,22 @@ type CreateEventRequest = schemas['CreateEventRequest'];
|
|
|
1110
1243
|
type CreateEventResponse = schemas['CreateEventResponse'];
|
|
1111
1244
|
type Article = schemas['Article'];
|
|
1112
1245
|
type ListArticlesResponse = schemas['ListArticlesResponse'];
|
|
1246
|
+
type GetArticleResponse = schemas['GetArticleResponse'];
|
|
1247
|
+
type PatchArticleRequest = schemas['PatchArticleRequest'];
|
|
1248
|
+
type PatchArticleResponse = schemas['PatchArticleResponse'];
|
|
1249
|
+
type FeatureImage = schemas['FeatureImage'];
|
|
1250
|
+
type PatchFeatureImageRequest = schemas['PatchFeatureImageRequest'];
|
|
1251
|
+
/**
|
|
1252
|
+
* Args for `client.articles.uploadFeatureImage()`. The SDK accepts a
|
|
1253
|
+
* `Buffer` or `Uint8Array` payload + filename + content-type — it
|
|
1254
|
+
* builds the FormData internally so callers don't have to know about
|
|
1255
|
+
* multipart wire encoding.
|
|
1256
|
+
*/
|
|
1257
|
+
interface UploadFeatureImageArgs {
|
|
1258
|
+
data: Buffer | Uint8Array;
|
|
1259
|
+
filename: string;
|
|
1260
|
+
contentType: string;
|
|
1261
|
+
}
|
|
1113
1262
|
interface ListArticlesOptions {
|
|
1114
1263
|
/** Only return articles whose `tags` array contains this value. */
|
|
1115
1264
|
tag?: string;
|
|
@@ -1118,6 +1267,8 @@ interface ListArticlesOptions {
|
|
|
1118
1267
|
/** When `true`, include articles whose `isActive` is `false`. Default `false`. */
|
|
1119
1268
|
includeInactive?: boolean;
|
|
1120
1269
|
}
|
|
1270
|
+
type Venue = schemas['Venue'];
|
|
1271
|
+
type GetVenueResponse = schemas['GetVenueResponse'];
|
|
1121
1272
|
/**
|
|
1122
1273
|
* Order fulfillment type - matches order_fulfillment_type enum in order3000 database.
|
|
1123
1274
|
* Keep in sync with apps/order3000/src/drizzle/enums.ts
|
|
@@ -1907,6 +2058,42 @@ declare class ArticlesResource extends BaseResource {
|
|
|
1907
2058
|
* for human-friendly node addressing.
|
|
1908
2059
|
*/
|
|
1909
2060
|
list(options?: ListArticlesOptions): Promise<ListArticlesResponse>;
|
|
2061
|
+
/**
|
|
2062
|
+
* Fetch a single article by id or accessor within the active venue.
|
|
2063
|
+
* Returns the full row including the TipTap `content` document.
|
|
2064
|
+
*/
|
|
2065
|
+
getByAccessor(idOrAccessor: string): Promise<Article>;
|
|
2066
|
+
/**
|
|
2067
|
+
* Partial-update an article. Locale-keyed fields (slug, title, excerpt)
|
|
2068
|
+
* merge at the locale level — `{ slug: { en: 'foo' } }` updates `en`
|
|
2069
|
+
* without touching `de`. Plain scalar / array fields fully replace.
|
|
2070
|
+
* Returns the resulting article.
|
|
2071
|
+
*/
|
|
2072
|
+
patch(idOrAccessor: string, body: PatchArticleRequest): Promise<Article>;
|
|
2073
|
+
/**
|
|
2074
|
+
* Read the article's resolved feature image — asset id, public URL,
|
|
2075
|
+
* matched locale, plus the FULL per-locale caption + alt records.
|
|
2076
|
+
* Returns null when the article has no feature image yet (the wire
|
|
2077
|
+
* 404 is mapped here for ergonomic null-checking on the caller side).
|
|
2078
|
+
*/
|
|
2079
|
+
getFeatureImage(idOrAccessor: string, options?: {
|
|
2080
|
+
locale?: string;
|
|
2081
|
+
}): Promise<FeatureImage | null>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Upload a new feature image. Replaces any existing feature image
|
|
2084
|
+
* for the venue's primary locale (the previous one is demoted to
|
|
2085
|
+
* `role='inline'`). The SDK builds the multipart body internally —
|
|
2086
|
+
* pass a Buffer/Uint8Array, the original filename, and the MIME
|
|
2087
|
+
* type.
|
|
2088
|
+
*/
|
|
2089
|
+
uploadFeatureImage(idOrAccessor: string, file: UploadFeatureImageArgs): Promise<FeatureImage>;
|
|
2090
|
+
/**
|
|
2091
|
+
* Update per-locale caption / alt on the article's feature image.
|
|
2092
|
+
* Locale-keyed merge — `{ caption: { en: '…' } }` does not touch
|
|
2093
|
+
* `de`. Plain-string locale values are server-side wrapped into
|
|
2094
|
+
* minimal TipTap docs (the storage shape).
|
|
2095
|
+
*/
|
|
2096
|
+
patchFeatureImage(idOrAccessor: string, body: PatchFeatureImageRequest): Promise<FeatureImage>;
|
|
1910
2097
|
}
|
|
1911
2098
|
|
|
1912
2099
|
declare class BasketsResource extends BaseResource {
|
|
@@ -2592,6 +2779,27 @@ declare class TeamOrdersResource {
|
|
|
2592
2779
|
}): Promise<UpdateDeliveryAddressResponse>;
|
|
2593
2780
|
}
|
|
2594
2781
|
|
|
2782
|
+
/**
|
|
2783
|
+
* Reads at the venue level. Doesn't extend `BaseResource` because that
|
|
2784
|
+
* class hard-codes a `/venues/{venueId}/<resourcePath>` URL template,
|
|
2785
|
+
* which assumes a venue-scoped sub-resource. Venues themselves are AT
|
|
2786
|
+
* `/venues/:venueIdOrAccessor` directly.
|
|
2787
|
+
*/
|
|
2788
|
+
declare class VenuesResource {
|
|
2789
|
+
private readonly tokenManager;
|
|
2790
|
+
private readonly baseUrl;
|
|
2791
|
+
constructor(tokenManager: TokenManager, baseUrl: string);
|
|
2792
|
+
/**
|
|
2793
|
+
* Fetch a venue by its UUID or its accessor (slug). The path accepts
|
|
2794
|
+
* either form; the server resolves transparently.
|
|
2795
|
+
*
|
|
2796
|
+
* Powers the order3000-cli's `venues use <accessor>` validation step
|
|
2797
|
+
* — the CLI hits this to prove the accessor exists and to cache the
|
|
2798
|
+
* resolved UUID + display fields locally.
|
|
2799
|
+
*/
|
|
2800
|
+
getByAccessor(idOrAccessor: string): Promise<Venue>;
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2595
2803
|
type RealtimeEvent = 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
2596
2804
|
type RealtimeRow = {
|
|
2597
2805
|
[key: string]: any;
|
|
@@ -2763,6 +2971,7 @@ declare class Order3000Client {
|
|
|
2763
2971
|
reservations: ReservationsResource;
|
|
2764
2972
|
subscriptions: SubscriptionsResource;
|
|
2765
2973
|
teamOrders: TeamOrdersResource;
|
|
2974
|
+
venues: VenuesResource;
|
|
2766
2975
|
realtime: RealtimeManager;
|
|
2767
2976
|
private readonly baseUrl;
|
|
2768
2977
|
private readonly tokenManager;
|
|
@@ -2770,4 +2979,4 @@ declare class Order3000Client {
|
|
|
2770
2979
|
}
|
|
2771
2980
|
|
|
2772
2981
|
export { Order3000Client, fulfillmentTypeEnum, getScheduleInfo, participantStatusEnum, paymentMethodEnum, teamOrderStatusEnum };
|
|
2773
|
-
export type { AddToBasketRequest, AddToBasketResponse, Area, AreaAsset, AreaAvailabilityResponse, AreaAvailabilityWindow, AreaBookingMode, AreaBookingRequestResponse, AreaBookingRequestSource, AreaBookingRequestStatus, AreaBookingStatus, AreaFeature, Article, Basket, BasketItem, BasketItemDeposit, BasketItemMenuItemRef, BasketItemMetadata, BasketStatus, BasketTotals, CancelTeamOrderResponse, ConfirmOrderRequest, ConfirmOrderResponse, CreateDeltaPaymentIntentRequest, CreateDeltaPaymentIntentResponse, CreatePaymentIntentRequest, CreatePaymentIntentResponse, CreateTeamOrderRequest, CreateTeamOrderResponse, CropArea, Currency, DayOfWeek, DeclaredReturn, Event, EventByAccessor, EventMenu, EventPoster, EventRow, ExtendDeadlineResponse as ExtendTeamOrderDeadlineResponse, FetchTeamOrderResponse, GetAreaAvailabilityOptions, GetAreaOptions, GetEventOptions, GetMenuOptions, JoinTeamOrderRequest, JoinTeamOrderResponse, LatestOrder, ListArticlesOptions, ListArticlesResponse, ListEventsOptions, ListEventsResponse, Menu, MenuAsset, MenuBeverage, MenuBundle, MenuBundleDeposit, MenuDish, MenuItem, MenuItemRow, MenuItemType, MenuSubscription, MenuSubscriptionPoster, Order3000ClientConfig, OrderFulfillmentType, OrderStatus, PaymentStatus, PlaceOrderRequest, Promotion, RealtimeConfig, RealtimeEvent, RealtimeSubscription, RemoveFromBasketResponse, Schedule, ScheduleInfo, ScheduleOverride, ScheduleOverrideRow, ScheduleRow, ScheduleTimeSlot, ScheduleWithTimeSlots, SubmitAreaBookingRequestPayload, SubmitTeamOrderResponse, SubscribeRequest, SubscribeResponse, SubscriberStatus, SubscriptionCredit, SubscriptionCreditStatus, SubscriptionOptions, SubscriptionPeriod, SwitchFulfillmentResponse as SwitchTeamOrderFulfillmentResponse, TeamDeliveryAddress, TeamOrderBasketItem, TeamOrderBasketItemMenuItemRef, FulfillmentType as TeamOrderFulfillmentType, TeamOrderParticipant, ParticipantStatus as TeamOrderParticipantStatus, PaymentMethod as TeamOrderPaymentMethod, TeamOrderStatus, ThresholdCheck as TeamOrderThresholdCheck, TimeSlot, Unit, UpdateDeliveryAddressResponse as UpdateTeamOrderDeliveryAddressResponse };
|
|
2982
|
+
export type { AddToBasketRequest, AddToBasketResponse, Area, AreaAsset, AreaAvailabilityResponse, AreaAvailabilityWindow, AreaBookingMode, AreaBookingRequestResponse, AreaBookingRequestSource, AreaBookingRequestStatus, AreaBookingStatus, AreaFeature, Article, Basket, BasketItem, BasketItemDeposit, BasketItemMenuItemRef, BasketItemMetadata, BasketStatus, BasketTotals, CancelTeamOrderResponse, ConfirmOrderRequest, ConfirmOrderResponse, CreateDeltaPaymentIntentRequest, CreateDeltaPaymentIntentResponse, CreatePaymentIntentRequest, CreatePaymentIntentResponse, CreateTeamOrderRequest, CreateTeamOrderResponse, CropArea, Currency, DayOfWeek, DeclaredReturn, Event, EventByAccessor, EventMenu, EventPoster, EventRow, ExtendDeadlineResponse as ExtendTeamOrderDeadlineResponse, FeatureImage, FetchTeamOrderResponse, GetAreaAvailabilityOptions, GetAreaOptions, GetArticleResponse, GetEventOptions, GetMenuOptions, GetVenueResponse, JoinTeamOrderRequest, JoinTeamOrderResponse, LatestOrder, ListArticlesOptions, ListArticlesResponse, ListEventsOptions, ListEventsResponse, Menu, MenuAsset, MenuBeverage, MenuBundle, MenuBundleDeposit, MenuDish, MenuItem, MenuItemRow, MenuItemType, MenuSubscription, MenuSubscriptionPoster, Order3000ClientConfig, OrderFulfillmentType, OrderStatus, PatchArticleRequest, PatchArticleResponse, PatchFeatureImageRequest, PaymentStatus, PlaceOrderRequest, Promotion, RealtimeConfig, RealtimeEvent, RealtimeSubscription, RemoveFromBasketResponse, Schedule, ScheduleInfo, ScheduleOverride, ScheduleOverrideRow, ScheduleRow, ScheduleTimeSlot, ScheduleWithTimeSlots, SubmitAreaBookingRequestPayload, SubmitTeamOrderResponse, SubscribeRequest, SubscribeResponse, SubscriberStatus, SubscriptionCredit, SubscriptionCreditStatus, SubscriptionOptions, SubscriptionPeriod, SwitchFulfillmentResponse as SwitchTeamOrderFulfillmentResponse, TeamDeliveryAddress, TeamOrderBasketItem, TeamOrderBasketItemMenuItemRef, FulfillmentType as TeamOrderFulfillmentType, TeamOrderParticipant, ParticipantStatus as TeamOrderParticipantStatus, PaymentMethod as TeamOrderPaymentMethod, TeamOrderStatus, ThresholdCheck as TeamOrderThresholdCheck, TimeSlot, Unit, UpdateDeliveryAddressResponse as UpdateTeamOrderDeliveryAddressResponse, UploadFeatureImageArgs, Venue };
|
package/dist/client.mjs
CHANGED
|
@@ -132,6 +132,38 @@ class BaseResource {
|
|
|
132
132
|
}
|
|
133
133
|
return response.json();
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Multipart counterpart to `request`. Skips the JSON Content-Type
|
|
137
|
+
* default — `fetch` sets `multipart/form-data; boundary=…`
|
|
138
|
+
* automatically when the body is a `FormData`. Use for binary uploads
|
|
139
|
+
* (e.g. article feature image).
|
|
140
|
+
*/
|
|
141
|
+
async requestMultipart(method, path, formData) {
|
|
142
|
+
const token = await this.tokenManager.getToken();
|
|
143
|
+
const venueId = this.tokenManager.getVenueId();
|
|
144
|
+
const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
|
|
145
|
+
const response = await fetch(url, {
|
|
146
|
+
method,
|
|
147
|
+
headers: {
|
|
148
|
+
Authorization: `Bearer ${token}`
|
|
149
|
+
// Intentionally NO Content-Type — fetch sets the boundary.
|
|
150
|
+
},
|
|
151
|
+
body: formData,
|
|
152
|
+
cache: "no-store",
|
|
153
|
+
signal: AbortSignal.timeout(36e4)
|
|
154
|
+
});
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
let body = "";
|
|
157
|
+
try {
|
|
158
|
+
body = await response.text();
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
throw new Error(
|
|
162
|
+
`HTTP ${response.status}: ${response.statusText}${body ? ` \u2014 ${body}` : ""}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return response.json();
|
|
166
|
+
}
|
|
135
167
|
}
|
|
136
168
|
|
|
137
169
|
class AreasResource extends BaseResource {
|
|
@@ -209,6 +241,79 @@ class ArticlesResource extends BaseResource {
|
|
|
209
241
|
const path = qs ? `?${qs}` : "";
|
|
210
242
|
return this.request("GET", path);
|
|
211
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Fetch a single article by id or accessor within the active venue.
|
|
246
|
+
* Returns the full row including the TipTap `content` document.
|
|
247
|
+
*/
|
|
248
|
+
async getByAccessor(idOrAccessor) {
|
|
249
|
+
return this.request("GET", `/${encodeURIComponent(idOrAccessor)}`);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Partial-update an article. Locale-keyed fields (slug, title, excerpt)
|
|
253
|
+
* merge at the locale level — `{ slug: { en: 'foo' } }` updates `en`
|
|
254
|
+
* without touching `de`. Plain scalar / array fields fully replace.
|
|
255
|
+
* Returns the resulting article.
|
|
256
|
+
*/
|
|
257
|
+
async patch(idOrAccessor, body) {
|
|
258
|
+
return this.request(
|
|
259
|
+
"PATCH",
|
|
260
|
+
`/${encodeURIComponent(idOrAccessor)}`,
|
|
261
|
+
body
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Read the article's resolved feature image — asset id, public URL,
|
|
266
|
+
* matched locale, plus the FULL per-locale caption + alt records.
|
|
267
|
+
* Returns null when the article has no feature image yet (the wire
|
|
268
|
+
* 404 is mapped here for ergonomic null-checking on the caller side).
|
|
269
|
+
*/
|
|
270
|
+
async getFeatureImage(idOrAccessor, options) {
|
|
271
|
+
const params = new URLSearchParams();
|
|
272
|
+
if (options?.locale) params.set("locale", options.locale);
|
|
273
|
+
const qs = params.toString();
|
|
274
|
+
const path = `/${encodeURIComponent(idOrAccessor)}/feature-image${qs ? `?${qs}` : ""}`;
|
|
275
|
+
try {
|
|
276
|
+
return await this.request("GET", path);
|
|
277
|
+
} catch (err) {
|
|
278
|
+
if (err instanceof Error && err.message.includes("HTTP 404")) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
throw err;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Upload a new feature image. Replaces any existing feature image
|
|
286
|
+
* for the venue's primary locale (the previous one is demoted to
|
|
287
|
+
* `role='inline'`). The SDK builds the multipart body internally —
|
|
288
|
+
* pass a Buffer/Uint8Array, the original filename, and the MIME
|
|
289
|
+
* type.
|
|
290
|
+
*/
|
|
291
|
+
async uploadFeatureImage(idOrAccessor, file) {
|
|
292
|
+
const form = new FormData();
|
|
293
|
+
form.append(
|
|
294
|
+
"file",
|
|
295
|
+
new Blob([new Uint8Array(file.data)], { type: file.contentType }),
|
|
296
|
+
file.filename
|
|
297
|
+
);
|
|
298
|
+
return this.requestMultipart(
|
|
299
|
+
"POST",
|
|
300
|
+
`/${encodeURIComponent(idOrAccessor)}/feature-image`,
|
|
301
|
+
form
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Update per-locale caption / alt on the article's feature image.
|
|
306
|
+
* Locale-keyed merge — `{ caption: { en: '…' } }` does not touch
|
|
307
|
+
* `de`. Plain-string locale values are server-side wrapped into
|
|
308
|
+
* minimal TipTap docs (the storage shape).
|
|
309
|
+
*/
|
|
310
|
+
async patchFeatureImage(idOrAccessor, body) {
|
|
311
|
+
return this.request(
|
|
312
|
+
"PATCH",
|
|
313
|
+
`/${encodeURIComponent(idOrAccessor)}/feature-image`,
|
|
314
|
+
body
|
|
315
|
+
);
|
|
316
|
+
}
|
|
212
317
|
}
|
|
213
318
|
|
|
214
319
|
class BasketsResource extends BaseResource {
|
|
@@ -794,6 +899,44 @@ class TeamOrdersResource {
|
|
|
794
899
|
}
|
|
795
900
|
}
|
|
796
901
|
|
|
902
|
+
class VenuesResource {
|
|
903
|
+
constructor(tokenManager, baseUrl) {
|
|
904
|
+
this.tokenManager = tokenManager;
|
|
905
|
+
this.baseUrl = baseUrl;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Fetch a venue by its UUID or its accessor (slug). The path accepts
|
|
909
|
+
* either form; the server resolves transparently.
|
|
910
|
+
*
|
|
911
|
+
* Powers the order3000-cli's `venues use <accessor>` validation step
|
|
912
|
+
* — the CLI hits this to prove the accessor exists and to cache the
|
|
913
|
+
* resolved UUID + display fields locally.
|
|
914
|
+
*/
|
|
915
|
+
async getByAccessor(idOrAccessor) {
|
|
916
|
+
const token = await this.tokenManager.getToken();
|
|
917
|
+
const url = `${this.baseUrl}/venues/${encodeURIComponent(idOrAccessor)}`;
|
|
918
|
+
const response = await fetch(url, {
|
|
919
|
+
method: "GET",
|
|
920
|
+
headers: {
|
|
921
|
+
Authorization: `Bearer ${token}`,
|
|
922
|
+
"Content-Type": "application/json"
|
|
923
|
+
},
|
|
924
|
+
cache: "no-store"
|
|
925
|
+
});
|
|
926
|
+
if (!response.ok) {
|
|
927
|
+
let body = "";
|
|
928
|
+
try {
|
|
929
|
+
body = await response.text();
|
|
930
|
+
} catch {
|
|
931
|
+
}
|
|
932
|
+
throw new Error(
|
|
933
|
+
`HTTP ${response.status}: ${response.statusText}${body ? ` \u2014 ${body}` : ""}`
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
return response.json();
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
797
940
|
var __defProp$2 = Object.defineProperty;
|
|
798
941
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
799
942
|
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -1128,6 +1271,7 @@ class Order3000Client {
|
|
|
1128
1271
|
__publicField(this, "reservations");
|
|
1129
1272
|
__publicField(this, "subscriptions");
|
|
1130
1273
|
__publicField(this, "teamOrders");
|
|
1274
|
+
__publicField(this, "venues");
|
|
1131
1275
|
__publicField(this, "realtime");
|
|
1132
1276
|
__publicField(this, "baseUrl");
|
|
1133
1277
|
__publicField(this, "tokenManager");
|
|
@@ -1158,6 +1302,7 @@ class Order3000Client {
|
|
|
1158
1302
|
this.baseUrl
|
|
1159
1303
|
);
|
|
1160
1304
|
this.teamOrders = new TeamOrdersResource(this.tokenManager, this.baseUrl);
|
|
1305
|
+
this.venues = new VenuesResource(this.tokenManager, this.baseUrl);
|
|
1161
1306
|
this.realtime = new RealtimeManager(this.tokenManager, this.baseUrl);
|
|
1162
1307
|
}
|
|
1163
1308
|
}
|
package/dist/schemas.cjs
CHANGED
|
@@ -9,8 +9,14 @@ const GetAreaAvailabilityResponse = zod.z.object({ from: zod.z.string().regex(/^
|
|
|
9
9
|
const SubmitAreaBookingRequest = zod.z.object({ requestedDate: zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/), requestedStartTime: zod.z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/).optional(), requestedEndTime: zod.z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/).optional(), partySize: zod.z.number().int().lte(9007199254740991), customerFirstName: zod.z.string().min(1), customerLastName: zod.z.string().min(1), customerEmail: zod.z.string().regex(/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/).email(), customerPhone: zod.z.string().optional(), message: zod.z.string().optional(), source: zod.z.enum(["website", "phone", "walk_in"]).optional() }).strict();
|
|
10
10
|
const SubmitAreaBookingResponse = zod.z.object({ id: zod.z.string(), venueId: zod.z.string(), areaId: zod.z.string(), requestedDate: zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/), requestedStartTime: zod.z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/).nullable(), requestedEndTime: zod.z.string().regex(/^\d{2}:\d{2}(:\d{2})?$/).nullable(), partySize: zod.z.number().int().gte(-9007199254740991).lte(9007199254740991), customerFirstName: zod.z.string(), customerLastName: zod.z.string(), customerEmail: zod.z.string(), customerPhone: zod.z.string().nullable(), message: zod.z.string().nullable(), source: zod.z.enum(["website", "phone", "walk_in"]), status: zod.z.enum(["pending", "approved", "rejected", "cancelled"]), areaBookingId: zod.z.string().nullable(), createdAt: zod.z.string().nullable(), updatedAt: zod.z.string().nullable() }).strict();
|
|
11
11
|
const includeDrafts = zod.z.union([zod.z.literal("true"), zod.z.literal("false")]).optional();
|
|
12
|
-
const
|
|
12
|
+
const FeatureImage = zod.z.object({ id: zod.z.string(), publicUrl: zod.z.string().nullable(), locale: zod.z.string(), caption: zod.z.object({}).partial().strict().passthrough().nullable(), alt: zod.z.object({}).partial().strict().passthrough().nullable() }).strict();
|
|
13
|
+
const Article = zod.z.object({ id: zod.z.string(), venueId: zod.z.string(), accessor: zod.z.string(), slug: zod.z.record(zod.z.string()), title: zod.z.record(zod.z.string()), excerpt: zod.z.record(zod.z.string()).nullable(), content: zod.z.object({}).partial().strict().passthrough().nullable(), tags: zod.z.array(zod.z.string()), isActive: zod.z.boolean(), isFeatured: zod.z.boolean(), priority: zod.z.number().int().gte(-2147483648).lte(2147483647), publishedAt: zod.z.unknown().nullable(), createdAt: zod.z.unknown().nullable(), updatedAt: zod.z.unknown().nullable(), featureImage: FeatureImage.nullable() }).strict();
|
|
13
14
|
const ListArticlesResponse = zod.z.array(Article);
|
|
15
|
+
const GetArticleResponse = zod.z.object({ id: zod.z.string(), venueId: zod.z.string(), accessor: zod.z.string(), slug: zod.z.record(zod.z.string()), title: zod.z.record(zod.z.string()), excerpt: zod.z.record(zod.z.string()).nullable(), content: zod.z.object({}).partial().strict().passthrough().nullable(), tags: zod.z.array(zod.z.string()), isActive: zod.z.boolean(), isFeatured: zod.z.boolean(), priority: zod.z.number().int().gte(-2147483648).lte(2147483647), publishedAt: zod.z.unknown().nullable(), createdAt: zod.z.unknown().nullable(), updatedAt: zod.z.unknown().nullable(), featureImage: FeatureImage.nullable() }).strict();
|
|
16
|
+
const PatchArticleRequest = zod.z.object({ slug: zod.z.record(zod.z.string()), title: zod.z.record(zod.z.string()), excerpt: zod.z.record(zod.z.string()), content: zod.z.object({}).partial().strict().passthrough(), tags: zod.z.array(zod.z.string()), isActive: zod.z.boolean(), isFeatured: zod.z.boolean(), priority: zod.z.number().int().gte(-9007199254740991).lte(9007199254740991) }).partial().strict();
|
|
17
|
+
const PatchArticleResponse = zod.z.object({ id: zod.z.string(), venueId: zod.z.string(), accessor: zod.z.string(), slug: zod.z.record(zod.z.string()), title: zod.z.record(zod.z.string()), excerpt: zod.z.record(zod.z.string()).nullable(), content: zod.z.object({}).partial().strict().passthrough().nullable(), tags: zod.z.array(zod.z.string()), isActive: zod.z.boolean(), isFeatured: zod.z.boolean(), priority: zod.z.number().int().gte(-2147483648).lte(2147483647), publishedAt: zod.z.unknown().nullable(), createdAt: zod.z.unknown().nullable(), updatedAt: zod.z.unknown().nullable(), featureImage: FeatureImage.nullable() }).strict();
|
|
18
|
+
const UploadFeatureImageRequest = zod.z.object({ file: zod.z.unknown() }).strict();
|
|
19
|
+
const PatchFeatureImageRequest = zod.z.object({ caption: zod.z.object({}).partial().strict().passthrough(), alt: zod.z.object({}).partial().strict().passthrough() }).partial().strict();
|
|
14
20
|
const AddToBasketRequest = zod.z.object({ venueId: zod.z.string().regex(/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/).uuid(), sessionId: zod.z.string().min(1), menuItems: zod.z.array(zod.z.object({ menuItemId: zod.z.string().min(1), role: zod.z.string().optional(), quantity: zod.z.number().gt(0).optional(), unit: zod.z.enum(["grams", "kilograms", "liters", "milliliters", "pieces"]).optional() }).strict()).min(1), metadata: zod.z.object({}).partial().strict().passthrough().optional() }).strict();
|
|
15
21
|
const AddToBasketResponse = zod.z.object({ basketItemId: zod.z.string().regex(/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/).uuid(), itemCount: zod.z.number().int().gte(0).lte(9007199254740991), deposit: zod.z.object({ depositwareTemplateId: zod.z.string(), name: zod.z.record(zod.z.string()), amount: zod.z.number().int().gte(0).lte(9007199254740991), currency: zod.z.enum(["EUR", "CHF"]) }).strict().nullable(), totals: zod.z.object({ currency: zod.z.enum(["EUR", "CHF"]), itemsTotal: zod.z.number().int().gte(0).lte(9007199254740991), taxAmount: zod.z.number().int().gte(0).lte(9007199254740991), depositCharge: zod.z.number().int().gte(0).lte(9007199254740991), grossTotal: zod.z.number().int().gte(0).lte(9007199254740991), depositCredit: zod.z.number().int().gte(0).lte(9007199254740991), effectiveTotal: zod.z.number().int().gte(0).lte(9007199254740991), cashRefund: zod.z.number().int().gte(0).lte(9007199254740991), returnable: zod.z.array(zod.z.object({ depositwareTemplateId: zod.z.string(), count: zod.z.number().int().gte(0).lte(9007199254740991) }).strict()) }).strict() }).strict();
|
|
16
22
|
const RemoveFromBasketResponse = zod.z.object({ success: zod.z.boolean(), basketItemId: zod.z.string().regex(/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/).uuid(), itemCount: zod.z.number().int().gte(0).lte(9007199254740991), totals: zod.z.object({ currency: zod.z.enum(["EUR", "CHF"]), itemsTotal: zod.z.number().int().gte(0).lte(9007199254740991), taxAmount: zod.z.number().int().gte(0).lte(9007199254740991), depositCharge: zod.z.number().int().gte(0).lte(9007199254740991), grossTotal: zod.z.number().int().gte(0).lte(9007199254740991), depositCredit: zod.z.number().int().gte(0).lte(9007199254740991), effectiveTotal: zod.z.number().int().gte(0).lte(9007199254740991), cashRefund: zod.z.number().int().gte(0).lte(9007199254740991), returnable: zod.z.array(zod.z.object({ depositwareTemplateId: zod.z.string(), count: zod.z.number().int().gte(0).lte(9007199254740991) }).strict()) }).strict().nullable() }).strict();
|
|
@@ -62,6 +68,7 @@ const SwitchFulfillmentTeamOrderRequest = zod.z.object({ publicId: zod.z.string(
|
|
|
62
68
|
const SwitchFulfillmentTeamOrderResponse = zod.z.object({ teamOrderId: zod.z.string().regex(/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/).uuid(), status: zod.z.enum(["draft", "collecting", "locked", "placed", "ready", "completed", "cancelled"]), fulfillmentType: zod.z.enum(["pickup", "delivery"]), deliveryAddressId: zod.z.string().nullable() }).strict();
|
|
63
69
|
const UpdateDeliveryAddressTeamOrderRequest = zod.z.object({ publicId: zod.z.string().min(1), sessionId: zod.z.string().min(1), deliveryAddress: zod.z.object({ street: zod.z.string(), city: zod.z.string(), state: zod.z.string(), postalCode: zod.z.string(), country: zod.z.string() }).strict() }).strict();
|
|
64
70
|
const UpdateDeliveryAddressTeamOrderResponse = zod.z.object({ teamOrderId: zod.z.string().regex(/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/).uuid(), deliveryAddressId: zod.z.string() }).strict();
|
|
71
|
+
const GetVenueResponse = zod.z.object({ id: zod.z.string(), accessor: zod.z.string(), officialName: zod.z.string(), legalName: zod.z.string(), shortName: zod.z.string(), brandName: zod.z.string(), primaryLocale: zod.z.string(), supportedLocales: zod.z.array(zod.z.string()), timezone: zod.z.string(), createdAt: zod.z.unknown().nullable(), updatedAt: zod.z.unknown().nullable() }).strict();
|
|
65
72
|
const schemas = {
|
|
66
73
|
Area,
|
|
67
74
|
ListAreasResponse,
|
|
@@ -70,8 +77,14 @@ const schemas = {
|
|
|
70
77
|
SubmitAreaBookingRequest,
|
|
71
78
|
SubmitAreaBookingResponse,
|
|
72
79
|
includeDrafts,
|
|
80
|
+
FeatureImage,
|
|
73
81
|
Article,
|
|
74
82
|
ListArticlesResponse,
|
|
83
|
+
GetArticleResponse,
|
|
84
|
+
PatchArticleRequest,
|
|
85
|
+
PatchArticleResponse,
|
|
86
|
+
UploadFeatureImageRequest,
|
|
87
|
+
PatchFeatureImageRequest,
|
|
75
88
|
AddToBasketRequest,
|
|
76
89
|
AddToBasketResponse,
|
|
77
90
|
RemoveFromBasketResponse,
|
|
@@ -122,7 +135,8 @@ const schemas = {
|
|
|
122
135
|
SwitchFulfillmentTeamOrderRequest,
|
|
123
136
|
SwitchFulfillmentTeamOrderResponse,
|
|
124
137
|
UpdateDeliveryAddressTeamOrderRequest,
|
|
125
|
-
UpdateDeliveryAddressTeamOrderResponse
|
|
138
|
+
UpdateDeliveryAddressTeamOrderResponse,
|
|
139
|
+
GetVenueResponse
|
|
126
140
|
};
|
|
127
141
|
|
|
128
142
|
exports.schemas = schemas;
|