@owlmeans/entrypoint 0.1.18-rc.9 → 0.1.18

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 (53) hide show
  1. package/README.md +254 -70
  2. package/agent-meta/manifest.json +3 -3
  3. package/agent-meta/skills/entrypoint/SKILL.md +77 -130
  4. package/build/consts.d.ts +0 -5
  5. package/build/consts.d.ts.map +1 -1
  6. package/build/consts.js +0 -5
  7. package/build/consts.js.map +1 -1
  8. package/build/entrypoint.d.ts.map +1 -1
  9. package/build/entrypoint.js +18 -6
  10. package/build/entrypoint.js.map +1 -1
  11. package/build/filter/types.d.ts +16 -0
  12. package/build/filter/types.d.ts.map +1 -0
  13. package/build/filter/types.js +2 -0
  14. package/build/filter/types.js.map +1 -0
  15. package/build/filter.d.ts +3 -7
  16. package/build/filter.d.ts.map +1 -1
  17. package/build/filter.js +22 -18
  18. package/build/filter.js.map +1 -1
  19. package/build/helper.d.ts.map +1 -1
  20. package/build/index.d.ts +5 -3
  21. package/build/index.d.ts.map +1 -1
  22. package/build/index.js +4 -3
  23. package/build/index.js.map +1 -1
  24. package/build/materialize.d.ts +7 -0
  25. package/build/materialize.d.ts.map +1 -0
  26. package/build/materialize.js +34 -0
  27. package/build/materialize.js.map +1 -0
  28. package/build/protocol.d.ts +44 -0
  29. package/build/protocol.d.ts.map +1 -0
  30. package/build/protocol.js +124 -0
  31. package/build/protocol.js.map +1 -0
  32. package/build/types.d.ts +169 -5
  33. package/build/types.d.ts.map +1 -1
  34. package/build/types.local.d.ts +27 -0
  35. package/build/types.local.d.ts.map +1 -0
  36. package/build/types.local.js +2 -0
  37. package/build/types.local.js.map +1 -0
  38. package/build/utils/entrypoint.d.ts.map +1 -1
  39. package/build/utils.d.ts +6 -0
  40. package/build/utils.d.ts.map +1 -0
  41. package/build/utils.js +6 -0
  42. package/build/utils.js.map +1 -0
  43. package/package.json +6 -6
  44. package/src/consts.ts +0 -5
  45. package/src/entrypoint.ts +18 -8
  46. package/src/filter/types.ts +16 -0
  47. package/src/filter.ts +24 -17
  48. package/src/index.ts +5 -3
  49. package/src/materialize.ts +43 -0
  50. package/src/protocol.ts +191 -0
  51. package/src/types.local.ts +24 -0
  52. package/src/types.ts +200 -5
  53. package/src/utils.ts +5 -0
package/build/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { ResolvedServiceRoute, RouteAddress, RouteModel, RouteProtocols } from '@owlmeans/route';
2
- import type { InitializedService, LazyService, BasicEntrypoint } from '@owlmeans/context';
3
- import type { AnySchemaObject } from 'ajv';
1
+ import type { ResolvedServiceRoute, RouteAddress, RouteModel, RouteProtocol } from '@owlmeans/route';
2
+ import type { InitializedService, LazyService, BasicEntrypoint, EntrypointReference } from '@owlmeans/context';
3
+ import type { AnySchemaObject, JSONSchemaType } from 'ajv';
4
4
  import type { EntrypointOutcome } from './consts.js';
5
5
  import type { Auth } from '@owlmeans/auth';
6
+ import type { AnyShapeSource, entrypointSchemaType, SourceValue, TypeToken, UrlRequest } from './types.local.js';
6
7
  /**
7
8
  * A URL unit: an immutable route declaration plus what guards, gates and schemas it answers under.
8
9
  *
@@ -123,11 +124,174 @@ export interface Filter {
123
124
  * How a call to an entrypoint is actually carried.
124
125
  *
125
126
  * The transport is chosen by the route's protocol, so a consumer always writes `ep.call(...)` and
126
- * never learns whether that became an HTTP request, a socket message or a queued job. An
127
+ * never learns which built-in or package-owned carrier handled it. An
127
128
  * application binds a protocol by registering a transport service under `transportAlias(protocol)`.
128
129
  */
