order3000 0.2.1 → 0.3.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kolaveri Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,262 @@
1
- # order3000-nodejs
1
+ # Order3000 Node.js SDK
2
2
 
3
- node.js sdk to interact with order3000.
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
- ## New release
5
+ ## Overview
6
6
 
7
- If you want to release a new version for this package simply create a new changeset and describe the changes that have been included in the new release.
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
- It's a manual process. This project has no dependencies, so it's not possible that the update of another project will trigger a new release here.
9
+ ### Key Features
10
+
11
+ - 🔐 **OAuth2 Authentication** - Secure client credentials flow with automatic token management
12
+ - 🏢 **Multi-Tenant Support** - Built for multi-restaurant/tenant operations
13
+ - 📝 **TypeScript Support** - Full TypeScript support with auto-generated types from OpenAPI spec
14
+ - 🔄 **Auto Token Refresh** - Automatic token renewal with 5-minute buffer before expiration
15
+ - 🎯 **Type-Safe API** - OpenAPI-generated types ensure type safety across all operations
16
+ - ⚡ **Modern Architecture** - Built with ES modules and CommonJS dual support
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install order3000
22
+ # or
23
+ yarn add order3000
24
+ # or
25
+ pnpm add order3000
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ```typescript
31
+ import { Order3000Client } from 'order3000'
32
+
33
+ // Initialize the client
34
+ const client = new Order3000Client({
35
+ clientId: 'your-client-id',
36
+ clientSecret: 'your-client-secret',
37
+ tenantId: 'your-tenant-id', // Optional - will use default from token if not provided
38
+ baseUrl: 'https://api.order3000.com', // Optional - defaults to production
39
+ })
40
+
41
+ // Place an order
42
+ const order = await client.orders.place({
43
+ tenantId: 'restaurant-123',
44
+ basketId: 'basket-456',
45
+ status: 'PENDING',
46
+ paymentMethod: 'CARD',
47
+ taxAmount: '2.50',
48
+ totalAmount: '25.00',
49
+ currency: 'USD',
50
+ orderedBy: 'customer@example.com',
51
+ })
52
+
53
+ console.log('Order placed:', order.id)
54
+ ```
55
+
56
+ ## Architecture
57
+
58
+ ### Authentication Flow
59
+
60
+ The SDK uses OAuth2 client credentials flow for authentication:
61
+
62
+ 1. **Initial Authentication**: On first use, the SDK requests an access token using your client credentials
63
+ 2. **Token Storage**: The access token is stored in memory with its expiration time
64
+ 3. **Automatic Refresh**: Tokens are automatically refreshed 5 minutes before expiration
65
+ 4. **Tenant Resolution**: If no tenant ID is provided, the SDK extracts the default tenant from the JWT token
66
+
67
+ ### Project Structure
68
+
69
+ ```
70
+ order3000-nodejs/
71
+ ├── src/
72
+ │ ├── client.ts # Main client class and initialization
73
+ │ ├── token-manager.ts # OAuth2 token management and refresh logic
74
+ │ ├── resources/
75
+ │ │ ├── index.ts # Base resource class for API calls
76
+ │ │ └── orders.ts # Orders resource implementation
77
+ │ └── types/
78
+ │ ├── index.ts # Type exports
79
+ │ └── generated.d.ts # Auto-generated types from OpenAPI spec
80
+ ├── scripts/
81
+ │ ├── dev.sh # Development script with Vault integration
82
+ │ └── vaultcar.sh # HashiCorp Vault integration for secrets
83
+ └── package.json
84
+ ```
85
+
86
+ ## Configuration
87
+
88
+ ### Client Options
89
+
90
+ ```typescript
91
+ interface Order3000ClientConfig {
92
+ clientId: string // OAuth2 client ID (required)
93
+ clientSecret: string // OAuth2 client secret (required)
94
+ tenantId?: string // Specific tenant ID (optional)
95
+ baseUrl?: string // Base URL for API requests (default: https://order3000.com/api)
96
+ tokenUrl?: string // OAuth2 token endpoint (default: ${baseUrl}/auth/token)
97
+ }
98
+ ```
99
+
100
+ ### Environment Variables
101
+
102
+ For development, you can use environment variables:
103
+
104
+ ```bash
105
+ ORDER3000_CLIENT_ID=your-client-id
106
+ ORDER3000_CLIENT_SECRET=your-client-secret
107
+ ORDER3000_BASE_URL=https://api.order3000.com
108
+ ```
109
+
110
+ ## API Documentation
111
+
112
+ For complete API documentation including all available endpoints, request/response schemas, and interactive examples, visit:
113
+
114
+ - **Development**: http://localhost:3000/developers/reference
115
+ - **Staging**: https://order3000.kolaveri.co/developers/reference
116
+ - **Production**: https://order3000.com/developers/reference
117
+
118
+ The API documentation is powered by Scalar and provides a comprehensive view of all available endpoints, schemas, and integration examples.
119
+
120
+ ## SDK Development Workflow
121
+
122
+ ### Adding New API Endpoints
123
+
124
+ When new endpoints are added or modified in the Order3000 platform, follow this workflow to update the SDK:
125
+
126
+ 1. **Define API Contracts**: Create or update TypeScript contracts that define the API structure
127
+
128
+ - Add/modify contracts in `/apps/order3000/src/app/api/openapi/contracts/`
129
+ - Use `@ts-rest/core` to define type-safe contracts
130
+ - Export contracts from `/apps/order3000/src/app/api/openapi/contract.ts`
131
+ - Generate OpenAPI spec to preview changes: `npx nx run order3000:generate-openapi`
132
+ - View updated docs at http://localhost:3000/developers/reference
133
+
134
+ 2. **Implement API Endpoints**: Create the actual endpoint logic in the Order3000 application
135
+
136
+ - Implement handlers in `/apps/order3000/src/app/api/` following the contract definitions
137
+ - Ensure endpoints match the contracts exactly
138
+
139
+ 3. **Update SDK Resources**: Integrate the new endpoints into the SDK
140
+
141
+ - Create or update resource classes in `/apps/order3000-nodejs/src/resources/`
142
+ - Follow the existing pattern extending from `BaseResource`
143
+ - Export new resources from the main `Order3000Client` class
144
+ - Note: Type generation (`npm run build:types`) is handled automatically by CI/CD
145
+
146
+ 4. **Create Changeset**: Document the changes
147
+
148
+ ```bash
149
+ pnpm changeset
150
+ ```
151
+
152
+ - Select `order3000` package
153
+ - Choose version bump type (patch/minor/major)
154
+ - Describe the new endpoints or changes added
155
+
156
+ 5. **CI/CD Pipeline**: The automated pipeline handles the rest
157
+ - Generates types from OpenAPI spec automatically
158
+ - Builds the SDK package with `pkgroll`
159
+ - Runs tests and type checking
160
+ - Publishes to npm registry as `order3000` package
161
+ - Updates version numbers based on changeset
162
+
163
+ ### Local Development
164
+
165
+ ```bash
166
+ # Generate types from OpenAPI spec
167
+ npm run build:types
168
+
169
+ # Build the package locally
170
+ npm run build
171
+
172
+ # Test SDK in development mode
173
+ npm run dev
174
+ ```
175
+
176
+ ### Development with Vault
177
+
178
+ The SDK includes HashiCorp Vault integration for secure credential management:
179
+
180
+ ```bash
181
+ # Run with Vault integration
182
+ npm run dev
183
+ ```
184
+
185
+ Credentials are fetched from:
186
+
187
+ - `secret/kolaveri/thamarai/ORDER3000_CLIENT_ID`
188
+ - `secret/kolaveri/thamarai/ORDER3000_CLIENT_SECRET`
189
+ - `secret/kolaveri/thamarai/ORDER3000_BASE_URL`
190
+
191
+ ## Security Considerations
192
+
193
+ 1. **Never commit credentials** - Always use environment variables or secret management systems
194
+ 2. **Token Security** - Access tokens are stored in memory only, never persisted to disk
195
+ 3. **HTTPS Only** - All API calls are made over HTTPS
196
+ 4. **Automatic Token Rotation** - Tokens are refreshed automatically before expiration
197
+
198
+ ## Error Handling
199
+
200
+ ```typescript
201
+ try {
202
+ const order = await client.orders.place({
203
+ // ... order details
204
+ })
205
+ } catch (error) {
206
+ if (error.response?.statusCode === 401) {
207
+ console.error('Authentication failed - check credentials')
208
+ } else if (error.response?.statusCode === 400) {
209
+ console.error('Invalid order data:', error.response.body)
210
+ } else {
211
+ console.error('Unexpected error:', error)
212
+ }
213
+ }
214
+ ```
215
+
216
+ ## Platform Integration
217
+
218
+ ### Multi-Tenant Architecture
219
+
220
+ Order3000 supports multi-tenant operations where each restaurant or location is a separate tenant:
221
+
222
+ - **Automatic Tenant Resolution**: If no tenant ID is provided, the SDK uses the default tenant from the authentication token
223
+ - **Explicit Tenant Selection**: You can specify a tenant ID in the client configuration or per-request
224
+ - **Tenant Isolation**: All operations are scoped to the specified tenant
225
+
226
+ ### Related Components
227
+
228
+ The Order3000 platform includes:
229
+
230
+ - **Reservations System**: Complete table reservation management with flexible contact preferences
231
+ - **Customer Management**: Customer profiles with order history and preferences
232
+ - **Order Management**: Full order lifecycle from placement to fulfillment
233
+ - **Payment Integration**: Support for multiple payment methods
234
+
235
+ ## Roadmap
236
+
237
+ Planned features for future releases:
238
+
239
+ - [ ] Reservations API support
240
+ - [ ] Customer management endpoints
241
+ - [ ] Webhook support for real-time updates
242
+ - [ ] Batch operations
243
+ - [ ] Analytics and reporting APIs
244
+ - [ ] Menu management
245
+ - [ ] Table management
246
+
247
+ ## Contributing
248
+
249
+ This SDK is part of the Kolaveri monorepo. Development follows the monorepo conventions:
250
+
251
+ 1. Use CVA for styling in library packages
252
+ 2. Follow TypeScript strict mode
253
+ 3. Run linting before commits: `npx nx lint order3000-nodejs`
254
+ 4. Generate types from OpenAPI spec when API changes
255
+
256
+ ## License
257
+
258
+ Part of the Kolaveri platform - see root repository for license information.
259
+
260
+ ## Support
261
+
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.
package/dist/client.cjs CHANGED
@@ -104,16 +104,39 @@ class OrdersResource extends BaseResource {
104
104
  }
