@powerhousedao/reactor-workflow 6.2.3-dev.54 → 6.2.3-dev.55

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,13 +1,12 @@
1
- import { $ as isPrivateAddress, A as declaredConnectionIds, B as stepBlock, C as builtinPiece, D as AttachmentCache, E as CORE_PIECE_VERSION, G as PieceWorkerError, H as PieceWorkerPool, I as SecretDeletedError, J as redact, K as PieceWorkerTimeoutError, L as SecretNotFoundError, M as shapeConnection, N as resolveStepInput, O as BoundConnectionResolver, P as expressionsIn, Q as DEFAULT_EGRESS_POLICY, R as parseSecretRef, S as blockPorts, T as CORE_PIECE_NAME, U as PieceWorker, V as triggerBlock, W as PieceWorkerDisposedError, X as rememberSecrets, Y as redactMessage, Z as secretsFor, _ as resolvedBlock, _t as isIndeterminateError, at as pieceModuleRef, b as resolutionOf, c as canonicalJson, ct as UnsupportedPieceFeatureError, d as DynamicPropertiesError, dt as unsupportedTrigger, et as parseAddress, f as checkDynamicProperties, g as isHostBound, gt as setPieceRegistryUrl, h as CompositeBlockExecutor, ht as pieceRegistrySource, i as packagePieces, it as bundleResolver, j as declaredReactorConnectionIds, l as hashOf, lt as authMethodFor, m as ActivepiecesBlockExecutor, mt as npmRegistryBaseUrl, n as installedPiece, nt as FileTooLargeError, o as errorNameOf, ot as sourcedResolver, p as effectiveRetryPolicy, q as containsRedactedMarker, r as installedPieces, rt as maxFileBytes, s as runWorkflow, t as PieceRegistry, tt as extractDedupeKey, u as stepConfigHash, ut as unsupportedAuth, v as storeHandlers, w as describeBuiltinPiece, x as unpinnedNote, y as blockLabel, z as secretRefFromId } from "./piece-registry-0pdOQQdk.js";
1
+ import { $ as isPrivateAddress, A as declaredConnectionIds, B as stepBlock, C as builtinPiece, D as AttachmentCache, E as CORE_PIECE_VERSION, G as PieceWorkerError, H as PieceWorkerPool, I as SecretDeletedError, J as redact, K as PieceWorkerTimeoutError, L as SecretNotFoundError, M as shapeConnection, N as resolveStepInput, O as BoundConnectionResolver, P as expressionsIn, Q as DEFAULT_EGRESS_POLICY, R as parseSecretRef, S as blockPorts, T as CORE_PIECE_NAME, U as PieceWorker, V as triggerBlock, W as PieceWorkerDisposedError, X as rememberSecrets, Y as redactMessage, Z as secretsFor, _ as resolvedBlock, _t as isIndeterminateError, at as pieceModuleRef, b as resolutionOf, c as canonicalJson, ct as UnsupportedPieceFeatureError, d as DynamicPropertiesError, dt as unsupportedTrigger, et as parseAddress, f as checkDynamicProperties, g as isHostBound, gt as setPieceRegistryUrl, h as CompositeBlockExecutor, ht as pieceRegistrySource, i as packagePieces, it as bundleResolver, j as declaredReactorConnectionIds, l as hashOf, lt as authMethodFor, m as ActivepiecesBlockExecutor, mt as npmRegistryBaseUrl, n as installedPiece, nt as FileTooLargeError, o as errorNameOf, ot as sourcedResolver, p as effectiveRetryPolicy, q as containsRedactedMarker, r as installedPieces, rt as maxFileBytes, s as runWorkflow, t as PieceRegistry, tt as extractDedupeKey, u as stepConfigHash, ut as unsupportedAuth, v as storeHandlers, w as describeBuiltinPiece, x as unpinnedNote, y as blockLabel, z as secretRefFromId } from "./piece-registry-CsBrnpGl.js";
2
2
  import { ReactorAccessDeniedError, ReactorAccessDeniedError as ReactorAccessDeniedError$1, ReactorActionsFailedError, ReactorJobFailedError, ReactorJobPendingError as ReactorJobPendingError$1, WebhookHandshakeStrategy } from "@powerhousedao/pieces-framework";
