@webpieces/http-client-browser 0.4.793 → 0.4.794
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.794",
|
|
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.794",
|
|
26
|
+
"@webpieces/http-client-core": "0.4.794"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -18,13 +18,22 @@ import { RequestOutcome } from '@webpieces/http-client-core';
|
|
|
18
18
|
* `onRequestStart` and `onRequestEnd` are PAIRED: every start is followed by exactly one end, on
|
|
19
19
|
* every path (2xx, HTTP error, network reject), so a counter driven off them cannot leak.
|
|
20
20
|
*
|
|
21
|
+
* `route.background` is the endpoint's own declaration that it is plumbing the user did not ask for
|
|
22
|
+
* — a log shipper, a heartbeat, a telemetry flush (`@Endpoint(..., { background: true })`). It is not
|
|
23
|
+
* progress, so a bar driven off these callbacks should skip it, and so should any app-level RPC
|
|
24
|
+
* instrumentation whose own lines would otherwise become the next batch's payload. webpieces already
|
|
25
|
+
* emits no `[API-client-*]` line for such a route; this is the app's half of the same fact, read from
|
|
26
|
+
* the ROUTE rather than matched on a path string.
|
|
27
|
+
*
|
|
21
28
|
* ```typescript
|
|
22
29
|
* class RpcLifecycleListener implements RequestLifecycleListener {
|
|
23
|
-
* onRequestStart(
|
|
30
|
+
* onRequestStart(route: RouteMetadata): void {
|
|
31
|
+
* if (route.background) return;
|
|
24
32
|
* progressBar.noteRequestStart();
|
|
25
33
|
* }
|
|
26
|
-
* onRequestEnd(
|
|
34
|
+
* onRequestEnd(route: RouteMetadata, outcome: RequestOutcome): void {
|
|
27
35
|
* serverVersionBridge.set(outcome.headers?.get('x-myorg-server-version'));
|
|
36
|
+
* if (route.background) return;
|
|
28
37
|
* progressBar.noteRequestEnd(!outcome.ok);
|
|
29
38
|
* }
|
|
30
39
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestLifecycleListener.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/RequestLifecycleListener.ts"],"names":[],"mappings":"","sourcesContent":["import { RouteMetadata } from '@webpieces/core-util';\nimport { RequestOutcome } from '@webpieces/http-client-core';\n\n/**\n * The inbound seam an app implements to observe the FULL lifecycle of every RPC call — symmetric\n * with the outbound header propagation done by {@link MutableContextStore} / {@link ContextMgr}.\n * Registered once on {@link ClientHttpBrowserFactory}; invoked by {@link BrowserProxyClient} around\n * each call.\n *\n * Replaces the older header-only ResponseHeadersListener. `onRequestEnd`'s `outcome.headers` carries\n * the same Response Headers (after settlement, on both ok and error), and it adds the\n * two signals the header-only seam could not give: a START marker, and success-or-error.\n *\n * The driver is a browser app that must drive ONE progress bar across N requests per user action,\n * AND detect that a newer server is deployed than this bundle (the server stamps\n * `x-<org>-server-version` on every response) — reloading only at a safe moment, so a half-filled\n * form is never blown away. It needs, per RPC: bar on, bar off, the outcome, and the headers.\n *\n * `onRequestStart` and `onRequestEnd` are PAIRED: every start is followed by exactly one end, on\n * every path (2xx, HTTP error, network reject), so a counter driven off them cannot leak.\n *\n * ```typescript\n * class RpcLifecycleListener implements RequestLifecycleListener {\n * onRequestStart(
|
|
1
|
+
{"version":3,"file":"RequestLifecycleListener.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/RequestLifecycleListener.ts"],"names":[],"mappings":"","sourcesContent":["import { RouteMetadata } from '@webpieces/core-util';\nimport { RequestOutcome } from '@webpieces/http-client-core';\n\n/**\n * The inbound seam an app implements to observe the FULL lifecycle of every RPC call — symmetric\n * with the outbound header propagation done by {@link MutableContextStore} / {@link ContextMgr}.\n * Registered once on {@link ClientHttpBrowserFactory}; invoked by {@link BrowserProxyClient} around\n * each call.\n *\n * Replaces the older header-only ResponseHeadersListener. `onRequestEnd`'s `outcome.headers` carries\n * the same Response Headers (after settlement, on both ok and error), and it adds the\n * two signals the header-only seam could not give: a START marker, and success-or-error.\n *\n * The driver is a browser app that must drive ONE progress bar across N requests per user action,\n * AND detect that a newer server is deployed than this bundle (the server stamps\n * `x-<org>-server-version` on every response) — reloading only at a safe moment, so a half-filled\n * form is never blown away. It needs, per RPC: bar on, bar off, the outcome, and the headers.\n *\n * `onRequestStart` and `onRequestEnd` are PAIRED: every start is followed by exactly one end, on\n * every path (2xx, HTTP error, network reject), so a counter driven off them cannot leak.\n *\n * `route.background` is the endpoint's own declaration that it is plumbing the user did not ask for\n * — a log shipper, a heartbeat, a telemetry flush (`@Endpoint(..., { background: true })`). It is not\n * progress, so a bar driven off these callbacks should skip it, and so should any app-level RPC\n * instrumentation whose own lines would otherwise become the next batch's payload. webpieces already\n * emits no `[API-client-*]` line for such a route; this is the app's half of the same fact, read from\n * the ROUTE rather than matched on a path string.\n *\n * ```typescript\n * class RpcLifecycleListener implements RequestLifecycleListener {\n * onRequestStart(route: RouteMetadata): void {\n * if (route.background) return;\n * progressBar.noteRequestStart();\n * }\n * onRequestEnd(route: RouteMetadata, outcome: RequestOutcome): void {\n * serverVersionBridge.set(outcome.headers?.get('x-myorg-server-version'));\n * if (route.background) return;\n * progressBar.noteRequestEnd(!outcome.ok);\n * }\n * }\n * const factory = new ClientHttpBrowserFactory(store, new RpcLifecycleListener());\n * ```\n *\n * This is BUSINESS LOGIC (methods), so it is an interface, not a data class — unlike the\n * {@link RequestOutcome} it is handed.\n */\nexport interface RequestLifecycleListener {\n /** Before fetch, once per RPC. */\n onRequestStart(route: RouteMetadata): void;\n\n /** Once, after the call settles, on every path (success, HTTP error, network reject). */\n onRequestEnd(route: RouteMetadata, outcome: RequestOutcome): void;\n}\n"]}
|