@fougere/app 0.5.0-alpha.1 → 0.7.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 (59) hide show
  1. package/dist/auth.d.ts +1 -7
  2. package/dist/auth.d.ts.map +1 -1
  3. package/dist/auth.js.map +1 -1
  4. package/dist/boot.d.ts +14 -96
  5. package/dist/boot.d.ts.map +1 -1
  6. package/dist/boot.js +19 -217
  7. package/dist/boot.js.map +1 -1
  8. package/dist/client.d.ts +5 -24
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +6 -32
  11. package/dist/client.js.map +1 -1
  12. package/dist/express.d.ts +2 -12
  13. package/dist/express.d.ts.map +1 -1
  14. package/dist/express.js +4 -52
  15. package/dist/express.js.map +1 -1
  16. package/dist/form.d.ts +11 -56
  17. package/dist/form.d.ts.map +1 -1
  18. package/dist/form.js +15 -33
  19. package/dist/form.js.map +1 -1
  20. package/dist/graphql.d.ts +2 -28
  21. package/dist/graphql.d.ts.map +1 -1
  22. package/dist/graphql.js +1 -6
  23. package/dist/graphql.js.map +1 -1
  24. package/dist/index.d.ts +3 -12
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +4 -12
  27. package/dist/index.js.map +1 -1
  28. package/dist/rest.d.ts +2 -16
  29. package/dist/rest.d.ts.map +1 -1
  30. package/dist/rest.js +4 -34
  31. package/dist/rest.js.map +1 -1
  32. package/dist/serve.d.ts +10 -57
  33. package/dist/serve.d.ts.map +1 -1
  34. package/dist/serve.js +12 -55
  35. package/dist/serve.js.map +1 -1
  36. package/dist/session.d.ts +2 -7
  37. package/dist/session.d.ts.map +1 -1
  38. package/dist/session.js +2 -7
  39. package/dist/session.js.map +1 -1
  40. package/dist/state.d.ts.map +1 -1
  41. package/dist/state.js +1 -11
  42. package/dist/state.js.map +1 -1
  43. package/dist/web.d.ts +3 -19
  44. package/dist/web.d.ts.map +1 -1
  45. package/dist/web.js +4 -32
  46. package/dist/web.js.map +1 -1
  47. package/package.json +11 -10
  48. package/src/auth.ts +1 -7
  49. package/src/boot.ts +31 -260
  50. package/src/client.ts +7 -33
  51. package/src/express.ts +4 -52
  52. package/src/form.ts +20 -73
  53. package/src/graphql.ts +2 -28
  54. package/src/index.ts +4 -12
  55. package/src/rest.ts +4 -34
  56. package/src/serve.ts +13 -60
  57. package/src/session.ts +2 -7
  58. package/src/state.ts +1 -11
  59. package/src/web.ts +4 -32
package/dist/serve.d.ts CHANGED
@@ -1,16 +1,4 @@
1
- /**
2
- * The three doors, decided — and nothing about how a request arrives.
3
- *
4
- * A host (Nuxt, Next) owns exactly two translations: read the request into the
5
- * plain values below, and write the outcome back out. Everything between — which
6
- * operation a verb and a path name, which audience a segment selects, what a
7
- * refusal becomes — is decided here, once, for every host.
8
- *
9
- * The split matters because the alternative was measured in this repo: two copies
10
- * of a REST rule drifted until the Nuxt door answered differently from
11
- * `schema-rest` on the verb, the path AND the exposure. A second host would have
12
- * been a third copy.
13
- */
1
+ /** The three doors, decided — and nothing about how a request arrives. */
14
2
  import { type App, type FrondCall, type InvocationContext } from '@fougere/core';
15
3
  /** What a host must read off the request before any decision is possible. */
16
4
  export interface DoorRequest {
@@ -19,11 +7,7 @@ export interface DoorRequest {
19
7
  path: string;
20
8
  query: Record<string, string>;
21
9
  body?: unknown;
22
- /**
23
- * The server-resolved session. Stamped by the host from what IT resolved —
24
- * never taken from the wire, which is the whole trust boundary of the browser
25
- * door (`transport/http/src/server.ts` carries the same warning for the split).
26
- */
10
+ /** The server-resolved session. */
27
11
  state: Record<string, unknown>;
28
12
  }
29
13
  /** What a host must write back. `pass` is the one that keeps a door additive. */
@@ -43,27 +27,12 @@ export type Outcome =
43
27
  } & Record<string, unknown>;
