@memberstack/dom 2.0.1 → 2.0.2-beta.0
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 +356 -3
- package/lib/auth/index.d.mts +58 -4
- package/lib/auth/index.d.ts +58 -4
- package/lib/auth/index.js +5 -2
- package/lib/auth/index.mjs +4 -2
- package/lib/constants/endpoints.js +2 -1
- package/lib/constants/endpoints.mjs +1 -1
- package/lib/index.d.mts +1874 -61
- package/lib/index.d.ts +1874 -61
- package/lib/index.js +1544 -30624
- package/lib/index.mjs +1530 -30624
- package/lib/methods/dom/index.js +1 -0
- package/lib/methods/dom/main-dom.d.mts +1 -13
- package/lib/methods/dom/main-dom.d.ts +1 -13
- package/lib/methods/dom/main-dom.js +14545 -29552
- package/lib/methods/dom/main-dom.mjs +14544 -29552
- package/lib/methods/dom/methods.d.mts +88 -6
- package/lib/methods/dom/methods.d.ts +88 -6
- package/lib/methods/dom/methods.js +137 -30637
- package/lib/methods/dom/methods.mjs +135 -30639
- package/lib/methods/index.d.mts +111 -29
- package/lib/methods/index.d.ts +111 -29
- package/lib/methods/index.js +1020 -30615
- package/lib/methods/index.mjs +1019 -30615
- package/lib/methods/requests/index.d.mts +843 -23
- package/lib/methods/requests/index.d.ts +843 -23
- package/lib/methods/requests/index.js +863 -40
- package/lib/methods/requests/index.mjs +862 -40
- package/lib/methods/requests/requests.d.mts +9 -8
- package/lib/methods/requests/requests.d.ts +9 -8
- package/lib/methods/requests/requests.js +5 -3
- package/lib/methods/requests/requests.mjs +4 -3
- package/lib/models-BmZS-mc4.d.ts +193 -0
- package/lib/models-CTRKogoR.d.ts +487 -0
- package/lib/models-le7xaT4H.d.ts +193 -0
- package/lib/testing/index.d.mts +272 -0
- package/lib/testing/index.d.ts +272 -0
- package/lib/testing/index.js +313 -0
- package/lib/testing/index.mjs +284 -0
- package/lib/types/index.d.mts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/params.d.mts +632 -8
- package/lib/types/params.d.ts +632 -8
- package/lib/types/params.js +1 -0
- package/lib/types/payloads.d.mts +200 -1
- package/lib/types/payloads.d.ts +200 -1
- package/lib/types/payloads.js +1 -0
- package/lib/types/translations.d.mts +58 -0
- package/lib/types/translations.d.ts +58 -0
- package/lib/types/translations.js +1 -0
- package/lib/types/utils/payloads.d.mts +1 -3
- package/lib/types/utils/payloads.d.ts +1 -3
- package/lib/types/utils/payloads.js +1 -0
- package/lib/utils/cookies.d.mts +5 -5
- package/lib/utils/cookies.d.ts +5 -5
- package/lib/utils/cookies.js +14 -3
- package/lib/utils/cookies.mjs +13 -3
- package/lib/utils/defaultMessageBox.js +1 -0
- package/package.json +23 -12
- package/lib/index.global.js +0 -46364
package/lib/types/params.d.ts
CHANGED
|
@@ -1,211 +1,599 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameters for signing up a new member with email and password.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* await memberstack.signupMemberEmailPassword({
|
|
7
|
+
* email: 'user@example.com',
|
|
8
|
+
* password: 'securePassword123',
|
|
9
|
+
* customFields: { firstName: 'John', company: 'Acme Inc' },
|
|
10
|
+
* plans: [{ planId: 'pln_free_tier' }]
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
1
14
|
type SignupMemberEmailPasswordParams = {
|
|
15
|
+
/** Member's email address (must be unique within your app) */
|
|
2
16
|
email: string;
|
|
17
|
+
/** Member's password (minimum 8 characters recommended) */
|
|
3
18
|
password: string;
|
|
19
|
+
/** Custom field values to set during signup (keys must match your app's custom fields) */
|
|
4
20
|
customFields?: Record<string, any>;
|
|
21
|
+
/** Metadata to store with the member (not displayed in dashboard) */
|
|
5
22
|
metaData?: Record<string, any>;
|
|
23
|
+
/** Array of plans to assign on signup */
|
|
6
24
|
plans?: {
|
|
7
25
|
planId: string;
|
|
8
26
|
}[];
|
|
27
|
+
/** reCAPTCHA token if captcha is enabled for your app */
|
|
9
28
|
captchaToken?: string;
|
|
29
|
+
/** Team invite token to join a team during signup */
|
|
10
30
|
inviteToken?: string;
|
|
11
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Parameters for joining a team with an invite token.
|
|
34
|
+
*/
|
|
12
35
|
type JoinTeamParams = {
|
|
36
|
+
/** The invite token received from team admin */
|
|
13
37
|
inviteToken: string;
|
|
14
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Parameters for retrieving team information.
|
|
41
|
+
*/
|
|
15
42
|
type GetTeamParams = {
|
|
43
|
+
/** The ID of the team to retrieve */
|
|
16
44
|
teamId: string;
|
|
17
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Parameters for removing a member from a team.
|
|
48
|
+
*/
|
|
18
49
|
type RemoveMemberFromTeamParams = {
|
|
50
|
+
/** The ID of the team */
|
|
19
51
|
teamId: string;
|
|
52
|
+
/** The ID of the member to remove */
|
|
20
53
|
memberId: string;
|
|
21
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Parameters for generating a team invite token.
|
|
57
|
+
*/
|
|
22
58
|
type GenerateInviteTokenParams = {
|
|
59
|
+
/** The ID of the team to generate an invite for */
|
|
23
60
|
teamId: string;
|
|
24
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Parameters for retrieving posts from a channel.
|
|
64
|
+
*/
|
|
25
65
|
type GetPostsParams = {
|
|
66
|
+
/** The key/identifier of the channel */
|
|
26
67
|
channelKey: string;
|
|
68
|
+
/** Sort order for posts */
|
|
27
69
|
order?: "newest" | "oldest";
|
|
70
|
+
/** Cursor for pagination (post ID to start after) */
|
|
28
71
|
after?: string;
|
|
72
|
+
/** Maximum number of posts to return */
|
|
29
73
|
limit?: number;
|
|
30
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Parameters for retrieving threads (replies) on a post.
|
|
77
|
+
*/
|
|
31
78
|
type GetThreadsParams = {
|
|
79
|
+
/** The ID of the parent post */
|
|
32
80
|
postId: string;
|
|
81
|
+
/** Sort order for threads */
|
|
33
82
|
order?: "newest" | "oldest";
|
|
83
|
+
/** Cursor for pagination (thread ID to start after) */
|
|
34
84
|
after?: string;
|
|
85
|
+
/** Maximum number of threads to return */
|
|
35
86
|
limit?: number;
|
|
36
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Parameters for creating a new post in a channel.
|
|
90
|
+
*/
|
|
37
91
|
type CreatePostParams = {
|
|
92
|
+
/** The key/identifier of the channel to post in */
|
|
38
93
|
channelKey: string;
|
|
94
|
+
/** The content of the post (supports markdown) */
|
|
39
95
|
content: string;
|
|
40
96
|
};
|
|
97
|
+
/**
|
|
98
|
+
* Parameters for updating an existing post.
|
|
99
|
+
*/
|
|
41
100
|
type UpdatePostParams = {
|
|
101
|
+
/** The ID of the post to update */
|
|
42
102
|
postId: string;
|
|
103
|
+
/** The new content for the post */
|
|
43
104
|
content: string;
|
|
44
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Parameters for deleting a post.
|
|
108
|
+
*/
|
|
45
109
|
type DeletePostParams = {
|
|
110
|
+
/** The ID of the post to delete */
|
|
46
111
|
postId: string;
|
|
47
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Parameters for voting on a post.
|
|
115
|
+
*/
|
|
48
116
|
type PostVoteParams = {
|
|
117
|
+
/** The ID of the post to vote on */
|
|
49
118
|
postId: string;
|
|
119
|
+
/** The vote type: UP, DOWN, or NONE to remove vote */
|
|
50
120
|
vote: "UP" | "DOWN" | "NONE";
|
|
51
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Parameters for voting on a thread.
|
|
124
|
+
*/
|
|
52
125
|
type ThreadVoteParams = {
|
|
126
|
+
/** The ID of the thread to vote on */
|
|
53
127
|
threadId: string;
|
|
128
|
+
/** The vote type: UP, DOWN, or NONE to remove vote */
|
|
54
129
|
vote: "UP" | "DOWN" | "NONE";
|
|
55
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Parameters for creating a reply thread on a post.
|
|
133
|
+
*/
|
|
56
134
|
type CreateThreadParams = {
|
|
135
|
+
/** The ID of the post to reply to */
|
|
57
136
|
postId: string;
|
|
137
|
+
/** The content of the reply (supports markdown) */
|
|
58
138
|
content: string;
|
|
59
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Parameters for updating an existing thread.
|
|
142
|
+
*/
|
|
60
143
|
type UpdateThreadParams = {
|
|
144
|
+
/** The ID of the thread to update */
|
|
61
145
|
threadId: string;
|
|
146
|
+
/** The new content for the thread */
|
|
62
147
|
content: string;
|
|
63
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Parameters for deleting a thread.
|
|
151
|
+
*/
|
|
64
152
|
type DeleteThreadParams = {
|
|
153
|
+
/** The ID of the thread to delete */
|
|
65
154
|
threadId: string;
|
|
66
155
|
};
|
|
156
|
+
/**
|
|
157
|
+
* Parameters for updating a member's profile image.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
162
|
+
* await memberstack.updateMemberProfileImage({
|
|
163
|
+
* profileImage: fileInput.files[0]
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
67
167
|
type UpdateMemberProfileImageParams = {
|
|
168
|
+
/** The image file to upload (accepts standard image formats) */
|
|
68
169
|
profileImage: File;
|
|
69
170
|
};
|
|
171
|
+
/**
|
|
172
|
+
* Parameters for retrieving secure/gated content.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* const { data: content } = await memberstack.getSecureContent({
|
|
177
|
+
* contentId: 'cnt_premium_article_123'
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
70
181
|
type GetSecureContentParams = {
|
|
182
|
+
/** The ID of the secure content block to retrieve */
|
|
71
183
|
contentId: string;
|
|
72
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Parameters for setting a password (for passwordless or OAuth users).
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* // After signing up with Google, user can set a password
|
|
191
|
+
* await memberstack.setPassword({
|
|
192
|
+
* password: 'myNewPassword123'
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
73
196
|
type SetPasswordParams = {
|
|
197
|
+
/** The new password to set (minimum 8 characters recommended) */
|
|
74
198
|
password: string;
|
|
75
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* Parameters for signing up with an OAuth provider.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* await memberstack.signupWithProvider({
|
|
206
|
+
* provider: 'google',
|
|
207
|
+
* customFields: { referralSource: 'twitter' },
|
|
208
|
+
* plans: [{ planId: 'pln_starter' }]
|
|
209
|
+
* });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
76
212
|
type SignupWithProviderParams = {
|
|
213
|
+
/** OAuth provider name ('google', 'facebook', etc.) */
|
|
77
214
|
provider: string;
|
|
215
|
+
/** Custom field values to set during signup */
|
|
78
216
|
customFields?: Record<string, any>;
|
|
217
|
+
/** Array of plans to assign on signup */
|
|
79
218
|
plans?: {
|
|
80
219
|
planId: string;
|
|
81
220
|
}[];
|
|
221
|
+
/** If true, allows login to existing account (default: false) */
|
|
82
222
|
allowLogin?: boolean;
|
|
223
|
+
/** Team invite token to join a team during signup */
|
|
224
|
+
inviteToken?: string;
|
|
83
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Parameters for logging in with an OAuth provider.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* await memberstack.loginWithProvider({
|
|
232
|
+
* provider: 'google',
|
|
233
|
+
* allowSignup: false // Only allow existing accounts
|
|
234
|
+
* });
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
84
237
|
type LoginWithProviderParams = {
|
|
238
|
+
/** OAuth provider name ('google', 'facebook', etc.) */
|
|
85
239
|
provider: string;
|
|
240
|
+
/** If true, creates new account if one doesn't exist (default: false) */
|
|
86
241
|
allowSignup?: boolean;
|
|
87
242
|
};
|
|
243
|
+
/**
|
|
244
|
+
* Parameters for completing a passwordless login flow.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* // After user receives email with code
|
|
249
|
+
* await memberstack.loginMemberPasswordless({
|
|
250
|
+
* email: 'user@example.com',
|
|
251
|
+
* passwordlessToken: '123456'
|
|
252
|
+
* });
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
88
255
|
type LoginMemberPasswordlessParams = {
|
|
256
|
+
/** The verification code from the email */
|
|
89
257
|
passwordlessToken: string;
|
|
258
|
+
/** The email address that received the code */
|
|
90
259
|
email: string;
|
|
91
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* Parameters for sending a passwordless login email.
|
|
263
|
+
*/
|
|
92
264
|
type SendMemberLoginPasswordlessEmailParams = {
|
|
265
|
+
/** The email address to send the login code to */
|
|
93
266
|
email: string;
|
|
94
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* Parameters for signing up with an auth provider code (internal use).
|
|
270
|
+
*/
|
|
95
271
|
type SignupMemberAuthProviderParams = {
|
|
272
|
+
/** The authorization code from OAuth flow */
|
|
96
273
|
code: string;
|
|
274
|
+
/** The OAuth provider */
|
|
97
275
|
provider: "GOOGLE" | "FACEBOOK";
|
|
276
|
+
/** Plan ID to assign (deprecated, use plans array) */
|
|
98
277
|
planId?: string;
|
|
278
|
+
/** Custom field values to set during signup */
|
|
99
279
|
customFields?: Record<string, any>;
|
|
280
|
+
/** Metadata to store with the member */
|
|
100
281
|
metaData?: Record<string, any>;
|
|
282
|
+
/** Array of plans to assign on signup */
|
|
101
283
|
plans?: {
|
|
102
284
|
planId: string;
|
|
103
285
|
}[];
|
|
286
|
+
/** Payment information for paid plans */
|
|
104
287
|
payment?: {
|
|
105
288
|
stripe?: {
|
|
106
289
|
paymentMethodId: string;
|
|
107
290
|
};
|
|
108
291
|
};
|
|
109
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* Parameters for logging in with email and password.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const { data } = await memberstack.loginMemberEmailPassword({
|
|
299
|
+
* email: 'user@example.com',
|
|
300
|
+
* password: 'password123'
|
|
301
|
+
* });
|
|
302
|
+
* console.log('Logged in:', data.member.auth.email);
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
110
305
|
type LoginMemberEmailPasswordParams = {
|
|
306
|
+
/** Member's email address */
|
|
111
307
|
email: string;
|
|
308
|
+
/** Member's password */
|
|
112
309
|
password: string;
|
|
113
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* Parameters for updating member profile data.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* await memberstack.updateMember({
|
|
317
|
+
* customFields: {
|
|
318
|
+
* firstName: 'Jane',
|
|
319
|
+
* company: 'New Company Inc'
|
|
320
|
+
* }
|
|
321
|
+
* });
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
114
324
|
type UpdateMemberParams = {
|
|
325
|
+
/** Custom field values to update (keys must match your app's custom fields) */
|
|
115
326
|
customFields?: Record<string, any>;
|
|
116
327
|
};
|
|
328
|
+
/**
|
|
329
|
+
* Parameters for updating member authentication credentials.
|
|
330
|
+
*
|
|
331
|
+
* @example Change email
|
|
332
|
+
* ```typescript
|
|
333
|
+
* await memberstack.updateMemberAuth({
|
|
334
|
+
* email: 'newemail@example.com'
|
|
335
|
+
* });
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @example Change password
|
|
339
|
+
* ```typescript
|
|
340
|
+
* await memberstack.updateMemberAuth({
|
|
341
|
+
* oldPassword: 'currentPassword',
|
|
342
|
+
* newPassword: 'newSecurePassword123'
|
|
343
|
+
* });
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
117
346
|
type UpdateMemberAuthParams = {
|
|
347
|
+
/** New email address (will require verification) */
|
|
118
348
|
email?: string;
|
|
349
|
+
/** Current password (required when changing password) */
|
|
119
350
|
oldPassword?: string;
|
|
351
|
+
/** New password to set */
|
|
120
352
|
newPassword?: string;
|
|
121
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Parameters for purchasing plans with payment.
|
|
356
|
+
*/
|
|
122
357
|
type PurchasePlansParams = {
|
|
358
|
+
/** Array of plans to purchase with optional specific price */
|
|
123
359
|
plans: {
|
|
124
360
|
planId: string;
|
|
125
361
|
priceId?: string;
|
|
126
362
|
}[];
|
|
363
|
+
/** Payment method information */
|
|
127
364
|
payment: {
|
|
365
|
+
/** Saved card ID from member's cards */
|
|
128
366
|
cardId?: string;
|
|
367
|
+
/** Stripe payment method */
|
|
129
368
|
stripe?: {
|
|
130
369
|
paymentMethodId: string;
|
|
131
370
|
};
|
|
132
371
|
};
|
|
133
372
|
};
|
|
373
|
+
/**
|
|
374
|
+
* Parameters for adding a free plan to a member.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* await memberstack.addPlan({
|
|
379
|
+
* planId: 'pln_free_tier'
|
|
380
|
+
* });
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
134
383
|
type AddPlanParams = {
|
|
384
|
+
/** The ID of the free plan to add */
|
|
135
385
|
planId: string;
|
|
136
386
|
};
|
|
387
|
+
/**
|
|
388
|
+
* Parameters for launching Stripe Checkout for plan purchase.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* await memberstack.purchasePlansWithCheckout({
|
|
393
|
+
* priceId: 'prc_monthly_pro',
|
|
394
|
+
* successUrl: 'https://yoursite.com/thank-you',
|
|
395
|
+
* cancelUrl: 'https://yoursite.com/pricing',
|
|
396
|
+
* couponId: 'SAVE20'
|
|
397
|
+
* });
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
137
400
|
type PurchasePlansWithCheckoutParams = {
|
|
401
|
+
/** The price ID to purchase (from your Memberstack dashboard) */
|
|
138
402
|
priceId: string;
|
|
403
|
+
/** Stripe coupon ID to apply discount */
|
|
139
404
|
couponId?: string;
|
|
405
|
+
/** URL to redirect on checkout cancellation */
|
|
140
406
|
cancelUrl?: string;
|
|
407
|
+
/** URL to redirect on successful purchase */
|
|
141
408
|
successUrl?: string;
|
|
409
|
+
/** Auto-redirect to Stripe Checkout (default: true) */
|
|
142
410
|
autoRedirect?: boolean;
|
|
411
|
+
/** Custom metadata to attach to the Stripe checkout session */
|
|
143
412
|
metadataForCheckout?: object;
|
|
144
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* Parameters for launching Stripe Customer Portal.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* await memberstack.launchStripeCustomerPortal({
|
|
420
|
+
* returnUrl: 'https://yoursite.com/account'
|
|
421
|
+
* });
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
145
424
|
type LaunchStripeCustomerPortalParams = {
|
|
425
|
+
/** Price IDs to show update options for */
|
|
146
426
|
priceIds?: string[];
|
|
427
|
+
/** Stripe portal configuration object */
|
|
147
428
|
configuration?: object;
|
|
429
|
+
/** URL to return to after leaving the portal */
|
|
148
430
|
returnUrl?: string;
|
|
431
|
+
/** Auto-redirect to Stripe portal (default: true) */
|
|
149
432
|
autoRedirect?: boolean;
|
|
150
433
|
};
|
|
434
|
+
/**
|
|
435
|
+
* Parameters for opening Stripe Customer Portal (alias for launchStripeCustomerPortal).
|
|
436
|
+
*/
|
|
151
437
|
type OpenStripeCustomerPortalParams = {
|
|
438
|
+
/** Stripe portal configuration object */
|
|
152
439
|
configuration?: object;
|
|
440
|
+
/** URL to return to after leaving the portal */
|
|
153
441
|
returnUrl?: string;
|
|
442
|
+
/** Auto-redirect to Stripe portal (default: true) */
|
|
154
443
|
autoRedirect?: boolean;
|
|
155
444
|
};
|
|
445
|
+
/**
|
|
446
|
+
* Parameters for removing a plan from a member.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```typescript
|
|
450
|
+
* await memberstack.removePlan({
|
|
451
|
+
* planId: 'pln_free_tier'
|
|
452
|
+
* });
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
156
455
|
type RemovePlanParams = {
|
|
456
|
+
/** The ID of the plan to remove */
|
|
157
457
|
planId: string;
|
|
158
458
|
};
|
|
459
|
+
/**
|
|
460
|
+
* Parameters for canceling a subscription plan connection.
|
|
461
|
+
*/
|
|
159
462
|
type CancelPlanParams = {
|
|
463
|
+
/** The ID of the plan connection to cancel */
|
|
160
464
|
planConnectionId: string;
|
|
161
465
|
};
|
|
466
|
+
/**
|
|
467
|
+
* Parameters for adding a payment card to a member.
|
|
468
|
+
*/
|
|
162
469
|
type AddMemberCardParams = {
|
|
470
|
+
/** Stripe payment method ID for the card */
|
|
163
471
|
stripePaymentMethodId: string;
|
|
472
|
+
/** Set as default payment method */
|
|
164
473
|
default?: boolean;
|
|
165
474
|
};
|
|
475
|
+
/**
|
|
476
|
+
* Parameters for updating the default payment card.
|
|
477
|
+
*/
|
|
166
478
|
type UpdateDefaultCardParams = {
|
|
479
|
+
/** The ID of the card to set as default */
|
|
167
480
|
cardId: string;
|
|
168
481
|
};
|
|
482
|
+
/**
|
|
483
|
+
* Parameters for updating payment method on a plan.
|
|
484
|
+
*/
|
|
169
485
|
type UpdatePlanPaymentParams = {
|
|
486
|
+
/** The plan connection ID to update */
|
|
170
487
|
planConnectionId: string;
|
|
488
|
+
/** The card ID to use for future payments */
|
|
171
489
|
cardId: string;
|
|
172
490
|
};
|
|
491
|
+
/**
|
|
492
|
+
* Parameters for retrieving member receipts.
|
|
493
|
+
*/
|
|
173
494
|
type GetMemberReceiptsParams = {
|
|
495
|
+
/** Number of receipts to return */
|
|
174
496
|
first?: number;
|
|
497
|
+
/** Cursor for pagination */
|
|
175
498
|
after?: string;
|
|
499
|
+
/** Sort order */
|
|
176
500
|
order?: "ASC" | "DESC";
|
|
177
501
|
};
|
|
502
|
+
/**
|
|
503
|
+
* Parameters for retrieving member invoices.
|
|
504
|
+
*/
|
|
178
505
|
type GetMemberInvoicesParams = {
|
|
506
|
+
/** Number of invoices to return */
|
|
179
507
|
first?: number;
|
|
508
|
+
/** Cursor for pagination */
|
|
180
509
|
after?: string;
|
|
510
|
+
/** Sort order */
|
|
181
511
|
order?: "ASC" | "DESC";
|
|
182
512
|
};
|
|
513
|
+
/**
|
|
514
|
+
* Parameters for updating member JSON store.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* ```typescript
|
|
518
|
+
* await memberstack.updateMemberJSON({
|
|
519
|
+
* json: { preferences: { theme: 'dark', notifications: true } }
|
|
520
|
+
* });
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
183
523
|
type UpdateMemberJSONParams = {
|
|
524
|
+
/** JSON object to store (completely replaces existing JSON) */
|
|
184
525
|
json: object;
|
|
185
526
|
};
|
|
527
|
+
/**
|
|
528
|
+
* Parameters for retrieving member purchases with optional expansions.
|
|
529
|
+
*/
|
|
186
530
|
type GetMemberPurchasesParams = {
|
|
531
|
+
/** Include full plan details */
|
|
187
532
|
expandPlan?: boolean;
|
|
533
|
+
/** Include full price details */
|
|
188
534
|
expandPrice?: boolean;
|
|
535
|
+
/** Include card details */
|
|
189
536
|
expandCard?: boolean;
|
|
537
|
+
/** Include subscription details */
|
|
190
538
|
expandSubscription?: boolean;
|
|
191
539
|
};
|
|
540
|
+
/**
|
|
541
|
+
* Parameters for retrieving a specific plan.
|
|
542
|
+
*/
|
|
192
543
|
type GetPlanParams = {
|
|
544
|
+
/** The ID of the plan to retrieve */
|
|
193
545
|
planId: string;
|
|
194
546
|
};
|
|
547
|
+
/**
|
|
548
|
+
* Parameters for retrieving plans list.
|
|
549
|
+
*/
|
|
195
550
|
type GetPlansParams = {
|
|
551
|
+
/** Filter by plan status */
|
|
196
552
|
status?: "ALL" | "ACTIVE" | "INACTIVE";
|
|
197
553
|
};
|
|
554
|
+
/**
|
|
555
|
+
* Parameters for sending a password reset email.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```typescript
|
|
559
|
+
* await memberstack.sendMemberResetPasswordEmail({
|
|
560
|
+
* email: 'user@example.com'
|
|
561
|
+
* });
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
198
564
|
type SendMemberResetPasswordEmailParams = {
|
|
565
|
+
/** Email address of the member requesting password reset */
|
|
199
566
|
email: string;
|
|
200
567
|
};
|
|
568
|
+
/**
|
|
569
|
+
* Parameters for completing a password reset.
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```typescript
|
|
573
|
+
* // Token comes from the reset email link
|
|
574
|
+
* await memberstack.resetMemberPassword({
|
|
575
|
+
* token: 'reset_token_from_email',
|
|
576
|
+
* newPassword: 'newSecurePassword123'
|
|
577
|
+
* });
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
201
580
|
type ResetMemberPasswordParams = {
|
|
581
|
+
/** Reset token from the password reset email */
|
|
202
582
|
token: string;
|
|
583
|
+
/** The new password to set */
|
|
203
584
|
newPassword: string;
|
|
204
585
|
};
|
|
586
|
+
/**
|
|
587
|
+
* Parameters for replacing/upgrading a plan.
|
|
588
|
+
*/
|
|
205
589
|
type ReplacePlanParams = {
|
|
590
|
+
/** The current plan connection to replace */
|
|
206
591
|
planConnectionId: string;
|
|
592
|
+
/** The new plan ID to switch to */
|
|
207
593
|
newPlanId?: string;
|
|
594
|
+
/** Specific price ID for the new plan */
|
|
208
595
|
priceId?: string;
|
|
596
|
+
/** Payment method for the new plan */
|
|
209
597
|
payment?: {
|
|
210
598
|
cardId?: string;
|
|
211
599
|
stripe?: {
|
|
@@ -213,109 +601,345 @@ type ReplacePlanParams = {
|
|
|
213
601
|
};
|
|
214
602
|
};
|
|
215
603
|
};
|
|
604
|
+
/**
|
|
605
|
+
* Parameters for getting authentication client secret.
|
|
606
|
+
*/
|
|
216
607
|
type GetAuthenticationClientSecretParams = {
|
|
608
|
+
/** The plan connection requiring authentication */
|
|
217
609
|
planConnectionId: string;
|
|
218
610
|
};
|
|
611
|
+
/**
|
|
612
|
+
* Parameters for calculating total checkout amount.
|
|
613
|
+
*/
|
|
219
614
|
type GetTotalCheckoutAmountParams = {
|
|
615
|
+
/** Array of price IDs to calculate total for */
|
|
220
616
|
priceIds: string[];
|
|
221
617
|
};
|
|
618
|
+
/**
|
|
619
|
+
* Parameters for retrieving records from a data table.
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* ```typescript
|
|
623
|
+
* const { data } = await memberstack.getDataRecords({
|
|
624
|
+
* table: 'posts',
|
|
625
|
+
* limit: 10,
|
|
626
|
+
* sortBy: 'createdAt',
|
|
627
|
+
* sortDirection: 'DESC'
|
|
628
|
+
* });
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
222
631
|
type GetDataRecordsParams = {
|
|
632
|
+
/** The table key/identifier */
|
|
223
633
|
table: string;
|
|
634
|
+
/** ISO date string - only return records created after this date */
|
|
224
635
|
createdAfter?: string;
|
|
636
|
+
/** ISO date string - only return records created before this date */
|
|
225
637
|
createdBefore?: string;
|
|
638
|
+
/** Field name to sort by */
|
|
226
639
|
sortBy?: string;
|
|
640
|
+
/** Sort direction */
|
|
227
641
|
sortDirection?: 'ASC' | 'DESC';
|
|
642
|
+
/** Maximum number of records to return (1-100) */
|
|
228
643
|
limit?: number;
|
|
644
|
+
/** Cursor for pagination (internalOrder value from previous response) */
|
|
229
645
|
after?: string;
|
|
230
646
|
};
|
|
647
|
+
/**
|
|
648
|
+
* Parameters for creating a new data record.
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```typescript
|
|
652
|
+
* await memberstack.createDataRecord({
|
|
653
|
+
* table: 'posts',
|
|
654
|
+
* data: {
|
|
655
|
+
* title: 'My First Post',
|
|
656
|
+
* content: 'Hello world!',
|
|
657
|
+
* published: true
|
|
658
|
+
* }
|
|
659
|
+
* });
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
231
662
|
type CreateDataRecordParams = {
|
|
663
|
+
/** The table key/identifier */
|
|
232
664
|
table: string;
|
|
665
|
+
/** Record data as key-value pairs (keys must match table fields) */
|
|
233
666
|
data: Record<string, any>;
|
|
667
|
+
/** Optional member ID to associate with the record */
|
|
234
668
|
memberId?: string;
|
|
235
669
|
};
|
|
670
|
+
/**
|
|
671
|
+
* Parameters for retrieving a single data record.
|
|
672
|
+
*/
|
|
236
673
|
type GetDataRecordParams = {
|
|
674
|
+
/** The table key/identifier */
|
|
237
675
|
table: string;
|
|
676
|
+
/** The ID of the record to retrieve */
|
|
238
677
|
recordId: string;
|
|
239
678
|
};
|
|
679
|
+
/**
|
|
680
|
+
* Selector for referencing records by ID in reference field operations.
|
|
681
|
+
*/
|
|
240
682
|
type ReferenceSelector = {
|
|
683
|
+
/** The ID of the record to reference */
|
|
241
684
|
id: string;
|
|
242
685
|
};
|
|
686
|
+
/**
|
|
687
|
+
* Operations for connecting/disconnecting reference field relationships.
|
|
688
|
+
*
|
|
689
|
+
* @example Connect a record
|
|
690
|
+
* ```typescript
|
|
691
|
+
* await memberstack.updateDataRecord({
|
|
692
|
+
* recordId: 'rec_abc',
|
|
693
|
+
* data: {
|
|
694
|
+
* author: { connect: { id: 'rec_author123' } }
|
|
695
|
+
* }
|
|
696
|
+
* });
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
243
699
|
type ReferenceOperation = {
|
|
700
|
+
/** Connect one or more records to this reference field */
|
|
244
701
|
connect?: ReferenceSelector | ReferenceSelector[];
|
|
702
|
+
/** Disconnect one or more records from this reference field */
|
|
245
703
|
disconnect?: ReferenceSelector | ReferenceSelector[];
|
|
246
704
|
};
|
|
705
|
+
/**
|
|
706
|
+
* Selector for referencing the current member in member reference fields.
|
|
707
|
+
*/
|
|
247
708
|
type MemberReferenceSelector = {
|
|
709
|
+
/** Set to true to reference the current authenticated member */
|
|
248
710
|
self: true;
|
|
249
711
|
};
|
|
712
|
+
/**
|
|
713
|
+
* Operations for connecting/disconnecting member reference relationships.
|
|
714
|
+
*/
|
|
250
715
|
type MemberReferenceOperation = {
|
|
716
|
+
/** Connect the current member to this field */
|
|
251
717
|
connect?: MemberReferenceSelector | MemberReferenceSelector[];
|
|
718
|
+
/** Disconnect the current member from this field */
|
|
252
719
|
disconnect?: MemberReferenceSelector | MemberReferenceSelector[];
|
|
253
720
|
};
|
|
721
|
+
/**
|
|
722
|
+
* Parameters for updating an existing data record.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```typescript
|
|
726
|
+
* await memberstack.updateDataRecord({
|
|
727
|
+
* recordId: 'rec_abc123',
|
|
728
|
+
* data: {
|
|
729
|
+
* title: 'Updated Title',
|
|
730
|
+
* published: false
|
|
731
|
+
* }
|
|
732
|
+
* });
|
|
733
|
+
* ```
|
|
734
|
+
*/
|
|
254
735
|
type UpdateDataRecordParams = {
|
|
736
|
+
/** The ID of the record to update */
|
|
255
737
|
recordId: string;
|
|
738
|
+
/** Fields to update as key-value pairs */
|
|
256
739
|
data: Record<string, any>;
|
|
257
740
|
};
|
|
741
|
+
/**
|
|
742
|
+
* Parameters for deleting a data record.
|
|
743
|
+
*/
|
|
258
744
|
type DeleteDataRecordParams = {
|
|
745
|
+
/** The ID of the record to delete */
|
|
259
746
|
recordId: string;
|
|
260
747
|
};
|
|
748
|
+
/**
|
|
749
|
+
* Parameters for retrieving a data table schema.
|
|
750
|
+
*/
|
|
261
751
|
type GetDataTableParams = {
|
|
752
|
+
/** The table key/identifier */
|
|
262
753
|
table: string;
|
|
263
754
|
};
|
|
755
|
+
/**
|
|
756
|
+
* Filter operators for query where clauses.
|
|
757
|
+
* Follows Prisma-like syntax for powerful filtering.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* {
|
|
762
|
+
* where: {
|
|
763
|
+
* age: { gte: 18, lt: 65 },
|
|
764
|
+
* name: { contains: 'john', mode: 'insensitive' },
|
|
765
|
+
* status: { in: ['active', 'pending'] }
|
|
766
|
+
* }
|
|
767
|
+
* }
|
|
768
|
+
* ```
|
|
769
|
+
*/
|
|
264
770
|
type WhereOperators = {
|
|
771
|
+
/** Exact match */
|
|
265
772
|
equals?: any;
|
|
773
|
+
/** Not equal */
|
|
266
774
|
not?: any;
|
|
775
|
+
/** Value is in array */
|
|
267
776
|
in?: any[];
|
|
777
|
+
/** Value is not in array */
|
|
268
778
|
notIn?: any[];
|
|
779
|
+
/** Less than */
|
|
269
780
|
lt?: any;
|
|
781
|
+
/** Less than or equal */
|
|
270
782
|
lte?: any;
|
|
783
|
+
/** Greater than */
|
|
271
784
|
gt?: any;
|
|
785
|
+
/** Greater than or equal */
|
|
272
786
|
gte?: any;
|
|
787
|
+
/** String contains substring */
|
|
273
788
|
contains?: string;
|
|
789
|
+
/** String starts with prefix */
|
|
274
790
|
startsWith?: string;
|
|
791
|
+
/** String ends with suffix */
|
|
275
792
|
endsWith?: string;
|
|
793
|
+
/** Full-text search */
|
|
276
794
|
search?: string;
|
|
795
|
+
/** Case sensitivity mode for string operations */
|
|
277
796
|
mode?: 'insensitive' | 'default';
|
|
278
797
|
};
|
|
798
|
+
/**
|
|
799
|
+
* Where clause for filtering records with support for logical operators.
|
|
800
|
+
*
|
|
801
|
+
* @example Complex where clause
|
|
802
|
+
* ```typescript
|
|
803
|
+
* {
|
|
804
|
+
* where: {
|
|
805
|
+
* AND: [
|
|
806
|
+
* { status: { equals: 'published' } },
|
|
807
|
+
* { OR: [
|
|
808
|
+
* { category: 'tech' },
|
|
809
|
+
* { featured: true }
|
|
810
|
+
* ]}
|
|
811
|
+
* ]
|
|
812
|
+
* }
|
|
813
|
+
* }
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
279
816
|
type WhereClause = {
|
|
817
|
+
/** Field conditions - key is field name, value is condition */
|
|
280
818
|
[field: string]: any | WhereOperators;
|
|
819
|
+
/** All conditions must match */
|
|
281
820
|
AND?: WhereClause[];
|
|
821
|
+
/** At least one condition must match */
|
|
282
822
|
OR?: WhereClause[];
|
|
823
|
+
/** Condition must not match */
|
|
283
824
|
NOT?: WhereClause;
|
|
284
825
|
};
|
|
826
|
+
/**
|
|
827
|
+
* Clause for counting related records.
|
|
828
|
+
*/
|
|
285
829
|
type CountClause = {
|
|
286
830
|
select: {
|
|
831
|
+
/** Relation name to count */
|
|
287
832
|
[relationName: string]: boolean;
|
|
288
833
|
};
|
|
289
834
|
};
|
|
835
|
+
/**
|
|
836
|
+
* Clause for selecting specific fields in query results.
|
|
837
|
+
*/
|
|
290
838
|
type SelectClause = {
|
|
839
|
+
/** Field name - true to include, false to exclude */
|
|
291
840
|
[fieldName: string]: boolean | CountClause;
|
|
292
841
|
};
|
|
842
|
+
/**
|
|
843
|
+
* Clause for including related records in query results.
|
|
844
|
+
*
|
|
845
|
+
* @example Include with nested query
|
|
846
|
+
* ```typescript
|
|
847
|
+
* {
|
|
848
|
+
* include: {
|
|
849
|
+
* author: true,
|
|
850
|
+
* comments: {
|
|
851
|
+
* where: { approved: true },
|
|
852
|
+
* orderBy: { createdAt: 'desc' },
|
|
853
|
+
* take: 5
|
|
854
|
+
* },
|
|
855
|
+
* _count: { select: { likes: true } }
|
|
856
|
+
* }
|
|
857
|
+
* }
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
860
|
+
/** Base include options for a relation */
|
|
861
|
+
type IncludeOptions = boolean | {
|
|
862
|
+
where?: WhereClause;
|
|
863
|
+
include?: IncludeClause;
|
|
864
|
+
select?: SelectClause;
|
|
865
|
+
orderBy?: OrderByClause;
|
|
866
|
+
take?: number;
|
|
867
|
+
skip?: number;
|
|
868
|
+
};
|
|
293
869
|
type IncludeClause = {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
orderBy?: OrderByClause;
|
|
299
|
-
take?: number;
|
|
300
|
-
skip?: number;
|
|
301
|
-
};
|
|
870
|
+
/** Relation name - true to include all, or object for nested query */
|
|
871
|
+
[relationName: string]: IncludeOptions | boolean | CountClause;
|
|
872
|
+
} & {
|
|
873
|
+
/** Include counts of related records */
|
|
302
874
|
_count?: boolean | CountClause;
|
|
303
875
|
};
|
|
876
|
+
/**
|
|
877
|
+
* Clause for sorting query results.
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* ```typescript
|
|
881
|
+
* { orderBy: { createdAt: 'desc' } }
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
304
884
|
type OrderByClause = {
|
|
885
|
+
/** Field name to sort by - 'asc' for ascending, 'desc' for descending */
|
|
305
886
|
[fieldName: string]: 'asc' | 'desc';
|
|
306
887
|
};
|
|
888
|
+
/**
|
|
889
|
+
* Main query structure for advanced record querying.
|
|
890
|
+
* Follows Prisma-like syntax for powerful data operations.
|
|
891
|
+
*
|
|
892
|
+
* @example Full query
|
|
893
|
+
* ```typescript
|
|
894
|
+
* {
|
|
895
|
+
* where: { published: { equals: true } },
|
|
896
|
+
* include: { author: true },
|
|
897
|
+
* orderBy: { createdAt: 'desc' },
|
|
898
|
+
* take: 10,
|
|
899
|
+
* skip: 0
|
|
900
|
+
* }
|
|
901
|
+
* ```
|
|
902
|
+
*/
|
|
307
903
|
type DataRecordsQuery = {
|
|
904
|
+
/** Filter conditions */
|
|
308
905
|
where?: WhereClause;
|
|
906
|
+
/** Related records to include */
|
|
309
907
|
include?: IncludeClause;
|
|
908
|
+
/** Fields to select (alternative to include) */
|
|
310
909
|
select?: SelectClause;
|
|
910
|
+
/** Sort order */
|
|
311
911
|
orderBy?: OrderByClause;
|
|
912
|
+
/** Maximum records to return (1-100) */
|
|
312
913
|
take?: number;
|
|
914
|
+
/** Records to skip (0-10,000) for offset pagination */
|
|
313
915
|
skip?: number;
|
|
916
|
+
/** Cursor for cursor-based pagination */
|
|
314
917
|
after?: string;
|
|
918
|
+
/** Include record counts */
|
|
315
919
|
_count?: boolean | CountClause;
|
|
316
920
|
};
|
|
921
|
+
/**
|
|
922
|
+
* Parameters for advanced data record queries.
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```typescript
|
|
926
|
+
* const { data } = await memberstack.queryDataRecords({
|
|
927
|
+
* table: 'posts',
|
|
928
|
+
* query: {
|
|
929
|
+
* where: {
|
|
930
|
+
* published: { equals: true },
|
|
931
|
+
* category: { in: ['tech', 'news'] }
|
|
932
|
+
* },
|
|
933
|
+
* orderBy: { createdAt: 'desc' },
|
|
934
|
+
* take: 10
|
|
935
|
+
* }
|
|
936
|
+
* });
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
317
939
|
type QueryDataRecordsParams = {
|
|
940
|
+
/** The table key/identifier */
|
|
318
941
|
table: string;
|
|
942
|
+
/** Query configuration */
|
|
319
943
|
query: DataRecordsQuery;
|
|
320
944
|
};
|
|
321
945
|
|