@temporalio/common 1.11.8 → 1.12.0-rc.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.
Files changed (87) hide show
  1. package/lib/activity-options.d.ts +6 -1
  2. package/lib/activity-options.js.map +1 -1
  3. package/lib/converter/failure-converter.d.ts +3 -3
  4. package/lib/converter/failure-converter.js +3 -1
  5. package/lib/converter/failure-converter.js.map +1 -1
  6. package/lib/converter/payload-converter.d.ts +2 -15
  7. package/lib/converter/payload-converter.js +6 -69
  8. package/lib/converter/payload-converter.js.map +1 -1
  9. package/lib/converter/payload-search-attributes.d.ts +26 -0
  10. package/lib/converter/payload-search-attributes.js +171 -0
  11. package/lib/converter/payload-search-attributes.js.map +1 -0
  12. package/lib/converter/protobuf-payload-converters.js +3 -2
  13. package/lib/converter/protobuf-payload-converters.js.map +1 -1
  14. package/lib/errors.d.ts +2 -1
  15. package/lib/errors.js +6 -1
  16. package/lib/errors.js.map +1 -1
  17. package/lib/failure.d.ts +20 -1
  18. package/lib/failure.js +47 -5
  19. package/lib/failure.js.map +1 -1
  20. package/lib/index.d.ts +7 -0
  21. package/lib/index.js +9 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib/interfaces.d.ts +0 -7
  24. package/lib/interfaces.js.map +1 -1
  25. package/lib/internal-non-workflow/codec-helpers.d.ts +2 -2
  26. package/lib/internal-non-workflow/index.d.ts +0 -1
  27. package/lib/internal-non-workflow/index.js +0 -1
  28. package/lib/internal-non-workflow/index.js.map +1 -1
  29. package/lib/internal-workflow/index.d.ts +1 -0
  30. package/lib/internal-workflow/index.js +1 -0
  31. package/lib/internal-workflow/index.js.map +1 -1
  32. package/lib/internal-workflow/objects-helpers.d.ts +15 -0
  33. package/lib/internal-workflow/objects-helpers.js +29 -0
  34. package/lib/internal-workflow/objects-helpers.js.map +1 -0
  35. package/lib/logger.d.ts +32 -0
  36. package/lib/logger.js +91 -1
  37. package/lib/logger.js.map +1 -1
  38. package/lib/metrics.d.ts +181 -0
  39. package/lib/metrics.js +240 -0
  40. package/lib/metrics.js.map +1 -0
  41. package/lib/priority.d.ts +36 -0
  42. package/lib/priority.js +27 -0
  43. package/lib/priority.js.map +1 -0
  44. package/lib/search-attributes.d.ts +77 -0
  45. package/lib/search-attributes.js +233 -0
  46. package/lib/search-attributes.js.map +1 -0
  47. package/lib/type-helpers.d.ts +5 -1
  48. package/lib/type-helpers.js +0 -22
  49. package/lib/type-helpers.js.map +1 -1
  50. package/lib/versioning-intent-enum.d.ts +1 -1
  51. package/lib/versioning-intent-enum.js +1 -1
  52. package/lib/versioning-intent.d.ts +1 -1
  53. package/lib/worker-deployments.d.ts +47 -0
  54. package/lib/worker-deployments.js +32 -0
  55. package/lib/worker-deployments.js.map +1 -0
  56. package/lib/workflow-definition-options.d.ts +18 -0
  57. package/lib/workflow-definition-options.js +3 -0
  58. package/lib/workflow-definition-options.js.map +1 -0
  59. package/lib/workflow-options.d.ts +22 -2
  60. package/lib/workflow-options.js.map +1 -1
  61. package/package.json +6 -3
  62. package/src/activity-options.ts +7 -1
  63. package/src/converter/failure-converter.ts +9 -4
  64. package/src/converter/payload-converter.ts +7 -71
  65. package/src/converter/payload-search-attributes.ts +220 -0
  66. package/src/errors.ts +2 -1
  67. package/src/failure.ts +38 -3
  68. package/src/index.ts +13 -0
  69. package/src/interfaces.ts +0 -8
  70. package/src/internal-non-workflow/codec-helpers.ts +2 -2
  71. package/src/internal-non-workflow/index.ts +0 -1
  72. package/src/internal-workflow/index.ts +1 -0
  73. package/src/internal-workflow/objects-helpers.ts +37 -0
  74. package/src/logger.ts +108 -0
  75. package/src/metrics.ts +443 -0
  76. package/src/priority.ts +54 -0
  77. package/src/search-attributes.ts +292 -0
  78. package/src/type-helpers.ts +11 -23
  79. package/src/versioning-intent-enum.ts +1 -1
  80. package/src/versioning-intent.ts +1 -1
  81. package/src/worker-deployments.ts +70 -0
  82. package/src/workflow-definition-options.ts +20 -0
  83. package/src/workflow-options.ts +27 -3
  84. package/lib/internal-non-workflow/utils.d.ts +0 -4
  85. package/lib/internal-non-workflow/utils.js +0 -10
  86. package/lib/internal-non-workflow/utils.js.map +0 -1
  87. package/src/internal-non-workflow/utils.ts +0 -6
