@powerhousedao/reactor-workflow 6.2.3-dev.19 → 6.2.3-dev.21
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 +67 -16
- package/dist/{descriptor-CRkDqx3C.js → descriptor-Doax7KPd.js} +19 -5
- package/dist/descriptor-Doax7KPd.js.map +1 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +380 -61
- package/dist/index.js.map +1 -1
- package/dist/{piece-registry-DWTQoft_.d.ts → piece-registry-BH39cD-k.d.ts} +30 -9
- package/dist/piece-registry-BH39cD-k.d.ts.map +1 -0
- package/dist/{piece-registry-WukyH-O-.js → piece-registry-lsGsY9fT.js} +178 -35
- package/dist/piece-registry-lsGsY9fT.js.map +1 -0
- package/dist/{redact-C7LWgAyD.js → redact-ChAU8USo.js} +16 -12
- package/dist/redact-ChAU8USo.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -3
- package/dist/worker-entry.js +6 -3
- package/dist/worker-entry.js.map +1 -1
- package/package.json +6 -6
- package/dist/descriptor-CRkDqx3C.js.map +0 -1
- package/dist/piece-registry-DWTQoft_.d.ts.map +0 -1
- package/dist/piece-registry-WukyH-O-.js.map +0 -1
- package/dist/redact-C7LWgAyD.js.map +0 -1
package/README.md
CHANGED
|
@@ -103,6 +103,67 @@ in-memory secret and connection resolvers. It is what a piece author's own
|
|
|
103
103
|
package uses to run its piece the way this reactor will, without standing up a
|
|
104
104
|
reactor to do it.
|
|
105
105
|
|
|
106
|
+
## Configuration
|
|
107
|
+
|
|
108
|
+
Everything the engine itself reads from the environment is prefixed
|
|
109
|
+
`PH_WORKFLOWS_`, and every one of these is declared under `config` in
|
|
110
|
+
[`packages/workflow/powerhouse.manifest.json`](../workflow/powerhouse.manifest.json)
|
|
111
|
+
— that manifest is the published surface a host reads, this table is the
|
|
112
|
+
explanation behind it.
|
|
113
|
+
|
|
114
|
+
| Variable | Default | What it sets |
|
|
115
|
+
| ------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------- |
|
|
116
|
+
| `PH_WORKFLOWS_SECRETS_MASTER_KEY` | generated key file | 64 hex chars (32 bytes) encrypting connection secrets at rest (`reactor/secret-store.ts`) |
|
|
117
|
+
| `PH_WORKFLOWS_EGRESS_ALLOW_ADDRESSES` | unset | Addresses or CIDRs a piece may reach, widening the default policy (`reactor/lib.ts`) |
|
|
118
|
+
| `PH_WORKFLOWS_RUN_CONCURRENCY` | `4` | Runs executing at once; one forked node child each (`worker/pool.ts`) |
|
|
119
|
+
| `PH_WORKFLOWS_RUN_QUEUE_DEPTH` | `0` | Runs that may wait for a slot before new ones are refused; `0` waits without limit |
|
|
120
|
+
| `PH_WORKFLOWS_POLL_INTERVAL_MS` | `60000` | Cadence for a polling trigger that names none of its own |
|
|
121
|
+
| `PH_WORKFLOWS_WEBHOOK_RECONCILE_MS` | `900000` | How often a webhook trigger re-registers with its provider |
|
|
122
|
+
| `PH_WORKFLOWS_WEBHOOK_TIMEOUT_MS` | `30000` | How long a sync-mode delivery holds the provider's socket |
|
|
123
|
+
| `PH_WORKFLOWS_PIECE_MAX_FILE_BYTES` | `8388608` | File-size ceiling for FILE-property hydration and `ctx.files.write` |
|
|
124
|
+
|
|
125
|
+
Each numeric one parses as `Number(raw) || default`: a value that is not a
|
|
126
|
+
positive number falls back silently rather than failing at boot.
|
|
127
|
+
|
|
128
|
+
One of them carries a caveat worth knowing before a deployment depends on it.
|
|
129
|
+
**The secrets key is not optional in production.** Unset, `loadKey` generates
|
|
130
|
+
`./.ph/secrets.key` — relative to the working directory, like the bundle cache
|
|
131
|
+
and the attachment staging dir. A host whose working directory does not survive
|
|
132
|
+
a restart comes back with a new key, and every stored connection secret is
|
|
133
|
+
undecryptable.
|
|
134
|
+
|
|
135
|
+
Only the host process reads any of these. The worker child is forked with an
|
|
136
|
+
empty environment, so the two settings it enforces travel on the wire instead:
|
|
137
|
+
the egress policy is compiled per request in the child, and the file ceiling is
|
|
138
|
+
stamped onto every request in `PieceWorker.execute` and installed by the child
|
|
139
|
+
before it dispatches.
|
|
140
|
+
|
|
141
|
+
### From the host
|
|
142
|
+
|
|
143
|
+
Workflows are turned on by switchboard, not here: `PH_WORKFLOWS_ENABLED`
|
|
144
|
+
(`"1"`/`"0"`/`"true"`/`"false"`), which loses to the host's own `workflows`
|
|
145
|
+
option and wins over `workflows.enabled` in `powerhouse.config.json`. Two more
|
|
146
|
+
switchboard-side settings shape what the runtime can do, and keep their own
|
|
147
|
+
names because they are not workflow settings:
|
|
148
|
+
|
|
149
|
+
- `PH_REGISTRY_URL` — or `packageRegistryUrl` in `powerhouse.config.json`. See
|
|
150
|
+
the paragraph below.
|
|
151
|
+
- `PUBLIC_URL` (then `RENDER_EXTERNAL_URL`, then
|
|
152
|
+
`HEROKU_APP_DEFAULT_DOMAIN_NAME`) — the origin a minted webhook URL carries.
|
|
153
|
+
Unset, endpoints are advertised as `http://localhost:<port>`, which is not
|
|
154
|
+
something a provider can call. This is **not** `PH_SWITCHBOARD_PUBLIC_URL`,
|
|
155
|
+
which sets the attachment service base URL instead.
|
|
156
|
+
|
|
157
|
+
Pieces are also read from the registry the host installs packages from —
|
|
158
|
+
`packageRegistryUrl` in `powerhouse.config.json`, or `PH_REGISTRY_URL`. It
|
|
159
|
+
serves the same list, detail and bundle endpoints cloud.activepieces.com and
|
|
160
|
+
its CDN do, and is read ahead of both: its listing merges into the catalog and
|
|
161
|
+
into block search, and its tarball is the first download source tried. A host
|
|
162
|
+
that installs packages from no registry reads the Activepieces CDN and npm
|
|
163
|
+
only. There is no second setting: a package installed from that registry
|
|
164
|
+
already ships pieces that run in the worker, so a bundle fetched from it is no
|
|
165
|
+
more trusted than one that arrived inside a package.
|
|
166
|
+
|
|
106
167
|
## Running the tests
|
|
107
168
|
|
|
108
169
|
```sh
|
|
@@ -115,22 +176,12 @@ suites that need one skip when it cannot be fetched, so the offline run is
|
|
|
115
176
|
smaller but green. Two suites need the docling piece's own package checked out
|
|
116
177
|
beside this repo, and skip otherwise.
|
|
117
178
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
to a local mock service widens it.
|
|
125
|
-
Pieces are also read from the registry the host installs packages from —
|
|
126
|
-
`packageRegistryUrl` in `powerhouse.config.json`, or `PH_REGISTRY_URL`. It
|
|
127
|
-
serves the same list, detail and bundle endpoints cloud.activepieces.com and
|
|
128
|
-
its CDN do, and is read ahead of both: its listing merges into the catalog and
|
|
129
|
-
into block search, and its tarball is the first download source tried. A host
|
|
130
|
-
that installs packages from no registry reads the Activepieces CDN and npm
|
|
131
|
-
only. There is no second setting: a package installed from that registry
|
|
132
|
-
already ships pieces that run in the worker, so a bundle fetched from it is no
|
|
133
|
-
more trusted than one that arrived inside a package.
|
|
179
|
+
The suites set the variables above themselves where they need to — a mock
|
|
180
|
+
service on loopback is reached by widening
|
|
181
|
+
`PH_WORKFLOWS_EGRESS_ALLOW_ADDRESSES`, and the secret-store suites set a master
|
|
182
|
+
key so no run picks up a developer's key file. The two live piece suites read
|
|
183
|
+
`DOCLING_E2E_URL` / `DOCLING_E2E_API_KEY` and `PAPERLESS_E2E_URL` /
|
|
184
|
+
`PAPERLESS_E2E_USER` / `PAPERLESS_E2E_PASSWORD`, and skip when unset.
|
|
134
185
|
|
|
135
186
|
## Design documents
|
|
136
187
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as getActions, V as getTriggers } from "./redact-ChAU8USo.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { readFileSync, realpathSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -56,6 +56,12 @@ function findPiece(mod) {
|
|
|
56
56
|
check: "structural"
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
+
function missingModule(entryPath, error) {
|
|
60
|
+
const code = error?.code;
|
|
61
|
+
if (code !== "ERR_MODULE_NOT_FOUND" && code !== "MODULE_NOT_FOUND") return;
|
|
62
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
63
|
+
return /* @__PURE__ */ new Error(`Piece at ${entryPath} could not be loaded: it imports a module that is not there. Its dependencies are installed with lifecycle scripts disabled, so one that compiles or downloads on install -- a native addon, a browser download -- cannot be prepared here. ${detail}`);
|
|
64
|
+
}
|
|
59
65
|
async function loadPiece(entryPath) {
|
|
60
66
|
let mod;
|
|
61
67
|
try {
|
|
@@ -63,8 +69,12 @@ async function loadPiece(entryPath) {
|
|
|
63
69
|
/* @vite-ignore */
|
|
64
70
|
pathToFileURL(entryPath).href
|
|
65
71
|
);
|
|
66
|
-
} catch {
|
|
67
|
-
|
|
72
|
+
} catch (imported) {
|
|
73
|
+
try {
|
|
74
|
+
mod = createRequire(import.meta.url)(entryPath);
|
|
75
|
+
} catch (required) {
|
|
76
|
+
throw missingModule(entryPath, imported) ?? missingModule(entryPath, required) ?? required;
|
|
77
|
+
}
|
|
68
78
|
}
|
|
69
79
|
const found = findPiece(mod);
|
|
70
80
|
if (!found) throw new Error(`No Piece export found in ${entryPath}. Export keys: ${Object.keys(mod).join(", ")}`);
|
|
@@ -126,7 +136,9 @@ function buildDescriptor(piece, source) {
|
|
|
126
136
|
displayName: action.displayName ?? actionName,
|
|
127
137
|
description: action.description,
|
|
128
138
|
requireAuth: action.requireAuth ?? false,
|
|
129
|
-
props: describeProperties(action.props, (propName) => `activepieces:${source.packageName}#${actionName}.${propName}`)
|
|
139
|
+
props: describeProperties(action.props, (propName) => `activepieces:${source.packageName}#${actionName}.${propName}`),
|
|
140
|
+
...action.outputSchema !== void 0 ? { outputSchema: action.outputSchema } : {},
|
|
141
|
+
...action.audience !== void 0 ? { audience: action.audience } : {}
|
|
130
142
|
}));
|
|
131
143
|
const triggers = Object.entries(getTriggers(piece)).map(([triggerName, trigger]) => ({
|
|
132
144
|
name: trigger.name ?? triggerName,
|
|
@@ -136,7 +148,9 @@ function buildDescriptor(piece, source) {
|
|
|
136
148
|
testStrategy: trigger.testStrategy,
|
|
137
149
|
requireAuth: trigger.requireAuth ?? false,
|
|
138
150
|
props: describeProperties(trigger.props, (propName) => `activepieces:${source.packageName}#${triggerName}.${propName}`),
|
|
151
|
+
...trigger.outputSchema !== void 0 ? { outputSchema: trigger.outputSchema } : {},
|
|
139
152
|
hasSampleData: trigger.sampleData !== void 0 && trigger.sampleData !== null,
|
|
153
|
+
...trigger.sampleData !== void 0 && trigger.sampleData !== null ? { sampleData: trigger.sampleData } : {},
|
|
140
154
|
handshake: describeHandshake(trigger)
|
|
141
155
|
}));
|
|
142
156
|
const descriptor = {
|
|
@@ -166,4 +180,4 @@ function buildDescriptor(piece, source) {
|
|
|
166
180
|
//#endregion
|
|
167
181
|
export { loadPieceFromDir as i, describeProperties as n, loadPiece as r, buildDescriptor as t };
|
|
168
182
|
|
|
169
|
-
//# sourceMappingURL=descriptor-
|
|
183
|
+
//# sourceMappingURL=descriptor-Doax7KPd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-Doax7KPd.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// A module the piece names and node cannot find. Dependencies are installed\n// with scripts disabled, so a native or downloaded one looks like this.\nfunction missingModule(entryPath: string, error: unknown): Error | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\" && code !== \"MODULE_NOT_FOUND\") {\n return undefined;\n }\n const detail = error instanceof Error ? error.message : String(error);\n return new Error(\n `Piece at ${entryPath} could not be loaded: it imports a module that is ` +\n `not there. Its dependencies are installed with lifecycle scripts ` +\n `disabled, so one that compiles or downloads on install -- a native ` +\n `addon, a browser download -- cannot be prepared here. ${detail}`,\n );\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 (imported) {\n try {\n const require = createRequire(import.meta.url);\n mod = require(entryPath) as Record<string, unknown>;\n } catch (required) {\n // The import's error names the missing module; require's often names\n // only the entry it was handed.\n throw (\n missingModule(entryPath, imported) ??\n missingModule(entryPath, required) ??\n required\n );\n }\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 // Carried verbatim: it is what the expression picker builds a later step's\n // field list from, and a package piece has no published listing to read.\n outputSchema?: unknown;\n // Orders the action picker, so a package piece that declares it must be\n // ordered by it too rather than counting as unset.\n audience?: string;\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 outputSchema?: unknown;\n hasSampleData: boolean;\n // The sample itself, not just whether there is one: a trigger that declares\n // no outputSchema is read for its shape instead.\n sampleData?: unknown;\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 ...(action.outputSchema !== undefined\n ? { outputSchema: action.outputSchema }\n : {}),\n ...(action.audience !== undefined ? { audience: action.audience } : {}),\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 ...(trigger.outputSchema !== undefined\n ? { outputSchema: trigger.outputSchema }\n : {}),\n hasSampleData:\n trigger.sampleData !== undefined && trigger.sampleData !== null,\n ...(trigger.sampleData !== undefined && trigger.sampleData !== null\n ? { sampleData: trigger.sampleData }\n : {}),\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,IAAI;UAClB;AACN;;AAEF,MAAI,SAAS,QAAQ,CAAC,KAAK,WAAW,YAAY,CAAE;AACpD,SAAO;;AAET,OAAM,IAAI,MAAM,2CAA2C,WAAW;;AAGxE,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU;;AAKhD,SAAS,UACP,KACkD;CAClD,MAAM,aAAwB;EAC5B,GAAG,OAAO,OAAO,IAAI;EACrB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,MAAM,QAAQ,OAAO,MAAM,SAAS,UAAU;EAGhD,MAAM,YACJ,MAAM,KAAK,SAAS,OAAO,MAAM,KAAK,UAAU,WAC5C,mBAAmB,MAAM,KAAK,MAAM,GACpC,EAAE;AACR,aAAW,OAAO;GAChB,MAAM,MAAM,KAAK,QAAQ;GACzB,aAAa,MAAM,KAAK;GACxB,aAAa,MAAM,KAAK;GACxB,UAAU,MAAM,KAAK;GACrB,GAAI,UAAU,SAAS,IAAI,EAAE,OAAO,WAAW,GAAG,EAAE;GACrD;;AAEH,QAAO"}
|
package/dist/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-
|
|
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-BH39cD-k.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";
|
|
@@ -295,6 +295,8 @@ declare class TriggerSupervisor {
|
|
|
295
295
|
private readonly enableRetries;
|
|
296
296
|
upsert(binding: TriggerBinding): Promise<void>;
|
|
297
297
|
remove(workflowId: string): Promise<void>;
|
|
298
|
+
reject(workflowId: string, blockType: string, config: unknown, message: string, retryAt?: Date): Promise<void>;
|
|
299
|
+
private recordRejection;
|
|
298
300
|
test(binding: PieceTriggerBinding): Promise<unknown>;
|
|
299
301
|
private dropTestPartitions;
|
|
300
302
|
handshake(binding: PieceTriggerBinding, payload: unknown): Promise<PieceWorkerResult>;
|
|
@@ -376,6 +378,13 @@ declare class WorkflowRuntimeService {
|
|
|
376
378
|
private registerWebhook;
|
|
377
379
|
private supervisedBinding;
|
|
378
380
|
private pieceBinding;
|
|
381
|
+
private resolveBlockType;
|
|
382
|
+
private resolvedBlock;
|
|
383
|
+
private readonly unarmed;
|
|
384
|
+
private reportUnarmedTrigger;
|
|
385
|
+
private readonly resolutionRetries;
|
|
386
|
+
private scheduleResolutionRetry;
|
|
387
|
+
private cancelResolutionRetry;
|
|
379
388
|
private dropSupervised;
|
|
380
389
|
private refreshRegistration;
|
|
381
390
|
private readonly seenOps;
|
|
@@ -434,7 +443,12 @@ declare class WorkflowRuntimeService {
|
|
|
434
443
|
run(runId: string, ctx?: WorkflowCaller): Promise<RunRecord | null>;
|
|
435
444
|
connections(ctx?: WorkflowCaller): Promise<ConnectionSummary[]>;
|
|
436
445
|
checkConnection(connectionId: string, ctx?: WorkflowCaller): Promise<ConnectionCheckResult>;
|
|
446
|
+
private readonly versionMisses;
|
|
447
|
+
private readonly versionLookups;
|
|
437
448
|
private pieceVersion;
|
|
449
|
+
private startVersionLookup;
|
|
450
|
+
private boundedLookup;
|
|
451
|
+
private lookUpPieceVersion;
|
|
438
452
|
private recordCheckResult;
|
|
439
453
|
private localPieces;
|
|
440
454
|
private localPiece;
|