@valbuild/core 0.26.0 → 0.27.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/package.json +12 -3
- package/CHANGELOG.md +0 -0
- package/ROADMAP.md +0 -106
- package/jest.config.js +0 -4
- package/src/Json.ts +0 -4
- package/src/ValApi.ts +0 -81
- package/src/expr/README.md +0 -193
- package/src/expr/eval.test.ts +0 -198
- package/src/expr/eval.ts +0 -251
- package/src/expr/expr.ts +0 -91
- package/src/expr/index.ts +0 -3
- package/src/expr/parser.test.ts +0 -158
- package/src/expr/parser.ts +0 -229
- package/src/expr/repl.ts +0 -88
- package/src/expr/tokenizer.test.ts +0 -539
- package/src/expr/tokenizer.ts +0 -117
- package/src/fp/array.ts +0 -30
- package/src/fp/index.ts +0 -3
- package/src/fp/result.ts +0 -214
- package/src/fp/util.ts +0 -52
- package/src/future/fetchVal.test.ts +0 -164
- package/src/future/fetchVal.ts +0 -206
- package/src/getSha256.ts +0 -8
- package/src/index.ts +0 -132
- package/src/initSchema.ts +0 -50
- package/src/initVal.ts +0 -73
- package/src/module.test.ts +0 -170
- package/src/module.ts +0 -397
- package/src/patch/deref.test.ts +0 -298
- package/src/patch/deref.ts +0 -136
- package/src/patch/index.ts +0 -12
- package/src/patch/json.test.ts +0 -582
- package/src/patch/json.ts +0 -304
- package/src/patch/operation.ts +0 -86
- package/src/patch/ops.ts +0 -83
- package/src/patch/parse.test.ts +0 -202
- package/src/patch/parse.ts +0 -202
- package/src/patch/patch.ts +0 -49
- package/src/patch/util.ts +0 -74
- package/src/schema/array.ts +0 -93
- package/src/schema/boolean.ts +0 -49
- package/src/schema/future/i18n.ts +0 -69
- package/src/schema/future/oneOf.ts +0 -63
- package/src/schema/image.ts +0 -137
- package/src/schema/index.ts +0 -70
- package/src/schema/keyOf.ts +0 -167
- package/src/schema/literal.ts +0 -63
- package/src/schema/number.ts +0 -56
- package/src/schema/object.ts +0 -110
- package/src/schema/record.ts +0 -103
- package/src/schema/richtext.ts +0 -44
- package/src/schema/string.ts +0 -95
- package/src/schema/union.ts +0 -63
- package/src/schema/validation/ValidationError.ts +0 -16
- package/src/schema/validation/ValidationFix.ts +0 -6
- package/src/schema/validation.test.ts +0 -291
- package/src/selector/SelectorProxy.ts +0 -238
- package/src/selector/array.ts +0 -13
- package/src/selector/boolean.ts +0 -4
- package/src/selector/file.ts +0 -6
- package/src/selector/future/ExprProxy.test.ts +0 -203
- package/src/selector/future/ExprProxy.ts +0 -216
- package/src/selector/future/SelectorProxy.test.ts +0 -172
- package/src/selector/future/SelectorProxy.ts +0 -238
- package/src/selector/future/array.ts +0 -37
- package/src/selector/future/boolean.ts +0 -4
- package/src/selector/future/file.ts +0 -14
- package/src/selector/future/i18n.ts +0 -13
- package/src/selector/future/index.ts +0 -169
- package/src/selector/future/number.ts +0 -4
- package/src/selector/future/object.ts +0 -22
- package/src/selector/future/primitive.ts +0 -17
- package/src/selector/future/remote.ts +0 -9
- package/src/selector/future/selector.test.ts +0 -429
- package/src/selector/future/selectorOf.ts +0 -7
- package/src/selector/future/string.ts +0 -4
- package/src/selector/index.ts +0 -121
- package/src/selector/number.ts +0 -4
- package/src/selector/object.ts +0 -5
- package/src/selector/primitive.ts +0 -4
- package/src/selector/string.ts +0 -4
- package/src/source/file.ts +0 -45
- package/src/source/future/i18n.ts +0 -60
- package/src/source/future/remote.ts +0 -54
- package/src/source/index.ts +0 -53
- package/src/source/link.ts +0 -14
- package/src/source/richtext.ts +0 -178
- package/src/val/array.ts +0 -10
- package/src/val/index.ts +0 -100
- package/src/val/object.ts +0 -13
- package/src/val/primitive.ts +0 -8
- package/tsconfig.json +0 -8
package/src/patch/deref.ts
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
import { FILE_REF_PROP, isFile } from "../source/file";
|
2
|
-
import { result } from "../fp";
|
3
|
-
import { isRemote, REMOTE_REF_PROP } from "../source/future/remote";
|
4
|
-
import { Ops, PatchError } from "./ops";
|
5
|
-
import { Patch } from "./patch";
|
6
|
-
import { Operation } from "./operation";
|
7
|
-
|
8
|
-
function derefPath(
|
9
|
-
path: string[]
|
10
|
-
): result.Result<[string[], string[] | null], PatchError> {
|
11
|
-
const dereffedPath: string[] = [];
|
12
|
-
let referencedPath: string[] | null = null;
|
13
|
-
for (const segment of path) {
|
14
|
-
if (segment.startsWith("$")) {
|
15
|
-
const dereffedSegment = segment.slice(1);
|
16
|
-
dereffedPath.push(dereffedSegment);
|
17
|
-
referencedPath = [];
|
18
|
-
for (const segment of path.slice(dereffedPath.length)) {
|
19
|
-
if (segment.startsWith("$")) {
|
20
|
-
return result.err(
|
21
|
-
new PatchError(
|
22
|
-
`Cannot reference within reference: ${segment}. Path: ${path.join(
|
23
|
-
"/"
|
24
|
-
)}`
|
25
|
-
)
|
26
|
-
);
|
27
|
-
}
|
28
|
-
referencedPath.push(segment);
|
29
|
-
}
|
30
|
-
break;
|
31
|
-
} else {
|
32
|
-
dereffedPath.push(segment);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
return result.ok([dereffedPath, referencedPath]);
|
36
|
-
}
|
37
|
-
|
38
|
-
export type DerefPatchResult = {
|
39
|
-
dereferencedPatch: Patch;
|
40
|
-
fileUpdates: { [path: string]: string };
|
41
|
-
};
|
42
|
-
|
43
|
-
export function derefPatch<D, E>(
|
44
|
-
patch: Operation[],
|
45
|
-
document: D,
|
46
|
-
ops: Ops<D, E>
|
47
|
-
): result.Result<DerefPatchResult, E | PatchError> {
|
48
|
-
const fileUpdates: {
|
49
|
-
[file: string]: string;
|
50
|
-
} = {};
|
51
|
-
const dereferencedPatch: Patch = [];
|
52
|
-
for (const op of patch) {
|
53
|
-
if (op.op === "replace") {
|
54
|
-
const maybeDerefRes = derefPath(op.path);
|
55
|
-
if (result.isErr(maybeDerefRes)) {
|
56
|
-
return maybeDerefRes;
|
57
|
-
}
|
58
|
-
const [dereffedPath, referencedPath] = maybeDerefRes.value;
|
59
|
-
if (referencedPath) {
|
60
|
-
const maybeValue = ops.get(document, dereffedPath);
|
61
|
-
if (result.isOk(maybeValue)) {
|
62
|
-
const value = maybeValue.value;
|
63
|
-
if (isFile(value)) {
|
64
|
-
if (referencedPath.length > 0) {
|
65
|
-
return result.err(
|
66
|
-
new PatchError(
|
67
|
-
`Cannot sub-reference file reference at path: ${dereffedPath.join(
|
68
|
-
"/"
|
69
|
-
)}`
|
70
|
-
)
|
71
|
-
);
|
72
|
-
}
|
73
|
-
if (typeof op.value !== "string") {
|
74
|
-
return result.err(
|
75
|
-
new PatchError(
|
76
|
-
`Expected base64 encoded string value for file reference, got ${JSON.stringify(
|
77
|
-
op.value
|
78
|
-
)}`
|
79
|
-
)
|
80
|
-
);
|
81
|
-
}
|
82
|
-
fileUpdates[value[FILE_REF_PROP]] = op.value;
|
83
|
-
// } else if (isRemote(value)) {
|
84
|
-
// if (!remotePatches[value[REMOTE_REF_PROP]]) {
|
85
|
-
// remotePatches[value[REMOTE_REF_PROP]] = [];
|
86
|
-
// }
|
87
|
-
// remotePatches[value[REMOTE_REF_PROP]].push({
|
88
|
-
// op: "replace",
|
89
|
-
// path: referencedPath,
|
90
|
-
// value: op.value,
|
91
|
-
// });
|
92
|
-
} else {
|
93
|
-
return result.err(
|
94
|
-
new PatchError(
|
95
|
-
`Unknown reference: ${JSON.stringify(
|
96
|
-
op
|
97
|
-
)} at path: ${dereffedPath.join("/")}`
|
98
|
-
)
|
99
|
-
);
|
100
|
-
}
|
101
|
-
} else {
|
102
|
-
return maybeValue;
|
103
|
-
}
|
104
|
-
} else {
|
105
|
-
dereferencedPatch.push(op);
|
106
|
-
}
|
107
|
-
} else if (op.op === "file") {
|
108
|
-
if (!op.filePath.startsWith("/public")) {
|
109
|
-
return result.err(new PatchError(`Path must start with /public`));
|
110
|
-
}
|
111
|
-
if (typeof op.value !== "string") {
|
112
|
-
return result.err(
|
113
|
-
new PatchError(
|
114
|
-
`File operation must have a value that is typeof string. Found: ${typeof op.value}`
|
115
|
-
)
|
116
|
-
);
|
117
|
-
}
|
118
|
-
fileUpdates[op.filePath] = op.value;
|
119
|
-
} else {
|
120
|
-
const maybeDerefRes = derefPath(op.path);
|
121
|
-
if (result.isErr(maybeDerefRes)) {
|
122
|
-
return maybeDerefRes;
|
123
|
-
}
|
124
|
-
const [, referencedPath] = maybeDerefRes.value;
|
125
|
-
if (referencedPath) {
|
126
|
-
throw new Error(`Unimplemented operation: ${JSON.stringify(op)}`);
|
127
|
-
}
|
128
|
-
dereferencedPatch.push(op);
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
return result.ok({
|
133
|
-
fileUpdates,
|
134
|
-
dereferencedPatch,
|
135
|
-
});
|
136
|
-
}
|
package/src/patch/index.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
export { JSONOps } from "./json";
|
2
|
-
export { type OperationJSON, type Operation } from "./operation";
|
3
|
-
export { parsePatch, parseJSONPointer, formatJSONPointer } from "./parse";
|
4
|
-
export { type JSONValue, type Ops, PatchError } from "./ops";
|
5
|
-
export { type PatchJSON, type Patch, applyPatch } from "./patch";
|
6
|
-
export {
|
7
|
-
isNotRoot,
|
8
|
-
deepEqual,
|
9
|
-
deepClone,
|
10
|
-
parseAndValidateArrayIndex,
|
11
|
-
sourceToPatchPath,
|
12
|
-
} from "./util";
|