jazz-tools 0.15.10 → 0.15.12
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 +37 -37
- package/CHANGELOG.md +20 -0
- package/dist/{chunk-V54IPL5M.js → chunk-DZFT4EZM.js} +426 -303
- package/dist/chunk-DZFT4EZM.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -3
- package/dist/react/testing.js +1 -3
- package/dist/react/testing.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools/coValues/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/ContextManager.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/CoValueCoreSubscription.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/testStorage.d.ts +5 -0
- package/dist/tools/tests/testStorage.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/react-core/tests/useCoState.test.ts +20 -0
- 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/ContextManager.ts +5 -1
- 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 +34 -5
- package/src/tools/implementation/zodSchema/zodSchema.ts +78 -19
- package/src/tools/internal.ts +1 -0
- package/src/tools/subscribe/CoValueCoreSubscription.ts +4 -0
- package/src/tools/tests/ContextManager.test.ts +84 -10
- 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 +3 -3
- package/src/tools/tests/inbox.test.ts +3 -11
- package/src/tools/tests/load.test.ts +9 -0
- 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/testStorage.ts +70 -0
- package/src/tools/tests/zod.test-d.ts +70 -0
- package/src/tools/tests/zod.test.ts +64 -5
- package/dist/chunk-V54IPL5M.js.map +0 -1
@@ -1,9 +1,11 @@
|
|
1
1
|
import { Account, CoRichText, Group } from "../../../internal.js";
|
2
2
|
import { AnonymousJazzAgent } from "../../anonymousJazzAgent.js";
|
3
3
|
import { z } from "../zodReExport.js";
|
4
|
-
export type
|
4
|
+
export type AnyRichTextSchema = z.core.$ZodCustom<CoRichText, unknown> & {
|
5
5
|
collaborative: true;
|
6
6
|
builtin: "CoRichText";
|
7
|
+
};
|
8
|
+
export type RichTextSchema = AnyRichTextSchema & {
|
7
9
|
create(text: string, options?: {
|
8
10
|
owner: Account | Group;
|
9
11
|
} | Account | Group): CoRichText;
|
@@ -14,6 +16,7 @@ export type RichTextSchema = z.core.$ZodCustom<CoRichText, unknown> & {
|
|
14
16
|
loadAs: Account | AnonymousJazzAgent;
|
15
17
|
}, listener: (value: CoRichText, unsubscribe: () => void) => void): () => void;
|
16
18
|
subscribe(id: string, listener: (value: CoRichText, unsubscribe: () => void) => void): () => void;
|
17
|
-
|
19
|
+
getCoValueClass: () => typeof CoRichText;
|
18
20
|
};
|
21
|
+
export declare function enrichRichTextSchema(schema: AnyRichTextSchema, coValueClass: typeof CoRichText): RichTextSchema;
|
19
22
|
//# sourceMappingURL=RichTextSchema.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RichTextSchema.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"RichTextSchema.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG;IACvE,aAAa,EAAE,IAAI,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG;IAC/C,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE,GAAG,OAAO,GAAG,KAAK,GACrD,UAAU,CAAC;IACd,IAAI,CACF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,GAAG,kBAAkB,CAAA;KAAE,GAChD,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,SAAS,CACP,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,GAAG,kBAAkB,CAAA;KAAE,EACjD,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,GAC7D,MAAM,IAAI,CAAC;IACd,SAAS,CACP,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,GAC7D,MAAM,IAAI,CAAC;IACd,eAAe,EAAE,MAAM,OAAO,UAAU,CAAC;CAC1C,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,EACzB,YAAY,EAAE,OAAO,UAAU,GAC9B,cAAc,CAgBhB"}
|
@@ -1,24 +1,19 @@
|
|
1
|
-
import { Account, CoFeed, CoList, CoMap, CoPlainText, CoRichText, CoValueClass, FileStream } from "../../../internal.js";
|
1
|
+
import { Account, AnyAccountSchema, AnyCoRecordSchema, CoFeed, CoList, CoMap, CoPlainText, CoRichText, CoValueClass, FileStream } from "../../../internal.js";
|
2
2
|
import { AnyCoFeedSchema } from "../schemaTypes/CoFeedSchema.js";
|
3
3
|
import { AnyCoListSchema } from "../schemaTypes/CoListSchema.js";
|
4
4
|
import { AnyCoMapSchema } from "../schemaTypes/CoMapSchema.js";
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
5
|
+
import { AnyFileStreamSchema } from "../schemaTypes/FileStreamSchema.js";
|
6
|
+
import { AnyPlainTextSchema } from "../schemaTypes/PlainTextSchema.js";
|
7
|
+
import { AnyRichTextSchema } from "../schemaTypes/RichTextSchema.js";
|
8
8
|
import { z } from "../zodReExport.js";
|
9
9
|
import { InstanceOrPrimitiveOfSchema } from "./InstanceOrPrimitiveOfSchema.js";
|
10
|
-
export type InstanceOfSchema<S extends CoValueClass | z.core.$ZodType> = S extends z.core.$ZodType ? S extends
|
11
|
-
collaborative: true;
|
12
|
-
builtin: "Account";
|
13
|
-
} ? {
|
10
|
+
export type InstanceOfSchema<S extends CoValueClass | z.core.$ZodType> = S extends z.core.$ZodType ? S extends AnyAccountSchema<infer Shape> ? {
|
14
11
|
[key in keyof Shape]: InstanceOrPrimitiveOfSchema<Shape[key]>;
|
15
|
-
} & Account : S extends
|
16
|
-
collaborative: true;
|
17
|
-
} ? {
|
12
|
+
} & Account : S extends AnyCoRecordSchema<infer K, infer V> ? {
|
18
13
|
[key in z.output<K> & string]: InstanceOrPrimitiveOfSchema<V>;
|
19
14
|
} & CoMap : S extends AnyCoMapSchema<infer Shape, infer Config> ? {
|
20
15
|
[key in keyof Shape]: InstanceOrPrimitiveOfSchema<Shape[key]>;
|
21
16
|
} & (unknown extends Config["out"][string] ? {} : {
|
22
17
|
[key: string]: Config["out"][string];
|
23
|
-
}) & CoMap : S extends AnyCoListSchema<infer T> ? CoList<InstanceOrPrimitiveOfSchema<T>> : S extends AnyCoFeedSchema<infer T> ? CoFeed<InstanceOrPrimitiveOfSchema<T>> : S extends
|
18
|
+
}) & CoMap : S extends AnyCoListSchema<infer T> ? CoList<InstanceOrPrimitiveOfSchema<T>> : S extends AnyCoFeedSchema<infer T> ? CoFeed<InstanceOrPrimitiveOfSchema<T>> : S extends AnyPlainTextSchema ? CoPlainText : S extends AnyRichTextSchema ? CoRichText : S extends AnyFileStreamSchema ? FileStream : S extends z.core.$ZodOptional<infer Inner> ? InstanceOrPrimitiveOfSchema<Inner> : S extends z.core.$ZodUnion<infer Members> ? InstanceOrPrimitiveOfSchema<Members[number]> : never : S extends CoValueClass ? InstanceType<S> : never;
|
24
19
|
//# sourceMappingURL=InstanceOfSchema.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"InstanceOfSchema.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,MAAM,EACN,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"InstanceOfSchema.d.ts","sourceRoot":"","sources":["../../../../../src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,MAAM,EACN,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,iBA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B,UAAU,GACV,CAAC,SAAS,mBAAmB,GAC3B,UAAU,GACV,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,GACxC,2BAA2B,CAAC,KAAK,CAAC,GAClC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,GACvC,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAC5C,KAAK,GACzB,CAAC,SAAS,YAAY,GACpB,YAAY,CAAC,CAAC,CAAC,GACf,KAAK,CAAC"}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { RawAccount, RawCoList, RawCoMap } from "cojson";
|
2
|
+
import { CoValueClass, CoValueFromRaw } from "../../internal.js";
|
2
3
|
import { z } from "./zodReExport.js";
|
3
|
-
export declare function schemaUnionDiscriminatorFor(schema: z.core.$ZodDiscriminatedUnion): (_raw: RawCoMap | RawAccount | RawCoList) =>
|
4
|
-
[k: string]: z.core.$ZodType<unknown, unknown>;
|
5
|
-
}>>, z.core.$ZodObjectConfig>>;
|
4
|
+
export declare function schemaUnionDiscriminatorFor(schema: z.core.$ZodDiscriminatedUnion): (_raw: RawCoMap | RawAccount | RawCoList) => CoValueClass<any> & CoValueFromRaw<any>;
|
6
5
|
export declare function isUnionOfCoMapsDeeply(schema: z.core.$ZodType): schema is z.core.$ZodDiscriminatedUnion;
|
7
6
|
export declare function isUnionOfPrimitivesDeeply(schema: z.core.$ZodType): boolean;
|
8
7
|
//# sourceMappingURL=unionUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unionUtils.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/unionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
1
|
+
{"version":3,"file":"unionUtils.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/unionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQjE,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,UA4CJ,QAAQ,GAAG,UAAU,GAAG,SAAS,KA+ChB,YAAY,CAAC,GAAG,CAAC,GACzD,cAAc,CAAC,GAAG,CAAC,CAe9B;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GACtB,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAMzC;AAcD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,WAMhE"}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
import { type AccountSchema, BaseAccountShape, type CoFeedSchema, type CoListSchema, type CoMapSchema, type CoProfileSchema, type CoRecordSchema, type FileStreamSchema, ImageDefinition, type PlainTextSchema } from "../../internal.js";
|
1
|
+
import { type AccountSchema, AnyCoSchema, BaseAccountShape, type CoFeedSchema, type CoListSchema, type CoMapSchema, type CoProfileSchema, type CoRecordSchema, type DefaultProfileShape, type FileStreamSchema, ImageDefinition, type PlainTextSchema } from "../../internal.js";
|
2
|
+
import { AnyDiscriminableCoSchema, CoDiscriminatedUnionSchema } from "./schemaTypes/CoDiscriminatedUnionSchema.js";
|
3
|
+
import { CoOptionalSchema } from "./schemaTypes/CoOptionalSchema.js";
|
2
4
|
import { RichTextSchema } from "./schemaTypes/RichTextSchema.js";
|
3
5
|
import { z } from "./zodReExport.js";
|
4
6
|
export declare const coMapDefiner: <Shape extends z.core.$ZodLooseShape>(shape: Shape) => CoMapSchema<Shape>;
|
@@ -46,14 +48,12 @@ export declare const coProfileDefiner: <Shape extends z.core.$ZodLooseShape = {
|
|
46
48
|
name: z.core.$ZodString<string>;
|
47
49
|
inbox: z.core.$ZodOptional<z.core.$ZodString>;
|
48
50
|
inboxInvite: z.core.$ZodOptional<z.core.$ZodString>;
|
49
|
-
}>(shape?: Shape &
|
50
|
-
name?: z.core.$ZodString<string>;
|
51
|
-
inbox?: z.core.$ZodOptional<z.core.$ZodString>;
|
52
|
-
inboxInvite?: z.core.$ZodOptional<z.core.$ZodString>;
|
53
|
-
}) => CoProfileSchema<Shape>;
|
51
|
+
}>(shape?: Shape & Partial<DefaultProfileShape>) => CoProfileSchema<Shape>;
|
54
52
|
export declare const coFeedDefiner: <T extends z.core.$ZodType>(element: T) => CoFeedSchema<T>;
|
55
53
|
export declare const coFileStreamDefiner: () => FileStreamSchema;
|
56
54
|
export declare const coPlainTextDefiner: () => PlainTextSchema;
|
57
55
|
export declare const coRichTextDefiner: () => RichTextSchema;
|
58
56
|
export declare const coImageDefiner: () => typeof ImageDefinition;
|
57
|
+
export declare const coOptionalDefiner: <T extends AnyCoSchema>(schema: T) => CoOptionalSchema<T>;
|
58
|
+
export declare const coDiscriminatedUnionDefiner: <T extends readonly [AnyDiscriminableCoSchema, ...AnyDiscriminableCoSchema[]]>(discriminator: string, schemas: T) => CoDiscriminatedUnionSchema<T>;
|
59
59
|
//# sourceMappingURL=zodCo.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zodCo.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/zodCo.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"zodCo.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/zodCo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAIlB,WAAW,EAGX,gBAAgB,EAEhB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,KAAK,eAAe,EACpB,KAAK,c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K,CAOvB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,WAC5C,CAAC,KACT,YAAY,CAAC,CAAC,CAQhB,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,gBAOtC,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,eAOrC,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,cAOpC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,OAAO,eAExC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,WAAW,UAC7C,CAAC,KACR,gBAAgB,CAAC,CAAC,CAEpB,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,CAAC,SAAS,SAAS,CAAC,wBAAwB,EAAE,GAAG,wBAAwB,EAAE,CAAC,iBAE7D,MAAM,WACZ,CAAC,KACT,0BAA0B,CAAC,CAAC,CAG9B,CAAC"}
|
@@ -1,2 +1,9 @@
|
|
1
|
-
|
1
|
+
import { ZodArray, ZodTuple, ZodUnion, core } from "zod/v4";
|
2
|
+
export { string, number, boolean, object, templateLiteral, json, date, emoji, base64, base64url, nanoid, cuid, cuid2, ulid, ipv4, ipv6, email, url, uuid, literal, enum, cidrv4, cidrv6, iso, int32, strictObject, discriminatedUnion, int, optional, type ZodOptional, type ZodReadonly, type ZodLazy, type ZodDefault, type ZodCatch, type output as infer, type ZodDiscriminatedUnion, z, } from "zod/v4";
|
3
|
+
type NonCoZodType = core.$ZodType & {
|
4
|
+
collaborative?: false;
|
5
|
+
};
|
6
|
+
export declare function union<const T extends readonly NonCoZodType[]>(options: T, params?: string | core.$ZodUnionParams): ZodUnion<T>;
|
7
|
+
export declare function array<T extends NonCoZodType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T>;
|
8
|
+
export declare function tuple<T extends readonly [NonCoZodType, ...NonCoZodType[]]>(options: T, params?: string | core.$ZodTupleParams): ZodTuple<T>;
|
2
9
|
//# sourceMappingURL=zodReExport.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zodReExport.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/zodReExport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,
|
1
|
+
{"version":3,"file":"zodReExport.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/zodReExport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,IAAI,EAIL,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,SAAS,EACT,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,GAAG,EACH,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,MAAM,EACN,MAAM,EACN,GAAG,EACH,KAAK,EACL,YAAY,EACZ,kBAAkB,EAGlB,GAAG,EACH,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,MAAM,IAAI,KAAK,EACpB,KAAK,qBAAqB,EAC1B,CAAC,GACF,MAAM,QAAQ,CAAC;AAEhB,KAAK,YAAY,GAAG,IAAI,CAAC,QAAQ,GAAG;IAAE,aAAa,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9D,wBAAgB,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,YAAY,EAAE,EAC3D,OAAO,EAAE,CAAC,EACV,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,eAAe,GACrC,QAAQ,CAAC,CAAC,CAAC,CAEb;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,YAAY,EAC1C,OAAO,EAAE,CAAC,EACV,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,eAAe,GACrC,QAAQ,CAAC,CAAC,CAAC,CAEb;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,SAAS,CAAC,YAAY,EAAE,GAAG,YAAY,EAAE,CAAC,EACxE,OAAO,EAAE,CAAC,EACV,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,eAAe,GACrC,QAAQ,CAAC,CAAC,CAAC,CAEb"}
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import { LocalNode, RawAccount } from "cojson";
|
2
|
-
import { Account, AccountClass, CoValueClass, CoValueFromRaw, RefsToResolve, RefsToResolveStrict, Resolved, Simplify } from "../../internal.js";
|
3
|
-
import { AnyAccountSchema } from "./schemaTypes/AccountSchema.js";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
2
|
+
import { Account, AccountClass, CoValueClass, CoValueFromRaw, InstanceOfSchema, RefsToResolve, RefsToResolveStrict, Resolved, Simplify } from "../../internal.js";
|
3
|
+
import { AccountSchema, AnyAccountSchema, BaseAccountShape } from "./schemaTypes/AccountSchema.js";
|
4
|
+
import { AnyDiscriminableCoSchema, CoDiscriminatedUnionSchema } from "./schemaTypes/CoDiscriminatedUnionSchema.js";
|
5
|
+
import { AnyCoFeedSchema, CoFeedSchema } from "./schemaTypes/CoFeedSchema.js";
|
6
|
+
import { AnyCoListSchema, CoListSchema } from "./schemaTypes/CoListSchema.js";
|
7
|
+
import { AnyCoMapSchema, CoMapInitZod, CoMapSchema } from "./schemaTypes/CoMapSchema.js";
|
8
|
+
import { AnyCoOptionalSchema } from "./schemaTypes/CoOptionalSchema.js";
|
9
|
+
import { AnyCoRecordSchema, CoRecordSchema } from "./schemaTypes/CoRecordSchema.js";
|
10
|
+
import { AnyFileStreamSchema, FileStreamSchema } from "./schemaTypes/FileStreamSchema.js";
|
11
|
+
import { AnyPlainTextSchema, PlainTextSchema } from "./schemaTypes/PlainTextSchema.js";
|
12
|
+
import { AnyRichTextSchema, RichTextSchema } from "./schemaTypes/RichTextSchema.js";
|
12
13
|
import { InstanceOfSchemaCoValuesNullable } from "./typeConverters/InstanceOfSchemaCoValuesNullable.js";
|
13
14
|
import { z } from "./zodReExport.js";
|
14
15
|
export type WithHelpers<Base extends z.core.$ZodType, Helpers extends object> = Base & Helpers;
|
@@ -16,17 +17,21 @@ export type ZodPrimitiveSchema = z.core.$ZodString | z.core.$ZodNumber | z.core.
|
|
16
17
|
export type AnyCoUnionSchema = z.core.$ZodDiscriminatedUnion<((z.core.$ZodType & {
|
17
18
|
collaborative: true;
|
18
19
|
}) | z.core.$ZodDiscriminatedUnion)[]>;
|
19
|
-
export declare function isZodObject(schema: z.core.$ZodType): schema is z.
|
20
|
+
export declare function isZodObject(schema: z.core.$ZodType): schema is z.ZodObject<any, any>;
|
20
21
|
export declare function isZodArray(schema: z.core.$ZodType): schema is z.core.$ZodArray<any>;
|
21
22
|
export declare function isZodCustom(schema: z.core.$ZodType): schema is z.core.$ZodCustom<any, any>;
|
22
23
|
export declare function getDef<S extends z.core.$ZodType>(schema: S): S["_zod"]["def"];
|
23
24
|
export type CoValueOrZodSchema = CoValueClass | AnyCoSchema;
|
24
|
-
export type
|
25
|
+
export type CoValueSchemaFromZodSchema<S extends z.core.$ZodType> = S extends z.core.$ZodType ? S extends AnyAccountSchema<infer Shape extends BaseAccountShape> ? AccountSchema<Shape> : S extends AnyCoRecordSchema<infer K, infer V> ? CoRecordSchema<K, V> : S extends AnyCoMapSchema<infer Shape, infer Config> ? CoMapSchema<Shape, Config> : S extends AnyCoListSchema<infer T> ? CoListSchema<T> : S extends AnyCoFeedSchema<infer T> ? CoFeedSchema<T> : S extends AnyPlainTextSchema ? PlainTextSchema : S extends AnyRichTextSchema ? RichTextSchema : S extends AnyFileStreamSchema ? FileStreamSchema : S extends z.core.$ZodOptional<infer Inner> ? CoValueSchemaFromZodSchema<Inner> : S extends z.core.$ZodUnion<infer Members extends readonly [
|
26
|
+
AnyDiscriminableCoSchema,
|
27
|
+
...AnyDiscriminableCoSchema[]
|
28
|
+
]> ? CoDiscriminatedUnionSchema<Members> : never : never;
|
29
|
+
export type CoValueClassFromAnySchema<S extends CoValueOrZodSchema> = S extends CoValueClass<any> ? S : CoValueClass<InstanceOfSchema<S>> & CoValueFromRaw<InstanceOfSchema<S>> & (S extends AnyAccountSchema ? AccountClassEssentials : {});
|
25
30
|
type AccountClassEssentials = {
|
26
31
|
fromRaw: <A extends Account>(this: AccountClass<A>, raw: RawAccount) => A;
|
27
32
|
fromNode: <A extends Account>(this: AccountClass<A>, node: LocalNode) => A;
|
28
33
|
};
|
29
|
-
export type AnyCoSchema = AnyCoMapSchema | AnyAccountSchema | AnyCoRecordSchema | AnyCoListSchema | AnyCoFeedSchema | AnyCoUnionSchema |
|
34
|
+
export type AnyCoSchema = AnyCoMapSchema | AnyAccountSchema | AnyCoRecordSchema | AnyCoListSchema | AnyCoFeedSchema | AnyCoUnionSchema | AnyCoOptionalSchema | AnyPlainTextSchema | AnyRichTextSchema | AnyFileStreamSchema;
|
30
35
|
export type Loaded<T extends CoValueClass | AnyCoSchema, R extends ResolveQuery<T> = true> = Resolved<NonNullable<InstanceOfSchemaCoValuesNullable<T>>, R>;
|
31
36
|
export type ResolveQuery<T extends CoValueClass | AnyCoSchema> = RefsToResolve<NonNullable<InstanceOfSchemaCoValuesNullable<T>>>;
|
32
37
|
export type ResolveQueryStrict<T extends CoValueClass | AnyCoSchema, R extends ResolveQuery<T>> = RefsToResolveStrict<NonNullable<InstanceOfSchemaCoValuesNullable<T>>, R>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zodSchema.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/zodSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,YAAY,
|
1
|
+
{"version":3,"file":"zodSchema.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementation/zodSchema/zodSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,cAAc,EACd,YAAY,EACZ,WAAW,EACZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAIrC,MAAM,MAAM,WAAW,CACrB,IAAI,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAC5B,OAAO,SAAS,MAAM,IACpB,IAAI,GAAG,OAAO,CAAC;AA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/zodCo.js";
|
30
30
|
export * as co from "./implementation/zodSchema/coExport.js";
|
31
31
|
export * from "./implementation/zodSchema/schemaTypes/CoMapSchema.js";
|
32
|
+
export * from "./implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.js";
|
32
33
|
export * from "./implementation/zodSchema/schemaTypes/CoRecordSchema.js";
|
33
34
|
export * from "./implementation/zodSchema/schemaTypes/CoListSchema.js";
|
34
35
|
export * from "./implementation/zodSchema/schemaTypes/CoFeedSchema.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/tools/internal.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mCAAmC,CAAC;AAElD,cAAc,YAAY,CAAC;AAC3B,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC7D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3B,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC7D,cAAc,uDAAuD,CAAC;AACtE,cAAc,sEAAsE,CAAC;AACrF,cAAc,0DAA0D,CAAC;AACzE,cAAc,wDAAwD,CAAC;AACvE,cAAc,wDAAwD,CAAC;AACvE,cAAc,yDAAyD,CAAC;AACxE,cAAc,4DAA4D,CAAC;AAC3E,cAAc,2DAA2D,CAAC;AAC1E,cAAc,0EAA0E,CAAC;AACzF,cAAc,0FAA0F,CAAC;AACzG,cAAc,+DAA+D,CAAC;AAC9E,cAAc,+EAA+E,CAAC;AAC9F,cAAc,qEAAqE,CAAC;AACpF,cAAc,sEAAsE,CAAC;AACrF,cAAc,mCAAmC,CAAC;AAElD,cAAc,oCAAoC,CAAC;AAEnD,OAAO,wCAAwC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CoValueCoreSubscription.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/CoValueCoreSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtE,qBAAa,uBAAuB;IAOzB,IAAI,EAAE,SAAS;IACf,EAAE,EAAE,MAAM;IACV,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,KAAK,IAAI;IACrD,SAAS,CAAC,EAAE,OAAO;IAT5B,YAAY,EAAE,MAAM,IAAI,CAAY;IACpC,YAAY,UAAS;IAErB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;gBAGnB,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,KAAK,IAAI,EACrD,SAAS,CAAC,EAAE,OAAO,YAAA;
|
1
|
+
{"version":3,"file":"CoValueCoreSubscription.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/CoValueCoreSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtE,qBAAa,uBAAuB;IAOzB,IAAI,EAAE,SAAS;IACf,EAAE,EAAE,MAAM;IACV,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,KAAK,IAAI;IACrD,SAAS,CAAC,EAAE,OAAO;IAT5B,YAAY,EAAE,MAAM,IAAI,CAAY;IACpC,YAAY,UAAS;IAErB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;gBAGnB,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,KAAK,IAAI,EACrD,SAAS,CAAC,EAAE,OAAO,YAAA;IA0B5B,gBAAgB;IAwBhB,SAAS,CAAC,KAAK,EAAE,UAAU;IAU3B,WAAW;CAKZ"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coDiscriminatedUnion.test-d.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/coDiscriminatedUnion.test-d.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coDiscriminatedUnion.test.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/coDiscriminatedUnion.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coOptional.test.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/coOptional.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"testStorage.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/testStorage.ts"],"names":[],"mappings":"AA+CA,wBAAsB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,6CAU3E;AAED,wBAAgB,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,UAU/C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"zod.test-d.d.ts","sourceRoot":"","sources":["../../../src/tools/tests/zod.test-d.ts"],"names":[],"mappings":""}
|
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.12",
|
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.12",
|
162
|
+
"cojson-storage-indexeddb": "0.15.12",
|
163
|
+
"cojson-transport-ws": "0.15.12"
|
164
164
|
},
|
165
165
|
"devDependencies": {
|
166
166
|
"@scure/bip39": "^1.3.0",
|
@@ -239,6 +239,7 @@
|
|
239
239
|
}
|
240
240
|
},
|
241
241
|
"scripts": {
|
242
|
+
"check": "tsc --noEmit",
|
242
243
|
"format-and-lint": "biome check .",
|
243
244
|
"format-and-lint:fix": "biome check . --write",
|
244
245
|
"dev": "tsup --watch --dts",
|
@@ -1,16 +1,6 @@
|
|
1
1
|
// @vitest-environment happy-dom
|
2
2
|
|
3
|
-
import {
|
4
|
-
Account,
|
5
|
-
CoMap,
|
6
|
-
Loaded,
|
7
|
-
RefsToResolve,
|
8
|
-
Resolved,
|
9
|
-
co,
|
10
|
-
coField,
|
11
|
-
z,
|
12
|
-
zodSchemaToCoSchema,
|
13
|
-
} from "jazz-tools";
|
3
|
+
import { RefsToResolve, co, z, zodSchemaToCoSchema } from "jazz-tools";
|
14
4
|
import { beforeEach, describe, expect, it } from "vitest";
|
15
5
|
import { useAccount, useJazzContextManager } from "../hooks.js";
|
16
6
|
import { useIsAuthenticated } from "../index.js";
|
@@ -47,6 +47,26 @@ describe("useCoState", () => {
|
|
47
47
|
expect(result.current?.value).toBe("123");
|
48
48
|
});
|
49
49
|
|
50
|
+
it("should return null on invalid id", async () => {
|
51
|
+
const TestMap = co.map({
|
52
|
+
value: z.string(),
|
53
|
+
});
|
54
|
+
|
55
|
+
const account = await createJazzTestAccount({
|
56
|
+
isCurrentActiveAccount: true,
|
57
|
+
});
|
58
|
+
|
59
|
+
const { result } = renderHook(() => useCoState(TestMap, "test", {}), {
|
60
|
+
account,
|
61
|
+
});
|
62
|
+
|
63
|
+
expect(result.current).toBeUndefined();
|
64
|
+
|
65
|
+
await waitFor(() => {
|
66
|
+
expect(result.current).toBeNull();
|
67
|
+
});
|
68
|
+
});
|
69
|
+
|
50
70
|
it("should update the value when the coValue changes", async () => {
|
51
71
|
const TestMap = co.map({
|
52
72
|
value: z.string(),
|
@@ -11,10 +11,10 @@ import {
|
|
11
11
|
anySchemaToCoSchema,
|
12
12
|
coValuesCache,
|
13
13
|
inspect,
|
14
|
+
isCoValueSchema,
|
14
15
|
} from "../internal.js";
|
15
16
|
import type {
|
16
17
|
Account,
|
17
|
-
CoValueClassFromZodSchema,
|
18
18
|
Group,
|
19
19
|
InstanceOfSchemaCoValuesNullable,
|
20
20
|
} from "../internal.js";
|
@@ -101,7 +101,7 @@ export class CoValueBase implements CoValue {
|
|
101
101
|
: S extends z.core.$ZodType
|
102
102
|
? NonNullable<InstanceOfSchemaCoValuesNullable<S>>
|
103
103
|
: never {
|
104
|
-
const cl =
|
104
|
+
const cl = isCoValueSchema(schema) ? schema.getCoValueClass() : schema;
|
105
105
|
|
106
106
|
if (this.constructor === cl) {
|
107
107
|
return this as any;
|
@@ -3,14 +3,12 @@ import { CoStreamItem, RawCoStream } from "cojson";
|
|
3
3
|
import {
|
4
4
|
type Account,
|
5
5
|
CoValue,
|
6
|
-
CoValueClass,
|
7
6
|
CoValueOrZodSchema,
|
8
7
|
ID,
|
9
8
|
InstanceOfSchema,
|
10
9
|
activeAccountContext,
|
11
10
|
anySchemaToCoSchema,
|
12
11
|
loadCoValue,
|
13
|
-
zodSchemaToCoSchema,
|
14
12
|
} from "../internal.js";
|
15
13
|
|
16
14
|
export type InboxInvite = `${CoID<MessagesStream>}/${InviteSecret}`;
|
@@ -1,8 +1,19 @@
|
|
1
1
|
import {
|
2
|
+
Account,
|
3
|
+
AnonymousJazzAgent,
|
2
4
|
CoValue,
|
3
5
|
CoValueBase,
|
4
6
|
CoValueClass,
|
5
7
|
CoValueFromRaw,
|
8
|
+
ID,
|
9
|
+
RefsToResolve,
|
10
|
+
RefsToResolveStrict,
|
11
|
+
Resolved,
|
12
|
+
SubscribeListenerOptions,
|
13
|
+
SubscribeRestArgs,
|
14
|
+
loadCoValueWithoutMe,
|
15
|
+
parseSubscribeRestArgs,
|
16
|
+
subscribeToCoValueWithoutMe,
|
6
17
|
} from "../internal.js";
|
7
18
|
|
8
19
|
/**
|
@@ -99,4 +110,55 @@ export abstract class SchemaUnion extends CoValueBase implements CoValue {
|
|
99
110
|
static fromRaw<V extends CoValue>(this: CoValueClass<V>, raw: V["_raw"]): V {
|
100
111
|
throw new Error("Not implemented");
|
101
112
|
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Load a `SchemaUnion` with a given ID, as a given account.
|
116
|
+
*
|
117
|
+
* Note: The `resolve` option is not supported for `SchemaUnion`s due to https://github.com/garden-co/jazz/issues/2639
|
118
|
+
*
|
119
|
+
* @category Subscription & Loading
|
120
|
+
*/
|
121
|
+
static load<M extends SchemaUnion>(
|
122
|
+
this: CoValueClass<M>,
|
123
|
+
id: ID<M>,
|
124
|
+
options?: {
|
125
|
+
loadAs?: Account | AnonymousJazzAgent;
|
126
|
+
skipRetry?: boolean;
|
127
|
+
},
|
128
|
+
): Promise<Resolved<M, true> | null> {
|
129
|
+
return loadCoValueWithoutMe(this, id, options);
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Load and subscribe to a `CoMap` with a given ID, as a given account.
|
134
|
+
*
|
135
|
+
* Automatically also subscribes to updates to all referenced/nested CoValues as soon as they are accessed in the listener.
|
136
|
+
*
|
137
|
+
* Returns an unsubscribe function that you should call when you no longer need updates.
|
138
|
+
*
|
139
|
+
* Also see the `useCoState` hook to reactively subscribe to a CoValue in a React component.
|
140
|
+
*
|
141
|
+
* Note: The `resolve` option is not supported for `SchemaUnion`s due to https://github.com/garden-co/jazz/issues/2639
|
142
|
+
*
|
143
|
+
* @category Subscription & Loading
|
144
|
+
*/
|
145
|
+
static subscribe<M extends SchemaUnion>(
|
146
|
+
this: CoValueClass<M>,
|
147
|
+
id: ID<M>,
|
148
|
+
listener: (value: Resolved<M, true>, unsubscribe: () => void) => void,
|
149
|
+
): () => void;
|
150
|
+
static subscribe<M extends SchemaUnion>(
|
151
|
+
this: CoValueClass<M>,
|
152
|
+
id: ID<M>,
|
153
|
+
options: SubscribeListenerOptions<M, true>,
|
154
|
+
listener: (value: Resolved<M, true>, unsubscribe: () => void) => void,
|
155
|
+
): () => void;
|
156
|
+
static subscribe<M extends SchemaUnion>(
|
157
|
+
this: CoValueClass<M>,
|
158
|
+
id: ID<M>,
|
159
|
+
...args: SubscribeRestArgs<M, true>
|
160
|
+
): () => void {
|
161
|
+
const { options, listener } = parseSubscribeRestArgs(args);
|
162
|
+
return subscribeToCoValueWithoutMe<M, true>(this, id, options, listener);
|
163
|
+
}
|
102
164
|
}
|
@@ -279,8 +279,12 @@ export class JazzContextManager<
|
|
279
279
|
},
|
280
280
|
);
|
281
281
|
|
282
|
-
prevContext
|
282
|
+
// Closing storage on the prevContext to avoid conflicting transactions and getting stuck on waitForAllCoValuesSync
|
283
|
+
// The storage is reachable through currentContext using the connectedPeers
|
284
|
+
prevContext.node.removeStorage();
|
285
|
+
|
283
286
|
currentContext.node.syncManager.addPeer(prevAccountAsPeer);
|
287
|
+
prevContext.node.syncManager.addPeer(currentAccountAsPeer);
|
284
288
|
|
285
289
|
try {
|
286
290
|
await this.props.onAnonymousAccountDiscarded?.(prevContext.me);
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { CoMap, CoValueClass, isCoValueClass } from "../../../internal.js";
|
2
2
|
import { coField } from "../../schema.js";
|
3
|
+
import { isAnyCoOptionalSchema } from "../schemaTypes/CoOptionalSchema.js";
|
3
4
|
import {
|
4
5
|
isUnionOfCoMapsDeeply,
|
5
6
|
isUnionOfPrimitivesDeeply,
|
@@ -12,10 +13,19 @@ import {
|
|
12
13
|
ZodReadonly,
|
13
14
|
z,
|
14
15
|
} from "../zodReExport.js";
|
15
|
-
import { ZodPrimitiveSchema } from "../zodSchema.js";
|
16
|
-
import {
|
16
|
+
import { AnyCoSchema, ZodPrimitiveSchema } from "../zodSchema.js";
|
17
|
+
import {
|
18
|
+
isCoValueSchema,
|
19
|
+
zodSchemaToCoSchemaOrKeepPrimitive,
|
20
|
+
} from "./zodSchemaToCoSchema.js";
|
17
21
|
|
18
|
-
|
22
|
+
/**
|
23
|
+
* Types of objects that can be nested inside CoValue schema containers
|
24
|
+
*/
|
25
|
+
type SchemaField =
|
26
|
+
// Schemas created with co.map(), co.record(), co.list(), etc.
|
27
|
+
| AnyCoSchema
|
28
|
+
// CoValue classes created with class syntax, or framework-provided classes like Group
|
19
29
|
| CoValueClass
|
20
30
|
| ZodPrimitiveSchema
|
21
31
|
| z.core.$ZodOptional<z.core.$ZodType>
|
@@ -33,9 +43,16 @@ type FieldSchema =
|
|
33
43
|
| z.core.$ZodCatch<z.core.$ZodType>
|
34
44
|
| (z.core.$ZodCustom<any, any> & { builtin: any });
|
35
45
|
|
36
|
-
export function
|
46
|
+
export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
37
47
|
if (isCoValueClass(schema)) {
|
38
48
|
return coField.ref(schema);
|
49
|
+
} else if (isCoValueSchema(schema)) {
|
50
|
+
if (isAnyCoOptionalSchema(schema)) {
|
51
|
+
return coField.ref(schema.getCoValueClass(), {
|
52
|
+
optional: true,
|
53
|
+
});
|
54
|
+
}
|
55
|
+
return coField.ref(schema.getCoValueClass());
|
39
56
|
} else {
|
40
57
|
if ("_zod" in schema) {
|
41
58
|
if (schema._zod.def.type === "optional") {
|
@@ -45,7 +62,7 @@ export function zodFieldToCoFieldDef(schema: FieldSchema) {
|
|
45
62
|
if (isCoValueClass(inner)) {
|
46
63
|
return coField.ref(inner, { optional: true });
|
47
64
|
} else {
|
48
|
-
return
|
65
|
+
return schemaFieldToCoFieldDef(inner);
|
49
66
|
}
|
50
67
|
} else if (schema._zod.def.type === "string") {
|
51
68
|
return coField.string;
|
@@ -58,8 +75,8 @@ export function zodFieldToCoFieldDef(schema: FieldSchema) {
|
|
58
75
|
} else if (schema._zod.def.type === "enum") {
|
59
76
|
return coField.string;
|
60
77
|
} else if (schema._zod.def.type === "readonly") {
|
61
|
-
return
|
62
|
-
(schema as unknown as ZodReadonly).def.innerType as
|
78
|
+
return schemaFieldToCoFieldDef(
|
79
|
+
(schema as unknown as ZodReadonly).def.innerType as SchemaField,
|
63
80
|
);
|
64
81
|
} else if (schema._zod.def.type === "date") {
|
65
82
|
return coField.optional.Date;
|
@@ -67,8 +84,8 @@ export function zodFieldToCoFieldDef(schema: FieldSchema) {
|
|
67
84
|
return coField.string;
|
68
85
|
} else if (schema._zod.def.type === "lazy") {
|
69
86
|
// Mostly to support z.json()
|
70
|
-
return
|
71
|
-
(schema as unknown as ZodLazy).unwrap() as
|
87
|
+
return schemaFieldToCoFieldDef(
|
88
|
+
(schema as unknown as ZodLazy).unwrap() as SchemaField,
|
72
89
|
);
|
73
90
|
} else if (
|
74
91
|
schema._zod.def.type === "default" ||
|
@@ -78,9 +95,9 @@ export function zodFieldToCoFieldDef(schema: FieldSchema) {
|
|
78
95
|
"z.default()/z.catch() are not supported in collaborative schemas. They will be ignored.",
|
79
96
|
);
|
80
97
|
|
81
|
-
return
|
98
|
+
return schemaFieldToCoFieldDef(
|
82
99
|
(schema as unknown as ZodDefault | ZodCatch).def
|
83
|
-
.innerType as
|
100
|
+
.innerType as SchemaField,
|
84
101
|
);
|
85
102
|
} else if (schema._zod.def.type === "literal") {
|
86
103
|
if (
|
@@ -112,7 +129,7 @@ export function zodFieldToCoFieldDef(schema: FieldSchema) {
|
|
112
129
|
return coField.json();
|
113
130
|
} else if (schema._zod.def.type === "custom") {
|
114
131
|
if ("builtin" in schema) {
|
115
|
-
return
|
132
|
+
return schemaFieldToCoFieldDef(schema.builtin);
|
116
133
|
} else {
|
117
134
|
throw new Error(`Unsupported custom zod type`);
|
118
135
|
}
|