@webpieces/http-routing 0.4.868 → 0.4.870
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/package.json +7 -5
- package/src/Binder.d.ts +45 -0
- package/src/Binder.js +64 -0
- package/src/Binder.js.map +1 -0
- package/src/Wiring.d.ts +15 -7
- package/src/Wiring.js +13 -0
- package/src/Wiring.js.map +1 -1
- package/src/WiringCompileAssertions.d.ts +6 -3
- package/src/WiringCompileAssertions.js +31 -3
- package/src/WiringCompileAssertions.js.map +1 -1
- package/src/filters/LogApiFilter.js +1 -1
- package/src/filters/LogApiFilter.js.map +1 -1
- package/src/index.d.ts +5 -2
- package/src/index.js +8 -3
- package/src/index.js.map +1 -1
- package/src/setupRuntime.d.ts +3 -3
- package/src/setupRuntime.js +8 -7
- package/src/setupRuntime.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-routing",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.870",
|
|
4
4
|
"description": "Decorator-based routing with auto-wiring for WebPieces",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
25
|
-
"@webpieces/core-context": "0.4.
|
|
26
|
-
"@webpieces/core-util": "0.4.
|
|
27
|
-
"@webpieces/gcp-identity": "0.4.
|
|
25
|
+
"@webpieces/core-context": "0.4.870",
|
|
26
|
+
"@webpieces/core-util": "0.4.870",
|
|
27
|
+
"@webpieces/gcp-identity": "0.4.870",
|
|
28
28
|
"inversify": "7.10.4",
|
|
29
29
|
"jsonwebtoken": "9.0.2",
|
|
30
30
|
"minimatch": "10.0.1",
|
|
31
|
-
"@webpieces/http-client-core": "0.4.
|
|
31
|
+
"@webpieces/http-client-core": "0.4.870",
|
|
32
|
+
"@webpieces/http-client-node": "0.4.870",
|
|
33
|
+
"@webpieces/cloudtasks-client": "0.4.870"
|
|
32
34
|
}
|
|
33
35
|
}
|
package/src/Binder.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BindToFluentSyntax, ContainerModuleLoadOptions, Newable, ServiceIdentifier } from 'inversify';
|
|
2
|
+
import type { ApiPrototype, ClientFilterDefinition } from '@webpieces/http-client-core';
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link Binder.createRpcClientAndBind}. Both are optional.
|
|
5
|
+
*
|
|
6
|
+
* `token` is an EXTRA identity, needed only when two clients of the SAME api must coexist (e.g. one
|
|
7
|
+
* per deployment). Omitted, the API class itself is the DI token. `filters` are this client's own
|
|
8
|
+
* outbound filters, exactly as ClientHttpFactory.createRpcClient takes them.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ClientBindOptions<T> {
|
|
11
|
+
readonly token?: ServiceIdentifier<T> | undefined;
|
|
12
|
+
readonly filters?: readonly ClientFilterDefinition[] | undefined;
|
|
13
|
+
constructor(token?: ServiceIdentifier<T> | undefined, filters?: readonly ClientFilterDefinition[] | undefined);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Options for {@link Binder.createPubSubClientAndBind}. A Cloud Tasks client has no outbound filter
|
|
17
|
+
* chain, so its options carry the extra `token` only; omitted, the API class is the DI token.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PubSubBindOptions<T> {
|
|
20
|
+
readonly token?: ServiceIdentifier<T> | undefined;
|
|
21
|
+
constructor(token?: ServiceIdentifier<T> | undefined);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The Node host's binder, handed to every {@link BindModule}.configure. One object per load:
|
|
25
|
+
* plain Inversify DI plus the three framework registrations that must stay visible in wiring.ts.
|
|
26
|
+
*/
|
|
27
|
+
export interface Binder {
|
|
28
|
+
/** Plain DI, unchanged Inversify fluent syntax. */
|
|
29
|
+
bind<T>(token: ServiceIdentifier<T>): BindToFluentSyntax<T>;
|
|
30
|
+
/** Creates the RPC client lazily from the already-bound ClientHttpFactory and binds it (singleton). */
|
|
31
|
+
createRpcClientAndBind<T extends object>(api: ApiPrototype<T>, deployment: string, options?: ClientBindOptions<NoInfer<T>>): void;
|
|
32
|
+
/** Creates the Cloud Tasks client lazily from the already-bound ClientCloudTasksFactory and binds it (singleton). */
|
|
33
|
+
createPubSubClientAndBind<T extends object>(api: ApiPrototype<T>, deployment: string, options?: PubSubBindOptions<NoInfer<T>>): void;
|
|
34
|
+
/** Binds a vendor implementation of an external contract AND records the external-contract graph edge. */
|
|
35
|
+
bindExternal<T extends object>(api: ApiPrototype<T>, impl: Newable<NoInfer<T>>): void;
|
|
36
|
+
}
|
|
37
|
+
/** The one Node {@link Binder}: wraps the Inversify load setupRuntime opens for each BindModule. */
|
|
38
|
+
export declare class ContainerBinder implements Binder {
|
|
39
|
+
private readonly options;
|
|
40
|
+
constructor(options: ContainerModuleLoadOptions);
|
|
41
|
+
bind<T>(token: ServiceIdentifier<T>): BindToFluentSyntax<T>;
|
|
42
|
+
createRpcClientAndBind<T extends object>(api: ApiPrototype<T>, deployment: string, options?: ClientBindOptions<NoInfer<T>>): void;
|
|
43
|
+
createPubSubClientAndBind<T extends object>(api: ApiPrototype<T>, deployment: string, options?: PubSubBindOptions<NoInfer<T>>): void;
|
|
44
|
+
bindExternal<T extends object>(api: ApiPrototype<T>, impl: Newable<NoInfer<T>>): void;
|
|
45
|
+
}
|
package/src/Binder.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContainerBinder = exports.PubSubBindOptions = exports.ClientBindOptions = void 0;
|
|
4
|
+
const http_client_node_1 = require("@webpieces/http-client-node");
|
|
5
|
+
const cloudtasks_client_1 = require("@webpieces/cloudtasks-client");
|
|
6
|
+
/**
|
|
7
|
+
* Options for {@link Binder.createRpcClientAndBind}. Both are optional.
|
|
8
|
+
*
|
|
9
|
+
* `token` is an EXTRA identity, needed only when two clients of the SAME api must coexist (e.g. one
|
|
10
|
+
* per deployment). Omitted, the API class itself is the DI token. `filters` are this client's own
|
|
11
|
+
* outbound filters, exactly as ClientHttpFactory.createRpcClient takes them.
|
|
12
|
+
*/
|
|
13
|
+
class ClientBindOptions {
|
|
14
|
+
token;
|
|
15
|
+
filters;
|
|
16
|
+
constructor(token, filters) {
|
|
17
|
+
this.token = token;
|
|
18
|
+
this.filters = filters;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ClientBindOptions = ClientBindOptions;
|
|
22
|
+
/**
|
|
23
|
+
* Options for {@link Binder.createPubSubClientAndBind}. A Cloud Tasks client has no outbound filter
|
|
24
|
+
* chain, so its options carry the extra `token` only; omitted, the API class is the DI token.
|
|
25
|
+
*/
|
|
26
|
+
class PubSubBindOptions {
|
|
27
|
+
token;
|
|
28
|
+
constructor(token) {
|
|
29
|
+
this.token = token;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.PubSubBindOptions = PubSubBindOptions;
|
|
33
|
+
/** The one Node {@link Binder}: wraps the Inversify load setupRuntime opens for each BindModule. */
|
|
34
|
+
class ContainerBinder {
|
|
35
|
+
options;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.options = options;
|
|
38
|
+
}
|
|
39
|
+
bind(token) {
|
|
40
|
+
return this.options.bind(token);
|
|
41
|
+
}
|
|
42
|
+
createRpcClientAndBind(api, deployment, options) {
|
|
43
|
+
const filters = options?.filters;
|
|
44
|
+
this.options
|
|
45
|
+
.bind(options?.token ?? api)
|
|
46
|
+
.toDynamicValue((context) => context
|
|
47
|
+
.get(http_client_node_1.ClientHttpFactory)
|
|
48
|
+
.createRpcClient(api, new http_client_node_1.ClientConfig(deployment), filters))
|
|
49
|
+
.inSingletonScope();
|
|
50
|
+
}
|
|
51
|
+
createPubSubClientAndBind(api, deployment, options) {
|
|
52
|
+
this.options
|
|
53
|
+
.bind(options?.token ?? api)
|
|
54
|
+
.toDynamicValue((context) => context
|
|
55
|
+
.get(cloudtasks_client_1.ClientCloudTasksFactory)
|
|
56
|
+
.createPubSubClient(api, new cloudtasks_client_1.TaskClientConfig(deployment)))
|
|
57
|
+
.inSingletonScope();
|
|
58
|
+
}
|
|
59
|
+
bindExternal(api, impl) {
|
|
60
|
+
this.options.bind(api).to(impl).inSingletonScope();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ContainerBinder = ContainerBinder;
|
|
64
|
+
//# sourceMappingURL=Binder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Binder.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/Binder.ts"],"names":[],"mappings":";;;AAQA,kEAA8E;AAC9E,oEAAyF;AAEzF;;;;;;GAMG;AACH,MAAa,iBAAiB;IAEN;IACA;IAFpB,YACoB,KAA4B,EAC5B,OAA2C;QAD3C,UAAK,GAAL,KAAK,CAAuB;QAC5B,YAAO,GAAP,OAAO,CAAoC;IAC5D,CAAC;CACP;AALD,8CAKC;AAED;;;GAGG;AACH,MAAa,iBAAiB;IACE;IAA5B,YAA4B,KAA4B;QAA5B,UAAK,GAAL,KAAK,CAAuB;IAAG,CAAC;CAC/D;AAFD,8CAEC;AAyBD,oGAAoG;AACpG,MAAa,eAAe;IACK;IAA7B,YAA6B,OAAmC;QAAnC,YAAO,GAAP,OAAO,CAA4B;IAAG,CAAC;IAEpE,IAAI,CAAI,KAA2B;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAI,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,sBAAsB,CAClB,GAAoB,EACpB,UAAkB,EAClB,OAAuC;QAEvC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QACjC,IAAI,CAAC,OAAO;aACP,IAAI,CAAI,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC;aAC9B,cAAc,CAAC,CAAC,OAA0B,EAAE,EAAE,CAC3C,OAAO;aACF,GAAG,CAAC,oCAAiB,CAAC;aACtB,eAAe,CAAC,GAAG,EAAE,IAAI,+BAAY,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CACnE;aACA,gBAAgB,EAAE,CAAC;IAC5B,CAAC;IAED,yBAAyB,CACrB,GAAoB,EACpB,UAAkB,EAClB,OAAuC;QAEvC,IAAI,CAAC,OAAO;aACP,IAAI,CAAI,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC;aAC9B,cAAc,CAAC,CAAC,OAA0B,EAAE,EAAE,CAC3C,OAAO;aACF,GAAG,CAAC,2CAAuB,CAAC;aAC5B,kBAAkB,CAAC,GAAG,EAAE,IAAI,oCAAgB,CAAC,UAAU,CAAC,CAAC,CACjE;aACA,gBAAgB,EAAE,CAAC;IAC5B,CAAC;IAED,YAAY,CAAmB,GAAoB,EAAE,IAAyB;QAC1E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAI,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC1D,CAAC;CACJ;AAzCD,0CAyCC","sourcesContent":["import type {\n BindToFluentSyntax,\n ContainerModuleLoadOptions,\n Newable,\n ResolutionContext,\n ServiceIdentifier,\n} from 'inversify';\nimport type { ApiPrototype, ClientFilterDefinition } from '@webpieces/http-client-core';\nimport { ClientConfig, ClientHttpFactory } from '@webpieces/http-client-node';\nimport { ClientCloudTasksFactory, TaskClientConfig } from '@webpieces/cloudtasks-client';\n\n/**\n * Options for {@link Binder.createRpcClientAndBind}. Both are optional.\n *\n * `token` is an EXTRA identity, needed only when two clients of the SAME api must coexist (e.g. one\n * per deployment). Omitted, the API class itself is the DI token. `filters` are this client's own\n * outbound filters, exactly as ClientHttpFactory.createRpcClient takes them.\n */\nexport class ClientBindOptions<T> {\n constructor(\n public readonly token?: ServiceIdentifier<T>,\n public readonly filters?: readonly ClientFilterDefinition[],\n ) {}\n}\n\n/**\n * Options for {@link Binder.createPubSubClientAndBind}. A Cloud Tasks client has no outbound filter\n * chain, so its options carry the extra `token` only; omitted, the API class is the DI token.\n */\nexport class PubSubBindOptions<T> {\n constructor(public readonly token?: ServiceIdentifier<T>) {}\n}\n\n/**\n * The Node host's binder, handed to every {@link BindModule}.configure. One object per load:\n * plain Inversify DI plus the three framework registrations that must stay visible in wiring.ts.\n */\nexport interface Binder {\n /** Plain DI, unchanged Inversify fluent syntax. */\n bind<T>(token: ServiceIdentifier<T>): BindToFluentSyntax<T>;\n /** Creates the RPC client lazily from the already-bound ClientHttpFactory and binds it (singleton). */\n createRpcClientAndBind<T extends object>(\n api: ApiPrototype<T>,\n deployment: string,\n options?: ClientBindOptions<NoInfer<T>>,\n ): void;\n /** Creates the Cloud Tasks client lazily from the already-bound ClientCloudTasksFactory and binds it (singleton). */\n createPubSubClientAndBind<T extends object>(\n api: ApiPrototype<T>,\n deployment: string,\n options?: PubSubBindOptions<NoInfer<T>>,\n ): void;\n /** Binds a vendor implementation of an external contract AND records the external-contract graph edge. */\n bindExternal<T extends object>(api: ApiPrototype<T>, impl: Newable<NoInfer<T>>): void;\n}\n\n/** The one Node {@link Binder}: wraps the Inversify load setupRuntime opens for each BindModule. */\nexport class ContainerBinder implements Binder {\n constructor(private readonly options: ContainerModuleLoadOptions) {}\n\n bind<T>(token: ServiceIdentifier<T>): BindToFluentSyntax<T> {\n return this.options.bind<T>(token);\n }\n\n createRpcClientAndBind<T extends object>(\n api: ApiPrototype<T>,\n deployment: string,\n options?: ClientBindOptions<NoInfer<T>>,\n ): void {\n const filters = options?.filters;\n this.options\n .bind<T>(options?.token ?? api)\n .toDynamicValue((context: ResolutionContext) =>\n context\n .get(ClientHttpFactory)\n .createRpcClient(api, new ClientConfig(deployment), filters),\n )\n .inSingletonScope();\n }\n\n createPubSubClientAndBind<T extends object>(\n api: ApiPrototype<T>,\n deployment: string,\n options?: PubSubBindOptions<NoInfer<T>>,\n ): void {\n this.options\n .bind<T>(options?.token ?? api)\n .toDynamicValue((context: ResolutionContext) =>\n context\n .get(ClientCloudTasksFactory)\n .createPubSubClient(api, new TaskClientConfig(deployment)),\n )\n .inSingletonScope();\n }\n\n bindExternal<T extends object>(api: ApiPrototype<T>, impl: Newable<NoInfer<T>>): void {\n this.options.bind<T>(api).to(impl).inSingletonScope();\n }\n}\n"]}
|
package/src/Wiring.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type { ContainerModuleLoadOptions } from 'inversify';
|
|
2
1
|
import type { AnyContextKey } from '@webpieces/core-util';
|
|
3
|
-
import type { Wiring as
|
|
2
|
+
import type { BindModule as HostBindModule, Wiring as HostWiring, AppWiring as HostAppWiring } from '@webpieces/http-client-core';
|
|
3
|
+
import type { Binder } from './Binder';
|
|
4
4
|
import type { WebpiecesRouter } from './WebpiecesRouter';
|
|
5
|
-
/** Named DI declaration
|
|
6
|
-
export interface
|
|
7
|
-
configure(
|
|
5
|
+
/** Named DI declaration. setupRuntime hands it the Node {@link Binder} over one Inversify load. */
|
|
6
|
+
export interface BindModule extends HostBindModule<Binder> {
|
|
7
|
+
configure(binder: Binder): void | Promise<void>;
|
|
8
8
|
}
|
|
9
|
+
/** api -> controller routes and filters. Node-only: only a server has routes. */
|
|
9
10
|
export interface RouteModule {
|
|
10
11
|
configure(router: WebpiecesRouter): void;
|
|
11
12
|
}
|
|
12
|
-
export interface Wiring extends
|
|
13
|
+
export interface Wiring extends HostWiring<BindModule> {
|
|
14
|
+
getRouteModules(): RouteModule[];
|
|
13
15
|
}
|
|
14
16
|
/** Applications retain ownership of their server context headers. */
|
|
15
|
-
export interface AppWiring extends
|
|
17
|
+
export interface AppWiring extends HostAppWiring<BindModule, Wiring>, Wiring {
|
|
16
18
|
getHeaders(): AnyContextKey[];
|
|
17
19
|
}
|
|
20
|
+
/** The app's modules first, then each selected library's, in selection order. */
|
|
21
|
+
export declare class NodeWiringModules {
|
|
22
|
+
readonly bindModules: BindModule[];
|
|
23
|
+
readonly routeModules: RouteModule[];
|
|
24
|
+
constructor(app: AppWiring);
|
|
25
|
+
}
|
package/src/Wiring.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeWiringModules = void 0;
|
|
4
|
+
const http_client_core_1 = require("@webpieces/http-client-core");
|
|
5
|
+
/** The app's modules first, then each selected library's, in selection order. */
|
|
6
|
+
class NodeWiringModules {
|
|
7
|
+
bindModules;
|
|
8
|
+
routeModules;
|
|
9
|
+
constructor(app) {
|
|
10
|
+
const order = new http_client_core_1.WiringOrder(app, app.getWirings());
|
|
11
|
+
this.bindModules = order.collect((wiring) => wiring.getBindModules());
|
|
12
|
+
this.routeModules = order.collect((wiring) => wiring.getRouteModules());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.NodeWiringModules = NodeWiringModules;
|
|
3
16
|
//# sourceMappingURL=Wiring.js.map
|
package/src/Wiring.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wiring.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/Wiring.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"Wiring.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/Wiring.ts"],"names":[],"mappings":";;;AAMA,kEAA0D;AAuB1D,iFAAiF;AACjF,MAAa,iBAAiB;IACjB,WAAW,CAAe;IAC1B,YAAY,CAAgB;IAErC,YAAY,GAAc;QACtB,MAAM,KAAK,GAAG,IAAI,8BAAW,CAAS,GAAG,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;IACpF,CAAC;CACJ;AATD,8CASC","sourcesContent":["import type { AnyContextKey } from '@webpieces/core-util';\nimport type {\n BindModule as HostBindModule,\n Wiring as HostWiring,\n AppWiring as HostAppWiring,\n} from '@webpieces/http-client-core';\nimport { WiringOrder } from '@webpieces/http-client-core';\nimport type { Binder } from './Binder';\nimport type { WebpiecesRouter } from './WebpiecesRouter';\n\n/** Named DI declaration. setupRuntime hands it the Node {@link Binder} over one Inversify load. */\nexport interface BindModule extends HostBindModule<Binder> {\n configure(binder: Binder): void | Promise<void>;\n}\n\n/** api -> controller routes and filters. Node-only: only a server has routes. */\nexport interface RouteModule {\n configure(router: WebpiecesRouter): void;\n}\n\nexport interface Wiring extends HostWiring<BindModule> {\n getRouteModules(): RouteModule[];\n}\n\n/** Applications retain ownership of their server context headers. */\nexport interface AppWiring extends HostAppWiring<BindModule, Wiring>, Wiring {\n getHeaders(): AnyContextKey[];\n}\n\n/** The app's modules first, then each selected library's, in selection order. */\nexport class NodeWiringModules {\n readonly bindModules: BindModule[];\n readonly routeModules: RouteModule[];\n\n constructor(app: AppWiring) {\n const order = new WiringOrder<Wiring>(app, app.getWirings());\n this.bindModules = order.collect((wiring: Wiring) => wiring.getBindModules());\n this.routeModules = order.collect((wiring: Wiring) => wiring.getRouteModules());\n }\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { AppWiring, BindModule, RouteModule, Wiring } from './Wiring';
|
|
2
|
+
import type { Binder } from './Binder';
|
|
3
|
+
/** Checked by tsc, never invoked; vitest strips types, so these guarantees live in compiled source. */
|
|
3
4
|
export declare class WiringCompileAssertions {
|
|
4
|
-
check(binding:
|
|
5
|
+
check(binding: BindModule, routing: RouteModule): void;
|
|
6
|
+
channels(wiring: Wiring, app: AppWiring): void;
|
|
7
|
+
binder(binder: Binder, strings: symbol): void;
|
|
5
8
|
}
|
|
@@ -1,16 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WiringCompileAssertions = void 0;
|
|
4
|
-
|
|
4
|
+
const Binder_1 = require("./Binder");
|
|
5
|
+
class StringApi {
|
|
6
|
+
}
|
|
7
|
+
class NumberApi {
|
|
8
|
+
}
|
|
9
|
+
class StringClient extends StringApi {
|
|
10
|
+
read() {
|
|
11
|
+
return 'value';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Checked by tsc, never invoked; vitest strips types, so these guarantees live in compiled source. */
|
|
5
15
|
class WiringCompileAssertions {
|
|
6
16
|
check(binding, routing) {
|
|
7
|
-
// @ts-expect-error A
|
|
17
|
+
// @ts-expect-error A route module cannot configure a binder.
|
|
8
18
|
const invalidBinding = routing;
|
|
9
|
-
// @ts-expect-error A
|
|
19
|
+
// @ts-expect-error A bind module cannot configure a router.
|
|
10
20
|
const invalidRoute = binding;
|
|
11
21
|
void invalidBinding;
|
|
12
22
|
void invalidRoute;
|
|
13
23
|
}
|
|
24
|
+
channels(wiring, app) {
|
|
25
|
+
// @ts-expect-error The getters were renamed: getBindModules / getRouteModules.
|
|
26
|
+
wiring.getBindingModules();
|
|
27
|
+
// @ts-expect-error The getters were renamed: getBindModules / getRouteModules.
|
|
28
|
+
app.getRoutingModules();
|
|
29
|
+
}
|
|
30
|
+
binder(binder, strings) {
|
|
31
|
+
binder.createRpcClientAndBind(StringApi, 'strings');
|
|
32
|
+
binder.createRpcClientAndBind(StringApi, 'strings', new Binder_1.ClientBindOptions(strings));
|
|
33
|
+
// @ts-expect-error The deployment is a required argument.
|
|
34
|
+
binder.createRpcClientAndBind(StringApi);
|
|
35
|
+
// @ts-expect-error Destination wrappers were removed; pass the deployment string.
|
|
36
|
+
binder.createRpcClientAndBind(StringApi, { serviceName: 'strings' });
|
|
37
|
+
binder.createPubSubClientAndBind(StringApi, 'strings', new Binder_1.PubSubBindOptions(strings));
|
|
38
|
+
binder.bindExternal(StringApi, StringClient);
|
|
39
|
+
// @ts-expect-error The vendor implementation must implement the external contract.
|
|
40
|
+
binder.bindExternal(NumberApi, StringClient);
|
|
41
|
+
}
|
|
14
42
|
}
|
|
15
43
|
exports.WiringCompileAssertions = WiringCompileAssertions;
|
|
16
44
|
//# sourceMappingURL=WiringCompileAssertions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WiringCompileAssertions.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/WiringCompileAssertions.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"WiringCompileAssertions.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/WiringCompileAssertions.ts"],"names":[],"mappings":";;;AAEA,qCAAgE;AAEhE,MAAe,SAAS;CAEvB;AACD,MAAe,SAAS;CAEvB;AACD,MAAM,YAAa,SAAQ,SAAS;IAChC,IAAI;QACA,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,uGAAuG;AACvG,MAAa,uBAAuB;IAChC,KAAK,CAAC,OAAmB,EAAE,OAAoB;QAC3C,6DAA6D;QAC7D,MAAM,cAAc,GAAe,OAAO,CAAC;QAC3C,4DAA4D;QAC5D,MAAM,YAAY,GAAgB,OAAO,CAAC;QAC1C,KAAK,cAAc,CAAC;QACpB,KAAK,YAAY,CAAC;IACtB,CAAC;IAED,QAAQ,CAAC,MAAc,EAAE,GAAc;QACnC,+EAA+E;QAC/E,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC3B,+EAA+E;QAC/E,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,OAAe;QAClC,MAAM,CAAC,sBAAsB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACpD,MAAM,CAAC,sBAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,0BAAiB,CAAY,OAAO,CAAC,CAAC,CAAC;QAC/F,0DAA0D;QAC1D,MAAM,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;QACzC,kFAAkF;QAClF,MAAM,CAAC,sBAAsB,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,MAAM,CAAC,yBAAyB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,0BAAiB,CAAY,OAAO,CAAC,CAAC,CAAC;QAClG,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAC7C,mFAAmF;QACnF,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC;CACJ;AA7BD,0DA6BC","sourcesContent":["import type { AppWiring, BindModule, RouteModule, Wiring } from './Wiring';\nimport type { Binder } from './Binder';\nimport { ClientBindOptions, PubSubBindOptions } from './Binder';\n\nabstract class StringApi {\n abstract read(): string;\n}\nabstract class NumberApi {\n abstract read(): number;\n}\nclass StringClient extends StringApi {\n read(): string {\n return 'value';\n }\n}\n\n/** Checked by tsc, never invoked; vitest strips types, so these guarantees live in compiled source. */\nexport class WiringCompileAssertions {\n check(binding: BindModule, routing: RouteModule): void {\n // @ts-expect-error A route module cannot configure a binder.\n const invalidBinding: BindModule = routing;\n // @ts-expect-error A bind module cannot configure a router.\n const invalidRoute: RouteModule = binding;\n void invalidBinding;\n void invalidRoute;\n }\n\n channels(wiring: Wiring, app: AppWiring): void {\n // @ts-expect-error The getters were renamed: getBindModules / getRouteModules.\n wiring.getBindingModules();\n // @ts-expect-error The getters were renamed: getBindModules / getRouteModules.\n app.getRoutingModules();\n }\n\n binder(binder: Binder, strings: symbol): void {\n binder.createRpcClientAndBind(StringApi, 'strings');\n binder.createRpcClientAndBind(StringApi, 'strings', new ClientBindOptions<StringApi>(strings));\n // @ts-expect-error The deployment is a required argument.\n binder.createRpcClientAndBind(StringApi);\n // @ts-expect-error Destination wrappers were removed; pass the deployment string.\n binder.createRpcClientAndBind(StringApi, { serviceName: 'strings' });\n binder.createPubSubClientAndBind(StringApi, 'strings', new PubSubBindOptions<StringApi>(strings));\n binder.bindExternal(StringApi, StringClient);\n // @ts-expect-error The vendor implementation must implement the external contract.\n binder.bindExternal(NumberApi, StringClient);\n }\n}\n"]}
|
|
@@ -67,7 +67,7 @@ let LogApiFilter = class LogApiFilter extends core_util_2.Filter {
|
|
|
67
67
|
const info = new core_util_1.ApiMethodInfo('server', rm.apiName ?? rm.controllerClassName ?? 'Unknown', rm.methodName, rm.controllerClassName, rm.mask,
|
|
68
68
|
// The server half of the same self-reference: `[API-server-req]` for a log-INGEST
|
|
69
69
|
// endpoint is the shipped line arriving one hop later. Same flag, same reader.
|
|
70
|
-
rm.
|
|
70
|
+
rm.noLogging, rm.hideProgress, rm.allowUpgradeInFlight);
|
|
71
71
|
const response = await this.logApiCall.execute(info, meta.requestDto, method);
|
|
72
72
|
return new WpResponse_1.WpResponse(response);
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogApiFilter.js","sourceRoot":"","sources":["../../../../../../packages/http/http-routing/src/filters/LogApiFilter.ts"],"names":[],"mappings":";;;;AAAA,0DAIiC;AACjC,oDAK8B;AAC9B,oDAAuD;AACvD,8CAA2C;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,GAAG,GAAG,sBAAU,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAI1C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,kBAAuC;IACrE;;;;OAIG;IACc,UAAU,GAAG,IAAI,0BAAc,CAAC,IAAI,2CAA4B,EAAE,CAAC,CAAC;IAErF,iGAAiG;IACjG,KAAK,CAAC,MAAM,CACR,IAAgB,EAChB,UAAoD;QAEpD,+DAA+D;QAC/D,uFAAuF;QACvF,MAAM,MAAM,GAAG,KAAK,IAAsB,EAAE;YACxC,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjD,OAAO,UAAU,CAAC,QAAQ,CAAC;QAC/B,CAAC,CAAC;QAEF,gDAAgD;QAChD,+FAA+F;QAC/F,+FAA+F;QAC/F,iGAAiG;QACjG,sGAAsG;QACtG,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAE1B,iGAAiG;QACjG,4FAA4F;QAC5F,kGAAkG;QAClG,kGAAkG;QAClG,oGAAoG;QACpG,IAAI,EAAE,CAAC,mBAAmB,EAAE,CAAC;YACzB,6BAAc,CAAC,YAAY,CAAC,gCAAoB,CAAC,UAAU,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC;QACzF,CAAC;QACD,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;YAChB,6BAAc,CAAC,YAAY,CAAC,gCAAoB,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,yBAAa,CAC1B,QAAQ,EACR,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,mBAAmB,IAAI,SAAS,EACjD,EAAE,CAAC,UAAU,EACb,EAAE,CAAC,mBAAmB,EACtB,EAAE,CAAC,IAAI;QACP,kFAAkF;QAClF,+EAA+E;QAC/E,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"LogApiFilter.js","sourceRoot":"","sources":["../../../../../../packages/http/http-routing/src/filters/LogApiFilter.ts"],"names":[],"mappings":";;;;AAAA,0DAIiC;AACjC,oDAK8B;AAC9B,oDAAuD;AACvD,8CAA2C;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,GAAG,GAAG,sBAAU,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;AAI1C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,kBAAuC;IACrE;;;;OAIG;IACc,UAAU,GAAG,IAAI,0BAAc,CAAC,IAAI,2CAA4B,EAAE,CAAC,CAAC;IAErF,iGAAiG;IACj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AAtDY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,wCAAyB,GAAE;IAC5B,iGAAiG;GACpF,YAAY,CAsDxB","sourcesContent":["import {\n provideFrameworkSingleton,\n RequestContext,\n RequestContextApiCallContext,\n} from '@webpieces/core-context';\nimport {\n LogManager,\n WebpiecesCoreHeaders,\n LogApiCallImpl,\n ApiMethodInfo,\n} from '@webpieces/core-util';\nimport { Filter, Service } from '@webpieces/core-util';\nimport { WpResponse } from '../WpResponse';\nimport { MethodMeta } from '../MethodMeta';\n\n/**\n * LogApiFilter - the OUTERMOST fixed framework filter (auto-installed at priority 1,000,000 on\n * every route, above AuthFilter). It logs the request AND the response/failure for EVERY call —\n * over HTTP or via createApiClient — and stamps the routed controller identity so every log line\n * of the request carries [Controller.method].\n *\n * Being outermost is deliberate: a request rejected by AuthFilter (401), or any other below-it\n * filter, is STILL logged here with its request body and controller identity. (The former\n * ErrorLogFilter sat above auth but logged only a bare error line — no request, no identity;\n * LogApiFilter replaces it and subsumes its error-logging via LogApiCall.)\n *\n * Logging patterns (via LogApiCall):\n * - [API-server-req] Class.method request={...}\n * - [API-server-resp-SUCCESS] Class.method response={...}\n * - [API-server-resp-FAIL] Class.method error=... (server errors: 500, 502, 504)\n * - [API-server-resp-OTHER] Class.method errorType=... error=... (user errors: 400, 401, 403, 404, 266)\n *\n * User errors (ApiUnauthorizedError, ApiBadRequestError, etc.) are logged as OTHER, not FAIL,\n * because they are expected behavior from the server's perspective. LogApiCall re-throws the\n * error unchanged; the transport (express adapter, or another framework's adapter) maps\n * API error subclasses → HTTP status, so in-process and HTTP paths log identically.\n *\n * Headers are read from RequestContext (NOT from meta.requestHeaders which is undefined\n * after ContextFilter runs).\n */\nconst log = LogManager.getLogger('LogApiFilter');\n\n@provideFrameworkSingleton()\n// webpieces-disable no-any-unknown -- Filter generic params use unknown for response flexibility\nexport class LogApiFilter extends Filter<MethodMeta, WpResponse<unknown>> {\n /**\n * The SERVER's api-call log seam, built here around the RequestContext-backed ApiCallContext.\n * This is the server's inbound construction point; the outbound ones live in each client package\n * (NodeProxyClient, TaskProxyClient, BrowserProxyClient).\n */\n private readonly logApiCall = new LogApiCallImpl(new RequestContextApiCallContext());\n\n // webpieces-disable no-any-unknown -- Filter generic params use unknown for response flexibility\n async filter(\n meta: MethodMeta,\n nextFilter: Service<MethodMeta, WpResponse<unknown>>,\n ): Promise<WpResponse<unknown>> {\n // Wrap nextFilter.invoke in a method that returns the response\n // webpieces-disable no-any-unknown -- response DTO is erased at the api/proxy boundary\n const method = async (): Promise<unknown> => {\n const wpResponse = await nextFilter.invoke(meta);\n return wpResponse.response;\n };\n\n // LogApiCall logs the text lines AND stamps the\n // structured `api={method:{side:'server',...},...}` tag into RequestContext, so every log line\n // during the request carries jsonPayload.api. Correlation fields (requestId, ...) are added by\n // the backend. apiClass is the CONTRACT name (routeMeta.apiName, e.g. 'SaveApi') so a server log\n // line MATCHES the client's for the same call; controllerName keeps the impl (e.g. 'SaveController').\n const rm = meta.routeMeta;\n\n // Stamp the routed endpoint's IMPLEMENTATION identity onto the request context so EVERY log line\n // of this request (not just the api req/resp lines) carries the concrete controller class +\n // handler method name — what you actually grep for, and more useful than the raw requestPath. GCP\n // gets them as separate jsonPayload.controller / jsonPayload.method; the local console formatters\n // render them together as a compact [Controller.method] bracket. They clear with the request scope.\n if (rm.controllerClassName) {\n RequestContext.putUntrusted(WebpiecesCoreHeaders.CONTROLLER, rm.controllerClassName);\n }\n if (rm.methodName) {\n RequestContext.putUntrusted(WebpiecesCoreHeaders.METHOD, rm.methodName);\n }\n\n const info = new ApiMethodInfo(\n 'server',\n rm.apiName ?? rm.controllerClassName ?? 'Unknown',\n rm.methodName,\n rm.controllerClassName,\n rm.mask,\n // The server half of the same self-reference: `[API-server-req]` for a log-INGEST\n // endpoint is the shipped line arriving one hop later. Same flag, same reader.\n rm.noLogging,\n rm.hideProgress,\n rm.allowUpgradeInFlight,\n );\n const response = await this.logApiCall.execute(info, meta.requestDto, method);\n return new WpResponse(response);\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ export { MethodMeta } from './MethodMeta';
|
|
|
13
13
|
export { RouteHandler } from './RouteHandler';
|
|
14
14
|
export { LogApiFilter } from './filters/LogApiFilter';
|
|
15
15
|
export { FilterMatcher, HttpFilter } from './FilterMatcher';
|
|
16
|
-
export type { Wiring, AppWiring,
|
|
16
|
+
export type { Wiring, AppWiring, BindModule, RouteModule } from './Wiring';
|
|
17
|
+
export { NodeWiringModules } from './Wiring';
|
|
18
|
+
export type { Binder } from './Binder';
|
|
19
|
+
export { ContainerBinder, ClientBindOptions, PubSubBindOptions } from './Binder';
|
|
17
20
|
export { ApiFactory } from './ApiFactory';
|
|
18
21
|
export { ApiClient, ApiClientProxy } from './ApiClient';
|
|
19
22
|
export { AuthConfig, AUTH_CONFIG, AuthenticatedCaller, AuthenticatedMachineIdentity, AUTHENTICATED_CALLER_KEY, SharedSecrets, } from './AuthConfig';
|
|
@@ -26,4 +29,4 @@ export { WebpiecesConfig, WEBPIECES_CONFIG_TOKEN } from './WebpiecesConfig';
|
|
|
26
29
|
export { AuthorizationHook, AuthorizationService, CanonicalUserRoles, AUTHORIZATION_HOOK, VERIFIED_MACHINE_CALLER, VerifiedMachineCaller } from './AuthorizationHook';
|
|
27
30
|
export { AuthorizedApiDocument } from './AuthorizedApiDocument';
|
|
28
31
|
export type { ApiDocumentObject, ApiDocumentValue } from './AuthorizedApiDocument';
|
|
29
|
-
export { WiringPolicy
|
|
32
|
+
export { WiringPolicy } from '@webpieces/http-client-core';
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDocumentDesign = exports.DocumentDesign = exports.EXTERNAL = exports.CRON = exports.CLOUDTASKS = exports.RPC = exports.WRITE = exports.WRITE_IDEMPOTENT = exports.READ = exports.POST = exports.GET = exports.METADATA_KEYS = exports.HttpContractMapper = exports.RouteMetadataFactory = exports.RouteMetadata = exports.AuthMeta = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.assertEveryEndpointHasAuthMode = exports.getAuthMeta = exports.isApiPath = exports.isRawBody = exports.isFormPost = exports.getHttpParameterDeclarations = exports.getEndpointOperation = exports.getEndpointHttpMethod = exports.getEndpointOptions = exports.getEndpoints = exports.getApiPath = exports.Queue = exports.PubSub = exports.Rpc = exports.getAuthorization = exports.AuthorizationType = exports.WpAuthorization = exports.apiKey = exports.webhook = exports.sharedSecret = exports.oidc = exports.jwt = exports.isLocalOnly = exports.WpLocalOnly = exports.WpAuth = exports.WpAuthPublic = exports.QueryParam = exports.PathParam = exports.Endpoint = exports.ApiPath = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
4
|
+
exports.CanonicalUserRoles = exports.AuthorizationService = exports.AuthorizationHook = exports.WEBPIECES_CONFIG_TOKEN = exports.WebpiecesConfig = exports.RuntimeSetupOptions = exports.setupRuntime = exports.WebpiecesRouterFactory = exports.WebpiecesRouter = exports.DefaultJwtMintRequest = exports.DefaultJwtHook = exports.DefaultOidcVerifier = exports.API_KEY_HOOK = exports.ApiKeyHook = exports.WEBHOOK_AUTH_CALLBACK = exports.WebhookAuthCallback = exports.OIDC_HOOK = exports.OidcHook = exports.JWT_HOOK = exports.MintedJwt = exports.JwtHook = exports.SharedSecrets = exports.AUTHENTICATED_CALLER_KEY = exports.AuthenticatedMachineIdentity = exports.AuthenticatedCaller = exports.AUTH_CONFIG = exports.AuthConfig = exports.ApiClient = exports.PubSubBindOptions = exports.ClientBindOptions = exports.ContainerBinder = exports.NodeWiringModules = exports.FilterMatcher = exports.LogApiFilter = exports.RouteHandler = exports.MethodMeta = exports.InvocationAuthentication = exports.AuthenticatedCallerContext = exports.WpResponse = exports.RawRequest = exports.HttpRequest = exports.FilterDefinition = exports.RouteDefinition = exports.ApiRoutingFactory = exports.buildFrameworkModule = exports.provideFrameworkSingletonDefaultForApi = exports.provideFrameworkSingleton = exports.provideSingletonDefaultForApi = exports.ROUTING_METADATA_KEYS = exports.SourceFile = void 0;
|
|
5
|
+
exports.WiringPolicy = exports.AuthorizedApiDocument = exports.VerifiedMachineCaller = exports.VERIFIED_MACHINE_CALLER = exports.AUTHORIZATION_HOOK = void 0;
|
|
6
6
|
// Re-export API decorators from core-util for convenience
|
|
7
7
|
var core_util_1 = require("@webpieces/core-util");
|
|
8
8
|
Object.defineProperty(exports, "ApiPath", { enumerable: true, get: function () { return core_util_1.ApiPath; } });
|
|
@@ -102,6 +102,12 @@ Object.defineProperty(exports, "LogApiFilter", { enumerable: true, get: function
|
|
|
102
102
|
// Filter matching
|
|
103
103
|
var FilterMatcher_1 = require("./FilterMatcher");
|
|
104
104
|
Object.defineProperty(exports, "FilterMatcher", { enumerable: true, get: function () { return FilterMatcher_1.FilterMatcher; } });
|
|
105
|
+
var Wiring_1 = require("./Wiring");
|
|
106
|
+
Object.defineProperty(exports, "NodeWiringModules", { enumerable: true, get: function () { return Wiring_1.NodeWiringModules; } });
|
|
107
|
+
var Binder_1 = require("./Binder");
|
|
108
|
+
Object.defineProperty(exports, "ContainerBinder", { enumerable: true, get: function () { return Binder_1.ContainerBinder; } });
|
|
109
|
+
Object.defineProperty(exports, "ClientBindOptions", { enumerable: true, get: function () { return Binder_1.ClientBindOptions; } });
|
|
110
|
+
Object.defineProperty(exports, "PubSubBindOptions", { enumerable: true, get: function () { return Binder_1.PubSubBindOptions; } });
|
|
105
111
|
var ApiClient_1 = require("./ApiClient");
|
|
106
112
|
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return ApiClient_1.ApiClient; } });
|
|
107
113
|
// Auth: the app-provided, container-bound pieces the framework AuthFilter injects.
|
|
@@ -157,5 +163,4 @@ var AuthorizedApiDocument_1 = require("./AuthorizedApiDocument");
|
|
|
157
163
|
Object.defineProperty(exports, "AuthorizedApiDocument", { enumerable: true, get: function () { return AuthorizedApiDocument_1.AuthorizedApiDocument; } });
|
|
158
164
|
var http_client_core_1 = require("@webpieces/http-client-core");
|
|
159
165
|
Object.defineProperty(exports, "WiringPolicy", { enumerable: true, get: function () { return http_client_core_1.WiringPolicy; } });
|
|
160
|
-
Object.defineProperty(exports, "ExternalContractUse", { enumerable: true, get: function () { return http_client_core_1.ExternalContractUse; } });
|
|
161
166
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/index.ts"],"names":[],"mappings":";;;;;AAAA,0DAA0D;AAC1D,kDA6C8B;AA5C1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,mGAAA,MAAM,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,gGAAA,GAAG,OAAA;AAAE,iGAAA,IAAI,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,oGAAA,OAAO,OAAA;AAAE,mGAAA,MAAM,OAAA;AAC1E,4GAAA,eAAe,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AACpD,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AACL,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAClB,kHAAA,qBAAqB,OAAA;AACrB,iHAAA,oBAAoB,OAAA;AACpB,yHAAA,4BAA4B,OAAA;AAC5B,uGAAA,UAAU,OAAA;AACV,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,wGAAA,WAAW,OAAA;AACX,2HAAA,8BAA8B,OAAA;AAC9B,uGAAA,UAAU,OAAA;AACV,0GAAA,aAAa,OAAA;AACb,oHAA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AACxF,0FAA0F;AAC1F,uDAAsD;AAA7C,4GAAA,YAAY,OAAA;AAErB,oFAAoF;AACpF,sFAAsF;AAEtF,kBAAkB;AAClB,iDAA4D;AAAnD,8GAAA,aAAa,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/index.ts"],"names":[],"mappings":";;;;;AAAA,0DAA0D;AAC1D,kDA6C8B;AA5C1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,mGAAA,MAAM,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,gGAAA,GAAG,OAAA;AAAE,iGAAA,IAAI,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,oGAAA,OAAO,OAAA;AAAE,mGAAA,MAAM,OAAA;AAC1E,4GAAA,eAAe,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AACpD,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AACL,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,+GAAA,kBAAkB,OAAA;AAClB,kHAAA,qBAAqB,OAAA;AACrB,iHAAA,oBAAoB,OAAA;AACpB,yHAAA,4BAA4B,OAAA;AAC5B,uGAAA,UAAU,OAAA;AACV,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,wGAAA,WAAW,OAAA;AACX,2HAAA,8BAA8B,OAAA;AAC9B,uGAAA,UAAU,OAAA;AACV,0GAAA,aAAa,OAAA;AACb,oHAAA,uBAAuB,OAAA;AACvB,yGAAA,YAAY,OAAA;AACZ,qGAAA,QAAQ,OAAA;AACR,0GAAA,aAAa,OAAA;AACb,iHAAA,oBAAoB,OAAA;AACpB,+GAAA,kBAAkB,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uB,OAAA;AAAE,0HAAA,qBAAqB,OAAA;AACxI,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAG9B,gEAA2D;AAAlD,gHAAA,YAAY,OAAA","sourcesContent":["// Re-export API decorators from core-util for convenience\nexport {\n ApiPath,\n Endpoint,\n PathParam,\n QueryParam,\n WpAuthPublic,\n WpAuth, WpLocalOnly, isLocalOnly, jwt, oidc, sharedSecret, webhook, apiKey,\n WpAuthorization, AuthorizationType, getAuthorization,\n Rpc,\n PubSub,\n Queue,\n getApiPath,\n getEndpoints,\n getEndpointOptions,\n getEndpointHttpMethod,\n getEndpointOperation,\n getHttpParameterDeclarations,\n isFormPost,\n isRawBody,\n isApiPath,\n getAuthMeta,\n assertEveryEndpointHasAuthMode,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n AuthMeta,\n RouteMetadata,\n RouteMetadataFactory,\n HttpContractMapper,\n METADATA_KEYS,\n ValidateImplementation,\n GET,\n POST,\n READ,\n WRITE_IDEMPOTENT,\n WRITE,\n RPC,\n CLOUDTASKS,\n CRON,\n EXTERNAL,\n // @DocumentDesign moved to core-util (design-root marker, browser + Node);\n // re-exported here for back-compat.\n DocumentDesign,\n isDocumentDesign,\n} from '@webpieces/core-util';\nexport type {\n AuthMode,\n ApiKind,\n HttpMethod,\n EndpointOperation,\n EndpointKind,\n EndpointOptions,\n EndpointResponseType,\n} from '@webpieces/core-util';\n\n// Server-side routing decorators and utilities\nexport { SourceFile, ROUTING_METADATA_KEYS } from './decorators';\n\n// DI provider decorators moved to core-context; re-exported here for back-compat\nexport { provideSingletonDefaultForApi } from '@webpieces/core-context';\n// Framework-only DI registry (packages/** framework classes use these; see frameworkProvide.ts)\nexport {\n provideFrameworkSingleton,\n provideFrameworkSingletonDefaultForApi,\n buildFrameworkModule,\n} from '@webpieces/core-context';\n\nexport { ApiRoutingFactory, ClassType } from './ApiRoutingFactory';\n\n// Core routing types\nexport { Routes, RouteBuilder, RouteDefinition, FilterDefinition } from './WebAppMeta';\n\n// The transport-neutral request type (defined in core-context; this is http-routing's\n// public request — a transport adapter builds one and the chain reads it from RequestContext).\nexport { HttpRequest, RawHttpRequest, RawRequest } from '@webpieces/core-context';\n\n// The INBOUND chain's response type. `Filter`, `Service` and `FilterChain` are NOT re-exported\n// here: they moved to @webpieces/core-util so the outbound client chain is the SAME abstraction\n// rather than a second spelling of it. Import them from '@webpieces/core-util'.\nexport { WpResponse } from './WpResponse';\nexport { AuthenticatedCallerContext } from './AuthenticatedCallerContext';\nexport { InvocationAuthentication } from './InvocationAuthentication';\nexport { MethodMeta } from './MethodMeta';\nexport { RouteHandler } from './RouteHandler';\n\n// LogApiFilter: the fixed OUTERMOST framework filter (auto-installed at 1,000,000 above\n// AuthFilter). Exported for reference/testing only — apps must NOT install it themselves.\nexport { LogApiFilter } from './filters/LogApiFilter';\n\n// RouteBuilderImpl (the route table + chain composer) is now INTERNAL — it is never\n// handed to upper layers. The express layer consumes ApiFactory.apiClients() instead.\n\n// Filter matching\nexport { FilterMatcher, HttpFilter } from './FilterMatcher';\n\n// The app's server-surface declaration: DI bind modules + route groups + headers.\nexport type { Wiring, AppWiring, BindModule, RouteModule } from './Wiring';\nexport { NodeWiringModules } from './Wiring';\n// The Node binder every BindModule.configure receives.\nexport type { Binder } from './Binder';\nexport { ContainerBinder, ClientBindOptions, PubSubBindOptions } from './Binder';\n\n// The public API-surface abstraction: declare routes/filters, get them back as ApiClient[].\nexport { ApiFactory } from './ApiFactory';\nexport { ApiClient, ApiClientProxy } from './ApiClient';\n\n// Auth: the app-provided, container-bound pieces the framework AuthFilter injects.\n// - AuthConfig: shared-secret STATE (sharedSecret(...) values).\n// - JwtHook / OidcHook / WebhookAuthCallback / ApiKeyHook: OPTIONAL verification mechanisms\n// (bind only what you use; unbound means the matching endpoints 401, never open).\n// - DefaultOidcVerifier: the built-in Google OIDC verifier used when no OidcHook is bound.\nexport {\n AuthConfig,\n AUTH_CONFIG,\n AuthenticatedCaller,\n AuthenticatedMachineIdentity,\n AUTHENTICATED_CALLER_KEY,\n SharedSecrets,\n} from './AuthConfig';\nexport {\n JwtHook,\n MintedJwt,\n JWT_HOOK,\n OidcHook,\n OIDC_HOOK,\n WebhookAuthCallback,\n WEBHOOK_AUTH_CALLBACK,\n ApiKeyHook,\n API_KEY_HOOK,\n} from './AuthHooks';\nexport { DefaultOidcVerifier } from './DefaultOidcVerifier';\n// DefaultJwtHook: batteries-included HS256 JwtHook — `new DefaultJwtHook(secret)` and go.\nexport { DefaultJwtHook, DefaultJwtMintRequest } from './DefaultJwtHook';\n\n// Above-boundary context setup shared by every transport adapter.\n\n// Node-only router (the express-free heart: container + filter chain + in-process client)\nexport { WebpiecesRouter, WebpiecesRouterFactory, WebpiecesRouterOptions } from './WebpiecesRouter';\n\n// The ONE transport-free startup sequence (headers → logging → router → routes) → ApiFactory.\n// Reusable by any company/app and any framework adapter; a company wraps it with its own headers.\nexport { setupRuntime, RuntimeSetupOptions } from './setupRuntime';\n\n// Server configuration\nexport { WebpiecesConfig, WEBPIECES_CONFIG_TOKEN } from './WebpiecesConfig';\n\n\nexport { AuthorizationHook, AuthorizationService, CanonicalUserRoles, AUTHORIZATION_HOOK, VERIFIED_MACHINE_CALLER, VerifiedMachineCaller } from './AuthorizationHook';\nexport { AuthorizedApiDocument } from './AuthorizedApiDocument';\nexport type { ApiDocumentObject, ApiDocumentValue } from './AuthorizedApiDocument';\n\nexport { WiringPolicy } from '@webpieces/http-client-core';\n"]}
|
package/src/setupRuntime.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ApiFactory } from './ApiFactory';
|
|
|
7
7
|
* RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT
|
|
8
8
|
* declared by the app's {@link AppWiring}): the logging backend, whether to include the platform
|
|
9
9
|
* default headers, and config. Data-only structure (a class, per the webpieces guidelines). The
|
|
10
|
-
* app's own
|
|
10
|
+
* app's own bind modules + route groups + headers come from the AppWiring passed alongside;
|
|
11
11
|
* the test-override module is the separate `appOverrides` param of {@link setupRuntime}.
|
|
12
12
|
*
|
|
13
13
|
* Headers: {@link HeaderRegistry.configure} registers the platform defaults (when
|
|
@@ -71,8 +71,8 @@ export declare class RuntimeSetupOptions {
|
|
|
71
71
|
*
|
|
72
72
|
* 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)
|
|
73
73
|
* 2. LogManager.setFactory (fails fast unless the registry is configured first)
|
|
74
|
-
* 3. build the router + DI container (from appModules.
|
|
75
|
-
* 4. configure each appModules.
|
|
74
|
+
* 3. build the router + DI container (from appModules.getBindModules(), each handed a Binder)
|
|
75
|
+
* 4. configure each appModules.getRouteModules() onto the router (addRoutes/addFilter)
|
|
76
76
|
*
|
|
77
77
|
* and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or
|
|
78
78
|
* `createApiClient()` for in-process tests. There is NO express (or any transport) here; a
|
package/src/setupRuntime.js
CHANGED
|
@@ -6,12 +6,13 @@ const inversify_1 = require("inversify");
|
|
|
6
6
|
const core_util_1 = require("@webpieces/core-util");
|
|
7
7
|
const WebpiecesConfig_1 = require("./WebpiecesConfig");
|
|
8
8
|
const WebpiecesRouter_1 = require("./WebpiecesRouter");
|
|
9
|
-
const
|
|
9
|
+
const Wiring_1 = require("./Wiring");
|
|
10
|
+
const Binder_1 = require("./Binder");
|
|
10
11
|
/**
|
|
11
12
|
* RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT
|
|
12
13
|
* declared by the app's {@link AppWiring}): the logging backend, whether to include the platform
|
|
13
14
|
* default headers, and config. Data-only structure (a class, per the webpieces guidelines). The
|
|
14
|
-
* app's own
|
|
15
|
+
* app's own bind modules + route groups + headers come from the AppWiring passed alongside;
|
|
15
16
|
* the test-override module is the separate `appOverrides` param of {@link setupRuntime}.
|
|
16
17
|
*
|
|
17
18
|
* Headers: {@link HeaderRegistry.configure} registers the platform defaults (when
|
|
@@ -65,8 +66,8 @@ exports.RuntimeSetupOptions = RuntimeSetupOptions;
|
|
|
65
66
|
*
|
|
66
67
|
* 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)
|
|
67
68
|
* 2. LogManager.setFactory (fails fast unless the registry is configured first)
|
|
68
|
-
* 3. build the router + DI container (from appModules.
|
|
69
|
-
* 4. configure each appModules.
|
|
69
|
+
* 3. build the router + DI container (from appModules.getBindModules(), each handed a Binder)
|
|
70
|
+
* 4. configure each appModules.getRouteModules() onto the router (addRoutes/addFilter)
|
|
70
71
|
*
|
|
71
72
|
* and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or
|
|
72
73
|
* `createApiClient()` for in-process tests. There is NO express (or any transport) here; a
|
|
@@ -92,14 +93,14 @@ appOverrides) {
|
|
|
92
93
|
// 2. Install the logging backend ONCE, before anything else logs.
|
|
93
94
|
core_util_1.LogManager.setFactory(options.loggerFactory);
|
|
94
95
|
// 3. Build the node-only router + DI container.
|
|
95
|
-
const modules = new
|
|
96
|
+
const modules = new Wiring_1.NodeWiringModules(appModules);
|
|
96
97
|
const router = await WebpiecesRouter_1.WebpiecesRouterFactory.create({
|
|
97
|
-
appBindings: modules.
|
|
98
|
+
appBindings: modules.bindModules.map((module) => new inversify_1.ContainerModule((load) => module.configure(new Binder_1.ContainerBinder(load)))),
|
|
98
99
|
appOverrides: appOverrides,
|
|
99
100
|
config: options.config ?? new WebpiecesConfig_1.WebpiecesConfig(),
|
|
100
101
|
});
|
|
101
102
|
// 4. Let each route group declare its routes + filters, then hand back the consumer surface.
|
|
102
|
-
for (const routeModule of modules.
|
|
103
|
+
for (const routeModule of modules.routeModules) {
|
|
103
104
|
routeModule.configure(router);
|
|
104
105
|
}
|
|
105
106
|
return router;
|
package/src/setupRuntime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AAoEA,oCAyCC;AA7GD,yCAAwE;AACxE,oDAO8B;AAC9B,uDAAoD;AACpD,uDAA2D;
|
|
1
|
+
{"version":3,"file":"setupRuntime.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/setupRuntime.ts"],"names":[],"mappings":";;;AAoEA,oCAyCC;AA7GD,yCAAwE;AACxE,oDAO8B;AAC9B,uDAAoD;AACpD,uDAA2D;AAC3D,qCAAoE;AACpE,qCAA2C;AAG3C;;;;;;;;;GASG;AACH,MAAa,mBAAmB;IAIR;IAIA;IAWA;IAEA;IAEA;IAEA;IAxBpB;IACI;iFAC6E;IAC7D,OAAe;IAC/B;;+DAE2D;IAC3C,UAAkB;IAClC;;;;;;;;;OASG;IACa,QAAkB;IAClC,0DAA0D;IAC1C,aAA4B;IAC5C,sDAAsD;IACtC,kBAA2B,IAAI;IAC/C,gFAAgF;IAChE,MAAwB;QArBxB,YAAO,GAAP,OAAO,CAAQ;QAIf,eAAU,GAAV,UAAU,CAAQ;QAWlB,aAAQ,GAAR,QAAQ,CAAU;QAElB,kBAAa,GAAb,aAAa,CAAe;QAE5B,oBAAe,GAAf,eAAe,CAAgB;QAE/B,WAAM,GAAN,MAAM,CAAkB;IACzC,CAAC;CACP;AA3BD,kDA2BC;AAED;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,YAAY,CAC9B,OAA4B,EAC5B,UAAqB;AACrB;mEACmE;AACnE,YAA8B;IAE9B,gGAAgG;IAChG,6FAA6F;IAC7F,kGAAkG;IAClG,kGAAkG;IAClG,kGAAkG;IAClG,iCAAiC;IACjC,uBAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzD,+FAA+F;IAC/F,6FAA6F;IAC7F,6EAA6E;IAC7E,2BAAe,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1C,6FAA6F;IAC7F,0BAAc,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3E,kEAAkE;IAClE,sBAAU,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7C,gDAAgD;IAChD,MAAM,OAAO,GAAG,IAAI,0BAAiB,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,wCAAsB,CAAC,MAAM,CAAC;QAC/C,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAChC,CAAC,MAAkB,EAAE,EAAE,CAAC,IAAI,2BAAe,CAAC,CAAC,IAAgC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,wBAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CACjI;QACD,YAAY,EAAE,YAAY;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,iCAAe,EAAE;KAClD,CAAC,CAAC;IAEH,6FAA6F;IAC7F,KAAK,MAAM,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QAC7C,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ContainerModule, ContainerModuleLoadOptions } from 'inversify';\nimport {\n HeaderRegistry,\n Locality,\n LoggerFactory,\n LogManager,\n RuntimeLocality,\n ServiceInfo,\n} from '@webpieces/core-util';\nimport { WebpiecesConfig } from './WebpiecesConfig';\nimport { WebpiecesRouterFactory } from './WebpiecesRouter';\nimport { AppWiring, BindModule, NodeWiringModules } from './Wiring';\nimport { ContainerBinder } from './Binder';\nimport { ApiFactory } from './ApiFactory';\n\n/**\n * RuntimeSetupOptions - the environment/wiring inputs to {@link setupRuntime} (everything NOT\n * declared by the app's {@link AppWiring}): the logging backend, whether to include the platform\n * default headers, and config. Data-only structure (a class, per the webpieces guidelines). The\n * app's own bind modules + route groups + headers come from the AppWiring passed alongside;\n * the test-override module is the separate `appOverrides` param of {@link setupRuntime}.\n *\n * Headers: {@link HeaderRegistry.configure} registers the platform defaults (when\n * `platformHeaders` is true) plus AppWiring.getHeaders() (by convention the company-wide set).\n */\nexport class RuntimeSetupOptions {\n constructor(\n /** This service's name — published to ServiceInfo. Names every log line and stamps\n * `requestIdSource` on request-ids this service mints. Must be non-blank. */\n public readonly svcName: string,\n /** This build's version — published to ServiceInfo alongside svcName. Opaque to webpieces\n * (a git SHA, a semver tag, a CI build number); it just has to identify THIS build so a log\n * line can say which one emitted it. Must be non-blank. */\n public readonly svcVersion: string,\n /**\n * WHERE this process runs — `'local'` (a developer's machine) or `'deployed'` (everything\n * else). Published to {@link RuntimeLocality}; the ONE input to `@WpLocalOnly` enforcement.\n *\n * REQUIRED and POSITIONAL on purpose, exactly like `@Endpoint(path, kind)`: only the app\n * knows how its platform is detected (Cloud Run's `K_SERVICE`, an ECS metadata URL, the\n * absence of both), the framework must not guess, and a defaulted field would mean \"forgot\n * to say\" and \"said deployed\" are the same line of code. Derive it at your startup, e.g.\n * `getServiceName() === 'local' ? 'local' : 'deployed'`.\n */\n public readonly locality: Locality,\n /** Logging backend to install (LogManager.setFactory). */\n public readonly loggerFactory: LoggerFactory,\n /** Include the webpieces platform default headers. */\n public readonly platformHeaders: boolean = true,\n /** Optional WebpiecesConfig (e.g. recording flags); defaults to a fresh one. */\n public readonly config?: WebpiecesConfig,\n ) {}\n}\n\n/**\n * setupRuntime - the ONE canonical, TRANSPORT-FREE startup sequence, reusable by any company/app\n * AND any framework adapter (express, fastify, a serverless handler, ...). It runs, in the correct\n * fail-fast order:\n *\n * 1. HeaderRegistry.configure (filters read it at construction; logging masks off it)\n * 2. LogManager.setFactory (fails fast unless the registry is configured first)\n * 3. build the router + DI container (from appModules.getBindModules(), each handed a Binder)\n * 4. configure each appModules.getRouteModules() onto the router (addRoutes/addFilter)\n *\n * and returns the built {@link ApiFactory} — `apiClients()` for a transport to bind, or\n * `createApiClient()` for in-process tests. There is NO express (or any transport) here; a\n * transport adapter (e.g. WebpiecesExpressRouter in @webpieces/http-server) serves the result.\n */\nexport async function setupRuntime(\n options: RuntimeSetupOptions,\n appModules: AppWiring,\n /** A single DI module loaded LAST so tests can rebind bindings to mocks.\n * Or special case servers that want to override specific things */\n appOverrides?: ContainerModule,\n): Promise<ApiFactory> {\n // 0. IDENTIFY this service (name + build version) FIRST, before anything logs. Name and version\n // are REQUIRED inputs to this call, so a build cannot boot anonymously — setInfo throws on a\n // blank value, which kills the deploy (the revision never goes healthy) rather than shipping logs\n // that cannot say which build emitted them. Reads of ServiceInfo elsewhere never throw (a missing\n // log field must never 500 live traffic); the \"say which build you are\" guarantee lives HERE, the\n // one startup every server runs.\n ServiceInfo.setInfo(options.svcName, options.svcVersion);\n\n // 0b. Declare WHERE we run, before any route is built: ApiRoutingFactory reads it in step 4 to\n // decide whether @WpLocalOnly routes are registered at all. Undeclared reads as DEPLOYED, so\n // this call is what lets a local-only endpoint exist — never what hides one.\n RuntimeLocality.declare(options.locality);\n\n // 1. Register the global HeaderRegistry FIRST (this service's own keys come from AppWiring).\n HeaderRegistry.configure(appModules.getHeaders(), options.platformHeaders);\n\n // 2. Install the logging backend ONCE, before anything else logs.\n LogManager.setFactory(options.loggerFactory);\n\n // 3. Build the node-only router + DI container.\n const modules = new NodeWiringModules(appModules);\n const router = await WebpiecesRouterFactory.create({\n appBindings: modules.bindModules.map(\n (module: BindModule) => new ContainerModule((load: ContainerModuleLoadOptions) => module.configure(new ContainerBinder(load))),\n ),\n appOverrides: appOverrides,\n config: options.config ?? new WebpiecesConfig(),\n });\n\n // 4. Let each route group declare its routes + filters, then hand back the consumer surface.\n for (const routeModule of modules.routeModules) {\n routeModule.configure(router);\n }\n return router;\n}\n"]}
|