@faable/auth-sdk 1.0.14 → 1.0.16

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.
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { TeamCreate } from "./types";
3
- import { FaablePaginator } from "./paginator";
2
+ import { TeamCreate, UserCreate, UserUpdate } from "./types";
3
+ import { FaablePaginator, Page } from "./paginator";
4
4
  export declare class FaableAuthApi {
5
5
  client: AxiosInstance;
6
6
  paginator: FaablePaginator;
@@ -42,6 +42,34 @@ export declare class FaableAuthApi {
42
42
  createdAt: string;
43
43
  updatedAt?: string;
44
44
  }[]>;
45
+ first: () => Promise<Page<{
46
+ id: string;
47
+ name?: string;
48
+ username?: string;
49
+ given_name?: string;
50
+ family_name?: string;
51
+ email?: string;
52
+ email_verified: boolean;
53
+ phone?: string;
54
+ phone_verified: boolean;
55
+ country_iso?: string;
56
+ birth_date?: string;
57
+ locale: string;
58
+ region?: string;
59
+ picture?: string;
60
+ logins_count: number;
61
+ last_ip?: string;
62
+ last_login?: string;
63
+ user_metadata: {
64
+ [key: string]: unknown;
65
+ };
66
+ app_metadata: {
67
+ [key: string]: unknown;
68
+ };
69
+ account: string;
70
+ createdAt: string;
71
+ updatedAt?: string;
72
+ }>>;
45
73
  };
