@simpleapps-com/augur-server 2.0.8 → 2.0.10
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 +4 -4
- package/dist/auth.js +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/{chunk-RQIWNNTR.js → chunk-XW5ITWCZ.js} +86 -9
- package/dist/chunk-XW5ITWCZ.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -11
- package/dist/index.js.map +1 -1
- package/dist/prefetch.js +1 -0
- package/dist/prefetch.js.map +1 -1
- package/dist/query.js +1 -0
- package/dist/{server-site-registry-C76mQOn1.d.ts → server-site-registry-HoJ5dPLU.d.ts} +6 -1
- package/dist/site.js +4 -6
- package/dist/site.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-6T2IRPPO.js +0 -34
- package/dist/chunk-6T2IRPPO.js.map +0 -1
- package/dist/chunk-QRCB7P2N.js +0 -23
- package/dist/chunk-QRCB7P2N.js.map +0 -1
- package/dist/chunk-RQIWNNTR.js.map +0 -1
package/dist/actions.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import {
|
|
3
|
+
getSiteActions,
|
|
3
4
|
safeAction
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
} from "./chunk-QRCB7P2N.js";
|
|
5
|
+
} from "./chunk-XW5ITWCZ.js";
|
|
6
|
+
import "./chunk-XGRQ53P2.js";
|
|
7
|
+
import "./chunk-DGUM43GV.js";
|
|
8
8
|
|
|
9
9
|
// src/server-actions.ts
|
|
10
10
|
function siteAction(fn) {
|
package/dist/auth.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-DGUM43GV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
batchFetch
|
|
3
3
|
} from "./chunk-XGRQ53P2.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
__require
|
|
6
|
+
} from "./chunk-DGUM43GV.js";
|
|
7
7
|
|
|
8
8
|
// src/environment.ts
|
|
9
9
|
function getEnvironment() {
|
|
@@ -128,6 +128,32 @@ function isRedisConnected() {
|
|
|
128
128
|
return state.client?.status === "ready";
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
// src/sdk-call.ts
|
|
132
|
+
import { unwrap, unwrapOr } from "@simpleapps-com/augur-utils";
|
|
133
|
+
async function sdkCall(method, ...args) {
|
|
134
|
+
return method(...args);
|
|
135
|
+
}
|
|
136
|
+
function toListResult(response) {
|
|
137
|
+
return {
|
|
138
|
+
data: response.data,
|
|
139
|
+
total: response.total ?? 0,
|
|
140
|
+
count: response.count,
|
|
141
|
+
totalResults: response.totalResults,
|
|
142
|
+
message: response.message,
|
|
143
|
+
status: response.status
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async function safeAction(fn, onError) {
|
|
147
|
+
try {
|
|
148
|
+
const data = await fn();
|
|
149
|
+
return { ok: true, data };
|
|
150
|
+
} catch (e) {
|
|
151
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
152
|
+
if (onError) onError(error);
|
|
153
|
+
return { ok: false, error: error.message };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
131
157
|
// src/cache/with-cache.ts
|
|
132
158
|
import { buildCacheKey } from "@simpleapps-com/augur-core";
|
|
133
159
|
async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
@@ -859,7 +885,7 @@ function createJoomlaActions(api, config = {}) {
|
|
|
859
885
|
raw.customerId ?? raw["customer_id"] ?? raw["p21_customer_id"] ?? ""
|
|
860
886
|
);
|
|
861
887
|
const groups = Array.isArray(raw.groups) ? raw.groups : [];
|
|
862
|
-
const permissions = groups.map((
|
|
888
|
+
const permissions = groups.map((g3) => String(g3["title"] ?? g3["name"] ?? "")).filter(Boolean);
|
|
863
889
|
return {
|
|
864
890
|
id: String(raw.id ?? userId),
|
|
865
891
|
name: String(raw.name ?? ""),
|
|
@@ -1321,7 +1347,14 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1321
1347
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1322
1348
|
await api.payments.unified.validate.get(withMode(params))
|
|
1323
1349
|
);
|
|
1324
|
-
|
|
1350
|
+
const raw = response.data;
|
|
1351
|
+
if (typeof raw === "boolean") {
|
|
1352
|
+
return { valid: raw };
|
|
1353
|
+
}
|
|
1354
|
+
if (typeof raw === "object" && raw !== null && "valid" in raw) {
|
|
1355
|
+
return raw;
|
|
1356
|
+
}
|
|
1357
|
+
return { valid: Boolean(raw) };
|
|
1325
1358
|
} catch {
|
|
1326
1359
|
return void 0;
|
|
1327
1360
|
}
|
|
@@ -2491,17 +2524,17 @@ function createSiteActions(api, config = {}) {
|
|
|
2491
2524
|
};
|
|
2492
2525
|
const proxyFallback = createActionsProxy(api, {
|
|
2493
2526
|
cachePrefix,
|
|
2494
|
-
wrapCall: async ({ methodPath, args, sdkCall, tier, isRead: read }) => {
|
|
2527
|
+
wrapCall: async ({ methodPath, args, sdkCall: sdkCall2, tier, isRead: read }) => {
|
|
2495
2528
|
if (read && tier.redisTtl) {
|
|
2496
2529
|
return withServerCache(
|
|
2497
2530
|
cachePrefix,
|
|
2498
2531
|
tier.redisTtl,
|
|
2499
2532
|
methodPath,
|
|
2500
|
-
() =>
|
|
2533
|
+
() => sdkCall2(...args),
|
|
2501
2534
|
...args
|
|
2502
2535
|
);
|
|
2503
2536
|
}
|
|
2504
|
-
return
|
|
2537
|
+
return sdkCall2(...args);
|
|
2505
2538
|
}
|
|
2506
2539
|
});
|
|
2507
2540
|
const wrappedCache = /* @__PURE__ */ new Map();
|
|
@@ -2533,6 +2566,42 @@ function createSiteActions(api, config = {}) {
|
|
|
2533
2566
|
});
|
|
2534
2567
|
}
|
|
2535
2568
|
|
|
2569
|
+
// src/server-site-registry.ts
|
|
2570
|
+
var g2 = globalThis;
|
|
2571
|
+
var _cachedActions = null;
|
|
2572
|
+
function registerSiteActions(actions) {
|
|
2573
|
+
_cachedActions = actions;
|
|
2574
|
+
g2.__augur_site_actions = actions;
|
|
2575
|
+
}
|
|
2576
|
+
function autoInitFromEnv() {
|
|
2577
|
+
const siteId = process.env["AUGUR_SITE_ID"];
|
|
2578
|
+
const bearerToken = process.env["AUGUR_JWT"];
|
|
2579
|
+
if (!siteId || !bearerToken) return null;
|
|
2580
|
+
const { AugurAPI } = __require("@simpleapps-com/augur-api");
|
|
2581
|
+
const api = new AugurAPI({ siteId, bearerToken });
|
|
2582
|
+
const actions = createSiteActions(api);
|
|
2583
|
+
registerSiteActions(actions);
|
|
2584
|
+
return actions;
|
|
2585
|
+
}
|
|
2586
|
+
function getSiteActions() {
|
|
2587
|
+
const actions = g2.__augur_site_actions ?? _cachedActions;
|
|
2588
|
+
if (actions) {
|
|
2589
|
+
if (!g2.__augur_site_actions) {
|
|
2590
|
+
g2.__augur_site_actions = actions;
|
|
2591
|
+
}
|
|
2592
|
+
return actions;
|
|
2593
|
+
}
|
|
2594
|
+
const autoInit = autoInitFromEnv();
|
|
2595
|
+
if (autoInit) return autoInit;
|
|
2596
|
+
throw new Error(
|
|
2597
|
+
"Server actions not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars."
|
|
2598
|
+
);
|
|
2599
|
+
}
|
|
2600
|
+
function clearSiteActions() {
|
|
2601
|
+
_cachedActions = null;
|
|
2602
|
+
g2.__augur_site_actions = void 0;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2536
2605
|
export {
|
|
2537
2606
|
env,
|
|
2538
2607
|
isDev,
|
|
@@ -2542,6 +2611,11 @@ export {
|
|
|
2542
2611
|
cacheSet,
|
|
2543
2612
|
getCircuitState,
|
|
2544
2613
|
isRedisConnected,
|
|
2614
|
+
sdkCall,
|
|
2615
|
+
toListResult,
|
|
2616
|
+
safeAction,
|
|
2617
|
+
unwrap,
|
|
2618
|
+
unwrapOr,
|
|
2545
2619
|
withServerCache,
|
|
2546
2620
|
paginateOffset,
|
|
2547
2621
|
createPricingActions,
|
|
@@ -2571,6 +2645,9 @@ export {
|
|
|
2571
2645
|
createBrandFolderActions,
|
|
2572
2646
|
createGregorovichActions,
|
|
2573
2647
|
createSlackActions,
|
|
2574
|
-
createSiteActions
|
|
2648
|
+
createSiteActions,
|
|
2649
|
+
registerSiteActions,
|
|
2650
|
+
getSiteActions,
|
|
2651
|
+
clearSiteActions
|
|
2575
2652
|
};
|
|
2576
|
-
//# sourceMappingURL=chunk-
|
|
2653
|
+
//# sourceMappingURL=chunk-XW5ITWCZ.js.map
|