105
105
  }
106
106
 
107
+ class ReservationsResource extends BaseResource {
108
+ constructor(tokenManager, baseUrl) {
109
+ super(tokenManager, baseUrl, "/reservations");
110
+ }
111
+ /**
112
+ * Make a new reservation
113
+ * @param reservation - The reservation details
114
+ * @returns The created reservation with confirmation code
115
+ */
116
+ async make(reservation) {
117
+ return this.request("POST", "", reservation);
118
+ }
119
+ /**
120
+ * Get a reservation by ID
121
+ * @param reservationId - The reservation ID
122
+ * @returns The reservation details
123
+ */
124
+ async get(reservationId) {
125
+ return this.request("GET", `/${reservationId}`);
126
+ }
127
+ }
128
+
107
129
  var __defProp = Object.defineProperty;
108
130
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
109
131
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
110
132
  class Order3000Client {
111
133
  constructor(config) {
112
134
  __publicField(this, "orders");
113
- __publicField(this, "apiEndpoint");
135
+ __publicField(this, "reservations");
136
+ __publicField(this, "baseUrl");
114
137
  __publicField(this, "tokenManager");
115
- this.apiEndpoint = config.apiEndpoint || "https://order3000.com/api";
116
- const tokenUrl = config.tokenUrl || `${this.apiEndpoint}/auth/token`;
138
+ this.baseUrl = config.baseUrl || "https://order3000.com/api";
139
+ const tokenUrl = config.tokenUrl || `${this.baseUrl}/auth/token`;
117
140
  this.tokenManager = new TokenManager(
118
141
  config.clientId,
119
142
  config.clientSecret,
@@ -121,7 +144,11 @@ class Order3000Client {
121
144
  config.tenantId
122
145
  );
123
146
  console.log("refreshToken 12");
124
- this.orders = new OrdersResource(this.tokenManager, this.apiEndpoint);
147
+ this.orders = new OrdersResource(this.tokenManager, this.baseUrl);
148
+ this.reservations = new ReservationsResource(
149
+ this.tokenManager,
150
+ this.baseUrl
151
+ );
125
152
  console.log("refreshToken 13");
126
153
  this.initialize();
127
154
  console.log("refreshToken 14");
package/dist/client.d.cts CHANGED
@@ -68,6 +68,252 @@ interface components {
68
68
  updatedAt: string | null;
69
69
  updatedBy: string | null;
70
70
  };
71
+ /**
72
+ * MakeReservationRequest
73
+ * @description Request payload for making a new reservation
74
+ */
75
+ MakeReservationRequest: {
76
+ /** @description Date of the reservation in YYYY-MM-DD format */
77
+ reservationDate: string;
78
+ /** @description Time of the reservation in HH:MM:SS format */
79
+ reservationTime: string;
80
+ /** @description Number of guests in the party. Must be between 1 and 20. */
81
+ partySize: number;
82
+ /** @description Reservation duration in minutes. Defaults to 120 minutes if not specified. Range: 30-300 minutes. */
83
+ duration: number | null;
84
+ /**
85
+ * Format: uuid
86
+ * @description UUID of existing customer profile if available
87
+ */
88
+ customerId: string | null;
89
+ /** @description Full name of the customer making the reservation */
90
+ customerName: string;
91
+ /**
92
+ * Format: email
93
+ * @description Email address for reservation confirmations and updates
94
+ */
95
+ customerEmail?: string | null;
96
+ /** @description Phone number for reservation confirmations and updates. Include country code for international numbers. */
97
+ customerPhone?: string | null;
98
+ /**
99
+ * @description Preferred method for reservation reminders and updates
100
+ * @enum {string}
101
+ */
102
+ contactPreference: "email" | "phone" | "sms" | "none";
103
+ /**
104
+ * @description Origin of the reservation request
105
+ * @enum {string}
106
+ */
107
+ source: "website" | "phone" | "walk_in";
108
+ /** @description Any dietary restrictions, allergies, or special occasions (max 500 characters) */
109
+ specialRequests: string | null;
110
+ /** @description Preferred seating area or table type (e.g., "window seat", "quiet area", "patio") */
111
+ tablePreference: string | null;
112
+ };
113
+ /**
114
+ * MakeReservationResponse
115
+ * @description Successfully created reservation
116
+ */
117
+ MakeReservationResponse: {
118
+ /**
119
+ * Format: uuid
120
+ * @description Unique identifier for the reservation
121
+ */
122
+ id: string;
123
+ /**
124
+ * Format: uuid
125
+ * @description Restaurant/tenant identifier
126
+ */
127
+ tenantId: string;
128
+ /** @description Date of the reservation in YYYY-MM-DD format */
129
+ reservationDate: string;
130
+ /** @description Time of the reservation in HH:MM:SS format */
131
+ reservationTime: string;
132
+ /** @description Number of guests in the party */
133
+ partySize: number;
134
+ /** @description Reservation duration in minutes */
135
+ duration: number | null;
136
+ /**
137
+ * Format: uuid
138
+ * @description Link to customer profile if exists
139
+ */
140
+ customerId: string | null;
141
+ /** @description Full name of the customer */
142
+ customerName: string;
143
+ /** @description Customer email address */
144
+ customerEmail: string | null;
145
+ /** @description Customer phone number */
146
+ customerPhone: string | null;
147
+ /**
148
+ * @description Preferred contact method
149
+ * @enum {string}
150
+ */
151
+ contactPreference: "email" | "phone" | "sms" | "none";
152
+ /**
153
+ * @description Current status of the reservation
154
+ * @enum {string}
155
+ */
156
+ status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
157
+ /** @description 6-character confirmation code for the reservation */
158
+ confirmationCode: string | null;
159
+ /**
160
+ * Format: date-time
161
+ * @description When the reservation was confirmed
162
+ */
163
+ confirmedAt: string | null;
164
+ /**
165
+ * Format: date-time
166
+ * @description When the guest arrived
167
+ */
168
+ arrivedAt: string | null;
169
+ /**
170
+ * Format: date-time
171
+ * @description When the guest was seated
172
+ */
173
+ seatedAt: string | null;
174
+ /**
175
+ * Format: date-time
176
+ * @description When the dining was completed
177
+ */
178
+ completedAt: string | null;
179
+ /**
180
+ * Format: date-time
181
+ * @description When the reservation was cancelled
182
+ */
183
+ cancelledAt: string | null;
184
+ /**
185
+ * @description Who initiated the cancellation
186
+ * @enum {string|null}
187
+ */
188
+ cancellationReason: "customer_request" | "restaurant_request" | null;
189
+ /** @description Additional cancellation details */
190
+ cancellationNote: string | null;
191
+ /**
192
+ * @description Origin of the reservation
193
+ * @enum {string}
194
+ */
195
+ source: "website" | "phone" | "walk_in";
196
+ /** @description Any special requirements or notes */
197
+ specialRequests: string | null;
198
+ /** @description Preferred seating location */
199
+ tablePreference: string | null;
200
+ /** @description User ID who created the reservation */
201
+ createdBy: string;
202
+ /** @description User ID who last updated the reservation */
203
+ updatedBy: string;
204
+ /**
205
+ * Format: date-time
206
+ * @description Reservation creation timestamp
207
+ */
208
+ createdAt: string | null;
209
+ /**
210
+ * Format: date-time
211
+ * @description Last update timestamp
212
+ */
213
+ updatedAt: string | null;
214
+ };
215
+ /**
216
+ * ReservationDetails
217
+ * @description Reservation details
218
+ */
219
+ ReservationDetails: {
220
+ /**
221
+ * Format: uuid
222
+ * @description Unique identifier for the reservation
223
+ */
224
+ id: string;
225
+ /**
226
+ * Format: uuid
227
+ * @description Restaurant/tenant identifier
228
+ */
229
+ tenantId: string;
230
+ /** @description Date of the reservation in YYYY-MM-DD format */
231
+ reservationDate: string;
232
+ /** @description Time of the reservation in HH:MM:SS format */
233
+ reservationTime: string;
234
+ /** @description Number of guests in the party */
235
+ partySize: number;
236
+ /** @description Reservation duration in minutes */
237
+ duration: number | null;
238
+ /**
239
+ * Format: uuid
240
+ * @description Link to customer profile if exists
241
+ */
242
+ customerId: string | null;
243
+ /** @description Full name of the customer */
244
+ customerName: string;
245
+ /** @description Customer email address */
246
+ customerEmail: string | null;
247
+ /** @description Customer phone number */
248
+ customerPhone: string | null;
249
+ /**
250
+ * @description Preferred contact method
251
+ * @enum {string}
252
+ */
253
+ contactPreference: "email" | "phone" | "sms" | "none";
254
+ /**
255
+ * @description Current status of the reservation
256
+ * @enum {string}
257
+ */
258
+ status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
259
+ /** @description 6-character confirmation code for the reservation */
260
+ confirmationCode: string | null;
261
+ /**
262
+ * Format: date-time
263
+ * @description When the reservation was confirmed
264
+ */
265
+ confirmedAt: string | null;
266
+ /**
267
+ * Format: date-time
268
+ * @description When the guest arrived
269
+ */
270
+ arrivedAt: string | null;
271
+ /**
272
+ * Format: date-time
273
+ * @description When the guest was seated
274
+ */
275
+ seatedAt: string | null;
276
+ /**
277
+ * Format: date-time
278
+ * @description When the dining was completed
279
+ */
280
+ completedAt: string | null;
281
+ /**
282
+ * Format: date-time
283
+ * @description When the reservation was cancelled
284
+ */
285
+ cancelledAt: string | null;
286
+ /**
287
+ * @description Who initiated the cancellation
288
+ * @enum {string|null}
289
+ */
290
+ cancellationReason: "customer_request" | "restaurant_request" | null;
291
+ /** @description Additional cancellation details */
292
+ cancellationNote: string | null;
293
+ /**
294
+ * @description Origin of the reservation
295
+ * @enum {string}
296
+ */
297
+ source: "website" | "phone" | "walk_in";
298
+ /** @description Any special requirements or notes */
299
+ specialRequests: string | null;
300
+ /** @description Preferred seating location */
301
+ tablePreference: string | null;
302
+ /** @description User ID who created the reservation */
303
+ createdBy: string;
304
+ /** @description User ID who last updated the reservation */
305
+ updatedBy: string;
306
+ /**
307
+ * Format: date-time
308
+ * @description Reservation creation timestamp
309
+ */
310
+ createdAt: string | null;
311
+ /**
312
+ * Format: date-time
313
+ * @description Last update timestamp
314
+ */
315
+ updatedAt: string | null;
316
+ };
71
317
  };
72
318
  responses: never;
73
319
  parameters: never;
@@ -79,6 +325,8 @@ interface components {
79
325
  type schemas = components['schemas'];
80
326
  type PlaceOrderRequest = schemas['PlaceOrderRequest'];
81
327
  type PlaceOrderResponse = schemas['PlaceOrderResponse'];
328
+ type MakeReservationRequest = schemas['MakeReservationRequest'];
329
+ type MakeReservationResponse = schemas['MakeReservationResponse'];
82
330
 
83
331
  declare class OrdersResource extends BaseResource {
84
332
  constructor(tokenManager: TokenManager, baseUrl: string);
@@ -86,24 +334,41 @@ declare class OrdersResource extends BaseResource {
86
334
  get(orderId: string): Promise<PlaceOrderRequest>;
87
335
  }
88
336
 
337
+ declare class ReservationsResource extends BaseResource {
338
+ constructor(tokenManager: TokenManager, baseUrl: string);
339
+ /**
340
+ * Make a new reservation
341
+ * @param reservation - The reservation details
342
+ * @returns The created reservation with confirmation code
343
+ */
344
+ make(reservation: MakeReservationRequest): Promise<MakeReservationResponse>;
345
+ /**
346
+ * Get a reservation by ID
347
+ * @param reservationId - The reservation ID
348
+ * @returns The reservation details
349
+ */
350
+ get(reservationId: string): Promise<MakeReservationResponse>;
351
+ }
352
+
89
353
  interface Order3000ClientConfig {
90
354
  clientId: string;
91
355
  clientSecret: string;
92
356
  tenantId?: string;
93
357
  /**
94
- * Base URL for API services
358
+ * Base URL for API requests
95
359
  * @default "https://order3000.com/api"
96
360
  */
97
- apiEndpoint?: string;
361
+ baseUrl?: string;
98
362
  /**
99
363
  * OAuth 2.0 token endpoint
100
- * @default "${apiEndpoint}/auth/token"
364
+ * @default "${baseUrl}/auth/token"
101
365
  */
102
366
  tokenUrl?: string;
103
367
  }
104
368
  declare class Order3000Client {
105
369
  orders: OrdersResource;
106
- private readonly apiEndpoint;
370
+ reservations: ReservationsResource;
371
+ private readonly baseUrl;
107
372
  private readonly tokenManager;
108
373
  constructor(config: Order3000ClientConfig);
109
374
  private initialize;
package/dist/client.d.mts CHANGED
@@ -68,6 +68,252 @@ interface components {
68
68
  updatedAt: string | null;
69
69
  updatedBy: string | null;
70
70
  };
71
+ /**
72
+ * MakeReservationRequest
73
+ * @description Request payload for making a new reservation
74
+ */
75
+ MakeReservationRequest: {
76
+ /** @description Date of the reservation in YYYY-MM-DD format */
77
+ reservationDate: string;
78
+ /** @description Time of the reservation in HH:MM:SS format */
79
+ reservationTime: string;
80
+ /** @description Number of guests in the party. Must be between 1 and 20. */
81
+ partySize: number;
82
+ /** @description Reservation duration in minutes. Defaults to 120 minutes if not specified. Range: 30-300 minutes. */
83
+ duration: number | null;
84
+ /**
85
+ * Format: uuid
86
+ * @description UUID of existing customer profile if available
87
+ */
88
+ customerId: string | null;
89
+ /** @description Full name of the customer making the reservation */
90
+ customerName: string;
91
+ /**
92
+ * Format: email
93
+ * @description Email address for reservation confirmations and updates
94
+ */
95
+ customerEmail?: string | null;
96
+ /** @description Phone number for reservation confirmations and updates. Include country code for international numbers. */
97
+ customerPhone?: string | null;
98
+ /**
99
+ * @description Preferred method for reservation reminders and updates
100
+ * @enum {string}
101
+ */
102
+ contactPreference: "email" | "phone" | "sms" | "none";
103
+ /**
104
+ * @description Origin of the reservation request
105
+ * @enum {string}
106
+ */
107
+ source: "website" | "phone" | "walk_in";
108
+ /** @description Any dietary restrictions, allergies, or special occasions (max 500 characters) */
109
+ specialRequests: string | null;
110
+ /** @description Preferred seating area or table type (e.g., "window seat", "quiet area", "patio") */
111
+ tablePreference: string | null;
112
+ };
113
+ /**
114
+ * MakeReservationResponse
115
+ * @description Successfully created reservation
116
+ */
117
+ MakeReservationResponse: {
118
+ /**
119
+ * Format: uuid
120
+ * @description Unique identifier for the reservation
121
+ */
122
+ id: string;
123
+ /**
124
+ * Format: uuid
125
+ * @description Restaurant/tenant identifier
126
+ */
127
+ tenantId: string;
128
+ /** @description Date of the reservation in YYYY-MM-DD format */
129
+ reservationDate: string;
130
+ /** @description Time of the reservation in HH:MM:SS format */
131
+ reservationTime: string;
132
+ /** @description Number of guests in the party */
133
+ partySize: number;
134
+ /** @description Reservation duration in minutes */
135
+ duration: number | null;
136
+ /**
137
+ * Format: uuid
138
+ * @description Link to customer profile if exists
139
+ */
140
+ customerId: string | null;
141
+ /** @description Full name of the customer */
142
+ customerName: string;
143
+ /** @description Customer email address */
144
+ customerEmail: string | null;
145
+ /** @description Customer phone number */
146
+ customerPhone: string | null;
147
+ /**
148
+ * @description Preferred contact method
149
+ * @enum {string}
150
+ */
151
+ contactPreference: "email" | "phone" | "sms" | "none";
152
+ /**
153
+ * @description Current status of the reservation
154
+ * @enum {string}
155
+ */
156
+ status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
157
+ /** @description 6-character confirmation code for the reservation */
158
+ confirmationCode: string | null;
159
+ /**
160
+ * Format: date-time
161
+ * @description When the reservation was confirmed
162
+ */
163
+ confirmedAt: string | null;
164
+ /**
165
+ * Format: date-time
166
+ * @description When the guest arrived
167
+ */
168
+ arrivedAt: string | null;
169
+ /**
170
+ * Format: date-time
171
+ * @description When the guest was seated
172
+ */
173
+ seatedAt: string | null;
174
+ /**
175
+ * Format: date-time
176
+ * @description When the dining was completed
177
+ */
178
+ completedAt: string | null;
179
+ /**
180
+ * Format: date-time
181
+ * @description When the reservation was cancelled
182
+ */
183
+ cancelledAt: string | null;
184
+ /**
185
+ * @description Who initiated the cancellation
186
+ * @enum {string|null}
187
+ */
188
+ cancellationReason: "customer_request" | "restaurant_request" | null;
189
+ /** @description Additional cancellation details */
190
+ cancellationNote: string | null;
191
+ /**
192
+ * @description Origin of the reservation
193
+ * @enum {string}
194
+ */
195
+ source: "website" | "phone" | "walk_in";
196
+ /** @description Any special requirements or notes */
197
+ specialRequests: string | null;
198
+ /** @description Preferred seating location */
199
+ tablePreference: string | null;
200
+ /** @description User ID who created the reservation */
201
+ createdBy: string;
202
+ /** @description User ID who last updated the reservation */
203
+ updatedBy: string;
204
+ /**
205
+ * Format: date-time
206
+ * @description Reservation creation timestamp
207
+ */
208
+ createdAt: string | null;
209
+ /**
210
+ * Format: date-time
211
+ * @description Last update timestamp
212
+ */
213
+ updatedAt: string | null;
214
+ };
215
+ /**
216
+ * ReservationDetails
217
+ * @description Reservation details
218
+ */
219
+ ReservationDetails: {
220
+ /**
221
+ * Format: uuid
222
+ * @description Unique identifier for the reservation
223
+ */
224
+ id: string;
225
+ /**
226
+ * Format: uuid
227
+ * @description Restaurant/tenant identifier
228
+ */
229
+ tenantId: string;
230
+ /** @description Date of the reservation in YYYY-MM-DD format */
231
+ reservationDate: string;
232
+ /** @description Time of the reservation in HH:MM:SS format */
233
+ reservationTime: string;
234
+ /** @description Number of guests in the party */
235
+ partySize: number;
236
+ /** @description Reservation duration in minutes */
237
+ duration: number | null;
238
+ /**
239
+ * Format: uuid
240
+ * @description Link to customer profile if exists
241
+ */
242
+ customerId: string | null;
243
+ /** @description Full name of the customer */
244
+ customerName: string;
245
+ /** @description Customer email address */
246
+ customerEmail: string | null;
247
+ /** @description Customer phone number */
248
+ customerPhone: string | null;
249
+ /**
250
+ * @description Preferred contact method
251
+ * @enum {string}
252
+ */
253
+ contactPreference: "email" | "phone" | "sms" | "none";
254
+ /**
255
+ * @description Current status of the reservation
256
+ * @enum {string}
257
+ */
258
+ status: "pending" | "confirmed" | "arrived" | "seated" | "completed" | "cancelled" | "no_show";
259
+ /** @description 6-character confirmation code for the reservation */
260
+ confirmationCode: string | null;
261
+ /**
262
+ * Format: date-time
263
+ * @description When the reservation was confirmed
264
+ */
265
+ confirmedAt: string | null;
266
+ /**
267
+ * Format: date-time
268
+ * @description When the guest arrived
269
+ */
270
+ arrivedAt: string | null;
271
+ /**
272
+ * Format: date-time
273
+ * @description When the guest was seated
274
+ */
275
+ seatedAt: string | null;
276
+ /**
277
+ * Format: date-time
278
+ * @description When the dining was completed
279
+ */
280
+ completedAt: string | null;
281
+ /**
282
+ * Format: date-time
283
+ * @description When the reservation was cancelled
284
+ */
285
+ cancelledAt: string | null;
286
+ /**
287
+ * @description Who initiated the cancellation
288
+ * @enum {string|null}
289
+ */
290
+ cancellationReason: "customer_request" | "restaurant_request" | null;
291
+ /** @description Additional cancellation details */
292
+ cancellationNote: string | null;
293
+ /**
294
+ * @description Origin of the reservation
295
+ * @enum {string}
296
+ */
297
+ source: "website" | "phone" | "walk_in";
298
+ /** @description Any special requirements or notes */
299
+ specialRequests: string | null;
300
+ /** @description Preferred seating location */
301
+ tablePreference: string | null;
302
+ /** @description User ID who created the reservation */
303
+ createdBy: string;
304
+ /** @description User ID who last updated the reservation */
305
+ updatedBy: string;
306
+ /**
307
+ * Format: date-time
308
+ * @description Reservation creation timestamp
309
+ */
310
+ createdAt: string | null;
311
+ /**
312
+ * Format: date-time
313
+ * @description Last update timestamp
314
+ */
315
+ updatedAt: string | null;
316
+ };
71
317
  };
72
318
  responses: never;
73
319
  parameters: never;
@@ -79,6 +325,8 @@ interface components {
79
325
  type schemas = components['schemas'];
80
326
  type PlaceOrderRequest = schemas['PlaceOrderRequest'];
81
327
  type PlaceOrderResponse = schemas['PlaceOrderResponse'];
328
+ type MakeReservationRequest = schemas['MakeReservationRequest'];
329
+ type MakeReservationResponse = schemas['MakeReservationResponse'];
82
330
 
83
331
  declare class OrdersResource extends BaseResource {
84
332
  constructor(tokenManager: TokenManager, baseUrl: string);
@@ -86,24 +334,41 @@ declare class OrdersResource extends BaseResource {
86
334
  get(orderId: string): Promise<PlaceOrderRequest>;
87
335
  }
88
336
 
337
+ declare class ReservationsResource extends BaseResource {
338
+ constructor(tokenManager: TokenManager, baseUrl: string);
339
+ /**
340
+ * Make a new reservation
341
+ * @param reservation - The reservation details
342
+ * @returns The created reservation with confirmation code
343
+ */
344
+ make(reservation: MakeReservationRequest): Promise<MakeReservationResponse>;
345
+ /**
346
+ * Get a reservation by ID
347
+ * @param reservationId - The reservation ID
348
+ * @returns The reservation details
349
+ */
350
+ get(reservationId: string): Promise<MakeReservationResponse>;
351
+ }
352
+
89
353
  interface Order3000ClientConfig {
90
354
  clientId: string;
91
355
  clientSecret: string;
92
356
  tenantId?: string;
93
357
  /**
94
- * Base URL for API services
358
+ * Base URL for API requests
95
359
  * @default "https://order3000.com/api"
96
360
  */
97
- apiEndpoint?: string;
361
+ baseUrl?: string;
98
362
  /**
99
363
  * OAuth 2.0 token endpoint
100
- * @default "${apiEndpoint}/auth/token"
364
+ * @default "${baseUrl}/auth/token"
101
365
  */
102
366
  tokenUrl?: string;
103
367
  }
104
368
  declare class Order3000Client {
105
369
  orders: OrdersResource;
106
- private readonly apiEndpoint;
370
+ reservations: ReservationsResource;
371
+ private readonly baseUrl;
107
372
  private readonly tokenManager;
108
373
  constructor(config: Order3000ClientConfig);
109
374
  private initialize;
package/dist/client.mjs CHANGED
@@ -102,16 +102,39 @@ class OrdersResource extends BaseResource {
102
102
  }
103
103
  }
104
104
 
105
+ class ReservationsResource extends BaseResource {
106
+ constructor(tokenManager, baseUrl) {
107
+ super(tokenManager, baseUrl, "/reservations");
108
+ }
109
+ /**
110
+ * Make a new reservation
111
+ * @param reservation - The reservation details
112
+ * @returns The created reservation with confirmation code
113
+ */
114
+ async make(reservation) {
115
+ return this.request("POST", "", reservation);
116
+ }
117
+ /**
118
+ * Get a reservation by ID
119
+ * @param reservationId - The reservation ID
120
+ * @returns The reservation details
121
+ */
122
+ async get(reservationId) {
123
+ return this.request("GET", `/${reservationId}`);
124
+ }
125
+ }
126
+
105
127
  var __defProp = Object.defineProperty;
106
128
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
107
129
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
108
130
  class Order3000Client {
109
131
  constructor(config) {
110
132
  __publicField(this, "orders");
111
- __publicField(this, "apiEndpoint");
133
+ __publicField(this, "reservations");
134
+ __publicField(this, "baseUrl");
112
135
  __publicField(this, "tokenManager");
113
- this.apiEndpoint = config.apiEndpoint || "https://order3000.com/api";
114
- const tokenUrl = config.tokenUrl || `${this.apiEndpoint}/auth/token`;
136
+ this.baseUrl = config.baseUrl || "https://order3000.com/api";
137
+ const tokenUrl = config.tokenUrl || `${this.baseUrl}/auth/token`;
115
138
  this.tokenManager = new TokenManager(
116
139
  config.clientId,
117
140
  config.clientSecret,
@@ -119,7 +142,11 @@ class Order3000Client {
119
142
  config.tenantId
120
143
  );
121
144
  console.log("refreshToken 12");
122
- this.orders = new OrdersResource(this.tokenManager, this.apiEndpoint);
145
+ this.orders = new OrdersResource(this.tokenManager, this.baseUrl);
146
+ this.reservations = new ReservationsResource(
147
+ this.tokenManager,
148
+ this.baseUrl
149
+ );
123
150
  console.log("refreshToken 13");
124
151
  this.initialize();
125
152
  console.log("refreshToken 14");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "order3000",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "order3000 node.js sdk",
5
5
  "main": "./dist/client.cjs",
6
6
  "module": "./dist/client.mjs",
@@ -17,9 +17,11 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@supabase/supabase-js": "^2.49.8",
20
+ "@types/react-type-animation": "^2.0.0",
20
21
  "got": "^14.4.6",
21
22
  "i18next": "^25.0.0",
22
- "i18next-fs-backend": "^2.6.0"
23
+ "i18next-fs-backend": "^2.6.0",
24
+ "react-type-animation": "^3.2.0"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@types/node": "^22.13.9",
@@ -37,7 +39,7 @@
37
39
  "prettier": "@kolaveri/prettier-config",
38
40
  "scripts": {
39
41
  "dev": "scripts/dev.sh tsx src/dev.ts",
40
- "build:types": "openapi-typescript ../../apps/order3000/public/openapi.json -o src/types/generated.d.ts",
42
+ "build:types": "openapi-typescript ../order3000/public/openapi.json -o src/types/generated.d.ts",
41
43
  "build": "npm run build:types && pkgroll"
42
44
  }
43
45
  }