@payloadcms/plugin-stripe 0.0.9 → 0.0.11
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/README.md +69 -61
- package/dist/hooks/createNewInStripe.d.ts +1 -1
- package/dist/hooks/createNewInStripe.js +1 -1
- package/dist/hooks/deleteFromStripe.d.ts +1 -1
- package/dist/hooks/deleteFromStripe.js +1 -1
- package/dist/hooks/syncExistingWithStripe.d.ts +1 -1
- package/dist/hooks/syncExistingWithStripe.js +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/routes/rest.js +3 -3
- package/dist/routes/rest.js.map +1 -1
- package/dist/routes/webhooks.js +1 -1
- package/dist/types.d.ts +9 -8
- package/dist/ui/{index.d.ts → LinkToDoc.d.ts} +1 -0
- package/dist/ui/LinkToDoc.js +36 -0
- package/dist/ui/LinkToDoc.js.map +1 -0
- package/dist/utilities/stripeProxy.js +10 -7
- package/dist/utilities/stripeProxy.js.map +1 -1
- package/dist/webhooks/handleCreatedOrUpdated.d.ts +1 -1
- package/dist/webhooks/handleCreatedOrUpdated.js +5 -3
- package/dist/webhooks/handleCreatedOrUpdated.js.map +1 -1
- package/dist/webhooks/handleDeleted.d.ts +1 -1
- package/dist/webhooks/handleDeleted.js +1 -1
- package/dist/webhooks/index.js +1 -1
- package/package.json +9 -5
- package/types.d.ts +1 -0
- package/types.js +1 -0
- package/dist/hooks/createNewStripeCustomer.d.ts +0 -2
- package/dist/hooks/createNewStripeCustomer.js +0 -104
- package/dist/hooks/createNewStripeCustomer.js.map +0 -1
- package/dist/hooks/deleteStripeCustomer.d.ts +0 -2
- package/dist/hooks/deleteStripeCustomer.js +0 -74
- package/dist/hooks/deleteStripeCustomer.js.map +0 -1
- package/dist/hooks/syncExistingStripeCustomer.d.ts +0 -2
- package/dist/hooks/syncExistingStripeCustomer.js +0 -80
- package/dist/hooks/syncExistingStripeCustomer.js.map +0 -1
- package/dist/routes/getAllProducts.d.ts +0 -3
- package/dist/routes/getAllProducts.js +0 -78
- package/dist/routes/getAllProducts.js.map +0 -1
- package/dist/routes/getSubscriptions.d.ts +0 -3
- package/dist/routes/getSubscriptions.js +0 -115
- package/dist/routes/getSubscriptions.js.map +0 -1
- package/dist/routes/updatePayment.d.ts +0 -3
- package/dist/routes/updatePayment.js +0 -96
- package/dist/routes/updatePayment.js.map +0 -1
- package/dist/ui/index.js +0 -35
- package/dist/ui/index.js.map +0 -1
- package/dist/webhooks/handleWebhooks.d.ts +0 -2
- package/dist/webhooks/handleWebhooks.js +0 -236
- package/dist/webhooks/handleWebhooks.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
A plugin for [Payload CMS](https://github.com/payloadcms/payload) to connect [Stripe](https://stripe.com) and Payload.
|
|
6
6
|
|
|
7
7
|
Core features:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
8
|
+
|
|
9
|
+
- Hides your Stripe credentials when shipping SaaS applications
|
|
10
|
+
- Allows restricted keys through [Payload access control](https://payloadcms.com/docs/access-control/overview)
|
|
11
|
+
- Enables a two-way communication channel between Stripe and Payload
|
|
12
|
+
- Proxies the [Stripe REST API](https://stripe.com/docs/api)
|
|
13
|
+
- Proxies [Stripe webhooks](https://stripe.com/docs/webhooks)
|
|
14
|
+
- Automatically syncs data between the two platforms
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
@@ -25,15 +26,15 @@ Core features:
|
|
|
25
26
|
In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options):
|
|
26
27
|
|
|
27
28
|
```js
|
|
28
|
-
import { buildConfig } from
|
|
29
|
-
import stripePlugin from
|
|
29
|
+
import { buildConfig } from "payload/config";
|
|
30
|
+
import stripePlugin from "@payloadcms/plugin-stripe";
|
|
30
31
|
|
|
31
32
|
const config = buildConfig({
|
|
32
33
|
plugins: [
|
|
33
34
|
stripePlugin({
|
|
34
35
|
stripeSecretKey: process.env.STRIPE_SECRET_KEY,
|
|
35
|
-
})
|
|
36
|
-
]
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
export default config;
|
|
@@ -70,8 +71,8 @@ This option will setup a basic sync between Payload collections and Stripe resou
|
|
|
70
71
|
> NOTE: Due to limitations in the Stripe API, this currently only works with top-level fields. This is because every Stripe object is a separate entity, making it difficult to abstract into a simple reusable library. In the future, we may find a pattern around this. But for now, cases like that will need to be hard-coded. See the [demo](./demo) for an example of this.
|
|
71
72
|
|
|
72
73
|
```js
|
|
73
|
-
import { buildConfig } from
|
|
74
|
-
import stripePlugin from
|
|
74
|
+
import { buildConfig } from "payload/config";
|
|
75
|
+
import stripePlugin from "@payloadcms/plugin-stripe";
|
|
75
76
|
|
|
76
77
|
const config = buildConfig({
|
|
77
78
|
plugins: [
|
|
@@ -80,19 +81,19 @@ const config = buildConfig({
|
|
|
80
81
|
stripeWebhooksEndpointSecret: process.env.STRIPE_WEBHOOKS_ENDPOINT_SECRET,
|
|
81
82
|
sync: [
|
|
82
83
|
{
|
|
83
|
-
collection:
|
|
84
|
-
stripeResourceType:
|
|
85
|
-
stripeResourceTypeSingular:
|
|
84
|
+
collection: "customers",
|
|
85
|
+
stripeResourceType: "customers",
|
|
86
|
+
stripeResourceTypeSingular: "customer",
|
|
86
87
|
fields: [
|
|
87
88
|
{
|
|
88
|
-
fieldPath:
|
|
89
|
-
stripeProperty:
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
})
|
|
95
|
-
]
|
|
89
|
+
fieldPath: "name", // this is a field on your own Payload config
|
|
90
|
+
stripeProperty: "name", // use dot notation, if applicable
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
}),
|
|
96
|
+
],
|
|
96
97
|
});
|
|
97
98
|
|
|
98
99
|
export default config;
|
|
@@ -116,27 +117,29 @@ Using `sync` will do the following:
|
|
|
116
117
|
|
|
117
118
|
The following custom endpoints are automatically opened for you:
|
|
118
119
|
|
|
119
|
-
>NOTE: the `/api` part of these routes may be different based on the settings defined in your Payload config.
|
|
120
|
+
> NOTE: the `/api` part of these routes may be different based on the settings defined in your Payload config.
|
|
120
121
|
|
|
121
122
|
- #### `POST /api/stripe/rest`
|
|
122
123
|
|
|
123
124
|
Proxies the [Stripe REST API](https://stripe.com/docs/api) behind [Payload access control](https://payloadcms.com/docs/access-control/overview) and returns the result. If you need to proxy the API server-side, use the [stripeProxy](#node) function.
|
|
124
125
|
|
|
125
126
|
```js
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
const res = await fetch(`/api/stripe/rest`, {
|
|
128
|
+
method: "POST",
|
|
129
|
+
credentials: "include",
|
|
130
|
+
headers: {
|
|
131
|
+
"Content-Type": "application/json",
|
|
132
|
+
// Authorization: `JWT ${token}` // NOTE: do this if not in a browser (i.e. curl or Postman)
|
|
133
|
+
},
|
|
134
|
+
body: JSON.stringify({
|
|
135
|
+
stripeMethod: "stripe.subscriptions.list",
|
|
136
|
+
stripeArgs: [
|
|
137
|
+
{
|
|
138
|
+
customer: "abc",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
140
143
|
```
|
|
141
144
|
|
|
142
145
|
- #### `POST /stripe/webhooks`
|
|
@@ -148,11 +151,13 @@ The following custom endpoints are automatically opened for you:
|
|
|
148
151
|
[Stripe webhooks](https://stripe.com/docs/webhooks) are used to sync from Stripe to Payload. Webhooks listen for events on your Stripe account so you can trigger reactions to them. Follow the steps below to enable webhooks.
|
|
149
152
|
|
|
150
153
|
Development:
|
|
154
|
+
|
|
151
155
|
1. Login using Stripe cli `stripe login`
|
|
152
156
|
1. Forward events to localhost `stripe listen --forward-to localhost:3000/stripe/webhooks`
|
|
153
157
|
1. Paste the given secret into your `.env` file as `STRIPE_WEBHOOKS_ENDPOINT_SECRET`
|
|
154
158
|
|
|
155
159
|
Production:
|
|
160
|
+
|
|
156
161
|
1. Login and [create a new webhook](https://dashboard.stripe.com/test/webhooks/create) from the Stripe dashboard
|
|
157
162
|
1. Paste `YOUR_DOMAIN_NAME/api/stripe/webhooks` as the "Webhook Endpoint URL"
|
|
158
163
|
1. Select which events to broadcast
|
|
@@ -160,8 +165,8 @@ Production:
|
|
|
160
165
|
1. Then, handle these events using the `webhooks` portion of this plugin's config:
|
|
161
166
|
|
|
162
167
|
```js
|
|
163
|
-
import { buildConfig } from
|
|
164
|
-
import stripePlugin from
|
|
168
|
+
import { buildConfig } from "payload/config";
|
|
169
|
+
import stripePlugin from "@payloadcms/plugin-stripe";
|
|
165
170
|
|
|
166
171
|
const config = buildConfig({
|
|
167
172
|
plugins: [
|
|
@@ -169,15 +174,15 @@ const config = buildConfig({
|
|
|
169
174
|
stripeSecretKey: process.env.STRIPE_SECRET_KEY,
|
|
170
175
|
stripeWebhooksEndpointSecret: process.env.STRIPE_WEBHOOKS_ENDPOINT_SECRET,
|
|
171
176
|
webhooks: {
|
|
172
|
-
|
|
173
|
-
//
|
|
174
|
-
}
|
|
175
|
-
}
|
|
177
|
+
"customer.subscription.updated": ({ event, stripe, stripeConfig }) => {
|
|
178
|
+
// do something...
|
|
179
|
+
},
|
|
180
|
+
},
|
|
176
181
|
// NOTE: you can also catch all Stripe webhook events and handle the event types yourself
|
|
177
182
|
// webhooks: (event, stripe, stripeConfig) => {
|
|
178
183
|
// switch (event.type): {
|
|
179
184
|
// case 'customer.subscription.updated': {
|
|
180
|
-
// //
|
|
185
|
+
// // do something...
|
|
181
186
|
// break;
|
|
182
187
|
// }
|
|
183
188
|
// default: {
|
|
@@ -185,8 +190,8 @@ const config = buildConfig({
|
|
|
185
190
|
// }
|
|
186
191
|
// }
|
|
187
192
|
// }
|
|
188
|
-
})
|
|
189
|
-
]
|
|
193
|
+
}),
|
|
194
|
+
],
|
|
190
195
|
});
|
|
191
196
|
|
|
192
197
|
export default config;
|
|
@@ -199,10 +204,10 @@ For a full list of available webhooks, see [here](https://stripe.com/docs/cli/tr
|
|
|
199
204
|
On the server you should interface with Stripe directly using the [stripe](https://www.npmjs.com/package/stripe) npm module. That might look something like this:
|
|
200
205
|
|
|
201
206
|
```js
|
|
202
|
-
import Stripe from
|
|
207
|
+
import Stripe from "stripe";
|
|
203
208
|
|
|
204
209
|
const stripeSecretKey = process.env.STRIPE_SECRET_KEY;
|
|
205
|
-
const stripe = new Stripe(stripeSecretKey, { apiVersion:
|
|
210
|
+
const stripe = new Stripe(stripeSecretKey, { apiVersion: "2022-08-01" });
|
|
206
211
|
|
|
207
212
|
export const MyFunction = async () => {
|
|
208
213
|
try {
|
|
@@ -210,30 +215,32 @@ export const MyFunction = async () => {
|
|
|
210
215
|
email: data.email,
|
|
211
216
|
});
|
|
212
217
|
|
|
213
|
-
//
|
|
218
|
+
// do something...
|
|
214
219
|
} catch (error) {
|
|
215
220
|
console.error(error.message);
|
|
216
221
|
}
|
|
217
|
-
}
|
|
222
|
+
};
|
|
218
223
|
```
|
|
219
224
|
|
|
220
225
|
Alternatively, you can interface with the Stripe using the `stripeProxy`, which is exactly what the `/api/stripe/rest` endpoint does behind-the-scenes. Here's the same example as above, but piped through the proxy:
|
|
221
226
|
|
|
222
227
|
```js
|
|
223
|
-
import { stripeProxy } from
|
|
228
|
+
import { stripeProxy } from "@payloadcms/plugin-stripe";
|
|
224
229
|
|
|
225
230
|
export const MyFunction = async () => {
|
|
226
231
|
try {
|
|
227
232
|
const customer = await stripeProxy({
|
|
228
233
|
stripeSecretKey: process.env.STRIPE_SECRET_KEY,
|
|
229
|
-
stripeMethod:
|
|
230
|
-
stripeArgs:
|
|
231
|
-
|
|
232
|
-
|
|
234
|
+
stripeMethod: "customers.create",
|
|
235
|
+
stripeArgs: [
|
|
236
|
+
{
|
|
237
|
+
email: data.email,
|
|
238
|
+
},
|
|
239
|
+
],
|
|
233
240
|
});
|
|
234
241
|
|
|
235
242
|
if (customer.status === 200) {
|
|
236
|
-
//
|
|
243
|
+
// do something...
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
if (customer.status >= 400) {
|
|
@@ -242,7 +249,7 @@ export const MyFunction = async () => {
|
|
|
242
249
|
} catch (error) {
|
|
243
250
|
console.error(error.message);
|
|
244
251
|
}
|
|
245
|
-
}
|
|
252
|
+
};
|
|
246
253
|
```
|
|
247
254
|
|
|
248
255
|
## TypeScript
|
|
@@ -252,9 +259,10 @@ All types can be directly imported:
|
|
|
252
259
|
```js
|
|
253
260
|
import {
|
|
254
261
|
StripeConfig,
|
|
255
|
-
StripeWebhookHandler
|
|
256
|
-
StripeProxy
|
|
257
|
-
|
|
262
|
+
StripeWebhookHandler,
|
|
263
|
+
StripeProxy,
|
|
264
|
+
...
|
|
265
|
+
} from '@payloadcms/plugin-stripe/types';
|
|
258
266
|
```
|
|
259
267
|
|
|
260
268
|
### Development
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionBeforeValidateHook, CollectionConfig } from 'payload/types';
|
|
2
2
|
import { StripeConfig } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type CollectionBeforeValidateHookWithArgs = (args: Parameters<CollectionBeforeValidateHook>[0] & {
|
|
4
4
|
collection?: CollectionConfig;
|
|
5
5
|
stripeConfig?: StripeConfig;
|
|
6
6
|
}) => void;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionAfterDeleteHook, CollectionConfig } from 'payload/types';
|
|
2
2
|
import { StripeConfig } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type CollectionAfterDeleteHookWithArgs = (args: Parameters<CollectionAfterDeleteHook>[0] & {
|
|
4
4
|
collection?: CollectionConfig;
|
|
5
5
|
stripeConfig?: StripeConfig;
|
|
6
6
|
}) => void;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionBeforeChangeHook, CollectionConfig } from 'payload/types';
|
|
2
2
|
import { StripeConfig } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type CollectionBeforeChangeHookWithArgs = (args: Parameters<CollectionBeforeChangeHook>[0] & {
|
|
4
4
|
collection?: CollectionConfig;
|
|
5
5
|
stripeConfig?: StripeConfig;
|
|
6
6
|
}) => void;
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -66,13 +66,14 @@ var extendWebpackConfig_1 = require("./extendWebpackConfig");
|
|
|
66
66
|
var createNewInStripe_1 = require("./hooks/createNewInStripe");
|
|
67
67
|
var syncExistingWithStripe_1 = require("./hooks/syncExistingWithStripe");
|
|
68
68
|
var deleteFromStripe_1 = require("./hooks/deleteFromStripe");
|
|
69
|
-
var
|
|
69
|
+
var LinkToDoc_1 = require("./ui/LinkToDoc");
|
|
70
70
|
var stripePlugin = function (incomingStripeConfig) { return function (config) {
|
|
71
|
-
var _a;
|
|
72
71
|
var collections = config.collections;
|
|
73
72
|
// set config defaults here
|
|
74
73
|
var stripeConfig = __assign(__assign({}, incomingStripeConfig), { sync: (incomingStripeConfig === null || incomingStripeConfig === void 0 ? void 0 : incomingStripeConfig.sync) || [] });
|
|
75
|
-
|
|
74
|
+
// NOTE: env variables are never passed to the client, and bc we use theme in the admin panel
|
|
75
|
+
// so unfortunately we must set the 'isTestKey' property on the config instead of using the following code:
|
|
76
|
+
// const isTestKey = stripeConfig.stripeSecretKey?.startsWith('sk_test_');
|
|
76
77
|
return (__assign(__assign({}, config), { admin: __assign(__assign({}, config.admin), { webpack: (0, extendWebpackConfig_1.extendWebpackConfig)(config) }), endpoints: __spreadArray(__spreadArray([], (config === null || config === void 0 ? void 0 : config.endpoints) || [], true), [
|
|
77
78
|
{
|
|
78
79
|
path: '/stripe/webhooks',
|
|
@@ -152,7 +153,7 @@ var stripePlugin = function (incomingStripeConfig) { return function (config) {
|
|
|
152
153
|
admin: {
|
|
153
154
|
position: 'sidebar',
|
|
154
155
|
components: {
|
|
155
|
-
Field: function (args) { return (0,
|
|
156
|
+
Field: function (args) { return (0, LinkToDoc_1.LinkToDoc)(__assign(__assign({}, args), { isTestKey: stripeConfig.isTestKey, stripeResourceType: syncConfig.stripeResourceType, nameOfIDField: 'stripeID' })); }
|
|
156
157
|
},
|
|
157
158
|
},
|
|
158
159
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sCAA2C;AAC3C,8CAAmD;AACnD,oDAA8B;AAE9B,6DAA4D;AAC5D,+DAA8D;AAC9D,yEAAwE;AACxE,6DAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sCAA2C;AAC3C,8CAAmD;AACnD,oDAA8B;AAE9B,6DAA4D;AAC5D,+DAA8D;AAC9D,yEAAwE;AACxE,6DAA4D;AA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gCACnB,QAAQ,EAAE,IAAI;6BACf;yBACF;wBACD;4BACE,IAAI,EAAE,QAAQ;4BACd,IAAI,EAAE,IAAI;4BACV,KAAK,EAAE;gCACL,QAAQ,EAAE,SAAS;gCACnB,UAAU,EAAE;oCACV,KAAK,EAAE,UAAC,IAAI,IAAK,OAAA,IAAA,qBAAS,wBACrB,IAAI,KACP,SAAS,EAAE,YAAY,CAAC,SAAS,EACjC,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,EACjD,aAAa,EAAE,UAAU,IACzB,EALe,CAKf;iCACH;6BACF;yBACF;iCAEH;aACH;YAED,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,IACF,CAAA;AACJ,CAAC,EAnI4D,CAmI5D,CAAA;AAED,kBAAe,YAAY,CAAC"}
|
package/dist/routes/rest.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -40,7 +40,7 @@ exports.stripeREST = void 0;
|
|
|
40
40
|
var errors_1 = require("payload/errors");
|
|
41
41
|
var stripeProxy_1 = require("../utilities/stripeProxy");
|
|
42
42
|
var stripeREST = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var req, res, next, stripeConfig, payload, user, _a, stripeMethod, stripeArgs // example: 'cus_MGgt3Tuj3D66f2'
|
|
43
|
+
var req, res, next, stripeConfig, payload, user, _a, stripeMethod, stripeArgs // example: ['cus_MGgt3Tuj3D66f2'] or [{ limit: 100 }, { stripeAccount: 'acct_1J9Z4pKZ4Z4Z4Z4Z' }]
|
|
44
44
|
, stripeSecretKey, pluginRes, status_1, error_1, message;
|
|
45
45
|
return __generator(this, function (_b) {
|
|
46
46
|
switch (_b.label) {
|
|
@@ -57,7 +57,7 @@ var stripeREST = function (args) { return __awaiter(void 0, void 0, void 0, func
|
|
|
57
57
|
return [4 /*yield*/, (0, stripeProxy_1.stripeProxy)({
|
|
58
58
|
stripeSecretKey: stripeSecretKey,
|
|
59
59
|
stripeMethod: stripeMethod,
|
|
60
|
-
stripeArgs: stripeArgs
|
|
60
|
+
stripeArgs: stripeArgs
|
|
61
61
|
})];
|
|
62
62
|
case 2:
|
|
63
63
|
pluginRes = _b.sent();
|
package/dist/routes/rest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/routes/rest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA2C;AAG3C,wDAAuD;AAEhD,IAAM,UAAU,GAAG,UAAO,IAKhC;;;;;;gBAEG,GAAG,GAID,IAAI,IAJH,EACH,GAAG,GAGD,IAAI,IAHH,EACH,IAAI,GAEF,IAAI,KAFF,EACJ,YAAY,GACV,IAAI,aADM,CACL;gBAGP,OAAO,GAML,GAAG,QANE,EACP,IAAI,GAKF,GAAG,KALD,EACJ,KAIE,GAAG,KADJ,EAFC,YAAY,kBAAA,EACZ,UAAU,gBAAA,CAEN;gBAEA,eAAe,GAAK,YAAY,gBAAjB,CAAkB;;;;gBAGvC,IAAI,CAAC,IAAI,EAAE,EAAE,+CAA+C;oBAC1D,MAAM,IAAI,kBAAS,EAAE,CAAC;iBACvB;gBAEiB,qBAAM,IAAA,yBAAW,EAAC;wBAClC,eAAe,iBAAA;wBACf,YAAY,cAAA;wBACZ,UAAU,YAAA
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/routes/rest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA2C;AAG3C,wDAAuD;AAEhD,IAAM,UAAU,GAAG,UAAO,IAKhC;;;;;;gBAEG,GAAG,GAID,IAAI,IAJH,EACH,GAAG,GAGD,IAAI,IAHH,EACH,IAAI,GAEF,IAAI,KAFF,EACJ,YAAY,GACV,IAAI,aADM,CACL;gBAGP,OAAO,GAML,GAAG,QANE,EACP,IAAI,GAKF,GAAG,KALD,EACJ,KAIE,GAAG,KADJ,EAFC,YAAY,kBAAA,EACZ,UAAU,gBAAA,CAEN;gBAEA,eAAe,GAAK,YAAY,gBAAjB,CAAkB;;;;gBAGvC,IAAI,CAAC,IAAI,EAAE,EAAE,+CAA+C;oBAC1D,MAAM,IAAI,kBAAS,EAAE,CAAC;iBACvB;gBAEiB,qBAAM,IAAA,yBAAW,EAAC;wBAClC,eAAe,iBAAA;wBACf,YAAY,cAAA;wBACZ,UAAU,YAAA;qBACX,CAAC,EAAA;;gBAJI,SAAS,GAAG,SAIhB;gBAGA,WACE,SAAS,OADL,CACM;gBAEd,GAAG,CAAC,MAAM,CAAC,QAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;;;gBAG7B,OAAO,GAAG,oEAA6D,OAAK,MAAG,CAAC;gBACtF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC9B,sBAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;wBAC1B,OAAO,SAAA;qBACR,CAAC,EAAC;;;;KAEN,CAAC;AAhDW,QAAA,UAAU,cAgDrB"}
|
package/dist/routes/webhooks.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { Payload } from "payload";
|
|
2
2
|
import { Config as PayloadConfig } from "payload/config";
|
|
3
3
|
import Stripe from "stripe";
|
|
4
|
-
export
|
|
4
|
+
export type StripeWebhookHandler<T = any> = (args: {
|
|
5
5
|
payload: Payload;
|
|
6
|
-
event:
|
|
6
|
+
event: T;
|
|
7
7
|
stripe: Stripe;
|
|
8
8
|
config: PayloadConfig;
|
|
9
9
|
stripeConfig?: StripeConfig;
|
|
10
10
|
}) => void;
|
|
11
|
-
export
|
|
11
|
+
export type StripeWebhookHandlers = {
|
|
12
12
|
[webhookName: string]: StripeWebhookHandler;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type FieldSyncConfig = {
|
|
15
15
|
fieldPath: string;
|
|
16
16
|
stripeProperty: string;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type SyncConfig = {
|
|
19
19
|
collection: string;
|
|
20
20
|
stripeResourceType: 'customers' | 'products';
|
|
21
21
|
stripeResourceTypeSingular: 'customer' | 'product';
|
|
22
22
|
fields: FieldSyncConfig[];
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type StripeConfig = {
|
|
25
25
|
stripeSecretKey: string;
|
|
26
|
+
isTestKey?: boolean;
|
|
26
27
|
stripeWebhooksEndpointSecret?: string;
|
|
27
28
|
webhooks?: StripeWebhookHandler | StripeWebhookHandlers;
|
|
28
29
|
sync?: SyncConfig[];
|
|
29
30
|
logs?: boolean;
|
|
30
31
|
};
|
|
31
|
-
export
|
|
32
|
+
export type SanitizedStripeConfig = StripeConfig & {
|
|
32
33
|
sync: SyncConfig[];
|
|
33
34
|
};
|
|
34
|
-
export
|
|
35
|
+
export type StripeProxy = (args: {
|
|
35
36
|
stripeSecretKey: string;
|
|
36
37
|
stripeMethod: string;
|
|
37
38
|
stripeArgs: any[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LinkToDoc = void 0;
|
|
7
|
+
var forms_1 = require("payload/components/forms");
|
|
8
|
+
var react_1 = __importDefault(require("react"));
|
|
9
|
+
var CopyToClipboard_1 = __importDefault(require("payload/dist/admin/components/elements/CopyToClipboard"));
|
|
10
|
+
var LinkToDoc = function (props) {
|
|
11
|
+
var isTestKey = props.isTestKey, stripeResourceType = props.stripeResourceType, nameOfIDField = props.nameOfIDField;
|
|
12
|
+
var field = (0, forms_1.useFormFields)(function (_a) {
|
|
13
|
+
var fields = _a[0];
|
|
14
|
+
return fields[nameOfIDField];
|
|
15
|
+
});
|
|
16
|
+
var stripeID = (field || {}).value;
|
|
17
|
+
var stripeEnv = isTestKey ? 'test/' : '';
|
|
18
|
+
var href = "https://dashboard.stripe.com/".concat(stripeEnv).concat(stripeResourceType, "/").concat(stripeID);
|
|
19
|
+
if (stripeID) {
|
|
20
|
+
return (react_1.default.createElement("div", null,
|
|
21
|
+
react_1.default.createElement("div", null,
|
|
22
|
+
react_1.default.createElement("span", { className: "label", style: {
|
|
23
|
+
color: '#9A9A9A'
|
|
24
|
+
} }, "View in Stripe"),
|
|
25
|
+
react_1.default.createElement(CopyToClipboard_1.default, { value: href })),
|
|
26
|
+
react_1.default.createElement("div", { style: {
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
textOverflow: 'ellipsis',
|
|
29
|
+
fontWeight: '600'
|
|
30
|
+
} },
|
|
31
|
+
react_1.default.createElement("a", { href: href, target: "_blank", rel: "noreferrer noopener" }, href))));
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
exports.LinkToDoc = LinkToDoc;
|
|
36
|
+
//# sourceMappingURL=LinkToDoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkToDoc.js","sourceRoot":"","sources":["../../src/ui/LinkToDoc.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAwD;AACxD,gDAA0B;AAC1B,2GAAqF;AAG9E,IAAM,SAAS,GAIjB,UAAC,KAAK;IAEP,IAAA,SAAS,GAGP,KAAK,UAHE,EACT,kBAAkB,GAEhB,KAAK,mBAFW,EAClB,aAAa,GACX,KAAK,cADM,CACL;IAEV,IAAM,KAAK,GAAG,IAAA,qBAAa,EAAC,UAAC,EAAQ;YAAP,MAAM,QAAA;QAAM,OAAA,MAAM,CAAC,aAAa,CAAC;IAArB,CAAqB,CAAC,CAAC;IACzD,IAAO,QAAQ,GAAK,CAAA,KAAK,IAAI,EAAE,CAAA,MAAhB,CAAiB;IAExC,IAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,IAAM,IAAI,GAAG,uCAAgC,SAAS,SAAG,kBAAkB,cAAI,QAAQ,CAAE,CAAA;IAEzF,IAAI,QAAQ,EAAE;QACZ,OAAO,CACL;YACE;gBACE,wCACE,SAAS,EAAC,OAAO,EACjB,KAAK,EAAE;wBACL,KAAK,EAAE,SAAS;qBACjB,qBAGI;gBACP,8BAAC,yBAAe,IACd,KAAK,EAAE,IAAc,GACrB,CACE;YACN,uCACE,KAAK,EAAE;oBACL,QAAQ,EAAE,QAAQ;oBAClB,YAAY,EAAE,UAAU;oBACxB,UAAU,EAAE,KAAK;iBAClB;gBAED,qCACE,IAAI,EAAE,IAAc,EACpB,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,IAExB,IAAI,CACH,CACA,CACF,CACP,CAAC;KACH;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAC;AArDW,QAAA,SAAS,aAqDpB"}
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -56,15 +56,16 @@ var stripeProxy = function (_a) {
|
|
|
56
56
|
url: 'https://payloadcms.com',
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
if (!(typeof stripeMethod === 'string')) return [3 /*break*/,
|
|
59
|
+
if (!(typeof stripeMethod === 'string')) return [3 /*break*/, 9];
|
|
60
60
|
topLevelMethod = stripeMethod.split('.')[0];
|
|
61
61
|
contextToBind = stripe[topLevelMethod];
|
|
62
62
|
foundMethod = (0, lodash_get_1.default)(stripe, stripeMethod).bind(contextToBind);
|
|
63
|
-
if (!(typeof foundMethod === 'function')) return [3 /*break*/,
|
|
63
|
+
if (!(typeof foundMethod === 'function')) return [3 /*break*/, 7];
|
|
64
|
+
if (!Array.isArray(stripeArgs)) return [3 /*break*/, 5];
|
|
64
65
|
_b.label = 1;
|
|
65
66
|
case 1:
|
|
66
67
|
_b.trys.push([1, 3, , 4]);
|
|
67
|
-
return [4 /*yield*/, foundMethod(stripeArgs)];
|
|
68
|
+
return [4 /*yield*/, foundMethod.apply(void 0, stripeArgs)];
|
|
68
69
|
case 2:
|
|
69
70
|
stripeResponse = _b.sent();
|
|
70
71
|
return [2 /*return*/, {
|
|
@@ -78,10 +79,12 @@ var stripeProxy = function (_a) {
|
|
|
78
79
|
message: "A Stripe API error has occurred: ".concat(error_1)
|
|
79
80
|
}];
|
|
80
81
|
case 4: return [3 /*break*/, 6];
|
|
81
|
-
case 5: throw Error("
|
|
82
|
+
case 5: throw new Error("Argument 'stripeArgs' must be an array.");
|
|
82
83
|
case 6: return [3 /*break*/, 8];
|
|
83
|
-
case 7: throw Error('
|
|
84
|
-
case 8: return [
|
|
84
|
+
case 7: throw Error("The provided Stripe method of '".concat(stripeMethod, "' is not a part of the Stripe API."));
|
|
85
|
+
case 8: return [3 /*break*/, 10];
|
|
86
|
+
case 9: throw Error('You must provide a Stripe method to call.');
|
|
87
|
+
case 10: return [2 /*return*/];
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stripeProxy.js","sourceRoot":"","sources":["../../src/utilities/stripeProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAmC;AACnC,kDAA4B;AAGrB,IAAM,WAAW,GAAgB,UAAO,EAI9C;QAHC,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,UAAU,gBAAA;;;;;;oBAEJ,MAAM,GAAG,IAAI,gBAAM,CAAC,eAAe,EAAE;wBACzC,UAAU,EAAE,YAAY;wBACxB,OAAO,EAAE;4BACP,IAAI,EAAE,uBAAuB;4BAC7B,GAAG,EAAE,wBAAwB;yBAC9B;qBACF,CAAC,CAAC;yBAEC,CAAA,OAAO,YAAY,KAAK,QAAQ,CAAA,EAAhC,wBAAgC;oBAC5B,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAiB,CAAC;oBAC5D,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;oB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C,OAAK,CAAE;yBACrD,EAAC;;wBAGJ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;;wBAG7D,MAAM,KAAK,CAAC,yCAAkC,YAAY,uCAAoC,CAAC,CAAA;;wBAGjG,MAAM,KAAK,CAAC,2CAA2C,CAAC,CAAA;;;;;CAE3D,CAAA;AA3CY,QAAA,WAAW,eA2CvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SanitizedStripeConfig, StripeWebhookHandler } from '../types';
|
|
2
|
-
|
|
2
|
+
type HandleCreatedOrUpdated = (args: Parameters<StripeWebhookHandler>[0] & {
|
|
3
3
|
syncConfig: SanitizedStripeConfig['sync'][0];
|
|
4
4
|
resourceType: string;
|
|
5
5
|
}) => void;
|
|
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
29
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
30
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
31
|
switch (op[0]) {
|
|
@@ -49,8 +49,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.handleCreatedOrUpdated = void 0;
|
|
51
51
|
var deepen_1 = require("../utilities/deepen");
|
|
52
|
+
var uuid_1 = require("uuid");
|
|
52
53
|
var handleCreatedOrUpdated = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
-
var payload, event, resourceType, stripeConfig, payloadConfig, syncConfig, logs, stripeDoc, stripeID, eventObject, isNestedChange, collectionSlug_1, isAuthCollection, payloadQuery, foundDoc, syncedData, authDoc, authQuery, err_1, error_1, error_2, error_3;
|
|
54
|
+
var payload, event, resourceType, stripeConfig, payloadConfig, syncConfig, logs, stripeDoc, stripeID, eventObject, isNestedChange, collectionSlug_1, isAuthCollection, payloadQuery, foundDoc, syncedData, authDoc, authQuery, err_1, error_1, password, error_2, error_3;
|
|
54
55
|
var _a, _b, _c;
|
|
55
56
|
return __generator(this, function (_d) {
|
|
56
57
|
switch (_d.label) {
|
|
@@ -150,9 +151,10 @@ var handleCreatedOrUpdated = function (args) { return __awaiter(void 0, void 0,
|
|
|
150
151
|
_d.trys.push([12, 14, , 15]);
|
|
151
152
|
if (logs)
|
|
152
153
|
payload.logger.info("- Creating new '".concat(collectionSlug_1, "' document in Payload with Stripe ID: '").concat(stripeID, "'."));
|
|
154
|
+
password = (0, uuid_1.v4)();
|
|
153
155
|
return [4 /*yield*/, payload.create({
|
|
154
156
|
collection: collectionSlug_1,
|
|
155
|
-
data: __assign(__assign({}, syncedData), { password:
|
|
157
|
+
data: __assign(__assign({}, syncedData), { password: password, passwordConfirm: password }),
|
|
156
158
|
disableVerificationEmail: isAuthCollection ? true : undefined,
|
|
157
159
|
})];
|
|
158
160
|
case 13:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleCreatedOrUpdated.js","sourceRoot":"","sources":["../../src/webhooks/handleCreatedOrUpdated.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAA6C;
|
|
1
|
+
{"version":3,"file":"handleCreatedOrUpdated.js","sourceRoot":"","sources":["../../src/webhooks/handleCreatedOrUpdated.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAA6C;AAC7C,6BAAkC;AAO3B,IAAM,sBAAsB,GAA2B,UAAO,IAAI;;;;;;gBAErE,OAAO,GAML,IAAI,QANC,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