@simpleapps-com/augur-server 2.0.8 → 2.0.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
@@ -1,10 +1,10 @@
1
1
  "use server";
2
2
  import {
3
+ getSiteActions,
3
4
  safeAction
4
- } from "./chunk-6T2IRPPO.js";
5
- import {
6
- getSiteActions
7
- } from "./chunk-QRCB7P2N.js";
5
+ } from "./chunk-L25NLWJU.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
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  createAuthConfig
3
3
  } from "./chunk-R3XT54FD.js";
4
+ import "./chunk-DGUM43GV.js";
4
5
  export {
5
6
  createAuthConfig
6
7
  };
@@ -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
- toListResult
6
- } from "./chunk-6T2IRPPO.js";
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((g2) => String(g2["title"] ?? g2["name"] ?? "")).filter(Boolean);
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 ?? ""),
@@ -2491,17 +2517,17 @@ function createSiteActions(api, config = {}) {
2491
2517
  };
2492
2518
  const proxyFallback = createActionsProxy(api, {
2493
2519
  cachePrefix,
2494
- wrapCall: async ({ methodPath, args, sdkCall, tier, isRead: read }) => {
2520
+ wrapCall: async ({ methodPath, args, sdkCall: sdkCall2, tier, isRead: read }) => {
2495
2521
  if (read && tier.redisTtl) {
2496
2522
  return withServerCache(
2497
2523
  cachePrefix,
2498
2524
  tier.redisTtl,
2499
2525
  methodPath,
2500
- () => sdkCall(...args),
2526
+ () => sdkCall2(...args),
2501
2527
  ...args
2502
2528
  );
2503
2529
  }
2504
- return sdkCall(...args);
2530
+ return sdkCall2(...args);
2505
2531
  }
2506
2532
  });
2507
2533
  const wrappedCache = /* @__PURE__ */ new Map();
@@ -2533,6 +2559,42 @@ function createSiteActions(api, config = {}) {
2533
2559
  });
2534
2560
  }
2535
2561
 
2562
+ // src/server-site-registry.ts
2563
+ var g2 = globalThis;
2564
+ var _cachedActions = null;
2565
+ function registerSiteActions(actions) {
2566
+ _cachedActions = actions;
2567
+ g2.__augur_site_actions = actions;
2568
+ }
2569
+ function autoInitFromEnv() {
2570
+ const siteId = process.env["AUGUR_SITE_ID"];
2571
+ const bearerToken = process.env["AUGUR_JWT"];
2572
+ if (!siteId || !bearerToken) return null;
2573
+ const { AugurAPI } = __require("@simpleapps-com/augur-api");
2574
+ const api = new AugurAPI({ siteId, bearerToken });
2575
+ const actions = createSiteActions(api);
2576
+ registerSiteActions(actions);
2577
+ return actions;
2578
+ }
2579
+ function getSiteActions() {
2580
+ const actions = g2.__augur_site_actions ?? _cachedActions;
2581
+ if (actions) {
2582
+ if (!g2.__augur_site_actions) {
2583
+ g2.__augur_site_actions = actions;
2584
+ }
2585
+ return actions;
2586
+ }
2587
+ const autoInit = autoInitFromEnv();
2588
+ if (autoInit) return autoInit;
2589
+ throw new Error(
2590
+ "Server actions not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars."
2591
+ );
2592
+ }
2593
+ function clearSiteActions() {
2594
+ _cachedActions = null;
2595
+ g2.__augur_site_actions = void 0;
2596
+ }
2597
+
2536
2598
  export {
2537
2599
  env,
2538
2600
  isDev,
@@ -2542,6 +2604,11 @@ export {
2542
2604
  cacheSet,
2543
2605
  getCircuitState,
2544
2606
  isRedisConnected,
2607
+ sdkCall,
2608
+ toListResult,
2609
+ safeAction,
2610
+ unwrap,
2611
+ unwrapOr,
2545
2612
  withServerCache,
2546
2613
  paginateOffset,
2547
2614
  createPricingActions,
@@ -2571,6 +2638,9 @@ export {
2571
2638
  createBrandFolderActions,
2572
2639
  createGregorovichActions,
2573
2640
  createSlackActions,
2574
- createSiteActions
2641
+ createSiteActions,
2642
+ registerSiteActions,
2643
+ getSiteActions,
2644
+ clearSiteActions
2575
2645
  };
2576
- //# sourceMappingURL=chunk-RQIWNNTR.js.map
2646
+ //# sourceMappingURL=chunk-L25NLWJU.js.map