@@ -0,0 +1,181 @@
1
+ /**
2
+ * A meter for creating metrics to record values on.
3
+ *
4
+ * @experimental The Metric API is an experimental feature and may be subject to change.
5
+ */
6
+ export interface MetricMeter {
7
+ /**
8
+ * Create a new counter metric that supports adding values.
9
+ *
10
+ * @param name Name for the counter metric.
11
+ * @param unit Unit for the counter metric. Optional.
12
+ * @param description Description for the counter metric. Optional.
13
+ */
14
+ createCounter(name: string, unit?: string, description?: string): MetricCounter;
15
+ /**
16
+ * Create a new histogram metric that supports recording values.
17
+ *
18
+ * @param name Name for the histogram metric.
19
+ * @param valueType Type of value to record. Defaults to `int`.
20
+ * @param unit Unit for the histogram metric. Optional.
21
+ * @param description Description for the histogram metric. Optional.
22
+ */
23
+ createHistogram(name: string, valueType?: NumericMetricValueType, unit?: string, description?: string): MetricHistogram;
24
+ /**
25
+ * Create a new gauge metric that supports setting values.
26
+ *
27
+ * @param name Name for the gauge metric.
28
+ * @param valueType Type of value to set. Defaults to `int`.
29
+ * @param unit Unit for the gauge metric. Optional.
30
+ * @param description Description for the gauge metric. Optional.
31
+ */
32
+ createGauge(name: string, valueType?: NumericMetricValueType, unit?: string, description?: string): MetricGauge;
33
+ /**
34
+ * Return a clone of this meter, with additional tags. All metrics created off the meter will
35
+ * have the tags.
36
+ *
37
+ * @param tags Tags to append.
38
+ */
39
+ withTags(tags: MetricTags): MetricMeter;
40
+ }
41
+ /**
42
+ * Base interface for all metrics.
43
+ *
44
+ * @experimental The Metric API is an experimental feature and may be subject to change.
45
+ */
46
+ export interface Metric {
47
+ /**
48
+ * The name of the metric.
49
+ */
50
+ name: string;
51
+ /**
52
+ * The unit of the metric, if any.
53
+ */
54
+ unit?: string;
55
+ /**
56
+ * The description of the metric, if any.
57
+ */
58
+ description?: string;
59
+ }
60
+ /**
61
+ * A metric that supports adding values as a counter.
62
+ *
63
+ * @experimental The Metric API is an experimental feature and may be subject to change.
64
+ */
65
+ export interface MetricCounter extends Metric {
66
+ /**
67
+ * Add the given value to the counter.
68
+ *
69
+ * @param value Value to add.
70
+ * @param extraTags Extra tags if any.
71
+ */
72
+ add(value: number, extraTags?: MetricTags): void;
73
+ /**
74
+ * Return a clone of this counter, with additional tags.
75
+ *
76
+ * @param tags Tags to append to existing tags.
77
+ */
78
+ withTags(tags: MetricTags): MetricCounter;
79
+ }
80
+ /**
81
+ * A metric that supports recording values on a histogram.
82
+ *
83
+ * @experimental The Metric API is an experimental feature and may be subject to change.
84
+ */
85
+ export interface MetricHistogram extends Metric {
86
+ /**
87
+ * The type of value to record. Either `int` or `float`.
88
+ */
89
+ valueType: NumericMetricValueType;
90
+ /**
91
+ * Record the given value on the histogram.
92
+ *
93
+ * @param value Value to record. Must be a non-negative number. Value will be casted to the given
94
+ * {@link valueType}. Loss of precision may occur if the value is not already of the
95
+ * correct type.
96
+ * @param extraTags Extra tags if any.
97
+ */
98
+ record(value: number, extraTags?: MetricTags): void;
99
+ /**
100
+ * Return a clone of this histogram, with additional tags.
101
+ *
102
+ * @param tags Tags to append to existing tags.
103
+ */
104
+ withTags(tags: MetricTags): MetricHistogram;
105
+ }
106
+ /**
107
+ * A metric that supports setting values.
108
+ *
109
+ * @experimental The Metric API is an experimental feature and may be subject to change.
110
+ */
111
+ export interface MetricGauge extends Metric {
112
+ /**
113
+ * The type of value to set. Either `int` or `float`.
114
+ */
115
+ valueType: NumericMetricValueType;
116
+ /**
117
+ * Set the given value on the gauge.
118
+ *
119
+ * @param value Value to set.
120
+ * @param extraTags Extra tags if any.
121
+ */
122
+ set(value: number, extraTags?: MetricTags): void;
123
+ /**
124
+ * Return a clone of this gauge, with additional tags.
125
+ *
126
+ * @param tags Tags to append to existing tags.
127
+ */
128
+ withTags(tags: MetricTags): MetricGauge;
129
+ }
130
+ /**
131
+ * Tags to be attached to some metrics.
132
+ *
133
+ * @experimental The Metric API is an experimental feature and may be subject to change.
134
+ */
135
+ export type MetricTags = Record<string, string | number | boolean>;
136
+ export type NumericMetricValueType = 'int' | 'float';
137
+ /**
138
+ * A meter implementation that does nothing.
139
+ */
140
+ declare class NoopMetricMeter implements MetricMeter {
141
+ createCounter(name: string, unit?: string, description?: string): MetricCounter;
142
+ createHistogram(name: string, valueType?: NumericMetricValueType, unit?: string, description?: string): MetricHistogram;
143
+ createGauge(name: string, valueType?: NumericMetricValueType, unit?: string, description?: string): MetricGauge;
144
+ withTags(_extraTags: MetricTags): MetricMeter;
145
+ }
146
+ export declare const noopMetricMeter: NoopMetricMeter;
147
+ export type MetricTagsOrFunc = MetricTags | (() => MetricTags);
148
+ /**
149
+ * A meter implementation that adds tags before delegating calls to a parent meter.
150
+ *
151
+ * @experimental The Metric API is an experimental feature and may be subject to change.
152
+ * @internal
153
+ * @hidden
154
+ */
155
+ export declare class MetricMeterWithComposedTags implements MetricMeter {
156
+ private readonly parentMeter;
157
+ private readonly contributors;
158
+ /**
159
+ * Return a {@link MetricMeter} that adds tags before delegating calls to a parent meter.
160
+ *
161
+ * New tags may either be specified statically as a delta object, or as a function evaluated
162
+ * every time a metric is recorded that will return a delta object.
163
+ *
164
+ * Some optimizations are performed to avoid creating unnecessary objects and to keep runtime
165
+ * overhead associated with resolving tags as low as possible.
166
+ *
167
+ * @param meter The parent meter to delegate calls to.
168
+ * @param tagsOrFunc New tags may either be specified statically as a delta object, or as a function
169
+ * evaluated every time a metric is recorded that will return a delta object.
170
+ * @param force if `true`, then a `MetricMeterWithComposedTags` will be created even if there
171
+ * is no tags to add. This is useful to add tags support to an underlying meter
172
+ * implementation that does not support tags directly.
173
+ */
174
+ static compose(meter: MetricMeter, tagsOrFunc: MetricTagsOrFunc, force?: boolean): MetricMeter;
175
+ private constructor();
176
+ createCounter(name: string, unit?: string, description?: string): MetricCounter;
177
+ createHistogram(name: string, valueType?: NumericMetricValueType, unit?: string, description?: string): MetricHistogram;
178
+ createGauge(name: string, valueType?: NumericMetricValueType, unit?: string, description?: string): MetricGauge;
179
+ withTags(tags: MetricTags): MetricMeter;
180
+ }
181
+ export {};
package/lib/metrics.js ADDED
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetricMeterWithComposedTags = exports.noopMetricMeter = void 0;
4
+ const internal_workflow_1 = require("./internal-workflow");
5
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
6
+ /**
7
+ * A meter implementation that does nothing.
8
+ */
9
+ class NoopMetricMeter {
10
+ createCounter(name, unit, description) {
11
+ return {
12
+ name,
13
+ unit,
14
+ description,
15
+ add(_value, _extraTags) { },
16
+ withTags(_extraTags) {
17
+ return this;
18
+ },
19
+ };
20
+ }
21
+ createHistogram(name, valueType = 'int', unit, description) {
22
+ return {
23
+ name,
24
+ valueType,
25
+ unit,
26
+ description,
27
+ record(_value, _extraTags) { },
28
+ withTags(_extraTags) {
29
+ return this;
30
+ },
31
+ };
32
+ }
33
+ createGauge(name, valueType, unit, description) {
34
+ return {
35
+ name,
36
+ valueType: valueType ?? 'int',
37
+ unit,
38
+ description,
39
+ set(_value, _extraTags) { },
40
+ withTags(_extraTags) {
41
+ return this;
42
+ },
43
+ };
44
+ }
45
+ withTags(_extraTags) {
46
+ return this;
47
+ }
48
+ }
49
+ exports.noopMetricMeter = new NoopMetricMeter();
50
+ /**
51
+ * A meter implementation that adds tags before delegating calls to a parent meter.
52
+ *
53
+ * @experimental The Metric API is an experimental feature and may be subject to change.
54
+ * @internal
55
+ * @hidden
56
+ */
57
+ class MetricMeterWithComposedTags {
58
+ parentMeter;
59
+ contributors;
60
+ /**
61
+ * Return a {@link MetricMeter} that adds tags before delegating calls to a parent meter.
62
+ *
63
+ * New tags may either be specified statically as a delta object, or as a function evaluated
64
+ * every time a metric is recorded that will return a delta object.
65
+ *
66
+ * Some optimizations are performed to avoid creating unnecessary objects and to keep runtime
67
+ * overhead associated with resolving tags as low as possible.
68
+ *
69
+ * @param meter The parent meter to delegate calls to.
70
+ * @param tagsOrFunc New tags may either be specified statically as a delta object, or as a function
71
+ * evaluated every time a metric is recorded that will return a delta object.
72
+ * @param force if `true`, then a `MetricMeterWithComposedTags` will be created even if there
73
+ * is no tags to add. This is useful to add tags support to an underlying meter
74
+ * implementation that does not support tags directly.
75
+ */
76
+ static compose(meter, tagsOrFunc, force = false) {
77
+ if (meter instanceof MetricMeterWithComposedTags) {
78
+ const contributors = appendToChain(meter.contributors, tagsOrFunc);
79
+ // If the new contributor results in no actual change to the chain, then we don't need a new meter
80
+ if (contributors === undefined && !force)
81
+ return meter;
82
+ return new MetricMeterWithComposedTags(meter.parentMeter, contributors ?? []);
83
+ }
84
+ else {
85
+ const contributors = appendToChain(undefined, tagsOrFunc);
86
+ if (contributors === undefined && !force)
87
+ return meter;
88
+ return new MetricMeterWithComposedTags(meter, contributors ?? []);
89
+ }
90
+ }
91
+ constructor(parentMeter, contributors) {
92
+ this.parentMeter = parentMeter;
93
+ this.contributors = contributors;
94
+ }
95
+ createCounter(name, unit, description) {
96
+ const parentCounter = this.parentMeter.createCounter(name, unit, description);
97
+ return new MetricCounterWithComposedTags(parentCounter, this.contributors);
98
+ }
99
+ createHistogram(name, valueType = 'int', unit, description) {
100
+ const parentHistogram = this.parentMeter.createHistogram(name, valueType, unit, description);
101
+ return new MetricHistogramWithComposedTags(parentHistogram, this.contributors);
102
+ }
103
+ createGauge(name, valueType = 'int', unit, description) {
104
+ const parentGauge = this.parentMeter.createGauge(name, valueType, unit, description);
105
+ return new MetricGaugeWithComposedTags(parentGauge, this.contributors);
106
+ }
107
+ withTags(tags) {
108
+ return MetricMeterWithComposedTags.compose(this, tags);
109
+ }
110
+ }
111
+ exports.MetricMeterWithComposedTags = MetricMeterWithComposedTags;
112
+ /**
113
+ * @experimental The Metric API is an experimental feature and may be subject to change.
114
+ */
115
+ class MetricCounterWithComposedTags {
116
+ parentCounter;
117
+ contributors;
118
+ constructor(parentCounter, contributors) {
119
+ this.parentCounter = parentCounter;
120
+ this.contributors = contributors;
121
+ }
122
+ add(value, extraTags) {
123
+ this.parentCounter.add(value, resolveTags(this.contributors, extraTags));
124
+ }
125
+ withTags(extraTags) {
126
+ const contributors = appendToChain(this.contributors, extraTags);
127
+ if (contributors === undefined)
128
+ return this;
129
+ return new MetricCounterWithComposedTags(this.parentCounter, contributors);
130
+ }
131
+ get name() {
132
+ return this.parentCounter.name;
133
+ }
134
+ get unit() {
135
+ return this.parentCounter.unit;
136
+ }
137
+ get description() {
138
+ return this.parentCounter.description;
139
+ }
140
+ }
141
+ /**
142
+ * @experimental The Metric API is an experimental feature and may be subject to change.
143
+ */
144
+ class MetricHistogramWithComposedTags {
145
+ parentHistogram;
146
+ contributors;
147
+ constructor(parentHistogram, contributors) {
148
+ this.parentHistogram = parentHistogram;
149
+ this.contributors = contributors;
150
+ }
151
+ record(value, extraTags) {
152
+ this.parentHistogram.record(value, resolveTags(this.contributors, extraTags));
153
+ }
154
+ withTags(extraTags) {
155
+ const contributors = appendToChain(this.contributors, extraTags);
156
+ if (contributors === undefined)
157
+ return this;
158
+ return new MetricHistogramWithComposedTags(this.parentHistogram, contributors);
159
+ }
160
+ get name() {
161
+ return this.parentHistogram.name;
162
+ }
163
+ get valueType() {
164
+ return this.parentHistogram.valueType;
165
+ }
166
+ get unit() {
167
+ return this.parentHistogram.unit;
168
+ }
169
+ get description() {
170
+ return this.parentHistogram.description;
171
+ }
172
+ }
173
+ /**
174
+ * @internal
175
+ * @hidden
176
+ */
177
+ class MetricGaugeWithComposedTags {
178
+ parentGauge;
179
+ contributors;
180
+ constructor(parentGauge, contributors) {
181
+ this.parentGauge = parentGauge;
182
+ this.contributors = contributors;
183
+ }
184
+ set(value, extraTags) {
185
+ this.parentGauge.set(value, resolveTags(this.contributors, extraTags));
186
+ }
187
+ withTags(extraTags) {
188
+ const contributors = appendToChain(this.contributors, extraTags);
189
+ if (contributors === undefined)
190
+ return this;
191
+ return new MetricGaugeWithComposedTags(this.parentGauge, contributors);
192
+ }
193
+ get name() {
194
+ return this.parentGauge.name;
195
+ }
196
+ get valueType() {
197
+ return this.parentGauge.valueType;
198
+ }
199
+ get unit() {
200
+ return this.parentGauge.unit;
201
+ }
202
+ get description() {
203
+ return this.parentGauge.description;
204
+ }
205
+ }
206
+ function resolveTags(contributors, extraTags) {
207
+ const resolved = {};
208
+ for (const contributor of contributors) {
209
+ Object.assign(resolved, typeof contributor === 'function' ? contributor() : contributor);
210
+ }
211
+ Object.assign(resolved, extraTags);
212
+ return (0, internal_workflow_1.filterNullAndUndefined)(resolved);
213
+ }
214
+ /**
215
+ * Append a tags contributor to the chain, merging it with the former last contributor if possible.
216
+ *
217
+ * If appending the new contributor results in no actual change to the chain of contributors, return
218
+ * `existingContributors`; in that case, the caller should avoid creating a new object if possible.
219
+ */
220
+ function appendToChain(existingContributors, newContributor) {
221
+ // If the new contributor is an empty object, then it results in no actual change to the chain
222
+ if (typeof newContributor === 'object' && Object.keys(newContributor).length === 0) {
223
+ return existingContributors;
224
+ }
225
+ // If existing chain is empty, then the new contributor is the chain
226
+ if (existingContributors == null || existingContributors.length === 0) {
227
+ return [newContributor];
228
+ }
229
+ // If both last contributor and new contributor are plain objects, merge them to a single object.
230
+ const last = existingContributors[existingContributors.length - 1];
231
+ if (typeof last === 'object' && typeof newContributor === 'object') {
232
+ const merged = (0, internal_workflow_1.mergeObjects)(last, newContributor);
233
+ if (merged === last)
234
+ return existingContributors;
235
+ return [...existingContributors.slice(0, -1), merged];
236
+ }
237
+ // Otherwise, just append the new contributor to the chain.
238
+ return [...existingContributors, newContributor];
239
+ }
240
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":";;;AAAA,2DAA2E;AAgK3E,oGAAoG;AAEpG;;GAEG;AACH,MAAM,eAAe;IACnB,aAAa,CAAC,IAAY,EAAE,IAAa,EAAE,W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KAAK,IAAI;YAAE,OAAO,oBAAoB,CAAC;QACjD,OAAO,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAO,CAAC,CAAC;IACzD,CAAC;IAED,2DAA2D;IAC3D,OAAO,CAAC,GAAG,oBAAoB,EAAE,cAAc,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { temporal } from '@temporalio/proto';
2
+ /**
3
+ * Priority contains metadata that controls relative ordering of task processing when tasks are
4
+ * backlogged in a queue. Initially, Priority will be used in activity and workflow task queues,
5
+ * which are typically where backlogs exist.
6
+ * Priority is (for now) attached to workflows and activities. Activities and child workflows
7
+ * inherit Priority from the workflow that created them, but may override fields when they are
8
+ * started or modified. For each field of a Priority on an activity/workflow, not present or equal
9
+ * to zero/empty string means to inherit the value from the calling workflow, or if there is no
10
+ * calling workflow, then use the default (documented on the field).
11
+ * The overall semantics of Priority are:
12
+ * 1. First, consider "priority_key": lower number goes first.
13
+ * (more will be added here later)
14
+ */
15
+ export interface Priority {
16
+ /**
17
+ * Priority key is a positive integer from 1 to n, where smaller integers
18
+ * correspond to higher priorities (tasks run sooner). In general, tasks in
19
+ * a queue should be processed in close to priority order, although small
20
+ * deviations are possible.
21
+ *
22
+ * The maximum priority value (minimum priority) is determined by server configuration, and
23
+ * defaults to 5.
24
+ *
25
+ * The default priority is (min+max)/2. With the default max of 5 and min of 1, that comes out to 3.
26
+ */
27
+ priorityKey?: number;
28
+ }
29
+ /**
30
+ * Turn a proto compatible Priority into a TS Priority
31
+ */
32
+ export declare function decodePriority(priority?: temporal.api.common.v1.IPriority | null): Priority;
33
+ /**
34
+ * Turn a TS Priority into a proto compatible Priority
35
+ */
36
+ export declare function compilePriority(priority: Priority): temporal.api.common.v1.IPriority;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodePriority = decodePriority;
4
+ exports.compilePriority = compilePriority;
5
+ /**
6
+ * Turn a proto compatible Priority into a TS Priority
7
+ */
8
+ function decodePriority(priority) {
9
+ return { priorityKey: priority?.priorityKey ?? undefined };
10
+ }
11
+ /**
12
+ * Turn a TS Priority into a proto compatible Priority
13
+ */
14
+ function compilePriority(priority) {
15
+ if (priority.priorityKey !== undefined && priority.priorityKey !== null) {
16
+ if (!Number.isInteger(priority.priorityKey)) {
17
+ throw new TypeError('priorityKey must be an integer');
18
+ }
19
+ if (priority.priorityKey < 0) {
20
+ throw new RangeError('priorityKey must be a positive integer');
21
+ }
22
+ }
23
+ return {
24
+ priorityKey: priority.priorityKey ?? 0,
25
+ };
26
+ }
27
+ //# sourceMappingURL=priority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority.js","sourceRoot":"","sources":["../src/priority.ts"],"names":[],"mappings":";;AAiCA,wCAEC;AAKD,0CAaC;AAvBD;;GAEG;AACH,SAAgB,cAAc,CAAC,QAAkD;IAC/E,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,IAAI,SAAS,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,QAAkB;IAChD,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS,IAAI,QAAQ,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,QAAQ,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,CAAC;KACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,77 @@
1
+ import type { temporal } from '@temporalio/proto';
2
+ /** @deprecated: Use {@link TypedSearchAttributes} instead */
3
+ export type SearchAttributeValueOrReadonly = SearchAttributeValue | Readonly<SearchAttributeValue> | undefined;
4
+ /** @deprecated: Use {@link TypedSearchAttributes} instead */
5
+ export type SearchAttributes = Record<string, SearchAttributeValueOrReadonly>;
6
+ /** @deprecated: Use {@link TypedSearchAttributes} instead */
7
+ export type SearchAttributeValue = string[] | number[] | boolean[] | Date[];
8
+ export declare const SearchAttributeType: {
9
+ readonly TEXT: "TEXT";
10
+ readonly KEYWORD: "KEYWORD";
11
+ readonly INT: "INT";
12
+ readonly DOUBLE: "DOUBLE";
13
+ readonly BOOL: "BOOL";
14
+ readonly DATETIME: "DATETIME";
15
+ readonly KEYWORD_LIST: "KEYWORD_LIST";
16
+ };
17
+ export type SearchAttributeType = (typeof SearchAttributeType)[keyof typeof SearchAttributeType];
18
+ export declare const encodeSearchAttributeIndexedValueType: (input: "TEXT" | "KEYWORD" | "INT" | "DOUBLE" | "BOOL" | "DATETIME" | "KEYWORD_LIST" | temporal.api.enums.v1.IndexedValueType | "INDEXED_VALUE_TYPE_TEXT" | "INDEXED_VALUE_TYPE_KEYWORD" | "INDEXED_VALUE_TYPE_INT" | "INDEXED_VALUE_TYPE_DOUBLE" | "INDEXED_VALUE_TYPE_BOOL" | "INDEXED_VALUE_TYPE_DATETIME" | "INDEXED_VALUE_TYPE_KEYWORD_LIST" | null | undefined) => temporal.api.enums.v1.IndexedValueType | undefined, _: (input: temporal.api.enums.v1.IndexedValueType | null | undefined) => "TEXT" | "KEYWORD" | "INT" | "DOUBLE" | "BOOL" | "DATETIME" | "KEYWORD_LIST" | undefined;
19
+ interface IndexedValueTypeMapping {
20
+ TEXT: string;
21
+ KEYWORD: string;
22
+ INT: number;
23
+ DOUBLE: number;
24
+ BOOL: boolean;
25
+ DATETIME: Date;
26
+ KEYWORD_LIST: string[];
27
+ }
28
+ export declare function isValidValueForType<T extends SearchAttributeType>(type: T, value: unknown): value is IndexedValueTypeMapping[T];
29
+ export interface SearchAttributeKey<T extends SearchAttributeType> {
30
+ name: string;
31
+ type: T;
32
+ }
33
+ export declare function defineSearchAttributeKey<T extends SearchAttributeType>(name: string, type: T): SearchAttributeKey<T>;
34
+ declare class BaseSearchAttributeValue<T extends SearchAttributeType, V = IndexedValueTypeMapping[T]> {
35
+ private readonly _type;
36
+ private readonly _value;
37
+ constructor(type: T, value: V);
38
+ get type(): T;
39
+ get value(): V;
40
+ }
41
+ export declare class TypedSearchAttributeValue<T extends SearchAttributeType> extends BaseSearchAttributeValue<T> {
42
+ }
43
+ export declare class TypedSearchAttributeUpdateValue<T extends SearchAttributeType> extends BaseSearchAttributeValue<T, IndexedValueTypeMapping[T] | null> {
44
+ }
45
+ export type SearchAttributePair = {
46
+ [T in SearchAttributeType]: {
47
+ key: SearchAttributeKey<T>;
48
+ value: IndexedValueTypeMapping[T];
49
+ };
50
+ }[SearchAttributeType];
51
+ export type SearchAttributeUpdatePair = {
52
+ [T in SearchAttributeType]: {
53
+ key: SearchAttributeKey<T>;
54
+ value: IndexedValueTypeMapping[T] | null;
55
+ };
56
+ }[SearchAttributeType];
57
+ export declare class TypedSearchAttributes {
58
+ private searchAttributes;
59
+ constructor(initialAttributes?: SearchAttributePair[]);
60
+ get<T extends SearchAttributeType>(key: SearchAttributeKey<T>): IndexedValueTypeMapping[T] | undefined;
61
+ /** Returns a deep copy of the given TypedSearchAttributes instance */
62
+ copy(): TypedSearchAttributes;
63
+ /**
64
+ * @hidden
65
+ * Return JSON representation of this class as SearchAttributePair[]
66
+ * Default toJSON method is not used because it's JSON representation includes private state.
67
+ */
68
+ toJSON(): SearchAttributePair[];
69
+ /** Returns a copy of the current TypedSearchAttributes instance with the updated attributes. */
70
+ updateCopy(updates: SearchAttributeUpdatePair[]): TypedSearchAttributes;
71
+ private update;
72
+ getAll(): SearchAttributePair[];
73
+ static getKeyFromUntyped(key: string, value: SearchAttributeValueOrReadonly): SearchAttributeKey<SearchAttributeType> | undefined;
74
+ static toMetadataType(type: SearchAttributeType): string;
75
+ static toSearchAttributeType(type: string): SearchAttributeType | undefined;
76
+ }
77
+ export {};