@powerhousedao/pieces-framework 6.2.3-dev.11
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/LICENSE +59 -0
- package/README.md +202 -0
- package/UPSTREAM.md +172 -0
- package/dist/action--RmO83_Y.d.ts +12766 -0
- package/dist/action--RmO83_Y.d.ts.map +1 -0
- package/dist/authentication-B7brX_It.js +242 -0
- package/dist/authentication-B7brX_It.js.map +1 -0
- package/dist/common.d.ts +324 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +828 -0
- package/dist/common.js.map +1 -0
- package/dist/host.d.ts +95 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +723 -0
- package/dist/host.js.map +1 -0
- package/dist/index-BW6GxXEN.d.ts +5544 -0
- package/dist/index-BW6GxXEN.d.ts.map +1 -0
- package/dist/index.d.ts +1156 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1569 -0
- package/dist/index.js.map +1 -0
- package/dist/input-COuhC1I-.js +308 -0
- package/dist/input-COuhC1I-.js.map +1 -0
- package/dist/markdown-property-Df2l6_y_.js +285 -0
- package/dist/markdown-property-Df2l6_y_.js.map +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Powerhouse Inc.
|
|
4
|
+
|
|
5
|
+
Applies to everything in this package outside upstream/ and test/upstream/
|
|
6
|
+
(src/, scripts/, test/, the build and package files).
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
|
|
26
|
+
--------------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
The code under upstream/ and test/upstream/ is vendored from
|
|
29
|
+
https://github.com/activepieces/activepieces (packages/pieces/framework,
|
|
30
|
+
packages/pieces/common, packages/core/piece-types and packages/core/utils, none
|
|
31
|
+
of which lie under the "packages/ee/" carve-out) and stays under its original
|
|
32
|
+
license, reproduced verbatim below. The exact tag and commit are recorded in
|
|
33
|
+
upstream/MANIFEST.json.
|
|
34
|
+
|
|
35
|
+
Copyright (c) 2020-2024 Activepieces Inc.
|
|
36
|
+
|
|
37
|
+
Portions of this software are licensed as follows:
|
|
38
|
+
|
|
39
|
+
* All content that resides under the "packages/ee/" and "packages/server/api/src/app/ee" directory of this repository, if that directory exists, is licensed under the license defined in packages/ee/LICENSE
|
|
40
|
+
* All third party components incorporated into the Activepieces Inc Software are licensed under the original license provided by the owner of the applicable component.
|
|
41
|
+
* Content outside of the above mentioned directories or restrictions above is available under the "MIT Expat" license as defined below.
|
|
42
|
+
|
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
44
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
45
|
+
in the Software without restriction, including without limitation the rights
|
|
46
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
47
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
48
|
+
furnished to do so, subject to the following conditions:
|
|
49
|
+
|
|
50
|
+
The above copyright notice and this permission notice shall be included in all
|
|
51
|
+
copies or substantial portions of the Software.
|
|
52
|
+
|
|
53
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
54
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
55
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
56
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
57
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
58
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
59
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# @powerhousedao/pieces-framework
|
|
2
|
+
|
|
3
|
+
Powerhouse's published copy of the [Activepieces](https://www.activepieces.com)
|
|
4
|
+
piece framework, plus the one thing a piece running on a Powerhouse reactor
|
|
5
|
+
gets that no other host serves: `ctx.reactor`.
|
|
6
|
+
|
|
7
|
+
## Why this package exists
|
|
8
|
+
|
|
9
|
+
Activepieces pieces are written against `@activepieces/pieces-framework` and
|
|
10
|
+
`@activepieces/pieces-common`. Since Activepieces v0.86.0 pieces ship as
|
|
11
|
+
self-contained bundles with the framework inlined, and upstream stopped
|
|
12
|
+
publishing those two packages to npm. Anyone authoring a piece outside the
|
|
13
|
+
Activepieces monorepo has nothing to install.
|
|
14
|
+
|
|
15
|
+
This package vendors the framework, `pieces-common` and the two core packages
|
|
16
|
+
they depend on from a pinned upstream tag (see [UPSTREAM.md](./UPSTREAM.md)),
|
|
17
|
+
publishes them as ESM under the Powerhouse release train, and adds the
|
|
18
|
+
Powerhouse types on top. The authoring API is upstream's, unchanged.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import {
|
|
22
|
+
createAction,
|
|
23
|
+
createPiece,
|
|
24
|
+
Property,
|
|
25
|
+
reactorOf,
|
|
26
|
+
} from "@powerhousedao/pieces-framework";
|
|
27
|
+
import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Writing a piece for a reactor package
|
|
31
|
+
|
|
32
|
+
1. **Start from a reactor package.** `ph init` gives you one; then add the
|
|
33
|
+
framework:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pnpm add @powerhousedao/pieces-framework
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The types need `@types/node`, which a `ph init` project already has.
|
|
40
|
+
|
|
41
|
+
2. **Write the piece** in `pieces/<name>/index.ts` with `createPiece`,
|
|
42
|
+
`createAction`, `createTrigger` and `Property`, exactly as an Activepieces
|
|
43
|
+
piece. The reactor the piece runs inside is on every context; read it with
|
|
44
|
+
`reactorOf(ctx)`:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import {
|
|
48
|
+
createAction,
|
|
49
|
+
createPiece,
|
|
50
|
+
PieceAuth,
|
|
51
|
+
Property,
|
|
52
|
+
reactorOf,
|
|
53
|
+
} from "@powerhousedao/pieces-framework";
|
|
54
|
+
|
|
55
|
+
const listInvoices = createAction({
|
|
56
|
+
name: "list_invoices",
|
|
57
|
+
displayName: "List invoices",
|
|
58
|
+
description: "Invoices on this reactor",
|
|
59
|
+
props: {
|
|
60
|
+
parentId: Property.ShortText({ displayName: "Drive", required: false }),
|
|
61
|
+
},
|
|
62
|
+
async run(ctx) {
|
|
63
|
+
return reactorOf(ctx).find({
|
|
64
|
+
documentType: "powerhouse/invoice",
|
|
65
|
+
parentId: ctx.propsValue.parentId,
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const invoices = createPiece({
|
|
71
|
+
displayName: "Invoices",
|
|
72
|
+
logoUrl: "https://example.com/invoices.png",
|
|
73
|
+
authors: ["acme"],
|
|
74
|
+
auth: PieceAuth.None(),
|
|
75
|
+
actions: [listInvoices],
|
|
76
|
+
triggers: [],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`ReactorService` offers `models()`, `model(type)`, `get`, `find`, `create`
|
|
81
|
+
and `execute`. The typed contexts are exported too:
|
|
82
|
+
`PowerhouseActionContext`, `PowerhousePropertyContext`,
|
|
83
|
+
`PowerhouseTriggerHookContext` and the generic `WithReactor<C>`.
|
|
84
|
+
|
|
85
|
+
3. **Register it.** List the piece in `pieces/index.ts` as a `PackagePiece`
|
|
86
|
+
and in the package manifest under `"pieces"`:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import type { PackagePiece } from "@powerhousedao/pieces-framework";
|
|
90
|
+
|
|
91
|
+
export const pieces: PackagePiece[] = [
|
|
92
|
+
{
|
|
93
|
+
name: "@acme/pieces-invoices",
|
|
94
|
+
version: "1.0.0",
|
|
95
|
+
entry: "dist/node/pieces/invoices/index.mjs",
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`entry` is the built module, relative to the package root: `ph build`
|
|
101
|
+
emits `pieces/<name>/index.ts` to `dist/node/pieces/<name>/index.mjs`.
|
|
102
|
+
|
|
103
|
+
4. **Build.** `ph build` inlines the framework into each piece bundle under
|
|
104
|
+
`dist/node/pieces`, so a host loads a self-contained module. The host that
|
|
105
|
+
runs pieces on a reactor (the workflow runtime, arriving separately) reads
|
|
106
|
+
the `pieces` list, imports each `entry` and serves `ctx.reactor`.
|
|
107
|
+
|
|
108
|
+
Bundling with esbuild to ESM instead of `ph build`? `form-data`, which
|
|
109
|
+
`./common` uses, is CommonJS, so pass
|
|
110
|
+
`--banner:js="import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);"`
|
|
111
|
+
or the bundle throws `Dynamic require of "util" is not supported` on import.
|
|
112
|
+
|
|
113
|
+
Outside a Powerhouse reactor, `reactorOf(ctx)` throws an error that names
|
|
114
|
+
`ctx.reactor`, so a piece that ends up on another host fails legibly.
|
|
115
|
+
|
|
116
|
+
## `./host`, for the host and not for piece authors
|
|
117
|
+
|
|
118
|
+
A host that _runs_ pieces needs more than the authoring API: stored prop values
|
|
119
|
+
arrive as strings from a form and have to be coerced to what the piece's
|
|
120
|
+
`props` declare, outbound requests have to be checked against the private
|
|
121
|
+
address space, and a thrown HTTP client error has to be turned into something a
|
|
122
|
+
user can read. Activepieces does all three in its engine; `./host` re-exports
|
|
123
|
+
that code so a Powerhouse host does not reimplement it.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import {
|
|
127
|
+
formatPieceError,
|
|
128
|
+
processors,
|
|
129
|
+
propsProcessor,
|
|
130
|
+
ssrfIpClassifier,
|
|
131
|
+
} from "@powerhousedao/pieces-framework/host";
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
From the engine, coercion of what an editor stored into what a piece's `props`
|
|
135
|
+
declare:
|
|
136
|
+
|
|
137
|
+
- `processors` — `PropertyType` → coercion function, for the eleven types that
|
|
138
|
+
need one, and `numberProcessor`, `checkboxProcessor`, `dateTimeProcessor`,
|
|
139
|
+
`fileProcessor`, `jsonProcessor`, `objectProcessor`, `textProcessor` and
|
|
140
|
+
`multiSelectProcessor` individually.
|
|
141
|
+
- `arrayZipperProcessor` — turns an object of parallel arrays into `ARRAY`
|
|
142
|
+
items; `ARRAY` has no entry in the map.
|
|
143
|
+
- `propsProcessor.applyProcessorsAndValidators` — a whole props map at once,
|
|
144
|
+
auth and nested `ARRAY`/`DYNAMIC` props included, returning the processed
|
|
145
|
+
input and per-key validation errors.
|
|
146
|
+
- `dynamicPropKeys` — escapes and restores `DYNAMIC` prop keys around a form
|
|
147
|
+
that treats `.` and `[` as path separators.
|
|
148
|
+
- `ProcessorFn`, and `PropertySettings` (ours, see
|
|
149
|
+
[UPSTREAM.md](./UPSTREAM.md)) for the stored `DYNAMIC` schema.
|
|
150
|
+
|
|
151
|
+
From `core-utils`, the two host jobs that are not coercion:
|
|
152
|
+
|
|
153
|
+
- `ssrfIpClassifier.isBlockedIp({ ip, allowList })` — blocks every non-unicast
|
|
154
|
+
range, with CIDR entries in the allow list.
|
|
155
|
+
- `formatPieceError` — lifts the API message out of an HTTP-shaped error,
|
|
156
|
+
strips an HTML error page down to its text and caps serialization depth;
|
|
157
|
+
with `tryParseFriendlyPieceError` and the `FriendlyPieceError` type.
|
|
158
|
+
|
|
159
|
+
Nothing here belongs in a piece: a piece is handed values that are already
|
|
160
|
+
coerced. `.` and `./common` are unchanged, and `test/surface.test.ts` holds them
|
|
161
|
+
that way.
|
|
162
|
+
|
|
163
|
+
The consumer is [`@powerhousedao/reactor-workflow`](../reactor-workflow), which
|
|
164
|
+
runs pieces on a reactor: its `context/normalize.ts` dispatches to `processors`,
|
|
165
|
+
its `worker/egress.ts` classifies with `ssrfIpClassifier`, and its worker runs a
|
|
166
|
+
thrown piece error through `formatPieceError` before redacting it.
|
|
167
|
+
|
|
168
|
+
The coercion half comes from `@activepieces/engine`, of which this package
|
|
169
|
+
vendors only the prop-coercion files, for the reasons in
|
|
170
|
+
[UPSTREAM.md](./UPSTREAM.md). `dayjs` (the DATE_TIME processor) and `ipaddr.js`
|
|
171
|
+
(the classifier) are runtime dependencies because `./host` reaches them.
|
|
172
|
+
|
|
173
|
+
## Publishing the same piece to Activepieces
|
|
174
|
+
|
|
175
|
+
A piece that does not use `ctx.reactor` is a plain Activepieces piece. To
|
|
176
|
+
contribute it upstream, scaffold one in the Activepieces monorepo with
|
|
177
|
+
`npm run cli pieces create`, copy your `src/` over its own, rewrite the import
|
|
178
|
+
specifiers (`@powerhousedao/pieces-framework` to
|
|
179
|
+
`@activepieces/pieces-framework`, `@powerhousedao/pieces-framework/common` to
|
|
180
|
+
`@activepieces/pieces-common`) and run `npm run build-piece <name>`.
|
|
181
|
+
|
|
182
|
+
## Syncing upstream
|
|
183
|
+
|
|
184
|
+
```sh
|
|
185
|
+
pnpm --filter @powerhousedao/pieces-framework sync-upstream -- --tag 0.91.0
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`scripts/sync-upstream.mts` is the only thing that writes `upstream/` and
|
|
189
|
+
`test/upstream/`. It fetches the tag, copies the four piece source trees plus a
|
|
190
|
+
named handful of engine files, rewrites
|
|
191
|
+
them to ESM with `.js` specifiers and type-only imports, formats them, applies
|
|
192
|
+
a short list of literal patches that fail loudly when upstream changes, and
|
|
193
|
+
records every file's upstream path and hash in `upstream/MANIFEST.json`.
|
|
194
|
+
Details in [UPSTREAM.md](./UPSTREAM.md).
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT. The vendored Activepieces code keeps its original MIT license and
|
|
199
|
+
copyright, reproduced verbatim in [LICENSE](./LICENSE) alongside the Powerhouse
|
|
200
|
+
notice for everything else. The framework is inlined into every piece an
|
|
201
|
+
external developer builds, which is why this package is MIT rather than AGPL
|
|
202
|
+
like the rest of the Powerhouse monorepo.
|
package/UPSTREAM.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Upstream
|
|
2
|
+
|
|
3
|
+
`upstream/` and `test/upstream/` are generated from
|
|
4
|
+
[activepieces/activepieces](https://github.com/activepieces/activepieces).
|
|
5
|
+
Never edit them by hand; re-run the sync instead.
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
| --------- | ------------------------------------------ |
|
|
9
|
+
| Tag | `0.91.0` |
|
|
10
|
+
| Commit | `da4410d1bf6212054e55805a98d566ff1b9310b2` |
|
|
11
|
+
| Committed | 2026-09-14 |
|
|
12
|
+
|
|
13
|
+
The same facts, plus the per-file upstream path and the SHA-256 of every
|
|
14
|
+
original file, live in `upstream/MANIFEST.json`; the package versions are in
|
|
15
|
+
`package.json` under `"upstream"`.
|
|
16
|
+
|
|
17
|
+
## What is vendored
|
|
18
|
+
|
|
19
|
+
| Upstream package | Upstream path | Here |
|
|
20
|
+
| --------------------------------------- | ------------------------------- | ---------------------------- |
|
|
21
|
+
| `@activepieces/pieces-framework` 0.39.0 | `packages/pieces/framework/src` | `upstream/framework/` |
|
|
22
|
+
| `@activepieces/pieces-common` 0.14.0 | `packages/pieces/common/src` | `upstream/common/` |
|
|
23
|
+
| `@activepieces/core-piece-types` 0.11.1 | `packages/core/piece-types/src` | `upstream/core-piece-types/` |
|
|
24
|
+
| `@activepieces/core-utils` 0.6.2 | `packages/core/utils/src` | `upstream/core-utils/` |
|
|
25
|
+
| `@activepieces/engine` 0.7.0 | `packages/server/engine/src` | `upstream/engine/` |
|
|
26
|
+
|
|
27
|
+
The first four are vendored whole. The engine is not: `PACKAGES` gives it an
|
|
28
|
+
explicit `files` list, and the sync fails if any listed path disappears
|
|
29
|
+
upstream. Only the prop-coercion corner is taken — `lib/variables/processors/*`,
|
|
30
|
+
`lib/variables/props-processor.ts` and `lib/helper/dynamic-prop-keys.ts` — which
|
|
31
|
+
is what `./host` re-exports. Everything else in that package reaches for the
|
|
32
|
+
flow executor, the isolated-vm sandbox or the platform API: the trigger helper,
|
|
33
|
+
the piece executor and loader, and `lib/helper/error-handling.ts`, whose
|
|
34
|
+
retry/continue-on-failure logic takes `EngineConstants` and
|
|
35
|
+
`FlowExecutorContext` and so would drag the whole handler tree in.
|
|
36
|
+
`lib/variables/property-path.ts` is left out too: `props-processor.ts` does not
|
|
37
|
+
import it, and it would add a `jsep` dependency.
|
|
38
|
+
|
|
39
|
+
Each package's own vitest suites (`*.spec.ts`, `*.test.ts` under `src/`, and
|
|
40
|
+
`test/`) go to `test/upstream/<package>/` and run with `pnpm test`.
|
|
41
|
+
|
|
42
|
+
Left out: `mime-db-min.cjs` (upstream's bundler alias that keeps `mime-db`,
|
|
43
|
+
pulled in through `form-data`, out of piece bundles; aliasing is the piece
|
|
44
|
+
build's job, so `ph build` may adopt it later) and upstream's unused `ai` and
|
|
45
|
+
`semver` dependencies.
|
|
46
|
+
Of the engine's own tests only `test/variables/props-validator.test.ts` and
|
|
47
|
+
`test/variables/file-processor.test.ts` come along: the rest need
|
|
48
|
+
`@activepieces/shared`, `props-resolver` or `FlowExecutorContext`.
|
|
49
|
+
|
|
50
|
+
`@activepieces/shared` (8k lines of platform entities) is not vendored. The four
|
|
51
|
+
piece packages never import it; the engine files do, so the codemod re-homes
|
|
52
|
+
each symbol they use — `AUTHENTICATION_PROPERTY_NAME` and `AppConnectionValue`
|
|
53
|
+
to `upstream/core-piece-types/`, which really defines them, and `PropertySettings`
|
|
54
|
+
to `src/host/shared-shim.ts`, a Powerhouse-owned declaration of the minimal
|
|
55
|
+
shape `props-processor.ts` reads. An unmapped symbol fails the sync.
|
|
56
|
+
|
|
57
|
+
`deepmerge-ts` is a devDependency only: `core-utils` imports it in
|
|
58
|
+
`deepMergeAndCast`, which the framework barrel never re-exports, so the source
|
|
59
|
+
typechecks against it and the build tree-shakes it away. `test/dist.test.ts`
|
|
60
|
+
fails if a sync makes it reachable; that is the moment to move it to
|
|
61
|
+
`dependencies`. `ipaddr.js` and `dayjs` are runtime dependencies because `./host`
|
|
62
|
+
does reach them, through `ssrfIpClassifier` and the DATE_TIME processor.
|
|
63
|
+
|
|
64
|
+
## How to sync
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
pnpm --filter @powerhousedao/pieces-framework sync-upstream -- --tag <tag>
|
|
68
|
+
# or, from a checkout you already have at that tag:
|
|
69
|
+
pnpm --filter @powerhousedao/pieces-framework sync-upstream -- --tag <tag> --from ../activepieces
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Without `--from` the script sparse-clones the tag into a temp dir. Then run the
|
|
73
|
+
gates (`tsc`, `lint`, `test`, `build`) and commit the result together with the
|
|
74
|
+
`UPSTREAM.md` table above. The script is idempotent: running it twice yields no
|
|
75
|
+
diff.
|
|
76
|
+
|
|
77
|
+
## What the codemod changes
|
|
78
|
+
|
|
79
|
+
Upstream is CommonJS with extensionless imports; this package is ESM under
|
|
80
|
+
`NodeNext` with `verbatimModuleSyntax`. For every copied `.ts` file the script:
|
|
81
|
+
|
|
82
|
+
1. Rewrites bare `@activepieces/{pieces-framework,pieces-common,core-piece-types,core-utils}`
|
|
83
|
+
imports to relative paths into `upstream/`.
|
|
84
|
+
2. Adds `.js` (or `/index.js`) to relative specifiers, resolved against the
|
|
85
|
+
real files.
|
|
86
|
+
3. Prefixes node builtins with `node:`, and adds the extension Node's ESM
|
|
87
|
+
resolver will not infer for a subpath of a dependency with no `"exports"`
|
|
88
|
+
map (`dayjs/plugin/utc` becomes `dayjs/plugin/utc.js`).
|
|
89
|
+
4. Prepends a two-line header naming the upstream path and the tag.
|
|
90
|
+
5. Runs `eslint --fix` with `scripts/sync-upstream.eslint.config.mjs`
|
|
91
|
+
(`consistent-type-imports`, `consistent-type-exports`, prettier) so
|
|
92
|
+
type-only imports and re-exports satisfy `verbatimModuleSyntax` and
|
|
93
|
+
`isolatedModules`. Unused-directive reporting is off there, so upstream's
|
|
94
|
+
`eslint-disable` comments survive even though their rules do not run.
|
|
95
|
+
6. Splits an `@activepieces/shared` import across the modules that really own
|
|
96
|
+
each symbol, per `SHARED_SYMBOL_HOMES`.
|
|
97
|
+
7. Applies the literal patches listed in `PATCHES` in
|
|
98
|
+
`scripts/sync-upstream.mts`. Each must match exactly the expected number of
|
|
99
|
+
times or the sync fails, so a change upstream cannot go unnoticed.
|
|
100
|
+
|
|
101
|
+
Current patches:
|
|
102
|
+
|
|
103
|
+
- `upstream/common/lib/http/core/fetch-http-client.ts`: cast a buffered
|
|
104
|
+
form-data body to `BodyInit` (`@types/node` 25 no longer accepts
|
|
105
|
+
`Buffer<ArrayBufferLike>` there), and replace a `@ts-expect-error` whose
|
|
106
|
+
target line prettier moves with an explicit cast on `Readable.fromWeb`.
|
|
107
|
+
- `upstream/common/lib/http/core/fetch-http-client.ts`: drop the unconditional
|
|
108
|
+
`process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"` at the top of `sendRequest`.
|
|
109
|
+
That flag is process-wide, so it disabled certificate verification for every
|
|
110
|
+
HTTPS request in the host for as long as the process ran, not just the
|
|
111
|
+
current one. Upstream's own bug (activepieces/activepieces@main still has
|
|
112
|
+
it); no design here relies on it.
|
|
113
|
+
- `upstream/common/lib/http/core/fetch-http-client.ts`: stop `console.error`-ing
|
|
114
|
+
the `HttpError` built for a failed request. `HttpError`'s message embeds the
|
|
115
|
+
raw outgoing request body, so this was writing piece secrets (API keys,
|
|
116
|
+
tokens, form fields) to host-level logs on every failed call. Upstream's own
|
|
117
|
+
bug too; callers already get the same detail back via `toFailsafeOutput`.
|
|
118
|
+
- `upstream/common/lib/stream/index.ts`: guard `readChunks` against a
|
|
119
|
+
non-positive `chunkSize`. `pendingLength >= chunkSize` is permanently true
|
|
120
|
+
for `chunkSize <= 0`, so the drain loop never yields control back to the
|
|
121
|
+
outer `for await`, hanging the generator forever. Unreachable today (nothing
|
|
122
|
+
calls it yet) but it is public framework API.
|
|
123
|
+
- `upstream/common/lib/helpers/index.ts`: in `createCustomApiCallAction`, stop
|
|
124
|
+
injecting `authValue` into headers whenever `authLocation` is merely
|
|
125
|
+
non-nil. `authLocation` defaults to `"headers"` and is never actually nil at
|
|
126
|
+
that point, so `authLocation === "headers" || !isNil(authLocation)` always
|
|
127
|
+
held — query-param credentials were duplicated into the request headers.
|
|
128
|
+
- `upstream/framework/lib/property/input/array-property.ts`: add
|
|
129
|
+
`JsonProperty` and `ColorProperty` to the runtime `ArraySubProps` union (and
|
|
130
|
+
import them as values). The exported `ArraySubProps<R>` type and
|
|
131
|
+
`Property.Array` both already allow Json/Color sub-properties; the runtime
|
|
132
|
+
schema rejected them.
|
|
133
|
+
- `upstream/framework/lib/property/input/array-property.ts`: make
|
|
134
|
+
`ArrayProperty`'s `properties` field `z.optional(...)`. The exported
|
|
135
|
+
`ArrayProperty<R>` type already marks it optional, and
|
|
136
|
+
`piecePropertiesUtils.buildSchema` already handles an absent value; the
|
|
137
|
+
runtime schema required it.
|
|
138
|
+
- `upstream/framework/lib/property/input/index.ts`: add `CustomProperty` to
|
|
139
|
+
the runtime `InputProperty` union (and import it as a value).
|
|
140
|
+
`Property.Custom` builds exactly that shape, and it's part of the exported
|
|
141
|
+
`InputProperty` type, but the runtime schema rejected it.
|
|
142
|
+
- `upstream/framework/lib/property/authentication/custom-auth-prop.ts`: add
|
|
143
|
+
`SecretTextProperty`, `MarkDownProperty` and `StaticMultiSelectDropdownProperty`
|
|
144
|
+
to the runtime `CustomAuthProps` union (and import them as values). All
|
|
145
|
+
three are part of the exported `CustomAuthProps` type; the runtime schema
|
|
146
|
+
was narrower.
|
|
147
|
+
- `upstream/framework/lib/property/input/markdown-property.ts`: add an
|
|
148
|
+
optional `variant` field to the runtime `MarkDownProperty` schema.
|
|
149
|
+
`Property.MarkDown` always writes one and the exported type declares it,
|
|
150
|
+
but the schema had no such key, so zod silently stripped
|
|
151
|
+
`WARNING`/`TIP`/`BORDERLESS` variants on parse.
|
|
152
|
+
- `upstream/framework/index.ts` and `upstream/framework/lib/property/index.ts`:
|
|
153
|
+
re-export `SeekPage`, `McpAuthConfig` and `InputProperty` as values instead
|
|
154
|
+
of `export type`. Each is a zod schema merged with a type; rolldown-plugin-dts
|
|
155
|
+
drops the `type` modifier when it bundles `dist/index.d.ts`, so upstream's
|
|
156
|
+
type-only re-export let `import { SeekPage }` typecheck and then fail at link
|
|
157
|
+
time. The runtime gains three exports upstream's lacks; `test/dist.test.ts`
|
|
158
|
+
holds the d.ts to the runtime.
|
|
159
|
+
- `test/upstream/framework/test/connection-identifier-flag.test.ts`: pass
|
|
160
|
+
`authors: []` to `createPiece` (upstream does not typecheck its tests).
|
|
161
|
+
- `test/upstream/core-utils/test/ai-provider-health.test.ts`: make the outcome
|
|
162
|
+
reporter return `void` instead of `Array.prototype.push`'s number (three
|
|
163
|
+
sites).
|
|
164
|
+
- `test/upstream/engine/test/variables/file-processor.test.ts`: cast the
|
|
165
|
+
processor's `unknown` result to `ApStreamingFile` instead of annotating the
|
|
166
|
+
binding (five sites).
|
|
167
|
+
- `test/upstream/engine/test/variables/props-validator.test.ts`: pass
|
|
168
|
+
`auth: undefined` to `Property.Dropdown` and `Property.MultiSelectDropdown`,
|
|
169
|
+
which require it.
|
|
170
|
+
|
|
171
|
+
The vendored trees are excluded from the root ESLint run: their lint stance is
|
|
172
|
+
upstream's, and the codemod already applies this repo's formatting.
|