jazz-tools 0.14.8 → 0.14.10
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 +7 -7
- package/CHANGELOG.md +14 -0
- package/dist/{chunk-PA6UHG6Q.js → chunk-YLZ5746T.js} +114 -40
- package/dist/chunk-YLZ5746T.js.map +1 -0
- package/dist/coValues/extensions/imageDef.d.ts +3 -3
- package/dist/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +2 -2
- package/dist/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +1 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +2 -1
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +2 -1
- package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +2 -1
- package/dist/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +1 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +2 -2
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +2 -2
- package/dist/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/implementation/zodSchema/unionUtils.d.ts +1 -1
- package/dist/implementation/zodSchema/unionUtils.d.ts.map +1 -1
- package/dist/implementation/zodSchema/zodCo.d.ts +1 -1
- package/dist/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/implementation/zodSchema/zodReExport.d.ts +1 -1
- package/dist/implementation/zodSchema/zodReExport.d.ts.map +1 -1
- package/dist/implementation/zodSchema/zodSchema.d.ts +1 -1
- package/dist/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/index.js +4 -75
- package/dist/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/extensions/imageDef.ts +3 -8
- package/src/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +21 -5
- package/src/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +1 -1
- package/src/implementation/zodSchema/schemaTypes/AccountSchema.ts +1 -1
- package/src/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +1 -1
- package/src/implementation/zodSchema/schemaTypes/CoListSchema.ts +2 -1
- package/src/implementation/zodSchema/schemaTypes/CoMapSchema.ts +2 -1
- package/src/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +2 -1
- package/src/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +1 -1
- package/src/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +1 -1
- package/src/implementation/zodSchema/schemaTypes/RichTextSchema.ts +1 -1
- package/src/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +1 -1
- package/src/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +1 -1
- package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +10 -2
- package/src/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +10 -2
- package/src/implementation/zodSchema/unionUtils.ts +1 -1
- package/src/implementation/zodSchema/zodCo.ts +4 -1
- package/src/implementation/zodSchema/zodReExport.ts +7 -1
- package/src/implementation/zodSchema/zodSchema.ts +1 -1
- package/src/tests/zod.test.ts +35 -17
- package/dist/chunk-PA6UHG6Q.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.14.
|
2
|
+
> jazz-tools@0.14.10 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup && pnpm types
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
|
@@ -9,14 +9,14 @@
|
|
9
9
|
[34mCLI[39m Target: es2021
|
10
10
|
[34mCLI[39m Cleaning output folder
|
11
11
|
[34mESM[39m Build start
|
12
|
-
[32mESM[39m [1mdist/index.js [22m[
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m11.07 KB[39m
|
13
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.31 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
15
|
-
[32mESM[39m [1mdist/index.js.map [22m[
|
14
|
+
[32mESM[39m [1mdist/chunk-YLZ5746T.js [22m[32m132.99 KB[39m
|
15
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m18.38 KB[39m
|
16
16
|
[32mESM[39m [1mdist/testing.js.map [22m[32m12.57 KB[39m
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
17
|
+
[32mESM[39m [1mdist/chunk-YLZ5746T.js.map [22m[32m307.99 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 79ms
|
19
19
|
|
20
|
-
> jazz-tools@0.14.
|
20
|
+
> jazz-tools@0.14.10 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
21
21
|
> tsc --outDir dist
|
22
22
|
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.14.10
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- dc746a2: Make the react peerDependency definition more relaxed
|
8
|
+
- f869d9a: Deprecated the withHelpers method in favor of standalone functions
|
9
|
+
- 3fe6832: Add support for z.catch/default. We ignore them for the moment and flag a warning.
|
10
|
+
|
11
|
+
## 0.14.9
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- 22c2600: Move back to zod as dependency and clean up zod re-export
|
16
|
+
|
3
17
|
## 0.14.8
|
4
18
|
|
5
19
|
### Patch Changes
|
@@ -4,6 +4,79 @@ var __export = (target, all) => {
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
5
5
|
};
|
6
6
|
|
7
|
+
// src/implementation/zodSchema/zodReExport.ts
|
8
|
+
var zodReExport_exports = {};
|
9
|
+
__export(zodReExport_exports, {
|
10
|
+
array: () => array,
|
11
|
+
base64: () => base64,
|
12
|
+
base64url: () => base64url,
|
13
|
+
boolean: () => boolean,
|
14
|
+
cidrv4: () => cidrv4,
|
15
|
+
cidrv6: () => cidrv6,
|
16
|
+
cuid: () => cuid,
|
17
|
+
cuid2: () => cuid2,
|
18
|
+
date: () => date,
|
19
|
+
discriminatedUnion: () => discriminatedUnion,
|
20
|
+
email: () => email,
|
21
|
+
emoji: () => emoji,
|
22
|
+
enum: () => enum2,
|
23
|
+
int: () => int,
|
24
|
+
int32: () => int32,
|
25
|
+
ipv4: () => ipv4,
|
26
|
+
ipv6: () => ipv6,
|
27
|
+
iso: () => iso,
|
28
|
+
json: () => json,
|
29
|
+
literal: () => literal,
|
30
|
+
nanoid: () => nanoid,
|
31
|
+
number: () => number,
|
32
|
+
object: () => object,
|
33
|
+
optional: () => optional,
|
34
|
+
strictObject: () => strictObject,
|
35
|
+
string: () => string,
|
36
|
+
templateLiteral: () => templateLiteral,
|
37
|
+
tuple: () => tuple,
|
38
|
+
ulid: () => ulid,
|
39
|
+
union: () => union,
|
40
|
+
url: () => url,
|
41
|
+
uuid: () => uuid,
|
42
|
+
z: () => z
|
43
|
+
});
|
44
|
+
import {
|
45
|
+
string,
|
46
|
+
number,
|
47
|
+
boolean,
|
48
|
+
union,
|
49
|
+
object,
|
50
|
+
array,
|
51
|
+
templateLiteral,
|
52
|
+
json,
|
53
|
+
tuple,
|
54
|
+
date,
|
55
|
+
emoji,
|
56
|
+
base64,
|
57
|
+
base64url,
|
58
|
+
nanoid,
|
59
|
+
cuid,
|
60
|
+
cuid2,
|
61
|
+
ulid,
|
62
|
+
ipv4,
|
63
|
+
ipv6,
|
64
|
+
email,
|
65
|
+
url,
|
66
|
+
uuid,
|
67
|
+
literal,
|
68
|
+
enum as enum2,
|
69
|
+
cidrv4,
|
70
|
+
cidrv6,
|
71
|
+
iso,
|
72
|
+
int32,
|
73
|
+
strictObject,
|
74
|
+
discriminatedUnion,
|
75
|
+
int,
|
76
|
+
optional,
|
77
|
+
z
|
78
|
+
} from "zod/v4";
|
79
|
+
|
7
80
|
// src/coValues/CoValueBase.ts
|
8
81
|
import { ControlledAccount, RawAccount } from "cojson";
|
9
82
|
var CoValueBase = class {
|
@@ -2560,7 +2633,7 @@ var Encoders = {
|
|
2560
2633
|
decode: (value) => value === null ? void 0 : new Date(value)
|
2561
2634
|
}
|
2562
2635
|
};
|
2563
|
-
var
|
2636
|
+
var optional2 = {
|
2564
2637
|
ref: optionalRef,
|
2565
2638
|
json() {
|
2566
2639
|
return { [SchemaInit]: "json" };
|
@@ -2614,7 +2687,7 @@ var coField = {
|
|
2614
2687
|
},
|
2615
2688
|
ref,
|
2616
2689
|
items: ItemsSym,
|
2617
|
-
optional
|
2690
|
+
optional: optional2
|
2618
2691
|
};
|
2619
2692
|
function optionalRef(arg) {
|
2620
2693
|
return ref(arg, { optional: true });
|
@@ -3368,7 +3441,6 @@ function getDef(schema) {
|
|
3368
3441
|
}
|
3369
3442
|
|
3370
3443
|
// src/implementation/zodSchema/zodCo.ts
|
3371
|
-
import z from "jazz-tools-zod-v4-rn-patch/v4";
|
3372
3444
|
var coMapDefiner = (shape) => {
|
3373
3445
|
const objectSchema = z.object(shape).meta({
|
3374
3446
|
collaborative: true
|
@@ -3564,12 +3636,8 @@ __export(coExport_exports, {
|
|
3564
3636
|
richText: () => coRichTextDefiner
|
3565
3637
|
});
|
3566
3638
|
|
3567
|
-
// src/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts
|
3568
|
-
import z3 from "jazz-tools-zod-v4-rn-patch/v4";
|
3569
|
-
|
3570
3639
|
// src/implementation/zodSchema/unionUtils.ts
|
3571
3640
|
import { RawCoList } from "cojson";
|
3572
|
-
import z2 from "jazz-tools-zod-v4-rn-patch/v4";
|
3573
3641
|
function schemaUnionDiscriminatorFor(schema) {
|
3574
3642
|
if (isUnionOfCoMapsDeeply(schema)) {
|
3575
3643
|
if (!schema._zod.disc || schema._zod.disc.size == 0) {
|
@@ -3655,23 +3723,23 @@ function schemaUnionDiscriminatorFor(schema) {
|
|
3655
3723
|
}
|
3656
3724
|
}
|
3657
3725
|
function isUnionOfCoMapsDeeply(schema) {
|
3658
|
-
if (schema instanceof
|
3726
|
+
if (schema instanceof z.core.$ZodUnion) {
|
3659
3727
|
return schema._zod.def.options.every(isCoMapOrUnionOfCoMapsDeeply);
|
3660
3728
|
} else {
|
3661
3729
|
return false;
|
3662
3730
|
}
|
3663
3731
|
}
|
3664
3732
|
function isCoMapOrUnionOfCoMapsDeeply(schema) {
|
3665
|
-
if (schema instanceof
|
3733
|
+
if (schema instanceof z.core.$ZodObject && "collaborative" in schema && schema.collaborative) {
|
3666
3734
|
return true;
|
3667
|
-
} else if (schema instanceof
|
3735
|
+
} else if (schema instanceof z.core.$ZodUnion) {
|
3668
3736
|
return schema._zod.def.options.every(isCoMapOrUnionOfCoMapsDeeply);
|
3669
3737
|
} else {
|
3670
3738
|
return false;
|
3671
3739
|
}
|
3672
3740
|
}
|
3673
3741
|
function isUnionOfPrimitivesDeeply(schema) {
|
3674
|
-
if (schema instanceof
|
3742
|
+
if (schema instanceof z.core.$ZodUnion) {
|
3675
3743
|
return schema._zod.def.options.every(isUnionOfPrimitivesDeeply);
|
3676
3744
|
} else {
|
3677
3745
|
return !("collaborative" in schema);
|
@@ -3715,16 +3783,23 @@ function zodFieldToCoFieldDef(schema) {
|
|
3715
3783
|
return zodFieldToCoFieldDef(
|
3716
3784
|
schema.unwrap()
|
3717
3785
|
);
|
3786
|
+
} else if (schema._zod.def.type === "default" || schema._zod.def.type === "catch") {
|
3787
|
+
console.warn(
|
3788
|
+
"z.default()/z.catch() are not supported in collaborative schemas. They will be ignored."
|
3789
|
+
);
|
3790
|
+
return zodFieldToCoFieldDef(
|
3791
|
+
schema.def.innerType
|
3792
|
+
);
|
3718
3793
|
} else if (schema._zod.def.type === "literal") {
|
3719
3794
|
if (schema._zod.def.values.some(
|
3720
|
-
(
|
3795
|
+
(literal2) => typeof literal2 === "undefined"
|
3721
3796
|
)) {
|
3722
3797
|
throw new Error("z.literal() with undefined is not supported");
|
3723
3798
|
}
|
3724
|
-
if (schema._zod.def.values.some((
|
3799
|
+
if (schema._zod.def.values.some((literal2) => literal2 === null)) {
|
3725
3800
|
throw new Error("z.literal() with null is not supported");
|
3726
3801
|
}
|
3727
|
-
if (schema._zod.def.values.some((
|
3802
|
+
if (schema._zod.def.values.some((literal2) => typeof literal2 === "bigint")) {
|
3728
3803
|
throw new Error("z.literal() with bigint is not supported");
|
3729
3804
|
}
|
3730
3805
|
return coField.literal(
|
@@ -3838,7 +3913,7 @@ function tryZodSchemaToCoSchema(schema) {
|
|
3838
3913
|
`Unsupported zod CoValue type for top-level schema: ${schema._zod?.def?.type || JSON.stringify(schema, void 0, 2)}`
|
3839
3914
|
);
|
3840
3915
|
}
|
3841
|
-
} else if (schema instanceof
|
3916
|
+
} else if (schema instanceof z.core.$ZodDiscriminatedUnion) {
|
3842
3917
|
if (isUnionOfCoMapsDeeply(schema)) {
|
3843
3918
|
return SchemaUnion.Of(
|
3844
3919
|
schemaUnionDiscriminatorFor(schema)
|
@@ -3877,10 +3952,9 @@ function zodSchemaToCoSchemaOrKeepPrimitive(schema) {
|
|
3877
3952
|
}
|
3878
3953
|
|
3879
3954
|
// src/coValues/extensions/imageDef.ts
|
3880
|
-
import z4 from "jazz-tools-zod-v4-rn-patch/v4";
|
3881
3955
|
var ImageDefinitionBase = coMapDefiner({
|
3882
|
-
originalSize:
|
3883
|
-
placeholderDataURL:
|
3956
|
+
originalSize: z.tuple([z.number(), z.number()]),
|
3957
|
+
placeholderDataURL: z.string().optional()
|
3884
3958
|
}).catchall(coFileStreamDefiner());
|
3885
3959
|
var ImageDefinition = ImageDefinitionBase.withHelpers((Self) => ({
|
3886
3960
|
highestResAvailable(imageDef, options) {
|
@@ -4255,23 +4329,23 @@ function createResolvablePromise() {
|
|
4255
4329
|
// src/implementation/devtoolsFormatters.ts
|
4256
4330
|
globalThis.devtoolsFormatters = [
|
4257
4331
|
{
|
4258
|
-
header: (
|
4259
|
-
if (
|
4260
|
-
return ["div", {}, ["span", {},
|
4261
|
-
} else if (
|
4332
|
+
header: (object2) => {
|
4333
|
+
if (object2._type === "CoMap") {
|
4334
|
+
return ["div", {}, ["span", {}, object2.constructor.name]];
|
4335
|
+
} else if (object2._type === "CoList") {
|
4262
4336
|
return [
|
4263
4337
|
"div",
|
4264
4338
|
{},
|
4265
|
-
["span", {},
|
4339
|
+
["span", {}, object2.constructor.name + "(" + object2.length + ") "]
|
4266
4340
|
];
|
4267
|
-
} else if (
|
4341
|
+
} else if (object2._type === "Account") {
|
4268
4342
|
return [
|
4269
4343
|
"div",
|
4270
4344
|
{},
|
4271
4345
|
[
|
4272
4346
|
"span",
|
4273
4347
|
{},
|
4274
|
-
|
4348
|
+
object2.constructor.name + "(" + object2._refs.profile.value?.name + (object2.isMe ? " ME" : "") + ")"
|
4275
4349
|
]
|
4276
4350
|
];
|
4277
4351
|
} else {
|
@@ -4281,44 +4355,44 @@ globalThis.devtoolsFormatters = [
|
|
4281
4355
|
hasBody: function() {
|
4282
4356
|
return true;
|
4283
4357
|
},
|
4284
|
-
body: function(
|
4285
|
-
if (
|
4358
|
+
body: function(object2) {
|
4359
|
+
if (object2._type === "CoMap" || object2._type === "Account") {
|
4286
4360
|
return [
|
4287
4361
|
"div",
|
4288
4362
|
{ style: "margin-left: 15px" },
|
4289
|
-
["div", "id: ", ["object", { object:
|
4290
|
-
...Object.entries(
|
4363
|
+
["div", "id: ", ["object", { object: object2.id }]],
|
4364
|
+
...Object.entries(object2).map(([k, v]) => [
|
4291
4365
|
"div",
|
4292
4366
|
{ style: "white-space: nowrap;" },
|
4293
4367
|
["span", { style: "font-weight: bold; opacity: 0.6" }, k, ": "],
|
4294
4368
|
["object", { object: v }],
|
4295
|
-
...typeof
|
4369
|
+
...typeof object2._schema[k] === "function" ? v === null ? [
|
4296
4370
|
[
|
4297
4371
|
"span",
|
4298
4372
|
{ style: "opacity: 0.5" },
|
4299
|
-
` (pending ${
|
4300
|
-
["object", { object:
|
4373
|
+
` (pending ${object2._schema[k].name} `,
|
4374
|
+
["object", { object: object2._refs[k] }],
|
4301
4375
|
")"
|
4302
4376
|
]
|
4303
4377
|
] : [] : []
|
4304
4378
|
])
|
4305
4379
|
];
|
4306
|
-
} else if (
|
4380
|
+
} else if (object2._type === "CoList") {
|
4307
4381
|
return [
|
4308
4382
|
"div",
|
4309
4383
|
{ style: "margin-left: 15px" },
|
4310
|
-
["div", "id: ", ["object", { object:
|
4311
|
-
...
|
4384
|
+
["div", "id: ", ["object", { object: object2.id }]],
|
4385
|
+
...object2.map((v, i) => [
|
4312
4386
|
"div",
|
4313
4387
|
{ style: "white-space: nowrap;" },
|
4314
4388
|
["span", { style: "font-weight: bold; opacity: 0.6" }, i, ": "],
|
4315
4389
|
["object", { object: v }],
|
4316
|
-
...typeof
|
4390
|
+
...typeof object2._schema[ItemsSym] === "function" ? v === null ? [
|
4317
4391
|
[
|
4318
4392
|
"span",
|
4319
4393
|
{ style: "opacity: 0.5" },
|
4320
|
-
` (pending ${
|
4321
|
-
["object", { object:
|
4394
|
+
` (pending ${object2._schema[ItemsSym].name} `,
|
4395
|
+
["object", { object: object2._refs[i] }],
|
4322
4396
|
")"
|
4323
4397
|
]
|
4324
4398
|
] : [] : []
|
@@ -4531,7 +4605,7 @@ function parseGroupCreateOptions(options) {
|
|
4531
4605
|
}
|
4532
4606
|
|
4533
4607
|
export {
|
4534
|
-
|
4608
|
+
zodReExport_exports,
|
4535
4609
|
loadCoValue,
|
4536
4610
|
subscribeToCoValue,
|
4537
4611
|
createCoValueObservable,
|
@@ -4568,4 +4642,4 @@ export {
|
|
4568
4642
|
JazzContextManager
|
4569
4643
|
};
|
4570
4644
|
/* istanbul ignore file -- @preserve */
|
4571
|
-
//# sourceMappingURL=chunk-
|
4645
|
+
//# sourceMappingURL=chunk-YLZ5746T.js.map
|