@simpleapps-com/augur-server 2.2.6 → 2.2.8
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 +3 -3
- package/dist/chunk-BCS5Q2MG.js +40 -0
- package/dist/chunk-BCS5Q2MG.js.map +1 -0
- package/dist/{chunk-3N37FS5N.js → chunk-OJZBX6L4.js} +38 -6
- package/dist/chunk-OJZBX6L4.js.map +1 -0
- package/dist/chunk-XSM747FM.js +33 -0
- package/dist/chunk-XSM747FM.js.map +1 -0
- package/dist/hooks.js +2 -2
- package/dist/index.js +2 -2
- package/dist/query-action.d.ts +9 -4
- package/dist/query-action.js +2 -2
- package/dist/site.js +16 -3
- package/dist/site.js.map +1 -1
- package/dist/testing.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-3N37FS5N.js.map +0 -1
- package/dist/chunk-EYMB52E5.js +0 -28
- package/dist/chunk-EYMB52E5.js.map +0 -1
- package/dist/chunk-GP6W4BV3.js +0 -32
- package/dist/chunk-GP6W4BV3.js.map +0 -1
package/dist/actions.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import {
|
|
3
3
|
queryAction
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BCS5Q2MG.js";
|
|
5
5
|
import {
|
|
6
6
|
getSiteActions,
|
|
7
7
|
safeAction
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-OJZBX6L4.js";
|
|
9
|
+
import "./chunk-XSM747FM.js";
|
|
10
10
|
import "./chunk-DGUM43GV.js";
|
|
11
11
|
|
|
12
12
|
// src/server-actions.ts
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSdkCallWrapper,
|
|
3
|
+
getSdkClientOrNull
|
|
4
|
+
} from "./chunk-XSM747FM.js";
|
|
5
|
+
|
|
6
|
+
// src/query-action.ts
|
|
7
|
+
import { isReadMethod } from "@simpleapps-com/augur-core";
|
|
8
|
+
async function queryAction(methodPath, ...args) {
|
|
9
|
+
const client = getSdkClientOrNull();
|
|
10
|
+
if (!client) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"SDK client not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars."
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
const segments = methodPath.split(".");
|
|
16
|
+
let current = client;
|
|
17
|
+
for (const segment of segments) {
|
|
18
|
+
if (current == null || typeof current !== "object" && typeof current !== "function") {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Cannot resolve "${methodPath}": "${segment}" is not accessible on ${typeof current}`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
current = current[segment];
|
|
24
|
+
}
|
|
25
|
+
if (typeof current !== "function") {
|
|
26
|
+
throw new Error(`"${methodPath}" does not resolve to a function (got ${typeof current})`);
|
|
27
|
+
}
|
|
28
|
+
const resolvedMethod = current;
|
|
29
|
+
const leafName = segments[segments.length - 1];
|
|
30
|
+
const wrapper = getSdkCallWrapper();
|
|
31
|
+
if (wrapper && isReadMethod(leafName)) {
|
|
32
|
+
return wrapper(methodPath, () => resolvedMethod(...args), ...args);
|
|
33
|
+
}
|
|
34
|
+
return resolvedMethod(...args);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
queryAction
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-BCS5Q2MG.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 * 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":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./chunk-EYMB52E5.js";
|
|
2
|
+
registerSdkCallWrapper,
|
|
3
|
+
registerSdkClient
|
|
4
|
+
} from "./chunk-XSM747FM.js";
|
|
6
5
|
import {
|
|
7
6
|
__require
|
|
8
7
|
} from "./chunk-DGUM43GV.js";
|
|
@@ -911,7 +910,7 @@ function createJoomlaActions(api, config = {}) {
|
|
|
911
910
|
raw["customerId"] ?? raw["customer_id"] ?? raw["p21_customer_id"] ?? ""
|
|
912
911
|
);
|
|
913
912
|
const groups = Array.isArray(raw["groups"]) ? raw["groups"] : [];
|
|
914
|
-
const permissions = groups.map((
|
|
913
|
+
const permissions = groups.map((g3) => String(g3["title"] ?? g3["name"] ?? "")).filter(Boolean);
|
|
915
914
|
return {
|
|
916
915
|
id: String(raw["id"] ?? userId),
|
|
917
916
|
name: String(raw["name"] ?? ""),
|
|
@@ -2690,10 +2689,42 @@ function createSiteActions(api, config = {}) {
|
|
|
2690
2689
|
});
|
|
2691
2690
|
}
|
|
2692
2691
|
|
|
2692
|
+
// src/site-actions-store.ts
|
|
2693
|
+
var g2 = globalThis;
|
|
2694
|
+
var _cachedActions = null;
|
|
2695
|
+
function registerSiteActions(actions) {
|
|
2696
|
+
_cachedActions = actions;
|
|
2697
|
+
g2.__augur_site_actions = actions;
|
|
2698
|
+
}
|
|
2699
|
+
function getSiteActionsOrNull() {
|
|
2700
|
+
const actions = g2.__augur_site_actions ?? _cachedActions;
|
|
2701
|
+
if (actions) {
|
|
2702
|
+
if (!g2.__augur_site_actions) {
|
|
2703
|
+
g2.__augur_site_actions = actions;
|
|
2704
|
+
}
|
|
2705
|
+
return actions;
|
|
2706
|
+
}
|
|
2707
|
+
return null;
|
|
2708
|
+
}
|
|
2709
|
+
function clearSiteActions() {
|
|
2710
|
+
_cachedActions = null;
|
|
2711
|
+
g2.__augur_site_actions = void 0;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2693
2714
|
// src/server-site-registry.ts
|
|
2715
|
+
import { getCacheTier } from "@simpleapps-com/augur-core";
|
|
2694
2716
|
function registerSiteActions2(actions) {
|
|
2695
2717
|
registerSiteActions(actions);
|
|
2696
2718
|
}
|
|
2719
|
+
function registerClientAndWrapper(api) {
|
|
2720
|
+
registerSdkClient(api);
|
|
2721
|
+
registerSdkCallWrapper((methodPath, sdkCall2, ...keyArgs) => {
|
|
2722
|
+
const tier = getCacheTier(methodPath);
|
|
2723
|
+
if (tier.staleTime === 0) return sdkCall2();
|
|
2724
|
+
const ttl = tier.staleTime >= 36e5 ? 28800 : 3600;
|
|
2725
|
+
return withServerCache("", ttl, methodPath, sdkCall2, ...keyArgs);
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2697
2728
|
function autoInitFromEnv() {
|
|
2698
2729
|
const siteId = process.env["AUGUR_SITE_ID"];
|
|
2699
2730
|
const bearerToken = process.env["AUGUR_JWT"];
|
|
@@ -2702,6 +2733,7 @@ function autoInitFromEnv() {
|
|
|
2702
2733
|
const api = new AugurAPI({ siteId, bearerToken });
|
|
2703
2734
|
const actions = createSiteActions(api);
|
|
2704
2735
|
registerSiteActions2(actions);
|
|
2736
|
+
registerClientAndWrapper(api);
|
|
2705
2737
|
return actions;
|
|
2706
2738
|
}
|
|
2707
2739
|
function getSiteActions() {
|
|
@@ -2738,4 +2770,4 @@ export {
|
|
|
2738
2770
|
getSiteActions,
|
|
2739
2771
|
clearSiteActions2 as clearSiteActions
|
|
2740
2772
|
};
|
|
2741
|
-
//# sourceMappingURL=chunk-
|
|
2773
|
+
//# sourceMappingURL=chunk-OJZBX6L4.js.map
|