@coasy/piece-coasy 0.2.5 → 0.2.7

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-05-06)
18
+ ### Available actions (as of 2026-07-08)
19
19
 
20
20
  | Action | Endpoint | Purpose |
21
21
  | --- | --- | --- |
@@ -26,14 +26,19 @@ 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 |
30
+ | `sendEmail` | `POST /apps/actions/sendEmail` | Queue an email dispatch to a raw email address |
29
31
  | `sendPushNotification` | `POST /apps/actions/sendPushNotification` | Send a push notification to all of a user's devices |
30
32
 
31
33
  ### Gotchas worth remembering
32
34
 
33
- - **`assignToUser`** requires at least one of `features` / `communityTopics` / `communityTopicGroups` / `meditationCategories`; otherwise the server returns `400`. Cross-app `userId` returns `401`, not `404`.
35
+ - **`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.
36
+ - **`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
37
  - **`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
38
  - **`createFunnelParticipant`** lowercases `email` server-side. The response includes server-generated `funnelParticipantId`, `registrationTime`, and `timestamp`.
36
39
  - **`createVoucher`** auto-generates the voucher ID (`VOC-…`) and sets `status: "ACTIVE"`. Setting `countLeft` implicitly sets `isCountLimited: true`.
40
+ - **`sendEmail`** requires exactly one of `templateKey` / `templateId` (XOR, `400` otherwise). A `templateId` of a foreign app returns `401`, an unknown or soft-deleted one `404`. `data` is validated against the `MetaData` DTO — unknown keys are rejected with `400`.
41
+ - **`POST /apps/actions/listEmailTemplates`** is a backend endpoint the piece calls, not a piece action — it only backs the Send Email template dropdown, via `common/emailTemplates.ts`. It takes no body and returns only the app's *configured* keys, not the whole `email_templates` table. Keys whose template is gone are omitted. Several keys can share one template.
37
42
  - **`addTrialPeriod`** has its own domain error model (`AppSubscriptionError`) mapped to HTTP via `toApiErrorIfAppSubscriptionError` — surface the server's error message rather than masking it.
38
43
  - **`addTrialPeriod` funnel guard** (coasy-core PR #220): the piece's `funnelGuard` array maps to the nested body `guards: { funnel: string[] }`. Guards are checked before the user is resolved; a match is a **silent no-op success** (`subscriptionStatus: "BLOCKED"`, `blockedBy` set, HTTP 200) — nothing is created/extended. Omitting it preserves original behavior.
39
44
 
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coasy/piece-coasy",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "dependencies": {
5
5
  "@sinclair/typebox": "0.34.11",
6
6
  "axios": "1.8.3",
package/src/index.js CHANGED
@@ -7,6 +7,7 @@ const create_funnel_participant_1 = require("./lib/actions/create-funnel-partici
7
7
  const create_voucher_1 = require("./lib/actions/create-voucher");
8
8
  const enroll_user_course_1 = require("./lib/actions/enroll-user-course");
9
9
  const find_event_1 = require("./lib/actions/find-event");
10
+ const send_email_1 = require("./lib/actions/send-email");
10
11
  const send_push_notification_1 = require("./lib/actions/send-push-notification");
11
12
  const cancelled_membership_1 = require("./lib/triggers/cancelled-membership");
12
13
  const cancelled_order_1 = require("./lib/triggers/cancelled-order");
@@ -25,6 +26,7 @@ const webinar_participant_attend_1 = require("./lib/triggers/webinar-participant
25
26
  const webinar_participant_reminder_1 = require("./lib/triggers/webinar-participant-reminder");
26
27
  const add_trial_period_1 = require("./lib/actions/add-trial-period");
27
28
  const assign_to_user_1 = require("./lib/actions/assign-to-user");
29
+ const remove_from_user_1 = require("./lib/actions/remove-from-user");
28
30
  exports.coasyAuth = pieces_framework_1.PieceAuth.CustomAuth({
29
31
  required: true,
30
32
  description: 'Enter coasy authentication details',
@@ -57,6 +59,8 @@ exports.coasy = (0, pieces_framework_1.createPiece)({
57
59
  create_voucher_1.createVoucher,
58
60
  enroll_user_course_1.enrollUserCourse,
59
61
  find_event_1.findEvent,
62
+ remove_from_user_1.removeFromUser,
63
+ send_email_1.sendEmail,
60
64
  send_push_notification_1.sendPushNotification,
61
65
  ],
62
66
  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;AAE/C,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,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"}
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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ACZ,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"}
@@ -0,0 +1,12 @@
1
+ export declare const sendEmail: 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
+ toEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
6
+ toName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
+ templateKey: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
8
+ templateId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ bcc: import("@activepieces/pieces-framework").ArrayProperty<false>;
10
+ data: import("@activepieces/pieces-framework").ObjectProperty<false>;
11
+ attachments: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
12
+ }>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendEmail = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const index_1 = require("../../index");
6
+ const actions_1 = require("../common/actions");
7
+ const emailTemplates_1 = require("../common/emailTemplates");
8
+ const name = 'sendEmail';
9
+ exports.sendEmail = (0, pieces_framework_1.createAction)({
10
+ auth: index_1.coasyAuth,
11
+ name,
12
+ displayName: 'Send Email',
13
+ description: 'Queues an email dispatch to a raw email address',
14
+ props: {
15
+ toEmail: pieces_framework_1.Property.ShortText({
16
+ displayName: 'To Email',
17
+ description: 'Recipient email address',
18
+ required: true,
19
+ }),
20
+ toName: pieces_framework_1.Property.ShortText({
21
+ displayName: 'To Name',
22
+ description: 'Optional recipient name',
23
+ required: false,
24
+ }),
25
+ templateKey: emailTemplates_1.emailTemplateKey,
26
+ templateId: emailTemplates_1.emailTemplateId,
27
+ bcc: pieces_framework_1.Property.Array({
28
+ displayName: 'BCC',
29
+ description: 'Optional blind copy recipients',
30
+ required: false,
31
+ }),
32
+ data: pieces_framework_1.Property.Object({
33
+ displayName: 'Template Variables',
34
+ description: 'Optional template variables. Only keys known to the Coasy MetaData DTO are accepted, e.g. firstName, lastName, link, voucherCode — unknown keys are rejected with a 400.',
35
+ required: false,
36
+ }),
37
+ attachments: pieces_framework_1.Property.Array({
38
+ displayName: 'Attachments',
39
+ required: false,
40
+ properties: {
41
+ filename: pieces_framework_1.Property.ShortText({
42
+ displayName: 'Filename',
43
+ required: true,
44
+ }),
45
+ contentType: pieces_framework_1.Property.ShortText({
46
+ displayName: 'Content Type',
47
+ description: 'MIME type, e.g. application/pdf',
48
+ required: true,
49
+ }),
50
+ base64Content: pieces_framework_1.Property.LongText({
51
+ displayName: 'Base64 Content',
52
+ required: true,
53
+ }),
54
+ },
55
+ }),
56
+ },
57
+ // templateKey / templateId are XOR — both optional here, the server rejects both-or-neither.
58
+ run: (configValue) => (0, actions_1.runCoasyAction)(configValue, name),
59
+ });
60
+ //# sourceMappingURL=send-email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-email.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/actions/send-email.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,uCAAwC;AACxC,+CAAmD;AACnD,6DAA6E;AAE7E,MAAM,IAAI,GAAG,WAAW,CAAC;AAEZ,QAAA,SAAS,GAAG,IAAA,+BAAY,EAAC;IACpC,IAAI,EAAE,iBAAS;IACf,IAAI;IACJ,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,iDAAiD;IAC9D,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,WAAW,EAAE,iCAAgB;QAC7B,UAAU,EAAE,gCAAe;QAC3B,GAAG,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAClB,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,gCAAgC;YAC7C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,oBAAoB;YACjC,WAAW,EACT,0KAA0K;YAC5K,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE;gBACV,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBAC3B,WAAW,EAAE,UAAU;oBACvB,QAAQ,EAAE,IAAI;iBACf,CAAC;gBACF,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBAC9B,WAAW,EAAE,cAAc;oBAC3B,WAAW,EAAE,iCAAiC;oBAC9C,QAAQ,EAAE,IAAI;iBACf,CAAC;gBACF,aAAa,EAAE,2BAAQ,CAAC,QAAQ,CAAC;oBAC/B,WAAW,EAAE,gBAAgB;oBAC7B,QAAQ,EAAE,IAAI;iBACf,CAAC;aACH;SACF,CAAC;KACH;IACD,6FAA6F;IAC7F,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,IAAA,wBAAc,EAAC,WAAW,EAAE,IAAI,CAAC;CACxD,CAAC,CAAC"}
@@ -4,9 +4,8 @@ exports.runCoasyAction = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const coasyClient_1 = require("./coasyClient");
6
6
  const runCoasyAction = (configValue, action, request) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
7
- var _a;
8
7
  const { propsValue, auth: authPayload } = configValue;
9
- const client = new coasyClient_1.CoasyClient((_a = authPayload.baseUrl) !== null && _a !== void 0 ? _a : 'https://backend.api.prod.coasy.io', authPayload.apiKey);
8
+ const client = (0, coasyClient_1.createCoasyClient)(authPayload);
10
9
  const body = Object.assign({}, (request !== null && request !== void 0 ? request : propsValue));
11
10
  delete body['auth'];
12
11
  return client.action(action, body);
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/common/actions.ts"],"names":[],"mappings":";;;;AAKA,+CAA4C;AAErC,MAAM,cAAc,GAAG,CAC5B,WAA+C,EAC/C,MAAc,EACd,OAAiC,EACjC,EAAE;;IACF,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,yBAAW,CAC5B,MAAA,WAAW,CAAC,OAAO,mCAAI,mCAAmC,EAC1D,WAAW,CAAC,MAAM,CACnB,CAAC;IAEF,MAAM,IAAI,qBAAQ,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,UAAU,CAAC,CAAE,CAAC;IAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAfW,QAAA,cAAc,kBAezB"}
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/common/actions.ts"],"names":[],"mappings":";;;;AAKA,+CAAkD;AAE3C,MAAM,cAAc,GAAG,CAC5B,WAA+C,EAC/C,MAAc,EACd,OAAiC,EACjC,EAAE;IACF,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IACtD,MAAM,MAAM,GAAG,IAAA,+BAAiB,EAAC,WAAW,CAAC,CAAC;IAE9C,MAAM,IAAI,qBAAQ,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,UAAU,CAAC,CAAE,CAAC;IAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAZW,QAAA,cAAc,kBAYzB"}
@@ -1,3 +1,8 @@
1
+ export type CoasyAuth = {
2
+ baseUrl?: string;
3
+ apiKey: string;
4
+ };
5
+ export declare const DEFAULT_BASE_URL = "https://backend.api.prod.coasy.io";
1
6
  export declare class CoasyClient {
2
7
  private baseUrl;
3
8
  private apiKey;
@@ -8,3 +13,4 @@ export declare class CoasyClient {
8
13
  pollTriggerExample(trigger: string): Promise<any>;
9
14
  request(path: string, requestBody: any): Promise<any>;
10
15
  }
16
+ export declare const createCoasyClient: (auth: CoasyAuth) => CoasyClient;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoasyClient = void 0;
3
+ exports.createCoasyClient = exports.CoasyClient = exports.DEFAULT_BASE_URL = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const pieces_common_1 = require("@activepieces/pieces-common");
6
+ exports.DEFAULT_BASE_URL = 'https://backend.api.prod.coasy.io';
6
7
  class CoasyClient {
7
8
  constructor(baseUrl, apiKey) {
8
9
  this.baseUrl = baseUrl;
@@ -56,4 +57,6 @@ class CoasyClient {
56
57
  }
57
58
  }
58
59
  exports.CoasyClient = CoasyClient;
60
+ const createCoasyClient = (auth) => { var _a; return new CoasyClient((_a = auth.baseUrl) !== null && _a !== void 0 ? _a : exports.DEFAULT_BASE_URL, auth.apiKey); };
61
+ exports.createCoasyClient = createCoasyClient;
59
62
  //# sourceMappingURL=coasyClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coasyClient.js","sourceRoot":"","sources":["../../../../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AG,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;KAAA;CACF;AAlDD,kCAkDC"}
1
+ {"version":3,"file":"coasyClient.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/common/coasyClient.ts"],"names":[],"mappings":";;;;AAAA,+DAKqC;AAOxB,QAAA,gBAAgB,GAAG,mCAAmC,CAAC;AAEpE,MAAa,WAAW;IAItB,YAAY,OAAe,EAAE,MAAc;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEK,MAAM,CAAC,UAAkB,EAAE,OAAY;;YAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC;KAAA;IAEK,aAAa,CAAC,OAAe,EAAE,OAAe,EAAE,MAAW;;YAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE;gBAC3C,OAAO;gBACP,OAAO;gBACP,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,cAAc,CAAC,SAAiB;;YACpC,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/D,CAAC;KAAA;IAEK,kBAAkB,CAAC,OAAe;;YACtC,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE;gBAC1C,OAAO;aACR,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,OAAO,CAAC,IAAY,EAAE,WAAgB;;YAC1C,MAAM,OAAO,GAAwB;gBACnC,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE;gBAC7B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;gBACjC,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,MAAM;iBACnB;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEvD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;KAAA;CACF;AAlDD,kCAkDC;AAEM,MAAM,iBAAiB,GAAG,CAAC,IAAe,EAAE,EAAE,WACnD,OAAA,IAAI,WAAW,CAAC,MAAA,IAAI,CAAC,OAAO,mCAAI,wBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA,EAAA,CAAC;AADpD,QAAA,iBAAiB,qBACmC"}
@@ -0,0 +1,11 @@
1
+ import { CoasyAuth } from './coasyClient';
2
+ export interface EmailTemplate {
3
+ templateKey: string;
4
+ emailTemplateId: string;
5
+ name: string;
6
+ subject: string;
7
+ language?: string;
8
+ }
9
+ export declare const fetchEmailTemplates: (auth: CoasyAuth) => Promise<EmailTemplate[]>;
10
+ export declare const emailTemplateKey: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
11
+ export declare const emailTemplateId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emailTemplateId = exports.emailTemplateKey = exports.fetchEmailTemplates = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const coasyClient_1 = require("./coasyClient");
7
+ const fetchEmailTemplates = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
8
+ var _a;
9
+ const response = (yield (0, coasyClient_1.createCoasyClient)(auth).action('listEmailTemplates', {}));
10
+ return (_a = response.templates) !== null && _a !== void 0 ? _a : [];
11
+ });
12
+ exports.fetchEmailTemplates = fetchEmailTemplates;
13
+ const templateLabel = (template) => template.language ? `${template.name} (${template.language})` : template.name;
14
+ exports.emailTemplateKey = pieces_framework_1.Property.Dropdown({
15
+ displayName: 'Email Template',
16
+ description: 'Template configured for this app under a template key. Set either this or the Template ID, not both.',
17
+ required: false,
18
+ refreshers: ['auth'],
19
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
20
+ if (!auth) {
21
+ return {
22
+ disabled: true,
23
+ placeholder: 'Connect your account',
24
+ options: [],
25
+ };
26
+ }
27
+ const templates = yield (0, exports.fetchEmailTemplates)(auth);
28
+ if (templates.length === 0) {
29
+ return {
30
+ disabled: true,
31
+ placeholder: 'This app has no email templates configured',
32
+ options: [],
33
+ };
34
+ }
35
+ return {
36
+ options: templates.map((template) => ({
37
+ label: templateLabel(template),
38
+ value: template.templateKey,
39
+ })),
40
+ };
41
+ }),
42
+ });
43
+ exports.emailTemplateId = pieces_framework_1.Property.ShortText({
44
+ displayName: 'Template ID',
45
+ description: 'ID of an email template of this app, e.g. EMT-A7O-ODB-PL7. Any template of the app works, also funnel and broadcast templates that are not bound to a template key. Set either this or the Email Template, not both.',
46
+ required: false,
47
+ });
48
+ //# sourceMappingURL=emailTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailTemplates.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/common/emailTemplates.ts"],"names":[],"mappings":";;;;AAAA,qEAA0D;AAC1D,+CAA6D;AAUtD,MAAM,mBAAmB,GAAG,CACjC,IAAe,EACW,EAAE;;IAC5B,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,+BAAiB,EAAC,IAAI,CAAC,CAAC,MAAM,CACpD,oBAAoB,EACpB,EAAE,CACH,CAAoC,C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