@valbuild/core 0.16.0 → 0.17.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 (104) hide show
  1. package/ROADMAP.md +106 -0
  2. package/dist/declarations/src/ValApi.d.ts +26 -0
  3. package/dist/declarations/src/expr/eval.d.ts +1 -1
  4. package/dist/declarations/src/future/fetchVal.d.ts +5 -0
  5. package/dist/declarations/src/index.d.ts +36 -9
  6. package/dist/declarations/src/initSchema.d.ts +2 -10
  7. package/dist/declarations/src/initVal.d.ts +3 -21
  8. package/dist/declarations/src/module.d.ts +2 -14
  9. package/dist/declarations/src/schema/image.d.ts +1 -1
  10. package/dist/declarations/src/schema/index.d.ts +3 -5
  11. package/dist/declarations/src/schema/keyOf.d.ts +23 -0
  12. package/dist/declarations/src/schema/record.d.ts +19 -0
  13. package/dist/declarations/src/schema/union.d.ts +1 -0
  14. package/dist/declarations/src/selector/SelectorProxy.d.ts +7 -0
  15. package/dist/declarations/src/selector/array.d.ts +2 -13
  16. package/dist/declarations/src/selector/file.d.ts +1 -4
  17. package/dist/declarations/src/selector/future/array.d.ts +17 -0
  18. package/dist/declarations/src/selector/future/boolean.d.ts +2 -0
  19. package/dist/declarations/src/selector/future/file.d.ts +9 -0
  20. package/dist/declarations/src/selector/{i18n.d.ts → future/i18n.d.ts} +2 -2
  21. package/dist/declarations/src/selector/future/index.d.ts +81 -0
  22. package/dist/declarations/src/selector/future/number.d.ts +2 -0
  23. package/dist/declarations/src/selector/future/object.d.ts +10 -0
  24. package/dist/declarations/src/selector/future/primitive.d.ts +9 -0
  25. package/dist/declarations/src/selector/{remote.d.ts → future/remote.d.ts} +1 -1
  26. package/dist/declarations/src/selector/future/string.d.ts +2 -0
  27. package/dist/declarations/src/selector/index.d.ts +5 -32
  28. package/dist/declarations/src/selector/object.d.ts +2 -9
  29. package/dist/declarations/src/selector/primitive.d.ts +3 -9
  30. package/dist/declarations/src/source/{i18n.d.ts → future/i18n.d.ts} +2 -2
  31. package/dist/declarations/src/source/{remote.d.ts → future/remote.d.ts} +3 -3
  32. package/dist/declarations/src/source/index.d.ts +4 -3
  33. package/dist/declarations/src/val/index.d.ts +2 -2
  34. package/dist/{SelectorProxy-63c2d0e2.esm.js → index-369caccf.esm.js} +23 -195
  35. package/dist/{index-af761363.esm.js → index-3e3e839e.esm.js} +189 -1
  36. package/dist/{index-2fff5ca8.cjs.dev.js → index-486c7fbf.cjs.dev.js} +242 -54
  37. package/dist/{index-cac9ecbd.cjs.prod.js → index-601a7d73.cjs.prod.js} +242 -54
  38. package/dist/{SelectorProxy-2af1b2b8.cjs.prod.js → index-8706c87e.cjs.prod.js} +25 -199
  39. package/dist/{SelectorProxy-873782a5.cjs.dev.js → index-a6e642dd.cjs.dev.js} +25 -199
  40. package/dist/{ops-1b6e0e35.cjs.prod.js → ops-0d09f8ee.cjs.prod.js} +258 -126
  41. package/dist/{ops-74661336.esm.js → ops-23a5abb2.esm.js} +195 -65
  42. package/dist/{ops-ea4827fc.cjs.dev.js → ops-f3015423.cjs.dev.js} +258 -126
  43. package/dist/valbuild-core.cjs.dev.js +585 -198
  44. package/dist/valbuild-core.cjs.prod.js +585 -198
  45. package/dist/valbuild-core.esm.js +520 -134
  46. package/expr/dist/valbuild-core-expr.cjs.dev.js +8 -8
  47. package/expr/dist/valbuild-core-expr.cjs.prod.js +8 -8
  48. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  49. package/package.json +2 -3
  50. package/patch/dist/valbuild-core-patch.cjs.dev.js +24 -24
  51. package/patch/dist/valbuild-core-patch.cjs.prod.js +24 -24
  52. package/patch/dist/valbuild-core-patch.esm.js +3 -3
  53. package/src/ValApi.ts +85 -0
  54. package/src/expr/eval.test.ts +2 -2
  55. package/src/expr/eval.ts +2 -2
  56. package/src/{fetchVal.test.ts → future/fetchVal.test.ts} +57 -57
  57. package/src/{fetchVal.ts → future/fetchVal.ts} +17 -22
  58. package/src/index.ts +46 -14
  59. package/src/initSchema.ts +11 -12
  60. package/src/initVal.ts +42 -52
  61. package/src/module.test.ts +40 -40
  62. package/src/module.ts +53 -43
  63. package/src/patch/deref.test.ts +1 -1
  64. package/src/patch/deref.ts +1 -1
  65. package/src/patch/json.test.ts +0 -1
  66. package/src/schema/{i18n.ts → future/i18n.ts} +12 -10
  67. package/src/schema/{oneOf.ts → future/oneOf.ts} +19 -17
  68. package/src/schema/image.ts +1 -1
  69. package/src/schema/index.ts +16 -13
  70. package/src/schema/keyOf.ts +167 -0
  71. package/src/schema/record.ts +103 -0
  72. package/src/schema/union.ts +1 -1
  73. package/src/schema/validation.test.ts +195 -130
  74. package/src/selector/SelectorProxy.ts +15 -15
  75. package/src/selector/array.ts +2 -26
  76. package/src/selector/file.ts +1 -9
  77. package/src/selector/{ExprProxy.test.ts → future/ExprProxy.test.ts} +2 -2
  78. package/src/selector/{ExprProxy.ts → future/ExprProxy.ts} +9 -2
  79. package/src/selector/{SelectorProxy.test.ts → future/SelectorProxy.test.ts} +4 -4
  80. package/src/selector/future/SelectorProxy.ts +238 -0
  81. package/src/selector/future/array.ts +37 -0
  82. package/src/selector/future/boolean.ts +4 -0
  83. package/src/selector/future/file.ts +14 -0
  84. package/src/selector/{i18n.ts → future/i18n.ts} +2 -2
  85. package/src/selector/future/index.ts +165 -0
  86. package/src/selector/future/number.ts +4 -0
  87. package/src/selector/future/object.ts +22 -0
  88. package/src/selector/future/primitive.ts +17 -0
  89. package/src/selector/{remote.ts → future/remote.ts} +1 -1
  90. package/src/selector/{selector.test.ts → future/selector.test.ts} +8 -28
  91. package/src/selector/{selectorOf.ts → future/selectorOf.ts} +1 -1
  92. package/src/selector/future/string.ts +4 -0
  93. package/src/selector/index.ts +4 -46
  94. package/src/selector/object.ts +2 -19
  95. package/src/selector/primitive.ts +3 -16
  96. package/src/source/{i18n.ts → future/i18n.ts} +2 -2
  97. package/src/source/{remote.ts → future/remote.ts} +3 -3
  98. package/src/source/index.ts +3 -2
  99. package/src/val/array.ts +1 -1
  100. package/src/val/index.ts +2 -2
  101. package/src/val/object.ts +1 -1
  102. package/dist/declarations/src/fetchVal.d.ts +0 -5
  103. package/dist/declarations/src/schema/i18n.d.ts +0 -22
  104. package/dist/declarations/src/schema/oneOf.d.ts +0 -23
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
 
