@aeriajs/common 0.0.128 → 0.0.130
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/freshItem.d.ts +2 -1
- package/dist/freshItem.js +17 -12
- package/dist/freshItem.mjs +15 -11
- package/package.json +2 -2
package/dist/freshItem.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { Description } from '@aeriajs/types';
|
|
1
|
+
import type { Description, Property, InferProperty } from '@aeriajs/types';
|
|
2
|
+
export declare const freshProperty: <const TProperty extends Property>(property: TProperty) => InferProperty<TProperty>;
|
|
2
3
|
export declare const freshItem: (description: Pick<Description, "properties" | "freshItem">) => Record<string, unknown>;
|
package/dist/freshItem.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.freshItem = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.freshItem = exports.freshProperty = void 0;
|
|
4
|
+
const freshProperty = (property) => {
|
|
5
5
|
const value = (() => {
|
|
6
6
|
if ('$ref' in property && property.inline) {
|
|
7
7
|
return {};
|
|
8
8
|
}
|
|
9
9
|
if ('properties' in property) {
|
|
10
|
-
|
|
10
|
+
const obj = {};
|
|
11
|
+
for (const propName in property.properties) {
|
|
12
|
+
obj[propName] = (0, exports.freshProperty)(property.properties[propName]);
|
|
13
|
+
}
|
|
14
|
+
return obj;
|
|
11
15
|
}
|
|
12
16
|
if ('type' in property) {
|
|
13
17
|
switch (property.type) {
|
|
@@ -18,16 +22,17 @@ const freshProperties = (properties) => Object.entries(properties).reduce((a, [k
|
|
|
18
22
|
}
|
|
19
23
|
return null;
|
|
20
24
|
})();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...a,
|
|
26
|
-
[key]: value,
|
|
27
|
-
};
|
|
28
|
-
}, {});
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
exports.freshProperty = freshProperty;
|
|
29
28
|
const freshItem = (description) => {
|
|
30
|
-
const item =
|
|
29
|
+
const item = {};
|
|
30
|
+
for (const propName in description.properties) {
|
|
31
|
+
const value = (0, exports.freshProperty)(description.properties[propName]);
|
|
32
|
+
if (value !== null) {
|
|
33
|
+
item[propName] = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
31
36
|
if (description.freshItem) {
|
|
32
37
|
Object.assign(item, description.freshItem);
|
|
33
38
|
}
|
package/dist/freshItem.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
export const freshProperty = (property) => {
|
|
3
3
|
const value = (() => {
|
|
4
4
|
if ("$ref" in property && property.inline) {
|
|
5
5
|
return {};
|
|
6
6
|
}
|
|
7
7
|
if ("properties" in property) {
|
|
8
|
-
|
|
8
|
+
const obj = {};
|
|
9
|
+
for (const propName in property.properties) {
|
|
10
|
+
obj[propName] = freshProperty(property.properties[propName]);
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
9
13
|
}
|
|
10
14
|
if ("type" in property) {
|
|
11
15
|
switch (property.type) {
|
|
@@ -19,16 +23,16 @@ const freshProperties = (properties) => Object.entries(properties).reduce((a, [k
|
|
|
19
23
|
}
|
|
20
24
|
return null;
|
|
21
25
|
})();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
...a,
|
|
27
|
-
[key]: value
|
|
28
|
-
};
|
|
29
|
-
}, {});
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
30
28
|
export const freshItem = (description) => {
|
|
31
|
-
const item =
|
|
29
|
+
const item = {};
|
|
30
|
+
for (const propName in description.properties) {
|
|
31
|
+
const value = freshProperty(description.properties[propName]);
|
|
32
|
+
if (value !== null) {
|
|
33
|
+
item[propName] = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
32
36
|
if (description.freshItem) {
|
|
33
37
|
Object.assign(item, description.freshItem);
|
|
34
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.130",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"bson": "^6.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@aeriajs/types": "^0.0.
|
|
34
|
+
"@aeriajs/types": "^0.0.112",
|
|
35
35
|
"bson": "^6.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|