@valbuild/core 0.72.4 → 0.73.0
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/declarations/src/index.d.ts +20 -4
- package/dist/declarations/src/initSchema.d.ts +3 -3
- package/dist/declarations/src/initVal.d.ts +3 -1
- package/dist/declarations/src/patch/index.d.ts +1 -1
- package/dist/declarations/src/patch/operation.d.ts +3 -0
- package/dist/declarations/src/remote/fileHash.d.ts +5 -0
- package/dist/declarations/src/remote/splitRemoteRef.d.ts +13 -0
- package/dist/declarations/src/remote/validationBasis.d.ts +13 -0
- package/dist/declarations/src/schema/file.d.ts +7 -3
- package/dist/declarations/src/schema/image.d.ts +7 -3
- package/dist/declarations/src/schema/remote.d.ts +11 -0
- package/dist/declarations/src/schema/richtext.d.ts +5 -3
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/declarations/src/selector/index.d.ts +2 -1
- package/dist/declarations/src/source/file.d.ts +2 -2
- package/dist/declarations/src/source/image.d.ts +2 -2
- package/dist/declarations/src/source/index.d.ts +3 -4
- package/dist/declarations/src/source/remote.d.ts +22 -0
- package/dist/declarations/src/source/richtext.d.ts +30 -3
- package/dist/declarations/src/val/index.d.ts +4 -3
- package/dist/{index-25ee166a.cjs.prod.js → index-da9933cf.cjs.prod.js} +529 -1332
- package/dist/{index-a49a4c82.cjs.dev.js → index-f6fd3df3.cjs.dev.js} +529 -1332
- package/dist/{index-e01fe365.esm.js → index-fee3aa6d.esm.js} +531 -1326
- package/dist/{result-168dfc1d.esm.js → result-daff1cae.esm.js} +1 -1
- package/dist/valbuild-core.cjs.dev.js +27 -27
- package/dist/valbuild-core.cjs.prod.js +27 -27
- package/dist/valbuild-core.esm.js +2 -2
- package/fp/dist/valbuild-core-fp.esm.js +1 -1
- package/package.json +2 -9
- package/patch/dist/valbuild-core-patch.cjs.dev.js +38 -37
- package/patch/dist/valbuild-core-patch.cjs.prod.js +38 -37
- package/patch/dist/valbuild-core-patch.esm.js +5 -4
- package/dist/declarations/src/expr/eval.d.ts +0 -20
- package/dist/declarations/src/expr/expr.d.ts +0 -32
- package/dist/declarations/src/expr/index.d.ts +0 -3
- package/dist/declarations/src/expr/parser.d.ts +0 -8
- package/dist/declarations/src/future/fetchVal.d.ts +0 -5
- package/dist/declarations/src/selector/future/array.d.ts +0 -17
- package/dist/declarations/src/selector/future/boolean.d.ts +0 -2
- package/dist/declarations/src/selector/future/file.d.ts +0 -9
- package/dist/declarations/src/selector/future/i18n.d.ts +0 -11
- package/dist/declarations/src/selector/future/index.d.ts +0 -82
- package/dist/declarations/src/selector/future/number.d.ts +0 -2
- package/dist/declarations/src/selector/future/object.d.ts +0 -10
- package/dist/declarations/src/selector/future/primitive.d.ts +0 -9
- package/dist/declarations/src/selector/future/remote.d.ts +0 -7
- package/dist/declarations/src/selector/future/string.d.ts +0 -2
- package/dist/declarations/src/source/future/i18n.d.ts +0 -29
- package/dist/declarations/src/source/future/remote.d.ts +0 -29
- package/expr/dist/valbuild-core-expr.cjs.d.ts +0 -2
- package/expr/dist/valbuild-core-expr.cjs.dev.js +0 -17
- package/expr/dist/valbuild-core-expr.cjs.js +0 -7
- package/expr/dist/valbuild-core-expr.cjs.prod.js +0 -17
- package/expr/dist/valbuild-core-expr.esm.js +0 -2
- package/expr/package.json +0 -4
@@ -272,4 +272,4 @@ var result = /*#__PURE__*/Object.freeze({
|
|
272
272
|
filterOrElse: filterOrElse
|
273
273
|
});
|
274
274
|
|
275
|
-
export { _unsupportedIterableToArray as _, _arrayLikeToArray as a,
|
275
|
+
export { _unsupportedIterableToArray as _, _arrayLikeToArray as a, _createForOfIteratorHelper as b, isOk as c, array as d, err as e, isNonEmpty as f, flatMap as g, flatMapReduce as h, isErr as i, filterOrElse as j, mapErr as k, map$1 as l, map as m, all as n, ok as o, flatten as p, allT as q, result as r };
|
@@ -2,34 +2,34 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
5
|
+
var dist_valbuildCore = require('./index-f6fd3df3.cjs.dev.js');
|
6
6
|
require('./result-bb1f436e.cjs.dev.js');
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
exports.ArraySchema =
|
11
|
-
exports.BooleanSchema =
|
12
|
-
exports.
|
13
|
-
exports.
|
14
|
-
exports.
|
15
|
-
exports.
|
16
|
-
exports.
|
17
|
-
exports.
|
18
|
-
exports.
|
19
|
-
exports.
|
20
|
-
exports.
|
21
|
-
exports.
|
22
|
-
exports.
|
23
|
-
exports.
|
24
|
-
exports.
|
25
|
-
exports.
|
26
|
-
exports.
|
27
|
-
exports.
|
28
|
-
exports.
|
29
|
-
exports.
|
30
|
-
exports.
|
31
|
-
exports.
|
32
|
-
exports.
|
33
|
-
exports.
|
34
|
-
exports.initVal =
|
35
|
-
exports.modules =
|
10
|
+
exports.ArraySchema = dist_valbuildCore.ArraySchema;
|
11
|
+
exports.BooleanSchema = dist_valbuildCore.BooleanSchema;
|
12
|
+
exports.DEFAULT_VAL_REMOTE_HOST = dist_valbuildCore.DEFAULT_VAL_REMOTE_HOST;
|
13
|
+
exports.DateSchema = dist_valbuildCore.DateSchema;
|
14
|
+
exports.FATAL_ERROR_TYPES = dist_valbuildCore.FATAL_ERROR_TYPES;
|
15
|
+
exports.FILE_REF_PROP = dist_valbuildCore.FILE_REF_PROP;
|
16
|
+
exports.FILE_REF_SUBTYPE_TAG = dist_valbuildCore.FILE_REF_SUBTYPE_TAG;
|
17
|
+
exports.FileSchema = dist_valbuildCore.FileSchema;
|
18
|
+
exports.GenericSelector = dist_valbuildCore.GenericSelector;
|
19
|
+
exports.ImageSchema = dist_valbuildCore.ImageSchema;
|
20
|
+
exports.Internal = dist_valbuildCore.Internal;
|
21
|
+
exports.KeyOfSchema = dist_valbuildCore.KeyOfSchema;
|
22
|
+
exports.LiteralSchema = dist_valbuildCore.LiteralSchema;
|
23
|
+
exports.ModuleFilePathSep = dist_valbuildCore.ModuleFilePathSep;
|
24
|
+
exports.NumberSchema = dist_valbuildCore.NumberSchema;
|
25
|
+
exports.ObjectSchema = dist_valbuildCore.ObjectSchema;
|
26
|
+
exports.RecordSchema = dist_valbuildCore.RecordSchema;
|
27
|
+
exports.RichTextSchema = dist_valbuildCore.RichTextSchema;
|
28
|
+
exports.Schema = dist_valbuildCore.Schema;
|
29
|
+
exports.StringSchema = dist_valbuildCore.StringSchema;
|
30
|
+
exports.UnionSchema = dist_valbuildCore.UnionSchema;
|
31
|
+
exports.VAL_EXTENSION = dist_valbuildCore.VAL_EXTENSION;
|
32
|
+
exports.derefPatch = dist_valbuildCore.derefPatch;
|
33
|
+
exports.deserializeSchema = dist_valbuildCore.deserializeSchema;
|
34
|
+
exports.initVal = dist_valbuildCore.initVal;
|
35
|
+
exports.modules = dist_valbuildCore.modules;
|
@@ -2,34 +2,34 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
5
|
+
var dist_valbuildCore = require('./index-da9933cf.cjs.prod.js');
|
6
6
|
require('./result-787e35f6.cjs.prod.js');
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
exports.ArraySchema =
|
11
|
-
exports.BooleanSchema =
|
12
|
-
exports.
|
13
|
-
exports.
|
14
|
-
exports.
|
15
|
-
exports.
|
16
|
-
exports.
|
17
|
-
exports.
|
18
|
-
exports.
|
19
|
-
exports.
|
20
|
-
exports.
|
21
|
-
exports.
|
22
|
-
exports.
|
23
|
-
exports.
|
24
|
-
exports.
|
25
|
-
exports.
|
26
|
-
exports.
|
27
|
-
exports.
|
28
|
-
exports.
|
29
|
-
exports.
|
30
|
-
exports.
|
31
|
-
exports.
|
32
|
-
exports.
|
33
|
-
exports.
|
34
|
-
exports.initVal =
|
35
|
-
exports.modules =
|
10
|
+
exports.ArraySchema = dist_valbuildCore.ArraySchema;
|
11
|
+
exports.BooleanSchema = dist_valbuildCore.BooleanSchema;
|
12
|
+
exports.DEFAULT_VAL_REMOTE_HOST = dist_valbuildCore.DEFAULT_VAL_REMOTE_HOST;
|
13
|
+
exports.DateSchema = dist_valbuildCore.DateSchema;
|
14
|
+
exports.FATAL_ERROR_TYPES = dist_valbuildCore.FATAL_ERROR_TYPES;
|
15
|
+
exports.FILE_REF_PROP = dist_valbuildCore.FILE_REF_PROP;
|
16
|
+
exports.FILE_REF_SUBTYPE_TAG = dist_valbuildCore.FILE_REF_SUBTYPE_TAG;
|
17
|
+
exports.FileSchema = dist_valbuildCore.FileSchema;
|
18
|
+
exports.GenericSelector = dist_valbuildCore.GenericSelector;
|
19
|
+
exports.ImageSchema = dist_valbuildCore.ImageSchema;
|
20
|
+
exports.Internal = dist_valbuildCore.Internal;
|
21
|
+
exports.KeyOfSchema = dist_valbuildCore.KeyOfSchema;
|
22
|
+
exports.LiteralSchema = dist_valbuildCore.LiteralSchema;
|
23
|
+
exports.ModuleFilePathSep = dist_valbuildCore.ModuleFilePathSep;
|
24
|
+
exports.NumberSchema = dist_valbuildCore.NumberSchema;
|
25
|
+
exports.ObjectSchema = dist_valbuildCore.ObjectSchema;
|
26
|
+
exports.RecordSchema = dist_valbuildCore.RecordSchema;
|
27
|
+
exports.RichTextSchema = dist_valbuildCore.RichTextSchema;
|
28
|
+
exports.Schema = dist_valbuildCore.Schema;
|
29
|
+
exports.StringSchema = dist_valbuildCore.StringSchema;
|
30
|
+
exports.UnionSchema = dist_valbuildCore.UnionSchema;
|
31
|
+
exports.VAL_EXTENSION = dist_valbuildCore.VAL_EXTENSION;
|
32
|
+
exports.derefPatch = dist_valbuildCore.derefPatch;
|
33
|
+
exports.deserializeSchema = dist_valbuildCore.deserializeSchema;
|
34
|
+
exports.initVal = dist_valbuildCore.initVal;
|
35
|
+
exports.modules = dist_valbuildCore.modules;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { A as ArraySchema, B as BooleanSchema, D as DateSchema, F as FATAL_ERROR_TYPES,
|
2
|
-
import './result-
|
1
|
+
export { A as ArraySchema, B as BooleanSchema, D as DEFAULT_VAL_REMOTE_HOST, l as DateSchema, F as FATAL_ERROR_TYPES, e as FILE_REF_PROP, f as FILE_REF_SUBTYPE_TAG, k as FileSchema, G as GenericSelector, j as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, n as RichTextSchema, S as Schema, h as StringSchema, U as UnionSchema, V as VAL_EXTENSION, g as derefPatch, o as deserializeSchema, i as initVal, m as modules } from './index-fee3aa6d.esm.js';
|
2
|
+
import './result-daff1cae.esm.js';
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { d as array, r as result } from '../../dist/result-
|
1
|
+
export { d as array, r as result } from '../../dist/result-daff1cae.esm.js';
|
2
2
|
export { p as pipe, t as tap } from '../../dist/util-18613e99.esm.js';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/core",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.73.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "Val - supercharged hard-coded content",
|
6
6
|
"scripts": {
|
@@ -19,10 +19,6 @@
|
|
19
19
|
"module": "./fp/dist/valbuild-core-fp.esm.js",
|
20
20
|
"default": "./fp/dist/valbuild-core-fp.cjs.js"
|
21
21
|
},
|
22
|
-
"./expr": {
|
23
|
-
"module": "./expr/dist/valbuild-core-expr.esm.js",
|
24
|
-
"default": "./expr/dist/valbuild-core-expr.cjs.js"
|
25
|
-
},
|
26
22
|
"./patch": {
|
27
23
|
"module": "./patch/dist/valbuild-core-patch.esm.js",
|
28
24
|
"default": "./patch/dist/valbuild-core-patch.cjs.js"
|
@@ -34,8 +30,7 @@
|
|
34
30
|
"entrypoints": [
|
35
31
|
"./index.ts",
|
36
32
|
"./fp/index.ts",
|
37
|
-
"./patch/index.ts"
|
38
|
-
"./expr/index.ts"
|
33
|
+
"./patch/index.ts"
|
39
34
|
],
|
40
35
|
"exports": true
|
41
36
|
},
|
@@ -47,8 +42,6 @@
|
|
47
42
|
"dist",
|
48
43
|
"fp/dist",
|
49
44
|
"fp/package.json",
|
50
|
-
"expr/dist",
|
51
|
-
"expr/package.json",
|
52
45
|
"patch/dist",
|
53
46
|
"patch/package.json"
|
54
47
|
]
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
5
|
+
var dist_valbuildCore = require('../../dist/index-f6fd3df3.cjs.dev.js');
|
6
6
|
var result = require('../../dist/result-bb1f436e.cjs.dev.js');
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
8
8
|
|
@@ -13,7 +13,7 @@ function deepEqual(a, b) {
|
|
13
13
|
if (a === b) {
|
14
14
|
return true;
|
15
15
|
}
|
16
|
-
if (
|
16
|
+
if (dist_valbuildCore._typeof(a) === "object" && dist_valbuildCore._typeof(b) === "object" && a !== null && b !== null) {
|
17
17
|
if (Array.isArray(a) && Array.isArray(b)) {
|
18
18
|
if (a.length !== b.length) return false;
|
19
19
|
for (var i = 0; i < a.length; ++i) {
|
@@ -25,7 +25,7 @@ function deepEqual(a, b) {
|
|
25
25
|
// If the objects have a different amount of keys, they cannot be equal
|
26
26
|
if (aEntries.length !== Object.keys(b).length) return false;
|
27
27
|
for (var _i = 0, _aEntries = aEntries; _i < _aEntries.length; _i++) {
|
28
|
-
var _aEntries$_i =
|
28
|
+
var _aEntries$_i = dist_valbuildCore._slicedToArray(_aEntries[_i], 2),
|
29
29
|
key = _aEntries$_i[0],
|
30
30
|
aValue = _aEntries$_i[1];
|
31
31
|
// b must be a JSON object, so the only way for the bValue to be
|
@@ -42,9 +42,9 @@ function deepEqual(a, b) {
|
|
42
42
|
function deepClone(value) {
|
43
43
|
if (Array.isArray(value)) {
|
44
44
|
return value.map(deepClone);
|
45
|
-
} else if (
|
45
|
+
} else if (dist_valbuildCore._typeof(value) === "object" && value !== null) {
|
46
46
|
return Object.fromEntries(Object.entries(value).map(function (_ref) {
|
47
|
-
var _ref2 =
|
47
|
+
var _ref2 = dist_valbuildCore._slicedToArray(_ref, 2),
|
48
48
|
key = _ref2[0],
|
49
49
|
value = _ref2[1];
|
50
50
|
return [key, deepClone(value)];
|
@@ -55,13 +55,13 @@ function deepClone(value) {
|
|
55
55
|
}
|
56
56
|
function parseAndValidateArrayIndex(value) {
|
57
57
|
if (!/^(0|[1-9][0-9]*)$/g.test(value)) {
|
58
|
-
return result.err(new
|
58
|
+
return result.err(new dist_valbuildCore.PatchError("Invalid array index \"".concat(value, "\"")));
|
59
59
|
}
|
60
60
|
return result.ok(Number(value));
|
61
61
|
}
|
62
62
|
function sourceToPatchPath(sourcePath) {
|
63
|
-
var _splitModuleFilePathA =
|
64
|
-
_splitModuleFilePathA2 =
|
63
|
+
var _splitModuleFilePathA = dist_valbuildCore.splitModuleFilePathAndModulePath(sourcePath),
|
64
|
+
_splitModuleFilePathA2 = dist_valbuildCore._slicedToArray(_splitModuleFilePathA, 2),
|
65
65
|
modulePath = _splitModuleFilePathA2[1];
|
66
66
|
return modulePath.split(".").map(function (p) {
|
67
67
|
return JSON.parse(p).toString();
|
@@ -75,14 +75,14 @@ function parseAndValidateArrayInsertIndex(key, nodes) {
|
|
75
75
|
return util.pipe(parseAndValidateArrayIndex(key), result.filterOrElse(function (index) {
|
76
76
|
return index <= nodes.length;
|
77
77
|
}, function () {
|
78
|
-
return new
|
78
|
+
return new dist_valbuildCore.PatchError("Array index out of bounds");
|
79
79
|
}));
|
80
80
|
}
|
81
81
|
function parseAndValidateArrayInboundsIndex(key, nodes) {
|
82
82
|
return util.pipe(parseAndValidateArrayIndex(key), result.filterOrElse(function (index) {
|
83
83
|
return index < nodes.length;
|
84
84
|
}, function () {
|
85
|
-
return new
|
85
|
+
return new dist_valbuildCore.PatchError("Array index out of bounds");
|
86
86
|
}));
|
87
87
|
}
|
88
88
|
function replaceInNode(node, key, value) {
|
@@ -92,22 +92,22 @@ function replaceInNode(node, key, value) {
|
|
92
92
|
node[index] = value;
|
93
93
|
return replaced;
|
94
94
|
}));
|
95
|
-
} else if (
|
95
|
+
} else if (dist_valbuildCore._typeof(node) === "object" && node !== null) {
|
96
96
|
// Prototype pollution protection
|
97
97
|
if (Object.prototype.hasOwnProperty.call(node, key)) {
|
98
98
|
var replaced = node[key];
|
99
99
|
node[key] = value;
|
100
100
|
return result.ok(replaced);
|
101
101
|
} else {
|
102
|
-
return result.err(new
|
102
|
+
return result.err(new dist_valbuildCore.PatchError("Cannot replace object element which does not exist"));
|
103
103
|
}
|
104
104
|
}
|
105
|
-
return result.err(new
|
105
|
+
return result.err(new dist_valbuildCore.PatchError("Cannot replace in non-object/array"));
|
106
106
|
}
|
107
107
|
function replaceAtPath(document, path, value) {
|
108
108
|
if (isNotRoot(path)) {
|
109
109
|
return util.pipe(getPointerFromPath(document, path), result.flatMap(function (_ref) {
|
110
|
-
var _ref2 =
|
110
|
+
var _ref2 = dist_valbuildCore._slicedToArray(_ref, 2),
|
111
111
|
node = _ref2[0],
|
112
112
|
key = _ref2[1];
|
113
113
|
return replaceInNode(node, key, value);
|
@@ -122,12 +122,12 @@ function getFromNode(node, key) {
|
|
122
122
|
if (Array.isArray(node)) {
|
123
123
|
return util.pipe(parseAndValidateArrayIndex(key), result.flatMap(function (index) {
|
124
124
|
if (index >= node.length) {
|
125
|
-
return result.err(new
|
125
|
+
return result.err(new dist_valbuildCore.PatchError("Array index out of bounds"));
|
126
126
|
} else {
|
127
127
|
return result.ok(node[index]);
|
128
128
|
}
|
129
129
|
}));
|
130
|
-
} else if (
|
130
|
+
} else if (dist_valbuildCore._typeof(node) === "object" && node !== null) {
|
131
131
|
// Prototype pollution protection
|
132
132
|
if (Object.prototype.hasOwnProperty.call(node, key)) {
|
133
133
|
return result.ok(node[key]);
|
@@ -135,7 +135,7 @@ function getFromNode(node, key) {
|
|
135
135
|
return result.ok(undefined);
|
136
136
|
}
|
137
137
|
}
|
138
|
-
return result.err(new
|
138
|
+
return result.err(new dist_valbuildCore.PatchError("Cannot access non-object/array"));
|
139
139
|
}
|
140
140
|
function getPointerFromPath(node, path) {
|
141
141
|
var targetNode = node;
|
@@ -146,7 +146,7 @@ function getPointerFromPath(node, path) {
|
|
146
146
|
return childNode;
|
147
147
|
}
|
148
148
|
if (childNode.value === undefined) {
|
149
|
-
return result.err(new
|
149
|
+
return result.err(new dist_valbuildCore.PatchError("Path refers to non-existing object/array"));
|
150
150
|
}
|
151
151
|
targetNode = childNode.value;
|
152
152
|
}
|
@@ -157,7 +157,7 @@ function getAtPath(node, path) {
|
|
157
157
|
return util.pipe(getFromNode(node, key), result.filterOrElse(function (childNode) {
|
158
158
|
return childNode !== undefined;
|
159
159
|
}, function () {
|
160
|
-
return new
|
160
|
+
return new dist_valbuildCore.PatchError("Path refers to non-existing object/array");
|
161
161
|
}));
|
162
162
|
}, node));
|
163
163
|
}
|
@@ -165,11 +165,11 @@ function removeFromNode(node, key) {
|
|
165
165
|
if (Array.isArray(node)) {
|
166
166
|
return util.pipe(parseAndValidateArrayInboundsIndex(key, node), result.map(function (index) {
|
167
167
|
var _node$splice = node.splice(index, 1),
|
168
|
-
_node$splice2 =
|
168
|
+
_node$splice2 = dist_valbuildCore._slicedToArray(_node$splice, 1),
|
169
169
|
removed = _node$splice2[0];
|
170
170
|
return removed;
|
171
171
|
}));
|
172
|
-
} else if (
|
172
|
+
} else if (dist_valbuildCore._typeof(node) === "object" && node !== null) {
|
173
173
|
// Prototype pollution protection
|
174
174
|
if (Object.prototype.hasOwnProperty.call(node, key)) {
|
175
175
|
var removed = node[key];
|
@@ -177,11 +177,11 @@ function removeFromNode(node, key) {
|
|
177
177
|
return result.ok(removed);
|
178
178
|
}
|
179
179
|
}
|
180
|
-
return result.err(new
|
180
|
+
return result.err(new dist_valbuildCore.PatchError("Cannot remove from non-object/array"));
|
181
181
|
}
|
182
182
|
function removeAtPath(document, path) {
|
183
183
|
return util.pipe(getPointerFromPath(document, path), result.flatMap(function (_ref3) {
|
184
|
-
var _ref4 =
|
184
|
+
var _ref4 = dist_valbuildCore._slicedToArray(_ref3, 2),
|
185
185
|
node = _ref4[0],
|
186
186
|
key = _ref4[1];
|
187
187
|
return removeFromNode(node, key);
|
@@ -193,7 +193,7 @@ function addToNode(node, key, value) {
|
|
193
193
|
node.splice(index, 0, value);
|
194
194
|
return undefined;
|
195
195
|
}));
|
196
|
-
} else if (
|
196
|
+
} else if (dist_valbuildCore._typeof(node) === "object" && node !== null) {
|
197
197
|
var replaced;
|
198
198
|
// Prototype pollution protection
|
199
199
|
if (Object.prototype.hasOwnProperty.call(node, key)) {
|
@@ -202,12 +202,12 @@ function addToNode(node, key, value) {
|
|
202
202
|
node[key] = value;
|
203
203
|
return result.ok(replaced);
|
204
204
|
}
|
205
|
-
return result.err(new
|
205
|
+
return result.err(new dist_valbuildCore.PatchError("Cannot add to non-object/array"));
|
206
206
|
}
|
207
207
|
function addAtPath(document, path, value) {
|
208
208
|
if (isNotRoot(path)) {
|
209
209
|
return util.pipe(getPointerFromPath(document, path), result.flatMap(function (_ref5) {
|
210
|
-
var _ref6 =
|
210
|
+
var _ref6 = dist_valbuildCore._slicedToArray(_ref5, 2),
|
211
211
|
node = _ref6[0],
|
212
212
|
key = _ref6[1];
|
213
213
|
return addToNode(node, key, value);
|
@@ -219,15 +219,15 @@ function addAtPath(document, path, value) {
|
|
219
219
|
}
|
220
220
|
}
|
221
221
|
function pickDocument(_ref7) {
|
222
|
-
var _ref8 =
|
222
|
+
var _ref8 = dist_valbuildCore._slicedToArray(_ref7, 1),
|
223
223
|
document = _ref8[0];
|
224
224
|
return document;
|
225
225
|
}
|
226
226
|
var JSONOps = /*#__PURE__*/function () {
|
227
227
|
function JSONOps() {
|
228
|
-
|
228
|
+
dist_valbuildCore._classCallCheck(this, JSONOps);
|
229
229
|
}
|
230
|
-
return
|
230
|
+
return dist_valbuildCore._createClass(JSONOps, [{
|
231
231
|
key: "get",
|
232
232
|
value: function get(document, path) {
|
233
233
|
return getAtPath(document, path);
|
@@ -321,7 +321,7 @@ function prefixIssuePath(prefix, _ref) {
|
|
321
321
|
var path = _ref.path,
|
322
322
|
message = _ref.message;
|
323
323
|
return {
|
324
|
-
path: [prefix].concat(
|
324
|
+
path: [prefix].concat(dist_valbuildCore._toConsumableArray(path)),
|
325
325
|
message: message
|
326
326
|
};
|
327
327
|
}
|
@@ -368,7 +368,8 @@ function parseOperation(operation) {
|
|
368
368
|
op: operation.op,
|
369
369
|
path: path,
|
370
370
|
filePath: operation.filePath,
|
371
|
-
value: operation.value
|
371
|
+
value: operation.value,
|
372
|
+
remote: operation.remote
|
372
373
|
};
|
373
374
|
}));
|
374
375
|
case "remove":
|
@@ -386,14 +387,14 @@ function parseOperation(operation) {
|
|
386
387
|
return util.pipe(result.allT([util.pipe(parseJSONPointer(operation.from), result.filterOrElse(result.isNonEmpty, function () {
|
387
388
|
return "Cannot move root";
|
388
389
|
}), result.mapErr(createIssueAtPath(["from"]))), util.pipe(path, result.mapErr(createIssueAtPath(["path"])))]), result.filterOrElse(function (_ref2) {
|
389
|
-
var _ref3 =
|
390
|
+
var _ref3 = dist_valbuildCore._slicedToArray(_ref2, 2),
|
390
391
|
from = _ref3[0],
|
391
392
|
path = _ref3[1];
|
392
393
|
return !isProperPathPrefix(from, path);
|
393
394
|
}, function () {
|
394
395
|
return [createIssueAtPath(["from"])("Cannot be a proper prefix of path")];
|
395
396
|
}), result.map(function (_ref4) {
|
396
|
-
var _ref5 =
|
397
|
+
var _ref5 = dist_valbuildCore._slicedToArray(_ref4, 2),
|
397
398
|
from = _ref5[0],
|
398
399
|
path = _ref5[1];
|
399
400
|
return {
|
@@ -404,7 +405,7 @@ function parseOperation(operation) {
|
|
404
405
|
}));
|
405
406
|
case "copy":
|
406
407
|
return util.pipe(result.allT([util.pipe(parseJSONPointer(operation.from), result.mapErr(createIssueAtPath(["from"]))), util.pipe(path, result.mapErr(createIssueAtPath(["path"])))]), result.map(function (_ref6) {
|
407
|
-
var _ref7 =
|
408
|
+
var _ref7 = dist_valbuildCore._slicedToArray(_ref6, 2),
|
408
409
|
from = _ref7[0],
|
409
410
|
path = _ref7[1];
|
410
411
|
return {
|
@@ -436,13 +437,13 @@ function apply(document, ops, op) {
|
|
436
437
|
case "test":
|
437
438
|
{
|
438
439
|
if (!ops.test(document, op.path, op.value)) {
|
439
|
-
return result.err(new
|
440
|
+
return result.err(new dist_valbuildCore.PatchError("Test failed"));
|
440
441
|
}
|
441
442
|
return result.ok(document);
|
442
443
|
}
|
443
444
|
case "file":
|
444
445
|
{
|
445
|
-
return result.err(new
|
446
|
+
return result.err(new dist_valbuildCore.PatchError("Cannot apply a file patch here"));
|
446
447
|
}
|
447
448
|
}
|
448
449
|
}
|
@@ -452,7 +453,7 @@ function applyPatch(document, ops, patch) {
|
|
452
453
|
}, document));
|
453
454
|
}
|
454
455
|
|
455
|
-
exports.PatchError =
|
456
|
+
exports.PatchError = dist_valbuildCore.PatchError;
|
456
457
|
exports.JSONOps = JSONOps;
|
457
458
|
exports.applyPatch = applyPatch;
|
458
459
|
exports.deepClone = deepClone;
|