order3000 0.24.5 → 0.25.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
@@ -28,10 +28,10 @@ pnpm add order3000
28
28
  ## Quick Start
29
29
 
30
30
  ```typescript
31
- import { Order3000Client } from 'order3000'
31
+ import { O3KClient } from 'order3000'
32
32
 
33
33
  // Initialize the client
34
- const client = new Order3000Client({
34
+ const client = new O3KClient({
35
35
  clientId: 'your-client-id',
36
36
  clientSecret: 'your-client-secret',
37
37
  tenantId: 'your-tenant-id', // Optional - will use default from token if not provided
@@ -53,6 +53,19 @@ const order = await client.orders.place({
53
53
  console.log('Order placed:', order.id)
54
54
  ```
55
55
 
56
+ ## Type naming convention
57
+
58
+ Every exported name in this SDK carries an **`O3K`** prefix
59
+ (`O3KClient`, `O3KFetchTeamOrderResponse`, `O3KMenuItem`,
60
+ `O3KPaymentMethodEnum`, …). The prefix namespaces the SDK surface so
61
+ consumer code never has to alias imports to disambiguate them from local
62
+ domain types:
63
+
64
+ ```typescript
65
+ // no `as SDKFoo` aliasing needed — the name is already namespaced
66
+ import type { O3KFetchTeamOrderResponse } from 'order3000'
67
+ ```
68
+
56
69
  ## Architecture
57
70
 
58
71
  ### Authentication Flow
@@ -88,7 +101,7 @@ order3000-nodejs/
88
101
  ### Client Options
89
102
 
