@valbuild/core 0.72.3 → 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.
Files changed (56) hide show
  1. package/dist/declarations/src/index.d.ts +20 -4
  2. package/dist/declarations/src/initSchema.d.ts +4 -4
  3. package/dist/declarations/src/initVal.d.ts +3 -1
  4. package/dist/declarations/src/patch/index.d.ts +1 -1
  5. package/dist/declarations/src/patch/operation.d.ts +3 -0
  6. package/dist/declarations/src/remote/fileHash.d.ts +5 -0
  7. package/dist/declarations/src/remote/splitRemoteRef.d.ts +13 -0
  8. package/dist/declarations/src/remote/validationBasis.d.ts +13 -0
  9. package/dist/declarations/src/schema/file.d.ts +7 -3
  10. package/dist/declarations/src/schema/image.d.ts +7 -3
  11. package/dist/declarations/src/schema/remote.d.ts +11 -0
  12. package/dist/declarations/src/schema/richtext.d.ts +16 -7
  13. package/dist/declarations/src/schema/string.d.ts +8 -0
  14. package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
  15. package/dist/declarations/src/selector/index.d.ts +2 -1
  16. package/dist/declarations/src/source/file.d.ts +2 -2
  17. package/dist/declarations/src/source/image.d.ts +2 -2
  18. package/dist/declarations/src/source/index.d.ts +3 -4
  19. package/dist/declarations/src/source/remote.d.ts +22 -0
  20. package/dist/declarations/src/source/richtext.d.ts +30 -3
  21. package/dist/declarations/src/val/index.d.ts +4 -3
  22. package/dist/{index-380b80a1.cjs.prod.js → index-da9933cf.cjs.prod.js} +687 -1412
  23. package/dist/{index-7ae61742.cjs.dev.js → index-f6fd3df3.cjs.dev.js} +687 -1412
  24. package/dist/{index-7218e8b1.esm.js → index-fee3aa6d.esm.js} +688 -1405
  25. package/dist/{result-168dfc1d.esm.js → result-daff1cae.esm.js} +1 -1
  26. package/dist/valbuild-core.cjs.dev.js +27 -27
  27. package/dist/valbuild-core.cjs.prod.js +27 -27
  28. package/dist/valbuild-core.esm.js +2 -2
  29. package/fp/dist/valbuild-core-fp.esm.js +1 -1
  30. package/package.json +2 -9
  31. package/patch/dist/valbuild-core-patch.cjs.dev.js +38 -37
  32. package/patch/dist/valbuild-core-patch.cjs.prod.js +38 -37
  33. package/patch/dist/valbuild-core-patch.esm.js +5 -4
  34. package/dist/declarations/src/expr/eval.d.ts +0 -20
  35. package/dist/declarations/src/expr/expr.d.ts +0 -32
  36. package/dist/declarations/src/expr/index.d.ts +0 -3
  37. package/dist/declarations/src/expr/parser.d.ts +0 -8
  38. package/dist/declarations/src/future/fetchVal.d.ts +0 -5
  39. package/dist/declarations/src/selector/future/array.d.ts +0 -17
  40. package/dist/declarations/src/selector/future/boolean.d.ts +0 -2
  41. package/dist/declarations/src/selector/future/file.d.ts +0 -9
  42. package/dist/declarations/src/selector/future/i18n.d.ts +0 -11
  43. package/dist/declarations/src/selector/future/index.d.ts +0 -82
  44. package/dist/declarations/src/selector/future/number.d.ts +0 -2
  45. package/dist/declarations/src/selector/future/object.d.ts +0 -10
  46. package/dist/declarations/src/selector/future/primitive.d.ts +0 -9
  47. package/dist/declarations/src/selector/future/remote.d.ts +0 -7
  48. package/dist/declarations/src/selector/future/string.d.ts +0 -2
  49. package/dist/declarations/src/source/future/i18n.d.ts +0 -29
  50. package/dist/declarations/src/source/future/remote.d.ts +0 -29
  51. package/expr/dist/valbuild-core-expr.cjs.d.ts +0 -2
  52. package/expr/dist/valbuild-core-expr.cjs.dev.js +0 -17
  53. package/expr/dist/valbuild-core-expr.cjs.js +0 -7
  54. package/expr/dist/valbuild-core-expr.cjs.prod.js +0 -17
  55. package/expr/dist/valbuild-core-expr.esm.js +0 -2
  56. package/expr/package.json +0 -4
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var expr_dist_valbuildCoreExpr = require('../../dist/index-380b80a1.cjs.prod.js');
5
+ var dist_valbuildCore = require('../../dist/index-da9933cf.cjs.prod.js');
6
6
  var result = require('../../dist/result-787e35f6.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
8
 
@@ -13,7 +13,7 @@ function deepEqual(a, b) {
13
13
  if (a === b) {
14
14
  return true;
15
15
  }
16
- if (expr_dist_valbuildCoreExpr._typeof(a) === "object" && expr_dist_valbuildCoreExpr._typeof(b) === "object" && a !== null && b !== null) {
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 = expr_dist_valbuildCoreExpr._slicedToArray(_aEntries[_i], 2),
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 (expr_dist_valbuildCoreExpr._typeof(value) === "object" && value !== null) {
45
+ } else if (dist_valbuildCore._typeof(value) === "object" && value !== null) {
46
46
  return Object.fromEntries(Object.entries(value).map(function (_ref) {
47
- var _ref2 = expr_dist_valbuildCoreExpr._slicedToArray(_ref, 2),
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 expr_dist_valbuildCoreExpr.PatchError("Invalid array index \"".concat(value, "\"")));
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 = expr_dist_valbuildCoreExpr.splitModuleFilePathAndModulePath(sourcePath),
64
- _splitModuleFilePathA2 = expr_dist_valbuildCoreExpr._slicedToArray(_splitModuleFilePathA, 2),
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 expr_dist_valbuildCoreExpr.PatchError("Array index out of bounds");
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 expr_dist_valbuildCoreExpr.PatchError("Array index out of bounds");
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 (expr_dist_valbuildCoreExpr._typeof(node) === "object" && node !== null) {
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 expr_dist_valbuildCoreExpr.PatchError("Cannot replace object element which does not exist"));
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 expr_dist_valbuildCoreExpr.PatchError("Cannot replace in non-object/array"));
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref, 2),
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 expr_dist_valbuildCoreExpr.PatchError("Array index out of bounds"));
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 (expr_dist_valbuildCoreExpr._typeof(node) === "object" && node !== null) {
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 expr_dist_valbuildCoreExpr.PatchError("Cannot access non-object/array"));
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 expr_dist_valbuildCoreExpr.PatchError("Path refers to non-existing object/array"));
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 expr_dist_valbuildCoreExpr.PatchError("Path refers to non-existing object/array");
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 = expr_dist_valbuildCoreExpr._slicedToArray(_node$splice, 1),
168
+ _node$splice2 = dist_valbuildCore._slicedToArray(_node$splice, 1),
169
169
  removed = _node$splice2[0];
170
170
  return removed;
171
171
  }));
