swiftbase-sdk 1.0.1
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/LICENSE +19 -0
- package/README.md +215 -0
- package/dist/index.cjs +4778 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +296 -0
- package/dist/index.d.ts +296 -0
- package/dist/index.js +4744 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
interface initializeSdkOptions {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
debounceTimeout?: number;
|
|
4
|
+
cacheArticles?: boolean;
|
|
5
|
+
searchCacheEnabled?: boolean;
|
|
6
|
+
searchCacheCapacity?: number;
|
|
7
|
+
}
|
|
8
|
+
declare const initializeSdk: (projectId: string, options?: initializeSdkOptions) => void;
|
|
9
|
+
declare const setAccessToken: (token: string, expiration?: number) => void;
|
|
10
|
+
declare const setRefreshToken: (token: string, expiration?: number) => void;
|
|
11
|
+
declare const refreshTokens: () => Promise<void>;
|
|
12
|
+
|
|
13
|
+
interface RESTPaginatedResponse<T> {
|
|
14
|
+
data: T[];
|
|
15
|
+
meta: {
|
|
16
|
+
total: number;
|
|
17
|
+
page: number;
|
|
18
|
+
limit: number;
|
|
19
|
+
next: string | null;
|
|
20
|
+
back: string | null;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare class PaginatedResponse<T> {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(response: RESTPaginatedResponse<T>);
|
|
26
|
+
get items(): T[];
|
|
27
|
+
get total(): number;
|
|
28
|
+
get page(): number;
|
|
29
|
+
get limit(): number;
|
|
30
|
+
get hasNext(): boolean;
|
|
31
|
+
get hasBack(): boolean;
|
|
32
|
+
next(): Promise<PaginatedResponse<T> | null>;
|
|
33
|
+
back(): Promise<PaginatedResponse<T> | null>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface Profile {
|
|
37
|
+
id: string;
|
|
38
|
+
email: string;
|
|
39
|
+
firstName?: string;
|
|
40
|
+
lastName?: string;
|
|
41
|
+
projectId?: string;
|
|
42
|
+
roles?: string[];
|
|
43
|
+
lastLoginAt?: string;
|
|
44
|
+
failedLoginAttempts?: number;
|
|
45
|
+
lockedUntilAt?: string;
|
|
46
|
+
attributes?: Record<string, any>;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
updatedAt?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ProfileInput {
|
|
51
|
+
firstName?: string;
|
|
52
|
+
lastName?: string;
|
|
53
|
+
attributes?: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
interface ChangePasswordInput {
|
|
56
|
+
currentPassword?: string;
|
|
57
|
+
newPassword?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface LoginInput {
|
|
61
|
+
projectId: string;
|
|
62
|
+
email: string;
|
|
63
|
+
password?: string;
|
|
64
|
+
}
|
|
65
|
+
interface ResetPasswordInput {
|
|
66
|
+
projectId: string;
|
|
67
|
+
email: string;
|
|
68
|
+
}
|
|
69
|
+
interface AuthorizeOptions {
|
|
70
|
+
redirectUri?: string;
|
|
71
|
+
state?: string;
|
|
72
|
+
scope?: string;
|
|
73
|
+
prompt?: "login" | "none";
|
|
74
|
+
}
|
|
75
|
+
interface TokenResponse {
|
|
76
|
+
access_token: string;
|
|
77
|
+
refresh_token?: string;
|
|
78
|
+
id_token?: string;
|
|
79
|
+
token_type: string;
|
|
80
|
+
expires_in: number;
|
|
81
|
+
scope?: string;
|
|
82
|
+
user?: Profile;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Login with email and password
|
|
87
|
+
*
|
|
88
|
+
* @param {LoginInput} input The login credentials
|
|
89
|
+
*
|
|
90
|
+
* @returns {Promise<Profile>} The user profile
|
|
91
|
+
*/
|
|
92
|
+
declare const loginWithPassword: (input: LoginInput) => Promise<Profile>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Login as a service
|
|
96
|
+
*
|
|
97
|
+
* @param {string} projectId The project ID
|
|
98
|
+
* @param {string} serviceId The service ID
|
|
99
|
+
* @param {string} secretKey The service secret key
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<any>} The login response
|
|
102
|
+
*/
|
|
103
|
+
declare const loginService: (projectId: string, serviceId: string, secretKey: string) => Promise<any>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Redirects the user to the Swiftbase-Auth universal login page
|
|
107
|
+
*
|
|
108
|
+
* @param {AuthorizeOptions} options Optional authorization parameters
|
|
109
|
+
*/
|
|
110
|
+
declare const loginWithRedirect: (options?: AuthorizeOptions) => Promise<void>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Handles the redirect callback from the Swiftbase-Auth service
|
|
114
|
+
*
|
|
115
|
+
* @param {string} url Optional URL to parse, defaults to window.location.href
|
|
116
|
+
*
|
|
117
|
+
* @returns {Promise<Profile>} The user profile
|
|
118
|
+
*/
|
|
119
|
+
declare const handleRedirectCallback: (url?: string) => Promise<Profile>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Reset password for email
|
|
123
|
+
*
|
|
124
|
+
* @param {ResetPasswordInput} input The reset password input
|
|
125
|
+
*
|
|
126
|
+
* @returns {Promise<{ success: boolean }>} The result of the reset password request
|
|
127
|
+
*/
|
|
128
|
+
declare const resetPassword: (input: ResetPasswordInput) => Promise<{
|
|
129
|
+
success: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Checks if the user is currently logged in (has a valid session)
|
|
134
|
+
*
|
|
135
|
+
* @returns {boolean} True if logged in, false otherwise
|
|
136
|
+
*/
|
|
137
|
+
declare const isLoggedIn: () => boolean;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Logs the user out by clearing tokens and redirecting to the logout page
|
|
141
|
+
*/
|
|
142
|
+
declare const logout: () => Promise<void>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Gets the current access token, refreshing it if necessary
|
|
146
|
+
*
|
|
147
|
+
* @param {boolean} forceRefresh If true, the token will be refreshed even if it's not expired
|
|
148
|
+
*
|
|
149
|
+
* @returns {Promise<string | null>} The access token, or null if no session exists
|
|
150
|
+
*/
|
|
151
|
+
declare const getAccessToken: (forceRefresh?: boolean) => Promise<string | null>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Verify a user token
|
|
155
|
+
*
|
|
156
|
+
* @param {string} token The token to verify
|
|
157
|
+
* @param {string} projectId The project ID (optional, defaults to SDK initialized project)
|
|
158
|
+
*
|
|
159
|
+
* @returns {Promise<Profile>} The user profile if valid
|
|
160
|
+
*/
|
|
161
|
+
declare const verifyToken: (token: string, projectId?: string) => Promise<Profile>;
|
|
162
|
+
/**
|
|
163
|
+
* Verify a service token
|
|
164
|
+
*
|
|
165
|
+
* @param {string} token The token to verify
|
|
166
|
+
* @param {string} projectId The project ID (optional, defaults to SDK initialized project)
|
|
167
|
+
* @param {string} scope The scope to check (optional)
|
|
168
|
+
*
|
|
169
|
+
* @returns {Promise<any>} The service info if valid
|
|
170
|
+
*/
|
|
171
|
+
declare const verifyServiceToken: (token: string, projectId?: string, scope?: string) => Promise<any>;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Get the current user profile
|
|
175
|
+
*
|
|
176
|
+
* @returns {Promise<Profile>} The user profile
|
|
177
|
+
*/
|
|
178
|
+
declare const getProfile: () => Promise<Profile>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Update the current user profile
|
|
182
|
+
*
|
|
183
|
+
* @param {ProfileInput} input The profile data to update
|
|
184
|
+
*
|
|
185
|
+
* @returns {Promise<Profile>} The updated user profile
|
|
186
|
+
*/
|
|
187
|
+
declare const updateProfile: (input: ProfileInput) => Promise<Profile>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Update any user profile (Admin only)
|
|
191
|
+
*
|
|
192
|
+
* @param {string} id The user ID to update
|
|
193
|
+
* @param {any} input The profile data to update
|
|
194
|
+
*
|
|
195
|
+
* @returns {Promise<Profile>} The updated user profile
|
|
196
|
+
*/
|
|
197
|
+
declare const updateUser: (id: string, input: any) => Promise<Profile>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Change the current user password
|
|
201
|
+
*
|
|
202
|
+
* @param {ChangePasswordInput} input The password change input
|
|
203
|
+
*
|
|
204
|
+
* @returns {Promise<{ success: boolean }>} The result of the password change request
|
|
205
|
+
*/
|
|
206
|
+
declare const changePassword: (input: ChangePasswordInput) => Promise<{
|
|
207
|
+
success: boolean;
|
|
208
|
+
}>;
|
|
209
|
+
|
|
210
|
+
declare const getUsers: (projectId: string) => Promise<any>;
|
|
211
|
+
declare const getRoles: (projectId: string) => Promise<any>;
|
|
212
|
+
declare const getServices: (projectId: string) => Promise<any>;
|
|
213
|
+
declare const createRole: (input: any) => Promise<any>;
|
|
214
|
+
declare const deleteRole: (id: string) => Promise<any>;
|
|
215
|
+
declare const createService: (input: any) => Promise<any>;
|
|
216
|
+
declare const deleteService: (id: string) => Promise<any>;
|
|
217
|
+
declare const assignRole: (userId: string, roleName: string) => Promise<any>;
|
|
218
|
+
declare const unassignRole: (userId: string, roleName: string) => Promise<any>;
|
|
219
|
+
|
|
220
|
+
declare class QueryBuilder implements PromiseLike<any> {
|
|
221
|
+
private dbName;
|
|
222
|
+
private tableName;
|
|
223
|
+
private payload;
|
|
224
|
+
constructor(dbName: string, tableName: string);
|
|
225
|
+
select(...columns: Array<string | string[]>): this;
|
|
226
|
+
where(column: string, value: any): this;
|
|
227
|
+
where(column: string, operator: string, value: any): this;
|
|
228
|
+
where(obj: Record<string, any>): this;
|
|
229
|
+
limit(value: number): this;
|
|
230
|
+
offset(value: number): this;
|
|
231
|
+
insert(data: any): this;
|
|
232
|
+
update(data: any): this;
|
|
233
|
+
delete(): this;
|
|
234
|
+
listen(callback: (change: {
|
|
235
|
+
event: 'insert' | 'update' | 'delete';
|
|
236
|
+
data: any;
|
|
237
|
+
}) => void): () => void;
|
|
238
|
+
execute(): Promise<{
|
|
239
|
+
data: any[];
|
|
240
|
+
columns: string[];
|
|
241
|
+
count: number;
|
|
242
|
+
}>;
|
|
243
|
+
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
244
|
+
}
|
|
245
|
+
declare function db(dbName: string): (tableName: string) => QueryBuilder;
|
|
246
|
+
|
|
247
|
+
interface StorageOptions {
|
|
248
|
+
bucket: string;
|
|
249
|
+
endpoint?: string;
|
|
250
|
+
region?: string;
|
|
251
|
+
accessKeyId?: string;
|
|
252
|
+
secretAccessKey?: string;
|
|
253
|
+
}
|
|
254
|
+
interface BucketInfo {
|
|
255
|
+
name: string;
|
|
256
|
+
creationDate?: string;
|
|
257
|
+
}
|
|
258
|
+
interface S3Object {
|
|
259
|
+
key: string;
|
|
260
|
+
lastModified?: string;
|
|
261
|
+
etag?: string;
|
|
262
|
+
size: number;
|
|
263
|
+
}
|
|
264
|
+
interface ListObjectsResult {
|
|
265
|
+
name: string;
|
|
266
|
+
prefix: string;
|
|
267
|
+
maxKeys: number;
|
|
268
|
+
isTruncated: boolean;
|
|
269
|
+
contents: S3Object[];
|
|
270
|
+
commonPrefixes: string[];
|
|
271
|
+
}
|
|
272
|
+
declare class Storage {
|
|
273
|
+
private bucket;
|
|
274
|
+
private endpoint;
|
|
275
|
+
private region;
|
|
276
|
+
private accessKeyId?;
|
|
277
|
+
private secretAccessKey?;
|
|
278
|
+
constructor(options: StorageOptions);
|
|
279
|
+
private getHeaders;
|
|
280
|
+
listBuckets(): Promise<BucketInfo[]>;
|
|
281
|
+
listObjects(options?: {
|
|
282
|
+
prefix?: string;
|
|
283
|
+
delimiter?: string;
|
|
284
|
+
maxKeys?: number;
|
|
285
|
+
}): Promise<ListObjectsResult>;
|
|
286
|
+
getObject(key: string): Promise<Response>;
|
|
287
|
+
getObjectAsText(key: string): Promise<string>;
|
|
288
|
+
getObjectAsJson<T = any>(key: string): Promise<T>;
|
|
289
|
+
getObjectAsArrayBuffer(key: string): Promise<ArrayBuffer>;
|
|
290
|
+
putObject(key: string, body: Uint8Array | ArrayBuffer | string | Blob, options?: {
|
|
291
|
+
contentType?: string;
|
|
292
|
+
}): Promise<void>;
|
|
293
|
+
deleteObject(key: string): Promise<void>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export { type AuthorizeOptions, type BucketInfo, type ChangePasswordInput, type ListObjectsResult, type LoginInput, PaginatedResponse, type Profile, type ProfileInput, type ResetPasswordInput, type S3Object, Storage, type StorageOptions, type TokenResponse, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getProfile, getRoles, getServices, getUsers, handleRedirectCallback, initializeSdk, isLoggedIn, loginService as login, loginService, loginWithPassword, loginWithRedirect, logout, refreshTokens, resetPassword, setAccessToken, setRefreshToken, unassignRole, updateProfile, updateUser, verifyServiceToken, verifyToken };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
interface initializeSdkOptions {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
debounceTimeout?: number;
|
|
4
|
+
cacheArticles?: boolean;
|
|
5
|
+
searchCacheEnabled?: boolean;
|
|
6
|
+
searchCacheCapacity?: number;
|
|
7
|
+
}
|
|
8
|
+
declare const initializeSdk: (projectId: string, options?: initializeSdkOptions) => void;
|
|
9
|
+
declare const setAccessToken: (token: string, expiration?: number) => void;
|
|
10
|
+
declare const setRefreshToken: (token: string, expiration?: number) => void;
|
|
11
|
+
declare const refreshTokens: () => Promise<void>;
|
|
12
|
+
|
|
13
|
+
interface RESTPaginatedResponse<T> {
|
|
14
|
+
data: T[];
|
|
15
|
+
meta: {
|
|
16
|
+
total: number;
|
|
17
|
+
page: number;
|
|
18
|
+
limit: number;
|
|
19
|
+
next: string | null;
|
|
20
|
+
back: string | null;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare class PaginatedResponse<T> {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(response: RESTPaginatedResponse<T>);
|
|
26
|
+
get items(): T[];
|
|
27
|
+
get total(): number;
|
|
28
|
+
get page(): number;
|
|
29
|
+
get limit(): number;
|
|
30
|
+
get hasNext(): boolean;
|
|
31
|
+
get hasBack(): boolean;
|
|
32
|
+
next(): Promise<PaginatedResponse<T> | null>;
|
|
33
|
+
back(): Promise<PaginatedResponse<T> | null>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface Profile {
|
|
37
|
+
id: string;
|
|
38
|
+
email: string;
|
|
39
|
+
firstName?: string;
|
|
40
|
+
lastName?: string;
|
|
41
|
+
projectId?: string;
|
|
42
|
+
roles?: string[];
|
|
43
|
+
lastLoginAt?: string;
|
|
44
|
+
failedLoginAttempts?: number;
|
|
45
|
+
lockedUntilAt?: string;
|
|
46
|
+
attributes?: Record<string, any>;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
updatedAt?: string;
|
|
49
|
+
}
|
|
50
|
+
interface ProfileInput {
|
|
51
|
+
firstName?: string;
|
|
52
|
+
lastName?: string;
|
|
53
|
+
attributes?: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
interface ChangePasswordInput {
|
|
56
|
+
currentPassword?: string;
|
|
57
|
+
newPassword?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface LoginInput {
|
|
61
|
+
projectId: string;
|
|
62
|
+
email: string;
|
|
63
|
+
password?: string;
|
|
64
|
+
}
|
|
65
|
+
interface ResetPasswordInput {
|
|
66
|
+
projectId: string;
|
|
67
|
+
email: string;
|
|
68
|
+
}
|
|
69
|
+
interface AuthorizeOptions {
|
|
70
|
+
redirectUri?: string;
|
|
71
|
+
state?: string;
|
|
72
|
+
scope?: string;
|
|
73
|
+
prompt?: "login" | "none";
|
|
74
|
+
}
|
|
75
|
+
interface TokenResponse {
|
|
76
|
+
access_token: string;
|
|
77
|
+
refresh_token?: string;
|
|
78
|
+
id_token?: string;
|
|
79
|
+
token_type: string;
|
|
80
|
+
expires_in: number;
|
|
81
|
+
scope?: string;
|
|
82
|
+
user?: Profile;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Login with email and password
|
|
87
|
+
*
|
|
88
|
+
* @param {LoginInput} input The login credentials
|
|
89
|
+
*
|
|
90
|
+
* @returns {Promise<Profile>} The user profile
|
|
91
|
+
*/
|
|
92
|
+
declare const loginWithPassword: (input: LoginInput) => Promise<Profile>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Login as a service
|
|
96
|
+
*
|
|
97
|
+
* @param {string} projectId The project ID
|
|
98
|
+
* @param {string} serviceId The service ID
|
|
99
|
+
* @param {string} secretKey The service secret key
|
|
100
|
+
*
|
|
101
|
+
* @returns {Promise<any>} The login response
|
|
102
|
+
*/
|
|
103
|
+
declare const loginService: (projectId: string, serviceId: string, secretKey: string) => Promise<any>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Redirects the user to the Swiftbase-Auth universal login page
|
|
107
|
+
*
|
|
108
|
+
* @param {AuthorizeOptions} options Optional authorization parameters
|
|
109
|
+
*/
|
|
110
|
+
declare const loginWithRedirect: (options?: AuthorizeOptions) => Promise<void>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Handles the redirect callback from the Swiftbase-Auth service
|
|
114
|
+
*
|
|
115
|
+
* @param {string} url Optional URL to parse, defaults to window.location.href
|
|
116
|
+
*
|
|
117
|
+
* @returns {Promise<Profile>} The user profile
|
|
118
|
+
*/
|
|
119
|
+
declare const handleRedirectCallback: (url?: string) => Promise<Profile>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Reset password for email
|
|
123
|
+
*
|
|
124
|
+
* @param {ResetPasswordInput} input The reset password input
|
|
125
|
+
*
|
|
126
|
+
* @returns {Promise<{ success: boolean }>} The result of the reset password request
|
|
127
|
+
*/
|
|
128
|
+
declare const resetPassword: (input: ResetPasswordInput) => Promise<{
|
|
129
|
+
success: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Checks if the user is currently logged in (has a valid session)
|
|
134
|
+
*
|
|
135
|
+
* @returns {boolean} True if logged in, false otherwise
|
|
136
|
+
*/
|
|
137
|
+
declare const isLoggedIn: () => boolean;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Logs the user out by clearing tokens and redirecting to the logout page
|
|
141
|
+
*/
|
|
142
|
+
declare const logout: () => Promise<void>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Gets the current access token, refreshing it if necessary
|
|
146
|
+
*
|
|
147
|
+
* @param {boolean} forceRefresh If true, the token will be refreshed even if it's not expired
|
|
148
|
+
*
|
|
149
|
+
* @returns {Promise<string | null>} The access token, or null if no session exists
|
|
150
|
+
*/
|
|
151
|
+
declare const getAccessToken: (forceRefresh?: boolean) => Promise<string | null>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Verify a user token
|
|
155
|
+
*
|
|
156
|
+
* @param {string} token The token to verify
|
|
157
|
+
* @param {string} projectId The project ID (optional, defaults to SDK initialized project)
|
|
158
|
+
*
|
|
159
|
+
* @returns {Promise<Profile>} The user profile if valid
|
|
160
|
+
*/
|
|
161
|
+
declare const verifyToken: (token: string, projectId?: string) => Promise<Profile>;
|
|
162
|
+
/**
|
|
163
|
+
* Verify a service token
|
|
164
|
+
*
|
|
165
|
+
* @param {string} token The token to verify
|
|
166
|
+
* @param {string} projectId The project ID (optional, defaults to SDK initialized project)
|
|
167
|
+
* @param {string} scope The scope to check (optional)
|
|
168
|
+
*
|
|
169
|
+
* @returns {Promise<any>} The service info if valid
|
|
170
|
+
*/
|
|
171
|
+
declare const verifyServiceToken: (token: string, projectId?: string, scope?: string) => Promise<any>;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Get the current user profile
|
|
175
|
+
*
|
|
176
|
+
* @returns {Promise<Profile>} The user profile
|
|
177
|
+
*/
|
|
178
|
+
declare const getProfile: () => Promise<Profile>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Update the current user profile
|
|
182
|
+
*
|
|
183
|
+
* @param {ProfileInput} input The profile data to update
|
|
184
|
+
*
|
|
185
|
+
* @returns {Promise<Profile>} The updated user profile
|
|
186
|
+
*/
|
|
187
|
+
declare const updateProfile: (input: ProfileInput) => Promise<Profile>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Update any user profile (Admin only)
|
|
191
|
+
*
|
|
192
|
+
* @param {string} id The user ID to update
|
|
193
|
+
* @param {any} input The profile data to update
|
|
194
|
+
*
|
|
195
|
+
* @returns {Promise<Profile>} The updated user profile
|
|
196
|
+
*/
|
|
197
|
+
declare const updateUser: (id: string, input: any) => Promise<Profile>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Change the current user password
|
|
201
|
+
*
|
|
202
|
+
* @param {ChangePasswordInput} input The password change input
|
|
203
|
+
*
|
|
204
|
+
* @returns {Promise<{ success: boolean }>} The result of the password change request
|
|
205
|
+
*/
|
|
206
|
+
declare const changePassword: (input: ChangePasswordInput) => Promise<{
|
|
207
|
+
success: boolean;
|
|
208
|
+
}>;
|
|
209
|
+
|
|
210
|
+
declare const getUsers: (projectId: string) => Promise<any>;
|
|
211
|
+
declare const getRoles: (projectId: string) => Promise<any>;
|
|
212
|
+
declare const getServices: (projectId: string) => Promise<any>;
|
|
213
|
+
declare const createRole: (input: any) => Promise<any>;
|
|
214
|
+
declare const deleteRole: (id: string) => Promise<any>;
|
|
215
|
+
declare const createService: (input: any) => Promise<any>;
|
|
216
|
+
declare const deleteService: (id: string) => Promise<any>;
|
|
217
|
+
declare const assignRole: (userId: string, roleName: string) => Promise<any>;
|
|
218
|
+
declare const unassignRole: (userId: string, roleName: string) => Promise<any>;
|
|
219
|
+
|
|
220
|
+
declare class QueryBuilder implements PromiseLike<any> {
|
|
221
|
+
private dbName;
|
|
222
|
+
private tableName;
|
|
223
|
+
private payload;
|
|
224
|
+
constructor(dbName: string, tableName: string);
|
|
225
|
+
select(...columns: Array<string | string[]>): this;
|
|
226
|
+
where(column: string, value: any): this;
|
|
227
|
+
where(column: string, operator: string, value: any): this;
|
|
228
|
+
where(obj: Record<string, any>): this;
|
|
229
|
+
limit(value: number): this;
|
|
230
|
+
offset(value: number): this;
|
|
231
|
+
insert(data: any): this;
|
|
232
|
+
update(data: any): this;
|
|
233
|
+
delete(): this;
|
|
234
|
+
listen(callback: (change: {
|
|
235
|
+
event: 'insert' | 'update' | 'delete';
|
|
236
|
+
data: any;
|
|
237
|
+
}) => void): () => void;
|
|
238
|
+
execute(): Promise<{
|
|
239
|
+
data: any[];
|
|
240
|
+
columns: string[];
|
|
241
|
+
count: number;
|
|
242
|
+
}>;
|
|
243
|
+
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
244
|
+
}
|
|
245
|
+
declare function db(dbName: string): (tableName: string) => QueryBuilder;
|
|
246
|
+
|
|
247
|
+
interface StorageOptions {
|
|
248
|
+
bucket: string;
|
|
249
|
+
endpoint?: string;
|
|
250
|
+
region?: string;
|
|
251
|
+
accessKeyId?: string;
|
|
252
|
+
secretAccessKey?: string;
|
|
253
|
+
}
|
|
254
|
+
interface BucketInfo {
|
|
255
|
+
name: string;
|
|
256
|
+
creationDate?: string;
|
|
257
|
+
}
|
|
258
|
+
interface S3Object {
|
|
259
|
+
key: string;
|
|
260
|
+
lastModified?: string;
|
|
261
|
+
etag?: string;
|
|
262
|
+
size: number;
|
|
263
|
+
}
|
|
264
|
+
interface ListObjectsResult {
|
|
265
|
+
name: string;
|
|
266
|
+
prefix: string;
|
|
267
|
+
maxKeys: number;
|
|
268
|
+
isTruncated: boolean;
|
|
269
|
+
contents: S3Object[];
|
|
270
|
+
commonPrefixes: string[];
|
|
271
|
+
}
|
|
272
|
+
declare class Storage {
|
|
273
|
+
private bucket;
|
|
274
|
+
private endpoint;
|
|
275
|
+
private region;
|
|
276
|
+
private accessKeyId?;
|
|
277
|
+
private secretAccessKey?;
|
|
278
|
+
constructor(options: StorageOptions);
|
|
279
|
+
private getHeaders;
|
|
280
|
+
listBuckets(): Promise<BucketInfo[]>;
|
|
281
|
+
listObjects(options?: {
|
|
282
|
+
prefix?: string;
|
|
283
|
+
delimiter?: string;
|
|
284
|
+
maxKeys?: number;
|
|
285
|
+
}): Promise<ListObjectsResult>;
|
|
286
|
+
getObject(key: string): Promise<Response>;
|
|
287
|
+
getObjectAsText(key: string): Promise<string>;
|
|
288
|
+
getObjectAsJson<T = any>(key: string): Promise<T>;
|
|
289
|
+
getObjectAsArrayBuffer(key: string): Promise<ArrayBuffer>;
|
|
290
|
+
putObject(key: string, body: Uint8Array | ArrayBuffer | string | Blob, options?: {
|
|
291
|
+
contentType?: string;
|
|
292
|
+
}): Promise<void>;
|
|
293
|
+
deleteObject(key: string): Promise<void>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export { type AuthorizeOptions, type BucketInfo, type ChangePasswordInput, type ListObjectsResult, type LoginInput, PaginatedResponse, type Profile, type ProfileInput, type ResetPasswordInput, type S3Object, Storage, type StorageOptions, type TokenResponse, assignRole, changePassword, createRole, createService, db, deleteRole, deleteService, getAccessToken, getProfile, getRoles, getServices, getUsers, handleRedirectCallback, initializeSdk, isLoggedIn, loginService as login, loginService, loginWithPassword, loginWithRedirect, logout, refreshTokens, resetPassword, setAccessToken, setRefreshToken, unassignRole, updateProfile, updateUser, verifyServiceToken, verifyToken };
|