129
130
  export interface EntrypointTransport extends InitializedService {
130
- readonly protocol: RouteProtocols;
131
+ readonly protocol: RouteProtocol;
131
132
  handle: EntrypointHandler;
132
133
  }
134
+ /** A deliberately broad value used only by declarations without an I/O contract. */
135
+ export type OpenValue = object | string | number | boolean | bigint | null | undefined;
136
+ /** The four independent request sections an entrypoint may declare. */
137
+ export interface RequestShape {
138
+ body?: OpenValue;
139
+ params?: object;
140
+ query?: object;
141
+ headers?: object;
142
+ }
143
+ export interface RuntimeRequestSchemas {
144
+ body?: AnySchemaObject;
145
+ params?: AnySchemaObject;
146
+ query?: AnySchemaObject;
147
+ headers?: AnySchemaObject;
148
+ }
149
+ export interface RuntimeResponseSchemas {
150
+ default?: AnySchemaObject;
151
+ byStatus?: Readonly<Record<number, AnySchemaObject>>;
152
+ }
153
+ /** The runtime schemas and compile-time request/response pair attached to one protocol. */
154
+ export interface EntrypointContract<Request extends RequestShape, Response> {
155
+ readonly kind: 'entrypoint-contract';
156
+ readonly requestSchemas: RuntimeRequestSchemas;
157
+ readonly responseSchemas?: RuntimeResponseSchemas;
158
+ readonly requestType?: Request;
159
+ readonly responseType?: Response;
160
+ }
161
+ /** Runtime fields common to every protocol, regardless of its compile-time request/reply pair. */
162
+ export interface EntrypointProtocolDeclaration {
163
+ readonly kind: 'entrypoint-protocol';
164
+ readonly alias: string;
165
+ readonly route: RouteModel;
166
+ readonly contract?: Pick<EntrypointContract<RequestShape, OpenValue>, 'kind' | 'requestSchemas' | 'responseSchemas'>;
167
+ readonly sticky: boolean;
168
+ readonly guards: readonly string[];
169
+ readonly gate?: {
170
+ readonly alias: string;
171
+ readonly params: readonly string[];
172
+ };
173
+ }
174
+ /** A context-bound entrypoint made from an immutable protocol declaration. */
175
+ export interface MaterializedEntrypoint<Protocol extends EntrypointProtocolDeclaration> extends CommonEntrypoint {
176
+ readonly protocol: Protocol;
177
+ }
178
+ /** The request accepted by a declaration that intentionally supplies no contract. */
179
+ export interface OpenRequest {
180
+ body?: object;
181
+ params?: object;
182
+ query?: object;
183
+ headers?: object;
184
+ }
185
+ /** Addressing and transport controls are never part of an entrypoint's payload contract. */
186
+ export interface CallOptions {
187
+ auth?: Auth;
188
+ host?: string;
189
+ base?: string | boolean;
190
+ unsecure?: boolean;
191
+ timeout?: number;
192
+ signal?: AbortSignal;
193
+ }
194
+ /** A type-only contract source, optionally paired with an AJV schema. */
195
+ export interface Typed<T> extends TypeToken {
196
+ readonly value?: T;
197
+ }
198
+ /**
199
+ * A JSON schema carrying the model type it validates. Use `schema<Model>(...)` once beside the
200
+ * model; every protocol that consumes it then infers the model without another generic.
201
+ */
202
+ export type EntrypointSchema<T> = JSONSchemaType<T> & {
203
+ readonly [entrypointSchemaType]: T;
204
+ };
205
+ /** A schema or an explicit type-only source for one request/response value. */
206
+ export type ShapeSource<T> = EntrypointSchema<T> | JSONSchemaType<T> | Typed<T>;
207
+ export interface RequestSources {
208
+ body?: AnyShapeSource;
209
+ params?: AnyShapeSource;
210
+ query?: AnyShapeSource;
211
+ headers?: AnyShapeSource;
212
+ }
213
+ /** An access gate declared by a protocol, including inherited parent declarations. */
214
+ export interface EntrypointGate {
215
+ readonly alias: string;
216
+ readonly params: readonly string[];
217
+ }
218
+ export type RequestFromSources<Sources extends RequestSources> = (Sources extends {
219
+ body: infer Source;
220
+ } ? {
221
+ body: SourceValue<Source>;
222
+ } : {}) & (Sources extends {
223
+ params: infer Source;
224
+ } ? {
225
+ params: SourceValue<Source>;
226
+ } : {}) & (Sources extends {
227
+ query: infer Source;
228
+ } ? {
229
+ query: SourceValue<Source>;
230
+ } : {}) & (Sources extends {
231
+ headers: infer Source;
232
+ } ? {
233
+ headers: SourceValue<Source>;
234
+ } : {});
235
+ export interface EntrypointOptions {
236
+ sticky?: boolean;
237
+ guards?: string | readonly string[];
238
+ gate?: {
239
+ alias: string;
240
+ params?: string | readonly string[];
241
+ };
242
+ }
243
+ export interface EntrypointResult<Response> {
244
+ value: Response;
245
+ outcome: EntrypointOutcome;
246
+ }
247
+ export type CallArguments<Request extends RequestShape> = {} extends Request ? [request?: Request & CallOptions] : [request: Request & CallOptions];
248
+ export type UrlArguments<Request extends RequestShape> = {} extends UrlRequest<Request> ? [request?: UrlRequest<Request> & CallOptions] : [request: UrlRequest<Request> & CallOptions];
249
+ export interface EntrypointRequestMeta {
250
+ alias: string;
251
+ auth?: Auth;
252
+ entity?: ResolvedEntity;
253
+ path: string;
254
+ canceled?: boolean;
255
+ cancel?: () => void;
256
+ }
257
+ /**
258
+ * A protocol request at an implementation boundary.
259
+ *
260
+ * Transport metadata and empty request sections remain available to handlers; a declared section
261
+ * then refines that base shape to its protocol contract.
262
+ */
263
+ export type HandlerRequest<Request extends RequestShape> = AbstractRequest & Request & EntrypointRequestMeta;
264
+ /**
265
+ * An immutable shared declaration. Its inherited reference type is what gives a context lookup
266
+ * the exact registered entrypoint type without a consumer-supplied generic.
267
+ */
268
+ export interface EntrypointProtocol<Request extends RequestShape = RequestShape, Response = OpenValue> extends EntrypointProtocolDeclaration, EntrypointReference<RegisteredEntrypoint<Request, Response>> {
269
+ readonly contract?: EntrypointContract<Request, Response>;
270
+ }
271
+ /** The context-bound counterpart of an immutable protocol declaration. */
272
+ export interface RegisteredEntrypoint<Request extends RequestShape, Response> extends BasicEntrypoint {
273
+ readonly protocol: EntrypointProtocol<Request, Response>;
274
+ call: (...args: CallArguments<Request>) => Promise<Response>;
275
+ invoke: (...args: CallArguments<Request>) => Promise<EntrypointResult<Response>>;
276
+ url: (...args: UrlArguments<Request>) => Promise<string>;
277
+ validate: (...args: CallArguments<Request>) => Promise<boolean>;
278
+ }
279
+ export type RequestOf<Protocol extends EntrypointProtocolDeclaration> = Protocol extends EntrypointProtocol<infer Request, infer _Response> ? Request : OpenRequest;
280
+ export type ResponseOf<Protocol extends EntrypointProtocolDeclaration> = Protocol extends EntrypointProtocol<infer _Request, infer Response> ? Response : OpenValue;
281
+ export type BodyOf<Protocol extends EntrypointProtocolDeclaration> = RequestOf<Protocol> extends {
282
+ body: infer Body;
283
+ } ? Body : OpenValue;
284
+ export type ParamsOf<Protocol extends EntrypointProtocolDeclaration> = RequestOf<Protocol> extends {
285
+ params: infer Params;
286
+ } ? Params : object;
287
+ export type QueryOf<Protocol extends EntrypointProtocolDeclaration> = RequestOf<Protocol> extends {
288
+ query: infer Query;
289
+ } ? Query : object;
290
+ export type HeadersOf<Protocol extends EntrypointProtocolDeclaration> = RequestOf<Protocol> extends {
291
+ headers: infer Headers;
292
+ } ? Headers : object;
293
+ export type CallRequestOf<Protocol extends EntrypointProtocolDeclaration> = RequestOf<Protocol> & CallOptions;
294
+ export interface EntrypointTree {
295
+ readonly [key: string]: EntrypointProtocolDeclaration | EntrypointTree;
296
+ }
133
297
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrG,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,KAAK,EAAE,UAAU,CAAA;IACjB;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAA;IACf,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAE1B,gEAAgE;IAChE,OAAO,EAAE,MAAM,MAAM,CAAA;IACrB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,MAAM,CAAA;IAClB,sEAAsE;IACtE,KAAK,EAAE,MAAM,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,oBAAoB,CAAA;IACnC,OAAO,EAAE,MAAM,YAAY,CAAA;IAC3B,iEAAiE;IACjE,OAAO,EAAE,MAAM,OAAO,CAAA;IAC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AAC,SAAS;IAAE,MAAM,EAAE,MAAM,MAAM,CAAA;CAAE,GACvH,MAAM,GACN,MAAM,CAAA;AAEV,MAAM,MAAM,OAAO,CAAC,QAAQ,SAAS,6BAA6B,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,KAAK,CAAA;CAAE,GACpH,KAAK,GACL,MAAM,CAAA;AAEV,MAAM,MAAM,SAAS,CAAC,QAAQ,SAAS,6BAA6B,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS;IAAE,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,GAC1H,OAAO,GACP,MAAM,CAAA;AAGV,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,6BAA6B,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAA;AAE7G,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,6BAA6B,GAAG,cAAc,CAAA;CACvE"}
@@ -0,0 +1,27 @@
1
+ import type { JSONSchemaType, AnySchemaObject } from 'ajv';
2
+ import type { EntrypointSchema, OpenValue, RequestShape, Typed } from './types.js';
3
+ export interface TypeToken {
4
+ readonly kind: 'entrypoint-type';
5
+ readonly schema?: AnySchemaObject;
6
+ }
7
+ export declare const entrypointSchemaType: unique symbol;
8
+ export type AnyShapeSource = AnySchemaObject | TypeToken;
9
+ export type SourceValue<Source> = Source extends Typed<infer Value> ? Value : Source extends EntrypointSchema<infer Value> ? Value : Source extends JSONSchemaType<infer Value> ? Value extends OpenValue ? Value : OpenValue : OpenValue;
10
+ export type UrlRequest<Request extends RequestShape> = (Request extends {
11
+ params: infer Params;
12
+ } ? {
13
+ params: Params;
14
+ } : Request extends {
15
+ params?: infer Params;
16
+ } ? {
17
+ params?: Params;
18
+ } : {}) & (Request extends {
19
+ query: infer Query;
20
+ } ? {
21
+ query: Query;
22
+ } : Request extends {
23
+ query?: infer Query;
24
+ } ? {
25
+ query?: Query;
26
+ } : {});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AAC,EAAE,MAAM,KAAK,CAAA;CAAE,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG,EAAE,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.js","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,GAAG,IAAI,gBAC5B,CAAA"}
1
+ {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,GAAG,IAAI,gBAC5B,CAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Service alias a transport registers under. The default protocol is the web one, so an application
3
+ * that binds nothing keeps talking HTTP.
4
+ */
5
+ export declare const transportAlias: (protocol?: string) => string;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc,cAAc,MAAM,WAAqC,CAAA"}
package/build/utils.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Service alias a transport registers under. The default protocol is the web one, so an application
3
+ * that binds nothing keeps talking HTTP.
4
+ */
5
+ export const transportAlias = (protocol = 'http') => `transport:${protocol}`;
6
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,GAAW,MAAM,EAAE,EAAE,CAAC,aAAa,QAAQ,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/entrypoint",
3
- "version": "0.1.18-rc.9",
3
+ "version": "0.1.18",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -28,13 +28,13 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@owlmeans/auth": "^0.1.18-rc.8",
32
- "@owlmeans/context": "^0.1.18-rc.7",
33
- "@owlmeans/route": "^0.1.18-rc.7",
34
- "ajv": "^8.17.1"
31
+ "@owlmeans/auth": "^0.1.18",
32
+ "@owlmeans/context": "^0.1.18",
33
+ "@owlmeans/route": "^0.1.18",
34
+ "ajv": "^8.20.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@owlmeans/dep-config": "workspace:*",
37
+ "@owlmeans/dep-config": "^0.1.18",
38
38
  "nodemon": "^3.1.14",
39
39
  "typescript": "^7.0.2"
40
40
  },
