@simpleapps-com/augur-server 2026.11.3 → 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 +12 -12
- package/dist/api-handler.d.ts +2 -1
- package/dist/api-handler.d.ts.map +1 -1
- package/dist/api.js +12 -8
- package/dist/api.js.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/{chunk-5I7TBMGU.js → chunk-34NCJS52.js} +2 -2
- package/dist/{chunk-RGOLZMU3.js → chunk-B4MGIUCU.js} +12 -3
- package/dist/{chunk-RGOLZMU3.js.map → chunk-B4MGIUCU.js.map} +1 -1
- package/dist/{chunk-22B3WOGA.js → chunk-F7QWHMHH.js} +2 -2
- package/dist/{chunk-R573MZQL.js → chunk-WR7WT2FI.js} +12 -7
- package/dist/chunk-WR7WT2FI.js.map +1 -0
- package/dist/hooks.js +2 -2
- package/dist/index.js +2 -2
- package/dist/query-action.d.ts +21 -98
- package/dist/query-action.d.ts.map +1 -1
- package/dist/query-action.js +4 -2
- package/dist/rules.d.ts +20 -4
- package/dist/rules.d.ts.map +1 -1
- package/dist/site.js +3 -3
- package/dist/testing.js +2 -2
- package/llms.txt +3 -2
- package/package.json +2 -2
- package/dist/chunk-R573MZQL.js.map +0 -1
- /package/dist/{chunk-5I7TBMGU.js.map → chunk-34NCJS52.js.map} +0 -0
- /package/dist/{chunk-22B3WOGA.js.map → chunk-F7QWHMHH.js.map} +0 -0
package/EXPORTS.md
CHANGED
|
@@ -113,7 +113,8 @@
|
|
|
113
113
|
| Export | Kind | Description |
|
|
114
114
|
|--------|------|-------------|
|
|
115
115
|
| `getSessionCredentials` | function | Resolve session credentials from the Auth.js JWT cookie. |
|
|
116
|
-
| `queryAction` | function |
|
|
116
|
+
| `queryAction` | function | The SDK call `callSdk` makes (everything above), answered as its envelope's data. |
|
|
117
|
+
| `queryActionRaw` | function | 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. |
|
|
117
118
|
| `resetSessionImports` | function | Reset lazy-loaded imports. Used in tests only. @internal |
|
|
118
119
|
| `resolveMethod` | function | Resolve a dot-separated method path on an object, returning the leaf function. |
|
|
119
120
|
| `unwrapBaseResponse` | value | |
|
|
@@ -124,7 +125,7 @@
|
|
|
124
125
|
|
|
125
126
|
| Export | Kind | Description |
|
|
126
127
|
|--------|------|-------------|
|
|
127
|
-
| `createAugurApiHandler` | function | Creates a Next.js Route Handler that routes method calls through queryAction. |
|
|
128
|
+
| `createAugurApiHandler` | function | 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`). |
|
|
128
129
|
|
|
129
130
|
## `@simpleapps-com/augur-server/next-auth`
|
|
130
131
|
|
package/README.md
CHANGED
|
@@ -15,18 +15,18 @@ version; nothing requires them to share one.
|
|
|
15
15
|
pnpm add @simpleapps-com/augur-server
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
| Import | Purpose
|
|
19
|
-
| ------------------------------------------- |
|
|
20
|
-
| `@simpleapps-com/augur-server` | Site actions, caching, `safeAction`, environment, Redis
|
|
21
|
-
| `@simpleapps-com/augur-server/site` | `createServerSite`
|
|
22
|
-
| `@simpleapps-com/augur-server/hooks` | `createServerQueryProxy` (registers `queryAction`)
|
|
23
|
-
| `@simpleapps-com/augur-server/query-action` | `queryAction`, `getSessionCredentials`
|
|
24
|
-
| `@simpleapps-com/augur-server/api` | `createAugurApiHandler` (fetch mode)
|
|
25
|
-
| `@simpleapps-com/augur-server/auth` | `createAuthConfig`
|
|
26
|
-
| `@simpleapps-com/augur-server/query` | `createQueryOptions`, `createSuspenseQueryOptions`
|
|
27
|
-
| `@simpleapps-com/augur-server/actions` | Types only
|
|
28
|
-
| `@simpleapps-com/augur-server/testing` | `createMockSiteActions`, `createMockClient`
|
|
29
|
-
| `@simpleapps-com/augur-server/next-auth` | NextAuth type augmentations
|
|
18
|
+
| Import | Purpose |
|
|
19
|
+
| ------------------------------------------- | -------------------------------------------------------- |
|
|
20
|
+
| `@simpleapps-com/augur-server` | Site actions, caching, `safeAction`, environment, Redis |
|
|
21
|
+
| `@simpleapps-com/augur-server/site` | `createServerSite` |
|
|
22
|
+
| `@simpleapps-com/augur-server/hooks` | `createServerQueryProxy` (registers `queryAction`) |
|
|
23
|
+
| `@simpleapps-com/augur-server/query-action` | `queryAction`, `queryActionRaw`, `getSessionCredentials` |
|
|
24
|
+
| `@simpleapps-com/augur-server/api` | `createAugurApiHandler` (fetch mode) |
|
|
25
|
+
| `@simpleapps-com/augur-server/auth` | `createAuthConfig` |
|
|
26
|
+
| `@simpleapps-com/augur-server/query` | `createQueryOptions`, `createSuspenseQueryOptions` |
|
|
27
|
+
| `@simpleapps-com/augur-server/actions` | Types only |
|
|
28
|
+
| `@simpleapps-com/augur-server/testing` | `createMockSiteActions`, `createMockClient` |
|
|
29
|
+
| `@simpleapps-com/augur-server/next-auth` | NextAuth type augmentations |
|
|
30
30
|
|
|
31
31
|
**Cross-site sessions** (a site signing users in for other sites, augur-support's pattern) need
|
|
32
32
|
`createServerSite(client, { auth: { crossSite: true } })`. Without it, sign-in ignores the
|
package/dist/api-handler.d.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* (set by browsers automatically and cannot be forged by scripts).
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* Creates a Next.js Route Handler that routes method calls through queryAction
|
|
13
|
+
* Creates a Next.js Route Handler that routes method calls through queryAction, or through
|
|
14
|
+
* queryActionRaw when the body has `raw: true` (augur-core's `createFetchQueryActionRaw`).
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-handler.d.ts","sourceRoot":"","sources":["../src/api-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"api-handler.d.ts","sourceRoot":"","sources":["../src/api-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyBH;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,KACrB,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CA+B/C"}
|
package/dist/api.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
queryAction
|
|
3
|
-
|
|
2
|
+
queryAction,
|
|
3
|
+
queryActionRaw
|
|
4
|
+
} from "./chunk-WR7WT2FI.js";
|
|
4
5
|
import {
|
|
6
|
+
answersFullOf,
|
|
5
7
|
apiMessageOf,
|
|
6
8
|
apiStatusOf,
|
|
7
9
|
bodyOutcomeOf,
|
|
8
|
-
isCrossOrigin
|
|
9
|
-
|
|
10
|
+
isCrossOrigin,
|
|
11
|
+
runsOf
|
|
12
|
+
} from "./chunk-B4MGIUCU.js";
|
|
10
13
|
|
|
11
14
|
// src/api-handler.ts
|
|
12
15
|
function refusal(outcome) {
|
|
@@ -21,15 +24,16 @@ function createAugurApiHandler() {
|
|
|
21
24
|
} catch {
|
|
22
25
|
return refusal("bad-json");
|
|
23
26
|
}
|
|
24
|
-
const { methodPath, args } = body;
|
|
27
|
+
const { methodPath, args, raw } = body;
|
|
25
28
|
const outcome = bodyOutcomeOf(
|
|
26
29
|
true,
|
|
27
30
|
typeof methodPath === "string" && methodPath !== "",
|
|
28
|
-
Array.isArray(args)
|
|
31
|
+
Array.isArray(args),
|
|
32
|
+
raw === true
|
|
29
33
|
);
|
|
30
|
-
if (outcome
|
|
34
|
+
if (!runsOf(outcome)) return refusal(outcome);
|
|
31
35
|
try {
|
|
32
|
-
const result = await queryAction(methodPath, ...args);
|
|
36
|
+
const result = answersFullOf(outcome) ? await queryActionRaw(methodPath, ...args) : await queryAction(methodPath, ...args);
|
|
33
37
|
return Response.json(result);
|
|
34
38
|
} catch (error) {
|
|
35
39
|
const message = error instanceof Error ? error.message : "Internal server error";
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api-handler.ts"],"sourcesContent":["/**\n * Generic API route handler for fetch-mode proxy.\n *\n * Exposes the existing queryAction as an HTTP POST endpoint so that\n * `createFetchQueryAction()` from augur-core can route calls through\n * fetch() instead of server actions. This is needed on platforms where\n * server actions cannot access request cookies (e.g., CF Workers via OpenNext).\n *\n * The handler validates same-origin requests via the Sec-Fetch-Site header\n * (set by browsers automatically and cannot be forged by scripts).\n */\n\nimport { queryAction } from \"./query-action\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/api-handler.ts"],"sourcesContent":["/**\n * Generic API route handler for fetch-mode proxy.\n *\n * Exposes the existing queryAction as an HTTP POST endpoint so that\n * `createFetchQueryAction()` from augur-core can route calls through\n * fetch() instead of server actions. This is needed on platforms where\n * server actions cannot access request cookies (e.g., CF Workers via OpenNext).\n *\n * The handler validates same-origin requests via the Sec-Fetch-Site header\n * (set by browsers automatically and cannot be forged by scripts).\n */\n\nimport { queryAction, queryActionRaw } from \"./query-action\";\nimport {\n answersFullOf,\n apiMessageOf,\n apiStatusOf,\n bodyOutcomeOf,\n isCrossOrigin,\n runsOf,\n type ApiOutcome,\n} from \"./rules\";\n\n/** A refused request's response: the outcome's text and status. */\nfunction refusal(outcome: ApiOutcome): Response {\n return new Response(apiMessageOf(outcome), { status: apiStatusOf(outcome) });\n}\n\n/** Request body shape for the API handler; `raw: true` asks for the full response. */\ninterface AugurApiRequestBody {\n methodPath: string;\n args: unknown[];\n raw?: unknown;\n}\n\n/**\n * Creates a Next.js Route Handler that routes method calls through queryAction, or through\n * queryActionRaw when the body has `raw: true` (augur-core's `createFetchQueryActionRaw`).\n *\n * @example\n * ```ts\n * // app/api/augur/route.ts\n * import { createAugurApiHandler } from \"@simpleapps-com/augur-server/api\";\n *\n * const handler = createAugurApiHandler();\n * export const POST = handler;\n * ```\n */\nexport function createAugurApiHandler() {\n return async (req: Request): Promise<Response> => {\n // Same-origin validation: Sec-Fetch-Site is set by browsers and\n // cannot be forged by JavaScript. Reject cross-origin requests.\n if (isCrossOrigin(req.headers.get(\"sec-fetch-site\") ?? \"\")) return refusal(\"forbidden\");\n\n let body: AugurApiRequestBody;\n try {\n body = (await req.json()) as AugurApiRequestBody;\n } catch {\n return refusal(\"bad-json\");\n }\n\n const { methodPath, args, raw } = body;\n const outcome = bodyOutcomeOf(\n true,\n typeof methodPath === \"string\" && methodPath !== \"\",\n Array.isArray(args),\n raw === true,\n );\n if (!runsOf(outcome)) return refusal(outcome);\n\n try {\n const result = answersFullOf(outcome)\n ? await queryActionRaw(methodPath, ...args)\n : await queryAction(methodPath, ...args);\n return Response.json(result);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Internal server error\";\n return new Response(message, { status: 500 });\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAS,QAAQ,SAA+B;AAC9C,SAAO,IAAI,SAAS,aAAa,OAAO,GAAG,EAAE,QAAQ,YAAY,OAAO,EAAE,CAAC;AAC7E;AAsBO,SAAS,wBAAwB;AACtC,SAAO,OAAO,QAAoC;AAGhD,QAAI,cAAc,IAAI,QAAQ,IAAI,gBAAgB,KAAK,EAAE,EAAG,QAAO,QAAQ,WAAW;AAEtF,QAAI;AACJ,QAAI;AACF,aAAQ,MAAM,IAAI,KAAK;AAAA,IACzB,QAAQ;AACN,aAAO,QAAQ,UAAU;AAAA,IAC3B;AAEA,UAAM,EAAE,YAAY,MAAM,IAAI,IAAI;AAClC,UAAM,UAAU;AAAA,MACd;AAAA,MACA,OAAO,eAAe,YAAY,eAAe;AAAA,MACjD,MAAM,QAAQ,IAAI;AAAA,MAClB,QAAQ;AAAA,IACV;AACA,QAAI,CAAC,OAAO,OAAO,EAAG,QAAO,QAAQ,OAAO;AAE5C,QAAI;AACF,YAAM,SAAS,cAAc,OAAO,IAChC,MAAM,eAAe,YAAY,GAAG,IAAI,IACxC,MAAM,YAAY,YAAY,GAAG,IAAI;AACzC,aAAO,SAAS,KAAK,MAAM;AAAA,IAC7B,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU;AACzD,aAAO,IAAI,SAAS,SAAS,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;","names":[]}
|
package/dist/auth.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
shouldCache,
|
|
19
19
|
takesItemId,
|
|
20
20
|
ttlFor
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-B4MGIUCU.js";
|
|
22
22
|
|
|
23
23
|
// src/environment.ts
|
|
24
24
|
function getEnvironment() {
|
|
@@ -2342,4 +2342,4 @@ export {
|
|
|
2342
2342
|
getSiteActions,
|
|
2343
2343
|
clearSiteActions2 as clearSiteActions
|
|
2344
2344
|
};
|
|
2345
|
-
//# sourceMappingURL=chunk-
|
|
2345
|
+
//# sourceMappingURL=chunk-34NCJS52.js.map
|
|
@@ -80,15 +80,22 @@ function hostEnvOf(host) {
|
|
|
80
80
|
function isCrossOrigin(fetchSite) {
|
|
81
81
|
return fetchSite !== "" && fetchSite !== "same-origin";
|
|
82
82
|
}
|
|
83
|
-
function bodyOutcomeOf(jsonOk, methodPathOk, argsIsArray) {
|
|
83
|
+
function bodyOutcomeOf(jsonOk, methodPathOk, argsIsArray, full) {
|
|
84
84
|
if (!jsonOk) return "bad-json";
|
|
85
85
|
if (!methodPathOk) return "bad-method-path";
|
|
86
86
|
if (!argsIsArray) return "bad-args";
|
|
87
|
+
if (full) return "run-full";
|
|
87
88
|
return "run";
|
|
88
89
|
}
|
|
90
|
+
function runsOf(o) {
|
|
91
|
+
return o === "run" || o === "run-full";
|
|
92
|
+
}
|
|
93
|
+
function answersFullOf(o) {
|
|
94
|
+
return o === "run-full";
|
|
95
|
+
}
|
|
89
96
|
function apiStatusOf(o) {
|
|
90
97
|
if (o === "forbidden") return 403;
|
|
91
|
-
if (o === "run") return 200;
|
|
98
|
+
if (o === "run" || o === "run-full") return 200;
|
|
92
99
|
return 400;
|
|
93
100
|
}
|
|
94
101
|
function apiMessageOf(o) {
|
|
@@ -283,6 +290,8 @@ export {
|
|
|
283
290
|
envOf,
|
|
284
291
|
isCrossOrigin,
|
|
285
292
|
bodyOutcomeOf,
|
|
293
|
+
runsOf,
|
|
294
|
+
answersFullOf,
|
|
286
295
|
apiStatusOf,
|
|
287
296
|
apiMessageOf,
|
|
288
297
|
ttlFor,
|
|
@@ -320,4 +329,4 @@ export {
|
|
|
320
329
|
getOrCreateScopedClient,
|
|
321
330
|
parseMethodPath
|
|
322
331
|
};
|
|
323
|
-
//# sourceMappingURL=chunk-
|
|
332
|
+
//# sourceMappingURL=chunk-B4MGIUCU.js.map
|