3
- import { createValPathOfItem } from "../selector/SelectorProxy";
3
+ import { createValPathOfItem } from "../selector/future/SelectorProxy";
4
4
  import { SourcePath } from "../val";
5
5
  import { array } from "./array";
6
6
  import { boolean } from "./boolean";
@@ -17,6 +17,9 @@ import {
17
17
  ValidationErrors,
18
18
  } from "./validation/ValidationError";
19
19
  import { richtext } from "./richtext";
20
+ import { record } from "./record";
21
+ import { keyOf } from "./keyOf";
22
+ import { content } from "../module";
20
23
 
21
24
  const testPath = "/test" as SourcePath;
22
25
  const pathOf = (p: string | symbol | number) => {
@@ -56,135 +59,198 @@ const ValidationTestCases: {
56
59
  schema: boolean().optional(),
57
60
  expected: false,
58
61
  },
59
- // {
60
- // description: "failing boolean",
61
- // input: "false",
62
- // schema: boolean(),
63
- // expected: [testPath],
64
- // },
65
- // // number
66
- // {
67
- // description: "basic number (0)",
68
- // input: 0,
69
- // schema: number(),
70
- // expected: false,
71
- // },
72
- // {
73
- // description: "basic number (-1)",
74
- // input: -1,
75
- // schema: number(),
76
- // expected: false,
77
- // },
78
- // {
79
- // description: "basic number (1)",
80
- // input: 1,
81
- // schema: number(),
82
- // expected: false,
83
- // },
84
- // {
85
- // description: "basic number (1)",
86
- // input: 1,
87
- // schema: number(),
88
- // expected: false,
89
- // },
90
- // // string
91
- // {
92
- // description: "basic string",
93
- // input: "two",
94
- // schema: string(),
95
- // expected: false,
96
- // },
97
- // {
98
- // description: "failing string",
99
- // input: 1,
100
- // schema: string(),
101
- // expected: [testPath],
102
- // },
103
- // // literal
104
- // {
105
- // description: "basic literal",
106
- // input: "one",
107
- // schema: literal("one"),
108
- // expected: false,
109
- // },
110
- // {
111
- // description: "failing literal",
112
- // input: "two",
113
- // schema: literal("one"),
114
- // expected: [testPath],
115
- // },
116
- // // array
117
- // {
118
- // description: "basic array(string)",
119
- // input: ["one", "two"],
120
- // schema: array(string()),
121
- // expected: false,
122
- // },
123
- // {
124
- // description: "failing array(string)",
125
- // input: [true, "false"],
126
- // schema: array(string()),
127
- // expected: [pathOf(0)],
128
- // },
129
- // // object
130
- // {
131
- // description: "basic object(string)",
132
- // input: { one: "one val", two: 2 },
133
- // schema: object({
134
- // one: string(),
135
- // two: number(),
136
- // }),
137
- // expected: false,
138
- // },
139
- // {
140
- // description: "basic object(string)",
141
- // input: { one: "one val", two: 1 },
142
- // schema: object({
143
- // one: string(),
144
- // two: string(),
145
- // }),
146
- // expected: [pathOf("two")],
147
- // },
62
+ {
63
+ description: "failing boolean",
64
+ input: "false",
65
+ schema: boolean(),
66
+ expected: [testPath],
67
+ },
68
+ // number
69
+ {
70
+ description: "basic number (0)",
71
+ input: 0,
72
+ schema: number(),
73
+ expected: false,
74
+ },
75
+ {
76
+ description: "basic number (-1)",
77
+ input: -1,
78
+ schema: number(),
79
+ expected: false,
80
+ },
81
+ {
82
+ description: "basic number (1)",
83
+ input: 1,
84
+ schema: number(),
85
+ expected: false,
86
+ },
87
+ {
88
+ description: "basic number (1)",
89
+ input: 1,
90
+ schema: number(),
91
+ expected: false,
92
+ },
93
+ // string
94
+ {
95
+ description: "basic string",
96
+ input: "two",
97
+ schema: string(),
98
+ expected: false,
99
+ },
100
+ {
101
+ description: "failing string",
102
+ input: 1,
103
+ schema: string(),
104
+ expected: [testPath],
105
+ },
106
+ // literal
107
+ {
108
+ description: "basic literal",
109
+ input: "one",
110
+ schema: literal("one"),
111
+ expected: false,
112
+ },
113
+ {
114
+ description: "failing literal",
115
+ input: "two",
116
+ schema: literal("one"),
117
+ expected: [testPath],
118
+ },
119
+ // array
120
+ {
121
+ description: "basic array(string)",
122
+ input: ["one", "two"],
123
+ schema: array(string()),
124
+ expected: false,
125
+ },
126
+ {
127
+ description: "failing array(string)",
128
+ input: [true, "false"],
129
+ schema: array(string()),
130
+ expected: [pathOf(0)],
131
+ },
132
+ // object
133
+ {
134
+ description: "basic object(string)",
135
+ input: { one: "one val", two: 2 },
136
+ schema: object({
137
+ one: string(),
138
+ two: number(),
139
+ }),
140
+ expected: false,
141
+ },
142
+ {
143
+ description: "failing object(string)",
144
+ input: { one: "one val", two: 1 },
145
+ schema: object({
146
+ one: string(),
147
+ two: string(),
148
+ }),
149
+ expected: [pathOf("two")],
150
+ },
151
+ // record
152
+ {
153
+ description: "basic record(string)",
154
+ input: { one: "one val", two: "two val" },
155
+ schema: record(string()),
156
+ expected: false,
157
+ },
158
+ {
159
+ description: "failing record(string)",
160
+ input: { one: "one val", two: 1 },
161
+ schema: object({
162
+ one: string(),
163
+ two: string(),
164
+ }),
165
+ expected: [pathOf("two")],
166
+ },
167
+ // keyof
168
+ {
169
+ description: "basic keyOf(array)",
170
+ input: 1,
171
+ schema: keyOf(content("/keyof-module", array(string()), [])),
172
+ expected: false,
173
+ },
174
+ {
175
+ description: "failing keyOf(record)",
176
+ input: "1",
177
+ schema: keyOf(content("/keyof-module", array(string()), [])),
178
+ expected: [testPath],
179
+ },
180
+ {
181
+ description: "basic keyOf(record)",
182
+ input: "one",
183
+ schema: keyOf(content("/keyof-module", record(string()), {})),
184
+ expected: false,
185
+ },
186
+ {
187
+ description: "failing keyOf(record)",
188
+ input: 1,
189
+ schema: keyOf(content("/keyof-module", record(string()), {})),
190
+ expected: [testPath],
191
+ },
192
+ {
193
+ description: "basic keyOf(object)",
194
+ input: "test1",
195
+ schema: keyOf(
196
+ content("/keyof-module", object({ test1: string(), test2: string() }), {
197
+ test1: "",
198
+ test2: "",
199
+ })
200
+ ),
201
+ expected: false,
202
+ },
203
+ {
204
+ description: "failing keyOf(object)",
205
+ input: "test",
206
+ schema: keyOf(
207
+ content("/keyof-module", object({ test1: string(), test2: string() }), {
208
+ test1: "",
209
+ test2: "",
210
+ })
211
+ ),
212
+ expected: [testPath],
213
+ },
148
214
  // image / file
149
- // {
150
- // description: "optional image",
151
- // input: null,
152
- // schema: image().optional(),
153
- // expected: false,
154
- // },
155
- // {
156
- // description: "failure image:: null",
157
- // input: null,
158
- // schema: image(),
159
- // expected: [testPath],
160
- // },
161
- // {
162
- // description: "failure image: add metadata",
163
- // input: fileVal("test", {
164
- // width: 100,
165
- // height: 100,
166
- // sha256: "test",
167
- // }),
168
- // schema: image(),
169
- // expected: [testPath],
170
- // fixes: {
171
- // [testPath]: ["image:add-metadata"],
172
- // },
173
- // },
174
- // {
175
- // description: "failure image: check metadata",
176
- // input: fileVal("test", {
177
- // width: 100,
178
- // height: 100,
179
- // sha256:
180
- // "9e420dc93157ab98338542ba6f1d34fcf829d646aa729a86720fa3f4cb2d0076",
181
- // }),
182
- // schema: image(),
183
- // expected: [testPath],
184
- // fixes: {
185
- // [testPath]: ["image:check-metadata"],
186
- // },
187
- // },
215
+ {
216
+ description: "optional image",
217
+ input: null,
218
+ schema: image().optional(),
219
+ expected: false,
220
+ },
221
+ {
222
+ description: "failure image:: null",
223
+ input: null,
224
+ schema: image(),
225
+ expected: [testPath],
226
+ },
227
+ {
228
+ description: "failure image: replace metadata",
229
+ input: fileVal("test", {
230
+ width: 100,
231
+ height: 100,
232
+ sha256: "test",
233
+ }),
234
+ schema: image(),
235
+ expected: [testPath],
236
+ fixes: {
237
+ [testPath]: ["image:replace-metadata"],
238
+ },
239
+ },
240
+ {
241
+ description: "failure image: check metadata",
242
+ input: fileVal("test", {
243
+ width: 100,
244
+ height: 100,
245
+ sha256:
246
+ "9e420dc93157ab98338542ba6f1d34fcf829d646aa729a86720fa3f4cb2d0076",
247
+ }),
248
+ schema: image(),
249
+ expected: [testPath],
250
+ fixes: {
251
+ [testPath]: ["image:replace-metadata"],
252
+ },
253
+ },
188
254
  // richtext
189
255
  {
190
256
  description: "basic richtext",
@@ -203,7 +269,6 @@ describe("validation", () => {
203
269
  'validate ($description): "$expected"',
204
270
  ({ input, schema, expected, fixes }) => {
205
271
  const result = schema.validate(testPath, input);
206
- console.log(JSON.stringify({ result, expected }, null, 2));
207
272
  if (result) {
208
273
  expect(Object.keys(result)).toStrictEqual(expected);
209
274
  if (fixes) {
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Path, GenericSelector, SourceOrExpr, GetSchema } from ".";
2
+ import { Path, GenericSelector, GetSource, GetSchema } from "./index";
3
3
  import { Expr } from "../expr/expr";
4
4
  import { Schema } from "../schema";
5
- import { convertImageSource } from "../schema/image";
5
+ import { convertFileSource } from "../schema/image";
6
6
  import { Source, SourcePrimitive, VAL_EXTENSION } from "../source";
7
7
  import { FILE_REF_PROP } from "../source/file";
8
8
  import { isSerializedVal, SourcePath } from "../val";
@@ -22,7 +22,7 @@ export function isSelector(source: any): source is GenericSelector<Source> {
22
22
  return (
23
23
  typeof source === "object" &&
24
24
  source !== null &&
25
- (SourceOrExpr in source || Path in source)
25
+ (GetSource in source || Path in source)
26
26
  );
27
27
  }
28
28
 
@@ -44,7 +44,7 @@ export function newSelectorProxy(
44
44
  if (typeof fileRef !== "string") {
45
45
  throw Error("Invalid file ref: " + fileRef);
46
46
  }
47
- return newSelectorProxy(convertImageSource(source), path, moduleSchema);
47
+ return newSelectorProxy(convertFileSource(source), path, moduleSchema);
48
48
  }
49
49
 
50
50
  switch (typeof source) {
@@ -57,7 +57,7 @@ export function newSelectorProxy(
57
57
  return new Proxy(source, {
58
58
  // TODO: see proxy docs if we want more traps
59
59
  has(target, prop: string | symbol) {
60
- if (prop === SourceOrExpr) {
60
+ if (prop === GetSource) {
61
61
  return true;
62
62
  }
63
63
  if (prop === Path) {
@@ -72,7 +72,7 @@ export function newSelectorProxy(
72
72
  return prop in target;
73
73
  },
74
74
  get(target, prop: string | symbol) {
75
- if (prop === SourceOrExpr) {
75
+ if (prop === GetSource) {
76
76
  return source;
77
77
  }
78
78
  if (prop === Path) {
@@ -154,7 +154,7 @@ export function newSelectorProxy(
154
154
  eq: (other: SourcePrimitive | GenericSelector<Source>) => {
155
155
  let otherValue: any = other;
156
156
  if (isSelector(other)) {
157
- otherValue = other[SourceOrExpr];
157
+ otherValue = other[GetSource];
158
158
  if (otherValue instanceof Expr) {
159
159
  throw Error("TODO: Cannot evaluate equality with an Expr");
160
160
  }
@@ -164,7 +164,7 @@ export function newSelectorProxy(
164
164
  andThen: (f: any) => {
165
165
  return andThen(f, source === undefined ? null : source, path);
166
166
  },
167
- [SourceOrExpr]: source === undefined ? null : source,
167
+ [GetSource]: source === undefined ? null : source,
168
168
  [Path]: path,
169
169
  [GetSchema]: moduleSchema,
170
170
  };
@@ -178,7 +178,7 @@ function selectorAsVal(sel: any): any {
178
178
  } else if (
179
179
  typeof sel === "object" &&
180
180
  sel &&
181
- !(SourceOrExpr in sel) &&
181
+ !(GetSource in sel) &&
182
182
  !Array.isArray(sel)
183
183
  ) {
184
184
  // is object
@@ -188,7 +188,7 @@ function selectorAsVal(sel: any): any {
188
188
  } else if (
189
189
  typeof sel === "object" &&
190
190
  sel &&
191
- !(SourceOrExpr in sel) &&
191
+ !(GetSource in sel) &&
192
192
  Array.isArray(sel)
193
193
  ) {
194
194
  // is array
@@ -196,9 +196,9 @@ function selectorAsVal(sel: any): any {
196
196
  } else if (
197
197
  typeof sel === "object" &&
198
198
  sel &&
199
- (SourceOrExpr in sel || Path in sel)
199
+ (GetSource in sel || Path in sel)
200
200
  ) {
201
- return selectorAsVal(sel?.[SourceOrExpr]);
201
+ return selectorAsVal(sel?.[GetSource]);
202
202
  } else if (sel === undefined) {
203
203
  return null;
204
204
  }
@@ -218,7 +218,7 @@ export function createValPathOfItem(
218
218
  }
219
219
 
220
220
  export function selectorToVal(s: any): any {
221
- const v = selectorAsVal(s?.[SourceOrExpr]);
221
+ const v = selectorAsVal(s?.[GetSource]);
222
222
  return {
223
223
  val: v,
224
224
  [Path]: s?.[Path],
@@ -229,9 +229,9 @@ export function selectorToVal(s: any): any {
229
229
  function unValify(valueOrSelector: any) {
230
230
  if (
231
231
  typeof valueOrSelector === "object" &&
232
- (SourceOrExpr in valueOrSelector || Path in valueOrSelector)
232
+ (GetSource in valueOrSelector || Path in valueOrSelector)
233
233
  ) {
234
- const selectorValue = valueOrSelector[SourceOrExpr];
234
+ const selectorValue = valueOrSelector[GetSource];
235
235
  return selectorValue;
236
236
  }
237
237
  return valueOrSelector;
@@ -1,13 +1,5 @@
1
- import {
2
- Selector as UnknownSelector,
3
- GenericSelector,
4
- SelectorOf,
5
- SelectorSource,
6
- } from ".";
7
- import { Schema } from "../schema";
1
+ import { GenericSelector } from ".";
8
2
  import { Source, SourceArray } from "../source";
9
- import { Selector as BooleanSelector } from "./boolean";
10
- import { Selector as NumberSelector } from "./number";
11
3
 
12
4
  export type UndistributedSourceArray<T extends SourceArray> = [T] extends [
13
5
  infer U // infer here to avoid Type instantiation is excessively deep and possibly infinite. See: https://github.com/microsoft/TypeScript/issues/30188#issuecomment-478938437. Avoiding infer extends to keep us below TS 4.9 compat
@@ -18,20 +10,4 @@ export type UndistributedSourceArray<T extends SourceArray> = [T] extends [
18
10
  : never;
19
11
 
20
12
  // TODO: docs
21
- export type Selector<T extends SourceArray> = GenericSelector<T> & {
22
- readonly [key: number]: UnknownSelector<T[number]>;
23
- } & {
24
- length: NumberSelector<number>;
25
- filter(
26
- predicate: (
27
- v: UnknownSelector<T[number]>
28
- ) => BooleanSelector<boolean> | boolean
29
- ): Selector<T>;
30
- filter<U extends Source>(schema: Schema<U>): Selector<U[]>;
31
- map<U extends SelectorSource>(
32
- f: (v: UnknownSelector<T[number]>, i: UnknownSelector<number>) => U
33
- ): SelectorOf<U[]>; // TODO: this should be SelectorOf<ArraySelectorSourceBranded<U[]>>;
34
- andThen<U extends SelectorSource>(
35
- f: (v: UnknownSelector<NonNullable<T>>) => U
36
- ): SelectorOf<U | T>;
37
- };
13
+ export type Selector<T extends SourceArray> = GenericSelector<T>;
@@ -1,14 +1,6 @@
1
- import {
2
- Selector as UnknownSelector,
3
- GenericSelector,
4
- SelectorOf,
5
- SelectorSource,
6
- } from ".";
1
+ import { Selector as UnknownSelector, GenericSelector } from "./index";
7
2
 
8
3
  // TODO: docs
9
4
  export type FileSelector = GenericSelector<{ url: string }> & {
10
5
  readonly url: UnknownSelector<string>;
11
- andThen<U extends SelectorSource>(
12
- f: (v: UnknownSelector<NonNullable<{ url: string }>>) => U
13
- ): SelectorOf<U> | UnknownSelector<boolean>;
14
6
  };
@@ -1,8 +1,8 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { convertLiteralProxy, newExprSelectorProxy } from "./ExprProxy";
3
- import * as expr from "../expr/expr";
3
+ import * as expr from "../../expr/expr";
4
4
  import { GenericSelector, SelectorSource, SourceOrExpr } from ".";
5
- import { Source } from "../source";
5
+ import { Source } from "../../source";
6
6
 
7
7
  const ExprSelectorTestCases: any[] = [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  import { Selector, SelectorSource, SourceOrExpr } from ".";
2
- import * as expr from "../expr/expr";
3
- import { Source, SourcePrimitive } from "../source";
2
+ import * as expr from "../../expr/expr";
3
+ import { Source, SourcePrimitive } from "../../source";
4
4
 
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
6
  type AnyFun = (...args: any[]) => any;
@@ -25,6 +25,13 @@ export function newExprSelectorProxy<T extends Source>(
25
25
  }) as unknown as Selector<T>;
26
26
  }
27
27
 
28
+ export function root(sourcePath: string) {
29
+ return new expr.Call(
30
+ [new expr.Sym("val"), new expr.StringLiteral(sourcePath)],
31
+ false
32
+ );
33
+ }
34
+
28
35
  class GenericExprSelector {
29
36
  [SourceOrExpr]: expr.Expr;
30
37
  constructor(private readonly root: expr.Expr, private readonly depth = 0) {
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { Selector, GenericSelector, Path } from ".";
3
- import { number } from "../schema/number";
4
- import { string } from "../schema/string";
5
- import { Source } from "../source";
6
- import { SourcePath } from "../val";
3
+ import { number } from "../../schema/number";
4
+ import { string } from "../../schema/string";
5
+ import { Source } from "../../source";
6
+ import { SourcePath } from "../../val";
7
7
  import { newSelectorProxy, selectorToVal } from "./SelectorProxy";
8
8
 
9
9
  describe("SelectorProxy", () => {