package/src/consts.ts CHANGED
@@ -6,8 +6,3 @@ export enum EntrypointOutcome {
6
6
  Finished = 'finished'
7
7
  }
8
8
 
9
- /**
10
- * Service alias a transport registers under. The default protocol is the web one, so an application
11
- * that binds nothing keeps talking HTTP.
12
- */
13
- export const transportAlias = (protocol: string = 'http') => `transport:${protocol}`
package/src/entrypoint.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { CommonEntrypoint } from './types.js'
2
2
  import { appendContextual } from '@owlmeans/context'
3
- import {
4
- isLocalRoute, resolveAddress, resolveMount, resolvePath, resolveService
5
- } from '@owlmeans/route/utils'
3
+ import { routeAddressOf } from '@owlmeans/route/utils'
6
4
  import type { CreateEntrypointSignature } from './utils/types.js'
7
5
 
8
6
  export const entrypoint: CreateEntrypointSignature<CommonEntrypoint> = (route, opts) => {
@@ -15,15 +13,15 @@ export const entrypoint: CreateEntrypointSignature<CommonEntrypoint> = (route, o
15
13
 
16
14
  segment: () => ep.route.route.path,
17
15
 
18
- path: () => resolvePath(ep.assertCtx(), ep.route.route),
16
+ path: () => routeAddressOf(ep.assertCtx()).resolvePath(ep.route.route),
19
17
 
20
- mount: () => resolveMount(ep.assertCtx(), ep.route.route),
18
+ mount: () => routeAddressOf(ep.assertCtx()).resolveMount(ep.route.route),
21
19
 
22
- service: () => resolveService(ep.assertCtx(), ep.route.route),
20
+ service: () => routeAddressOf(ep.assertCtx()).resolveService(ep.route.route),
23
21
 
24
- address: () => resolveAddress(ep.assertCtx(), ep.route.route),
22
+ address: () => routeAddressOf(ep.assertCtx()).resolveAddress(ep.route.route),
25
23
 
26
- isLocal: () => isLocalRoute(ep.assertCtx(), ep.route.route),
24
+ isLocal: () => routeAddressOf(ep.assertCtx()).isLocalRoute(ep.route.route),
27
25
 
28
26
  parent: () => ep.route.route.parent == null ? null
29
27
  : ep.assertCtx().entrypoint<CommonEntrypoint>(ep.route.route.parent),
@@ -40,6 +38,18 @@ export const entrypoint: CreateEntrypointSignature<CommonEntrypoint> = (route, o
40
38
  return guards
41
39
  },
42
40
 
41
+ /**
42
+ * The gates standing over this entrypoint: its own, then an ancestor's for each gate service
43
+ * this entrypoint has not already named.
44
+ *
45
+ * KNOWN HAZARD, deliberately left alone: the dedup is by gate SERVICE, and two gates under one
46
+ * service are two different questions because their parameters differ — so a child that
47
+ * declares its own gate silently drops its ancestor's, which is the opposite of what
48
+ * "inherited" means. Anything that needs a group rule AND a member rule must therefore not
49
+ * express the group half as a gate under the same service. Changing this would widen every
50
+ * backend and socket entrypoint that today relies on the replacement, so it is a migration
51
+ * rather than a fix.
52
+ */
43
53
  getGates: () => {
44
54
  const gates: [string, string[]][] = ep.gate != null ? [[
45
55
  ep.gate, ep.gateParams == null
@@ -0,0 +1,16 @@
1
+ import type { JSONSchemaType } from 'ajv'
2
+ import type { Filter } from '../types.js'
3
+
4
+ /** Builds the request/response schema filter of an entrypoint, one section at a time. */
5
+ export interface FilterHelper {
6
+ /** `filter` with its body schema set. */
7
+ body: <T>(schema: JSONSchemaType<T>, filter?: Filter) => Filter
8
+ /** `filter` with its query schema set. */
9
+ query: <T>(schema: JSONSchemaType<T>, filter?: Filter) => Filter
10
+ /** `filter` with its params schema set. */
11
+ params: <T>(schema: JSONSchemaType<T>, filter?: Filter) => Filter
12
+ /** `filter` with its response schema set — keyed by `code` when the filter already has responses. */
13
+ response: <T>(schema: JSONSchemaType<T>, code?: number, filter?: Filter) => Filter
14
+ /** `filter` with its headers schema set. */
15
+ headers: <T>(schema: JSONSchemaType<T>, filter?: Filter) => Filter
16
+ }
package/src/filter.ts CHANGED
@@ -1,26 +1,33 @@
1
1
  import type { JSONSchemaType } from 'ajv'
2
2
  import type { Filter } from './types.js'
3
+ import type { FilterHelper } from './filter/types.js'
3
4
 
4
- export const body = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
5
- return { ...filter, body: schema as any }
6
- }
5
+ export const createFilterHelper = (): FilterHelper => {
6
+ const body = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
7
+ return { ...filter, body: schema as any }
8
+ }
7
9
 
8
- export const query = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
9
- return { ...filter, query: schema as any }
10
- }
10
+ const query = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
11
+ return { ...filter, query: schema as any }
12
+ }
11
13
 
12
- export const params = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
13
- return { ...filter, params: schema as any }
14
- }
14
+ const params = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
15
+ return { ...filter, params: schema as any }
16
+ }
15
17
 
