@globalart/nestjs-temporal 1.1.5 → 1.2.1

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/dist/index.mjs CHANGED
@@ -1,30 +1,26 @@
1
- import { ConfigurableModuleBuilder, Inject, Injectable, Logger, Module, SetMetadata } from "@nestjs/common";
1
+ import { ConfigurableModuleBuilder, Inject, Injectable, Logger, Module, SetMetadata, createParamDecorator } from "@nestjs/common";
2
2
  import { DiscoveryModule, DiscoveryService, ExternalContextCreator, MetadataScanner, Reflector } from "@nestjs/core";
3
3
  import { isObservable, lastValueFrom } from "rxjs";
4
4
  import { NativeConnection, Runtime, Worker } from "@temporalio/worker";
5
- import { Context as Context$1 } from "@temporalio/activity";
5
+ import { Context } from "@temporalio/activity";
6
6
  import { WorkflowClient } from "@temporalio/client";
7
7
  import { SCOPE_OPTIONS_METADATA } from "@nestjs/common/constants";
8
8
 
9
- //#region rolldown:runtime
10
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
-
12
- //#endregion
13
- //#region src/temporal.constants.ts
9
+ //#region src/constants/temporal.constants.ts
14
10
  const TEMPORAL_MODULE_ACTIVITIES = "_temporal_module_activities";
15
11
  const TEMPORAL_MODULE_ACTIVITY = "_temporal_module_activity";
16
12
  const TEMPORAL_MODULE_WORKFLOW = "_temporal_module_workFlow";
17
13
  const TEMPORAL_MODULE_WORKFLOW_METHOD = "_temporal_module_workflow_method";
18
- const TEMPORAL_ARGS_METADATA = "temporal:args";
14
+ const TEMPORAL_ARGS_METADATA = "_temporal_module_args";
19
15
 
20
16
  //#endregion
21
- //#region \0@oxc-project+runtime@0.107.0/helpers/decorateMetadata.js
17
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateMetadata.js
22
18
  function __decorateMetadata(k, v) {
23
19
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
24
20
  }
25
21
 
26
22
  //#endregion
