@io-orkes/conductor-javascript 3.0.1 → 3.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.mjs CHANGED
@@ -41404,20 +41404,51 @@ var TaskHandler = class _TaskHandler {
41404
41404
 
41405
41405
  // src/sdk/worker/schema/decorators.ts
41406
41406
  var SCHEMA_METADATA_KEY = Symbol("conductor:schemaField");
41407
+ function isNewDecoratorContext(arg) {
41408
+ return typeof arg === "object" && arg !== null && "kind" in arg && typeof arg.kind === "string";
41409
+ }
41410
+ var schemaFieldProcessed = /* @__PURE__ */ new WeakMap();
41411
+ function storeSchemaFieldMetadata(cls, propertyKey, options, designType) {
41412
+ const existing = Reflect.getOwnMetadata(SCHEMA_METADATA_KEY, cls) ?? [];
41413
+ existing.push({
41414
+ ...options,
41415
+ propertyKey,
41416
+ designType
41417
+ });
41418
+ Reflect.defineMetadata(SCHEMA_METADATA_KEY, existing, cls);
41419
+ }
41407
41420
  function schemaField(options = {}) {
41408
- return function(target, propertyKey) {
41409
- const existing = Reflect.getOwnMetadata(SCHEMA_METADATA_KEY, target.constructor) ?? [];
41421
+ return function(targetOrValue, propertyKeyOrContext) {
41422
+ if (isNewDecoratorContext(propertyKeyOrContext)) {
41423
+ const propertyKey2 = String(propertyKeyOrContext.name);
41424
+ return function(initialValue) {
41425
+ const cls = this.constructor;
41426
+ const processed = schemaFieldProcessed.get(cls) ?? /* @__PURE__ */ new Set();
41427
+ if (!processed.has(propertyKey2)) {
41428
+ processed.add(propertyKey2);
41429
+ schemaFieldProcessed.set(cls, processed);
41430
+ let designType2;
41431
+ try {
41432
+ designType2 = Reflect.getMetadata(
41433
+ "design:type",
41434
+ this,
41435
+ propertyKey2
41436
+ );
41437
+ } catch {
41438
+ }
41439
+ storeSchemaFieldMetadata(cls, propertyKey2, options, designType2);
41440
+ }
41441
+ return initialValue;
41442
+ };
41443
+ }
41444
+ const target = targetOrValue;
41445
+ const propertyKey = propertyKeyOrContext;
41410
41446
  let designType;
41411
41447
  try {
41412
41448
  designType = Reflect.getMetadata("design:type", target, propertyKey);
41413
41449
  } catch {
41414
41450
  }
41415
- existing.push({
41416
- ...options,
41417
- propertyKey,
41418
- designType
41419
- });
41420
- Reflect.defineMetadata(SCHEMA_METADATA_KEY, existing, target.constructor);
41451
+ storeSchemaFieldMetadata(target.constructor, propertyKey, options, designType);
41421
41452
  };
41422
41453
  }
41423
41454
  function inferType(designType) {
@@ -41478,9 +41509,20 @@ function generateSchemaFromClass(cls) {
41478
41509
  }
41479
41510
 
41480
41511
  // src/sdk/worker/decorators/worker.ts
41512
+ function isNewDecoratorContext2(arg) {
41513
+ return typeof arg === "object" && arg !== null && "kind" in arg && typeof arg.kind === "string";
41514
+ }
41481
41515
  function worker(options) {
41482
- return function(target, propertyKey, descriptor) {
41483
- const executeFunction = descriptor?.value || target;
41516
+ function decorator(target, propertyKeyOrContext, descriptor) {
41517
+ let executeFunction;
41518
+ let isNewApi = false;
41519
+ if (isNewDecoratorContext2(propertyKeyOrContext)) {
41520
+ executeFunction = target;
41521
+ isNewApi = true;
41522
+ } else {
41523
+ const fn = descriptor?.value ?? target;
41524
+ executeFunction = fn;
41525
+ }
41484
41526
  if (typeof executeFunction !== "function") {
41485
41527
  throw new Error(
41486
41528
  `@worker decorator can only be applied to functions. Received: ${typeof executeFunction}`
@@ -41494,10 +41536,14 @@ function worker(options) {
41494
41536
  let resolvedInputSchema = options.inputSchema;
41495
41537
  let resolvedOutputSchema = options.outputSchema;
41496
41538
  if (options.inputType) {
41497
- resolvedInputSchema = generateSchemaFromClass(options.inputType);
41539
+ resolvedInputSchema = generateSchemaFromClass(
41540
+ options.inputType
41541
+ );
41498
41542
  }
41499
41543
  if (options.outputType) {
41500
- resolvedOutputSchema = generateSchemaFromClass(options.outputType);
41544
+ resolvedOutputSchema = generateSchemaFromClass(
41545
+ options.outputType
41546
+ );
41501
41547
  }
41502
41548
  const registeredWorker = {
41503
41549
  taskDefName: options.taskDefName,
@@ -41524,18 +41570,25 @@ function worker(options) {
41524
41570
  builderArgs.inputParameters ?? {}
41525
41571
  );
41526
41572
  }
41527
- return executeFunction.apply(this, args);
41573
+ return executeFunction.apply(
41574
+ this,
41575
+ args
41576
+ );
41528
41577
  };
41529
41578
  Object.defineProperty(dualModeFunction, "name", {
41530
41579
  value: executeFunction.name,
41531
41580
  configurable: true
41532
41581
  });
41582
+ if (isNewApi) {
41583
+ return dualModeFunction;
41584
+ }
41533
41585
  if (descriptor) {
41534
41586
  descriptor.value = dualModeFunction;
41535
41587
  return descriptor;
41536
41588
  }
41537
41589
  return dualModeFunction;
41538
- };
41590
+ }
41591
+ return decorator;
41539
41592
  }
41540
41593
 
41541
41594
  // src/sdk/worker/metrics/MetricsCollector.ts