@powerhousedao/reactor-workflow 6.2.3-dev.13 → 6.2.3-dev.14

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.
@@ -47,7 +47,7 @@ function findPiece(mod) {
47
47
  ...isRecord(mod.default) ? Object.values(mod.default) : [],
48
48
  mod.default
49
49
  ];
50
- for (const candidate of candidates) if (isRecord(candidate) && candidate.constructor.name === "Piece") return {
50
+ for (const candidate of candidates) if (isRecord(candidate) && candidate.constructor?.name === "Piece") return {
51
51
  piece: candidate,
52
52
  check: "constructor-name"
53
53
  };
@@ -166,4 +166,4 @@ function buildDescriptor(piece, source) {
166
166
  //#endregion
167
167
  export { loadPieceFromDir as i, describeProperties as n, loadPiece as r, buildDescriptor as t };
168
168
 
169
- //# sourceMappingURL=descriptor-DXbWuxhE.js.map
169
+ //# sourceMappingURL=descriptor-CRkDqx3C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor-CRkDqx3C.js","names":[],"sources":["../src/pieces/activepieces/loader.ts","../src/pieces/activepieces/descriptor.ts"],"sourcesContent":["import { readFileSync, realpathSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ApPiece } from \"./types.js\";\n\nexport interface LoadedPiece {\n piece: ApPiece;\n entryPath: string;\n // Which duck-type check identified the export.\n check: \"constructor-name\" | \"structural\";\n}\n\n// Resolves a bundle's entry file. Published bundles typically carry only\n// `main` (no `exports`, no `type` — they are CJS).\nexport function resolveEntry(pieceDir: string): string {\n const raw = readFileSync(path.join(pieceDir, \"package.json\"), \"utf8\");\n const pkg = JSON.parse(raw) as {\n main?: string;\n module?: string;\n exports?: Record<string, unknown>;\n };\n const dotExport = pkg.exports?.[\".\"];\n const candidates: (string | undefined)[] = [];\n if (typeof dotExport === \"string\") candidates.push(dotExport);\n if (dotExport && typeof dotExport === \"object\") {\n const cond = dotExport as Record<string, unknown>;\n for (const key of [\"import\", \"require\", \"default\"]) {\n const value = cond[key];\n if (typeof value === \"string\") candidates.push(value);\n }\n }\n candidates.push(pkg.main, pkg.module, \"src/index.js\", \"index.js\", \"main.js\");\n // A bundle's manifest (or a symlink inside it) must not point the entry\n // outside pieceDir; realpath so a symlink can't launder the escape.\n const root = realpathSync(pieceDir);\n const rootWithSep = root + path.sep;\n for (const candidate of candidates) {\n if (!candidate) continue;\n const abs = path.resolve(pieceDir, candidate);\n let real: string;\n try {\n real = realpathSync(abs);\n } catch {\n continue; // candidate doesn't exist; try the next one\n }\n if (real !== root && !real.startsWith(rootWithSep)) continue;\n return abs;\n }\n throw new Error(`No entry file found for piece bundle at ${pieceDir}`);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\n// Identify the piece by constructor name (their own loader's check), falling\n// back to structure for bundles minified without keepNames. No `instanceof`.\nfunction findPiece(\n mod: Record<string, unknown>,\n): Pick<LoadedPiece, \"piece\" | \"check\"> | undefined {\n const candidates: unknown[] = [\n ...Object.values(mod),\n ...(isRecord(mod.default) ? Object.values(mod.default) : []),\n mod.default,\n ];\n for (const candidate of candidates) {\n // `constructor?.name`: a bundle may export an Object.create(null), and the\n // real piece is usually beside it in the same module.\n if (isRecord(candidate) && candidate.constructor?.name === \"Piece\") {\n return {\n piece: candidate as unknown as ApPiece,\n check: \"constructor-name\",\n };\n }\n }\n for (const candidate of candidates) {\n if (\n isRecord(candidate) &&\n typeof candidate.displayName === \"string\" &&\n (isRecord(candidate.actions) ||\n typeof candidate.actions === \"function\" ||\n typeof candidate.getAction === \"function\")\n ) {\n return { piece: candidate as unknown as ApPiece, check: \"structural\" };\n }\n }\n return undefined;\n}\n\n// ESM-first `import()` — Node's CJS interop handles the typical CJS bundle —\n// with a `require` fallback.\nexport async function loadPiece(entryPath: string): Promise<LoadedPiece> {\n let mod: Record<string, unknown>;\n try {\n mod = (await import(\n /* @vite-ignore */ pathToFileURL(entryPath).href\n )) as Record<string, unknown>;\n } catch {\n const require = createRequire(import.meta.url);\n mod = require(entryPath) as Record<string, unknown>;\n }\n const found = findPiece(mod);\n if (!found) {\n throw new Error(\n `No Piece export found in ${entryPath}. Export keys: ${Object.keys(mod).join(\", \")}`,\n );\n }\n return { ...found, entryPath };\n}\n\nexport async function loadPieceFromDir(pieceDir: string): Promise<LoadedPiece> {\n return loadPiece(resolveEntry(pieceDir));\n}\n","import {\n getActions,\n getTriggers,\n type ApPiece,\n type ApProperty,\n type ApPropertyType,\n type ApDropdownOption,\n type ApTrigger,\n type ApTriggerStrategy,\n} from \"./types.js\";\n\nexport interface PiecePropDescriptor {\n name: string;\n displayName: string;\n description?: string;\n placeholder?: string;\n type: ApPropertyType;\n required: boolean;\n defaultValue?: unknown;\n // STATIC_DROPDOWN choices, extracted so the editor needs no runtime call.\n staticOptions?: ApDropdownOption[];\n // True when the prop carries a design-time resolver (DROPDOWN options() / DYNAMIC props()).\n hasDynamicResolver: boolean;\n // Synthesised domain-provider id: activepieces:<pkg>#<action>.<prop> (doc 08 §6.3).\n // Only top-level props get one; nested resolvers are not addressable yet.\n dynamicResolverId?: string;\n // Sibling prop names whose values feed the resolver; the editor re-runs\n // it when any of them changes.\n refreshers?: string[];\n // Nested shape: an ARRAY item's fields, or the props a DYNAMIC resolver\n // produced (see describeProperties). OBJECT props are free-form and carry none.\n properties?: PiecePropDescriptor[];\n}\n\nexport interface PieceActionDescriptor {\n name: string;\n displayName: string;\n description?: string;\n // UI metadata only — not a credential contract (spike finding).\n requireAuth: boolean;\n props: PiecePropDescriptor[];\n}\n\nexport interface PieceTriggerDescriptor {\n name: string;\n displayName: string;\n description?: string;\n strategy: ApTriggerStrategy;\n testStrategy?: string;\n requireAuth: boolean;\n props: PiecePropDescriptor[];\n hasSampleData: boolean;\n // How the sender proves the endpoint exists before it will register it.\n // Absent when the trigger declares no handshake, or declares NONE.\n handshake?: { strategy: string; paramName?: string };\n}\n\nexport interface PieceAuthDescriptor {\n type: ApPropertyType;\n displayName?: string;\n description?: string;\n required?: boolean;\n // CUSTOM_AUTH's own fields. Without them a connection form has nothing to\n // ask for, which is what a piece read from a package rather than a published\n // listing would otherwise leave the editor with.\n props?: PiecePropDescriptor[];\n}\n\n// NONE is how the framework spells \"no handshake\", so it is not carried:\n// a caller checking the field would otherwise have to know that too.\nfunction describeHandshake(\n trigger: ApTrigger,\n): { strategy: string; paramName?: string } | undefined {\n const strategy = trigger.handshakeConfiguration?.strategy;\n if (!strategy || strategy === \"NONE\") return undefined;\n return { strategy, paramName: trigger.handshakeConfiguration?.paramName };\n}\n\nexport interface PieceSource {\n packageName: string;\n version: string;\n}\n\n// Serializable descriptor of an adapted piece; the engine never learns\n// Activepieces exists (doc 08 §6.2).\nexport interface PieceDescriptor {\n id: string;\n source: PieceSource;\n displayName: string;\n description?: string;\n logoUrl?: string;\n categories?: string[];\n auth?: PieceAuthDescriptor;\n minimumSupportedRelease?: string;\n maximumSupportedRelease?: string;\n actions: PieceActionDescriptor[];\n triggers: PieceTriggerDescriptor[];\n}\n\nfunction hasResolver(prop: ApProperty): boolean {\n return typeof prop.options === \"function\" || typeof prop.props === \"function\";\n}\n\nfunction toPropDescriptor(\n name: string,\n prop: ApProperty,\n resolverId?: string,\n): PiecePropDescriptor {\n const dynamic = hasResolver(prop);\n const descriptor: PiecePropDescriptor = {\n name,\n displayName: prop.displayName ?? name,\n type: prop.type ?? \"UNKNOWN\",\n required: prop.required ?? false,\n hasDynamicResolver: dynamic,\n };\n if (typeof prop.description === \"string\" && prop.description !== \"\") {\n descriptor.description = prop.description;\n }\n if (typeof prop.placeholder === \"string\" && prop.placeholder !== \"\") {\n descriptor.placeholder = prop.placeholder;\n }\n if (prop.defaultValue !== undefined) {\n descriptor.defaultValue = prop.defaultValue;\n }\n if (dynamic && resolverId) {\n descriptor.dynamicResolverId = resolverId;\n }\n if (dynamic && Array.isArray(prop.refreshers)) {\n descriptor.refreshers = prop.refreshers.filter(\n (entry): entry is string => typeof entry === \"string\",\n );\n }\n if (typeof prop.options === \"object\" && Array.isArray(prop.options.options)) {\n descriptor.staticOptions = prop.options.options.map((o) => ({\n label: o.label,\n value: o.value,\n }));\n }\n if (prop.properties && typeof prop.properties === \"object\") {\n const nested = describeProperties(prop.properties);\n if (nested.length > 0) descriptor.properties = nested;\n }\n return descriptor;\n}\n\n// Descriptor list for a props map: nested ARRAY items and what a DYNAMIC\n// resolver returns, so the editor never sees raw piece properties.\nexport function describeProperties(\n props: Record<string, ApProperty> | null | undefined,\n resolverIdFor?: (propName: string) => string,\n): PiecePropDescriptor[] {\n if (!props || typeof props !== \"object\") return [];\n return Object.entries(props)\n .filter((entry): entry is [string, ApProperty] =>\n isPropertyObject(entry[1]),\n )\n .map(([propName, prop]) =>\n toPropDescriptor(propName, prop, resolverIdFor?.(propName)),\n );\n}\n\n// Bundles are duck-typed; a props map may carry non-object junk.\nfunction isPropertyObject(value: unknown): value is ApProperty {\n return value !== null && typeof value === \"object\";\n}\n\n// Pure translation over a loaded piece; performs no I/O and never executes\n// piece code beyond the actions()/triggers() accessors.\nexport function buildDescriptor(\n piece: ApPiece,\n source: PieceSource,\n): PieceDescriptor {\n const actions = Object.entries(getActions(piece)).map(\n ([actionName, action]): PieceActionDescriptor => ({\n name: action.name ?? actionName,\n displayName: action.displayName ?? actionName,\n description: action.description,\n requireAuth: action.requireAuth ?? false,\n props: describeProperties(\n action.props,\n (propName) =>\n `activepieces:${source.packageName}#${actionName}.${propName}`,\n ),\n }),\n );\n\n const triggers = Object.entries(getTriggers(piece)).map(\n ([triggerName, trigger]): PieceTriggerDescriptor => ({\n name: trigger.name ?? triggerName,\n displayName: trigger.displayName ?? triggerName,\n description: trigger.description,\n strategy: trigger.type ?? \"UNKNOWN\",\n testStrategy: trigger.testStrategy,\n requireAuth: trigger.requireAuth ?? false,\n props: describeProperties(\n trigger.props,\n (propName) =>\n `activepieces:${source.packageName}#${triggerName}.${propName}`,\n ),\n hasSampleData:\n trigger.sampleData !== undefined && trigger.sampleData !== null,\n handshake: describeHandshake(trigger),\n }),\n );\n\n const descriptor: PieceDescriptor = {\n id: `activepieces:${source.packageName}`,\n source,\n displayName: piece.displayName,\n description: piece.description,\n logoUrl: piece.logoUrl,\n categories: piece.categories,\n minimumSupportedRelease: piece.minimumSupportedRelease,\n maximumSupportedRelease: piece.maximumSupportedRelease,\n actions,\n triggers,\n };\n if (piece.auth && typeof piece.auth === \"object\") {\n // CUSTOM_AUTH carries a record here; a DYNAMIC prop would carry a\n // resolver function, which is not an auth shape at all.\n const authProps =\n piece.auth.props && typeof piece.auth.props === \"object\"\n ? describeProperties(piece.auth.props)\n : [];\n descriptor.auth = {\n type: piece.auth.type ?? \"UNKNOWN\",\n displayName: piece.auth.displayName,\n description: piece.auth.description,\n required: piece.auth.required,\n ...(authProps.length > 0 ? { props: authProps } : {}),\n };\n }\n return descriptor;\n}\n"],"mappings":";;;;;;AAeA,SAAgB,aAAa,UAA0B;CACrD,MAAM,MAAM,aAAa,KAAK,KAAK,UAAU,eAAe,EAAE,OAAO;CACrE,MAAM,MAAM,KAAK,MAAM,IAAI;CAK3B,MAAM,YAAY,IAAI,UAAU;CAChC,MAAM,aAAqC,EAAE;AAC7C,KAAI,OAAO,cAAc,SAAU,YAAW,KAAK,UAAU;AAC7D,KAAI,aAAa,OAAO,cAAc,UAAU;EAC9C,MAAM,OAAO;AACb,OAAK,MAAM,OAAO;GAAC;GAAU;GAAW;GAAU,EAAE;GAClD,MAAM,QAAQ,KAAK;AACnB,OAAI,OAAO,UAAU,SAAU,YAAW,KAAK,MAAM;;;AAGzD,YAAW,KAAK,IAAI,MAAM,IAAI,QAAQ,gBAAgB,YAAY,UAAU;CAG5E,MAAM,OAAO,aAAa,SAAS;CACnC,MAAM,cAAc,OAAO,KAAK;AAChC,MAAK,MAAM,aAAa,YAAY;AAClC,MAAI,CAAC,UAAW;EAChB,MAAM,MAAM,KAAK,QAAQ,UAAU,UAAU;EAC7C,IAAI;AACJ,MAAI;AACF,UAAO,aAAa,IA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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as EgressPolicy, _ as PieceWorker, a as AttachmentPort, c as ConnectionRequest, d as SecretStore, m as WorkflowRunResult, n as packagePieces, p as StepExecutionRecord, t as PieceRegistry, v as PieceWorkerResult, x as PieceResolver } from "./piece-registry-CE0UFmDA.js";
1
+ import { C as EgressPolicy, _ as PieceWorker, a as AttachmentPort, c as ConnectionRequest, d as SecretStore, m as WorkflowRunResult, n as packagePieces, p as StepExecutionRecord, t as PieceRegistry, v as PieceWorkerResult, x as PieceResolver } from "./piece-registry-DxYByELl.js";
2
2
  import { ActionBase, TriggerBase } from "@powerhousedao/pieces-framework";
3
3
  import { ILogger, OperationWithContext } from "document-model";
4
4
  import { BaseReadModel, DocumentViewDatabase, IConsistencyTracker, IOperationIndex, IReactorClient, IWriteCache, ReadModelRegistrationStage } from "@powerhousedao/reactor";