@simpleapps-com/augur-hooks 2.2.5 → 2.2.7

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","../src/server.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACJA,8BAAsB;AACtB,mDAA4B;AAC5B,uDAAmC;AAU5B,IAAM,eAAA,EAAiB,0BAAA;AAAA,EAC5B,CAAA,EAAA,GACE,IAAI,4BAAA,CAAY;AAAA,IACd,cAAA,EAAgB;AAAA,MACd,OAAA,EAAS;AAAA,QACP,SAAA,EAAW,GAAA,EAAK,GAAA;AAAA,QAChB,oBAAA,EAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF,CAAC;AACL,CAAA;AAgBO,SAAS,kBAAA,CACd,GAAA,EACA,WAAA,EACwB;AACxB,EAAA,MAAM,YAAA,EAA8C,YAAA,EAChD,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,WAAA,CAAY,MAAA,EAAQ,UAAA,EAAY,WAAA,CAAY,WAAW,EAAE,EAAA,EAC5E,KAAA,CAAA;AACJ,EAAA,OAAO,2CAAA,GAAmB,EAAK,WAAW,CAAA;AAC5C;ADxBA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,+VAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","sourcesContent":[null,"// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy } from \"@simpleapps-com/augur-core\";\nimport type { DeepQueryOptions, OptionsProxyConfig, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * @example\n * ```ts\n * import { createAugurOptions } from \"@simpleapps-com/augur-hooks/server\";\n *\n * const q = createAugurOptions(api, cacheConfig);\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));\n * ```\n */\nexport function createAugurOptions<TApi extends object>(\n api: TApi,\n cacheConfig?: CacheConfig,\n): DeepQueryOptions<TApi> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n return createOptionsProxy(api, proxyConfig);\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n// Re-export shared types from augur-core\nexport type { AugurAuthContext, InfiniteScrollPage, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n// Types needed for server-side usage (type-only, erased at compile time)\nexport type { AugurApiClient } from \"./provider\";\nexport type { PageData } from \"./types\";\n"]}
1
+ {"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","../src/server.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,8BAAsB;AACtB,mDAA4B;AAC5B,uDAA2D;AAgBpD,IAAM,eAAA,EAAiB,0BAAA;AAAA,EAC5B,CAAA,EAAA,GACE,IAAI,4BAAA,CAAY;AAAA,IACd,cAAA,EAAgB;AAAA,MACd,OAAA,EAAS;AAAA,QACP,SAAA,EAAW,GAAA,EAAK,GAAA;AAAA,QAChB,oBAAA,EAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF,CAAC;AACL,CAAA;AA2BO,SAAS,kBAAA,CACd,gBAAA,EACA,WAAA,EACwB;AACxB,EAAA,MAAM,YAAA,EAA8C,YAAA,EAChD,EAAE,KAAA,EAAO,EAAE,MAAA,EAAQ,WAAA,CAAY,MAAA,EAAQ,UAAA,EAAY,WAAA,CAAY,WAAW,EAAE,EAAA,EAC5E,KAAA,CAAA;AAGJ,EAAA,GAAA,CAAI,OAAO,iBAAA,IAAqB,UAAA,EAAY;AAC1C,IAAA,OAAO,+CAAA,gBAA6B,EAAmC,WAAW,CAAA;AAAA,EACpF;AAGA,EAAA,GAAA,CAAI,gBAAA,EAAkB;AACpB,IAAA,OAAO,2CAAA,gBAAmB,EAAkB,WAAW,CAAA;AAAA,EACzD;AAGA,EAAA,MAAM,iBAAA,EAAmB,wDAAA,CAAyB;AAClD,EAAA,GAAA,CAAI,gBAAA,EAAkB;AACpB,IAAA,OAAO,+CAAA,gBAA6B,EAAkB,WAAW,CAAA;AAAA,EACnE;AAEA,EAAA,MAAM,IAAI,KAAA;AAAA,IACR;AAAA,EAEF,CAAA;AACF;ADhDA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,+VAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/server.cjs","sourcesContent":[null,"// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy, createQueryActionProxy } from \"@simpleapps-com/augur-core\";\nimport type {\n DeepQueryOptions,\n OptionsProxyConfig,\n CacheConfig,\n QueryActionFn,\n} from \"@simpleapps-com/augur-core\";\nimport { getRegisteredQueryAction } from \"./query-action-registry\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * Accepts either an SDK client instance or a queryAction function.\n * When called with no arguments, uses the auto-registered queryAction\n * (registered by augur-server/hooks on import).\n *\n * @example\n * ```ts\n * // With SDK client (traditional)\n * const q = createAugurOptions(site.client, cacheConfig);\n *\n * // With queryAction (server-only JWT sites)\n * import { queryAction } from \"@simpleapps-com/augur-server/query-action\";\n * const q = createAugurOptions(queryAction, cacheConfig);\n *\n * // With auto-registered queryAction (zero args -- requires augur-server/hooks import)\n * const q = createAugurOptions();\n *\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(42));\n * ```\n */\nexport function createAugurOptions<TApi extends object = object>(\n apiOrQueryAction?: TApi | QueryActionFn,\n cacheConfig?: CacheConfig,\n): DeepQueryOptions<TApi> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n\n // If a function is passed, treat it as a queryAction\n if (typeof apiOrQueryAction === \"function\") {\n return createQueryActionProxy<TApi>(apiOrQueryAction as QueryActionFn, proxyConfig);\n }\n\n // If an object is passed, treat it as an SDK client\n if (apiOrQueryAction) {\n return createOptionsProxy(apiOrQueryAction, proxyConfig);\n }\n\n // No args — use auto-registered queryAction\n const registeredAction = getRegisteredQueryAction();\n if (registeredAction) {\n return createQueryActionProxy<TApi>(registeredAction, proxyConfig);\n }\n\n throw new Error(\n \"createAugurOptions() requires either an SDK client, a queryAction function, or \" +\n \"a registered queryAction (import augur-server/hooks to auto-register).\",\n );\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n// Re-export shared types from augur-core\nexport type { AugurAuthContext, InfiniteScrollPage, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n// Types needed for server-side usage (type-only, erased at compile time)\nexport type { AugurApiClient } from \"./provider\";\nexport type { PageData } from \"./types\";\n"]}
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
- import { CacheConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
2
+ import { QueryActionFn, CacheConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
3
3
  export { AugurAuthContext, CacheConfig, InfiniteScrollPage } from '@simpleapps-com/augur-core';
4
4
  export { A as AugurApiClient, B as BatchQueryConfig, b as PageData, e as executeBatchQuery, g as getCartPricingQueryOptions, c as getStockKey, d as getStockOptions } from './cart-pricing-BF0FTKmm.cjs';
5
5
  import '@simpleapps-com/augur-utils';
@@ -20,14 +20,25 @@ declare const getQueryClient: () => QueryClient;
20
20
  * Uses the same augur-core proxy as `useAugurOptions()`, so query keys
21
21
  * are identical on server and client — SSR hydration is automatic.
22
22
  *
23
+ * Accepts either an SDK client instance or a queryAction function.
24
+ * When called with no arguments, uses the auto-registered queryAction
25
+ * (registered by augur-server/hooks on import).
26
+ *
23
27
  * @example
24
28
  * ```ts
25
- * import { createAugurOptions } from "@simpleapps-com/augur-hooks/server";
29
+ * // With SDK client (traditional)
30
+ * const q = createAugurOptions(site.client, cacheConfig);
31
+ *
32
+ * // With queryAction (server-only JWT sites)
33
+ * import { queryAction } from "@simpleapps-com/augur-server/query-action";
34
+ * const q = createAugurOptions(queryAction, cacheConfig);
35
+ *
36
+ * // With auto-registered queryAction (zero args -- requires augur-server/hooks import)
37
+ * const q = createAugurOptions();
26
38
  *
27
- * const q = createAugurOptions(api, cacheConfig);
28
- * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));
39
+ * await queryClient.prefetchQuery(q.items.invMast.doc.get(42));
29
40
  * ```
30
41
  */
31
- declare function createAugurOptions<TApi extends object>(api: TApi, cacheConfig?: CacheConfig): DeepQueryOptions<TApi>;
42
+ declare function createAugurOptions<TApi extends object = object>(apiOrQueryAction?: TApi | QueryActionFn, cacheConfig?: CacheConfig): DeepQueryOptions<TApi>;
32
43
 
33
44
  export { createAugurOptions, getQueryClient };
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
- import { CacheConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
2
+ import { QueryActionFn, CacheConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
3
3
  export { AugurAuthContext, CacheConfig, InfiniteScrollPage } from '@simpleapps-com/augur-core';
4
4
  export { A as AugurApiClient, B as BatchQueryConfig, b as PageData, e as executeBatchQuery, g as getCartPricingQueryOptions, c as getStockKey, d as getStockOptions } from './cart-pricing-BF0FTKmm.js';
5
5
  import '@simpleapps-com/augur-utils';
@@ -20,14 +20,25 @@ declare const getQueryClient: () => QueryClient;
20
20
  * Uses the same augur-core proxy as `useAugurOptions()`, so query keys
21
21
  * are identical on server and client — SSR hydration is automatic.
22
22
  *
23
+ * Accepts either an SDK client instance or a queryAction function.
24
+ * When called with no arguments, uses the auto-registered queryAction
25
+ * (registered by augur-server/hooks on import).
26
+ *
23
27
  * @example
24
28
  * ```ts
25
- * import { createAugurOptions } from "@simpleapps-com/augur-hooks/server";
29
+ * // With SDK client (traditional)
30
+ * const q = createAugurOptions(site.client, cacheConfig);
31
+ *
32
+ * // With queryAction (server-only JWT sites)
33
+ * import { queryAction } from "@simpleapps-com/augur-server/query-action";
34
+ * const q = createAugurOptions(queryAction, cacheConfig);
35
+ *
36
+ * // With auto-registered queryAction (zero args -- requires augur-server/hooks import)
37
+ * const q = createAugurOptions();
26
38
  *
27
- * const q = createAugurOptions(api, cacheConfig);
28
- * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));
39
+ * await queryClient.prefetchQuery(q.items.invMast.doc.get(42));
29
40
  * ```
30
41
  */
31
- declare function createAugurOptions<TApi extends object>(api: TApi, cacheConfig?: CacheConfig): DeepQueryOptions<TApi>;
42
+ declare function createAugurOptions<TApi extends object = object>(apiOrQueryAction?: TApi | QueryActionFn, cacheConfig?: CacheConfig): DeepQueryOptions<TApi>;
32
43
 
33
44
  export { createAugurOptions, getQueryClient };
package/dist/server.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import {
2
2
  executeBatchQuery,
3
3
  getCartPricingQueryOptions,
4
+ getRegisteredQueryAction,
4
5
  getStockKey,
5
6
  getStockOptions
6
- } from "./chunk-F6GEN6PI.js";
7
+ } from "./chunk-7XCI5EZQ.js";
7
8
 
8
9
  // src/server.ts
9
10
  import { cache } from "react";
10
11
  import { QueryClient } from "@tanstack/react-query";
11
- import { createOptionsProxy } from "@simpleapps-com/augur-core";
12
+ import { createOptionsProxy, createQueryActionProxy } from "@simpleapps-com/augur-core";
12
13
  var getQueryClient = cache(
13
14
  () => new QueryClient({
14
15
  defaultOptions: {
@@ -19,9 +20,21 @@ var getQueryClient = cache(
19
20
  }
20
21
  })
21
22
  );
22
- function createAugurOptions(api, cacheConfig) {
23
+ function createAugurOptions(apiOrQueryAction, cacheConfig) {
23
24
  const proxyConfig = cacheConfig ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } } : void 0;
24
- return createOptionsProxy(api, proxyConfig);
25
+ if (typeof apiOrQueryAction === "function") {
26
+ return createQueryActionProxy(apiOrQueryAction, proxyConfig);
27
+ }
28
+ if (apiOrQueryAction) {
29
+ return createOptionsProxy(apiOrQueryAction, proxyConfig);
30
+ }
31
+ const registeredAction = getRegisteredQueryAction();
32
+ if (registeredAction) {
33
+ return createQueryActionProxy(registeredAction, proxyConfig);
34
+ }
35
+ throw new Error(
36
+ "createAugurOptions() requires either an SDK client, a queryAction function, or a registered queryAction (import augur-server/hooks to auto-register)."
37
+ );
25
38
  }
26
39
  export {
27
40
  createAugurOptions,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy } from \"@simpleapps-com/augur-core\";\nimport type { DeepQueryOptions, OptionsProxyConfig, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * @example\n * ```ts\n * import { createAugurOptions } from \"@simpleapps-com/augur-hooks/server\";\n *\n * const q = createAugurOptions(api, cacheConfig);\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(params.id));\n * ```\n */\nexport function createAugurOptions<TApi extends object>(\n api: TApi,\n cacheConfig?: CacheConfig,\n): DeepQueryOptions<TApi> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n return createOptionsProxy(api, proxyConfig);\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n// Re-export shared types from augur-core\nexport type { AugurAuthContext, InfiniteScrollPage, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n// Types needed for server-side usage (type-only, erased at compile time)\nexport type { AugurApiClient } from \"./provider\";\nexport type { PageData } from \"./types\";\n"],"mappings":";;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAU5B,IAAM,iBAAiB;AAAA,EAC5B,MACE,IAAI,YAAY;AAAA,IACd,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,KAAK;AAAA,QAChB,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF,CAAC;AACL;AAgBO,SAAS,mBACd,KACA,aACwB;AACxB,QAAM,cAA8C,cAChD,EAAE,OAAO,EAAE,QAAQ,YAAY,QAAQ,YAAY,YAAY,WAAW,EAAE,IAC5E;AACJ,SAAO,mBAAmB,KAAK,WAAW;AAC5C;","names":[]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["// @simpleapps-com/augur-hooks/server\n// Query options, keys, and utilities for server-side prefetching in Next.js App Router.\n\nimport { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { createOptionsProxy, createQueryActionProxy } from \"@simpleapps-com/augur-core\";\nimport type {\n DeepQueryOptions,\n OptionsProxyConfig,\n CacheConfig,\n QueryActionFn,\n} from \"@simpleapps-com/augur-core\";\nimport { getRegisteredQueryAction } from \"./query-action-registry\";\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so layout, page, and header all share the same prefetch cache without\n * leaking state between requests.\n */\nexport const getQueryClient = cache(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n refetchOnWindowFocus: false,\n },\n },\n }),\n);\n\n/**\n * Creates server-side query options proxy for prefetching.\n *\n * Uses the same augur-core proxy as `useAugurOptions()`, so query keys\n * are identical on server and client — SSR hydration is automatic.\n *\n * Accepts either an SDK client instance or a queryAction function.\n * When called with no arguments, uses the auto-registered queryAction\n * (registered by augur-server/hooks on import).\n *\n * @example\n * ```ts\n * // With SDK client (traditional)\n * const q = createAugurOptions(site.client, cacheConfig);\n *\n * // With queryAction (server-only JWT sites)\n * import { queryAction } from \"@simpleapps-com/augur-server/query-action\";\n * const q = createAugurOptions(queryAction, cacheConfig);\n *\n * // With auto-registered queryAction (zero args -- requires augur-server/hooks import)\n * const q = createAugurOptions();\n *\n * await queryClient.prefetchQuery(q.items.invMast.doc.get(42));\n * ```\n */\nexport function createAugurOptions<TApi extends object = object>(\n apiOrQueryAction?: TApi | QueryActionFn,\n cacheConfig?: CacheConfig,\n): DeepQueryOptions<TApi> {\n const proxyConfig: OptionsProxyConfig | undefined = cacheConfig\n ? { cache: { static: cacheConfig.static, semiStatic: cacheConfig.semiStatic } }\n : undefined;\n\n // If a function is passed, treat it as a queryAction\n if (typeof apiOrQueryAction === \"function\") {\n return createQueryActionProxy<TApi>(apiOrQueryAction as QueryActionFn, proxyConfig);\n }\n\n // If an object is passed, treat it as an SDK client\n if (apiOrQueryAction) {\n return createOptionsProxy(apiOrQueryAction, proxyConfig);\n }\n\n // No args — use auto-registered queryAction\n const registeredAction = getRegisteredQueryAction();\n if (registeredAction) {\n return createQueryActionProxy<TApi>(registeredAction, proxyConfig);\n }\n\n throw new Error(\n \"createAugurOptions() requires either an SDK client, a queryAction function, or \" +\n \"a registered queryAction (import augur-server/hooks to auto-register).\",\n );\n}\n\n// All pure query options and keys (legacy)\nexport * from \"./queries\";\n\n// Re-export shared types from augur-core\nexport type { AugurAuthContext, InfiniteScrollPage, CacheConfig } from \"@simpleapps-com/augur-core\";\n\n// Types needed for server-side usage (type-only, erased at compile time)\nexport type { AugurApiClient } from \"./provider\";\nexport type { PageData } from \"./types\";\n"],"mappings":";;;;;;;;;AAGA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB,8BAA8B;AAgBpD,IAAM,iBAAiB;AAAA,EAC5B,MACE,IAAI,YAAY;AAAA,IACd,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,KAAK;AAAA,QAChB,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF,CAAC;AACL;AA2BO,SAAS,mBACd,kBACA,aACwB;AACxB,QAAM,cAA8C,cAChD,EAAE,OAAO,EAAE,QAAQ,YAAY,QAAQ,YAAY,YAAY,WAAW,EAAE,IAC5E;AAGJ,MAAI,OAAO,qBAAqB,YAAY;AAC1C,WAAO,uBAA6B,kBAAmC,WAAW;AAAA,EACpF;AAGA,MAAI,kBAAkB;AACpB,WAAO,mBAAmB,kBAAkB,WAAW;AAAA,EACzD;AAGA,QAAM,mBAAmB,yBAAyB;AAClD,MAAI,kBAAkB;AACpB,WAAO,uBAA6B,kBAAkB,WAAW;AAAA,EACnE;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EAEF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleapps-com/augur-hooks",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "description": "Cross-platform React Query hooks and Zustand stores for Augur ecommerce sites",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,8 +33,8 @@
33
33
  "llms.txt"
34
34
  ],
35
35
  "dependencies": {
36
- "@simpleapps-com/augur-core": "2.2.5",
37
- "@simpleapps-com/augur-utils": "2.2.5"
36
+ "@simpleapps-com/augur-core": "2.2.7",
37
+ "@simpleapps-com/augur-utils": "2.2.7"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@simpleapps-com/augur-api": "^2026.3.6",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/queries/cache-helper.ts","../src/queries/stock.ts","../src/queries/batch-query.ts","../src/queries/cart-pricing.ts"],"sourcesContent":["import type { CacheProvider, CacheTierConfig } from \"../types\";\nimport { stableStringify } from \"@simpleapps-com/augur-core\";\n\n/**\n * FNV-1a 32-bit hash. Fast, cross-platform (no Node crypto needed).\n */\nfunction fnv1a(str: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < str.length; i++) {\n h ^= str.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return (h >>> 0).toString(16).padStart(8, \"0\");\n}\n\n/**\n * Wraps an async function with optional Redis caching.\n *\n * - When `provider` and `tier.redis` are both set, checks Redis before\n * calling `fn`, then caches the result on miss.\n * - When either is missing, calls `fn` directly (no-op passthrough).\n *\n * @param provider Redis-compatible get/set + prefix. Undefined = skip Redis.\n * @param tier Cache tier config. Undefined or missing `redis` = skip Redis.\n * @param methodPath Dot-separated SDK method path (used as cache key segment).\n * @param fn The async function to cache (typically the SDK call).\n * @param keyArgs Values to hash for the cache key (e.g. query params).\n */\nexport async function withCache<T>(\n provider: CacheProvider | undefined,\n tier: CacheTierConfig | undefined,\n methodPath: string,\n fn: () => Promise<T>,\n ...keyArgs: unknown[]\n): Promise<T> {\n const redisTtl = tier?.redis;\n if (!provider || !redisTtl) return fn();\n\n const key = `${provider.prefix}sdk:${methodPath}:${fnv1a(stableStringify(keyArgs))}`;\n\n try {\n const cached = await provider.get(key);\n if (cached != null) return JSON.parse(cached) as T;\n } catch {\n /* Redis read error — fall through to SDK call */\n }\n\n const result = await fn();\n\n try {\n provider.set(key, JSON.stringify(result), redisTtl).catch(() => {});\n } catch {\n /* Non-serializable or write error — skip caching */\n }\n\n return result;\n}\n","import type { TStock } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getStockKey = (invMastUid: number | string) => {\n return [\"stock\", invMastUid] as const;\n};\n\n/** @deprecated Use createServerQueryProxy() from augur-server/hooks instead. */\nexport const getStockOptions = (\n api: AugurApiClient,\n invMastUid: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getStockKey(invMastUid),\n queryFn: async (): Promise<TStock> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.invMast.stock.get\",\n async () => {\n const response = await api.items.invMast.stock.get(Number(invMastUid), {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n const stockData = response.data?.stockData ?? [];\n const companySummary = response.data?.companySummary ?? {};\n return { stockData, companySummary } as TStock;\n },\n invMastUid,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { QueryClient } from \"@tanstack/react-query\";\n\nexport interface BatchQueryConfig<TParam, TData> {\n params: TParam[];\n queryClient: QueryClient;\n /** Build individual cache key for a single param. */\n getItemKey: (param: TParam) => readonly unknown[];\n /** Build the string key for the result Record from a param. */\n getResultKey: (param: TParam) => string;\n /** Fetch only uncached items, return keyed Record. */\n fetchItems: (uncached: TParam[]) => Promise<Record<string, TData>>;\n /** Extract individual cache key from a fetched result entry (for seeding). */\n getSeedKey: (resultKey: string, data: TData) => readonly unknown[];\n}\n\n/**\n * Generic batch query executor.\n *\n * 1. Checks queryClient cache for each param\n * 2. Fetches only uncached items in a single batch call\n * 3. Seeds individual cache entries from the response\n * 4. Returns merged cached + fetched record\n */\nexport async function executeBatchQuery<TParam, TData>(\n config: BatchQueryConfig<TParam, TData>,\n): Promise<Record<string, TData>> {\n const { params, queryClient, getItemKey, getResultKey, fetchItems, getSeedKey } = config;\n\n if (params.length === 0) {\n return {};\n }\n\n const cached: Record<string, TData> = {};\n const uncached: TParam[] = [];\n\n for (const param of params) {\n const existing = queryClient.getQueryData<TData>(getItemKey(param));\n if (existing !== undefined) {\n cached[getResultKey(param)] = existing;\n } else {\n uncached.push(param);\n }\n }\n\n if (uncached.length === 0) {\n return cached;\n }\n\n const fetched = await fetchItems(uncached);\n\n for (const [key, data] of Object.entries(fetched)) {\n queryClient.setQueryData(getSeedKey(key, data as TData), data);\n }\n\n return { ...cached, ...fetched };\n}\n","import type { TPriceData } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\n/**\n * Generates a consistent query key for item price queries.\n * Used internally by useCartPricing and getCartPricingQueryOptions.\n */\nexport const getItemPriceKey = (\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => {\n return [\"price\", itemId?.toUpperCase() || \"\", customerId, quantity] as const;\n};\n\n/**\n * Query options for item price. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n * Used internally by useCartPricing and getCartPricingQueryOptions.\n *\n * @deprecated Use createServerQueryProxy() from augur-server/hooks instead.\n */\nexport const getItemPriceOptions = (\n api: AugurApiClient,\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getItemPriceKey(itemId, customerId, quantity),\n queryFn: async (): Promise<TPriceData> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"pricing.priceEngine.get\",\n async () => {\n const response = await api.pricing.priceEngine.get({\n itemId: itemId?.toUpperCase() || \"\",\n customerId: Number(customerId),\n quantity,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n itemId,\n customerId,\n quantity,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n refetchOnReconnect: true,\n refetchOnWindowFocus: false,\n meta: { persist: true },\n };\n};\n\n/**\n * Get cart pricing query options for prefetching or parent components.\n *\n * @deprecated Use createServerQueryProxy() from augur-server/hooks instead.\n */\nexport function getCartPricingQueryOptions(\n api: AugurApiClient,\n cartLines: Array<{ itemId: string; quantity: number }>,\n customerId: string | number | undefined,\n cache?: CacheConfig,\n) {\n return cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity, cache),\n enabled: !!customerId && !!line.itemId,\n }));\n}\n"],"mappings":"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","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/chunk-SP2RWD73.cjs","../src/queries/cache-helper.ts","../src/queries/stock.ts","../src/queries/batch-query.ts","../src/queries/cart-pricing.ts"],"names":[],"mappings":"AAAA;ACCA,uDAAgC;AAKhC,SAAS,KAAA,CAAM,GAAA,EAAqB;AAClC,EAAA,IAAI,EAAA,EAAI,UAAA;AACR,EAAA,IAAA,CAAA,IAAS,EAAA,EAAI,CAAA,EAAG,EAAA,EAAI,GAAA,CAAI,MAAA,EAAQ,CAAA,EAAA,EAAK;AACnC,IAAA,EAAA,GAAK,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AACrB,IAAA,EAAA,EAAI,IAAA,CAAK,IAAA,CAAK,CAAA,EAAG,QAAU,CAAA;AAAA,EAC7B;AACA,EAAA,OAAA,CAAQ,EAAA,IAAM,CAAA,CAAA,CAAG,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,EAAG,GAAG,CAAA;AAC/C;AAeA,MAAA,SAAsB,SAAA,CACpB,QAAA,EACA,IAAA,EACA,UAAA,EACA,EAAA,EAAA,GACG,OAAA,EACS;AACZ,EAAA,MAAM,SAAA,kBAAW,IAAA,2BAAM,OAAA;AACvB,EAAA,GAAA,CAAI,CAAC,SAAA,GAAY,CAAC,QAAA,EAAU,OAAO,EAAA,CAAG,CAAA;AAEtC,EAAA,MAAM,IAAA,EAAM,CAAA,EAAA;AAER,EAAA;AACI,IAAA;AACF,IAAA;AACE,EAAA;AAER,EAAA;AAEM,EAAA;AAEF,EAAA;AACO,IAAA;AAAyD,IAAA;AAC5D,EAAA;AAER,EAAA;AAEO,EAAA;AACT;AD7Be;AACA;AEvBF;AACH,EAAA;AACV;AAGa;AAKE,EAAA;AACN,EAAA;AACK,IAAA;AACD,IAAA;AACD,MAAA;AACC,MAAA;AACE,wBAAA;AACP,QAAA;AACA,QAAA;AACA,QAAA;AACE,UAAA;AACM,YAAA;AACL,UAAA;AACD,UAAA;AACA,UAAA;AACA,UAAA;AACF,QAAA;AACA,QAAA;AACF,MAAA;AACF,IAAA;AACW,IAAA;AACH,IAAA;AACV,EAAA;AACF;AFmBe;AACA;AGnCO;AAGZ,EAAA;AAEG,EAAA;AACD,IAAA;AACV,EAAA;AAEM,EAAA;AACA,EAAA;AAEK,EAAA;AACH,IAAA;AACF,IAAA;AACK,MAAA;AACF,IAAA;AACI,MAAA;AACX,IAAA;AACF,EAAA;AAEa,EAAA;AACJ,IAAA;AACT,EAAA;AAEM,EAAA;AAEM,EAAA;AACV,IAAA;AACF,EAAA;AAEY,EAAA;AACd;AH4Be;AACA;AI3EF;AAKH,EAAA;AACV;AASa;AAOE,EAAA;AACN,EAAA;AACK,IAAA;AACD,IAAA;AACD,MAAA;AACC,MAAA;AACE,wBAAA;AACP,QAAA;AACA,QAAA;AACA,QAAA;AACE,UAAA;AACE,YAAA;AACA,YAAA;AACA,YAAA;AACI,YAAA;AACL,UAAA;AACD,UAAA;AACF,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AACF,IAAA;AACW,IAAA;AACH,IAAA;AACR,IAAA;AACA,IAAA;AACQ,IAAA;AACV,EAAA;AACF;AAOgB;AAMP,EAAA;AACF,IAAA;AACQ,IAAA;AACX,EAAA;AACJ;AJgDe;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/chunk-SP2RWD73.cjs","sourcesContent":[null,"import type { CacheProvider, CacheTierConfig } from \"../types\";\nimport { stableStringify } from \"@simpleapps-com/augur-core\";\n\n/**\n * FNV-1a 32-bit hash. Fast, cross-platform (no Node crypto needed).\n */\nfunction fnv1a(str: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < str.length; i++) {\n h ^= str.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return (h >>> 0).toString(16).padStart(8, \"0\");\n}\n\n/**\n * Wraps an async function with optional Redis caching.\n *\n * - When `provider` and `tier.redis` are both set, checks Redis before\n * calling `fn`, then caches the result on miss.\n * - When either is missing, calls `fn` directly (no-op passthrough).\n *\n * @param provider Redis-compatible get/set + prefix. Undefined = skip Redis.\n * @param tier Cache tier config. Undefined or missing `redis` = skip Redis.\n * @param methodPath Dot-separated SDK method path (used as cache key segment).\n * @param fn The async function to cache (typically the SDK call).\n * @param keyArgs Values to hash for the cache key (e.g. query params).\n */\nexport async function withCache<T>(\n provider: CacheProvider | undefined,\n tier: CacheTierConfig | undefined,\n methodPath: string,\n fn: () => Promise<T>,\n ...keyArgs: unknown[]\n): Promise<T> {\n const redisTtl = tier?.redis;\n if (!provider || !redisTtl) return fn();\n\n const key = `${provider.prefix}sdk:${methodPath}:${fnv1a(stableStringify(keyArgs))}`;\n\n try {\n const cached = await provider.get(key);\n if (cached != null) return JSON.parse(cached) as T;\n } catch {\n /* Redis read error — fall through to SDK call */\n }\n\n const result = await fn();\n\n try {\n provider.set(key, JSON.stringify(result), redisTtl).catch(() => {});\n } catch {\n /* Non-serializable or write error — skip caching */\n }\n\n return result;\n}\n","import type { TStock } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getStockKey = (invMastUid: number | string) => {\n return [\"stock\", invMastUid] as const;\n};\n\n/** @deprecated Use createServerQueryProxy() from augur-server/hooks instead. */\nexport const getStockOptions = (\n api: AugurApiClient,\n invMastUid: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getStockKey(invMastUid),\n queryFn: async (): Promise<TStock> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.invMast.stock.get\",\n async () => {\n const response = await api.items.invMast.stock.get(Number(invMastUid), {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n const stockData = response.data?.stockData ?? [];\n const companySummary = response.data?.companySummary ?? {};\n return { stockData, companySummary } as TStock;\n },\n invMastUid,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { QueryClient } from \"@tanstack/react-query\";\n\nexport interface BatchQueryConfig<TParam, TData> {\n params: TParam[];\n queryClient: QueryClient;\n /** Build individual cache key for a single param. */\n getItemKey: (param: TParam) => readonly unknown[];\n /** Build the string key for the result Record from a param. */\n getResultKey: (param: TParam) => string;\n /** Fetch only uncached items, return keyed Record. */\n fetchItems: (uncached: TParam[]) => Promise<Record<string, TData>>;\n /** Extract individual cache key from a fetched result entry (for seeding). */\n getSeedKey: (resultKey: string, data: TData) => readonly unknown[];\n}\n\n/**\n * Generic batch query executor.\n *\n * 1. Checks queryClient cache for each param\n * 2. Fetches only uncached items in a single batch call\n * 3. Seeds individual cache entries from the response\n * 4. Returns merged cached + fetched record\n */\nexport async function executeBatchQuery<TParam, TData>(\n config: BatchQueryConfig<TParam, TData>,\n): Promise<Record<string, TData>> {\n const { params, queryClient, getItemKey, getResultKey, fetchItems, getSeedKey } = config;\n\n if (params.length === 0) {\n return {};\n }\n\n const cached: Record<string, TData> = {};\n const uncached: TParam[] = [];\n\n for (const param of params) {\n const existing = queryClient.getQueryData<TData>(getItemKey(param));\n if (existing !== undefined) {\n cached[getResultKey(param)] = existing;\n } else {\n uncached.push(param);\n }\n }\n\n if (uncached.length === 0) {\n return cached;\n }\n\n const fetched = await fetchItems(uncached);\n\n for (const [key, data] of Object.entries(fetched)) {\n queryClient.setQueryData(getSeedKey(key, data as TData), data);\n }\n\n return { ...cached, ...fetched };\n}\n","import type { TPriceData } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\n/**\n * Generates a consistent query key for item price queries.\n * Used internally by useCartPricing and getCartPricingQueryOptions.\n */\nexport const getItemPriceKey = (\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => {\n return [\"price\", itemId?.toUpperCase() || \"\", customerId, quantity] as const;\n};\n\n/**\n * Query options for item price. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n * Used internally by useCartPricing and getCartPricingQueryOptions.\n *\n * @deprecated Use createServerQueryProxy() from augur-server/hooks instead.\n */\nexport const getItemPriceOptions = (\n api: AugurApiClient,\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getItemPriceKey(itemId, customerId, quantity),\n queryFn: async (): Promise<TPriceData> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"pricing.priceEngine.get\",\n async () => {\n const response = await api.pricing.priceEngine.get({\n itemId: itemId?.toUpperCase() || \"\",\n customerId: Number(customerId),\n quantity,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n itemId,\n customerId,\n quantity,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n refetchOnReconnect: true,\n refetchOnWindowFocus: false,\n meta: { persist: true },\n };\n};\n\n/**\n * Get cart pricing query options for prefetching or parent components.\n *\n * @deprecated Use createServerQueryProxy() from augur-server/hooks instead.\n */\nexport function getCartPricingQueryOptions(\n api: AugurApiClient,\n cartLines: Array<{ itemId: string; quantity: number }>,\n customerId: string | number | undefined,\n cache?: CacheConfig,\n) {\n return cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity, cache),\n enabled: !!customerId && !!line.itemId,\n }));\n}\n"]}