@powerhousedao/pieces-framework 6.2.3-dev.21 → 6.2.3-dev.22
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 +17 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @powerhousedao/pieces-framework
|
|
2
2
|
|
|
3
3
|
Powerhouse's published copy of the [Activepieces](https://www.activepieces.com)
|
|
4
|
-
piece framework,
|
|
5
|
-
gets that no other host serves: `ctx.reactor`.
|
|
4
|
+
piece framework, so a piece can be authored outside their monorepo.
|
|
6
5
|
|
|
7
|
-
`ctx.reactor
|
|
8
|
-
whose actions are that surface
|
|
9
|
-
however it was loaded and
|
|
6
|
+
It also carries `ctx.reactor`, which is internal: it is served to
|
|
7
|
+
`@powerhousedao/piece-reactor` alone — the piece whose actions are that surface
|
|
8
|
+
— and every other piece finds the member throwing, however it was loaded and
|
|
9
|
+
whoever shipped it. Nothing you write should reach for it.
|
|
10
10
|
|
|
11
11
|
## Why this package exists
|
|
12
12
|
|
|
@@ -31,8 +31,8 @@ Powerhouse types on top. The authoring API is upstream's, unchanged.
|
|
|
31
31
|
import {
|
|
32
32
|
createAction,
|
|
33
33
|
createPiece,
|
|
34
|
+
PieceAuth,
|
|
34
35
|
Property,
|
|
35
|
-
reactorOf,
|
|
36
36
|
} from "@powerhousedao/pieces-framework";
|
|
37
37
|
import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
|
|
38
38
|
```
|
|
@@ -50,8 +50,7 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
|
|
|
50
50
|
|
|
51
51
|
2. **Write the piece** in `pieces/<name>/index.ts` with `createPiece`,
|
|
52
52
|
`createAction`, `createTrigger` and `Property`, exactly as an Activepieces
|
|
53
|
-
piece
|
|
54
|
-
`reactorOf(ctx)`:
|
|
53
|
+
piece:
|
|
55
54
|
|
|
56
55
|
```ts
|
|
57
56
|
import {
|
|
@@ -59,21 +58,18 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
|
|
|
59
58
|
createPiece,
|
|
60
59
|
PieceAuth,
|
|
61
60
|
Property,
|
|
62
|
-
reactorOf,
|
|
63
61
|
} from "@powerhousedao/pieces-framework";
|
|
64
62
|
|
|
65
63
|
const listInvoices = createAction({
|
|
64
|
+
auth: invoicesAuth,
|
|
66
65
|
name: "list_invoices",
|
|
67
66
|
displayName: "List invoices",
|
|
68
|
-
description: "Invoices
|
|
67
|
+
description: "Invoices in the billing system",
|
|
69
68
|
props: {
|
|
70
|
-
|
|
69
|
+
since: Property.ShortText({ displayName: "Since", required: false }),
|
|
71
70
|
},
|
|
72
71
|
async run(ctx) {
|
|
73
|
-
return
|
|
74
|
-
documentType: "powerhouse/invoice",
|
|
75
|
-
parentId: ctx.propsValue.parentId,
|
|
76
|
-
});
|
|
72
|
+
return clientFor(ctx.auth).listInvoices(ctx.propsValue.since);
|
|
77
73
|
},
|
|
78
74
|
});
|
|
79
75
|
|
|
@@ -81,16 +77,15 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
|
|
|
81
77
|
displayName: "Invoices",
|
|
82
78
|
logoUrl: "https://example.com/invoices.png",
|
|
83
79
|
authors: ["acme"],
|
|
84
|
-
auth:
|
|
80
|
+
auth: invoicesAuth,
|
|
85
81
|
actions: [listInvoices],
|
|
86
82
|
triggers: [],
|
|
87
83
|
});
|
|
88
84
|
```
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
`PowerhouseTriggerHookContext` and the generic `WithReactor<C>`.
|
|
86
|
+
A piece connects a reactor to something outside it. Reading and writing
|
|
87
|
+
Powerhouse documents is the reactor piece's job, and a workflow composes the
|
|
88
|
+
two as separate steps.
|
|
94
89
|
|
|
95
90
|
3. **Register it.** List the piece in `pieces/index.ts` as a `PackagePiece`
|
|
96
91
|
and in the package manifest under `"pieces"`:
|
|
@@ -128,17 +123,13 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
|
|
|
128
123
|
`document-models/index.ts`, `editors/index.ts` and `style.css`, even when
|
|
129
124
|
those are empty. `ph build` runs every step for it unchanged, so there is
|
|
130
125
|
no piece-only mode to know about. The host that runs pieces on a reactor
|
|
131
|
-
(the workflow runtime) reads the `pieces` list
|
|
132
|
-
serves `ctx.reactor`.
|
|
126
|
+
(the workflow runtime) reads the `pieces` list and imports each `entry`.
|
|
133
127
|
|
|
134
128
|
Bundling with esbuild to ESM instead of `ph build`? `form-data`, which
|
|
135
129
|
`./common` uses, is CommonJS, so pass
|
|
136
130
|
`--banner:js="import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);"`
|
|
137
131
|
or the bundle throws `Dynamic require of "util" is not supported` on import.
|
|
138
132
|
|
|
139
|
-
Outside a Powerhouse reactor, `reactorOf(ctx)` throws an error that names
|
|
140
|
-
`ctx.reactor`, so a piece that ends up on another host fails legibly.
|
|
141
|
-
|
|
142
133
|
## `./host`, for the host and not for piece authors
|
|
143
134
|
|
|
144
135
|
A host that _runs_ pieces needs more than the authoring API: stored prop values
|
|
@@ -198,7 +189,7 @@ vendors only the prop-coercion files, for the reasons in
|
|
|
198
189
|
|
|
199
190
|
## Publishing the same piece to Activepieces
|
|
200
191
|
|
|
201
|
-
A piece
|
|
192
|
+
A piece written against this package is a plain Activepieces piece. To
|
|
202
193
|
contribute it upstream, scaffold one in the Activepieces monorepo with
|
|
203
194
|
`npm run cli pieces create`, copy your `src/` over its own, rewrite the import
|
|
204
195
|
specifiers (`@powerhousedao/pieces-framework` to
|
package/package.json
CHANGED