@planningcenter/core-automations 0.3.0-rc.2 â 0.3.0-rc.4
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/CHANGELOG.md +53 -0
- package/README.md +73 -15
- package/dist/cjs/core-automations.esm.js +1 -1
- package/dist/cjs/core-automations.esm.js.map +1 -1
- package/dist/cjs/core-automations.js +1 -1
- package/dist/cjs/core-automations.js.map +1 -1
- package/dist/cjs/core-automations.modern.mjs +1 -1
- package/dist/cjs/core-automations.modern.mjs.map +1 -1
- package/dist/cjs/core-automations.umd.js +1 -1
- package/dist/cjs/core-automations.umd.js.map +1 -1
- package/dist/types/src/automations.d.ts.map +1 -1
- package/dist/types/src/definition.d.ts.map +1 -1
- package/dist/types/src/field.d.ts.map +1 -1
- package/dist/types/src/fields.d.ts.map +1 -1
- package/dist/types/src/history.d.ts.map +1 -1
- package/dist/types/src/history_modal.d.ts +1 -1
- package/dist/types/src/history_modal.d.ts.map +1 -1
- package/dist/types/src/new_automation.d.ts.map +1 -1
- package/dist/types/src/new_automation_modal.d.ts +1 -1
- package/dist/types/src/new_automation_modal.d.ts.map +1 -1
- package/dist/types/src/utils/alerts.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/types/assets/svg_automations.d.ts +0 -3
- package/dist/types/assets/svg_automations.d.ts.map +0 -1
- package/dist/types/automations.d.ts +0 -23
- package/dist/types/automations.d.ts.map +0 -1
- package/dist/types/definition.d.ts +0 -7
- package/dist/types/definition.d.ts.map +0 -1
- package/dist/types/field.d.ts +0 -11
- package/dist/types/field.d.ts.map +0 -1
- package/dist/types/fields.d.ts +0 -10
- package/dist/types/fields.d.ts.map +0 -1
- package/dist/types/history.d.ts +0 -8
- package/dist/types/history.d.ts.map +0 -1
- package/dist/types/history_modal.d.ts +0 -8
- package/dist/types/history_modal.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/new_automation.d.ts +0 -13
- package/dist/types/new_automation.d.ts.map +0 -1
- package/dist/types/new_automation_modal.d.ts +0 -8
- package/dist/types/new_automation_modal.d.ts.map +0 -1
- package/dist/types/utils/alerts.d.ts +0 -7
- package/dist/types/utils/alerts.d.ts.map +0 -1
- package/dist/types/utils/theme.d.ts +0 -22
- package/dist/types/utils/theme.d.ts.map +0 -1
- package/dist/types/utils/utils.d.ts +0 -17
- package/dist/types/utils/utils.d.ts.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Change sizing of `Select`s in the `NewAutomation` form
|
|
13
|
+
|
|
14
|
+
## [0.3.0] - 2023-03-29
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Take in a `afterCreateOptions` prop. This `afterCreateOptions` prop will contain a `label` and a `onConfirm` callback function to be executed after the automation is created.
|
|
19
|
+
- Support multiple trigger events (e.g. "when person [joins|leaves] this group")
|
|
20
|
+
- Added implementation guide to the README
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Update `border-radius` of modals to match newest design spec
|
|
25
|
+
- Migrated components to Typescript
|
|
26
|
+
|
|
27
|
+
## [0.2.0] - 2023-03-21
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- Take in a `currentOrganization` prop instead of reading from `window.currentOrganization`
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- Use `currentOrganization` prop for date formatting
|
|
36
|
+
- Use outline `Badge` variant in history table
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- Build errors: specify `jsxFragment` for microbundle when building (#15)
|
|
41
|
+
- Move function definition above callsite (#16)
|
|
42
|
+
|
|
43
|
+
## [0.1.0] - 2023-03-14
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- Set up initial repo with components extracted from People's original implementation
|
|
48
|
+
- Set up basic theme that includes necessary icons along with host app styles
|
|
49
|
+
- Add basic usage information to README
|
|
50
|
+
|
|
51
|
+
[0.1.0]: https://github.com/planningcenter/core-automations/releases/tag/v0.1.0
|
|
52
|
+
[0.2.0]: https://github.com/planningcenter/core-automations/releases/tag/v0.2.0
|
|
53
|
+
[0.3.0]: https://github.com/planningcenter/core-automations/releases/tag/v0.3.0
|
package/README.md
CHANGED
|
@@ -2,15 +2,75 @@
|
|
|
2
2
|
|
|
3
3
|
A package for implementing core automations in a product.
|
|
4
4
|
|
|
5
|
+
## How does it work?
|
|
6
|
+
|
|
7
|
+
Core automations are built on top of [Webhooks](https://github.com/planningcenter/webhooks). Automation definitions are stored in the Webhooks database, and this package of React components creates/reads/updates/deletes them via the Webhooks API.
|
|
8
|
+
Any [message bus](https://github.com/planningcenter/pco-message-bus) event can be registered as a trigger for an automation, and an automation can run any `pco-people-list` [Operation](https://github.com/planningcenter/pco-people-lists/blob/main/README_OPERATIONS.md).
|
|
9
|
+
|
|
5
10
|
## Usage
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
Implementing core automations in a product requires the following:
|
|
13
|
+
|
|
14
|
+
1. đ Add your event triggers to the message bus
|
|
15
|
+
2. đ Tell [Webhooks](https://github.com/planningcenter/webhooks) how to parse your event messages
|
|
16
|
+
3. đ Build an encrypted parameter to secure the automations requests from your product to Webhooks
|
|
17
|
+
4. đŧī¸ Install and render the `<Automations>` components in your product
|
|
18
|
+
|
|
19
|
+
### 1. đ Add your event triggers to the message bus
|
|
20
|
+
|
|
21
|
+
Automations are triggered by message bus messages, so make sure you're [broadcasting](https://github.com/planningcenter/pco-message-bus#broadcaster) the appropriate messages.
|
|
22
|
+
|
|
23
|
+
âšī¸ Example: [Adding Groups memberships to the bus](https://github.com/planningcenter/groups/pull/4951)
|
|
24
|
+
|
|
25
|
+
### 2. đ Tell Webhooks how to parse your event messages
|
|
26
|
+
|
|
27
|
+
When Webhooks receives the trigger message, it needs to know how to:
|
|
28
|
+
|
|
29
|
+
1. extract the `person_id` from the message payload
|
|
30
|
+
2. build a URL to the page where the automation components live (for notifications)
|
|
31
|
+
|
|
32
|
+
You'll need to open a PR into Webhooks to add new products/trigger events.
|
|
33
|
+
|
|
34
|
+
âšī¸ Example: [Teach Webhooks to handle automations triggered by groups events](https://github.com/planningcenter/webhooks/pull/368)
|
|
35
|
+
|
|
36
|
+
### 3. đ Build an encrypted parameter to secure the automations requests from your product to Webhooks
|
|
37
|
+
|
|
38
|
+
All requests to the Webhooks Automations APIs must include this encrypted parameter. Webhooks uses this to authorize the requests.
|
|
39
|
+
|
|
40
|
+
Example from Groups:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
module GroupAutomationsHelper
|
|
44
|
+
def encrypted_group_trigger_resource(group)
|
|
45
|
+
trigger_resource = {
|
|
46
|
+
# The resource that owns the automations (e.g. the Group/Form/List)
|
|
47
|
+
trigger_resource: "groups/v2/groups/#{group.id}",
|
|
48
|
+
# The person making the requests
|
|
49
|
+
requested_by_id: Person.current.account_center_id,
|
|
50
|
+
# Used to prevent replaying old messages
|
|
51
|
+
time_of_request: Time.current,
|
|
52
|
+
# Can this person edit these automations?
|
|
53
|
+
updates_permitted: policy(group).edit?
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
PCO::URL::Encryption.encrypt(trigger_resource.to_json)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
âšī¸ Example: [`encrypted_group_trigger_resource`](https://github.com/planningcenter/groups/pull/4986/commits/c4e6fe06db11ed9a7759e19fabfad3cc678151ad)
|
|
62
|
+
|
|
63
|
+
### 4. đŧī¸ Install and render the `<Automations>` components in your product
|
|
64
|
+
|
|
65
|
+
âšī¸ Example: [Core automations in Groups](https://github.com/planningcenter/groups/pull/4986)
|
|
66
|
+
|
|
67
|
+
#### Installation
|
|
8
68
|
|
|
9
69
|
```bash
|
|
10
70
|
yarn add @planningcenter/core-automations
|
|
11
71
|
```
|
|
12
72
|
|
|
13
|
-
|
|
73
|
+
#### Rendering the Automations components
|
|
14
74
|
|
|
15
75
|
```jsx
|
|
16
76
|
import { Automations } from "@planningcenter/core-automations"
|
|
@@ -42,24 +102,23 @@ import { Automations } from "@planningcenter/core-automations"
|
|
|
42
102
|
#### Props
|
|
43
103
|
|
|
44
104
|
- `blankStateDescription` (string): Text to be displayed when there are no current automations
|
|
105
|
+
- `currentOrganization` (object): Date formatting info from the current org:
|
|
106
|
+
- `dateFormat` (string): The org's desired date format, in Ruby `strftime` [format](https://apidock.com/ruby/DateTime/strftime)
|
|
107
|
+
- `olsonTimeZone` (string): The org's time zone
|
|
108
|
+
- `twentyFourHourTime` (boolean): Whether the org wants to see 12 or 24 hour times
|
|
45
109
|
- `currentPersonCanCreate` (boolean): Can the user create an automation?
|
|
46
110
|
- `currentPersonId` (number): ID of current user
|
|
47
|
-
- `
|
|
48
|
-
- `dateFormat` (string): The org's desired date format, in Ruby `strftime` [format](https://apidock.com/ruby/DateTime/strftime)
|
|
49
|
-
- `olsonTimeZone` (string): The org's time zone
|
|
50
|
-
- `twentyFourHourTime` (boolean): Whether the org wants to see 12 or 24 hour times
|
|
51
|
-
}}
|
|
52
|
-
- `defaultApp` (string): Which app should be selected by default?
|
|
111
|
+
- `defaultApp` (string): Which app should be selected as the default target when creating a new automation?
|
|
53
112
|
- `theme` (object) optional: Accepts a [Tapestry-React theme object](https://planningcenter.github.io/tapestry-react/theming)
|
|
54
113
|
- `trigger` (object):
|
|
55
|
-
- `
|
|
56
|
-
- `
|
|
57
|
-
- `events` (array[object]): An array of objects describing the possible trigger events (created/deleted/etc)
|
|
114
|
+
- `conditions` (object): The specific conditions for triggering this automation: Should be a subset of the message payload
|
|
115
|
+
- `events` (object[]): An array of objects describing the possible trigger events (created/deleted/etc)
|
|
58
116
|
- `name` (string): The event name (matches the webhooks message `routing_key`)
|
|
59
117
|
- `description` (string): Human-readable description of this event (the words after "When a person...", e.g. "Joins this group")
|
|
60
|
-
- `
|
|
61
|
-
|
|
62
|
-
|
|
118
|
+
- `resource` (string): The encrypted trigger resource param from Step 3 (đ)
|
|
119
|
+
- `afterCreateOptions` (object) optional: Show a custom checkbox to optionally perform an action after the automation is created
|
|
120
|
+
- `label` (string): Description of the action to perform (e.g. "apply to everyone on this list")
|
|
121
|
+
- `onConfirm` (function): The function that will perform after the automation is created
|
|
63
122
|
|
|
64
123
|
### Theming
|
|
65
124
|
|
|
@@ -83,7 +142,6 @@ If your app is already using `Tapestry-React`, you can simply reuse whatever you
|
|
|
83
142
|
|
|
84
143
|
For more information about theming in Tapestry-React, see <https://planningcenter.github.io/tapestry-react/theming>.
|
|
85
144
|
|
|
86
|
-
|
|
87
145
|
## Contributing
|
|
88
146
|
|
|
89
147
|
If you'd like to contribute, you can find details for getting started in the [contribution guide](/CONTRIBUTING.md).
|