@memberstack/dom 2.0.2-beta.0 → 2.0.3

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 (87) hide show
  1. package/lib/index.d.mts +76 -61
  2. package/lib/index.d.ts +76 -61
  3. package/lib/index.js +840 -61
  4. package/lib/index.mjs +840 -61
  5. package/lib/{models-CTRKogoR.d.ts → models-CFT_ABd5.d.ts} +2 -2
  6. package/lib/testing/index.d.mts +25 -2
  7. package/lib/testing/index.d.ts +25 -2
  8. package/lib/testing/index.js +28 -6
  9. package/lib/testing/index.mjs +26 -5
  10. package/package.json +1 -1
  11. package/lib/auth/index.d.mts +0 -63
  12. package/lib/auth/index.d.ts +0 -63
  13. package/lib/auth/index.global.js +0 -244
  14. package/lib/auth/index.js +0 -161
  15. package/lib/auth/index.mjs +0 -123
  16. package/lib/constants/endpoints.d.mts +0 -5
  17. package/lib/constants/endpoints.d.ts +0 -5
  18. package/lib/constants/endpoints.global.js +0 -29
  19. package/lib/constants/endpoints.js +0 -32
  20. package/lib/constants/endpoints.mjs +0 -7
  21. package/lib/methods/dom/index.d.mts +0 -2
  22. package/lib/methods/dom/index.d.ts +0 -2
  23. package/lib/methods/dom/index.global.js +0 -2
  24. package/lib/methods/dom/index.js +0 -1
  25. package/lib/methods/dom/index.mjs +0 -0
  26. package/lib/methods/dom/main-dom.d.mts +0 -2
  27. package/lib/methods/dom/main-dom.d.ts +0 -2
  28. package/lib/methods/dom/main-dom.global.js +0 -30620
  29. package/lib/methods/dom/main-dom.js +0 -15611
  30. package/lib/methods/dom/main-dom.mjs +0 -15593
  31. package/lib/methods/dom/methods.d.mts +0 -100
  32. package/lib/methods/dom/methods.d.ts +0 -100
  33. package/lib/methods/dom/methods.global.js +0 -30827
  34. package/lib/methods/dom/methods.js +0 -335
  35. package/lib/methods/dom/methods.mjs +0 -302
  36. package/lib/methods/index.d.mts +0 -185
  37. package/lib/methods/index.d.ts +0 -185
  38. package/lib/methods/index.global.js +0 -46361
  39. package/lib/methods/index.js +0 -2530
  40. package/lib/methods/index.mjs +0 -2500
  41. package/lib/methods/requests/index.d.mts +0 -912
  42. package/lib/methods/requests/index.d.ts +0 -912
  43. package/lib/methods/requests/index.global.js +0 -15553
  44. package/lib/methods/requests/index.js +0 -2145
  45. package/lib/methods/requests/index.mjs +0 -2110
  46. package/lib/methods/requests/requests.d.mts +0 -43
  47. package/lib/methods/requests/requests.d.ts +0 -43
  48. package/lib/methods/requests/requests.global.js +0 -14528
  49. package/lib/methods/requests/requests.js +0 -244
  50. package/lib/methods/requests/requests.mjs +0 -210
  51. package/lib/models-BmZS-mc4.d.ts +0 -193
  52. package/lib/models-le7xaT4H.d.ts +0 -193
  53. package/lib/types/index.d.mts +0 -5
  54. package/lib/types/index.d.ts +0 -5
  55. package/lib/types/index.global.js +0 -19
  56. package/lib/types/index.js +0 -18
  57. package/lib/types/index.mjs +0 -0
  58. package/lib/types/params.d.mts +0 -946
  59. package/lib/types/params.d.ts +0 -946
  60. package/lib/types/params.global.js +0 -19
  61. package/lib/types/params.js +0 -18
  62. package/lib/types/params.mjs +0 -0
  63. package/lib/types/payloads.d.mts +0 -342
  64. package/lib/types/payloads.d.ts +0 -342
  65. package/lib/types/payloads.global.js +0 -19
  66. package/lib/types/payloads.js +0 -18
  67. package/lib/types/payloads.mjs +0 -0
  68. package/lib/types/translations.d.mts +0 -101
  69. package/lib/types/translations.d.ts +0 -101
  70. package/lib/types/translations.global.js +0 -19
  71. package/lib/types/translations.js +0 -18
  72. package/lib/types/translations.mjs +0 -0
  73. package/lib/types/utils/payloads.d.mts +0 -297
  74. package/lib/types/utils/payloads.d.ts +0 -297
  75. package/lib/types/utils/payloads.global.js +0 -19
  76. package/lib/types/utils/payloads.js +0 -18
  77. package/lib/types/utils/payloads.mjs +0 -0
  78. package/lib/utils/cookies.d.mts +0 -13
  79. package/lib/utils/cookies.d.ts +0 -13
  80. package/lib/utils/cookies.global.js +0 -261
  81. package/lib/utils/cookies.js +0 -190
  82. package/lib/utils/cookies.mjs +0 -148
  83. package/lib/utils/defaultMessageBox.d.mts +0 -5
  84. package/lib/utils/defaultMessageBox.d.ts +0 -5
  85. package/lib/utils/defaultMessageBox.global.js +0 -125
  86. package/lib/utils/defaultMessageBox.js +0 -130
  87. package/lib/utils/defaultMessageBox.mjs +0 -103
