order3000 0.6.1 → 0.7.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/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # Order3000 Node.js SDK
1
+ # order3000 Node.js SDK
2
2
 
3
- A TypeScript-first Node.js SDK for integrating with the Order3000 restaurant management platform. This SDK provides a simple, type-safe interface for managing orders, reservations, and other restaurant operations through the Order3000 API.
3
+ A TypeScript-first Node.js SDK for integrating with the order3000 restaurant management platform. This SDK provides a simple, type-safe interface for managing orders, reservations, and other restaurant operations through the order3000 API.
4
4
 
5
5
  ## Overview
6
6
 
7
- Order3000 is a comprehensive restaurant management platform that handles orders, reservations, customer management, and more. This SDK allows external applications and websites to integrate seamlessly with Order3000 through a clean, promise-based API.
7
+ order3000 is a comprehensive restaurant management platform that handles orders, reservations, customer management, and more. This SDK allows external applications and websites to integrate seamlessly with order3000 through a clean, promise-based API.
8
8
 
9
9
  ### Key Features
10
10
 
@@ -121,23 +121,20 @@ The API documentation is powered by Scalar and provides a comprehensive view of
121
121
 
122
122
  ### Adding New API Endpoints
123
123
 
124
- When new endpoints are added or modified in the Order3000 platform, follow this workflow to update the SDK:
124
+ When new endpoints are added or modified in the order3000 platform, follow this workflow to update the SDK:
125
125
 
126
126
  1. **Define API Contracts**: Create or update TypeScript contracts that define the API structure
127
-
128
127
  - Add/modify contracts in `/apps/order3000/src/app/api/openapi/contracts/`
129
128
  - Use `@ts-rest/core` to define type-safe contracts
130
129
  - Export contracts from `/apps/order3000/src/app/api/openapi/contract.ts`
131
130
  - Generate OpenAPI spec to preview changes: `npx nx run order3000:generate-openapi`
132
131
  - View updated docs at http://localhost:3000/developers/reference
133
132
 
134
- 2. **Implement API Endpoints**: Create the actual endpoint logic in the Order3000 application
135
-
133
+ 2. **Implement API Endpoints**: Create the actual endpoint logic in the order3000 application
136
134
  - Implement handlers in `/apps/order3000/src/app/api/` following the contract definitions
137
135
  - Ensure endpoints match the contracts exactly
138
136
 
139
137
  3. **Update SDK Resources**: Integrate the new endpoints into the SDK
140
-
141
138
  - Create or update resource classes in `/apps/order3000-nodejs/src/resources/`
142
139
  - Follow the existing pattern extending from `BaseResource`
143
140
  - Export new resources from the main `Order3000Client` class
