@fougere/nuxt 0.3.0-alpha.0 → 0.5.0-alpha.0

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.
Files changed (60) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.ts +29 -2
  3. package/dist/module.d.ts.map +1 -1
  4. package/dist/module.js +91 -34
  5. package/dist/module.js.map +1 -1
  6. package/dist/runtime/composables/useCurrentUser.d.ts +8 -0
  7. package/dist/runtime/composables/useCurrentUser.d.ts.map +1 -0
  8. package/dist/runtime/composables/useCurrentUser.js +21 -0
  9. package/dist/runtime/composables/useCurrentUser.js.map +1 -0
  10. package/dist/runtime/composables/useFormFor.d.ts +27 -0
  11. package/dist/runtime/composables/useFormFor.d.ts.map +1 -0
  12. package/dist/runtime/composables/useFormFor.js +76 -0
  13. package/dist/runtime/composables/useFormFor.js.map +1 -0
  14. package/dist/runtime/composables/useFougereData.d.ts +21 -0
  15. package/dist/runtime/composables/useFougereData.d.ts.map +1 -0
  16. package/dist/runtime/composables/useFougereData.js +74 -0
  17. package/dist/runtime/composables/useFougereData.js.map +1 -0
  18. package/dist/runtime/plugins/session.server.d.ts +3 -0
  19. package/dist/runtime/plugins/session.server.d.ts.map +1 -0
  20. package/dist/runtime/plugins/session.server.js +13 -0
  21. package/dist/runtime/plugins/session.server.js.map +1 -0
  22. package/dist/runtime/server/api/crud.d.ts +3 -0
  23. package/dist/runtime/server/api/crud.d.ts.map +1 -0
  24. package/dist/runtime/server/api/crud.js +46 -0
  25. package/dist/runtime/server/api/crud.js.map +1 -0
  26. package/dist/runtime/server/auth/middleware/auth.d.ts +7 -0
  27. package/dist/runtime/server/auth/middleware/auth.d.ts.map +1 -0
  28. package/dist/runtime/server/auth/middleware/auth.js +32 -0
  29. package/dist/runtime/server/auth/middleware/auth.js.map +1 -0
  30. package/dist/runtime/server/auth/routes/api/me.get.d.ts +5 -0
  31. package/dist/runtime/server/auth/routes/api/me.get.d.ts.map +1 -0
  32. package/dist/runtime/server/auth/routes/api/me.get.js +10 -0
  33. package/dist/runtime/server/auth/routes/api/me.get.js.map +1 -0
  34. package/dist/runtime/server/auth/routes/auth/[...].d.ts +3 -0
  35. package/dist/runtime/server/auth/routes/auth/[...].d.ts.map +1 -0
  36. package/dist/runtime/server/auth/routes/auth/[...].js +8 -0
  37. package/dist/runtime/server/auth/routes/auth/[...].js.map +1 -0
  38. package/dist/runtime/server/routes/call.post.d.ts +3 -0
  39. package/dist/runtime/server/routes/call.post.d.ts.map +1 -0
  40. package/dist/runtime/server/routes/call.post.js +125 -0
  41. package/dist/runtime/server/routes/call.post.js.map +1 -0
  42. package/dist/runtime/server/routes/session.get.d.ts +3 -0
  43. package/dist/runtime/server/routes/session.get.d.ts.map +1 -0
  44. package/dist/runtime/server/routes/session.get.js +9 -0
  45. package/dist/runtime/server/routes/session.get.js.map +1 -0
  46. package/dist/runtime/server/utils/boot.d.ts +13 -0
  47. package/dist/runtime/server/utils/boot.d.ts.map +1 -0
  48. package/dist/runtime/server/utils/boot.js +13 -0
  49. package/dist/runtime/server/utils/boot.js.map +1 -0
  50. package/dist/runtime/server/utils/invoke.d.ts +9 -0
  51. package/dist/runtime/server/utils/invoke.d.ts.map +1 -0
  52. package/dist/runtime/server/utils/invoke.js +24 -0
  53. package/dist/runtime/server/utils/invoke.js.map +1 -0
  54. package/package.json +7 -7
  55. package/src/module.ts +501 -0
  56. package/src/runtime/composables/useFormFor.ts +2 -2
  57. package/src/runtime/composables/useFougereData.ts +11 -1
  58. package/src/runtime/server/auth/routes/auth/[...].ts +1 -1
  59. package/src/runtime/server/routes/call.post.ts +1 -1
  60. package/src/shims.d.ts +7 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.server.js","sourceRoot":"","sources":["../../../src/runtime/plugins/session.server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,aAAa,EAAoB,MAAM,qBAAqB,CAAC;AAEtE,eAAe,gBAAgB,CAAC,GAAG,EAAE;IACnC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,QAAQ,CAAc,iBAAiB,EAAE,GAAG,EAAE,CAC5C,aAAa,CAAC,CAAC,KAAK,EAAE,OAAO,IAAI,EAAE,CAA4B,CAAC,CACjE,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
