@owlmeans/client-entrypoint 0.1.18-rc.5 → 0.1.18-rc.50

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 (71) hide show
  1. package/README.md +170 -49
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/client-entrypoint/SKILL.md +33 -30
  4. package/build/consts.d.ts +2 -0
  5. package/build/consts.d.ts.map +1 -0
  6. package/build/consts.js +2 -0
  7. package/build/consts.js.map +1 -0
  8. package/build/entrypoint.d.ts +2 -3
  9. package/build/entrypoint.d.ts.map +1 -1
  10. package/build/entrypoint.js +27 -39
  11. package/build/entrypoint.js.map +1 -1
  12. package/build/failure.d.ts +5 -0
  13. package/build/failure.d.ts.map +1 -0
  14. package/build/failure.js +27 -0
  15. package/build/failure.js.map +1 -0
  16. package/build/helper/types.d.ts +10 -0
  17. package/build/helper/types.d.ts.map +1 -0
  18. package/build/helper/types.js +2 -0
  19. package/build/helper/types.js.map +1 -0
  20. package/build/helper.d.ts +5 -6
  21. package/build/helper.d.ts.map +1 -1
  22. package/build/helper.js +22 -34
  23. package/build/helper.js.map +1 -1
  24. package/build/index.d.ts +6 -2
  25. package/build/index.d.ts.map +1 -1
  26. package/build/index.js +5 -2
  27. package/build/index.js.map +1 -1
  28. package/build/protocol.d.ts +9 -0
  29. package/build/protocol.d.ts.map +1 -0
  30. package/build/protocol.js +15 -0
  31. package/build/protocol.js.map +1 -0
  32. package/build/stab.d.ts +4 -0
  33. package/build/stab.d.ts.map +1 -0
  34. package/build/stab.js +5 -0
  35. package/build/stab.js.map +1 -0
  36. package/build/types.d.ts +53 -9
  37. package/build/types.d.ts.map +1 -1
  38. package/build/utils/entrypoint.d.ts +2 -4
  39. package/build/utils/entrypoint.d.ts.map +1 -1
  40. package/build/utils/entrypoint.js +0 -9
  41. package/build/utils/entrypoint.js.map +1 -1
  42. package/build/utils/handler/types.d.ts +15 -0
  43. package/build/utils/handler/types.d.ts.map +1 -0
  44. package/build/utils/handler/types.js +2 -0
  45. package/build/utils/handler/types.js.map +1 -0
  46. package/build/utils/handler.d.ts +7 -5
  47. package/build/utils/handler.d.ts.map +1 -1
  48. package/build/utils/handler.js +126 -95
  49. package/build/utils/handler.js.map +1 -1
  50. package/build/utils/index.d.ts +1 -0
  51. package/build/utils/index.d.ts.map +1 -1
  52. package/build/utils/index.js.map +1 -1
  53. package/build/utils/types.local.d.ts +5 -0
  54. package/build/utils/types.local.d.ts.map +1 -0
  55. package/build/utils/types.local.js +2 -0
  56. package/build/utils/types.local.js.map +1 -0
  57. package/package.json +13 -12
  58. package/src/consts.ts +1 -0
  59. package/src/entrypoint.ts +37 -49
  60. package/src/failure.ts +26 -0
  61. package/src/helper/types.ts +10 -0
  62. package/src/helper.ts +30 -49
  63. package/src/index.ts +6 -2
  64. package/src/protocol.ts +39 -0
  65. package/src/stab.ts +6 -0
  66. package/src/types.ts +62 -11
  67. package/src/utils/entrypoint.ts +2 -17
  68. package/src/utils/handler/types.ts +15 -0
  69. package/src/utils/handler.ts +106 -77
  70. package/src/utils/index.ts +1 -0
  71. package/src/utils/types.local.ts +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAKrD,MAAM,CAA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AC,KAAK,CAAC,QAAQ,KAAK,cAAc,CAAC,MAAM,CAAA;QAEhE,+FAA+F;QAC/F,kGAAkG;QAClG,sDAAsD;QACtD,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,QAAQ,KAAK,IAAI,EAAE,CAAC;YACvD,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;YACtC,IAAI,GAAG,MAAM,CAAC,OAAO,CACnB,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,CACvF,CAAA;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;AACjD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAE9D,0FAA0F;AAC1F,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAwB,EAAE,GAAgB,EAAE,IAA2B,EACtD,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA"}
