@aeriajs/builtins 0.0.176 → 0.0.178
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/insert.js +2 -2
- package/dist/collections/file/insert.mjs +2 -2
- package/dist/collections/log/index.d.ts +1 -1
- package/dist/collections/user/getActivationLink.d.ts +1 -1
- package/dist/collections/user/index.d.ts +2 -2
- package/dist/functions/describe.d.ts +6 -30
- package/dist/functions/describe.js +1 -0
- package/dist/functions/describe.mjs +2 -1
- package/dist/index.d.ts +3 -3
- package/package.json +6 -6
|
@@ -8,7 +8,7 @@ const insert = async (payload, context) => {
|
|
|
8
8
|
if (!context.token.authenticated) {
|
|
9
9
|
throw new Error('');
|
|
10
10
|
}
|
|
11
|
-
const what = Object.assign({}, payload.what);
|
|
11
|
+
const { content, ...what } = Object.assign({}, payload.what);
|
|
12
12
|
what.owner = context.token.sub;
|
|
13
13
|
const extension = what.name.split('.').at(-1);
|
|
14
14
|
if (!context.config.storage) {
|
|
@@ -35,7 +35,7 @@ const insert = async (payload, context) => {
|
|
|
35
35
|
.update(what.name + Date.now())
|
|
36
36
|
.digest('hex');
|
|
37
37
|
what.absolute_path = `${tempPath}/${filenameHash}.${extension}`;
|
|
38
|
-
await (0, promises_1.writeFile)(what.absolute_path, Buffer.from(
|
|
38
|
+
await (0, promises_1.writeFile)(what.absolute_path, Buffer.from(content.split(',').at(-1), 'base64'));
|
|
39
39
|
return (0, core_1.insert)({
|
|
40
40
|
...payload,
|
|
41
41
|
what,
|
|
@@ -6,7 +6,7 @@ export const insert = async (payload, context) => {
|
|
|
6
6
|
if (!context.token.authenticated) {
|
|
7
7
|
throw new Error("");
|
|
8
8
|
}
|
|
9
|
-
const what = Object.assign({}, payload.what);
|
|
9
|
+
const { content, ...what } = Object.assign({}, payload.what);
|
|
10
10
|
what.owner = context.token.sub;
|
|
11
11
|
const extension = what.name.split(".").at(-1);
|
|
12
12
|
if (!context.config.storage) {
|
|
@@ -34,7 +34,7 @@ export const insert = async (payload, context) => {
|
|
|
34
34
|
}
|
|
35
35
|
const filenameHash = createHash("sha1").update(what.name + Date.now()).digest("hex");
|
|
36
36
|
what.absolute_path = `${tempPath}/${filenameHash}.${extension}`;
|
|
37
|
-
await writeFile(what.absolute_path, Buffer.from(
|
|
37
|
+
await writeFile(what.absolute_path, Buffer.from(content.split(",").at(-1), "base64"));
|
|
38
38
|
return originalInsert({
|
|
39
39
|
...payload,
|
|
40
40
|
what
|
|
@@ -55,7 +55,7 @@ export declare const log: Omit<import("@aeriajs/types").Collection<never>, "func
|
|
|
55
55
|
};
|
|
56
56
|
functions: {
|
|
57
57
|
get: (payload: import("@aeriajs/types").GetPayload<import("@aeriajs/types").SchemaWithId<any>>, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").GetOptions) => Promise<import("@aeriajs/types").GetReturnType<import("@aeriajs/types").SchemaWithId<any>>>;
|
|
58
|
-
getAll: (payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<any>> | undefined, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").
|
|
58
|
+
getAll: (payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<any>> | undefined, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").GetAllReturnType<import("@aeriajs/types").SchemaWithId<any>>>;
|
|
59
59
|
insert: (payload: import("@aeriajs/types").InsertPayload<import("@aeriajs/types").SchemaWithId<any>>, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").InsertOptions) => Promise<import("@aeriajs/types").InsertReturnType<import("@aeriajs/types").SchemaWithId<any>>>;
|
|
60
60
|
};
|
|
61
61
|
contracts: {
|
|
@@ -7,7 +7,7 @@ export declare const getActivationLink: (payload: {
|
|
|
7
7
|
userId: ObjectId | string;
|
|
8
8
|
}, context: Context) => Promise<{
|
|
9
9
|
readonly _tag: "Error";
|
|
10
|
-
readonly error: import("@aeriajs/types").
|
|
10
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, HTTPStatus.BadRequest | HTTPStatus.Forbidden | HTTPStatus.NotFound>;
|
|
11
11
|
readonly result: undefined;
|
|
12
12
|
} | Result.Error<{
|
|
13
13
|
readonly code: ActivationError.AlreadyActiveUser;
|
|
@@ -205,7 +205,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
205
205
|
};
|
|
206
206
|
functions: {
|
|
207
207
|
get: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").GetPayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>>, context: TContext, options?: import("@aeriajs/core").GetOptions) => Promise<import("@aeriajs/types").GetReturnType<import("@aeriajs/types").SchemaWithId<TContext["description"]>>>;
|
|
208
|
-
getAll: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").
|
|
208
|
+
getAll: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").GetAllReturnType<import("@aeriajs/types").SchemaWithId<TContext["description"]>>>;
|
|
209
209
|
remove: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").RemovePayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>>, context: TContext, options?: import("@aeriajs/core").RemoveOptions) => Promise<{
|
|
210
210
|
readonly _tag: "Result";
|
|
211
211
|
readonly error: undefined;
|
|
@@ -557,7 +557,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
557
557
|
userId: import("@aeriajs/core").ObjectId | string;
|
|
558
558
|
}, context: import("@aeriajs/types").Context) => Promise<{
|
|
559
559
|
readonly _tag: "Error";
|
|
560
|
-
readonly error: import("@aeriajs/types").
|
|
560
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
561
561
|
readonly result: undefined;
|
|
562
562
|
} | import("@aeriajs/types").Result.Error<{
|
|
563
563
|
readonly code: import("./activate.js").ActivationError.AlreadyActiveUser;
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import type { Description, RouteContext } from '@aeriajs/types';
|
|
2
|
-
import { Result, ACError } from '@aeriajs/types';
|
|
2
|
+
import { Result, ACError, HTTPStatus } from '@aeriajs/types';
|
|
3
3
|
import { authenticate } from '../collections/user/authenticate.js';
|
|
4
|
-
declare const Payload:
|
|
5
|
-
readonly collections: {
|
|
6
|
-
readonly type: "array";
|
|
7
|
-
readonly items: {
|
|
8
|
-
readonly type: "string";
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
readonly noSerialize: {
|
|
12
|
-
readonly type: "boolean";
|
|
13
|
-
};
|
|
14
|
-
readonly revalidate: {
|
|
15
|
-
readonly type: "boolean";
|
|
16
|
-
};
|
|
17
|
-
readonly roles: {
|
|
18
|
-
readonly type: "boolean";
|
|
19
|
-
};
|
|
20
|
-
readonly router: {
|
|
21
|
-
readonly type: "boolean";
|
|
22
|
-
};
|
|
23
|
-
}>> & {
|
|
24
|
-
roles: boolean;
|
|
25
|
-
revalidate: boolean;
|
|
26
|
-
collections: string[];
|
|
27
|
-
noSerialize: boolean;
|
|
28
|
-
router: boolean;
|
|
29
|
-
}, never>, never> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
4
|
+
declare const Payload: Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
30
5
|
readonly collections: {
|
|
31
6
|
readonly type: "array";
|
|
32
7
|
readonly items: {
|
|
@@ -55,6 +30,7 @@ declare const Payload: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterRe
|
|
|
55
30
|
export declare const describe: (contextOrPayload: RouteContext | typeof Payload) => Promise<import("@aeriajs/types").GenericResponse | {
|
|
56
31
|
readonly _tag: "Error";
|
|
57
32
|
readonly error: {
|
|
33
|
+
readonly httpStatus: HTTPStatus.UnprocessableContent;
|
|
58
34
|
readonly code: ACError.MalformedInput;
|
|
59
35
|
readonly details: import("@aeriajs/types").PropertyValidationError | import("@aeriajs/types").ValidationError;
|
|
60
36
|
};
|
|
@@ -64,15 +40,15 @@ export declare const describe: (contextOrPayload: RouteContext | typeof Payload)
|
|
|
64
40
|
readonly error: ({
|
|
65
41
|
readonly code: ACError.AuthorizationError;
|
|
66
42
|
} & {
|
|
67
|
-
httpStatus:
|
|
43
|
+
httpStatus: HTTPStatus.Unauthorized;
|
|
68
44
|
}) | ({
|
|
69
45
|
readonly code: import("../authentication.js").AuthenticationError.InvalidCredentials;
|
|
70
46
|
} & {
|
|
71
|
-
httpStatus:
|
|
47
|
+
httpStatus: HTTPStatus.Unauthorized;
|
|
72
48
|
}) | ({
|
|
73
49
|
readonly code: import("../authentication.js").AuthenticationError.InactiveUser;
|
|
74
50
|
} & {
|
|
75
|
-
httpStatus:
|
|
51
|
+
httpStatus: HTTPStatus.Unauthorized;
|
|
76
52
|
});
|
|
77
53
|
readonly result: undefined;
|
|
78
54
|
} | {
|
|
@@ -39,6 +39,7 @@ const describe = async (contextOrPayload) => {
|
|
|
39
39
|
const { error, result: validatedPayload } = validatePayload(contextOrPayload.request.payload);
|
|
40
40
|
if (error) {
|
|
41
41
|
return (0, common_1.endpointError)({
|
|
42
|
+
httpStatus: types_1.HTTPStatus.UnprocessableContent,
|
|
42
43
|
code: types_1.ACError.MalformedInput,
|
|
43
44
|
details: error,
|
|
44
45
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { createContext, preloadDescription, getEndpoints, isValidCollection } from "@aeriajs/core";
|
|
3
3
|
import { getCollections, getAvailableRoles } from "@aeriajs/entrypoint";
|
|
4
|
-
import { Result, ACError } from "@aeriajs/types";
|
|
4
|
+
import { Result, ACError, HTTPStatus } from "@aeriajs/types";
|
|
5
5
|
import { serialize, endpointError } from "@aeriajs/common";
|
|
6
6
|
import { validator } from "@aeriajs/validation";
|
|
7
7
|
import { authenticate } from "../collections/user/authenticate.mjs";
|
|
@@ -37,6 +37,7 @@ export const describe = async (contextOrPayload) => {
|
|
|
37
37
|
const { error, result: validatedPayload } = validatePayload(contextOrPayload.request.payload);
|
|
38
38
|
if (error) {
|
|
39
39
|
return endpointError({
|
|
40
|
+
httpStatus: HTTPStatus.UnprocessableContent,
|
|
40
41
|
code: ACError.MalformedInput,
|
|
41
42
|
details: error
|
|
42
43
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -336,7 +336,7 @@ export declare const collections: {
|
|
|
336
336
|
};
|
|
337
337
|
functions: {
|
|
338
338
|
get: (payload: import("@aeriajs/types").GetPayload<import("@aeriajs/types").SchemaWithId<any>>, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").GetOptions) => Promise<import("@aeriajs/types").GetReturnType<import("@aeriajs/types").SchemaWithId<any>>>;
|
|
339
|
-
getAll: (payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<any>> | undefined, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").
|
|
339
|
+
getAll: (payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<any>> | undefined, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").GetAllReturnType<import("@aeriajs/types").SchemaWithId<any>>>;
|
|
340
340
|
insert: (payload: import("@aeriajs/types").InsertPayload<import("@aeriajs/types").SchemaWithId<any>>, context: import("@aeriajs/types").StrictContext<any>, options?: import("@aeriajs/core").InsertOptions) => Promise<import("@aeriajs/types").InsertReturnType<import("@aeriajs/types").SchemaWithId<any>>>;
|
|
341
341
|
};
|
|
342
342
|
contracts: {
|
|
@@ -626,7 +626,7 @@ export declare const collections: {
|
|
|
626
626
|
};
|
|
627
627
|
functions: {
|
|
628
628
|
get: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").GetPayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>>, context: TContext, options?: import("@aeriajs/core").GetOptions) => Promise<import("@aeriajs/types").GetReturnType<import("@aeriajs/types").SchemaWithId<TContext["description"]>>>;
|
|
629
|
-
getAll: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").
|
|
629
|
+
getAll: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").GetAllPayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: import("@aeriajs/core").GetAllOptions) => Promise<import("@aeriajs/types").GetAllReturnType<import("@aeriajs/types").SchemaWithId<TContext["description"]>>>;
|
|
630
630
|
remove: <TContext extends import("@aeriajs/types").Context>(payload: import("@aeriajs/types").RemovePayload<import("@aeriajs/types").SchemaWithId<TContext["description"]>>, context: TContext, options?: import("@aeriajs/core").RemoveOptions) => Promise<{
|
|
631
631
|
readonly _tag: "Result";
|
|
632
632
|
readonly error: undefined;
|
|
@@ -978,7 +978,7 @@ export declare const collections: {
|
|
|
978
978
|
userId: import("mongodb").ObjectId | string;
|
|
979
979
|
}, context: import("@aeriajs/types").Context) => Promise<{
|
|
980
980
|
readonly _tag: "Error";
|
|
981
|
-
readonly error: import("@aeriajs/types").
|
|
981
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
982
982
|
readonly result: undefined;
|
|
983
983
|
} | import("@aeriajs/types").Result.Error<{
|
|
984
984
|
readonly code: import("./collections/user/activate.js").ActivationError.AlreadyActiveUser;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/builtins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.178",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"mongodb": "^6.5.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@aeriajs/core": "^0.0.
|
|
49
|
-
"@aeriajs/common": "^0.0.
|
|
50
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
51
|
-
"@aeriajs/types": "^0.0.
|
|
52
|
-
"@aeriajs/validation": "^0.0.
|
|
48
|
+
"@aeriajs/core": "^0.0.178",
|
|
49
|
+
"@aeriajs/common": "^0.0.108",
|
|
50
|
+
"@aeriajs/entrypoint": "^0.0.111",
|
|
51
|
+
"@aeriajs/types": "^0.0.91",
|
|
52
|
+
"@aeriajs/validation": "^0.0.111"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"test": "echo skipping",
|