@aeriajs/core 0.0.111 → 0.0.113
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/collection/fill.d.ts +1 -1
- package/dist/collection/normalizeProjection.d.ts +1 -1
- package/dist/collection/normalizeProjection.js +1 -1
- package/dist/collection/normalizeProjection.mjs +1 -1
- package/dist/collection/pagination.d.ts +4 -2
- package/dist/collection/pagination.js +4 -3
- package/dist/collection/pagination.mjs +3 -2
- package/dist/collection/traverseDocument.d.ts +1 -0
- package/dist/collection/traverseDocument.js +4 -2
- package/dist/collection/traverseDocument.mjs +4 -2
- package/dist/functions/builtin/insert.js +2 -1
- package/dist/functions/builtin/insert.mjs +2 -1
- package/dist/functions/builtin/remove.d.ts +6 -6
- package/dist/functions/builtin/removeAll.d.ts +1 -1
- package/package.json +8 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Description } from '@aeriajs/types';
|
|
2
|
-
export declare const fill: <TDocument extends
|
|
2
|
+
export declare const fill: <TDocument extends unknown>(doc: TDocument & Record<string, any>, description: Description) => Record<string, any> & TDocument;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Description } from '@aeriajs/types';
|
|
2
|
-
export declare const normalizeProjection: <TDescription extends Pick<Description, "properties">, TProjectedProperties extends (keyof TDescription["properties"])[]>(properties: TProjectedProperties, description: TDescription) => {} |
|
|
2
|
+
export declare const normalizeProjection: <TDescription extends Pick<Description, "properties">, TProjectedProperties extends (keyof TDescription["properties"])[]>(properties: TProjectedProperties, description: TDescription) => {} | undefined;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type { Context, Pagination, GetAllPayload } from '@aeriajs/types';
|
|
2
|
-
export declare const makePagination: (payload: GetAllPayload<any>, documents: any[], context: Context
|
|
1
|
+
import type { Context, Description, Pagination, GetAllPayload } from '@aeriajs/types';
|
|
2
|
+
export declare const makePagination: (payload: GetAllPayload<any>, documents: any[], context: Context<Description, {
|
|
3
|
+
count?: (...args: unknown[]) => unknown;
|
|
4
|
+
}>) => Promise<Pagination>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makePagination = void 0;
|
|
4
|
+
const common_1 = require("@aeriajs/common");
|
|
4
5
|
const makePagination = async (payload, documents, context) => {
|
|
5
6
|
const limit = payload.limit
|
|
6
7
|
? payload.limit
|
|
7
8
|
: context.config.paginationLimit;
|
|
8
9
|
const offset = payload.offset || 0;
|
|
9
|
-
const recordsTotal = context.collection.
|
|
10
|
-
? await context.collection.functions.count({
|
|
10
|
+
const recordsTotal = typeof context.collection.functions.count === 'function'
|
|
11
|
+
? (0, common_1.throwIfError)(await context.collection.functions.count({
|
|
11
12
|
filters: payload.filters,
|
|
12
|
-
})
|
|
13
|
+
}))
|
|
13
14
|
: await context.collection.model.countDocuments(payload.filters);
|
|
14
15
|
return {
|
|
15
16
|
recordsCount: documents.length,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
import { throwIfError } from "@aeriajs/common";
|
|
2
3
|
export const makePagination = async (payload, documents, context) => {
|
|
3
4
|
const limit = payload.limit ? payload.limit : context.config.paginationLimit;
|
|
4
5
|
const offset = payload.offset || 0;
|
|
5
|
-
const recordsTotal = context.collection.
|
|
6
|
+
const recordsTotal = typeof context.collection.functions.count === "function" ? throwIfError(await context.collection.functions.count({
|
|
6
7
|
filters: payload.filters
|
|
7
|
-
}) : await context.collection.model.countDocuments(payload.filters);
|
|
8
|
+
})) : await context.collection.model.countDocuments(payload.filters);
|
|
8
9
|
return {
|
|
9
10
|
recordsCount: documents.length,
|
|
10
11
|
recordsTotal,
|
|
@@ -250,8 +250,10 @@ const recurse = async (target, ctx) => {
|
|
|
250
250
|
for (const propName in entrypoint) {
|
|
251
251
|
const value = target[propName];
|
|
252
252
|
const property = getProperty(propName, ctx.property);
|
|
253
|
-
if (
|
|
254
|
-
|
|
253
|
+
if (ctx.options.skipUndefined) {
|
|
254
|
+
if (value === undefined && !(ctx.options.getters && property && 'getter' in property)) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
255
257
|
}
|
|
256
258
|
if (ctx.options.autoCast && propName === '_id') {
|
|
257
259
|
entries.push([
|
|
@@ -214,8 +214,10 @@ const recurse = async (target, ctx) => {
|
|
|
214
214
|
for (const propName in entrypoint) {
|
|
215
215
|
const value = target[propName];
|
|
216
216
|
const property = getProperty(propName, ctx.property);
|
|
217
|
-
if (
|
|
218
|
-
|
|
217
|
+
if (ctx.options.skipUndefined) {
|
|
218
|
+
if (value === void 0 && !(ctx.options.getters && property && "getter" in property)) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
219
221
|
}
|
|
220
222
|
if (ctx.options.autoCast && propName === "_id") {
|
|
221
223
|
entries.push([
|
|
@@ -30,10 +30,11 @@ const insert = async (payload, context, options) => {
|
|
|
30
30
|
recurseDeep: true,
|
|
31
31
|
autoCast: true,
|
|
32
32
|
validate: true,
|
|
33
|
-
validateRequired: payload.what._id
|
|
33
|
+
validateRequired: '_id' in payload.what && payload.what._id
|
|
34
34
|
? []
|
|
35
35
|
: context.description.required,
|
|
36
36
|
moveFiles: true,
|
|
37
|
+
skipUndefined: true,
|
|
37
38
|
context,
|
|
38
39
|
});
|
|
39
40
|
if (error) {
|
|
@@ -25,8 +25,9 @@ export const insert = async (payload, context, options) => {
|
|
|
25
25
|
recurseDeep: true,
|
|
26
26
|
autoCast: true,
|
|
27
27
|
validate: true,
|
|
28
|
-
validateRequired: payload.what._id ? [] : context.description.required,
|
|
28
|
+
validateRequired: "_id" in payload.what && payload.what._id ? [] : context.description.required,
|
|
29
29
|
moveFiles: true,
|
|
30
|
+
skipUndefined: true,
|
|
30
31
|
context
|
|
31
32
|
});
|
|
32
33
|
if (error) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Context, SchemaWithId, RemovePayload } from '@aeriajs/types';
|
|
2
2
|
import { Result, HTTPStatus, ACError } from '@aeriajs/types';
|
|
3
|
-
export declare const remove: <TContext extends Context>(payload: RemovePayload<SchemaWithId<TContext['description']>>, context: TContext) => Promise<{
|
|
4
|
-
readonly _tag: "Result";
|
|
5
|
-
readonly error: undefined;
|
|
6
|
-
readonly result: any;
|
|
7
|
-
} | Result.Error<{
|
|
3
|
+
export declare const remove: <TContext extends Context>(payload: RemovePayload<SchemaWithId<TContext['description']>>, context: TContext) => Promise<Result.Error<{
|
|
8
4
|
readonly code: ACError.ResourceNotFound;
|
|
9
5
|
} & {
|
|
10
6
|
httpStatus: HTTPStatus.NotFound;
|
|
11
|
-
}
|
|
7
|
+
}> | {
|
|
8
|
+
readonly _tag: "Result";
|
|
9
|
+
readonly error: undefined;
|
|
10
|
+
readonly result: import("mongodb").WithId<Omit<import("@aeriajs/types").PackReferences<SchemaWithId<import("@aeriajs/types").Description>>, "_id">> | null;
|
|
11
|
+
}>;
|
|
@@ -2,5 +2,5 @@ import type { Context, RemoveAllPayload } from '@aeriajs/types';
|
|
|
2
2
|
export declare const removeAll: <TContext extends Context>(payload: RemoveAllPayload, context: TContext) => Promise<{
|
|
3
3
|
readonly _tag: "Result";
|
|
4
4
|
readonly error: undefined;
|
|
5
|
-
readonly result:
|
|
5
|
+
readonly result: import("mongodb").DeleteResult;
|
|
6
6
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.113",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"mongodb-memory-server": "^9.2.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@aeriajs/builtins": "^0.0.
|
|
45
|
-
"@aeriajs/common": "^0.0.
|
|
46
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
47
|
-
"@aeriajs/http": "^0.0.
|
|
48
|
-
"@aeriajs/security": "^0.0.
|
|
49
|
-
"@aeriajs/types": "^0.0.
|
|
50
|
-
"@aeriajs/validation": "^0.0.
|
|
44
|
+
"@aeriajs/builtins": "^0.0.113",
|
|
45
|
+
"@aeriajs/common": "^0.0.72",
|
|
46
|
+
"@aeriajs/entrypoint": "^0.0.74",
|
|
47
|
+
"@aeriajs/http": "^0.0.83",
|
|
48
|
+
"@aeriajs/security": "^0.0.113",
|
|
49
|
+
"@aeriajs/types": "^0.0.63",
|
|
50
|
+
"@aeriajs/validation": "^0.0.75"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"mongodb": "^6.5.0",
|