@reventlessdev/reventless-local 3.0.0-alpha.223 → 3.0.0-alpha.225
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/CHANGELOG.md +21 -0
- package/package.json +12 -12
- package/src/BakedManifest.res +11 -37
- package/src/BakedManifest.res.mjs +2 -27
- package/src/ShellConfig.res +9 -19
- package/src/ShellConfig.res.mjs +6 -10
- package/src/adapter/LocalBus.res +3 -0
- package/src/adapter/LocalStateChangeDescriptor.res +46 -2
- package/src/adapter/LocalStateChangeDescriptor.res.mjs +16 -4
- package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res +67 -6
- package/src/adapter/QueryDb/QueryDbResolvers_GraphQL.res.mjs +45 -8
- package/src/adapter/QueryDb/QueryDbStorage_InMemory.res +2 -0
- package/src/adapter/QueryDb/QueryDbStorage_InMemory.res.mjs +2 -2
- package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res +37 -0
- package/src/adapter/QueryDb/QueryDbStorage_Sqlite.res.mjs +14 -3
- package/src/reset/LocalSeedReset.res +23 -6
- package/src/reset/LocalSeedReset.res.mjs +2 -19
- package/tests/adapter/GraphQL_SchemaInspectorTest.res +7 -4
- package/tests/adapter/GraphQL_SchemaInspectorTest.res.mjs +10 -7
- package/tests/adapter/GraphQL_SubscriptionResolversTest.res.mjs +2 -2
- package/tests/adapter/QueryDbListPushdownParityTest.res +82 -10
- package/tests/adapter/QueryDbListPushdownParityTest.res.mjs +96 -26
- package/tests/adapter/QueryDbListResolverTest.res +2 -1
- package/tests/adapter/QueryDbListResolverTest.res.mjs +3 -2
|
@@ -36,13 +36,16 @@ let capability = {
|
|
|
36
36
|
sortFields: capability_sortFields
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
function mk(id, status, name, qty, owner) {
|
|
39
|
+
function mk(id, status, name, qty, owner, archived) {
|
|
40
40
|
let o = {};
|
|
41
41
|
o["id"] = id;
|
|
42
42
|
o["status"] = status;
|
|
43
43
|
o["name"] = name;
|
|
44
44
|
o["qty"] = qty;
|
|
45
45
|
o["owner"] = owner;
|
|
46
|
+
if (archived !== undefined) {
|
|
47
|
+
o["archived"] = archived;
|
|
48
|
+
}
|
|
46
49
|
return o;
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -52,35 +55,40 @@ let rows = [
|
|
|
52
55
|
"active",
|
|
53
56
|
"Charlie",
|
|
54
57
|
3,
|
|
55
|
-
"u-a"
|
|
58
|
+
"u-a",
|
|
59
|
+
false
|
|
56
60
|
],
|
|
57
61
|
[
|
|
58
62
|
"p-2",
|
|
59
63
|
"active",
|
|
60
64
|
"Alpha",
|
|
61
65
|
1,
|
|
62
|
-
"u-b"
|
|
66
|
+
"u-b",
|
|
67
|
+
true
|
|
63
68
|
],
|
|
64
69
|
[
|
|
65
70
|
"p-3",
|
|
66
71
|
"inactive",
|
|
67
72
|
"Echo",
|
|
68
73
|
5,
|
|
69
|
-
"u-a"
|
|
74
|
+
"u-a",
|
|
75
|
+
false
|
|
70
76
|
],
|
|
71
77
|
[
|
|
72
78
|
"p-4",
|
|
73
79
|
"active",
|
|
74
80
|
"Bravo",
|
|
75
81
|
2,
|
|
76
|
-
"u-c"
|
|
82
|
+
"u-c",
|
|
83
|
+
true
|
|
77
84
|
],
|
|
78
85
|
[
|
|
79
86
|
"p-5",
|
|
80
87
|
"inactive",
|
|
81
88
|
"Delta",
|
|
82
89
|
4,
|
|
83
|
-
"u-a"
|
|
90
|
+
"u-a",
|
|
91
|
+
undefined
|
|
84
92
|
]
|
|
85
93
|
];
|
|
86
94
|
|
|
@@ -96,7 +104,7 @@ async function build() {
|
|
|
96
104
|
for (let i = 0, i_finish = rows.length; i < i_finish; ++i) {
|
|
97
105
|
let match = rows[i];
|
|
98
106
|
let id = match[0];
|
|
99
|
-
await ops.save(id, mk(id, match[1], match[2], match[3], match[4]), "Any", undefined);
|
|
107
|
+
await ops.save(id, mk(id, match[1], match[2], match[3], match[4], match[5]), "Any", undefined);
|
|
100
108
|
}
|
|
101
109
|
return {
|
|
102
110
|
listPage: Stdlib_Option.getOrThrow(TestBus.getQueryDbListPage("items"), undefined),
|
|
@@ -148,11 +156,11 @@ function orderBy(f, dir) {
|
|
|
148
156
|
]);
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
async function checkPushed(label, ownerScope, args) {
|
|
159
|
+
async function checkPushed(label, ownerScope, retiredScope, args) {
|
|
152
160
|
let s = await build();
|
|
153
161
|
let argsDict = Object.fromEntries(args);
|
|
154
|
-
let expected = norm(QueryDbListQuery$ReventlessCore.run(s.fullScan(), argsDict, capability, "name", param => {}, ownerScope));
|
|
155
|
-
let actual = s.listPage(argsDict, capability, "name", ownerScope);
|
|
162
|
+
let expected = norm(QueryDbListQuery$ReventlessCore.run(s.fullScan(), argsDict, capability, "name", param => {}, ownerScope, retiredScope));
|
|
163
|
+
let actual = s.listPage(argsDict, capability, "name", ownerScope, retiredScope);
|
|
156
164
|
if (actual !== undefined) {
|
|
157
165
|
globalThis.expect(norm(actual)).toEqual(expected);
|
|
158
166
|
} else {
|
|
@@ -162,7 +170,20 @@ async function checkPushed(label, ownerScope, args) {
|
|
|
162
170
|
|
|
163
171
|
async function checkFallback(args) {
|
|
164
172
|
let s = await build();
|
|
165
|
-
globalThis.expect(Stdlib_Option.isSome(s.listPage(Object.fromEntries(args), capability, "name", undefined))).toBe(false);
|
|
173
|
+
globalThis.expect(Stdlib_Option.isSome(s.listPage(Object.fromEntries(args), capability, "name", undefined, undefined))).toBe(false);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function liveIds(args) {
|
|
177
|
+
let s = await build();
|
|
178
|
+
let conn = s.listPage(Object.fromEntries(args), capability, "name", undefined, {
|
|
179
|
+
field: "archived",
|
|
180
|
+
values: undefined
|
|
181
|
+
});
|
|
182
|
+
if (conn !== undefined) {
|
|
183
|
+
return norm(conn).edges.map(e => e.id);
|
|
184
|
+
} else {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
166
187
|
}
|
|
167
188
|
|
|
168
189
|
async function scopedIds(owner, args) {
|
|
@@ -170,7 +191,7 @@ async function scopedIds(owner, args) {
|
|
|
170
191
|
let conn = s.listPage(Object.fromEntries(args), capability, "name", [
|
|
171
192
|
"owner",
|
|
172
193
|
owner
|
|
173
|
-
]);
|
|
194
|
+
], undefined);
|
|
174
195
|
if (conn !== undefined) {
|
|
175
196
|
return norm(conn).edges.map(e => e.id);
|
|
176
197
|
} else {
|
|
@@ -179,12 +200,12 @@ async function scopedIds(owner, args) {
|
|
|
179
200
|
}
|
|
180
201
|
|
|
181
202
|
globalThis.describe("QueryDb list push-down parity (SQLite ≡ QueryDbListQuery spec)", () => {
|
|
182
|
-
globalThis.test("bare page", () => checkPushed("bare", undefined, []));
|
|
183
|
-
globalThis.test("first:2", () => checkPushed("first", undefined, [[
|
|
203
|
+
globalThis.test("bare page", () => checkPushed("bare", undefined, undefined, []));
|
|
204
|
+
globalThis.test("first:2", () => checkPushed("first", undefined, undefined, [[
|
|
184
205
|
"first",
|
|
185
206
|
2
|
|
186
207
|
]]));
|
|
187
|
-
globalThis.test("first:2 + after", () => checkPushed("after", undefined, [
|
|
208
|
+
globalThis.test("first:2 + after", () => checkPushed("after", undefined, undefined, [
|
|
188
209
|
[
|
|
189
210
|
"first",
|
|
190
211
|
2
|
|
@@ -194,14 +215,14 @@ globalThis.describe("QueryDb list push-down parity (SQLite ≡ QueryDbListQuery
|
|
|
194
215
|
QueryDbListQuery$ReventlessCore.encodeCursor("p-2")
|
|
195
216
|
]
|
|
196
217
|
]));
|
|
197
|
-
globalThis.test("statusEq active", () => checkPushed("eq", undefined, [[
|
|
218
|
+
globalThis.test("statusEq active", () => checkPushed("eq", undefined, undefined, [[
|
|
198
219
|
"filter",
|
|
199
220
|
Object.fromEntries([[
|
|
200
221
|
"statusEq",
|
|
201
222
|
"active"
|
|
202
223
|
]])
|
|
203
224
|
]]));
|
|
204
|
-
globalThis.test("statusEq active + first:2", () => checkPushed("eq+first", undefined, [
|
|
225
|
+
globalThis.test("statusEq active + first:2", () => checkPushed("eq+first", undefined, undefined, [
|
|
205
226
|
[
|
|
206
227
|
"filter",
|
|
207
228
|
Object.fromEntries([[
|
|
@@ -214,15 +235,15 @@ globalThis.describe("QueryDb list push-down parity (SQLite ≡ QueryDbListQuery
|
|
|
214
235
|
2
|
|
215
236
|
]
|
|
216
237
|
]));
|
|
217
|
-
globalThis.test("orderBy name ASC", () => checkPushed("order-asc", undefined, [[
|
|
238
|
+
globalThis.test("orderBy name ASC", () => checkPushed("order-asc", undefined, undefined, [[
|
|
218
239
|
"orderBy",
|
|
219
240
|
orderBy("name", "ASC")
|
|
220
241
|
]]));
|
|
221
|
-
globalThis.test("orderBy name DESC", () => checkPushed("order-desc", undefined, [[
|
|
242
|
+
globalThis.test("orderBy name DESC", () => checkPushed("order-desc", undefined, undefined, [[
|
|
222
243
|
"orderBy",
|
|
223
244
|
orderBy("name", "DESC")
|
|
224
245
|
]]));
|
|
225
|
-
globalThis.test("orderBy name DESC + first:2 + after", () => checkPushed("order-desc-after", undefined, [
|
|
246
|
+
globalThis.test("orderBy name DESC + first:2 + after", () => checkPushed("order-desc-after", undefined, undefined, [
|
|
226
247
|
[
|
|
227
248
|
"orderBy",
|
|
228
249
|
orderBy("name", "DESC")
|
|
@@ -236,11 +257,11 @@ globalThis.describe("QueryDb list push-down parity (SQLite ≡ QueryDbListQuery
|
|
|
236
257
|
QueryDbListQuery$ReventlessCore.encodeCursor("Delta")
|
|
237
258
|
]
|
|
238
259
|
]));
|
|
239
|
-
globalThis.test("orderBy status ASC (tiebreak by id)", () => checkPushed("order-tiebreak", undefined, [[
|
|
260
|
+
globalThis.test("orderBy status ASC (tiebreak by id)", () => checkPushed("order-tiebreak", undefined, undefined, [[
|
|
240
261
|
"orderBy",
|
|
241
262
|
orderBy("status", "ASC")
|
|
242
263
|
]]));
|
|
243
|
-
globalThis.test("qty range From/To (numeric-as-string)", () => checkPushed("range", undefined, [[
|
|
264
|
+
globalThis.test("qty range From/To (numeric-as-string)", () => checkPushed("range", undefined, undefined, [[
|
|
244
265
|
"filter",
|
|
245
266
|
Object.fromEntries([
|
|
246
267
|
[
|
|
@@ -253,7 +274,7 @@ globalThis.describe("QueryDb list push-down parity (SQLite ≡ QueryDbListQuery
|
|
|
253
274
|
]
|
|
254
275
|
])
|
|
255
276
|
]]));
|
|
256
|
-
globalThis.test("orderBy qty ASC (numeric-as-string sort)", () => checkPushed("order-qty", undefined, [[
|
|
277
|
+
globalThis.test("orderBy qty ASC (numeric-as-string sort)", () => checkPushed("order-qty", undefined, undefined, [[
|
|
257
278
|
"orderBy",
|
|
258
279
|
orderBy("qty", "ASC")
|
|
259
280
|
]]));
|
|
@@ -288,22 +309,70 @@ globalThis.describe("QueryDb list push-down parity (SQLite ≡ QueryDbListQuery
|
|
|
288
309
|
QueryDbListQuery$ReventlessCore.encodeCursor("p-4")
|
|
289
310
|
]
|
|
290
311
|
]));
|
|
312
|
+
globalThis.describe("retirement narrowing", () => {
|
|
313
|
+
globalThis.test("bare page, narrowed", () => checkPushed("retired-bare", undefined, {
|
|
314
|
+
field: "archived",
|
|
315
|
+
values: undefined
|
|
316
|
+
}, []));
|
|
317
|
+
globalThis.test("narrowed + orderBy", () => checkPushed("retired-order", undefined, {
|
|
318
|
+
field: "archived",
|
|
319
|
+
values: undefined
|
|
320
|
+
}, [[
|
|
321
|
+
"orderBy",
|
|
322
|
+
orderBy("name", "DESC")
|
|
323
|
+
]]));
|
|
324
|
+
globalThis.test("narrowed + the caller's own filter", () => checkPushed("retired-filter", undefined, {
|
|
325
|
+
field: "archived",
|
|
326
|
+
values: undefined
|
|
327
|
+
}, [[
|
|
328
|
+
"filter",
|
|
329
|
+
Object.fromEntries([[
|
|
330
|
+
"statusEq",
|
|
331
|
+
"active"
|
|
332
|
+
]])
|
|
333
|
+
]]));
|
|
334
|
+
globalThis.test("narrowed + owner-scoped together", () => checkPushed("retired-owner", [
|
|
335
|
+
"owner",
|
|
336
|
+
"u-a"
|
|
337
|
+
], {
|
|
338
|
+
field: "archived",
|
|
339
|
+
values: undefined
|
|
340
|
+
}, []));
|
|
341
|
+
globalThis.test("drops the archived rows and keeps the one with no flag", async () => {
|
|
342
|
+
let ids = await liveIds([]);
|
|
343
|
+
globalThis.expect(ids).toEqual([
|
|
344
|
+
"p-1",
|
|
345
|
+
"p-3",
|
|
346
|
+
"p-5"
|
|
347
|
+
]);
|
|
348
|
+
});
|
|
349
|
+
globalThis.test("a page of first:2 is two live rows, not two rows minus the archived", async () => {
|
|
350
|
+
let ids = await liveIds([[
|
|
351
|
+
"first",
|
|
352
|
+
2
|
|
353
|
+
]]);
|
|
354
|
+
globalThis.expect(ids).toEqual([
|
|
355
|
+
"p-1",
|
|
356
|
+
"p-3"
|
|
357
|
+
]);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
291
360
|
globalThis.describe("owner scoping", () => {
|
|
292
361
|
globalThis.test("bare page, scoped", () => checkPushed("owner-bare", [
|
|
293
362
|
"owner",
|
|
294
363
|
"u-a"
|
|
295
|
-
], []));
|
|
364
|
+
], undefined, []));
|
|
296
365
|
globalThis.test("scoped + orderBy", () => checkPushed("owner-order", [
|
|
297
366
|
"owner",
|
|
298
367
|
"u-a"
|
|
299
|
-
], [[
|
|
368
|
+
], undefined, [[
|
|
300
369
|
"orderBy",
|
|
301
370
|
orderBy("name", "DESC")
|
|
302
371
|
]]));
|
|
303
372
|
globalThis.test("scoped + client filter compose", () => checkPushed("owner-and-filter", [
|
|
304
373
|
"owner",
|
|
305
374
|
"u-a"
|
|
306
|
-
], [[
|
|
375
|
+
], undefined, [[
|
|
307
376
|
"filter",
|
|
308
377
|
Object.fromEntries([[
|
|
309
378
|
"statusEq",
|
|
@@ -361,6 +430,7 @@ export {
|
|
|
361
430
|
cur,
|
|
362
431
|
checkPushed,
|
|
363
432
|
checkFallback,
|
|
433
|
+
liveIds,
|
|
364
434
|
scopedIds,
|
|
365
435
|
}
|
|
366
436
|
/* Not a pure module */
|
|
@@ -45,10 +45,11 @@ let rowStateSchemaWithAnnotations = S.Metadata.set(rowStateSchema, StateAnnotati
|
|
|
45
45
|
scanSort: ["name"],
|
|
46
46
|
semantic: [],
|
|
47
47
|
metric: [],
|
|
48
|
-
|
|
48
|
+
lifecycle: undefined,
|
|
49
49
|
groupBy: undefined,
|
|
50
50
|
visibility: undefined,
|
|
51
|
-
live: undefined
|
|
51
|
+
live: undefined,
|
|
52
|
+
retired: undefined
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
let newrecord = {...Identity$Reventless.anonymous};
|