@coasy/piece-coasy 0.2.4 → 0.2.5
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 +1 -0
- package/package.json +15 -5
- package/src/lib/actions/add-trial-period.d.ts +1 -0
- package/src/lib/actions/add-trial-period.js +25 -1
- package/src/lib/actions/add-trial-period.js.map +1 -1
- package/src/lib/common/actions.d.ts +1 -1
- package/src/lib/common/actions.js +4 -5
- package/src/lib/common/actions.js.map +1 -1
package/CLAUDE.md
CHANGED
|
@@ -35,5 +35,6 @@ The doc is **private** — fetch it with `gh api repos/coasy/coasy-core/contents
|
|
|
35
35
|
- **`createFunnelParticipant`** lowercases `email` server-side. The response includes server-generated `funnelParticipantId`, `registrationTime`, and `timestamp`.
|
|
36
36
|
- **`createVoucher`** auto-generates the voucher ID (`VOC-…`) and sets `status: "ACTIVE"`. Setting `countLeft` implicitly sets `isCountLimited: true`.
|
|
37
37
|
- **`addTrialPeriod`** has its own domain error model (`AppSubscriptionError`) mapped to HTTP via `toApiErrorIfAppSubscriptionError` — surface the server's error message rather than masking it.
|
|
38
|
+
- **`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.
|
|
38
39
|
|
|
39
40
|
When the upstream doc changes, refresh this file by re-fetching the source via `gh api`.
|
package/package.json
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coasy/piece-coasy",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"resolutions": {
|
|
5
|
-
"rollup": "npm:@rollup/wasm-node"
|
|
6
|
-
},
|
|
3
|
+
"version": "0.2.5",
|
|
7
4
|
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.34.11",
|
|
6
|
+
"axios": "1.8.3",
|
|
7
|
+
"axios-retry": "4.4.1",
|
|
8
|
+
"deepmerge-ts": "7.1.0",
|
|
9
|
+
"mime-types": "2.1.35",
|
|
10
|
+
"nanoid": "3.3.8",
|
|
11
|
+
"semver": "7.6.0",
|
|
12
|
+
"socket.io-client": "4.8.1",
|
|
13
|
+
"zod": "3.25.76",
|
|
8
14
|
"@activepieces/pieces-common": "0.8.1",
|
|
9
15
|
"@activepieces/pieces-framework": "0.20.2",
|
|
10
|
-
"@activepieces/shared": "0.25.2"
|
|
16
|
+
"@activepieces/shared": "0.25.2",
|
|
17
|
+
"tslib": "2.6.2"
|
|
18
|
+
},
|
|
19
|
+
"resolutions": {
|
|
20
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
11
21
|
},
|
|
12
22
|
"types": "./src/index.d.ts",
|
|
13
23
|
"main": "./src/index.js",
|
|
@@ -7,4 +7,5 @@ export declare const addTrialPeriod: import("@activepieces/pieces-framework").IA
|
|
|
7
7
|
offerId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
8
|
paymentPlanId: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
9
|
firstName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
10
|
+
funnelGuard: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
10
11
|
}>;
|
|
@@ -5,6 +5,25 @@ const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
|
5
5
|
const index_1 = require("../../index");
|
|
6
6
|
const actions_1 = require("../common/actions");
|
|
7
7
|
const name = 'addTrialPeriod';
|
|
8
|
+
// Reshapes flat guard props into the nested `guards: { ... }` body the server
|
|
9
|
+
// expects. `guardSources` maps a prop name to its server guard key (e.g.
|
|
10
|
+
// `{ funnelGuard: 'funnel' }`). Blank entries are dropped and `guards` is omitted
|
|
11
|
+
// when no guard has any value.
|
|
12
|
+
const buildGuardedRequest = (request, guardSources) => {
|
|
13
|
+
const rest = Object.assign({}, request);
|
|
14
|
+
const guards = {};
|
|
15
|
+
for (const [propName, guardKey] of Object.entries(guardSources)) {
|
|
16
|
+
const value = rest[propName];
|
|
17
|
+
delete rest[propName];
|
|
18
|
+
const ids = Array.isArray(value)
|
|
19
|
+
? value.filter((id) => typeof id === 'string' && id.trim() !== '')
|
|
20
|
+
: [];
|
|
21
|
+
if (ids.length > 0) {
|
|
22
|
+
guards[guardKey] = ids;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return Object.keys(guards).length > 0 ? Object.assign(Object.assign({}, rest), { guards }) : rest;
|
|
26
|
+
};
|
|
8
27
|
exports.addTrialPeriod = (0, pieces_framework_1.createAction)({
|
|
9
28
|
auth: index_1.coasyAuth,
|
|
10
29
|
name,
|
|
@@ -36,7 +55,12 @@ exports.addTrialPeriod = (0, pieces_framework_1.createAction)({
|
|
|
36
55
|
description: 'Optional first name, forwarded when a new user is created.',
|
|
37
56
|
required: false,
|
|
38
57
|
}),
|
|
58
|
+
funnelGuard: pieces_framework_1.Property.Array({
|
|
59
|
+
displayName: 'Funnel Guard',
|
|
60
|
+
description: 'Guards against extending the trial period if the user is already a funnel participant in one of these funnels.',
|
|
61
|
+
required: false,
|
|
62
|
+
}),
|
|
39
63
|
},
|
|
40
|
-
run: (configValue) => (0, actions_1.runCoasyAction)(configValue, name),
|
|
64
|
+
run: (configValue) => (0, actions_1.runCoasyAction)(configValue, name, buildGuardedRequest(configValue.propsValue, { funnelGuard: 'funnel' })),
|
|
41
65
|
});
|
|
42
66
|
//# sourceMappingURL=add-trial-period.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-trial-period.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/coasy/src/lib/actions/add-trial-period.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,uCAAwC;AACxC,+CAAmD;AAEnD,MAAM,IAAI,GAAG,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"add-trial-period.js","sourceRoot":"","sources":["../../../../../../../../packages/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AAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,6DAA6D;YAC1E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,4DAA4D;YACzE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,2DAA2D;YACxE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EACT,wFAAwF;YAC1F,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,4DAA4D;YACzE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC1B,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,gHAAgH;YAClH,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACD,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CACnB,IAAA,wBAAc,EACZ,WAAW,EACX,IAAI,EACJ,mBAAmB,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CACvE;CACJ,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ActionContext, InputPropertyMap } from '@activepieces/pieces-framework';
|
|
2
2
|
import { coasyAuth } from '../..';
|
|
3
|
-
export declare const runCoasyAction: <T extends InputPropertyMap>(configValue: ActionContext<typeof coasyAuth, T>, action: string) => Promise<any>;
|
|
3
|
+
export declare const runCoasyAction: <T extends InputPropertyMap>(configValue: ActionContext<typeof coasyAuth, T>, action: string, request?: Record<string, unknown>) => Promise<any>;
|
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runCoasyAction = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const coasyClient_1 = require("./coasyClient");
|
|
6
|
-
const runCoasyAction = (configValue, action) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
6
|
+
const runCoasyAction = (configValue, action, request) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
7
|
var _a;
|
|
8
8
|
const { propsValue, auth: authPayload } = configValue;
|
|
9
9
|
const client = new coasyClient_1.CoasyClient((_a = authPayload.baseUrl) !== null && _a !== void 0 ? _a : 'https://backend.api.prod.coasy.io', authPayload.apiKey);
|
|
10
|
-
const
|
|
11
|
-
delete
|
|
12
|
-
|
|
13
|
-
return client.action(action, request);
|
|
10
|
+
const body = Object.assign({}, (request !== null && request !== void 0 ? request : propsValue));
|
|
11
|
+
delete body['auth'];
|
|
12
|
+
return client.action(action, body);
|
|
14
13
|
});
|
|
15
14
|
exports.runCoasyAction = runCoasyAction;
|
|
16
15
|
//# sourceMappingURL=actions.js.map
|
|
@@ -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,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,
|
|
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"}
|