172
- } else if (expr_dist_valbuildCoreExpr._typeof(node) === "object" && node !== null) {
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 expr_dist_valbuildCoreExpr.PatchError("Cannot remove from non-object/array"));
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref3, 2),
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 (expr_dist_valbuildCoreExpr._typeof(node) === "object" && node !== null) {
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 expr_dist_valbuildCoreExpr.PatchError("Cannot add to non-object/array"));
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref5, 2),
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref7, 1),
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
- expr_dist_valbuildCoreExpr._classCallCheck(this, JSONOps);
228
+ dist_valbuildCore._classCallCheck(this, JSONOps);
229
229
  }
230
- return expr_dist_valbuildCoreExpr._createClass(JSONOps, [{
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(expr_dist_valbuildCoreExpr._toConsumableArray(path)),
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref2, 2),
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref4, 2),
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 = expr_dist_valbuildCoreExpr._slicedToArray(_ref6, 2),
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 expr_dist_valbuildCoreExpr.PatchError("Test failed"));
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 expr_dist_valbuildCoreExpr.PatchError("Cannot apply a file patch here"));
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 = expr_dist_valbuildCoreExpr.PatchError;
456
+ exports.PatchError = dist_valbuildCore.PatchError;
456
457
  exports.JSONOps = JSONOps;