44
28
  headers?: Record<string, string>;
45
29
  };
46
- /**
47
- * The audience this door serves — the path segment after `/_fougere/call`.
48
- *
49
- * The envelope is a surface like REST and GraphQL, so it selects its audience like
50
- * they do; the difference is only that it takes it from the path instead of an
51
- * option, because a door is mounted, not called. The same word names the directory
52
- * (`handlers/public/`), the config key (`surfaces: { public: [...] }`) and this
53
- * segment — derived, never configured.
54
- *
55
- * No escalation to guard: a named surface serves the entities it names and nothing
56
- * else (closed by naming), so every one of them is a subset of what the bare path
57
- * already serves.
58
- */
30
+ /** The audience this door serves — the path segment after `/_fougere/call`. */
59
31
  export declare function surfaceOf(path: string): string | undefined;
60
32
  /**
61
- * Receiving end for the browser — same wire as process-to-process (JSON-RPC),
62
- * different trust boundary: the browser sits outside the topology, so `state` is
63
- * whatever the host resolved server-side, never what the payload claims.
64
- *
65
- * The runner follows the app's topology: local façades and remote doublures alike
66
- * — the browser never knows where a Frond lives.
33
+ * Receiving end for the browser — same wire as process-to-process (JSON-RPC), different trust
34
+ * boundary: the browser sits outside the topology, so `state` is whatever the host resolved
35
+ * server-side, never what the payload claims.
67
36
  */
68
37
  export declare function serveRpc(app: App, request: Pick<DoorRequest, 'path' | 'body' | 'state'>): Promise<unknown>;
69
38
  /** The answer a host returns when it could not even parse the payload. */
@@ -76,34 +45,18 @@ export declare function rpcParseError(): {
76
45
  };
77
46
  };
78
47
  /**
79
- * Match the URL against the canonical table, invoke the call it names, shape the
80
- * result for HTTP. The decision lives in `rest.ts`; dispatch belongs to the runner.
81
- *
82
- * `path` is what follows the REST mount point, so `/api/blog/posts/1` arrives as
83
- * `blog/posts/1`. A path this door does not serve returns `pass`, and that is what
84
- * lets an app keep its own `/api/*` handlers.
48
+ * Match the URL against the canonical table, invoke the call it names, shape the result for HTTP.
85
49
  */
86
50
  export declare function serveRest(app: App, request: DoorRequest): Promise<Outcome>;
87
- /**
88
- * What an operation's return becomes on the wire.
89
- *
90
- * Separate from `serveRest` because it is a DECISION and dispatch is not: it can be
91
- * pinned without a runner, and both hosts get it whether the call ran in memory or
92
- * came back over JSON-RPC.
93
- */
51
+ /** What an operation's return becomes on the wire. */
94
52
  export declare function shapeRest(operationName: string, result: unknown): Outcome;
95
53
  type EntityClass = {
96
54
  name: string;
97
55
  };
98
56
  type CallInput = Partial<InvocationContext>;
99
57
  /**
100
- * Name a call server-side and let the runner place it — local façade → direct
101
- * in-memory execution, a frond in `remotes` → JSON-RPC on the wire. The caller
102
- * never knows which.
103
- *
104
- * `state` is explicit here. Each host wraps this with its own way of finding the
105
- * current request (Nitro's async context, Next's `headers()` scope), because that
106
- * is the one part a host actually owns.
58
+ * Name a call server-side and let the runner place it — local façade → direct in-memory execution,
59
+ * a frond in `remotes` → JSON-RPC on the wire.
107
60
  */
108
61
  export declare function invokeOn<T = unknown>(app: App, target: EntityClass | FrondCall, opOrInput?: string | CallInput, input?: CallInput, state?: Record<string, unknown>): Promise<T>;
109
62
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,iBAAiB,EACvB,MAAM,eAAe,CAAC;AAIvB,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,iFAAiF;AACjF,MAAM,MAAM,OAAO;AACjB,uEAAuE;AACrE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM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,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAkBzE;AAID,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACpC,KAAK,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE5C;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EACxC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,OAAO,CAAC,CAAC,CAAC,CAMZ"}
package/dist/serve.js CHANGED
@@ -1,44 +1,17 @@
1
- /**
2
- * The three doors, decided — and nothing about how a request arrives.
3
- *
4
- * A host (Nuxt, Next) owns exactly two translations: read the request into the
5
- * plain values below, and write the outcome back out. Everything between — which
6
- * operation a verb and a path name, which audience a segment selects, what a
7
- * refusal becomes — is decided here, once, for every host.
8
- *
9
- * The split matters because the alternative was measured in this repo: two copies
10
- * of a REST rule drifted until the Nuxt door answered differently from
11
- * `schema-rest` on the verb, the path AND the exposure. A second host would have
12
- * been a third copy.
13
- */
1
+ /** The three doors, decided — and nothing about how a request arrives. */
14
2
  import { createAppRunner, callValueOf, toHttpError, } from '@fougere/core';
