@aeriajs/core 0.0.151 → 0.0.153
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.
|
@@ -28,10 +28,10 @@ const common_1 = require("@aeriajs/common");
|
|
|
28
28
|
const assets_js_1 = require("../assets.js");
|
|
29
29
|
const presets = __importStar(require("../presets/index.js"));
|
|
30
30
|
const preloadMemo = {};
|
|
31
|
-
const recurseProperty = async (_property,
|
|
31
|
+
const recurseProperty = async (_property, propName, description) => {
|
|
32
32
|
const property = Object.assign({}, _property);
|
|
33
33
|
if ('items' in property) {
|
|
34
|
-
property.items = await recurseProperty(property.items,
|
|
34
|
+
property.items = await recurseProperty(property.items, propName, description);
|
|
35
35
|
return property;
|
|
36
36
|
}
|
|
37
37
|
if ('properties' in property) {
|
|
@@ -102,10 +102,10 @@ const preloadDescription = async (originalDescription, options) => {
|
|
|
102
102
|
}
|
|
103
103
|
if (description.properties) {
|
|
104
104
|
const properties = [];
|
|
105
|
-
for (const [
|
|
105
|
+
for (const [propName, property] of Object.entries(description.properties)) {
|
|
106
106
|
properties.push([
|
|
107
|
-
|
|
108
|
-
await recurseProperty(property,
|
|
107
|
+
propName,
|
|
108
|
+
await recurseProperty(property, propName, description),
|
|
109
109
|
]);
|
|
110
110
|
}
|
|
111
111
|
description.properties = Object.fromEntries(properties);
|
|
@@ -3,10 +3,10 @@ import { getReferenceProperty, deepMerge, serialize } from "@aeriajs/common";
|
|
|
3
3
|
import { getCollectionAsset } from "../assets.mjs";
|
|
4
4
|
import * as presets from "../presets/index.mjs";
|
|
5
5
|
const preloadMemo = {};
|
|
6
|
-
const recurseProperty = async (_property,
|
|
6
|
+
const recurseProperty = async (_property, propName, description) => {
|
|
7
7
|
const property = Object.assign({}, _property);
|
|
8
8
|
if ("items" in property) {
|
|
9
|
-
property.items = await recurseProperty(property.items,
|
|
9
|
+
property.items = await recurseProperty(property.items, propName, description);
|
|
10
10
|
return property;
|
|
11
11
|
}
|
|
12
12
|
if ("properties" in property) {
|
|
@@ -78,10 +78,10 @@ export const preloadDescription = async (originalDescription, options) => {
|
|
|
78
78
|
}
|
|
79
79
|
if (description.properties) {
|
|
80
80
|
const properties = [];
|
|
81
|
-
for (const [
|
|
81
|
+
for (const [propName, property] of Object.entries(description.properties)) {
|
|
82
82
|
properties.push([
|
|
83
|
-
|
|
84
|
-
await recurseProperty(property,
|
|
83
|
+
propName,
|
|
84
|
+
await recurseProperty(property, propName, description)
|
|
85
85
|
]);
|
|
86
86
|
}
|
|
87
87
|
description.properties = Object.fromEntries(properties);
|
|
@@ -31,20 +31,20 @@ const mongodb_1 = require("mongodb");
|
|
|
31
31
|
const assets_js_1 = require("../assets.js");
|
|
32
32
|
const preload_js_1 = require("./preload.js");
|
|
33
33
|
const fs = __importStar(require("fs/promises"));
|
|
34
|
-
const getProperty = (
|
|
35
|
-
if (
|
|
34
|
+
const getProperty = (propName, parentProperty) => {
|
|
35
|
+
if (propName === '_id') {
|
|
36
36
|
return {
|
|
37
37
|
type: 'string',
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
if ('items' in parentProperty && 'properties' in parentProperty.items &&
|
|
41
|
-
return parentProperty.items.properties[
|
|
40
|
+
if ('items' in parentProperty && 'properties' in parentProperty.items && propName in parentProperty.items.properties) {
|
|
41
|
+
return parentProperty.items.properties[propName];
|
|
42
42
|
}
|
|
43
43
|
if ('additionalProperties' in parentProperty && typeof parentProperty.additionalProperties === 'object') {
|
|
44
44
|
return parentProperty.additionalProperties;
|
|
45
45
|
}
|
|
46
46
|
if ('properties' in parentProperty) {
|
|
47
|
-
return parentProperty.properties[
|
|
47
|
+
return parentProperty.properties[propName];
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
const disposeOldFiles = async (ctx, options = {}) => {
|
|
@@ -313,6 +313,14 @@ const recurse = async (target, ctx) => {
|
|
|
313
313
|
]);
|
|
314
314
|
}
|
|
315
315
|
if (property) {
|
|
316
|
+
if (ctx.options.getters && 'getter' in property) {
|
|
317
|
+
if (property.requires) {
|
|
318
|
+
const missing = property.requires.some((requiredPropName) => !(requiredPropName in target));
|
|
319
|
+
if (missing) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
316
324
|
if (ctx.options.recurseReferences) {
|
|
317
325
|
const propCast = 'items' in property
|
|
318
326
|
? property.items
|
|
@@ -6,20 +6,20 @@ import { ObjectId } from "mongodb";
|
|
|
6
6
|
import { getCollectionAsset } from "../assets.mjs";
|
|
7
7
|
import { preloadDescription } from "./preload.mjs";
|
|
8
8
|
import * as fs from "fs/promises";
|
|
9
|
-
const getProperty = (
|
|
10
|
-
if (
|
|
9
|
+
const getProperty = (propName, parentProperty) => {
|
|
10
|
+
if (propName === "_id") {
|
|
11
11
|
return {
|
|
12
12
|
type: "string"
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
if ("items" in parentProperty && "properties" in parentProperty.items &&
|
|
16
|
-
return parentProperty.items.properties[
|
|
15
|
+
if ("items" in parentProperty && "properties" in parentProperty.items && propName in parentProperty.items.properties) {
|
|
16
|
+
return parentProperty.items.properties[propName];
|
|
17
17
|
}
|
|
18
18
|
if ("additionalProperties" in parentProperty && typeof parentProperty.additionalProperties === "object") {
|
|
19
19
|
return parentProperty.additionalProperties;
|
|
20
20
|
}
|
|
21
21
|
if ("properties" in parentProperty) {
|
|
22
|
-
return parentProperty.properties[
|
|
22
|
+
return parentProperty.properties[propName];
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
const disposeOldFiles = async (ctx, options = {}) => {
|
|
@@ -275,6 +275,14 @@ const recurse = async (target, ctx) => {
|
|
|
275
275
|
]);
|
|
276
276
|
}
|
|
277
277
|
if (property) {
|
|
278
|
+
if (ctx.options.getters && "getter" in property) {
|
|
279
|
+
if (property.requires) {
|
|
280
|
+
const missing = property.requires.some((requiredPropName) => !(requiredPropName in target));
|
|
281
|
+
if (missing) {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
278
286
|
if (ctx.options.recurseReferences) {
|
|
279
287
|
const propCast = "items" in property ? property.items : property;
|
|
280
288
|
if ("$ref" in propCast && value && !(value instanceof ObjectId)) {
|
|
@@ -4,7 +4,7 @@ exports.removeFile = void 0;
|
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
5
|
const security_1 = require("@aeriajs/security");
|
|
6
6
|
const internalRemoveFile = async (payload, context) => {
|
|
7
|
-
const {
|
|
7
|
+
const { propName, parentId, ...props } = payload;
|
|
8
8
|
const doc = await context.collections.file.functions.remove(props);
|
|
9
9
|
return types_1.Result.result(doc);
|
|
10
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.153",
|
|
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.153",
|
|
46
|
+
"@aeriajs/common": "^0.0.92",
|
|
47
|
+
"@aeriajs/entrypoint": "^0.0.94",
|
|
48
|
+
"@aeriajs/http": "^0.0.104",
|
|
49
|
+
"@aeriajs/security": "^0.0.153",
|
|
50
|
+
"@aeriajs/types": "^0.0.79",
|
|
51
|
+
"@aeriajs/validation": "^0.0.95"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"mongodb": "^6.5.0",
|