@aeriajs/common 0.0.23 → 0.0.25
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/arraysIntersects.mjs +6 -7
- package/dist/checkForUndefined.mjs +6 -5
- package/dist/convertConditionToQuery.mjs +53 -68
- package/dist/date.mjs +31 -96
- package/dist/deepClone.mjs +3 -2
- package/dist/deepMerge.mjs +30 -62
- package/dist/dynamicImport.mjs +12 -145
- package/dist/either.mjs +24 -27
- package/dist/evaluateCondition.mjs +56 -59
- package/dist/formatValue.mjs +46 -55
- package/dist/freshItem.mjs +32 -129
- package/dist/getMissingProperties.mjs +36 -44
- package/dist/getReferenceProperty.mjs +9 -10
- package/dist/getValueFromPath.mjs +6 -5
- package/dist/http.mjs +39 -220
- package/dist/index.mjs +1 -0
- package/dist/isReference.mjs +3 -2
- package/dist/isRequired.mjs +13 -12
- package/dist/pipe.mjs +21 -255
- package/dist/schema.mjs +61 -64
- package/dist/serialize.mjs +4 -36
- package/package.json +3 -3
package/dist/schema.mjs
CHANGED
|
@@ -1,72 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, fromLiteral(value));
|
|
10
|
-
}
|
|
11
|
-
if (value === Date) {
|
|
12
|
-
return {
|
|
13
|
-
type: "string",
|
|
14
|
-
format: "date-time"
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
return {
|
|
19
|
-
type: "array",
|
|
20
|
-
items: mapValueToProperty(value[0])
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (value && typeof value === "string") {
|
|
24
|
-
return {
|
|
25
|
-
$ref: value
|
|
26
|
-
};
|
|
27
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
const mapValueToProperty = (value) => {
|
|
3
|
+
if (value.constructor === Object) {
|
|
4
|
+
return Object.assign({
|
|
5
|
+
type: "object"
|
|
6
|
+
}, fromLiteral(value));
|
|
7
|
+
}
|
|
8
|
+
if (value === Date) {
|
|
28
9
|
return {
|
|
29
|
-
|
|
10
|
+
type: "string",
|
|
11
|
+
format: "date-time"
|
|
30
12
|
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var entries = [];
|
|
34
|
-
for(var propName in object){
|
|
35
|
-
var value = object[propName];
|
|
36
|
-
if (value === null || value === undefined) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
entries.push([
|
|
40
|
-
propName,
|
|
41
|
-
mapValueToProperty(value)
|
|
42
|
-
]);
|
|
43
|
-
}
|
|
44
|
-
var properties = Object.fromEntries(entries);
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(value)) {
|
|
45
15
|
return {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
properties: properties
|
|
16
|
+
type: "array",
|
|
17
|
+
items: mapValueToProperty(value[0])
|
|
49
18
|
};
|
|
50
|
-
}
|
|
51
|
-
|
|
19
|
+
}
|
|
20
|
+
if (value && typeof value === "string") {
|
|
52
21
|
return {
|
|
53
|
-
|
|
54
|
-
properties: {
|
|
55
|
-
_tag: {
|
|
56
|
-
const: "Left"
|
|
57
|
-
},
|
|
58
|
-
value: object
|
|
59
|
-
}
|
|
22
|
+
$ref: value
|
|
60
23
|
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
type: typeof value
|
|
27
|
+
};
|
|
61
28
|
};
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
29
|
+
export const fromLiteral = (object, required) => {
|
|
30
|
+
const entries = [];
|
|
31
|
+
for (const propName in object) {
|
|
32
|
+
const value = object[propName];
|
|
33
|
+
if (value === null || value === void 0) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
entries.push([
|
|
37
|
+
propName,
|
|
38
|
+
mapValueToProperty(value)
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
const properties = Object.fromEntries(entries);
|
|
42
|
+
return {
|
|
43
|
+
type: "object",
|
|
44
|
+
required,
|
|
45
|
+
properties
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export const leftSchema = (object) => {
|
|
49
|
+
return {
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
_tag: {
|
|
53
|
+
const: "Left"
|
|
54
|
+
},
|
|
55
|
+
value: object
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export const rightSchema = (object) => {
|
|
60
|
+
return {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
_tag: {
|
|
64
|
+
const: "Right"
|
|
65
|
+
},
|
|
66
|
+
value: object
|
|
67
|
+
}
|
|
68
|
+
};
|
|
72
69
|
};
|
package/dist/serialize.mjs
CHANGED
|
@@ -1,38 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_without_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
-
}
|
|
9
|
-
function _iterable_to_array(iter) {
|
|
10
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
-
}
|
|
12
|
-
function _non_iterable_spread() {
|
|
13
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
-
}
|
|
15
|
-
function _to_consumable_array(arr) {
|
|
16
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
|
-
}
|
|
18
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
|
-
if (!o) return;
|
|
20
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
21
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
|
-
}
|
|
26
|
-
var _BSON;
|
|
1
|
+
"use strict";
|
|
27
2
|
import * as BSON from "bson";
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return Buffer.from((_BSON = BSON).serialize.apply(_BSON, _to_consumable_array(args))).toString("latin1");
|
|
33
|
-
};
|
|
34
|
-
export var deserialize = function(buffer) {
|
|
35
|
-
return BSON.deserialize(new Uint8Array(Array.from(buffer).map(function(c) {
|
|
36
|
-
return c.charCodeAt(0);
|
|
37
|
-
})));
|
|
3
|
+
export const serialize = (...args) => Buffer.from(BSON.serialize(...args)).toString("latin1");
|
|
4
|
+
export const deserialize = (buffer) => {
|
|
5
|
+
return BSON.deserialize(new Uint8Array(Array.from(buffer).map((c) => c.charCodeAt(0))));
|
|
38
6
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@aeriajs/types": "^0.0.
|
|
30
|
+
"@aeriajs/types": "^0.0.22",
|
|
31
31
|
"bson": "^5.4.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lint:fix": "eslint src --fix",
|
|
37
37
|
"build": "pnpm build:cjs && pnpm build:esm",
|
|
38
38
|
"build:cjs": "tsc",
|
|
39
|
-
"build:esm": "
|
|
39
|
+
"build:esm": "esbuild './src/**/*.ts' --outdir=dist --out-extension:.js=.mjs && pnpm build:esm-transform",
|
|
40
40
|
"build:esm-transform": "pnpm -w esm-transform $PWD/dist"
|
|
41
41
|
}
|
|
42
42
|
}
|