jazz-tools 0.14.19 → 0.14.20
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 +5 -5
- package/CHANGELOG.md +8 -0
- package/dist/{chunk-AA3SCYKI.js → chunk-SJKS4244.js} +202 -122
- package/dist/chunk-SJKS4244.js.map +1 -0
- package/dist/coValues/CoValueBase.d.ts +14 -3
- package/dist/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/coValues/coMap.d.ts +11 -1
- package/dist/coValues/coMap.d.ts.map +1 -1
- package/dist/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -1
- package/dist/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +1 -0
- package/dist/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +1 -0
- package/dist/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +2 -0
- 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 -0
- package/dist/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +1 -0
- package/dist/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +1 -0
- package/dist/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/implementation/zodSchema/zodCo.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 +1 -1
- package/dist/lib/migration.d.ts +3 -0
- package/dist/lib/migration.d.ts.map +1 -0
- package/dist/subscribe/SubscriptionScope.d.ts +2 -0
- package/dist/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/CoValueBase.ts +31 -7
- package/src/coValues/coMap.ts +0 -1
- package/src/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +4 -15
- package/src/implementation/zodSchema/schemaTypes/AccountSchema.ts +3 -1
- package/src/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +2 -0
- package/src/implementation/zodSchema/schemaTypes/CoListSchema.ts +2 -0
- package/src/implementation/zodSchema/schemaTypes/CoMapSchema.ts +11 -0
- package/src/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +2 -1
- package/src/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +1 -0
- package/src/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +1 -0
- package/src/implementation/zodSchema/schemaTypes/RichTextSchema.ts +1 -0
- package/src/implementation/zodSchema/zodCo.ts +214 -246
- package/src/implementation/zodSchema/zodSchema.ts +1 -1
- package/src/lib/migration.ts +23 -0
- package/src/subscribe/SubscriptionScope.ts +26 -0
- package/src/tests/coMap.test.ts +215 -1
- package/dist/chunk-AA3SCYKI.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.20 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"}
|
@@ -11,12 +11,12 @@
|
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.js [22m[32m11.11 KB[39m
|
13
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.31 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
14
|
+
[32mESM[39m [1mdist/chunk-SJKS4244.js [22m[32m134.94 KB[39m
|
15
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-SJKS4244.js.map [22m[32m309.25 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 48ms
|
19
19
|
|
20
|
-
> jazz-tools@0.14.
|
20
|
+
> jazz-tools@0.14.20 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
21
21
|
> tsc --outDir dist
|
22
22
|
|
package/CHANGELOG.md
CHANGED
@@ -123,7 +123,8 @@ var CoValueBase = class {
|
|
123
123
|
return this.toJSON();
|
124
124
|
}
|
125
125
|
/** @category Type Helpers */
|
126
|
-
castAs(
|
126
|
+
castAs(schema) {
|
127
|
+
const cl = "getCoSchema" in schema ? schema.getCoSchema() : schema;
|
127
128
|
if (this.constructor === cl) {
|
128
129
|
return this;
|
129
130
|
}
|
@@ -2710,6 +2711,19 @@ function instantiateRefEncoded(schema, raw) {
|
|
2710
2711
|
).fromRaw(raw);
|
2711
2712
|
}
|
2712
2713
|
|
2714
|
+
// src/lib/migration.ts
|
2715
|
+
function applyCoValueMigrations(instance) {
|
2716
|
+
const node = instance._raw.core.node;
|
2717
|
+
const migratedCoValues = node._migratedCoValues ??= /* @__PURE__ */ new Set();
|
2718
|
+
if ("migrate" in instance && typeof instance.migrate === "function" && instance._type !== "Account" && !migratedCoValues.has(instance.id)) {
|
2719
|
+
migratedCoValues.add(instance.id);
|
2720
|
+
const result = instance.migrate?.(instance);
|
2721
|
+
if (result && "then" in result) {
|
2722
|
+
throw new Error("Migration function cannot be async");
|
2723
|
+
}
|
2724
|
+
}
|
2725
|
+
}
|
2726
|
+
|
2713
2727
|
// src/subscribe/CoValueCoreSubscription.ts
|
2714
2728
|
var CoValueCoreSubscription = class {
|
2715
2729
|
constructor(node, id, listener) {
|
@@ -2838,6 +2852,8 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
2838
2852
|
this.autoloadedKeys = /* @__PURE__ */ new Set();
|
2839
2853
|
this.skipInvalidKeys = /* @__PURE__ */ new Set();
|
2840
2854
|
this.totalValidTransactions = 0;
|
2855
|
+
this.migrated = false;
|
2856
|
+
this.migrating = false;
|
2841
2857
|
this.silenceUpdates = false;
|
2842
2858
|
this.handleChildUpdate = (id, value, key) => {
|
2843
2859
|
if (value.type === "unloaded") {
|
@@ -2863,7 +2879,19 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
2863
2879
|
this.subscribers = /* @__PURE__ */ new Set();
|
2864
2880
|
this.resolve = resolve;
|
2865
2881
|
this.value = { type: "unloaded", id };
|
2882
|
+
let lastUpdate;
|
2866
2883
|
this.subscription = new CoValueCoreSubscription(node, id, (value) => {
|
2884
|
+
lastUpdate = value;
|
2885
|
+
if (!this.migrated && value !== "unavailable") {
|
2886
|
+
if (this.migrating) {
|
2887
|
+
return;
|
2888
|
+
}
|
2889
|
+
this.migrating = true;
|
2890
|
+
applyCoValueMigrations(instantiateRefEncoded(this.schema, value));
|
2891
|
+
this.migrated = true;
|
2892
|
+
this.handleUpdate(lastUpdate);
|
2893
|
+
return;
|
2894
|
+
}
|
2867
2895
|
this.handleUpdate(value);
|
2868
2896
|
});
|
2869
2897
|
}
|
@@ -3467,6 +3495,13 @@ function enrichCoMapSchema(schema) {
|
|
3467
3495
|
},
|
3468
3496
|
withHelpers: (helpers) => {
|
3469
3497
|
return Object.assign(schema, helpers(schema));
|
3498
|
+
},
|
3499
|
+
withMigration: (migration) => {
|
3500
|
+
coSchema.prototype.migrate = migration;
|
3501
|
+
return enrichedSchema;
|
3502
|
+
},
|
3503
|
+
getCoSchema: () => {
|
3504
|
+
return coSchema;
|
3470
3505
|
}
|
3471
3506
|
});
|
3472
3507
|
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
@@ -3478,6 +3513,44 @@ var coMapDefiner = (shape) => {
|
|
3478
3513
|
});
|
3479
3514
|
return enrichCoMapSchema(objectSchema);
|
3480
3515
|
};
|
3516
|
+
function enrichAccountSchema(schema) {
|
3517
|
+
const enrichedSchema = Object.assign(schema, {
|
3518
|
+
collaborative: true,
|
3519
|
+
builtin: "Account",
|
3520
|
+
create: (...args) => {
|
3521
|
+
return coSchema.create(...args);
|
3522
|
+
},
|
3523
|
+
createAs: (...args) => {
|
3524
|
+
return coSchema.createAs(...args);
|
3525
|
+
},
|
3526
|
+
getMe: (...args) => {
|
3527
|
+
return coSchema.getMe(...args);
|
3528
|
+
},
|
3529
|
+
load: (...args) => {
|
3530
|
+
return coSchema.load(...args);
|
3531
|
+
},
|
3532
|
+
subscribe: (...args) => {
|
3533
|
+
return coSchema.subscribe(...args);
|
3534
|
+
},
|
3535
|
+
withHelpers: (helpers) => {
|
3536
|
+
return Object.assign(schema, helpers(schema));
|
3537
|
+
},
|
3538
|
+
fromRaw: (...args) => {
|
3539
|
+
return coSchema.fromRaw(...args);
|
3540
|
+
},
|
3541
|
+
withMigration: (migration) => {
|
3542
|
+
coSchema.prototype.migrate = async function(creationProps) {
|
3543
|
+
await migration(this, creationProps);
|
3544
|
+
};
|
3545
|
+
return enrichedSchema;
|
3546
|
+
},
|
3547
|
+
getCoSchema: () => {
|
3548
|
+
return coSchema;
|
3549
|
+
}
|
3550
|
+
});
|
3551
|
+
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3552
|
+
return enrichedSchema;
|
3553
|
+
}
|
3481
3554
|
var coAccountDefiner = (shape = {
|
3482
3555
|
profile: coMapDefiner({
|
3483
3556
|
name: z.string(),
|
@@ -3489,54 +3562,38 @@ var coAccountDefiner = (shape = {
|
|
3489
3562
|
const objectSchema = z.object(shape).meta({
|
3490
3563
|
collaborative: true
|
3491
3564
|
});
|
3492
|
-
|
3493
|
-
accountSchema.collaborative = true;
|
3494
|
-
accountSchema.builtin = "Account";
|
3495
|
-
accountSchema.create = function(...args) {
|
3496
|
-
return zodSchemaToCoSchema2(this).create(...args);
|
3497
|
-
};
|
3498
|
-
accountSchema.createAs = function(...args) {
|
3499
|
-
return zodSchemaToCoSchema2(this).createAs(...args);
|
3500
|
-
};
|
3501
|
-
accountSchema.getMe = function() {
|
3502
|
-
return zodSchemaToCoSchema2(this).getMe();
|
3503
|
-
};
|
3504
|
-
accountSchema.load = function(...args) {
|
3505
|
-
return zodSchemaToCoSchema2(this).load(...args);
|
3506
|
-
};
|
3507
|
-
accountSchema.subscribe = function(...args) {
|
3508
|
-
return zodSchemaToCoSchema2(this).subscribe(...args);
|
3509
|
-
};
|
3510
|
-
accountSchema.withHelpers = function(helpers) {
|
3511
|
-
return { ...this, ...helpers };
|
3512
|
-
};
|
3513
|
-
accountSchema.withMigration = function(migration) {
|
3514
|
-
return Object.assign(this, { migration });
|
3515
|
-
};
|
3516
|
-
return accountSchema;
|
3565
|
+
return enrichAccountSchema(objectSchema);
|
3517
3566
|
};
|
3518
3567
|
var coRecordDefiner = (_keyType, valueType) => {
|
3519
3568
|
return coMapDefiner({}).catchall(valueType);
|
3520
3569
|
};
|
3570
|
+
function enrichCoListSchema(schema) {
|
3571
|
+
const enrichedSchema = Object.assign(schema, {
|
3572
|
+
collaborative: true,
|
3573
|
+
create: (...args) => {
|
3574
|
+
return coSchema.create(...args);
|
3575
|
+
},
|
3576
|
+
load: (...args) => {
|
3577
|
+
return coSchema.load(...args);
|
3578
|
+
},
|
3579
|
+
subscribe: (...args) => {
|
3580
|
+
return coSchema.subscribe(...args);
|
3581
|
+
},
|
3582
|
+
withHelpers: (helpers) => {
|
3583
|
+
return Object.assign(schema, helpers(schema));
|
3584
|
+
},
|
3585
|
+
getCoSchema: () => {
|
3586
|
+
return coSchema;
|
3587
|
+
}
|
3588
|
+
});
|
3589
|
+
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3590
|
+
return enrichedSchema;
|
3591
|
+
}
|
3521
3592
|
var coListDefiner = (element) => {
|
3522
3593
|
const arraySchema = z.array(element).meta({
|
3523
3594
|
collaborative: true
|
3524
3595
|
});
|
3525
|
-
|
3526
|
-
coListSchema.collaborative = true;
|
3527
|
-
coListSchema.create = function(...args) {
|
3528
|
-
return zodSchemaToCoSchema2(this).create(...args);
|
3529
|
-
};
|
3530
|
-
coListSchema.load = function(...args) {
|
3531
|
-
return zodSchemaToCoSchema2(this).load(...args);
|
3532
|
-
};
|
3533
|
-
coListSchema.subscribe = function(...args) {
|
3534
|
-
return zodSchemaToCoSchema2(this).subscribe(...args);
|
3535
|
-
};
|
3536
|
-
coListSchema.withHelpers = function(helpers) {
|
3537
|
-
return Object.assign(this, helpers(this));
|
3538
|
-
};
|
3539
|
-
return coListSchema;
|
3596
|
+
return enrichCoListSchema(arraySchema);
|
3540
3597
|
};
|
3541
3598
|
var coProfileDefiner = (shape = {}) => {
|
3542
3599
|
const ehnancedShape = Object.assign(shape ?? {}, {
|
@@ -3546,79 +3603,110 @@ var coProfileDefiner = (shape = {}) => {
|
|
3546
3603
|
});
|
3547
3604
|
return coMapDefiner(ehnancedShape);
|
3548
3605
|
};
|
3606
|
+
function enrichCoFeedSchema(schema, element) {
|
3607
|
+
const enrichedSchema = Object.assign(schema, {
|
3608
|
+
collaborative: true,
|
3609
|
+
builtin: "CoFeed",
|
3610
|
+
element,
|
3611
|
+
create: (...args) => {
|
3612
|
+
return coSchema.create(...args);
|
3613
|
+
},
|
3614
|
+
load: (...args) => {
|
3615
|
+
return coSchema.load(...args);
|
3616
|
+
},
|
3617
|
+
subscribe: (...args) => {
|
3618
|
+
return coSchema.subscribe(...args);
|
3619
|
+
},
|
3620
|
+
withHelpers: (helpers) => {
|
3621
|
+
return Object.assign(schema, helpers(schema));
|
3622
|
+
},
|
3623
|
+
getCoSchema: () => {
|
3624
|
+
return coSchema;
|
3625
|
+
}
|
3626
|
+
});
|
3627
|
+
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3628
|
+
return enrichedSchema;
|
3629
|
+
}
|
3549
3630
|
var coFeedDefiner = (element) => {
|
3550
|
-
|
3551
|
-
const coFeedSchema = placeholderSchema;
|
3552
|
-
coFeedSchema.collaborative = true;
|
3553
|
-
coFeedSchema.builtin = "CoFeed";
|
3554
|
-
coFeedSchema.element = element;
|
3555
|
-
coFeedSchema.create = function(...args) {
|
3556
|
-
return zodSchemaToCoSchema2(this).create(...args);
|
3557
|
-
};
|
3558
|
-
coFeedSchema.load = function(...args) {
|
3559
|
-
return zodSchemaToCoSchema2(this).load(...args);
|
3560
|
-
};
|
3561
|
-
coFeedSchema.subscribe = function(...args) {
|
3562
|
-
return zodSchemaToCoSchema2(this).subscribe(...args);
|
3563
|
-
};
|
3564
|
-
return coFeedSchema;
|
3631
|
+
return enrichCoFeedSchema(z.instanceof(CoFeed), element);
|
3565
3632
|
};
|
3633
|
+
function enrichFileStreamSchema(schema) {
|
3634
|
+
const enrichedSchema = Object.assign(schema, {
|
3635
|
+
collaborative: true,
|
3636
|
+
builtin: "FileStream",
|
3637
|
+
create: (...args) => {
|
3638
|
+
return coSchema.create(...args);
|
3639
|
+
},
|
3640
|
+
createFromBlob: (...args) => {
|
3641
|
+
return coSchema.createFromBlob(...args);
|
3642
|
+
},
|
3643
|
+
load: (...args) => {
|
3644
|
+
return coSchema.load(...args);
|
3645
|
+
},
|
3646
|
+
loadAsBlob: (...args) => {
|
3647
|
+
return coSchema.loadAsBlob(...args);
|
3648
|
+
},
|
3649
|
+
subscribe: (...args) => {
|
3650
|
+
return coSchema.subscribe(...args);
|
3651
|
+
},
|
3652
|
+
getCoSchema: () => {
|
3653
|
+
return coSchema;
|
3654
|
+
}
|
3655
|
+
});
|
3656
|
+
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3657
|
+
return enrichedSchema;
|
3658
|
+
}
|
3566
3659
|
var coFileStreamDefiner = () => {
|
3567
|
-
|
3568
|
-
const fileStreamSchema = placeholderSchema;
|
3569
|
-
fileStreamSchema.collaborative = true;
|
3570
|
-
fileStreamSchema.builtin = "FileStream";
|
3571
|
-
fileStreamSchema.create = function(options) {
|
3572
|
-
return FileStream.create(options);
|
3573
|
-
};
|
3574
|
-
fileStreamSchema.createFromBlob = function(blob, options) {
|
3575
|
-
return FileStream.createFromBlob(blob, options);
|
3576
|
-
};
|
3577
|
-
fileStreamSchema.load = function(id, options) {
|
3578
|
-
return FileStream.load(id, options);
|
3579
|
-
};
|
3580
|
-
fileStreamSchema.loadAsBlob = function(id, options) {
|
3581
|
-
return FileStream.loadAsBlob(id, options);
|
3582
|
-
};
|
3583
|
-
fileStreamSchema.subscribe = function(id, options, listener) {
|
3584
|
-
return FileStream.subscribe(id, options, listener);
|
3585
|
-
};
|
3586
|
-
return fileStreamSchema;
|
3660
|
+
return enrichFileStreamSchema(z.instanceof(FileStream));
|
3587
3661
|
};
|
3662
|
+
function enrichPlainTextSchema(schema) {
|
3663
|
+
const enrichedSchema = Object.assign(schema, {
|
3664
|
+
collaborative: true,
|
3665
|
+
builtin: "CoPlainText",
|
3666
|
+
create: (...args) => {
|
3667
|
+
return coSchema.create(...args);
|
3668
|
+
},
|
3669
|
+
load: (...args) => {
|
3670
|
+
return coSchema.load(...args);
|
3671
|
+
},
|
3672
|
+
subscribe: (...args) => {
|
3673
|
+
return coSchema.subscribe(...args);
|
3674
|
+
},
|
3675
|
+
fromRaw: (...args) => {
|
3676
|
+
return coSchema.fromRaw(...args);
|
3677
|
+
},
|
3678
|
+
getCoSchema: () => {
|
3679
|
+
return coSchema;
|
3680
|
+
}
|
3681
|
+
});
|
3682
|
+
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3683
|
+
return enrichedSchema;
|
3684
|
+
}
|
3588
3685
|
var coPlainTextDefiner = () => {
|
3589
|
-
|
3590
|
-
const plainTextSchema = placeholderSchema;
|
3591
|
-
plainTextSchema.collaborative = true;
|
3592
|
-
plainTextSchema.builtin = "CoPlainText";
|
3593
|
-
plainTextSchema.create = function(...args) {
|
3594
|
-
return CoPlainText.create(...args);
|
3595
|
-
};
|
3596
|
-
plainTextSchema.load = function(...args) {
|
3597
|
-
return CoPlainText.load(...args);
|
3598
|
-
};
|
3599
|
-
plainTextSchema.subscribe = function(...args) {
|
3600
|
-
return CoPlainText.subscribe(...args);
|
3601
|
-
};
|
3602
|
-
plainTextSchema.fromRaw = function(...args) {
|
3603
|
-
return CoPlainText.fromRaw(...args);
|
3604
|
-
};
|
3605
|
-
return plainTextSchema;
|
3686
|
+
return enrichPlainTextSchema(z.instanceof(CoPlainText));
|
3606
3687
|
};
|
3688
|
+
function enrichRichTextSchema(schema) {
|
3689
|
+
const enrichedSchema = Object.assign(schema, {
|
3690
|
+
collaborative: true,
|
3691
|
+
builtin: "CoRichText",
|
3692
|
+
create: (...args) => {
|
3693
|
+
return coSchema.create(...args);
|
3694
|
+
},
|
3695
|
+
load: (...args) => {
|
3696
|
+
return coSchema.load(...args);
|
3697
|
+
},
|
3698
|
+
subscribe: (...args) => {
|
3699
|
+
return coSchema.subscribe(...args);
|
3700
|
+
},
|
3701
|
+
getCoSchema: () => {
|
3702
|
+
return coSchema;
|
3703
|
+
}
|
3704
|
+
});
|
3705
|
+
const coSchema = zodSchemaToCoSchema2(enrichedSchema);
|
3706
|
+
return enrichedSchema;
|
3707
|
+
}
|
3607
3708
|
var coRichTextDefiner = () => {
|
3608
|
-
|
3609
|
-
const richTextSchema = placeholderSchema;
|
3610
|
-
richTextSchema.collaborative = true;
|
3611
|
-
richTextSchema.builtin = "CoRichText";
|
3612
|
-
richTextSchema.create = function(...args) {
|
3613
|
-
return CoRichText.create(...args);
|
3614
|
-
};
|
3615
|
-
richTextSchema.load = function(...args) {
|
3616
|
-
return CoRichText.load(...args);
|
3617
|
-
};
|
3618
|
-
richTextSchema.subscribe = function(...args) {
|
3619
|
-
return CoRichText.subscribe(...args);
|
3620
|
-
};
|
3621
|
-
return richTextSchema;
|
3709
|
+
return enrichRichTextSchema(z.instanceof(CoRichText));
|
3622
3710
|
};
|
3623
3711
|
var coImageDefiner = () => {
|
3624
3712
|
return ImageDefinition;
|
@@ -3865,15 +3953,6 @@ function tryZodSchemaToCoSchema(schema) {
|
|
3865
3953
|
}
|
3866
3954
|
}
|
3867
3955
|
};
|
3868
|
-
if ("migration" in schema) {
|
3869
|
-
const migration = schema.migration;
|
3870
|
-
if (typeof migration !== "function") {
|
3871
|
-
throw new Error("migration must be a function");
|
3872
|
-
}
|
3873
|
-
coSchema.prototype.migrate = async function(creationProps) {
|
3874
|
-
await migration(this, creationProps);
|
3875
|
-
};
|
3876
|
-
}
|
3877
3956
|
coSchemasForZodSchemas.set(schema, coSchema);
|
3878
3957
|
return coSchema;
|
3879
3958
|
} else if (isZodArray(schema)) {
|
@@ -3941,9 +4020,10 @@ function zodSchemaToCoSchema2(schema) {
|
|
3941
4020
|
function anySchemaToCoSchema(schema) {
|
3942
4021
|
if (isCoValueClass(schema)) {
|
3943
4022
|
return schema;
|
3944
|
-
} else {
|
3945
|
-
return
|
4023
|
+
} else if ("getCoSchema" in schema) {
|
4024
|
+
return schema.getCoSchema();
|
3946
4025
|
}
|
4026
|
+
throw new Error(`Unsupported schema: ${schema}`);
|
3947
4027
|
}
|
3948
4028
|
function zodSchemaToCoSchemaOrKeepPrimitive(schema) {
|
3949
4029
|
const coSchema = tryZodSchemaToCoSchema(schema);
|
@@ -4611,9 +4691,9 @@ function isAccountInstance(instance) {
|
|
4611
4691
|
return "_type" in instance && instance._type === "Account";
|
4612
4692
|
}
|
4613
4693
|
function parseCoValueCreateOptions(options) {
|
4614
|
-
const
|
4694
|
+
const Group3 = RegisteredSchemas["Group"];
|
4615
4695
|
if (!options) {
|
4616
|
-
return { owner:
|
4696
|
+
return { owner: Group3.create(), uniqueness: void 0 };
|
4617
4697
|
}
|
4618
4698
|
if ("_type" in options) {
|
4619
4699
|
if (options._type === "Account" || options._type === "Group") {
|
@@ -4622,7 +4702,7 @@ function parseCoValueCreateOptions(options) {
|
|
4622
4702
|
}
|
4623
4703
|
const uniqueness = options.unique ? { uniqueness: options.unique } : void 0;
|
4624
4704
|
return {
|
4625
|
-
owner: options.owner ??
|
4705
|
+
owner: options.owner ?? Group3.create(),
|
4626
4706
|
uniqueness
|
4627
4707
|
};
|
4628
4708
|
}
|
@@ -4672,4 +4752,4 @@ export {
|
|
4672
4752
|
JazzContextManager
|
4673
4753
|
};
|
4674
4754
|
/* istanbul ignore file -- @preserve */
|
4675
|
-
//# sourceMappingURL=chunk-
|
4755
|
+
//# sourceMappingURL=chunk-SJKS4244.js.map
|