order3000 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.cjs CHANGED
@@ -103,20 +103,25 @@ class BaseResource {
103
103
  this.baseUrl = baseUrl;
104
104
  this.resourcePath = resourcePath;
105
105
  }
106
- async request(method, path, data) {
106
+ async request(method, path, data, cacheOptions) {
107
107
  const token = await this.tokenManager.getToken();
108
108
  const venueId = this.tokenManager.getVenueId();
109
109
  const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
110
- const response = await fetch(url, {
110
+ const init = {
111
111
  method,
112
112
  headers: {
113
113
  Authorization: `Bearer ${token}`,
114
114
  "Content-Type": "application/json"
115
115
  },
116
116
  body: data ? JSON.stringify(data) : void 0,
117
- cache: "no-store",
118
117
  signal: AbortSignal.timeout(36e4)
119
- });
118
+ };
119
+ if (cacheOptions?.next !== void 0) {
120
+ init.next = cacheOptions.next;
121
+ } else {
122
+ init.cache = cacheOptions?.cache ?? "no-store";
123
+ }
124
+ const response = await fetch(url, init);
120
125
  if (!response.ok) {
121
126
  let body = "";
122
127
  try {
@@ -324,7 +329,12 @@ class EventsResource extends BaseResource {
324
329
  */
325
330
  async getByAccessor(accessor, options) {
326
331
  const queryString = this.buildQueryString(options);
327
- return this.request("GET", `/${accessor}${queryString}`);
332
+ return this.request(
333
+ "GET",
334
+ `/${accessor}${queryString}`,
335
+ void 0,
336
+ { next: { revalidate: 2700 } }
337
+ );
328
338
  }
329
339
  buildQueryString(options) {
330
340
  if (!options?.expand?.length) return "";
@@ -712,6 +722,22 @@ class TeamOrdersResource {
712
722
  request
713
723
  );
714
724
  }
725
+ /**
726
+ * Toggle a participant's "settled" tick on the team Lead's
727
+ * post-placement settle-up checklist. Writes to
728
+ * `orders.leadSettledAt` — sets it to `NOW()` when `settled` is
729
+ * `true`, clears it back to `null` when `false`.
730
+ *
731
+ * Authorized only for the team Lead's session — server rejects
732
+ * non-Lead callers and `orderId`s that don't belong to this team.
733
+ */
734
+ async setOrderLeadSettled(publicId, request) {
735
+ return this.request(
736
+ "POST",
737
+ `${this.baseUrl}/team-orders/${encodeURIComponent(publicId)}/lead-settled`,
738
+ request
739
+ );
740
+ }
715
741
  /**
716
742
  * Any participant proposes an auto-extend when their local clock sees
717
743
  * that `fulfillmentAt` has passed while the team order is still
package/dist/client.d.cts CHANGED
@@ -28,12 +28,29 @@ declare class TokenManager {
28
28
  private setDefaultVenueId;
29
29
  }
30
30
 
31
+ /**
32
+ * Per-call cache override. Default behaviour is `cache: 'no-store'`
33
+ * — correct for live-read endpoints (basket, team-order, payment
34
+ * intents) where any caching causes stale responses against realtime
35
+ * mutations. Resources that surface near-static data consumed during
36
+ * static generation (e.g. `events.getByAccessor` for the Tiffinbox
37
+ * event schedule) can override with `next: { revalidate: N }` so
38
+ * Next.js can pre-render the calling page during the build instead
39
+ * of bailing out to dynamic rendering with `DYNAMIC_SERVER_USAGE`.
40
+ */
41
+ interface RequestCacheOptions {
42
+ cache?: RequestCache;
43
+ next?: {
44
+ revalidate?: number | false;
45
+ tags?: string[];
46
+ };
47
+ }
31
48
  declare abstract class BaseResource {
32
49
  protected readonly tokenManager: TokenManager;
33
50
  protected readonly baseUrl: string;
34
51
  protected readonly resourcePath: string;
35
52
  constructor(tokenManager: TokenManager, baseUrl: string, resourcePath: string);
36
- protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown): Promise<T>;
53
+ protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown, cacheOptions?: RequestCacheOptions): Promise<T>;
37
54
  }
38
55
 
39
56
  interface components {
@@ -1518,6 +1535,14 @@ interface TeamOrderParticipant {
1518
1535
  depositwareTemplateId: string;
1519
1536
  count: number;
1520
1537
  }>;
1538
+ /**
1539
+ * ISO timestamp the team Lead checked off this participant on
1540
+ * their post-placement settle-up checklist — a private "this
1541
+ * person has handed over what they owe me" tick. `null` while
1542
+ * unchecked. Lead-private; consumer-side rendering decides
1543
+ * whether to surface it.
1544
+ */
1545
+ leadSettledAt: string | null;
1521
1546
  }
1522
1547
  interface ThresholdCheck {
1523
1548
  meets: boolean;
@@ -1734,6 +1759,23 @@ declare class TeamOrdersResource {
1734
1759
  diningTime: string;
1735
1760
  diningOffsetMinutes: number;
1736
1761
  }>;
1762
+ /**
1763
+ * Toggle a participant's "settled" tick on the team Lead's
1764
+ * post-placement settle-up checklist. Writes to
1765
+ * `orders.leadSettledAt` — sets it to `NOW()` when `settled` is
1766
+ * `true`, clears it back to `null` when `false`.
1767
+ *
1768
+ * Authorized only for the team Lead's session — server rejects
1769
+ * non-Lead callers and `orderId`s that don't belong to this team.
1770
+ */
1771
+ setOrderLeadSettled(publicId: string, request: {
1772
+ sessionId: string;
1773
+ orderId: string;
1774
+ settled: boolean;
1775
+ }): Promise<{
1776
+ orderId: string;
1777
+ leadSettledAt: string | null;
1778
+ }>;
1737
1779
  /**
1738
1780
  * Any participant proposes an auto-extend when their local clock sees
1739
1781
  * that `fulfillmentAt` has passed while the team order is still
package/dist/client.d.mts CHANGED
@@ -28,12 +28,29 @@ declare class TokenManager {
28
28
  private setDefaultVenueId;
29
29
  }
30
30
 
31
+ /**
32
+ * Per-call cache override. Default behaviour is `cache: 'no-store'`
33
+ * — correct for live-read endpoints (basket, team-order, payment
34
+ * intents) where any caching causes stale responses against realtime
35
+ * mutations. Resources that surface near-static data consumed during
36
+ * static generation (e.g. `events.getByAccessor` for the Tiffinbox
37
+ * event schedule) can override with `next: { revalidate: N }` so
38
+ * Next.js can pre-render the calling page during the build instead
39
+ * of bailing out to dynamic rendering with `DYNAMIC_SERVER_USAGE`.
40
+ */
41
+ interface RequestCacheOptions {
42
+ cache?: RequestCache;
43
+ next?: {
44
+ revalidate?: number | false;
45
+ tags?: string[];
46
+ };
47
+ }
31
48
  declare abstract class BaseResource {
32
49
  protected readonly tokenManager: TokenManager;
33
50
  protected readonly baseUrl: string;
34
51
  protected readonly resourcePath: string;
35
52
  constructor(tokenManager: TokenManager, baseUrl: string, resourcePath: string);
36
- protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown): Promise<T>;
53
+ protected request<T>(method: 'GET' | 'POST' | 'DELETE', path: string, data?: unknown, cacheOptions?: RequestCacheOptions): Promise<T>;
37
54
  }
38
55
 
39
56
  interface components {
@@ -1518,6 +1535,14 @@ interface TeamOrderParticipant {
1518
1535
  depositwareTemplateId: string;
1519
1536
  count: number;
1520
1537
  }>;
1538
+ /**
1539
+ * ISO timestamp the team Lead checked off this participant on
1540
+ * their post-placement settle-up checklist — a private "this
1541
+ * person has handed over what they owe me" tick. `null` while
1542
+ * unchecked. Lead-private; consumer-side rendering decides
1543
+ * whether to surface it.
1544
+ */
1545
+ leadSettledAt: string | null;
1521
1546
  }
1522
1547
  interface ThresholdCheck {
1523
1548
  meets: boolean;
@@ -1734,6 +1759,23 @@ declare class TeamOrdersResource {
1734
1759
  diningTime: string;
1735
1760
  diningOffsetMinutes: number;
1736
1761
  }>;
1762
+ /**
1763
+ * Toggle a participant's "settled" tick on the team Lead's
1764
+ * post-placement settle-up checklist. Writes to
1765
+ * `orders.leadSettledAt` — sets it to `NOW()` when `settled` is
1766
+ * `true`, clears it back to `null` when `false`.
1767
+ *
1768
+ * Authorized only for the team Lead's session — server rejects
1769
+ * non-Lead callers and `orderId`s that don't belong to this team.
1770
+ */
1771
+ setOrderLeadSettled(publicId: string, request: {
1772
+ sessionId: string;
1773
+ orderId: string;
1774
+ settled: boolean;
1775
+ }): Promise<{
1776
+ orderId: string;
1777
+ leadSettledAt: string | null;
1778
+ }>;
1737
1779
  /**
1738
1780
  * Any participant proposes an auto-extend when their local clock sees
1739
1781
  * that `fulfillmentAt` has passed while the team order is still
package/dist/client.mjs CHANGED
@@ -101,20 +101,25 @@ class BaseResource {
101
101
  this.baseUrl = baseUrl;
102
102
  this.resourcePath = resourcePath;
103
103
  }
104
- async request(method, path, data) {
104
+ async request(method, path, data, cacheOptions) {
105
105
  const token = await this.tokenManager.getToken();
106
106
  const venueId = this.tokenManager.getVenueId();
107
107
  const url = `${this.baseUrl}/venues/${venueId}${this.resourcePath}${path}`;
108
- const response = await fetch(url, {
108
+ const init = {
109
109
  method,
110
110
  headers: {
111
111
  Authorization: `Bearer ${token}`,
112
112
  "Content-Type": "application/json"
113
113
  },
114
114
  body: data ? JSON.stringify(data) : void 0,
115
- cache: "no-store",
116
115
  signal: AbortSignal.timeout(36e4)
117
- });
116
+ };
117
+ if (cacheOptions?.next !== void 0) {
118
+ init.next = cacheOptions.next;
119
+ } else {
120
+ init.cache = cacheOptions?.cache ?? "no-store";
121
+ }
122
+ const response = await fetch(url, init);
118
123
  if (!response.ok) {
119
124
  let body = "";
120
125
  try {
@@ -322,7 +327,12 @@ class EventsResource extends BaseResource {
322
327
  */
323
328
  async getByAccessor(accessor, options) {
324
329
  const queryString = this.buildQueryString(options);
325
- return this.request("GET", `/${accessor}${queryString}`);
330
+ return this.request(
331
+ "GET",
332
+ `/${accessor}${queryString}`,
333
+ void 0,
334
+ { next: { revalidate: 2700 } }
335
+ );
326
336
  }
327
337
  buildQueryString(options) {
328
338
  if (!options?.expand?.length) return "";
@@ -710,6 +720,22 @@ class TeamOrdersResource {
710
720
  request
711
721
  );
712
722
  }
723
+ /**
724
+ * Toggle a participant's "settled" tick on the team Lead's
725
+ * post-placement settle-up checklist. Writes to
726
+ * `orders.leadSettledAt` — sets it to `NOW()` when `settled` is
727
+ * `true`, clears it back to `null` when `false`.
728
+ *
729
+ * Authorized only for the team Lead's session — server rejects
730
+ * non-Lead callers and `orderId`s that don't belong to this team.
731
+ */
732
+ async setOrderLeadSettled(publicId, request) {
733
+ return this.request(
734
+ "POST",
735
+ `${this.baseUrl}/team-orders/${encodeURIComponent(publicId)}/lead-settled`,
736
+ request
737
+ );
738
+ }
713
739
  /**
714
740
  * Any participant proposes an auto-extend when their local clock sees
715
741
  * that `fulfillmentAt` has passed while the team order is still
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "order3000",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "order3000 node.js sdk",
5
5
  "main": "./dist/client.cjs",
6
6
  "module": "./dist/client.mjs",
@@ -32,9 +32,9 @@
32
32
  "prettier": "^3.7.4",
33
33
  "tsx": "^4.19.2",
34
34
  "typescript": "^5.9.3",
35
- "@kolaveri/prettier-config": "1.0.6",
36
35
  "@kolaveri/eslint-config": "1.5.0",
37
- "@kolaveri/tsconfig": "1.0.1"
36
+ "@kolaveri/tsconfig": "1.0.1",
37
+ "@kolaveri/prettier-config": "1.0.6"
38
38
  },
39
39
  "files": [
40
40
  "dist"