@@ -1,3 +1,4 @@
1
+ export type * from './handler/types.js';
1
2
  export * from './entrypoint.js';
2
3
  export * from './handler.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,mBAAmB,oBAAoB,CAAA;AACvC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { ClientConfig, ClientContext } from '@owlmeans/client-context';
2
+ export type Config = ClientConfig;
3
+ export interface Context<C extends Config = Config> extends ClientContext<C> {
4
+ }
5
+ //# sourceMappingURL=types.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../../src/utils/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE3E,MAAM,MAAM,MAAM,GAAG,YAAY,CAAA;AAEjC,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;CAAI"}
@@ -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/utils/types.local.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/client-entrypoint",
3
- "version": "0.1.18-rc.5",
3
+ "version": "0.1.18-rc.50",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -28,24 +28,25 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@owlmeans/api": "^0.1.18-rc.5",
32
- "@owlmeans/client-config": "^0.1.18-rc.5",
33
- "@owlmeans/client-context": "^0.1.18-rc.5",
34
- "@owlmeans/client-route": "^0.1.18-rc.5",
35
- "@owlmeans/config": "^0.1.18-rc.5",
36
- "@owlmeans/context": "^0.1.18-rc.5",
37
- "@owlmeans/entrypoint": "^0.1.18-rc.5",
38
- "@owlmeans/error": "^0.1.18-rc.5",
39
- "@owlmeans/route": "^0.1.18-rc.5",
31
+ "@owlmeans/api": "^0.1.18-rc.50",
32
+ "@owlmeans/client-config": "^0.1.18-rc.45",
33
+ "@owlmeans/client-context": "^0.1.18-rc.51",
34
+ "@owlmeans/client-route": "^0.1.18-rc.51",
35
+ "@owlmeans/config": "^0.1.18-rc.44",
36
+ "@owlmeans/context": "^0.1.18-rc.34",
37
+ "@owlmeans/entrypoint": "^0.1.18-rc.41",
38
+ "@owlmeans/error": "^0.1.18-rc.38",
39
+ "@owlmeans/log": "^0.1.18-rc.3",
40
+ "@owlmeans/route": "^0.1.18-rc.35",
40
41
  "ajv-formats": "^3.0.1",
41
- "qs": "^6.13.0"
42
+ "qs": "^6.16.0"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "ajv": "*"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@owlmeans/dep-config": "workspace:*",
48
- "@types/qs": "^6.9.16",
49
+ "@types/qs": "^6.15.1",
49
50
  "nodemon": "^3.1.14",
50
51
  "typescript": "^7.0.2"
51
52
  },
package/src/consts.ts ADDED
@@ -0,0 +1 @@
1
+ export const ENTRYPOINT_FAILURE_SERVICE = 'client-entrypoint:failure'
package/src/entrypoint.ts CHANGED
@@ -1,60 +1,55 @@
1
- import type { ClientRouteModel } from '@owlmeans/client-route'
2
1
  import type { ClientEntrypoint, ClientEntrypointOptions, EntrypointRef, RefedEntrypointHandler } from './types.js'
3
2
  import type { AbstractRequest, CommonEntrypoint } from '@owlmeans/entrypoint'
4
- import { isEntrypoint, makeBasicEntrypoint, normalizeHelperParams, validate } from './utils/entrypoint.js'
5
- import { isClientRouteModel, route } from '@owlmeans/client-route'
6
- import { apiCall, apiHandler, urlCall } from './utils/handler.js'
3
+ import { validate } from './utils/entrypoint.js'
4
+ import { route } from '@owlmeans/client-route'
5
+ import { apiCallOf } from './utils/handler.js'
7
6
  import { AppType } from '@owlmeans/context'
