order3000 2.1.2 → 2.2.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
@@ -117,7 +117,8 @@ class BaseResource {
117
117
  },
118
118
  body: data ? JSON.stringify(data) : void 0,
119
119
  signal: AbortSignal.timeout(36e4),
120
- cache: cacheOptions?.cache ?? "no-store"
120
+ cache: cacheOptions?.cache ?? "no-store",
121
+ ...cacheOptions?.next ? { next: cacheOptions.next } : {}
121
122
  };
122
123
  const response = await fetch(url, init);
123
124
  if (!response.ok) {
@@ -816,9 +817,14 @@ class EventsResource extends BaseResource {
816
817
  * @param options - Optional expand options
817
818
  * @returns The event with optional schedule, timeSlots, menus, and assets
818
819
  */
819
- async get(idOrAccessor, options) {
820
+ async get(idOrAccessor, options, cacheOptions) {
820
821
  const queryString = this.buildQueryString(options);
821
- return this.request("GET", `/${idOrAccessor}${queryString}`);
822
+ return this.request(
823
+ "GET",
824
+ `/${idOrAccessor}${queryString}`,
825
+ void 0,
826
+ cacheOptions
827
+ );
822
828
  }
823
829
  buildQueryString(options) {
824
830
  if (!options?.expand?.length) return "";
@@ -920,29 +926,44 @@ class MenusResource extends BaseResource {
920
926
  * The server resolves either form transparently.
921
927
  * @param idOrAccessor - The menu UUID or accessor (slug)
922
928
  * @param options - Optional expand options
929
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
923
930
  * @returns The menu with optional items and assets
924
931
  */
925
- async get(idOrAccessor, options) {
932
+ async get(idOrAccessor, options, cacheOptions) {
926
933
  const queryString = this.buildQueryString(options);
927
- return this.request("GET", `/${idOrAccessor}${queryString}`);
934
+ return this.request(
935
+ "GET",
936
+ `/${idOrAccessor}${queryString}`,
937
+ void 0,
938
+ cacheOptions
939
+ );
928
940
  }
929
941
  /**
930
942
  * Get all bundles for a menu
931
943
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
944
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
932
945
  * @returns Array of menu bundles
933
946
  */
934
- async getBundles(menuIdOrAccessor) {
935
- return this.request("GET", `/${menuIdOrAccessor}/bundles`);
947
+ async getBundles(menuIdOrAccessor, cacheOptions) {
948
+ return this.request(
949
+ "GET",
950
+ `/${menuIdOrAccessor}/bundles`,
951
+ void 0,
952
+ cacheOptions
953
+ );
936
954
  }
937
955
  /**
938
956
  * Get all active subscriptions for a menu
939
957
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
958
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
940
959
  * @returns Array of menu subscriptions with posters
941
960
  */
942
- async getSubscriptions(menuIdOrAccessor) {
961
+ async getSubscriptions(menuIdOrAccessor, cacheOptions) {
943
962
  return this.request(
944
963
  "GET",
945
- `/${menuIdOrAccessor}/subscriptions`
964
+ `/${menuIdOrAccessor}/subscriptions`,
965
+ void 0,
966
+ cacheOptions
946
967
  );
947
968
  }
948
969
  buildQueryString(options) {
package/dist/client.d.cts CHANGED
@@ -32,20 +32,25 @@ declare class TokenManager {
32
32
  }
33
33
 
34
34
  /**
35
- * Per-call cache override. SDK reads are uniformly `cache: 'no-store'`
36
- * — correct for live-read endpoints (basket, team-order, payment
37
- * intents) where any caching causes stale responses against realtime
38
- * mutations. No SDK method bakes in ISR: apps that consume near-static
39
- * data during static generation own caching at the call site by
40
- * wrapping the SDK call in Next.js `unstable_cache(fn, key, { revalidate })`
41
- * (e.g. thamarai's `getTiffinBoxEvent` / `getALaCarteMenu`), which is
42
- * what lets Next.js pre-render the page during the build instead of
43
- * bailing out to dynamic rendering with `DYNAMIC_SERVER_USAGE`. The
44
- * `cache` field below remains only as a per-call escape hatch for the
45
- * rare reader that needs a non-default `RequestCache` value.
35
+ * Per-call cache override. SDK reads default to `cache: 'no-store'` —
36
+ * correct for live-read endpoints (basket, team-order, payment intents)
37
+ * where any caching causes stale responses against realtime mutations.
38
+ *
39
+ * Near-static reads that a Next.js app renders into many pages (a menu,
40
+ * its bundles and subscriptions, an event's schedule) pass Next's own
41
+ * fetch-cache options instead: `{ cache: 'force-cache', next: { revalidate,
42
+ * tags } }`. Next then caches the response, revalidates it on schedule and
43
+ * — unlike `unstable_cache` — locks the cache key while the request runs,
44
+ * so the pages a build renders at the same time share ONE request instead
45
+ * of each sending its own (THMR-206: one thamarai build sent ~1000).
46
46
  */
47
47
  interface RequestCacheOptions {
48
48
  cache?: RequestCache;
49
+ /** Next.js fetch-cache options; ignored outside Next.js. */
50
+ next?: {
51
+ revalidate?: number | false;
52
+ tags?: string[];
53
+ };
49
54
  }
50
55
  declare abstract class BaseResource {
51
56
  protected readonly tokenManager: TokenManager;
@@ -468,7 +473,7 @@ declare class EventsResource extends BaseResource {
468
473
  * @param options - Optional expand options
469
474
  * @returns The event with optional schedule, timeSlots, menus, and assets
470
475
  */
471
- get(idOrAccessor: string, options?: GetEventOptions): Promise<EventByAccessor>;
476
+ get(idOrAccessor: string, options?: GetEventOptions, cacheOptions?: RequestCacheOptions): Promise<EventByAccessor>;
472
477
  private buildQueryString;
473
478
  /**
474
479
  * Partial-update an event by id or accessor. Every body field is
@@ -523,21 +528,24 @@ declare class MenusResource extends BaseResource {
523
528
  * The server resolves either form transparently.
524
529
  * @param idOrAccessor - The menu UUID or accessor (slug)
525
530
  * @param options - Optional expand options
531
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
526
532
  * @returns The menu with optional items and assets
527
533
  */
528
- get(idOrAccessor: string, options?: GetMenuOptions): Promise<Menu>;
534
+ get(idOrAccessor: string, options?: GetMenuOptions, cacheOptions?: RequestCacheOptions): Promise<Menu>;
529
535
  /**
530
536
  * Get all bundles for a menu
531
537
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
538
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
532
539
  * @returns Array of menu bundles
533
540
  */
534
- getBundles(menuIdOrAccessor: string): Promise<MenuBundle[]>;
541
+ getBundles(menuIdOrAccessor: string, cacheOptions?: RequestCacheOptions): Promise<MenuBundle[]>;
535
542
  /**
536
543
  * Get all active subscriptions for a menu
537
544
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
545
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
538
546
  * @returns Array of menu subscriptions with posters
539
547
  */
540
- getSubscriptions(menuIdOrAccessor: string): Promise<MenuSubscription[]>;
548
+ getSubscriptions(menuIdOrAccessor: string, cacheOptions?: RequestCacheOptions): Promise<MenuSubscription[]>;
541
549
  private buildQueryString;
542
550
  }
543
551
 
package/dist/client.d.mts CHANGED
@@ -32,20 +32,25 @@ declare class TokenManager {
32
32
  }
33
33
 
34
34
  /**
35
- * Per-call cache override. SDK reads are uniformly `cache: 'no-store'`
36
- * — correct for live-read endpoints (basket, team-order, payment
37
- * intents) where any caching causes stale responses against realtime
38
- * mutations. No SDK method bakes in ISR: apps that consume near-static
39
- * data during static generation own caching at the call site by
40
- * wrapping the SDK call in Next.js `unstable_cache(fn, key, { revalidate })`
41
- * (e.g. thamarai's `getTiffinBoxEvent` / `getALaCarteMenu`), which is
42
- * what lets Next.js pre-render the page during the build instead of
43
- * bailing out to dynamic rendering with `DYNAMIC_SERVER_USAGE`. The
44
- * `cache` field below remains only as a per-call escape hatch for the
45
- * rare reader that needs a non-default `RequestCache` value.
35
+ * Per-call cache override. SDK reads default to `cache: 'no-store'` —
36
+ * correct for live-read endpoints (basket, team-order, payment intents)
37
+ * where any caching causes stale responses against realtime mutations.
38
+ *
39
+ * Near-static reads that a Next.js app renders into many pages (a menu,
40
+ * its bundles and subscriptions, an event's schedule) pass Next's own
41
+ * fetch-cache options instead: `{ cache: 'force-cache', next: { revalidate,
42
+ * tags } }`. Next then caches the response, revalidates it on schedule and
43
+ * — unlike `unstable_cache` — locks the cache key while the request runs,
44
+ * so the pages a build renders at the same time share ONE request instead
45
+ * of each sending its own (THMR-206: one thamarai build sent ~1000).
46
46
  */
47
47
  interface RequestCacheOptions {
48
48
  cache?: RequestCache;
49
+ /** Next.js fetch-cache options; ignored outside Next.js. */
50
+ next?: {
51
+ revalidate?: number | false;
52
+ tags?: string[];
53
+ };
49
54
  }
50
55
  declare abstract class BaseResource {
51
56
  protected readonly tokenManager: TokenManager;
@@ -468,7 +473,7 @@ declare class EventsResource extends BaseResource {
468
473
  * @param options - Optional expand options
469
474
  * @returns The event with optional schedule, timeSlots, menus, and assets
470
475
  */
471
- get(idOrAccessor: string, options?: GetEventOptions): Promise<EventByAccessor>;
476
+ get(idOrAccessor: string, options?: GetEventOptions, cacheOptions?: RequestCacheOptions): Promise<EventByAccessor>;
472
477
  private buildQueryString;
473
478
  /**
474
479
  * Partial-update an event by id or accessor. Every body field is
@@ -523,21 +528,24 @@ declare class MenusResource extends BaseResource {
523
528
  * The server resolves either form transparently.
524
529
  * @param idOrAccessor - The menu UUID or accessor (slug)
525
530
  * @param options - Optional expand options
531
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
526
532
  * @returns The menu with optional items and assets
527
533
  */
528
- get(idOrAccessor: string, options?: GetMenuOptions): Promise<Menu>;
534
+ get(idOrAccessor: string, options?: GetMenuOptions, cacheOptions?: RequestCacheOptions): Promise<Menu>;
529
535
  /**
530
536
  * Get all bundles for a menu
531
537
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
538
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
532
539
  * @returns Array of menu bundles
533
540
  */
534
- getBundles(menuIdOrAccessor: string): Promise<MenuBundle[]>;
541
+ getBundles(menuIdOrAccessor: string, cacheOptions?: RequestCacheOptions): Promise<MenuBundle[]>;
535
542
  /**
536
543
  * Get all active subscriptions for a menu
537
544
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
545
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
538
546
  * @returns Array of menu subscriptions with posters
539
547
  */
540
- getSubscriptions(menuIdOrAccessor: string): Promise<MenuSubscription[]>;
548
+ getSubscriptions(menuIdOrAccessor: string, cacheOptions?: RequestCacheOptions): Promise<MenuSubscription[]>;
541
549
  private buildQueryString;
542
550
  }
543
551
 
package/dist/client.mjs CHANGED
@@ -116,7 +116,8 @@ class BaseResource {
116
116
  },
117
117
  body: data ? JSON.stringify(data) : void 0,
118
118
  signal: AbortSignal.timeout(36e4),
119
- cache: cacheOptions?.cache ?? "no-store"
119
+ cache: cacheOptions?.cache ?? "no-store",
120
+ ...cacheOptions?.next ? { next: cacheOptions.next } : {}
120
121
  };
121
122
  const response = await fetch(url, init);
122
123
  if (!response.ok) {
@@ -815,9 +816,14 @@ class EventsResource extends BaseResource {
815
816
  * @param options - Optional expand options
816
817
  * @returns The event with optional schedule, timeSlots, menus, and assets
817
818
  */
818
- async get(idOrAccessor, options) {
819
+ async get(idOrAccessor, options, cacheOptions) {
819
820
  const queryString = this.buildQueryString(options);
820
- return this.request("GET", `/${idOrAccessor}${queryString}`);
821
+ return this.request(
822
+ "GET",
823
+ `/${idOrAccessor}${queryString}`,
824
+ void 0,
825
+ cacheOptions
826
+ );
821
827
  }
822
828
  buildQueryString(options) {
823
829
  if (!options?.expand?.length) return "";
@@ -919,29 +925,44 @@ class MenusResource extends BaseResource {
919
925
  * The server resolves either form transparently.
920
926
  * @param idOrAccessor - The menu UUID or accessor (slug)
921
927
  * @param options - Optional expand options
928
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
922
929
  * @returns The menu with optional items and assets
923
930
  */
924
- async get(idOrAccessor, options) {
931
+ async get(idOrAccessor, options, cacheOptions) {
925
932
  const queryString = this.buildQueryString(options);
926
- return this.request("GET", `/${idOrAccessor}${queryString}`);
933
+ return this.request(
934
+ "GET",
935
+ `/${idOrAccessor}${queryString}`,
936
+ void 0,
937
+ cacheOptions
938
+ );
927
939
  }
928
940
  /**
929
941
  * Get all bundles for a menu
930
942
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
943
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
931
944
  * @returns Array of menu bundles
932
945
  */
933
- async getBundles(menuIdOrAccessor) {
934
- return this.request("GET", `/${menuIdOrAccessor}/bundles`);
946
+ async getBundles(menuIdOrAccessor, cacheOptions) {
947
+ return this.request(
948
+ "GET",
949
+ `/${menuIdOrAccessor}/bundles`,
950
+ void 0,
951
+ cacheOptions
952
+ );
935
953
  }
936
954
  /**
937
955
  * Get all active subscriptions for a menu
938
956
  * @param menuIdOrAccessor - The menu UUID or accessor (slug)
957
+ * @param cacheOptions - Next.js fetch-cache options for near-static reads
939
958
  * @returns Array of menu subscriptions with posters
940
959
  */
941
- async getSubscriptions(menuIdOrAccessor) {
960
+ async getSubscriptions(menuIdOrAccessor, cacheOptions) {
942
961
  return this.request(
943
962
  "GET",
944
- `/${menuIdOrAccessor}/subscriptions`
963
+ `/${menuIdOrAccessor}/subscriptions`,
964
+ void 0,
965
+ cacheOptions
945
966
  );
946
967
  }
947
968
  buildQueryString(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "order3000",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "order3000 node.js sdk",
5
5
  "main": "./dist/client.cjs",
6
6
  "module": "./dist/client.mjs",
@@ -67,8 +67,8 @@
67
67
  "prettier": "^3.7.4",
68
68
  "tsx": "^4.19.2",
69
69
  "typescript": "^5.9.3",
70
- "@kolaveri/eslint-config": "1.19.2",
71
70
  "@kolaveri/prettier-config": "1.0.6",
71
+ "@kolaveri/eslint-config": "1.20.0",
72
72
  "@kolaveri/tsconfig": "1.0.1"
73
73
  },
74
74
  "files": [