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