@simpleapps-com/augur-server 2.2.5 → 2.2.6
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/hooks.d.ts +3 -4
- package/dist/hooks.js +4 -27
- package/dist/hooks.js.map +1 -1
- package/package.json +5 -5
package/dist/hooks.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { OptionsProxyConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
|
|
1
|
+
import { QueryActionFn, OptionsProxyConfig, DeepQueryOptions } from '@simpleapps-com/augur-core';
|
|
2
|
+
export { QueryActionFn } from '@simpleapps-com/augur-core';
|
|
2
3
|
|
|
3
|
-
/** Server action function signature accepted by createServerQueryProxy. */
|
|
4
|
-
type QueryActionFn = (methodPath: string, ...args: unknown[]) => Promise<unknown>;
|
|
5
4
|
/**
|
|
6
5
|
* Creates a client-side proxy that mirrors the SDK namespace and routes
|
|
7
6
|
* every method call through a server action function.
|
|
@@ -32,4 +31,4 @@ type QueryActionFn = (methodPath: string, ...args: unknown[]) => Promise<unknown
|
|
|
32
31
|
*/
|
|
33
32
|
declare function createServerQueryProxy<TApi extends object = object>(queryActionOrConfig?: QueryActionFn | OptionsProxyConfig, config?: OptionsProxyConfig): DeepQueryOptions<TApi>;
|
|
34
33
|
|
|
35
|
-
export {
|
|
34
|
+
export { createServerQueryProxy };
|
package/dist/hooks.js
CHANGED
|
@@ -6,36 +6,13 @@ import "./chunk-EYMB52E5.js";
|
|
|
6
6
|
import "./chunk-DGUM43GV.js";
|
|
7
7
|
|
|
8
8
|
// src/hooks.ts
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
getCacheTier,
|
|
13
|
-
buildQueryKey,
|
|
14
|
-
stableArgs
|
|
15
|
-
} from "@simpleapps-com/augur-core";
|
|
9
|
+
import { createQueryActionProxy } from "@simpleapps-com/augur-core";
|
|
10
|
+
import { registerQueryAction } from "@simpleapps-com/augur-hooks";
|
|
11
|
+
registerQueryAction(queryAction);
|
|
16
12
|
function createServerQueryProxy(queryActionOrConfig, config) {
|
|
17
13
|
const queryAction2 = typeof queryActionOrConfig === "function" ? queryActionOrConfig : queryAction;
|
|
18
14
|
const resolvedConfig = typeof queryActionOrConfig === "function" ? config : queryActionOrConfig;
|
|
19
|
-
return
|
|
20
|
-
(path, args) => {
|
|
21
|
-
const methodName = path[path.length - 1];
|
|
22
|
-
const methodPath = path.join(".");
|
|
23
|
-
const normalizedArgs = stableArgs(args);
|
|
24
|
-
if (isReadMethod(methodName)) {
|
|
25
|
-
const tier = getCacheTier(methodPath, resolvedConfig?.cache);
|
|
26
|
-
return {
|
|
27
|
-
queryKey: buildQueryKey(path, normalizedArgs),
|
|
28
|
-
queryFn: () => queryAction2(methodPath, ...args),
|
|
29
|
-
staleTime: tier.staleTime,
|
|
30
|
-
gcTime: tier.gcTime
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
mutationKey: path,
|
|
35
|
-
mutationFn: (...mutationArgs) => queryAction2(methodPath, ...mutationArgs)
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
);
|
|
15
|
+
return createQueryActionProxy(queryAction2, resolvedConfig);
|
|
39
16
|
}
|
|
40
17
|
export {
|
|
41
18
|
createServerQueryProxy
|
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 {
|
|
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 { 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.get({ itemId, customerId }));\n *\n * // Infinite queries — spread and add infinite-specific options\n * const { data, fetchNextPage } = useInfiniteQuery({\n * ...q.items.itemCategory.categoryItems.get(uid, filters),\n * getNextPageParam: (lastPage) => lastPage.nextCursor,\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 = object>(\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;AAMvC,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-server",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"llms.txt"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@simpleapps-com/augur-core": "2.2.
|
|
58
|
-
"@simpleapps-com/augur-hooks": "2.2.
|
|
59
|
-
"@simpleapps-com/augur-utils": "2.2.
|
|
57
|
+
"@simpleapps-com/augur-core": "2.2.6",
|
|
58
|
+
"@simpleapps-com/augur-hooks": "2.2.6",
|
|
59
|
+
"@simpleapps-com/augur-utils": "2.2.6"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@simpleapps-com/augur-api": "^2026.3.5",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"tsup": "^8.5.0",
|
|
85
85
|
"vitest": "^3.2.0",
|
|
86
86
|
"@augur-packages/tsconfig": "0.0.0",
|
|
87
|
-
"@simpleapps-com/augur-hooks": "2.2.
|
|
87
|
+
"@simpleapps-com/augur-hooks": "2.2.6"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "tsup",
|