@powerhousedao/pieces-framework 6.2.3-dev.20 → 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.
Files changed (2) hide show
  1. package/README.md +25 -24
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,27 @@
1
1
  # @powerhousedao/pieces-framework
2
2
 
3
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`.
4
+ piece framework, so a piece can be authored outside their monorepo.
5
+
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.
6
10
 
7
11
  ## Why this package exists
8
12
 
9
13
  Activepieces pieces are written against `@activepieces/pieces-framework` and
10
- `@activepieces/pieces-common`. Since Activepieces v0.86.0 pieces ship as
14
+ `@activepieces/pieces-common`. Since Activepieces v0.86.0 most pieces ship as
11
15
  self-contained bundles with the framework inlined, and upstream stopped
12
16
  publishing those two packages to npm. Anyone authoring a piece outside the
13
17
  Activepieces monorepo has nothing to install.
14
18
 
19
+ "Most", not all: their bundler externalises what esbuild cannot trace, so a
20
+ piece can still declare a dependency — 21 of the 760 published ones do. A
21
+ reactor installs those before loading the piece, with lifecycle scripts
22
+ disabled, which is why one needing a postinstall or a native build will not
23
+ run there whatever version is pinned.
24
+
15
25
  This package vendors the framework, `pieces-common` and the two core packages
16
26
  they depend on from a pinned upstream tag (see [UPSTREAM.md](./UPSTREAM.md)),
17
27
  publishes them as ESM under the Powerhouse release train, and adds the
@@ -21,8 +31,8 @@ Powerhouse types on top. The authoring API is upstream's, unchanged.
21
31
  import {
22
32
  createAction,
23
33
  createPiece,
34
+ PieceAuth,
24
35
  Property,
25
- reactorOf,
26
36
  } from "@powerhousedao/pieces-framework";
27
37
  import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
28
38
  ```
@@ -40,8 +50,7 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
40
50
 
41
51
  2. **Write the piece** in `pieces/<name>/index.ts` with `createPiece`,
42
52
  `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)`:
53
+ piece:
45
54
 
46
55
  ```ts
47
56
  import {
@@ -49,21 +58,18 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
49
58
  createPiece,
50
59
  PieceAuth,
51
60
  Property,
52
- reactorOf,
53
61
  } from "@powerhousedao/pieces-framework";
54
62
 
55
63
  const listInvoices = createAction({
64
+ auth: invoicesAuth,
56
65
  name: "list_invoices",
57
66
  displayName: "List invoices",
58
- description: "Invoices on this reactor",
67
+ description: "Invoices in the billing system",
59
68
  props: {
60
- parentId: Property.ShortText({ displayName: "Drive", required: false }),
69
+ since: Property.ShortText({ displayName: "Since", required: false }),
61
70
  },
62
71
  async run(ctx) {
63
- return reactorOf(ctx).find({
64
- documentType: "powerhouse/invoice",
65
- parentId: ctx.propsValue.parentId,
66
- });
72
+ return clientFor(ctx.auth).listInvoices(ctx.propsValue.since);
67
73
  },
68
74
  });
69
75
 
@@ -71,16 +77,15 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
71
77
  displayName: "Invoices",
72
78
  logoUrl: "https://example.com/invoices.png",
73
79
  authors: ["acme"],
74
- auth: PieceAuth.None(),
80
+ auth: invoicesAuth,
75
81
  actions: [listInvoices],
76
82
  triggers: [],
77
83
  });
78
84
  ```
79
85
 
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>`.
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.
84
89
 
85
90
  3. **Register it.** List the piece in `pieces/index.ts` as a `PackagePiece`
86
91
  and in the package manifest under `"pieces"`:
@@ -118,17 +123,13 @@ import { httpClient, HttpMethod } from "@powerhousedao/pieces-framework/common";
118
123
  `document-models/index.ts`, `editors/index.ts` and `style.css`, even when
119
124
  those are empty. `ph build` runs every step for it unchanged, so there is
120
125
  no piece-only mode to know about. The host that runs pieces on a reactor
121
- (the workflow runtime) reads the `pieces` list, imports each `entry` and
122
- serves `ctx.reactor`.
126
+ (the workflow runtime) reads the `pieces` list and imports each `entry`.
123
127
 
124
128
  Bundling with esbuild to ESM instead of `ph build`? `form-data`, which
125
129
  `./common` uses, is CommonJS, so pass
126
130
  `--banner:js="import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);"`
127
131
  or the bundle throws `Dynamic require of "util" is not supported` on import.
128
132
 
129
- Outside a Powerhouse reactor, `reactorOf(ctx)` throws an error that names
130
- `ctx.reactor`, so a piece that ends up on another host fails legibly.
131
-
132
133
  ## `./host`, for the host and not for piece authors
133
134
 
134
135
  A host that _runs_ pieces needs more than the authoring API: stored prop values
@@ -188,7 +189,7 @@ vendors only the prop-coercion files, for the reasons in
188
189
 
189
190
  ## Publishing the same piece to Activepieces
190
191
 
191
- A piece that does not use `ctx.reactor` is a plain Activepieces piece. To
192
+ A piece written against this package is a plain Activepieces piece. To
192
193
  contribute it upstream, scaffold one in the Activepieces monorepo with
193
194
  `npm run cli pieces create`, copy your `src/` over its own, rewrite the import
194
195
  specifiers (`@powerhousedao/pieces-framework` to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/pieces-framework",
3
- "version": "6.2.3-dev.20",
3
+ "version": "6.2.3-dev.22",
4
4
  "description": "Powerhouse's published copy of the Activepieces piece framework, widened with the reactor context.",
5
5
  "license": "MIT",
6
6
  "type": "module",