16
- export const response = <T>(schema: JSONSchemaType<T>, code?: number, filter?: Filter): Filter => {
17
- let _schema: any = schema
18
- if (filter?.response != null && code != null) {
19
- _schema = { ...filter.response, [code]: schema }
18
+ const response = <T>(schema: JSONSchemaType<T>, code?: number, filter?: Filter): Filter => {
19
+ let _schema: any = schema
20
+ if (filter?.response != null && code != null) {
21
+ _schema = { ...filter.response, [code]: schema }
22
+ }
23
+ return { ...filter, response: _schema }
20
24
  }
21
- return { ...filter, response: _schema }
22
- }
23
25
 
24
- export const headers = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
25
- return { ...filter, headers: schema as any }
26
+ const headers = <T>(schema: JSONSchemaType<T>, filter?: Filter): Filter => {
27
+ return { ...filter, headers: schema as any }
28
+ }
29
+
30
+ return { body, query, params, response, headers }
26
31
  }
32
+
33
+ export const filterHelper = createFilterHelper()
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
 
2
2
  export type * from './types.js'
3
- export * from './entrypoint.js'
4
- export * from './filter.js'
5
- export * from './helper.js'
3
+ export type * from './filter/types.js'
6
4
  export * from './consts.js'
5
+ export * from './utils.js'
6
+ export * from './protocol.js'
7
+ export * from './materialize.js'
8
+ export { provideResponse } from './helper.js'
@@ -0,0 +1,43 @@
1
+ import { entrypoint } from './entrypoint.js'
2
+ import type { CommonEntrypointOptions, Filter, EntrypointProtocolDeclaration, MaterializedEntrypoint } from './types.js'
3
+
4
+ const filterOf = (protocol: EntrypointProtocolDeclaration): Filter | undefined => {
5
+ const request = protocol.contract?.requestSchemas
6
+ const response = protocol.contract?.responseSchemas
7
+
8
+ if (request == null && response == null) return undefined
9
+
10
+ return {
11
+ body: request?.body == null ? undefined : structuredClone(request.body),
12
+ params: request?.params == null ? undefined : structuredClone(request.params),
13
+ query: request?.query == null ? undefined : structuredClone(request.query),
14
+ headers: request?.headers == null ? undefined : structuredClone(request.headers),
15
+ // Fastify requires response serializers to be keyed by a status code. A protocol's
16
+ // ordinary response has no explicit outcome, so it is the normal successful 200 reply.
17
+ response: response == null ? undefined : {
18
+ ...(response.default == null ? {} : { 200: structuredClone(response.default) }),
19
+ ...Object.fromEntries(Object.entries(response.byStatus ?? {}).map(([status, schema]) => [
20
+ status, structuredClone(schema),
21
+ ])),
22
+ },
23
+ }
24
+ }
25
+
26
+ const optionsOf = (protocol: EntrypointProtocolDeclaration): CommonEntrypointOptions => ({
27
+ sticky: protocol.sticky,
28
+ guards: [...protocol.guards],
29
+ gate: protocol.gate?.alias,
30
+ gateParams: protocol.gate == null ? undefined : [...protocol.gate.params],
31
+ filter: filterOf(protocol),
32
+ })
33
+
34
+ /**
35
+ * Make a local, mutable registration from a shared declaration. The protocol is never mutated;
36
+ * guards, route resolution and handlers belong exclusively to this materialized entrypoint.
37
+ */
38
+ export const materializeEntrypoint = <Protocol extends EntrypointProtocolDeclaration>(
39
+ protocol: Protocol,
40
+ ): MaterializedEntrypoint<Protocol> => Object.assign(
41
+ entrypoint({ route: { ...protocol.route.route } }, optionsOf(protocol)),
42
+ { protocol },
43
+ )