@aeriajs/builtins 0.0.256 → 0.0.258
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/file/download.d.ts +56 -16
- package/dist/collections/file/download.js +40 -1
- package/dist/collections/file/download.mjs +40 -1
- package/dist/collections/file/index.d.ts +461 -20
- package/dist/collections/file/index.js +3 -0
- package/dist/collections/file/index.mjs +4 -1
- package/dist/collections/file/remove.d.ts +2 -2
- package/dist/collections/user/activate.d.ts +67 -33
- package/dist/collections/user/activate.js +45 -1
- package/dist/collections/user/activate.mjs +45 -1
- package/dist/collections/user/authenticate.d.ts +136 -41
- package/dist/collections/user/authenticate.js +98 -2
- package/dist/collections/user/authenticate.mjs +98 -2
- package/dist/collections/user/createAccount.d.ts +124 -111
- package/dist/collections/user/createAccount.js +27 -1
- package/dist/collections/user/createAccount.mjs +27 -1
- package/dist/collections/user/editProfile.d.ts +95 -103
- package/dist/collections/user/editProfile.js +21 -1
- package/dist/collections/user/editProfile.mjs +21 -1
- package/dist/collections/user/getActivationLink.d.ts +92 -60
- package/dist/collections/user/getActivationLink.js +39 -4
- package/dist/collections/user/getActivationLink.mjs +39 -3
- package/dist/collections/user/getCurrentUser.d.ts +43 -113
- package/dist/collections/user/getCurrentUser.js +31 -1
- package/dist/collections/user/getCurrentUser.mjs +31 -1
- package/dist/collections/user/getInfo.d.ts +71 -26
- package/dist/collections/user/getInfo.js +47 -1
- package/dist/collections/user/getInfo.mjs +47 -1
- package/dist/collections/user/getRedefinePasswordLink.d.ts +91 -55
- package/dist/collections/user/getRedefinePasswordLink.js +32 -2
- package/dist/collections/user/getRedefinePasswordLink.mjs +33 -3
- package/dist/collections/user/index.d.ts +3493 -619
- package/dist/collections/user/index.js +9 -21
- package/dist/collections/user/index.mjs +18 -30
- package/dist/collections/user/redefinePassword.d.ts +98 -34
- package/dist/collections/user/redefinePassword.js +51 -6
- package/dist/collections/user/redefinePassword.mjs +51 -6
- package/dist/functions/describe.d.ts +38 -12
- package/dist/index.d.ts +4427 -1112
- package/package.json +6 -6
|
@@ -1,64 +1,96 @@
|
|
|
1
|
-
import type { Context } from '@aeriajs/types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly
|
|
1
|
+
import type { Context, ContractToFunction } from '@aeriajs/types';
|
|
2
|
+
import type { description } from './description.js';
|
|
3
|
+
export declare const getActivationLinkContract: {
|
|
4
|
+
readonly payload: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly required: readonly ["userId"];
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly userId: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly format: "objectid";
|
|
11
|
+
};
|
|
12
|
+
readonly redirect: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
};
|
|
13
15
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
readonly
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
};
|
|
17
|
+
readonly response: [{
|
|
18
|
+
readonly type: "object";
|
|
19
|
+
readonly properties: {
|
|
20
|
+
readonly _tag: {
|
|
21
|
+
readonly const: "Error";
|
|
22
|
+
};
|
|
23
|
+
readonly result: {
|
|
24
|
+
readonly const: undefined;
|
|
25
|
+
};
|
|
26
|
+
readonly error: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
readonly required: readonly ["httpStatus", "code"];
|
|
29
|
+
readonly properties: {
|
|
30
|
+
readonly httpStatus: {
|
|
31
|
+
readonly enum: [403, 404, 400];
|
|
32
|
+
};
|
|
33
|
+
readonly code: {
|
|
34
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
35
|
+
};
|
|
36
|
+
readonly message: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
};
|
|
39
|
+
readonly details: {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
readonly additionalProperties: true;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
35
45
|
};
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
}, {
|
|
47
|
+
readonly type: "object";
|
|
48
|
+
readonly properties: {
|
|
49
|
+
readonly _tag: {
|
|
50
|
+
readonly const: "Error";
|
|
51
|
+
};
|
|
52
|
+
readonly result: {
|
|
53
|
+
readonly const: undefined;
|
|
54
|
+
};
|
|
55
|
+
readonly error: {
|
|
56
|
+
readonly type: "object";
|
|
57
|
+
readonly required: readonly ["httpStatus", "code"];
|
|
58
|
+
readonly properties: {
|
|
59
|
+
readonly httpStatus: {
|
|
60
|
+
readonly enum: [400, 403];
|
|
61
|
+
};
|
|
62
|
+
readonly code: {
|
|
63
|
+
readonly enum: ["INVALID_LINK", "ALREADY_ACTIVE_USER"];
|
|
64
|
+
};
|
|
65
|
+
readonly message: {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
};
|
|
68
|
+
readonly details: {
|
|
69
|
+
readonly type: "object";
|
|
70
|
+
readonly additionalProperties: true;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
38
74
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
75
|
+
}, {
|
|
76
|
+
readonly type: "object";
|
|
77
|
+
readonly properties: {
|
|
78
|
+
readonly _tag: {
|
|
79
|
+
readonly const: "Result";
|
|
80
|
+
};
|
|
81
|
+
readonly error: {
|
|
82
|
+
readonly const: undefined;
|
|
83
|
+
};
|
|
84
|
+
readonly result: {
|
|
85
|
+
readonly type: "object";
|
|
86
|
+
readonly properties: {
|
|
87
|
+
readonly url: {
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
42
92
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
details: any;
|
|
48
|
-
}, never>>;
|
|
49
|
-
readonly result: undefined;
|
|
50
|
-
} | Result.Error<{
|
|
51
|
-
readonly code: "INVALID_LINK";
|
|
52
|
-
} & {
|
|
53
|
-
httpStatus: 400;
|
|
54
|
-
}> | Result.Error<{
|
|
55
|
-
readonly code: "ALREADY_ACTIVE_USER";
|
|
56
|
-
} & {
|
|
57
|
-
httpStatus: 403;
|
|
58
|
-
}> | {
|
|
59
|
-
readonly _tag: "Result";
|
|
60
|
-
readonly error: undefined;
|
|
61
|
-
readonly result: {
|
|
62
|
-
readonly url: string;
|
|
63
|
-
};
|
|
64
|
-
}>;
|
|
93
|
+
}];
|
|
94
|
+
};
|
|
95
|
+
export declare const getActivationToken: (userId: string, context: Context) => Promise<string>;
|
|
96
|
+
export declare const getActivationLink: ContractToFunction<typeof getActivationLinkContract, Context<typeof description>>;
|
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getActivationLink = exports.getActivationToken = void 0;
|
|
3
|
+
exports.getActivationLink = exports.getActivationToken = exports.getActivationLinkContract = void 0;
|
|
4
4
|
const core_1 = require("@aeriajs/core");
|
|
5
5
|
const types_1 = require("@aeriajs/types");
|
|
6
6
|
const activate_js_1 = require("./activate.js");
|
|
7
|
-
|
|
7
|
+
exports.getActivationLinkContract = (0, types_1.defineContract)({
|
|
8
|
+
payload: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['userId'],
|
|
11
|
+
properties: {
|
|
12
|
+
userId: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
format: 'objectid',
|
|
15
|
+
},
|
|
16
|
+
redirect: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
response: [
|
|
22
|
+
types_1.functionSchemas.getError(),
|
|
23
|
+
(0, types_1.endpointErrorSchema)({
|
|
24
|
+
httpStatus: [
|
|
25
|
+
types_1.HTTPStatus.BadRequest,
|
|
26
|
+
types_1.HTTPStatus.Forbidden,
|
|
27
|
+
],
|
|
28
|
+
code: [
|
|
29
|
+
activate_js_1.ActivationError.InvalidLink,
|
|
30
|
+
activate_js_1.ActivationError.AlreadyActiveUser,
|
|
31
|
+
],
|
|
32
|
+
}),
|
|
33
|
+
(0, types_1.resultSchema)({
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
url: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
const getActivationToken = async (userId, context) => {
|
|
8
44
|
if (context.calledFunction === 'getActivationToken') {
|
|
9
45
|
throw new Error('cannot be called externally');
|
|
10
46
|
}
|
|
@@ -12,7 +48,7 @@ const getActivationToken = async (strId, context) => {
|
|
|
12
48
|
throw new Error('config.secret is not set');
|
|
13
49
|
}
|
|
14
50
|
const token = await (0, core_1.signToken)({
|
|
15
|
-
data:
|
|
51
|
+
data: userId,
|
|
16
52
|
}, context.config.secret, {
|
|
17
53
|
expiresIn: context.config.security.linkTokenExpiration,
|
|
18
54
|
});
|
|
@@ -40,7 +76,6 @@ const getActivationLink = async (payload, context) => {
|
|
|
40
76
|
});
|
|
41
77
|
}
|
|
42
78
|
const activationToken = await (0, exports.getActivationToken)(payload.userId.toString(), context);
|
|
43
|
-
//const url = `${context.config.webPublicUrl}/user/activation?step=password&u=${payload.userId.toString()}&t=${activationToken}`
|
|
44
79
|
const url = new URL(`${context.config.webPublicUrl}/user/activation`);
|
|
45
80
|
url.searchParams.set('u', payload.userId.toString());
|
|
46
81
|
url.searchParams.set('t', activationToken);
|
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { signToken } from "@aeriajs/core";
|
|
3
|
-
import { Result, HTTPStatus } from "@aeriajs/types";
|
|
3
|
+
import { Result, HTTPStatus, defineContract, resultSchema, endpointErrorSchema, functionSchemas } from "@aeriajs/types";
|
|
4
4
|
import { ActivationError } from "./activate.mjs";
|
|
5
|
-
export const
|
|
5
|
+
export const getActivationLinkContract = defineContract({
|
|
6
|
+
payload: {
|
|
7
|
+
type: "object",
|
|
8
|
+
required: ["userId"],
|
|
9
|
+
properties: {
|
|
10
|
+
userId: {
|
|
11
|
+
type: "string",
|
|
12
|
+
format: "objectid"
|
|
13
|
+
},
|
|
14
|
+
redirect: {
|
|
15
|
+
type: "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
response: [
|
|
20
|
+
functionSchemas.getError(),
|
|
21
|
+
endpointErrorSchema({
|
|
22
|
+
httpStatus: [
|
|
23
|
+
HTTPStatus.BadRequest,
|
|
24
|
+
HTTPStatus.Forbidden
|
|
25
|
+
],
|
|
26
|
+
code: [
|
|
27
|
+
ActivationError.InvalidLink,
|
|
28
|
+
ActivationError.AlreadyActiveUser
|
|
29
|
+
]
|
|
30
|
+
}),
|
|
31
|
+
resultSchema({
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
url: {
|
|
35
|
+
type: "string"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
export const getActivationToken = async (userId, context) => {
|
|
6
42
|
if (context.calledFunction === "getActivationToken") {
|
|
7
43
|
throw new Error("cannot be called externally");
|
|
8
44
|
}
|
|
@@ -10,7 +46,7 @@ export const getActivationToken = async (strId, context) => {
|
|
|
10
46
|
throw new Error("config.secret is not set");
|
|
11
47
|
}
|
|
12
48
|
const token = await signToken({
|
|
13
|
-
data:
|
|
49
|
+
data: userId
|
|
14
50
|
}, context.config.secret, {
|
|
15
51
|
expiresIn: context.config.security.linkTokenExpiration
|
|
16
52
|
});
|
|
@@ -1,127 +1,57 @@
|
|
|
1
|
-
import type { Context } from '@aeriajs/types';
|
|
1
|
+
import type { Context, ContractToFunction } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
3
|
export declare const ActivationError: {
|
|
4
4
|
readonly UserNotFound: "USER_NOT_FOUND";
|
|
5
5
|
readonly AlreadyActiveUser: "ALREADY_ACTIVE_USER";
|
|
6
6
|
readonly InvalidLink: "INVALID_LINK";
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
readonly result: {
|
|
12
|
-
_id: null;
|
|
13
|
-
name: string;
|
|
14
|
-
email: string;
|
|
15
|
-
roles: string[];
|
|
16
|
-
active: boolean;
|
|
17
|
-
};
|
|
18
|
-
} | {
|
|
19
|
-
readonly _tag: "Result";
|
|
20
|
-
readonly error: undefined;
|
|
21
|
-
readonly result: import("@aeriajs/types").SchemaWithId<{
|
|
22
|
-
readonly $id: "user";
|
|
23
|
-
readonly icon: "users";
|
|
24
|
-
readonly required: readonly ["name", "roles", "email"];
|
|
25
|
-
readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
|
|
26
|
-
readonly indexes: readonly ["name"];
|
|
27
|
-
readonly unique: readonly ["email"];
|
|
8
|
+
export declare const getCurrentUserContract: {
|
|
9
|
+
readonly response: [{
|
|
10
|
+
readonly type: "object";
|
|
28
11
|
readonly properties: {
|
|
29
|
-
readonly
|
|
30
|
-
readonly
|
|
31
|
-
readonly minLength: 1;
|
|
12
|
+
readonly _tag: {
|
|
13
|
+
readonly const: "Result";
|
|
32
14
|
};
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
15
|
+
readonly error: {
|
|
16
|
+
readonly const: undefined;
|
|
35
17
|
};
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
};
|
|
39
|
-
readonly active: {
|
|
40
|
-
readonly type: "boolean";
|
|
41
|
-
};
|
|
42
|
-
readonly roles: {
|
|
43
|
-
readonly type: "array";
|
|
44
|
-
readonly items: {
|
|
45
|
-
readonly type: "string";
|
|
46
|
-
};
|
|
47
|
-
readonly uniqueItems: true;
|
|
48
|
-
readonly minItems: 1;
|
|
49
|
-
};
|
|
50
|
-
readonly email: {
|
|
51
|
-
readonly type: "string";
|
|
52
|
-
readonly inputType: "email";
|
|
53
|
-
readonly minLength: 3;
|
|
54
|
-
};
|
|
55
|
-
readonly password: {
|
|
56
|
-
readonly type: "string";
|
|
57
|
-
readonly inputType: "password";
|
|
58
|
-
readonly hidden: true;
|
|
59
|
-
};
|
|
60
|
-
readonly phone_number: {
|
|
61
|
-
readonly type: "string";
|
|
62
|
-
readonly mask: "(##) #####-####";
|
|
63
|
-
};
|
|
64
|
-
readonly picture_file: {
|
|
65
|
-
readonly $ref: "file";
|
|
66
|
-
readonly accept: readonly ["image/*"];
|
|
67
|
-
};
|
|
68
|
-
readonly picture: {
|
|
69
|
-
readonly getter: (doc: object) => Promise<string> | undefined;
|
|
70
|
-
};
|
|
71
|
-
readonly self_registered: {
|
|
72
|
-
readonly type: "boolean";
|
|
73
|
-
readonly readOnly: true;
|
|
74
|
-
};
|
|
75
|
-
readonly updated_at: {
|
|
76
|
-
readonly type: "string";
|
|
77
|
-
readonly format: "date-time";
|
|
18
|
+
readonly result: {
|
|
19
|
+
readonly $ref: "user";
|
|
78
20
|
};
|
|
79
21
|
};
|
|
80
|
-
|
|
81
|
-
readonly
|
|
82
|
-
|
|
83
|
-
readonly
|
|
84
|
-
readonly
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
readonly
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
readonly
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
readonly translate: true;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
readonly filters: readonly ["name", "roles", "email", "phone_number"];
|
|
114
|
-
readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
|
|
115
|
-
readonly tableMeta: readonly ["email"];
|
|
116
|
-
readonly formLayout: {
|
|
117
|
-
readonly fields: {
|
|
118
|
-
readonly given_name: {
|
|
119
|
-
readonly span: 3;
|
|
120
|
-
};
|
|
121
|
-
readonly family_name: {
|
|
122
|
-
readonly span: 3;
|
|
22
|
+
}, {
|
|
23
|
+
readonly type: "object";
|
|
24
|
+
readonly properties: {
|
|
25
|
+
readonly _tag: {
|
|
26
|
+
readonly const: "Result";
|
|
27
|
+
};
|
|
28
|
+
readonly error: {
|
|
29
|
+
readonly const: undefined;
|
|
30
|
+
};
|
|
31
|
+
readonly result: {
|
|
32
|
+
readonly type: "object";
|
|
33
|
+
readonly properties: {
|
|
34
|
+
readonly _id: {
|
|
35
|
+
readonly const: null;
|
|
36
|
+
};
|
|
37
|
+
readonly name: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
};
|
|
40
|
+
readonly email: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
};
|
|
43
|
+
readonly roles: {
|
|
44
|
+
readonly type: "array";
|
|
45
|
+
readonly items: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
readonly active: {
|
|
50
|
+
readonly type: "boolean";
|
|
51
|
+
};
|
|
123
52
|
};
|
|
124
53
|
};
|
|
125
54
|
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
55
|
+
}];
|
|
56
|
+
};
|
|
57
|
+
export declare const getCurrentUser: ContractToFunction<typeof getCurrentUserContract, Context<typeof description>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCurrentUser = exports.ActivationError = void 0;
|
|
3
|
+
exports.getCurrentUser = exports.getCurrentUserContract = exports.ActivationError = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
5
|
const core_1 = require("@aeriajs/core");
|
|
6
6
|
const authentication_js_1 = require("../../authentication.js");
|
|
@@ -9,6 +9,36 @@ exports.ActivationError = {
|
|
|
9
9
|
AlreadyActiveUser: 'ALREADY_ACTIVE_USER',
|
|
10
10
|
InvalidLink: 'INVALID_LINK',
|
|
11
11
|
};
|
|
12
|
+
exports.getCurrentUserContract = (0, types_1.defineContract)({
|
|
13
|
+
response: [
|
|
14
|
+
(0, types_1.resultSchema)({
|
|
15
|
+
$ref: 'user',
|
|
16
|
+
}),
|
|
17
|
+
(0, types_1.resultSchema)({
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
_id: {
|
|
21
|
+
const: null,
|
|
22
|
+
},
|
|
23
|
+
name: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
},
|
|
26
|
+
email: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
},
|
|
29
|
+
roles: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
items: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
active: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
});
|
|
12
42
|
const getCurrentUser = async (_payload, context) => {
|
|
13
43
|
if (!context.token.authenticated) {
|
|
14
44
|
throw new Error();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import { Result } from "@aeriajs/types";
|
|
2
|
+
import { Result, defineContract, resultSchema } from "@aeriajs/types";
|
|
3
3
|
import { get } from "@aeriajs/core";
|
|
4
4
|
import { defaultSuccessfulAuthentication } from "../../authentication.mjs";
|
|
5
5
|
export const ActivationError = {
|
|
@@ -7,6 +7,36 @@ export const ActivationError = {
|
|
|
7
7
|
AlreadyActiveUser: "ALREADY_ACTIVE_USER",
|
|
8
8
|
InvalidLink: "INVALID_LINK"
|
|
9
9
|
};
|
|
10
|
+
export const getCurrentUserContract = defineContract({
|
|
11
|
+
response: [
|
|
12
|
+
resultSchema({
|
|
13
|
+
$ref: "user"
|
|
14
|
+
}),
|
|
15
|
+
resultSchema({
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
_id: {
|
|
19
|
+
const: null
|
|
20
|
+
},
|
|
21
|
+
name: {
|
|
22
|
+
type: "string"
|
|
23
|
+
},
|
|
24
|
+
email: {
|
|
25
|
+
type: "string"
|
|
26
|
+
},
|
|
27
|
+
roles: {
|
|
28
|
+
type: "array",
|
|
29
|
+
items: {
|
|
30
|
+
type: "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
active: {
|
|
34
|
+
type: "boolean"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
});
|
|
10
40
|
export const getCurrentUser = async (_payload, context) => {
|
|
11
41
|
if (!context.token.authenticated) {
|
|
12
42
|
throw new Error();
|
|
@@ -1,33 +1,78 @@
|
|
|
1
|
-
import type { Context } from '@aeriajs/types';
|
|
2
|
-
import type
|
|
3
|
-
import { Result } from '@aeriajs/types';
|
|
1
|
+
import type { Context, ContractToFunction } from '@aeriajs/types';
|
|
2
|
+
import { type description } from './description.js';
|
|
4
3
|
export declare const ActivationError: {
|
|
5
4
|
readonly UserNotFound: "USER_NOT_FOUND";
|
|
6
5
|
readonly AlreadyActiveUser: "ALREADY_ACTIVE_USER";
|
|
7
6
|
readonly InvalidLink: "INVALID_LINK";
|
|
8
7
|
readonly InvalidToken: "INVALID_TOKEN";
|
|
9
8
|
};
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
readonly code: "INVALID_TOKEN";
|
|
23
|
-
} & {
|
|
24
|
-
httpStatus: 401;
|
|
25
|
-
}> | {
|
|
26
|
-
readonly _tag: "Result";
|
|
27
|
-
readonly error: undefined;
|
|
28
|
-
readonly result: {
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly email: string;
|
|
31
|
-
readonly active: boolean | undefined;
|
|
9
|
+
export declare const getInfoContract: {
|
|
10
|
+
readonly payload: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly required: readonly [];
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly userId: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
};
|
|
17
|
+
readonly token: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
32
21
|
};
|
|
33
|
-
|
|
22
|
+
readonly response: [{
|
|
23
|
+
readonly type: "object";
|
|
24
|
+
readonly properties: {
|
|
25
|
+
readonly _tag: {
|
|
26
|
+
readonly const: "Error";
|
|
27
|
+
};
|
|
28
|
+
readonly result: {
|
|
29
|
+
readonly const: undefined;
|
|
30
|
+
};
|
|
31
|
+
readonly error: {
|
|
32
|
+
readonly type: "object";
|
|
33
|
+
readonly required: readonly ["httpStatus", "code"];
|
|
34
|
+
readonly properties: {
|
|
35
|
+
readonly httpStatus: {
|
|
36
|
+
readonly enum: [404, 401, 422];
|
|
37
|
+
};
|
|
38
|
+
readonly code: {
|
|
39
|
+
readonly enum: ["INVALID_LINK", "INVALID_TOKEN", "USER_NOT_FOUND"];
|
|
40
|
+
};
|
|
41
|
+
readonly message: {
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
};
|
|
44
|
+
readonly details: {
|
|
45
|
+
readonly type: "object";
|
|
46
|
+
readonly additionalProperties: true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}, {
|
|
52
|
+
readonly type: "object";
|
|
53
|
+
readonly properties: {
|
|
54
|
+
readonly _tag: {
|
|
55
|
+
readonly const: "Result";
|
|
56
|
+
};
|
|
57
|
+
readonly error: {
|
|
58
|
+
readonly const: undefined;
|
|
59
|
+
};
|
|
60
|
+
readonly result: {
|
|
61
|
+
readonly type: "object";
|
|
62
|
+
readonly required: readonly ["name", "email"];
|
|
63
|
+
readonly properties: {
|
|
64
|
+
readonly name: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
};
|
|
67
|
+
readonly email: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
};
|
|
70
|
+
readonly active: {
|
|
71
|
+
readonly type: "boolean";
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
}];
|
|
77
|
+
};
|
|
78
|
+
export declare const getInfo: ContractToFunction<typeof getInfoContract, Context<typeof description>>;
|