46
74
  getUser(user_id: any): Promise<{
47
75
  id: string;
@@ -71,6 +99,62 @@ export declare class FaableAuthApi {
71
99
  createdAt: string;
72
100
  updatedAt?: string;
73
101
  }>;
102
+ createUser(data: UserCreate): Promise<{
103
+ id: string;
104
+ name?: string;
105
+ username?: string;
106
+ given_name?: string;
107
+ family_name?: string;
108
+ email?: string;
109
+ email_verified: boolean;
110
+ phone?: string;
111
+ phone_verified: boolean;
112
+ country_iso?: string;
113
+ birth_date?: string;
114
+ locale: string;
115
+ region?: string;
116
+ picture?: string;
117
+ logins_count: number;
118
+ last_ip?: string;
119
+ last_login?: string;
120
+ user_metadata: {
121
+ [key: string]: unknown;
122
+ };
123
+ app_metadata: {
124
+ [key: string]: unknown;
125
+ };
126
+ account: string;
127
+ createdAt: string;
128
+ updatedAt?: string;
129
+ }>;
130
+ updateUser(user_id: string, data: UserUpdate): Promise<{
131
+ id: string;
132
+ name?: string;
133
+ username?: string;
134
+ given_name?: string;
135
+ family_name?: string;
136
+ email?: string;
137
+ email_verified: boolean;
138
+ phone?: string;
139
+ phone_verified: boolean;
140
+ country_iso?: string;
141
+ birth_date?: string;
142
+ locale: string;
143
+ region?: string;
144
+ picture?: string;
145
+ logins_count: number;
146
+ last_ip?: string;
147
+ last_login?: string;
148
+ user_metadata: {
149
+ [key: string]: unknown;
150
+ };
151
+ app_metadata: {
152
+ [key: string]: unknown;
153
+ };
154
+ account: string;
155
+ createdAt: string;
156
+ updatedAt?: string;
157
+ }>;
74
158
  getTeam(team_id: any): Promise<{
75
159
  id: string;
76
160
  name: string;
@@ -113,6 +197,19 @@ export declare class FaableAuthApi {
113
197
  createdAt: string;
114
198
  updatedAt?: string;
115
199
  }[]>;
200
+ first: () => Promise<Page<{
201
+ id: string;
202
+ name: string;
203
+ slug: string;
204
+ description: string;
205
+ logo_url: string;
206
+ metadata: {
207
+ [key: string]: unknown;
208
+ };
209
+ account: string;
210
+ createdAt: string;
211
+ updatedAt?: string;
212
+ }>>;
116
213
  };
117
214
  listTeamMembers(params: {
118
215
  query?: string;
@@ -129,6 +226,18 @@ export declare class FaableAuthApi {
129
226
  createdAt: string;
130
227
  updatedAt?: string;
131
228
  }[]>;
229
+ first: () => Promise<Page<{
230
+ id: string;
231
+ user: unknown;
232
+ team: unknown;
233
+ roles: unknown[];
234
+ metadata: {
235
+ [key: string]: unknown;
236
+ };
237
+ account: string;
238
+ createdAt: string;
239
+ updatedAt?: string;
240
+ }>>;
132
241
  };
133
242
  isUserMemberOfTeam(user_id: string, team_id: string): Promise<boolean>;
134
243
  }
@@ -41,6 +41,12 @@ class FaableAuthApi {
41
41
  async getUser(user_id) {
42
42
  return await handleError(this.client.get(`/user/${user_id}`));
43
43
  }
44
+ async createUser(data) {
45
+ return await handleError(this.client.post(`/user`, data));
46
+ }
47
+ async updateUser(user_id, data) {
48
+ return await handleError(this.client.post(`/user/${user_id}`, data));
49
+ }
44
50
  async getTeam(team_id) {
45
51
  return await handleError(this.client.get(`/team/${team_id}`));
46
52
  }
@@ -1,8 +1,13 @@
1
1
  import { AxiosInstance, AxiosRequestConfig } from "axios";
2
+ export interface Page<T> {
3
+ next: string | null;
4
+ results: T[];
5
+ }
2
6
  export declare class FaablePaginator {
3
7
  client: AxiosInstance;
4
8
  constructor(client: AxiosInstance);
5
9
  paginate<T>(req: AxiosRequestConfig): {
6
10
  all: () => Promise<T[]>;
11
+ first: () => Promise<Page<T>>;
7
12
  };
8
13
  }
package/dist/paginator.js CHANGED
@@ -7,9 +7,9 @@ class FaablePaginator {
7
7
  this.client = client;
8
8
  }
9
9
  paginate(req) {
10
- const pages = [];
11
10
  return {
12
11
  all: async () => {
12
+ const pages = [];
13
13
  let res;
14
14
  do {
15
15
  res = await this.client.request({
@@ -20,6 +20,10 @@ class FaablePaginator {
20
20
  } while (res.data.next);
21
21
  return pages.map((page) => page.results).flat();
22
22
  },
23
+ first: async () => {
24
+ const res = await this.client.request(req);
25
+ return res.data;
26
+ },
23
27
  };
24
28
  }
25
29
  }
@@ -550,8 +550,10 @@ export interface paths {
550
550
  };
551
551
  responses: {
552
552
  /** @description Default Response */
553
- 200: {
554
- content: never;
553
+ 201: {
554
+ content: {
555
+ "application/json": components["schemas"]["TeamMember"];
556
+ };
555
557
  };
556
558
  };
557
559
  };
@@ -993,27 +995,6 @@ export interface components {
993
995
  /** @description TeamMember updated date */
994
996
  updatedAt?: string;
995
997
  };
996
- /** @description TeamCreate */
997
- TeamCreate: {
998
- name: string;
999
- description?: string;
1000
- metadata?: {
1001
- [key: string]: unknown;
1002
- };
1003
- };
1004
- /** @description TeamUpdate */
1005
- TeamUpdate: {
1006
- /** @description name */
1007
- name?: string;
1008
- /** @description description */
1009
- description?: string;
1010
- metadata?: {
1011
- [key: string]: unknown;
1012
- };
1013
- };
1014
- TeamMemberCreate: {
1015
- users: string[];
1016
- };
1017
998
  /** @description Team paginated response */
1018
999
  TeamPage: {
1019
1000
  /** @description next cursor */
@@ -1028,6 +1009,17 @@ export interface components {
1028
1009
  /** @description list of results */
1029
1010
  results: components["schemas"]["TeamMember"][];
1030
1011
  };
1012
+ /** @description TeamCreate */
1013
+ TeamCreate: {
1014
+ name: string;
1015
+ description?: string;
1016
+ metadata?: {
1017
+ [key: string]: unknown;
1018
+ };
1019
+ };
1020
+ TeamMemberCreate: {
1021
+ users: string[];
1022
+ };
1031
1023
  /** @description Webhook */
1032
1024
  Webhook: {
1033
1025
  /** @description Webhook ID */
@@ -1135,6 +1127,16 @@ export interface components {
1135
1127
  RoleMemberCreate: {
1136
1128
  users: string[];
1137
1129
  };
1130
+ /** @description TeamUpdate */
1131
+ TeamUpdate: {
1132
+ /** @description name */
1133
+ name?: string;
1134
+ /** @description description */
1135
+ description?: string;
1136
+ metadata?: {
1137
+ [key: string]: unknown;
1138
+ };
1139
+ };
1138
1140
  };
1139
1141
  responses: never;
1140
1142
  parameters: never;
@@ -1,5 +1,7 @@
1
1
  import { components } from "./api";
2
2
  export type User = components["schemas"]["User"];
3
+ export type UserCreate = components["schemas"]["UserCreate"];
4
+ export type UserUpdate = components["schemas"]["UserUpdate"];
3
5
  export type Team = components["schemas"]["Team"];
4
6
  export type TeamMember = components["schemas"]["TeamMember"];
5
7
  export type TeamCreate = components["schemas"]["TeamCreate"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/auth-sdk",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "author": "Marc Pomar <marc@faable.com>",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,9 @@
13
13
  "axios": "^1.6.2"
14
14
  },
15
15
  "devDependencies": {
16
+ "@ava/typescript": "^5.0.0",
16
17
  "@types/node": "^20.10.5",
18
+ "ava": "^6.1.3",
17
19
  "openapi-typescript": "^6.7.3",
18
20
  "rimraf": "^5.0.5",
19
21
  "semantic-release": "^22.0.12",
package/tsconfig.json CHANGED
@@ -10,5 +10,6 @@
10
10
  "experimentalDecorators": true,
11
11
  "declaration": true
12
12
  },
13
- "include": ["src/**/*"]
13
+ "include": ["src/**/*"],
14
+ "exclude": ["src/**/*.test.ts"]
14
15
  }