@aeriajs/server 0.0.166 → 0.0.168
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/handler.js +6 -7
- package/dist/handler.mjs +6 -7
- package/dist/init.d.ts +101 -1
- package/dist/init.js +2 -2
- package/dist/init.mjs +3 -3
- package/dist/routes.d.ts +2 -2
- package/package.json +9 -9
package/dist/handler.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.regularVerb = exports.customVerbs = exports.safeHandle = void 0;
|
|
4
4
|
const core_1 = require("@aeriajs/core");
|
|
5
5
|
const entrypoint_1 = require("@aeriajs/entrypoint");
|
|
6
|
-
const http_1 = require("@aeriajs/http");
|
|
7
6
|
const types_1 = require("@aeriajs/types");
|
|
8
7
|
const common_1 = require("@aeriajs/common");
|
|
9
8
|
const appendPagination_js_1 = require("./appendPagination.js");
|
|
@@ -44,12 +43,12 @@ const customVerbs = () => async (parentContext) => {
|
|
|
44
43
|
const { fragments: [collectionName, functionName] } = parentContext.request;
|
|
45
44
|
const collection = await (0, entrypoint_1.getCollection)(collectionName);
|
|
46
45
|
if (!collection) {
|
|
47
|
-
return
|
|
46
|
+
return;
|
|
48
47
|
}
|
|
49
48
|
const context = await (0, core_1.createContext)({
|
|
50
|
-
|
|
51
|
-
collectionName,
|
|
49
|
+
collectionName: collectionName,
|
|
52
50
|
calledFunction: functionName,
|
|
51
|
+
parentContext,
|
|
53
52
|
});
|
|
54
53
|
const { error, result: fn } = await (0, core_1.getFunction)(collectionName, functionName, context.token, {
|
|
55
54
|
exposedOnly: true,
|
|
@@ -67,12 +66,12 @@ const regularVerb = (functionName) => async (parentContext) => {
|
|
|
67
66
|
const { fragments: [collectionName, id] } = parentContext.request;
|
|
68
67
|
const collection = await (0, entrypoint_1.getCollection)(collectionName);
|
|
69
68
|
if (!collection) {
|
|
70
|
-
return
|
|
69
|
+
return;
|
|
71
70
|
}
|
|
72
71
|
const context = await (0, core_1.createContext)({
|
|
73
|
-
|
|
74
|
-
collectionName,
|
|
72
|
+
collectionName: collectionName,
|
|
75
73
|
calledFunction: functionName,
|
|
74
|
+
parentContext,
|
|
76
75
|
});
|
|
77
76
|
const requestCopy = Object.assign({}, context.request);
|
|
78
77
|
if (id) {
|
package/dist/handler.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { createContext, getFunction } from "@aeriajs/core";
|
|
3
3
|
import { getCollection } from "@aeriajs/entrypoint";
|
|
4
|
-
import { next } from "@aeriajs/http";
|
|
5
4
|
import { ACError, HTTPStatus, Result } from "@aeriajs/types";
|
|
6
5
|
import { pipe } from "@aeriajs/common";
|
|
7
6
|
import { appendPagination } from "./appendPagination.mjs";
|
|
@@ -45,12 +44,12 @@ export const customVerbs = () => async (parentContext) => {
|
|
|
45
44
|
const { fragments: [collectionName, functionName] } = parentContext.request;
|
|
46
45
|
const collection = await getCollection(collectionName);
|
|
47
46
|
if (!collection) {
|
|
48
|
-
return
|
|
47
|
+
return;
|
|
49
48
|
}
|
|
50
49
|
const context = await createContext({
|
|
51
|
-
parentContext,
|
|
52
50
|
collectionName,
|
|
53
|
-
calledFunction: functionName
|
|
51
|
+
calledFunction: functionName,
|
|
52
|
+
parentContext
|
|
54
53
|
});
|
|
55
54
|
const { error, result: fn } = await getFunction(
|
|
56
55
|
collectionName,
|
|
@@ -72,12 +71,12 @@ export const regularVerb = (functionName) => async (parentContext) => {
|
|
|
72
71
|
const { fragments: [collectionName, id] } = parentContext.request;
|
|
73
72
|
const collection = await getCollection(collectionName);
|
|
74
73
|
if (!collection) {
|
|
75
|
-
return
|
|
74
|
+
return;
|
|
76
75
|
}
|
|
77
76
|
const context = await createContext({
|
|
78
|
-
parentContext,
|
|
79
77
|
collectionName,
|
|
80
|
-
calledFunction: functionName
|
|
78
|
+
calledFunction: functionName,
|
|
79
|
+
parentContext
|
|
81
80
|
});
|
|
82
81
|
const requestCopy = Object.assign({}, context.request);
|
|
83
82
|
if (id) {
|
package/dist/init.d.ts
CHANGED
|
@@ -15,7 +15,107 @@ export type InitOptions = {
|
|
|
15
15
|
export declare const getToken: (request: GenericRequest, context: Context) => Promise<{
|
|
16
16
|
readonly _tag: "Result";
|
|
17
17
|
readonly error: undefined;
|
|
18
|
-
readonly result: AuthenticatedToken<null
|
|
18
|
+
readonly result: import("@aeriajs/types").UnauthenticatedToken | AuthenticatedToken<null, import("@aeriajs/types").UserRole, Omit<import("@aeriajs/types").SchemaWithId<{
|
|
19
|
+
readonly $id: "user";
|
|
20
|
+
readonly icon: "users";
|
|
21
|
+
readonly required: readonly ["name", "roles", "email"];
|
|
22
|
+
readonly form: readonly ["name", "active", "roles", "email", "phone_number", "picture_file"];
|
|
23
|
+
readonly indexes: readonly ["name"];
|
|
24
|
+
readonly properties: {
|
|
25
|
+
readonly name: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
};
|
|
28
|
+
readonly given_name: {
|
|
29
|
+
readonly getter: (doc: object) => string | undefined;
|
|
30
|
+
};
|
|
31
|
+
readonly family_name: {
|
|
32
|
+
readonly getter: (doc: object) => string | undefined;
|
|
33
|
+
};
|
|
34
|
+
readonly active: {
|
|
35
|
+
readonly type: "boolean";
|
|
36
|
+
};
|
|
37
|
+
readonly roles: {
|
|
38
|
+
readonly type: "array";
|
|
39
|
+
readonly items: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
};
|
|
42
|
+
readonly uniqueItems: true;
|
|
43
|
+
readonly minItems: 1;
|
|
44
|
+
};
|
|
45
|
+
readonly email: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
readonly inputType: "email";
|
|
48
|
+
readonly unique: true;
|
|
49
|
+
};
|
|
50
|
+
readonly password: {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
readonly inputType: "password";
|
|
53
|
+
readonly hidden: true;
|
|
54
|
+
};
|
|
55
|
+
readonly phone_number: {
|
|
56
|
+
readonly type: "string";
|
|
57
|
+
readonly mask: "(##) #####-####";
|
|
58
|
+
};
|
|
59
|
+
readonly picture_file: {
|
|
60
|
+
readonly $ref: "file";
|
|
61
|
+
readonly accept: readonly ["image/*"];
|
|
62
|
+
};
|
|
63
|
+
readonly picture: {
|
|
64
|
+
readonly getter: (doc: object) => string | undefined;
|
|
65
|
+
};
|
|
66
|
+
readonly group: {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
};
|
|
69
|
+
readonly self_registered: {
|
|
70
|
+
readonly type: "boolean";
|
|
71
|
+
readonly readOnly: true;
|
|
72
|
+
};
|
|
73
|
+
readonly updated_at: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
readonly format: "date-time";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly presets: readonly ["crud", "duplicate"];
|
|
79
|
+
readonly layout: {
|
|
80
|
+
readonly name: "grid";
|
|
81
|
+
readonly options: {
|
|
82
|
+
readonly title: "name";
|
|
83
|
+
readonly badge: "roles";
|
|
84
|
+
readonly picture: "picture_file";
|
|
85
|
+
readonly information: "email";
|
|
86
|
+
readonly active: "active";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
readonly individualActions: {
|
|
90
|
+
readonly changePassword: {
|
|
91
|
+
readonly label: "change_password";
|
|
92
|
+
readonly icon: "key";
|
|
93
|
+
readonly translate: true;
|
|
94
|
+
readonly route: {
|
|
95
|
+
readonly name: "/dashboard/user/changepass";
|
|
96
|
+
readonly fetchItem: true;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
readonly copyActivationLink: {
|
|
100
|
+
readonly label: "copy_activation_link";
|
|
101
|
+
readonly icon: "link";
|
|
102
|
+
readonly translate: true;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly filters: readonly ["name", "roles", "email", "phone_number"];
|
|
106
|
+
readonly table: readonly ["name", "roles", "picture_file", "active", "updated_at"];
|
|
107
|
+
readonly tableMeta: readonly ["email"];
|
|
108
|
+
readonly formLayout: {
|
|
109
|
+
readonly fields: {
|
|
110
|
+
readonly given_name: {
|
|
111
|
+
readonly span: 3;
|
|
112
|
+
};
|
|
113
|
+
readonly family_name: {
|
|
114
|
+
readonly span: 3;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}>, "_id" | "roles">>;
|
|
19
119
|
} | {
|
|
20
120
|
readonly _tag: "Error";
|
|
21
121
|
readonly error: {
|
package/dist/init.js
CHANGED
|
@@ -81,13 +81,13 @@ const init = (_options = {}) => {
|
|
|
81
81
|
});
|
|
82
82
|
if (options.callback) {
|
|
83
83
|
const result = await options.callback(context);
|
|
84
|
-
if (result !== undefined
|
|
84
|
+
if (result !== undefined) {
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
if (options.router) {
|
|
89
89
|
const result = await options.router.install(context);
|
|
90
|
-
if (result !== undefined
|
|
90
|
+
if (result !== undefined) {
|
|
91
91
|
return result;
|
|
92
92
|
}
|
|
93
93
|
}
|
package/dist/init.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { Result, ACError } from "@aeriajs/types";
|
|
3
3
|
import { endpointError, throwIfError, deepMerge } from "@aeriajs/common";
|
|
4
|
-
import { defineServerOptions, cors, wrapRouteExecution
|
|
4
|
+
import { defineServerOptions, cors, wrapRouteExecution } from "@aeriajs/http";
|
|
5
5
|
import { registerServer } from "@aeriajs/node-http";
|
|
6
6
|
import { createContext, decodeToken, traverseDocument, ObjectId } from "@aeriajs/core";
|
|
7
7
|
import { getDatabase } from "@aeriajs/core";
|
|
@@ -75,13 +75,13 @@ export const init = (_options = {}) => {
|
|
|
75
75
|
});
|
|
76
76
|
if (options.callback) {
|
|
77
77
|
const result = await options.callback(context);
|
|
78
|
-
if (result !== void 0
|
|
78
|
+
if (result !== void 0) {
|
|
79
79
|
return result;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
if (options.router) {
|
|
83
83
|
const result = await options.router.install(context);
|
|
84
|
-
if (result !== void 0
|
|
84
|
+
if (result !== void 0) {
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
87
|
}
|
package/dist/routes.d.ts
CHANGED
|
@@ -12,11 +12,11 @@ export declare const registerRoutes: () => import("@aeriajs/http").ProxiedRouter
|
|
|
12
12
|
} ? import("@aeriajs/types").InferProperties<Query> : Record<string, unknown>;
|
|
13
13
|
};
|
|
14
14
|
}) => Response : never>(method: import("@aeriajs/types").RequestMethod | import("@aeriajs/types").RequestMethod[], exp: import("@aeriajs/types").RouteUri, cb: TCallback, contract?: TContractWithRoles) => void;
|
|
15
|
-
routes: ((_: unknown, context: RouteContext, groupOptions?: import("@aeriajs/http").RouteGroupOptions) =>
|
|
15
|
+
routes: ((_: unknown, context: RouteContext, groupOptions?: import("@aeriajs/http").RouteGroupOptions) => unknown)[];
|
|
16
16
|
routesMeta: import("@aeriajs/http").RoutesMeta;
|
|
17
17
|
group: <TRouter extends {
|
|
18
18
|
install: (context: RouteContext, options?: import("@aeriajs/http").RouterOptions) => unknown;
|
|
19
19
|
routesMeta: import("@aeriajs/http").RoutesMeta;
|
|
20
20
|
}>(exp: import("@aeriajs/types").RouteUri, router: TRouter, middleware?: (context: RouteContext) => unknown) => void;
|
|
21
|
-
install: (_context: RouteContext, _options?: import("@aeriajs/http").RouterOptions) => Promise<
|
|
21
|
+
install: (_context: RouteContext, _options?: import("@aeriajs/http").RouterOptions) => Promise<unknown>;
|
|
22
22
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.168",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"mongodb": "^6.5.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@aeriajs/core": "^0.0.
|
|
37
|
-
"@aeriajs/builtins": "^0.0.
|
|
38
|
-
"@aeriajs/common": "^0.0.
|
|
39
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
40
|
-
"@aeriajs/http": "^0.0.
|
|
41
|
-
"@aeriajs/node-http": "^0.0.
|
|
42
|
-
"@aeriajs/server": "^0.0.
|
|
43
|
-
"@aeriajs/types": "^0.0.
|
|
36
|
+
"@aeriajs/core": "^0.0.166",
|
|
37
|
+
"@aeriajs/builtins": "^0.0.166",
|
|
38
|
+
"@aeriajs/common": "^0.0.102",
|
|
39
|
+
"@aeriajs/entrypoint": "^0.0.104",
|
|
40
|
+
"@aeriajs/http": "^0.0.115",
|
|
41
|
+
"@aeriajs/node-http": "^0.0.115",
|
|
42
|
+
"@aeriajs/server": "^0.0.168",
|
|
43
|
+
"@aeriajs/types": "^0.0.87",
|
|
44
44
|
"mongodb": "^6.5.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|