@simpleapps-com/augur-server 2.4.0 → 2026.11.2
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/EXPORTS.md +30 -73
- package/README.md +29 -198
- package/dist/actions/agr-info.d.ts +44 -0
- package/dist/actions/agr-info.d.ts.map +1 -0
- package/dist/actions/agr-site.d.ts +38 -0
- package/dist/actions/agr-site.d.ts.map +1 -0
- package/dist/actions/agr-work.d.ts +29 -0
- package/dist/actions/agr-work.d.ts.map +1 -0
- package/dist/actions/avalara.d.ts +38 -0
- package/dist/actions/avalara.d.ts.map +1 -0
- package/dist/actions/basecamp2.d.ts +48 -0
- package/dist/actions/basecamp2.d.ts.map +1 -0
- package/dist/actions/brand-folder.d.ts +39 -0
- package/dist/actions/brand-folder.d.ts.map +1 -0
- package/dist/actions/commerce.d.ts +58 -0
- package/dist/actions/commerce.d.ts.map +1 -0
- package/dist/actions/customers.d.ts +45 -0
- package/dist/actions/customers.d.ts.map +1 -0
- package/dist/actions/favorites.d.ts +21 -0
- package/dist/actions/favorites.d.ts.map +1 -0
- package/dist/actions/gregorovich.d.ts +35 -0
- package/dist/actions/gregorovich.d.ts.map +1 -0
- package/dist/actions/items.d.ts +81 -0
- package/dist/actions/items.d.ts.map +1 -0
- package/dist/actions/joomla.d.ts +60 -0
- package/dist/actions/joomla.d.ts.map +1 -0
- package/dist/actions/legacy.d.ts +46 -0
- package/dist/actions/legacy.d.ts.map +1 -0
- package/dist/actions/logistics.d.ts +41 -0
- package/dist/actions/logistics.d.ts.map +1 -0
- package/dist/actions/orders.d.ts +37 -0
- package/dist/actions/orders.d.ts.map +1 -0
- package/dist/actions/p21-apis.d.ts +34 -0
- package/dist/actions/p21-apis.d.ts.map +1 -0
- package/dist/actions/p21-core.d.ts +47 -0
- package/dist/actions/p21-core.d.ts.map +1 -0
- package/dist/actions/p21-pim.d.ts +37 -0
- package/dist/actions/p21-pim.d.ts.map +1 -0
- package/dist/actions/p21-sism.d.ts +38 -0
- package/dist/actions/p21-sism.d.ts.map +1 -0
- package/dist/actions/payments.d.ts +39 -0
- package/dist/actions/payments.d.ts.map +1 -0
- package/dist/actions/pricing.d.ts +46 -0
- package/dist/actions/pricing.d.ts.map +1 -0
- package/dist/actions/search.d.ts +62 -0
- package/dist/actions/search.d.ts.map +1 -0
- package/dist/actions/shipping.d.ts +57 -0
- package/dist/actions/shipping.d.ts.map +1 -0
- package/dist/actions/site.d.ts +142 -0
- package/dist/actions/site.d.ts.map +1 -0
- package/dist/actions/smarty-streets.d.ts +45 -0
- package/dist/actions/smarty-streets.d.ts.map +1 -0
- package/dist/actions/vmi.d.ts +45 -0
- package/dist/actions/vmi.d.ts.map +1 -0
- package/dist/actions/wishlists.d.ts +29 -0
- package/dist/actions/wishlists.d.ts.map +1 -0
- package/dist/api-handler.d.ts +25 -0
- package/dist/api-handler.d.ts.map +1 -0
- package/dist/api.d.ts +2 -26
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +19 -14
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +10 -12
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +2 -2
- package/dist/cache/redis-client.d.ts +18 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/with-cache.d.ts +17 -0
- package/dist/cache/with-cache.d.ts.map +1 -0
- package/dist/{chunk-PIYHMA6F.js → chunk-6CSVIBHQ.js} +15 -18
- package/dist/chunk-6CSVIBHQ.js.map +1 -0
- package/dist/{chunk-ALTIINP6.js → chunk-A4IVBK6P.js} +30 -6
- package/dist/chunk-A4IVBK6P.js.map +1 -0
- package/dist/{chunk-KHFEDL47.js → chunk-INVDQQ7T.js} +18 -12
- package/dist/chunk-INVDQQ7T.js.map +1 -0
- package/dist/{chunk-26WZBC4F.js → chunk-LX7SJJOU.js} +275 -667
- package/dist/chunk-LX7SJJOU.js.map +1 -0
- package/dist/chunk-OBWQSGB6.js +205 -0
- package/dist/chunk-OBWQSGB6.js.map +1 -0
- package/dist/{chunk-2NL4QKJN.js → chunk-UVGG74FO.js} +31 -30
- package/dist/chunk-UVGG74FO.js.map +1 -0
- package/dist/duration.d.ts +16 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/environment.d.ts +10 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/hooks.d.ts +8 -10
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +3 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +16 -125
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/pagination.d.ts +32 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/query-action.d.ts +15 -117
- package/dist/query-action.d.ts.map +1 -0
- package/dist/query-action.js +3 -3
- package/dist/query-options-helper.d.ts +34 -0
- package/dist/query-options-helper.d.ts.map +1 -0
- package/dist/query.js +1 -2
- package/dist/recaptcha.d.ts +6 -0
- package/dist/recaptcha.d.ts.map +1 -0
- package/dist/rules.d.ts +230 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/scoped-client-key.d.ts +9 -0
- package/dist/scoped-client-key.d.ts.map +1 -0
- package/dist/sdk-call.d.ts +66 -0
- package/dist/sdk-call.d.ts.map +1 -0
- package/dist/sdk-client-store.d.ts +250 -0
- package/dist/sdk-client-store.d.ts.map +1 -0
- package/dist/server-actions.d.ts +2 -0
- package/dist/server-actions.d.ts.map +1 -0
- package/dist/server-query-client.d.ts +19 -0
- package/dist/server-query-client.d.ts.map +1 -0
- package/dist/{server-site-registry-CdBfczOj.d.ts → server-site-registry.d.ts} +7 -9
- package/dist/server-site-registry.d.ts.map +1 -0
- package/dist/{site.d.ts → server-site.d.ts} +11 -16
- package/dist/server-site.d.ts.map +1 -0
- package/dist/site-actions-store.d.ts +27 -0
- package/dist/site-actions-store.d.ts.map +1 -0
- package/dist/site.js +15 -14
- package/dist/site.js.map +1 -1
- package/dist/testing.d.ts +9 -12
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +7 -27
- package/dist/testing.js.map +1 -1
- package/dist/utils/batch-fetch.d.ts +7 -0
- package/dist/utils/batch-fetch.d.ts.map +1 -0
- package/llms.txt +72 -51
- package/package.json +30 -20
- package/dist/actions.d.ts +0 -2
- package/dist/chunk-26WZBC4F.js.map +0 -1
- package/dist/chunk-2NL4QKJN.js.map +0 -1
- package/dist/chunk-ALTIINP6.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-KHFEDL47.js.map +0 -1
- package/dist/chunk-PIYHMA6F.js.map +0 -1
- package/dist/query.d.ts +0 -35
- package/dist/site-BjSFqufX.d.ts +0 -469
package/dist/hooks.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
queryAction
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-UVGG74FO.js";
|
|
5
|
+
import "./chunk-A4IVBK6P.js";
|
|
6
|
+
import "./chunk-OBWQSGB6.js";
|
|
7
7
|
|
|
8
8
|
// src/hooks.ts
|
|
9
9
|
import { createQueryActionProxy } from "@simpleapps-com/augur-core";
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks.ts"],"sourcesContent":["// \"use client\" banner is injected by tsup at build time.\n// Client-side proxy that generates React Query options backed by server actions.\n//\n// IMPORTANT: This file MUST NOT import from server-actions.ts or any module\n// that transitively depends on ioredis/withServerCache/action factories.\n// The queryAction import comes from query-action.ts which only depends on\n// site-actions-store.ts (a lightweight globalThis getter with zero deps).\n\nimport { createQueryActionProxy } from \"@simpleapps-com/augur-core\";\nimport type {\n DeepQueryOptions,\n OptionsProxyConfig,\n QueryActionFn,\n} from \"@simpleapps-com/augur-core\";\nimport type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport { registerQueryAction } from \"@simpleapps-com/augur-hooks\";\nimport { queryAction as defaultQueryAction } from \"./query-action\";\n\n// Auto-register queryAction so augur-hooks provider and hooks can detect it.\n// This runs as a side effect when any site imports from augur-server/hooks.\nregisterQueryAction(defaultQueryAction);\n\n// Re-export for consumers who need the type\nexport type { QueryActionFn };\n\n/**\n * Creates a client-side proxy that mirrors the SDK namespace and routes\n * every method call through a server action function.\n *\n * The `queryAction` parameter is optional. If omitted, it uses the built-in\n * server action from `@simpleapps-com/augur-server/query-action`.\n *\n * @example\n * ```tsx\n * import { createServerQueryProxy } from \"@simpleapps-com/augur-server/hooks\";\n *\n * const q = createServerQueryProxy();\n *\n * // Reads — any SDK method, routed through server actions\n * const { data: item } = useQuery(q.items.invMast.doc.get(42));\n * const { data: price } = useQuery(q.pricing.priceEngine.
|
|
1
|
+
{"version":3,"sources":["../src/hooks.ts"],"sourcesContent":["// \"use client\" banner is injected by tsup at build time.\n// Client-side proxy that generates React Query options backed by server actions.\n//\n// IMPORTANT: This file MUST NOT import from server-actions.ts or any module\n// that transitively depends on ioredis/withServerCache/action factories.\n// The queryAction import comes from query-action.ts which only depends on\n// site-actions-store.ts (a lightweight globalThis getter with zero deps).\n\nimport { createQueryActionProxy } from \"@simpleapps-com/augur-core\";\nimport type {\n DeepQueryOptions,\n OptionsProxyConfig,\n QueryActionFn,\n} from \"@simpleapps-com/augur-core\";\nimport type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport { registerQueryAction } from \"@simpleapps-com/augur-hooks\";\nimport { queryAction as defaultQueryAction } from \"./query-action\";\n\n// Auto-register queryAction so augur-hooks provider and hooks can detect it.\n// This runs as a side effect when any site imports from augur-server/hooks.\nregisterQueryAction(defaultQueryAction);\n\n// Re-export for consumers who need the type\nexport type { QueryActionFn };\n\n/**\n * Creates a client-side proxy that mirrors the SDK namespace and routes\n * every method call through a server action function.\n *\n * The `queryAction` parameter is optional. If omitted, it uses the built-in\n * server action from `@simpleapps-com/augur-server/query-action`.\n *\n * @example\n * ```tsx\n * import { createServerQueryProxy } from \"@simpleapps-com/augur-server/hooks\";\n *\n * const q = createServerQueryProxy();\n *\n * // Reads — any SDK method, routed through server actions\n * const { data: item } = useQuery(q.items.invMast.doc.get(42));\n * const { data: price } = useQuery(q.pricing.priceEngine.list({ itemId, customerId }));\n *\n * // Infinite queries — spread and add infinite-specific options\n * const { data, fetchNextPage } = useInfiniteQuery({\n * ...q.items.categories.items.list(itemCategoryUid, filters),\n * getNextPageParam: (lastPage, pages) => nextOffset(lastPage, pages), // the site's paging rule\n * initialPageParam: 0,\n * });\n *\n * // Mutations — write methods return mutation options\n * const addToCart = useMutation(q.commerce.cartLine.add.create());\n * ```\n */\nexport function createServerQueryProxy<TApi extends object = AugurAPI>(\n queryActionOrConfig?: QueryActionFn | OptionsProxyConfig,\n config?: OptionsProxyConfig,\n): DeepQueryOptions<TApi> {\n const queryAction =\n typeof queryActionOrConfig === \"function\" ? queryActionOrConfig : defaultQueryAction;\n const resolvedConfig = typeof queryActionOrConfig === \"function\" ? config : queryActionOrConfig;\n\n return createQueryActionProxy<TApi>(queryAction, resolvedConfig);\n}\n"],"mappings":";;;;;;;AAQA,SAAS,8BAA8B;AAOvC,SAAS,2BAA2B;AAKpC,oBAAoB,WAAkB;AAiC/B,SAAS,uBACd,qBACA,QACwB;AACxB,QAAMA,eACJ,OAAO,wBAAwB,aAAa,sBAAsB;AACpE,QAAM,iBAAiB,OAAO,wBAAwB,aAAa,SAAS;AAE5E,SAAO,uBAA6BA,cAAa,cAAc;AACjE;","names":["queryAction"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,125 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Read a cached value by key.
|
|
20
|
-
* Returns `null` on cache miss, circuit-open, connection failure, or if
|
|
21
|
-
* Redis is unavailable. Never throws.
|
|
22
|
-
*/
|
|
23
|
-
declare function cacheGet(key: string): Promise<string | null>;
|
|
24
|
-
/**
|
|
25
|
-
* Write a value to cache with a TTL. Fire-and-forget semantics: no-ops
|
|
26
|
-
* silently when the circuit is open or Redis is unavailable. Never throws.
|
|
27
|
-
*/
|
|
28
|
-
declare function cacheSet(key: string, value: string, ttlSeconds: number): Promise<void>;
|
|
29
|
-
/** Returns the current circuit breaker state. */
|
|
30
|
-
declare function getCircuitState(): "closed" | "open";
|
|
31
|
-
/** Whether the Redis client is connected and ready to accept commands. */
|
|
32
|
-
declare function isRedisConnected(): boolean;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Calls an Augur SDK method, forwarding all arguments with full type safety.
|
|
36
|
-
*
|
|
37
|
-
* With augur-api >= 0.9.6, SDK methods properly declare their `CacheParams`
|
|
38
|
-
* option (including `edgeCache`), so this wrapper preserves both parameter
|
|
39
|
-
* and return-type inference end-to-end.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* const result = await sdkCall(
|
|
44
|
-
* augurServices.items.invMast.get,
|
|
45
|
-
* invMastUid,
|
|
46
|
-
* { edgeCache: 4 },
|
|
47
|
-
* );
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
declare function sdkCall<TArgs extends unknown[], TResult>(method: (...args: TArgs) => Promise<TResult>, ...args: TArgs): Promise<TResult>;
|
|
51
|
-
/**
|
|
52
|
-
* Wraps an async function call with error handling, returning a
|
|
53
|
-
* `SafeActionResult<T>` instead of throwing.
|
|
54
|
-
*
|
|
55
|
-
* Use this to eliminate try/catch boilerplate in server actions.
|
|
56
|
-
* Reads that go through React Query should NOT use this — let errors
|
|
57
|
-
* propagate so React Query can handle retries and error state.
|
|
58
|
-
*
|
|
59
|
-
* @param fn — The async function to execute
|
|
60
|
-
* @param onError — Optional callback for logging/reporting
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* const result = await safeAction(
|
|
65
|
-
* () => actions.commerce.addToCart(cartId, items),
|
|
66
|
-
* );
|
|
67
|
-
* if (result.ok) {
|
|
68
|
-
* // result.data is the response data (undefined for void actions)
|
|
69
|
-
* } else {
|
|
70
|
-
* // result.error is the error message
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
declare function safeAction<T>(fn: () => Promise<T>, onError?: (error: Error) => void): Promise<SafeActionResult<T>>;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Fetches data for multiple params in parallel, returning a Record keyed by
|
|
78
|
-
* `getKey(param)`. Individual failures are silently excluded from the result
|
|
79
|
-
* so one bad item never takes down the entire batch.
|
|
80
|
-
*/
|
|
81
|
-
declare function batchFetch<TParam, TKey extends string | number, TData>(params: TParam[], fetchOne: (param: TParam) => Promise<TData>, getKey: (param: TParam) => TKey): Promise<Record<TKey, TData>>;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Creates a server-side query client optimised for prefetching.
|
|
85
|
-
*
|
|
86
|
-
* - No persistence (server-only)
|
|
87
|
-
* - No GC timers (gcTime: Infinity), so the client is freed with the request
|
|
88
|
-
* - No retries (fail fast on server)
|
|
89
|
-
* - No refetching (server renders are one-shot)
|
|
90
|
-
*/
|
|
91
|
-
declare function createServerQueryClient(): QueryClient;
|
|
92
|
-
/**
|
|
93
|
-
* Returns a per-request singleton QueryClient for React Server Components.
|
|
94
|
-
*
|
|
95
|
-
* React's `cache()` deduplicates calls within a single server request,
|
|
96
|
-
* so each request gets its own QueryClient while avoiding the cross-request
|
|
97
|
-
* state leakage that a module-level singleton would cause.
|
|
98
|
-
*/
|
|
99
|
-
declare const getServerQueryClient: () => QueryClient;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Server-side cache wrapper using augur-server's Redis client.
|
|
103
|
-
*
|
|
104
|
-
* Uses the same cache key format as augur-hooks' client-side caching
|
|
105
|
-
* via augur-core's `buildCacheKey`:
|
|
106
|
-
* `${prefix}sdk:${methodPath}:${fnv1a(stableStringify(keyArgs))}`
|
|
107
|
-
*
|
|
108
|
-
* This means server-side cached data can be read by client-side hooks
|
|
109
|
-
* (and vice versa) when using the same prefix and method path.
|
|
110
|
-
*
|
|
111
|
-
* @param prefix Cache key prefix (e.g. "ampro:"). Empty string if none.
|
|
112
|
-
* @param redisTtl Redis TTL in seconds. 0 or undefined = skip caching.
|
|
113
|
-
* @param methodPath Dot-separated SDK method path (e.g. "pricing.priceEngine.get").
|
|
114
|
-
* @param fn The async function to cache.
|
|
115
|
-
* @param keyArgs Values to hash for the cache key.
|
|
116
|
-
*/
|
|
117
|
-
declare function withServerCache<T>(prefix: string, redisTtl: number | undefined, methodPath: string, fn: () => Promise<T>, ...keyArgs: unknown[]): Promise<T>;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Server-side Google reCAPTCHA v3 verification.
|
|
121
|
-
* Used by API routes that accept public form submissions.
|
|
122
|
-
*/
|
|
123
|
-
declare function verifyRecaptcha(token: string): Promise<boolean>;
|
|
124
|
-
|
|
125
|
-
export { batchFetch, cacheGet, cacheSet, createServerQueryClient, env, getCircuitState, getServerQueryClient, isDev, isProduction, isRedisConnected, isStaging, safeAction, sdkCall, verifyRecaptcha, withServerCache };
|
|
1
|
+
export { env, isDev, isStaging, isProduction } from "./environment";
|
|
2
|
+
export { cacheGet, cacheSet, getCircuitState, isRedisConnected } from "./cache/redis-client";
|
|
3
|
+
export { sdkCall, safeAction, unwrap, unwrapOr } from "./sdk-call";
|
|
4
|
+
export { batchFetch } from "./utils/batch-fetch";
|
|
5
|
+
export type { ActionResult, EdgeCacheValue, SafeActionResult } from "./sdk-call";
|
|
6
|
+
export { createServerQueryClient, getServerQueryClient } from "./server-query-client";
|
|
7
|
+
export { createQueryOptions, createSuspenseQueryOptions } from "./query-options-helper";
|
|
8
|
+
export type { QueryOptionsConfig } from "./query-options-helper";
|
|
9
|
+
export { withServerCache } from "./cache/with-cache";
|
|
10
|
+
export { paginateOffset } from "./pagination";
|
|
11
|
+
export type { PaginatedResult } from "./pagination";
|
|
12
|
+
export { createSiteActions } from "./actions/site";
|
|
13
|
+
export type { SiteActionsConfig, SiteActions } from "./actions/site";
|
|
14
|
+
export { getSiteActions, registerSiteActions } from "./server-site-registry";
|
|
15
|
+
export { verifyRecaptcha } from "./recaptcha";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGpE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGjF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAExF,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGrE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createQueryOptions,
|
|
3
3
|
createSuspenseQueryOptions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6CSVIBHQ.js";
|
|
5
5
|
import {
|
|
6
6
|
batchFetch,
|
|
7
7
|
cacheGet,
|
|
@@ -21,9 +21,11 @@ import {
|
|
|
21
21
|
unwrap,
|
|
22
22
|
unwrapOr,
|
|
23
23
|
withServerCache
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import
|
|
24
|
+
} from "./chunk-LX7SJJOU.js";
|
|
25
|
+
import "./chunk-A4IVBK6P.js";
|
|
26
|
+
import {
|
|
27
|
+
recaptchaOk
|
|
28
|
+
} from "./chunk-OBWQSGB6.js";
|
|
27
29
|
|
|
28
30
|
// src/server-query-client.ts
|
|
29
31
|
import { cache } from "react";
|
|
@@ -51,7 +53,7 @@ var getServerQueryClient = cache(() => createServerQueryClient());
|
|
|
51
53
|
async function verifyRecaptcha(token) {
|
|
52
54
|
try {
|
|
53
55
|
const secretKey = process.env["RECAPTCHA_SECRET_KEY"];
|
|
54
|
-
if (!secretKey) return false;
|
|
56
|
+
if (!secretKey) return recaptchaOk(false, false, void 0);
|
|
55
57
|
const res = await fetch("https://www.google.com/recaptcha/api/siteverify", {
|
|
56
58
|
method: "POST",
|
|
57
59
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -59,10 +61,10 @@ async function verifyRecaptcha(token) {
|
|
|
59
61
|
});
|
|
60
62
|
if (!res.ok) {
|
|
61
63
|
console.error("reCAPTCHA verify failed:", res.status);
|
|
62
|
-
return false;
|
|
64
|
+
return recaptchaOk(true, false, void 0);
|
|
63
65
|
}
|
|
64
66
|
const result = await res.json();
|
|
65
|
-
return result.success
|
|
67
|
+
return recaptchaOk(true, true, result.success);
|
|
66
68
|
} catch (error) {
|
|
67
69
|
console.error("reCAPTCHA verify error:", error);
|
|
68
70
|
return false;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server-query-client.ts","../src/recaptcha.ts"],"sourcesContent":["import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * - No GC timers (gcTime: Infinity), so the client is freed with the request\n * - No retries (fail fast on server)\n * - No refetching (server renders are one-shot)\n */\nexport function createServerQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: CACHE_CONFIG.STATIC.staleTime,\n // Infinity = no GC timer. A finite value pins this per-request client\n // (and its whole cache) in memory until the timer fires (#481).\n gcTime: Infinity,\n retry: 0,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n },\n });\n}\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 each request gets its own QueryClient while avoiding the cross-request\n * state leakage that a module-level singleton would cause.\n */\nexport const getServerQueryClient = cache((): QueryClient => createServerQueryClient());\n","/**\n * Server-side Google reCAPTCHA v3 verification.\n * Used by API routes that accept public form submissions.\n */\nexport async function verifyRecaptcha(token: string): Promise<boolean> {\n try {\n const secretKey = process.env[\"RECAPTCHA_SECRET_KEY\"];\n if (!secretKey) return false;\n\n const res = await fetch(\"https://www.google.com/recaptcha/api/siteverify\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({ secret: secretKey, response: token }),\n });\n if (!res.ok) {\n console.error(\"reCAPTCHA verify failed:\", res.status);\n return false;\n }\n const result = (await res.json()) as { success?: boolean };\n return result.success
|
|
1
|
+
{"version":3,"sources":["../src/server-query-client.ts","../src/recaptcha.ts"],"sourcesContent":["import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * - No GC timers (gcTime: Infinity), so the client is freed with the request\n * - No retries (fail fast on server)\n * - No refetching (server renders are one-shot)\n */\nexport function createServerQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: CACHE_CONFIG.STATIC.staleTime,\n // Infinity = no GC timer. A finite value pins this per-request client\n // (and its whole cache) in memory until the timer fires (#481).\n gcTime: Infinity,\n retry: 0,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n },\n });\n}\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 each request gets its own QueryClient while avoiding the cross-request\n * state leakage that a module-level singleton would cause.\n */\nexport const getServerQueryClient = cache((): QueryClient => createServerQueryClient());\n","import { recaptchaOk } from \"./rules\";\n\n/**\n * Server-side Google reCAPTCHA v3 verification.\n * Used by API routes that accept public form submissions.\n */\nexport async function verifyRecaptcha(token: string): Promise<boolean> {\n try {\n const secretKey = process.env[\"RECAPTCHA_SECRET_KEY\"];\n if (!secretKey) return recaptchaOk(false, false, undefined);\n\n const res = await fetch(\"https://www.google.com/recaptcha/api/siteverify\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({ secret: secretKey, response: token }),\n });\n if (!res.ok) {\n console.error(\"reCAPTCHA verify failed:\", res.status);\n return recaptchaOk(true, false, undefined);\n }\n const result = (await res.json()) as { success?: boolean };\n return recaptchaOk(true, true, result.success);\n } catch (error) {\n console.error(\"reCAPTCHA verify error:\", error);\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAUtB,SAAS,0BAAuC;AACrD,SAAO,IAAI,YAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,aAAa,OAAO;AAAA;AAAA;AAAA,QAG/B,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,gBAAgB;AAAA,QAChB,sBAAsB;AAAA,QACtB,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AASO,IAAM,uBAAuB,MAAM,MAAmB,wBAAwB,CAAC;;;AC9BtF,eAAsB,gBAAgB,OAAiC;AACrE,MAAI;AACF,UAAM,YAAY,QAAQ,IAAI,sBAAsB;AACpD,QAAI,CAAC,UAAW,QAAO,YAAY,OAAO,OAAO,MAAS;AAE1D,UAAM,MAAM,MAAM,MAAM,mDAAmD;AAAA,MACzE,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,oCAAoC;AAAA,MAC/D,MAAM,IAAI,gBAAgB,EAAE,QAAQ,WAAW,UAAU,MAAM,CAAC;AAAA,IAClE,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,cAAQ,MAAM,4BAA4B,IAAI,MAAM;AACpD,aAAO,YAAY,MAAM,OAAO,MAAS;AAAA,IAC3C;AACA,UAAM,SAAU,MAAM,IAAI,KAAK;AAC/B,WAAO,YAAY,MAAM,MAAM,OAAO,OAAO;AAAA,EAC/C,SAAS,OAAO;AACd,YAAQ,MAAM,2BAA2B,KAAK;AAC9C,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standardized paginated response shape.
|
|
3
|
+
* Works with any factory method — compose with `paginateOffset()`.
|
|
4
|
+
*/
|
|
5
|
+
export interface PaginatedResult<T> {
|
|
6
|
+
data: T[];
|
|
7
|
+
total: number;
|
|
8
|
+
nextCursor?: number;
|
|
9
|
+
hasMore: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a list of items with offset-based pagination metadata.
|
|
13
|
+
*
|
|
14
|
+
* Use this to standardize pagination responses from any factory method.
|
|
15
|
+
* Compatible with React Query's infinite query pattern (`getNextPageParam`).
|
|
16
|
+
*
|
|
17
|
+
* @param items - The items returned from the current page
|
|
18
|
+
* @param pageParam - The current page number (0-based)
|
|
19
|
+
* @param limit - The page size
|
|
20
|
+
* @param total - Optional total count of items (from API response)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const result = await actions.items.getCategoryItems(uid, {
|
|
25
|
+
* ...filters, offset: page * 24, limit: 24,
|
|
26
|
+
* });
|
|
27
|
+
* return paginateOffset(result.items, page, 24, result.total);
|
|
28
|
+
* // { data: [...], total: 150, nextCursor: 1, hasMore: true }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
|
|
32
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,eAAe,CAAC,CAAC,CAAC,CASpB"}
|
package/dist/query-action.d.ts
CHANGED
|
@@ -1,78 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const SessionCredentialsBrand: unique symbol;
|
|
4
|
-
declare const ApprovedMethodPathBrand: unique symbol;
|
|
5
|
-
/**
|
|
6
|
-
* Site identifier extracted from a validated Auth.js session JWT cookie.
|
|
7
|
-
*
|
|
8
|
-
* Intended to be minted only by `getSessionCredentials` in query-action.ts.
|
|
9
|
-
*
|
|
10
|
-
* Brand strength: code-review signal, not type-system enforcement. TypeScript
|
|
11
|
-
* allows `value as SessionSiteId` casts, so audit `as SessionSiteId` usages
|
|
12
|
-
* to catch unintended mints — there should be exactly one, at the JWT mint
|
|
13
|
-
* point.
|
|
14
|
-
*/
|
|
15
|
-
type SessionSiteId = string & {
|
|
16
|
-
readonly [SessionSiteIdBrand]: true;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Bearer token extracted from a validated Auth.js session JWT cookie.
|
|
20
|
-
* Same intended-mint and brand-strength caveat as {@link SessionSiteId}.
|
|
21
|
-
*/
|
|
22
|
-
type SessionBearerToken = string & {
|
|
23
|
-
readonly [SessionBearerTokenBrand]: true;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Paired session credentials. Bundles `siteId` and `token` from the same
|
|
27
|
-
* validated session into one value so downstream functions can accept the
|
|
28
|
-
* pair as a unit, instead of two separate parameters that callers might
|
|
29
|
-
* accidentally mix across sessions.
|
|
30
|
-
*
|
|
31
|
-
* Intended to be minted only by `getSessionCredentials` in query-action.ts,
|
|
32
|
-
* which performs the cross-check that the bearer's `client_id` siteId
|
|
33
|
-
* matches `targetSiteId`. Anything that holds a `SessionCredentials` *was*
|
|
34
|
-
* cross-checked at mint time — provided the value came through that mint
|
|
35
|
-
* and not via a cast.
|
|
36
|
-
*
|
|
37
|
-
* Brand strength: same code-review signal as the field brands. `value as
|
|
38
|
-
* SessionCredentials` compiles. Audit `as SessionCredentials` usages — there
|
|
39
|
-
* should be exactly one, in `getSessionCredentials`.
|
|
40
|
-
*/
|
|
41
|
-
type SessionCredentials = {
|
|
42
|
-
readonly siteId: SessionSiteId;
|
|
43
|
-
readonly token: SessionBearerToken;
|
|
44
|
-
readonly [SessionCredentialsBrand]: true;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* SDK method path validated against the registered allowlist.
|
|
48
|
-
*
|
|
49
|
-
* Intended to be minted only by `parseMethodPath` below. Functions that walk
|
|
50
|
-
* the path into the SDK client (notably `resolveMethod`) demand this type
|
|
51
|
-
* so that an unvalidated string flowing into the walker is a compile error
|
|
52
|
-
* for code that respects the convention.
|
|
53
|
-
*
|
|
54
|
-
* Brand strength: code-review signal. `value as ApprovedMethodPath` compiles.
|
|
55
|
-
* Audit `as ApprovedMethodPath` usages — there should be one, in
|
|
56
|
-
* `parseMethodPath`.
|
|
57
|
-
*
|
|
58
|
-
* Scope of validation: this is a *site-level surface restriction*, not a
|
|
59
|
-
* security boundary. augur-api is the auth authority; the allowlist limits
|
|
60
|
-
* what the application's proxy will forward to the SDK, not what tokens are
|
|
61
|
-
* permitted to do. Useful for narrowing same-origin attack surface (XSS,
|
|
62
|
-
* malicious bundled deps); not a substitute for API-level authorization.
|
|
63
|
-
*/
|
|
64
|
-
type ApprovedMethodPath = string & {
|
|
65
|
-
readonly [ApprovedMethodPathBrand]: true;
|
|
66
|
-
};
|
|
67
|
-
|
|
1
|
+
import { type SessionCredentials, type ApprovedMethodPath } from "./sdk-client-store";
|
|
2
|
+
import { unwrapBaseResponse } from "@simpleapps-com/augur-core";
|
|
68
3
|
/**
|
|
69
4
|
* Resolve session credentials from the Auth.js JWT cookie.
|
|
70
5
|
*
|
|
71
6
|
* Trust-boundary mint point: this is the only function in the package that
|
|
72
7
|
* produces {@link SessionCredentials} values. Bytes from a cookie become
|
|
73
|
-
* typed, paired credentials here and only here.
|
|
74
|
-
*
|
|
75
|
-
*
|
|
8
|
+
* typed, paired credentials here and only here. No other production code
|
|
9
|
+
* constructs the branded pair, so a `SessionCredentials` that came through
|
|
10
|
+
* this mint is JWT-validated and internally consistent. The brand is not
|
|
11
|
+
* enforced by the compiler: an `as SessionCredentials` cast compiles (tests
|
|
12
|
+
* do it), so audit casts (see "Brand strength" below).
|
|
76
13
|
*
|
|
77
14
|
* Returns null when:
|
|
78
15
|
* - no AUTH_SECRET is configured
|
|
@@ -81,6 +18,9 @@ type ApprovedMethodPath = string & {
|
|
|
81
18
|
* - the JWT decode fails or returns null
|
|
82
19
|
* - the decoded payload is missing `targetSiteId` or `token`, or either is
|
|
83
20
|
* not a non-empty string (refuse to mint partial credentials)
|
|
21
|
+
* - `targetSiteId` fails augur-api's `isSiteId` (`[a-z0-9_-]+`): siteIds are
|
|
22
|
+
* lowercase by convention, and the scoped-client key's injectivity proof
|
|
23
|
+
* (`scoped-client-key.ts`) needs a NUL-free siteId
|
|
84
24
|
* - the bearer token's `client_id` siteId portion does not match
|
|
85
25
|
* `targetSiteId` (defense-in-depth: refuses internally inconsistent sessions
|
|
86
26
|
* before they reach the augur-api authority check)
|
|
@@ -90,7 +30,7 @@ type ApprovedMethodPath = string & {
|
|
|
90
30
|
* AUTH_SECRET configured
|
|
91
31
|
* next-auth/jwt, next/headers, jose all loadable
|
|
92
32
|
* session cookie present and decodable with the secret
|
|
93
|
-
* typeof jwt.targetSiteId === "string" ∧ jwt.targetSiteId
|
|
33
|
+
* typeof jwt.targetSiteId === "string" ∧ isSiteId(jwt.targetSiteId) // implies non-empty
|
|
94
34
|
* typeof jwt.token === "string" ∧ jwt.token.length > 0
|
|
95
35
|
* bearerClientSiteId(jwt.token) = some jwt.targetSiteId
|
|
96
36
|
*
|
|
@@ -117,48 +57,6 @@ type ApprovedMethodPath = string & {
|
|
|
117
57
|
* exactly one, in this function), not a hard type-system gate.
|
|
118
58
|
*/
|
|
119
59
|
declare function getSessionCredentials(): Promise<SessionCredentials | null>;
|
|
120
|
-
/**
|
|
121
|
-
* Unwrap SDK BaseResponse if the result matches the standard shape.
|
|
122
|
-
* The SDK wraps all responses in `{ data: T, status: number, message: string }`.
|
|
123
|
-
* SiteActions previously unwrapped this; queryAction now does it automatically
|
|
124
|
-
* so consumers receive `T` directly.
|
|
125
|
-
*
|
|
126
|
-
* ## Property
|
|
127
|
-
*
|
|
128
|
-
* ∀ raw. result(raw) ∈ {raw.data, raw}
|
|
129
|
-
* BaseResponse?(raw) ⟺ raw is non-null object ∧ "data" ∈ keys(raw)
|
|
130
|
-
* ∧ "status" ∈ keys(raw)
|
|
131
|
-
* ∧ "message" ∈ keys(raw)
|
|
132
|
-
*
|
|
133
|
-
* Two possible outcomes; never throws, never reshapes. The structural
|
|
134
|
-
* test checks key presence only — it does NOT validate field types or
|
|
135
|
-
* values. Assumes upstream code does not produce `{data, status, message}`
|
|
136
|
-
* shapes that aren't actually BaseResponses; if it does, those will be
|
|
137
|
-
* incorrectly unwrapped (false positive). In practice the augur-api SDK
|
|
138
|
-
* is the only producer of this shape on the server path.
|
|
139
|
-
*
|
|
140
|
-
* This property is what lets queryAction call this exactly once per
|
|
141
|
-
* request without double-unwrap risk: applying unwrapBaseResponse to
|
|
142
|
-
* an already-unwrapped value is a no-op (the second branch of the
|
|
143
|
-
* property fires).
|
|
144
|
-
*
|
|
145
|
-
* ## SDK envelope coupling — forward-compat additive, brittle to renames
|
|
146
|
-
*
|
|
147
|
-
* The structural test checks for `data ∧ status ∧ message`. Three implications:
|
|
148
|
-
*
|
|
149
|
-
* - Additive SDK changes (envelope grows new fields, e.g. `pagination`,
|
|
150
|
-
* `requestId`) are forward-compatible — the predicate still matches and
|
|
151
|
-
* this function still unwraps correctly.
|
|
152
|
-
* - Renames are brittle: if the augur-api SDK ever changes the envelope
|
|
153
|
-
* to `{ result, status, message }` (or any rename of `data`), this
|
|
154
|
-
* function silently STOPS unwrapping. Consumers receive the envelope
|
|
155
|
-
* as `T` and downstream code breaks far from the cause. The fix is
|
|
156
|
-
* mechanical (update the predicate) but the failure mode is silent —
|
|
157
|
-
* audit this function whenever the SDK envelope contract changes.
|
|
158
|
-
* - This predicate MUST stay in sync with augur-api's BaseResponse type.
|
|
159
|
-
* Treat the envelope shape as a coupled contract, not as inferred behaviour.
|
|
160
|
-
*/
|
|
161
|
-
declare function unwrapBaseResponse(raw: unknown): unknown;
|
|
162
60
|
/**
|
|
163
61
|
* Resolve a dot-separated method path on an object, returning the leaf function.
|
|
164
62
|
*
|
|
@@ -279,8 +177,8 @@ declare function resolveMethod(client: unknown, methodPath: ApprovedMethodPath):
|
|
|
279
177
|
* @param args Arguments to pass to the resolved method
|
|
280
178
|
* @returns The unwrapped result from the SDK method (possibly from Redis cache)
|
|
281
179
|
*/
|
|
282
|
-
declare function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown>;
|
|
180
|
+
export declare function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown>;
|
|
283
181
|
/** Reset lazy-loaded imports. Used in tests only. @internal */
|
|
284
|
-
declare function resetSessionImports(): void;
|
|
285
|
-
|
|
286
|
-
|
|
182
|
+
export declare function resetSessionImports(): void;
|
|
183
|
+
export { unwrapBaseResponse, getSessionCredentials, resolveMethod };
|
|
184
|
+
//# sourceMappingURL=query-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-action.d.ts","sourceRoot":"","sources":["../src/query-action.ts"],"names":[],"mappings":"AAUA,OAAO,EAOL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAGxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AA+FpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,iBAAe,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAyBzE;AA2DD;;;;;GAKG;AACH,iBAAS,aAAa,CACpB,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,kBAAkB,GAC7B,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAkBvC;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgHG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CA4C1F;AAED,+DAA+D;AAC/D,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C;AAED,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/query-action.js
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
resetSessionImports,
|
|
6
6
|
resolveMethod,
|
|
7
7
|
unwrapBaseResponse
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-UVGG74FO.js";
|
|
9
|
+
import "./chunk-A4IVBK6P.js";
|
|
10
|
+
import "./chunk-OBWQSGB6.js";
|
|
11
11
|
export {
|
|
12
12
|
getSessionCredentials,
|
|
13
13
|
queryAction,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { UseQueryOptions, UseSuspenseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { Millis } from "./duration";
|
|
3
|
+
export interface QueryOptionsConfig<TParams, TData> {
|
|
4
|
+
/** Base query key (e.g., "customer-orders") */
|
|
5
|
+
baseKey: string;
|
|
6
|
+
/** Parameters object */
|
|
7
|
+
params: TParams;
|
|
8
|
+
/** Function that returns the data */
|
|
9
|
+
queryFn: (params: TParams) => Promise<TData>;
|
|
10
|
+
/** Function to determine if query should be enabled */
|
|
11
|
+
enabledFn?: (params: TParams) => boolean;
|
|
12
|
+
/** Custom stale time (default: SEMI_STATIC's) */
|
|
13
|
+
staleTime?: Millis;
|
|
14
|
+
/**
|
|
15
|
+
* Custom garbage collection time in the browser (default: SEMI_STATIC's). On the server the
|
|
16
|
+
* returned gcTime is always `Infinity` (no GC timer), so the per-request cache is freed with
|
|
17
|
+
* the request (#481).
|
|
18
|
+
*/
|
|
19
|
+
gcTime?: Millis;
|
|
20
|
+
/** Key to exclude from query key generation */
|
|
21
|
+
excludeFromKey?: keyof TParams;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates useQuery options with consistent key generation.
|
|
25
|
+
* Filters out undefined/null/empty params from the query key.
|
|
26
|
+
*/
|
|
27
|
+
export declare const createQueryOptions: <TParams extends Record<string, unknown>, TData>({ baseKey, params, queryFn, enabledFn, staleTime, gcTime, excludeFromKey, }: QueryOptionsConfig<TParams, TData>) => UseQueryOptions<TData>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates useSuspenseQuery options with consistent key generation.
|
|
30
|
+
* Same as createQueryOptions but without enabledFn (suspense queries
|
|
31
|
+
* cannot be disabled).
|
|
32
|
+
*/
|
|
33
|
+
export declare const createSuspenseQueryOptions: <TParams extends Record<string, unknown>, TData>({ baseKey, params, queryFn, staleTime, gcTime, excludeFromKey, }: Omit<QueryOptionsConfig<TParams, TData>, "enabledFn">) => UseSuspenseQueryOptions<TData>;
|
|
34
|
+
//# sourceMappingURL=query-options-helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-options-helper.d.ts","sourceRoot":"","sources":["../src/query-options-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,WAAW,kBAAkB,CAAC,OAAO,EAAE,KAAK;IAChD,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,uDAAuD;IACvD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;IACzC,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC;CAChC;AAsBD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,6EAQhF,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,KAAG,eAAe,CAAC,KAAK,CAQ5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,kEAOxF,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,KAAG,uBAAuB,CAAC,KAAK,CAOvF,CAAC"}
|
package/dist/query.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recaptcha.d.ts","sourceRoot":"","sources":["../src/recaptcha.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBrE"}
|