8
- import type { BasicContext } from '@owlmeans/context'
9
- import { normalizePath } from '@owlmeans/route'
10
- import type { CommonRouteModel } from '@owlmeans/route'
11
- import { provideRequest } from './helper.js'
7
+ import { clientRequestHelper } from './helper.js'
12
8
 
13
- export const entrypoint = <T, R extends AbstractRequest = AbstractRequest>(
14
- arg: CommonEntrypoint | ClientRouteModel | CommonRouteModel,
15
- handler?: RefedEntrypointHandler<T, R> | ClientEntrypointOptions | boolean,
16
- opts?: ClientEntrypointOptions | boolean
9
+ /** Attach client behaviour to an entrypoint already materialized from a protocol. */
10
+ export const bindMaterializedEntrypoint = <T, R extends AbstractRequest = AbstractRequest>(
11
+ arg: CommonEntrypoint,
12
+ handler?: RefedEntrypointHandler<T, R>,
13
+ opts?: ClientEntrypointOptions,
17
14
  ): ClientEntrypoint<T, R> => {
18
15
  const entrypointHandle: EntrypointRef<T, R> = { ref: undefined }
19
16
 
20
17
  let _entrypoint: ClientEntrypoint<T, R>
21
18
 
22
- ;[handler, opts] = normalizeHelperParams(handler, opts)
23
-
24
- const _handler = handler as RefedEntrypointHandler<T, R> | undefined ??
25
- (('route' in arg.route ? arg.route.route.type : arg.route.type)
26
- === AppType.Backend ? apiHandler : undefined)
27
-
28
- if (isEntrypoint(arg)) {
29
- assertExplicitHandler(arg.route.route.type, handler as RefedEntrypointHandler<T, R>)
30
- const routeModel = route(arg.route, opts?.routeOptions)
31
- _entrypoint = arg as ClientEntrypoint<T, R>
32
- _entrypoint.route = routeModel
33
- _entrypoint.guards = opts?.guards ?? arg.guards
34
- _entrypoint.filter = opts?.filter ?? arg.filter
35
- _entrypoint.gate = opts?.gate ?? arg.gate
36
- _entrypoint.gateParams = opts?.gateParams ?? arg.gateParams
37
- } else if (isClientRouteModel(arg)) {
38
- assertExplicitHandler(arg.route.type, handler as RefedEntrypointHandler<T, R>)
39
- _entrypoint = makeBasicEntrypoint(arg, { ...opts }) as ClientEntrypoint<T, R>
40
- _entrypoint.route = arg
41
- } else {
42
- assertExplicitHandler(arg.route.type, handler as RefedEntrypointHandler<T, R>)
43
- const _route = route(arg, opts?.routeOptions)
44
- _entrypoint = makeBasicEntrypoint(_route, { ...opts }) as ClientEntrypoint<T, R>
45
- _entrypoint.route = _route
46
- }
47
-
48
- _entrypoint.getPath = (partial?: boolean) =>
49
- partial === true ? normalizePath(_entrypoint.route.route.partialPath) : _entrypoint.route.route.path
19
+ const apiHandler: RefedEntrypointHandler<T, R> = ref => apiCallOf(ref).apiHandler
20
+ const _handler = handler ?? (arg.route.route.type === AppType.Backend ? apiHandler : undefined)
21
+
22
+ assertExplicitHandler(arg.route.route.type, handler)
23
+ const routeModel = route(arg.route, opts?.routeOptions)
24
+ _entrypoint = arg as ClientEntrypoint<T, R>
25
+ _entrypoint.route = routeModel
26
+ // Binding adds guards, it never swaps them: what the declaration carries still applies.
27
+ _entrypoint.guards = [...new Set([...(arg.guards ?? []), ...(opts?.guards ?? [])])]
28
+ _entrypoint.filter = opts?.filter ?? arg.filter
29
+ _entrypoint.gate = opts?.gate ?? arg.gate
30
+ _entrypoint.gateParams = opts?.gateParams ?? arg.gateParams
31
+
32
+ _entrypoint.url = ((req?: Partial<R>, urlOpts?: { absolute?: boolean }) =>
33
+ apiCallOf(entrypointHandle).entrypointUrl(req as never, urlOpts)) as ClientEntrypoint<T, R>['url']
34
+
35
+ // An entrypoint carrying a renderer IS a screen: it is addressed by URL, never called over the
36
+ // wire. Saying so here turns what used to be a URL-shaped answer from `call()` into a report.
37
+ _entrypoint.invoke = (handler != null
38
+ ? (async () => {
39
+ throw new SyntaxError(
40
+ `Entrypoint ${_entrypoint.alias} renders a screen - address it with url() instead of call()/invoke()`
41
+ )
42
+ })
43
+ : apiCallOf(entrypointHandle).apiInvoke(opts)) as ClientEntrypoint<T, R>['invoke']
50
44
 
51
- _entrypoint.call = handler != null ? urlCall<T, R>(entrypointHandle, opts) : apiCall<T, R>(entrypointHandle, opts)
45
+ _entrypoint.call = (async (req?: Partial<R>) =>
46
+ (await _entrypoint.invoke(req)).value) as ClientEntrypoint<T, R>['call']
52
47
 
53
48
  _entrypoint.request = ((request: R): R => {
54
49
  if (entrypointHandle.ref == null) {
55
50
  throw SyntaxError(`Try to request uninitialized entrypoint ${JSON.stringify(arg)}`)
56
51
  }
57
- const _request = provideRequest(entrypointHandle.ref.getAlias(), entrypointHandle.ref.getPath()) as R
52
+ const _request = clientRequestHelper.provideRequest(entrypointHandle.ref.alias, entrypointHandle.ref.path()) as R
58
53
 
59
54
  request != null && Object.entries(request).forEach(([key, value]) => {
60
55
  _request[key as keyof R] = value
@@ -67,13 +62,6 @@ export const entrypoint = <T, R extends AbstractRequest = AbstractRequest>(
67
62
 
68
63
  _entrypoint.validate = validate(entrypointHandle)
69
64
 
70
- _entrypoint.reinitializeContext = <T>(context: BasicContext<any>) => {
71
- const newEntrypoint = entrypoint(_entrypoint.route, handler, opts)
72
- newEntrypoint.ctx = context
73
-
74
- return newEntrypoint as T
75
- }
76
-
77
65
  entrypointHandle.ref = _entrypoint
78
66
 
79
67
  return _entrypoint
package/src/failure.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { createLazyService, type BasicContext } from '@owlmeans/context'
2
+ import { logger } from '@owlmeans/log'
3
+ import { ENTRYPOINT_FAILURE_SERVICE } from './consts.js'
4
+ import type { EntrypointFailurePlugin, EntrypointFailureService } from './types.js'
5
+
6
+ const log = logger('client-entrypoint')
7
+
8
+ /** Context-local observers for rejected client calls; observers never replace the thrown error. */
9
+ export const ensureEntrypointFailureService = (ctx: BasicContext<any>): EntrypointFailureService => {
10
+ if (ctx.hasService(ENTRYPOINT_FAILURE_SERVICE)) {
11
+ return ctx.service<EntrypointFailureService>(ENTRYPOINT_FAILURE_SERVICE)
12
+ }
13
+ const plugins = new Map<string, EntrypointFailurePlugin>()
14
+ const service = createLazyService<EntrypointFailureService>(ENTRYPOINT_FAILURE_SERVICE, {
15
+ registerPlugin: plugin => { plugins.set(plugin.alias, plugin) },
16
+ notify: async failure => {
17
+ for (const plugin of plugins.values()) {
18
+ try { await plugin.onFailure(failure) } catch (cause) {
19
+ log.warn('Entrypoint failure observer failed', { plugin: plugin.alias, error: cause })
20
+ }
21
+ }
22
+ },
23
+ })
24
+ ctx.registerService(service)
25
+ return service
26
+ }
@@ -0,0 +1,10 @@
1
+ import type { AbstractRequest } from '@owlmeans/entrypoint'
2
+ import type { JSONSchemaType } from 'ajv'
3
+
4
+ /** Builds and shapes the requests a client sends. */
5
+ export interface ClientRequestHelper {
6
+ /** A minimal cancellable `AbstractRequest` for an entrypoint alias at a path. */
7
+ provideRequest: <T extends {} = {}>(alias: string, path: string) => AbstractRequest<T>
8
+ /** Keeps only the non-null keys of `object` the AJV schema declares. */
9
+ pickPerSchema: <T, R>(object: T, schema: JSONSchemaType<R>) => Partial<R>
10
+ }
package/src/helper.ts CHANGED
@@ -1,55 +1,36 @@
1
- import type { ClientEntrypoint, ClientEntrypointOptions, RefedEntrypointHandler } from './types.js'
2
- import { entrypoint } from './entrypoint.js'
3
- import { isClientRouteModel } from '@owlmeans/client-route'
4
- import type { AbstractRequest, CommonEntrypoint } from '@owlmeans/entrypoint'
5
- import { normalizeHelperParams } from './utils/entrypoint.js'
1
+ import type { AbstractRequest } from '@owlmeans/entrypoint'
6
2
  import type { JSONSchemaType } from "ajv"
7
-
8
- export const elevate = <T = {}, R extends AbstractRequest = AbstractRequest>(
9
- entrypoints: (CommonEntrypoint | ClientEntrypoint<T, R>)[],
10
- alias: string,
11
- handler?: RefedEntrypointHandler<T, R> | ClientEntrypointOptions | boolean,
12
- opts?: ClientEntrypointOptions | boolean
13
- ): ClientEntrypoint<T, R>[] => {
14
- [handler, opts] = normalizeHelperParams(handler, opts)
15
-
16
- const idx = entrypoints.findIndex(({ route }) => route.route.alias === alias)
17
- if (idx === -1) {
18
- throw new SyntaxError(`Entrypoint with alias ${alias} not present`)
19
- }
20
- if (isClientRouteModel(entrypoints[idx].route) && opts?.force !== true) {
21
- throw new SyntaxError(`Entrypoint with alias ${alias} is already elevated`)
3
+ import type { ClientRequestHelper } from './helper/types.js'
4
+
5
+ export const createClientRequestHelper = (): ClientRequestHelper => {
6
+ const provideRequest = <T extends {} = {}>(alias: string, path: string): AbstractRequest<T> => {
7
+ const request = {
8
+ alias,
9
+ params: {},
10
+ headers: {},
11
+ query: {},
12
+ path,
13
+ canceled: false,
14
+ cancel: () => request.canceled = true
15
+ }
16
+
17
+ return request
22
18
  }
23
19
 
24
- entrypoints[idx] = entrypoint(entrypoints[idx], handler, opts)
25
-
26
- return entrypoints as ClientEntrypoint<T, R>[]
20
+ const pickPerSchema = <T, R>(object: T, schema: JSONSchemaType<R>): Partial<R> =>
21
+ Object.keys(schema.properties).reduce(
22
+ (acc, key) => {
23
+ if (object[key as keyof T] != null) {
24
+ acc[key as keyof R] = object[key as keyof T] as unknown as R[keyof R]
25
+ }
26
+ return acc
27
+ }, {} as Partial<R>
28
+ )
29
+
30
+ return { provideRequest, pickPerSchema }
27
31
  }
28
32
 
29
- export const stab: RefedEntrypointHandler<{}> = () => () => {
30
- return void 0 as any
31
- }
32
-
33
- export const provideRequest = <T extends {} = {}>(alias: string, path: string): AbstractRequest<T> => {
34
- const request = {
35
- alias,
36
- params: {},
37
- headers: {},
38
- query: {},
39
- path,
40
- canceled: false,
41
- cancel: () => request.canceled = true
42
- }
43
-
44
- return request
45
- }
33
+ export const clientRequestHelper = createClientRequestHelper()
46
34
 
47
- export const pickPerSchema = <T, R>(object: T, schema: JSONSchemaType<R>): Partial<R> =>
48
- Object.keys(schema.properties).reduce(
49
- (acc, key) => {
50
- if (object[key as keyof T] != null) {
51
- acc[key as keyof R] = object[key as keyof T] as unknown as R[keyof R]
52
- }
53
- return acc
54
- }, {} as Partial<R>
55
- )
35
+ /** @deprecated compat:factory-refactor — use `clientRequestHelper.provideRequest(…)` */
36
+ export const provideRequest = <T extends {} = {}>(alias: string, path: string): AbstractRequest<T> => clientRequestHelper.provideRequest<T>(alias, path)
package/src/index.ts CHANGED
@@ -1,5 +1,9 @@
1
1
 
2
- export * from './helper.js'
3
2
  export type * from './types.js'
4
- export * from './entrypoint.js'
3
+ export type * from './helper/types.js'
5
4
  export * from './errors.js'
5
+ export * from './failure.js'
6
+ export * from './consts.js'
7
+ export * from './protocol.js'
8
+ export { clientRequestHelper, createClientRequestHelper, provideRequest } from './helper.js'
9
+ export { stab } from './stab.js'
@@ -0,0 +1,39 @@
1
+ import { materializeEntrypoint, protocols } from '@owlmeans/entrypoint'
2
+ import type { EntrypointProtocolDeclaration, EntrypointTree } from '@owlmeans/entrypoint'
3
+ import { bindMaterializedEntrypoint } from './entrypoint.js'
4
+ import type {
5
+ ClientEntrypointOptions, ClientProtocolEntrypoint, RefedEntrypointHandler,
6
+ } from './types.js'
7
+
8
+ /** Bind a shared protocol to the client context without changing the declaration itself. */
9
+ export const bind = <Protocol extends EntrypointProtocolDeclaration>(
10
+ protocol: Protocol,
11
+ options?: ClientEntrypointOptions,
12
+ ): ClientProtocolEntrypoint<Protocol> => {
13
+ const bound = Object.assign(bindMaterializedEntrypoint(
14
+ materializeEntrypoint(protocol),
15
+ undefined,
16
+ options,
17
+ ), { protocol })
18
+
19
+ return bound as ClientProtocolEntrypoint<Protocol>
20
+ }
21
+
22
+ /** Materialize every protocol in an exported declaration tree for a browser context. */
23
+ export const bindAll = (tree: EntrypointTree): ClientProtocolEntrypoint<EntrypointProtocolDeclaration>[] =>
24
+ protocols(tree).map(protocol => bind(protocol))
25
+
26
+ /** Bind a frontend protocol to the component that renders it. */
27
+ export const bindScreen = <Protocol extends EntrypointProtocolDeclaration>(
28
+ protocol: Protocol,
29
+ handler: RefedEntrypointHandler,
30
+ options?: ClientEntrypointOptions,
31
+ ): ClientProtocolEntrypoint<Protocol> => {
32
+ const bound = Object.assign(bindMaterializedEntrypoint(
33
+ materializeEntrypoint(protocol),
34
+ handler,
35
+ options,
36
+ ), { protocol })
37
+
38
+ return bound as ClientProtocolEntrypoint<Protocol>
39
+ }
package/src/stab.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { RefedEntrypointHandler } from './types.js'
2
+
3
+ /** The no-op handler of a URL-only frontend binding. */
4
+ export const stab: RefedEntrypointHandler<{}> = () => () => {
5
+ return void 0 as any
6
+ }
package/src/types.ts CHANGED
@@ -1,18 +1,58 @@
1
1
  import type { ClientRouteModel, ClientRouteOptions } from '@owlmeans/client-route'
2
- import type { AbstractRequest, AbstractResponse, CommonEntrypoint, CommonEntrypointOptions, EntrypointHandler, EntrypointOutcome } from '@owlmeans/entrypoint'
2
+ import type {
3
+ AbstractRequest, CommonEntrypoint, CommonEntrypointOptions, EntrypointHandler,
4
+ EntrypointOutcome, EntrypointProtocolDeclaration, RegisteredEntrypoint, RequestOf,
5
+ } from '@owlmeans/entrypoint'
6
+ import type { LazyService } from '@owlmeans/context'
3
7
 
4
8
  export interface ClientEntrypoint<T = {}, R extends ClientRequest = ClientRequest> extends CommonEntrypoint {
5
9
  route: ClientRouteModel
10
+ /**
11
+ * Address the entrypoint and resolve to what it answered. The reply's error is thrown, so a
12
+ * caller that only needs the value never inspects an outcome.
13
+ */
6
14
  call: EntrypointCall<T, R>
15
+ /**
16
+ * The same round trip as {@link ClientEntrypoint.call}, resolving to the value AND the outcome.
17
+ * Use it only where the outcome decides what happens next.
18
+ */
19
+ invoke: EntrypointInvoke<T, R>
20
+ /**
21
+ * Build the URL this entrypoint addresses, with `:params` filled in and the query appended.
22
+ * Absolute when the route belongs to another service, or when `absolute` is asked for.
23
+ */
24
+ url: EntrypointUrl<R>
7
25
  validate: EntrypointFilter<R>
8
- getPath: (partial?: boolean) => string
9
26
  request: (request?: Partial<R>) => R
10
27
  }
11
28
 
29
+ /**
30
+ * The context-bound client view of a protocol. Unlike the legacy `ClientEntrypoint` generic,
31
+ * its request and reply types are read directly from the declaration and cannot be replaced at a
32
+ * call site.
33
+ */
34
+ export interface ClientProtocolEntrypoint<Protocol extends EntrypointProtocolDeclaration> extends Omit<ClientEntrypoint, 'call' | 'invoke' | 'url' | 'validate' | 'request'>, RegisteredEntrypoint<RequestOf<Protocol>, import('@owlmeans/entrypoint').ResponseOf<Protocol>> { readonly protocol: Protocol }
35
+
12
36
  export interface EntrypointCall<T, Req extends ClientRequest = ClientRequest> {
13
- <
14
- Type extends T, R extends Req = Req, P extends AbstractResponse<Type> = AbstractResponse<Type>
15
- >(req?: Partial<R>, res?: P): Promise<[Type, EntrypointOutcome]>
37
+ <Type extends T, R extends Req = Req>(req?: Partial<R>): Promise<Type>
38
+ }
39
+
40
+ export interface EntrypointInvoke<T, Req extends ClientRequest = ClientRequest> {
41
+ <Type extends T, R extends Req = Req>(req?: Partial<R>): Promise<EntrypointReply<Type>>
42
+ }
43
+
44
+ export interface EntrypointReply<T> {
45
+ value: T
46
+ outcome: EntrypointOutcome
47
+ }
48
+
49
+ export interface EntrypointUrl<Req extends ClientRequest = ClientRequest> {
50
+ <R extends Req = Req>(req?: Partial<R>, opts?: EntrypointUrlOptions): Promise<string>
51
+ }
52
+
53
+ export interface EntrypointUrlOptions {
54
+ /** Force a fully qualified URL even when the route belongs to the current service. */
55
+ absolute?: boolean
16
56
  }
17
57
 
18
58
  export interface EntrypointFilter<Req extends AbstractRequest = AbstractRequest> {
@@ -20,14 +60,9 @@ export interface EntrypointFilter<Req extends AbstractRequest = AbstractRequest>
20
60
  }
21
61
 
22
62
  export interface ClientRequest<T extends {} = {}> extends AbstractRequest<T> {
23
- full?: boolean
24
63
  }
25
64
 
26
65
  export interface ClientEntrypointOptions extends CommonEntrypointOptions {
27
- /**
28
- * Force entrypoint to be elevated even if it is already elevated
29
- */
30
- force?: boolean
31
66
  routeOptions?: ClientRouteOptions
32
67
  validateOnCall?: boolean
33
68
  }
@@ -36,6 +71,22 @@ export interface EntrypointRef<T, R extends AbstractRequest = AbstractRequest> {
36
71
  ref?: ClientEntrypoint<T, R>
37
72
  }
38
73
 
39
- export interface RefedEntrypointHandler<T, R extends AbstractRequest = AbstractRequest> {
74
+ export interface RefedEntrypointHandler<T = {}, R extends AbstractRequest = AbstractRequest> {
40
75
  (ref: EntrypointRef<T, R>): EntrypointHandler
41
76
  }
77
+
78
+ export interface EntrypointFailure {
79
+ alias: string
80
+ request: AbstractRequest
81
+ error: unknown
82
+ }
83
+
84
+ export interface EntrypointFailurePlugin {
85
+ alias: string
86
+ onFailure: (failure: EntrypointFailure) => void | Promise<void>
87
+ }
88
+
89
+ export interface EntrypointFailureService extends LazyService {
90
+ registerPlugin: (plugin: EntrypointFailurePlugin) => void
91
+ notify: (failure: EntrypointFailure) => Promise<void>
92
+ }
@@ -1,12 +1,11 @@
1
1
  import Ajv from 'ajv'
2
2
  import type { ErrorObject } from 'ajv'
3
- import type { EntrypointFilter, ClientEntrypointOptions } from '../types.js'
3
+ import type { EntrypointFilter } from '../types.js'
4
4
  import { ClientValidationError } from '../errors.js'
5
5
  import type { AbstractRequest } from '@owlmeans/entrypoint'
6
- import type { EntrypointRef, RefedEntrypointHandler } from '../types.js'
6
+ import type { EntrypointRef } from '../types.js'
7
7
  import formatsPlugin from 'ajv-formats'
8
8
 
9
- export { entrypoint as makeBasicEntrypoint } from '@owlmeans/entrypoint'
10
9
  export { isEntrypoint } from '@owlmeans/entrypoint/utils'
11
10
 
12
11
  const ajv = new Ajv({ strict: false })
@@ -50,17 +49,3 @@ export const validate: <T, R extends AbstractRequest = AbstractRequest>(ref: Ent
50
49
 
51
50
  return true
52
51
  }
53
-
54
- export const normalizeHelperParams = <T, R extends AbstractRequest = AbstractRequest>(
55
- handler?: RefedEntrypointHandler<T, R> | ClientEntrypointOptions | boolean,
56
- opts?: ClientEntrypointOptions | boolean
57
- ): [RefedEntrypointHandler<T, R> | undefined, ClientEntrypointOptions | undefined] => {
58
- if (typeof handler !== 'function' && handler != null) {
59
- opts = handler as ClientEntrypointOptions | boolean
60
- handler = undefined
61
- }
62
-
63
- opts = typeof opts === 'boolean' ? { validateOnCall: opts } : opts
64
-
65
- return [handler, opts]
66
- }
@@ -0,0 +1,15 @@
1
+ import type { AbstractRequest, EntrypointHandler } from '@owlmeans/entrypoint'
2
+ import type { ClientEntrypointOptions, EntrypointInvoke, EntrypointUrlOptions } from '../../types.js'
3
+
4
+ /** How a client entrypoint reaches its backend: the handler, the round trip and the address. */
5
+ export interface ApiCallHelper<T, R extends AbstractRequest = AbstractRequest> {
6
+ /**
7
+ * The handler that carries the entrypoint's call: the transport service bound to its route's
8
+ * protocol, else the API client of the web service its route answers on.
9
+ */
10
+ apiHandler: EntrypointHandler
11
+ /** The round trip behind `invoke()`: builds the request, validates it on demand and notifies failure observers. */
12
+ apiInvoke: (opts?: ClientEntrypointOptions) => EntrypointInvoke<T, R>
13
+ /** The address behind `url()`: `:params` filled in, the query appended, absolute when the route is not local. */
14
+ entrypointUrl: (req?: Partial<R>, opts?: EntrypointUrlOptions) => Promise<string>
15
+ }