@fabriktor/client 0.0.48 → 0.0.49
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/src/users/users.d.ts +12 -7
- package/dist/src/users/users.js +28 -29
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InUser, type OperationResult, type PLUsersContactList, type PLUsersForgotPassword, type PLUsersResolveUsername, type PLUsersSignInLink, type PLUsersVerifyEmail, type UpsertResult, type User } from "@fabriktor/schema";
|
|
2
2
|
import type { TokenProvider } from "../core/auth.js";
|
|
3
|
-
import type { OperationResultOf } from "../core/crud.js";
|
|
3
|
+
import type { DeleteOneOptionsCRUD, FindOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD, SearchManyOptionsCRUD, SearchResultOf } from "../core/crud.js";
|
|
4
4
|
import type { HTTPDoer } from "../core/http.js";
|
|
5
5
|
import type { CompletePayload } from "../core/type.js";
|
|
6
6
|
export type BootstrapOptions = {
|
|
@@ -11,14 +11,15 @@ export type ForgotPasswordOptions = CompletePayload<PLUsersForgotPassword>;
|
|
|
11
11
|
export type SendSignInLinkOptions = CompletePayload<PLUsersSignInLink>;
|
|
12
12
|
export type SendEmailVerificationOptions = CompletePayload<PLUsersVerifyEmail>;
|
|
13
13
|
export type MatchOptions = CompletePayload<PLUsersContactList>;
|
|
14
|
-
export type SearchOptions = {
|
|
15
|
-
q: string;
|
|
16
|
-
limit?: number;
|
|
17
|
-
};
|
|
18
14
|
export type GetByUIDOptions = {
|
|
19
15
|
uid: string;
|
|
20
16
|
};
|
|
21
17
|
export interface UsersOperator {
|
|
18
|
+
queryUsers(opts?: QueryOptionsCRUD): Promise<OperationResultOf<User[]>>;
|
|
19
|
+
findOneUser(opts: FindOneOptionsCRUD): Promise<OperationResultOf<User>>;
|
|
20
|
+
replaceOneUser(opts: ReplaceOneOptionsCRUD<InUser>): Promise<OperationResult>;
|
|
21
|
+
deleteOneUser(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
22
|
+
searchManyUsers(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<User>>>;
|
|
22
23
|
bootstrap(opts: BootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
|
|
23
24
|
sync(): Promise<OperationResult>;
|
|
24
25
|
sendEmailVerification(opts: SendEmailVerificationOptions): Promise<void>;
|
|
@@ -26,7 +27,6 @@ export interface UsersOperator {
|
|
|
26
27
|
sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
|
|
27
28
|
resolveUsername(opts: ResolveUsernameOptions): Promise<OperationResultOf<string>>;
|
|
28
29
|
match(opts: MatchOptions): Promise<OperationResultOf<User[]>>;
|
|
29
|
-
search(opts: SearchOptions): Promise<OperationResultOf<User[]>>;
|
|
30
30
|
getByUID(opts: GetByUIDOptions): Promise<OperationResultOf<User[]>>;
|
|
31
31
|
}
|
|
32
32
|
export type UsersClientOptions = {
|
|
@@ -35,10 +35,16 @@ export type UsersClientOptions = {
|
|
|
35
35
|
get_token?: TokenProvider;
|
|
36
36
|
};
|
|
37
37
|
export declare class UsersClient implements UsersOperator {
|
|
38
|
+
private users;
|
|
38
39
|
private http;
|
|
39
40
|
private base_url;
|
|
40
41
|
private get_token?;
|
|
41
42
|
constructor(opts: UsersClientOptions);
|
|
43
|
+
queryUsers(opts?: QueryOptionsCRUD): Promise<OperationResultOf<User[]>>;
|
|
44
|
+
findOneUser(opts: FindOneOptionsCRUD): Promise<OperationResultOf<User>>;
|
|
45
|
+
replaceOneUser(opts: ReplaceOneOptionsCRUD<InUser>): Promise<OperationResult>;
|
|
46
|
+
deleteOneUser(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
47
|
+
searchManyUsers(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<User>>>;
|
|
42
48
|
bootstrap(opts: BootstrapOptions): Promise<OperationResultOf<UpsertResult>>;
|
|
43
49
|
sync(): Promise<OperationResult>;
|
|
44
50
|
sendEmailVerification(opts: SendEmailVerificationOptions): Promise<void>;
|
|
@@ -46,7 +52,6 @@ export declare class UsersClient implements UsersOperator {
|
|
|
46
52
|
sendSignInLink(opts: SendSignInLinkOptions): Promise<void>;
|
|
47
53
|
resolveUsername(opts: ResolveUsernameOptions): Promise<OperationResultOf<string>>;
|
|
48
54
|
match(opts: MatchOptions): Promise<OperationResultOf<User[]>>;
|
|
49
|
-
search(opts: SearchOptions): Promise<OperationResultOf<User[]>>;
|
|
50
55
|
getByUID(opts: GetByUIDOptions): Promise<OperationResultOf<User[]>>;
|
|
51
56
|
}
|
|
52
57
|
export declare function newUsersClient(opts: UsersClientOptions): UsersClient;
|
package/dist/src/users/users.js
CHANGED
|
@@ -3,19 +3,43 @@
|
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
4
4
|
// not use this file except in compliance with the License. You may obtain
|
|
5
5
|
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
import { ColUsersUsers,
|
|
6
|
+
import { ColUsersUsers, HTTPMethodPost, PathUsersBootstrap, PathUsersForgotPassword, PathUsersMatch, PathUsersResolveUsername, PathUsersSendEmailVerification, PathUsersSendSignInLink, PathUsersSync, SvcUsers, } from "@fabriktor/schema";
|
|
7
7
|
import { requiredToken } from "../core/auth.js";
|
|
8
|
-
import { queryParam
|
|
8
|
+
import { queryParam } from "../core/col.js";
|
|
9
|
+
import { newCRUDClient } from "../core/crud.js";
|
|
9
10
|
import { buildPath } from "../core/path.js";
|
|
10
11
|
export class UsersClient {
|
|
12
|
+
users;
|
|
11
13
|
http;
|
|
12
14
|
base_url;
|
|
13
15
|
get_token;
|
|
14
16
|
constructor(opts) {
|
|
17
|
+
this.users = newCRUDClient({
|
|
18
|
+
http: opts.http,
|
|
19
|
+
base_url: opts.base_url,
|
|
20
|
+
svc: SvcUsers,
|
|
21
|
+
col: ColUsersUsers,
|
|
22
|
+
get_token: opts.get_token,
|
|
23
|
+
});
|
|
15
24
|
this.http = opts.http;
|
|
16
25
|
this.base_url = opts.base_url;
|
|
17
26
|
this.get_token = opts.get_token;
|
|
18
27
|
}
|
|
28
|
+
async queryUsers(opts) {
|
|
29
|
+
return await this.users.query(opts);
|
|
30
|
+
}
|
|
31
|
+
async findOneUser(opts) {
|
|
32
|
+
return await this.users.findOne(opts);
|
|
33
|
+
}
|
|
34
|
+
async replaceOneUser(opts) {
|
|
35
|
+
return await this.users.replaceOne(opts);
|
|
36
|
+
}
|
|
37
|
+
async deleteOneUser(opts) {
|
|
38
|
+
return await this.users.deleteOne(opts);
|
|
39
|
+
}
|
|
40
|
+
async searchManyUsers(opts) {
|
|
41
|
+
return await this.users.searchMany(opts);
|
|
42
|
+
}
|
|
19
43
|
async bootstrap(opts) {
|
|
20
44
|
const token = await requiredToken(this.get_token);
|
|
21
45
|
return await this.http.do({
|
|
@@ -79,40 +103,15 @@ export class UsersClient {
|
|
|
79
103
|
body: opts,
|
|
80
104
|
});
|
|
81
105
|
}
|
|
82
|
-
async search(opts) {
|
|
83
|
-
const token = await requiredToken(this.get_token);
|
|
84
|
-
return await this.http.do({
|
|
85
|
-
base_url: this.base_url,
|
|
86
|
-
path: userPath(PathSearch),
|
|
87
|
-
method: HTTPMethodPost,
|
|
88
|
-
token,
|
|
89
|
-
body: {
|
|
90
|
-
q: opts.q,
|
|
91
|
-
limit: opts.limit,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
106
|
async getByUID(opts) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
base_url: this.base_url,
|
|
99
|
-
path: withQuery(collectionPath(), {
|
|
100
|
-
query: queryParam("uid", opts.uid),
|
|
101
|
-
}),
|
|
102
|
-
method: HTTPMethodGet,
|
|
103
|
-
token,
|
|
107
|
+
return await this.queryUsers({
|
|
108
|
+
query: queryParam("uid", opts.uid),
|
|
104
109
|
});
|
|
105
110
|
}
|
|
106
111
|
}
|
|
107
112
|
export function newUsersClient(opts) {
|
|
108
113
|
return new UsersClient(opts);
|
|
109
114
|
}
|
|
110
|
-
function collectionPath() {
|
|
111
|
-
return buildPath({
|
|
112
|
-
svc: SvcUsers,
|
|
113
|
-
col: ColUsersUsers,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
115
|
function userPath(action) {
|
|
117
116
|
return buildPath({
|
|
118
117
|
svc: SvcUsers,
|