@aeriajs/builtins 0.0.88 → 0.0.89
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 +6 -5
- package/dist/collections/file/download.js +8 -9
- package/dist/collections/file/download.mjs +7 -8
- package/dist/collections/file/index.d.ts +14 -6
- package/dist/collections/file/insert.d.ts +1 -1
- package/dist/collections/log/index.d.ts +6 -6
- package/dist/collections/user/activate.d.ts +15 -2
- package/dist/collections/user/activate.js +21 -13
- package/dist/collections/user/activate.mjs +20 -12
- package/dist/collections/user/authenticate.d.ts +17 -5
- package/dist/collections/user/authenticate.js +26 -18
- package/dist/collections/user/authenticate.mjs +23 -15
- package/dist/collections/user/createAccount.d.ts +1 -1
- package/dist/collections/user/createAccount.js +2 -2
- package/dist/collections/user/createAccount.mjs +3 -3
- package/dist/collections/user/getCurrentUser.d.ts +4 -4
- package/dist/collections/user/getCurrentUser.js +10 -10
- package/dist/collections/user/getCurrentUser.mjs +10 -10
- package/dist/collections/user/getInfo.d.ts +18 -5
- package/dist/collections/user/getInfo.js +22 -14
- package/dist/collections/user/getInfo.mjs +21 -13
- package/dist/collections/user/index.d.ts +106 -62
- package/dist/collections/user/index.js +3 -10
- package/dist/collections/user/index.mjs +3 -10
- package/dist/collections/user/insert.d.ts +1 -1
- package/dist/functions/describe.d.ts +124 -113
- package/dist/functions/describe.js +3 -5
- package/dist/functions/describe.mjs +4 -6
- package/dist/index.d.ts +126 -74
- package/package.json +6 -6
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { RouteContext } from '@aeriajs/types';
|
|
2
|
-
import type { Description } from '@aeriajs/types';
|
|
1
|
+
import type { Description, RouteContext } from '@aeriajs/types';
|
|
3
2
|
type Payload = {
|
|
4
3
|
collections?: string[];
|
|
5
4
|
noSerialize?: boolean;
|
|
@@ -7,126 +6,138 @@ type Payload = {
|
|
|
7
6
|
revalidate?: boolean;
|
|
8
7
|
router?: boolean;
|
|
9
8
|
};
|
|
10
|
-
export declare const describe: (contextOrPayload: RouteContext | Payload) => Promise<import("@aeriajs/types").GenericResponse |
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
readonly
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
readonly roles: {
|
|
36
|
-
readonly type: "array";
|
|
37
|
-
readonly items: {
|
|
38
|
-
readonly type: "string";
|
|
39
|
-
};
|
|
40
|
-
readonly uniqueItems: true;
|
|
41
|
-
};
|
|
42
|
-
readonly email: {
|
|
43
|
-
readonly type: "string";
|
|
44
|
-
readonly inputType: "email";
|
|
45
|
-
readonly unique: true;
|
|
46
|
-
};
|
|
47
|
-
readonly password: {
|
|
48
|
-
readonly type: "string";
|
|
49
|
-
readonly inputType: "password";
|
|
50
|
-
readonly hidden: true;
|
|
51
|
-
};
|
|
52
|
-
readonly phone_number: {
|
|
53
|
-
readonly type: "string";
|
|
54
|
-
readonly mask: "(##) #####-####";
|
|
55
|
-
};
|
|
56
|
-
readonly picture_file: {
|
|
57
|
-
readonly $ref: "file";
|
|
58
|
-
readonly accept: readonly ["image/*"];
|
|
59
|
-
};
|
|
60
|
-
readonly picture: {
|
|
61
|
-
readonly getter: (value: any) => any;
|
|
62
|
-
};
|
|
63
|
-
readonly group: {
|
|
64
|
-
readonly type: "string";
|
|
65
|
-
};
|
|
66
|
-
readonly self_registered: {
|
|
67
|
-
readonly type: "boolean";
|
|
68
|
-
readonly readOnly: true;
|
|
69
|
-
};
|
|
70
|
-
readonly updated_at: {
|
|
9
|
+
export declare const describe: (contextOrPayload: RouteContext | Payload) => Promise<import("@aeriajs/types").GenericResponse | (({
|
|
10
|
+
user: Pick<import("@aeriajs/types").SchemaWithId<{
|
|
11
|
+
readonly $id: "user";
|
|
12
|
+
readonly required: readonly ["name", "roles", "email"];
|
|
13
|
+
readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
|
|
14
|
+
readonly indexes: readonly ["name"];
|
|
15
|
+
readonly freshItem: {
|
|
16
|
+
readonly active: true;
|
|
17
|
+
};
|
|
18
|
+
readonly properties: {
|
|
19
|
+
readonly name: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
};
|
|
22
|
+
readonly given_name: {
|
|
23
|
+
readonly getter: (document: any) => string;
|
|
24
|
+
};
|
|
25
|
+
readonly family_name: {
|
|
26
|
+
readonly getter: (document: any) => string;
|
|
27
|
+
};
|
|
28
|
+
readonly active: {
|
|
29
|
+
readonly type: "boolean";
|
|
30
|
+
};
|
|
31
|
+
readonly roles: {
|
|
32
|
+
readonly type: "array";
|
|
33
|
+
readonly items: {
|
|
71
34
|
readonly type: "string";
|
|
72
|
-
readonly format: "date-time";
|
|
73
35
|
};
|
|
36
|
+
readonly uniqueItems: true;
|
|
74
37
|
};
|
|
75
|
-
readonly
|
|
76
|
-
|
|
77
|
-
readonly
|
|
78
|
-
readonly
|
|
79
|
-
readonly title: "name";
|
|
80
|
-
readonly badge: "roles";
|
|
81
|
-
readonly picture: "picture_file";
|
|
82
|
-
readonly information: "email";
|
|
83
|
-
readonly active: "active";
|
|
84
|
-
};
|
|
38
|
+
readonly email: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly inputType: "email";
|
|
41
|
+
readonly unique: true;
|
|
85
42
|
};
|
|
86
|
-
readonly
|
|
87
|
-
readonly
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
readonly translate: true;
|
|
91
|
-
};
|
|
92
|
-
readonly 'route:/dashboard/user/changepass': {
|
|
93
|
-
readonly label: "change_password";
|
|
94
|
-
readonly icon: "key";
|
|
95
|
-
readonly fetchItem: true;
|
|
96
|
-
readonly translate: true;
|
|
97
|
-
};
|
|
43
|
+
readonly password: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly inputType: "password";
|
|
46
|
+
readonly hidden: true;
|
|
98
47
|
};
|
|
99
|
-
readonly
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
readonly
|
|
104
|
-
readonly
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
48
|
+
readonly phone_number: {
|
|
49
|
+
readonly type: "string";
|
|
50
|
+
readonly mask: "(##) #####-####";
|
|
51
|
+
};
|
|
52
|
+
readonly picture_file: {
|
|
53
|
+
readonly $ref: "file";
|
|
54
|
+
readonly accept: readonly ["image/*"];
|
|
55
|
+
};
|
|
56
|
+
readonly picture: {
|
|
57
|
+
readonly getter: (value: any) => any;
|
|
58
|
+
};
|
|
59
|
+
readonly group: {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
};
|
|
62
|
+
readonly self_registered: {
|
|
63
|
+
readonly type: "boolean";
|
|
64
|
+
readonly readOnly: true;
|
|
65
|
+
};
|
|
66
|
+
readonly updated_at: {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
readonly format: "date-time";
|
|
112
69
|
};
|
|
113
|
-
}>, "name" | "roles" | "email" | "active"> & {
|
|
114
|
-
_id: import("@aeriajs/core").ObjectId | null;
|
|
115
70
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
71
|
+
readonly presets: readonly ["crud", "view", "duplicate"];
|
|
72
|
+
readonly layout: {
|
|
73
|
+
readonly name: "grid";
|
|
74
|
+
readonly options: {
|
|
75
|
+
readonly title: "name";
|
|
76
|
+
readonly badge: "roles";
|
|
77
|
+
readonly picture: "picture_file";
|
|
78
|
+
readonly information: "email";
|
|
79
|
+
readonly active: "active";
|
|
80
|
+
};
|
|
124
81
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
82
|
+
readonly individualActions: {
|
|
83
|
+
readonly 'ui:spawnEdit': {
|
|
84
|
+
readonly label: "action.edit";
|
|
85
|
+
readonly icon: "pencil";
|
|
86
|
+
readonly translate: true;
|
|
87
|
+
};
|
|
88
|
+
readonly 'route:/dashboard/user/changepass': {
|
|
89
|
+
readonly label: "change_password";
|
|
90
|
+
readonly icon: "key";
|
|
91
|
+
readonly fetchItem: true;
|
|
92
|
+
readonly translate: true;
|
|
93
|
+
};
|
|
128
94
|
};
|
|
129
|
-
|
|
95
|
+
readonly icon: "users";
|
|
96
|
+
readonly filters: readonly ["name", "roles", "email", "phone_number"];
|
|
97
|
+
readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
|
|
98
|
+
readonly tableMeta: readonly ["email"];
|
|
99
|
+
readonly formLayout: {
|
|
100
|
+
readonly fields: {
|
|
101
|
+
readonly given_name: {
|
|
102
|
+
readonly span: 3;
|
|
103
|
+
};
|
|
104
|
+
readonly family_name: {
|
|
105
|
+
readonly span: 3;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
}>, "name" | "roles" | "email" | "active"> & {
|
|
110
|
+
_id: import("@aeriajs/core").ObjectId | null;
|
|
111
|
+
};
|
|
112
|
+
token: import("@aeriajs/types").TokenRecipient;
|
|
113
|
+
} | import("@aeriajs/types").EndpointError<{
|
|
114
|
+
readonly code: import("@aeriajs/types").ACError.AuthorizationError;
|
|
115
|
+
} & {
|
|
116
|
+
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
117
|
+
}> | {
|
|
118
|
+
user: {
|
|
119
|
+
_id: null;
|
|
120
|
+
name: string;
|
|
121
|
+
email: string;
|
|
122
|
+
roles: string[];
|
|
123
|
+
active: boolean;
|
|
124
|
+
};
|
|
125
|
+
token: {
|
|
126
|
+
type: string;
|
|
127
|
+
content: string;
|
|
128
|
+
};
|
|
129
|
+
} | import("@aeriajs/types").EndpointError<{
|
|
130
|
+
readonly code: import("../collections/user/authenticate.js").AuthenticationError.InvalidCredentials;
|
|
131
|
+
} & {
|
|
132
|
+
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
133
|
+
}> | import("@aeriajs/types").EndpointError<{
|
|
134
|
+
readonly code: import("../collections/user/authenticate.js").AuthenticationError.InactiveUser;
|
|
135
|
+
} & {
|
|
136
|
+
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
137
|
+
}>) & import("@aeriajs/types").EndpointError<import("@aeriajs/types").EndpointErrorContent>) | {
|
|
138
|
+
descriptions: Record<string, Description>;
|
|
139
|
+
roles?: string[] | undefined;
|
|
140
|
+
auth?: undefined;
|
|
130
141
|
router?: any;
|
|
131
142
|
}>;
|
|
132
143
|
export {};
|
|
@@ -11,17 +11,15 @@ const describe = async (contextOrPayload) => {
|
|
|
11
11
|
? contextOrPayload.request.payload
|
|
12
12
|
: contextOrPayload;
|
|
13
13
|
if ('request' in contextOrPayload && props.revalidate) {
|
|
14
|
-
const
|
|
14
|
+
const auth = await (0, authenticate_js_1.authenticate)({
|
|
15
15
|
revalidate: true,
|
|
16
16
|
}, await (0, core_1.createContext)({
|
|
17
17
|
collectionName: 'user',
|
|
18
18
|
parentContext: contextOrPayload,
|
|
19
19
|
}));
|
|
20
|
-
if ((0, common_1.
|
|
21
|
-
|
|
22
|
-
return (0, common_1.left)(error);
|
|
20
|
+
if ((0, common_1.isError)(auth)) {
|
|
21
|
+
return auth;
|
|
23
22
|
}
|
|
24
|
-
const auth = (0, common_1.unwrapEither)(authEither);
|
|
25
23
|
result.auth = JSON.parse(JSON.stringify(auth));
|
|
26
24
|
}
|
|
27
25
|
const collections = await (0, entrypoint_1.getCollections)();
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { createContext, preloadDescription, getEndpoints } from "@aeriajs/core";
|
|
3
3
|
import { getCollections, getAvailableRoles } from "@aeriajs/entrypoint";
|
|
4
|
-
import { serialize,
|
|
4
|
+
import { serialize, isError } from "@aeriajs/common";
|
|
5
5
|
import { authenticate } from "../collections/user/authenticate.mjs";
|
|
6
6
|
export const describe = async (contextOrPayload) => {
|
|
7
7
|
const result = {};
|
|
8
8
|
const props = "request" in contextOrPayload ? contextOrPayload.request.payload : contextOrPayload;
|
|
9
9
|
if ("request" in contextOrPayload && props.revalidate) {
|
|
10
|
-
const
|
|
10
|
+
const auth = await authenticate({
|
|
11
11
|
revalidate: true
|
|
12
12
|
}, await createContext({
|
|
13
13
|
collectionName: "user",
|
|
14
14
|
parentContext: contextOrPayload
|
|
15
15
|
}));
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
return left(error);
|
|
16
|
+
if (isError(auth)) {
|
|
17
|
+
return auth;
|
|
19
18
|
}
|
|
20
|
-
const auth = unwrapEither(authEither);
|
|
21
19
|
result.auth = JSON.parse(JSON.stringify(auth));
|
|
22
20
|
}
|
|
23
21
|
const collections = await getCollections();
|