@simpleapps-com/augur-server 2.2.8 → 2.2.9
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/actions.js
CHANGED
|
@@ -5,6 +5,12 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// src/query-action.ts
|
|
7
7
|
import { isReadMethod } from "@simpleapps-com/augur-core";
|
|
8
|
+
function unwrapBaseResponse(raw) {
|
|
9
|
+
if (raw != null && typeof raw === "object" && "data" in raw && "status" in raw && "message" in raw) {
|
|
10
|
+
return raw.data;
|
|
11
|
+
}
|
|
12
|
+
return raw;
|
|
13
|
+
}
|
|
8
14
|
async function queryAction(methodPath, ...args) {
|
|
9
15
|
const client = getSdkClientOrNull();
|
|
10
16
|
if (!client) {
|
|
@@ -29,12 +35,15 @@ async function queryAction(methodPath, ...args) {
|
|
|
29
35
|
const leafName = segments[segments.length - 1];
|
|
30
36
|
const wrapper = getSdkCallWrapper();
|
|
31
37
|
if (wrapper && isReadMethod(leafName)) {
|
|
32
|
-
|
|
38
|
+
const result2 = await wrapper(methodPath, () => resolvedMethod(...args), ...args);
|
|
39
|
+
return unwrapBaseResponse(result2);
|
|
33
40
|
}
|
|
34
|
-
|
|
41
|
+
const result = await resolvedMethod(...args);
|
|
42
|
+
return unwrapBaseResponse(result);
|
|
35
43
|
}
|
|
36
44
|
|
|
37
45
|
export {
|
|
46
|
+
unwrapBaseResponse,
|
|
38
47
|
queryAction
|
|
39
48
|
};
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-YHI2PFKJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/query-action.ts"],"sourcesContent":["// \"use server\" banner is injected by tsup at build time.\n// Isolated server action for the proxy pattern.\n// This file MUST NOT import from server-actions.ts, server-site-registry.ts,\n// cache/, or any factory. It imports only from lightweight stores with zero\n// deps, plus augur-core (external in tsup — not bundled into chunks).\n\nimport { getSdkClientOrNull, getSdkCallWrapper } from \"./sdk-client-store\";\nimport { isReadMethod } from \"@simpleapps-com/augur-core\";\n\n/**\n * Unwrap SDK BaseResponse if the result matches the standard shape.\n * The SDK wraps all responses in `{ data: T, status: number, message: string }`.\n * SiteActions previously unwrapped this; queryAction now does it automatically\n * so consumers receive `T` directly.\n */\nfunction unwrapBaseResponse(raw: unknown): unknown {\n if (\n raw != null &&\n typeof raw === \"object\" &&\n \"data\" in raw &&\n \"status\" in raw &&\n \"message\" in raw\n ) {\n return (raw as { data: unknown }).data;\n }\n return raw;\n}\n\n/**\n * Generic server action that routes any SDK method call through the raw\n * SDK client with optional Redis caching. Used internally by\n * `createServerQueryProxy()` to bridge client-side React Query hooks\n * to server-side API calls.\n *\n * For read methods (get, list, lookup, search, suggest), the call is\n * wrapped in the registered cache wrapper (Redis) if one was registered\n * by createServerSite(). Write methods bypass caching.\n *\n * SDK responses wrapped in BaseResponse are automatically unwrapped --\n * consumers receive `T` instead of `{ data: T, status, message }`.\n *\n * @param methodPath Dot-separated SDK method path (e.g. \"items.invMast.doc.get\")\n * @param args Arguments to pass to the resolved method\n * @returns The unwrapped result from the SDK method (possibly from Redis cache)\n */\nexport async function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown> {\n const client = getSdkClientOrNull();\n if (!client) {\n throw new Error(\n \"SDK client not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars.\",\n );\n }\n const segments = methodPath.split(\".\");\n\n let current: unknown = client;\n for (const segment of segments) {\n if (current == null || (typeof current !== \"object\" && typeof current !== \"function\")) {\n throw new Error(\n `Cannot resolve \"${methodPath}\": \"${segment}\" is not accessible on ${typeof current}`,\n );\n }\n current = (current as Record<string, unknown>)[segment];\n }\n\n if (typeof current !== \"function\") {\n throw new Error(`\"${methodPath}\" does not resolve to a function (got ${typeof current})`);\n }\n\n const resolvedMethod = current as (...a: unknown[]) => Promise<unknown>;\n const leafName = segments[segments.length - 1]!;\n const wrapper = getSdkCallWrapper();\n\n // Read methods get Redis caching via the registered wrapper\n if (wrapper && isReadMethod(leafName)) {\n const result = await wrapper(methodPath, () => resolvedMethod(...args), ...args);\n return unwrapBaseResponse(result);\n }\n\n const result = await resolvedMethod(...args);\n return unwrapBaseResponse(result);\n}\n\nexport { unwrapBaseResponse };\n"],"mappings":";;;;;;AAOA,SAAS,oBAAoB;AAQ7B,SAAS,mBAAmB,KAAuB;AACjD,MACE,OAAO,QACP,OAAO,QAAQ,YACf,UAAU,OACV,YAAY,OACZ,aAAa,KACb;AACA,WAAQ,IAA0B;AAAA,EACpC;AACA,SAAO;AACT;AAmBA,eAAsB,YAAY,eAAuB,MAAmC;AAC1F,QAAM,SAAS,mBAAmB;AAClC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,WAAW,MAAM,GAAG;AAErC,MAAI,UAAmB;AACvB,aAAW,WAAW,UAAU;AAC9B,QAAI,WAAW,QAAS,OAAO,YAAY,YAAY,OAAO,YAAY,YAAa;AACrF,YAAM,IAAI;AAAA,QACR,mBAAmB,UAAU,OAAO,OAAO,0BAA0B,OAAO,OAAO;AAAA,MACrF;AAAA,IACF;AACA,cAAW,QAAoC,OAAO;AAAA,EACxD;AAEA,MAAI,OAAO,YAAY,YAAY;AACjC,UAAM,IAAI,MAAM,IAAI,UAAU,yCAAyC,OAAO,OAAO,GAAG;AAAA,EAC1F;AAEA,QAAM,iBAAiB;AACvB,QAAM,WAAW,SAAS,SAAS,SAAS,CAAC;AAC7C,QAAM,UAAU,kBAAkB;AAGlC,MAAI,WAAW,aAAa,QAAQ,GAAG;AACrC,UAAMA,UAAS,MAAM,QAAQ,YAAY,MAAM,eAAe,GAAG,IAAI,GAAG,GAAG,IAAI;AAC/E,WAAO,mBAAmBA,OAAM;AAAA,EAClC;AAEA,QAAM,SAAS,MAAM,eAAe,GAAG,IAAI;AAC3C,SAAO,mBAAmB,MAAM;AAClC;","names":["result"]}
|
package/dist/hooks.js
CHANGED
package/dist/query-action.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwrap SDK BaseResponse if the result matches the standard shape.
|
|
3
|
+
* The SDK wraps all responses in `{ data: T, status: number, message: string }`.
|
|
4
|
+
* SiteActions previously unwrapped this; queryAction now does it automatically
|
|
5
|
+
* so consumers receive `T` directly.
|
|
6
|
+
*/
|
|
7
|
+
declare function unwrapBaseResponse(raw: unknown): unknown;
|
|
1
8
|
/**
|
|
2
9
|
* Generic server action that routes any SDK method call through the raw
|
|
3
10
|
* SDK client with optional Redis caching. Used internally by
|
|
@@ -8,10 +15,13 @@
|
|
|
8
15
|
* wrapped in the registered cache wrapper (Redis) if one was registered
|
|
9
16
|
* by createServerSite(). Write methods bypass caching.
|
|
10
17
|
*
|
|
18
|
+
* SDK responses wrapped in BaseResponse are automatically unwrapped --
|
|
19
|
+
* consumers receive `T` instead of `{ data: T, status, message }`.
|
|
20
|
+
*
|
|
11
21
|
* @param methodPath Dot-separated SDK method path (e.g. "items.invMast.doc.get")
|
|
12
22
|
* @param args Arguments to pass to the resolved method
|
|
13
|
-
* @returns The
|
|
23
|
+
* @returns The unwrapped result from the SDK method (possibly from Redis cache)
|
|
14
24
|
*/
|
|
15
25
|
declare function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown>;
|
|
16
26
|
|
|
17
|
-
export { queryAction };
|
|
27
|
+
export { queryAction, unwrapBaseResponse };
|
package/dist/query-action.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import {
|
|
3
|
-
queryAction
|
|
4
|
-
|
|
3
|
+
queryAction,
|
|
4
|
+
unwrapBaseResponse
|
|
5
|
+
} from "./chunk-YHI2PFKJ.js";
|
|
5
6
|
import "./chunk-XSM747FM.js";
|
|
6
7
|
import "./chunk-DGUM43GV.js";
|
|
7
8
|
export {
|
|
8
|
-
queryAction
|
|
9
|
+
queryAction,
|
|
10
|
+
unwrapBaseResponse
|
|
9
11
|
};
|
|
10
12
|
//# sourceMappingURL=query-action.js.map
|
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.9",
|
|
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.9",
|
|
58
|
+
"@simpleapps-com/augur-hooks": "2.2.9",
|
|
59
|
+
"@simpleapps-com/augur-utils": "2.2.9"
|
|
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.9"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "tsup",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query-action.ts"],"sourcesContent":["// \"use server\" banner is injected by tsup at build time.\n// Isolated server action for the proxy pattern.\n// This file MUST NOT import from server-actions.ts, server-site-registry.ts,\n// cache/, or any factory. It imports only from lightweight stores with zero\n// deps, plus augur-core (external in tsup — not bundled into chunks).\n\nimport { getSdkClientOrNull, getSdkCallWrapper } from \"./sdk-client-store\";\nimport { isReadMethod } from \"@simpleapps-com/augur-core\";\n\n/**\n * Generic server action that routes any SDK method call through the raw\n * SDK client with optional Redis caching. Used internally by\n * `createServerQueryProxy()` to bridge client-side React Query hooks\n * to server-side API calls.\n *\n * For read methods (get, list, lookup, search, suggest), the call is\n * wrapped in the registered cache wrapper (Redis) if one was registered\n * by createServerSite(). Write methods bypass caching.\n *\n * @param methodPath Dot-separated SDK method path (e.g. \"items.invMast.doc.get\")\n * @param args Arguments to pass to the resolved method\n * @returns The raw result from the SDK method (possibly from Redis cache)\n */\nexport async function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown> {\n const client = getSdkClientOrNull();\n if (!client) {\n throw new Error(\n \"SDK client not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars.\",\n );\n }\n const segments = methodPath.split(\".\");\n\n let current: unknown = client;\n for (const segment of segments) {\n if (current == null || (typeof current !== \"object\" && typeof current !== \"function\")) {\n throw new Error(\n `Cannot resolve \"${methodPath}\": \"${segment}\" is not accessible on ${typeof current}`,\n );\n }\n current = (current as Record<string, unknown>)[segment];\n }\n\n if (typeof current !== \"function\") {\n throw new Error(`\"${methodPath}\" does not resolve to a function (got ${typeof current})`);\n }\n\n const resolvedMethod = current as (...a: unknown[]) => Promise<unknown>;\n const leafName = segments[segments.length - 1]!;\n const wrapper = getSdkCallWrapper();\n\n // Read methods get Redis caching via the registered wrapper\n if (wrapper && isReadMethod(leafName)) {\n return wrapper(methodPath, () => resolvedMethod(...args), ...args);\n }\n\n return resolvedMethod(...args);\n}\n"],"mappings":";;;;;;AAOA,SAAS,oBAAoB;AAgB7B,eAAsB,YAAY,eAAuB,MAAmC;AAC1F,QAAM,SAAS,mBAAmB;AAClC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,WAAW,MAAM,GAAG;AAErC,MAAI,UAAmB;AACvB,aAAW,WAAW,UAAU;AAC9B,QAAI,WAAW,QAAS,OAAO,YAAY,YAAY,OAAO,YAAY,YAAa;AACrF,YAAM,IAAI;AAAA,QACR,mBAAmB,UAAU,OAAO,OAAO,0BAA0B,OAAO,OAAO;AAAA,MACrF;AAAA,IACF;AACA,cAAW,QAAoC,OAAO;AAAA,EACxD;AAEA,MAAI,OAAO,YAAY,YAAY;AACjC,UAAM,IAAI,MAAM,IAAI,UAAU,yCAAyC,OAAO,OAAO,GAAG;AAAA,EAC1F;AAEA,QAAM,iBAAiB;AACvB,QAAM,WAAW,SAAS,SAAS,SAAS,CAAC;AAC7C,QAAM,UAAU,kBAAkB;AAGlC,MAAI,WAAW,aAAa,QAAQ,GAAG;AACrC,WAAO,QAAQ,YAAY,MAAM,eAAe,GAAG,IAAI,GAAG,GAAG,IAAI;AAAA,EACnE;AAEA,SAAO,eAAe,GAAG,IAAI;AAC/B;","names":[]}
|