@webpieces/http-client-browser 0.3.383 → 0.3.385
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/BrowserApiCallContext.d.ts +27 -0
- package/src/BrowserApiCallContext.js +45 -0
- package/src/BrowserApiCallContext.js.map +1 -0
- package/src/ClientHttpBrowserFactory.js +5 -0
- package/src/ClientHttpBrowserFactory.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-client-browser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.385",
|
|
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.3.
|
|
26
|
-
"@webpieces/http-client-core": "0.3.
|
|
25
|
+
"@webpieces/core-util": "0.3.385",
|
|
26
|
+
"@webpieces/http-client-core": "0.3.385"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ApiCallContext, ContextKey } from '@webpieces/core-util';
|
|
2
|
+
/**
|
|
3
|
+
* BrowserApiCallContext - the BROWSER implementation of the {@link ApiCallContext} seam, so
|
|
4
|
+
* {@link LogApiCall} (shared, browser-safe core-util) stamps its structured `api` tag in the browser
|
|
5
|
+
* too. Installed by {@link ClientHttpBrowserFactory}.
|
|
6
|
+
*
|
|
7
|
+
* WHY a module-level global is SAFE here (no AsyncLocalStorage / Zone.js): {@link LogApiCall} stamps as
|
|
8
|
+
* `set → log → remove` in ONE synchronous span, so the slot is only ever populated while the logger reads
|
|
9
|
+
* it and is cleared before the `await fetch`. A browser is single-threaded, so nothing can interleave
|
|
10
|
+
* between set and remove — a concurrent in-flight call can never clobber the slot. (Because of that, only
|
|
11
|
+
* the `[API-*]` req/resp lines carry `api`, not lines emitted mid-fetch — exactly the filter surface.)
|
|
12
|
+
*
|
|
13
|
+
* READ side: the object-valued `api` tag cannot ride the string-only MutableContextStore, so a
|
|
14
|
+
* downstream browser/Angular logger reads it here via {@link BrowserApiCallContext.snapshot} DURING its
|
|
15
|
+
* log emit (inside the set → remove span) and folds `api.{side,type,result,...}` into that line.
|
|
16
|
+
*/
|
|
17
|
+
export declare class BrowserApiCallContext implements ApiCallContext {
|
|
18
|
+
private static readonly store;
|
|
19
|
+
/** Always active in the browser — there is always the single global slot per key to stamp into. */
|
|
20
|
+
isActive(): boolean;
|
|
21
|
+
set(contextKey: ContextKey, value: unknown): void;
|
|
22
|
+
remove(contextKey: ContextKey): void;
|
|
23
|
+
/**
|
|
24
|
+
* The current stamped values, keyed by ContextKey name — for a browser logger to fold into each line.
|
|
25
|
+
*/
|
|
26
|
+
static snapshot(): ReadonlyMap<string, unknown>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserApiCallContext = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* BrowserApiCallContext - the BROWSER implementation of the {@link ApiCallContext} seam, so
|
|
6
|
+
* {@link LogApiCall} (shared, browser-safe core-util) stamps its structured `api` tag in the browser
|
|
7
|
+
* too. Installed by {@link ClientHttpBrowserFactory}.
|
|
8
|
+
*
|
|
9
|
+
* WHY a module-level global is SAFE here (no AsyncLocalStorage / Zone.js): {@link LogApiCall} stamps as
|
|
10
|
+
* `set → log → remove` in ONE synchronous span, so the slot is only ever populated while the logger reads
|
|
11
|
+
* it and is cleared before the `await fetch`. A browser is single-threaded, so nothing can interleave
|
|
12
|
+
* between set and remove — a concurrent in-flight call can never clobber the slot. (Because of that, only
|
|
13
|
+
* the `[API-*]` req/resp lines carry `api`, not lines emitted mid-fetch — exactly the filter surface.)
|
|
14
|
+
*
|
|
15
|
+
* READ side: the object-valued `api` tag cannot ride the string-only MutableContextStore, so a
|
|
16
|
+
* downstream browser/Angular logger reads it here via {@link BrowserApiCallContext.snapshot} DURING its
|
|
17
|
+
* log emit (inside the set → remove span) and folds `api.{side,type,result,...}` into that line.
|
|
18
|
+
*/
|
|
19
|
+
class BrowserApiCallContext {
|
|
20
|
+
// Shared across every instance (a browser app may build the factory more than once) so the value a
|
|
21
|
+
// logger reads is the same one LogApiCall stamped, whichever instance the holder currently holds.
|
|
22
|
+
// webpieces-disable no-any-unknown -- context values are heterogeneous (the api struct; future keys)
|
|
23
|
+
static store = new Map();
|
|
24
|
+
/** Always active in the browser — there is always the single global slot per key to stamp into. */
|
|
25
|
+
isActive() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
// webpieces-disable no-any-unknown -- a context value is heterogeneous (the api struct here; strings elsewhere)
|
|
29
|
+
set(contextKey, value) {
|
|
30
|
+
BrowserApiCallContext.store.set(contextKey.name, value);
|
|
31
|
+
}
|
|
32
|
+
remove(contextKey) {
|
|
33
|
+
BrowserApiCallContext.store.delete(contextKey.name);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The current stamped values, keyed by ContextKey name — for a browser logger to fold into each line.
|
|
37
|
+
*/
|
|
38
|
+
// webpieces-disable no-any-unknown -- context values are heterogeneous (the api struct; future keys)
|
|
39
|
+
// webpieces-disable no-function-outside-class -- static read accessor of the module-global browser slot (like ApiCallContextHolder), read by a browser logger, not DI-injected
|
|
40
|
+
static snapshot() {
|
|
41
|
+
return BrowserApiCallContext.store;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BrowserApiCallContext = BrowserApiCallContext;
|
|
45
|
+
//# sourceMappingURL=BrowserApiCallContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserApiCallContext.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/BrowserApiCallContext.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAa,qBAAqB;IAC9B,mGAAmG;IACnG,kGAAkG;IAClG,qGAAqG;IAC7F,MAAM,CAAU,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE3D,mGAAmG;IACnG,QAAQ;QACJ,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gHAAgH;IAChH,GAAG,CAAC,UAAsB,EAAE,KAAc;QACtC,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,UAAsB;QACzB,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,qGAAqG;IACrG,+KAA+K;IAC/K,MAAM,CAAC,QAAQ;QACX,OAAO,qBAAqB,CAAC,KAAK,CAAC;IACvC,CAAC;;AA3BL,sDA4BC","sourcesContent":["import { ApiCallContext, ContextKey } from '@webpieces/core-util';\n\n/**\n * BrowserApiCallContext - the BROWSER implementation of the {@link ApiCallContext} seam, so\n * {@link LogApiCall} (shared, browser-safe core-util) stamps its structured `api` tag in the browser\n * too. Installed by {@link ClientHttpBrowserFactory}.\n *\n * WHY a module-level global is SAFE here (no AsyncLocalStorage / Zone.js): {@link LogApiCall} stamps as\n * `set → log → remove` in ONE synchronous span, so the slot is only ever populated while the logger reads\n * it and is cleared before the `await fetch`. A browser is single-threaded, so nothing can interleave\n * between set and remove — a concurrent in-flight call can never clobber the slot. (Because of that, only\n * the `[API-*]` req/resp lines carry `api`, not lines emitted mid-fetch — exactly the filter surface.)\n *\n * READ side: the object-valued `api` tag cannot ride the string-only MutableContextStore, so a\n * downstream browser/Angular logger reads it here via {@link BrowserApiCallContext.snapshot} DURING its\n * log emit (inside the set → remove span) and folds `api.{side,type,result,...}` into that line.\n */\nexport class BrowserApiCallContext implements ApiCallContext {\n // Shared across every instance (a browser app may build the factory more than once) so the value a\n // logger reads is the same one LogApiCall stamped, whichever instance the holder currently holds.\n // webpieces-disable no-any-unknown -- context values are heterogeneous (the api struct; future keys)\n private static readonly store = new Map<string, unknown>();\n\n /** Always active in the browser — there is always the single global slot per key to stamp into. */\n isActive(): boolean {\n return true;\n }\n\n // webpieces-disable no-any-unknown -- a context value is heterogeneous (the api struct here; strings elsewhere)\n set(contextKey: ContextKey, value: unknown): void {\n BrowserApiCallContext.store.set(contextKey.name, value);\n }\n\n remove(contextKey: ContextKey): void {\n BrowserApiCallContext.store.delete(contextKey.name);\n }\n\n /**\n * The current stamped values, keyed by ContextKey name — for a browser logger to fold into each line.\n */\n // webpieces-disable no-any-unknown -- context values are heterogeneous (the api struct; future keys)\n // webpieces-disable no-function-outside-class -- static read accessor of the module-global browser slot (like ApiCallContextHolder), read by a browser logger, not DI-injected\n static snapshot(): ReadonlyMap<string, unknown> {\n return BrowserApiCallContext.store;\n }\n}\n"]}
|
|
@@ -4,6 +4,7 @@ exports.ClientHttpBrowserFactory = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_util_1 = require("@webpieces/core-util");
|
|
6
6
|
const http_client_core_1 = require("@webpieces/http-client-core");
|
|
7
|
+
const BrowserApiCallContext_1 = require("./BrowserApiCallContext");
|
|
7
8
|
const BrowserProxyClient_1 = require("./BrowserProxyClient");
|
|
8
9
|
const MutableContextStore_1 = require("./MutableContextStore");
|
|
9
10
|
/**
|
|
@@ -40,6 +41,10 @@ let ClientHttpBrowserFactory = class ClientHttpBrowserFactory {
|
|
|
40
41
|
constructor(store, headersListener) {
|
|
41
42
|
this.headersListener = headersListener;
|
|
42
43
|
this.contextMgr = new core_util_1.ContextMgr(store);
|
|
44
|
+
// Bind the BROWSER ApiCallContext so LogApiCall (core-util) stamps the `api` tag into the
|
|
45
|
+
// module-global browser slot. Idempotent — building the factory more than once is harmless.
|
|
46
|
+
// Without this, the browser keeps NoopApiCallContext and `api` tagging is inert.
|
|
47
|
+
core_util_1.ApiCallContextHolder.install(new BrowserApiCallContext_1.BrowserApiCallContext());
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
45
50
|
* Create a type-safe HTTP client for one API contract.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientHttpBrowserFactory.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ClientHttpBrowserFactory.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ClientHttpBrowserFactory.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ClientHttpBrowserFactory.ts"],"names":[],"mappings":";;;;AAAA,oDAAwF;AACxF,kEAA6E;AAC7E,mEAAgE;AAChE,6DAA0D;AAE1D,+DAA4D;AAG5D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAKZ;IAJJ,UAAU,CAAa;IAExC,YACI,KAA0B,EACT,eAAyC;QAAzC,oBAAe,GAAf,eAAe,CAA0B;QAE1D,IAAI,CAAC,UAAU,GAAG,IAAI,sBAAU,CAAC,KAAK,CAAC,CAAC;QACxC,0FAA0F;QAC1F,4FAA4F;QAC5F,iFAAiF;QACjF,gCAAoB,CAAC,OAAO,CAAC,IAAI,6CAAqB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAmB,YAA6B,EAAE,MAAoB;QACjF,MAAM,WAAW,GAAG,IAAI,uCAAkB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAClF,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACvC,OAAO,IAAA,mCAAgB,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IACvD,CAAC;CACJ,CAAA;AAzBY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,0BAAc,GAAE;6CAKF,yCAAmB;GAJrB,wBAAwB,CAyBpC","sourcesContent":["import { ApiCallContextHolder, ContextMgr, DocumentDesign } from '@webpieces/core-util';\nimport { ApiPrototype, buildClientProxy } from '@webpieces/http-client-core';\nimport { BrowserApiCallContext } from './BrowserApiCallContext';\nimport { BrowserProxyClient } from './BrowserProxyClient';\nimport { ClientConfig } from './ClientConfig';\nimport { MutableContextStore } from './MutableContextStore';\nimport { ResponseHeadersListener } from './ResponseHeadersListener';\n\n/**\n * ClientHttpBrowserFactory - builds type-safe HTTP clients for a BROWSER from API prototypes\n * carrying @ApiPath/@Endpoint decorators.\n *\n * Deliberately a plain class with NO decorators and NO inversify: this package may be bundled by\n * React just as easily as by Angular, and neither should be forced to adopt a Node DI container.\n * The app provides it through whatever DI it already has — Angular's `useFactory`, a React context,\n * or a module-level `const`.\n *\n * The factory holds the ONE collaborator every browser client shares (the app's\n * {@link MutableContextStore}); each {@link ClientConfig} holds only that one client's base URL.\n *\n * ```typescript\n * // once, at startup (after HeaderRegistry.configure(...)):\n * const store = new MutableContextStore();\n * const factory = new ClientHttpBrowserFactory(store);\n *\n * const saveApi = factory.createRpcClient(SaveApi, new ClientConfig('server'));\n * const response = await saveApi.save({ query: 'test' }); // type-safe\n *\n * // later, when the user logs in / picks a tenant — every subsequent call carries them:\n * store.set(AppHeaders.AUTHORIZATION, token); // an app-defined key, if it wants auto-attach\n * store.set(CompanyHeaders.TENANT_ID, tenantId);\n * ```\n *\n * A browser cannot hold service credentials, so a contract with an @AuthOidc or @AuthSharedSecret\n * endpoint throws in `createRpcClient`, not on the first call.\n */\n@DocumentDesign()\nexport class ClientHttpBrowserFactory {\n private readonly contextMgr: ContextMgr;\n\n constructor(\n store: MutableContextStore,\n private readonly headersListener?: ResponseHeadersListener,\n ) {\n this.contextMgr = new ContextMgr(store);\n // Bind the BROWSER ApiCallContext so LogApiCall (core-util) stamps the `api` tag into the\n // module-global browser slot. Idempotent — building the factory more than once is harmless.\n // Without this, the browser keeps NoopApiCallContext and `api` tagging is inert.\n ApiCallContextHolder.install(new BrowserApiCallContext());\n }\n\n /**\n * Create a type-safe HTTP client for one API contract.\n *\n * @param apiPrototype - The API prototype class with @ApiPath/@Endpoint decorators\n * @param config - This client's state (its baseUrl)\n */\n createRpcClient<T extends object>(apiPrototype: ApiPrototype<T>, config: ClientConfig): T {\n const proxyClient = new BrowserProxyClient(this.contextMgr, this.headersListener);\n proxyClient.init(apiPrototype, config);\n return buildClientProxy(apiPrototype, proxyClient);\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
export { ClientHttpBrowserFactory } from './ClientHttpBrowserFactory';
|
|
27
27
|
export { BrowserProxyClient } from './BrowserProxyClient';
|
|
28
|
+
export { BrowserApiCallContext } from './BrowserApiCallContext';
|
|
28
29
|
export { ClientConfig } from './ClientConfig';
|
|
29
30
|
export { MutableContextStore } from './MutableContextStore';
|
|
30
31
|
export type { ResponseHeadersListener } from './ResponseHeadersListener';
|
package/src/index.js
CHANGED
|
@@ -25,11 +25,15 @@
|
|
|
25
25
|
* The server twin is @webpieces/http-client-node.
|
|
26
26
|
*/
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Queue = exports.PubSub = exports.Rpc = exports.AuthSharedSecret = exports.AuthOidc = exports.AuthJwt = exports.Public = exports.AuthenticationConfig = exports.Authentication = exports.Endpoint = exports.ApiPath = exports.WebpiecesCoreHeaders = exports.templateDeriver = exports.ClientRegistry = exports.HeaderRegistry = exports.ContextKey = exports.ContextMgr = exports.ClientErrorTranslator = exports.ProxyClient = exports.MutableContextStore = exports.ClientConfig = exports.BrowserProxyClient = exports.ClientHttpBrowserFactory = void 0;
|
|
28
|
+
exports.Queue = exports.PubSub = exports.Rpc = exports.AuthSharedSecret = exports.AuthOidc = exports.AuthJwt = exports.Public = exports.AuthenticationConfig = exports.Authentication = exports.Endpoint = exports.ApiPath = exports.WebpiecesCoreHeaders = exports.templateDeriver = exports.ClientRegistry = exports.HeaderRegistry = exports.ContextKey = exports.ContextMgr = 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");
|
|
32
32
|
Object.defineProperty(exports, "BrowserProxyClient", { enumerable: true, get: function () { return BrowserProxyClient_1.BrowserProxyClient; } });
|
|
33
|
+
// Browser impl of the ApiCallContext seam (installed by the factory). Exported so a browser/Angular
|
|
34
|
+
// logger can read the current tag via ApiCallContextHolder.get().peek() and fold it into log lines.
|
|
35
|
+
var BrowserApiCallContext_1 = require("./BrowserApiCallContext");
|
|
36
|
+
Object.defineProperty(exports, "BrowserApiCallContext", { enumerable: true, get: function () { return BrowserApiCallContext_1.BrowserApiCallContext; } });
|
|
33
37
|
var ClientConfig_1 = require("./ClientConfig");
|
|
34
38
|
Object.defineProperty(exports, "ClientConfig", { enumerable: true, get: function () { return ClientConfig_1.ClientConfig; } });
|
|
35
39
|
var MutableContextStore_1 = require("./MutableContextStore");
|
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,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,wEAAwE;AACxE,gEAAiF;AAAxE,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAG3C,iGAAiG;AACjG,mGAAmG;AACnG,kDAAkD;AAAzC,uGAAA,UAAU,OAAA;AAEnB,yFAAyF;AACzF,kDAO8B;AAL1B,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iHAAA,oBAAoB,OAAA;AAIxB,uEAAuE;AACvE,kDAa8B;AAZ1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,6GAAA,gBAAgB,OAAA;AAChB,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,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.getAllHeaders(), 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';\nexport { ClientConfig } from './ClientConfig';\nexport { MutableContextStore } from './MutableContextStore';\nexport type { ResponseHeadersListener } from './ResponseHeadersListener';\n\n// The isomorphic engine, re-exported so a browser app needs one import.\nexport { ProxyClient, ClientErrorTranslator } from '@webpieces/http-client-core';\nexport type { ApiPrototype } 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 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 Authentication,\n AuthenticationConfig,\n Public,\n AuthJwt,\n AuthOidc,\n AuthSharedSecret,\n Rpc,\n PubSub,\n Queue,\n ValidateImplementation,\n} from '@webpieces/core-util';\n"]}
|
|
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,oGAAoG;AACpG,oGAAoG;AACpG,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,wEAAwE;AACxE,gEAAiF;AAAxE,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAG3C,iGAAiG;AACjG,mGAAmG;AACnG,kDAAkD;AAAzC,uGAAA,UAAU,OAAA;AAEnB,yFAAyF;AACzF,kDAO8B;AAL1B,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iHAAA,oBAAoB,OAAA;AAIxB,uEAAuE;AACvE,kDAa8B;AAZ1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,6GAAA,gBAAgB,OAAA;AAChB,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,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.getAllHeaders(), 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 (installed by the factory). Exported so a browser/Angular\n// logger can read the current tag via ApiCallContextHolder.get().peek() and fold it into log lines.\nexport { BrowserApiCallContext } from './BrowserApiCallContext';\nexport { ClientConfig } from './ClientConfig';\nexport { MutableContextStore } from './MutableContextStore';\nexport type { ResponseHeadersListener } from './ResponseHeadersListener';\n\n// The isomorphic engine, re-exported so a browser app needs one import.\nexport { ProxyClient, ClientErrorTranslator } from '@webpieces/http-client-core';\nexport type { ApiPrototype } 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 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 Authentication,\n AuthenticationConfig,\n Public,\n AuthJwt,\n AuthOidc,\n AuthSharedSecret,\n Rpc,\n PubSub,\n Queue,\n ValidateImplementation,\n} from '@webpieces/core-util';\n"]}
|