@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
|
@@ -13,17 +13,18 @@ declare enum HttpHeaders {
|
|
|
13
13
|
USER_AGENT = "X-User-Agent",
|
|
14
14
|
SESSION_ID = "X-Session-ID"
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
publicKey:
|
|
18
|
-
appId
|
|
19
|
-
token
|
|
20
|
-
customEndpoint
|
|
21
|
-
}
|
|
16
|
+
interface RequestHandlerConfig {
|
|
17
|
+
publicKey: string;
|
|
18
|
+
appId?: string;
|
|
19
|
+
token?: string;
|
|
20
|
+
customEndpoint?: string;
|
|
21
|
+
}
|
|
22
|
+
declare const createRequestHandler: ({ publicKey, appId, token, customEndpoint, }: RequestHandlerConfig) => {
|
|
22
23
|
sendRequest: (data: {
|
|
23
24
|
method: HttpMethod;
|
|
24
25
|
url: string;
|
|
25
26
|
data?: object;
|
|
26
|
-
headers?:
|
|
27
|
+
headers?: Record<string, string>;
|
|
27
28
|
contentType?: string;
|
|
28
29
|
}, options?: {
|
|
29
30
|
token?: string;
|
|
@@ -32,7 +33,7 @@ declare const createRequestHandler: ({ publicKey, appId, token, customEndpoint,
|
|
|
32
33
|
method: HttpMethod;
|
|
33
34
|
url: string;
|
|
34
35
|
data?: object;
|
|
35
|
-
headers?:
|
|
36
|
+
headers?: Record<string, string>;
|
|
36
37
|
contentType?: string;
|
|
37
38
|
}, options?: {
|
|
38
39
|
token?: string;
|
|
@@ -13,17 +13,18 @@ declare enum HttpHeaders {
|
|
|
13
13
|
USER_AGENT = "X-User-Agent",
|
|
14
14
|
SESSION_ID = "X-Session-ID"
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
publicKey:
|
|
18
|
-
appId
|
|
19
|
-
token
|
|
20
|
-
customEndpoint
|
|
21
|
-
}
|
|
16
|
+
interface RequestHandlerConfig {
|
|
17
|
+
publicKey: string;
|
|
18
|
+
appId?: string;
|
|
19
|
+
token?: string;
|
|
20
|
+
customEndpoint?: string;
|
|
21
|
+
}
|
|
22
|
+
declare const createRequestHandler: ({ publicKey, appId, token, customEndpoint, }: RequestHandlerConfig) => {
|
|
22
23
|
sendRequest: (data: {
|
|
23
24
|
method: HttpMethod;
|
|
24
25
|
url: string;
|
|
25
26
|
data?: object;
|
|
26
|
-
headers?:
|
|
27
|
+
headers?: Record<string, string>;
|
|
27
28
|
contentType?: string;
|
|
28
29
|
}, options?: {
|
|
29
30
|
token?: string;
|
|
@@ -32,7 +33,7 @@ declare const createRequestHandler: ({ publicKey, appId, token, customEndpoint,
|
|
|
32
33
|
method: HttpMethod;
|
|
33
34
|
url: string;
|
|
34
35
|
data?: object;
|
|
35
|
-
headers?:
|
|
36
|
+
headers?: Record<string, string>;
|
|
36
37
|
contentType?: string;
|
|
37
38
|
}, options?: {
|
|
38
39
|
token?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __defProps = Object.defineProperties;
|
|
@@ -75,7 +76,7 @@ var import_axios = __toESM(require("axios"));
|
|
|
75
76
|
|
|
76
77
|
// src/constants/endpoints.ts
|
|
77
78
|
var endpoints = {
|
|
78
|
-
API: "
|
|
79
|
+
API: "http://localhost:3005"
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
// src/utils/cookies.ts
|
|
@@ -174,9 +175,10 @@ var createRequestHandler = ({
|
|
|
174
175
|
}
|
|
175
176
|
return res == null ? void 0 : res.data;
|
|
176
177
|
} catch (e) {
|
|
177
|
-
|
|
178
|
+
const error = e;
|
|
179
|
+
if (!error.response)
|
|
178
180
|
throw e;
|
|
179
|
-
throw ((_g = (_f =
|
|
181
|
+
throw ((_g = (_f = error.response) == null ? void 0 : _f.data) == null ? void 0 : _g.error) || ((_h = error.response) == null ? void 0 : _h.data);
|
|
180
182
|
}
|
|
181
183
|
}),
|
|
182
184
|
sendRequestWithFetch: (data, options) => __async(void 0, null, function* () {
|
|
@@ -43,7 +43,7 @@ import axios from "axios";
|
|
|
43
43
|
|
|
44
44
|
// src/constants/endpoints.ts
|
|
45
45
|
var endpoints = {
|
|
46
|
-
API: "
|
|
46
|
+
API: "http://localhost:3005"
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
// src/utils/cookies.ts
|
|
@@ -142,9 +142,10 @@ var createRequestHandler = ({
|
|
|
142
142
|
}
|
|
143
143
|
return res == null ? void 0 : res.data;
|
|
144
144
|
} catch (e) {
|
|
145
|
-
|
|
145
|
+
const error = e;
|
|
146
|
+
if (!error.response)
|
|
146
147
|
throw e;
|
|
147
|
-
throw ((_g = (_f =
|
|
148
|
+
throw ((_g = (_f = error.response) == null ? void 0 : _f.data) == null ? void 0 : _g.error) || ((_h = error.response) == null ? void 0 : _h.data);
|
|
148
149
|
}
|
|
149
150
|
}),
|
|
150
151
|
sendRequestWithFetch: (data, options) => __async(void 0, null, function* () {
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Payload } from './types/utils/payloads.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Convenience type exports for Memberstack SDK.
|
|
5
|
+
* These types provide direct access to core data models without needing
|
|
6
|
+
* to navigate the Payload.Transforms namespace.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import type { Member, Plan, PlanConnection } from '@memberstack/dom';
|
|
11
|
+
*
|
|
12
|
+
* function displayMember(member: Member) {
|
|
13
|
+
* console.log(member.auth.email);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A Memberstack member (authenticated user).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const { data: member } = await memberstack.getCurrentMember();
|
|
24
|
+
* if (member) {
|
|
25
|
+
* console.log('Email:', member.auth.email);
|
|
26
|
+
* console.log('Verified:', member.verified);
|
|
27
|
+
* console.log('Plans:', member.planConnections.map(p => p.planId));
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
type Member = Payload.Transforms["Member"];
|
|
32
|
+
/**
|
|
33
|
+
* A membership plan in your Memberstack app.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const { data: plans } = await memberstack.getPlans();
|
|
38
|
+
* plans.forEach((plan: Plan) => {
|
|
39
|
+
* console.log(`${plan.name}: ${plan.prices?.[0]?.amount}`);
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
type Plan = Payload.Transforms["Plan"];
|
|
44
|
+
/**
|
|
45
|
+
* A price option for a plan (monthly, yearly, etc.).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const plan = plans[0];
|
|
50
|
+
* plan.prices?.forEach((price: Price) => {
|
|
51
|
+
* console.log(`${price.name}: ${price.amount} ${price.currency}/${price.interval.type}`);
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
type Price = Payload.Transforms["Price"];
|
|
56
|
+
/**
|
|
57
|
+
* A member's connection to a plan (subscription or one-time purchase).
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const activePlans = member.planConnections.filter(
|
|
62
|
+
* (conn: PlanConnection) => conn.active
|
|
63
|
+
* );
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
type PlanConnection = Payload.Transforms["MemberPlanConnection"];
|
|
67
|
+
/**
|
|
68
|
+
* A content group that restricts access to URLs.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const { data: groups } = await memberstack.getRestrictedUrlGroups();
|
|
73
|
+
* const accessibleGroups = groups.filter(
|
|
74
|
+
* (g: ContentGroup) => g.activeMemberHasAccess
|
|
75
|
+
* );
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
type ContentGroup = Payload.Transforms["RestrictedUrlGroup"];
|
|
79
|
+
/**
|
|
80
|
+
* App configuration and settings.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const { data: app } = await memberstack.getApp();
|
|
85
|
+
* console.log('App:', app.name);
|
|
86
|
+
* console.log('Mode:', app.mode); // 'live' or 'sandbox'
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
type App = Payload.Transforms["App"];
|
|
90
|
+
/**
|
|
91
|
+
* Authentication provider configuration (Google, Facebook, etc.).
|
|
92
|
+
*/
|
|
93
|
+
type AuthProvider = Payload.Transforms["AuthProvider"];
|
|
94
|
+
/**
|
|
95
|
+
* Authentication response with tokens and member data.
|
|
96
|
+
*/
|
|
97
|
+
type MemberAuth = Payload.Transforms["MemberAuth"];
|
|
98
|
+
/**
|
|
99
|
+
* Auth tokens returned after login/signup.
|
|
100
|
+
*/
|
|
101
|
+
type AuthTokens = MemberAuth["tokens"];
|
|
102
|
+
/**
|
|
103
|
+
* A saved payment card for a member.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const { data: cards } = await memberstack.getMemberCards();
|
|
108
|
+
* const defaultCard = cards.find((card: MemberCard) => card.default);
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
type MemberCard = Payload.Transforms["MemberCard"];
|
|
112
|
+
/**
|
|
113
|
+
* An invoice for a member's subscription.
|
|
114
|
+
*/
|
|
115
|
+
type MemberInvoice = Payload.Transforms["MemberInvoice"];
|
|
116
|
+
/**
|
|
117
|
+
* A payment receipt.
|
|
118
|
+
*/
|
|
119
|
+
type MemberReceipt = Payload.Transforms["MemberReceipt"];
|
|
120
|
+
/**
|
|
121
|
+
* Checkout total calculation including taxes and fees.
|
|
122
|
+
*/
|
|
123
|
+
type CheckoutTotal = Payload.Transforms["TotalCheckoutAmount"];
|
|
124
|
+
/**
|
|
125
|
+
* Gated content returned by getSecureContent().
|
|
126
|
+
*/
|
|
127
|
+
type SecureContent = Payload.Transforms["SecureContent"];
|
|
128
|
+
/**
|
|
129
|
+
* A custom field defined in your Memberstack app.
|
|
130
|
+
*/
|
|
131
|
+
type CustomField = Payload.Transforms["CustomField"];
|
|
132
|
+
/**
|
|
133
|
+
* App branding configuration.
|
|
134
|
+
*/
|
|
135
|
+
type Branding = Payload.Transforms["Branding"];
|
|
136
|
+
/**
|
|
137
|
+
* A community post.
|
|
138
|
+
*/
|
|
139
|
+
type Post = Payload.Transforms["Post"];
|
|
140
|
+
/**
|
|
141
|
+
* A thread/reply on a post.
|
|
142
|
+
*/
|
|
143
|
+
type Thread = Payload.Transforms["Thread"];
|
|
144
|
+
/**
|
|
145
|
+
* Extract the data type from a Memberstack SDK response.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import type { ExtractData, GetCurrentMemberPayload } from '@memberstack/dom';
|
|
150
|
+
*
|
|
151
|
+
* // Get the member type from the response
|
|
152
|
+
* type MemberData = ExtractData<GetCurrentMemberPayload>;
|
|
153
|
+
* // MemberData = Member | null
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
type ExtractData<T> = T extends {
|
|
157
|
+
data: infer D;
|
|
158
|
+
} ? D : never;
|
|
159
|
+
/**
|
|
160
|
+
* Generic paginated response shape.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* type InvoicesPage = PaginatedData<MemberInvoice>;
|
|
165
|
+
* // { data: MemberInvoice[], hasNext: boolean, endCursor: string | null, totalCount: number }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
type PaginatedData<T> = {
|
|
169
|
+
data: T[];
|
|
170
|
+
hasNext: boolean;
|
|
171
|
+
endCursor: string | null;
|
|
172
|
+
totalCount: number;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Common member fields for display purposes.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* function getMemberDisplayInfo(member: Member): MemberDisplayInfo {
|
|
180
|
+
* return {
|
|
181
|
+
* id: member.id,
|
|
182
|
+
* email: member.auth.email,
|
|
183
|
+
* profileImage: member.profileImage,
|
|
184
|
+
* verified: member.verified,
|
|
185
|
+
* };
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
type MemberDisplayInfo = Pick<Member, 'id' | 'profileImage' | 'verified'> & {
|
|
190
|
+
email: string;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export type { App as A, Branding as B, ContentGroup as C, ExtractData as E, Member as M, Plan as P, SecureContent as S, Thread as T, Price as a, PlanConnection as b, AuthProvider as c, MemberAuth as d, AuthTokens as e, MemberCard as f, MemberInvoice as g, MemberReceipt as h, CheckoutTotal as i, CustomField as j, Post as k, PaginatedData as l, MemberDisplayInfo as m };
|