@webpieces/http-client-browser 0.4.439 → 0.4.441
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-client-browser",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.441",
|
|
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.441",
|
|
26
|
+
"@webpieces/http-client-core": "0.4.441"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiCallContext,
|
|
1
|
+
import { ApiCallContext, AnyContextKey } from '@webpieces/core-util';
|
|
2
2
|
/**
|
|
3
3
|
* BrowserApiCallContext - the BROWSER implementation of the {@link ApiCallContext} seam, so
|
|
4
4
|
* {@link LogApiCall} (shared, browser-safe core-util) stamps its structured `api` tag in the browser
|
|
@@ -18,8 +18,8 @@ export declare class BrowserApiCallContext implements ApiCallContext {
|
|
|
18
18
|
private static readonly store;
|
|
19
19
|
/** Always active in the browser — there is always the single global slot per key to stamp into. */
|
|
20
20
|
isActive(): boolean;
|
|
21
|
-
set(contextKey:
|
|
22
|
-
remove(contextKey:
|
|
21
|
+
set(contextKey: AnyContextKey, value: unknown): void;
|
|
22
|
+
remove(contextKey: AnyContextKey): void;
|
|
23
23
|
/**
|
|
24
24
|
* The current stamped values, keyed by ContextKey name — for a browser logger to fold into each line.
|
|
25
25
|
*/
|
|
@@ -1 +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,
|
|
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,UAAyB,EAAE,KAAc;QACzC,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,UAAyB;QAC5B,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, AnyContextKey } 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: AnyContextKey, value: unknown): void {\n BrowserApiCallContext.store.set(contextKey.name, value);\n }\n\n remove(contextKey: AnyContextKey): 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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyContextKey, ContextReader } from '@webpieces/core-util';
|
|
2
2
|
/**
|
|
3
3
|
* MutableContextStore - the BROWSER ContextReader.
|
|
4
4
|
*
|
|
@@ -23,10 +23,10 @@ import { ContextKey, ContextReader } from '@webpieces/core-util';
|
|
|
23
23
|
export declare class MutableContextStore implements ContextReader {
|
|
24
24
|
private values;
|
|
25
25
|
/** Set (or overwrite) the current value for a context key. */
|
|
26
|
-
set(key:
|
|
26
|
+
set(key: AnyContextKey, value: string): void;
|
|
27
27
|
/** Remove the current value for a context key (e.g. on logout). */
|
|
28
|
-
remove(key:
|
|
28
|
+
remove(key: AnyContextKey): void;
|
|
29
29
|
/** Clear all stored values. */
|
|
30
30
|
clear(): void;
|
|
31
|
-
read(key:
|
|
31
|
+
read(key: AnyContextKey): string | undefined;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutableContextStore.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/MutableContextStore.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,mBAAmB;IACpB,MAAM,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEhD,8DAA8D;IAC9D,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"MutableContextStore.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/MutableContextStore.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,mBAAmB;IACpB,MAAM,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEhD,8DAA8D;IAC9D,GAAG,CAAC,GAAkB,EAAE,KAAa;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,mEAAmE;IACnE,MAAM,CAAC,GAAkB;QACrB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,+BAA+B;IAC/B,KAAK;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,GAAkB;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACJ;AArBD,kDAqBC","sourcesContent":["import { ContextKey, AnyContextKey, ContextReader } from '@webpieces/core-util';\n\n/**\n * MutableContextStore - the BROWSER ContextReader.\n *\n * Browsers have no AsyncLocalStorage, so apps (Angular/React) hold one of these\n * (e.g. as an Angular service / React context value) and set values as they become\n * known (login token, selected tenant, ...). The ContextMgr then reads from it on\n * every outbound request.\n *\n * Example (Angular):\n * ```typescript\n * const store = new MutableContextStore();\n * // startup:\n * HeaderRegistry.configure(CompanyHeaders.getAllHeaders(), true);\n * const factory = new ClientHttpFactory(new ContextMgr(store));\n * const client = factory.createRpcClient(SaveApi, new ClientConfig('server'));\n *\n * // later, when the user logs in / picks a tenant:\n * store.set(AppHeaders.AUTHORIZATION, token); // an app-defined key, if it wants auto-attach\n * store.set(CompanyHeaders.TENANT_ID, tenantId);\n * ```\n */\nexport class MutableContextStore implements ContextReader {\n private values: Map<string, string> = new Map();\n\n /** Set (or overwrite) the current value for a context key. */\n set(key: AnyContextKey, value: string): void {\n this.values.set(key.name, value);\n }\n\n /** Remove the current value for a context key (e.g. on logout). */\n remove(key: AnyContextKey): void {\n this.values.delete(key.name);\n }\n\n /** Clear all stored values. */\n clear(): void {\n this.values.clear();\n }\n\n read(key: AnyContextKey): string | undefined {\n return this.values.get(key.name);\n }\n}\n"]}
|