15
3
  import { handleRpc, PARSE_ERROR } from '@fougere/transport-http';
16
4
  import { matchRoute, tableOf } from './rest.js';
17
5
  // ── The call envelope ────────────────────────────
18
- /**
19
- * The audience this door serves — the path segment after `/_fougere/call`.
20
- *
21
- * The envelope is a surface like REST and GraphQL, so it selects its audience like
22
- * they do; the difference is only that it takes it from the path instead of an
23
- * option, because a door is mounted, not called. The same word names the directory
24
- * (`handlers/public/`), the config key (`surfaces: { public: [...] }`) and this
25
- * segment — derived, never configured.
26
- *
27
- * No escalation to guard: a named surface serves the entities it names and nothing
28
- * else (closed by naming), so every one of them is a subset of what the bare path
29
- * already serves.
30
- */
6
+ /** The audience this door serves — the path segment after `/_fougere/call`. */
31
7
  export function surfaceOf(path) {
32
8
  const named = /^\/_fougere\/call\/([A-Za-z0-9_-]+)/.exec(path.replace(/\?.*$/, ''));
33
9
  return named?.[1];
34
10
  }
35
11
  /**
36
- * Receiving end for the browser — same wire as process-to-process (JSON-RPC),
37
- * different trust boundary: the browser sits outside the topology, so `state` is
38
- * whatever the host resolved server-side, never what the payload claims.
39
- *
40
- * The runner follows the app's topology: local façades and remote doublures alike
41
- * — the browser never knows where a Frond lives.
12
+ * Receiving end for the browser — same wire as process-to-process (JSON-RPC), different trust
13
+ * boundary: the browser sits outside the topology, so `state` is whatever the host resolved
14
+ * server-side, never what the payload claims.
42
15
  */
