@powerhousedao/reactor-workflow 6.2.3-dev.45 → 6.2.3-dev.47

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { B as UnsupportedPieceFeatureError, H as unsupportedAuth, M as maxFileBytes, U as unsupportedTrigger, V as authMethodFor, a as redact, c as rememberSecrets, f as isPrivateAddress, i as containsRedactedMarker, k as FileTooLargeError, l as secretsFor, p as parseAddress, s as redactMessage, u as DEFAULT_EGRESS_POLICY, w as extractDedupeKey } from "./reactor-rpc-BqAjCK1p.js";
2
- import { A as expressionsIn, B as PieceWorkerError, C as CORE_PIECE_VERSION, D as declaredReactorConnectionIds, E as declaredConnectionIds, F as secretRefFromId, H as bundleResolver, I as stepBlock, J as pieceRegistrySource, L as triggerBlock, M as SecretDeletedError, N as SecretNotFoundError, O as shapeConnection, P as parseSecretRef, R as PieceWorkerPool, S as CORE_PIECE_NAME, U as pieceModuleRef, V as PieceWorkerTimeoutError, W as sourcedResolver, Y as setPieceRegistryUrl, _ as blockLabel, a as errorNameOf, b as builtinPiece, c as hashOf, d as checkDynamicProperties, f as ActivepiecesBlockExecutor, g as storeHandlers, h as resolvedBlock, i as packagePieces, k as resolveStepInput, l as stepConfigHash, m as isHostBound, n as installedPiece, o as runWorkflow, p as CompositeBlockExecutor, q as npmRegistryBaseUrl, r as installedPieces, s as canonicalJson, t as PieceRegistry, u as DynamicPropertiesError, v as unpinnedNote, w as BoundConnectionResolver, x as describeBuiltinPiece, y as blockPorts, z as PieceWorker } from "./piece-registry-Cv8Zw8ex.js";
2
+ import { A as expressionsIn, B as PieceWorkerError, C as CORE_PIECE_VERSION, D as declaredReactorConnectionIds, E as declaredConnectionIds, F as secretRefFromId, H as bundleResolver, I as stepBlock, J as pieceRegistrySource, L as triggerBlock, M as SecretDeletedError, N as SecretNotFoundError, O as shapeConnection, P as parseSecretRef, R as PieceWorkerPool, S as CORE_PIECE_NAME, U as pieceModuleRef, V as PieceWorkerTimeoutError, W as sourcedResolver, Y as setPieceRegistryUrl, _ as blockLabel, a as errorNameOf, b as builtinPiece, c as hashOf, d as checkDynamicProperties, f as ActivepiecesBlockExecutor, g as storeHandlers, h as resolvedBlock, i as packagePieces, k as resolveStepInput, l as stepConfigHash, m as isHostBound, n as installedPiece, o as runWorkflow, p as CompositeBlockExecutor, q as npmRegistryBaseUrl, r as installedPieces, s as canonicalJson, t as PieceRegistry, u as DynamicPropertiesError, v as unpinnedNote, w as BoundConnectionResolver, x as describeBuiltinPiece, y as blockPorts, z as PieceWorker } from "./piece-registry-L1gY1Hbq.js";
3
3
  import { ReactorAccessDeniedError, ReactorAccessDeniedError as ReactorAccessDeniedError$1, ReactorActionsFailedError as ReactorActionsFailedError$1, ReactorJobFailedError as ReactorJobFailedError$1, ReactorJobPendingError as ReactorJobPendingError$1, WebhookHandshakeStrategy } from "@powerhousedao/pieces-framework";
4
4
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { open, readFile, rm } from "node:fs/promises";
@@ -9448,7 +9448,7 @@ var WorkflowRuntimeService = class {
9448
9448
  });
9449
9449
  if (this.alreadySeen(opKey)) continue;
9450
9450
  if (context.scope === DOCUMENT_SCOPE) {
9451
- await this.matchDocumentLifecycle(operation, context, hints, opKey);
9451
+ await this.matchDocumentLifecycle(operation, context, hints);
9452
9452
  await this.forgetDeletedWorkflow(operation, context);
9453
9453
  continue;
9454
9454
  }
@@ -9474,12 +9474,12 @@ var WorkflowRuntimeService = class {
9474
9474
  timestampUtcMs: operation.timestampUtcMs
9475
9475
  }
9476
9476
  };
9477
- await this.enqueueFire(registration.workflowId, payload, registration.kind, opKey);
9477
+ await this.enqueueFire(registration.workflowId, payload, registration.kind, `op:${opKey}`);
9478
9478
  }
