@valbuild/core 0.25.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.
Files changed (94) hide show
  1. package/dist/declarations/src/selector/future/index.d.ts +1 -1
  2. package/dist/declarations/src/source/future/i18n.d.ts +1 -1
  3. package/package.json +12 -3
  4. package/CHANGELOG.md +0 -0
  5. package/ROADMAP.md +0 -106
  6. package/jest.config.js +0 -4
  7. package/src/Json.ts +0 -4
  8. package/src/ValApi.ts +0 -81
  9. package/src/expr/README.md +0 -193
  10. package/src/expr/eval.test.ts +0 -198
  11. package/src/expr/eval.ts +0 -251
  12. package/src/expr/expr.ts +0 -91
  13. package/src/expr/index.ts +0 -3
  14. package/src/expr/parser.test.ts +0 -158
  15. package/src/expr/parser.ts +0 -229
  16. package/src/expr/repl.ts +0 -88
  17. package/src/expr/tokenizer.test.ts +0 -539
  18. package/src/expr/tokenizer.ts +0 -117
  19. package/src/fp/array.ts +0 -30
  20. package/src/fp/index.ts +0 -3
  21. package/src/fp/result.ts +0 -214
  22. package/src/fp/util.ts +0 -52
  23. package/src/future/fetchVal.test.ts +0 -164
  24. package/src/future/fetchVal.ts +0 -206
  25. package/src/getSha256.ts +0 -8
  26. package/src/index.ts +0 -132
  27. package/src/initSchema.ts +0 -50
  28. package/src/initVal.ts +0 -73
  29. package/src/module.test.ts +0 -170
  30. package/src/module.ts +0 -397
  31. package/src/patch/deref.test.ts +0 -298
  32. package/src/patch/deref.ts +0 -136
  33. package/src/patch/index.ts +0 -12
  34. package/src/patch/json.test.ts +0 -582
  35. package/src/patch/json.ts +0 -304
  36. package/src/patch/operation.ts +0 -86
  37. package/src/patch/ops.ts +0 -83
  38. package/src/patch/parse.test.ts +0 -202
  39. package/src/patch/parse.ts +0 -202
  40. package/src/patch/patch.ts +0 -49
  41. package/src/patch/util.ts +0 -74
  42. package/src/schema/array.ts +0 -93
  43. package/src/schema/boolean.ts +0 -49
  44. package/src/schema/future/i18n.ts +0 -69
  45. package/src/schema/future/oneOf.ts +0 -63
  46. package/src/schema/image.ts +0 -137
  47. package/src/schema/index.ts +0 -70
  48. package/src/schema/keyOf.ts +0 -167
  49. package/src/schema/literal.ts +0 -63
  50. package/src/schema/number.ts +0 -56
  51. package/src/schema/object.ts +0 -110
  52. package/src/schema/record.ts +0 -103
  53. package/src/schema/richtext.ts +0 -44
  54. package/src/schema/string.ts +0 -95
  55. package/src/schema/union.ts +0 -63
  56. package/src/schema/validation/ValidationError.ts +0 -16
  57. package/src/schema/validation/ValidationFix.ts +0 -6
  58. package/src/schema/validation.test.ts +0 -291
  59. package/src/selector/SelectorProxy.ts +0 -238
  60. package/src/selector/array.ts +0 -13
  61. package/src/selector/boolean.ts +0 -4
  62. package/src/selector/file.ts +0 -6
  63. package/src/selector/future/ExprProxy.test.ts +0 -203
  64. package/src/selector/future/ExprProxy.ts +0 -216
  65. package/src/selector/future/SelectorProxy.test.ts +0 -172
  66. package/src/selector/future/SelectorProxy.ts +0 -238
  67. package/src/selector/future/array.ts +0 -37
  68. package/src/selector/future/boolean.ts +0 -4
  69. package/src/selector/future/file.ts +0 -14
  70. package/src/selector/future/i18n.ts +0 -13
  71. package/src/selector/future/index.ts +0 -169
  72. package/src/selector/future/number.ts +0 -4
  73. package/src/selector/future/object.ts +0 -22
  74. package/src/selector/future/primitive.ts +0 -17
  75. package/src/selector/future/remote.ts +0 -9
  76. package/src/selector/future/selector.test.ts +0 -429
  77. package/src/selector/future/selectorOf.ts +0 -7
  78. package/src/selector/future/string.ts +0 -4
  79. package/src/selector/index.ts +0 -121
  80. package/src/selector/number.ts +0 -4
  81. package/src/selector/object.ts +0 -5
  82. package/src/selector/primitive.ts +0 -4
  83. package/src/selector/string.ts +0 -4
  84. package/src/source/file.ts +0 -45
  85. package/src/source/future/i18n.ts +0 -60
  86. package/src/source/future/remote.ts +0 -54
  87. package/src/source/index.ts +0 -53
  88. package/src/source/link.ts +0 -14
  89. package/src/source/richtext.ts +0 -178
  90. package/src/val/array.ts +0 -10
  91. package/src/val/index.ts +0 -100
  92. package/src/val/object.ts +0 -13
  93. package/src/val/primitive.ts +0 -8
  94. package/tsconfig.json +0 -8
@@ -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
- }
@@ -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";