@webpieces/cloudtasks-client 0.3.380 → 0.3.382

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/README.md CHANGED
@@ -22,10 +22,11 @@ await scheduler.addToQueue(() => emailTasks.sendEmail(req), { dedupName: req.id
22
22
  - `ClientCloudTasksFactory.createPubSubClient(Api, TaskClientConfig)` — builds the enqueue proxy. It
23
23
  injects a `Provider<TaskProxyClient>` and calls `get()` per contract; `TaskProxyClient` is bound
24
24
  TRANSIENT, so each client gets its own. The delivery URL is resolved at enqueue time from `svcName`
25
- via `resolveServiceUrl`: a `ClientRegistry` override wins, else on GCP it is derived from the Cloud
26
- Run service name (same project + region, so you maintain no URL table), else (off-GCP, unregistered)
27
- it throws. Register non-derivable URLs (localhost, cross-region, non-Cloud-Run) once at startup with
28
- `ClientRegistry.addMapping(svcName, port)` / `addUrlMapping(svcName, url)`
25
+ through `ClientRegistry.resolve` the SAME chain the RPC client runs: a registered mapping wins,
26
+ else the installed deriver (`ClientRegistry.setDeriver(gcpCloudRunDeriver())` on GCP), else it
27
+ throws, because an unresolvable target is a setup bug. Register non-derivable URLs (localhost,
28
+ cross-region, non-Cloud-Run) once at startup with `ClientRegistry.addMapping(svcName, port)` /
29
+ `addUrlMapping(svcName, url)`
29
30
  - An enqueue outside `RequestContext.run(...)` **throws**: a task with no caller trace is a bug
30
31
  - `CloudTaskScheduler` — `addToQueue` / `schedule` / `cancelJob`; carries scheduling
31
32
  options out-of-band so the contract signature stays identical on both sides
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/cloudtasks-client",
3
- "version": "0.3.380",
3
+ "version": "0.3.382",
4
4
  "description": "Cloud Tasks enqueue client generated from a shared @PubSub API contract (twin of http-client)",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -23,9 +23,9 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@webpieces/core-context": "0.3.380",
27
- "@webpieces/core-util": "0.3.380",
28
- "@webpieces/gcp-identity": "0.3.380",
26
+ "@webpieces/core-context": "0.3.382",
27
+ "@webpieces/core-util": "0.3.382",
28
+ "@webpieces/gcp-identity": "0.3.382",
29
29
  "@google-cloud/tasks": "5.5.2",
30
30
  "inversify": "7.10.4",
31
31
  "reflect-metadata": "0.2.2"
@@ -25,6 +25,12 @@ export declare class TaskClientConfig {
25
25
  * host — is a `ClientRegistry` mapping registered at startup, NOT a per-client URL.
26
26
  */
27
27
  svcName: string);
28
- /** Resolved per enqueue, not at construction — so building a client stays synchronous. */
28
+ /**
29
+ * Resolved per enqueue, not at construction — so building a client stays synchronous.
30
+ *
31
+ * This goes through {@link ClientRegistry.resolve}, the SAME chain (mapping, else deriver, else
32
+ * throw) the RPC client runs. Cloud Tasks does not go through `ProxyClient.resolveBaseUrl()`, so
33
+ * it has to reach the chain itself — otherwise enqueue targets drift from call targets.
34
+ */
29
35
  resolveUrl(): Promise<string>;
30
36
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskClientConfig = void 0;
4
- const gcp_identity_1 = require("@webpieces/gcp-identity");
4
+ const core_util_1 = require("@webpieces/core-util");
5
5
  /**
6
6
  * Per-client STATE for a Cloud Tasks enqueue client — nothing else.
7
7
  *
@@ -21,9 +21,15 @@ class TaskClientConfig {
21
21
  svcName) {
22
22
  this.svcName = svcName;
23
23
  }
24
- /** Resolved per enqueue, not at construction — so building a client stays synchronous. */
24
+ /**
25
+ * Resolved per enqueue, not at construction — so building a client stays synchronous.
26
+ *
27
+ * This goes through {@link ClientRegistry.resolve}, the SAME chain (mapping, else deriver, else
28
+ * throw) the RPC client runs. Cloud Tasks does not go through `ProxyClient.resolveBaseUrl()`, so
29
+ * it has to reach the chain itself — otherwise enqueue targets drift from call targets.
30
+ */
25
31
  resolveUrl() {
26
- return (0, gcp_identity_1.resolveServiceUrl)(this.svcName);
32
+ return core_util_1.ClientRegistry.resolve(this.svcName);
27
33
  }
28
34
  }
29
35
  exports.TaskClientConfig = TaskClientConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"TaskClientConfig.js","sourceRoot":"","sources":["../../../../../packages/cloud/cloudtasks-client/src/TaskClientConfig.ts"],"names":[],"mappings":";;;AAAA,0DAA4D;AAK5D;;;;;;GAMG;AACH,MAAa,gBAAgB;IAQL;IAPpB;IACI;;;;;OAKG;IACa,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAChC,CAAC;IAEJ,0FAA0F;IAC1F,UAAU;QACN,OAAO,IAAA,gCAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;CACJ;AAfD,4CAeC","sourcesContent":["import { resolveServiceUrl } from '@webpieces/gcp-identity';\n\n/** Constructor whose prototype is T (the abstract @PubSub API class). */\nexport type ApiPrototype<T> = Function & { prototype: T };\n\n/**\n * Per-client STATE for a Cloud Tasks enqueue client — nothing else.\n *\n * Collaborators (TaskInvoker, RequestContextHeaders) are NOT config: they are dependencies of\n * {@link ClientCloudTasksFactory} and shared by every client it builds. This is the fire-and-forget\n * twin of http-client-node's ClientConfig, and takes the same single field.\n */\nexport class TaskClientConfig {\n constructor(\n /**\n * The service name. On GCP the URL is DERIVED from it (same project, same region — the Cloud\n * Run service name, so you maintain no URL table), which works across demo/qa/prod. Anything\n * the derivation cannot describe — a localhost port, another region/project, a non-Cloud-Run\n * host — is a `ClientRegistry` mapping registered at startup, NOT a per-client URL.\n */\n public readonly svcName: string,\n ) {}\n\n /** Resolved per enqueue, not at construction — so building a client stays synchronous. */\n resolveUrl(): Promise<string> {\n return resolveServiceUrl(this.svcName);\n }\n}\n"]}
