@theholocron/clerk-client 0.3.2 → 0.5.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/dist/index.d.mts +27 -1
- package/dist/index.mjs +32 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,19 @@ import "@theholocron/http-client";
|
|
|
3
3
|
interface ClerkClientOptions {
|
|
4
4
|
/** Clerk secret key (sk_live_... or sk_test_...). */
|
|
5
5
|
token: string;
|
|
6
|
+
/** Override base URL for testing. Defaults to https://api.clerk.com/v1. */
|
|
7
|
+
baseUrl?: string;
|
|
6
8
|
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
7
9
|
fetch?: typeof fetch;
|
|
8
10
|
}
|
|
9
11
|
//#endregion
|
|
12
|
+
//#region src/instance/instance.d.ts
|
|
13
|
+
interface ClerkInstance {
|
|
14
|
+
id?: string;
|
|
15
|
+
object?: string;
|
|
16
|
+
environment_type?: "development" | "production" | "staging" | string;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
10
19
|
//#region src/users/users.d.ts
|
|
11
20
|
interface ClerkEmailAddress {
|
|
12
21
|
id: string;
|
|
@@ -132,8 +141,21 @@ interface UpdateClerkUserInput {
|
|
|
132
141
|
create_organization_enabled?: boolean;
|
|
133
142
|
}
|
|
134
143
|
//#endregion
|
|
144
|
+
//#region src/webhooks/webhooks.d.ts
|
|
145
|
+
interface ClerkSvixApp {
|
|
146
|
+
svix_app_id?: string;
|
|
147
|
+
}
|
|
148
|
+
/** Older Clerk instances return `svix_url`; newer return `url`. */
|
|
149
|
+
interface ClerkSvixUrl {
|
|
150
|
+
url?: string;
|
|
151
|
+
svix_url?: string;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
135
154
|
//#region src/index.d.ts
|
|
136
155
|
declare function createClerkClient(opts: ClerkClientOptions): {
|
|
156
|
+
instance: {
|
|
157
|
+
get: () => Promise<ClerkInstance>;
|
|
158
|
+
};
|
|
137
159
|
users: {
|
|
138
160
|
list: (params?: ClerkUsersListParams) => Promise<ClerkUser[]>;
|
|
139
161
|
count: (params?: Pick<ClerkUsersListParams, "email_address" | "phone_number" | "username" | "external_id" | "user_id" | "query">) => Promise<ClerkUserCount>;
|
|
@@ -146,7 +168,11 @@ declare function createClerkClient(opts: ClerkClientOptions): {
|
|
|
146
168
|
lock: (id: string) => Promise<ClerkUser>;
|
|
147
169
|
unlock: (id: string) => Promise<ClerkUser>;
|
|
148
170
|
};
|
|
171
|
+
webhooks: {
|
|
172
|
+
ensureSvixApp: () => Promise<ClerkSvixApp>;
|
|
173
|
+
getSvixUrl: () => Promise<ClerkSvixUrl>;
|
|
174
|
+
};
|
|
149
175
|
};
|
|
150
176
|
type ClerkClient = ReturnType<typeof createClerkClient>;
|
|
151
177
|
//#endregion
|
|
152
|
-
export { ClerkClient, type ClerkClientOptions, type ClerkDeletedObject, type ClerkEmailAddress, type ClerkPhoneNumber, type ClerkUser, type ClerkUserCount, type ClerkUsersListParams, type CreateClerkUserInput, type UpdateClerkUserInput, createClerkClient };
|
|
178
|
+
export { ClerkClient, type ClerkClientOptions, type ClerkDeletedObject, type ClerkEmailAddress, type ClerkInstance, type ClerkPhoneNumber, type ClerkSvixApp, type ClerkSvixUrl, type ClerkUser, type ClerkUserCount, type ClerkUsersListParams, type CreateClerkUserInput, type UpdateClerkUserInput, createClerkClient };
|
package/dist/index.mjs
CHANGED
|
@@ -2,15 +2,20 @@ import { createRestClient } from "@theholocron/http-client";
|
|
|
2
2
|
//#region src/utils.ts
|
|
3
3
|
function createClerkRestClient(opts) {
|
|
4
4
|
return createRestClient({
|
|
5
|
-
baseUrl: "https://api.clerk.com/v1",
|
|
5
|
+
baseUrl: opts.baseUrl ?? "https://api.clerk.com/v1",
|
|
6
6
|
token: opts.token,
|
|
7
7
|
vendor: "Clerk",
|
|
8
8
|
fetch: opts.fetch
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
+
//#region src/instance/instance.ts
|
|
13
|
+
function instance(rest) {
|
|
14
|
+
return { get: () => rest.request("/instance") };
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
12
17
|
//#region src/users/users.ts
|
|
13
|
-
const PATH = "/users";
|
|
18
|
+
const PATH$1 = "/users";
|
|
14
19
|
function buildUsersQuery(params) {
|
|
15
20
|
const qs = new URLSearchParams();
|
|
16
21
|
if (params.limit !== void 0) qs.set("limit", String(params.limit));
|
|
@@ -29,32 +34,46 @@ function users(rest) {
|
|
|
29
34
|
return {
|
|
30
35
|
list: (params = {}) => {
|
|
31
36
|
const q = buildUsersQuery(params);
|
|
32
|
-
return rest.request(q ? `${PATH}?${q}` : PATH);
|
|
37
|
+
return rest.request(q ? `${PATH$1}?${q}` : PATH$1);
|
|
33
38
|
},
|
|
34
39
|
count: (params = {}) => {
|
|
35
40
|
const q = buildUsersQuery(params);
|
|
36
|
-
return rest.request(q ? `${PATH}/count?${q}` : `${PATH}/count`);
|
|
41
|
+
return rest.request(q ? `${PATH$1}/count?${q}` : `${PATH$1}/count`);
|
|
37
42
|
},
|
|
38
|
-
get: (id) => rest.request(`${PATH}/${id}`),
|
|
39
|
-
create: (data) => rest.request(PATH, {
|
|
43
|
+
get: (id) => rest.request(`${PATH$1}/${id}`),
|
|
44
|
+
create: (data) => rest.request(PATH$1, {
|
|
40
45
|
method: "POST",
|
|
41
46
|
body: data
|
|
42
47
|
}),
|
|
43
|
-
update: (id, data) => rest.request(`${PATH}/${id}`, {
|
|
48
|
+
update: (id, data) => rest.request(`${PATH$1}/${id}`, {
|
|
44
49
|
method: "PATCH",
|
|
45
50
|
body: data
|
|
46
51
|
}),
|
|
47
|
-
delete: (id) => rest.request(`${PATH}/${id}`, { method: "DELETE" }),
|
|
48
|
-
ban: (id) => rest.request(`${PATH}/${id}/ban`, { method: "POST" }),
|
|
49
|
-
unban: (id) => rest.request(`${PATH}/${id}/unban`, { method: "POST" }),
|
|
50
|
-
lock: (id) => rest.request(`${PATH}/${id}/lock`, { method: "POST" }),
|
|
51
|
-
unlock: (id) => rest.request(`${PATH}/${id}/unlock`, { method: "POST" })
|
|
52
|
+
delete: (id) => rest.request(`${PATH$1}/${id}`, { method: "DELETE" }),
|
|
53
|
+
ban: (id) => rest.request(`${PATH$1}/${id}/ban`, { method: "POST" }),
|
|
54
|
+
unban: (id) => rest.request(`${PATH$1}/${id}/unban`, { method: "POST" }),
|
|
55
|
+
lock: (id) => rest.request(`${PATH$1}/${id}/lock`, { method: "POST" }),
|
|
56
|
+
unlock: (id) => rest.request(`${PATH$1}/${id}/unlock`, { method: "POST" })
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/webhooks/webhooks.ts
|
|
61
|
+
const PATH = "/webhooks";
|
|
62
|
+
function webhooks(rest) {
|
|
63
|
+
return {
|
|
64
|
+
ensureSvixApp: () => rest.request(`${PATH}/svix`, { method: "POST" }),
|
|
65
|
+
getSvixUrl: () => rest.request(`${PATH}/svix_url`, { method: "POST" })
|
|
52
66
|
};
|
|
53
67
|
}
|
|
54
68
|
//#endregion
|
|
55
69
|
//#region src/index.ts
|
|
56
70
|
function createClerkClient(opts) {
|
|
57
|
-
|
|
71
|
+
const rest = createClerkRestClient(opts);
|
|
72
|
+
return {
|
|
73
|
+
instance: instance(rest),
|
|
74
|
+
users: users(rest),
|
|
75
|
+
webhooks: webhooks(rest)
|
|
76
|
+
};
|
|
58
77
|
}
|
|
59
78
|
//#endregion
|
|
60
79
|
export { createClerkClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/clerk-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A TypeScript client for the Clerk Backend API",
|
|
5
5
|
"homepage": "https://github.com/theholocron/clients/tree/main/packages/clerk-client#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/clients/issues",
|