+ export default _default;
3
+ //# sourceMappingURL=crud.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/crud.ts"],"names":[],"mappings":""}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * REST catch-all — the h3 half of a door whose decisions live in `@fougere/app`.
3
+ *
4
+ * It used to derive its own answers: its own `pluralize`, its own "segment = op or
5
+ * id", and its own method rule — which was no rule at all. A known operation name
6
+ * won whatever the verb, so `GET /api/blog/posts/delete?id=…` reached the mutating
7
+ * method with the session cookie a browser attaches to any navigation, and a
8
+ * body-less `DELETE /api/blog/posts` was read as `create`.
9
+ *
10
+ * `schema-rest` already answers all three in one place, `exposed === false`
11
+ * included — so the fix was not a guard added here, it was the removal of the
12
+ * second answer. `serveRest` is now the third: the same decision serves Next, and
13
+ * neither adapter restates it.
14
+ *
15
+ * What stays here is translation: read the h3 event, write the h3 answer. The state
16
+ * is stamped from `event.context` — what the server resolved, never the wire.
17
+ */
18
+ import { defineEventHandler, readBody, getQuery, createError, setResponseStatus, setResponseHeaders } from 'h3';
19
+ import { serveRest, useFougereApp } from '@fougere/app';
20
+ export default defineEventHandler(async (event) => {
21
+ const app = await useFougereApp();
22
+ const method = event.method.toUpperCase();
23
+ const hasBody = method === 'POST' || method === 'PUT' || method === 'PATCH';
24
+ const outcome = await serveRest(app, {
25
+ method,
26
+ path: event.path.replace(/^\/api\//, '').replace(/\?.*$/, ''),
27
+ query: getQuery(event),
28
+ body: hasBody ? await readBody(event) : undefined,
29
+ state: (event.context ?? {}),
30
+ });
31
+ // Nothing here is ours — an app's own /api/* routes must still reach their handler.
32
+ if (outcome.kind === 'pass')
33
+ return;
34
+ if (outcome.kind === 'error') {
35
+ if (outcome.headers)
36
+ setResponseHeaders(event, outcome.headers);
37
+ throw createError({
38
+ statusCode: outcome.status,
39
+ message: outcome.body.message,
40
+ data: outcome.body,
41
+ });
42
+ }
43
+ setResponseStatus(event, outcome.status);
44
+ return outcome.body;
45
+ });
46
+ //# sourceMappingURL=crud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud.js","sourceRoot":"","sources":["../../../../src/runtime/server/api/crud.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAChH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAExD,eAAe,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAChD,MAAM,GAAG,GAAG,MAAM,aAAa,EAAE,CAAC;IAElC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO,CAAC;IAE5E,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE;QACnC,MAAM;QACN,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7D,KAAK,EAAE,QAAQ,CAAC,KAAK,CAA2B;QAChD,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;QACjD,KAAK,EAAE,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAA4B;KACxD,CAAC,CAAC;IAEH,oFAAoF;IACpF,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO;IAEpC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,OAAO;YAAE,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,WAAW,CAAC;YAChB,UAAU,EAAE,OAAO,CAAC,MAAM;YAC1B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;YAC7B,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Resolves the current session/user from the request cookie and exposes them
3
+ * on event.context. Auth-related routes are skipped so the catch-all handles them.
4
+ */
5
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
6
+ export default _default;
7
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/server/auth/middleware/auth.ts"],"names":[],"mappings":"AAGA;;;GAGG"}
@@ -0,0 +1,32 @@
1
+ import { defineEventHandler, getRequestHeader } from 'h3';
2
+ import { useFougereAuth } from '@fougere/app';
3
+ /**
4
+ * Resolves the current session/user from the request cookie and exposes them
5
+ * on event.context. Auth-related routes are skipped so the catch-all handles them.
6
+ */
7
+ export default defineEventHandler(async (event) => {
8
+ if (event.path.startsWith('/auth/'))
9
+ return;
10
+ const cookie = getRequestHeader(event, 'cookie');
11
+ if (!cookie)
12
+ return;
13
+ let auth;
14
+ try {
15
+ auth = await useFougereAuth();
16
+ }
17
+ catch {
18
+ return; // no auth configured
19
+ }
20
+ try {
21
+ // event.headers, not toWebRequest(event).headers — the web request wraps
22
+ // the body stream, and a later readBody would hang on the captured stream
23
+ const result = await auth.api
24
+ .getSession({ headers: event.headers });
25
+ if (result?.session && result?.user) {
26
+ event.context.user = result.user;
27
+ event.context.session = result.session;
28
+ }
29
+ }
30
+ catch { }
31
+ });
32
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/runtime/server/auth/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;GAGG;AACH,eAAe,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAChD,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO;IAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,IAAI,CAAC;IACT,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,cAAc,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,qBAAqB;IAC/B,CAAC;IAED,IAAI,CAAC;QACH,yEAAyE;QACzE,0EAA0E;QAC1E,MAAM,MAAM,GAAG,MAAO,IAAI,CAAC,GAAsI;aAC9J,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,OAAO,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC;YACpC,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YACjC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACzC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, {
2
+ [x: string]: unknown;
3
+ }>;
4
+ export default _default;
5
+ //# sourceMappingURL=me.get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.get.d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/server/auth/routes/api/me.get.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { defineEventHandler, createError } from 'h3';
2
+ export default defineEventHandler((event) => {
3
+ const user = event.context.user;
4
+ if (!user) {
5
+ throw createError({ statusCode: 401, message: 'Not logged in' });
6
+ }
7
+ const { passwordHash, ...safe } = user;
8
+ return safe;
9
+ });
10
+ //# sourceMappingURL=me.get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.get.js","sourceRoot":"","sources":["../../../../../../src/runtime/server/auth/routes/api/me.get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAErD,eAAe,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE;IAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IAChC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,IAA+B,CAAC;IAClE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
2
+ export default _default;
3
+ //# sourceMappingURL=%5B...%5D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"[...].d.ts","sourceRoot":"","sources":["../../../../../../src/runtime/server/auth/routes/auth/[...].ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { defineEventHandler, toWebRequest, sendWebResponse } from 'h3';
2
+ import { useFougereAuth } from '@fougere/app';
3
+ export default defineEventHandler(async (event) => {
4
+ const auth = await useFougereAuth();
5
+ const webResponse = await auth.handler(toWebRequest(event));
6
+ return sendWebResponse(event, webResponse);
7
+ });
8
+ //# sourceMappingURL=%5B...%5D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"[...].js","sourceRoot":"","sources":["../../../../../../src/runtime/server/auth/routes/auth/[...].ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,eAAe,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IAChD,MAAM,IAAI,GAAG,MAAM,cAAc,EAAE,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5D,OAAO,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<unknown>>;
2
+ export default _default;
3
+ //# sourceMappingURL=call.post.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.post.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/routes/call.post.ts"],"names":[],"mappings":""}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Receiving end for the browser — the h3 half. The decision (which audience, which
3
+ * runner, what a parse failure answers) lives in `@fougere/app`; what stays here is
4
+ * getting a JSON payload out of an h3 event, which is the one thing that genuinely
5
+ * differs between hosts. Next reads `await request.json()` and needs none of this.
6
+ *
7
+ * Trust boundary, unchanged: the browser sits outside the topology, so `state` is
8
+ * stamped from the server-resolved session (event.context), never taken from the wire.
9
+ */
10
+ import { defineEventHandler } from 'h3';
11
+ import { serveRpc, rpcParseError, useFougereApp } from '@fougere/app';
12
+ import { MAX_BODY_BYTES } from '@fougere/core';
13
+ function payloadTooLarge() {
14
+ return Object.assign(new Error('Payload too large'), { statusCode: 413, statusMessage: 'Payload too large' });
15
+ }
16
+ function parseRawJson(raw) {
17
+ if (Buffer.byteLength(raw) > MAX_BODY_BYTES)
18
+ throw payloadTooLarge();
19
+ return raw ? JSON.parse(raw) : {};
20
+ }
21
+ async function readWebBody(req) {
22
+ const declaredLength = Number(req.headers?.get?.('content-length'));
23
+ if (Number.isFinite(declaredLength) && declaredLength > MAX_BODY_BYTES)
24
+ throw payloadTooLarge();
25
+ const reader = req.body?.getReader?.();
26
+ if (reader) {
27
+ const chunks = [];
28
+ let size = 0;
29
+ for (;;) {
30
+ const { done, value } = await reader.read();
31
+ if (done)
32
+ break;
33
+ const chunk = Buffer.from(value ?? []);
34
+ size += chunk.length;
35
+ if (size > MAX_BODY_BYTES) {
36
+ await reader.cancel?.();
37
+ throw payloadTooLarge();
38
+ }
39
+ chunks.push(chunk);
40
+ }
41
+ return parseRawJson(Buffer.concat(chunks).toString('utf8'));
42
+ }
43
+ if (typeof req.text === 'function')
44
+ return parseRawJson(await req.text());
45
+ // Legacy request-like implementations may expose only json(). The content-length
46
+ // check above still rejects declared oversized payloads; standard Request objects
47
+ // take the streamed branch and enforce the limit while reading.
48
+ if (typeof req.json === 'function')
49
+ return req.json();
50
+ return {};
51
+ }
52
+ /**
53
+ * Read the JSON-RPC payload from the h3 event, agnostic to h3 version AND trust
54
+ * boundary. We read the event's shape directly instead of calling `readBody`,
55
+ * whose static `from 'h3'` import can bind to a different h3 major than the one
56
+ * that shaped the event (nitro's runtime is v1 here; devtools drag in v2) —
57
+ * `readBody` v2 on a v1 event throws `event.req.text is not a function`.
58
+ *
59
+ * Two shapes occur, both verified:
60
+ * - SSR internal `$fetch`: a synthetic event whose `node.req.body` is already
61
+ * the raw JSON string — the mock stream is not readable, never drain it.
62
+ * - Browser POST: a real IncomingMessage, drained via stream events (`for
63
+ * await` fails: the SSR mock has no async iterator).
64
+ * The `event.req.json()` branch is the future once nitro is fully on h3 v2.
65
+ */
66
+ async function readJsonBody(event) {
67
+ const rawNodeReq = event.node?.req;
68
+ const nodeReq = rawNodeReq && typeof rawNodeReq === 'object' ? rawNodeReq : undefined;
69
+ const preset = nodeReq?.body;
70
+ if (typeof preset === 'string') {
71
+ if (Buffer.byteLength(preset) > MAX_BODY_BYTES)
72
+ throw payloadTooLarge();
73
+ return parseRawJson(preset);
74
+ }
75
+ if (preset instanceof Uint8Array) {
76
+ if (preset.byteLength > MAX_BODY_BYTES)
77
+ throw payloadTooLarge();
78
+ const raw = Buffer.from(preset).toString('utf8');
79
+ return parseRawJson(raw);
80
+ }
81
+ const webReq = event.req && typeof event.req === 'object' ? event.req : undefined;
82
+ if (webReq
83
+ && (webReq.body?.getReader || typeof webReq.text === 'function' || typeof webReq.json === 'function'))
84
+ return readWebBody(webReq);
85
+ if (nodeReq && typeof nodeReq.on === 'function') {
86
+ const raw = await new Promise((resolve, reject) => {
87
+ const chunks = [];
88
+ let size = 0;
89
+ let exceeded = false;
90
+ nodeReq.on('data', (chunk) => {
91
+ if (exceeded)
92
+ return;
93
+ const buffer = Buffer.from(chunk);
94
+ size += buffer.length;
95
+ if (size > MAX_BODY_BYTES) {
96
+ exceeded = true;
97
+ reject(payloadTooLarge());
98
+ return;
99
+ }
100
+ chunks.push(buffer);
101
+ });
102
+ nodeReq.on('end', () => { if (!exceeded)
103
+ resolve(Buffer.concat(chunks).toString('utf8')); });
104
+ nodeReq.on('error', reject);
105
+ });
106
+ return parseRawJson(raw);
107
+ }
108
+ return {};
109
+ }
110
+ export default defineEventHandler(async (event) => {
111
+ const app = await useFougereApp();
112
+ try {
113
+ return await serveRpc(app, {
114
+ path: event.path,
115
+ body: await readJsonBody(event),
116
+ state: (event.context ?? {}),
117
+ });
118
+ }
119
+ catch (err) {
120
+ if (err?.statusCode === 413)
121
+ throw err;
122
+ return rpcParseError();
123
+ }
124
+ });
125
+ //# sourceMappingURL=call.post.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.post.js","sourceRoot":"","sources":["../../../../src/runtime/server/routes/call.post.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAe/C,SAAS,eAAe;IACtB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC,CAAC;AAChH,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,cAAc;QAAE,MAAM,eAAe,EAAE,CAAC;IACrE,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACpE,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,cAAc;QAAE,MAAM,eAAe,EAAE,CAAC;IAEhG,MAAM,MAAM,GAAG,GAAG,CA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").EventHandler<import("h3").EventHandlerRequest, import("@fougere/app").SessionView>;
2
+ export default _default;
3
+ //# sourceMappingURL=session.get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.get.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/routes/session.get.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The session view over the wire — same resolution the hydration reads,
3
+ * for a client refreshing after login/logout. Internal route, same
4
+ * family as /_fougere/call.
5
+ */
6
+ import { defineEventHandler } from 'h3';
7
+ import { sessionViewOf } from '@fougere/app';
8
+ export default defineEventHandler((event) => sessionViewOf((event.context ?? {})));
9
+ //# sourceMappingURL=session.get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.get.js","sourceRoot":"","sources":["../../../../src/runtime/server/routes/session.get.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,eAAe,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1C,aAAa,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAA4B,CAAC,CAChE,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The boot, re-exported under a path inside this package.
3
+ *
4
+ * Every runtime file here reaches `@fougere/app` by name, because it is resolved
5
+ * from this package's own node_modules. The generated Nitro plugin cannot: it is
6
+ * written into the user's `.nuxt/`, so a bare `@fougere/app` would be resolved from
7
+ * the USER's project, where a transitive dependency is not visible under pnpm.
8
+ *
9
+ * So the codegen imports this file by absolute path, and this file — which does sit
10
+ * in `@fougere/nuxt` — does the resolving. One indirection, one reason.
11
+ */
12
+ export { configureFougere, extendFougere, useFougereApp, type FougereServerConfig } from '@fougere/app';
13
+ //# sourceMappingURL=boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/utils/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The boot, re-exported under a path inside this package.
3
+ *
4
+ * Every runtime file here reaches `@fougere/app` by name, because it is resolved
5
+ * from this package's own node_modules. The generated Nitro plugin cannot: it is
6
+ * written into the user's `.nuxt/`, so a bare `@fougere/app` would be resolved from
7
+ * the USER's project, where a transitive dependency is not visible under pnpm.
8
+ *
9
+ * So the codegen imports this file by absolute path, and this file — which does sit
10
+ * in `@fougere/nuxt` — does the resolving. One indirection, one reason.
11
+ */
12
+ export { configureFougere, extendFougere, useFougereApp } from '@fougere/app';
13
+ //# sourceMappingURL=boot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot.js","sourceRoot":"","sources":["../../../../src/runtime/server/utils/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAA4B,MAAM,cAAc,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { FrondCall, InvocationContext } from '@fougere/core';
2
+ type EntityClass = {
3
+ name: string;
4
+ };
5
+ type CallInput = Partial<InvocationContext>;
6
+ export declare function invoke<T = unknown>(entity: EntityClass, op: string, input?: CallInput): Promise<T>;
7
+ export declare function invoke<T = unknown>(call: FrondCall, input?: CallInput): Promise<T>;
8
+ export {};
9
+ //# sourceMappingURL=invoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/utils/invoke.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElE,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACpC,KAAK,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE5C,wBAAsB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1G,wBAAsB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The server dual of the couple — same designation (class + verb), same return,
3
+ * same errors. `invokeOn` places the call (local façade → direct in-memory
4
+ * execution, a frond in `remotes` → JSON-RPC on the wire); what this file owns is
5
+ * the one host-specific part: finding the current request.
6
+ *
7
+ * In request context the current session rides along (event.context →
8
+ * invocation.state); outside a request, state is empty or explicit.
9
+ */
10
+ import { useEvent } from 'nitropack/runtime';
11
+ import { invokeOn, useFougereApp } from '@fougere/app';
12
+ export async function invoke(target, opOrInput, input) {
13
+ const app = await useFougereApp();
14
+ return invokeOn(app, target, opOrInput, input, requestState());
15
+ }
16
+ function requestState() {
17
+ try {
18
+ return (useEvent()?.context ?? {});
19
+ }
20
+ catch {
21
+ return {};
22
+ }
23
+ }
24
+ //# sourceMappingURL=invoke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../../../src/runtime/server/utils/invoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQvD,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,MAA+B,EAC/B,SAA8B,EAC9B,KAAiB;IAEjB,MAAM,GAAG,GAAG,MAAM,aAAa,EAAE,CAAC;IAClC,OAAO,QAAQ,CAAI,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,IAAI,EAAE,CAA4B,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fougere/nuxt",
3
- "version": "0.3.0-alpha.0",
3
+ "version": "0.5.0-alpha.0",
4
4
  "description": "The Nuxt module: Fougere's client primitives and server surface.",
5
5
  "keywords": [
6
6
  "fougere",
@@ -28,14 +28,14 @@
28
28
  },
29
29
  "files": [
30
30
  "dist",
31
- "src/runtime"
31
+ "src"
32
32
  ],
33
33
  "dependencies": {
34
34
  "@nuxt/kit": "^4.5.1",
35
35
  "jiti": "^2.6.1",
36
- "@fougere/core": "0.3.0-alpha.0",
37
- "@fougere/app": "0.3.0-alpha.0",
38
- "@fougere/defaults": "0.3.0-alpha.0"
36
+ "@fougere/app": "0.5.0-alpha.0",
37
+ "@fougere/defaults": "0.5.0-alpha.0",
38
+ "@fougere/core": "0.5.0-alpha.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@nuxt/schema": "^4.5.1",
@@ -54,8 +54,8 @@
54
54
  "access": "public"
55
55
  },
56
56
  "scripts": {
57
- "build": "rm -rf dist && tsc",
57
+ "build": "rm -rf dist && tsc && tsc -p tsconfig.runtime.json",
58
58
  "test": "vitest run --passWithNoTests",
59
- "typecheck": "tsc --noEmit"
59
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.runtime.json --noEmit"
60
60
  }
61
61
  }