@webpieces/http-client-browser 0.4.869 → 0.4.871
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 +3 -3
- package/src/BinderCompileAssertions.d.ts +8 -0
- package/src/BinderCompileAssertions.js +45 -0
- package/src/BinderCompileAssertions.js.map +1 -0
- package/src/ExternalImpl.d.ts +34 -0
- package/src/ExternalImpl.js +43 -0
- package/src/ExternalImpl.js.map +1 -0
- package/src/RpcClientProvider.d.ts +7 -4
- package/src/RpcClientProvider.js +4 -6
- package/src/RpcClientProvider.js.map +1 -1
- package/src/Wiring.d.ts +32 -13
- package/src/Wiring.js +43 -15
- package/src/Wiring.js.map +1 -1
- package/src/index.d.ts +5 -4
- package/src/index.js +7 -6
- package/src/index.js.map +1 -1
- package/src/RpcClientProviderCompileAssertions.d.ts +0 -4
- package/src/RpcClientProviderCompileAssertions.js +0 -22
- package/src/RpcClientProviderCompileAssertions.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-client-browser",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.871",
|
|
4
4
|
"description": "Browser HTTP client for webpieces: DI-free (React or Angular), app-managed context store, no AsyncLocalStorage",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@webpieces/core-util": "0.4.
|
|
26
|
-
"@webpieces/http-client-core": "0.4.
|
|
25
|
+
"@webpieces/core-util": "0.4.871",
|
|
26
|
+
"@webpieces/http-client-core": "0.4.871"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Binder } from './Wiring';
|
|
2
|
+
import type { AppWiring, Wiring } from './Wiring';
|
|
3
|
+
/** Compiled fixtures protect token/API inference and the browser's missing route channel. */
|
|
4
|
+
export declare class BinderCompileAssertions {
|
|
5
|
+
check(binder: Binder, token: symbol): void;
|
|
6
|
+
external(binder: Binder): void;
|
|
7
|
+
routes(wiring: Wiring, app: AppWiring): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BinderCompileAssertions = void 0;
|
|
4
|
+
const Wiring_1 = require("./Wiring");
|
|
5
|
+
const ExternalImpl_1 = require("./ExternalImpl");
|
|
6
|
+
class TextApi {
|
|
7
|
+
}
|
|
8
|
+
class ClockApi {
|
|
9
|
+
}
|
|
10
|
+
class VendorText extends TextApi {
|
|
11
|
+
read() { return 'vendor'; }
|
|
12
|
+
}
|
|
13
|
+
class LoggedText extends TextApi {
|
|
14
|
+
}
|
|
15
|
+
/** Compiled fixtures protect token/API inference and the browser's missing route channel. */
|
|
16
|
+
class BinderCompileAssertions {
|
|
17
|
+
check(binder, token) {
|
|
18
|
+
binder.createRpcClientAndBind(TextApi, 'text-service');
|
|
19
|
+
binder.createRpcClientAndBind(TextApi, 'text-service', new Wiring_1.ClientBindOptions(token));
|
|
20
|
+
// @ts-expect-error A service destination is required.
|
|
21
|
+
binder.createRpcClientAndBind(TextApi);
|
|
22
|
+
// @ts-expect-error Wrapper destinations were removed; use a service string.
|
|
23
|
+
binder.createRpcClientAndBind(TextApi, { serviceName: 'text-service' });
|
|
24
|
+
}
|
|
25
|
+
external(binder) {
|
|
26
|
+
binder.bindExternal(TextApi, new ExternalImpl_1.UseClass(VendorText));
|
|
27
|
+
binder.bindExternal(TextApi, new ExternalImpl_1.UseExisting(LoggedText));
|
|
28
|
+
// @ts-expect-error A bare class is ambiguous (construct it, or alias it?); name the recipe: UseClass or UseExisting.
|
|
29
|
+
binder.bindExternal(TextApi, VendorText);
|
|
30
|
+
// @ts-expect-error The implementation must provide the external contract.
|
|
31
|
+
binder.bindExternal(ClockApi, new ExternalImpl_1.UseClass(VendorText));
|
|
32
|
+
// @ts-expect-error UseClass constructs its argument, so an abstract class is refused; alias it with UseExisting.
|
|
33
|
+
binder.bindExternal(TextApi, new ExternalImpl_1.UseClass(LoggedText));
|
|
34
|
+
// @ts-expect-error The implementation must provide the external contract.
|
|
35
|
+
binder.bindExternal(ClockApi, new ExternalImpl_1.UseExisting(LoggedText));
|
|
36
|
+
}
|
|
37
|
+
routes(wiring, app) {
|
|
38
|
+
// @ts-expect-error The browser has no route channel.
|
|
39
|
+
wiring.getRouteModules();
|
|
40
|
+
// @ts-expect-error The browser has no route channel.
|
|
41
|
+
app.getRoutingModules();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BinderCompileAssertions = BinderCompileAssertions;
|
|
45
|
+
//# sourceMappingURL=BinderCompileAssertions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinderCompileAssertions.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/BinderCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AAErD,iDAAuD;AAEvD,MAAe,OAAO;CAA6B;AACnD,MAAe,QAAQ;CAA4B;AACnD,MAAM,UAAW,SAAQ,OAAO;IAAG,IAAI,KAAa,OAAO,QAAQ,CAAC,CAAC,CAAC;CAAE;AACxE,MAAe,UAAW,SAAQ,OAAO;CAAG;AAE5C,6FAA6F;AAC7F,MAAa,uBAAuB;IAChC,KAAK,CAAC,MAAc,EAAE,KAAa;QAC/B,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACvD,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,0BAAiB,CAAU,KAAK,CAAC,CAAC,CAAC;QAC9F,sDAAsD;QACtD,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACvC,4EAA4E;QAC5E,MAAM,CAAC,sBAAsB,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,QAAQ,CAAC,MAAc;QACnB,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,uBAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACvD,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,0BAAW,CAAC,UAAU,CAAC,CAAC,CAAC;QAC1D,qHAAqH;QACrH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACzC,0EAA0E;QAC1E,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,uBAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACxD,iHAAiH;QACjH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,uBAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACvD,0EAA0E;QAC1E,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,0BAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,GAAc;QACjC,qDAAqD;QACrD,MAAM,CAAC,eAAe,EAAE,CAAC;QACzB,qDAAqD;QACrD,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAC5B,CAAC;CACJ;AA7BD,0DA6BC","sourcesContent":["import { Binder, ClientBindOptions } from './Wiring';\nimport type { AppWiring, Wiring } from './Wiring';\nimport { UseClass, UseExisting } from './ExternalImpl';\n\nabstract class TextApi { abstract read(): string; }\nabstract class ClockApi { abstract now(): number; }\nclass VendorText extends TextApi { read(): string { return 'vendor'; } }\nabstract class LoggedText extends TextApi {}\n\n/** Compiled fixtures protect token/API inference and the browser's missing route channel. */\nexport class BinderCompileAssertions {\n check(binder: Binder, token: symbol): void {\n binder.createRpcClientAndBind(TextApi, 'text-service');\n binder.createRpcClientAndBind(TextApi, 'text-service', new ClientBindOptions<TextApi>(token));\n // @ts-expect-error A service destination is required.\n binder.createRpcClientAndBind(TextApi);\n // @ts-expect-error Wrapper destinations were removed; use a service string.\n binder.createRpcClientAndBind(TextApi, { serviceName: 'text-service' });\n }\n\n external(binder: Binder): void {\n binder.bindExternal(TextApi, new UseClass(VendorText));\n binder.bindExternal(TextApi, new UseExisting(LoggedText));\n // @ts-expect-error A bare class is ambiguous (construct it, or alias it?); name the recipe: UseClass or UseExisting.\n binder.bindExternal(TextApi, VendorText);\n // @ts-expect-error The implementation must provide the external contract.\n binder.bindExternal(ClockApi, new UseClass(VendorText));\n // @ts-expect-error UseClass constructs its argument, so an abstract class is refused; alias it with UseExisting.\n binder.bindExternal(TextApi, new UseClass(LoggedText));\n // @ts-expect-error The implementation must provide the external contract.\n binder.bindExternal(ClockApi, new UseExisting(LoggedText));\n }\n\n routes(wiring: Wiring, app: AppWiring): void {\n // @ts-expect-error The browser has no route channel.\n wiring.getRouteModules();\n // @ts-expect-error The browser has no route channel.\n app.getRoutingModules();\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BrowserProvider, BrowserToken } from './BrowserProviders';
|
|
2
|
+
/** A class the injector may construct (`useClass`). */
|
|
3
|
+
export type ExternalClassType<T extends object> = new (...args: never[]) => T;
|
|
4
|
+
/** A class token the injector already provides (`useExisting`), possibly abstract. */
|
|
5
|
+
export type ExternalExistingType<T extends object> = abstract new (...args: never[]) => T;
|
|
6
|
+
/**
|
|
7
|
+
* The vendor implementation handed to {@link Binder.bindExternal}. A class the injector constructs
|
|
8
|
+
* and a class it already provides are both classes at runtime, so the recipe is NAMED by the class
|
|
9
|
+
* that carries it rather than guessed from the argument:
|
|
10
|
+
*
|
|
11
|
+
* - `new UseClass(Vendor)` — the external contract is constructed as `Vendor`.
|
|
12
|
+
* - `new UseExisting(Logged)` — the external contract aliases the token `Logged`, which is provided
|
|
13
|
+
* elsewhere (e.g. `@Injectable({ providedIn: 'root' })`), so both tokens share one instance.
|
|
14
|
+
*
|
|
15
|
+
* `T` is what the implementation provides; bindExternal requires it to satisfy the contract.
|
|
16
|
+
*/
|
|
17
|
+
export declare abstract class ExternalImpl<T extends object> {
|
|
18
|
+
/** Type-only: carries `T` so an implementation of the wrong contract does not compile. */
|
|
19
|
+
readonly implementation: T;
|
|
20
|
+
/** The structural provider registering `contract` with this implementation. */
|
|
21
|
+
abstract provider(contract: BrowserToken): BrowserProvider;
|
|
22
|
+
}
|
|
23
|
+
/** `useClass`: the external contract is constructed as {@link useClass}. */
|
|
24
|
+
export declare class UseClass<T extends object> extends ExternalImpl<T> {
|
|
25
|
+
readonly useClass: ExternalClassType<T>;
|
|
26
|
+
constructor(useClass: ExternalClassType<T>);
|
|
27
|
+
provider(contract: BrowserToken): BrowserProvider;
|
|
28
|
+
}
|
|
29
|
+
/** `useExisting`: the external contract aliases the already-provided token {@link useExisting}. */
|
|
30
|
+
export declare class UseExisting<T extends object> extends ExternalImpl<T> {
|
|
31
|
+
readonly useExisting: ExternalExistingType<T>;
|
|
32
|
+
constructor(useExisting: ExternalExistingType<T>);
|
|
33
|
+
provider(contract: BrowserToken): BrowserProvider;
|
|
34
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseExisting = exports.UseClass = exports.ExternalImpl = void 0;
|
|
4
|
+
const BrowserProviders_1 = require("./BrowserProviders");
|
|
5
|
+
/**
|
|
6
|
+
* The vendor implementation handed to {@link Binder.bindExternal}. A class the injector constructs
|
|
7
|
+
* and a class it already provides are both classes at runtime, so the recipe is NAMED by the class
|
|
8
|
+
* that carries it rather than guessed from the argument:
|
|
9
|
+
*
|
|
10
|
+
* - `new UseClass(Vendor)` — the external contract is constructed as `Vendor`.
|
|
11
|
+
* - `new UseExisting(Logged)` — the external contract aliases the token `Logged`, which is provided
|
|
12
|
+
* elsewhere (e.g. `@Injectable({ providedIn: 'root' })`), so both tokens share one instance.
|
|
13
|
+
*
|
|
14
|
+
* `T` is what the implementation provides; bindExternal requires it to satisfy the contract.
|
|
15
|
+
*/
|
|
16
|
+
class ExternalImpl {
|
|
17
|
+
}
|
|
18
|
+
exports.ExternalImpl = ExternalImpl;
|
|
19
|
+
/** `useClass`: the external contract is constructed as {@link useClass}. */
|
|
20
|
+
class UseClass extends ExternalImpl {
|
|
21
|
+
useClass;
|
|
22
|
+
constructor(useClass) {
|
|
23
|
+
super();
|
|
24
|
+
this.useClass = useClass;
|
|
25
|
+
}
|
|
26
|
+
provider(contract) {
|
|
27
|
+
return new BrowserProviders_1.BrowserClassProvider(contract, this.useClass);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.UseClass = UseClass;
|
|
31
|
+
/** `useExisting`: the external contract aliases the already-provided token {@link useExisting}. */
|
|
32
|
+
class UseExisting extends ExternalImpl {
|
|
33
|
+
useExisting;
|
|
34
|
+
constructor(useExisting) {
|
|
35
|
+
super();
|
|
36
|
+
this.useExisting = useExisting;
|
|
37
|
+
}
|
|
38
|
+
provider(contract) {
|
|
39
|
+
return new BrowserProviders_1.BrowserExistingProvider(contract, this.useExisting);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.UseExisting = UseExisting;
|
|
43
|
+
//# sourceMappingURL=ExternalImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExternalImpl.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ExternalImpl.ts"],"names":[],"mappings":";;;AAAA,yDAAmF;AAQnF;;;;;;;;;;GAUG;AACH,MAAsB,YAAY;CAMjC;AAND,oCAMC;AAED,4EAA4E;AAC5E,MAAa,QAA2B,SAAQ,YAAe;IAC/B;IAA5B,YAA4B,QAA8B;QACtD,KAAK,EAAE,CAAC;QADgB,aAAQ,GAAR,QAAQ,CAAsB;IAE1D,CAAC;IAED,QAAQ,CAAC,QAAsB;QAC3B,OAAO,IAAI,uCAAoB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACJ;AARD,4BAQC;AAED,mGAAmG;AACnG,MAAa,WAA8B,SAAQ,YAAe;IAClC;IAA5B,YAA4B,WAAoC;QAC5D,KAAK,EAAE,CAAC;QADgB,gBAAW,GAAX,WAAW,CAAyB;IAEhE,CAAC;IAED,QAAQ,CAAC,QAAsB;QAC3B,OAAO,IAAI,0CAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnE,CAAC;CACJ;AARD,kCAQC","sourcesContent":["import { BrowserClassProvider, BrowserExistingProvider } from './BrowserProviders';\nimport type { BrowserProvider, BrowserToken } from './BrowserProviders';\n\n/** A class the injector may construct (`useClass`). */\nexport type ExternalClassType<T extends object> = new (...args: never[]) => T;\n/** A class token the injector already provides (`useExisting`), possibly abstract. */\nexport type ExternalExistingType<T extends object> = abstract new (...args: never[]) => T;\n\n/**\n * The vendor implementation handed to {@link Binder.bindExternal}. A class the injector constructs\n * and a class it already provides are both classes at runtime, so the recipe is NAMED by the class\n * that carries it rather than guessed from the argument:\n *\n * - `new UseClass(Vendor)` — the external contract is constructed as `Vendor`.\n * - `new UseExisting(Logged)` — the external contract aliases the token `Logged`, which is provided\n * elsewhere (e.g. `@Injectable({ providedIn: 'root' })`), so both tokens share one instance.\n *\n * `T` is what the implementation provides; bindExternal requires it to satisfy the contract.\n */\nexport abstract class ExternalImpl<T extends object> {\n /** Type-only: carries `T` so an implementation of the wrong contract does not compile. */\n declare readonly implementation: T;\n\n /** The structural provider registering `contract` with this implementation. */\n abstract provider(contract: BrowserToken): BrowserProvider;\n}\n\n/** `useClass`: the external contract is constructed as {@link useClass}. */\nexport class UseClass<T extends object> extends ExternalImpl<T> {\n constructor(public readonly useClass: ExternalClassType<T>) {\n super();\n }\n\n provider(contract: BrowserToken): BrowserProvider {\n return new BrowserClassProvider(contract, this.useClass);\n }\n}\n\n/** `useExisting`: the external contract aliases the already-provided token {@link useExisting}. */\nexport class UseExisting<T extends object> extends ExternalImpl<T> {\n constructor(public readonly useExisting: ExternalExistingType<T>) {\n super();\n }\n\n provider(contract: BrowserToken): BrowserProvider {\n return new BrowserExistingProvider(contract, this.useExisting);\n }\n}\n"]}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { ApiPrototype } from '@webpieces/http-client-core';
|
|
2
|
+
import type { BrowserToken } from './BrowserProviders';
|
|
2
3
|
import { ClientHttpBrowserFactory } from './ClientHttpBrowserFactory';
|
|
3
4
|
import { ClientConfig } from './ClientConfig';
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Structurally compatible Angular factory provider, created by Binder.createRpcClientAndBind. The
|
|
7
|
+
* token remains overrideable and the client is created lazily, on first inject.
|
|
8
|
+
*/
|
|
5
9
|
export declare class RpcClientProvider<T extends object> {
|
|
6
|
-
readonly provide:
|
|
10
|
+
readonly provide: BrowserToken;
|
|
7
11
|
private readonly api;
|
|
8
12
|
private readonly destination;
|
|
9
13
|
readonly deps: (typeof ClientConfig | typeof ClientHttpBrowserFactory)[];
|
|
10
|
-
constructor(provide:
|
|
14
|
+
constructor(provide: BrowserToken, api: ApiPrototype<T>, destination: string);
|
|
11
15
|
readonly useFactory: (factory: ClientHttpBrowserFactory, _config: ClientConfig) => T;
|
|
12
16
|
}
|
|
13
|
-
export declare function provideRpcClient<T extends object>(token: ApiPrototype<NoInfer<T>> | symbol, api: ApiPrototype<T>, destination: string): RpcClientProvider<T>;
|
package/src/RpcClientProvider.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RpcClientProvider = void 0;
|
|
4
|
-
exports.provideRpcClient = provideRpcClient;
|
|
5
4
|
const ClientHttpBrowserFactory_1 = require("./ClientHttpBrowserFactory");
|
|
6
5
|
const ClientConfig_1 = require("./ClientConfig");
|
|
7
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Structurally compatible Angular factory provider, created by Binder.createRpcClientAndBind. The
|
|
8
|
+
* token remains overrideable and the client is created lazily, on first inject.
|
|
9
|
+
*/
|
|
8
10
|
class RpcClientProvider {
|
|
9
11
|
provide;
|
|
10
12
|
api;
|
|
@@ -18,8 +20,4 @@ class RpcClientProvider {
|
|
|
18
20
|
useFactory = (factory, _config) => factory.createRpcClient(this.api, new ClientConfig_1.ClientConfig(this.destination));
|
|
19
21
|
}
|
|
20
22
|
exports.RpcClientProvider = RpcClientProvider;
|
|
21
|
-
// webpieces-disable no-function-outside-class -- declarative framework integration seam
|
|
22
|
-
function provideRpcClient(token, api, destination) {
|
|
23
|
-
return new RpcClientProvider(token, api, destination);
|
|
24
|
-
}
|
|
25
23
|
//# sourceMappingURL=RpcClientProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcClientProvider.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/RpcClientProvider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RpcClientProvider.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/RpcClientProvider.ts"],"names":[],"mappings":";;;AAEA,yEAAsE;AACtE,iDAA8C;AAE9C;;;GAGG;AACH,MAAa,iBAAiB;IAIN;IACC;IACA;IALZ,IAAI,GAAG,CAAC,mDAAwB,EAAE,2BAAY,CAAC,CAAC;IAEzD,YACoB,OAAqB,EACpB,GAAoB,EACpB,WAAmB;QAFpB,YAAO,GAAP,OAAO,CAAc;QACpB,QAAG,GAAH,GAAG,CAAiB;QACpB,gBAAW,GAAX,WAAW,CAAQ;IACrC,CAAC;IAEK,UAAU,GAAG,CAAC,OAAiC,EAAE,OAAqB,EAAK,EAAE,CAClF,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,2BAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;CAC7E;AAXD,8CAWC","sourcesContent":["import type { ApiPrototype } from '@webpieces/http-client-core';\nimport type { BrowserToken } from './BrowserProviders';\nimport { ClientHttpBrowserFactory } from './ClientHttpBrowserFactory';\nimport { ClientConfig } from './ClientConfig';\n\n/**\n * Structurally compatible Angular factory provider, created by Binder.createRpcClientAndBind. The\n * token remains overrideable and the client is created lazily, on first inject.\n */\nexport class RpcClientProvider<T extends object> {\n readonly deps = [ClientHttpBrowserFactory, ClientConfig];\n\n constructor(\n public readonly provide: BrowserToken,\n private readonly api: ApiPrototype<T>,\n private readonly destination: string,\n ) {}\n\n readonly useFactory = (factory: ClientHttpBrowserFactory, _config: ClientConfig): T =>\n factory.createRpcClient(this.api, new ClientConfig(this.destination));\n}\n"]}
|
package/src/Wiring.d.ts
CHANGED
|
@@ -1,22 +1,41 @@
|
|
|
1
1
|
import type { BrowserProvider } from './BrowserProviders';
|
|
2
|
-
import type { Wiring as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type { ApiPrototype, BindModule as HostBindModule, Wiring as HostWiring, AppWiring as HostAppWiring } from '@webpieces/http-client-core';
|
|
3
|
+
import type { ExternalImpl } from './ExternalImpl';
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link Binder.createRpcClientAndBind}. `token` is an EXTRA identity, needed only when two
|
|
6
|
+
* clients of the SAME api must coexist (e.g. one per deployment); omitted, the API class is the token.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ClientBindOptions<T> {
|
|
9
|
+
readonly token?: (ApiPrototype<T> | symbol) | undefined;
|
|
10
|
+
constructor(token?: (ApiPrototype<T> | symbol) | undefined);
|
|
7
11
|
}
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The browser host's binder, handed to every {@link BindModule}.configure. It collects structural
|
|
14
|
+
* provider recipes; the package imports neither Angular nor Node runtime or types.
|
|
15
|
+
*/
|
|
16
|
+
export declare class Binder {
|
|
17
|
+
private readonly recipes;
|
|
18
|
+
/** Angular-compatible provider recipes, in order. */
|
|
19
|
+
provide(...recipes: BrowserProvider[]): void;
|
|
20
|
+
/** Registers a lazy factory provider: the client is created from ClientHttpBrowserFactory on first inject. */
|
|
21
|
+
createRpcClientAndBind<T extends object>(api: ApiPrototype<T>, deployment: string, options?: ClientBindOptions<NoInfer<T>>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Registers a vendor implementation of an external contract AND records the external-contract
|
|
24
|
+
* graph edge. `impl` is `new UseClass(Vendor)` or `new UseExisting(Token)`.
|
|
25
|
+
*/
|
|
26
|
+
bindExternal<T extends object>(api: ApiPrototype<T>, impl: ExternalImpl<NoInfer<T>>): void;
|
|
27
|
+
get providers(): BrowserProvider[];
|
|
10
28
|
}
|
|
11
|
-
/**
|
|
12
|
-
export interface
|
|
13
|
-
configure(
|
|
29
|
+
/** A browser DI module. Angular router providers are ordinary provider recipes here. */
|
|
30
|
+
export interface BindModule extends HostBindModule<Binder> {
|
|
31
|
+
configure(binder: Binder): void;
|
|
14
32
|
}
|
|
15
|
-
|
|
33
|
+
/** The browser has no route channel: a Wiring selects bind modules only. */
|
|
34
|
+
export interface Wiring extends HostWiring<BindModule> {
|
|
16
35
|
}
|
|
17
|
-
export interface AppWiring extends
|
|
36
|
+
export interface AppWiring extends HostAppWiring<BindModule, Wiring> {
|
|
18
37
|
}
|
|
19
|
-
/** Configure the selected
|
|
38
|
+
/** Configure the selected bind modules once, in topology order. */
|
|
20
39
|
export declare class BrowserWiringProviders {
|
|
21
40
|
toProviders(app: AppWiring): BrowserProvider[];
|
|
22
41
|
}
|
package/src/Wiring.js
CHANGED
|
@@ -1,25 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BrowserWiringProviders = exports.
|
|
3
|
+
exports.BrowserWiringProviders = exports.Binder = exports.ClientBindOptions = void 0;
|
|
4
4
|
const http_client_core_1 = require("@webpieces/http-client-core");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const RpcClientProvider_1 = require("./RpcClientProvider");
|
|
6
|
+
/**
|
|
7
|
+
* Options for {@link Binder.createRpcClientAndBind}. `token` is an EXTRA identity, needed only when two
|
|
8
|
+
* clients of the SAME api must coexist (e.g. one per deployment); omitted, the API class is the token.
|
|
9
|
+
*/
|
|
10
|
+
class ClientBindOptions {
|
|
11
|
+
token;
|
|
12
|
+
constructor(token) {
|
|
13
|
+
this.token = token;
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
|
-
exports.
|
|
13
|
-
/**
|
|
16
|
+
exports.ClientBindOptions = ClientBindOptions;
|
|
17
|
+
/**
|
|
18
|
+
* The browser host's binder, handed to every {@link BindModule}.configure. It collects structural
|
|
19
|
+
* provider recipes; the package imports neither Angular nor Node runtime or types.
|
|
20
|
+
*/
|
|
21
|
+
class Binder {
|
|
22
|
+
recipes = [];
|
|
23
|
+
/** Angular-compatible provider recipes, in order. */
|
|
24
|
+
provide(...recipes) {
|
|
25
|
+
this.recipes.push(...recipes);
|
|
26
|
+
}
|
|
27
|
+
/** Registers a lazy factory provider: the client is created from ClientHttpBrowserFactory on first inject. */
|
|
28
|
+
createRpcClientAndBind(api, deployment, options) {
|
|
29
|
+
const token = options?.token ?? api;
|
|
30
|
+
this.recipes.push(new RpcClientProvider_1.RpcClientProvider(token, api, deployment));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Registers a vendor implementation of an external contract AND records the external-contract
|
|
34
|
+
* graph edge. `impl` is `new UseClass(Vendor)` or `new UseExisting(Token)`.
|
|
35
|
+
*/
|
|
36
|
+
bindExternal(api, impl) {
|
|
37
|
+
this.recipes.push(impl.provider(api));
|
|
38
|
+
}
|
|
39
|
+
get providers() {
|
|
40
|
+
return [...this.recipes];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Binder = Binder;
|
|
44
|
+
/** Configure the selected bind modules once, in topology order. */
|
|
14
45
|
class BrowserWiringProviders {
|
|
15
46
|
toProviders(app) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (const module of modules.routingModules)
|
|
21
|
-
module.configure(bindings);
|
|
22
|
-
return bindings.providers;
|
|
47
|
+
const binder = new Binder();
|
|
48
|
+
for (const module of new http_client_core_1.WiringModules(app).bindModules)
|
|
49
|
+
module.configure(binder);
|
|
50
|
+
return binder.providers;
|
|
23
51
|
}
|
|
24
52
|
}
|
|
25
53
|
exports.BrowserWiringProviders = BrowserWiringProviders;
|
package/src/Wiring.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wiring.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/Wiring.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Wiring.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/Wiring.ts"],"names":[],"mappings":";;;AAOA,kEAA4D;AAC5D,2DAAwD;AAGxD;;;GAGG;AACH,MAAa,iBAAiB;IACE;IAA5B,YAA4B,KAAgC;QAAhC,UAAK,GAAL,KAAK,CAA2B;IAAG,CAAC;CACnE;AAFD,8CAEC;AAED;;;GAGG;AACH,MAAa,MAAM;IACE,OAAO,GAAsB,EAAE,CAAC;IAEjD,qDAAqD;IACrD,OAAO,CAAC,GAAG,OAA0B;QACjC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,8GAA8G;IAC9G,sBAAsB,CAClB,GAAoB,EACpB,UAAkB,EAClB,OAAuC;QAEvC,MAAM,KAAK,GAAiB,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,qCAAiB,CAAI,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACH,YAAY,CAAmB,GAAoB,EAAE,IAA8B;QAC/E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,SAAS;QACT,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;CACJ;AA7BD,wBA6BC;AAWD,mEAAmE;AACnE,MAAa,sBAAsB;IAC/B,WAAW,CAAC,GAAc;QACtB,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC5B,KAAK,MAAM,MAAM,IAAI,IAAI,gCAAa,CAAa,GAAG,CAAC,CAAC,WAAW;YAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC9F,OAAO,MAAM,CAAC,SAAS,CAAC;IAC5B,CAAC;CACJ;AAND,wDAMC","sourcesContent":["import type { BrowserProvider, BrowserToken } from './BrowserProviders';\nimport type {\n ApiPrototype,\n BindModule as HostBindModule,\n Wiring as HostWiring,\n AppWiring as HostAppWiring,\n} from '@webpieces/http-client-core';\nimport { WiringModules } from '@webpieces/http-client-core';\nimport { RpcClientProvider } from './RpcClientProvider';\nimport type { ExternalImpl } from './ExternalImpl';\n\n/**\n * Options for {@link Binder.createRpcClientAndBind}. `token` is an EXTRA identity, needed only when two\n * clients of the SAME api must coexist (e.g. one per deployment); omitted, the API class is the token.\n */\nexport class ClientBindOptions<T> {\n constructor(public readonly token?: ApiPrototype<T> | symbol) {}\n}\n\n/**\n * The browser host's binder, handed to every {@link BindModule}.configure. It collects structural\n * provider recipes; the package imports neither Angular nor Node runtime or types.\n */\nexport class Binder {\n private readonly recipes: BrowserProvider[] = [];\n\n /** Angular-compatible provider recipes, in order. */\n provide(...recipes: BrowserProvider[]): void {\n this.recipes.push(...recipes);\n }\n\n /** Registers a lazy factory provider: the client is created from ClientHttpBrowserFactory on first inject. */\n createRpcClientAndBind<T extends object>(\n api: ApiPrototype<T>,\n deployment: string,\n options?: ClientBindOptions<NoInfer<T>>,\n ): void {\n const token: BrowserToken = options?.token ?? api;\n this.recipes.push(new RpcClientProvider<T>(token, api, deployment));\n }\n\n /**\n * Registers a vendor implementation of an external contract AND records the external-contract\n * graph edge. `impl` is `new UseClass(Vendor)` or `new UseExisting(Token)`.\n */\n bindExternal<T extends object>(api: ApiPrototype<T>, impl: ExternalImpl<NoInfer<T>>): void {\n this.recipes.push(impl.provider(api));\n }\n\n get providers(): BrowserProvider[] {\n return [...this.recipes];\n }\n}\n\n/** A browser DI module. Angular router providers are ordinary provider recipes here. */\nexport interface BindModule extends HostBindModule<Binder> {\n configure(binder: Binder): void;\n}\n\n/** The browser has no route channel: a Wiring selects bind modules only. */\nexport interface Wiring extends HostWiring<BindModule> {}\nexport interface AppWiring extends HostAppWiring<BindModule, Wiring> {}\n\n/** Configure the selected bind modules once, in topology order. */\nexport class BrowserWiringProviders {\n toProviders(app: AppWiring): BrowserProvider[] {\n const binder = new Binder();\n for (const module of new WiringModules<BindModule>(app).bindModules) module.configure(binder);\n return binder.providers;\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -36,9 +36,10 @@ export { ContextMgr } from '@webpieces/core-util';
|
|
|
36
36
|
export { ContextReader, ContextWriter, ContextStore, ContextKey, HeaderRegistry, ClientRegistry, templateDeriver, WebpiecesCoreHeaders, } from '@webpieces/core-util';
|
|
37
37
|
export type { ServiceUrlDeriver } from '@webpieces/core-util';
|
|
38
38
|
export { ApiPath, Endpoint, PathParam, QueryParam, WpAuthPublic, WpAuth, WpAuthorization, AuthorizationType, WpLocalOnly, jwt, oidc, sharedSecret, webhook, apiKey, Rpc, PubSub, Queue, ValidateImplementation, } from '@webpieces/core-util';
|
|
39
|
-
export type { Wiring, AppWiring,
|
|
40
|
-
export {
|
|
39
|
+
export type { Wiring, AppWiring, BindModule } from './Wiring';
|
|
40
|
+
export { Binder, ClientBindOptions, BrowserWiringProviders } from './Wiring';
|
|
41
|
+
export { ExternalImpl, UseClass, UseExisting } from './ExternalImpl';
|
|
42
|
+
export type { ExternalClassType, ExternalExistingType } from './ExternalImpl';
|
|
41
43
|
export { BrowserValueProvider, BrowserClassProvider, BrowserExistingProvider, BrowserFactoryProvider } from './BrowserProviders';
|
|
42
44
|
export type { BrowserProvider, BrowserToken, BrowserType } from './BrowserProviders';
|
|
43
|
-
export {
|
|
44
|
-
export { WiringPolicy, ExternalContractUse } from '@webpieces/http-client-core';
|
|
45
|
+
export { WiringPolicy } from '@webpieces/http-client-core';
|
package/src/index.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* The server twin is @webpieces/http-client-node.
|
|
26
26
|
*/
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
28
|
+
exports.WiringPolicy = exports.BrowserFactoryProvider = exports.BrowserExistingProvider = exports.BrowserClassProvider = exports.BrowserValueProvider = exports.UseExisting = exports.UseClass = exports.ExternalImpl = exports.BrowserWiringProviders = exports.ClientBindOptions = exports.Binder = exports.Queue = exports.PubSub = exports.Rpc = exports.apiKey = exports.webhook = exports.sharedSecret = exports.oidc = exports.jwt = exports.WpLocalOnly = exports.AuthorizationType = exports.WpAuthorization = exports.WpAuth = exports.WpAuthPublic = exports.QueryParam = exports.PathParam = exports.Endpoint = exports.ApiPath = exports.WebpiecesCoreHeaders = exports.templateDeriver = exports.ClientRegistry = exports.HeaderRegistry = exports.ContextKey = exports.ContextMgr = exports.StreamingCapabilityError = exports.RequestOutcome = exports.ClientErrorTranslator = exports.ProxyClient = exports.MutableContextStore = exports.ClientConfig = exports.BrowserApiCallContext = exports.BrowserProxyClient = exports.ClientHttpBrowserFactory = void 0;
|
|
29
29
|
var ClientHttpBrowserFactory_1 = require("./ClientHttpBrowserFactory");
|
|
30
30
|
Object.defineProperty(exports, "ClientHttpBrowserFactory", { enumerable: true, get: function () { return ClientHttpBrowserFactory_1.ClientHttpBrowserFactory; } });
|
|
31
31
|
var BrowserProxyClient_1 = require("./BrowserProxyClient");
|
|
@@ -77,17 +77,18 @@ Object.defineProperty(exports, "Rpc", { enumerable: true, get: function () { ret
|
|
|
77
77
|
Object.defineProperty(exports, "PubSub", { enumerable: true, get: function () { return core_util_3.PubSub; } });
|
|
78
78
|
Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return core_util_3.Queue; } });
|
|
79
79
|
var Wiring_1 = require("./Wiring");
|
|
80
|
-
Object.defineProperty(exports, "
|
|
80
|
+
Object.defineProperty(exports, "Binder", { enumerable: true, get: function () { return Wiring_1.Binder; } });
|
|
81
|
+
Object.defineProperty(exports, "ClientBindOptions", { enumerable: true, get: function () { return Wiring_1.ClientBindOptions; } });
|
|
81
82
|
Object.defineProperty(exports, "BrowserWiringProviders", { enumerable: true, get: function () { return Wiring_1.BrowserWiringProviders; } });
|
|
83
|
+
var ExternalImpl_1 = require("./ExternalImpl");
|
|
84
|
+
Object.defineProperty(exports, "ExternalImpl", { enumerable: true, get: function () { return ExternalImpl_1.ExternalImpl; } });
|
|
85
|
+
Object.defineProperty(exports, "UseClass", { enumerable: true, get: function () { return ExternalImpl_1.UseClass; } });
|
|
86
|
+
Object.defineProperty(exports, "UseExisting", { enumerable: true, get: function () { return ExternalImpl_1.UseExisting; } });
|
|
82
87
|
var BrowserProviders_1 = require("./BrowserProviders");
|
|
83
88
|
Object.defineProperty(exports, "BrowserValueProvider", { enumerable: true, get: function () { return BrowserProviders_1.BrowserValueProvider; } });
|
|
84
89
|
Object.defineProperty(exports, "BrowserClassProvider", { enumerable: true, get: function () { return BrowserProviders_1.BrowserClassProvider; } });
|
|
85
90
|
Object.defineProperty(exports, "BrowserExistingProvider", { enumerable: true, get: function () { return BrowserProviders_1.BrowserExistingProvider; } });
|
|
86
91
|
Object.defineProperty(exports, "BrowserFactoryProvider", { enumerable: true, get: function () { return BrowserProviders_1.BrowserFactoryProvider; } });
|
|
87
|
-
var RpcClientProvider_1 = require("./RpcClientProvider");
|
|
88
|
-
Object.defineProperty(exports, "RpcClientProvider", { enumerable: true, get: function () { return RpcClientProvider_1.RpcClientProvider; } });
|
|
89
|
-
Object.defineProperty(exports, "provideRpcClient", { enumerable: true, get: function () { return RpcClientProvider_1.provideRpcClient; } });
|
|
90
92
|
var http_client_core_3 = require("@webpieces/http-client-core");
|
|
91
93
|
Object.defineProperty(exports, "WiringPolicy", { enumerable: true, get: function () { return http_client_core_3.WiringPolicy; } });
|
|
92
|
-
Object.defineProperty(exports, "ExternalContractUse", { enumerable: true, get: function () { return http_client_core_3.ExternalContractUse; } });
|
|
93
94
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAEH,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,4FAA4F;AAC5F,kGAAkG;AAClG,8BAA8B;AAC9B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,wEAAwE;AACxE,gEAAiG;AAAxF,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAAE,kHAAA,cAAc,OAAA;AAE3D,gEAAuE;AAA9D,4HAAA,wBAAwB,OAAA;AAEjC,iGAAiG;AACjG,mGAAmG;AACnG,kDAAkD;AAAzC,uGAAA,UAAU,OAAA;AAEnB,yFAAyF;AACzF,kDAS8B;AAL1B,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iHAAA,oBAAoB,OAAA;AAIxB,uEAAuE;AACvE,kDAmB8B;AAlB1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,mGAAA,MAAM,OAAA;AACN,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,wGAAA,WAAW,OAAA;AACX,gGAAA,GAAG,OAAA;AACH,iGAAA,IAAI,OAAA;AACJ,yGAAA,YAAY,OAAA;AACZ,oGAAA,OAAO,OAAA;AACP,mGAAA,MAAM,OAAA;AACN,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AAEH,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,4FAA4F;AAC5F,kGAAkG;AAClG,8BAA8B;AAC9B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,wEAAwE;AACxE,gEAAiG;AAAxF,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAAE,kHAAA,cAAc,OAAA;AAE3D,gEAAuE;AAA9D,4HAAA,wBAAwB,OAAA;AAEjC,iGAAiG;AACjG,mGAAmG;AACnG,kDAAkD;AAAzC,uGAAA,UAAU,OAAA;AAEnB,yFAAyF;AACzF,kDAS8B;AAL1B,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iHAAA,oBAAoB,OAAA;AAIxB,uEAAuE;AACvE,kDAmB8B;AAlB1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,mGAAA,MAAM,OAAA;AACN,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,wGAAA,WAAW,OAAA;AACX,gGAAA,GAAG,OAAA;AACH,iGAAA,IAAI,OAAA;AACJ,yGAAA,YAAY,OAAA;AACZ,oGAAA,OAAO,OAAA;AACP,mGAAA,MAAM,OAAA;AACN,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AAOT,mCAA6E;AAApE,gGAAA,MAAM,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAC1D,+CAAqE;AAA5D,4GAAA,YAAY,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAAE,2GAAA,WAAW,OAAA;AAE5C,uDAAiI;AAAxH,wHAAA,oBAAoB,OAAA;AAAE,wHAAA,oBAAoB,OAAA;AAAE,2HAAA,uBAAuB,OAAA;AAAE,0HAAA,sBAAsB,OAAA;AAGpG,gEAA2D;AAAlD,gHAAA,YAAY,OAAA","sourcesContent":["/**\n * @webpieces/http-client-browser\n *\n * The BROWSER HTTP client. Reads an API contract's decorators and generates type-safe HTTP\n * clients from it — the same contract the server implements.\n *\n * DI-free on purpose: this may be bundled by React or Angular, so it ships no inversify and no\n * @webpieces/core-context (which is AsyncLocalStorage-backed and Node-only). Browsers have no\n * ambient request scope, so the app holds a {@link MutableContextStore} and sets context values\n * as they become known; every outbound call then transfers them as headers.\n *\n * Usage:\n * ```typescript\n * import { ClientHttpBrowserFactory, ClientConfig, MutableContextStore } from '@webpieces/http-client-browser';\n *\n * HeaderRegistry.configure(CompanyHeaders.ALL_HEADERS, true);\n * const store = new MutableContextStore();\n * const factory = new ClientHttpBrowserFactory(store);\n *\n * const client = factory.createRpcClient(SaveApi, new ClientConfig('save-svc'));\n * const response = await client.save({ query: 'test' });\n * ```\n *\n * The server twin is @webpieces/http-client-node.\n */\n\nexport { ClientHttpBrowserFactory } from './ClientHttpBrowserFactory';\nexport { BrowserProxyClient } from './BrowserProxyClient';\n// Browser impl of the ApiCallContext seam, constructed by BrowserProxyClient. Exported so a\n// browser/Angular logger can read the current tag via the STATIC BrowserApiCallContext.snapshot()\n// and fold it into log lines.\nexport { BrowserApiCallContext } from './BrowserApiCallContext';\nexport { ClientConfig } from './ClientConfig';\nexport { MutableContextStore } from './MutableContextStore';\nexport type { RequestLifecycleListener } from './RequestLifecycleListener';\n\n// The isomorphic engine, re-exported so a browser app needs one import.\nexport { ProxyClient, ClientErrorTranslator, RequestOutcome } from '@webpieces/http-client-core';\nexport type { ApiPrototype } from '@webpieces/http-client-core';\nexport { StreamingCapabilityError } from '@webpieces/http-client-core';\n\n// ContextMgr is the BROWSER's outbound-header propagation. This is the only package that may use\n// it; the server reads RequestContext directly (RequestContextHeaders in @webpieces/core-context).\nexport { ContextMgr } from '@webpieces/core-util';\n\n// Re-export the context-key contract from core-util for convenience (browser one-import)\nexport {\n ContextReader,\n ContextWriter,\n ContextStore,\n ContextKey,\n HeaderRegistry,\n ClientRegistry,\n templateDeriver,\n WebpiecesCoreHeaders,\n} from '@webpieces/core-util';\nexport type { ServiceUrlDeriver } from '@webpieces/core-util';\n\n// Re-export API decorators for convenience (same as http-routing does)\nexport {\n ApiPath,\n Endpoint,\n PathParam,\n QueryParam,\n WpAuthPublic,\n WpAuth,\n WpAuthorization,\n AuthorizationType,\n WpLocalOnly,\n jwt,\n oidc,\n sharedSecret,\n webhook,\n apiKey,\n Rpc,\n PubSub,\n Queue,\n ValidateImplementation,\n} from '@webpieces/core-util';\n\n// The browser host's wiring: bind modules only (no route channel), the Binder they configure, and\n// the ExternalImpl recipes (UseClass / UseExisting) Binder.bindExternal takes.\nexport type { Wiring, AppWiring, BindModule } from './Wiring';\nexport { Binder, ClientBindOptions, BrowserWiringProviders } from './Wiring';\nexport { ExternalImpl, UseClass, UseExisting } from './ExternalImpl';\nexport type { ExternalClassType, ExternalExistingType } from './ExternalImpl';\nexport { BrowserValueProvider, BrowserClassProvider, BrowserExistingProvider, BrowserFactoryProvider } from './BrowserProviders';\nexport type { BrowserProvider, BrowserToken, BrowserType } from './BrowserProviders';\n\nexport { WiringPolicy } from '@webpieces/http-client-core';\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RpcClientProviderCompileAssertions = void 0;
|
|
4
|
-
const RpcClientProvider_1 = require("./RpcClientProvider");
|
|
5
|
-
class TextApi {
|
|
6
|
-
}
|
|
7
|
-
class CountApi {
|
|
8
|
-
}
|
|
9
|
-
/** Compiled fixtures protect token/API inference after removing destination wrappers. */
|
|
10
|
-
class RpcClientProviderCompileAssertions {
|
|
11
|
-
check() {
|
|
12
|
-
(0, RpcClientProvider_1.provideRpcClient)(TextApi, TextApi, 'text-service');
|
|
13
|
-
// @ts-expect-error Class tokens must match the API contract.
|
|
14
|
-
(0, RpcClientProvider_1.provideRpcClient)(CountApi, TextApi, 'text-service');
|
|
15
|
-
// @ts-expect-error A service destination is required.
|
|
16
|
-
(0, RpcClientProvider_1.provideRpcClient)(TextApi, TextApi);
|
|
17
|
-
// @ts-expect-error Wrapper destinations were removed; use a service string.
|
|
18
|
-
(0, RpcClientProvider_1.provideRpcClient)(TextApi, TextApi, { serviceName: 'text-service' });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.RpcClientProviderCompileAssertions = RpcClientProviderCompileAssertions;
|
|
22
|
-
//# sourceMappingURL=RpcClientProviderCompileAssertions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RpcClientProviderCompileAssertions.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/RpcClientProviderCompileAssertions.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AAEvD,MAAe,OAAO;CAA6B;AACnD,MAAe,QAAQ;CAA6B;AAEpD,yFAAyF;AACzF,MAAa,kCAAkC;IAC3C,KAAK;QACD,IAAA,oCAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACnD,6DAA6D;QAC7D,IAAA,oCAAgB,EAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACpD,sDAAsD;QACtD,IAAA,oCAAgB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnC,4EAA4E;QAC5E,IAAA,oCAAgB,EAAC,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;IACxE,CAAC;CACJ;AAVD,gFAUC","sourcesContent":["import { provideRpcClient } from './RpcClientProvider';\n\nabstract class TextApi { abstract read(): string; }\nabstract class CountApi { abstract read(): number; }\n\n/** Compiled fixtures protect token/API inference after removing destination wrappers. */\nexport class RpcClientProviderCompileAssertions {\n check(): void {\n provideRpcClient(TextApi, TextApi, 'text-service');\n // @ts-expect-error Class tokens must match the API contract.\n provideRpcClient(CountApi, TextApi, 'text-service');\n // @ts-expect-error A service destination is required.\n provideRpcClient(TextApi, TextApi);\n // @ts-expect-error Wrapper destinations were removed; use a service string.\n provideRpcClient(TextApi, TextApi, { serviceName: 'text-service' });\n }\n}\n"]}
|