@powerhousedao/reactor-workflow 6.2.3-dev.17 → 6.2.3-dev.19
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/README.md +9 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -74
- package/dist/index.js.map +1 -1
- package/dist/{piece-registry-DxYByELl.d.ts → piece-registry-DWTQoft_.d.ts} +4 -2
- package/dist/piece-registry-DWTQoft_.d.ts.map +1 -0
- package/dist/{piece-registry-fpNdxNLr.js → piece-registry-WukyH-O-.js} +57 -16
- package/dist/piece-registry-WukyH-O-.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/worker-entry.js +8 -4
- package/dist/worker-entry.js.map +1 -1
- package/package.json +6 -6
- package/dist/piece-registry-DxYByELl.d.ts.map +0 -1
- package/dist/piece-registry-fpNdxNLr.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { _ as FileTooLargeError, a as redactMessage, c as DEFAULT_EGRESS_POLICY, f as extractDedupeKey, n as containsRedactedMarker, o as rememberSecrets, r as redact, s as secretsFor, y as maxFileBytes } from "./redact-C7LWgAyD.js";
|
|
2
|
-
import { C as pieceModuleRef, S as localFirstResolver, _ as secretRefFromId, a as CompositeBlockExecutor, b as PieceWorkerError, c as storeHandlers, d as declaredConnectionIds, f as shapeConnection, g as parseSecretRef, h as SecretNotFoundError, i as ActivepiecesBlockExecutor, l as BoundConnectionResolver, m as SecretDeletedError, n as packagePieces, o as parseBlockType, r as runWorkflow, s as reactorHandlers, t as PieceRegistry, v as PieceWorkerPool, w as ensurePieceBundle, x as PieceWorkerTimeoutError, y as PieceWorker } from "./piece-registry-
|
|
2
|
+
import { C as pieceModuleRef, D as setPieceRegistryUrl, E as pieceRegistrySource, S as localFirstResolver, _ as secretRefFromId, a as CompositeBlockExecutor, b as PieceWorkerError, c as storeHandlers, d as declaredConnectionIds, f as shapeConnection, g as parseSecretRef, h as SecretNotFoundError, i as ActivepiecesBlockExecutor, l as BoundConnectionResolver, m as SecretDeletedError, n as packagePieces, o as parseBlockType, r as runWorkflow, s as reactorHandlers, t as PieceRegistry, v as PieceWorkerPool, w as ensurePieceBundle, x as PieceWorkerTimeoutError, y as PieceWorker } from "./piece-registry-WukyH-O-.js";
|
|
3
3
|
import { WebhookHandshakeStrategy } from "@powerhousedao/pieces-framework";
|
|
4
4
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { open, readFile, rm } from "node:fs/promises";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
|
+
import { childLogger, createAction } from "document-model";
|
|
7
8
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, randomUUID } from "node:crypto";
|
|
8
9
|
import { Cron } from "croner";
|
|
9
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
|
-
import { childLogger, createAction } from "document-model";
|
|
11
11
|
import { actions } from "@powerhousedao/workflow/document-models/connection";
|
|
12
12
|
import { Kind, parse } from "graphql";
|
|
13
13
|
import { BaseReadModel, defaultReadModelIndexingConfig } from "@powerhousedao/reactor";
|
|
14
14
|
//#region src/reactor/attachment-port.ts
|
|
15
|
-
const logger$
|
|
15
|
+
const logger$5 = childLogger(["workflow", "attachments"]);
|
|
16
16
|
function refOf(result) {
|
|
17
17
|
const direct = result.ref;
|
|
18
18
|
if (typeof direct === "string") return direct;
|
|
@@ -71,7 +71,7 @@ function createAttachmentPort(client, documentIdFor, canReadRef) {
|
|
|
71
71
|
fileName: file.fileName,
|
|
72
72
|
mimeType: file.contentType
|
|
73
73
|
}));
|
|
74
|
-
logger$
|
|
74
|
+
logger$5.debug(`Ingested ${file.fileName} (${file.size} bytes) as ${ref}`);
|
|
75
75
|
return ref;
|
|
76
76
|
}
|
|
77
77
|
};
|
|
@@ -331,9 +331,6 @@ function documentEventTree(actionInputChildren) {
|
|
|
331
331
|
];
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
334
|
-
//#region src/reactor/first-party-logos.ts
|
|
335
|
-
const PAPERLESS_LOGO = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PHJlY3Qgd2lkdGg9IjQ4IiBoZWlnaHQ9IjQ4IiByeD0iOCIgZmlsbD0iIzE3NTQxZiIvPjxwYXRoIGQ9Ik0xNCAxMGgxM2w3IDd2MjFhMiAyIDAgMCAxLTIgMkgxNmEyIDIgMCAwIDEtMi0yVjEyYTIgMiAwIDAgMSAyLTJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZD0iTTI3IDEwbDcgN2gtN3oiIGZpbGw9IiM5ZmQzYTYiLz48ZyBmaWxsPSIjMTc1NDFmIj48cmVjdCB4PSIxOCIgeT0iMjIiIHdpZHRoPSIxNiIgaGVpZ2h0PSIyIiByeD0iMSIvPjxyZWN0IHg9IjE4IiB5PSIyNyIgd2lkdGg9IjE2IiBoZWlnaHQ9IjIiIHJ4PSIxIi8+PHJlY3QgeD0iMTgiIHk9IjMyIiB3aWR0aD0iMTAiIGhlaWdodD0iMiIgcng9IjEiLz48L2c+PC9zdmc+";
|
|
336
|
-
//#endregion
|
|
337
334
|
//#region src/reactor/unsupported-pieces.ts
|
|
338
335
|
const SERVER_ONLY_PIECES = new Set([
|
|
339
336
|
"@activepieces/piece-ai",
|
|
@@ -349,6 +346,7 @@ const SERVER_ONLY_PIECES = new Set([
|
|
|
349
346
|
//#region src/reactor/piece-catalog.ts
|
|
350
347
|
const CATALOG_URL = "https://cloud.activepieces.com/api/v1/pieces";
|
|
351
348
|
const CACHE_TTL_MS = 3600 * 1e3;
|
|
349
|
+
const logger$4 = childLogger(["workflow", "piece-catalog"]);
|
|
352
350
|
function aiLast(audience) {
|
|
353
351
|
return audience === "ai" ? 1 : 0;
|
|
354
352
|
}
|
|
@@ -360,69 +358,42 @@ async function fetchJson(url, timeoutMs = 3e4) {
|
|
|
360
358
|
if (!response.ok) throw new Error(`${url} responded ${response.status}`);
|
|
361
359
|
return response.json();
|
|
362
360
|
}
|
|
361
|
+
function asList(value) {
|
|
362
|
+
return Array.isArray(value) ? value : [];
|
|
363
|
+
}
|
|
364
|
+
function asError(reason) {
|
|
365
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
366
|
+
}
|
|
367
|
+
async function publishedLists(suggestions, timeoutMs) {
|
|
368
|
+
const source = pieceRegistrySource();
|
|
369
|
+
const cloudUrl = suggestions ? `${CATALOG_URL}?suggestionType=ACTION_AND_TRIGGER` : CATALOG_URL;
|
|
370
|
+
const [fromRegistry, fromCloud] = await Promise.allSettled([source ? fetchJson(source.catalogUrl(suggestions), timeoutMs) : Promise.resolve([]), fetchJson(cloudUrl, timeoutMs)]);
|
|
371
|
+
const registry = fromRegistry.status === "fulfilled" ? asList(fromRegistry.value).filter((entry) => typeof entry.name === "string") : [];
|
|
372
|
+
if (fromRegistry.status === "rejected") logger$4.warn(`Piece registry ${source?.baseUrl ?? "?"} did not answer: ${String(fromRegistry.reason)}`);
|
|
373
|
+
if (fromCloud.status === "rejected") {
|
|
374
|
+
if (registry.length === 0) throw asError(fromCloud.reason);
|
|
375
|
+
logger$4.warn(`Serving registry pieces only: ${String(fromCloud.reason)}`);
|
|
376
|
+
return {
|
|
377
|
+
registry,
|
|
378
|
+
cloud: []
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
return {
|
|
382
|
+
registry,
|
|
383
|
+
cloud: asList(fromCloud.value)
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function registryFirst(registry, cloud) {
|
|
387
|
+
const claimed = new Set(registry.map((entry) => entry.name));
|
|
388
|
+
return [...registry, ...cloud.filter((entry) => !claimed.has(entry.name))];
|
|
389
|
+
}
|
|
363
390
|
async function fetchCatalogWithSuggestions() {
|
|
364
|
-
const
|
|
365
|
-
return
|
|
391
|
+
const { registry, cloud } = await publishedLists(true, 12e4);
|
|
392
|
+
return registryFirst(registry, cloud);
|
|
366
393
|
}
|
|
367
394
|
let catalogCache;
|
|
368
|
-
|
|
369
|
-
name
|
|
370
|
-
displayName: "Paperless-ngx",
|
|
371
|
-
description: "Manage documents in a self-hosted paperless-ngx archive: upload, search, tag, and react to new documents.",
|
|
372
|
-
logoUrl: PAPERLESS_LOGO,
|
|
373
|
-
version: "0.1.0",
|
|
374
|
-
actionCount: 9,
|
|
375
|
-
triggerCount: 2,
|
|
376
|
-
categories: ["CONTENT_AND_FILES"],
|
|
377
|
-
auth: {
|
|
378
|
-
type: "CUSTOM_AUTH",
|
|
379
|
-
displayName: "paperless-ngx",
|
|
380
|
-
required: true,
|
|
381
|
-
props: {
|
|
382
|
-
base_url: {
|
|
383
|
-
type: "SHORT_TEXT",
|
|
384
|
-
displayName: "Base URL",
|
|
385
|
-
required: true,
|
|
386
|
-
description: "e.g. https://paperless.example.com — no trailing slash, no /api suffix"
|
|
387
|
-
},
|
|
388
|
-
token: {
|
|
389
|
-
type: "SECRET_TEXT",
|
|
390
|
-
displayName: "API Token",
|
|
391
|
-
required: true,
|
|
392
|
-
description: "paperless web UI -> My Profile -> API Token"
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}, {
|
|
397
|
-
name: "@powerhousedao/piece-docling",
|
|
398
|
-
displayName: "Docling",
|
|
399
|
-
description: "Convert documents (PDF, DOCX, PPTX, images, HTML, …) to Markdown, docling-document JSON, HTML, DocTags and plain text via a docling-serve v1 API (self-hosted or Docling for IBM watsonx).",
|
|
400
|
-
logoUrl: "data:image/svg+xml," + encodeURIComponent("<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 48 48\"><rect width=\"48\" height=\"48\" rx=\"10\" fill=\"#1e3a8a\"/><path d=\"M14 10h14l8 8v20a2 2 0 0 1-2 2H14a2 2 0 0 1-2-2V12a2 2 0 0 1 2-2z\" fill=\"#fff\"/><path d=\"M28 10v8h8\" fill=\"none\" stroke=\"#1e3a8a\" stroke-width=\"2\"/><path d=\"M18 24h12M18 29h12M18 34h8\" stroke=\"#1e3a8a\" stroke-width=\"2\"/></svg>"),
|
|
401
|
-
version: "1.0.0",
|
|
402
|
-
actionCount: 6,
|
|
403
|
-
triggerCount: 0,
|
|
404
|
-
categories: ["CONTENT_AND_FILES"],
|
|
405
|
-
auth: {
|
|
406
|
-
type: "CUSTOM_AUTH",
|
|
407
|
-
displayName: "Docling Serve",
|
|
408
|
-
required: true,
|
|
409
|
-
props: {
|
|
410
|
-
base_url: {
|
|
411
|
-
type: "SHORT_TEXT",
|
|
412
|
-
displayName: "Service URL",
|
|
413
|
-
required: true
|
|
414
|
-
},
|
|
415
|
-
api_key: {
|
|
416
|
-
type: "SECRET_TEXT",
|
|
417
|
-
displayName: "API Key",
|
|
418
|
-
required: false
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}];
|
|
423
|
-
async function fetchPieceCatalog() {
|
|
424
|
-
if (catalogCache && catalogCache.expiresAt > Date.now()) return catalogCache.value;
|
|
425
|
-
const cloud = (await fetchJson(CATALOG_URL)).filter((entry) => typeof entry.name === "string" && typeof entry.version === "string" && !SERVER_ONLY_PIECES.has(entry.name) && (typeof entry.actions === "number" && entry.actions > 0 || typeof entry.triggers === "number" && entry.triggers > 0)).map((entry) => ({
|
|
395
|
+
function toSummaries(raw) {
|
|
396
|
+
return raw.filter((entry) => typeof entry.name === "string" && typeof entry.version === "string" && !SERVER_ONLY_PIECES.has(entry.name) && (typeof entry.actions === "number" && entry.actions > 0 || typeof entry.triggers === "number" && entry.triggers > 0)).map((entry) => ({
|
|
426
397
|
name: entry.name,
|
|
427
398
|
displayName: entry.displayName ?? entry.name,
|
|
428
399
|
description: entry.description ?? "",
|
|
@@ -433,20 +404,31 @@ async function fetchPieceCatalog() {
|
|
|
433
404
|
categories: entry.categories ?? [],
|
|
434
405
|
auth: entry.auth ?? null
|
|
435
406
|
}));
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
407
|
+
}
|
|
408
|
+
async function fetchPieceCatalog() {
|
|
409
|
+
if (catalogCache && catalogCache.expiresAt > Date.now()) return catalogCache.value;
|
|
410
|
+
const lists = await publishedLists(false, 3e4);
|
|
411
|
+
const value = [...registryFirst(toSummaries(lists.registry), toSummaries(lists.cloud))].sort((a, b) => a.displayName.localeCompare(b.displayName));
|
|
439
412
|
catalogCache = {
|
|
440
413
|
value,
|
|
441
414
|
expiresAt: Date.now() + CACHE_TTL_MS
|
|
442
415
|
};
|
|
443
416
|
return value;
|
|
444
417
|
}
|
|
418
|
+
async function fetchPieceJson(packageName) {
|
|
419
|
+
const source = pieceRegistrySource();
|
|
420
|
+
if (source) try {
|
|
421
|
+
return await fetchJson(source.pieceUrl(packageName));
|
|
422
|
+
} catch (error) {
|
|
423
|
+
logger$4.debug(`${source.baseUrl} does not serve "${packageName}": ${String(error)}`);
|
|
424
|
+
}
|
|
425
|
+
return fetchJson(pieceUrl(packageName));
|
|
426
|
+
}
|
|
445
427
|
const detailCache = /* @__PURE__ */ new Map();
|
|
446
428
|
async function fetchPieceDetail(packageName) {
|
|
447
429
|
const cached = detailCache.get(packageName);
|
|
448
430
|
if (cached && cached.expiresAt > Date.now()) return cached.value;
|
|
449
|
-
const value = await
|
|
431
|
+
const value = await fetchPieceJson(packageName);
|
|
450
432
|
detailCache.set(packageName, {
|
|
451
433
|
value,
|
|
452
434
|
expiresAt: Date.now() + CACHE_TTL_MS
|
|
@@ -457,7 +439,7 @@ const triggersCache = /* @__PURE__ */ new Map();
|
|
|
457
439
|
async function fetchPieceTriggers(packageName) {
|
|
458
440
|
const cached = triggersCache.get(packageName);
|
|
459
441
|
if (cached && cached.expiresAt > Date.now()) return cached.value;
|
|
460
|
-
const detail = await
|
|
442
|
+
const detail = await fetchPieceJson(packageName);
|
|
461
443
|
const version = detail.version ?? "";
|
|
462
444
|
const triggersRecord = detail.triggers && typeof detail.triggers === "object" ? detail.triggers : {};
|
|
463
445
|
const triggers = Object.entries(triggersRecord).map(([name, trigger]) => ({
|
|
@@ -484,7 +466,7 @@ const actionsCache = /* @__PURE__ */ new Map();
|
|
|
484
466
|
async function fetchPieceActions(packageName) {
|
|
485
467
|
const cached = actionsCache.get(packageName);
|
|
486
468
|
if (cached && cached.expiresAt > Date.now()) return cached.value;
|
|
487
|
-
const detail = await
|
|
469
|
+
const detail = await fetchPieceJson(packageName);
|
|
488
470
|
const version = detail.version ?? "";
|
|
489
471
|
const actionsRecord = detail.actions && typeof detail.actions === "object" ? detail.actions : {};
|
|
490
472
|
const actions = Object.entries(actionsRecord).map(([name, action]) => ({
|
|
@@ -3752,6 +3734,6 @@ var WorkflowTriggersReadModel = class extends BaseReadModel {
|
|
|
3752
3734
|
}
|
|
3753
3735
|
};
|
|
3754
3736
|
//#endregion
|
|
3755
|
-
export { PieceRegistry, WORKFLOW_PACKAGE_NAME, WORKFLOW_TRIGGERS_READ_MODEL, WORKFLOW_TRIGGERS_READ_MODEL_STAGE, WorkflowRuntimeService, WorkflowTriggersReadModel, createAttachmentPort, createWorkflowRuntime, packagePieces };
|
|
3737
|
+
export { PieceRegistry, WORKFLOW_PACKAGE_NAME, WORKFLOW_TRIGGERS_READ_MODEL, WORKFLOW_TRIGGERS_READ_MODEL_STAGE, WorkflowRuntimeService, WorkflowTriggersReadModel, createAttachmentPort, createWorkflowRuntime, packagePieces, setPieceRegistryUrl };
|
|
3756
3738
|
|
|
3757
3739
|
//# sourceMappingURL=index.js.map
|