43
16
  export async function serveRpc(app, request) {
44
17
  const runner = createAppRunner(app, surfaceOf(request.path));
@@ -50,12 +23,7 @@ export function rpcParseError() {
50
23
  }
51
24
  // ── REST ─────────────────────────────────────────
52
25
  /**
53
- * Match the URL against the canonical table, invoke the call it names, shape the
54
- * result for HTTP. The decision lives in `rest.ts`; dispatch belongs to the runner.
55
- *
56
- * `path` is what follows the REST mount point, so `/api/blog/posts/1` arrives as
57
- * `blog/posts/1`. A path this door does not serve returns `pass`, and that is what
58
- * lets an app keep its own `/api/*` handlers.
26
+ * Match the URL against the canonical table, invoke the call it names, shape the result for HTTP.
59
27
  */
60
28
  export async function serveRest(app, request) {
61
29
  // The app decides, not the host. A route file may exist and a middleware may be
@@ -84,7 +52,7 @@ export async function serveRest(app, request) {
84
52
  const { route, params } = match;
85
53
  let result;
86
54
  try {
87
- result = await invokeOn(app, { entity: route.entityName, op: route.operationName }, { params, query: request.query, body: request.body }, undefined, request.state);
55
+ result = await invokeOn(app, { entity: route.entityName, op: route.operationName }, { params, query: request.query, input: request.body }, undefined, request.state);
88
56
  }
89
57
  catch (err) {
90
58
  const { status, body } = toHttpError(err);
@@ -92,13 +60,7 @@ export async function serveRest(app, request) {
92
60
  }
93
61
  return shapeRest(route.operationName, result);
94
62
  }
95
- /**
96
- * What an operation's return becomes on the wire.
97
- *
98
- * Separate from `serveRest` because it is a DECISION and dispatch is not: it can be
99
- * pinned without a runner, and both hosts get it whether the call ran in memory or
100
- * came back over JSON-RPC.
101
- */
63
+ /** What an operation's return becomes on the wire. */
102
64
  export function shapeRest(operationName, result) {
103
65
  if (result === null)
104
66
  return { kind: 'error', status: 404, body: { message: 'Not found' } };
@@ -118,19 +80,14 @@ export function shapeRest(operationName, result) {
118
80
  return { kind: 'ok', status: 200, body: result };
119
81
  }
120
82
  /**
121
- * Name a call server-side and let the runner place it — local façade → direct
122
- * in-memory execution, a frond in `remotes` → JSON-RPC on the wire. The caller
123
- * never knows which.
124
- *
125
- * `state` is explicit here. Each host wraps this with its own way of finding the
126
- * current request (Nitro's async context, Next's `headers()` scope), because that
127
- * is the one part a host actually owns.
83
+ * Name a call server-side and let the runner place it — local façade → direct in-memory execution,
84
+ * a frond in `remotes` → JSON-RPC on the wire.
128
85
  */
129
86
  export async function invokeOn(app, target, opOrInput, input, state = {}) {
130
87
  const { call, invocation } = callValueOf(target, opOrInput, input);
131
88
  // An explicit `state` on the input wins over the request's — the caller who spells
132
89
  // it is answering for it, which is what makes a call outside any request possible.
133
- const given = typeof opOrInput === 'string' ? input : opOrInput;
134
- return (await createAppRunner(app)(call, { ...invocation, state: given?.state ?? state }));
90
+ const explicit = typeof opOrInput === 'string' ? input : opOrInput;
91
+ return (await createAppRunner(app)(call, { ...invocation, state: explicit?.state ?? state }));
135
92
  }
136
93
  //# sourceMappingURL=serve.js.map
package/dist/serve.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"serve.js","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,eAAe,EACf,WAAW,EACX,WAAW,GAIZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS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AAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;SAClG,CAAC;IACJ,CAAC;IAED,oFAAoF;IACpF,oFAAoF;IACpF,6EAA6E;IAC7E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACnD,CAAC;AAOD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,GAAQ,EACR,MAA+B,EAC/B,SAA8B,EAC9B,KAAiB,EACjB,KAAK,GAA4B,EAAE;IAEnC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACnE,mFAAmF;IACnF,mFAAmF;IACnF,MAAM,QAAQ,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,OAAO,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,KAAK,EAAE,CAAC,CAAM,CAAC;AACrG,CAAC"}
package/dist/session.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  /**
2
- * The session view — the one place that turns the server-resolved
3
- * request context (filled by the auth middleware) into what the client
4
- * is allowed to see. One resolution, three readers: the page by
5
- * hydration, the refresh route over the wire, handlers by invocation.
6
- *
7
- * The app-declared context (viewer enrichment) will attach here when
8
- * a real case lands — this function is the seam.
2
+ * The session view — the one place that turns the server-resolved request context (filled by the
3
+ * auth middleware) into what the client is allowed to see.
9
4
  */
10
5
  export interface SessionView {
11
6
  user: Record<string, unknown> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACtC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAK3E"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACtC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAK3E"}
package/dist/session.js CHANGED
@@ -1,11 +1,6 @@
1
1
  /**
2
- * The session view — the one place that turns the server-resolved
3
- * request context (filled by the auth middleware) into what the client
4
- * is allowed to see. One resolution, three readers: the page by
5
- * hydration, the refresh route over the wire, handlers by invocation.
6
- *
7
- * The app-declared context (viewer enrichment) will attach here when
8
- * a real case lands — this function is the seam.
2
+ * The session view — the one place that turns the server-resolved request context (filled by the
3
+ * auth middleware) into what the client is allowed to see.
9
4
  */
10
5
  export function sessionViewOf(context) {
11
6
  const raw = context.user;
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,UAAU,aAAa,CAAC,OAAgC;IAC5D,MAAM,GAAG,GAAG,OAAO,CAAC,IAA2C,CAAC;IAChE,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAChC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,UAAU,aAAa,CAAC,OAAgC;IAC5D,MAAM,GAAG,GAAG,OAAO,CAAC,IAA2C,CAAC;IAChE,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAChC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAiBA,mGAAmG;AACnG,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAcjF"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAOA,mGAAmG;AACnG,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAcjF"}
package/dist/state.js CHANGED
@@ -1,14 +1,4 @@
1
- /**
2
- * Who the caller is, resolved server-side from the request's own headers.
3
- *
4
- * Nuxt answers this with a Nitro middleware that stamps `event.context`; a
5
- * Web-standard host has no such seam on a route handler, so it resolves here
6
- * instead. Same source (the auth runtime mounted on `app.auth`), same result shape
7
- * (`{ user, session }`), so `serveRpc` and `serveRest` cannot tell hosts apart.
8
- *
9
- * What must stay true in both: this is what the SERVER resolved. A browser sits
10
- * outside the topology, so nothing here may come from the payload.
11
- */
1
+ /** Who the caller is, resolved server-side from the request's own headers. */
12
2
  import { useFougereApp } from './boot.js';
13
3
  /** The request state for these headers. Empty when no auth is declared, or nobody is signed in. */
14
4
  export async function stateFor(headers) {
package/dist/state.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;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CAAC;QACrF,IAAI,MAAM,EAAE,OAAO,IAAI,MAAM,EAAE,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAC7F,CAAC;IAAC,MAAM,CAAC;QACP,8EAA8E;QAC9E,wEAAwE;IAC1E,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/dist/web.d.ts CHANGED
@@ -1,25 +1,9 @@
1
- /**
2
- * The call envelope. A named surface is the path segment after the door —
3
- * `/_fougere/call/public` serves the `public` audience — and `surfaceOf` reads it,
4
- * so a host only has to mount this at a path that keeps the segments.
5
- */
1
+ /** The call envelope. */
6
2
  export declare function fougereCall(request: Request): Promise<Response>;
7
- /**
8
- * The REST projection, mounted under `/api`.
9
- *
10
- * `pass` — a path this app does not serve — becomes a 404 here rather than a
11
- * fall-through, because a Web handler has nobody to fall through to. Hosts that
12
- * resolve a static route before a catch-all (Next does) still let an app keep its
13
- * own `/api/*` handlers: they are reached BEFORE this one, not after.
14
- */
3
+ /** The REST projection, mounted under `/api`. */
15
4
  export declare function fougereRest(request: Request): Promise<Response>;
16
5
  /** The session view over the wire, for a client refreshing after login or logout. */
17
6
  export declare function fougereSession(request: Request): Promise<Response>;
18
- /**
19
- * GraphQL, at whatever path the host mounted it — `/graphql` by convention.
20
- *
21
- * Answers `404` when the app declares no GraphQL adapter, because unlike REST this
22
- * door is mounted at a path of its own: there is no app route underneath it to pass to.
23
- */
7
+ /** GraphQL, at whatever path the host mounted it — `/graphql` by convention. */
24
8
  export declare function fougereGraphQL(request: Request): Promise<Response>;
25
9
  //# sourceMappingURL=web.d.ts.map
package/dist/web.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqBrE;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoBrE;AAED,qFAAqF;AACrF,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAExE;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkBxE"}
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAQA,yBAAyB;AACzB,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqBrE;AAED,iDAAiD;AACjD,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoBrE;AAED,qFAAqF;AACrF,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAExE;AAED,gFAAgF;AAChF,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkBxE"}
package/dist/web.js CHANGED
@@ -1,26 +1,10 @@
1
- /**
2
- * The three doors as Web-standard handlers: `Request` in, `Response` out.
3
- *
4
- * This is the whole server surface for any host built on fetch semantics — Next
5
- * route handlers, TanStack Start server routes, Hono, a bare `Deno.serve`. Such a
6
- * host mounts these; it does not translate anything, because there is nothing left
7
- * to translate.
8
- *
9
- * Nuxt is the exception and keeps its own translation, for a reason worth stating:
10
- * an h3 event is not a `Request`, and reading its body has to straddle two h3
11
- * majors (`server/routes/call.post.ts` carries that hundred lines). That file is
12
- * what a NON-Web-standard host costs.
13
- */
1
+ /** The three doors as Web-standard handlers: `Request` in, `Response` out. */
14
2
  import { serveRest, serveRpc, rpcParseError, useFougereApp, serveGraphQL } from './index.js';
15
3
  import { MAX_BODY_BYTES } from '@fougere/core';
16
4
  import { sessionViewOf } from './session.js';
17
5
  import { stateFor } from './state.js';
18
6
  const WITH_BODY = new Set(['POST', 'PUT', 'PATCH']);
19
- /**
20
- * The call envelope. A named surface is the path segment after the door —
21
- * `/_fougere/call/public` serves the `public` audience — and `surfaceOf` reads it,
22
- * so a host only has to mount this at a path that keeps the segments.
23
- */
7
+ /** The call envelope. */
24
8
  export async function fougereCall(request) {
25
9
  const declared = Number(request.headers.get('content-length'));
26
10
  if (Number.isFinite(declared) && declared > MAX_BODY_BYTES) {
@@ -40,14 +24,7 @@ export async function fougereCall(request) {
40
24
  state: await stateFor(request.headers),
41
25
  }));
42
26
  }
43
- /**
44
- * The REST projection, mounted under `/api`.
45
- *
46
- * `pass` — a path this app does not serve — becomes a 404 here rather than a
47
- * fall-through, because a Web handler has nobody to fall through to. Hosts that
48
- * resolve a static route before a catch-all (Next does) still let an app keep its
49
- * own `/api/*` handlers: they are reached BEFORE this one, not after.
50
- */
27
+ /** The REST projection, mounted under `/api`. */
51
28
  export async function fougereRest(request) {
52
29
  const app = await useFougereApp();
53
30
  const url = new URL(request.url);
@@ -71,12 +48,7 @@ export async function fougereRest(request) {
71
48
  export async function fougereSession(request) {
72
49
  return Response.json(sessionViewOf(await stateFor(request.headers)));
73
50
  }
74
- /**
75
- * GraphQL, at whatever path the host mounted it — `/graphql` by convention.
76
- *
77
- * Answers `404` when the app declares no GraphQL adapter, because unlike REST this
78
- * door is mounted at a path of its own: there is no app route underneath it to pass to.
79
- */
51
+ /** GraphQL, at whatever path the host mounted it — `/graphql` by convention. */
80
52
  export async function fougereGraphQL(request) {
81
53
  const app = await useFougereApp();
82
54
  const body = (await request.json().catch(() => ({})));
package/dist/web.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aA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AAgB;IACnD,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAgB;IACnD,MAAM,GAAG,GAAG,MAAM,aAAa,EAAE,CAAC;IAClC,MAAM,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAInD,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE;QACtC,GAAG,IAAI;QACP,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACpE,KAAK,EAAE,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;KACvC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,mCAAmC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fougere/app",
3
- "version": "0.5.0-alpha.1",
3
+ "version": "0.7.0-alpha.0",
4
4
  "description": "The host-independent half of a Fougere app: boot, call envelope, REST table, form contract.",
5
5
  "keywords": [
6
6
  "fougere",
@@ -42,23 +42,24 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "jiti": "^2.6.1",
45
- "@fougere/core": "0.5.0-alpha.1",
46
- "@fougere/schema": "0.5.0-alpha.1",
47
- "@fougere/transport-http": "0.5.0-alpha.1",
48
- "@fougere/container": "0.5.0-alpha.1",
49
- "@fougere/defaults": "0.5.0-alpha.1",
50
- "@fougere/http": "0.5.0-alpha.1",
51
- "@fougere/adapter-rest": "0.5.0-alpha.1"
45
+ "@fougere/core": "0.7.0-alpha.0",
46
+ "@fougere/adapter-rest": "0.7.0-alpha.0",
47
+ "@fougere/defaults": "0.7.0-alpha.0",
48
+ "@fougere/schema": "0.7.0-alpha.0",
49
+ "@fougere/http": "0.7.0-alpha.0",
50
+ "@fougere/container": "0.7.0-alpha.0",
51
+ "@fougere/adapter-memory": "0.7.0-alpha.0",
52
+ "@fougere/transport-http": "0.7.0-alpha.0"
52
53
  },
53
54
  "devDependencies": {
54
55
  "vitest": "^4.1.0",
55
- "@fougere/adapter-graphql": "0.5.0-alpha.1"
56
+ "@fougere/adapter-graphql": "0.7.0-alpha.0"
56
57
  },
57
58
  "publishConfig": {
58
59
  "access": "public"
59
60
  },
60
61
  "peerDependencies": {
61
- "@fougere/adapter-graphql": "0.5.0-alpha.1"
62
+ "@fougere/adapter-graphql": "0.7.0-alpha.0"
62
63
  },
63
64
  "peerDependenciesMeta": {
64
65
  "@fougere/adapter-graphql": {
package/src/auth.ts CHANGED
@@ -1,10 +1,4 @@
1
- /**
2
- * Auth accessor — reads the AuthRuntime that the core mounted on the app.
3
- *
4
- * Auth is no longer a separate singleton: it lives on `app.auth`, built once
5
- * during boot from the `auth` field of fougere.config.ts. This accessor is a
6
- * thin async helper for server code (middleware, routes, /api/me).
7
- */
1
+ /** Auth accessor — reads the AuthRuntime that the core mounted on the app. */
8
2
  import type { AuthRuntime } from '@fougere/core';
9
3
  import { useFougereApp } from './boot.js';
10
4