jazz-tools 0.15.9 → 0.15.11
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-5PFEKHX5.js → chunk-MLLG3GBR.js} +422 -303
- package/dist/chunk-MLLG3GBR.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/testing.js +2 -0
- package/dist/react/testing.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +27 -1
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts +1 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +6 -3
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +6 -25
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +30 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +3 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +3 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts +11 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +2 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +5 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +5 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +5 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +7 -12
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts +2 -3
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +6 -6
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts +8 -1
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +18 -13
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +1 -0
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/tests/coDiscriminatedUnion.test-d.d.ts +2 -0
- package/dist/tools/tests/coDiscriminatedUnion.test-d.d.ts.map +1 -0
- package/dist/tools/tests/coDiscriminatedUnion.test.d.ts +2 -0
- package/dist/tools/tests/coDiscriminatedUnion.test.d.ts.map +1 -0
- package/dist/tools/tests/coOptional.test.d.ts +2 -0
- package/dist/tools/tests/coOptional.test.d.ts.map +1 -0
- package/dist/tools/tests/zod.test-d.d.ts +2 -0
- package/dist/tools/tests/zod.test-d.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/react-core/tests/useAccount.test.ts +1 -11
- package/src/tools/coValues/CoValueBase.ts +2 -2
- package/src/tools/coValues/inbox.ts +0 -2
- package/src/tools/coValues/schemaUnion.ts +62 -0
- package/src/tools/implementation/zodSchema/coExport.ts +2 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +29 -12
- package/src/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +93 -63
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +62 -3
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +90 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +27 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +27 -5
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +60 -5
- package/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts +33 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +3 -5
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +32 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +30 -2
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +26 -2
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +10 -13
- package/src/tools/implementation/zodSchema/unionUtils.ts +22 -14
- package/src/tools/implementation/zodSchema/zodCo.ts +68 -256
- package/src/tools/implementation/zodSchema/zodReExport.ts +35 -5
- package/src/tools/implementation/zodSchema/zodSchema.ts +78 -19
- package/src/tools/internal.ts +1 -0
- package/src/tools/subscribe/SubscriptionScope.ts +1 -2
- package/src/tools/tests/ContextManager.test.ts +5 -6
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +57 -0
- package/src/tools/tests/coDiscriminatedUnion.test.ts +93 -0
- package/src/tools/tests/coList.test.ts +4 -12
- package/src/tools/tests/coMap.record.test.ts +4 -4
- package/src/tools/tests/coMap.test-d.ts +3 -3
- package/src/tools/tests/coMap.test.ts +10 -10
- package/src/tools/tests/coOptional.test.ts +39 -0
- package/src/tools/tests/createContext.test.ts +5 -4
- package/src/tools/tests/deepLoading.test.ts +9 -9
- package/src/tools/tests/inbox.test.ts +3 -11
- package/src/tools/tests/patterns/requestToJoin.test.ts +1 -1
- package/src/tools/tests/schemaUnion.test.ts +11 -22
- package/src/tools/tests/subscribe.test.ts +25 -39
- package/src/tools/tests/zod.test-d.ts +70 -0
- package/src/tools/tests/zod.test.ts +64 -5
- package/dist/chunk-5PFEKHX5.js.map +0 -1
@@ -41,16 +41,18 @@ __export(zodReExport_exports, {
|
|
41
41
|
uuid: () => uuid,
|
42
42
|
z: () => z
|
43
43
|
});
|
44
|
+
import {
|
45
|
+
array as zodArray,
|
46
|
+
tuple as zodTuple,
|
47
|
+
union as zodUnion
|
48
|
+
} from "zod/v4";
|
44
49
|
import {
|
45
50
|
string,
|
46
51
|
number,
|
47
52
|
boolean,
|
48
|
-
union,
|
49
53
|
object,
|
50
|
-
array,
|
51
54
|
templateLiteral,
|
52
55
|
json,
|
53
|
-
tuple,
|
54
56
|
date,
|
55
57
|
emoji,
|
56
58
|
base64,
|
@@ -76,6 +78,15 @@ import {
|
|
76
78
|
optional,
|
77
79
|
z
|
78
80
|
} from "zod/v4";
|
81
|
+
function union(options, params) {
|
82
|
+
return zodUnion(options, params);
|
83
|
+
}
|
84
|
+
function array(element, params) {
|
85
|
+
return zodArray(element, params);
|
86
|
+
}
|
87
|
+
function tuple(options, params) {
|
88
|
+
return zodTuple(options, params);
|
89
|
+
}
|
79
90
|
|
80
91
|
// src/tools/coValues/CoValueBase.ts
|
81
92
|
import { ControlledAccount, RawAccount } from "cojson";
|
@@ -124,7 +135,7 @@ var CoValueBase = class {
|
|
124
135
|
}
|
125
136
|
/** @category Type Helpers */
|
126
137
|
castAs(schema) {
|
127
|
-
const cl =
|
138
|
+
const cl = isCoValueSchema(schema) ? schema.getCoValueClass() : schema;
|
128
139
|
if (this.constructor === cl) {
|
129
140
|
return this;
|
130
141
|
}
|
@@ -2653,6 +2664,20 @@ var SchemaUnion = class _SchemaUnion extends CoValueBase {
|
|
2653
2664
|
static fromRaw(raw) {
|
2654
2665
|
throw new Error("Not implemented");
|
2655
2666
|
}
|
2667
|
+
/**
|
2668
|
+
* Load a `SchemaUnion` with a given ID, as a given account.
|
2669
|
+
*
|
2670
|
+
* Note: The `resolve` option is not supported for `SchemaUnion`s due to https://github.com/garden-co/jazz/issues/2639
|
2671
|
+
*
|
2672
|
+
* @category Subscription & Loading
|
2673
|
+
*/
|
2674
|
+
static load(id, options) {
|
2675
|
+
return loadCoValueWithoutMe(this, id, options);
|
2676
|
+
}
|
2677
|
+
static subscribe(id, ...args) {
|
2678
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
2679
|
+
return subscribeToCoValueWithoutMe(this, id, options, listener);
|
2680
|
+
}
|
2656
2681
|
};
|
2657
2682
|
|
2658
2683
|
// src/tools/implementation/anonymousJazzAgent.ts
|
@@ -2911,13 +2936,13 @@ var CoValueCoreSubscription = class {
|
|
2911
2936
|
}
|
2912
2937
|
subscribeToState() {
|
2913
2938
|
const entry = this.node.getCoValue(this.id);
|
2914
|
-
const handleStateChange = (
|
2939
|
+
const handleStateChange = (core2, unsubFromStateChange2) => {
|
2915
2940
|
if (this.unsubscribed) {
|
2916
2941
|
unsubFromStateChange2();
|
2917
2942
|
return;
|
2918
2943
|
}
|
2919
|
-
if (
|
2920
|
-
this.subscribe(
|
2944
|
+
if (core2.isAvailable()) {
|
2945
|
+
this.subscribe(core2.getCurrentContent());
|
2921
2946
|
unsubFromStateChange2();
|
2922
2947
|
}
|
2923
2948
|
};
|
@@ -3098,7 +3123,7 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
3098
3123
|
new JazzError(this.id, "unauthorized", [
|
3099
3124
|
{
|
3100
3125
|
code: "unauthorized",
|
3101
|
-
message:
|
3126
|
+
message: `The current user (${this.node.getCurrentAgent().id}) is not authorized to access this value`,
|
3102
3127
|
params: {
|
3103
3128
|
id: this.id
|
3104
3129
|
},
|
@@ -3682,265 +3707,23 @@ function getDef(schema) {
|
|
3682
3707
|
return schema.def;
|
3683
3708
|
}
|
3684
3709
|
|
3685
|
-
// src/tools/implementation/zodSchema/
|
3686
|
-
function
|
3687
|
-
|
3688
|
-
const enrichedSchema = Object.assign(schema, {
|
3689
|
-
collaborative: true,
|
3690
|
-
create: (...args) => {
|
3691
|
-
return coSchema.create(...args);
|
3692
|
-
},
|
3693
|
-
load: (...args) => {
|
3694
|
-
return coSchema.load(...args);
|
3695
|
-
},
|
3696
|
-
subscribe: (...args) => {
|
3697
|
-
return coSchema.subscribe(...args);
|
3698
|
-
},
|
3699
|
-
findUnique: (...args) => {
|
3700
|
-
return coSchema.findUnique(...args);
|
3701
|
-
},
|
3702
|
-
upsertUnique: (...args) => {
|
3703
|
-
return coSchema.upsertUnique(...args);
|
3704
|
-
},
|
3705
|
-
loadUnique: (...args) => {
|
3706
|
-
return coSchema.loadUnique(...args);
|
3707
|
-
},
|
3708
|
-
catchall: (index) => {
|
3709
|
-
return enrichCoMapSchema(baseCatchall(index));
|
3710
|
-
},
|
3711
|
-
withHelpers: (helpers) => {
|
3712
|
-
return Object.assign(schema, helpers(schema));
|
3713
|
-
},
|
3714
|
-
withMigration: (migration) => {
|
3715
|
-
coSchema.prototype.migrate = migration;
|
3716
|
-
return enrichedSchema;
|
3717
|
-
},
|
3718
|
-
getCoSchema: () => {
|
3719
|
-
return coSchema;
|
3720
|
-
}
|
3721
|
-
});
|
3722
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3723
|
-
return enrichedSchema;
|
3724
|
-
}
|
3725
|
-
var coMapDefiner = (shape) => {
|
3726
|
-
const objectSchema = z.object(shape).meta({
|
3727
|
-
collaborative: true
|
3728
|
-
});
|
3729
|
-
return enrichCoMapSchema(objectSchema);
|
3730
|
-
};
|
3731
|
-
function enrichAccountSchema(schema) {
|
3732
|
-
const enrichedSchema = Object.assign(schema, {
|
3733
|
-
collaborative: true,
|
3734
|
-
builtin: "Account",
|
3735
|
-
create: (...args) => {
|
3736
|
-
return coSchema.create(...args);
|
3737
|
-
},
|
3738
|
-
createAs: (...args) => {
|
3739
|
-
return coSchema.createAs(...args);
|
3740
|
-
},
|
3741
|
-
getMe: (...args) => {
|
3742
|
-
return coSchema.getMe(...args);
|
3743
|
-
},
|
3744
|
-
load: (...args) => {
|
3745
|
-
return coSchema.load(...args);
|
3746
|
-
},
|
3747
|
-
subscribe: (...args) => {
|
3748
|
-
return coSchema.subscribe(...args);
|
3749
|
-
},
|
3750
|
-
withHelpers: (helpers) => {
|
3751
|
-
return Object.assign(schema, helpers(schema));
|
3752
|
-
},
|
3753
|
-
fromRaw: (...args) => {
|
3754
|
-
return coSchema.fromRaw(...args);
|
3755
|
-
},
|
3756
|
-
withMigration: (migration) => {
|
3757
|
-
coSchema.prototype.migrate = async function(creationProps) {
|
3758
|
-
await migration(this, creationProps);
|
3759
|
-
};
|
3760
|
-
return enrichedSchema;
|
3761
|
-
},
|
3762
|
-
getCoSchema: () => {
|
3763
|
-
return coSchema;
|
3764
|
-
}
|
3765
|
-
});
|
3766
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3767
|
-
return enrichedSchema;
|
3768
|
-
}
|
3769
|
-
var coAccountDefiner = (shape = {
|
3770
|
-
profile: coMapDefiner({
|
3771
|
-
name: z.string(),
|
3772
|
-
inbox: z.optional(z.string()),
|
3773
|
-
inboxInvite: z.optional(z.string())
|
3774
|
-
}),
|
3775
|
-
root: coMapDefiner({})
|
3776
|
-
}) => {
|
3777
|
-
const objectSchema = z.object(shape).meta({
|
3778
|
-
collaborative: true
|
3779
|
-
});
|
3780
|
-
return enrichAccountSchema(objectSchema);
|
3781
|
-
};
|
3782
|
-
var coRecordDefiner = (_keyType, valueType) => {
|
3783
|
-
return coMapDefiner({}).catchall(valueType);
|
3784
|
-
};
|
3785
|
-
function enrichCoListSchema(schema) {
|
3786
|
-
const enrichedSchema = Object.assign(schema, {
|
3787
|
-
collaborative: true,
|
3788
|
-
create: (...args) => {
|
3789
|
-
return coSchema.create(...args);
|
3790
|
-
},
|
3791
|
-
load: (...args) => {
|
3792
|
-
return coSchema.load(...args);
|
3793
|
-
},
|
3794
|
-
subscribe: (...args) => {
|
3795
|
-
return coSchema.subscribe(...args);
|
3796
|
-
},
|
3797
|
-
withHelpers: (helpers) => {
|
3798
|
-
return Object.assign(schema, helpers(schema));
|
3799
|
-
},
|
3800
|
-
getCoSchema: () => {
|
3801
|
-
return coSchema;
|
3802
|
-
}
|
3803
|
-
});
|
3804
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3805
|
-
return enrichedSchema;
|
3806
|
-
}
|
3807
|
-
var coListDefiner = (element) => {
|
3808
|
-
const arraySchema = z.array(element).meta({
|
3809
|
-
collaborative: true
|
3810
|
-
});
|
3811
|
-
return enrichCoListSchema(arraySchema);
|
3812
|
-
};
|
3813
|
-
var coProfileDefiner = (shape = {}) => {
|
3814
|
-
const ehnancedShape = Object.assign(shape ?? {}, {
|
3815
|
-
name: z.string(),
|
3816
|
-
inbox: z.optional(z.string()),
|
3817
|
-
inboxInvite: z.optional(z.string())
|
3818
|
-
});
|
3819
|
-
return coMapDefiner(ehnancedShape);
|
3820
|
-
};
|
3821
|
-
function enrichCoFeedSchema(schema, element) {
|
3822
|
-
const enrichedSchema = Object.assign(schema, {
|
3823
|
-
collaborative: true,
|
3824
|
-
builtin: "CoFeed",
|
3825
|
-
element,
|
3826
|
-
create: (...args) => {
|
3827
|
-
return coSchema.create(...args);
|
3828
|
-
},
|
3829
|
-
load: (...args) => {
|
3830
|
-
return coSchema.load(...args);
|
3831
|
-
},
|
3832
|
-
subscribe: (...args) => {
|
3833
|
-
return coSchema.subscribe(...args);
|
3834
|
-
},
|
3835
|
-
withHelpers: (helpers) => {
|
3836
|
-
return Object.assign(schema, helpers(schema));
|
3837
|
-
},
|
3838
|
-
getCoSchema: () => {
|
3839
|
-
return coSchema;
|
3840
|
-
}
|
3841
|
-
});
|
3842
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3843
|
-
return enrichedSchema;
|
3844
|
-
}
|
3845
|
-
var coFeedDefiner = (element) => {
|
3846
|
-
return enrichCoFeedSchema(z.instanceof(CoFeed), element);
|
3847
|
-
};
|
3848
|
-
function enrichFileStreamSchema(schema) {
|
3849
|
-
const enrichedSchema = Object.assign(schema, {
|
3850
|
-
collaborative: true,
|
3851
|
-
builtin: "FileStream",
|
3852
|
-
create: (...args) => {
|
3853
|
-
return coSchema.create(...args);
|
3854
|
-
},
|
3855
|
-
createFromBlob: (...args) => {
|
3856
|
-
return coSchema.createFromBlob(...args);
|
3857
|
-
},
|
3858
|
-
load: (...args) => {
|
3859
|
-
return coSchema.load(...args);
|
3860
|
-
},
|
3861
|
-
loadAsBlob: (...args) => {
|
3862
|
-
return coSchema.loadAsBlob(...args);
|
3863
|
-
},
|
3864
|
-
subscribe: (...args) => {
|
3865
|
-
return coSchema.subscribe(...args);
|
3866
|
-
},
|
3867
|
-
getCoSchema: () => {
|
3868
|
-
return coSchema;
|
3869
|
-
}
|
3870
|
-
});
|
3871
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3872
|
-
return enrichedSchema;
|
3873
|
-
}
|
3874
|
-
var coFileStreamDefiner = () => {
|
3875
|
-
return enrichFileStreamSchema(z.instanceof(FileStream));
|
3876
|
-
};
|
3877
|
-
function enrichPlainTextSchema(schema) {
|
3878
|
-
const enrichedSchema = Object.assign(schema, {
|
3879
|
-
collaborative: true,
|
3880
|
-
builtin: "CoPlainText",
|
3710
|
+
// src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts
|
3711
|
+
function enrichRichTextSchema(schema, coValueClass) {
|
3712
|
+
return Object.assign(schema, {
|
3881
3713
|
create: (...args) => {
|
3882
|
-
return
|
3714
|
+
return coValueClass.create(...args);
|
3883
3715
|
},
|
3884
3716
|
load: (...args) => {
|
3885
|
-
return
|
3717
|
+
return coValueClass.load(...args);
|
3886
3718
|
},
|
3887
3719
|
subscribe: (...args) => {
|
3888
|
-
return
|
3889
|
-
},
|
3890
|
-
fromRaw: (...args) => {
|
3891
|
-
return coSchema.fromRaw(...args);
|
3720
|
+
return coValueClass.subscribe(...args);
|
3892
3721
|
},
|
3893
|
-
|
3894
|
-
return
|
3722
|
+
getCoValueClass: () => {
|
3723
|
+
return coValueClass;
|
3895
3724
|
}
|
3896
3725
|
});
|
3897
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3898
|
-
return enrichedSchema;
|
3899
3726
|
}
|
3900
|
-
var coPlainTextDefiner = () => {
|
3901
|
-
return enrichPlainTextSchema(z.instanceof(CoPlainText));
|
3902
|
-
};
|
3903
|
-
function enrichRichTextSchema(schema) {
|
3904
|
-
const enrichedSchema = Object.assign(schema, {
|
3905
|
-
collaborative: true,
|
3906
|
-
builtin: "CoRichText",
|
3907
|
-
create: (...args) => {
|
3908
|
-
return coSchema.create(...args);
|
3909
|
-
},
|
3910
|
-
load: (...args) => {
|
3911
|
-
return coSchema.load(...args);
|
3912
|
-
},
|
3913
|
-
subscribe: (...args) => {
|
3914
|
-
return coSchema.subscribe(...args);
|
3915
|
-
},
|
3916
|
-
getCoSchema: () => {
|
3917
|
-
return coSchema;
|
3918
|
-
}
|
3919
|
-
});
|
3920
|
-
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3921
|
-
return enrichedSchema;
|
3922
|
-
}
|
3923
|
-
var coRichTextDefiner = () => {
|
3924
|
-
return enrichRichTextSchema(z.instanceof(CoRichText));
|
3925
|
-
};
|
3926
|
-
var coImageDefiner = () => {
|
3927
|
-
return ImageDefinition;
|
3928
|
-
};
|
3929
|
-
|
3930
|
-
// src/tools/implementation/zodSchema/coExport.ts
|
3931
|
-
var coExport_exports = {};
|
3932
|
-
__export(coExport_exports, {
|
3933
|
-
account: () => coAccountDefiner,
|
3934
|
-
feed: () => coFeedDefiner,
|
3935
|
-
fileStream: () => coFileStreamDefiner,
|
3936
|
-
image: () => coImageDefiner,
|
3937
|
-
list: () => coListDefiner,
|
3938
|
-
map: () => coMapDefiner,
|
3939
|
-
plainText: () => coPlainTextDefiner,
|
3940
|
-
profile: () => coProfileDefiner,
|
3941
|
-
record: () => coRecordDefiner,
|
3942
|
-
richText: () => coRichTextDefiner
|
3943
|
-
});
|
3944
3727
|
|
3945
3728
|
// src/tools/implementation/zodSchema/unionUtils.ts
|
3946
3729
|
import { RawCoList } from "cojson";
|
@@ -3948,20 +3731,20 @@ function schemaUnionDiscriminatorFor(schema) {
|
|
3948
3731
|
if (isUnionOfCoMapsDeeply(schema)) {
|
3949
3732
|
if (!schema._zod.disc || schema._zod.disc.size == 0) {
|
3950
3733
|
throw new Error(
|
3951
|
-
"z.union() of collaborative types is not supported, use
|
3734
|
+
"z.union() of collaborative types is not supported, use co.discriminatedUnion() instead"
|
3952
3735
|
);
|
3953
3736
|
}
|
3954
3737
|
const discriminator = schema._zod.def.discriminator;
|
3955
3738
|
const field = schema._zod.disc.get(discriminator);
|
3956
3739
|
if (!field) {
|
3957
3740
|
throw new Error(
|
3958
|
-
"
|
3741
|
+
"co.discriminatedUnion() of collaborative types with non-existent discriminator key is not supported"
|
3959
3742
|
);
|
3960
3743
|
}
|
3961
3744
|
for (const value of field.values) {
|
3962
3745
|
if (typeof value !== "string" && typeof value !== "number") {
|
3963
3746
|
throw new Error(
|
3964
|
-
"
|
3747
|
+
"co.discriminatedUnion() of collaborative types with non-string or non-number discriminator value is not supported"
|
3965
3748
|
);
|
3966
3749
|
}
|
3967
3750
|
}
|
@@ -3977,14 +3760,14 @@ function schemaUnionDiscriminatorFor(schema) {
|
|
3977
3760
|
}
|
3978
3761
|
} else {
|
3979
3762
|
throw new Error(
|
3980
|
-
"Unsupported zod type in
|
3763
|
+
"Unsupported zod type in co.discriminatedUnion() of collaborative types"
|
3981
3764
|
);
|
3982
3765
|
}
|
3983
3766
|
}
|
3984
3767
|
const determineSchema = (_raw) => {
|
3985
3768
|
if (_raw instanceof RawCoList) {
|
3986
3769
|
throw new Error(
|
3987
|
-
"
|
3770
|
+
"co.discriminatedUnion() of collaborative types is not supported for CoLists"
|
3988
3771
|
);
|
3989
3772
|
}
|
3990
3773
|
for (const option of availableOptions) {
|
@@ -4013,11 +3796,12 @@ function schemaUnionDiscriminatorFor(schema) {
|
|
4013
3796
|
}
|
4014
3797
|
}
|
4015
3798
|
if (match) {
|
4016
|
-
|
3799
|
+
const coValueSchema = zodSchemaToCoSchema(option);
|
3800
|
+
return coValueSchema.getCoValueClass();
|
4017
3801
|
}
|
4018
3802
|
}
|
4019
3803
|
throw new Error(
|
4020
|
-
"
|
3804
|
+
"co.discriminatedUnion() of collaborative types with no matching discriminator value found"
|
4021
3805
|
);
|
4022
3806
|
};
|
4023
3807
|
return determineSchema;
|
@@ -4035,7 +3819,7 @@ function isUnionOfCoMapsDeeply(schema) {
|
|
4035
3819
|
}
|
4036
3820
|
}
|
4037
3821
|
function isCoMapOrUnionOfCoMapsDeeply(schema) {
|
4038
|
-
if (schema instanceof z.core.$ZodObject &&
|
3822
|
+
if (schema instanceof z.core.$ZodObject && isAnyCoValueSchema(schema)) {
|
4039
3823
|
return true;
|
4040
3824
|
} else if (schema instanceof z.core.$ZodUnion) {
|
4041
3825
|
return schema._zod.def.options.every(isCoMapOrUnionOfCoMapsDeeply);
|
@@ -4047,14 +3831,21 @@ function isUnionOfPrimitivesDeeply(schema) {
|
|
4047
3831
|
if (schema instanceof z.core.$ZodUnion) {
|
4048
3832
|
return schema._zod.def.options.every(isUnionOfPrimitivesDeeply);
|
4049
3833
|
} else {
|
4050
|
-
return !(
|
3834
|
+
return !isAnyCoValueSchema(schema);
|
4051
3835
|
}
|
4052
3836
|
}
|
4053
3837
|
|
4054
3838
|
// src/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts
|
4055
|
-
function
|
3839
|
+
function schemaFieldToCoFieldDef(schema) {
|
4056
3840
|
if (isCoValueClass(schema)) {
|
4057
3841
|
return coField.ref(schema);
|
3842
|
+
} else if (isCoValueSchema(schema)) {
|
3843
|
+
if (isAnyCoOptionalSchema(schema)) {
|
3844
|
+
return coField.ref(schema.getCoValueClass(), {
|
3845
|
+
optional: true
|
3846
|
+
});
|
3847
|
+
}
|
3848
|
+
return coField.ref(schema.getCoValueClass());
|
4058
3849
|
} else {
|
4059
3850
|
if ("_zod" in schema) {
|
4060
3851
|
if (schema._zod.def.type === "optional") {
|
@@ -4064,7 +3855,7 @@ function zodFieldToCoFieldDef(schema) {
|
|
4064
3855
|
if (isCoValueClass(inner)) {
|
4065
3856
|
return coField.ref(inner, { optional: true });
|
4066
3857
|
} else {
|
4067
|
-
return
|
3858
|
+
return schemaFieldToCoFieldDef(inner);
|
4068
3859
|
}
|
4069
3860
|
} else if (schema._zod.def.type === "string") {
|
4070
3861
|
return coField.string;
|
@@ -4077,7 +3868,7 @@ function zodFieldToCoFieldDef(schema) {
|
|
4077
3868
|
} else if (schema._zod.def.type === "enum") {
|
4078
3869
|
return coField.string;
|
4079
3870
|
} else if (schema._zod.def.type === "readonly") {
|
4080
|
-
return
|
3871
|
+
return schemaFieldToCoFieldDef(
|
4081
3872
|
schema.def.innerType
|
4082
3873
|
);
|
4083
3874
|
} else if (schema._zod.def.type === "date") {
|
@@ -4085,14 +3876,14 @@ function zodFieldToCoFieldDef(schema) {
|
|
4085
3876
|
} else if (schema._zod.def.type === "template_literal") {
|
4086
3877
|
return coField.string;
|
4087
3878
|
} else if (schema._zod.def.type === "lazy") {
|
4088
|
-
return
|
3879
|
+
return schemaFieldToCoFieldDef(
|
4089
3880
|
schema.unwrap()
|
4090
3881
|
);
|
4091
3882
|
} else if (schema._zod.def.type === "default" || schema._zod.def.type === "catch") {
|
4092
3883
|
console.warn(
|
4093
3884
|
"z.default()/z.catch() are not supported in collaborative schemas. They will be ignored."
|
4094
3885
|
);
|
4095
|
-
return
|
3886
|
+
return schemaFieldToCoFieldDef(
|
4096
3887
|
schema.def.innerType
|
4097
3888
|
);
|
4098
3889
|
} else if (schema._zod.def.type === "literal") {
|
@@ -4114,7 +3905,7 @@ function zodFieldToCoFieldDef(schema) {
|
|
4114
3905
|
return coField.json();
|
4115
3906
|
} else if (schema._zod.def.type === "custom") {
|
4116
3907
|
if ("builtin" in schema) {
|
4117
|
-
return
|
3908
|
+
return schemaFieldToCoFieldDef(schema.builtin);
|
4118
3909
|
} else {
|
4119
3910
|
throw new Error(`Unsupported custom zod type`);
|
4120
3911
|
}
|
@@ -4143,61 +3934,81 @@ function zodFieldToCoFieldDef(schema) {
|
|
4143
3934
|
|
4144
3935
|
// src/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts
|
4145
3936
|
var coSchemasForZodSchemas = /* @__PURE__ */ new Map();
|
3937
|
+
function isAnyCoValueSchema(schema) {
|
3938
|
+
return "collaborative" in schema && schema.collaborative === true;
|
3939
|
+
}
|
3940
|
+
function isCoValueSchema(schema) {
|
3941
|
+
return isAnyCoValueSchema(schema) && "getCoValueClass" in schema;
|
3942
|
+
}
|
4146
3943
|
function tryZodSchemaToCoSchema(schema) {
|
4147
|
-
if (
|
3944
|
+
if (isAnyCoValueSchema(schema)) {
|
4148
3945
|
if (coSchemasForZodSchemas.has(schema)) {
|
4149
|
-
return coSchemasForZodSchemas.get(
|
3946
|
+
return coSchemasForZodSchemas.get(
|
3947
|
+
schema
|
3948
|
+
);
|
4150
3949
|
}
|
4151
|
-
if (
|
3950
|
+
if (isAnyCoOptionalSchema(schema)) {
|
3951
|
+
return null;
|
3952
|
+
} else if (isZodObject(schema)) {
|
4152
3953
|
const def = getDef(schema);
|
4153
3954
|
const ClassToExtend = "builtin" in schema && schema.builtin === "Account" ? Account : CoMap;
|
4154
|
-
const
|
3955
|
+
const coValueClass = class ZCoMap extends ClassToExtend {
|
4155
3956
|
constructor(options) {
|
4156
3957
|
super(options);
|
4157
3958
|
for (const [field, fieldType] of Object.entries(
|
4158
3959
|
def.shape
|
4159
3960
|
)) {
|
4160
|
-
this[field] =
|
3961
|
+
this[field] = schemaFieldToCoFieldDef(
|
4161
3962
|
zodSchemaToCoSchemaOrKeepPrimitive(fieldType)
|
4162
3963
|
);
|
4163
3964
|
}
|
4164
3965
|
if (def.catchall) {
|
4165
|
-
this[coField.items] =
|
3966
|
+
this[coField.items] = schemaFieldToCoFieldDef(
|
4166
3967
|
zodSchemaToCoSchemaOrKeepPrimitive(def.catchall)
|
4167
3968
|
);
|
4168
3969
|
}
|
4169
3970
|
}
|
4170
3971
|
};
|
4171
|
-
|
4172
|
-
|
3972
|
+
const coValueSchema = ClassToExtend === Account ? enrichAccountSchema(schema, coValueClass) : enrichCoMapSchema(schema, coValueClass);
|
3973
|
+
coSchemasForZodSchemas.set(schema, coValueSchema);
|
3974
|
+
return coValueSchema;
|
4173
3975
|
} else if (isZodArray(schema)) {
|
4174
3976
|
const def = getDef(schema);
|
4175
|
-
const
|
3977
|
+
const coValueClass = class ZCoList extends CoList {
|
4176
3978
|
constructor(options) {
|
4177
3979
|
super(options);
|
4178
|
-
this[coField.items] =
|
3980
|
+
this[coField.items] = schemaFieldToCoFieldDef(
|
4179
3981
|
zodSchemaToCoSchemaOrKeepPrimitive(def.element)
|
4180
3982
|
);
|
4181
3983
|
}
|
4182
3984
|
};
|
4183
|
-
|
4184
|
-
|
3985
|
+
const coValueSchema = enrichCoListSchema(schema, coValueClass);
|
3986
|
+
coSchemasForZodSchemas.set(schema, coValueSchema);
|
3987
|
+
return coValueSchema;
|
4185
3988
|
} else if (isZodCustom(schema)) {
|
4186
3989
|
if ("builtin" in schema) {
|
4187
3990
|
if (schema.builtin === "CoFeed" && "element" in schema) {
|
4188
|
-
|
4189
|
-
|
3991
|
+
const coValueClass = CoFeed.Of(
|
3992
|
+
schemaFieldToCoFieldDef(
|
4190
3993
|
zodSchemaToCoSchemaOrKeepPrimitive(
|
4191
3994
|
schema.element
|
4192
3995
|
)
|
4193
3996
|
)
|
4194
3997
|
);
|
3998
|
+
const coValueSchema = enrichCoFeedSchema(schema, coValueClass);
|
3999
|
+
return coValueSchema;
|
4195
4000
|
} else if (schema.builtin === "FileStream") {
|
4196
|
-
|
4001
|
+
const coValueClass = FileStream;
|
4002
|
+
const coValueSchema = enrichFileStreamSchema(schema, coValueClass);
|
4003
|
+
return coValueSchema;
|
4197
4004
|
} else if (schema.builtin === "CoPlainText") {
|
4198
|
-
|
4005
|
+
const coValueClass = CoPlainText;
|
4006
|
+
const coValueSchema = enrichPlainTextSchema(schema, coValueClass);
|
4007
|
+
return coValueSchema;
|
4199
4008
|
} else if (schema.builtin === "CoRichText") {
|
4200
|
-
|
4009
|
+
const coValueClass = CoRichText;
|
4010
|
+
const coValueSchema = enrichRichTextSchema(schema, coValueClass);
|
4011
|
+
return coValueSchema;
|
4201
4012
|
} else {
|
4202
4013
|
throw new Error(`Unsupported builtin type: ${schema.builtin}`);
|
4203
4014
|
}
|
@@ -4211,9 +4022,12 @@ function tryZodSchemaToCoSchema(schema) {
|
|
4211
4022
|
}
|
4212
4023
|
} else if (schema instanceof z.core.$ZodDiscriminatedUnion) {
|
4213
4024
|
if (isUnionOfCoMapsDeeply(schema)) {
|
4214
|
-
|
4215
|
-
|
4025
|
+
const coValueClass = SchemaUnion.Of(schemaUnionDiscriminatorFor(schema));
|
4026
|
+
const coValueSchema = enrichCoDiscriminatedUnionSchema(
|
4027
|
+
schema,
|
4028
|
+
coValueClass
|
4216
4029
|
);
|
4030
|
+
return coValueSchema;
|
4217
4031
|
} else {
|
4218
4032
|
throw new Error(
|
4219
4033
|
"z.discriminatedUnion() of non-collaborative types is not supported as a top-level schema"
|
@@ -4223,7 +4037,7 @@ function tryZodSchemaToCoSchema(schema) {
|
|
4223
4037
|
return null;
|
4224
4038
|
}
|
4225
4039
|
}
|
4226
|
-
function
|
4040
|
+
function zodSchemaToCoSchema(schema) {
|
4227
4041
|
const coSchema = tryZodSchemaToCoSchema(schema);
|
4228
4042
|
if (!coSchema) {
|
4229
4043
|
throw new Error(
|
@@ -4235,16 +4049,18 @@ function zodSchemaToCoSchema2(schema) {
|
|
4235
4049
|
function anySchemaToCoSchema(schema) {
|
4236
4050
|
if (isCoValueClass(schema)) {
|
4237
4051
|
return schema;
|
4238
|
-
} else if (
|
4239
|
-
return schema.
|
4052
|
+
} else if (isCoValueSchema(schema)) {
|
4053
|
+
return schema.getCoValueClass();
|
4240
4054
|
} else if ("def" in schema) {
|
4241
|
-
const coSchema = tryZodSchemaToCoSchema(
|
4055
|
+
const coSchema = tryZodSchemaToCoSchema(
|
4056
|
+
schema
|
4057
|
+
);
|
4242
4058
|
if (!coSchema) {
|
4243
4059
|
throw new Error(
|
4244
4060
|
`Unsupported zod type: ${schema.def?.type || JSON.stringify(schema)}`
|
4245
4061
|
);
|
4246
4062
|
}
|
4247
|
-
return coSchema;
|
4063
|
+
return coSchema.getCoValueClass();
|
4248
4064
|
}
|
4249
4065
|
throw new Error(`Unsupported schema: ${JSON.stringify(schema)}`);
|
4250
4066
|
}
|
@@ -4256,6 +4072,309 @@ function zodSchemaToCoSchemaOrKeepPrimitive(schema) {
|
|
4256
4072
|
return coSchema;
|
4257
4073
|
}
|
4258
4074
|
|
4075
|
+
// src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts
|
4076
|
+
function createCoOptionalSchema(schema) {
|
4077
|
+
return Object.assign(z.optional(schema), {
|
4078
|
+
collaborative: true,
|
4079
|
+
getCoValueClass: () => {
|
4080
|
+
return schema.getCoValueClass();
|
4081
|
+
}
|
4082
|
+
});
|
4083
|
+
}
|
4084
|
+
function isAnyCoOptionalSchema(schema) {
|
4085
|
+
return isAnyCoValueSchema(schema) && schema._zod.def.type === "optional";
|
4086
|
+
}
|
4087
|
+
|
4088
|
+
// src/tools/implementation/zodSchema/zodCo.ts
|
4089
|
+
var coMapDefiner = (shape) => {
|
4090
|
+
const objectSchema = z.object(shape).meta({
|
4091
|
+
collaborative: true
|
4092
|
+
});
|
4093
|
+
const enrichedSchema = Object.assign(objectSchema, {
|
4094
|
+
collaborative: true
|
4095
|
+
});
|
4096
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4097
|
+
};
|
4098
|
+
var coAccountDefiner = (shape = {
|
4099
|
+
profile: coMapDefiner({
|
4100
|
+
name: z.string(),
|
4101
|
+
inbox: z.optional(z.string()),
|
4102
|
+
inboxInvite: z.optional(z.string())
|
4103
|
+
}),
|
4104
|
+
root: coMapDefiner({})
|
4105
|
+
}) => {
|
4106
|
+
const schema = z.object(shape).meta({
|
4107
|
+
collaborative: true
|
4108
|
+
});
|
4109
|
+
const enrichedSchema = Object.assign(schema, {
|
4110
|
+
collaborative: true,
|
4111
|
+
builtin: "Account"
|
4112
|
+
});
|
4113
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4114
|
+
};
|
4115
|
+
var coRecordDefiner = (_keyType, valueType) => {
|
4116
|
+
return coMapDefiner({}).catchall(valueType);
|
4117
|
+
};
|
4118
|
+
var coListDefiner = (element) => {
|
4119
|
+
const schema = z.array(element).meta({
|
4120
|
+
collaborative: true
|
4121
|
+
});
|
4122
|
+
const enrichedSchema = Object.assign(schema, {
|
4123
|
+
collaborative: true
|
4124
|
+
});
|
4125
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4126
|
+
};
|
4127
|
+
var coProfileDefiner = (shape = {}) => {
|
4128
|
+
const ehnancedShape = Object.assign(shape, {
|
4129
|
+
name: z.string(),
|
4130
|
+
inbox: z.optional(z.string()),
|
4131
|
+
inboxInvite: z.optional(z.string())
|
4132
|
+
});
|
4133
|
+
return coMapDefiner(ehnancedShape);
|
4134
|
+
};
|
4135
|
+
var coFeedDefiner = (element) => {
|
4136
|
+
const schema = z.instanceof(CoFeed);
|
4137
|
+
const enrichedSchema = Object.assign(schema, {
|
4138
|
+
collaborative: true,
|
4139
|
+
builtin: "CoFeed",
|
4140
|
+
element
|
4141
|
+
});
|
4142
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4143
|
+
};
|
4144
|
+
var coFileStreamDefiner = () => {
|
4145
|
+
const schema = z.instanceof(FileStream);
|
4146
|
+
const enrichedSchema = Object.assign(schema, {
|
4147
|
+
collaborative: true,
|
4148
|
+
builtin: "FileStream"
|
4149
|
+
});
|
4150
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4151
|
+
};
|
4152
|
+
var coPlainTextDefiner = () => {
|
4153
|
+
const schema = z.instanceof(CoPlainText);
|
4154
|
+
const enrichedSchema = Object.assign(schema, {
|
4155
|
+
collaborative: true,
|
4156
|
+
builtin: "CoPlainText"
|
4157
|
+
});
|
4158
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4159
|
+
};
|
4160
|
+
var coRichTextDefiner = () => {
|
4161
|
+
const schema = z.instanceof(CoRichText);
|
4162
|
+
const enrichedSchema = Object.assign(schema, {
|
4163
|
+
collaborative: true,
|
4164
|
+
builtin: "CoRichText"
|
4165
|
+
});
|
4166
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4167
|
+
};
|
4168
|
+
var coImageDefiner = () => {
|
4169
|
+
return ImageDefinition;
|
4170
|
+
};
|
4171
|
+
var coOptionalDefiner = (schema) => {
|
4172
|
+
return createCoOptionalSchema(schema);
|
4173
|
+
};
|
4174
|
+
var coDiscriminatedUnionDefiner = (discriminator, schemas) => {
|
4175
|
+
const schema = z.discriminatedUnion(discriminator, schemas);
|
4176
|
+
return zodSchemaToCoSchema(schema);
|
4177
|
+
};
|
4178
|
+
|
4179
|
+
// src/tools/implementation/zodSchema/coExport.ts
|
4180
|
+
var coExport_exports = {};
|
4181
|
+
__export(coExport_exports, {
|
4182
|
+
account: () => coAccountDefiner,
|
4183
|
+
discriminatedUnion: () => coDiscriminatedUnionDefiner,
|
4184
|
+
feed: () => coFeedDefiner,
|
4185
|
+
fileStream: () => coFileStreamDefiner,
|
4186
|
+
image: () => coImageDefiner,
|
4187
|
+
list: () => coListDefiner,
|
4188
|
+
map: () => coMapDefiner,
|
4189
|
+
optional: () => coOptionalDefiner,
|
4190
|
+
plainText: () => coPlainTextDefiner,
|
4191
|
+
profile: () => coProfileDefiner,
|
4192
|
+
record: () => coRecordDefiner,
|
4193
|
+
richText: () => coRichTextDefiner
|
4194
|
+
});
|
4195
|
+
|
4196
|
+
// src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts
|
4197
|
+
function enrichCoMapSchema(schema, coValueClass) {
|
4198
|
+
const baseCatchall = schema.catchall;
|
4199
|
+
const coValueSchema = Object.assign(schema, {
|
4200
|
+
create: (...args) => {
|
4201
|
+
return coValueClass.create(...args);
|
4202
|
+
},
|
4203
|
+
load: (...args) => {
|
4204
|
+
return coValueClass.load(...args);
|
4205
|
+
},
|
4206
|
+
subscribe: (...args) => {
|
4207
|
+
return coValueClass.subscribe(...args);
|
4208
|
+
},
|
4209
|
+
findUnique: (...args) => {
|
4210
|
+
return coValueClass.findUnique(...args);
|
4211
|
+
},
|
4212
|
+
upsertUnique: (...args) => {
|
4213
|
+
return coValueClass.upsertUnique(...args);
|
4214
|
+
},
|
4215
|
+
loadUnique: (...args) => {
|
4216
|
+
return coValueClass.loadUnique(...args);
|
4217
|
+
},
|
4218
|
+
catchall: (index) => {
|
4219
|
+
const newSchema = baseCatchall(index);
|
4220
|
+
const enrichedSchema = Object.assign(newSchema, {
|
4221
|
+
collaborative: true
|
4222
|
+
});
|
4223
|
+
return zodSchemaToCoSchema(enrichedSchema);
|
4224
|
+
},
|
4225
|
+
withHelpers: (helpers) => {
|
4226
|
+
return Object.assign(schema, helpers(schema));
|
4227
|
+
},
|
4228
|
+
withMigration: (migration) => {
|
4229
|
+
coValueClass.prototype.migrate = migration;
|
4230
|
+
return coValueSchema;
|
4231
|
+
},
|
4232
|
+
getCoValueClass: () => {
|
4233
|
+
return coValueClass;
|
4234
|
+
}
|
4235
|
+
});
|
4236
|
+
return coValueSchema;
|
4237
|
+
}
|
4238
|
+
|
4239
|
+
// src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts
|
4240
|
+
function enrichCoDiscriminatedUnionSchema(schema, coValueClass) {
|
4241
|
+
return Object.assign(schema, {
|
4242
|
+
load: (...args) => {
|
4243
|
+
return coValueClass.load(...args);
|
4244
|
+
},
|
4245
|
+
subscribe: (...args) => {
|
4246
|
+
return coValueClass.subscribe(...args);
|
4247
|
+
},
|
4248
|
+
getCoValueClass: () => {
|
4249
|
+
return coValueClass;
|
4250
|
+
}
|
4251
|
+
});
|
4252
|
+
}
|
4253
|
+
|
4254
|
+
// src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts
|
4255
|
+
function enrichCoListSchema(schema, coValueClass) {
|
4256
|
+
return Object.assign(schema, {
|
4257
|
+
create: (...args) => {
|
4258
|
+
return coValueClass.create(...args);
|
4259
|
+
},
|
4260
|
+
load: (...args) => {
|
4261
|
+
return coValueClass.load(...args);
|
4262
|
+
},
|
4263
|
+
subscribe: (...args) => {
|
4264
|
+
return coValueClass.subscribe(...args);
|
4265
|
+
},
|
4266
|
+
withHelpers: (helpers) => {
|
4267
|
+
return Object.assign(schema, helpers(schema));
|
4268
|
+
},
|
4269
|
+
getCoValueClass: () => {
|
4270
|
+
return coValueClass;
|
4271
|
+
}
|
4272
|
+
});
|
4273
|
+
}
|
4274
|
+
|
4275
|
+
// src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts
|
4276
|
+
function enrichCoFeedSchema(schema, coValueClass) {
|
4277
|
+
return Object.assign(schema, {
|
4278
|
+
create: (...args) => {
|
4279
|
+
return coValueClass.create(...args);
|
4280
|
+
},
|
4281
|
+
load: (...args) => {
|
4282
|
+
return coValueClass.load(...args);
|
4283
|
+
},
|
4284
|
+
subscribe: (...args) => {
|
4285
|
+
return coValueClass.subscribe(...args);
|
4286
|
+
},
|
4287
|
+
withHelpers: (helpers) => {
|
4288
|
+
return Object.assign(schema, helpers(schema));
|
4289
|
+
},
|
4290
|
+
getCoValueClass: () => {
|
4291
|
+
return coValueClass;
|
4292
|
+
}
|
4293
|
+
});
|
4294
|
+
}
|
4295
|
+
|
4296
|
+
// src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts
|
4297
|
+
function enrichAccountSchema(schema, coValueClass) {
|
4298
|
+
const enrichedSchema = Object.assign(schema, {
|
4299
|
+
create: (...args) => {
|
4300
|
+
return coValueClass.create(...args);
|
4301
|
+
},
|
4302
|
+
createAs: (...args) => {
|
4303
|
+
return coValueClass.createAs(...args);
|
4304
|
+
},
|
4305
|
+
getMe: (...args) => {
|
4306
|
+
return coValueClass.getMe(...args);
|
4307
|
+
},
|
4308
|
+
load: (...args) => {
|
4309
|
+
return coValueClass.load(...args);
|
4310
|
+
},
|
4311
|
+
subscribe: (...args) => {
|
4312
|
+
return coValueClass.subscribe(...args);
|
4313
|
+
},
|
4314
|
+
withHelpers: (helpers) => {
|
4315
|
+
return Object.assign(schema, helpers(schema));
|
4316
|
+
},
|
4317
|
+
fromRaw: (...args) => {
|
4318
|
+
return coValueClass.fromRaw(...args);
|
4319
|
+
},
|
4320
|
+
withMigration: (migration) => {
|
4321
|
+
coValueClass.prototype.migrate = async function(creationProps) {
|
4322
|
+
await migration(this, creationProps);
|
4323
|
+
};
|
4324
|
+
return enrichedSchema;
|
4325
|
+
},
|
4326
|
+
getCoValueClass: () => {
|
4327
|
+
return coValueClass;
|
4328
|
+
}
|
4329
|
+
});
|
4330
|
+
return enrichedSchema;
|
4331
|
+
}
|
4332
|
+
|
4333
|
+
// src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts
|
4334
|
+
function enrichFileStreamSchema(schema, coValueClass) {
|
4335
|
+
return Object.assign(schema, {
|
4336
|
+
create: (...args) => {
|
4337
|
+
return coValueClass.create(...args);
|
4338
|
+
},
|
4339
|
+
createFromBlob: (...args) => {
|
4340
|
+
return coValueClass.createFromBlob(...args);
|
4341
|
+
},
|
4342
|
+
load: (...args) => {
|
4343
|
+
return coValueClass.load(...args);
|
4344
|
+
},
|
4345
|
+
loadAsBlob: (...args) => {
|
4346
|
+
return coValueClass.loadAsBlob(...args);
|
4347
|
+
},
|
4348
|
+
subscribe: (...args) => {
|
4349
|
+
return coValueClass.subscribe(...args);
|
4350
|
+
},
|
4351
|
+
getCoValueClass: () => {
|
4352
|
+
return coValueClass;
|
4353
|
+
}
|
4354
|
+
});
|
4355
|
+
}
|
4356
|
+
|
4357
|
+
// src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts
|
4358
|
+
function enrichPlainTextSchema(schema, coValueClass) {
|
4359
|
+
return Object.assign(schema, {
|
4360
|
+
create: (...args) => {
|
4361
|
+
return coValueClass.create(...args);
|
4362
|
+
},
|
4363
|
+
load: (...args) => {
|
4364
|
+
return coValueClass.load(...args);
|
4365
|
+
},
|
4366
|
+
subscribe: (...args) => {
|
4367
|
+
return coValueClass.subscribe(...args);
|
4368
|
+
},
|
4369
|
+
fromRaw: (...args) => {
|
4370
|
+
return coValueClass.fromRaw(...args);
|
4371
|
+
},
|
4372
|
+
getCoValueClass: () => {
|
4373
|
+
return coValueClass;
|
4374
|
+
}
|
4375
|
+
});
|
4376
|
+
}
|
4377
|
+
|
4259
4378
|
// src/tools/coValues/extensions/imageDef.ts
|
4260
4379
|
var ImageDefinitionBase = coMapDefiner({
|
4261
4380
|
originalSize: z.tuple([z.number(), z.number()]),
|
@@ -4921,9 +5040,9 @@ function isAccountInstance(instance) {
|
|
4921
5040
|
return "_type" in instance && instance._type === "Account";
|
4922
5041
|
}
|
4923
5042
|
function parseCoValueCreateOptions(options) {
|
4924
|
-
const
|
5043
|
+
const Group4 = RegisteredSchemas["Group"];
|
4925
5044
|
if (!options) {
|
4926
|
-
return { owner:
|
5045
|
+
return { owner: Group4.create(), uniqueness: void 0 };
|
4927
5046
|
}
|
4928
5047
|
if ("_type" in options) {
|
4929
5048
|
if (options._type === "Account" || options._type === "Group") {
|
@@ -4932,7 +5051,7 @@ function parseCoValueCreateOptions(options) {
|
|
4932
5051
|
}
|
4933
5052
|
const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
|
4934
5053
|
return {
|
4935
|
-
owner: options.owner ??
|
5054
|
+
owner: options.owner ?? Group4.create(),
|
4936
5055
|
uniqueness
|
4937
5056
|
};
|
4938
5057
|
}
|
@@ -4972,9 +5091,9 @@ export {
|
|
4972
5091
|
createJazzContextForNewAccount,
|
4973
5092
|
createJazzContext,
|
4974
5093
|
createAnonymousJazzContext,
|
4975
|
-
|
4976
|
-
zodSchemaToCoSchema2 as zodSchemaToCoSchema,
|
5094
|
+
zodSchemaToCoSchema,
|
4977
5095
|
anySchemaToCoSchema,
|
5096
|
+
coExport_exports,
|
4978
5097
|
ImageDefinition,
|
4979
5098
|
KvStoreContext,
|
4980
5099
|
AuthSecretStorage,
|
@@ -4982,4 +5101,4 @@ export {
|
|
4982
5101
|
JazzContextManager
|
4983
5102
|
};
|
4984
5103
|
/* istanbul ignore file -- @preserve */
|
4985
|
-
//# sourceMappingURL=chunk-
|
5104
|
+
//# sourceMappingURL=chunk-MLLG3GBR.js.map
|