@aeriajs/builtins 0.0.95 → 0.0.97
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 +1 -1
- package/dist/collections/file/index.d.ts +4 -4
- package/dist/collections/log/index.d.ts +12 -4
- package/dist/collections/user/activate.d.ts +3 -3
- package/dist/collections/user/authenticate.d.ts +17 -13
- package/dist/collections/user/authenticate.js +7 -7
- package/dist/collections/user/authenticate.mjs +6 -6
- package/dist/collections/user/createAccount.js +3 -4
- package/dist/collections/user/createAccount.mjs +3 -4
- package/dist/collections/user/getCurrentUser.d.ts +2 -2
- package/dist/collections/user/getCurrentUser.js +3 -5
- package/dist/collections/user/getCurrentUser.mjs +3 -5
- package/dist/collections/user/getInfo.d.ts +3 -3
- package/dist/collections/user/index.d.ts +266 -256
- package/dist/functions/describe.d.ts +18 -14
- package/dist/functions/describe.js +3 -3
- package/dist/functions/describe.mjs +4 -4
- package/dist/index.d.ts +280 -262
- package/package.json +6 -6
|
@@ -6,22 +6,26 @@ type Payload = {
|
|
|
6
6
|
revalidate?: boolean;
|
|
7
7
|
router?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export declare const describe: (contextOrPayload: RouteContext | Payload) => Promise<import("@aeriajs/types").GenericResponse |
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
9
|
+
export declare const describe: (contextOrPayload: RouteContext | Payload) => Promise<import("@aeriajs/types").GenericResponse | {
|
|
10
|
+
readonly _tag: "Error";
|
|
11
|
+
readonly error: ({
|
|
12
|
+
readonly code: import("@aeriajs/types").ACError.AuthorizationError;
|
|
13
|
+
} & {
|
|
14
|
+
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
15
|
+
}) | ({
|
|
16
|
+
readonly code: import("../collections/user/authenticate.js").AuthenticationError.InvalidCredentials;
|
|
17
|
+
} & {
|
|
18
|
+
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
19
|
+
}) | ({
|
|
20
|
+
readonly code: import("../collections/user/authenticate.js").AuthenticationError.InactiveUser;
|
|
21
|
+
} & {
|
|
22
|
+
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
23
|
+
});
|
|
24
|
+
readonly result: undefined;
|
|
25
|
+
} | {
|
|
22
26
|
descriptions: Record<string, Description>;
|
|
23
27
|
roles?: string[] | undefined;
|
|
24
|
-
auth?: undefined;
|
|
28
|
+
auth?: Partial<unknown> | undefined;
|
|
25
29
|
router?: any;
|
|
26
30
|
}>;
|
|
27
31
|
export {};
|
|
@@ -11,14 +11,14 @@ const describe = async (contextOrPayload) => {
|
|
|
11
11
|
? contextOrPayload.request.payload
|
|
12
12
|
: contextOrPayload;
|
|
13
13
|
if ('request' in contextOrPayload && props.revalidate) {
|
|
14
|
-
const auth = await (0, authenticate_js_1.authenticate)({
|
|
14
|
+
const { error, result: 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 (
|
|
21
|
-
return
|
|
20
|
+
if (error) {
|
|
21
|
+
return common_1.Result.error(error);
|
|
22
22
|
}
|
|
23
23
|
result.auth = JSON.parse(JSON.stringify(auth));
|
|
24
24
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
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, Result } 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 auth = await authenticate({
|
|
10
|
+
const { error, result: auth } = await authenticate({
|
|
11
11
|
revalidate: true
|
|
12
12
|
}, await createContext({
|
|
13
13
|
collectionName: "user",
|
|
14
14
|
parentContext: contextOrPayload
|
|
15
15
|
}));
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
16
|
+
if (error) {
|
|
17
|
+
return Result.error(error);
|
|
18
18
|
}
|
|
19
19
|
result.auth = JSON.parse(JSON.stringify(auth));
|
|
20
20
|
}
|