jazz-tools 0.15.13 → 0.15.15
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/.turbo/turbo-build.log +38 -38
- package/CHANGELOG.md +20 -0
- package/dist/{chunk-6CCJYSYQ.js → chunk-4CFNXQE7.js} +5 -6
- package/dist/chunk-4CFNXQE7.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/react/index.js +0 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/testing.js +1 -3
- package/dist/react/testing.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +8 -1
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/tools/coValues/deepLoading.ts +55 -41
- package/src/tools/exports.ts +1 -0
- package/src/tools/subscribe/SubscriptionScope.ts +7 -9
- package/src/tools/tests/coMap.test.ts +141 -0
- package/src/tools/tests/deepLoading.test.ts +58 -0
- package/vitest.config.ts +15 -14
- package/dist/chunk-6CCJYSYQ.js.map +0 -1
@@ -381,6 +381,64 @@ test("The resolve type doesn't accept extra keys", async () => {
|
|
381
381
|
}
|
382
382
|
});
|
383
383
|
|
384
|
+
test("The resolve type accepts keys from optional fields", async () => {
|
385
|
+
const Person = co.map({
|
386
|
+
name: z.string(),
|
387
|
+
});
|
388
|
+
const Dog = co.map({
|
389
|
+
type: z.literal("dog"),
|
390
|
+
owner: Person.optional(),
|
391
|
+
});
|
392
|
+
const Pets = co.list(Dog);
|
393
|
+
|
394
|
+
const pets = await Pets.create([
|
395
|
+
Dog.create({ type: "dog", owner: Person.create({ name: "Rex" }) }),
|
396
|
+
]);
|
397
|
+
|
398
|
+
await pets.ensureLoaded({
|
399
|
+
resolve: {
|
400
|
+
$each: { owner: true },
|
401
|
+
},
|
402
|
+
});
|
403
|
+
|
404
|
+
expect(pets[0]?.owner?.name).toEqual("Rex");
|
405
|
+
});
|
406
|
+
|
407
|
+
test("The resolve type doesn't accept keys from discriminated unions", async () => {
|
408
|
+
const Person = co.map({
|
409
|
+
name: z.string(),
|
410
|
+
});
|
411
|
+
const Dog = co.map({
|
412
|
+
type: z.literal("dog"),
|
413
|
+
owner: Person,
|
414
|
+
});
|
415
|
+
const Cat = co.map({
|
416
|
+
type: z.literal("cat"),
|
417
|
+
});
|
418
|
+
const Pet = co.discriminatedUnion("type", [Dog, Cat]);
|
419
|
+
const Pets = co.list(Pet);
|
420
|
+
|
421
|
+
const pets = await Pets.create([
|
422
|
+
Dog.create({ type: "dog", owner: Person.create({ name: "Rex" }) }),
|
423
|
+
]);
|
424
|
+
|
425
|
+
await pets.ensureLoaded({
|
426
|
+
resolve: {
|
427
|
+
$each: true,
|
428
|
+
},
|
429
|
+
});
|
430
|
+
|
431
|
+
await pets.ensureLoaded({
|
432
|
+
// @ts-expect-error cannot resolve owner
|
433
|
+
resolve: { $each: { owner: true } },
|
434
|
+
});
|
435
|
+
|
436
|
+
expect(pets).toBeTruthy();
|
437
|
+
if (pets?.[0]?.type === "dog") {
|
438
|
+
expect(pets[0].owner?.name).toEqual("Rex");
|
439
|
+
}
|
440
|
+
});
|
441
|
+
|
384
442
|
describe("Deep loading with unauthorized account", async () => {
|
385
443
|
const bob = await createJazzTestAccount({
|
386
444
|
creationProps: { name: "Bob" },
|
package/vitest.config.ts
CHANGED
@@ -1,22 +1,16 @@
|
|
1
|
-
import {
|
1
|
+
import { defineProject } from "vitest/config";
|
2
2
|
|
3
|
-
export default
|
3
|
+
export default defineProject({
|
4
4
|
test: {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
},
|
12
|
-
include: ["src/**/*.test.ts"],
|
13
|
-
name: "unit",
|
14
|
-
},
|
15
|
-
},
|
5
|
+
name: "jazz-tools",
|
6
|
+
typecheck: {
|
7
|
+
enabled: true,
|
8
|
+
checker: "tsc",
|
9
|
+
},
|
10
|
+
projects: [
|
16
11
|
{
|
17
12
|
test: {
|
18
13
|
include: ["src/**/*.test.browser.ts"],
|
19
|
-
name: "browser",
|
20
14
|
browser: {
|
21
15
|
enabled: true,
|
22
16
|
provider: "playwright",
|
@@ -24,6 +18,13 @@ export default defineConfig({
|
|
24
18
|
screenshotFailures: false,
|
25
19
|
instances: [{ browser: "chromium" }],
|
26
20
|
},
|
21
|
+
name: "browser",
|
22
|
+
},
|
23
|
+
},
|
24
|
+
{
|
25
|
+
test: {
|
26
|
+
include: ["src/**/*.test.{js,ts,svelte}"],
|
27
|
+
name: "unit",
|
27
28
|
},
|
28
29
|
},
|
29
30
|
],
|