@faable/auth-sdk 1.0.5 → 1.0.7
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/FaableAuthApi.d.ts +64 -0
- package/dist/FaableAuthApi.js +12 -0
- package/dist/paginator.d.ts +8 -0
- package/dist/paginator.js +26 -0
- package/package.json +1 -1
package/dist/FaableAuthApi.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { FaablePaginator } from "./paginator";
|
|
2
3
|
export declare class FaableAuthApi {
|
|
3
4
|
client: AxiosInstance;
|
|
5
|
+
paginator: FaablePaginator;
|
|
4
6
|
constructor(client?: AxiosInstance);
|
|
5
7
|
setUserMetadata(user_id: string, user_metadata: Record<string, string | any[] | boolean | number | null | undefined>): Promise<{
|
|
6
8
|
[key: string]: unknown;
|
|
@@ -8,6 +10,38 @@ export declare class FaableAuthApi {
|
|
|
8
10
|
getUserMetadata(user_id: string): Promise<{
|
|
9
11
|
[key: string]: unknown;
|
|
10
12
|
}>;
|
|
13
|
+
listUsers(params?: {
|
|
14
|
+
email?: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
all: () => Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
username?: string;
|
|
20
|
+
given_name?: string;
|
|
21
|
+
family_name?: string;
|
|
22
|
+
email?: string;
|
|
23
|
+
email_verified: boolean;
|
|
24
|
+
phone?: string;
|
|
25
|
+
phone_verified: boolean;
|
|
26
|
+
country_iso?: string;
|
|
27
|
+
birth_date?: string;
|
|
28
|
+
locale: string;
|
|
29
|
+
region?: string;
|
|
30
|
+
picture?: string;
|
|
31
|
+
logins_count: number;
|
|
32
|
+
last_ip?: string;
|
|
33
|
+
last_login?: string;
|
|
34
|
+
user_metadata: {
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
37
|
+
app_metadata: {
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
};
|
|
40
|
+
account: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
updatedAt?: string;
|
|
43
|
+
}[]>;
|
|
44
|
+
}>;
|
|
11
45
|
getUser(user_id: any): Promise<{
|
|
12
46
|
id: string;
|
|
13
47
|
name?: string;
|
|
@@ -36,5 +70,35 @@ export declare class FaableAuthApi {
|
|
|
36
70
|
createdAt: string;
|
|
37
71
|
updatedAt?: string;
|
|
38
72
|
}>;
|
|
73
|
+
getTeam(team_id: any): Promise<{
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
slug: string;
|
|
77
|
+
description: string;
|
|
78
|
+
logo_url: string;
|
|
79
|
+
metadata: {
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
};
|
|
82
|
+
account: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
updatedAt?: string;
|
|
85
|
+
}>;
|
|
86
|
+
listTeams(params?: {
|
|
87
|
+
user_id?: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
all: () => Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
slug: string;
|
|
93
|
+
description: string;
|
|
94
|
+
logo_url: string;
|
|
95
|
+
metadata: {
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
};
|
|
98
|
+
account: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
updatedAt?: string;
|
|
101
|
+
}[]>;
|
|
102
|
+
}>;
|
|
39
103
|
isUserMemberOfTeam(user_id: string, team_id: string): Promise<boolean>;
|
|
40
104
|
}
|
package/dist/FaableAuthApi.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FaableAuthApi = void 0;
|
|
4
4
|
const auth_helpers_axios_1 = require("@faable/auth-helpers-axios");
|
|
5
|
+
const paginator_1 = require("./paginator");
|
|
5
6
|
const handleError = async (q) => {
|
|
6
7
|
try {
|
|
7
8
|
const res = await q;
|
|
@@ -20,10 +21,12 @@ const handleError = async (q) => {
|
|
|
20
21
|
};
|
|
21
22
|
class FaableAuthApi {
|
|
22
23
|
client;
|
|
24
|
+
paginator;
|
|
23
25
|
constructor(client) {
|
|
24
26
|
if (!client) {
|
|
25
27
|
this.client = (0, auth_helpers_axios_1.authorize)();
|
|
26
28
|
}
|
|
29
|
+
this.paginator = new paginator_1.FaablePaginator(this.client);
|
|
27
30
|
}
|
|
28
31
|
async setUserMetadata(user_id, user_metadata) {
|
|
29
32
|
return (await handleError(this.client.post(`/user/${user_id}`, { user_metadata }))).user_metadata;
|
|
@@ -32,9 +35,18 @@ class FaableAuthApi {
|
|
|
32
35
|
return (await handleError(this.client.get(`/user/${user_id}`)))
|
|
33
36
|
.user_metadata;
|
|
34
37
|
}
|
|
38
|
+
async listUsers(params = {}) {
|
|
39
|
+
return this.paginator.paginate({ url: "/user", params });
|
|
40
|
+
}
|
|
35
41
|
async getUser(user_id) {
|
|
36
42
|
return await handleError(this.client.get(`/user/${user_id}`));
|
|
37
43
|
}
|
|
44
|
+
async getTeam(team_id) {
|
|
45
|
+
return await handleError(this.client.get(`/team/${team_id}`));
|
|
46
|
+
}
|
|
47
|
+
async listTeams(params) {
|
|
48
|
+
return this.paginator.paginate({ url: "/user", params });
|
|
49
|
+
}
|
|
38
50
|
async isUserMemberOfTeam(user_id, team_id) {
|
|
39
51
|
const members_res = await this.client.get(`/team/${team_id}/member/check/${user_id}`, {
|
|
40
52
|
validateStatus: () => true,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FaablePaginator = void 0;
|
|
4
|
+
class FaablePaginator {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
paginate(req) {
|
|
10
|
+
const pages = [];
|
|
11
|
+
return {
|
|
12
|
+
all: async () => {
|
|
13
|
+
let res;
|
|
14
|
+
do {
|
|
15
|
+
res = await this.client.request({
|
|
16
|
+
...req,
|
|
17
|
+
params: { ...req.params, next: res.data.next },
|
|
18
|
+
});
|
|
19
|
+
pages.push(res.data);
|
|
20
|
+
} while (res.data.next);
|
|
21
|
+
return pages.map((page) => page.results).flat();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.FaablePaginator = FaablePaginator;
|