@temporalio/proto 1.16.1 → 1.17.0

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.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.patchProtobufRoot = patchProtobufRoot;
4
- const ROOT_PROPS = [
4
+ // Properties used internally by protobufjs on Namespace/ReflectionObject instances.
5
+ // A protobuf package component that happens to share one of these names must not be
6
+ // promoted to a direct property, or it would corrupt protobufjs's internal state.
7
+ // (Such types are still reachable via root.lookup() or root.nested traversal.)
8
+ const ROOT_PROPS = new Set([
5
9
  'options',
6
10
  'parsedOptions',
7
11
  'name',
@@ -11,7 +15,7 @@ const ROOT_PROPS = [
11
15
  'filename',
12
16
  'nested',
13
17
  '_nestedArray',
14
- ];
18
+ ]);
15
19
  /**
16
20
  * Create a version of `root` with non-nested namespaces to match the generated types.
17
21
  * For more information, see:
@@ -20,19 +24,53 @@ const ROOT_PROPS = [
20
24
  * @returns A new patched `root`
21
25
  */
22
26
  function patchProtobufRoot(root) {
23
- return _patchProtobufRoot(root);
27
+ const patched = _patchProtobufRoot(root);
28
+ // Protobufjs >=7.5.2 added a fast-path cache in Namespace#lookup() that accesses
29
+ // `this.root._fullyQualifiedObjects`. The `root` accessor is defined as a non-enumerable
30
+ // getter on `ReflectionObject.prototype`, so it is not copied by `for...in` loops.
31
+ // When the patched root is imported via `import * as proto from '@temporalio/proto'`,
32
+ // TypeScript's `__importStar` helper wraps the CJS module in a plain object by iterating
33
+ // own enumerable properties with `for...in` + `hasOwnProperty`. Because `root` is
34
+ // non-enumerable, it is skipped, the wrapper's `root` is `undefined`, and any subsequent
35
+ // `this.root._fullyQualifiedObjects` access crashes.
36
+ // Defining `root` as an own **enumerable** getter ensures `__importStar` includes it in
37
+ // the wrapper, so that `wrapper.root` delegates back to the patched root (which has the
38
+ // proper `_fullyQualifiedObjects` map and full prototype chain).
39
+ if (!Object.getOwnPropertyDescriptor(patched, 'root')) {
40
+ Object.defineProperty(patched, 'root', {
41
+ get() {
42
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
43
+ let ptr = this;
44
+ while (ptr.parent !== null)
45
+ ptr = ptr.parent;
46
+ return ptr;
47
+ },
48
+ enumerable: true,
49
+ configurable: true,
50
+ });
51
+ }
52
+ return patched;
24
53
  }
25
54
  function _patchProtobufRoot(root, name) {
26
55
  const newRoot = new root.constructor(isNamespace(root) ? name : {});
27
56
  for (const key in root) {
57
+ // 'root' is a getter-only accessor defined on ReflectionObject.prototype. Trying to
58
+ // assign it as a plain property on a new Root/Namespace instance throws in strict mode.
59
+ // It is also safe to skip because each object correctly resolves its own root at runtime
60
+ // by traversing the parent chain. The top-level own enumerable getter is added separately
61
+ // by patchProtobufRoot() after recursion completes.
62
+ if (key === 'root')
63
+ continue;
28
64
  newRoot[key] = root[key];
29
65
  }
30
66
  if (isRecord(root.nested)) {
31
67
  for (const typeOrNamespace in root.nested) {
68
+ // Skip names that protobufjs uses internally — overriding them would corrupt
69
+ // the namespace object's internal state. Types/namespaces with these names are
70
+ // still reachable via root.lookup() or by traversing root.nested manually.
71
+ if (ROOT_PROPS.has(typeOrNamespace))
72
+ continue;
32
73
  const value = root.nested[typeOrNamespace];
33
- if (ROOT_PROPS.includes(typeOrNamespace)) {
34
- console.log(`patchProtobufRoot warning: overriding property '${typeOrNamespace}' that is used by protobufjs with the '${typeOrNamespace}' protobuf ${isNamespace(value) ? 'namespace' : 'type'}. This may result in protobufjs not working property.`);
35
- }
36
74
  if (isNamespace(value)) {
37
75
  newRoot[typeOrNamespace] = _patchProtobufRoot(value, typeOrNamespace);
38
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"patch-protobuf-root.js","sourceRoot":"","sources":["../src/patch-protobuf-root.ts"],"names":[],"mappings":";;AAmBA,8CAEC;AArBD,MAAM,UAAU,GAAG;IACjB,SAAS;IACT,eAAe;IACf,MAAM;IACN,QAAQ;IACR,UAAU;IACV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AAS,MAAM,CAAC,KAAc;IAC5B,kHAAkH;IAClH,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAK,KAAK,CAAC,WAAmB,CAAC,SAAS,KAAK,MAAM,CAAC;AAC5E,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,kHAAkH;IAClH,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAK,KAAK,CAAC,WAAmB,CAAC,SAAS,KAAK,WAAW,CAAC;AACjF,CAAC;AAED,yFAAyF;AACzF,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/proto",
3
- "version": "1.16.1",
3
+ "version": "1.17.0",
4
4
  "description": "Temporal.io SDK compiled protobuf definitions",
5
5
  "main": "protos/index.js",
6
6
  "types": "protos/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "long": "^5.2.3",
21
- "protobufjs": "^7.2.5"
21
+ "protobufjs": "7.5.5"
22
22
  },
23
23
  "devDependencies": {
24
24
  "glob": "^10.3.10",
package/protos/index.d.ts CHANGED
@@ -5,14 +5,14 @@
5
5
  *
6
6
  * ### Core SDK API
7
7
  *
8
- * [Core SDK](https://github.com/temporalio/sdk-core) interfaces can be accessed in the `coresdk` namespace.
8
+ * [Core SDK](https://github.com/temporalio/sdk-rust) interfaces can be accessed in the `coresdk` namespace.
9
9
  *
10
10
  * ```ts
11
11
  * import { coresdk } from '@temporalio/proto';
12
12
  * const activityTask: coresdk.activity_task.IActivityTask = { ... };
13
13
  * ```
14
14
  *
15
- * The source protos are in the [sdk-core repo](https://github.com/temporalio/sdk-core/tree/ts-release/protos/local/temporal/sdk/core), for example [`ActivityTask` in `activity_task.proto`](https://github.com/temporalio/sdk-core/blob/85454935e39f789aaaa81f8a05773f8e2cdbcde2/protos/local/temporal/sdk/core/activity_task/activity_task.proto#L12).
15
+ * The source protos are in the [sdk-rust repo](https://github.com/temporalio/sdk-rust/tree/ts-release/protos/local/temporal/sdk/core), for example [`ActivityTask` in `activity_task.proto`](https://github.com/temporalio/sdk-rust/blob/85454935e39f789aaaa81f8a05773f8e2cdbcde2/protos/local/temporal/sdk/core/activity_task/activity_task.proto#L12).
16
16
  *
17
17
  * ### Temporal Service API
18
18
  *
@@ -23,7 +23,7 @@
23
23
  * const retryPolicy: temporal.api.common.v1.IRetryPolicy = { ... };
24
24
  * ```
25
25
  *
26
- * The source protos are in [sdk-core/protos/api_upstream/temporal/api/](https://github.com/temporalio/sdk-core/tree/ts-release/protos/api_upstream/temporal/api), for example [`RetryPolicy` in `temporal/api/common/v1/message.proto`](https://github.com/temporalio/sdk-core/blob/85454935e39f789aaaa81f8a05773f8e2cdbcde2/protos/api_upstream/temporal/api/common/v1/message.proto#L96).
26
+ * The source protos are in [sdk-rust/protos/api_upstream/temporal/api/](https://github.com/temporalio/sdk-rust/tree/ts-release/protos/api_upstream/temporal/api), for example [`RetryPolicy` in `temporal/api/common/v1/message.proto`](https://github.com/temporalio/sdk-rust/blob/85454935e39f789aaaa81f8a05773f8e2cdbcde2/protos/api_upstream/temporal/api/common/v1/message.proto#L96).
27
27
  *
28
28
  * The gRPC service methods are documented in the proto comments and in the corresponding [`Temporal CLI` docs](https://docs.temporal.io/cli/).
29
29
  * @module