27
- //#region \0@oxc-project+runtime@0.107.0/helpers/decorate.js
23
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorate.js
28
24
  function __decorate(decorators, target, key, desc) {
29
25
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
30
26
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -35,7 +31,7 @@ function __decorate(decorators, target, key, desc) {
35
31
  //#endregion
36
32
  //#region src/temporal-metadata.accessors.ts
37
33
  var _ref$1;
38
- let TemporalMetadataAccessor = class TemporalMetadataAccessor$1 {
34
+ let TemporalMetadataAccessor = class TemporalMetadataAccessor {
39
35
  constructor(reflector) {
40
36
  this.reflector = reflector;
41
37
  }
@@ -76,14 +72,14 @@ const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN: TEMPORAL_MODULE_OPTIONS_T
76
72
 
77
73
  //#endregion
78
74
  //#region src/temporal-enums.ts
79
- let TemporalParamType = /* @__PURE__ */ function(TemporalParamType$1) {
80
- TemporalParamType$1[TemporalParamType$1["PAYLOAD"] = 3] = "PAYLOAD";
81
- TemporalParamType$1[TemporalParamType$1["CONTEXT"] = 4] = "CONTEXT";
82
- return TemporalParamType$1;
75
+ let TemporalParamType = /* @__PURE__ */ function(TemporalParamType) {
76
+ TemporalParamType[TemporalParamType["PAYLOAD"] = 3] = "PAYLOAD";
77
+ TemporalParamType[TemporalParamType["CONTEXT"] = 4] = "CONTEXT";
78
+ return TemporalParamType;
83
79
  }({});
84
80
 
85
81
  //#endregion
86
- //#region src/temporal-execution-context.ts
82
+ //#region src/core/temporal-execution-context.ts
87
83
  var TemporalExecutionContext = class {
88
84
  constructor(instance, handler, args) {
89
85
  this.instance = instance;
@@ -138,11 +134,11 @@ var TemporalParamsFactory = class {
138
134
  //#endregion
139
135
  //#region src/temporal.explorer.ts
140
136
  var _ref, _ref2, _ref3, _ref4, _TemporalExplorer;
141
- let TemporalExplorer = _TemporalExplorer = class TemporalExplorer$1 {
137
+ let TemporalExplorer = _TemporalExplorer = class TemporalExplorer {
142
138
  options;
143
139
  logger = new Logger(_TemporalExplorer.name);
144
- worker;
145
- workerRunPromise;
140
+ workers;
141
+ workerRunPromises;
146
142
  constructor(discoveryService, metadataAccessor, metadataScanner, externalContextCreator) {
147
143
  this.discoveryService = discoveryService;
148
144
  this.metadataAccessor = metadataAccessor;
@@ -159,19 +155,19 @@ let TemporalExplorer = _TemporalExplorer = class TemporalExplorer$1 {
159
155
  * Shuts down the Temporal worker when the module is destroyed.
160
156
  */
161
157
  async onModuleDestroy() {
162
- if (!this.worker) return;
158
+ if (!this.workers) return;
163
159
  try {
164
- this.worker.shutdown();
165
- if (this.workerRunPromise) await this.workerRunPromise;
160
+ this.workers.forEach((worker) => worker.shutdown());
161
+ if (this.workerRunPromises) await Promise.all(this.workers.map((worker) => worker.run()));
166
162
  } catch (err) {
167
- this.logger.warn("Temporal worker was not cleanly shutdown.", { err: err instanceof Error ? err.message : String(err) });
163
+ this.logger.warn("Temporal workers were not cleanly shutdown.", { err: err instanceof Error ? err.message : String(err) });
168
164
  }
169
165
  }
170
166
  /**
171
167
  * Starts the Temporal worker when the application is fully bootstrapped.
172
168
  */
173
169
  onApplicationBootstrap() {
174
- if (this.worker) this.workerRunPromise = this.worker.run();
170
+ if (this.workers) this.workerRunPromises = this.workers.map((worker) => worker.run());
175
171
  }
176
172
  /**
177
173
  * Explores the application for Temporal activities and creates the worker.
@@ -181,7 +177,7 @@ let TemporalExplorer = _TemporalExplorer = class TemporalExplorer$1 {
181
177
  const workerConfig = this.getWorkerConfigOptions();
182
178
  const runTimeOptions = this.getRuntimeOptions();
183
179
  const connectionOptions = this.getNativeConnectionOptions();
184
- if (!workerConfig.taskQueue) {
180
+ if (workerConfig.some((workerConfig) => !workerConfig.taskQueue)) {
185
181
  this.logger.warn("Temporal worker configuration missing taskQueue. Worker will not be created.");
186
182
  return;
187
183
  }
@@ -197,10 +193,12 @@ let TemporalExplorer = _TemporalExplorer = class TemporalExplorer$1 {
197
193
  workerOptions.connection = await NativeConnection.connect(connectionOptions);
198
194
  }
199
195
  this.logger.verbose("Creating a new Worker");
200
- this.worker = await Worker.create({
201
- ...workerConfig,
202
- ...workerOptions
203
- });
196
+ this.workers = await Promise.all(workerConfig.map(async (workerConfig) => {
197
+ return Worker.create({
198
+ ...workerConfig,
199
+ ...workerOptions
200
+ });
201
+ }));
204
202
  }
205
203
  /**
206
204
  * Gets the worker configuration options.
@@ -266,9 +264,8 @@ let TemporalExplorer = _TemporalExplorer = class TemporalExplorer$1 {
266
264
  if (isRequestScoped) this.logger.warn(`Request-scoped activities are not yet fully supported. Activity "${key}" from class "${instance.constructor.name}" may not work correctly.`);
267
265
  const paramsFactory = new TemporalParamsFactory(instance, instance[key]);
268
266
  const handler = this.externalContextCreator.create(instance, instance[key], key, TEMPORAL_ARGS_METADATA, paramsFactory, void 0, void 0, void 0, "temporal");
269
- Reflect.defineMetadata(TEMPORAL_ARGS_METADATA, paramsFactory, instance[key]);
270
267
  activitiesMethod[key] = async (...args) => {
271
- const result = handler(...args, Context$1.current().info);
268
+ const result = handler(...args, Context.current().info);
272
269
  return isObservable(result) ? await lastValueFrom(result) : await result;
273
270
  };
274
271
  }
@@ -358,7 +355,7 @@ function createClientAsyncProvider(asyncOptions) {
358
355
  //#endregion
359
356
  //#region src/temporal.module.ts
360
357
  var _TemporalModule;
361
- let TemporalModule = _TemporalModule = class TemporalModule$1 extends ConfigurableModuleClass {
358
+ let TemporalModule = _TemporalModule = class TemporalModule extends ConfigurableModuleClass {
362
359
  /**
363
360
  * Registers a Temporal worker asynchronously.
364
361
  * Useful when configuration depends on other async providers (e.g., ConfigService).
@@ -443,1259 +440,12 @@ function Workflows(nameOrOptions) {
443
440
  };
444
441
  }
445
442
 
446
- //#endregion
447
- //#region ../../node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js
448
- var require_Reflect = /* @__PURE__ */ __commonJSMin((() => {
449
- /*! *****************************************************************************
450
- Copyright (C) Microsoft. All rights reserved.
451
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
452
- this file except in compliance with the License. You may obtain a copy of the
453
- License at http://www.apache.org/licenses/LICENSE-2.0
454
-
455
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
456
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
457
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
458
- MERCHANTABLITY OR NON-INFRINGEMENT.
459
-
460
- See the Apache Version 2.0 License for specific language governing permissions
461
- and limitations under the License.
462
- ***************************************************************************** */
463
- var Reflect;
464
- (function(Reflect$1) {
465
- (function(factory) {
466
- var root = typeof globalThis === "object" ? globalThis : typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
467
- var exporter = makeExporter(Reflect$1);
468
- if (typeof root.Reflect !== "undefined") exporter = makeExporter(root.Reflect, exporter);
469
- factory(exporter, root);
470
- if (typeof root.Reflect === "undefined") root.Reflect = Reflect$1;
471
- function makeExporter(target, previous) {
472
- return function(key, value) {
473
- Object.defineProperty(target, key, {
474
- configurable: true,
475
- writable: true,
476
- value
477
- });
478
- if (previous) previous(key, value);
479
- };
480
- }
481
- function functionThis() {
482
- try {
483
- return Function("return this;")();
484
- } catch (_) {}
485
- }
486
- function indirectEvalThis() {
487
- try {
488
- return (0, eval)("(function() { return this; })()");
489
- } catch (_) {}
490
- }
491
- function sloppyModeThis() {
492
- return functionThis() || indirectEvalThis();
493
- }
494
- })(function(exporter, root) {
495
- var hasOwn = Object.prototype.hasOwnProperty;
496
- var supportsSymbol = typeof Symbol === "function";
497
- var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
498
- var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
499
- var supportsCreate = typeof Object.create === "function";
500
- var supportsProto = { __proto__: [] } instanceof Array;
501
- var downLevel = !supportsCreate && !supportsProto;
502
- var HashMap = {
503
- create: supportsCreate ? function() {
504
- return MakeDictionary(Object.create(null));
505
- } : supportsProto ? function() {
506
- return MakeDictionary({ __proto__: null });
507
- } : function() {
508
- return MakeDictionary({});
509
- },
510
- has: downLevel ? function(map, key) {
511
- return hasOwn.call(map, key);
512
- } : function(map, key) {
513
- return key in map;
514
- },
515
- get: downLevel ? function(map, key) {
516
- return hasOwn.call(map, key) ? map[key] : void 0;
517
- } : function(map, key) {
518
- return map[key];
519
- }
520
- };
521
- var functionPrototype = Object.getPrototypeOf(Function);
522
- var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
523
- var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
524
- var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
525
- var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : void 0;
526
- var metadataRegistry = GetOrCreateMetadataRegistry();
527
- var metadataProvider = CreateMetadataProvider(metadataRegistry);
528
- /**
529
- * Applies a set of decorators to a property of a target object.
530
- * @param decorators An array of decorators.
531
- * @param target The target object.
532
- * @param propertyKey (Optional) The property key to decorate.
533
- * @param attributes (Optional) The property descriptor for the target key.
534
- * @remarks Decorators are applied in reverse order.
535
- * @example
536
- *
537
- * class Example {
538
- * // property declarations are not part of ES6, though they are valid in TypeScript:
539
- * // static staticProperty;
540
- * // property;
541
- *
542
- * constructor(p) { }
543
- * static staticMethod(p) { }
544
- * method(p) { }
545
- * }
546
- *
547
- * // constructor
548
- * Example = Reflect.decorate(decoratorsArray, Example);
549
- *
550
- * // property (on constructor)
551
- * Reflect.decorate(decoratorsArray, Example, "staticProperty");
552
- *
553
- * // property (on prototype)
554
- * Reflect.decorate(decoratorsArray, Example.prototype, "property");
555
- *
556
- * // method (on constructor)
557
- * Object.defineProperty(Example, "staticMethod",
558
- * Reflect.decorate(decoratorsArray, Example, "staticMethod",
559
- * Object.getOwnPropertyDescriptor(Example, "staticMethod")));
560
- *
561
- * // method (on prototype)
562
- * Object.defineProperty(Example.prototype, "method",
563
- * Reflect.decorate(decoratorsArray, Example.prototype, "method",
564
- * Object.getOwnPropertyDescriptor(Example.prototype, "method")));
565
- *
566
- */
567
- function decorate(decorators, target, propertyKey, attributes) {
568
- if (!IsUndefined(propertyKey)) {
569
- if (!IsArray(decorators)) throw new TypeError();
570
- if (!IsObject(target)) throw new TypeError();
571
- if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes)) throw new TypeError();
572
- if (IsNull(attributes)) attributes = void 0;
573
- propertyKey = ToPropertyKey(propertyKey);
574
- return DecorateProperty(decorators, target, propertyKey, attributes);
575
- } else {
576
- if (!IsArray(decorators)) throw new TypeError();
577
- if (!IsConstructor(target)) throw new TypeError();
578
- return DecorateConstructor(decorators, target);
579
- }
580
- }
581
- exporter("decorate", decorate);
582
- /**
583
- * A default metadata decorator factory that can be used on a class, class member, or parameter.
584
- * @param metadataKey The key for the metadata entry.
585
- * @param metadataValue The value for the metadata entry.
586
- * @returns A decorator function.
587
- * @remarks
588
- * If `metadataKey` is already defined for the target and target key, the
589
- * metadataValue for that key will be overwritten.
590
- * @example
591
- *
592
- * // constructor
593
- * @Reflect.metadata(key, value)
594
- * class Example {
595
- * }
596
- *
597
- * // property (on constructor, TypeScript only)
598
- * class Example {
599
- * @Reflect.metadata(key, value)
600
- * static staticProperty;
601
- * }
602
- *
603
- * // property (on prototype, TypeScript only)
604
- * class Example {
605
- * @Reflect.metadata(key, value)
606
- * property;
607
- * }
608
- *
609
- * // method (on constructor)
610
- * class Example {
611
- * @Reflect.metadata(key, value)
612
- * static staticMethod() { }
613
- * }
614
- *
615
- * // method (on prototype)
616
- * class Example {
617
- * @Reflect.metadata(key, value)
618
- * method() { }
619
- * }
620
- *
621
- */
622
- function metadata(metadataKey, metadataValue) {
623
- function decorator(target, propertyKey) {
624
- if (!IsObject(target)) throw new TypeError();
625
- if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey)) throw new TypeError();
626
- OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
627
- }
628
- return decorator;
629
- }
630
- exporter("metadata", metadata);
631
- /**
632
- * Define a unique metadata entry on the target.
633
- * @param metadataKey A key used to store and retrieve metadata.
634
- * @param metadataValue A value that contains attached metadata.
635
- * @param target The target object on which to define metadata.
636
- * @param propertyKey (Optional) The property key for the target.
637
- * @example
638
- *
639
- * class Example {
640
- * // property declarations are not part of ES6, though they are valid in TypeScript:
641
- * // static staticProperty;
642
- * // property;
643
- *
644
- * constructor(p) { }
645
- * static staticMethod(p) { }
646
- * method(p) { }
647
- * }
648
- *
649
- * // constructor
650
- * Reflect.defineMetadata("custom:annotation", options, Example);
651
- *
652
- * // property (on constructor)
653
- * Reflect.defineMetadata("custom:annotation", options, Example, "staticProperty");
654
- *
655
- * // property (on prototype)
656
- * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "property");
657
- *
658
- * // method (on constructor)
659
- * Reflect.defineMetadata("custom:annotation", options, Example, "staticMethod");
660
- *
661
- * // method (on prototype)
662
- * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "method");
663
- *
664
- * // decorator factory as metadata-producing annotation.
665
- * function MyAnnotation(options): Decorator {
666
- * return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
667
- * }
668
- *
669
- */
670
- function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
671
- if (!IsObject(target)) throw new TypeError();
672
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
673
- return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
674
- }
675
- exporter("defineMetadata", defineMetadata);
676
- /**
677
- * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
678
- * @param metadataKey A key used to store and retrieve metadata.
679
- * @param target The target object on which the metadata is defined.
680
- * @param propertyKey (Optional) The property key for the target.
681
- * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
682
- * @example
683
- *
684
- * class Example {
685
- * // property declarations are not part of ES6, though they are valid in TypeScript:
686
- * // static staticProperty;
687
- * // property;
688
- *
689
- * constructor(p) { }
690
- * static staticMethod(p) { }
691
- * method(p) { }
692
- * }
693
- *
694
- * // constructor
695
- * result = Reflect.hasMetadata("custom:annotation", Example);
696
- *
697
- * // property (on constructor)
698
- * result = Reflect.hasMetadata("custom:annotation", Example, "staticProperty");
699
- *
700
- * // property (on prototype)
701
- * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "property");
702
- *
703
- * // method (on constructor)
704
- * result = Reflect.hasMetadata("custom:annotation", Example, "staticMethod");
705
- *
706
- * // method (on prototype)
707
- * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "method");
708
- *
709
- */
710
- function hasMetadata(metadataKey, target, propertyKey) {
711
- if (!IsObject(target)) throw new TypeError();
712
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
713
- return OrdinaryHasMetadata(metadataKey, target, propertyKey);
714
- }
715
- exporter("hasMetadata", hasMetadata);
716
- /**
717
- * Gets a value indicating whether the target object has the provided metadata key defined.
718
- * @param metadataKey A key used to store and retrieve metadata.
719
- * @param target The target object on which the metadata is defined.
720
- * @param propertyKey (Optional) The property key for the target.
721
- * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
722
- * @example
723
- *
724
- * class Example {
725
- * // property declarations are not part of ES6, though they are valid in TypeScript:
726
- * // static staticProperty;
727
- * // property;
728
- *
729
- * constructor(p) { }
730
- * static staticMethod(p) { }
731
- * method(p) { }
732
- * }
733
- *
734
- * // constructor
735
- * result = Reflect.hasOwnMetadata("custom:annotation", Example);
736
- *
737
- * // property (on constructor)
738
- * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticProperty");
739
- *
740
- * // property (on prototype)
741
- * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "property");
742
- *
743
- * // method (on constructor)
744
- * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticMethod");
745
- *
746
- * // method (on prototype)
747
- * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "method");
748
- *
749
- */
750
- function hasOwnMetadata(metadataKey, target, propertyKey) {
751
- if (!IsObject(target)) throw new TypeError();
752
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
753
- return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
754
- }
755
- exporter("hasOwnMetadata", hasOwnMetadata);
756
- /**
757
- * Gets the metadata value for the provided metadata key on the target object or its prototype chain.
758
- * @param metadataKey A key used to store and retrieve metadata.
759
- * @param target The target object on which the metadata is defined.
760
- * @param propertyKey (Optional) The property key for the target.
761
- * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
762
- * @example
763
- *
764
- * class Example {
765
- * // property declarations are not part of ES6, though they are valid in TypeScript:
766
- * // static staticProperty;
767
- * // property;
768
- *
769
- * constructor(p) { }
770
- * static staticMethod(p) { }
771
- * method(p) { }
772
- * }
773
- *
774
- * // constructor
775
- * result = Reflect.getMetadata("custom:annotation", Example);
776
- *
777
- * // property (on constructor)
778
- * result = Reflect.getMetadata("custom:annotation", Example, "staticProperty");
779
- *
780
- * // property (on prototype)
781
- * result = Reflect.getMetadata("custom:annotation", Example.prototype, "property");
782
- *
783
- * // method (on constructor)
784
- * result = Reflect.getMetadata("custom:annotation", Example, "staticMethod");
785
- *
786
- * // method (on prototype)
787
- * result = Reflect.getMetadata("custom:annotation", Example.prototype, "method");
788
- *
789
- */
790
- function getMetadata(metadataKey, target, propertyKey) {
791
- if (!IsObject(target)) throw new TypeError();
792
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
793
- return OrdinaryGetMetadata(metadataKey, target, propertyKey);
794
- }
795
- exporter("getMetadata", getMetadata);
796
- /**
797
- * Gets the metadata value for the provided metadata key on the target object.
798
- * @param metadataKey A key used to store and retrieve metadata.
799
- * @param target The target object on which the metadata is defined.
800
- * @param propertyKey (Optional) The property key for the target.
801
- * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
802
- * @example
803
- *
804
- * class Example {
805
- * // property declarations are not part of ES6, though they are valid in TypeScript:
806
- * // static staticProperty;
807
- * // property;
808
- *
809
- * constructor(p) { }
810
- * static staticMethod(p) { }
811
- * method(p) { }
812
- * }
813
- *
814
- * // constructor
815
- * result = Reflect.getOwnMetadata("custom:annotation", Example);
816
- *
817
- * // property (on constructor)
818
- * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty");
819
- *
820
- * // property (on prototype)
821
- * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property");
822
- *
823
- * // method (on constructor)
824
- * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod");
825
- *
826
- * // method (on prototype)
827
- * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method");
828
- *
829
- */
830
- function getOwnMetadata(metadataKey, target, propertyKey) {
831
- if (!IsObject(target)) throw new TypeError();
832
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
833
- return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
834
- }
835
- exporter("getOwnMetadata", getOwnMetadata);
836
- /**
837
- * Gets the metadata keys defined on the target object or its prototype chain.
838
- * @param target The target object on which the metadata is defined.
839
- * @param propertyKey (Optional) The property key for the target.
840
- * @returns An array of unique metadata keys.
841
- * @example
842
- *
843
- * class Example {
844
- * // property declarations are not part of ES6, though they are valid in TypeScript:
845
- * // static staticProperty;
846
- * // property;
847
- *
848
- * constructor(p) { }
849
- * static staticMethod(p) { }
850
- * method(p) { }
851
- * }
852
- *
853
- * // constructor
854
- * result = Reflect.getMetadataKeys(Example);
855
- *
856
- * // property (on constructor)
857
- * result = Reflect.getMetadataKeys(Example, "staticProperty");
858
- *
859
- * // property (on prototype)
860
- * result = Reflect.getMetadataKeys(Example.prototype, "property");
861
- *
862
- * // method (on constructor)
863
- * result = Reflect.getMetadataKeys(Example, "staticMethod");
864
- *
865
- * // method (on prototype)
866
- * result = Reflect.getMetadataKeys(Example.prototype, "method");
867
- *
868
- */
869
- function getMetadataKeys(target, propertyKey) {
870
- if (!IsObject(target)) throw new TypeError();
871
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
872
- return OrdinaryMetadataKeys(target, propertyKey);
873
- }
874
- exporter("getMetadataKeys", getMetadataKeys);
875
- /**
876
- * Gets the unique metadata keys defined on the target object.
877
- * @param target The target object on which the metadata is defined.
878
- * @param propertyKey (Optional) The property key for the target.
879
- * @returns An array of unique metadata keys.
880
- * @example
881
- *
882
- * class Example {
883
- * // property declarations are not part of ES6, though they are valid in TypeScript:
884
- * // static staticProperty;
885
- * // property;
886
- *
887
- * constructor(p) { }
888
- * static staticMethod(p) { }
889
- * method(p) { }
890
- * }
891
- *
892
- * // constructor
893
- * result = Reflect.getOwnMetadataKeys(Example);
894
- *
895
- * // property (on constructor)
896
- * result = Reflect.getOwnMetadataKeys(Example, "staticProperty");
897
- *
898
- * // property (on prototype)
899
- * result = Reflect.getOwnMetadataKeys(Example.prototype, "property");
900
- *
901
- * // method (on constructor)
902
- * result = Reflect.getOwnMetadataKeys(Example, "staticMethod");
903
- *
904
- * // method (on prototype)
905
- * result = Reflect.getOwnMetadataKeys(Example.prototype, "method");
906
- *
907
- */
908
- function getOwnMetadataKeys(target, propertyKey) {
909
- if (!IsObject(target)) throw new TypeError();
910
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
911
- return OrdinaryOwnMetadataKeys(target, propertyKey);
912
- }
913
- exporter("getOwnMetadataKeys", getOwnMetadataKeys);
914
- /**
915
- * Deletes the metadata entry from the target object with the provided key.
916
- * @param metadataKey A key used to store and retrieve metadata.
917
- * @param target The target object on which the metadata is defined.
918
- * @param propertyKey (Optional) The property key for the target.
919
- * @returns `true` if the metadata entry was found and deleted; otherwise, false.
920
- * @example
921
- *
922
- * class Example {
923
- * // property declarations are not part of ES6, though they are valid in TypeScript:
924
- * // static staticProperty;
925
- * // property;
926
- *
927
- * constructor(p) { }
928
- * static staticMethod(p) { }
929
- * method(p) { }
930
- * }
931
- *
932
- * // constructor
933
- * result = Reflect.deleteMetadata("custom:annotation", Example);
934
- *
935
- * // property (on constructor)
936
- * result = Reflect.deleteMetadata("custom:annotation", Example, "staticProperty");
937
- *
938
- * // property (on prototype)
939
- * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "property");
940
- *
941
- * // method (on constructor)
942
- * result = Reflect.deleteMetadata("custom:annotation", Example, "staticMethod");
943
- *
944
- * // method (on prototype)
945
- * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "method");
946
- *
947
- */
948
- function deleteMetadata(metadataKey, target, propertyKey) {
949
- if (!IsObject(target)) throw new TypeError();
950
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
951
- if (!IsObject(target)) throw new TypeError();
952
- if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey);
953
- var provider = GetMetadataProvider(target, propertyKey, false);
954
- if (IsUndefined(provider)) return false;
955
- return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
956
- }
957
- exporter("deleteMetadata", deleteMetadata);
958
- function DecorateConstructor(decorators, target) {
959
- for (var i = decorators.length - 1; i >= 0; --i) {
960
- var decorator = decorators[i];
961
- var decorated = decorator(target);
962
- if (!IsUndefined(decorated) && !IsNull(decorated)) {
963
- if (!IsConstructor(decorated)) throw new TypeError();
964
- target = decorated;
965
- }
966
- }
967
- return target;
968
- }
969
- function DecorateProperty(decorators, target, propertyKey, descriptor) {
970
- for (var i = decorators.length - 1; i >= 0; --i) {
971
- var decorator = decorators[i];
972
- var decorated = decorator(target, propertyKey, descriptor);
973
- if (!IsUndefined(decorated) && !IsNull(decorated)) {
974
- if (!IsObject(decorated)) throw new TypeError();
975
- descriptor = decorated;
976
- }
977
- }
978
- return descriptor;
979
- }
980
- function OrdinaryHasMetadata(MetadataKey, O, P) {
981
- if (OrdinaryHasOwnMetadata(MetadataKey, O, P)) return true;
982
- var parent = OrdinaryGetPrototypeOf(O);
983
- if (!IsNull(parent)) return OrdinaryHasMetadata(MetadataKey, parent, P);
984
- return false;
985
- }
986
- function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
987
- var provider = GetMetadataProvider(O, P, false);
988
- if (IsUndefined(provider)) return false;
989
- return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
990
- }
991
- function OrdinaryGetMetadata(MetadataKey, O, P) {
992
- if (OrdinaryHasOwnMetadata(MetadataKey, O, P)) return OrdinaryGetOwnMetadata(MetadataKey, O, P);
993
- var parent = OrdinaryGetPrototypeOf(O);
994
- if (!IsNull(parent)) return OrdinaryGetMetadata(MetadataKey, parent, P);
995
- }
996
- function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
997
- var provider = GetMetadataProvider(O, P, false);
998
- if (IsUndefined(provider)) return;
999
- return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
1000
- }
1001
- function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
1002
- GetMetadataProvider(O, P, true).OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
1003
- }
1004
- function OrdinaryMetadataKeys(O, P) {
1005
- var ownKeys = OrdinaryOwnMetadataKeys(O, P);
1006
- var parent = OrdinaryGetPrototypeOf(O);
1007
- if (parent === null) return ownKeys;
1008
- var parentKeys = OrdinaryMetadataKeys(parent, P);
1009
- if (parentKeys.length <= 0) return ownKeys;
1010
- if (ownKeys.length <= 0) return parentKeys;
1011
- var set = new _Set();
1012
- var keys = [];
1013
- for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {
1014
- var key = ownKeys_1[_i];
1015
- var hasKey = set.has(key);
1016
- if (!hasKey) {
1017
- set.add(key);
1018
- keys.push(key);
1019
- }
1020
- }
1021
- for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {
1022
- var key = parentKeys_1[_a];
1023
- var hasKey = set.has(key);
1024
- if (!hasKey) {
1025
- set.add(key);
1026
- keys.push(key);
1027
- }
1028
- }
1029
- return keys;
1030
- }
1031
- function OrdinaryOwnMetadataKeys(O, P) {
1032
- var provider = GetMetadataProvider(O, P, false);
1033
- if (!provider) return [];
1034
- return provider.OrdinaryOwnMetadataKeys(O, P);
1035
- }
1036
- function Type$1(x) {
1037
- if (x === null) return 1;
1038
- switch (typeof x) {
1039
- case "undefined": return 0;
1040
- case "boolean": return 2;
1041
- case "string": return 3;
1042
- case "symbol": return 4;
1043
- case "number": return 5;
1044
- case "object": return x === null ? 1 : 6;
1045
- default: return 6;
1046
- }
1047
- }
1048
- function IsUndefined(x) {
1049
- return x === void 0;
1050
- }
1051
- function IsNull(x) {
1052
- return x === null;
1053
- }
1054
- function IsSymbol(x) {
1055
- return typeof x === "symbol";
1056
- }
1057
- function IsObject(x) {
1058
- return typeof x === "object" ? x !== null : typeof x === "function";
1059
- }
1060
- function ToPrimitive(input, PreferredType) {
1061
- switch (Type$1(input)) {
1062
- case 0: return input;
1063
- case 1: return input;
1064
- case 2: return input;
1065
- case 3: return input;
1066
- case 4: return input;
1067
- case 5: return input;
1068
- }
1069
- var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
1070
- var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
1071
- if (exoticToPrim !== void 0) {
1072
- var result = exoticToPrim.call(input, hint);
1073
- if (IsObject(result)) throw new TypeError();
1074
- return result;
1075
- }
1076
- return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
1077
- }
1078
- function OrdinaryToPrimitive(O, hint) {
1079
- if (hint === "string") {
1080
- var toString_1 = O.toString;
1081
- if (IsCallable(toString_1)) {
1082
- var result = toString_1.call(O);
1083
- if (!IsObject(result)) return result;
1084
- }
1085
- var valueOf = O.valueOf;
1086
- if (IsCallable(valueOf)) {
1087
- var result = valueOf.call(O);
1088
- if (!IsObject(result)) return result;
1089
- }
1090
- } else {
1091
- var valueOf = O.valueOf;
1092
- if (IsCallable(valueOf)) {
1093
- var result = valueOf.call(O);
1094
- if (!IsObject(result)) return result;
1095
- }
1096
- var toString_2 = O.toString;
1097
- if (IsCallable(toString_2)) {
1098
- var result = toString_2.call(O);
1099
- if (!IsObject(result)) return result;
1100
- }
1101
- }
1102
- throw new TypeError();
1103
- }
1104
- function ToBoolean(argument) {
1105
- return !!argument;
1106
- }
1107
- function ToString(argument) {
1108
- return "" + argument;
1109
- }
1110
- function ToPropertyKey(argument) {
1111
- var key = ToPrimitive(argument, 3);
1112
- if (IsSymbol(key)) return key;
1113
- return ToString(key);
1114
- }
1115
- function IsArray(argument) {
1116
- return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
1117
- }
1118
- function IsCallable(argument) {
1119
- return typeof argument === "function";
1120
- }
1121
- function IsConstructor(argument) {
1122
- return typeof argument === "function";
1123
- }
1124
- function IsPropertyKey(argument) {
1125
- switch (Type$1(argument)) {
1126
- case 3: return true;
1127
- case 4: return true;
1128
- default: return false;
1129
- }
1130
- }
1131
- function SameValueZero(x, y) {
1132
- return x === y || x !== x && y !== y;
1133
- }
1134
- function GetMethod(V, P) {
1135
- var func = V[P];
1136
- if (func === void 0 || func === null) return void 0;
1137
- if (!IsCallable(func)) throw new TypeError();
1138
- return func;
1139
- }
1140
- function GetIterator(obj) {
1141
- var method = GetMethod(obj, iteratorSymbol);
1142
- if (!IsCallable(method)) throw new TypeError();
1143
- var iterator = method.call(obj);
1144
- if (!IsObject(iterator)) throw new TypeError();
1145
- return iterator;
1146
- }
1147
- function IteratorValue(iterResult) {
1148
- return iterResult.value;
1149
- }
1150
- function IteratorStep(iterator) {
1151
- var result = iterator.next();
1152
- return result.done ? false : result;
1153
- }
1154
- function IteratorClose(iterator) {
1155
- var f = iterator["return"];
1156
- if (f) f.call(iterator);
1157
- }
1158
- function OrdinaryGetPrototypeOf(O) {
1159
- var proto = Object.getPrototypeOf(O);
1160
- if (typeof O !== "function" || O === functionPrototype) return proto;
1161
- if (proto !== functionPrototype) return proto;
1162
- var prototype = O.prototype;
1163
- var prototypeProto = prototype && Object.getPrototypeOf(prototype);
1164
- if (prototypeProto == null || prototypeProto === Object.prototype) return proto;
1165
- var constructor = prototypeProto.constructor;
1166
- if (typeof constructor !== "function") return proto;
1167
- if (constructor === O) return proto;
1168
- return constructor;
1169
- }
1170
- /**
1171
- * Creates a registry used to allow multiple `reflect-metadata` providers.
1172
- */
1173
- function CreateMetadataRegistry() {
1174
- var fallback;
1175
- if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") fallback = CreateFallbackProvider(root.Reflect);
1176
- var first;
1177
- var second;
1178
- var rest;
1179
- var targetProviderMap = new _WeakMap();
1180
- var registry = {
1181
- registerProvider,
1182
- getProvider,
1183
- setProvider
1184
- };
1185
- return registry;
1186
- function registerProvider(provider) {
1187
- if (!Object.isExtensible(registry)) throw new Error("Cannot add provider to a frozen registry.");
1188
- switch (true) {
1189
- case fallback === provider: break;
1190
- case IsUndefined(first):
1191
- first = provider;
1192
- break;
1193
- case first === provider: break;
1194
- case IsUndefined(second):
1195
- second = provider;
1196
- break;
1197
- case second === provider: break;
1198
- default:
1199
- if (rest === void 0) rest = new _Set();
1200
- rest.add(provider);
1201
- break;
1202
- }
1203
- }
1204
- function getProviderNoCache(O, P) {
1205
- if (!IsUndefined(first)) {
1206
- if (first.isProviderFor(O, P)) return first;
1207
- if (!IsUndefined(second)) {
1208
- if (second.isProviderFor(O, P)) return first;
1209
- if (!IsUndefined(rest)) {
1210
- var iterator = GetIterator(rest);
1211
- while (true) {
1212
- var next = IteratorStep(iterator);
1213
- if (!next) return;
1214
- var provider = IteratorValue(next);
1215
- if (provider.isProviderFor(O, P)) {
1216
- IteratorClose(iterator);
1217
- return provider;
1218
- }
1219
- }
1220
- }
1221
- }
1222
- }
1223
- if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) return fallback;
1224
- }
1225
- function getProvider(O, P) {
1226
- var providerMap = targetProviderMap.get(O);
1227
- var provider;
1228
- if (!IsUndefined(providerMap)) provider = providerMap.get(P);
1229
- if (!IsUndefined(provider)) return provider;
1230
- provider = getProviderNoCache(O, P);
1231
- if (!IsUndefined(provider)) {
1232
- if (IsUndefined(providerMap)) {
1233
- providerMap = new _Map();
1234
- targetProviderMap.set(O, providerMap);
1235
- }
1236
- providerMap.set(P, provider);
1237
- }
1238
- return provider;
1239
- }
1240
- function hasProvider(provider) {
1241
- if (IsUndefined(provider)) throw new TypeError();
1242
- return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
1243
- }
1244
- function setProvider(O, P, provider) {
1245
- if (!hasProvider(provider)) throw new Error("Metadata provider not registered.");
1246
- var existingProvider = getProvider(O, P);
1247
- if (existingProvider !== provider) {
1248
- if (!IsUndefined(existingProvider)) return false;
1249
- var providerMap = targetProviderMap.get(O);
1250
- if (IsUndefined(providerMap)) {
1251
- providerMap = new _Map();
1252
- targetProviderMap.set(O, providerMap);
1253
- }
1254
- providerMap.set(P, provider);
1255
- }
1256
- return true;
1257
- }
1258
- }
1259
- /**
1260
- * Gets or creates the shared registry of metadata providers.
1261
- */
1262
- function GetOrCreateMetadataRegistry() {
1263
- var metadataRegistry$1;
1264
- if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) metadataRegistry$1 = root.Reflect[registrySymbol];
1265
- if (IsUndefined(metadataRegistry$1)) metadataRegistry$1 = CreateMetadataRegistry();
1266
- if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) Object.defineProperty(root.Reflect, registrySymbol, {
1267
- enumerable: false,
1268
- configurable: false,
1269
- writable: false,
1270
- value: metadataRegistry$1
1271
- });
1272
- return metadataRegistry$1;
1273
- }
1274
- function CreateMetadataProvider(registry) {
1275
- var metadata$1 = new _WeakMap();
1276
- var provider = {
1277
- isProviderFor: function(O, P) {
1278
- var targetMetadata = metadata$1.get(O);
1279
- if (IsUndefined(targetMetadata)) return false;
1280
- return targetMetadata.has(P);
1281
- },
1282
- OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata$1,
1283
- OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata$1,
1284
- OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata$1,
1285
- OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys$1,
1286
- OrdinaryDeleteMetadata
1287
- };
1288
- metadataRegistry.registerProvider(provider);
1289
- return provider;
1290
- function GetOrCreateMetadataMap(O, P, Create) {
1291
- var targetMetadata = metadata$1.get(O);
1292
- var createdTargetMetadata = false;
1293
- if (IsUndefined(targetMetadata)) {
1294
- if (!Create) return void 0;
1295
- targetMetadata = new _Map();
1296
- metadata$1.set(O, targetMetadata);
1297
- createdTargetMetadata = true;
1298
- }
1299
- var metadataMap = targetMetadata.get(P);
1300
- if (IsUndefined(metadataMap)) {
1301
- if (!Create) return void 0;
1302
- metadataMap = new _Map();
1303
- targetMetadata.set(P, metadataMap);
1304
- if (!registry.setProvider(O, P, provider)) {
1305
- targetMetadata.delete(P);
1306
- if (createdTargetMetadata) metadata$1.delete(O);
1307
- throw new Error("Wrong provider for target.");
1308
- }
1309
- }
1310
- return metadataMap;
1311
- }
1312
- function OrdinaryHasOwnMetadata$1(MetadataKey, O, P) {
1313
- var metadataMap = GetOrCreateMetadataMap(O, P, false);
1314
- if (IsUndefined(metadataMap)) return false;
1315
- return ToBoolean(metadataMap.has(MetadataKey));
1316
- }
1317
- function OrdinaryGetOwnMetadata$1(MetadataKey, O, P) {
1318
- var metadataMap = GetOrCreateMetadataMap(O, P, false);
1319
- if (IsUndefined(metadataMap)) return void 0;
1320
- return metadataMap.get(MetadataKey);
1321
- }
1322
- function OrdinaryDefineOwnMetadata$1(MetadataKey, MetadataValue, O, P) {
1323
- GetOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
1324
- }
1325
- function OrdinaryOwnMetadataKeys$1(O, P) {
1326
- var keys = [];
1327
- var metadataMap = GetOrCreateMetadataMap(O, P, false);
1328
- if (IsUndefined(metadataMap)) return keys;
1329
- var iterator = GetIterator(metadataMap.keys());
1330
- var k = 0;
1331
- while (true) {
1332
- var next = IteratorStep(iterator);
1333
- if (!next) {
1334
- keys.length = k;
1335
- return keys;
1336
- }
1337
- var nextValue = IteratorValue(next);
1338
- try {
1339
- keys[k] = nextValue;
1340
- } catch (e) {
1341
- try {
1342
- IteratorClose(iterator);
1343
- } finally {
1344
- throw e;
1345
- }
1346
- }
1347
- k++;
1348
- }
1349
- }
1350
- function OrdinaryDeleteMetadata(MetadataKey, O, P) {
1351
- var metadataMap = GetOrCreateMetadataMap(O, P, false);
1352
- if (IsUndefined(metadataMap)) return false;
1353
- if (!metadataMap.delete(MetadataKey)) return false;
1354
- if (metadataMap.size === 0) {
1355
- var targetMetadata = metadata$1.get(O);
1356
- if (!IsUndefined(targetMetadata)) {
1357
- targetMetadata.delete(P);
1358
- if (targetMetadata.size === 0) metadata$1.delete(targetMetadata);
1359
- }
1360
- }
1361
- return true;
1362
- }
1363
- }
1364
- function CreateFallbackProvider(reflect) {
1365
- var defineMetadata$1 = reflect.defineMetadata, hasOwnMetadata$1 = reflect.hasOwnMetadata, getOwnMetadata$1 = reflect.getOwnMetadata, getOwnMetadataKeys$1 = reflect.getOwnMetadataKeys, deleteMetadata$1 = reflect.deleteMetadata;
1366
- var metadataOwner = new _WeakMap();
1367
- return {
1368
- isProviderFor: function(O, P) {
1369
- var metadataPropertySet = metadataOwner.get(O);
1370
- if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) return true;
1371
- if (getOwnMetadataKeys$1(O, P).length) {
1372
- if (IsUndefined(metadataPropertySet)) {
1373
- metadataPropertySet = new _Set();
1374
- metadataOwner.set(O, metadataPropertySet);
1375
- }
1376
- metadataPropertySet.add(P);
1377
- return true;
1378
- }
1379
- return false;
1380
- },
1381
- OrdinaryDefineOwnMetadata: defineMetadata$1,
1382
- OrdinaryHasOwnMetadata: hasOwnMetadata$1,
1383
- OrdinaryGetOwnMetadata: getOwnMetadata$1,
1384
- OrdinaryOwnMetadataKeys: getOwnMetadataKeys$1,
1385
- OrdinaryDeleteMetadata: deleteMetadata$1
1386
- };
1387
- }
1388
- /**
1389
- * Gets the metadata provider for an object. If the object has no metadata provider and this is for a create operation,
1390
- * then this module's metadata provider is assigned to the object.
1391
- */
1392
- function GetMetadataProvider(O, P, Create) {
1393
- var registeredProvider = metadataRegistry.getProvider(O, P);
1394
- if (!IsUndefined(registeredProvider)) return registeredProvider;
1395
- if (Create) {
1396
- if (metadataRegistry.setProvider(O, P, metadataProvider)) return metadataProvider;
1397
- throw new Error("Illegal state.");
1398
- }
1399
- }
1400
- function CreateMapPolyfill() {
1401
- var cacheSentinel = {};
1402
- var arraySentinel = [];
1403
- var MapIterator = function() {
1404
- function MapIterator$1(keys, values, selector) {
1405
- this._index = 0;
1406
- this._keys = keys;
1407
- this._values = values;
1408
- this._selector = selector;
1409
- }
1410
- MapIterator$1.prototype["@@iterator"] = function() {
1411
- return this;
1412
- };
1413
- MapIterator$1.prototype[iteratorSymbol] = function() {
1414
- return this;
1415
- };
1416
- MapIterator$1.prototype.next = function() {
1417
- var index = this._index;
1418
- if (index >= 0 && index < this._keys.length) {
1419
- var result = this._selector(this._keys[index], this._values[index]);
1420
- if (index + 1 >= this._keys.length) {
1421
- this._index = -1;
1422
- this._keys = arraySentinel;
1423
- this._values = arraySentinel;
1424
- } else this._index++;
1425
- return {
1426
- value: result,
1427
- done: false
1428
- };
1429
- }
1430
- return {
1431
- value: void 0,
1432
- done: true
1433
- };
1434
- };
1435
- MapIterator$1.prototype.throw = function(error) {
1436
- if (this._index >= 0) {
1437
- this._index = -1;
1438
- this._keys = arraySentinel;
1439
- this._values = arraySentinel;
1440
- }
1441
- throw error;
1442
- };
1443
- MapIterator$1.prototype.return = function(value) {
1444
- if (this._index >= 0) {
1445
- this._index = -1;
1446
- this._keys = arraySentinel;
1447
- this._values = arraySentinel;
1448
- }
1449
- return {
1450
- value,
1451
- done: true
1452
- };
1453
- };
1454
- return MapIterator$1;
1455
- }();
1456
- return function() {
1457
- function Map$1() {
1458
- this._keys = [];
1459
- this._values = [];
1460
- this._cacheKey = cacheSentinel;
1461
- this._cacheIndex = -2;
1462
- }
1463
- Object.defineProperty(Map$1.prototype, "size", {
1464
- get: function() {
1465
- return this._keys.length;
1466
- },
1467
- enumerable: true,
1468
- configurable: true
1469
- });
1470
- Map$1.prototype.has = function(key) {
1471
- return this._find(key, false) >= 0;
1472
- };
1473
- Map$1.prototype.get = function(key) {
1474
- var index = this._find(key, false);
1475
- return index >= 0 ? this._values[index] : void 0;
1476
- };
1477
- Map$1.prototype.set = function(key, value) {
1478
- var index = this._find(key, true);
1479
- this._values[index] = value;
1480
- return this;
1481
- };
1482
- Map$1.prototype.delete = function(key) {
1483
- var index = this._find(key, false);
1484
- if (index >= 0) {
1485
- var size = this._keys.length;
1486
- for (var i = index + 1; i < size; i++) {
1487
- this._keys[i - 1] = this._keys[i];
1488
- this._values[i - 1] = this._values[i];
1489
- }
1490
- this._keys.length--;
1491
- this._values.length--;
1492
- if (SameValueZero(key, this._cacheKey)) {
1493
- this._cacheKey = cacheSentinel;
1494
- this._cacheIndex = -2;
1495
- }
1496
- return true;
1497
- }
1498
- return false;
1499
- };
1500
- Map$1.prototype.clear = function() {
1501
- this._keys.length = 0;
1502
- this._values.length = 0;
1503
- this._cacheKey = cacheSentinel;
1504
- this._cacheIndex = -2;
1505
- };
1506
- Map$1.prototype.keys = function() {
1507
- return new MapIterator(this._keys, this._values, getKey);
1508
- };
1509
- Map$1.prototype.values = function() {
1510
- return new MapIterator(this._keys, this._values, getValue);
1511
- };
1512
- Map$1.prototype.entries = function() {
1513
- return new MapIterator(this._keys, this._values, getEntry);
1514
- };
1515
- Map$1.prototype["@@iterator"] = function() {
1516
- return this.entries();
1517
- };
1518
- Map$1.prototype[iteratorSymbol] = function() {
1519
- return this.entries();
1520
- };
1521
- Map$1.prototype._find = function(key, insert) {
1522
- if (!SameValueZero(this._cacheKey, key)) {
1523
- this._cacheIndex = -1;
1524
- for (var i = 0; i < this._keys.length; i++) if (SameValueZero(this._keys[i], key)) {
1525
- this._cacheIndex = i;
1526
- break;
1527
- }
1528
- }
1529
- if (this._cacheIndex < 0 && insert) {
1530
- this._cacheIndex = this._keys.length;
1531
- this._keys.push(key);
1532
- this._values.push(void 0);
1533
- }
1534
- return this._cacheIndex;
1535
- };
1536
- return Map$1;
1537
- }();
1538
- function getKey(key, _) {
1539
- return key;
1540
- }
1541
- function getValue(_, value) {
1542
- return value;
1543
- }
1544
- function getEntry(key, value) {
1545
- return [key, value];
1546
- }
1547
- }
1548
- function CreateSetPolyfill() {
1549
- return function() {
1550
- function Set$1() {
1551
- this._map = new _Map();
1552
- }
1553
- Object.defineProperty(Set$1.prototype, "size", {
1554
- get: function() {
1555
- return this._map.size;
1556
- },
1557
- enumerable: true,
1558
- configurable: true
1559
- });
1560
- Set$1.prototype.has = function(value) {
1561
- return this._map.has(value);
1562
- };
1563
- Set$1.prototype.add = function(value) {
1564
- return this._map.set(value, value), this;
1565
- };
1566
- Set$1.prototype.delete = function(value) {
1567
- return this._map.delete(value);
1568
- };
1569
- Set$1.prototype.clear = function() {
1570
- this._map.clear();
1571
- };
1572
- Set$1.prototype.keys = function() {
1573
- return this._map.keys();
1574
- };
1575
- Set$1.prototype.values = function() {
1576
- return this._map.keys();
1577
- };
1578
- Set$1.prototype.entries = function() {
1579
- return this._map.entries();
1580
- };
1581
- Set$1.prototype["@@iterator"] = function() {
1582
- return this.keys();
1583
- };
1584
- Set$1.prototype[iteratorSymbol] = function() {
1585
- return this.keys();
1586
- };
1587
- return Set$1;
1588
- }();
1589
- }
1590
- function CreateWeakMapPolyfill() {
1591
- var UUID_SIZE = 16;
1592
- var keys = HashMap.create();
1593
- var rootKey = CreateUniqueKey();
1594
- return function() {
1595
- function WeakMap$1() {
1596
- this._key = CreateUniqueKey();
1597
- }
1598
- WeakMap$1.prototype.has = function(target) {
1599
- var table = GetOrCreateWeakMapTable(target, false);
1600
- return table !== void 0 ? HashMap.has(table, this._key) : false;
1601
- };
1602
- WeakMap$1.prototype.get = function(target) {
1603
- var table = GetOrCreateWeakMapTable(target, false);
1604
- return table !== void 0 ? HashMap.get(table, this._key) : void 0;
1605
- };
1606
- WeakMap$1.prototype.set = function(target, value) {
1607
- var table = GetOrCreateWeakMapTable(target, true);
1608
- table[this._key] = value;
1609
- return this;
1610
- };
1611
- WeakMap$1.prototype.delete = function(target) {
1612
- var table = GetOrCreateWeakMapTable(target, false);
1613
- return table !== void 0 ? delete table[this._key] : false;
1614
- };
1615
- WeakMap$1.prototype.clear = function() {
1616
- this._key = CreateUniqueKey();
1617
- };
1618
- return WeakMap$1;
1619
- }();
1620
- function CreateUniqueKey() {
1621
- var key;
1622
- do
1623
- key = "@@WeakMap@@" + CreateUUID();
1624
- while (HashMap.has(keys, key));
1625
- keys[key] = true;
1626
- return key;
1627
- }
1628
- function GetOrCreateWeakMapTable(target, create) {
1629
- if (!hasOwn.call(target, rootKey)) {
1630
- if (!create) return void 0;
1631
- Object.defineProperty(target, rootKey, { value: HashMap.create() });
1632
- }
1633
- return target[rootKey];
1634
- }
1635
- function FillRandomBytes(buffer, size) {
1636
- for (var i = 0; i < size; ++i) buffer[i] = Math.random() * 255 | 0;
1637
- return buffer;
1638
- }
1639
- function GenRandomBytes(size) {
1640
- if (typeof Uint8Array === "function") {
1641
- var array = new Uint8Array(size);
1642
- if (typeof crypto !== "undefined") crypto.getRandomValues(array);
1643
- else if (typeof msCrypto !== "undefined") msCrypto.getRandomValues(array);
1644
- else FillRandomBytes(array, size);
1645
- return array;
1646
- }
1647
- return FillRandomBytes(new Array(size), size);
1648
- }
1649
- function CreateUUID() {
1650
- var data = GenRandomBytes(UUID_SIZE);
1651
- data[6] = data[6] & 79 | 64;
1652
- data[8] = data[8] & 191 | 128;
1653
- var result = "";
1654
- for (var offset = 0; offset < UUID_SIZE; ++offset) {
1655
- var byte = data[offset];
1656
- if (offset === 4 || offset === 6 || offset === 8) result += "-";
1657
- if (byte < 16) result += "0";
1658
- result += byte.toString(16).toLowerCase();
1659
- }
1660
- return result;
1661
- }
1662
- }
1663
- function MakeDictionary(obj) {
1664
- obj.__ = void 0;
1665
- delete obj.__;
1666
- return obj;
1667
- }
1668
- });
1669
- })(Reflect || (Reflect = {}));
1670
- }));
1671
-
1672
- //#endregion
1673
- //#region src/decorators/params.utils.ts
1674
- var import_Reflect = require_Reflect();
1675
- const createTemporalParamDecorator = (paramtype) => {
1676
- return (data) => (target, key, index) => {
1677
- const args = Reflect.getMetadata(TEMPORAL_ARGS_METADATA, target, key) || {};
1678
- args[index] = {
1679
- index,
1680
- data,
1681
- type: paramtype
1682
- };
1683
- Reflect.defineMetadata(TEMPORAL_ARGS_METADATA, args, target, key);
1684
- };
1685
- };
1686
-
1687
443
  //#endregion
1688
444
  //#region src/decorators/payload.decorator.ts
1689
- function Payload(property) {
1690
- return createTemporalParamDecorator(TemporalParamType.PAYLOAD)(property);
1691
- }
1692
-
1693
- //#endregion
1694
- //#region src/decorators/context.decorator.ts
1695
- function Context() {
1696
- return createTemporalParamDecorator(TemporalParamType.CONTEXT)();
1697
- }
445
+ const ActivityPayload = () => createParamDecorator((_, ctx) => {
446
+ return ctx.getArgByIndex(0);
447
+ });
1698
448
 
1699
449
  //#endregion
1700
- export { Activities, Activity, Context, InjectTemporalClient, Payload, TemporalExecutionContext, TemporalExplorer, TemporalModule, WorkflowMethod, Workflows };
450
+ export { Activities, Activity, ActivityPayload, InjectTemporalClient, TemporalExecutionContext, TemporalExplorer, TemporalModule, WorkflowMethod, Workflows };
1701
451
  //# sourceMappingURL=index.mjs.map