@aeriajs/builtins 0.0.100 → 0.0.102
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/collections/user/createAccount.d.ts +11 -1
- package/dist/collections/user/createAccount.js +2 -1
- package/dist/collections/user/createAccount.mjs +2 -1
- package/dist/collections/user/getActivationLink.d.ts +5 -1
- package/dist/collections/user/getActivationLink.js +2 -1
- package/dist/collections/user/getActivationLink.mjs +2 -1
- package/dist/collections/user/getCurrentUser.d.ts +97 -93
- package/dist/collections/user/getCurrentUser.js +3 -2
- package/dist/collections/user/getCurrentUser.mjs +3 -2
- package/dist/collections/user/getInfo.d.ts +6 -2
- package/dist/collections/user/getInfo.js +4 -3
- package/dist/collections/user/getInfo.mjs +4 -3
- package/dist/collections/user/index.d.ts +234 -192
- package/dist/index.d.ts +234 -192
- package/package.json +5 -5
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import type { Context, Schema } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
|
-
|
|
3
|
+
import { HTTPStatus, ACError } from '@aeriajs/types';
|
|
4
|
+
export declare const createAccount: (payload: Omit<Schema<typeof description>, 'roles'>, context: Context<typeof description>) => Promise<import("../../../../types/dist/result.js").Result.Error<{
|
|
5
|
+
readonly code: ACError.MalformedInput;
|
|
6
|
+
readonly details: import("@aeriajs/types").PropertyValidationError | import("@aeriajs/types").ValidationError;
|
|
7
|
+
} & {
|
|
8
|
+
httpStatus: HTTPStatus.BadRequest;
|
|
9
|
+
}> | {
|
|
10
|
+
readonly _tag: "Result";
|
|
11
|
+
readonly error: undefined;
|
|
12
|
+
readonly result: any;
|
|
13
|
+
}>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createAccount = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
|
+
const common_1 = require("@aeriajs/common");
|
|
5
6
|
const validation_1 = require("@aeriajs/validation");
|
|
6
7
|
const bcrypt = require("bcrypt");
|
|
7
8
|
const createAccount = async (payload, context) => {
|
|
@@ -61,6 +62,6 @@ const createAccount = async (payload, context) => {
|
|
|
61
62
|
if (!newUser) {
|
|
62
63
|
throw new Error();
|
|
63
64
|
}
|
|
64
|
-
return newUser;
|
|
65
|
+
return common_1.Result.result(newUser);
|
|
65
66
|
};
|
|
66
67
|
exports.createAccount = createAccount;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { HTTPStatus, ACError } from "@aeriajs/types";
|
|
3
|
+
import { Result } from "@aeriajs/common";
|
|
3
4
|
import { validate } from "@aeriajs/validation";
|
|
4
5
|
import * as bcrypt from "bcrypt";
|
|
5
6
|
export const createAccount = async (payload, context) => {
|
|
@@ -59,5 +60,5 @@ export const createAccount = async (payload, context) => {
|
|
|
59
60
|
if (!newUser) {
|
|
60
61
|
throw new Error();
|
|
61
62
|
}
|
|
62
|
-
return newUser;
|
|
63
|
+
return Result.result(newUser);
|
|
63
64
|
};
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { ObjectId } from '@aeriajs/core';
|
|
2
|
-
export declare const getActivationLink: (userId: ObjectId) => Promise<
|
|
2
|
+
export declare const getActivationLink: (userId: ObjectId) => Promise<{
|
|
3
|
+
readonly _tag: "Result";
|
|
4
|
+
readonly error: undefined;
|
|
5
|
+
readonly result: string;
|
|
6
|
+
}>;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getActivationLink = void 0;
|
|
4
4
|
const entrypoint_1 = require("@aeriajs/entrypoint");
|
|
5
|
+
const common_1 = require("@aeriajs/common");
|
|
5
6
|
const bcrypt = require("bcrypt");
|
|
6
7
|
const getActivationLink = async (userId) => {
|
|
7
8
|
const config = await (0, entrypoint_1.getConfig)();
|
|
8
9
|
const activationToken = await bcrypt.hash(userId.toString(), 10);
|
|
9
10
|
const link = `${config.publicUrl}/user/activate?u=${userId.toString()}&t=${activationToken}`;
|
|
10
|
-
return link;
|
|
11
|
+
return common_1.Result.result(link);
|
|
11
12
|
};
|
|
12
13
|
exports.getActivationLink = getActivationLink;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { getConfig } from "@aeriajs/entrypoint";
|
|
3
|
+
import { Result } from "@aeriajs/common";
|
|
3
4
|
import * as bcrypt from "bcrypt";
|
|
4
5
|
export const getActivationLink = async (userId) => {
|
|
5
6
|
const config = await getConfig();
|
|
6
7
|
const activationToken = await bcrypt.hash(userId.toString(), 10);
|
|
7
8
|
const link = `${config.publicUrl}/user/activate?u=${userId.toString()}&t=${activationToken}`;
|
|
8
|
-
return link;
|
|
9
|
+
return Result.result(link);
|
|
9
10
|
};
|
|
@@ -5,103 +5,107 @@ export declare enum ActivationError {
|
|
|
5
5
|
AlreadyActiveUser = "ALREADY_ACTIVE_USER",
|
|
6
6
|
InvalidLink = "INVALID_LINK"
|
|
7
7
|
}
|
|
8
|
-
export declare const getCurrentUser: (_payload: undefined, context: Context<typeof description>) => Promise<
|
|
9
|
-
readonly
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly getter: (document: any) => string;
|
|
22
|
-
};
|
|
23
|
-
readonly family_name: {
|
|
24
|
-
readonly getter: (document: any) => string;
|
|
25
|
-
};
|
|
26
|
-
readonly active: {
|
|
27
|
-
readonly type: "boolean";
|
|
28
|
-
};
|
|
29
|
-
readonly roles: {
|
|
30
|
-
readonly type: "array";
|
|
31
|
-
readonly items: {
|
|
8
|
+
export declare const getCurrentUser: (_payload: undefined, context: Context<typeof description>) => Promise<{
|
|
9
|
+
readonly _tag: "Result";
|
|
10
|
+
readonly error: undefined;
|
|
11
|
+
readonly result: import("@aeriajs/types").SchemaWithId<{
|
|
12
|
+
readonly $id: "user";
|
|
13
|
+
readonly required: readonly ["name", "roles", "email"];
|
|
14
|
+
readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
|
|
15
|
+
readonly indexes: readonly ["name"];
|
|
16
|
+
readonly freshItem: {
|
|
17
|
+
readonly active: true;
|
|
18
|
+
};
|
|
19
|
+
readonly properties: {
|
|
20
|
+
readonly name: {
|
|
32
21
|
readonly type: "string";
|
|
33
22
|
};
|
|
34
|
-
readonly uniqueItems: true;
|
|
35
|
-
};
|
|
36
|
-
readonly email: {
|
|
37
|
-
readonly type: "string";
|
|
38
|
-
readonly inputType: "email";
|
|
39
|
-
readonly unique: true;
|
|
40
|
-
};
|
|
41
|
-
readonly password: {
|
|
42
|
-
readonly type: "string";
|
|
43
|
-
readonly inputType: "password";
|
|
44
|
-
readonly hidden: true;
|
|
45
|
-
};
|
|
46
|
-
readonly phone_number: {
|
|
47
|
-
readonly type: "string";
|
|
48
|
-
readonly mask: "(##) #####-####";
|
|
49
|
-
};
|
|
50
|
-
readonly picture_file: {
|
|
51
|
-
readonly $ref: "file";
|
|
52
|
-
readonly accept: readonly ["image/*"];
|
|
53
|
-
};
|
|
54
|
-
readonly picture: {
|
|
55
|
-
readonly getter: (value: any) => any;
|
|
56
|
-
};
|
|
57
|
-
readonly group: {
|
|
58
|
-
readonly type: "string";
|
|
59
|
-
};
|
|
60
|
-
readonly self_registered: {
|
|
61
|
-
readonly type: "boolean";
|
|
62
|
-
readonly readOnly: true;
|
|
63
|
-
};
|
|
64
|
-
readonly updated_at: {
|
|
65
|
-
readonly type: "string";
|
|
66
|
-
readonly format: "date-time";
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
readonly presets: readonly ["crud", "view", "duplicate"];
|
|
70
|
-
readonly layout: {
|
|
71
|
-
readonly name: "grid";
|
|
72
|
-
readonly options: {
|
|
73
|
-
readonly title: "name";
|
|
74
|
-
readonly badge: "roles";
|
|
75
|
-
readonly picture: "picture_file";
|
|
76
|
-
readonly information: "email";
|
|
77
|
-
readonly active: "active";
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
readonly individualActions: {
|
|
81
|
-
readonly 'ui:spawnEdit': {
|
|
82
|
-
readonly label: "action.edit";
|
|
83
|
-
readonly icon: "pencil";
|
|
84
|
-
readonly translate: true;
|
|
85
|
-
};
|
|
86
|
-
readonly 'route:/dashboard/user/changepass': {
|
|
87
|
-
readonly label: "change_password";
|
|
88
|
-
readonly icon: "key";
|
|
89
|
-
readonly fetchItem: true;
|
|
90
|
-
readonly translate: true;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
readonly icon: "users";
|
|
94
|
-
readonly filters: readonly ["name", "roles", "email", "phone_number"];
|
|
95
|
-
readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
|
|
96
|
-
readonly tableMeta: readonly ["email"];
|
|
97
|
-
readonly formLayout: {
|
|
98
|
-
readonly fields: {
|
|
99
23
|
readonly given_name: {
|
|
100
|
-
readonly
|
|
24
|
+
readonly getter: (document: any) => string;
|
|
101
25
|
};
|
|
102
26
|
readonly family_name: {
|
|
103
|
-
readonly
|
|
27
|
+
readonly getter: (document: any) => string;
|
|
28
|
+
};
|
|
29
|
+
readonly active: {
|
|
30
|
+
readonly type: "boolean";
|
|
31
|
+
};
|
|
32
|
+
readonly roles: {
|
|
33
|
+
readonly type: "array";
|
|
34
|
+
readonly items: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
};
|
|
37
|
+
readonly uniqueItems: true;
|
|
38
|
+
};
|
|
39
|
+
readonly email: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly inputType: "email";
|
|
42
|
+
readonly unique: true;
|
|
43
|
+
};
|
|
44
|
+
readonly password: {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly inputType: "password";
|
|
47
|
+
readonly hidden: true;
|
|
48
|
+
};
|
|
49
|
+
readonly phone_number: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly mask: "(##) #####-####";
|
|
52
|
+
};
|
|
53
|
+
readonly picture_file: {
|
|
54
|
+
readonly $ref: "file";
|
|
55
|
+
readonly accept: readonly ["image/*"];
|
|
56
|
+
};
|
|
57
|
+
readonly picture: {
|
|
58
|
+
readonly getter: (value: any) => any;
|
|
59
|
+
};
|
|
60
|
+
readonly group: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
};
|
|
63
|
+
readonly self_registered: {
|
|
64
|
+
readonly type: "boolean";
|
|
65
|
+
readonly readOnly: true;
|
|
66
|
+
};
|
|
67
|
+
readonly updated_at: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
readonly format: "date-time";
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly presets: readonly ["crud", "view", "duplicate"];
|
|
73
|
+
readonly layout: {
|
|
74
|
+
readonly name: "grid";
|
|
75
|
+
readonly options: {
|
|
76
|
+
readonly title: "name";
|
|
77
|
+
readonly badge: "roles";
|
|
78
|
+
readonly picture: "picture_file";
|
|
79
|
+
readonly information: "email";
|
|
80
|
+
readonly active: "active";
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
readonly individualActions: {
|
|
84
|
+
readonly 'ui:spawnEdit': {
|
|
85
|
+
readonly label: "action.edit";
|
|
86
|
+
readonly icon: "pencil";
|
|
87
|
+
readonly translate: true;
|
|
88
|
+
};
|
|
89
|
+
readonly 'route:/dashboard/user/changepass': {
|
|
90
|
+
readonly label: "change_password";
|
|
91
|
+
readonly icon: "key";
|
|
92
|
+
readonly fetchItem: true;
|
|
93
|
+
readonly translate: true;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
readonly icon: "users";
|
|
97
|
+
readonly filters: readonly ["name", "roles", "email", "phone_number"];
|
|
98
|
+
readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
|
|
99
|
+
readonly tableMeta: readonly ["email"];
|
|
100
|
+
readonly formLayout: {
|
|
101
|
+
readonly fields: {
|
|
102
|
+
readonly given_name: {
|
|
103
|
+
readonly span: 3;
|
|
104
|
+
};
|
|
105
|
+
readonly family_name: {
|
|
106
|
+
readonly span: 3;
|
|
107
|
+
};
|
|
104
108
|
};
|
|
105
109
|
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
110
|
+
}>;
|
|
111
|
+
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentUser = exports.ActivationError = void 0;
|
|
4
|
+
const common_1 = require("@aeriajs/common");
|
|
4
5
|
var ActivationError;
|
|
5
6
|
(function (ActivationError) {
|
|
6
7
|
ActivationError["UserNotFound"] = "USER_NOT_FOUND";
|
|
@@ -11,7 +12,7 @@ const getCurrentUser = async (_payload, context) => {
|
|
|
11
12
|
if (!context.token.authenticated) {
|
|
12
13
|
throw new Error();
|
|
13
14
|
}
|
|
14
|
-
const { error, result } = await context.collections.user.functions.get({
|
|
15
|
+
const { error, result: user } = await context.collections.user.functions.get({
|
|
15
16
|
filters: {
|
|
16
17
|
_id: context.token.sub,
|
|
17
18
|
},
|
|
@@ -19,6 +20,6 @@ const getCurrentUser = async (_payload, context) => {
|
|
|
19
20
|
if (error) {
|
|
20
21
|
throw new Error();
|
|
21
22
|
}
|
|
22
|
-
return result;
|
|
23
|
+
return common_1.Result.result(user);
|
|
23
24
|
};
|
|
24
25
|
exports.getCurrentUser = getCurrentUser;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
import { Result } from "@aeriajs/common";
|
|
2
3
|
export var ActivationError = /* @__PURE__ */ ((ActivationError2) => {
|
|
3
4
|
ActivationError2["UserNotFound"] = "USER_NOT_FOUND";
|
|
4
5
|
ActivationError2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
|
|
@@ -9,7 +10,7 @@ export const getCurrentUser = async (_payload, context) => {
|
|
|
9
10
|
if (!context.token.authenticated) {
|
|
10
11
|
throw new Error();
|
|
11
12
|
}
|
|
12
|
-
const { error, result } = await context.collections.user.functions.get({
|
|
13
|
+
const { error, result: user } = await context.collections.user.functions.get({
|
|
13
14
|
filters: {
|
|
14
15
|
_id: context.token.sub
|
|
15
16
|
}
|
|
@@ -17,5 +18,5 @@ export const getCurrentUser = async (_payload, context) => {
|
|
|
17
18
|
if (error) {
|
|
18
19
|
throw new Error();
|
|
19
20
|
}
|
|
20
|
-
return result;
|
|
21
|
+
return Result.result(user);
|
|
21
22
|
};
|
|
@@ -22,6 +22,10 @@ export declare const getInfo: (payload: {
|
|
|
22
22
|
} & {
|
|
23
23
|
httpStatus: HTTPStatus.Forbidden;
|
|
24
24
|
}> | {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
readonly _tag: "Result";
|
|
26
|
+
readonly error: undefined;
|
|
27
|
+
readonly result: {
|
|
28
|
+
readonly name: any;
|
|
29
|
+
readonly email: any;
|
|
30
|
+
};
|
|
27
31
|
}>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInfo = exports.ActivationError = void 0;
|
|
4
|
+
const bcrypt = require("bcrypt");
|
|
4
5
|
const types_1 = require("@aeriajs/types");
|
|
5
6
|
const core_1 = require("@aeriajs/core");
|
|
6
|
-
const
|
|
7
|
+
const common_1 = require("@aeriajs/common");
|
|
7
8
|
var ActivationError;
|
|
8
9
|
(function (ActivationError) {
|
|
9
10
|
ActivationError["UserNotFound"] = "USER_NOT_FOUND";
|
|
@@ -36,9 +37,9 @@ const getInfo = async (payload, context) => {
|
|
|
36
37
|
code: ActivationError.InvalidLink,
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
|
-
return {
|
|
40
|
+
return common_1.Result.result({
|
|
40
41
|
name: user.name,
|
|
41
42
|
email: user.email,
|
|
42
|
-
};
|
|
43
|
+
});
|
|
43
44
|
};
|
|
44
45
|
exports.getInfo = getInfo;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
import * as bcrypt from "bcrypt";
|
|
2
3
|
import { HTTPStatus } from "@aeriajs/types";
|
|
3
4
|
import { ObjectId } from "@aeriajs/core";
|
|
4
|
-
import
|
|
5
|
+
import { Result } from "@aeriajs/common";
|
|
5
6
|
export var ActivationError = /* @__PURE__ */ ((ActivationError2) => {
|
|
6
7
|
ActivationError2["UserNotFound"] = "USER_NOT_FOUND";
|
|
7
8
|
ActivationError2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
|
|
@@ -37,8 +38,8 @@ export const getInfo = async (payload, context) => {
|
|
|
37
38
|
code: "INVALID_LINK" /* InvalidLink */
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
return {
|
|
41
|
+
return Result.result({
|
|
41
42
|
name: user.name,
|
|
42
43
|
email: user.email
|
|
43
|
-
};
|
|
44
|
+
});
|
|
44
45
|
};
|