90
103
  ```typescript
91
- interface Order3000ClientConfig {
104
+ interface O3KClientConfig {
92
105
  clientId: string // OAuth2 client ID (required)
93
106
  clientSecret: string // OAuth2 client secret (required)
94
107
  tenantId?: string // Specific tenant ID (optional)
@@ -137,7 +150,7 @@ When new endpoints are added or modified in the order3000 platform, follow this
137
150
  3. **Update SDK Resources**: Integrate the new endpoints into the SDK
138
151
  - Create or update resource classes in `/apps/order3000-nodejs/src/resources/`
139
152
  - Follow the existing pattern extending from `BaseResource`
140
- - Export new resources from the main `Order3000Client` class
153
+ - Export new resources from the main `O3KClient` class
141
154
  - Note: Type generation (`npm run build:types`) is handled automatically by CI/CD
142
155
 
143
156
  4. **Create Changeset**: Document the changes
package/dist/client.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var deliveryAddressSchema = require('./deliveryAddressSchema-DQJ8BDYX.cjs');
3
4
  var supabaseJs = require('@supabase/supabase-js');
5
+ require('zod/v4');
4
6
 
5
7
  var __defProp$3 = Object.defineProperty;
6
8
  var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -686,32 +688,11 @@ class SubscriptionsResource extends BaseResource {
686
688
  }
687
689
  }
688
690
 
689
- const paymentMethodEnum = {
690
- enumValues: ["card", "cash", "voucher"]
691
- };
692
- const fulfillmentTypeEnum = {
693
- enumValues: ["pickup", "delivery"]
694
- };
695
- const teamOrderStatusEnum = {
696
- enumValues: [
697
- "draft",
698
- "collecting",
699
- "locked",
700
- "placed",
701
- "ready",
702
- "completed",
703
- "cancelled"
704
- ]
705
- };
691
+ const paymentMethodEnum = { enumValues: deliveryAddressSchema.paymentMethodSchema.options };
692
+ const fulfillmentTypeEnum = { enumValues: deliveryAddressSchema.fulfillmentTypeSchema.options };
693
+ const teamOrderStatusEnum = { enumValues: deliveryAddressSchema.teamOrderStatusSchema.options };
706
694
  const participantStatusEnum = {
707
- enumValues: [
708
- "browsing",
709
- "authorized",
710
- "cash_pending",
711
- "placed",
712
- "completed",
713
- "cancelled"
714
- ]
695
+ enumValues: deliveryAddressSchema.participantStatusSchema.options
715
696
  };
716
697
  class TeamOrdersResource {
717
698
  constructor(tokenManager, baseUrl) {
@@ -839,7 +820,7 @@ class TeamOrdersResource {
839
820
  /**
840
821
  * Lead sets when the team will start eating. Client sends HH:MM; server
841
822
  * computes the delta against `fulfillmentAt` and stores it as
842
- * `dining_offset_minutes` so the intent survives any later pickup change.
823
+ * `dining_offset` (ms) so the intent survives any later pickup change.
843
824
  */
844
825
  async setDiningTime(publicId, request) {
845
826
  return this.request(
@@ -1162,6 +1143,7 @@ const RRULE_DAY_MAP = {
1162
1143
  SA: "saturday",
1163
1144
  SU: "sunday"
1164
1145
  };
1146
+ const MINUTE_DURATION = 60 * 1e3;
1165
1147
  function parseDaysFromRRule(rrule) {
1166
1148
  if (!rrule) {
1167
1149
  return [];
@@ -1180,13 +1162,13 @@ function parseDaysFromRRule(rrule) {
1180
1162
  }
1181
1163
  return ALL_DAYS.filter((day) => days.includes(day));
1182
1164
  }
1183
- function addMinutesToTime(time, minutes) {
1165
+ function addDurationToTime(time, duration) {
1184
1166
  const parts = time.split(":");
1185
1167
  const hours = parseInt(parts[0], 10);
1186
1168
  const mins = parseInt(parts[1], 10);
1187
- const totalMinutes = hours * 60 + mins + minutes;
1188
- const newHours = Math.floor(totalMinutes / 60) % 24;
1189
- const newMins = totalMinutes % 60;
1169
+ const totalDuration = hours * 60 * MINUTE_DURATION + mins * MINUTE_DURATION + duration;
1170
+ const newHours = Math.floor(totalDuration / (60 * MINUTE_DURATION)) % 24;
1171
+ const newMins = Math.floor(totalDuration % (60 * MINUTE_DURATION) / MINUTE_DURATION);
1190
1172
  return `${newHours.toString().padStart(2, "0")}:${newMins.toString().padStart(2, "0")}`;
1191
1173
  }
1192
1174
  function formatTime(time) {
@@ -1206,7 +1188,7 @@ function getScheduleInfo(schedule) {
1206
1188
  }
1207
1189
  const timeSlots = schedule.scheduleTimeSlots;
1208
1190
  const rrule = schedule.rrule;
1209
- const intervalMinutes = schedule.intervalMinutes ?? 30;
1191
+ const intervalDuration = schedule.intervalDuration ?? 30 * MINUTE_DURATION;
1210
1192
  const activeDaysSet = /* @__PURE__ */ new Set();
1211
1193
  let hasNullDayOfWeek = false;
1212
1194
  const startTimes = [];
@@ -1246,7 +1228,7 @@ function getScheduleInfo(schedule) {
1246
1228
  if (latestEndTime) {
1247
1229
  endTime = latestEndTime;
1248
1230
  } else {
1249
- endTime = addMinutesToTime(latestStart, intervalMinutes);
1231
+ endTime = addDurationToTime(latestStart, intervalDuration);
1250
1232
  }
1251
1233
  const startFormatted = formatTime(earliestStart);
1252
1234
  const endFormatted = formatTime(endTime);
@@ -1261,7 +1243,7 @@ function getScheduleInfo(schedule) {
1261
1243
  var __defProp = Object.defineProperty;
1262
1244
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1263
1245
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1264
- class Order3000Client {
1246
+ class O3KClient {
1265
1247
  constructor(config) {
1266
1248
  __publicField(this, "areas");
1267
1249
  __publicField(this, "articles");
@@ -1309,9 +1291,10 @@ class Order3000Client {
1309
1291
  }
1310
1292
  }
1311
1293
 
1312
- exports.Order3000Client = Order3000Client;
1313
- exports.fulfillmentTypeEnum = fulfillmentTypeEnum;
1314
- exports.getScheduleInfo = getScheduleInfo;
1315
- exports.participantStatusEnum = participantStatusEnum;
1316
- exports.paymentMethodEnum = paymentMethodEnum;
1317
- exports.teamOrderStatusEnum = teamOrderStatusEnum;
1294
+ exports.O3KDeliveryAddressSchema = deliveryAddressSchema.deliveryAddressSchema;
1295
+ exports.O3KClient = O3KClient;
1296
+ exports.O3KFulfillmentTypeEnum = fulfillmentTypeEnum;
1297
+ exports.O3KGetScheduleInfo = getScheduleInfo;
1298
+ exports.O3KParticipantStatusEnum = participantStatusEnum;
1299
+ exports.O3KPaymentMethodEnum = paymentMethodEnum;
1300
+ exports.O3KTeamOrderStatusEnum = teamOrderStatusEnum;