3
- import { createReadStream, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { mkdirSync, openAsBlob, readFileSync, writeFileSync } from "node:fs";
4
4
  import { open, readdir, rm, stat } from "node:fs/promises";
5
- import path, { dirname, join } from "node:path";
5
+ import { dirname, join } from "node:path";
6
6
  import { childLogger, generateId } from "document-model";
7
7
  import { DEFAULT_TIMEZONE, DOCUMENT_REF_KEY, ScheduleConfigError, checkTriggerStrategy, containsDocumentRef, documentRefsIn, expandDocumentRefs, isDocumentRefMarker, parseScheduleConfig, referenceDocuments } from "@powerhousedao/pieces-framework/workflow";
8
8
  import { Cron } from "croner";
9
9
  import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
10
- import { Readable } from "node:stream";
11
10
  import dns from "node:dns";
12
11
  import net from "node:net";
13
12
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -101,21 +100,6 @@ function npmVersions(name, options = {}) {
101
100
  //#endregion
102
101
  //#region src/reactor/attachment-port.ts
103
102
  const logger$7 = childLogger(["workflow", "attachments"]);
104
- function fileStream(filePath) {
105
- return Readable.toWeb(createReadStream(filePath));
106
- }
107
- async function sha256File(filePath) {
108
- const hash = createHash("sha256");
109
- for await (const chunk of createReadStream(filePath)) hash.update(chunk);
110
- return hash.digest("hex");
111
- }
112
- function refOf(result) {
113
- const direct = result.ref;
114
- if (typeof direct === "string") return direct;
115
- const nested = result.reservation?.ref;
116
- if (typeof nested === "string") return nested;
117
- throw new Error("The attachment store returned no reference for the upload");
118
- }
119
103
  async function writeCapped(body, destPath, limit) {
120
104
  const reader = body.getReader();
121
105
  const handle = await open(destPath, "w");
@@ -162,34 +146,19 @@ function createAttachmentPort(client, access) {
162
146
  throw new FileTooLargeError(header.sizeBytes, limit);
163
147
  }
164
148
  await writeCapped(body, destPath, limit);
165
- const contentType = header.mimeType !== void 0 && header.mimeType !== "" ? header.mimeType : void 0;
149
+ const contentType = header.mimeType !== "" ? header.mimeType : void 0;
166
150
  return {
167
151
  fileName: header.fileName,
168
152
  contentType
169
153
  };
170
154
  },
171
155
  async write(file, signal) {
172
- const hash = await sha256File(file.path);
173
- const mimeType = file.contentType ?? "application/octet-stream";
174
- const extension = path.extname(file.fileName).slice(1);
175
- const preprocessed = {
176
- ref: `attachment://v1:${hash}`,
177
- hash,
178
- sizeBytes: file.size,
179
- options: {
180
- mimeType,
181
- fileName: file.fileName,
182
- ...extension ? { extension } : {},
183
- clientHash: hash,
184
- sizeBytes: file.size
185
- },
186
- data: fileStream(file.path),
187
- stream: () => fileStream(file.path)
188
- };
189
- const ref = refOf(await client.upload({
190
- preprocessed,
156
+ const { ref } = await client.upload({
157
+ file: await openAsBlob(file.path),
158
+ fileName: file.fileName,
159
+ mimeType: file.contentType ?? "application/octet-stream",
191
160
  ...signal ? { signal } : {}
192
- }));
161
+ });
193
162
  access.onWritten?.(ref);
194
163
  logger$7.debug(`Ingested ${file.fileName} (${file.size} bytes) as ${ref}`);
195
164
  return ref;