@@ -1,946 +0,0 @@
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
- */
14
- type SignupMemberEmailPasswordParams = {
15
- /** Member's email address (must be unique within your app) */
16
- email: string;
17
- /** Member's password (minimum 8 characters recommended) */
18
- password: string;
19
- /** Custom field values to set during signup (keys must match your app's custom fields) */
20
- customFields?: Record<string, any>;
21
- /** Metadata to store with the member (not displayed in dashboard) */
22
- metaData?: Record<string, any>;
23
- /** Array of plans to assign on signup */
24
- plans?: {
25
- planId: string;
26
- }[];
27
- /** reCAPTCHA token if captcha is enabled for your app */
28
- captchaToken?: string;
29
- /** Team invite token to join a team during signup */
30
- inviteToken?: string;
31
- };
32
- /**
33
- * Parameters for joining a team with an invite token.
34
- */
35
- type JoinTeamParams = {
36
- /** The invite token received from team admin */
37
- inviteToken: string;
38
- };
39
- /**
40
- * Parameters for retrieving team information.
41
- */
42
- type GetTeamParams = {
43
- /** The ID of the team to retrieve */
44
- teamId: string;
45
- };
46
- /**
47
- * Parameters for removing a member from a team.
48
- */
49
- type RemoveMemberFromTeamParams = {
50
- /** The ID of the team */
51
- teamId: string;
52
- /** The ID of the member to remove */
53
- memberId: string;
54
- };
55
- /**
56
- * Parameters for generating a team invite token.
57
- */
58
- type GenerateInviteTokenParams = {
59
- /** The ID of the team to generate an invite for */
60
- teamId: string;
61
- };
62
- /**
63
- * Parameters for retrieving posts from a channel.
64
- */
65
- type GetPostsParams = {
66
- /** The key/identifier of the channel */
67
- channelKey: string;
68
- /** Sort order for posts */
69
- order?: "newest" | "oldest";
70
- /** Cursor for pagination (post ID to start after) */
71
- after?: string;
72
- /** Maximum number of posts to return */
73
- limit?: number;
74
- };
75
- /**
76
- * Parameters for retrieving threads (replies) on a post.
77
- */
78
- type GetThreadsParams = {
79
- /** The ID of the parent post */
80
- postId: string;
81
- /** Sort order for threads */
82
- order?: "newest" | "oldest";
83
- /** Cursor for pagination (thread ID to start after) */
84
- after?: string;
85
- /** Maximum number of threads to return */
86
- limit?: number;
87
- };
88
- /**
89
- * Parameters for creating a new post in a channel.
90
- */
91
- type CreatePostParams = {
92
- /** The key/identifier of the channel to post in */
93
- channelKey: string;
94
- /** The content of the post (supports markdown) */
95
- content: string;
96
- };
97
- /**
98
- * Parameters for updating an existing post.
99
- */
100
- type UpdatePostParams = {
101
- /** The ID of the post to update */
102
- postId: string;
103
- /** The new content for the post */
104
- content: string;
105
- };
106
- /**
107
- * Parameters for deleting a post.
108
- */
109
- type DeletePostParams = {
110
- /** The ID of the post to delete */
111
- postId: string;
112
- };
113
- /**
114
- * Parameters for voting on a post.
115
- */
116
- type PostVoteParams = {
117
- /** The ID of the post to vote on */
118
- postId: string;
119
- /** The vote type: UP, DOWN, or NONE to remove vote */
120
- vote: "UP" | "DOWN" | "NONE";
121
- };
122
- /**
123
- * Parameters for voting on a thread.
124
- */
125
- type ThreadVoteParams = {
126
- /** The ID of the thread to vote on */
127
- threadId: string;
128
- /** The vote type: UP, DOWN, or NONE to remove vote */
129
- vote: "UP" | "DOWN" | "NONE";
130
- };
131
- /**
132
- * Parameters for creating a reply thread on a post.
133
- */
134
- type CreateThreadParams = {
135
- /** The ID of the post to reply to */
136
- postId: string;
137
- /** The content of the reply (supports markdown) */
138
- content: string;
139
- };
140
- /**
141
- * Parameters for updating an existing thread.
142
- */
143
- type UpdateThreadParams = {
144
- /** The ID of the thread to update */
145
- threadId: string;
146
- /** The new content for the thread */
147
- content: string;
148
- };
149
- /**
150
- * Parameters for deleting a thread.
151
- */
152
- type DeleteThreadParams = {
153
- /** The ID of the thread to delete */
154
- threadId: string;
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
- */
167
- type UpdateMemberProfileImageParams = {
168
- /** The image file to upload (accepts standard image formats) */
169
- profileImage: File;
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
- */
181
- type GetSecureContentParams = {
182
- /** The ID of the secure content block to retrieve */
183
- contentId: string;
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
- */
196
- type SetPasswordParams = {
197
- /** The new password to set (minimum 8 characters recommended) */
198
- password: string;
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
- */
212
- type SignupWithProviderParams = {
213
- /** OAuth provider name ('google', 'facebook', etc.) */
214
- provider: string;
215
- /** Custom field values to set during signup */
216
- customFields?: Record<string, any>;
217
- /** Array of plans to assign on signup */
218
- plans?: {
219
- planId: string;
220
- }[];
221
- /** If true, allows login to existing account (default: false) */
222
- allowLogin?: boolean;
223
- /** Team invite token to join a team during signup */
224
- inviteToken?: string;
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
- */
237
- type LoginWithProviderParams = {
238
- /** OAuth provider name ('google', 'facebook', etc.) */
239
- provider: string;
240
- /** If true, creates new account if one doesn't exist (default: false) */
241
- allowSignup?: boolean;
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
- */
255
- type LoginMemberPasswordlessParams = {
256
- /** The verification code from the email */
257
- passwordlessToken: string;
258
- /** The email address that received the code */
259
- email: string;
260
- };
261
- /**
262
- * Parameters for sending a passwordless login email.
263
- */
264
- type SendMemberLoginPasswordlessEmailParams = {
265
- /** The email address to send the login code to */
266
- email: string;
267
- };
268
- /**
269
- * Parameters for signing up with an auth provider code (internal use).
270
- */
271
- type SignupMemberAuthProviderParams = {
272
- /** The authorization code from OAuth flow */
273
- code: string;
274
- /** The OAuth provider */
275
- provider: "GOOGLE" | "FACEBOOK";
276
- /** Plan ID to assign (deprecated, use plans array) */
277
- planId?: string;
278
- /** Custom field values to set during signup */
279
- customFields?: Record<string, any>;
280
- /** Metadata to store with the member */
281
- metaData?: Record<string, any>;
282
- /** Array of plans to assign on signup */
283
- plans?: {
284
- planId: string;
285
- }[];
286
- /** Payment information for paid plans */
287
- payment?: {
288
- stripe?: {
289
- paymentMethodId: string;
290
- };
291
- };
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
- */
305
- type LoginMemberEmailPasswordParams = {
306
- /** Member's email address */
307
- email: string;
308
- /** Member's password */
309
- password: string;
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
- */
324
- type UpdateMemberParams = {
325
- /** Custom field values to update (keys must match your app's custom fields) */
326
- customFields?: Record<string, any>;
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
- */
346
- type UpdateMemberAuthParams = {
347
- /** New email address (will require verification) */
348
- email?: string;
349
- /** Current password (required when changing password) */
350
- oldPassword?: string;
351
- /** New password to set */
352
- newPassword?: string;
353
- };
354
- /**
355
- * Parameters for purchasing plans with payment.
356
- */
357
- type PurchasePlansParams = {
358
- /** Array of plans to purchase with optional specific price */
359
- plans: {
360
- planId: string;
361
- priceId?: string;
362
- }[];
363
- /** Payment method information */
364
- payment: {
365
- /** Saved card ID from member's cards */
366
- cardId?: string;
367
- /** Stripe payment method */
368
- stripe?: {
369
- paymentMethodId: string;
370
- };
371
- };
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
- */
383
- type AddPlanParams = {
384
- /** The ID of the free plan to add */
385
- planId: string;
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
- */
400
- type PurchasePlansWithCheckoutParams = {
401
- /** The price ID to purchase (from your Memberstack dashboard) */
402
- priceId: string;
403
- /** Stripe coupon ID to apply discount */
404
- couponId?: string;
405
- /** URL to redirect on checkout cancellation */
406
- cancelUrl?: string;
407
- /** URL to redirect on successful purchase */
408
- successUrl?: string;
409
- /** Auto-redirect to Stripe Checkout (default: true) */
410
- autoRedirect?: boolean;
411
- /** Custom metadata to attach to the Stripe checkout session */
412
- metadataForCheckout?: object;
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
- */
424
- type LaunchStripeCustomerPortalParams = {
425
- /** Price IDs to show update options for */
426
- priceIds?: string[];
427
- /** Stripe portal configuration object */
428
- configuration?: object;
429
- /** URL to return to after leaving the portal */
430
- returnUrl?: string;
431
- /** Auto-redirect to Stripe portal (default: true) */
432
- autoRedirect?: boolean;
433
- };
434
- /**
435
- * Parameters for opening Stripe Customer Portal (alias for launchStripeCustomerPortal).
436
- */
437
- type OpenStripeCustomerPortalParams = {
438
- /** Stripe portal configuration object */
439
- configuration?: object;
440
- /** URL to return to after leaving the portal */
441
- returnUrl?: string;
442
- /** Auto-redirect to Stripe portal (default: true) */
443
- autoRedirect?: boolean;
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
- */
455
- type RemovePlanParams = {
456
- /** The ID of the plan to remove */
457
- planId: string;
458
- };
459
- /**
460
- * Parameters for canceling a subscription plan connection.
461
- */
462
- type CancelPlanParams = {
463
- /** The ID of the plan connection to cancel */
464
- planConnectionId: string;
465
- };
466
- /**
467
- * Parameters for adding a payment card to a member.
468
- */
469
- type AddMemberCardParams = {
470
- /** Stripe payment method ID for the card */
471
- stripePaymentMethodId: string;
472
- /** Set as default payment method */
473
- default?: boolean;
474
- };
475
- /**
476
- * Parameters for updating the default payment card.
477
- */
478
- type UpdateDefaultCardParams = {
479
- /** The ID of the card to set as default */
480
- cardId: string;
481
- };
482
- /**
483
- * Parameters for updating payment method on a plan.
484
- */
485
- type UpdatePlanPaymentParams = {
486
- /** The plan connection ID to update */
487
- planConnectionId: string;
488
- /** The card ID to use for future payments */
489
- cardId: string;
490
- };
491
- /**
492
- * Parameters for retrieving member receipts.
493
- */
494
- type GetMemberReceiptsParams = {
495
- /** Number of receipts to return */
496
- first?: number;
497
- /** Cursor for pagination */
498
- after?: string;
499
- /** Sort order */
500
- order?: "ASC" | "DESC";
501
- };
502
- /**
503
- * Parameters for retrieving member invoices.
504
- */
505
- type GetMemberInvoicesParams = {
506
- /** Number of invoices to return */
507
- first?: number;
508
- /** Cursor for pagination */
509
- after?: string;
510
- /** Sort order */
511
- order?: "ASC" | "DESC";
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
- */
523
- type UpdateMemberJSONParams = {
524
- /** JSON object to store (completely replaces existing JSON) */
525
- json: object;
526
- };
527
- /**
528
- * Parameters for retrieving member purchases with optional expansions.
529
- */
530
- type GetMemberPurchasesParams = {
531
- /** Include full plan details */
532
- expandPlan?: boolean;
533
- /** Include full price details */
534
- expandPrice?: boolean;
535
- /** Include card details */
536
- expandCard?: boolean;
537
- /** Include subscription details */
538
- expandSubscription?: boolean;
539
- };
540
- /**
541
- * Parameters for retrieving a specific plan.
542
- */
543
- type GetPlanParams = {
544
- /** The ID of the plan to retrieve */
545
- planId: string;
546
- };
547
- /**
548
- * Parameters for retrieving plans list.
549
- */
550
- type GetPlansParams = {
551
- /** Filter by plan status */
552
- status?: "ALL" | "ACTIVE" | "INACTIVE";
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
- */
564
- type SendMemberResetPasswordEmailParams = {
565
- /** Email address of the member requesting password reset */
566
- email: string;
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
- */
580
- type ResetMemberPasswordParams = {
581
- /** Reset token from the password reset email */
582
- token: string;
583
- /** The new password to set */
584
- newPassword: string;
585
- };
586
- /**
587
- * Parameters for replacing/upgrading a plan.
588
- */
589
- type ReplacePlanParams = {
590
- /** The current plan connection to replace */
591
- planConnectionId: string;
592
- /** The new plan ID to switch to */
593
- newPlanId?: string;
594
- /** Specific price ID for the new plan */
595
- priceId?: string;
596
- /** Payment method for the new plan */
597
- payment?: {
598
- cardId?: string;
599
- stripe?: {
600
- paymentMethodId: string;
601
- };
602
- };
603
- };
604
- /**
605
- * Parameters for getting authentication client secret.
606
- */
607
- type GetAuthenticationClientSecretParams = {
608
- /** The plan connection requiring authentication */
609
- planConnectionId: string;
610
- };
611
- /**
612
- * Parameters for calculating total checkout amount.
613
- */
614
- type GetTotalCheckoutAmountParams = {
615
- /** Array of price IDs to calculate total for */
616
- priceIds: string[];
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
- */
631
- type GetDataRecordsParams = {
632
- /** The table key/identifier */
633
- table: string;
634
- /** ISO date string - only return records created after this date */
635
- createdAfter?: string;
636
- /** ISO date string - only return records created before this date */
637
- createdBefore?: string;
638
- /** Field name to sort by */
639
- sortBy?: string;
640
- /** Sort direction */
641
- sortDirection?: 'ASC' | 'DESC';
642
- /** Maximum number of records to return (1-100) */
643
- limit?: number;
644
- /** Cursor for pagination (internalOrder value from previous response) */
645
- after?: string;
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
- */
662
- type CreateDataRecordParams = {
663
- /** The table key/identifier */
664
- table: string;
665
- /** Record data as key-value pairs (keys must match table fields) */
666
- data: Record<string, any>;
667
- /** Optional member ID to associate with the record */
668
- memberId?: string;
669
- };
670
- /**
671
- * Parameters for retrieving a single data record.
672
- */
673
- type GetDataRecordParams = {
674
- /** The table key/identifier */
675
- table: string;
676
- /** The ID of the record to retrieve */
677
- recordId: string;
678
- };
679
- /**
680
- * Selector for referencing records by ID in reference field operations.
681
- */
682
- type ReferenceSelector = {
683
- /** The ID of the record to reference */
684
- id: string;
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
- */
699
- type ReferenceOperation = {
700
- /** Connect one or more records to this reference field */
701
- connect?: ReferenceSelector | ReferenceSelector[];
702
- /** Disconnect one or more records from this reference field */
703
- disconnect?: ReferenceSelector | ReferenceSelector[];
704
- };
705
- /**
706
- * Selector for referencing the current member in member reference fields.
707
- */
708
- type MemberReferenceSelector = {
709
- /** Set to true to reference the current authenticated member */
710
- self: true;
711
- };
712
- /**
713
- * Operations for connecting/disconnecting member reference relationships.
714
- */
715
- type MemberReferenceOperation = {
716
- /** Connect the current member to this field */
717
- connect?: MemberReferenceSelector | MemberReferenceSelector[];
718
- /** Disconnect the current member from this field */
719
- disconnect?: MemberReferenceSelector | MemberReferenceSelector[];
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
- */
735
- type UpdateDataRecordParams = {
736
- /** The ID of the record to update */
737
- recordId: string;
738
- /** Fields to update as key-value pairs */
739
- data: Record<string, any>;
740
- };
741
- /**
742
- * Parameters for deleting a data record.
743
- */
744
- type DeleteDataRecordParams = {
745
- /** The ID of the record to delete */
746
- recordId: string;
747
- };
748
- /**
749
- * Parameters for retrieving a data table schema.
750
- */
751
- type GetDataTableParams = {
752
- /** The table key/identifier */
753
- table: string;
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
- */
770
- type WhereOperators = {
771
- /** Exact match */
772
- equals?: any;
773
- /** Not equal */
774
- not?: any;
775
- /** Value is in array */
776
- in?: any[];
777
- /** Value is not in array */
778
- notIn?: any[];
779
- /** Less than */
780
- lt?: any;
781
- /** Less than or equal */
782
- lte?: any;
783
- /** Greater than */
784
- gt?: any;
785
- /** Greater than or equal */
786
- gte?: any;
787
- /** String contains substring */
788
- contains?: string;
789
- /** String starts with prefix */
790
- startsWith?: string;
791
- /** String ends with suffix */
792
- endsWith?: string;
793
- /** Full-text search */
794
- search?: string;
795
- /** Case sensitivity mode for string operations */
796
- mode?: 'insensitive' | 'default';
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
- */
816
- type WhereClause = {
817
- /** Field conditions - key is field name, value is condition */
818
- [field: string]: any | WhereOperators;
819
- /** All conditions must match */
820
- AND?: WhereClause[];
821
- /** At least one condition must match */
822
- OR?: WhereClause[];
823
- /** Condition must not match */
824
- NOT?: WhereClause;
825
- };
826
- /**
827
- * Clause for counting related records.
828
- */
829
- type CountClause = {
830
- select: {
831
- /** Relation name to count */
832
- [relationName: string]: boolean;
833
- };
834
- };
835
- /**
836
- * Clause for selecting specific fields in query results.
837
- */
838
- type SelectClause = {
839
- /** Field name - true to include, false to exclude */
840
- [fieldName: string]: boolean | CountClause;
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
- };
869
- type IncludeClause = {
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 */
874
- _count?: boolean | CountClause;
875
- };
876
- /**
877
- * Clause for sorting query results.
878
- *
879
- * @example
880
- * ```typescript
881
- * { orderBy: { createdAt: 'desc' } }
882
- * ```
883
- */
884
- type OrderByClause = {
885
- /** Field name to sort by - 'asc' for ascending, 'desc' for descending */
886
- [fieldName: string]: 'asc' | 'desc';
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
- */
903
- type DataRecordsQuery = {
904
- /** Filter conditions */
905
- where?: WhereClause;
906
- /** Related records to include */
907
- include?: IncludeClause;
908
- /** Fields to select (alternative to include) */
909
- select?: SelectClause;
910
- /** Sort order */
911
- orderBy?: OrderByClause;
912
- /** Maximum records to return (1-100) */
913
- take?: number;
914
- /** Records to skip (0-10,000) for offset pagination */
915
- skip?: number;
916
- /** Cursor for cursor-based pagination */
917
- after?: string;
918
- /** Include record counts */
919
- _count?: boolean | CountClause;
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
- */
939
- type QueryDataRecordsParams = {
940
- /** The table key/identifier */
941
- table: string;
942
- /** Query configuration */
943
- query: DataRecordsQuery;
944
- };
945
-
946
- export type { AddMemberCardParams, AddPlanParams, CancelPlanParams, CountClause, CreateDataRecordParams, CreatePostParams, CreateThreadParams, DataRecordsQuery, DeleteDataRecordParams, DeletePostParams, DeleteThreadParams, GenerateInviteTokenParams, GetAuthenticationClientSecretParams, GetDataRecordParams, GetDataRecordsParams, GetDataTableParams, GetMemberInvoicesParams, GetMemberPurchasesParams, GetMemberReceiptsParams, GetPlanParams, GetPlansParams, GetPostsParams, GetSecureContentParams, GetTeamParams, GetThreadsParams, GetTotalCheckoutAmountParams, IncludeClause, JoinTeamParams, LaunchStripeCustomerPortalParams, LoginMemberEmailPasswordParams, LoginMemberPasswordlessParams, LoginWithProviderParams, MemberReferenceOperation, MemberReferenceSelector, OpenStripeCustomerPortalParams, OrderByClause, PostVoteParams, PurchasePlansParams, PurchasePlansWithCheckoutParams, QueryDataRecordsParams, ReferenceOperation, ReferenceSelector, RemoveMemberFromTeamParams, RemovePlanParams, ReplacePlanParams, ResetMemberPasswordParams, SelectClause, SendMemberLoginPasswordlessEmailParams, SendMemberResetPasswordEmailParams, SetPasswordParams, SignupMemberAuthProviderParams, SignupMemberEmailPasswordParams, SignupWithProviderParams, ThreadVoteParams, UpdateDataRecordParams, UpdateDefaultCardParams, UpdateMemberAuthParams, UpdateMemberJSONParams, UpdateMemberParams, UpdateMemberProfileImageParams, UpdatePlanPaymentParams, UpdatePostParams, UpdateThreadParams, WhereClause, WhereOperators };