9479
9479
  if (context.documentType === DRIVE_DOCUMENT_TYPE) await this.matchDriveLifecycle(context.documentId, operation.action.type, operation.action.input, {
9480
9480
  index: operation.index,
9481
9481
  timestampUtcMs: operation.timestampUtcMs
9482
- }, opKey);
9482
+ });
9483
9483
  }
9484
9484
  }
9485
9485
  unjournaledFires = /* @__PURE__ */ new Set();
@@ -9492,13 +9492,13 @@ var WorkflowRuntimeService = class {
9492
9492
  }
9493
9493
  this.fireFromTrigger(workflowId, payload, kind);
9494
9494
  }
9495
- async enqueueFire(workflowId, payload, kind, opKey) {
9496
- const fireKey = JSON.stringify([workflowId, opKey]);
9495
+ async enqueueFire(workflowId, payload, kind, dedupeKey) {
9496
+ const fireKey = JSON.stringify([workflowId, dedupeKey]);
9497
9497
  const store = await this.store();
9498
9498
  if (this.unjournaledFires.has(fireKey)) {
9499
9499
  if (!store) return;
9500
9500
  try {
9501
- await store.claimDedupe(workflowId, `op:${opKey}`, OPERATION_DEDUPE_TTL_MS, (/* @__PURE__ */ new Date()).toISOString());
9501
+ await store.claimDedupe(workflowId, dedupeKey, OPERATION_DEDUPE_TTL_MS, (/* @__PURE__ */ new Date()).toISOString());
9502
9502
  this.unjournaledFires.delete(fireKey);
9503
9503
  } catch (error) {
9504
9504
  this.logger.warn(`Could not record the unjournaled ${kind} fire for workflow ${workflowId}: @error`, error);
@@ -9511,7 +9511,7 @@ var WorkflowRuntimeService = class {
9511
9511
  }
9512
9512
  let runId;
9513
9513
  try {
9514
- runId = await store.claimAndEnqueueRun(`op:${opKey}`, OPERATION_DEDUPE_TTL_MS, (/* @__PURE__ */ new Date()).toISOString(), {
9514
+ runId = await store.claimAndEnqueueRun(dedupeKey, OPERATION_DEDUPE_TTL_MS, (/* @__PURE__ */ new Date()).toISOString(), {
9515
9515
  workflowId,
9516
9516
  triggerKind: kind,
9517
9517
  triggerPayload: payload
@@ -9558,12 +9558,12 @@ var WorkflowRuntimeService = class {
9558
9558
  }
9559
9559
  return targets;
9560
9560
  }
9561
- async fireLifecycle(kind, payload, opKey) {
9561
+ async fireLifecycle(kind, payload) {
9562
9562
  let matched = false;
9563
9563
  for (const target of this.lifecycleTargets(kind)) {
9564
9564
  if (!matchesLifecycleFilter(target.filter, payload.documentType, payload.driveId)) continue;
9565
9565
  matched = true;
9566
- await this.enqueueFire(target.workflowId, payload, kind, opKey);
9566
+ await this.enqueueFire(target.workflowId, payload, kind, `lifecycle:${kind}:${payload.documentId}`);
9567
9567
  }
9568
9568
  if (matched) this.recordLifecycleFired(kind, payload.documentId);
9569
9569
  }
@@ -9616,7 +9616,7 @@ var WorkflowRuntimeService = class {
9616
9616
  await store.deleteDedupe(workflowId);
9617
9617
  for (const scope of ["FLOW", "PROJECT"]) await store.deletePieceStore(scope, testPartitionKey(scope, workflowId));
9618
9618
  }
9619
- async matchDocumentLifecycle(operation, context, hints, opKey) {
9619
+ async matchDocumentLifecycle(operation, context, hints) {
9620
9620
  const kind = lifecycleKindForDocumentAction(operation.action.type);
9621
9621
  if (!kind) return;
9622
9622
  if (operation.error !== void 0) return;
@@ -9637,9 +9637,9 @@ var WorkflowRuntimeService = class {
9637
9637
  index: operation.index,
9638
9638
  timestampUtcMs: operation.timestampUtcMs
9639
9639
  }
9640
- }, opKey);
9640
+ });
9641
9641
  }
9642
- async matchDriveLifecycle(driveId, actionType, input, operation, opKey) {
9642
+ async matchDriveLifecycle(driveId, actionType, input, operation) {
9643
9643
  const kind = lifecycleKindForDriveAction(actionType);
9644
9644
  if (!kind) return;
9645
9645
  if (this.lifecycleTargets(kind).length === 0) return;
@@ -9663,7 +9663,7 @@ var WorkflowRuntimeService = class {
9663
9663
  driveId,
9664
9664
  parentId: stringField(record, "parentFolder") ?? null,
9665
9665
  operation
9666
- }, opKey);
9666
+ });
9667
9667
  }
9668
9668
  triggerSupervisor;
9669
9669
  supervisor() {