@powerhousedao/reactor-workflow 6.2.3-dev.23 → 6.2.3-dev.25
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 +108 -0
- package/dist/{descriptor-Doax7KPd.js → descriptor-CtMB-wPx.js} +28 -13
- package/dist/descriptor-CtMB-wPx.js.map +1 -0
- package/dist/index.d.ts +61 -56
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +155 -110
- package/dist/index.js.map +1 -1
- package/dist/{piece-registry-lsGsY9fT.js → piece-registry-CAS4wiSA.js} +29 -7
- package/dist/piece-registry-CAS4wiSA.js.map +1 -0
- package/dist/{piece-registry-BH39cD-k.d.ts → piece-registry-D6dvy2OD.d.ts} +23 -38
- package/dist/piece-registry-D6dvy2OD.d.ts.map +1 -0
- package/dist/{redact-ChAU8USo.js → redact-DM3JhxdF.js} +50 -4
- package/dist/redact-DM3JhxdF.js.map +1 -0
- package/dist/testing.d.ts +37 -2
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/worker-entry.d.ts +2 -1
- package/dist/worker-entry.js +142 -51
- package/dist/worker-entry.js.map +1 -1
- package/package.json +8 -8
- package/dist/descriptor-Doax7KPd.js.map +0 -1
- package/dist/piece-registry-BH39cD-k.d.ts.map +0 -1
- package/dist/piece-registry-lsGsY9fT.js.map +0 -1
- package/dist/redact-ChAU8USo.js.map +0 -1
package/README.md
CHANGED
|
@@ -51,6 +51,15 @@ rather than restated here.
|
|
|
51
51
|
`apfile://` refs, the size ceiling and a host-injected fetcher have no
|
|
52
52
|
upstream equivalent. An `ApFile` a processor builds is flattened to a plain
|
|
53
53
|
object at that boundary: a class instance does not survive the worker IPC.
|
|
54
|
+
- **Prop validation**, from the same place. Before an action's `run()` or any
|
|
55
|
+
trigger hook but `onDisable`, a prop left unset takes its `defaultValue` and
|
|
56
|
+
the coerced values go through the engine's `validateProperty`. A failure is
|
|
57
|
+
a `PropsValidationError` naming each field, as in
|
|
58
|
+
`Title (title): Expected string, received: undefined`; the step fails and
|
|
59
|
+
piece code never runs. Two departures: a JSON or OBJECT prop whose text does
|
|
60
|
+
not parse reaches the piece as that text, as coercion already hands it on;
|
|
61
|
+
and every declared prop is checked, so a required one absent from the input
|
|
62
|
+
fails, where upstream's processor checks only the keys it was given.
|
|
54
63
|
- **The SSRF table**, likewise from `./host`. `worker/egress.ts` classifies an
|
|
55
64
|
address with `ssrfIpClassifier.isBlockedIp`; the connect-time socket and DNS
|
|
56
65
|
hooks, the per-request policy and the allow-lists are ours. The one range the
|
|
@@ -164,6 +173,94 @@ only. There is no second setting: a package installed from that registry
|
|
|
164
173
|
already ships pieces that run in the worker, so a bundle fetched from it is no
|
|
165
174
|
more trusted than one that arrived inside a package.
|
|
166
175
|
|
|
176
|
+
## Known missing features
|
|
177
|
+
|
|
178
|
+
This is what a piece can declare or call that this engine does not run. It is tracked in
|
|
179
|
+
[#3081](https://github.com/powerhouse-inc/powerhouse/issues/3081),
|
|
180
|
+
[#3090](https://github.com/powerhouse-inc/powerhouse/issues/3090),
|
|
181
|
+
[#3091](https://github.com/powerhouse-inc/powerhouse/issues/3091) and
|
|
182
|
+
[#3095](https://github.com/powerhouse-inc/powerhouse/issues/3095).
|
|
183
|
+
|
|
184
|
+
Some are **rejected** rather than run wrongly. A rejected feature is refused
|
|
185
|
+
wherever a user meets it: the catalog, `pieceActions`, `pieceTriggers` and
|
|
186
|
+
block search carry the reason as `unsupported`, and the editor lists the
|
|
187
|
+
block disabled; `blockDescriptor` throws `Piece "<name>": <reason>` (or
|
|
188
|
+
`Trigger "<name>" of "<piece>": <reason>`); enabling a trigger parks it in
|
|
189
|
+
`ERROR` with that message and no retry; a step or hook that reaches the
|
|
190
|
+
worker anyway fails before piece code runs, except `onDisable`, which still
|
|
191
|
+
releases what an earlier enable registered. The reason reads
|
|
192
|
+
`<feature> is not supported yet (<issue URL>)`.
|
|
193
|
+
|
|
194
|
+
**Triggers**
|
|
195
|
+
|
|
196
|
+
- `TriggerStrategy.APP_WEBHOOK` and `context.app.createListeners`: the
|
|
197
|
+
listeners are never read, so deliveries are refused (#3081).
|
|
198
|
+
- `renewConfiguration` / `onRenew`: rejected when the strategy is not
|
|
199
|
+
`NONE`, as `renewConfiguration` (#3090).
|
|
200
|
+
- `TriggerStrategy.MANUAL` on a piece trigger: rejected, as
|
|
201
|
+
`TriggerStrategy.MANUAL` (#3091). The engine's own `core#manual` is not a
|
|
202
|
+
piece trigger and is unaffected.
|
|
203
|
+
- Every `WEBHOOK` trigger's `run()` is called every 15 minutes without a
|
|
204
|
+
`payload`, as a reconciliation sweep. A `run` that only maps the delivery
|
|
205
|
+
either fails or fires a spurious run (#3090).
|
|
206
|
+
- `setSchedule({ cronExpression })` is run as a fixed interval; wall-clock
|
|
207
|
+
time and timezone are lost.
|
|
208
|
+
- `onStart` is never called. The trigger context's `server` is a throwing stub.
|
|
209
|
+
- Outside a delivery a hook's `payload` is `undefined`; upstream passes `{}`
|
|
210
|
+
(#3090).
|
|
211
|
+
- A webhook payload carries no raw body, and its signature headers
|
|
212
|
+
(`x-signature`, `x-hub-signature-256`, `stripe-signature`, `authorization`)
|
|
213
|
+
arrive redacted, so `run()` cannot verify the sender's signature (#3090).
|
|
214
|
+
|
|
215
|
+
**Auth**
|
|
216
|
+
|
|
217
|
+
- CustomAuth `refresh`: rejected, as `CustomAuth refresh` (#3091).
|
|
218
|
+
- `auth` as an array runs through the method whose type matches the
|
|
219
|
+
connection's. The piece is refused only when none of its methods can run,
|
|
220
|
+
with the first method's reason.
|
|
221
|
+
- OAuth2 and OIDC: rejected, as `OAuth2 auth` and `OIDC auth` (#3091). Their
|
|
222
|
+
connections are refused at check and run too.
|
|
223
|
+
- `server` in `validate` and `getConnectionIdentifier` is a throwing stub.
|
|
224
|
+
- A CUSTOM_AUTH value's props reach the piece as stored, not coerced: a
|
|
225
|
+
`Property.Number` prop arrives as the string it was entered as.
|
|
226
|
+
|
|
227
|
+
**Props**
|
|
228
|
+
|
|
229
|
+
- `refreshOnSearch`: a dropdown's `searchValue` is never sent.
|
|
230
|
+
- An optional prop set to `null` reaches `run()` as `null`; upstream passes
|
|
231
|
+
`undefined`.
|
|
232
|
+
- A DYNAMIC prop's value is not coerced against the props it resolved to, so
|
|
233
|
+
an ARRAY inside it arrives as parallel arrays rather than rows.
|
|
234
|
+
- Dynamic resolvers nested in ARRAY items or DYNAMIC output can't be called.
|
|
235
|
+
- CUSTOM props carry only their type.
|
|
236
|
+
- DYNAMIC prop keys are not escaped, and an `options()` that throws gets no
|
|
237
|
+
disabled-dropdown fallback (#3091).
|
|
238
|
+
|
|
239
|
+
**Actions**
|
|
240
|
+
|
|
241
|
+
- `errorHandlingOptions` (retry, continue on failure) is ignored.
|
|
242
|
+
- `test` is never called.
|
|
243
|
+
- `requireAuth` defaults to `false` in the descriptor; upstream defaults to
|
|
244
|
+
`true`.
|
|
245
|
+
- `run.stop`, `run.respond`, `run.pause`, waitpoints and `generateResumeUrl`
|
|
246
|
+
throw.
|
|
247
|
+
- `connections.get`, `tags`, `server`, `agent` and `flows.list` throw.
|
|
248
|
+
- `ctx.store` checks the key length on `put` only; `get` and `delete` of an
|
|
249
|
+
over-long key answer as if it were absent.
|
|
250
|
+
- `flows.current.version.id` is a constant. `project.id` is `reactor` on
|
|
251
|
+
every reactor: the reactor is the project, as it is for `ctx.store`'s
|
|
252
|
+
PROJECT scope.
|
|
253
|
+
|
|
254
|
+
**Piece**
|
|
255
|
+
|
|
256
|
+
- `deprecated` is not in the descriptor.
|
|
257
|
+
- Every piece gets the current context shape, whatever its `getContextInfo`
|
|
258
|
+
says.
|
|
259
|
+
- Reads of context members outside the documented surface are tracked but not
|
|
260
|
+
reported.
|
|
261
|
+
- A piece's setup markdown can describe Activepieces features this engine
|
|
262
|
+
does not serve, such as the webhook URL's `/sync` and `/test` forms (#3095).
|
|
263
|
+
|
|
167
264
|
## Running the tests
|
|
168
265
|
|
|
169
266
|
```sh
|
|
@@ -183,6 +280,17 @@ key so no run picks up a developer's key file. The two live piece suites read
|
|
|
183
280
|
`DOCLING_E2E_URL` / `DOCLING_E2E_API_KEY` and `PAPERLESS_E2E_URL` /
|
|
184
281
|
`PAPERLESS_E2E_USER` / `PAPERLESS_E2E_PASSWORD`, and skip when unset.
|
|
185
282
|
|
|
283
|
+
`test/upstream/` holds Activepieces' own engine tests, generated by
|
|
284
|
+
`pieces-framework`'s sync (see its
|
|
285
|
+
[`UPSTREAM.md`](../pieces-framework/UPSTREAM.md#conformance-suite-for-reactor-workflow))
|
|
286
|
+
and run against this engine through the adapters in `test/upstream-adapters/`.
|
|
287
|
+
A case this engine is known to fail runs as `it.fails` and names the issue that
|
|
288
|
+
fixes it; never edit those files by hand. To regenerate them:
|
|
289
|
+
|
|
290
|
+
```sh
|
|
291
|
+
pnpm --filter @powerhousedao/pieces-framework sync-upstream -- --tag 0.91.0 --from <activepieces checkout>
|
|
292
|
+
```
|
|
293
|
+
|
|
186
294
|
## Design documents
|
|
187
295
|
|
|
188
296
|
[`docs/plan`](./docs/plan) holds the specifications this engine was built from —
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as unsupportedTrigger, G as getTriggers, W as getActions, z as unsupportedAuth } from "./redact-DM3JhxdF.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { readFileSync, realpathSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -130,6 +130,22 @@ function describeProperties(props, resolverIdFor) {
|
|
|
130
130
|
function isPropertyObject(value) {
|
|
131
131
|
return value !== null && typeof value === "object";
|
|
132
132
|
}
|
|
133
|
+
function withUnsupported(feature) {
|
|
134
|
+
return feature ? { unsupported: feature } : {};
|
|
135
|
+
}
|
|
136
|
+
function describeAuthMethod(auth) {
|
|
137
|
+
if (!auth || typeof auth !== "object") return void 0;
|
|
138
|
+
const method = auth;
|
|
139
|
+
const props = method.props && typeof method.props === "object" ? describeProperties(method.props) : [];
|
|
140
|
+
return {
|
|
141
|
+
type: method.type ?? "UNKNOWN",
|
|
142
|
+
displayName: method.displayName,
|
|
143
|
+
description: method.description,
|
|
144
|
+
required: method.required,
|
|
145
|
+
...props.length > 0 ? { props } : {},
|
|
146
|
+
...withUnsupported(unsupportedAuth(method))
|
|
147
|
+
};
|
|
148
|
+
}
|
|
133
149
|
function buildDescriptor(piece, source) {
|
|
134
150
|
const actions = Object.entries(getActions(piece)).map(([actionName, action]) => ({
|
|
135
151
|
name: action.name ?? actionName,
|
|
@@ -151,7 +167,8 @@ function buildDescriptor(piece, source) {
|
|
|
151
167
|
...trigger.outputSchema !== void 0 ? { outputSchema: trigger.outputSchema } : {},
|
|
152
168
|
hasSampleData: trigger.sampleData !== void 0 && trigger.sampleData !== null,
|
|
153
169
|
...trigger.sampleData !== void 0 && trigger.sampleData !== null ? { sampleData: trigger.sampleData } : {},
|
|
154
|
-
handshake: describeHandshake(trigger)
|
|
170
|
+
handshake: describeHandshake(trigger),
|
|
171
|
+
...withUnsupported(unsupportedTrigger(trigger))
|
|
155
172
|
}));
|
|
156
173
|
const descriptor = {
|
|
157
174
|
id: `activepieces:${source.packageName}`,
|
|
@@ -163,21 +180,19 @@ function buildDescriptor(piece, source) {
|
|
|
163
180
|
minimumSupportedRelease: piece.minimumSupportedRelease,
|
|
164
181
|
maximumSupportedRelease: piece.maximumSupportedRelease,
|
|
165
182
|
actions,
|
|
166
|
-
triggers
|
|
183
|
+
triggers,
|
|
184
|
+
...withUnsupported(unsupportedAuth(piece.auth))
|
|
167
185
|
};
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
descriptor.auth =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
required: piece.auth.required,
|
|
175
|
-
...authProps.length > 0 ? { props: authProps } : {}
|
|
176
|
-
};
|
|
186
|
+
if (Array.isArray(piece.auth)) {
|
|
187
|
+
const methods = piece.auth.map(describeAuthMethod).filter((method) => method !== void 0);
|
|
188
|
+
if (methods.length > 0) descriptor.auth = methods;
|
|
189
|
+
} else {
|
|
190
|
+
const method = describeAuthMethod(piece.auth);
|
|
191
|
+
if (method) descriptor.auth = method;
|
|
177
192
|
}
|
|
178
193
|
return descriptor;
|
|
179
194
|
}
|
|
180
195
|
//#endregion
|
|
181
196
|
export { loadPieceFromDir as i, describeProperties as n, loadPiece as r, buildDescriptor as t };
|
|
182
197
|
|
|
183
|
-
//# sourceMappingURL=descriptor-
|
|
198
|
+
//# sourceMappingURL=descriptor-CtMB-wPx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-CtMB-wPx.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\";\nimport {\n unsupportedAuth,\n unsupportedTrigger,\n type UnsupportedFeature,\n} from \"./unsupported.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 // A trigger feature the engine cannot run; the piece's own is on the piece.\n unsupported?: UnsupportedFeature;\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 // Set when this engine can't sign in this way (OAuth2, for one).\n unsupported?: UnsupportedFeature;\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 // A list when the piece offers several sign-in methods.\n auth?: PieceAuthDescriptor | PieceAuthDescriptor[];\n minimumSupportedRelease?: string;\n maximumSupportedRelease?: string;\n actions: PieceActionDescriptor[];\n triggers: PieceTriggerDescriptor[];\n // Set when no block of the piece can run here, e.g. an OAuth2 piece.\n unsupported?: UnsupportedFeature;\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\nfunction withUnsupported(feature: UnsupportedFeature | undefined): {\n unsupported?: UnsupportedFeature;\n} {\n return feature ? { unsupported: feature } : {};\n}\n\n// Pure translation over a loaded piece; performs no I/O and never executes\n// piece code beyond the actions()/triggers() accessors.\nfunction describeAuthMethod(auth: unknown): PieceAuthDescriptor | undefined {\n if (!auth || typeof auth !== \"object\") return undefined;\n const method = auth as ApProperty;\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 props =\n method.props && typeof method.props === \"object\"\n ? describeProperties(method.props)\n : [];\n return {\n type: method.type ?? \"UNKNOWN\",\n displayName: method.displayName,\n description: method.description,\n required: method.required,\n ...(props.length > 0 ? { props } : {}),\n ...withUnsupported(unsupportedAuth(method)),\n };\n}\n\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 ...withUnsupported(unsupportedTrigger(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 ...withUnsupported(unsupportedAuth(piece.auth)),\n };\n // Several methods stay a list, in the piece's order; each says whether this\n // engine can run it.\n if (Array.isArray(piece.auth)) {\n const methods = piece.auth\n .map(describeAuthMethod)\n .filter((method) => method !== undefined);\n if (methods.length > 0) descriptor.auth = methods;\n } else {\n const method = describeAuthMethod(piece.auth);\n if (method) descriptor.auth = method;\n }\n return descriptor;\n}\n"],"mappings":";;;;;;AAeA,SAAgB,aAAa,UAA0B;CACrD,MAAM,MAAM,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM;CACpE,MAAM,MAAM,KAAK,MAAM,GAAG;CAK1B,MAAM,YAAY,IAAI,UAAU;CAChC,MAAM,aAAqC,CAAC;CAC5C,IAAI,OAAO,cAAc,UAAU,WAAW,KAAK,SAAS;CAC5D,IAAI,aAAa,OAAO,cAAc,UAAU;EAC9C,MAAM,OAAO;EACb,KAAK,MAAM,OAAO;GAAC;GAAU;GAAW;EAAS,GAAG;GAClD,MAAM,QAAQ,KAAK;GACnB,IAAI,OAAO,UAAU,UAAU,WAAW,KAAK,KAAK;EACtD;CACF;CACA,WAAW,KAAK,IAAI,MAAM,IAAI,QAAQ,gBAAgB,YAAY,SAAS;CAG3E,MAAM,OAAO,aAAa,QAAQ;CAClC,MAAM,cAAc,OAAO,KAAK;CAChC,KAAK,MAAM,aAAa,YAAY;EAClC,IAAI,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