@simpleapps-com/augur-server 2026.11.2 → 2026.11.4
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/EXPORTS.md +3 -2
- package/README.md +17 -12
- package/dist/api-handler.d.ts +2 -1
- package/dist/api-handler.d.ts.map +1 -1
- package/dist/api.js +12 -9
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/{chunk-LX7SJJOU.js → chunk-34NCJS52.js} +4 -6
- package/dist/{chunk-LX7SJJOU.js.map → chunk-34NCJS52.js.map} +1 -1
- package/dist/{chunk-OBWQSGB6.js → chunk-B4MGIUCU.js} +133 -6
- package/dist/chunk-B4MGIUCU.js.map +1 -0
- package/dist/{chunk-INVDQQ7T.js → chunk-F7QWHMHH.js} +7 -3
- package/dist/chunk-F7QWHMHH.js.map +1 -0
- package/dist/{chunk-UVGG74FO.js → chunk-WR7WT2FI.js} +17 -12
- package/dist/chunk-WR7WT2FI.js.map +1 -0
- package/dist/hooks.js +2 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/query-action.d.ts +24 -98
- package/dist/query-action.d.ts.map +1 -1
- package/dist/query-action.js +4 -3
- package/dist/rules.d.ts +42 -4
- package/dist/rules.d.ts.map +1 -1
- package/dist/sdk-client-store.d.ts +8 -0
- package/dist/sdk-client-store.d.ts.map +1 -1
- package/dist/server-site.d.ts +8 -0
- package/dist/server-site.d.ts.map +1 -1
- package/dist/site.js +14 -10
- package/dist/site.js.map +1 -1
- package/dist/testing.js +2 -3
- package/dist/testing.js.map +1 -1
- package/llms.txt +3 -2
- package/package.json +2 -2
- package/dist/chunk-A4IVBK6P.js +0 -103
- package/dist/chunk-A4IVBK6P.js.map +0 -1
- package/dist/chunk-INVDQQ7T.js.map +0 -1
- package/dist/chunk-OBWQSGB6.js.map +0 -1
- package/dist/chunk-UVGG74FO.js.map +0 -1
package/dist/hooks.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
queryAction
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-OBWQSGB6.js";
|
|
4
|
+
} from "./chunk-WR7WT2FI.js";
|
|
5
|
+
import "./chunk-B4MGIUCU.js";
|
|
7
6
|
|
|
8
7
|
// src/hooks.ts
|
|
9
8
|
import { createQueryActionProxy } from "@simpleapps-com/augur-core";
|
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 { createQueryActionProxy } from \"@simpleapps-com/augur-core\";\nimport type {\n DeepQueryOptions,\n OptionsProxyConfig,\n QueryActionFn,\n} from \"@simpleapps-com/augur-core\";\nimport type { AugurAPI } from \"@simpleapps-com/augur-api\";\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.list({ itemId, customerId }));\n *\n * // Infinite queries — spread and add infinite-specific options\n * const { data, fetchNextPage } = useInfiniteQuery({\n * ...q.items.categories.items.list(itemCategoryUid, filters),\n * getNextPageParam: (lastPage, pages) => nextOffset(lastPage, pages), // the site's paging rule\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 = AugurAPI>(\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":"
|
|
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 type { AugurAPI } from \"@simpleapps-com/augur-api\";\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.list({ itemId, customerId }));\n *\n * // Infinite queries — spread and add infinite-specific options\n * const { data, fetchNextPage } = useInfiniteQuery({\n * ...q.items.categories.items.list(itemCategoryUid, filters),\n * getNextPageParam: (lastPage, pages) => nextOffset(lastPage, pages), // the site's paging rule\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 = AugurAPI>(\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;AAOvC,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/dist/index.js
CHANGED
|
@@ -21,11 +21,10 @@ import {
|
|
|
21
21
|
unwrap,
|
|
22
22
|
unwrapOr,
|
|
23
23
|
withServerCache
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-A4IVBK6P.js";
|
|
24
|
+
} from "./chunk-34NCJS52.js";
|
|
26
25
|
import {
|
|
27
26
|
recaptchaOk
|
|
28
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-B4MGIUCU.js";
|
|
29
28
|
|
|
30
29
|
// src/server-query-client.ts
|
|
31
30
|
import { cache } from "react";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server-query-client.ts","../src/recaptcha.ts"],"sourcesContent":["import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * - No GC timers (gcTime: Infinity), so the client is freed with the request\n * - No retries (fail fast on server)\n * - No refetching (server renders are one-shot)\n */\nexport function createServerQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: CACHE_CONFIG.STATIC.staleTime,\n // Infinity = no GC timer. A finite value pins this per-request client\n // (and its whole cache) in memory until the timer fires (#481).\n gcTime: Infinity,\n retry: 0,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n },\n });\n}\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so each request gets its own QueryClient while avoiding the cross-request\n * state leakage that a module-level singleton would cause.\n */\nexport const getServerQueryClient = cache((): QueryClient => createServerQueryClient());\n","import { recaptchaOk } from \"./rules\";\n\n/**\n * Server-side Google reCAPTCHA v3 verification.\n * Used by API routes that accept public form submissions.\n */\nexport async function verifyRecaptcha(token: string): Promise<boolean> {\n try {\n const secretKey = process.env[\"RECAPTCHA_SECRET_KEY\"];\n if (!secretKey) return recaptchaOk(false, false, undefined);\n\n const res = await fetch(\"https://www.google.com/recaptcha/api/siteverify\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({ secret: secretKey, response: token }),\n });\n if (!res.ok) {\n console.error(\"reCAPTCHA verify failed:\", res.status);\n return recaptchaOk(true, false, undefined);\n }\n const result = (await res.json()) as { success?: boolean };\n return recaptchaOk(true, true, result.success);\n } catch (error) {\n console.error(\"reCAPTCHA verify error:\", error);\n return false;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/server-query-client.ts","../src/recaptcha.ts"],"sourcesContent":["import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * - No GC timers (gcTime: Infinity), so the client is freed with the request\n * - No retries (fail fast on server)\n * - No refetching (server renders are one-shot)\n */\nexport function createServerQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: CACHE_CONFIG.STATIC.staleTime,\n // Infinity = no GC timer. A finite value pins this per-request client\n // (and its whole cache) in memory until the timer fires (#481).\n gcTime: Infinity,\n retry: 0,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n },\n });\n}\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so each request gets its own QueryClient while avoiding the cross-request\n * state leakage that a module-level singleton would cause.\n */\nexport const getServerQueryClient = cache((): QueryClient => createServerQueryClient());\n","import { recaptchaOk } from \"./rules\";\n\n/**\n * Server-side Google reCAPTCHA v3 verification.\n * Used by API routes that accept public form submissions.\n */\nexport async function verifyRecaptcha(token: string): Promise<boolean> {\n try {\n const secretKey = process.env[\"RECAPTCHA_SECRET_KEY\"];\n if (!secretKey) return recaptchaOk(false, false, undefined);\n\n const res = await fetch(\"https://www.google.com/recaptcha/api/siteverify\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({ secret: secretKey, response: token }),\n });\n if (!res.ok) {\n console.error(\"reCAPTCHA verify failed:\", res.status);\n return recaptchaOk(true, false, undefined);\n }\n const result = (await res.json()) as { success?: boolean };\n return recaptchaOk(true, true, result.success);\n } catch (error) {\n console.error(\"reCAPTCHA verify error:\", error);\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAUtB,SAAS,0BAAuC;AACrD,SAAO,IAAI,YAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,aAAa,OAAO;AAAA;AAAA;AAAA,QAG/B,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,gBAAgB;AAAA,QAChB,sBAAsB;AAAA,QACtB,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AASO,IAAM,uBAAuB,MAAM,MAAmB,wBAAwB,CAAC;;;AC9BtF,eAAsB,gBAAgB,OAAiC;AACrE,MAAI;AACF,UAAM,YAAY,QAAQ,IAAI,sBAAsB;AACpD,QAAI,CAAC,UAAW,QAAO,YAAY,OAAO,OAAO,MAAS;AAE1D,UAAM,MAAM,MAAM,MAAM,mDAAmD;AAAA,MACzE,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,oCAAoC;AAAA,MAC/D,MAAM,IAAI,gBAAgB,EAAE,QAAQ,WAAW,UAAU,MAAM,CAAC;AAAA,IAClE,CAAC;AACD,QAAI,CAAC,IAAI,IAAI;AACX,cAAQ,MAAM,4BAA4B,IAAI,MAAM;AACpD,aAAO,YAAY,MAAM,OAAO,MAAS;AAAA,IAC3C;AACA,UAAM,SAAU,MAAM,IAAI,KAAK;AAC/B,WAAO,YAAY,MAAM,MAAM,OAAO,OAAO;AAAA,EAC/C,SAAS,OAAO;AACd,YAAQ,MAAM,2BAA2B,KAAK;AAC9C,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/query-action.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type SessionCredentials, type ApprovedMethodPath } from "./sdk-client-store";
|
|
2
2
|
import { unwrapBaseResponse } from "@simpleapps-com/augur-core";
|
|
3
|
+
import { type BaseResponse } from "@simpleapps-com/augur-api";
|
|
3
4
|
/**
|
|
4
5
|
* Resolve session credentials from the Auth.js JWT cookie.
|
|
5
6
|
*
|
|
@@ -12,6 +13,9 @@ import { unwrapBaseResponse } from "@simpleapps-com/augur-core";
|
|
|
12
13
|
* do it), so audit casts (see "Brand strength" below).
|
|
13
14
|
*
|
|
14
15
|
* Returns null when:
|
|
16
|
+
* - the site did not opt in to cross-site sessions (`createServerSite`'s
|
|
17
|
+
* `auth: { crossSite: true }`, atlas#105): then nothing is imported and no
|
|
18
|
+
* cookie is read, so pages using queryAction can render statically
|
|
15
19
|
* - no AUTH_SECRET is configured
|
|
16
20
|
* - next-auth/jwt, next/headers, or jose cannot be loaded
|
|
17
21
|
* - no session cookie is present
|
|
@@ -65,93 +69,7 @@ declare function getSessionCredentials(): Promise<SessionCredentials | null>;
|
|
|
65
69
|
*/
|
|
66
70
|
declare function resolveMethod(client: unknown, methodPath: ApprovedMethodPath): (...a: unknown[]) => Promise<unknown>;
|
|
67
71
|
/**
|
|
68
|
-
*
|
|
69
|
-
* SDK client with optional Redis caching. Used internally by
|
|
70
|
-
* `createServerQueryProxy()` to bridge client-side React Query hooks
|
|
71
|
-
* to server-side API calls.
|
|
72
|
-
*
|
|
73
|
-
* For read methods (get, list, lookup, search, suggest), the call is
|
|
74
|
-
* wrapped in the registered cache wrapper (Redis) if one was registered
|
|
75
|
-
* by createServerSite(). Write methods bypass caching.
|
|
76
|
-
*
|
|
77
|
-
* When the request has an active session with targetSiteId + token
|
|
78
|
-
* (from cross-site auth), the call uses a scoped SDK client with those
|
|
79
|
-
* credentials. Redis caching uses targetSiteId as the cache prefix so
|
|
80
|
-
* users managing the same site share cached data.
|
|
81
|
-
*
|
|
82
|
-
* SDK responses wrapped in BaseResponse are automatically unwrapped --
|
|
83
|
-
* consumers receive `T` instead of `{ data: T, status, message }`.
|
|
84
|
-
*
|
|
85
|
-
* This is the chokepoint: every B2B site without a client-side SDK
|
|
86
|
-
* routes EVERY data access through this one function. The invariants
|
|
87
|
-
* below are load-bearing across every site, every request, every user.
|
|
88
|
-
*
|
|
89
|
-
* ## Preconditions (enforced at runtime via thrown Error)
|
|
90
|
-
*
|
|
91
|
-
* parseMethodPath(methodPath) ≠ null
|
|
92
|
-
* resolveClient().client ≠ null
|
|
93
|
-
*
|
|
94
|
-
* First clause: methodPath is a non-empty string AND — if an allowlist
|
|
95
|
-
* has been registered via `registerAllowedMethodPaths` — methodPath is
|
|
96
|
-
* in the allowlist. Assumes the site opted into surface restriction
|
|
97
|
-
* when narrower-than-augur-api authority is desired; otherwise any
|
|
98
|
-
* non-empty string passes (transparent forwarder default).
|
|
99
|
-
*
|
|
100
|
-
* Second clause: createServerSite() ran during bootstrap OR
|
|
101
|
-
* AUGUR_SITE_ID + AUGUR_JWT env vars are set so the registry can
|
|
102
|
-
* auto-init. Assumes the caller has bootstrapped one of the two paths.
|
|
103
|
-
*
|
|
104
|
-
* Lean equivalent: `requires path : ApprovedMethodPath ∧ client : SDKClient`.
|
|
105
|
-
*
|
|
106
|
-
* ## Cross-tenant cache-prefix invariant (load-bearing)
|
|
107
|
-
*
|
|
108
|
-
* resolution.kind = "scoped" ⟹ cachePrefix = `${resolution.credentials.siteId}:`
|
|
109
|
-
*
|
|
110
|
-
* On the scoped path the cache prefix is derived structurally from the
|
|
111
|
-
* same `SessionCredentials` value that minted the scoped client — they
|
|
112
|
-
* cannot be sourced separately. This makes "siteId from session A
|
|
113
|
-
* combined with token from session B" or "siteId X with cache prefix Y"
|
|
114
|
-
* unrepresentable here. Assumes `getSessionCredentials` performed the
|
|
115
|
-
* bearer/session siteId cross-check at mint time; see the brand-strength
|
|
116
|
-
* caveat on `SessionCredentials`.
|
|
117
|
-
*
|
|
118
|
-
* A regression here would silently leak cached data across tenants.
|
|
119
|
-
* The structural derivation is the only thing standing between the
|
|
120
|
-
* request and that leak — do not reintroduce a separate `cachePrefix`
|
|
121
|
-
* parameter or compute it from anything other than `resolution.credentials`.
|
|
122
|
-
*
|
|
123
|
-
* ### Sibling assumption — bearer is NOT in the cache key
|
|
124
|
-
*
|
|
125
|
-
* The cross-tenant invariant covers cross-SITE leaks. It does NOT cover
|
|
126
|
-
* intra-site cross-USER leaks: the cache key is `(siteId, methodPath, args)`
|
|
127
|
-
* and the bearer token is intentionally absent. Two users with different
|
|
128
|
-
* bearers on the same site share cached data for cacheable namespaces.
|
|
129
|
-
*
|
|
130
|
-
* This is a deliberate design choice. The assumption is:
|
|
131
|
-
*
|
|
132
|
-
* ∀ namespace ∉ NO_CACHE_PATHS, ∀ siteId, ∀ args.
|
|
133
|
-
* augur-api(bearer_A, siteId, args) = augur-api(bearer_B, siteId, args)
|
|
134
|
-
*
|
|
135
|
-
* i.e. for cacheable namespaces, augur-api's response is bearer-independent
|
|
136
|
-
* within a site. augur-api remains the auth authority; `NO_CACHE_PATHS`
|
|
137
|
-
* (commerce.*, payments.*) is the carve-out for namespaces whose responses
|
|
138
|
-
* ARE bearer-coupled. If a future namespace produces bearer-dependent
|
|
139
|
-
* responses (e.g. user-specific permissions affecting query results), it
|
|
140
|
-
* MUST be added to `NO_CACHE_PATHS` or the bearer MUST become part of the
|
|
141
|
-
* cache key — otherwise this assumption silently produces a permission leak.
|
|
142
|
-
*
|
|
143
|
-
* ## No-edge-cache defense-in-depth (load-bearing)
|
|
144
|
-
*
|
|
145
|
-
* ∀ a ∈ safeArgs. methodPath ∈ NO_CACHE_PATHS ⟹ "edgeCache" ∉ keys(a)
|
|
146
|
-
*
|
|
147
|
-
* `stripEdgeCacheForNoCachePaths` removes the `edgeCache` key from every
|
|
148
|
-
* first-level object arg when methodPath belongs to a no-cache namespace
|
|
149
|
-
* (currently `commerce.*`, `payments.*`). The augur-api SDK transforms
|
|
150
|
-
* `edgeCache` into a Cloudflare `cacheSiteId{N}` query param; removing
|
|
151
|
-
* it here guarantees no CDN edge-caching of identity-bound responses
|
|
152
|
-
* even if a caller passed one explicitly or a legacy factory injected
|
|
153
|
-
* one. Assumes `NO_CACHE_PATHS` enumerates every namespace whose
|
|
154
|
-
* responses must not cross identity boundaries.
|
|
72
|
+
* The SDK call `callSdk` makes (everything above), answered as its envelope's data.
|
|
155
73
|
*
|
|
156
74
|
* ## Postcondition — BaseResponse pass-through (exactly-once unwrap)
|
|
157
75
|
*
|
|
@@ -161,23 +79,31 @@ declare function resolveMethod(client: unknown, methodPath: ApprovedMethodPath):
|
|
|
161
79
|
*
|
|
162
80
|
* Consumers receive `T` directly when the SDK returns
|
|
163
81
|
* `{ data: T, status, message }`, and the original value otherwise.
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* when that shape happens to round-trip through the API.
|
|
169
|
-
*
|
|
170
|
-
* ## Effects
|
|
171
|
-
*
|
|
172
|
-
* @mutates Redis (write-through on read methods when a wrapper is registered)
|
|
173
|
-
* @io augur-api SDK (network request)
|
|
174
|
-
* @throws Error when the allowlist gate fails or no client is initialised
|
|
82
|
+
* Double-unwrap (caller + queryAction) would silently strip a layer of
|
|
83
|
+
* legitimate `{data, status, message}` user data when that shape happens
|
|
84
|
+
* to round-trip through the API. The envelope's paging (`total`,
|
|
85
|
+
* `totalResults`, `count`) is not in `data`: read it with `queryActionRaw`.
|
|
175
86
|
*
|
|
176
87
|
* @param methodPath Dot-separated SDK method path (e.g. "items.invMast.doc.get")
|
|
177
88
|
* @param args Arguments to pass to the resolved method
|
|
178
89
|
* @returns The unwrapped result from the SDK method (possibly from Redis cache)
|
|
179
90
|
*/
|
|
180
91
|
export declare function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* The same call as `queryAction` (allowlist, client, `edgeCache` strip, Redis), answered as
|
|
94
|
+
* the SDK returned it: augur-api's `BaseResponse<T>` envelope (every SDK method's result) with
|
|
95
|
+
* `data`, `total`, `totalResults` and `count`, so client code can page a list (atlas#107). A
|
|
96
|
+
* method path carries no type, so the caller names `T` (`queryActionRaw<Article[]>(…)`). A
|
|
97
|
+
* `queryAction` and a `queryActionRaw` of one call share one Redis entry.
|
|
98
|
+
*
|
|
99
|
+
* MUST NOT run under a React Query key that also holds `queryAction`'s shape (an options
|
|
100
|
+
* proxy's `queryKey`): give it its own key.
|
|
101
|
+
*
|
|
102
|
+
* @param methodPath Dot-separated SDK method path (e.g. "joomla.content.list")
|
|
103
|
+
* @param args Arguments to pass to the resolved method
|
|
104
|
+
* @returns The SDK method's result unchanged (possibly from Redis cache)
|
|
105
|
+
*/
|
|
106
|
+
export declare function queryActionRaw<T = unknown>(methodPath: string, ...args: unknown[]): Promise<BaseResponse<T>>;
|
|
181
107
|
/** Reset lazy-loaded imports. Used in tests only. @internal */
|
|
182
108
|
export declare function resetSessionImports(): void;
|
|
183
109
|
export { unwrapBaseResponse, getSessionCredentials, resolveMethod };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-action.d.ts","sourceRoot":"","sources":["../src/query-action.ts"],"names":[],"mappings":"AAUA,OAAO,
|
|
1
|
+
{"version":3,"file":"query-action.d.ts","sourceRoot":"","sources":["../src/query-action.ts"],"names":[],"mappings":"AAUA,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAGxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AA+FxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,iBAAe,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA6BzE;AA2DD;;;;;GAKG;AACH,iBAAS,aAAa,CACpB,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,kBAAkB,GAC7B,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAkBvC;AAsLD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,cAAc,CAAC,CAAC,GAAG,OAAO,EAC9C,UAAU,EAAE,MAAM,EAClB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAE1B;AAED,+DAA+D;AAC/D,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C;AAED,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/query-action.js
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
import {
|
|
3
3
|
getSessionCredentials,
|
|
4
4
|
queryAction,
|
|
5
|
+
queryActionRaw,
|
|
5
6
|
resetSessionImports,
|
|
6
7
|
resolveMethod,
|
|
7
8
|
unwrapBaseResponse
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-OBWQSGB6.js";
|
|
9
|
+
} from "./chunk-WR7WT2FI.js";
|
|
10
|
+
import "./chunk-B4MGIUCU.js";
|
|
11
11
|
export {
|
|
12
12
|
getSessionCredentials,
|
|
13
13
|
queryAction,
|
|
14
|
+
queryActionRaw,
|
|
14
15
|
resetSessionImports,
|
|
15
16
|
resolveMethod,
|
|
16
17
|
unwrapBaseResponse
|
package/dist/rules.d.ts
CHANGED
|
@@ -56,8 +56,11 @@ export declare function serverEnvOf(nodeEnv: string): Env;
|
|
|
56
56
|
* @ensures exactly the model's host rule
|
|
57
57
|
*/
|
|
58
58
|
export declare function hostEnvOf(host: string): Env;
|
|
59
|
-
/**
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The API route's outcome for a request: "run" answers queryAction's data, "run-full"
|
|
61
|
+
* queryActionRaw's full response (atlas#107).
|
|
62
|
+
*/
|
|
63
|
+
export type ApiOutcome = "forbidden" | "bad-json" | "bad-method-path" | "bad-args" | "run" | "run-full";
|
|
61
64
|
/**
|
|
62
65
|
* A present, non-empty Sec-Fetch-Site other than same-origin is refused (a missing one, `""`
|
|
63
66
|
* from the caller, passes).
|
|
@@ -66,11 +69,24 @@ export type ApiOutcome = "forbidden" | "bad-json" | "bad-method-path" | "bad-arg
|
|
|
66
69
|
*/
|
|
67
70
|
export declare function isCrossOrigin(fetchSite: string): boolean;
|
|
68
71
|
/**
|
|
69
|
-
* The body's outcome: JSON, then a non-empty methodPath string, then an args array
|
|
72
|
+
* The body's outcome: JSON, then a non-empty methodPath string, then an args array; a valid
|
|
73
|
+
* body with `raw: true` (`full`) runs for the full response, any other for its data.
|
|
70
74
|
*
|
|
71
75
|
* @ensures exactly the model's ApiOutcomeOf past the origin check
|
|
72
76
|
*/
|
|
73
|
-
export declare function bodyOutcomeOf(jsonOk: boolean, methodPathOk: boolean, argsIsArray: boolean): ApiOutcome;
|
|
77
|
+
export declare function bodyOutcomeOf(jsonOk: boolean, methodPathOk: boolean, argsIsArray: boolean, full: boolean): ApiOutcome;
|
|
78
|
+
/**
|
|
79
|
+
* The route runs the call: either view; any other outcome is a refusal.
|
|
80
|
+
*
|
|
81
|
+
* @ensures exactly the model's Runs
|
|
82
|
+
*/
|
|
83
|
+
export declare function runsOf(o: ApiOutcome): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The route answers the full response (queryActionRaw), not its data.
|
|
86
|
+
*
|
|
87
|
+
* @ensures exactly the model's AnswersFull
|
|
88
|
+
*/
|
|
89
|
+
export declare function answersFullOf(o: ApiOutcome): boolean;
|
|
74
90
|
/**
|
|
75
91
|
* An outcome's HTTP status: 403, 400 for a bad body, 200 to run.
|
|
76
92
|
*
|
|
@@ -150,6 +166,28 @@ export declare function positiveOrZero(n: number): number;
|
|
|
150
166
|
* @ensures exactly the model's ItemsLimit, a missing limit as 0
|
|
151
167
|
*/
|
|
152
168
|
export declare function itemsLimitOf(limit: number | undefined): number;
|
|
169
|
+
/**
|
|
170
|
+
* The cross-site opt-in as configured (`auth.crossSite`): on only when set to true, so a site
|
|
171
|
+
* that says nothing stays off (atlas#105).
|
|
172
|
+
*
|
|
173
|
+
* @ensures exactly the model's CrossSiteOf
|
|
174
|
+
*/
|
|
175
|
+
export declare function crossSiteOf(flag: boolean | undefined): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether queryAction looks for a cross-site session (imports next/headers and reads the
|
|
178
|
+
* cookie): only on a site that opted in and has a secret. Every other site never reads cookies
|
|
179
|
+
* here, so its pages can render statically (atlas#105).
|
|
180
|
+
*
|
|
181
|
+
* @ensures exactly the model's ReadsSession
|
|
182
|
+
*/
|
|
183
|
+
export declare function readsSession(crossSite: boolean, hasSecret: boolean): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* The target siteId authorize writes into the session: the sign-in's `siteId` only on an
|
|
186
|
+
* opted-in site, and only when it is not empty (atlas#105).
|
|
187
|
+
*
|
|
188
|
+
* @ensures exactly the model's SignInTarget
|
|
189
|
+
*/
|
|
190
|
+
export declare function signInTarget(crossSite: boolean, siteId: string | undefined): string | undefined;
|
|
153
191
|
/** How queryAction resolves its client. */
|
|
154
192
|
export type Resolution = "scoped" | "global" | "uninit";
|
|
155
193
|
/**
|
package/dist/rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAMlD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED,kEAAkE;AAClE,MAAM,MA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ED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAInD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAIlE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMxD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAIlE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAMvE"}
|
|
@@ -107,6 +107,14 @@ export declare function getSdkCallWrapper(): SdkCallWrapper | null;
|
|
|
107
107
|
export declare function registerAuthSecret(secret: string): void;
|
|
108
108
|
/** Returns the registered auth secret, or null if not registered. */
|
|
109
109
|
export declare function getAuthSecret(): string | null;
|
|
110
|
+
/**
|
|
111
|
+
* Register the cross-site opt-in (`auth.crossSite`, through rules.crossSiteOf). Called by
|
|
112
|
+
* createServerSite(). The ONE source both queryAction's session read and authorize's sign-in
|
|
113
|
+
* target read (models/AugurServer.dfy, "the cross-site opt-in", atlas#105).
|
|
114
|
+
*/
|
|
115
|
+
export declare function registerCrossSite(on: boolean): void;
|
|
116
|
+
/** Whether this site opted in to cross-site sessions; false unless registered. */
|
|
117
|
+
export declare function getCrossSite(): boolean;
|
|
110
118
|
/** Register a factory that creates scoped SDK clients. Called by createServerSite(). */
|
|
111
119
|
export declare function registerClientFactory(factory: ClientFactory): void;
|
|
112
120
|
/** Returns the registered client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;AACxE,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CAEvD;AAED,2FAA2F;AAC3F,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAG5E;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,IAAI,kBAAkB,GAAG,IAAI,CAEjE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAWhF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAMzE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,OAAO,CAEzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAM7E;AAED,mGAAmG;AACnG,wBAAgB,cAAc,IAAI,IAAI,CAgBrC"}
|
package/dist/server-site.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export interface ServerSiteAuthConfig {
|
|
|
7
7
|
maxAge?: number;
|
|
8
8
|
callbacks?: Partial<AugurAuthCallbacks>;
|
|
9
9
|
debug?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Cross-site sessions (the augur-support pattern: an augur_info client, and the target
|
|
12
|
+
* `siteId` passed to `signIn`). Only when true does sign-in keep the target siteId and does
|
|
13
|
+
* `queryAction` read the session cookie to use a client scoped to that site. Default off: a
|
|
14
|
+
* site that does not set it never reads cookies in `queryAction`, so its pages can render
|
|
15
|
+
* statically (atlas#105). A multi-tenant site MUST set it.
|
|
16
|
+
*/
|
|
17
|
+
crossSite?: boolean;
|
|
10
18
|
}
|
|
11
19
|
/** Configuration for {@link createServerSite}, combining action config and auth. */
|
|
12
20
|
export interface ServerSiteConfig extends SiteActionsConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAchD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM;IAC7C,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAcD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,IAAI,EACZ,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAAC,IAAI,CAAC,CAmDlB"}
|
package/dist/site.js
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAuthConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F7QWHMHH.js";
|
|
4
4
|
import {
|
|
5
5
|
createSiteActions,
|
|
6
6
|
registerSiteActions,
|
|
7
7
|
withRawSdkCache
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-34NCJS52.js";
|
|
9
9
|
import {
|
|
10
|
+
crossSiteOf,
|
|
10
11
|
registerAuthSecret,
|
|
11
12
|
registerClientFactory,
|
|
13
|
+
registerCrossSite,
|
|
12
14
|
registerScopedCacheWrapper,
|
|
13
15
|
registerSdkCallWrapper,
|
|
14
|
-
registerSdkClient
|
|
15
|
-
} from "./chunk-A4IVBK6P.js";
|
|
16
|
-
import {
|
|
16
|
+
registerSdkClient,
|
|
17
17
|
ttlFor
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-B4MGIUCU.js";
|
|
19
19
|
|
|
20
20
|
// src/server-site.ts
|
|
21
21
|
import { hours } from "@simpleapps-com/augur-utils";
|
|
22
22
|
import { getCacheTier } from "@simpleapps-com/augur-core";
|
|
23
|
+
function registerSessionAuth(auth) {
|
|
24
|
+
const authSecret = auth?.secret ?? process.env["AUTH_SECRET"];
|
|
25
|
+
if (authSecret) {
|
|
26
|
+
registerAuthSecret(authSecret);
|
|
27
|
+
}
|
|
28
|
+
registerCrossSite(crossSiteOf(auth?.crossSite));
|
|
29
|
+
}
|
|
23
30
|
function createServerSite(client, config = {}) {
|
|
24
31
|
const actions = createSiteActions(client, config);
|
|
25
32
|
registerSiteActions(actions);
|
|
@@ -42,10 +49,7 @@ function createServerSite(client, config = {}) {
|
|
|
42
49
|
return new Ctor({ ...baseConfig, siteId, bearerToken });
|
|
43
50
|
});
|
|
44
51
|
}
|
|
45
|
-
|
|
46
|
-
if (authSecret) {
|
|
47
|
-
registerAuthSecret(authSecret);
|
|
48
|
-
}
|
|
52
|
+
registerSessionAuth(config.auth);
|
|
49
53
|
const auth = config.auth ? createAuthConfig({
|
|
50
54
|
augurClient: client,
|
|
51
55
|
defaultCustomerId: config.defaultCustomerId,
|
package/dist/site.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { ttlFor } from \"./rules\";\nimport { getCacheTier } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) => {\n // An hour of staleTime or more: the long TTL; any other: the standard; 0: no caching.\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) => {\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerCrossSite,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { crossSiteOf, ttlFor } from \"./rules\";\nimport { getCacheTier } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n /**\n * Cross-site sessions (the augur-support pattern: an augur_info client, and the target\n * `siteId` passed to `signIn`). Only when true does sign-in keep the target siteId and does\n * `queryAction` read the session cookie to use a client scoped to that site. Default off: a\n * site that does not set it never reads cookies in `queryAction`, so its pages can render\n * statically (atlas#105). A multi-tenant site MUST set it.\n */\n crossSite?: boolean;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Register what queryAction and sign-in need from `auth`: the secret (`auth.secret`, else\n * `AUTH_SECRET`) and the cross-site opt-in, the one source both read (atlas#105).\n */\nfunction registerSessionAuth(auth: ServerSiteAuthConfig | undefined): void {\n const authSecret = auth?.secret ?? process.env[\"AUTH_SECRET\"];\n if (authSecret) {\n registerAuthSecret(authSecret);\n }\n registerCrossSite(crossSiteOf(auth?.crossSite));\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) => {\n // An hour of staleTime or more: the long TTL; any other: the standard; 0: no caching.\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) => {\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n registerSessionAuth(config.auth);\n\n const auth = config.auth\n ? createAuthConfig({\n augurClient: client as unknown as AugurAuthClient,\n defaultCustomerId: config.defaultCustomerId,\n defaultContactId: config.defaultContactId,\n ...config.auth,\n })\n : undefined;\n\n return { client, actions, auth };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAiBtB,SAAS,oBAAoB;AAkC7B,SAAS,oBAAoB,MAA8C;AACzE,QAAM,aAAa,MAAM,UAAU,QAAQ,IAAI,aAAa;AAC5D,MAAI,YAAY;AACd,uBAAmB,UAAU;AAAA,EAC/B;AACA,oBAAkB,YAAY,MAAM,SAAS,CAAC;AAChD;AAkBO,SAAS,iBACd,QACA,SAA2B,CAAC,GACV;AAClB,QAAM,UAAU,kBAAkB,QAAQ,MAAM;AAChD,sBAAoB,OAAO;AAC3B,oBAAkB,MAAM;AAOxB,QAAM,EAAE,cAAc,IAAI,WAAW,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,EAAE,IAAI;AAC3E,yBAAuB,CAAC,YAAY,YAAY,YAAY;AAE1D,UAAM,MAAM,OAAO,aAAa,UAAU,EAAE,WAAW,UAAU,YAAY;AAC7E,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,aAAa,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EAC1E,CAAC;AAKD,6BAA2B,CAAC,QAAQ,YAAY,YAAY,YAAY;AACtE,UAAM,MAAM,OAAO,aAAa,UAAU,EAAE,WAAW,UAAU,YAAY;AAC7E,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,QAAQ,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EACrE,CAAC;AAKD,QAAM,aAAc,OAAmC,QAAQ;AAE/D,MAAI,YAAY;AACd,UAAM,OAAO,OAAO;AACpB,0BAAsB,CAAC,QAAgB,gBAAwB;AAC7D,aAAO,IAAI,KAAK,EAAE,GAAG,YAAY,QAAQ,YAAY,CAAC;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,sBAAoB,OAAO,IAAI;AAE/B,QAAM,OAAO,OAAO,OAChB,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,mBAAmB,OAAO;AAAA,IAC1B,kBAAkB,OAAO;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ,CAAC,IACD;AAEJ,SAAO,EAAE,QAAQ,SAAS,KAAK;AACjC;","names":[]}
|
package/dist/testing.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clearSiteActions
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-OBWQSGB6.js";
|
|
3
|
+
} from "./chunk-34NCJS52.js";
|
|
4
|
+
import "./chunk-B4MGIUCU.js";
|
|
6
5
|
|
|
7
6
|
// src/testing.ts
|
|
8
7
|
import { createMockClient } from "@simpleapps-com/augur-core/testing";
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type { DeepMockClient, MockClientResult } from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\"getSearchAttributes\", \"getSearchSuggestions\", \"itemSearch\", \"itemSearchInfinite\"],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\"getItemWebDesc\", \"getAlsoBoughtItems\", \"getItemTags\", \"getStates\"],\n customers: [\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getRobots\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\"refreshContacts\", \"refreshCustomers\"],\n p21Sism: [\"getRecentImports\", \"getImport\", \"getScheduledImports\"],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\"getContext\", \"getRubrics\", \"getMicroservices\", \"generateAkasha\", \"generateJoomla\"],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\"getDocuments\"],\n favorites: [\"getFavorites\", \"addFavorite\", \"removeFavorite\"],\n wishlists: [\n \"getWishlists\",\n \"createWishlist\",\n \"getWishlistDetail\",\n \"deleteWishlist\",\n \"addWishlistItems\",\n \"removeWishlistItem\",\n ],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type { DeepMockClient, MockClientResult } from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\"getSearchAttributes\", \"getSearchSuggestions\", \"itemSearch\", \"itemSearchInfinite\"],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\"getItemWebDesc\", \"getAlsoBoughtItems\", \"getItemTags\", \"getStates\"],\n customers: [\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getRobots\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\"refreshContacts\", \"refreshCustomers\"],\n p21Sism: [\"getRecentImports\", \"getImport\", \"getScheduledImports\"],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\"getContext\", \"getRubrics\", \"getMicroservices\", \"generateAkasha\", \"generateJoomla\"],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\"getDocuments\"],\n favorites: [\"getFavorites\", \"addFavorite\", \"removeFavorite\"],\n wishlists: [\n \"getWishlists\",\n \"createWishlist\",\n \"getWishlistDetail\",\n \"deleteWishlist\",\n \"addWishlistItems\",\n \"removeWishlistItem\",\n ],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":";;;;;;AAAA,SAAS,wBAAwB;AAmCjC,IAAM,kBAA4C;AAAA,EAChD,SAAS,CAAC,gBAAgB,sBAAsB,gBAAgB;AAAA,EAChE,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR;AAAA,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Line.add.create());
|
|
|
211
211
|
## @simpleapps-com/augur-server/query-action
|
|
212
212
|
|
|
213
213
|
- function: getSessionCredentials - Resolve session credentials from the Auth.js JWT cookie.
|
|
214
|
-
- function: queryAction -
|
|
214
|
+
- function: queryAction - The SDK call `callSdk` makes (everything above), answered as its envelope's data.
|
|
215
|
+
- function: queryActionRaw - The same call as `queryAction` (allowlist, client, `edgeCache` strip, Redis), answered as the SDK returned it: augur-api's `BaseResponse<T>` envelope (every SDK method's result) with `data`, `total`, `totalResults` and `count`, so client code can page a list (atlas#107). A method path carries no type, so the caller names `T` (`queryActionRaw<Article[]>(…)`). A `queryAction` and a `queryActionRaw` of one call share one Redis entry.
|
|
215
216
|
- function: resetSessionImports - Reset lazy-loaded imports. Used in tests only. @internal
|
|
216
217
|
- function: resolveMethod - Resolve a dot-separated method path on an object, returning the leaf function.
|
|
217
218
|
- value: unwrapBaseResponse
|
|
218
219
|
|
|
219
220
|
## @simpleapps-com/augur-server/api
|
|
220
221
|
|
|
221
|
-
- function: createAugurApiHandler - Creates a Next.js Route Handler that routes method calls through queryAction.
|
|
222
|
+
- function: createAugurApiHandler - Creates a Next.js Route Handler that routes method calls through queryAction, or through queryActionRaw when the body has `raw: true` (augur-core's `createFetchQueryActionRaw`).
|
|
222
223
|
|
|
223
224
|
### Examples
|
|
224
225
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-server",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.4",
|
|
4
4
|
"description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"llms.txt"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@simpleapps-com/augur-core": "^2026.11.
|
|
61
|
+
"@simpleapps-com/augur-core": "^2026.11.3",
|
|
62
62
|
"@simpleapps-com/augur-hooks": "^2026.11.2",
|
|
63
63
|
"@simpleapps-com/augur-utils": "^2026.11.3"
|
|
64
64
|
},
|