@fougere/app 0.9.2-alpha.0 → 0.10.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.
- package/dist/CallInput.d.ts +4 -0
- package/dist/CallInput.d.ts.map +1 -0
- package/dist/CallInput.js +2 -0
- package/dist/CallInput.js.map +1 -0
- package/dist/Designation.d.ts +55 -0
- package/dist/Designation.d.ts.map +1 -0
- package/dist/{client.js → Designation.js} +30 -9
- package/dist/Designation.js.map +1 -0
- package/dist/DoorRequest.d.ts +11 -0
- package/dist/DoorRequest.d.ts.map +1 -0
- package/dist/DoorRequest.js +2 -0
- package/dist/DoorRequest.js.map +1 -0
- package/dist/EntityClass.d.ts +6 -0
- package/dist/EntityClass.d.ts.map +1 -0
- package/dist/EntityClass.js +2 -0
- package/dist/EntityClass.js.map +1 -0
- package/dist/Fetcher.d.ts +5 -0
- package/dist/Fetcher.d.ts.map +1 -0
- package/dist/Fetcher.js +2 -0
- package/dist/Fetcher.js.map +1 -0
- package/dist/FormEntity.d.ts +18 -0
- package/dist/FormEntity.d.ts.map +1 -0
- package/dist/{form.js → FormEntity.js} +1 -5
- package/dist/FormEntity.js.map +1 -0
- package/dist/FormField.d.ts +28 -0
- package/dist/FormField.d.ts.map +1 -0
- package/dist/FormField.js +2 -0
- package/dist/FormField.js.map +1 -0
- package/dist/Matchable.d.ts +10 -0
- package/dist/Matchable.d.ts.map +1 -0
- package/dist/Matchable.js +2 -0
- package/dist/Matchable.js.map +1 -0
- package/dist/{serve.d.ts → Outcome.d.ts} +4 -14
- package/dist/Outcome.d.ts.map +1 -0
- package/dist/{serve.js → Outcome.js} +4 -5
- package/dist/Outcome.js.map +1 -0
- package/dist/{rest.d.ts → RouteMatch.d.ts} +2 -10
- package/dist/RouteMatch.d.ts.map +1 -0
- package/dist/{rest.js → RouteMatch.js} +2 -3
- package/dist/RouteMatch.js.map +1 -0
- package/dist/TableColumn.d.ts +14 -0
- package/dist/TableColumn.d.ts.map +1 -0
- package/dist/TableColumn.js +2 -0
- package/dist/TableColumn.js.map +1 -0
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js.map +1 -1
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/express.d.ts +2 -2
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js +8 -8
- package/dist/express.js.map +1 -1
- package/dist/graphql.d.ts +3 -3
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +1 -1
- package/dist/graphql.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/web.js +1 -1
- package/dist/web.js.map +1 -1
- package/package.json +14 -14
- package/src/CallInput.ts +4 -0
- package/src/{client.ts → Designation.ts} +42 -22
- package/src/DoorRequest.ts +10 -0
- package/src/EntityClass.ts +14 -0
- package/src/Fetcher.ts +1 -0
- package/src/{form.ts → FormEntity.ts} +3 -47
- package/src/FormField.ts +27 -0
- package/src/Matchable.ts +9 -0
- package/src/{serve.ts → Outcome.ts} +6 -16
- package/src/{rest.ts → RouteMatch.ts} +2 -12
- package/src/TableColumn.ts +13 -0
- package/src/boot.ts +3 -6
- package/src/client/index.ts +43 -0
- package/src/express.ts +8 -8
- package/src/graphql.ts +4 -4
- package/src/index.ts +5 -17
- package/src/web.ts +1 -1
- package/dist/client.d.ts +0 -45
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/form.d.ts +0 -56
- package/dist/form.d.ts.map +0 -1
- package/dist/form.js.map +0 -1
- package/dist/rest.d.ts.map +0 -1
- package/dist/rest.js.map +0 -1
- package/dist/serve.d.ts.map +0 -1
- package/dist/serve.js.map +0 -1
package/dist/express.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** The
|
|
1
|
+
/** The facades as Express middlewares — the form an Express app expects. */
|
|
2
2
|
import { readExpressBody } from '@fougere/http';
|
|
3
|
-
import { serveRest, serveRpc
|
|
3
|
+
import { rpcParseError, serveRest, serveRpc } from './Outcome.js';
|
|
4
4
|
import { serveGraphQL } from './graphql.js';
|
|
5
5
|
import { sessionViewOf } from './session.js';
|
|
6
6
|
import { useFougereApp } from './boot.js';
|
|
@@ -28,7 +28,7 @@ function fail(res, next, err) {
|
|
|
28
28
|
}
|
|
29
29
|
next(err);
|
|
30
30
|
}
|
|
31
|
-
/** The call envelope, at `/_fougere/call` — the
|
|
31
|
+
/** The call envelope, at `/_fougere/call` — the facade the browser primitives use. */
|
|
32
32
|
export function call(mountPath = '/_fougere/call') {
|
|
33
33
|
return (req, res, next) => {
|
|
34
34
|
const path = pathOf(req);
|
|
@@ -112,19 +112,19 @@ export function graphql(mountPath = '/graphql') {
|
|
|
112
112
|
})();
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
/** Every
|
|
115
|
+
/** Every facade, for an app that wants all of them. What each one SERVES is still the
|
|
116
116
|
* app's declaration — mounting is not publishing. */
|
|
117
117
|
export function fougere() {
|
|
118
|
-
const
|
|
118
|
+
const facades = [call(), session(), rest(), graphql()];
|
|
119
119
|
return (req, res, next) => {
|
|
120
120
|
let index = 0;
|
|
121
121
|
const step = (err) => {
|
|
122
122
|
if (err)
|
|
123
123
|
return next(err);
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
124
|
+
const facade = facades[index++];
|
|
125
|
+
if (!facade)
|
|
126
126
|
return next();
|
|
127
|
-
|
|
127
|
+
facade(req, res, step);
|
|
128
128
|
};
|
|
129
129
|
step();
|
|
130
130
|
};
|
package/dist/express.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,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I,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAChD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC,CAAC;AACJ,CAAC;AAED;sDACsD;AACtD,MAAM,UAAU,OAAO;IACrB,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACxB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,CAAC,GAAa,EAAE,EAAE;YAC7B,IAAI,GAAG;gBAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YAChC,IAAI,CAAC,MAAM;gBAAE,OAAO,IAAI,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/graphql.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/** The GraphQL
|
|
1
|
+
/** The GraphQL facade — declared like the others, mounted like the others. */
|
|
2
2
|
import type { App } from '@fougere/core';
|
|
3
|
-
import type { Outcome } from './
|
|
3
|
+
import type { Outcome } from './Outcome.js';
|
|
4
4
|
/** What a GraphQL request carries, whatever host read it. */
|
|
5
5
|
export interface GraphQLRequest {
|
|
6
6
|
query?: string;
|
|
7
7
|
variables?: Record<string, unknown>;
|
|
8
8
|
operationName?: string;
|
|
9
|
-
/** The audience, when the
|
|
9
|
+
/** The audience, when the facade was mounted per surface. */
|
|
10
10
|
surface?: string;
|
|
11
11
|
state: Record<string, unknown>;
|
|
12
12
|
}
|
package/dist/graphql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAyBD,kEAAkE;AAClE,wBAAsB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBtF"}
|
package/dist/graphql.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function serveGraphQL(app, request) {
|
|
|
23
23
|
variables: request.variables,
|
|
24
24
|
operationName: request.operationName,
|
|
25
25
|
surface: request.surface,
|
|
26
|
-
// The same state every other
|
|
26
|
+
// The same state every other facade stamps: what the server resolved, never the wire.
|
|
27
27
|
state: request.state,
|
|
28
28
|
});
|
|
29
29
|
// A GraphQL error is not an HTTP error: the transport succeeded, and the errors ride
|
package/dist/graphql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAsBA,KAAK,UAAU,QAAQ;IAC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ClF,WAAW,EACX,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;AACH,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAQ,EAAE,OAAuB;IAClE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAEpD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC;IAC5E,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,QAAQ,EAAE,CAAC;IACnC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,sFAAsF;QACtF,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC;IAEH,qFAAqF;IACrF,2DAA2D;IAC3D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAiC,EAAE,CAAC;AAC9E,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/** `@fougere/app` — what an app host needs and what no host owns. */
|
|
2
2
|
export { configureFougere, extendFougere, useFougereApp, reloadFougere, type FougereServerConfig, } from './boot.js';
|
|
3
3
|
export { useFougereAuth } from './auth.js';
|
|
4
|
-
export { tableOf } from './
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { tableOf } from './RouteMatch.js';
|
|
5
|
+
export { invokeOn, rpcParseError, serveRest, serveRpc, surfaceOf } from './Outcome.js';
|
|
6
|
+
export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf, type FormEntity } from './FormEntity.js';
|
|
7
|
+
export { type FormField } from './FormField.js';
|
|
8
|
+
export { type TableColumn } from './TableColumn.js';
|
|
7
9
|
export { sessionViewOf, type SessionView } from './session.js';
|
|
8
10
|
export { stateFor } from './state.js';
|
|
9
11
|
export { serveGraphQL, type GraphQLRequest } from './graphql.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1G,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** `@fougere/app` — what an app host needs and what no host owns. */
|
|
2
2
|
export { configureFougere, extendFougere, useFougereApp, reloadFougere, } from './boot.js';
|
|
3
3
|
export { useFougereAuth } from './auth.js';
|
|
4
|
-
export { tableOf } from './
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { tableOf } from './RouteMatch.js';
|
|
5
|
+
export { invokeOn, rpcParseError, serveRest, serveRpc, surfaceOf } from './Outcome.js';
|
|
6
|
+
export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf } from './FormEntity.js';
|
|
7
7
|
export { sessionViewOf } from './session.js';
|
|
8
8
|
export { stateFor } from './state.js';
|
|
9
9
|
export { serveGraphQL } from './graphql.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AAI1G,OAAO,EAAE,aAAa,EAAoB,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAuB,MAAM,cAAc,CAAC;AAEjE,sFAAsF;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The three
|
|
1
|
+
/** The three facades as Web-standard handlers: `Request` in, `Response` out. */
|
|
2
2
|
import { serveRest, serveRpc, rpcParseError, useFougereApp, serveGraphQL } from './index.js';
|
|
3
3
|
import { MAX_BODY_BYTES } from '@fougere/core';
|
|
4
4
|
import { sessionViewOf } from './session.js';
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAEpD,yBAA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,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.
|
|
3
|
+
"version": "0.10.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",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"import": "./dist/index.js"
|
|
25
25
|
},
|
|
26
26
|
"./client": {
|
|
27
|
-
"types": "./dist/client.d.ts",
|
|
28
|
-
"import": "./dist/client.js"
|
|
27
|
+
"types": "./dist/client/index.d.ts",
|
|
28
|
+
"import": "./dist/client/index.js"
|
|
29
29
|
},
|
|
30
30
|
"./web": {
|
|
31
31
|
"types": "./dist/web.d.ts",
|
|
@@ -42,25 +42,25 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"jiti": "^2.6.1",
|
|
45
|
-
"@fougere/core": "0.
|
|
46
|
-
"@fougere/defaults": "0.
|
|
47
|
-
"@fougere/
|
|
48
|
-
"@fougere/adapter-rest": "0.
|
|
49
|
-
"@fougere/
|
|
50
|
-
"@fougere/http": "0.
|
|
51
|
-
"@fougere/
|
|
52
|
-
"@fougere/adapter-memory": "0.
|
|
53
|
-
"@fougere/compiler": "0.
|
|
45
|
+
"@fougere/core": "0.10.0-alpha.0",
|
|
46
|
+
"@fougere/defaults": "0.10.0-alpha.0",
|
|
47
|
+
"@fougere/container": "0.10.0-alpha.0",
|
|
48
|
+
"@fougere/adapter-rest": "0.10.0-alpha.0",
|
|
49
|
+
"@fougere/http": "0.10.0-alpha.0",
|
|
50
|
+
"@fougere/transport-http": "0.10.0-alpha.0",
|
|
51
|
+
"@fougere/schema": "0.10.0-alpha.0",
|
|
52
|
+
"@fougere/adapter-memory": "0.10.0-alpha.0",
|
|
53
|
+
"@fougere/compiler": "0.10.0-alpha.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"vitest": "^4.1.0",
|
|
57
|
-
"@fougere/adapter-graphql": "0.
|
|
57
|
+
"@fougere/adapter-graphql": "0.10.0-alpha.0"
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@fougere/adapter-graphql": "0.
|
|
63
|
+
"@fougere/adapter-graphql": "0.10.0-alpha.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"@fougere/adapter-graphql": {
|
package/src/CallInput.ts
ADDED
|
@@ -1,26 +1,52 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The couple, minus the reactivity — everything `useQuery`/`useCommand` decide before a
|
|
3
|
-
* framework's state primitives get involved.
|
|
4
|
-
*/
|
|
5
1
|
import {
|
|
6
2
|
FougereError,
|
|
7
3
|
ErrorCode,
|
|
8
4
|
lowerFirst,
|
|
9
5
|
type InvocationContext,
|
|
10
6
|
type FrondCall,
|
|
7
|
+
type FacadeName,
|
|
8
|
+
type Addresses,
|
|
9
|
+
type HandlerOf,
|
|
10
|
+
type AnyHandler,
|
|
11
11
|
} from '@fougere/core/contract';
|
|
12
12
|
import { frameCall, unframeResponse, type RpcResponse } from '@fougere/transport-http/client';
|
|
13
|
+
import type { EntityClass } from './EntityClass.js';
|
|
14
|
+
import type { CallInput } from './CallInput.js';
|
|
15
|
+
import type { Fetcher } from './Fetcher.js';
|
|
13
16
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* One facade, built from its address alone — what a project that never generated `@fronds/facade`
|
|
19
|
+
* has, and what a test writes when it stands one up by hand.
|
|
20
|
+
*
|
|
21
|
+
* A page imports its facade instead, so a missing generated module fails to resolve rather than
|
|
22
|
+
* falling back to `string` in silence. A service writes no address at all: the container
|
|
23
|
+
* resolves `Facade<PostHandler>` from the type, and a browser has no container.
|
|
24
|
+
*/
|
|
25
|
+
export function facade<Address extends Addresses>(address: Address): FacadeName<HandlerOf<Address>, Address> {
|
|
26
|
+
return { address };
|
|
27
|
+
}
|
|
16
28
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The facade an ENTITY class names — the one designation computed rather than written, because a
|
|
31
|
+
* form is handed a set of FIELDS and works out where it submits from them. Its operations are
|
|
32
|
+
* not known from a type, which is exactly what `AnyHandler` says.
|
|
33
|
+
*/
|
|
34
|
+
export function facadeOf(entity: EntityClass): FacadeName<AnyHandler, string> {
|
|
35
|
+
return { address: entityKeyOf(entity) };
|
|
36
|
+
}
|
|
19
37
|
|
|
20
|
-
/**
|
|
21
|
-
export
|
|
38
|
+
/** Where a call goes: a named facade, an entity class that happens to name one, or the address. */
|
|
39
|
+
export function addressOf(designation: Designation): string {
|
|
40
|
+
if (typeof designation === 'string') return designation;
|
|
41
|
+
|
|
42
|
+
return 'address' in designation ? designation.address : entityKeyOf(designation);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The three ways a page designates one facade. */
|
|
46
|
+
export type Designation = FacadeName<unknown, string> | EntityClass | string;
|
|
22
47
|
|
|
23
|
-
|
|
48
|
+
/** The one facade the browser knows. A named surface adds `/{surface}` to it. */
|
|
49
|
+
export const CALL_ENDPOINT = '/_fougere/call';
|
|
24
50
|
|
|
25
51
|
let nextId = 1;
|
|
26
52
|
|
|
@@ -29,8 +55,8 @@ export function entityKeyOf(entity: EntityClass): string {
|
|
|
29
55
|
return lowerFirst(entity.name);
|
|
30
56
|
}
|
|
31
57
|
|
|
32
|
-
export function callOf(
|
|
33
|
-
return { entity:
|
|
58
|
+
export function callOf(designation: Designation, op: string): FrondCall {
|
|
59
|
+
return { entity: addressOf(designation), op };
|
|
34
60
|
}
|
|
35
61
|
|
|
36
62
|
export function invocationOf(input?: CallInput): InvocationContext {
|
|
@@ -129,13 +155,7 @@ export function asFougereError(err: unknown, entityKey: string, op: string): Fou
|
|
|
129
155
|
// The form contract is host-independent too, and a form is client code — so it
|
|
130
156
|
// reaches the browser through this subpath rather than through the package root,
|
|
131
157
|
// which carries the boot.
|
|
132
|
-
export {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
payloadOf,
|
|
136
|
-
errorsByField,
|
|
137
|
-
type FormEntity,
|
|
138
|
-
type FormField,
|
|
139
|
-
type TableColumn,
|
|
140
|
-
} from './form.js';
|
|
158
|
+
export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf, type FormEntity } from './FormEntity.js';
|
|
159
|
+
export { type FormField } from './FormField.js';
|
|
160
|
+
export { type TableColumn } from './TableColumn.js';
|
|
141
161
|
export { sessionViewOf, type SessionView } from './session.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What a host must read off the request before any decision is possible. */
|
|
2
|
+
export interface DoorRequest {
|
|
3
|
+
method: string;
|
|
4
|
+
/** Path with no query string. The REST facade strips its own `/api` prefix. */
|
|
5
|
+
path: string;
|
|
6
|
+
query: Record<string, string>;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
/** The server-resolved session. */
|
|
9
|
+
state: Record<string, unknown>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** An entity class is a designation: its name is the registration key. */
|
|
2
|
+
export type EntityClass = { name: string };
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
FougereOperations,
|
|
6
|
+
FacadeName,
|
|
7
|
+
Addresses,
|
|
8
|
+
AnyHandler,
|
|
9
|
+
HandlerOf,
|
|
10
|
+
Refused,
|
|
11
|
+
FougereHandlers,
|
|
12
|
+
Answer,
|
|
13
|
+
Rows,
|
|
14
|
+
} from '@fougere/core/contract';
|
package/src/Fetcher.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Fetcher = <T>(url: string, options: { method: 'POST'; body: unknown }) => Promise<T>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Lifecycle } from '@fougere/schema';
|
|
2
|
-
/**
|
|
3
|
-
* Form contract, pure part — derives what a create/edit form is made of from the entity's field
|
|
4
|
-
* axes.
|
|
5
|
-
*/
|
|
6
2
|
import { Shapes, lowerFirst, Role, Visibility } from '@fougere/schema';
|
|
7
|
-
import type { Field, SchemaView, ShapeType, ValidationError
|
|
3
|
+
import type { Field, SchemaView, ShapeType, ValidationError } from '@fougere/schema';
|
|
4
|
+
import type { FormField } from './FormField.js';
|
|
5
|
+
import type { TableColumn } from './TableColumn.js';
|
|
8
6
|
|
|
9
7
|
/** What an entity class exposes to a form — the schema statics it already has. */
|
|
10
8
|
export type FormEntity = SchemaView;
|
|
@@ -14,34 +12,6 @@ function defaultOf(field: Field): unknown {
|
|
|
14
12
|
return Lifecycle.of(field).literal?.value;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
export interface FormField {
|
|
18
|
-
name: string;
|
|
19
|
-
/** Rendering hint derived from the shape — the page maps it to widgets. */
|
|
20
|
-
control: 'text' | 'email' | 'url' | 'number' | 'boolean' | 'date' | 'select';
|
|
21
|
-
required: boolean;
|
|
22
|
-
/** i18n key by convention: `entity.field`. The schema never carries display text. */
|
|
23
|
-
labelKey: string;
|
|
24
|
-
/** Fallback label when no i18n message fills the key. */
|
|
25
|
-
label: string;
|
|
26
|
-
/** Enum values, when control is 'select'. */
|
|
27
|
-
options?: string[];
|
|
28
|
-
/**
|
|
29
|
-
* What the browser enforces, under the names it already knows — spread this on the input and the
|
|
30
|
-
* page states no rule of its own.
|
|
31
|
-
*/
|
|
32
|
-
attrs?: {
|
|
33
|
-
type?: 'text' | 'email' | 'url' | 'number';
|
|
34
|
-
required?: boolean;
|
|
35
|
-
minlength?: number;
|
|
36
|
-
maxlength?: number;
|
|
37
|
-
min?: number;
|
|
38
|
-
max?: number;
|
|
39
|
-
pattern?: string;
|
|
40
|
-
};
|
|
41
|
-
/** The value the field is born with — the literal its `lifecycle.create` rule names. */
|
|
42
|
-
default?: unknown;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
15
|
/** The base JSON type of a shape — unwraps the `[T,'null']` union. */
|
|
46
16
|
function baseType(type: unknown): string {
|
|
47
17
|
if (Array.isArray(type)) return (type.find((t) => t !== 'null') as string) ?? 'string';
|
|
@@ -131,20 +101,6 @@ export function formFieldsOf(entity: FormEntity, entityKey: string): FormField[]
|
|
|
131
101
|
});
|
|
132
102
|
}
|
|
133
103
|
|
|
134
|
-
export interface TableColumn {
|
|
135
|
-
name: string;
|
|
136
|
-
/**
|
|
137
|
-
* How to print the value — the dual of {@link FormField.control}, and deliberately not
|
|
138
|
-
* the same list: a closed set prints as its value, a reference prints as a link.
|
|
139
|
-
*/
|
|
140
|
-
render: 'text' | 'number' | 'boolean' | 'date' | 'json' | 'link';
|
|
141
|
-
/** The same key a form uses for the same field — one convention, two projections. */
|
|
142
|
-
labelKey: string;
|
|
143
|
-
label: string;
|
|
144
|
-
/** The entity a `link` points at, under the key its door is named by. */
|
|
145
|
-
to?: string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
104
|
/** Asked of the relation before the shape: a reference's own shape is a bare string. */
|
|
149
105
|
const RENDER_BY_TYPE: Record<ShapeType, TableColumn['render']> = {
|
|
150
106
|
number: 'number',
|
package/src/FormField.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface FormField {
|
|
2
|
+
name: string;
|
|
3
|
+
/** Rendering hint derived from the shape — the page maps it to widgets. */
|
|
4
|
+
control: 'text' | 'email' | 'url' | 'number' | 'boolean' | 'date' | 'select';
|
|
5
|
+
required: boolean;
|
|
6
|
+
/** i18n key by convention: `entity.field`. The schema never carries display text. */
|
|
7
|
+
labelKey: string;
|
|
8
|
+
/** Fallback label when no i18n message fills the key. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Enum values, when control is 'select'. */
|
|
11
|
+
options?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* What the browser enforces, under the names it already knows — spread this on the input and the
|
|
14
|
+
* page states no rule of its own.
|
|
15
|
+
*/
|
|
16
|
+
attrs?: {
|
|
17
|
+
type?: 'text' | 'email' | 'url' | 'number';
|
|
18
|
+
required?: boolean;
|
|
19
|
+
minlength?: number;
|
|
20
|
+
maxlength?: number;
|
|
21
|
+
min?: number;
|
|
22
|
+
max?: number;
|
|
23
|
+
pattern?: string;
|
|
24
|
+
};
|
|
25
|
+
/** The value the field is born with — the literal its `lifecycle.create` rule names. */
|
|
26
|
+
default?: unknown;
|
|
27
|
+
}
|
package/src/Matchable.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** One row of the canonical table, in the form this facade matches against. */
|
|
2
|
+
export interface Matchable {
|
|
3
|
+
method: string;
|
|
4
|
+
/** `route.path` split once: a literal segment, or `:name` to capture. */
|
|
5
|
+
segments: string[];
|
|
6
|
+
path: string;
|
|
7
|
+
entityName: string;
|
|
8
|
+
operationName: string;
|
|
9
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** The three doors, decided — and nothing about how a request arrives. */
|
|
2
1
|
import {
|
|
3
2
|
createAppRunner,
|
|
4
3
|
callValueOf,
|
|
@@ -8,20 +7,10 @@ import {
|
|
|
8
7
|
type InvocationContext,
|
|
9
8
|
} from '@fougere/core';
|
|
10
9
|
import { handleRpc, PARSE_ERROR } from '@fougere/transport-http';
|
|
11
|
-
import { matchRoute, tableOf } from './
|
|
12
|
-
|
|
13
|
-
/** What a host must read off the request before any decision is possible. */
|
|
14
|
-
export interface DoorRequest {
|
|
15
|
-
method: string;
|
|
16
|
-
/** Path with no query string. The REST door strips its own `/api` prefix. */
|
|
17
|
-
path: string;
|
|
18
|
-
query: Record<string, string>;
|
|
19
|
-
body?: unknown;
|
|
20
|
-
/** The server-resolved session. */
|
|
21
|
-
state: Record<string, unknown>;
|
|
22
|
-
}
|
|
10
|
+
import { matchRoute, tableOf } from './RouteMatch.js';
|
|
11
|
+
import type { DoorRequest } from './DoorRequest.js';
|
|
23
12
|
|
|
24
|
-
/** What a host must write back. `pass` is the one that keeps a
|
|
13
|
+
/** What a host must write back. `pass` is the one that keeps a facade additive. */
|
|
25
14
|
export type Outcome =
|
|
26
15
|
/** Not ours — the host's own routes must still reach their handler. */
|
|
27
16
|
| { kind: 'pass' }
|
|
@@ -30,7 +19,7 @@ export type Outcome =
|
|
|
30
19
|
|
|
31
20
|
// ── The call envelope ────────────────────────────
|
|
32
21
|
|
|
33
|
-
/** The audience this
|
|
22
|
+
/** The audience this facade serves — the path segment after `/_fougere/call`. */
|
|
34
23
|
export function surfaceOf(path: string): string | undefined {
|
|
35
24
|
const named = /^\/_fougere\/call\/([A-Za-z0-9_-]+)/.exec(path.replace(/\?.*$/, ''));
|
|
36
25
|
return named?.[1];
|
|
@@ -114,7 +103,7 @@ export function shapeRest(operationName: string, result: unknown): Outcome {
|
|
|
114
103
|
};
|
|
115
104
|
}
|
|
116
105
|
|
|
117
|
-
// 200 on every verb, including POST — what the Nuxt
|
|
106
|
+
// 200 on every verb, including POST — what the Nuxt facade has always answered. A 201
|
|
118
107
|
// would be better REST and is a change of behaviour, so it belongs to `schema-rest`
|
|
119
108
|
// (which owns what a verb means) and not to a refactor that moved this code.
|
|
120
109
|
return { kind: 'ok', status: 200, body: result };
|
|
@@ -123,6 +112,7 @@ export function shapeRest(operationName: string, result: unknown): Outcome {
|
|
|
123
112
|
// ── The server-side dual of the couple ───────────
|
|
124
113
|
|
|
125
114
|
type EntityClass = { name: string };
|
|
115
|
+
|
|
126
116
|
type CallInput = Partial<InvocationContext>;
|
|
127
117
|
|
|
128
118
|
/**
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
/** The REST table this app serves, and the rule that matches a request against it. */
|
|
2
1
|
import { generateRoutes } from '@fougere/adapter-rest';
|
|
3
2
|
import type { App } from '@fougere/core';
|
|
4
|
-
|
|
5
|
-
/** One row of the canonical table, in the form this door matches against. */
|
|
6
|
-
export interface Matchable {
|
|
7
|
-
method: string;
|
|
8
|
-
/** `route.path` split once: a literal segment, or `:name` to capture. */
|
|
9
|
-
segments: string[];
|
|
10
|
-
path: string;
|
|
11
|
-
entityName: string;
|
|
12
|
-
operationName: string;
|
|
13
|
-
}
|
|
3
|
+
import type { Matchable } from './Matchable.js';
|
|
14
4
|
|
|
15
5
|
export type RouteMatch =
|
|
16
6
|
| { kind: 'match'; route: Matchable; params: Record<string, string> }
|
|
@@ -63,7 +53,7 @@ function openness(route: Matchable): number {
|
|
|
63
53
|
return route.segments.filter((s) => s.startsWith(':')).length;
|
|
64
54
|
}
|
|
65
55
|
|
|
66
|
-
/** Verbs this
|
|
56
|
+
/** Verbs this facade accepts in place of the one the table names. */
|
|
67
57
|
const ALIASES: Record<string, string> = { PATCH: 'PUT' };
|
|
68
58
|
|
|
69
59
|
/** Path first, method second — a router's order, and what makes a 405 possible at all. */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface TableColumn {
|
|
2
|
+
name: string;
|
|
3
|
+
/**
|
|
4
|
+
* How to print the value — the dual of {@link FormField.control}, and deliberately not
|
|
5
|
+
* the same list: a closed set prints as its value, a reference prints as a link.
|
|
6
|
+
*/
|
|
7
|
+
render: 'text' | 'number' | 'boolean' | 'date' | 'json' | 'link';
|
|
8
|
+
/** The same key a form uses for the same field — one convention, two projections. */
|
|
9
|
+
labelKey: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** The entity a `link` points at, under the key its facade is named by. */
|
|
12
|
+
to?: string;
|
|
13
|
+
}
|
package/src/boot.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { Role } from '@fougere/schema';
|
|
2
|
-
import { Lifecycle } from '@fougere/schema';
|
|
3
1
|
/** Fougere server bootstrap — single entry point for an app's lifecycle, whatever hosts it. */
|
|
4
|
-
import { applyConfig, createApp, identityFromEnv, Logger
|
|
2
|
+
import { applyConfig, createApp, identityFromEnv, Logger } from '@fougere/core';
|
|
5
3
|
import { scanProject, frondAliases } from '@fougere/compiler';
|
|
6
4
|
import { resolveConventions } from '@fougere/core';
|
|
7
5
|
import { loadCascadedConfig, setModuleLoader } from '@fougere/core/node';
|
|
8
|
-
|
|
6
|
+
|
|
9
7
|
import { createContainer } from '@fougere/container';
|
|
10
8
|
import { createMemoryStorage } from '@fougere/adapter-memory';
|
|
11
|
-
import type { App, CreateAppOptions,
|
|
9
|
+
import type { App, CreateAppOptions, FougereConfig, Transport } from '@fougere/core';
|
|
12
10
|
import { layerOf, type ResolvedStorage } from '@fougere/defaults';
|
|
13
|
-
import { applyCreate, applyUpdate, type SchemaView } from '@fougere/schema';
|
|
14
11
|
|
|
15
12
|
// ── Public types ─────────────────────────────────
|
|
16
13
|
|