@aeriajs/core 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.
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Context, SchemaWithId, GetAllPayload } from '@aeriajs/types';
|
|
2
|
-
import { Result } from '@aeriajs/types';
|
|
1
|
+
import type { Context, SchemaWithId, GetAllPayload, GetAllReturnType } from '@aeriajs/types';
|
|
3
2
|
export type GetAllOptions = {
|
|
4
3
|
bypassSecurity?: boolean;
|
|
5
4
|
noDefaultLimit?: boolean;
|
|
6
5
|
};
|
|
7
|
-
export declare const getAll: <TContext extends Context>(payload: GetAllPayload<SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: GetAllOptions) => Promise<
|
|
6
|
+
export declare const getAll: <TContext extends Context>(payload: GetAllPayload<SchemaWithId<TContext["description"]>> | undefined, context: TContext, options?: GetAllOptions) => Promise<GetAllReturnType<SchemaWithId<TContext["description"]>>>;
|
package/dist/functions/getAll.js
CHANGED
|
@@ -52,9 +52,11 @@ const internalGetAll = async (payload, context) => {
|
|
|
52
52
|
$skip: offset,
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if (limit) {
|
|
56
|
+
pipeline.push({
|
|
57
|
+
$limit: limit,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
58
60
|
if (project) {
|
|
59
61
|
const projection = (0, index_js_1.normalizeProjection)(project, context.description);
|
|
60
62
|
if (projection) {
|
|
@@ -97,7 +99,9 @@ const getAll = async (payload, context, options = {}) => {
|
|
|
97
99
|
const security = (0, security_1.useSecurity)(context);
|
|
98
100
|
const { error, result: securedPayload } = await security.secureReadPayload(payload);
|
|
99
101
|
if (error) {
|
|
100
|
-
return types_1.
|
|
102
|
+
return context.error(types_1.HTTPStatus.Forbidden, {
|
|
103
|
+
code: error,
|
|
104
|
+
});
|
|
101
105
|
}
|
|
102
106
|
if (!options.noDefaultLimit) {
|
|
103
107
|
securedPayload.limit ||= context.config.defaultPaginationLimit;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { useSecurity, applyReadMiddlewares } from "@aeriajs/security";
|
|
3
|
-
import { Result } from "@aeriajs/types";
|
|
3
|
+
import { HTTPStatus, Result } from "@aeriajs/types";
|
|
4
4
|
import { throwIfError } from "@aeriajs/common";
|
|
5
5
|
import {
|
|
6
6
|
traverseDocument,
|
|
@@ -52,9 +52,11 @@ const internalGetAll = async (payload, context) => {
|
|
|
52
52
|
$skip: offset
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if (limit) {
|
|
56
|
+
pipeline.push({
|
|
57
|
+
$limit: limit
|
|
58
|
+
});
|
|
59
|
+
}
|
|
58
60
|
if (project) {
|
|
59
61
|
const projection = normalizeProjection(project, context.description);
|
|
60
62
|
if (projection) {
|
|
@@ -95,7 +97,9 @@ export const getAll = async (payload, context, options = {}) => {
|
|
|
95
97
|
const security = useSecurity(context);
|
|
96
98
|
const { error, result: securedPayload } = await security.secureReadPayload(payload);
|
|
97
99
|
if (error) {
|
|
98
|
-
return
|
|
100
|
+
return context.error(HTTPStatus.Forbidden, {
|
|
101
|
+
code: error
|
|
102
|
+
});
|
|
99
103
|
}
|
|
100
104
|
if (!options.noDefaultLimit) {
|
|
101
105
|
securedPayload.limit ||= context.config.defaultPaginationLimit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.178",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"aeriaMain": "tests/fixtures/aeriaMain.js",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"mongodb-memory-server": "^9.2.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@aeriajs/builtins": "^0.0.
|
|
46
|
-
"@aeriajs/common": "^0.0.
|
|
47
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
48
|
-
"@aeriajs/http": "^0.0.
|
|
49
|
-
"@aeriajs/security": "^0.0.
|
|
50
|
-
"@aeriajs/types": "^0.0.
|
|
51
|
-
"@aeriajs/validation": "^0.0.
|
|
45
|
+
"@aeriajs/builtins": "^0.0.178",
|
|
46
|
+
"@aeriajs/common": "^0.0.108",
|
|
47
|
+
"@aeriajs/entrypoint": "^0.0.111",
|
|
48
|
+
"@aeriajs/http": "^0.0.122",
|
|
49
|
+
"@aeriajs/security": "^0.0.178",
|
|
50
|
+
"@aeriajs/types": "^0.0.91",
|
|
51
|
+
"@aeriajs/validation": "^0.0.111"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"mongodb": "^6.5.0",
|