@memberstack/dom 2.0.0 → 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 +1548 -30626
- package/lib/index.mjs +1534 -30626
- 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 +1024 -30617
- package/lib/methods/index.mjs +1023 -30617
- package/lib/methods/requests/index.d.mts +843 -23
- package/lib/methods/requests/index.d.ts +843 -23
- package/lib/methods/requests/index.js +867 -42
- package/lib/methods/requests/index.mjs +866 -42
- 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 +634 -10
- package/lib/types/params.d.ts +634 -10
- 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
|
@@ -4,6 +4,10 @@ import '../../types/utils/payloads.mjs';
|
|
|
4
4
|
|
|
5
5
|
interface MemberstackOptions {
|
|
6
6
|
token?: BearerToken;
|
|
7
|
+
/** @internal Used by Webflow package to include content groups in response */
|
|
8
|
+
includeContentGroups?: boolean;
|
|
9
|
+
/** @internal Used by Webflow package to identify requests from Webflow integration */
|
|
10
|
+
isWebflow?: boolean;
|
|
7
11
|
}
|
|
8
12
|
interface GetCurrentMemberParams {
|
|
9
13
|
useCache?: Boolean;
|
|
@@ -21,71 +25,887 @@ declare const initRequest: ({ publicKey, appId, token, domain, }: ClientConfig)
|
|
|
21
25
|
_Event(params: {
|
|
22
26
|
data: any;
|
|
23
27
|
}): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Permanently deletes the current member's account.
|
|
30
|
+
* This action cannot be undone. The member will be logged out after deletion.
|
|
31
|
+
*
|
|
32
|
+
* @returns Promise resolving to deletion confirmation
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Confirm with user before calling
|
|
37
|
+
* if (confirm('Are you sure? This cannot be undone.')) {
|
|
38
|
+
* await memberstack.deleteMember();
|
|
39
|
+
* window.location.href = '/goodbye';
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
24
43
|
deleteMember(): Promise<DeleteMemberPayload>;
|
|
25
44
|
postIsTyping(params: {
|
|
26
45
|
channelKey: string;
|
|
27
46
|
}): Promise<void>;
|
|
28
|
-
getChannelInfo(params
|
|
47
|
+
getChannelInfo(params: {
|
|
29
48
|
channelKey: string;
|
|
30
49
|
}): Promise<any>;
|
|
31
|
-
subscribeToChannel(params
|
|
50
|
+
subscribeToChannel(params: {
|
|
32
51
|
channelKey: string;
|
|
33
52
|
action: "NONE" | "THREADS_ONLY";
|
|
34
53
|
}): Promise<void>;
|
|
35
|
-
getPosts(params
|
|
36
|
-
getThreads(params
|
|
37
|
-
createPost(params
|
|
38
|
-
updatePost(params
|
|
39
|
-
postVote(params
|
|
40
|
-
deletePost(params
|
|
41
|
-
createThread(params
|
|
42
|
-
updateThread(params
|
|
43
|
-
threadVote(params
|
|
44
|
-
deleteThread(params
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
getPosts(params: GetPostsParams): Promise<GetPostsPayload>;
|
|
55
|
+
getThreads(params: GetThreadsParams): Promise<GetThreadsPayload>;
|
|
56
|
+
createPost(params: CreatePostParams): Promise<CreatePostPayload>;
|
|
57
|
+
updatePost(params: UpdatePostParams): Promise<UpdatePostPayload>;
|
|
58
|
+
postVote(params: PostVoteParams): Promise<void>;
|
|
59
|
+
deletePost(params: DeletePostParams): Promise<void>;
|
|
60
|
+
createThread(params: CreateThreadParams): Promise<CreateThreadPayload>;
|
|
61
|
+
updateThread(params: UpdateThreadParams): Promise<UpdateThreadPayload>;
|
|
62
|
+
threadVote(params: ThreadVoteParams): Promise<void>;
|
|
63
|
+
deleteThread(params: DeleteThreadParams): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves gated/secure content by its content ID.
|
|
66
|
+
* Use this to fetch content that requires specific plan access.
|
|
67
|
+
*
|
|
68
|
+
* @param params - Content parameters
|
|
69
|
+
* @param params.contentId - The ID of the secure content block to retrieve
|
|
70
|
+
* @returns Promise resolving to the secure content data
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const { data: content } = await memberstack.getSecureContent({
|
|
75
|
+
* contentId: 'cnt_abc123'
|
|
76
|
+
* });
|
|
77
|
+
* document.getElementById('premium-content').innerHTML = content.html;
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
getSecureContent(params: GetSecureContentParams): Promise<GetSecureContentPayload>;
|
|
81
|
+
/**
|
|
82
|
+
* Signs up a new member using an OAuth provider (e.g., Google, Facebook).
|
|
83
|
+
* Opens a popup window for the OAuth flow. On success, the member is created and logged in.
|
|
84
|
+
*
|
|
85
|
+
* @param params - Signup parameters
|
|
86
|
+
* @param params.provider - The OAuth provider to use ('google', 'facebook', etc.)
|
|
87
|
+
* @param params.customFields - Optional custom field values to set during signup
|
|
88
|
+
* @param params.plans - Optional array of plan objects to assign on signup
|
|
89
|
+
* @param params.inviteToken - Optional team invite token
|
|
90
|
+
* @returns Promise resolving to the authenticated member data
|
|
91
|
+
*
|
|
92
|
+
* @example Sign up with Google
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const { data } = await memberstack.signupWithProvider({
|
|
95
|
+
* provider: 'google'
|
|
96
|
+
* });
|
|
97
|
+
* console.log('Signed up:', data.member.auth.email);
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example Sign up with custom fields
|
|
101
|
+
* ```typescript
|
|
102
|
+
* await memberstack.signupWithProvider({
|
|
103
|
+
* provider: 'google',
|
|
104
|
+
* customFields: { role: 'developer' },
|
|
105
|
+
* plans: [{ planId: 'pln_free' }]
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
signupWithProvider(params: SignupWithProviderParams): Promise<unknown>;
|
|
110
|
+
/**
|
|
111
|
+
* Logs in an existing member using an OAuth provider (e.g., Google, Facebook).
|
|
112
|
+
* Opens a popup window for the OAuth flow. Member must already have an account linked to this provider.
|
|
113
|
+
*
|
|
114
|
+
* @param params - Login parameters
|
|
115
|
+
* @param params.provider - The OAuth provider to use ('google', 'facebook', etc.)
|
|
116
|
+
* @param params.allowSignup - If true, creates a new account if one doesn't exist (default: false)
|
|
117
|
+
* @returns Promise resolving to the authenticated member data
|
|
118
|
+
*
|
|
119
|
+
* @example Log in with Google
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const { data } = await memberstack.loginWithProvider({
|
|
122
|
+
* provider: 'google'
|
|
123
|
+
* });
|
|
124
|
+
* console.log('Logged in:', data.member.auth.email);
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @example Allow signup if account doesn't exist
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const { data } = await memberstack.loginWithProvider({
|
|
130
|
+
* provider: 'google',
|
|
131
|
+
* allowSignup: true
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
loginWithProvider(params: LoginWithProviderParams): Promise<unknown>;
|
|
136
|
+
/**
|
|
137
|
+
* Connects an OAuth provider to the current member's account.
|
|
138
|
+
* Allows the member to use additional OAuth providers for login.
|
|
139
|
+
* Member must be logged in to use this method.
|
|
140
|
+
*
|
|
141
|
+
* @param params - Provider parameters
|
|
142
|
+
* @param params.provider - The OAuth provider to connect ('google', 'facebook', etc.)
|
|
143
|
+
* @returns Promise resolving to the connection result
|
|
144
|
+
*
|
|
145
|
+
* @example Connect Google to existing account
|
|
146
|
+
* ```typescript
|
|
147
|
+
* await memberstack.connectProvider({
|
|
148
|
+
* provider: 'google'
|
|
149
|
+
* });
|
|
150
|
+
* // Member can now log in with either email/password or Google
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
connectProvider(params: LoginWithProviderParams): Promise<ConnectProviderPayload>;
|
|
154
|
+
/**
|
|
155
|
+
* Disconnects an OAuth provider from the current member's account.
|
|
156
|
+
* After disconnecting, the member can no longer use this provider to log in.
|
|
157
|
+
* Member must be logged in and have another login method available.
|
|
158
|
+
*
|
|
159
|
+
* @param params - Provider parameters
|
|
160
|
+
* @param params.provider - The OAuth provider to disconnect ('google', 'facebook', etc.)
|
|
161
|
+
* @returns Promise resolving to the disconnection result
|
|
162
|
+
*
|
|
163
|
+
* @example Disconnect Google from account
|
|
164
|
+
* ```typescript
|
|
165
|
+
* await memberstack.disconnectProvider({
|
|
166
|
+
* provider: 'google'
|
|
167
|
+
* });
|
|
168
|
+
* // Member must now use email/password or another connected provider
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
49
171
|
disconnectProvider(params: LoginWithProviderParams): Promise<ConnectProviderPayload>;
|
|
50
|
-
getAppAndMember(params?:
|
|
172
|
+
getAppAndMember(params?: {
|
|
173
|
+
trackPageView?: boolean;
|
|
174
|
+
}): Promise<GetAppAndMemberPayload>;
|
|
175
|
+
/**
|
|
176
|
+
* Retrieves your Memberstack app configuration.
|
|
177
|
+
* Returns app settings including authentication options, branding, and enabled features.
|
|
178
|
+
*
|
|
179
|
+
* @returns Promise resolving to the app configuration
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* const { data: app } = await memberstack.getApp();
|
|
184
|
+
* console.log('App name:', app.name);
|
|
185
|
+
* console.log('OAuth providers:', app.authProviders);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
51
188
|
getApp(): Promise<AppPayload>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Authenticates a member using their email and password.
|
|
191
|
+
* On success, the member's session is automatically stored and they become the current user.
|
|
192
|
+
*
|
|
193
|
+
* @param params - Login credentials
|
|
194
|
+
* @param params.email - The member's email address
|
|
195
|
+
* @param params.password - The member's password
|
|
196
|
+
* @returns Promise resolving to the authenticated member data and tokens
|
|
197
|
+
* @throws When credentials are invalid or account doesn't exist
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* try {
|
|
202
|
+
* const { data } = await memberstack.loginMemberEmailPassword({
|
|
203
|
+
* email: 'user@example.com',
|
|
204
|
+
* password: 'securePassword123'
|
|
205
|
+
* });
|
|
206
|
+
* console.log('Logged in:', data.member.auth.email);
|
|
207
|
+
* } catch (error) {
|
|
208
|
+
* console.error('Login failed:', error.message);
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
loginMemberEmailPassword(params: LoginMemberEmailPasswordParams, options?: MemberstackOptions): Promise<LoginMemberEmailPasswordPayload>;
|
|
213
|
+
/**
|
|
214
|
+
* Sends a passwordless login code to an existing member's email.
|
|
215
|
+
* The member will receive a one-time code they can use to log in without a password.
|
|
216
|
+
*
|
|
217
|
+
* @param params - Email parameters
|
|
218
|
+
* @param params.email - The member's email address
|
|
219
|
+
* @returns Promise resolving to success confirmation
|
|
220
|
+
* @throws When the email is not associated with an existing member
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* // Step 1: Send the code
|
|
225
|
+
* await memberstack.sendMemberLoginPasswordlessEmail({
|
|
226
|
+
* email: 'user@example.com'
|
|
227
|
+
* });
|
|
228
|
+
* // User receives email with code
|
|
229
|
+
*
|
|
230
|
+
* // Step 2: Complete login with the code (see loginMemberPasswordless)
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
sendMemberLoginPasswordlessEmail(params: SendMemberLoginPasswordlessEmailParams, options?: MemberstackOptions): Promise<SendMemberLoginPasswordlessEmailPayload>;
|
|
234
|
+
/**
|
|
235
|
+
* Sends a passwordless signup code to a new member's email.
|
|
236
|
+
* Use this for registration flows where you don't want to collect passwords.
|
|
237
|
+
*
|
|
238
|
+
* @param params - Email parameters
|
|
239
|
+
* @param params.email - The new member's email address
|
|
240
|
+
* @returns Promise resolving to success confirmation
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* // Step 1: Send the signup code
|
|
245
|
+
* await memberstack.sendMemberSignupPasswordlessEmail({
|
|
246
|
+
* email: 'newuser@example.com'
|
|
247
|
+
* });
|
|
248
|
+
*
|
|
249
|
+
* // Step 2: Complete signup with the code (see signupMemberPasswordless)
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
sendMemberSignupPasswordlessEmail(params: SendMemberLoginPasswordlessEmailParams, options?: MemberstackOptions): Promise<SendMemberLoginPasswordlessEmailPayload>;
|
|
253
|
+
/**
|
|
254
|
+
* Completes passwordless login using the code sent via email.
|
|
255
|
+
* On success, the member is logged in and their session is stored.
|
|
256
|
+
*
|
|
257
|
+
* @param params - Login credentials
|
|
258
|
+
* @param params.email - The member's email address
|
|
259
|
+
* @param params.passwordlessToken - The one-time code from the email
|
|
260
|
+
* @returns Promise resolving to the authenticated member data and tokens
|
|
261
|
+
* @throws When the code is invalid or expired
|
|
262
|
+
*
|
|
263
|
+
* @example Complete passwordless login flow
|
|
264
|
+
* ```typescript
|
|
265
|
+
* // After user enters the code from their email
|
|
266
|
+
* const { data } = await memberstack.loginMemberPasswordless({
|
|
267
|
+
* email: 'user@example.com',
|
|
268
|
+
* passwordlessToken: '123456' // Code from email
|
|
269
|
+
* });
|
|
270
|
+
* console.log('Logged in:', data.member.auth.email);
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
loginMemberPasswordless(params: LoginMemberPasswordlessParams, options?: MemberstackOptions): Promise<LoginMemberEmailPasswordPayload>;
|
|
274
|
+
/**
|
|
275
|
+
* Retrieves details for a specific plan by ID.
|
|
276
|
+
* Returns plan information including name, description, and pricing.
|
|
277
|
+
*
|
|
278
|
+
* @param params - Plan parameters
|
|
279
|
+
* @param params.planId - The ID of the plan to retrieve
|
|
280
|
+
* @returns Promise resolving to the plan details
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* const { data: plan } = await memberstack.getPlan({
|
|
285
|
+
* planId: 'pln_pro123'
|
|
286
|
+
* });
|
|
287
|
+
* console.log('Plan:', plan.name);
|
|
288
|
+
* console.log('Prices:', plan.prices);
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
56
291
|
getPlan(params: GetPlanParams): Promise<GetPlanPayload>;
|
|
292
|
+
/**
|
|
293
|
+
* Retrieves all plans configured for your Memberstack app.
|
|
294
|
+
* Returns both free and paid plans with their pricing information.
|
|
295
|
+
*
|
|
296
|
+
* @returns Promise resolving to an array of plans
|
|
297
|
+
*
|
|
298
|
+
* @example List all plans
|
|
299
|
+
* ```typescript
|
|
300
|
+
* const { data: plans } = await memberstack.getPlans();
|
|
301
|
+
*
|
|
302
|
+
* plans.forEach(plan => {
|
|
303
|
+
* console.log(plan.name, plan.id);
|
|
304
|
+
* plan.prices?.forEach(price => {
|
|
305
|
+
* console.log(` ${price.name}: ${price.amount} ${price.currency}`);
|
|
306
|
+
* });
|
|
307
|
+
* });
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @example Build a pricing page
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const { data: plans } = await memberstack.getPlans();
|
|
313
|
+
*
|
|
314
|
+
* const pricingHtml = plans.map(plan => `
|
|
315
|
+
* <div class="plan">
|
|
316
|
+
* <h3>${plan.name}</h3>
|
|
317
|
+
* <p>${plan.description}</p>
|
|
318
|
+
* </div>
|
|
319
|
+
* `).join('');
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
57
322
|
getPlans(): Promise<GetPlansPayload>;
|
|
323
|
+
/**
|
|
324
|
+
* Retrieves URL restriction groups configured for your app.
|
|
325
|
+
* These define which URLs require specific plans or authentication to access.
|
|
326
|
+
*
|
|
327
|
+
* @returns Promise resolving to an array of content access groups
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* const { data: groups } = await memberstack.getRestrictedUrlGroups();
|
|
332
|
+
*
|
|
333
|
+
* groups.forEach(group => {
|
|
334
|
+
* console.log('Group:', group.name);
|
|
335
|
+
* console.log('Required plans:', group.planIds);
|
|
336
|
+
* console.log('URLs:', group.urls);
|
|
337
|
+
* });
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
58
340
|
getRestrictedUrlGroups(): Promise<GetRestrictedUrlGroupsPayload>;
|
|
341
|
+
/**
|
|
342
|
+
* Retrieves the currently authenticated member's data.
|
|
343
|
+
* Returns `null` if no user is logged in.
|
|
344
|
+
*
|
|
345
|
+
* @param options - Optional configuration
|
|
346
|
+
* @param options.useCache - If true, returns cached member data instead of fetching from server
|
|
347
|
+
* @returns Promise resolving to the current member's data, or null if not authenticated
|
|
348
|
+
*
|
|
349
|
+
* @example Check if user is logged in
|
|
350
|
+
* ```typescript
|
|
351
|
+
* const { data: member } = await memberstack.getCurrentMember();
|
|
352
|
+
*
|
|
353
|
+
* if (member) {
|
|
354
|
+
* console.log('Logged in as:', member.auth.email);
|
|
355
|
+
* console.log('Plans:', member.planConnections);
|
|
356
|
+
* } else {
|
|
357
|
+
* console.log('Not logged in');
|
|
358
|
+
* }
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* @example Access member properties
|
|
362
|
+
* ```typescript
|
|
363
|
+
* const { data: member } = await memberstack.getCurrentMember();
|
|
364
|
+
*
|
|
365
|
+
* if (member) {
|
|
366
|
+
* const email = member.auth.email;
|
|
367
|
+
* const isVerified = member.verified;
|
|
368
|
+
* const customFields = member.customFields;
|
|
369
|
+
* const hasPro = member.planConnections.some(p => p.planId === 'pln_pro');
|
|
370
|
+
* }
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
59
373
|
getCurrentMember(options?: GetCurrentMemberParams): Promise<GetCurrentMemberPayload>;
|
|
374
|
+
/**
|
|
375
|
+
* Retrieves the current member's JSON data store.
|
|
376
|
+
* This is a flexible key-value store for storing arbitrary member data.
|
|
377
|
+
*
|
|
378
|
+
* @returns Promise resolving to the member's JSON data object
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* const { data: json } = await memberstack.getMemberJSON();
|
|
383
|
+
* console.log('Preferences:', json.preferences);
|
|
384
|
+
* console.log('Last visited:', json.lastVisitedPage);
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
60
387
|
getMemberJSON(options?: MemberstackOptions): Promise<GetMemberJSONPayload>;
|
|
388
|
+
/**
|
|
389
|
+
* Updates the current member's JSON data store.
|
|
390
|
+
* You can store any JSON-serializable data. Updates are merged with existing data.
|
|
391
|
+
*
|
|
392
|
+
* @param params - JSON data to store
|
|
393
|
+
* @param params.json - Object containing the data to store
|
|
394
|
+
* @returns Promise resolving to the updated JSON data
|
|
395
|
+
*
|
|
396
|
+
* @example Store user preferences
|
|
397
|
+
* ```typescript
|
|
398
|
+
* await memberstack.updateMemberJSON({
|
|
399
|
+
* json: {
|
|
400
|
+
* preferences: { theme: 'dark', notifications: true },
|
|
401
|
+
* lastVisitedPage: '/dashboard',
|
|
402
|
+
* onboardingComplete: true
|
|
403
|
+
* }
|
|
404
|
+
* });
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @example Store app-specific data
|
|
408
|
+
* ```typescript
|
|
409
|
+
* await memberstack.updateMemberJSON({
|
|
410
|
+
* json: {
|
|
411
|
+
* savedItems: ['item1', 'item2'],
|
|
412
|
+
* progress: { level: 5, score: 1200 }
|
|
413
|
+
* }
|
|
414
|
+
* });
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
61
417
|
updateMemberJSON(params: UpdateMemberJSONParams, options?: MemberstackOptions): Promise<GetMemberJSONPayload>;
|
|
418
|
+
/**
|
|
419
|
+
* Adds a free plan to the current member.
|
|
420
|
+
* For paid plans, use `purchasePlansWithCheckout()` instead.
|
|
421
|
+
*
|
|
422
|
+
* @param params - Plan parameters
|
|
423
|
+
* @param params.planId - The ID of the free plan to add
|
|
424
|
+
* @returns Promise resolving to the updated member data with the new plan
|
|
425
|
+
*
|
|
426
|
+
* @example Add a free tier plan
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const { data } = await memberstack.addPlan({
|
|
429
|
+
* planId: 'pln_free_tier'
|
|
430
|
+
* });
|
|
431
|
+
* console.log('Plan added, redirect:', data.redirect);
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
62
434
|
addPlan(params: AddPlanParams, options?: MemberstackOptions): Promise<AddPlanPayload>;
|
|
435
|
+
/**
|
|
436
|
+
* Initiates a Stripe checkout session for purchasing a paid plan.
|
|
437
|
+
* By default, redirects the user to Stripe's hosted checkout page.
|
|
438
|
+
*
|
|
439
|
+
* @param params - Checkout configuration
|
|
440
|
+
* @param params.priceId - The Memberstack price ID to purchase (e.g., 'prc_monthly_pro')
|
|
441
|
+
* @param params.successUrl - URL to redirect to after successful payment (relative or absolute)
|
|
442
|
+
* @param params.cancelUrl - URL to redirect to if user cancels checkout (relative or absolute)
|
|
443
|
+
* @param params.couponId - Optional Stripe coupon ID to apply
|
|
444
|
+
* @param params.autoRedirect - Set to `false` to get the checkout URL without redirecting
|
|
445
|
+
* @returns Promise resolving to checkout data (includes URL if autoRedirect is false)
|
|
446
|
+
*
|
|
447
|
+
* @example Start checkout for a plan
|
|
448
|
+
* ```typescript
|
|
449
|
+
* await memberstack.purchasePlansWithCheckout({
|
|
450
|
+
* priceId: 'prc_monthly_pro',
|
|
451
|
+
* successUrl: '/welcome',
|
|
452
|
+
* cancelUrl: '/pricing'
|
|
453
|
+
* });
|
|
454
|
+
* // User is redirected to Stripe checkout
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @example Get checkout URL without redirecting
|
|
458
|
+
* ```typescript
|
|
459
|
+
* const { data } = await memberstack.purchasePlansWithCheckout({
|
|
460
|
+
* priceId: 'prc_monthly_pro',
|
|
461
|
+
* successUrl: '/welcome',
|
|
462
|
+
* cancelUrl: '/pricing',
|
|
463
|
+
* autoRedirect: false
|
|
464
|
+
* });
|
|
465
|
+
* console.log('Checkout URL:', data.url);
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* @example Apply a coupon
|
|
469
|
+
* ```typescript
|
|
470
|
+
* await memberstack.purchasePlansWithCheckout({
|
|
471
|
+
* priceId: 'prc_annual_pro',
|
|
472
|
+
* couponId: 'SAVE20',
|
|
473
|
+
* successUrl: '/welcome',
|
|
474
|
+
* cancelUrl: '/pricing'
|
|
475
|
+
* });
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
63
478
|
purchasePlansWithCheckout(params: PurchasePlansWithCheckoutParams, options?: MemberstackOptions): Promise<PurchasePlansWithCheckoutPayload>;
|
|
479
|
+
/**
|
|
480
|
+
* Opens the Stripe Customer Portal for the current member.
|
|
481
|
+
* The portal allows members to manage their subscriptions, update payment methods, and view invoices.
|
|
482
|
+
* By default, redirects the user to the Stripe-hosted portal.
|
|
483
|
+
*
|
|
484
|
+
* @param params - Portal configuration
|
|
485
|
+
* @param params.returnUrl - URL to redirect to when member exits the portal (relative or absolute)
|
|
486
|
+
* @param params.priceIds - Optional array of price IDs to show for plan switching
|
|
487
|
+
* @param params.autoRedirect - Set to `false` to get the portal URL without redirecting
|
|
488
|
+
* @returns Promise resolving to portal data (includes URL if autoRedirect is false)
|
|
489
|
+
*
|
|
490
|
+
* @example Open customer portal
|
|
491
|
+
* ```typescript
|
|
492
|
+
* await memberstack.launchStripeCustomerPortal({
|
|
493
|
+
* returnUrl: '/account'
|
|
494
|
+
* });
|
|
495
|
+
* // User is redirected to Stripe Customer Portal
|
|
496
|
+
* ```
|
|
497
|
+
*
|
|
498
|
+
* @example Get portal URL without redirecting
|
|
499
|
+
* ```typescript
|
|
500
|
+
* const { data } = await memberstack.launchStripeCustomerPortal({
|
|
501
|
+
* returnUrl: '/account',
|
|
502
|
+
* autoRedirect: false
|
|
503
|
+
* });
|
|
504
|
+
* console.log('Portal URL:', data.url);
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
64
507
|
launchStripeCustomerPortal(params: LaunchStripeCustomerPortalParams, options?: MemberstackOptions): Promise<LaunchStripeCustomerPortalPayload>;
|
|
508
|
+
/**
|
|
509
|
+
* Removes a plan from the current member.
|
|
510
|
+
* For paid plans, this will cancel the subscription.
|
|
511
|
+
*
|
|
512
|
+
* @param params - Plan parameters
|
|
513
|
+
* @param params.planId - The ID of the plan to remove
|
|
514
|
+
* @returns Promise resolving to the updated member data
|
|
515
|
+
*
|
|
516
|
+
* @example Remove a plan
|
|
517
|
+
* ```typescript
|
|
518
|
+
* await memberstack.removePlan({
|
|
519
|
+
* planId: 'pln_premium'
|
|
520
|
+
* });
|
|
521
|
+
* // Plan removed/subscription cancelled
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
65
524
|
removePlan(params: RemovePlanParams, options?: MemberstackOptions): Promise<RemovePlanPayload>;
|
|
525
|
+
/**
|
|
526
|
+
* Updates the current member's custom fields.
|
|
527
|
+
* Only updates the fields you specify; other fields remain unchanged.
|
|
528
|
+
*
|
|
529
|
+
* @param params - Update data
|
|
530
|
+
* @param params.customFields - Object containing custom field key-value pairs to update
|
|
531
|
+
* @returns Promise resolving to the updated member data
|
|
532
|
+
*
|
|
533
|
+
* @example Update custom fields
|
|
534
|
+
* ```typescript
|
|
535
|
+
* const { data: member } = await memberstack.updateMember({
|
|
536
|
+
* customFields: {
|
|
537
|
+
* firstName: 'Jane',
|
|
538
|
+
* company: 'Acme Inc',
|
|
539
|
+
* preferences: { theme: 'dark' }
|
|
540
|
+
* }
|
|
541
|
+
* });
|
|
542
|
+
* console.log('Updated:', member.customFields);
|
|
543
|
+
* ```
|
|
544
|
+
*
|
|
545
|
+
* @example Update a single field
|
|
546
|
+
* ```typescript
|
|
547
|
+
* await memberstack.updateMember({
|
|
548
|
+
* customFields: {
|
|
549
|
+
* lastLoginPage: window.location.pathname
|
|
550
|
+
* }
|
|
551
|
+
* });
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
66
554
|
updateMember(params: UpdateMemberParams, options?: MemberstackOptions): Promise<UpdateMemberPayload>;
|
|
555
|
+
/**
|
|
556
|
+
* Updates the current member's authentication credentials (email and/or password).
|
|
557
|
+
* Requires the current password to verify the member's identity.
|
|
558
|
+
*
|
|
559
|
+
* @param params - Auth update parameters
|
|
560
|
+
* @param params.email - New email address (optional)
|
|
561
|
+
* @param params.oldPassword - Current password (required for password changes)
|
|
562
|
+
* @param params.newPassword - New password (optional)
|
|
563
|
+
* @returns Promise resolving to the updated member data
|
|
564
|
+
* @throws When the old password is incorrect
|
|
565
|
+
*
|
|
566
|
+
* @example Change email
|
|
567
|
+
* ```typescript
|
|
568
|
+
* await memberstack.updateMemberAuth({
|
|
569
|
+
* email: 'newemail@example.com',
|
|
570
|
+
* oldPassword: 'currentPassword'
|
|
571
|
+
* });
|
|
572
|
+
* ```
|
|
573
|
+
*
|
|
574
|
+
* @example Change password
|
|
575
|
+
* ```typescript
|
|
576
|
+
* await memberstack.updateMemberAuth({
|
|
577
|
+
* oldPassword: 'currentPassword',
|
|
578
|
+
* newPassword: 'newSecurePassword123'
|
|
579
|
+
* });
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
67
582
|
updateMemberAuth(params: UpdateMemberAuthParams, options?: MemberstackOptions): Promise<UpdateMemberAuthPayload>;
|
|
583
|
+
/**
|
|
584
|
+
* Sets a password for a member who signed up via passwordless or OAuth.
|
|
585
|
+
* Use this when a member wants to add password-based login to their account.
|
|
586
|
+
*
|
|
587
|
+
* @param params - Password parameters
|
|
588
|
+
* @param params.password - The password to set
|
|
589
|
+
* @returns Promise resolving to the updated member data
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* // For members who signed up via Google OAuth or passwordless
|
|
594
|
+
* await memberstack.setPassword({
|
|
595
|
+
* password: 'newSecurePassword123'
|
|
596
|
+
* });
|
|
597
|
+
* // Member can now log in with email/password
|
|
598
|
+
* ```
|
|
599
|
+
*/
|
|
68
600
|
setPassword(params: SetPasswordParams, options?: MemberstackOptions): Promise<SetPasswordPayload>;
|
|
69
601
|
signupMemberPasswordless(params: Omit<SignupMemberEmailPasswordParams, "password"> & {
|
|
70
602
|
passwordlessToken: string;
|
|
71
|
-
}, options?:
|
|
72
|
-
|
|
603
|
+
}, options?: MemberstackOptions): Promise<SignupMemberEmailPasswordPayload>;
|
|
604
|
+
/**
|
|
605
|
+
* Creates a new member account with email and password.
|
|
606
|
+
* On success, the member is automatically logged in and their session is stored.
|
|
607
|
+
*
|
|
608
|
+
* @param params - Signup details
|
|
609
|
+
* @param params.email - The new member's email address
|
|
610
|
+
* @param params.password - The new member's password (minimum 8 characters recommended)
|
|
611
|
+
* @param params.customFields - Optional custom field values defined in your Memberstack dashboard
|
|
612
|
+
* @param params.plans - Optional array of plan IDs to assign on signup (for free plans)
|
|
613
|
+
* @param params.metaData - Optional metadata to store with the member
|
|
614
|
+
* @param params.inviteToken - Optional team invite token for team signups
|
|
615
|
+
* @returns Promise resolving to the new member data and tokens
|
|
616
|
+
* @throws When email is already in use or validation fails
|
|
617
|
+
*
|
|
618
|
+
* @example Basic signup
|
|
619
|
+
* ```typescript
|
|
620
|
+
* const { data } = await memberstack.signupMemberEmailPassword({
|
|
621
|
+
* email: 'newuser@example.com',
|
|
622
|
+
* password: 'securePassword123'
|
|
623
|
+
* });
|
|
624
|
+
* console.log('Welcome!', data.member.id);
|
|
625
|
+
* ```
|
|
626
|
+
*
|
|
627
|
+
* @example Signup with custom fields and a free plan
|
|
628
|
+
* ```typescript
|
|
629
|
+
* const { data } = await memberstack.signupMemberEmailPassword({
|
|
630
|
+
* email: 'newuser@example.com',
|
|
631
|
+
* password: 'securePassword123',
|
|
632
|
+
* customFields: {
|
|
633
|
+
* firstName: 'Jane',
|
|
634
|
+
* lastName: 'Doe',
|
|
635
|
+
* company: 'Acme Inc'
|
|
636
|
+
* },
|
|
637
|
+
* plans: [{ planId: 'pln_free_tier' }]
|
|
638
|
+
* });
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
signupMemberEmailPassword(params: SignupMemberEmailPasswordParams, options?: MemberstackOptions): Promise<SignupMemberEmailPasswordPayload>;
|
|
73
642
|
joinTeam(params: JoinTeamParams, options?: MemberstackOptions): Promise<void>;
|
|
74
643
|
getTeam(params: GetTeamParams, options?: MemberstackOptions): Promise<void>;
|
|
75
644
|
removeMemberFromTeam(params: RemoveMemberFromTeamParams, options?: MemberstackOptions): Promise<void>;
|
|
76
645
|
generateInviteToken(params: GenerateInviteTokenParams, options?: MemberstackOptions): Promise<void>;
|
|
646
|
+
/**
|
|
647
|
+
* Uploads a new profile image for the current member.
|
|
648
|
+
* Accepts a File object (from an input element) or a Blob.
|
|
649
|
+
*
|
|
650
|
+
* @param params - Image parameters
|
|
651
|
+
* @param params.profileImage - The image file to upload
|
|
652
|
+
* @returns Promise resolving to the new profile image URL
|
|
653
|
+
*
|
|
654
|
+
* @example Upload from file input
|
|
655
|
+
* ```typescript
|
|
656
|
+
* const input = document.querySelector('input[type="file"]');
|
|
657
|
+
* const file = input.files[0];
|
|
658
|
+
*
|
|
659
|
+
* const { data } = await memberstack.updateMemberProfileImage({
|
|
660
|
+
* profileImage: file
|
|
661
|
+
* });
|
|
662
|
+
* console.log('New image URL:', data.profileImage);
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
77
665
|
updateMemberProfileImage(params: UpdateMemberProfileImageParams): Promise<UpdateMemberProfileImagePayload>;
|
|
666
|
+
/**
|
|
667
|
+
* Sends a verification email to the current member.
|
|
668
|
+
* Use this when email verification is enabled in your Memberstack settings.
|
|
669
|
+
*
|
|
670
|
+
* @returns Promise resolving to success confirmation
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```typescript
|
|
674
|
+
* await memberstack.sendMemberVerificationEmail();
|
|
675
|
+
* // Show message: "Verification email sent! Check your inbox."
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
78
678
|
sendMemberVerificationEmail(): Promise<SendMemberVerificationEmailPayload>;
|
|
679
|
+
/**
|
|
680
|
+
* Sends a password reset email to a member.
|
|
681
|
+
* The email contains a link with a token that can be used to reset their password.
|
|
682
|
+
*
|
|
683
|
+
* @param params - Email parameters
|
|
684
|
+
* @param params.email - The member's email address
|
|
685
|
+
* @returns Promise resolving to success confirmation
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* ```typescript
|
|
689
|
+
* await memberstack.sendMemberResetPasswordEmail({
|
|
690
|
+
* email: 'user@example.com'
|
|
691
|
+
* });
|
|
692
|
+
* // Show confirmation: "Check your email for reset instructions"
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
79
695
|
sendMemberResetPasswordEmail(params: SendMemberResetPasswordEmailParams): Promise<SendMemberResetPasswordEmailPayload>;
|
|
696
|
+
/**
|
|
697
|
+
* Completes the password reset process using the token from the reset email.
|
|
698
|
+
* Typically called from a password reset page that receives the token via URL parameter.
|
|
699
|
+
*
|
|
700
|
+
* @param params - Reset parameters
|
|
701
|
+
* @param params.token - The reset token from the email link
|
|
702
|
+
* @param params.newPassword - The new password to set
|
|
703
|
+
* @returns Promise resolving to success confirmation
|
|
704
|
+
* @throws When the token is invalid or expired
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```typescript
|
|
708
|
+
* // Get token from URL: /reset-password?token=abc123
|
|
709
|
+
* const token = new URLSearchParams(window.location.search).get('token');
|
|
710
|
+
*
|
|
711
|
+
* await memberstack.resetMemberPassword({
|
|
712
|
+
* token,
|
|
713
|
+
* newPassword: 'newSecurePassword123'
|
|
714
|
+
* });
|
|
715
|
+
* // Password updated, redirect to login
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
80
718
|
resetMemberPassword(params: ResetMemberPasswordParams): Promise<ResetMemberPassworPayload>;
|
|
719
|
+
/**
|
|
720
|
+
* Signs out the currently authenticated member.
|
|
721
|
+
* Clears the local session and invalidates the server-side session.
|
|
722
|
+
*
|
|
723
|
+
* @returns Promise resolving to logout confirmation (may include a redirect URL)
|
|
724
|
+
*
|
|
725
|
+
* @example
|
|
726
|
+
* ```typescript
|
|
727
|
+
* await memberstack.logout();
|
|
728
|
+
* // User is now logged out
|
|
729
|
+
* window.location.href = '/login';
|
|
730
|
+
* ```
|
|
731
|
+
*
|
|
732
|
+
* @example With redirect handling
|
|
733
|
+
* ```typescript
|
|
734
|
+
* const { data } = await memberstack.logout();
|
|
735
|
+
* if (data.redirect) {
|
|
736
|
+
* window.location.href = data.redirect;
|
|
737
|
+
* }
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
81
740
|
logout(options?: MemberstackOptions): Promise<LogoutMemberPayload>;
|
|
741
|
+
/**
|
|
742
|
+
* Retrieves all data tables configured for your app.
|
|
743
|
+
* Returns the list of tables and their schemas.
|
|
744
|
+
*
|
|
745
|
+
* @returns Promise resolving to an array of data tables
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```typescript
|
|
749
|
+
* const { data: tables } = await memberstack.getDataTables();
|
|
750
|
+
* tables.forEach(table => {
|
|
751
|
+
* console.log('Table:', table.name, table.key);
|
|
752
|
+
* });
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
82
755
|
getDataTables(options?: MemberstackOptions): Promise<GetDataTablesPayload>;
|
|
756
|
+
/**
|
|
757
|
+
* Retrieves a specific data table's schema and configuration.
|
|
758
|
+
*
|
|
759
|
+
* @param params - Table parameters
|
|
760
|
+
* @param params.table - The table key/identifier
|
|
761
|
+
* @returns Promise resolving to the table schema
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* ```typescript
|
|
765
|
+
* const { data: table } = await memberstack.getDataTable({
|
|
766
|
+
* table: 'posts'
|
|
767
|
+
* });
|
|
768
|
+
* console.log('Columns:', table.columns);
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
83
771
|
getDataTable(params: GetDataTableParams, options?: MemberstackOptions): Promise<GetDataTablePayload>;
|
|
772
|
+
/**
|
|
773
|
+
* Retrieves records from a data table with optional filtering and pagination.
|
|
774
|
+
*
|
|
775
|
+
* @param params - Query parameters
|
|
776
|
+
* @param params.table - The table key/identifier
|
|
777
|
+
* @param params.limit - Maximum number of records to return
|
|
778
|
+
* @param params.after - Cursor for pagination (record ID to start after)
|
|
779
|
+
* @param params.sortBy - Field to sort by
|
|
780
|
+
* @param params.sortDirection - Sort direction ('asc' or 'desc')
|
|
781
|
+
* @param params.createdAfter - Filter records created after this date
|
|
782
|
+
* @param params.createdBefore - Filter records created before this date
|
|
783
|
+
* @returns Promise resolving to records array with pagination info
|
|
784
|
+
*
|
|
785
|
+
* @example List records with pagination
|
|
786
|
+
* ```typescript
|
|
787
|
+
* const { data } = await memberstack.getDataRecords({
|
|
788
|
+
* table: 'posts',
|
|
789
|
+
* limit: 10,
|
|
790
|
+
* sortBy: 'createdAt',
|
|
791
|
+
* sortDirection: 'desc'
|
|
792
|
+
* });
|
|
793
|
+
* console.log('Records:', data.records);
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
84
796
|
getDataRecords(params: GetDataRecordsParams, options?: MemberstackOptions): Promise<GetDataRecordsPayload>;
|
|
797
|
+
/**
|
|
798
|
+
* Creates a new record in a data table.
|
|
799
|
+
*
|
|
800
|
+
* @param params - Record parameters
|
|
801
|
+
* @param params.table - The table key/identifier
|
|
802
|
+
* @param params.data - The record data as key-value pairs
|
|
803
|
+
* @param params.memberId - Optional member ID to associate with the record
|
|
804
|
+
* @returns Promise resolving to the created record
|
|
805
|
+
*
|
|
806
|
+
* @example Create a new post
|
|
807
|
+
* ```typescript
|
|
808
|
+
* const { data: record } = await memberstack.createDataRecord({
|
|
809
|
+
* table: 'posts',
|
|
810
|
+
* data: {
|
|
811
|
+
* title: 'My First Post',
|
|
812
|
+
* content: 'Hello world!',
|
|
813
|
+
* published: true
|
|
814
|
+
* }
|
|
815
|
+
* });
|
|
816
|
+
* console.log('Created record:', record.id);
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
85
819
|
createDataRecord(params: CreateDataRecordParams, options?: MemberstackOptions): Promise<CreateDataRecordPayload>;
|
|
820
|
+
/**
|
|
821
|
+
* Retrieves a single record by ID from a data table.
|
|
822
|
+
*
|
|
823
|
+
* @param params - Record parameters
|
|
824
|
+
* @param params.table - The table key/identifier
|
|
825
|
+
* @param params.recordId - The ID of the record to retrieve
|
|
826
|
+
* @returns Promise resolving to the record data
|
|
827
|
+
*
|
|
828
|
+
* @example Get a specific post
|
|
829
|
+
* ```typescript
|
|
830
|
+
* const { data: record } = await memberstack.getDataRecord({
|
|
831
|
+
* table: 'posts',
|
|
832
|
+
* recordId: 'rec_abc123'
|
|
833
|
+
* });
|
|
834
|
+
* console.log('Post:', record.title);
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
86
837
|
getDataRecord(params: GetDataRecordParams, options?: MemberstackOptions): Promise<GetDataRecordPayload>;
|
|
838
|
+
/**
|
|
839
|
+
* Updates an existing record in a data table.
|
|
840
|
+
*
|
|
841
|
+
* @param params - Update parameters
|
|
842
|
+
* @param params.recordId - The ID of the record to update
|
|
843
|
+
* @param params.data - The fields to update as key-value pairs
|
|
844
|
+
* @returns Promise resolving to the updated record
|
|
845
|
+
*
|
|
846
|
+
* @example Update a post
|
|
847
|
+
* ```typescript
|
|
848
|
+
* const { data: record } = await memberstack.updateDataRecord({
|
|
849
|
+
* recordId: 'rec_abc123',
|
|
850
|
+
* data: {
|
|
851
|
+
* title: 'Updated Title',
|
|
852
|
+
* published: false
|
|
853
|
+
* }
|
|
854
|
+
* });
|
|
855
|
+
* ```
|
|
856
|
+
*/
|
|
87
857
|
updateDataRecord(params: UpdateDataRecordParams, options?: MemberstackOptions): Promise<UpdateDataRecordPayload>;
|
|
858
|
+
/**
|
|
859
|
+
* Deletes a record from a data table.
|
|
860
|
+
*
|
|
861
|
+
* @param params - Delete parameters
|
|
862
|
+
* @param params.recordId - The ID of the record to delete
|
|
863
|
+
* @returns Promise resolving to deletion confirmation
|
|
864
|
+
*
|
|
865
|
+
* @example Delete a post
|
|
866
|
+
* ```typescript
|
|
867
|
+
* await memberstack.deleteDataRecord({
|
|
868
|
+
* recordId: 'rec_abc123'
|
|
869
|
+
* });
|
|
870
|
+
* ```
|
|
871
|
+
*/
|
|
88
872
|
deleteDataRecord(params: DeleteDataRecordParams, options?: MemberstackOptions): Promise<DeleteDataRecordPayload>;
|
|
873
|
+
/**
|
|
874
|
+
* Queries records from a data table with advanced filtering.
|
|
875
|
+
* Provides more control than getDataRecords for complex queries.
|
|
876
|
+
*
|
|
877
|
+
* @param params - Query parameters
|
|
878
|
+
* @param params.table - The table key/identifier
|
|
879
|
+
* @param params.query - Query object with where, orderBy, take, skip options
|
|
880
|
+
* @returns Promise resolving to matching records
|
|
881
|
+
*
|
|
882
|
+
* @example Query with filters
|
|
883
|
+
* ```typescript
|
|
884
|
+
* const { data } = await memberstack.queryDataRecords({
|
|
885
|
+
* table: 'posts',
|
|
886
|
+
* query: {
|
|
887
|
+
* where: {
|
|
888
|
+
* published: { equals: true },
|
|
889
|
+
* category: { equals: 'tech' }
|
|
890
|
+
* },
|
|
891
|
+
* orderBy: { createdAt: 'desc' },
|
|
892
|
+
* take: 10
|
|
893
|
+
* }
|
|
894
|
+
* });
|
|
895
|
+
* ```
|
|
896
|
+
*
|
|
897
|
+
* @example Query with member filter
|
|
898
|
+
* ```typescript
|
|
899
|
+
* const { data } = await memberstack.queryDataRecords({
|
|
900
|
+
* table: 'comments',
|
|
901
|
+
* query: {
|
|
902
|
+
* where: {
|
|
903
|
+
* memberId: { equals: 'mem_xyz789' }
|
|
904
|
+
* }
|
|
905
|
+
* }
|
|
906
|
+
* });
|
|
907
|
+
* ```
|
|
908
|
+
*/
|
|
89
909
|
queryDataRecords(params: QueryDataRecordsParams, options?: MemberstackOptions): Promise<QueryDataRecordsPayload>;
|
|
90
910
|
};
|
|
91
911
|
|