@activepieces/piece-paddle 0.0.1

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 (61) hide show
  1. package/package.json +17 -0
  2. package/src/index.d.ts +3 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/index.js +58 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/cancel-subscription.d.ts +6 -0
  7. package/src/lib/actions/cancel-subscription.d.ts.map +1 -0
  8. package/src/lib/actions/cancel-subscription.js +55 -0
  9. package/src/lib/actions/cancel-subscription.js.map +1 -0
  10. package/src/lib/actions/create-transaction.d.ts +9 -0
  11. package/src/lib/actions/create-transaction.d.ts.map +1 -0
  12. package/src/lib/actions/create-transaction.js +70 -0
  13. package/src/lib/actions/create-transaction.js.map +1 -0
  14. package/src/lib/actions/get-subscription.d.ts +5 -0
  15. package/src/lib/actions/get-subscription.d.ts.map +1 -0
  16. package/src/lib/actions/get-subscription.js +32 -0
  17. package/src/lib/actions/get-subscription.js.map +1 -0
  18. package/src/lib/actions/list-customers.d.ts +7 -0
  19. package/src/lib/actions/list-customers.d.ts.map +1 -0
  20. package/src/lib/actions/list-customers.js +75 -0
  21. package/src/lib/actions/list-customers.js.map +1 -0
  22. package/src/lib/actions/update-subscription.d.ts +9 -0
  23. package/src/lib/actions/update-subscription.d.ts.map +1 -0
  24. package/src/lib/actions/update-subscription.js +88 -0
  25. package/src/lib/actions/update-subscription.js.map +1 -0
  26. package/src/lib/auth.d.ts +6 -0
  27. package/src/lib/auth.d.ts.map +1 -0
  28. package/src/lib/auth.js +32 -0
  29. package/src/lib/auth.js.map +1 -0
  30. package/src/lib/common/client.d.ts +112 -0
  31. package/src/lib/common/client.d.ts.map +1 -0
  32. package/src/lib/common/client.js +210 -0
  33. package/src/lib/common/client.js.map +1 -0
  34. package/src/lib/common/props.d.ts +12 -0
  35. package/src/lib/common/props.d.ts.map +1 -0
  36. package/src/lib/common/props.js +319 -0
  37. package/src/lib/common/props.js.map +1 -0
  38. package/src/lib/common/utils.d.ts +33 -0
  39. package/src/lib/common/utils.d.ts.map +1 -0
  40. package/src/lib/common/utils.js +79 -0
  41. package/src/lib/common/utils.js.map +1 -0
  42. package/src/lib/triggers/new-active-subscription.d.ts +3 -0
  43. package/src/lib/triggers/new-active-subscription.d.ts.map +1 -0
  44. package/src/lib/triggers/new-active-subscription.js +56 -0
  45. package/src/lib/triggers/new-active-subscription.js.map +1 -0
  46. package/src/lib/triggers/payment-failed.d.ts +3 -0
  47. package/src/lib/triggers/payment-failed.d.ts.map +1 -0
  48. package/src/lib/triggers/payment-failed.js +63 -0
  49. package/src/lib/triggers/payment-failed.js.map +1 -0
  50. package/src/lib/triggers/subscription-canceled.d.ts +3 -0
  51. package/src/lib/triggers/subscription-canceled.d.ts.map +1 -0
  52. package/src/lib/triggers/subscription-canceled.js +57 -0
  53. package/src/lib/triggers/subscription-canceled.js.map +1 -0
  54. package/src/lib/triggers/subscription-past-due.d.ts +3 -0
  55. package/src/lib/triggers/subscription-past-due.d.ts.map +1 -0
  56. package/src/lib/triggers/subscription-past-due.js +56 -0
  57. package/src/lib/triggers/subscription-past-due.js.map +1 -0
  58. package/src/lib/triggers/transaction-completed.d.ts +3 -0
  59. package/src/lib/triggers/transaction-completed.d.ts.map +1 -0
  60. package/src/lib/triggers/transaction-completed.js +64 -0
  61. package/src/lib/triggers/transaction-completed.js.map +1 -0