@@ -217,7 +214,7 @@ try {
217
214
 
218
215
  ### Multi-Tenant Architecture
219
216
 
220
- Order3000 supports multi-tenant operations where each restaurant or location is a separate tenant:
217
+ order3000 supports multi-tenant operations where each restaurant or location is a separate tenant:
221
218
 
222
219
  - **Automatic Tenant Resolution**: If no tenant ID is provided, the SDK uses the default tenant from the authentication token
223
220
  - **Explicit Tenant Selection**: You can specify a tenant ID in the client configuration or per-request
@@ -225,7 +222,7 @@ Order3000 supports multi-tenant operations where each restaurant or location is
225
222
 
226
223
  ### Related Components
227
224
 
228
- The Order3000 platform includes:
225
+ The order3000 platform includes:
229
226
 
230
227
  - **Reservations System**: Complete table reservation management with flexible contact preferences
231
228
  - **Customer Management**: Customer profiles with order history and preferences
@@ -259,4 +256,4 @@ Part of the Kolaveri platform - see root repository for license information.
259
256
 
260
257
  ## Support
261
258
 
262
- For issues, questions, or feature requests related to this SDK, please contact the Order3000 development team or open an issue in the main repository.
259
+ For issues, questions, or feature requests related to this SDK, please contact the order3000 development team or open an issue in the main repository.
package/dist/client.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var got = require('got');
4
-
5
3
  var __defProp$1 = Object.defineProperty;
6
4
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
5
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -46,23 +44,30 @@ class TokenManager {
46
44
  console.log("[SDK TOKEN] Requesting token from:", this.tokenEndpoint);
47
45
  console.log("[SDK TOKEN] Using clientId:", this.clientId);
48
46
  console.log("[SDK TOKEN] Secret length:", this.clientSecret?.length);
49
- this.refreshPromise = got.post(this.tokenEndpoint, {
50
- json: { clientId: this.clientId, clientSecret: this.clientSecret },
51
- responseType: "json",
52
- timeout: { request: 36e4 },
53
- retry: { limit: 3 }
54
- }).then((response) => {
47
+ this.refreshPromise = fetch(this.tokenEndpoint, {
48
+ method: "POST",
49
+ headers: { "Content-Type": "application/json" },
50
+ body: JSON.stringify({
51
+ clientId: this.clientId,
52
+ clientSecret: this.clientSecret
53
+ }),
54
+ signal: AbortSignal.timeout(36e4)
55
+ }).then(async (response) => {
56
+ if (!response.ok) {
57
+ const body = await response.text();
58
+ console.log("[SDK TOKEN] Response status:", response.status);
59
+ console.log("[SDK TOKEN] Response body:", body);
60
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
61
+ }
62
+ return response.json();
63
+ }).then((data) => {
55
64
  console.log("[SDK TOKEN] Token received successfully");
56
- this.accessToken = response.body.accessToken;
57
- this.tokenExpiresAt = Date.now() + response.body.expiresIn * 1e3;
65
+ this.accessToken = data.accessToken;
66
+ this.tokenExpiresAt = Date.now() + data.expiresIn * 1e3;
58
67
  this.setDefaultVenueId();
59
68
  return this.accessToken;
60
69
  }).catch((error) => {
61
70
  console.log("[SDK TOKEN] Token request failed:", error.message);
62
- if (error.response) {
63
- console.log("[SDK TOKEN] Response status:", error.response.statusCode);
64
- console.log("[SDK TOKEN] Response body:", error.response.body);
65
- }
66
71
  throw error;
67
72
  }).finally(() => {
68
73
  this.refreshPromise = null;
@@ -103,17 +108,19 @@ class BaseResource {
103
108
  const venueId = this.tokenManager.getVenueId();
104
109
  const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
105
110
  console.log(`[SDK] Making ${method} request to: ${url}`);
106
- return got(
107
- url,
108
- {
109
- method,
110
- json: data,
111
- headers: { Authorization: `Bearer ${token}` },
112
- responseType: "json",
113
- timeout: { request: 36e4 },
114
- retry: { limit: 2 }
115
- }
116
- ).json();
111
+ const response = await fetch(url, {
112
+ method,
113
+ headers: {
114
+ Authorization: `Bearer ${token}`,
115
+ "Content-Type": "application/json"
116
+ },
117
+ body: data ? JSON.stringify(data) : void 0,
118
+ signal: AbortSignal.timeout(36e4)
119
+ });
120
+ if (!response.ok) {
121
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
122
+ }
123
+ return response.json();
117
124
  }
118
125
  }
119
126
 
@@ -121,9 +128,45 @@ class EventsResource extends BaseResource {
121
128
  constructor(tokenManager, baseUrl) {
122
129
  super(tokenManager, baseUrl, "/events");
123
130
  }
131
+ /**
132
+ * List all events for the venue
133
+ * @param options - Optional filters for the list request
134
+ * @returns Array of events with schedule, posters, and promotions
135
+ */
136
+ async list(options) {
137
+ const queryParams = new URLSearchParams();
138
+ if (options?.includePrivate) {
139
+ queryParams.set("includePrivate", "true");
140
+ }
141
+ if (options?.isPublic !== void 0) {
142
+ queryParams.set("isPublic", String(options.isPublic));
143
+ }
144
+ if (options?.isRecurring !== void 0) {
145
+ queryParams.set("isRecurring", String(options.isRecurring));
146
+ }
147
+ if (options?.isClosed !== void 0) {
148
+ queryParams.set("isClosed", String(options.isClosed));
149
+ }
150
+ if (options?.upcomingWithinDays !== void 0) {
151
+ queryParams.set("upcomingWithinDays", String(options.upcomingWithinDays));
152
+ }
153
+ const queryString = queryParams.toString();
154
+ const path = queryString ? `?${queryString}` : "";
155
+ return this.request("GET", path);
156
+ }
157
+ /**
158
+ * Create a new event
159
+ * @param event - The event details
160
+ * @returns The created event
161
+ */
124
162
  async place(event) {
125
163
  return this.request("POST", "", event);
126
164
  }
165
+ /**
166
+ * Get a single event by ID
167
+ * @param eventId - The event ID
168
+ * @returns The event details
169
+ */
127
170
  async get(eventId) {
128
171
  return this.request("GET", `/${eventId}`);
129
172
  }
@@ -187,15 +230,6 @@ class Order3000Client {
187
230
  this.tokenManager,
188
231
  this.baseUrl
189
232
  );
190
- this.initialize();
191
- }
192
- async initialize() {
193
- try {
194
- await this.tokenManager.initialize();
195
- } catch (error) {
196
- console.error("Failed to initialize client:", error);
197
- process.exit(1);
198
- }
199
233
  }
200
234
  }
201
235
 
package/dist/client.d.cts CHANGED
@@ -41,11 +41,9 @@ interface components {
41
41
  taxAmount: string;
42
42
  totalAmount: string;
43
43
  currency?: string;
44
- /** Format: date-time */
45
- orderedAt?: string;
44
+ orderedAt?: unknown;
46
45
  orderedBy: string;
47
- /** Format: date-time */
48
- updatedAt?: string | null;
46
+ updatedAt?: unknown;
49
47
  updatedBy?: string | null;
50
48
  };
51
49
  /** PlaceOrderResponse */
@@ -61,11 +59,9 @@ interface components {
61
59
  taxAmount: string;
62
60
  totalAmount: string;
63
61
  currency: string;
64
- /** Format: date-time */
65
- orderedAt: string;
62
+ orderedAt: unknown;
66
63
  orderedBy: string;
67
- /** Format: date-time */
68
- updatedAt: string | null;
64
+ updatedAt: unknown;
69
65
  updatedBy: string | null;
70
66
  };
71
67
  /**
@@ -170,31 +166,16 @@ interface components {
170
166
  status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
171
167
  /** @description 6-character confirmation code for the reservation */
172
168
  confirmationCode: string | null;
173
- /**
174
- * Format: date-time
175
- * @description When the reservation was confirmed
176
- */
177
- confirmedAt: string | null;
178
- /**
179
- * Format: date-time
180
- * @description When the guest arrived
181
- */
182
- arrivedAt: string | null;
183
- /**
184
- * Format: date-time
185
- * @description When the guest was seated
186
- */
187
- seatedAt: string | null;
188
- /**
189
- * Format: date-time
190
- * @description When the dining was completed
191
- */
192
- completedAt: string | null;
193
- /**
194
- * Format: date-time
195
- * @description When the reservation was cancelled
196
- */
197
- cancelledAt: string | null;
169
+ /** @description When the reservation was confirmed */
170
+ confirmedAt: unknown;
171
+ /** @description When the guest arrived */
172
+ arrivedAt: unknown;
173
+ /** @description When the guest was seated */
174
+ seatedAt: unknown;
175
+ /** @description When the dining was completed */
176
+ completedAt: unknown;
177
+ /** @description When the reservation was cancelled */
178
+ cancelledAt: unknown;
198
179
  /**
199
180
  * @description Who initiated the cancellation
200
181
  * @enum {string|null}
@@ -215,138 +196,20 @@ interface components {
215
196
  createdBy: string | null;
216
197
  /** @description User ID who last updated the reservation */
217
198
  updatedBy: string | null;
218
- /**
219
- * Format: date-time
220
- * @description Reservation creation timestamp
221
- */
222
- createdAt: string | null;
223
- /**
224
- * Format: date-time
225
- * @description Last update timestamp
226
- */
227
- updatedAt: string | null;
228
- };
229
- /**
230
- * ReservationDetails
231
- * @description Reservation details
232
- */
233
- ReservationDetails: {
234
- /**
235
- * Format: uuid
236
- * @description Unique identifier for the reservation
237
- */
238
- id: string;
239
- /**
240
- * Format: uuid
241
- * @description Restaurant/tenant identifier
242
- */
243
- venueId: string;
244
- /**
245
- * Format: uuid
246
- * @description Event identifier for this reservation
247
- */
248
- eventId: string;
249
- /** @description Date of the reservation in YYYY-MM-DD format */
250
- reservationDate: string;
251
- /** @description Time of the reservation in HH:MM:SS format */
252
- reservationTime: string;
253
- /** @description Number of guests in the party */
254
- partySize: number;
255
- /** @description Reservation duration in minutes */
256
- duration: number | null;
257
- /**
258
- * Format: uuid
259
- * @description Link to customer profile if exists
260
- */
261
- customerId: string | null;
262
- /** @description First name of the customer */
263
- customerFirstName: string;
264
- /** @description Last name of the customer */
265
- customerLastName: string;
266
- /** @description Customer email address */
267
- customerEmail: string | null;
268
- /** @description Customer phone number */
269
- customerPhone: string | null;
270
- /**
271
- * @description Preferred contact method
272
- * @enum {string}
273
- */
274
- contactPreference: "email" | "phone" | "sms" | "none";
275
- /**
276
- * @description Current status of the reservation
277
- * @enum {string}
278
- */
279
- status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
280
- /** @description 6-character confirmation code for the reservation */
281
- confirmationCode: string | null;
282
- /**
283
- * Format: date-time
284
- * @description When the reservation was confirmed
285
- */
286
- confirmedAt: string | null;
287
- /**
288
- * Format: date-time
289
- * @description When the guest arrived
290
- */
291
- arrivedAt: string | null;
292
- /**
293
- * Format: date-time
294
- * @description When the guest was seated
295
- */
296
- seatedAt: string | null;
297
- /**
298
- * Format: date-time
299
- * @description When the dining was completed
300
- */
301
- completedAt: string | null;
302
- /**
303
- * Format: date-time
304
- * @description When the reservation was cancelled
305
- */
306
- cancelledAt: string | null;
307
- /**
308
- * @description Who initiated the cancellation
309
- * @enum {string|null}
310
- */
311
- cancellationReason: "customer_request" | "restaurant_request" | null;
312
- /** @description Additional cancellation details */
313
- cancellationNote: string | null;
314
- /**
315
- * @description Origin of the reservation
316
- * @enum {string}
317
- */
318
- source: "website" | "phone" | "walk_in";
319
- /** @description Any special requirements or notes */
320
- specialRequests: string | null;
321
- /** @description Preferred seating location */
322
- tablePreference: string | null;
323
- /** @description User ID who created the reservation */
324
- createdBy: string | null;
325
- /** @description User ID who last updated the reservation */
326
- updatedBy: string | null;
327
- /**
328
- * Format: date-time
329
- * @description Reservation creation timestamp
330
- */
331
- createdAt: string | null;
332
- /**
333
- * Format: date-time
334
- * @description Last update timestamp
335
- */
336
- updatedAt: string | null;
199
+ /** @description Reservation creation timestamp */
200
+ createdAt: unknown;
201
+ /** @description Last update timestamp */
202
+ updatedAt: unknown;
337
203
  };
338
204
  /**
339
205
  * CreateEventRequest
340
206
  * @description Request payload for creating a new event
341
207
  */
342
208
  CreateEventRequest: {
343
- venueId: string;
344
- /** @enum {string} */
345
- type: "regular" | "private" | "closure" | "maintenance";
346
- name: (((string | number | boolean | (string | null)) | null) | {
209
+ name: (string | number | boolean | (null)) | {
347
210
  [key: string]: unknown;
348
- } | unknown[]) | null;
349
- description?: (((string | number | boolean | (string | null)) | null) | {
211
+ } | unknown[];
212
+ description?: ((string | number | boolean | (null)) | {
350
213
  [key: string]: unknown;
351
214
  } | unknown[]) | null;
352
215
  scheduleId?: string | null;
@@ -354,7 +217,27 @@ interface components {
354
217
  maxGuests?: number | null;
355
218
  minPartySize?: number | null;
356
219
  maxPartySize?: number | null;
220
+ isPublic?: boolean;
221
+ isRecurring?: boolean;
222
+ acceptsReservations?: boolean;
223
+ bookingOpensAtDays?: number | null;
224
+ bookingClosesAtHours?: number | null;
357
225
  isActive?: boolean;
226
+ isClosed?: boolean;
227
+ priority?: number;
228
+ schedule?: {
229
+ rrule?: string | null;
230
+ timezone?: string | null;
231
+ validFrom?: unknown;
232
+ validTo?: unknown;
233
+ startTime?: string | null;
234
+ endTime?: string | null;
235
+ lastSeatingTime?: string | null;
236
+ /** @enum {string|null} */
237
+ slotMode?: "interval" | "duration" | null;
238
+ intervalMinutes?: number | null;
239
+ durationMinutes?: number | null;
240
+ } | null;
358
241
  };
359
242
  /**
360
243
  * CreateEventResponse
@@ -363,12 +246,10 @@ interface components {
363
246
  CreateEventResponse: {
364
247
  id: string;
365
248
  venueId: string;
366
- /** @enum {string} */
367
- type: "regular" | "private" | "closure" | "maintenance";
368
- name: (((string | number | boolean | (string | null)) | null) | {
249
+ name: (string | number | boolean | (null)) | {
369
250
  [key: string]: unknown;
370
- } | unknown[]) | null;
371
- description: (((string | number | boolean | (string | null)) | null) | {
251
+ } | unknown[];
252
+ description: ((string | number | boolean | (null)) | {
372
253
  [key: string]: unknown;
373
254
  } | unknown[]) | null;
374
255
  scheduleId: string | null;
@@ -376,13 +257,18 @@ interface components {
376
257
  maxGuests: number | null;
377
258
  minPartySize: number | null;
378
259
  maxPartySize: number | null;
260
+ isPublic: boolean;
261
+ isRecurring: boolean;
262
+ acceptsReservations: boolean;
263
+ bookingOpensAtDays: number | null;
264
+ bookingClosesAtHours: number | null;
379
265
  isActive: boolean;
266
+ isClosed: boolean;
267
+ priority: number;
380
268
  createdBy: string | null;
381
269
  updatedBy: string | null;
382
- /** Format: date-time */
383
- createdAt: string | null;
384
- /** Format: date-time */
385
- updatedAt: string | null;
270
+ createdAt: unknown;
271
+ updatedAt: unknown;
386
272
  };
387
273
  };
388
274
  responses: never;
@@ -399,11 +285,140 @@ type PlaceOrderRequest = schemas['PlaceOrderRequest'];
399
285
  type PlaceOrderResponse = schemas['PlaceOrderResponse'];
400
286
  type MakeReservationRequest = schemas['MakeReservationRequest'];
401
287
  type MakeReservationResponse = schemas['MakeReservationResponse'];
288
+ interface TimeSlot {
289
+ id: string;
290
+ startTime: string;
291
+ endTime: string | null;
292
+ dayOfWeek?: 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT' | 'SUN' | null;
293
+ }
294
+ interface ScheduleOverride {
295
+ id: string;
296
+ date: string;
297
+ reason: Record<string, string> | null;
298
+ timeSlots: TimeSlot[];
299
+ }
300
+ interface Schedule {
301
+ id: string;
302
+ name: Record<string, string>;
303
+ description: Record<string, string> | null;
304
+ timezone: string;
305
+ rrule: string | null;
306
+ exdates: string[] | null;
307
+ validFrom: string | null;
308
+ validTo: string | null;
309
+ priority: number | null;
310
+ isActive: boolean;
311
+ sortIndex: string | null;
312
+ updatedAt: string | null;
313
+ updatedBy: string | null;
314
+ createdAt: string | null;
315
+ createdBy: string | null;
316
+ slotMode: 'interval' | 'duration';
317
+ intervalMinutes: number | null;
318
+ durationMinutes: number | null;
319
+ startTime: string | null;
320
+ lastSeatingTime: string | null;
321
+ }
322
+ interface EventPoster {
323
+ id: string;
324
+ eventId: string;
325
+ storagePath: string;
326
+ /** Signed URL for accessing the poster image (1 hour expiry) */
327
+ signedUrl: string | null;
328
+ filename: string;
329
+ contentType: string;
330
+ sizeBytes: number;
331
+ isPrimary: boolean;
332
+ sortIndex: string | null;
333
+ createdBy: string | null;
334
+ createdAt: string | null;
335
+ }
336
+ interface Promotion {
337
+ id: string;
338
+ venueId: string;
339
+ name: Record<string, string>;
340
+ description: Record<string, string> | null;
341
+ benefitType: 'free_item' | 'discount_percentage' | 'discount_amount' | 'buy_x_get_y';
342
+ benefitValue: Record<string, unknown>;
343
+ conditions: Record<string, unknown> | null;
344
+ maxRedemptions: number | null;
345
+ currentRedemptions: number | null;
346
+ validFrom: string | null;
347
+ validTo: string | null;
348
+ isActive: boolean;
349
+ createdBy: string | null;
350
+ updatedBy: string | null;
351
+ createdAt: string | null;
352
+ updatedAt: string | null;
353
+ timeSlotIds?: string[] | null;
354
+ }
355
+ interface Event {
356
+ id: string;
357
+ venueId: string;
358
+ name: Record<string, string>;
359
+ description: Record<string, string> | null;
360
+ scheduleId: string | null;
361
+ maxBookings: number | null;
362
+ maxGuests: number | null;
363
+ minPartySize: number | null;
364
+ maxPartySize: number | null;
365
+ isPublic: boolean;
366
+ isRecurring: boolean;
367
+ isClosed: boolean;
368
+ acceptsReservations: boolean;
369
+ bookingOpensAtDays: number | null;
370
+ bookingClosesAtHours: number | null;
371
+ isActive: boolean;
372
+ /** Priority for conflict resolution (higher = takes precedence) */
373
+ priority: number;
374
+ createdBy: string | null;
375
+ updatedBy: string | null;
376
+ createdAt: string | null;
377
+ updatedAt: string | null;
378
+ schedule: Schedule | null;
379
+ posters: EventPoster[];
380
+ promotions: Promotion[];
381
+ /** Regular time slots (by day of week) */
382
+ timeSlots: TimeSlot[];
383
+ /** Date-specific schedule overrides */
384
+ scheduleOverrides: ScheduleOverride[];
385
+ /** Next occurrence date for recurring events (YYYY-MM-DD format) */
386
+ nextOccurrence?: string | null;
387
+ }
388
+ interface ListEventsOptions {
389
+ /** Include private events in the response */
390
+ includePrivate?: boolean;
391
+ /** Filter by isPublic status */
392
+ isPublic?: boolean;
393
+ /** Filter by isRecurring status */
394
+ isRecurring?: boolean;
395
+ /** Filter by isClosed status */
396
+ isClosed?: boolean;
397
+ /** Filter for events occurring within N days from today */
398
+ upcomingWithinDays?: number;
399
+ }
400
+ type ListEventsResponse = Event[];
402
401
 
403
402
  declare class EventsResource extends BaseResource {
404
403
  constructor(tokenManager: TokenManager, baseUrl: string);
404
+ /**
405
+ * List all events for the venue
406
+ * @param options - Optional filters for the list request
407
+ * @returns Array of events with schedule, posters, and promotions
408
+ */
409
+ list(options?: ListEventsOptions): Promise<ListEventsResponse>;
410
+ /**
411
+ * Create a new event
412
+ * @param event - The event details
413
+ * @returns The created event
414
+ */
405
415
  place(event: CreateEventRequest): Promise<CreateEventResponse>;
406
- get(eventId: string): Promise<CreateEventRequest>;
416
+ /**
417
+ * Get a single event by ID
418
+ * @param eventId - The event ID
419
+ * @returns The event details
420
+ */
421
+ get(eventId: string): Promise<Event>;
407
422
  }
408
423
 
409
424
  declare class OrdersResource extends BaseResource {
@@ -450,7 +465,6 @@ declare class Order3000Client {
450
465
  private readonly baseUrl;
451
466
  private readonly tokenManager;
452
467
  constructor(config: Order3000ClientConfig);
453
- private initialize;
454
468
  }
455
469
 
456
- export { Order3000Client, type Order3000ClientConfig };
470
+ export { type Event, type EventPoster, type ListEventsOptions, type ListEventsResponse, Order3000Client, type Order3000ClientConfig, type Promotion, type Schedule, type ScheduleOverride, type TimeSlot };
package/dist/client.d.mts CHANGED
@@ -41,11 +41,9 @@ interface components {
41
41
  taxAmount: string;
42
42
  totalAmount: string;
43
43
  currency?: string;
44
- /** Format: date-time */
45
- orderedAt?: string;
44
+ orderedAt?: unknown;
46
45
  orderedBy: string;
47
- /** Format: date-time */
48
- updatedAt?: string | null;
46
+ updatedAt?: unknown;
49
47
  updatedBy?: string | null;
50
48
  };
51
49
  /** PlaceOrderResponse */
@@ -61,11 +59,9 @@ interface components {
61
59
  taxAmount: string;
62
60
  totalAmount: string;
63
61
  currency: string;
64
- /** Format: date-time */
65
- orderedAt: string;
62
+ orderedAt: unknown;
66
63
  orderedBy: string;
67
- /** Format: date-time */
68
- updatedAt: string | null;
64
+ updatedAt: unknown;
69
65
  updatedBy: string | null;
70
66
  };
71
67
  /**
@@ -170,31 +166,16 @@ interface components {
170
166
  status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
171
167
  /** @description 6-character confirmation code for the reservation */
172
168
  confirmationCode: string | null;
173
- /**
174
- * Format: date-time
175
- * @description When the reservation was confirmed
176
- */
177
- confirmedAt: string | null;
178
- /**
179
- * Format: date-time
180
- * @description When the guest arrived
181
- */
182
- arrivedAt: string | null;
183
- /**
184
- * Format: date-time
185
- * @description When the guest was seated
186
- */
187
- seatedAt: string | null;
188
- /**
189
- * Format: date-time
190
- * @description When the dining was completed
191
- */
192
- completedAt: string | null;
193
- /**
194
- * Format: date-time
195
- * @description When the reservation was cancelled
196
- */
197
- cancelledAt: string | null;
169
+ /** @description When the reservation was confirmed */
170
+ confirmedAt: unknown;
171
+ /** @description When the guest arrived */
172
+ arrivedAt: unknown;
173
+ /** @description When the guest was seated */
174
+ seatedAt: unknown;
175
+ /** @description When the dining was completed */
176
+ completedAt: unknown;
177
+ /** @description When the reservation was cancelled */
178
+ cancelledAt: unknown;
198
179
  /**
199
180
  * @description Who initiated the cancellation
200
181
  * @enum {string|null}
@@ -215,138 +196,20 @@ interface components {
215
196
  createdBy: string | null;
216
197
  /** @description User ID who last updated the reservation */
217
198
  updatedBy: string | null;
218
- /**
219
- * Format: date-time
220
- * @description Reservation creation timestamp
221
- */
222
- createdAt: string | null;
223
- /**
224
- * Format: date-time
225
- * @description Last update timestamp
226
- */
227
- updatedAt: string | null;
228
- };
229
- /**
230
- * ReservationDetails
231
- * @description Reservation details
232
- */
233
- ReservationDetails: {
234
- /**
235
- * Format: uuid
236
- * @description Unique identifier for the reservation
237
- */
238
- id: string;
239
- /**
240
- * Format: uuid
241
- * @description Restaurant/tenant identifier
242
- */
243
- venueId: string;
244
- /**
245
- * Format: uuid
246
- * @description Event identifier for this reservation
247
- */
248
- eventId: string;
249
- /** @description Date of the reservation in YYYY-MM-DD format */
250
- reservationDate: string;
251
- /** @description Time of the reservation in HH:MM:SS format */
252
- reservationTime: string;
253
- /** @description Number of guests in the party */
254
- partySize: number;
255
- /** @description Reservation duration in minutes */
256
- duration: number | null;
257
- /**
258
- * Format: uuid
259
- * @description Link to customer profile if exists
260
- */
261
- customerId: string | null;
262
- /** @description First name of the customer */
263
- customerFirstName: string;
264
- /** @description Last name of the customer */
265
- customerLastName: string;
266
- /** @description Customer email address */
267
- customerEmail: string | null;
268
- /** @description Customer phone number */
269
- customerPhone: string | null;
270
- /**
271
- * @description Preferred contact method
272
- * @enum {string}
273
- */
274
- contactPreference: "email" | "phone" | "sms" | "none";
275
- /**
276
- * @description Current status of the reservation
277
- * @enum {string}
278
- */
279
- status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
280
- /** @description 6-character confirmation code for the reservation */
281
- confirmationCode: string | null;
282
- /**
283
- * Format: date-time
284
- * @description When the reservation was confirmed
285
- */
286
- confirmedAt: string | null;
287
- /**
288
- * Format: date-time
289
- * @description When the guest arrived
290
- */
291
- arrivedAt: string | null;
292
- /**
293
- * Format: date-time
294
- * @description When the guest was seated
295
- */
296
- seatedAt: string | null;
297
- /**
298
- * Format: date-time
299
- * @description When the dining was completed
300
- */
301
- completedAt: string | null;
302
- /**
303
- * Format: date-time
304
- * @description When the reservation was cancelled
305
- */
306
- cancelledAt: string | null;
307
- /**
308
- * @description Who initiated the cancellation
309
- * @enum {string|null}
310
- */
311
- cancellationReason: "customer_request" | "restaurant_request" | null;
312
- /** @description Additional cancellation details */
313
- cancellationNote: string | null;
314
- /**
315
- * @description Origin of the reservation
316
- * @enum {string}
317
- */
318
- source: "website" | "phone" | "walk_in";
319
- /** @description Any special requirements or notes */
320
- specialRequests: string | null;
321
- /** @description Preferred seating location */
322
- tablePreference: string | null;
323
- /** @description User ID who created the reservation */
324
- createdBy: string | null;
325
- /** @description User ID who last updated the reservation */
326
- updatedBy: string | null;
327
- /**
328
- * Format: date-time
329
- * @description Reservation creation timestamp
330
- */
331
- createdAt: string | null;
332
- /**
333
- * Format: date-time
334
- * @description Last update timestamp
335
- */
336
- updatedAt: string | null;
199
+ /** @description Reservation creation timestamp */
200
+ createdAt: unknown;
201
+ /** @description Last update timestamp */
202
+ updatedAt: unknown;
337
203
  };
338
204
  /**
339
205
  * CreateEventRequest
340
206
  * @description Request payload for creating a new event
341
207
  */
342
208
  CreateEventRequest: {
343
- venueId: string;
344
- /** @enum {string} */
345
- type: "regular" | "private" | "closure" | "maintenance";
346
- name: (((string | number | boolean | (string | null)) | null) | {
209
+ name: (string | number | boolean | (null)) | {
347
210
  [key: string]: unknown;
348
- } | unknown[]) | null;
349
- description?: (((string | number | boolean | (string | null)) | null) | {
211
+ } | unknown[];
212
+ description?: ((string | number | boolean | (null)) | {
350
213
  [key: string]: unknown;
351
214
  } | unknown[]) | null;
352
215
  scheduleId?: string | null;
@@ -354,7 +217,27 @@ interface components {
354
217
  maxGuests?: number | null;
355
218
  minPartySize?: number | null;
356
219
  maxPartySize?: number | null;
220
+ isPublic?: boolean;
221
+ isRecurring?: boolean;
222
+ acceptsReservations?: boolean;
223
+ bookingOpensAtDays?: number | null;
224
+ bookingClosesAtHours?: number | null;
357
225
  isActive?: boolean;
226
+ isClosed?: boolean;
227
+ priority?: number;
228
+ schedule?: {
229
+ rrule?: string | null;
230
+ timezone?: string | null;
231
+ validFrom?: unknown;
232
+ validTo?: unknown;
233
+ startTime?: string | null;
234
+ endTime?: string | null;
235
+ lastSeatingTime?: string | null;
236
+ /** @enum {string|null} */
237
+ slotMode?: "interval" | "duration" | null;
238
+ intervalMinutes?: number | null;
239
+ durationMinutes?: number | null;
240
+ } | null;
358
241
  };
359
242
  /**
360
243
  * CreateEventResponse
@@ -363,12 +246,10 @@ interface components {
363
246
  CreateEventResponse: {
364
247
  id: string;
365
248
  venueId: string;
366
- /** @enum {string} */
367
- type: "regular" | "private" | "closure" | "maintenance";
368
- name: (((string | number | boolean | (string | null)) | null) | {
249
+ name: (string | number | boolean | (null)) | {
369
250
  [key: string]: unknown;
370
- } | unknown[]) | null;
371
- description: (((string | number | boolean | (string | null)) | null) | {
251
+ } | unknown[];
252
+ description: ((string | number | boolean | (null)) | {
372
253
  [key: string]: unknown;
373
254
  } | unknown[]) | null;
374
255
  scheduleId: string | null;
@@ -376,13 +257,18 @@ interface components {
376
257
  maxGuests: number | null;
377
258
  minPartySize: number | null;
378
259
  maxPartySize: number | null;
260
+ isPublic: boolean;
261
+ isRecurring: boolean;
262
+ acceptsReservations: boolean;
263
+ bookingOpensAtDays: number | null;
264
+ bookingClosesAtHours: number | null;
379
265
  isActive: boolean;
266
+ isClosed: boolean;
267
+ priority: number;
380
268
  createdBy: string | null;
381
269
  updatedBy: string | null;
382
- /** Format: date-time */
383
- createdAt: string | null;
384
- /** Format: date-time */
385
- updatedAt: string | null;
270
+ createdAt: unknown;
271
+ updatedAt: unknown;
386
272
  };
387
273
  };
388
274
  responses: never;
@@ -399,11 +285,140 @@ type PlaceOrderRequest = schemas['PlaceOrderRequest'];
399
285
  type PlaceOrderResponse = schemas['PlaceOrderResponse'];
400
286
  type MakeReservationRequest = schemas['MakeReservationRequest'];
401
287
  type MakeReservationResponse = schemas['MakeReservationResponse'];
288
+ interface TimeSlot {
289
+ id: string;
290
+ startTime: string;
291
+ endTime: string | null;
292
+ dayOfWeek?: 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT' | 'SUN' | null;
293
+ }
294
+ interface ScheduleOverride {
295
+ id: string;
296
+ date: string;
297
+ reason: Record<string, string> | null;
298
+ timeSlots: TimeSlot[];
299
+ }
300
+ interface Schedule {
301
+ id: string;
302
+ name: Record<string, string>;
303
+ description: Record<string, string> | null;
304
+ timezone: string;
305
+ rrule: string | null;
306
+ exdates: string[] | null;
307
+ validFrom: string | null;
308
+ validTo: string | null;
309
+ priority: number | null;
310
+ isActive: boolean;
311
+ sortIndex: string | null;
312
+ updatedAt: string | null;
313
+ updatedBy: string | null;
314
+ createdAt: string | null;
315
+ createdBy: string | null;
316
+ slotMode: 'interval' | 'duration';
317
+ intervalMinutes: number | null;
318
+ durationMinutes: number | null;
319
+ startTime: string | null;
320
+ lastSeatingTime: string | null;
321
+ }
322
+ interface EventPoster {
323
+ id: string;
324
+ eventId: string;
325
+ storagePath: string;
326
+ /** Signed URL for accessing the poster image (1 hour expiry) */
327
+ signedUrl: string | null;
328
+ filename: string;
329
+ contentType: string;
330
+ sizeBytes: number;
331
+ isPrimary: boolean;
332
+ sortIndex: string | null;
333
+ createdBy: string | null;
334
+ createdAt: string | null;
335
+ }
336
+ interface Promotion {
337
+ id: string;
338
+ venueId: string;
339
+ name: Record<string, string>;
340
+ description: Record<string, string> | null;
341
+ benefitType: 'free_item' | 'discount_percentage' | 'discount_amount' | 'buy_x_get_y';
342
+ benefitValue: Record<string, unknown>;
343
+ conditions: Record<string, unknown> | null;
344
+ maxRedemptions: number | null;
345
+ currentRedemptions: number | null;
346
+ validFrom: string | null;
347
+ validTo: string | null;
348
+ isActive: boolean;
349
+ createdBy: string | null;
350
+ updatedBy: string | null;
351
+ createdAt: string | null;
352
+ updatedAt: string | null;
353
+ timeSlotIds?: string[] | null;
354
+ }
355
+ interface Event {
356
+ id: string;
357
+ venueId: string;
358
+ name: Record<string, string>;
359
+ description: Record<string, string> | null;
360
+ scheduleId: string | null;
361
+ maxBookings: number | null;
362
+ maxGuests: number | null;
363
+ minPartySize: number | null;
364
+ maxPartySize: number | null;
365
+ isPublic: boolean;
366
+ isRecurring: boolean;
367
+ isClosed: boolean;
368
+ acceptsReservations: boolean;
369
+ bookingOpensAtDays: number | null;
370
+ bookingClosesAtHours: number | null;
371
+ isActive: boolean;
372
+ /** Priority for conflict resolution (higher = takes precedence) */
373
+ priority: number;
374
+ createdBy: string | null;
375
+ updatedBy: string | null;
376
+ createdAt: string | null;
377
+ updatedAt: string | null;
378
+ schedule: Schedule | null;
379
+ posters: EventPoster[];
380
+ promotions: Promotion[];
381
+ /** Regular time slots (by day of week) */
382
+ timeSlots: TimeSlot[];
383
+ /** Date-specific schedule overrides */
384
+ scheduleOverrides: ScheduleOverride[];
385
+ /** Next occurrence date for recurring events (YYYY-MM-DD format) */
386
+ nextOccurrence?: string | null;
387
+ }
388
+ interface ListEventsOptions {
389
+ /** Include private events in the response */
390
+ includePrivate?: boolean;
391
+ /** Filter by isPublic status */
392
+ isPublic?: boolean;
393
+ /** Filter by isRecurring status */
394
+ isRecurring?: boolean;
395
+ /** Filter by isClosed status */
396
+ isClosed?: boolean;
397
+ /** Filter for events occurring within N days from today */
398
+ upcomingWithinDays?: number;
399
+ }
400
+ type ListEventsResponse = Event[];
402
401
 
403
402
  declare class EventsResource extends BaseResource {
404
403
  constructor(tokenManager: TokenManager, baseUrl: string);
404
+ /**
405
+ * List all events for the venue
406
+ * @param options - Optional filters for the list request
407
+ * @returns Array of events with schedule, posters, and promotions
408
+ */
409
+ list(options?: ListEventsOptions): Promise<ListEventsResponse>;
410
+ /**
411
+ * Create a new event
412
+ * @param event - The event details
413
+ * @returns The created event
414
+ */
405
415
  place(event: CreateEventRequest): Promise<CreateEventResponse>;
406
- get(eventId: string): Promise<CreateEventRequest>;
416
+ /**
417
+ * Get a single event by ID
418
+ * @param eventId - The event ID
419
+ * @returns The event details
420
+ */
421
+ get(eventId: string): Promise<Event>;
407
422
  }
408
423
 
409
424
  declare class OrdersResource extends BaseResource {
@@ -450,7 +465,6 @@ declare class Order3000Client {
450
465
  private readonly baseUrl;
451
466
  private readonly tokenManager;
452
467
  constructor(config: Order3000ClientConfig);
453
- private initialize;
454
468
  }
455
469
 
456
- export { Order3000Client, type Order3000ClientConfig };
470
+ export { type Event, type EventPoster, type ListEventsOptions, type ListEventsResponse, Order3000Client, type Order3000ClientConfig, type Promotion, type Schedule, type ScheduleOverride, type TimeSlot };
package/dist/client.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import got from 'got';
2
-
3
1
  var __defProp$1 = Object.defineProperty;
4
2
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
3
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -44,23 +42,30 @@ class TokenManager {
44
42
  console.log("[SDK TOKEN] Requesting token from:", this.tokenEndpoint);
45
43
  console.log("[SDK TOKEN] Using clientId:", this.clientId);
46
44
  console.log("[SDK TOKEN] Secret length:", this.clientSecret?.length);
47
- this.refreshPromise = got.post(this.tokenEndpoint, {
48
- json: { clientId: this.clientId, clientSecret: this.clientSecret },
49
- responseType: "json",
50
- timeout: { request: 36e4 },
51
- retry: { limit: 3 }
52
- }).then((response) => {
45
+ this.refreshPromise = fetch(this.tokenEndpoint, {
46
+ method: "POST",
47
+ headers: { "Content-Type": "application/json" },
48
+ body: JSON.stringify({
49
+ clientId: this.clientId,
50
+ clientSecret: this.clientSecret
51
+ }),
52
+ signal: AbortSignal.timeout(36e4)
53
+ }).then(async (response) => {
54
+ if (!response.ok) {
55
+ const body = await response.text();
56
+ console.log("[SDK TOKEN] Response status:", response.status);
57
+ console.log("[SDK TOKEN] Response body:", body);
58
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
59
+ }
60
+ return response.json();
61
+ }).then((data) => {
53
62
  console.log("[SDK TOKEN] Token received successfully");
54
- this.accessToken = response.body.accessToken;
55
- this.tokenExpiresAt = Date.now() + response.body.expiresIn * 1e3;
63
+ this.accessToken = data.accessToken;
64
+ this.tokenExpiresAt = Date.now() + data.expiresIn * 1e3;
56
65
  this.setDefaultVenueId();
57
66
  return this.accessToken;
58
67
  }).catch((error) => {
59
68
  console.log("[SDK TOKEN] Token request failed:", error.message);
60
- if (error.response) {
61
- console.log("[SDK TOKEN] Response status:", error.response.statusCode);
62
- console.log("[SDK TOKEN] Response body:", error.response.body);
63
- }
64
69
  throw error;
65
70
  }).finally(() => {
66
71
  this.refreshPromise = null;
@@ -101,17 +106,19 @@ class BaseResource {
101
106
  const venueId = this.tokenManager.getVenueId();
102
107
  const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
103
108
  console.log(`[SDK] Making ${method} request to: ${url}`);
104
- return got(
105
- url,
106
- {
107
- method,
108
- json: data,
109
- headers: { Authorization: `Bearer ${token}` },
110
- responseType: "json",
111
- timeout: { request: 36e4 },
112
- retry: { limit: 2 }
113
- }
114
- ).json();
109
+ const response = await fetch(url, {
110
+ method,
111
+ headers: {
112
+ Authorization: `Bearer ${token}`,
113
+ "Content-Type": "application/json"
114
+ },
115
+ body: data ? JSON.stringify(data) : void 0,
116
+ signal: AbortSignal.timeout(36e4)
117
+ });
118
+ if (!response.ok) {
119
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
120
+ }
121
+ return response.json();
115
122
  }
116
123
  }
117
124
 
@@ -119,9 +126,45 @@ class EventsResource extends BaseResource {
119
126
  constructor(tokenManager, baseUrl) {
120
127
  super(tokenManager, baseUrl, "/events");
121
128
  }
129
+ /**
130
+ * List all events for the venue
131
+ * @param options - Optional filters for the list request
132
+ * @returns Array of events with schedule, posters, and promotions
133
+ */
134
+ async list(options) {
135
+ const queryParams = new URLSearchParams();
136
+ if (options?.includePrivate) {
137
+ queryParams.set("includePrivate", "true");
138
+ }
139
+ if (options?.isPublic !== void 0) {
140
+ queryParams.set("isPublic", String(options.isPublic));
141
+ }
142
+ if (options?.isRecurring !== void 0) {
143
+ queryParams.set("isRecurring", String(options.isRecurring));
144
+ }
145
+ if (options?.isClosed !== void 0) {
146
+ queryParams.set("isClosed", String(options.isClosed));
147
+ }
148
+ if (options?.upcomingWithinDays !== void 0) {
149
+ queryParams.set("upcomingWithinDays", String(options.upcomingWithinDays));
150
+ }
151
+ const queryString = queryParams.toString();
152
+ const path = queryString ? `?${queryString}` : "";
153
+ return this.request("GET", path);
154
+ }
155
+ /**
156
+ * Create a new event
157
+ * @param event - The event details
158
+ * @returns The created event
159
+ */
122
160
  async place(event) {
123
161
  return this.request("POST", "", event);
124
162
  }
163
+ /**
164
+ * Get a single event by ID
165
+ * @param eventId - The event ID
166
+ * @returns The event details
167
+ */
125
168
  async get(eventId) {
126
169
  return this.request("GET", `/${eventId}`);
127
170
  }
@@ -185,15 +228,6 @@ class Order3000Client {
185
228
  this.tokenManager,
186
229
  this.baseUrl
187
230
  );
188
- this.initialize();
189
- }
190
- async initialize() {
191
- try {
192
- await this.tokenManager.initialize();
193
- } catch (error) {
194
- console.error("Failed to initialize client:", error);
195
- process.exit(1);
196
- }
197
231
  }
198
232
  }
199
233
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "order3000",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "order3000 node.js sdk",
5
5
  "main": "./dist/client.cjs",
6
6
  "module": "./dist/client.mjs",
@@ -18,20 +18,20 @@
18
18
  "dependencies": {
19
19
  "@supabase/supabase-js": "^2.49.8",
20
20
  "@types/react-type-animation": "^2.0.0",
21
- "got": "^14.4.6",
22
- "i18next": "^25.0.0",
21
+ "i18next": "^25.6.0",
23
22
  "i18next-fs-backend": "^2.6.0",
24
23
  "react-type-animation": "^3.2.0"
25
24
  },
26
25
  "devDependencies": {
27
- "@types/node": "^22.13.9",
26
+ "@types/node": "^24.10.0",
28
27
  "openapi-typescript": "^7.6.1",
29
28
  "pkgroll": "^2.11.2",
30
- "prettier": "^3.5.3",
29
+ "prettier": "^3.6.2",
31
30
  "tsx": "^4.19.2",
32
- "typescript": "^5.7.3",
31
+ "typescript": "^5.9.3",
33
32
  "@kolaveri/eslint-config": "1.0.8",
34
- "@kolaveri/prettier-config": "1.0.5"
33
+ "@kolaveri/prettier-config": "1.0.5",
34
+ "@kolaveri/tsconfig": "1.0.0"
35
35
  },
36
36
  "files": [
37
37
  "dist"