1
+ {"version":3,"file":"TaskClientConfig.js","sourceRoot":"","sources":["../../../../../packages/cloud/cloudtasks-client/src/TaskClientConfig.ts"],"names":[],"mappings":";;;AAAA,oDAAsD;AAKtD;;;;;;GAMG;AACH,MAAa,gBAAgB;IAQL;IAPpB;IACI;;;;;OAKG;IACa,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAChC,CAAC;IAEJ;;;;;;OAMG;IACH,UAAU;QACN,OAAO,0BAAc,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACJ;AArBD,4CAqBC","sourcesContent":["import { ClientRegistry } from '@webpieces/core-util';\n\n/** Constructor whose prototype is T (the abstract @PubSub API class). */\nexport type ApiPrototype<T> = Function & { prototype: T };\n\n/**\n * Per-client STATE for a Cloud Tasks enqueue client — nothing else.\n *\n * Collaborators (TaskInvoker, RequestContextHeaders) are NOT config: they are dependencies of\n * {@link ClientCloudTasksFactory} and shared by every client it builds. This is the fire-and-forget\n * twin of http-client-node's ClientConfig, and takes the same single field.\n */\nexport class TaskClientConfig {\n constructor(\n /**\n * The service name. On GCP the URL is DERIVED from it (same project, same region — the Cloud\n * Run service name, so you maintain no URL table), which works across demo/qa/prod. Anything\n * the derivation cannot describe — a localhost port, another region/project, a non-Cloud-Run\n * host — is a `ClientRegistry` mapping registered at startup, NOT a per-client URL.\n */\n public readonly svcName: string,\n ) {}\n\n /**\n * Resolved per enqueue, not at construction — so building a client stays synchronous.\n *\n * This goes through {@link ClientRegistry.resolve}, the SAME chain (mapping, else deriver, else\n * throw) the RPC client runs. Cloud Tasks does not go through `ProxyClient.resolveBaseUrl()`, so\n * it has to reach the chain itself — otherwise enqueue targets drift from call targets.\n */\n resolveUrl(): Promise<string> {\n return ClientRegistry.resolve(this.svcName);\n }\n}\n"]}