@coasy/piece-coasy 0.2.5 → 0.2.6
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/CLAUDE.md
CHANGED
|
@@ -15,7 +15,7 @@ The doc is **private** — fetch it with `gh api repos/coasy/coasy-core/contents
|
|
|
15
15
|
- **Validation:** Server-side via `class-validator`. Bad bodies return `400` with field details.
|
|
16
16
|
- **Response shape:** `{ "message": "...", "<entity>": { ... } }`
|
|
17
17
|
|
|
18
|
-
### Available actions (as of 2026-
|
|
18
|
+
### Available actions (as of 2026-07-08)
|
|
19
19
|
|
|
20
20
|
| Action | Endpoint | Purpose |
|
|
21
21
|
| --- | --- | --- |
|
|
@@ -26,11 +26,13 @@ The doc is **private** — fetch it with `gh api repos/coasy/coasy-core/contents
|
|
|
26
26
|
| `createVoucher` | `POST /apps/actions/createVoucher` | Create a discount voucher tied to offers |
|
|
27
27
|
| `enrollUserCourse` | `POST /apps/actions/enrollUserCourse` | Enroll a user in a course |
|
|
28
28
|
| `findEvent` | `POST /apps/actions/findEvent` | Find events of the calling app by exact title |
|
|
29
|
+
| `removeFromUser` | `POST /apps/actions/removeFromUser` | Remove features / community topics / topic groups / meditation categories from a user |
|
|
29
30
|
| `sendPushNotification` | `POST /apps/actions/sendPushNotification` | Send a push notification to all of a user's devices |
|
|
30
31
|
|
|
31
32
|
### Gotchas worth remembering
|
|
32
33
|
|
|
33
|
-
- **`assignToUser`** requires at least one of `features` / `communityTopics` / `communityTopicGroups` / `meditationCategories`; otherwise the server returns `400`. Cross-app `userId` returns `401`, not `404`.
|
|
34
|
+
- **`assignToUser`** requires at least one of `features` / `communityTopics` / `communityTopicGroups` / `meditationCategories`; otherwise the server returns `400`. Cross-app `userId` returns `401`, not `404`. It **does** validate that every referenced entity exists (`404` if not) — `removeFromUser` deliberately does not.
|
|
35
|
+
- **`removeFromUser`** (coasy-core PR #452) is the idempotent counterpart to `assignToUser`, same four array fields. Removing a value the user does not have is a **success**, not an error: HTTP `200`, `message: "Nothing to remove for user."`, `removed: {}`, and no write to the user record. Referenced entities are **not** existence-checked, so a deleted feature or meditation category stays removable. Same guards as `assignToUser` otherwise: unknown `userId` → `404`, cross-app `userId` → `401`, no field provided → `400`. The response adds a `removed` map reporting which values were actually present. Note the server rejects unknown body fields (`courses` is **not** supported here — courses use `enrollUserCourse`).
|
|
34
36
|
- **`sendPushNotification`** accepts a `topic` field in the DTO but it is silently discarded by the current `buildNotification` implementation — do not expose it as a piece property until the upstream handler is fixed.
|
|
35
37
|
- **`createFunnelParticipant`** lowercases `email` server-side. The response includes server-generated `funnelParticipantId`, `registrationTime`, and `timestamp`.
|
|
36
38
|
- **`createVoucher`** auto-generates the voucher ID (`VOC-…`) and sets `status: "ACTIVE"`. Setting `countLeft` implicitly sets `isCountLimited: true`.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const webinar_participant_attend_1 = require("./lib/triggers/webinar-participant
|
|
|
25
25
|
const webinar_participant_reminder_1 = require("./lib/triggers/webinar-participant-reminder");
|
|
26
26
|
const add_trial_period_1 = require("./lib/actions/add-trial-period");
|
|
27
27
|
const assign_to_user_1 = require("./lib/actions/assign-to-user");
|
|
28
|
+
const remove_from_user_1 = require("./lib/actions/remove-from-user");
|
|
28
29
|
exports.coasyAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
29
30
|
required: true,
|
|
30
31
|
description: 'Enter coasy authentication details',
|
|
@@ -57,6 +58,7 @@ exports.coasy = (0, pieces_framework_1.createPiece)({
|
|
|
57
58
|
create_voucher_1.createVoucher,
|
|
58
59
|
enroll_user_course_1.enrollUserCourse,
|
|
59
60
|
find_event_1.findEvent,
|
|
61
|
+
remove_from_user_1.removeFromUser,
|
|
60
62
|
send_push_notification_1.sendPushNotification,
|
|
61
63
|
],
|
|
62
64
|
triggers: [
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/coasy/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAIwC;AACxC,qFAAgF;AAChF,uFAAkF;AAClF,iEAA6D;AAC7D,yEAAoE;AACpE,yDAAqD;AACrD,iFAA4E;AAC5E,8EAA0E;AAC1E,oEAAgE;AAChE,8EAAyE;AACzE,kFAA8E;AAC9E,kFAA8E;AAC9E,kEAA6D;AAC7D,8DAA0D;AAC1D,kFAA6E;AAC7E,kEAA8D;AAC9D,wDAAoD;AACpD,kEAA6D;AAC7D,sEAAkE;AAClE,oFAA+E;AAC/E,0FAAqF;AACrF,8FAAyF;AACzF,qEAAgE;AAChE,iEAA4D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/coasy/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAIwC;AACxC,qFAAgF;AAChF,uFAAkF;AAClF,iEAA6D;AAC7D,yEAAoE;AACpE,yDAAqD;AACrD,iFAA4E;AAC5E,8EAA0E;AAC1E,oEAAgE;AAChE,8EAAyE;AACzE,kFAA8E;AAC9E,kFAA8E;AAC9E,kEAA6D;AAC7D,8DAA0D;AAC1D,kFAA6E;AAC7E,kEAA8D;AAC9D,wDAAoD;AACpD,kEAA6D;AAC7D,sEAAkE;AAClE,oFAA+E;AAC/E,0FAAqF;AACrF,8FAAyF;AACzF,qEAAgE;AAChE,iEAA4D;AAC5D,qEAAgE;AAEnD,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC5C,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,oCAAoC;IACjD,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,oBAAoB;YACjC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,mCAAmC;SAClD,CAAC;QACF,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC3B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;CACF,CAAC,CAAC;AAEU,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAC/B,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,iBAAS;IACf,WAAW,EAAE,wBAAwB;IACrC,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,CAAC,iBAAiB,CAAC;IAC5B,OAAO,EAAE;QACP,iCAAc;QACd,6BAAY;QACZ,iDAAsB;QACtB,mDAAuB;QACvB,8BAAa;QACb,qCAAgB;QAChB,sBAAS;QACT,iCAAc;QACd,6CAAoB;KACrB;IACD,QAAQ,EAAE;QACR,0CAAmB;QACnB,gCAAc;QACd,yCAAkB;QAClB,8CAAqB;QACrB,8CAAqB;QACrB,6BAAY;QACZ,0BAAW;QACX,6CAAoB;QACpB,8BAAa;QACb,oBAAQ;QACR,6BAAY;QACZ,kCAAe;QACf,+CAAqB;QACrB,qDAAwB;QACxB,yDAA0B;KAC3B;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const removeFromUser: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
3
|
+
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
}>, {
|
|
5
|
+
userId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
features: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
7
|
+
communityTopics: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
8
|
+
communityTopicGroups: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
9
|
+
meditationCategories: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeFromUser = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const __1 = require("../..");
|
|
6
|
+
const actions_1 = require("../common/actions");
|
|
7
|
+
const name = 'removeFromUser';
|
|
8
|
+
exports.removeFromUser = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.coasyAuth,
|
|
10
|
+
name,
|
|
11
|
+
displayName: 'Remove From User',
|
|
12
|
+
description: 'Removes features, community topics, community topic groups, or meditation categories from a user. Values the user does not have are ignored without raising an error',
|
|
13
|
+
props: {
|
|
14
|
+
userId: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'User ID',
|
|
16
|
+
description: 'ID of User',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
features: pieces_framework_1.Property.Array({
|
|
20
|
+
displayName: 'Features',
|
|
21
|
+
description: 'List of feature IDs to remove',
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
communityTopics: pieces_framework_1.Property.Array({
|
|
25
|
+
displayName: 'Community Topics',
|
|
26
|
+
description: 'List of community topic IDs to remove',
|
|
27
|
+
required: false,
|
|
28
|
+
}),
|
|
29
|
+
communityTopicGroups: pieces_framework_1.Property.Array({
|
|
30
|
+
displayName: 'Community Topic Groups',
|
|
31
|
+
description: 'List of community topic group IDs to remove',
|
|
32
|
+
required: false,
|
|
33
|
+
}),
|
|
34
|
+
meditationCategories: pieces_framework_1.Property.Array({
|
|
35
|
+
displayName: 'Meditation Categories',
|
|
36
|
+
description: 'List of meditation category IDs to remove. The format is "libraryId/categoryId"',
|
|
37
|
+
required: false,
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
run: (configValue) => (0, actions_1.runCoasyAction)(configValue, name),
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=remove-from-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-from-user.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/actions/remove-from-user.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,6BAAkC;AAClC,+CAAmD;AAEnD,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAEjB,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,aAAS;IACf,IAAI;IACJ,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EACT,sKAAsK;IACxK,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,YAAY;YACzB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACvB,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,eAAe,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC9B,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,oBAAoB,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACnC,WAAW,EAAE,wBAAwB;YACrC,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,oBAAoB,EAAE,2BAAQ,CAAC,KAAK,CAAC;YACnC,WAAW,EAAE,uBAAuB;YACpC,WAAW,EACT,iFAAiF;YACnF,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACD,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,IAAA,wBAAc,EAAC,WAAW,EAAE,IAAI,CAAC;CACxD,CAAC,CAAC"}
|