@@ -0,0 +1,112 @@
1
+ import { PaddleAuthType } from '../auth';
2
+ declare function validateAuth({ apiKey, }: {
3
+ apiKey: string;
4
+ }): Promise<void>;
5
+ declare function listCustomers({ auth, limit, email, status, }: {
6
+ auth: PaddleAuthType;
7
+ limit?: number;
8
+ email?: string;
9
+ status?: PaddleCustomerStatus;
10
+ }): Promise<PaddleCustomer[]>;
11
+ declare function listSubscriptions({ auth, limit, customerId, status, }: {
12
+ auth: PaddleAuthType;
13
+ limit?: number;
14
+ customerId?: string;
15
+ status?: PaddleSubscriptionStatus;
16
+ }): Promise<PaddleSubscription[]>;
17
+ declare function listPrices({ auth, limit, recurring, }: {
18
+ auth: PaddleAuthType;
19
+ limit?: number;
20
+ recurring?: boolean;
21
+ }): Promise<PaddlePrice[]>;
22
+ declare function getSubscription({ auth, subscriptionId, }: {
23
+ auth: PaddleAuthType;
24
+ subscriptionId: string;
25
+ }): Promise<PaddleSubscription>;
26
+ declare function updateSubscription({ auth, subscriptionId, request, }: {
27
+ auth: PaddleAuthType;
28
+ subscriptionId: string;
29
+ request: Record<string, unknown>;
30
+ }): Promise<PaddleSubscription>;
31
+ declare function listAddresses({ auth, customerId, }: {
32
+ auth: PaddleAuthType;
33
+ customerId: string;
34
+ }): Promise<Array<{
35
+ id: string;
36
+ }>>;
37
+ declare function createNotificationSetting({ auth, url, subscribedEvents, }: {
38
+ auth: PaddleAuthType;
39
+ url: string;
40
+ subscribedEvents: string[];
41
+ }): Promise<{
42
+ id: string;
43
+ }>;
44
+ declare function deleteNotificationSetting({ auth, notificationSettingId, }: {
45
+ auth: PaddleAuthType;
46
+ notificationSettingId: string;
47
+ }): Promise<void>;
48
+ declare function cancelSubscription({ auth, subscriptionId, request, }: {
49
+ auth: PaddleAuthType;
50
+ subscriptionId: string;
51
+ request: Record<string, unknown>;
52
+ }): Promise<PaddleSubscription>;
53
+ declare function createTransaction({ auth, request, }: {
54
+ auth: PaddleAuthType;
55
+ request: Record<string, unknown>;
56
+ }): Promise<PaddleTransaction>;
57
+ declare function getBaseUrl({ apiKey, }: {
58
+ apiKey: string;
59
+ }): string;
60
+ declare const paddleClient: {
61
+ cancelSubscription: typeof cancelSubscription;
62
+ createNotificationSetting: typeof createNotificationSetting;
63
+ createTransaction: typeof createTransaction;
64
+ deleteNotificationSetting: typeof deleteNotificationSetting;
65
+ getBaseUrl: typeof getBaseUrl;
66
+ getSubscription: typeof getSubscription;
67
+ listAddresses: typeof listAddresses;
68
+ listCustomers: typeof listCustomers;
69
+ listPrices: typeof listPrices;
70
+ listSubscriptions: typeof listSubscriptions;
71
+ updateSubscription: typeof updateSubscription;
72
+ validateAuth: typeof validateAuth;
73
+ };
74
+ type PaddleCustomer = {
75
+ id: string;
76
+ name?: string | null;
77
+ email?: string | null;
78
+ status?: PaddleCustomerStatus;
79
+ };
80
+ type PaddlePrice = {
81
+ id: string;
82
+ name?: string | null;
83
+ description?: string | null;
84
+ status?: string | null;
85
+ unit_price?: {
86
+ amount?: string | null;
87
+ currency_code?: string | null;
88
+ };
89
+ };
90
+ type PaddleSubscription = {
91
+ id: string;
92
+ customer_id?: string | null;
93
+ status?: PaddleSubscriptionStatus;
94
+ items?: Array<{
95
+ price?: {
96
+ id?: string | null;
97
+ name?: string | null;
98
+ };
99
+ quantity?: number | null;
100
+ }>;
101
+ };
102
+ type PaddleTransaction = {
103
+ id: string;
104
+ status?: string | null;
105
+ checkout?: {
106
+ url?: string | null;
107
+ } | null;
108
+ };
109
+ type PaddleCustomerStatus = 'active' | 'archived';
110
+ type PaddleSubscriptionStatus = 'active' | 'canceled' | 'past_due' | 'paused' | 'trialing';
111
+ export { paddleClient };
112
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,iBAAe,YAAY,CAAC,EAC1B,MAAM,GACP,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAShB;AAED,iBAAe,aAAa,CAAC,EAC3B,IAAI,EACJ,KAAyB,EACzB,KAAK,EACL,MAAM,GACP,EAAE;IACD,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAU5B;AAED,iBAAe,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B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC;CACH,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,KAAK,CAAC,EAAE;YACN,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;SACtB,CAAC;QACF,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B,CAAC,CAAC;CACJ,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE;QACT,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,GAAG,IAAI,CAAC;CACV,CAAC;AAEF,KAAK,oBAAoB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAElD,KAAK,wBAAwB,GACzB,QAAQ,GACR,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,CAAC;AAEf,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paddleClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ function validateAuth(_a) {
7
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, }) {
8
+ yield sendRequestWithApiKey({
9
+ apiKey,
10
+ method: pieces_common_1.HttpMethod.GET,
11
+ path: '/customers',
12
+ queryParams: {
13
+ per_page: '1',
14
+ },
15
+ });
16
+ });
17
+ }
18
+ function listCustomers(_a) {
19
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, limit = DEFAULT_PAGE_SIZE, email, status, }) {
20
+ return collectPaginatedItems({
21
+ auth,
22
+ path: '/customers',
23
+ limit,
24
+ queryParams: Object.assign(Object.assign({}, (email ? { email } : {})), (status ? { status } : {})),
25
+ });
26
+ });
27
+ }
28
+ function listSubscriptions(_a) {
29
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, limit = DEFAULT_PAGE_SIZE, customerId, status, }) {
30
+ return collectPaginatedItems({
31
+ auth,
32
+ path: '/subscriptions',
33
+ limit,
34
+ queryParams: Object.assign(Object.assign({}, (customerId ? { customer_id: customerId } : {})), (status ? { status } : {})),
35
+ });
36
+ });
37
+ }
38
+ function listPrices(_a) {
39
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, limit = DEFAULT_PAGE_SIZE, recurring = true, }) {
40
+ return collectPaginatedItems({
41
+ auth,
42
+ path: '/prices',
43
+ limit,
44
+ queryParams: Object.assign({ status: 'active' }, (recurring ? { recurring: 'true' } : {})),
45
+ });
46
+ });
47
+ }
48
+ function getSubscription(_a) {
49
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, subscriptionId, }) {
50
+ const response = yield sendRequest({
51
+ auth,
52
+ method: pieces_common_1.HttpMethod.GET,
53
+ path: `/subscriptions/${encodeURIComponent(subscriptionId)}`,
54
+ });
55
+ return response.data;
56
+ });
57
+ }
58
+ function updateSubscription(_a) {
59
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, subscriptionId, request, }) {
60
+ const response = yield sendRequest({
61
+ auth,
62
+ method: pieces_common_1.HttpMethod.PATCH,
63
+ path: `/subscriptions/${encodeURIComponent(subscriptionId)}`,
64
+ body: request,
65
+ });
66
+ return response.data;
67
+ });
68
+ }
69
+ function listAddresses(_a) {
70
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, customerId, }) {
71
+ const response = yield sendRequest({
72
+ auth,
73
+ method: pieces_common_1.HttpMethod.GET,
74
+ path: `/customers/${encodeURIComponent(customerId)}/addresses`,
75
+ });
76
+ return response.data;
77
+ });
78
+ }
79
+ function createNotificationSetting(_a) {
80
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, url, subscribedEvents, }) {
81
+ const response = yield sendRequest({
82
+ auth,
83
+ method: pieces_common_1.HttpMethod.POST,
84
+ path: '/notification-settings',
85
+ body: {
86
+ type: 'url',
87
+ destination: url,
88
+ subscribed_events: subscribedEvents,
89
+ active: true,
90
+ description: "Activepieces"
91
+ },
92
+ });
93
+ return response.data;
94
+ });
95
+ }
96
+ function deleteNotificationSetting(_a) {
97
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, notificationSettingId, }) {
98
+ yield sendRequest({
99
+ auth,
100
+ method: pieces_common_1.HttpMethod.DELETE,
101
+ path: `/notification-settings/${encodeURIComponent(notificationSettingId)}`,
102
+ });
103
+ });
104
+ }
105
+ function cancelSubscription(_a) {
106
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, subscriptionId, request, }) {
107
+ const response = yield sendRequest({
108
+ auth,
109
+ method: pieces_common_1.HttpMethod.POST,
110
+ path: `/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`,
111
+ body: request,
112
+ });
113
+ return response.data;
114
+ });
115
+ }
116
+ function createTransaction(_a) {
117
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, request, }) {
118
+ const response = yield sendRequest({
119
+ auth,
120
+ method: pieces_common_1.HttpMethod.POST,
121
+ path: '/transactions',
122
+ body: request,
123
+ });
124
+ return response.data;
125
+ });
126
+ }
127
+ function getBaseUrl({ apiKey, }) {
128
+ return apiKey.includes('_sdbx_')
129
+ ? PADDLE_SANDBOX_API_BASE_URL
130
+ : PADDLE_LIVE_API_BASE_URL;
131
+ }
132
+ function collectPaginatedItems(_a) {
133
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, path, limit, queryParams, }) {
134
+ var _b, _c, _d;
135
+ const items = [];
136
+ let after;
137
+ while (items.length < limit) {
138
+ const response = yield sendRequest({
139
+ auth,
140
+ method: pieces_common_1.HttpMethod.GET,
141
+ path,
142
+ queryParams: Object.assign(Object.assign(Object.assign({}, queryParams), { per_page: String(Math.min(limit - items.length, PADDLE_MAX_PAGE_SIZE)) }), (after ? { after } : {})),
143
+ });
144
+ items.push(...response.data);
145
+ const nextAfter = getNextAfter({
146
+ nextUrl: (_d = (_c = (_b = response.meta) === null || _b === void 0 ? void 0 : _b.pagination) === null || _c === void 0 ? void 0 : _c.next) !== null && _d !== void 0 ? _d : null,
147
+ });
148
+ if (!nextAfter || response.data.length === 0) {
149
+ break;
150
+ }
151
+ after = nextAfter;
152
+ }
153
+ return items;
154
+ });
155
+ }
156
+ function sendRequest(_a) {
157
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, method, path, body, queryParams, }) {
158
+ return sendRequestWithApiKey({
159
+ apiKey: auth.secret_text,
160
+ method,
161
+ path,
162
+ body,
163
+ queryParams,
164
+ });
165
+ });
166
+ }
167
+ function sendRequestWithApiKey(_a) {
168
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ apiKey, method, path, body, queryParams, }) {
169
+ const request = Object.assign(Object.assign({ method, url: `${getBaseUrl({ apiKey })}${path}`, headers: buildHeaders({
170
+ apiKey,
171
+ }) }, (body ? { body } : {})), (queryParams ? { queryParams } : {}));
172
+ const response = yield pieces_common_1.httpClient.sendRequest(request);
173
+ return response.body;
174
+ });
175
+ }
176
+ function buildHeaders({ apiKey, }) {
177
+ return {
178
+ Accept: 'application/json',
179
+ Authorization: `Bearer ${apiKey}`,
180
+ 'Content-Type': 'application/json',
181
+ 'Paddle-Version': '1',
182
+ };
183
+ }
184
+ function getNextAfter({ nextUrl, }) {
185
+ var _a;
186
+ if (!nextUrl) {
187
+ return undefined;
188
+ }
189
+ return (_a = new URL(nextUrl).searchParams.get('after')) !== null && _a !== void 0 ? _a : undefined;
190
+ }
191
+ const DEFAULT_PAGE_SIZE = 100;
192
+ const PADDLE_MAX_PAGE_SIZE = 200;
193
+ const PADDLE_LIVE_API_BASE_URL = 'https://api.paddle.com';
194
+ const PADDLE_SANDBOX_API_BASE_URL = 'https://sandbox-api.paddle.com';
195
+ const paddleClient = {
196
+ cancelSubscription,
197
+ createNotificationSetting,
198
+ createTransaction,
199
+ deleteNotificationSetting,
200
+ getBaseUrl,
201
+ getSubscription,
202
+ listAddresses,
203
+ listCustomers,
204
+ listPrices,
205
+ listSubscriptions,
206
+ updateSubscription,
207
+ validateAuth,
208
+ };
209
+ exports.paddleClient = paddleClient;
210
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/lib/common/client.ts"],"names":[],"mappings":";;;;AAAA,+DAAkF;AAIlF,SAAe,YAAY;iEAAC,EAC1B,MAAM,GAGP;QACC,MAAM,qBAAqB,CAAqC;YAC9D,MAAM;YACN,MAAM,EAAE,0BAAU,CAAC,GAAG;YACtB,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE;gBACX,QAAQ,EAAE,GAAG;aACd;SACF,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAe,aAAa;iEAAC,EAC3B,IAAI,EACJ,KAAK,GAAG,iBAAiB,EACzB,KAAK,EACL,MAAM,GAMP;QACC,OAAO,qBAAqB,CAAiB;YAC3C,IAAI;YACJ,IAAI,EAAE,YAAY;YAClB,KAAK;YACL,WAAW,kCACN,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACxB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9B;SACF,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAe,iBAAiB;iEAAC,EAC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ACtB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EACpB,OAAO,GAGR;;IACC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAA,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,mCAAI,SAAS,CAAC;AACjE,CAAC;AAED,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AAErE,MAAM,YAAY,GAAG;IACnB,kBAAkB;IAClB,yBAAyB;IACzB,iBAAiB;IACjB,yBAAyB;IACzB,UAAU;IACV,eAAe;IACf,aAAa;IACb,aAAa;IACb,UAAU;IACV,iBAAiB;IACjB,kBAAkB;IAClB,YAAY;CACb,CAAC;AAiEO,oCAAY"}
@@ -0,0 +1,12 @@
1
+ declare function customer(required?: boolean): import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").SecretTextProperty<true>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
2
+ declare function address(required?: boolean): import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").SecretTextProperty<true>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
3
+ declare function subscription(required?: boolean): import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").SecretTextProperty<true>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
4
+ declare function recurringPrice(required?: boolean): import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").SecretTextProperty<true>> | import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
5
+ declare const paddleProps: {
6
+ customer: typeof customer;
7
+ recurringPrice: typeof recurringPrice;
8
+ subscription: typeof subscription;
9
+ address: typeof address;
10
+ };
11
+ export { paddleProps };
12
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/props.ts"],"names":[],"mappings":"AAMA,iBAAS,QAAQ,CAAC,QAAQ,UAAO,4RA8DhC;AAED,iBAAS,OAAO,CAAC,QAAQ,UAAO,4RAoE/B;AAED,iBAAS,YAAY,CAAC,QAAQ,UAAO,4RAyDpC;AAED,iBAAS,cAAc,CAAC,QAAQ,UAAO,4RA0DtC;AA0PD,QAAA,MAAM,WAAW;;;;;CAKhB,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paddleProps = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const shared_1 = require("@activepieces/shared");
7
+ const auth_1 = require("../auth");
8
+ const client_1 = require("./client");
9
+ function customer(required = true) {
10
+ return pieces_framework_1.Property.Dropdown({
11
+ displayName: 'Customer',
12
+ description: 'Select the Paddle customer to use.',
13
+ required,
14
+ refreshers: ['auth'],
15
+ auth: auth_1.paddleAuth,
16
+ options: (_a) => tslib_1.__awaiter(this, [_a], void 0, function* ({ auth, searchValue }) {
17
+ if (!auth) {
18
+ return {
19
+ disabled: true,
20
+ options: [],
21
+ placeholder: 'Connect your Paddle account first.',
22
+ };
23
+ }
24
+ const normalizedSearchValue = normalizeSearchValue({
25
+ searchValue,
26
+ });
27
+ const { data: customers, error } = yield (0, shared_1.tryCatch)(() => client_1.paddleClient.listCustomers(Object.assign({ auth, limit: DEFAULT_DROPDOWN_LIMIT }, ((normalizedSearchValue === null || normalizedSearchValue === void 0 ? void 0 : normalizedSearchValue.includes('@'))
28
+ ? { email: normalizedSearchValue }
29
+ : {}))));
30
+ if (error) {
31
+ return {
32
+ disabled: true,
33
+ options: [],
34
+ placeholder: 'Failed to load customers. Check your connection.',
35
+ };
36
+ }
37
+ const filteredCustomers = filterCustomers({
38
+ customers,
39
+ searchValue: normalizedSearchValue,
40
+ });
41
+ if (filteredCustomers.length === 0) {
42
+ return {
43
+ disabled: false,
44
+ options: [],
45
+ placeholder: 'No customers found in Paddle.',
46
+ };
47
+ }
48
+ return {
49
+ disabled: false,
50
+ options: filteredCustomers.map((customerItem) => ({
51
+ label: buildCustomerLabel({
52
+ customer: customerItem,
53
+ }),
54
+ value: customerItem.id,
55
+ })),
56
+ };
57
+ }),
58
+ });
59
+ }
60
+ function address(required = true) {
61
+ return pieces_framework_1.Property.Dropdown({
62
+ displayName: 'Address',
63
+ description: 'Select the Paddle address to bill against.',
64
+ required,
65
+ refreshers: ['auth', 'customerId'],
66
+ auth: auth_1.paddleAuth,
67
+ options: (_a) => tslib_1.__awaiter(this, [_a], void 0, function* ({ auth, customerId, searchValue }) {
68
+ if (!auth) {
69
+ return {
70
+ disabled: true,
71
+ options: [],
72
+ placeholder: 'Connect your Paddle account first.',
73
+ };
74
+ }
75
+ if (!customerId || typeof customerId !== 'string') {
76
+ return {
77
+ disabled: true,
78
+ options: [],
79
+ placeholder: 'Select a customer first.',
80
+ };
81
+ }
82
+ const normalizedSearchValue = normalizeSearchValue({
83
+ searchValue,
84
+ });
85
+ const { data: addresses, error } = yield (0, shared_1.tryCatch)(() => client_1.paddleClient.listAddresses({
86
+ auth,
87
+ customerId,
88
+ }));
89
+ if (error) {
90
+ return {
91
+ disabled: true,
92
+ options: [],
93
+ placeholder: 'Failed to load addresses. Check your connection.',
94
+ };
95
+ }
96
+ const filteredAddresses = filterAddresses({
97
+ addresses,
98
+ searchValue: normalizedSearchValue,
99
+ });
100
+ if (filteredAddresses.length === 0) {
101
+ return {
102
+ disabled: false,
103
+ options: [],
104
+ placeholder: 'No addresses found in Paddle.',
105
+ };
106
+ }
107
+ return {
108
+ disabled: false,
109
+ options: filteredAddresses.map((addressItem) => ({
110
+ label: buildAddressLabel({
111
+ address: addressItem,
112
+ }),
113
+ value: addressItem.id,
114
+ })),
115
+ };
116
+ }),
117
+ });
118
+ }
119
+ function subscription(required = true) {
120
+ return pieces_framework_1.Property.Dropdown({
121
+ displayName: 'Subscription',
122
+ description: 'Select the Paddle subscription to use.',
123
+ required,
124
+ refreshers: ['auth'],
125
+ auth: auth_1.paddleAuth,
126
+ options: (_a) => tslib_1.__awaiter(this, [_a], void 0, function* ({ auth, searchValue }) {
127
+ if (!auth) {
128
+ return {
129
+ disabled: true,
130
+ options: [],
131
+ placeholder: 'Connect your Paddle account first.',
132
+ };
133
+ }
134
+ const { data: subscriptions, error } = yield (0, shared_1.tryCatch)(() => client_1.paddleClient.listSubscriptions({
135
+ auth,
136
+ limit: DEFAULT_DROPDOWN_LIMIT,
137
+ }));
138
+ if (error) {
139
+ return {
140
+ disabled: true,
141
+ options: [],
142
+ placeholder: 'Failed to load subscriptions. Check your connection.',
143
+ };
144
+ }
145
+ const filteredSubscriptions = filterSubscriptions({
146
+ subscriptions,
147
+ searchValue: normalizeSearchValue({
148
+ searchValue,
149
+ }),
150
+ });
151
+ if (filteredSubscriptions.length === 0) {
152
+ return {
153
+ disabled: false,
154
+ options: [],
155
+ placeholder: 'No subscriptions found in Paddle.',
156
+ };
157
+ }
158
+ return {
159
+ disabled: false,
160
+ options: filteredSubscriptions.map((subscriptionItem) => ({
161
+ label: buildSubscriptionLabel({
162
+ subscription: subscriptionItem,
163
+ }),
164
+ value: subscriptionItem.id,
165
+ })),
166
+ };
167
+ }),
168
+ });
169
+ }
170
+ function recurringPrice(required = true) {
171
+ return pieces_framework_1.Property.Dropdown({
172
+ displayName: 'Recurring Price',
173
+ description: 'Select an active recurring Paddle price.',
174
+ required,
175
+ refreshers: ['auth'],
176
+ auth: auth_1.paddleAuth,
177
+ options: (_a) => tslib_1.__awaiter(this, [_a], void 0, function* ({ auth, searchValue }) {
178
+ if (!auth) {
179
+ return {
180
+ disabled: true,
181
+ options: [],
182
+ placeholder: 'Connect your Paddle account first.',
183
+ };
184
+ }
185
+ const { data: prices, error } = yield (0, shared_1.tryCatch)(() => client_1.paddleClient.listPrices({
186
+ auth,
187
+ limit: DEFAULT_DROPDOWN_LIMIT,
188
+ recurring: true,
189
+ }));
190
+ if (error) {
191
+ return {
192
+ disabled: true,
193
+ options: [],
194
+ placeholder: 'Failed to load prices. Check your connection.',
195
+ };
196
+ }
197
+ const filteredPrices = filterPrices({
198
+ prices,
199
+ searchValue: normalizeSearchValue({
200
+ searchValue,
201
+ }),
202
+ });
203
+ if (filteredPrices.length === 0) {
204
+ return {
205
+ disabled: false,
206
+ options: [],
207
+ placeholder: 'No active recurring prices found in Paddle.',
208
+ };
209
+ }
210
+ return {
211
+ disabled: false,
212
+ options: filteredPrices.map((price) => ({
213
+ label: buildPriceLabel({
214
+ price,
215
+ }),
216
+ value: price.id,
217
+ })),
218
+ };
219
+ }),
220
+ });
221
+ }
222
+ function filterAddresses({ addresses, searchValue, }) {
223
+ if (!searchValue) {
224
+ return addresses;
225
+ }
226
+ return addresses.filter((addressItem) => buildAddressLabel({
227
+ address: addressItem,
228
+ })
229
+ .toLowerCase()
230
+ .includes(searchValue));
231
+ }
232
+ function buildAddressLabel({ address, }) {
233
+ const parts = [
234
+ address.country_code,
235
+ address.region,
236
+ address.postal_code,
237
+ ].filter((part) => part != null && part.trim().length > 0);
238
+ return parts.length > 0 ? parts.join(', ') : address.id;
239
+ }
240
+ function normalizeSearchValue({ searchValue, }) {
241
+ if (typeof searchValue !== 'string') {
242
+ return undefined;
243
+ }
244
+ const normalizedValue = searchValue.trim().toLowerCase();
245
+ return normalizedValue.length > 0 ? normalizedValue : undefined;
246
+ }
247
+ function filterCustomers({ customers, searchValue, }) {
248
+ if (!searchValue) {
249
+ return customers;
250
+ }
251
+ return customers.filter((customer) => buildCustomerLabel({
252
+ customer,
253
+ })
254
+ .toLowerCase()
255
+ .includes(searchValue));
256
+ }
257
+ function filterSubscriptions({ subscriptions, searchValue, }) {
258
+ if (!searchValue) {
259
+ return subscriptions;
260
+ }
261
+ return subscriptions.filter((subscriptionItem) => buildSubscriptionLabel({
262
+ subscription: subscriptionItem,
263
+ })
264
+ .toLowerCase()
265
+ .includes(searchValue));
266
+ }
267
+ function filterPrices({ prices, searchValue, }) {
268
+ if (!searchValue) {
269
+ return prices;
270
+ }
271
+ return prices.filter((price) => buildPriceLabel({
272
+ price,
273
+ })
274
+ .toLowerCase()
275
+ .includes(searchValue));
276
+ }
277
+ function buildCustomerLabel({ customer, }) {
278
+ var _a, _b, _c;
279
+ const name = (_a = customer.name) === null || _a === void 0 ? void 0 : _a.trim();
280
+ const email = (_b = customer.email) === null || _b === void 0 ? void 0 : _b.trim();
281
+ const status = (_c = customer.status) !== null && _c !== void 0 ? _c : 'unknown';
282
+ if (name && email) {
283
+ return `${name} (${email}) - ${status}`;
284
+ }
285
+ if (email) {
286
+ return `${email} - ${status}`;
287
+ }
288
+ return `${customer.id} - ${status}`;
289
+ }
290
+ function buildSubscriptionLabel({ subscription, }) {
291
+ var _a, _b, _c, _d, _e, _f;
292
+ const firstItemName = (_c = (_b = (_a = subscription.items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.price) === null || _c === void 0 ? void 0 : _c.name;
293
+ if (firstItemName) {
294
+ return `${subscription.id} (${(_d = subscription.status) !== null && _d !== void 0 ? _d : 'unknown'}, ${firstItemName})`;
295
+ }
296
+ if (subscription.customer_id) {
297
+ return `${subscription.id} (${(_e = subscription.status) !== null && _e !== void 0 ? _e : 'unknown'}, ${subscription.customer_id})`;
298
+ }
299
+ return `${subscription.id} (${(_f = subscription.status) !== null && _f !== void 0 ? _f : 'unknown'})`;
300
+ }
301
+ function buildPriceLabel({ price, }) {
302
+ var _a, _b, _c, _d;
303
+ const name = ((_a = price.name) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = price.description) === null || _b === void 0 ? void 0 : _b.trim()) || price.id;
304
+ const amount = (_c = price.unit_price) === null || _c === void 0 ? void 0 : _c.amount;
305
+ const currencyCode = (_d = price.unit_price) === null || _d === void 0 ? void 0 : _d.currency_code;
306
+ if (amount && currencyCode) {
307
+ return `${name} (${amount} ${currencyCode})`;
308
+ }
309
+ return name;
310
+ }
311
+ const DEFAULT_DROPDOWN_LIMIT = 100;
312
+ const paddleProps = {
313
+ customer,
314
+ recurringPrice,
315
+ subscription,
316
+ address,
317
+ };
318
+ exports.paddleProps = paddleProps;
319
+ //# sourceMappingURL=props.js.map