457
458
  exports.applyPatch = applyPatch;
458
459
  exports.deepClone = deepClone;
@@ -1,6 +1,6 @@
1
- import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-7218e8b1.esm.js';
2
- export { P as PatchError } from '../../dist/index-7218e8b1.esm.js';
3
- import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-168dfc1d.esm.js';
1
+ import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-fee3aa6d.esm.js';
2
+ export { P as PatchError } from '../../dist/index-fee3aa6d.esm.js';
3
+ import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
4
4
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
5
5
 
6
6
  function isNotRoot(path) {
@@ -365,7 +365,8 @@ function parseOperation(operation) {
365
365
  op: operation.op,
366
366
  path: path,
367
367
  filePath: operation.filePath,
368
- value: operation.value
368
+ value: operation.value,
369
+ remote: operation.remote
369
370
  };
370
371
  }));
371
372
  case "remove":
@@ -1,20 +0,0 @@
1
- import { Expr } from "./expr.js";
2
- import { Source } from "../source/index.js";
3
- import { result } from "../fp/index.js";
4
- import { Path, SourceOrExpr } from "../selector/future/index.js";
5
- import { SourcePath } from "../val/index.js";
6
- import { Json } from "../Json.js";
7
- export declare class EvalError {
8
- readonly message: string;
9
- readonly expr: Expr;
10
- constructor(message: string, expr: Expr);
11
- toString(): string;
12
- }
13
- type LocalSelector<S extends Source> = {
14
- readonly [key: string | number]: LocalSelector<Source> | ((...args: any[]) => any);
15
- } & {
16
- [SourceOrExpr]: S;
17
- [Path]: SourcePath | undefined;
18
- };
19
- export declare function evaluate(expr: Expr, source: (ref: string) => Json, stack: readonly LocalSelector<Source>[][]): result.Result<LocalSelector<Source>, EvalError>;
20
- export {};
@@ -1,32 +0,0 @@
1
- export declare abstract class Expr {
2
- readonly span?: [number, (number | undefined)?] | undefined;
3
- abstract type: "StringLiteral" | "Sym" | "StringTemplate" | "Call";
4
- abstract transpile(): string;
5
- constructor(span?: [number, (number | undefined)?] | undefined);
6
- }
7
- export declare class StringLiteral extends Expr {
8
- readonly value: string;
9
- type: "StringLiteral";
10
- constructor(value: string, span?: [start: number, stop: number]);
11
- transpile(): string;
12
- }
13
- export declare class Sym extends Expr {
14
- readonly value: string;
15
- type: "Sym";
16
- constructor(value: string, span?: [start: number, stop: number]);
17
- transpile(): string;
18
- }
19
- export declare const NilSym: Sym;
20
- export declare class StringTemplate extends Expr {
21
- readonly children: readonly Expr[];
22
- type: "StringTemplate";
23
- constructor(children: readonly Expr[], span?: [number, number]);
24
- transpile(): string;
25
- }
26
- export declare class Call extends Expr {
27
- readonly children: readonly Expr[];
28
- readonly isAnon: boolean;
29
- type: "Call";
30
- constructor(children: readonly Expr[], isAnon: boolean, span?: [number, number]);
31
- transpile(): string;
32
- }
@@ -1,3 +0,0 @@
1
- export { parse } from "./parser.js";
2
- export { Call, Expr, NilSym, StringLiteral, StringTemplate, Sym } from "./expr.js";
3
- export { evaluate } from "./eval.js";
@@ -1,8 +0,0 @@
1
- import { result } from "../fp/index.js";
2
- import { Expr } from "./expr.js";
3
- export declare class ParserError {
4
- readonly message: string;
5
- readonly span?: [number, (number | undefined)?] | undefined;
6
- constructor(message: string, span?: [number, (number | undefined)?] | undefined);
7
- }
8
- export declare function parse(input: string): result.Result<Expr, ParserError>;
@@ -1,5 +0,0 @@
1
- import { GenericSelector, SelectorOf, SelectorSource } from "../selector/index.js";
2
- import { JsonOfSource, Val } from "../val/index.js";
3
- export declare function fetchVal<T extends SelectorSource>(selector: T): SelectorOf<T> extends GenericSelector<infer S> ? Promise<Val<JsonOfSource<S>>> : never;
4
- export declare function getVal<T extends SelectorSource>(selector: T): SelectorOf<T> extends GenericSelector<infer S> ? Val<JsonOfSource<S>> : never;
5
- export declare function serializedValOfSelectorSource<T extends SelectorSource>(selector: T): any;
@@ -1,17 +0,0 @@
1
- import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from "./index.js";
2
- import { Schema } from "../../schema/index.js";
3
- import { Source, SourceArray } from "../../source/index.js";
4
- import { Selector as BooleanSelector } from "./boolean.js";
5
- import { Selector as NumberSelector } from "./number.js";
6
- export type UndistributedSourceArray<T extends SourceArray> = [T] extends [
7
- infer U
8
- ] ? U extends Source[] ? Selector<U> : never : never;
9
- export type Selector<T extends SourceArray> = GenericSelector<T> & {
10
- readonly [key: number]: UnknownSelector<T[number]>;
11
- } & {
12
- length: NumberSelector<number>;
13
- filter(predicate: (v: UnknownSelector<T[number]>) => BooleanSelector<boolean> | boolean): Selector<T>;
14
- filter<U extends Source>(schema: Schema<U>): Selector<U[]>;
15
- map<U extends SelectorSource>(f: (v: UnknownSelector<T[number]>, i: UnknownSelector<number>) => U): SelectorOf<U[]>;
16
- andThen<U extends SelectorSource>(f: (v: UnknownSelector<NonNullable<T>>) => U): SelectorOf<U | T>;
17
- };
@@ -1,2 +0,0 @@
1
- import { Selector as PrimitiveSelector } from "./primitive.js";
2
- export type Selector<T extends boolean> = PrimitiveSelector<T>;
@@ -1,9 +0,0 @@
1
- import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from "./index.js";
2
- export type FileSelector = GenericSelector<{
3
- url: string;
4
- }> & {
5
- readonly url: UnknownSelector<string>;
6
- andThen<U extends SelectorSource>(f: (v: UnknownSelector<NonNullable<{
7
- url: string;
8
- }>>) => U): SelectorOf<U> | UnknownSelector<boolean>;
9
- };
@@ -1,11 +0,0 @@
1
- import { SourceArray, SourceObject, SourcePrimitive } from "../../source/index.js";
2
- import { Selector as UnknownSelector } from "./index.js";
3
- import { FileSource } from "../../source/file.js";
4
- declare const brand: unique symbol;
5
- export type I18nSelector<Locales extends readonly string[], T extends SourcePrimitive | SourceObject | SourceArray | FileSource> = UnknownSelector<T> & {
6
- readonly [brand]: "I18nSelector";
7
- all(): {
8
- [locale in Locales[number]]: UnknownSelector<T>;
9
- };
10
- };
11
- export {};
@@ -1,82 +0,0 @@
1
- import { I18nSelector } from "./i18n.js";
2
- import { Selector as ObjectSelector } from "./object.js";
3
- import { UndistributedSourceArray as ArraySelector } from "./array.js";
4
- import { Selector as NumberSelector } from "./number.js";
5
- import { Selector as StringSelector } from "./string.js";
6
- import { Selector as BooleanSelector } from "./boolean.js";
7
- import { Selector as PrimitiveSelector } from "./primitive.js";
8
- import { FileSelector } from "./file.js";
9
- import { SourcePath } from "../../val/index.js";
10
- import { Source, SourceArray, SourceObject, SourcePrimitive } from "../../source/index.js";
11
- import { Schema } from "../../schema/index.js";
12
- import { Expr } from "../../expr/expr.js";
13
- import { RemoteSelector } from "./remote.js";
14
- import type { A } from "ts-toolbelt";
15
- import { I18nSource, I18nCompatibleSource } from "../../source/future/i18n.js";
16
- import { RemoteCompatibleSource, RemoteSource } from "../../source/future/remote.js";
17
- import { FileSource } from "../../source/file.js";
18
- import { AllRichTextOptions, RichTextSource } from "../../source/richtext.js";
19
- import { RichTextSelector } from "../richtext.js";
20
- /**
21
- * Selectors can be used to select parts of a Val module.
22
- * Unlike queries, joins, aggregates etc is and will not be supported.
23
- *
24
- * They are designed to be be used as if they were "normal" JSON data,
25
- * though some concessions had to be made because of TypeScript limitations.
26
- *
27
- * Selectors works equally on source content, defined in code, and remote content.
28
- *
29
- * @example
30
- * // Select the title of a document
31
- * const titles = useVal(docsVal.map((doc) => doc.title));
32
- *
33
- * @example
34
- * // Match on a union type
35
- * const titles = useVal(docsVal.map((doc) => doc.fold("type")({
36
- * newsletter: (newsletter) => newsletter.title,
37
- * email: (email) => email.subject,
38
- * }));
39
- *
40
- */
41
- export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends I18nSource<infer L, infer S> ? I18nSelector<L, S> : T extends RemoteSource<infer S> ? S extends RemoteCompatibleSource ? RemoteSelector<S> : GenericSelector<Source, "Could not determine remote source"> : T extends FileSource ? FileSelector : T extends RichTextSource<infer O> ? RichTextSelector<O> : T extends SourceObject ? ObjectSelector<T> : T extends SourceArray ? ArraySelector<T> : T extends string ? StringSelector<T> : T extends number ? NumberSelector<T> : T extends boolean ? BooleanSelector<T> : T extends null ? PrimitiveSelector<null> : never;
42
- export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSource[] | {
43
- [key: string]: SelectorSource;
44
- } | I18nSource<readonly string[], I18nCompatibleSource> | RemoteSource<RemoteCompatibleSource> | FileSource | RichTextSource<AllRichTextOptions> | GenericSelector<Source>;
45
- /**
46
- * @internal
47
- */
48
- export declare const GetSchema: unique symbol;
49
- /**
50
- /**
51
- * @internal
52
- */
53
- export declare const Path: unique symbol;
54
- /**
55
- * @internal
56
- */
57
- export declare const SourceOrExpr: unique symbol;
58
- /**
59
- * @internal
60
- */
61
- export declare const ValError: unique symbol;
62
- export declare abstract class GenericSelector<out T extends Source, Error extends string | undefined = undefined> {
63
- readonly [Path]: SourcePath | undefined;
64
- readonly [SourceOrExpr]: T | Expr;
65
- readonly [ValError]: Error | undefined;
66
- readonly [GetSchema]: Schema<T> | undefined;
67
- constructor(valOrExpr: T, path: SourcePath | undefined, schema?: Schema<T>, error?: Error);
68
- assert<U extends Source, E extends Source = null>(schema: Schema<U>, other?: () => E): SelectorOf<U | E>;
69
- }
70
- export type SourceOf<T extends SelectorSource> = Source extends T ? Source : T extends Source ? T : T extends undefined ? null : T extends GenericSelector<infer S> ? S : T extends readonly (infer S)[] ? S extends SelectorSource ? {
71
- [key in keyof T]: SourceOf<A.Try<T[key], SelectorSource>>;
72
- } : never : T extends {
73
- [key: string]: SelectorSource;
74
- } ? {
75
- [key in keyof T]: SourceOf<A.Try<T[key], SelectorSource>>;
76
- } : never;
77
- /**
78
- * Use this type to convert types that accepts both Source and Selectors
79
- *
80
- * An example would be where literals are supported like in most higher order functions (e.g. map in array)
81
- **/
82
- export type SelectorOf<U extends SelectorSource> = Source extends U ? GenericSelector<Source> : SourceOf<U> extends infer S ? S extends Source ? Selector<S> : GenericSelector<Source, "Could not determine selector of source"> : GenericSelector<Source, "Could not determine source">;
@@ -1,2 +0,0 @@
1
- import { Selector as PrimitiveSelector } from "./primitive.js";
2
- export type Selector<T extends number> = PrimitiveSelector<T>;
@@ -1,10 +0,0 @@
1
- import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from "./index.js";
2
- import { SourceObject } from "../../source/index.js";
3
- export type Selector<T extends SourceObject> = GenericSelector<T> & {
4
- fold<Tag extends string>(key: Tag): <U extends SelectorSource>(cases: {
5
- [key in T[Tag & keyof T] & string]: (v: UnknownSelector<T>) => U;
6
- }) => SelectorOf<U>;
7
- andThen<U extends SelectorSource>(f: (v: UnknownSelector<NonNullable<T>>) => U): SelectorOf<U>;
8
- } & {
9
- readonly [key in keyof T]: UnknownSelector<T[key]>;
10
- };
@@ -1,9 +0,0 @@
1
- import { Selector as UnknownSelector, GenericSelector, SelectorOf, SelectorSource } from "./index.js";
2
- import { Source, SourcePrimitive } from "../../source/index.js";
3
- import { Selector as BooleanSelector } from "./boolean.js";
4
- export type Selector<T extends SourcePrimitive> = GenericSelector<T> & {
5
- eq(other: Source): BooleanSelector<boolean>;
6
- andThen<U extends SelectorSource>(f: (v: UnknownSelector<NonNullable<T>>) => U): SelectorOf<U | NullableOf<T>>;
7
- };
8
- type NullableOf<T extends Source> = T extends null ? null : never;
9
- export {};
@@ -1,7 +0,0 @@
1
- import { Selector as UnknownSelector } from "./index.js";
2
- import { RemoteCompatibleSource } from "../../source/future/remote.js";
3
- declare const brand: unique symbol;
4
- export type RemoteSelector<T extends RemoteCompatibleSource> = UnknownSelector<T> & {
5
- readonly [brand]: "RemoteSelector";
6
- };
7
- export {};
@@ -1,2 +0,0 @@
1
- import { Selector as PrimitiveSelector } from "./primitive.js";
2
- export type Selector<T extends string> = PrimitiveSelector<T>;
@@ -1,29 +0,0 @@
1
- import type { F } from "ts-toolbelt";
2
- import { SourcePrimitive, VAL_EXTENSION } from "../index.js";
3
- import { FileSource } from "../file.js";
4
- /**
5
- * I18n sources cannot have nested remote sources.
6
- */
7
- export type I18nCompatibleSource = SourcePrimitive | I18nObject | I18nArray | FileSource;
8
- export type I18nObject = {
9
- [key in string]: I18nCompatibleSource;
10
- };
11
- export type I18nArray = readonly I18nCompatibleSource[];
12
- /**
13
- * An i18n source is a map of locales to sources.
14
- *
15
- * Its selector will default to the underlying source. It is possible to call `.all` on i18n sources, which returns an object with all the locales
16
- *
17
- */
18
- export type I18nSource<Locales extends readonly string[], T extends I18nCompatibleSource> = {
19
- readonly [locale in Locales[number]]: T;
20
- } & {
21
- readonly [VAL_EXTENSION]: "i18n";
22
- };
23
- export type I18n<Locales extends readonly string[]> = <Src extends I18nCompatibleSource>(source: {
24
- [locale in Locales[number]]: Src;
25
- }) => I18nSource<Locales, Src>;
26
- export declare function i18n<Locales extends readonly string[]>(locales: F.Narrow<Locales>): <Src extends I18nCompatibleSource>(source: {
27
- [locale in Locales[number]]: Src;
28
- }) => I18nSource<Locales, Src>;
29
- export declare function isI18n(obj: unknown): obj is I18nSource<string[], I18nCompatibleSource>;
@@ -1,29 +0,0 @@
1
- import { SourcePrimitive, VAL_EXTENSION, PhantomType } from "../index.js";
2
- import { FileSource } from "../file.js";
3
- import { I18nCompatibleSource, I18nSource } from "./i18n.js";
4
- import { AllRichTextOptions, RichTextSource } from "../richtext.js";
5
- /**
6
- * Remote sources cannot include other remote sources.
7
- */
8
- export type RemoteCompatibleSource = SourcePrimitive | RemoteObject | RemoteArray | RichTextSource<AllRichTextOptions> | FileSource | I18nSource<string[], I18nCompatibleSource>;
9
- export type RemoteObject = {
10
- [key in string]: RemoteCompatibleSource;
11
- };
12
- export type RemoteArray = readonly RemoteCompatibleSource[];
13
- export declare const REMOTE_REF_PROP: "_ref";
14
- declare const brand: unique symbol;
15
- export type RemoteRef = string & {
16
- readonly [brand]: "RemoteRef";
17
- };
18
- /**
19
- * A remote source is a hash that represents a remote object.
20
- *
21
- * It will be resolved into a ValRemote object.
22
- */
23
- export type RemoteSource<Src extends RemoteCompatibleSource> = {
24
- readonly [REMOTE_REF_PROP]: RemoteRef;
25
- readonly [VAL_EXTENSION]: "remote";
26
- } & PhantomType<Src>;
27
- export declare function remote<Src extends RemoteCompatibleSource>(ref: string): RemoteSource<Src>;
28
- export declare function isRemote(obj: unknown): obj is RemoteSource<RemoteCompatibleSource>;
29
- export {};
@@ -1,2 +0,0 @@
1
- export * from "../../dist/declarations/src/expr/index.js";
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsYnVpbGQtY29yZS1leHByLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vZGlzdC9kZWNsYXJhdGlvbnMvc3JjL2V4cHIvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var expr_dist_valbuildCoreExpr = require('../../dist/index-7ae61742.cjs.dev.js');
6
- require('../../dist/result-bb1f436e.cjs.dev.js');
7
-
8
-
9
-
10
- exports.Call = expr_dist_valbuildCoreExpr.Call;
11
- exports.Expr = expr_dist_valbuildCoreExpr.Expr;
12
- exports.NilSym = expr_dist_valbuildCoreExpr.NilSym;
13
- exports.StringLiteral = expr_dist_valbuildCoreExpr.StringLiteral;
14
- exports.StringTemplate = expr_dist_valbuildCoreExpr.StringTemplate;
15
- exports.Sym = expr_dist_valbuildCoreExpr.Sym;
16
- exports.evaluate = expr_dist_valbuildCoreExpr.evaluate;
17
- exports.parse = expr_dist_valbuildCoreExpr.parse;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./valbuild-core-expr.cjs.prod.js");
5
- } else {
6
- module.exports = require("./valbuild-core-expr.cjs.dev.js");
7
- }