jazz-tools 0.15.12 → 0.15.14
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 +47 -47
- package/CHANGELOG.md +20 -0
- package/dist/{chunk-DZFT4EZM.js → chunk-6CCJYSYQ.js} +26 -16
- package/dist/{chunk-DZFT4EZM.js.map → chunk-6CCJYSYQ.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +3 -1
- package/dist/react/testing.js +3 -1
- 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/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.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/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +27 -12
- package/src/tools/tests/deepLoading.test.ts +58 -0
- package/src/tools/tests/load.test.ts +114 -0
- package/vitest.config.ts +15 -14
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
"use client";
|
2
|
+
|
1
3
|
// src/react/provider.tsx
|
2
4
|
import {
|
3
5
|
JazzBrowserContextManager
|
@@ -696,4 +698,4 @@ export {
|
|
696
698
|
usePassphraseAuth2 as usePassphraseAuth,
|
697
699
|
useProgressiveImg
|
698
700
|
};
|
699
|
-
//# sourceMappingURL=index.js.
|
701
|
+
//# sourceMappingURL=index.js.map
|
package/dist/react/testing.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/react/testing.tsx"],"sourcesContent":["export * from \"jazz-tools/react-core/testing\";\n"],"mappings":"
|
1
|
+
{"version":3,"sources":["../../src/react/testing.tsx"],"sourcesContent":["export * from \"jazz-tools/react-core/testing\";\n"],"mappings":";;;AAAA,cAAc;","names":[]}
|
package/dist/testing.js
CHANGED
@@ -5,7 +5,14 @@ import { CoFeedEntry } from "./coFeed.js";
|
|
5
5
|
import { type CoKeys } from "./coMap.js";
|
6
6
|
import { type CoValue, type ID } from "./interfaces.js";
|
7
7
|
type NotNull<T> = Exclude<T, null>;
|
8
|
-
|
8
|
+
/**
|
9
|
+
* Used to check if T is a union type.
|
10
|
+
*
|
11
|
+
* If T is a union type, the left hand side of the extends becomes a union of function types.
|
12
|
+
* The right hand side is always a single function type.
|
13
|
+
*/
|
14
|
+
type IsUnion<T, U = T> = (T extends any ? (x: T) => void : never) extends (x: U) => void ? false : true;
|
15
|
+
export type RefsToResolve<V, DepthLimit extends number = 10, CurrentDepth extends number[] = []> = boolean | (DepthLimit extends CurrentDepth["length"] ? any : IsUnion<NonNullable<V>> extends true ? true : V extends Array<infer Item> ? {
|
9
16
|
$each: RefsToResolve<NotNull<Item>, DepthLimit, [
|
10
17
|
0,
|
11
18
|
...CurrentDepth
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deepLoading.d.ts","sourceRoot":"","sources":["../../../src/tools/coValues/deepLoading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,MAAM,
|
1
|
+
{"version":3,"file":"deepLoading.d.ts","sourceRoot":"","sources":["../../../src/tools/coValues/deepLoading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAA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CAAC,GACD,KAAK,CAAC"}
|
package/dist/tools/exports.d.ts
CHANGED
@@ -8,7 +8,7 @@ export { CoValueBase } from "./internal.js";
|
|
8
8
|
export { Profile } from "./internal.js";
|
9
9
|
export { SchemaUnion } from "./internal.js";
|
10
10
|
export { co } from "./internal.js";
|
11
|
-
export type { CoValueClass, CoValueFromRaw, DeeplyLoaded, Resolved, RefsToResolve, RefsToResolveStrict, CoMapInit, CoFeedEntry, TextPos, AccountClass, AccountCreationProps, } from "./internal.js";
|
11
|
+
export type { CoValueClass, CoValueFromRaw, DeeplyLoaded, Resolved, RefsToResolve, RefsToResolveStrict, CoMapInit, CoFeedEntry, TextPos, AccountClass, AccountCreationProps, WithHelpers, } from "./internal.js";
|
12
12
|
export { CoMap, CoList, BinaryCoStream, CoFeed, CoStream, FileStream, CoPlainText, CoRichText, Account, isControlledAccount, createCoValueObservable, loadCoValue, subscribeToCoValue, ImageDefinition, SubscriptionScope, } from "./internal.js";
|
13
13
|
export { JazzContextManager, type JazzContextManagerAuthProps, } from "./internal.js";
|
14
14
|
export { AuthSecretStorage, type AuthSetPayload, } from "./auth/AuthSecretStorage.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/tools/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,WAAW,GACZ,MAAM,QAAQ,CAAC;AAEhB,OAAO,KAAK,CAAC,MAAM,2CAA2C,CAAC;AAE/D,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE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O,EACZ,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC"}
|
@@ -7,6 +7,6 @@ import { AnyCoSchema, ZodPrimitiveSchema } from "../zodSchema.js";
|
|
7
7
|
type SchemaField = AnyCoSchema | CoValueClass | ZodPrimitiveSchema | z.core.$ZodOptional<z.core.$ZodType> | z.core.$ZodUnion<z.core.$ZodType[]> | z.core.$ZodObject<z.core.$ZodLooseShape> | z.core.$ZodArray<z.core.$ZodType> | z.core.$ZodTuple<z.core.$ZodType[]> | z.core.$ZodReadonly<z.core.$ZodType> | z.core.$ZodLazy<z.core.$ZodType> | z.core.$ZodTemplateLiteral<any> | z.core.$ZodLiteral<any> | z.core.$ZodCatch<z.core.$ZodType> | z.core.$ZodEnum<any> | z.core.$ZodDefault<z.core.$ZodType> | z.core.$ZodCatch<z.core.$ZodType> | (z.core.$ZodCustom<any, any> & {
|
8
8
|
builtin: any;
|
9
9
|
});
|
10
|
-
export declare function schemaFieldToCoFieldDef(schema: SchemaField): string | number | boolean | Date | import("../../../internal.js").CoValue | CoMap | import("../../../internal.js").CoPlainText | import("../../../internal.js").BinaryCoStream | import("../../../internal.js").CoStream<unknown> | import("../../../internal.js").CoList<unknown> | null | undefined;
|
10
|
+
export declare function schemaFieldToCoFieldDef(schema: SchemaField, isOptional?: boolean): string | number | boolean | Date | import("../../../internal.js").CoValue | CoMap | import("../../../internal.js").CoPlainText | import("../../../internal.js").BinaryCoStream | import("../../../internal.js").CoStream<unknown> | import("../../../internal.js").CoList<unknown> | null | undefined;
|
11
11
|
export {};
|
12
12
|
//# sourceMappingURL=zodFieldToCoFieldDef.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zodFieldToCoFieldDef.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAkB,MAAM,sBAAsB,CAAC;A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CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GACpB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GACnC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GACjC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAErD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,WAAW,EACnB,UAAU,UAAQ,ySA4HnB"}
|
package/package.json
CHANGED
@@ -139,7 +139,7 @@
|
|
139
139
|
},
|
140
140
|
"type": "module",
|
141
141
|
"license": "MIT",
|
142
|
-
"version": "0.15.
|
142
|
+
"version": "0.15.14",
|
143
143
|
"dependencies": {
|
144
144
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
145
145
|
"@scure/base": "1.2.1",
|
@@ -158,9 +158,9 @@
|
|
158
158
|
"prosemirror-state": "^1.4.3",
|
159
159
|
"prosemirror-transform": "^1.9.0",
|
160
160
|
"zod": "3.25.28",
|
161
|
-
"cojson": "0.15.
|
162
|
-
"cojson-storage-indexeddb": "0.15.
|
163
|
-
"cojson-transport-ws": "0.15.
|
161
|
+
"cojson": "0.15.14",
|
162
|
+
"cojson-storage-indexeddb": "0.15.14",
|
163
|
+
"cojson-transport-ws": "0.15.14"
|
164
164
|
},
|
165
165
|
"devDependencies": {
|
166
166
|
"@scure/bip39": "^1.3.0",
|
@@ -175,7 +175,7 @@
|
|
175
175
|
"playwright": "^1.50.1",
|
176
176
|
"tsup": "8.5.0",
|
177
177
|
"typescript": "5.6.2",
|
178
|
-
"vitest": "3.
|
178
|
+
"vitest": "3.2.4",
|
179
179
|
"ws": "^8.14.2"
|
180
180
|
},
|
181
181
|
"peerDependencies": {
|
@@ -2,11 +2,23 @@ import { SessionID } from "cojson";
|
|
2
2
|
import { ItemsSym } from "../internal.js";
|
3
3
|
import { type Account } from "./account.js";
|
4
4
|
import { CoFeedEntry } from "./coFeed.js";
|
5
|
-
import { type CoKeys
|
5
|
+
import { type CoKeys } from "./coMap.js";
|
6
6
|
import { type CoValue, type ID } from "./interfaces.js";
|
7
7
|
|
8
8
|
type NotNull<T> = Exclude<T, null>;
|
9
9
|
|
10
|
+
/**
|
11
|
+
* Used to check if T is a union type.
|
12
|
+
*
|
13
|
+
* If T is a union type, the left hand side of the extends becomes a union of function types.
|
14
|
+
* The right hand side is always a single function type.
|
15
|
+
*/
|
16
|
+
type IsUnion<T, U = T> = (T extends any ? (x: T) => void : never) extends (
|
17
|
+
x: U,
|
18
|
+
) => void
|
19
|
+
? false
|
20
|
+
: true;
|
21
|
+
|
10
22
|
export type RefsToResolve<
|
11
23
|
V,
|
12
24
|
DepthLimit extends number = 10,
|
@@ -16,56 +28,58 @@ export type RefsToResolve<
|
|
16
28
|
| (DepthLimit extends CurrentDepth["length"]
|
17
29
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
18
30
|
any
|
19
|
-
:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
$each: RefsToResolve<
|
24
|
-
NotNull<Item>,
|
25
|
-
DepthLimit,
|
26
|
-
[0, ...CurrentDepth]
|
27
|
-
>;
|
28
|
-
$onError?: null;
|
29
|
-
}
|
30
|
-
| boolean
|
31
|
-
: // Basically V extends CoMap | Group | Account - but if we used that we'd introduce circularity into the definition of CoMap itself
|
32
|
-
V extends { _type: "CoMap" | "Group" | "Account" }
|
31
|
+
: IsUnion<NonNullable<V>> extends true
|
32
|
+
? true
|
33
|
+
: // Basically V extends CoList - but if we used that we'd introduce circularity into the definition of CoList itself
|
34
|
+
V extends Array<infer Item>
|
33
35
|
?
|
34
|
-
|
|
35
|
-
|
36
|
-
|
37
|
-
: never]?: RefsToResolve<
|
38
|
-
NonNullable<V[Key]>,
|
36
|
+
| {
|
37
|
+
$each: RefsToResolve<
|
38
|
+
NotNull<Item>,
|
39
39
|
DepthLimit,
|
40
40
|
[0, ...CurrentDepth]
|
41
41
|
>;
|
42
|
-
|
43
|
-
|
44
|
-
? {
|
45
|
-
$each: RefsToResolve<
|
46
|
-
NonNullable<V[ItemsSym]>,
|
47
|
-
DepthLimit,
|
48
|
-
[0, ...CurrentDepth]
|
49
|
-
>;
|
50
|
-
$onError?: null;
|
51
|
-
}
|
52
|
-
: never)
|
42
|
+
$onError?: null;
|
43
|
+
}
|
53
44
|
| boolean
|
54
|
-
: V extends
|
55
|
-
|
56
|
-
byMe: CoFeedEntry<infer Item> | undefined;
|
57
|
-
}
|
45
|
+
: // Basically V extends CoMap | Group | Account - but if we used that we'd introduce circularity into the definition of CoMap itself
|
46
|
+
V extends { _type: "CoMap" | "Group" | "Account" }
|
58
47
|
?
|
59
|
-
| {
|
60
|
-
|
61
|
-
|
48
|
+
| ({
|
49
|
+
[Key in CoKeys<V> as NonNullable<V[Key]> extends CoValue
|
50
|
+
? Key
|
51
|
+
: never]?: RefsToResolve<
|
52
|
+
NonNullable<V[Key]>,
|
62
53
|
DepthLimit,
|
63
54
|
[0, ...CurrentDepth]
|
64
55
|
>;
|
65
|
-
|
66
|
-
|
56
|
+
} & { $onError?: null })
|
57
|
+
| (ItemsSym extends keyof V
|
58
|
+
? {
|
59
|
+
$each: RefsToResolve<
|
60
|
+
NonNullable<V[ItemsSym]>,
|
61
|
+
DepthLimit,
|
62
|
+
[0, ...CurrentDepth]
|
63
|
+
>;
|
64
|
+
$onError?: null;
|
65
|
+
}
|
66
|
+
: never)
|
67
67
|
| boolean
|
68
|
-
:
|
68
|
+
: V extends {
|
69
|
+
_type: "CoStream";
|
70
|
+
byMe: CoFeedEntry<infer Item> | undefined;
|
71
|
+
}
|
72
|
+
?
|
73
|
+
| {
|
74
|
+
$each: RefsToResolve<
|
75
|
+
NotNull<Item>,
|
76
|
+
DepthLimit,
|
77
|
+
[0, ...CurrentDepth]
|
78
|
+
>;
|
79
|
+
$onError?: null;
|
80
|
+
}
|
81
|
+
| boolean
|
82
|
+
: boolean);
|
69
83
|
|
70
84
|
export type RefsToResolveStrict<T, V> = V extends RefsToResolve<T>
|
71
85
|
? RefsToResolve<T>
|
package/src/tools/exports.ts
CHANGED
@@ -43,27 +43,35 @@ type SchemaField =
|
|
43
43
|
| z.core.$ZodCatch<z.core.$ZodType>
|
44
44
|
| (z.core.$ZodCustom<any, any> & { builtin: any });
|
45
45
|
|
46
|
-
export function schemaFieldToCoFieldDef(
|
46
|
+
export function schemaFieldToCoFieldDef(
|
47
|
+
schema: SchemaField,
|
48
|
+
isOptional = false,
|
49
|
+
) {
|
47
50
|
if (isCoValueClass(schema)) {
|
48
|
-
|
51
|
+
if (isOptional) {
|
52
|
+
return coField.ref(schema, { optional: true });
|
53
|
+
} else {
|
54
|
+
return coField.ref(schema);
|
55
|
+
}
|
49
56
|
} else if (isCoValueSchema(schema)) {
|
50
57
|
if (isAnyCoOptionalSchema(schema)) {
|
51
58
|
return coField.ref(schema.getCoValueClass(), {
|
52
59
|
optional: true,
|
53
60
|
});
|
54
61
|
}
|
55
|
-
|
62
|
+
|
63
|
+
if (isOptional) {
|
64
|
+
return coField.ref(schema.getCoValueClass(), { optional: true });
|
65
|
+
} else {
|
66
|
+
return coField.ref(schema.getCoValueClass());
|
67
|
+
}
|
56
68
|
} else {
|
57
69
|
if ("_zod" in schema) {
|
58
70
|
if (schema._zod.def.type === "optional") {
|
59
71
|
const inner = zodSchemaToCoSchemaOrKeepPrimitive(
|
60
72
|
schema._zod.def.innerType,
|
61
73
|
);
|
62
|
-
|
63
|
-
return coField.ref(inner, { optional: true });
|
64
|
-
} else {
|
65
|
-
return schemaFieldToCoFieldDef(inner);
|
66
|
-
}
|
74
|
+
return schemaFieldToCoFieldDef(inner, true);
|
67
75
|
} else if (schema._zod.def.type === "string") {
|
68
76
|
return coField.string;
|
69
77
|
} else if (schema._zod.def.type === "number") {
|
@@ -77,6 +85,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
|
77
85
|
} else if (schema._zod.def.type === "readonly") {
|
78
86
|
return schemaFieldToCoFieldDef(
|
79
87
|
(schema as unknown as ZodReadonly).def.innerType as SchemaField,
|
88
|
+
isOptional,
|
80
89
|
);
|
81
90
|
} else if (schema._zod.def.type === "date") {
|
82
91
|
return coField.optional.Date;
|
@@ -86,6 +95,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
|
86
95
|
// Mostly to support z.json()
|
87
96
|
return schemaFieldToCoFieldDef(
|
88
97
|
(schema as unknown as ZodLazy).unwrap() as SchemaField,
|
98
|
+
isOptional,
|
89
99
|
);
|
90
100
|
} else if (
|
91
101
|
schema._zod.def.type === "default" ||
|
@@ -98,6 +108,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
|
98
108
|
return schemaFieldToCoFieldDef(
|
99
109
|
(schema as unknown as ZodDefault | ZodCatch).def
|
100
110
|
.innerType as SchemaField,
|
111
|
+
isOptional,
|
101
112
|
);
|
102
113
|
} else if (schema._zod.def.type === "literal") {
|
103
114
|
if (
|
@@ -129,7 +140,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
|
129
140
|
return coField.json();
|
130
141
|
} else if (schema._zod.def.type === "custom") {
|
131
142
|
if ("builtin" in schema) {
|
132
|
-
return schemaFieldToCoFieldDef(schema.builtin);
|
143
|
+
return schemaFieldToCoFieldDef(schema.builtin, isOptional);
|
133
144
|
} else {
|
134
145
|
throw new Error(`Unsupported custom zod type`);
|
135
146
|
}
|
@@ -137,9 +148,13 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
|
137
148
|
if (isUnionOfPrimitivesDeeply(schema)) {
|
138
149
|
return coField.json();
|
139
150
|
} else if (isUnionOfCoMapsDeeply(schema)) {
|
140
|
-
|
141
|
-
|
142
|
-
)
|
151
|
+
const result = schemaUnionDiscriminatorFor(schema);
|
152
|
+
|
153
|
+
if (isOptional) {
|
154
|
+
return coField.ref<CoValueClass<CoMap>>(result, { optional: true });
|
155
|
+
} else {
|
156
|
+
return coField.ref<CoValueClass<CoMap>>(result);
|
157
|
+
}
|
143
158
|
} else {
|
144
159
|
throw new Error(
|
145
160
|
"z.union()/z.discriminatedUnion() of mixed collaborative and non-collaborative types is not supported",
|
@@ -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" },
|
@@ -42,6 +42,120 @@ test("return null if id is invalid", async () => {
|
|
42
42
|
expect(john).toBeNull();
|
43
43
|
});
|
44
44
|
|
45
|
+
test("load a missing optional value (co.optional)", async () => {
|
46
|
+
const Dog = co.map({
|
47
|
+
name: z.string(),
|
48
|
+
});
|
49
|
+
|
50
|
+
const Person = co.map({
|
51
|
+
name: z.string(),
|
52
|
+
dog: co.optional(Dog),
|
53
|
+
});
|
54
|
+
|
55
|
+
const group = Group.create();
|
56
|
+
const map = Person.create({ name: "John" }, group);
|
57
|
+
group.addMember("everyone", "reader");
|
58
|
+
|
59
|
+
const alice = await createJazzTestAccount();
|
60
|
+
|
61
|
+
const john = await Person.load(map.id, {
|
62
|
+
loadAs: alice,
|
63
|
+
resolve: { dog: true },
|
64
|
+
});
|
65
|
+
|
66
|
+
assert(john);
|
67
|
+
|
68
|
+
expect(john.name).toBe("John");
|
69
|
+
expect(john.dog).toBeUndefined();
|
70
|
+
});
|
71
|
+
|
72
|
+
test("load a missing optional value (z.optional)", async () => {
|
73
|
+
const Dog = co.map({
|
74
|
+
name: z.string(),
|
75
|
+
});
|
76
|
+
|
77
|
+
const Person = co.map({
|
78
|
+
name: z.string(),
|
79
|
+
dog: z.optional(Dog),
|
80
|
+
});
|
81
|
+
|
82
|
+
const group = Group.create();
|
83
|
+
const map = Person.create({ name: "John" }, group);
|
84
|
+
group.addMember("everyone", "reader");
|
85
|
+
|
86
|
+
const alice = await createJazzTestAccount();
|
87
|
+
|
88
|
+
const john = await Person.load(map.id, {
|
89
|
+
loadAs: alice,
|
90
|
+
resolve: { dog: true },
|
91
|
+
});
|
92
|
+
|
93
|
+
assert(john);
|
94
|
+
|
95
|
+
expect(john.name).toBe("John");
|
96
|
+
expect(john.dog).toBeUndefined();
|
97
|
+
});
|
98
|
+
|
99
|
+
test("load a missing optional value (Schema.optional)", async () => {
|
100
|
+
const Dog = co.map({
|
101
|
+
name: z.string(),
|
102
|
+
});
|
103
|
+
|
104
|
+
const Person = co.map({
|
105
|
+
name: z.string(),
|
106
|
+
dog: Dog.optional(),
|
107
|
+
});
|
108
|
+
|
109
|
+
const group = Group.create();
|
110
|
+
const map = Person.create({ name: "John" }, group);
|
111
|
+
group.addMember("everyone", "reader");
|
112
|
+
|
113
|
+
const alice = await createJazzTestAccount();
|
114
|
+
|
115
|
+
const john = await Person.load(map.id, {
|
116
|
+
loadAs: alice,
|
117
|
+
resolve: { dog: true },
|
118
|
+
});
|
119
|
+
|
120
|
+
assert(john);
|
121
|
+
|
122
|
+
expect(john.name).toBe("John");
|
123
|
+
expect(john.dog).toBeUndefined();
|
124
|
+
});
|
125
|
+
|
126
|
+
test("load a missing optional value (optional discrminatedUnion)", async () => {
|
127
|
+
const Dog = co.map({
|
128
|
+
type: z.literal("dog"),
|
129
|
+
name: z.string(),
|
130
|
+
});
|
131
|
+
|
132
|
+
const Cat = co.map({
|
133
|
+
type: z.literal("cat"),
|
134
|
+
name: z.string(),
|
135
|
+
});
|
136
|
+
|
137
|
+
const Person = co.map({
|
138
|
+
name: z.string(),
|
139
|
+
pet: co.discriminatedUnion("type", [Dog, Cat]).optional(),
|
140
|
+
});
|
141
|
+
|
142
|
+
const group = Group.create();
|
143
|
+
const map = Person.create({ name: "John" }, group);
|
144
|
+
group.addMember("everyone", "reader");
|
145
|
+
|
146
|
+
const alice = await createJazzTestAccount();
|
147
|
+
|
148
|
+
const john = await Person.load(map.id, {
|
149
|
+
loadAs: alice,
|
150
|
+
resolve: { pet: true },
|
151
|
+
});
|
152
|
+
|
153
|
+
assert(john);
|
154
|
+
|
155
|
+
expect(john.name).toBe("John");
|
156
|
+
expect(john.pet).toBeUndefined();
|
157
|
+
});
|
158
|
+
|
45
159
|
test("retry an unavailable value", async () => {
|
46
160
|
const Person = co.map({
|
47
161
|
name: z.string(),
|
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
|
],
|