jazz-tools 0.15.16 → 0.16.1
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/.svelte-kit/__package__/jazz.class.svelte.d.ts +2 -2
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/jazz.class.svelte.js +5 -5
- package/.svelte-kit/__package__/jazz.svelte.d.ts +2 -2
- package/.svelte-kit/__package__/jazz.svelte.d.ts.map +1 -1
- package/.turbo/turbo-build.log +44 -44
- package/CHANGELOG.md +34 -0
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser-media-images/index.d.ts +3 -1
- package/dist/browser-media-images/index.d.ts.map +1 -1
- package/dist/browser-media-images/index.js.map +1 -1
- package/dist/{chunk-OSVAAVWQ.js → chunk-CL3ROOZM.js} +598 -598
- package/dist/chunk-CL3ROOZM.js.map +1 -0
- package/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +2 -2
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts +2 -2
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +3 -3
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-native-core/hooks.d.ts +2 -2
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts +2 -2
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +5 -5
- package/dist/svelte/jazz.svelte.d.ts +2 -2
- package/dist/svelte/jazz.svelte.d.ts.map +1 -1
- package/dist/testing.js +3 -3
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts +3 -13
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +2 -2
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +8 -23
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +4 -1
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +4 -7
- package/dist/tools/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts +2 -2
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +2 -17
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/request.d.ts +3 -3
- package/dist/tools/coValues/request.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +5 -1
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +3 -3
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/createContext.d.ts +4 -4
- package/dist/tools/implementation/createContext.d.ts.map +1 -1
- package/dist/tools/implementation/invites.d.ts +2 -2
- package/dist/tools/implementation/invites.d.ts.map +1 -1
- package/dist/tools/implementation/schemaUtils.d.ts +8 -0
- package/dist/tools/implementation/schemaUtils.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/coExport.d.ts +11 -1
- package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts +22 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts +10 -0
- package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +11 -11
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +34 -24
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +17 -14
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +24 -17
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +31 -34
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts +20 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +19 -12
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts +18 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +14 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +14 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +14 -9
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts +10 -0
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +15 -13
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +12 -15
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +17 -20
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +17 -20
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts +3 -5
- package/dist/tools/implementation/zodSchema/unionUtils.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +10 -8
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts +4 -8
- package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +21 -30
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +3 -2
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/utilityTypes.d.ts +18 -0
- package/dist/tools/lib/utilityTypes.d.ts.map +1 -0
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +2 -2
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/worker/index.d.ts.map +1 -1
- package/dist/worker/index.js +2 -2
- package/dist/worker/index.js.map +1 -1
- package/package.json +5 -5
- package/src/browser/index.ts +2 -4
- package/src/browser-media-images/index.ts +1 -1
- package/src/react/hooks.tsx +2 -2
- package/src/react-core/hooks.ts +6 -6
- package/src/react-core/tests/useAccount.test.ts +2 -2
- package/src/react-core/tests/useCoState.test.ts +3 -2
- package/src/react-native-core/hooks.tsx +2 -2
- package/src/svelte/jazz.class.svelte.ts +10 -7
- package/src/svelte/jazz.svelte.ts +2 -2
- package/src/tools/coValues/CoValueBase.ts +8 -20
- package/src/tools/coValues/account.ts +18 -14
- package/src/tools/coValues/coFeed.ts +0 -4
- package/src/tools/coValues/coList.ts +7 -9
- package/src/tools/coValues/coMap.ts +5 -13
- package/src/tools/coValues/coPlainText.ts +4 -4
- package/src/tools/coValues/deepLoading.ts +4 -1
- package/src/tools/coValues/extensions/imageDef.ts +3 -3
- package/src/tools/coValues/inbox.ts +4 -4
- package/src/tools/coValues/interfaces.ts +4 -71
- package/src/tools/coValues/request.ts +17 -15
- package/src/tools/coValues/schemaUnion.ts +8 -4
- package/src/tools/exports.ts +3 -14
- package/src/tools/implementation/createContext.ts +9 -9
- package/src/tools/implementation/invites.ts +2 -2
- package/src/tools/implementation/schemaUtils.ts +18 -0
- package/src/tools/implementation/zodSchema/coExport.ts +14 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +156 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts +149 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +36 -17
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +101 -52
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +54 -50
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +54 -46
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +190 -161
- package/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts +29 -27
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +28 -18
- package/src/tools/implementation/zodSchema/schemaTypes/CoValueSchema.ts +18 -0
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +45 -36
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +47 -35
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +43 -30
- package/src/tools/implementation/zodSchema/typeConverters/CoFieldInit.ts +13 -0
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +30 -26
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +31 -28
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +89 -80
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.ts +95 -84
- package/src/tools/implementation/zodSchema/unionUtils.ts +47 -51
- package/src/tools/implementation/zodSchema/zodCo.ts +43 -76
- package/src/tools/implementation/zodSchema/zodReExport.ts +44 -24
- package/src/tools/implementation/zodSchema/zodSchema.ts +65 -103
- package/src/tools/internal.ts +3 -2
- package/src/tools/lib/utilityTypes.ts +16 -0
- package/src/tools/subscribe/utils.ts +4 -2
- package/src/tools/testing.ts +4 -4
- package/src/tools/tests/ContextManager.test.ts +8 -9
- package/src/tools/tests/account.test.ts +65 -3
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +38 -0
- package/src/tools/tests/coDiscriminatedUnion.test.ts +219 -1
- package/src/tools/tests/coFeed.test-d.ts +4 -3
- package/src/tools/tests/coFeed.test.ts +8 -6
- package/src/tools/tests/coList.test-d.ts +32 -3
- package/src/tools/tests/coList.test.ts +30 -2
- package/src/tools/tests/coMap.record.test-d.ts +31 -3
- package/src/tools/tests/coMap.record.test.ts +18 -9
- package/src/tools/tests/coMap.test-d.ts +36 -8
- package/src/tools/tests/coMap.test.ts +87 -6
- package/src/tools/tests/coOptional.test.ts +63 -1
- package/src/tools/tests/createContext.test.ts +7 -9
- package/src/tools/tests/deepLoading.test.ts +4 -10
- package/src/tools/tests/exportImport.test.ts +2 -2
- package/src/tools/tests/groupsAndAccounts.test.ts +5 -4
- package/src/tools/tests/inbox.test.ts +3 -2
- package/src/tools/tests/load.test.ts +3 -29
- package/src/tools/tests/schemaUnion.test.ts +2 -2
- package/src/tools/tests/subscribe.test.ts +22 -114
- package/src/tools/tests/testing.test.ts +6 -6
- package/src/tools/tests/zod.test-d.ts +27 -0
- package/src/tools/tests/zod.test.ts +88 -45
- package/src/worker/index.ts +0 -1
- package/dist/chunk-OSVAAVWQ.js.map +0 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts +0 -12
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.d.ts.map +0 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts +0 -9
- package/dist/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.d.ts.map +0 -1
- package/src/tools/implementation/zodSchema/runtimeConverters/zodFieldToCoFieldDef.ts +0 -172
- package/src/tools/implementation/zodSchema/runtimeConverters/zodSchemaToCoSchema.ts +0 -218
@@ -1,40 +1,31 @@
|
|
1
1
|
import { LocalNode, RawAccount } from "cojson";
|
2
|
-
import { Account, AccountClass, CoValueClass, CoValueFromRaw, InstanceOfSchema, RefsToResolve, RefsToResolveStrict, Resolved, Simplify } from "../../internal.js";
|
3
|
-
import { AccountSchema,
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
12
|
-
import {
|
2
|
+
import { Account, AccountClass, CoRecordSchema, CoValueClass, CoValueFromRaw, CoreCoRecordSchema, InstanceOfSchema, RefsToResolve, RefsToResolveStrict, Resolved, Simplify } from "../../internal.js";
|
3
|
+
import { AccountSchema, BaseAccountShape, CoreAccountSchema } from "./schemaTypes/AccountSchema.js";
|
4
|
+
import { CoDiscriminatedUnionSchema, CoreCoDiscriminatedUnionSchema } from "./schemaTypes/CoDiscriminatedUnionSchema.js";
|
5
|
+
import { CoFeedSchema, CoreCoFeedSchema } from "./schemaTypes/CoFeedSchema.js";
|
6
|
+
import { CoListSchema, CoreCoListSchema } from "./schemaTypes/CoListSchema.js";
|
7
|
+
import { CoMapSchema, CoMapSchemaInit, CoreCoMapSchema } from "./schemaTypes/CoMapSchema.js";
|
8
|
+
import { CoOptionalSchema, CoreCoOptionalSchema } from "./schemaTypes/CoOptionalSchema.js";
|
9
|
+
import { CoreCoValueSchema } from "./schemaTypes/CoValueSchema.js";
|
10
|
+
import { CoreFileStreamSchema, FileStreamSchema } from "./schemaTypes/FileStreamSchema.js";
|
11
|
+
import { CorePlainTextSchema, PlainTextSchema } from "./schemaTypes/PlainTextSchema.js";
|
12
|
+
import { CoreRichTextSchema, RichTextSchema } from "./schemaTypes/RichTextSchema.js";
|
13
13
|
import { InstanceOfSchemaCoValuesNullable } from "./typeConverters/InstanceOfSchemaCoValuesNullable.js";
|
14
14
|
import { z } from "./zodReExport.js";
|
15
|
-
export type WithHelpers<Base extends z.core.$ZodType, Helpers extends object> = Base & Helpers;
|
16
15
|
export type ZodPrimitiveSchema = z.core.$ZodString | z.core.$ZodNumber | z.core.$ZodBoolean | z.core.$ZodNull | z.core.$ZodDate | z.core.$ZodLiteral;
|
17
|
-
export type
|
18
|
-
|
19
|
-
|
20
|
-
export declare function isZodObject(schema: z.core.$ZodType): schema is z.ZodObject<any, any>;
|
21
|
-
export declare function isZodArray(schema: z.core.$ZodType): schema is z.core.$ZodArray<any>;
|
22
|
-
export declare function isZodCustom(schema: z.core.$ZodType): schema is z.core.$ZodCustom<any, any>;
|
23
|
-
export declare function getDef<S extends z.core.$ZodType>(schema: S): S["_zod"]["def"];
|
24
|
-
export type CoValueOrZodSchema = CoValueClass | AnyCoSchema;
|
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 : {});
|
16
|
+
export type CoValueClassOrSchema = CoValueClass | CoreCoValueSchema;
|
17
|
+
export type CoValueSchemaFromCoreSchema<S extends CoreCoValueSchema> = S extends CoreAccountSchema<infer Shape extends BaseAccountShape> ? AccountSchema<Shape> : S extends CoreCoRecordSchema<infer K, infer V> ? CoRecordSchema<K, V> : S extends CoreCoMapSchema<infer Shape, infer Config> ? CoMapSchema<Shape, Config> : S extends CoreCoListSchema<infer T> ? CoListSchema<T> : S extends CoreCoFeedSchema<infer T> ? CoFeedSchema<T> : S extends CorePlainTextSchema ? PlainTextSchema : S extends CoreRichTextSchema ? RichTextSchema : S extends CoreFileStreamSchema ? FileStreamSchema : S extends CoreCoOptionalSchema<infer Inner> ? CoOptionalSchema<Inner> : S extends CoreCoDiscriminatedUnionSchema<infer Members> ? CoDiscriminatedUnionSchema<Members> : never;
|
18
|
+
export type CoValueClassFromAnySchema<S extends CoValueClassOrSchema> = S extends CoValueClass<any> ? S : CoValueClass<InstanceOfSchema<S>> & CoValueFromRaw<InstanceOfSchema<S>> & (S extends CoreAccountSchema ? AccountClassEssentials : {});
|
30
19
|
type AccountClassEssentials = {
|
31
20
|
fromRaw: <A extends Account>(this: AccountClass<A>, raw: RawAccount) => A;
|
32
21
|
fromNode: <A extends Account>(this: AccountClass<A>, node: LocalNode) => A;
|
33
22
|
};
|
34
|
-
export type
|
35
|
-
|
36
|
-
export type
|
37
|
-
export type
|
38
|
-
export type
|
23
|
+
export type AnyCoreCoValueSchema = CoreCoMapSchema | CoreAccountSchema | CoreCoRecordSchema | CoreCoListSchema | CoreCoFeedSchema | CoreCoDiscriminatedUnionSchema<any> | CoreCoOptionalSchema | CorePlainTextSchema | CoreRichTextSchema | CoreFileStreamSchema;
|
24
|
+
type AnyZodSchema = z.core.$ZodType;
|
25
|
+
export type AnyZodOrCoValueSchema = AnyZodSchema | CoreCoValueSchema;
|
26
|
+
export type Loaded<T extends CoValueClassOrSchema, R extends ResolveQuery<T> = true> = Resolved<NonNullable<InstanceOfSchemaCoValuesNullable<T>>, R>;
|
27
|
+
export type ResolveQuery<T extends CoValueClassOrSchema> = RefsToResolve<NonNullable<InstanceOfSchemaCoValuesNullable<T>>>;
|
28
|
+
export type ResolveQueryStrict<T extends CoValueClassOrSchema, R extends ResolveQuery<T>> = RefsToResolveStrict<NonNullable<InstanceOfSchemaCoValuesNullable<T>>, R>;
|
29
|
+
export type InitFor<T extends CoValueClassOrSchema> = T extends CoreCoMapSchema<infer Shape> ? Simplify<CoMapSchemaInit<Shape>> : never;
|
39
30
|
export {};
|
40
31
|
//# sourceMappingURL=zodSchema.d.ts.map
|
@@ -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,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,
|
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,cAAc,EACd,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,eAAe,EACf,eAAe,EAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,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AAS,YAAY,CAAC,CAAC,CAAC,IACvB,mBAAmB,CAAC,WAAW,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7E,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,oBAAoB,IAAI,CAAC,SAAS,eAAe,CAC7E,MAAM,KAAK,CACZ,GACG,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAChC,KAAK,CAAC"}
|
package/dist/tools/internal.d.ts
CHANGED
@@ -23,6 +23,7 @@ export * from "./subscribe/SubscriptionScope.js";
|
|
23
23
|
export * from "./subscribe/types.js";
|
24
24
|
export * from "./subscribe/index.js";
|
25
25
|
export * from "./lib/cache.js";
|
26
|
+
export * from "./lib/utilityTypes.js";
|
26
27
|
export * from "./implementation/createContext.js";
|
27
28
|
export * from "./types.js";
|
28
29
|
export * from "./implementation/zodSchema/zodSchema.js";
|
@@ -40,8 +41,8 @@ export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSc
|
|
40
41
|
export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.js";
|
41
42
|
export * from "./implementation/zodSchema/typeConverters/InstanceOfSchema.js";
|
42
43
|
export * from "./implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.js";
|
43
|
-
export * from "./implementation/zodSchema/runtimeConverters/
|
44
|
-
export * from "./implementation/zodSchema/runtimeConverters/
|
44
|
+
export * from "./implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.js";
|
45
|
+
export * from "./implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.js";
|
45
46
|
export * from "./coValues/extensions/imageDef.js";
|
46
47
|
export * from "./implementation/ContextManager.js";
|
47
48
|
import "./implementation/devtoolsFormatters.js";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/tools/internal.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC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;AAElD,cAAc,oCAAoC,CAAC;AAEnD,OAAO,wCAAwC,CAAC"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Make any property optional if its type includes `undefined`, preserving the type as-is
|
3
|
+
*/
|
4
|
+
export type PartialOnUndefined<T> = {
|
5
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
6
|
+
} & {
|
7
|
+
[K in keyof T as undefined extends T[K] ? K : never]?: T[K];
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* Useful to flatten the type output to improve type hints shown in editors.
|
11
|
+
* And also to transform an interface into a type to aide with assignability.
|
12
|
+
*
|
13
|
+
* Taken from https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
14
|
+
*/
|
15
|
+
export type Simplify<T> = {
|
16
|
+
[KeyType in keyof T]: T[KeyType];
|
17
|
+
} & {};
|
18
|
+
//# sourceMappingURL=utilityTypes.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utilityTypes.d.ts","sourceRoot":"","sources":["../../../src/tools/lib/utilityTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;KACjC,CAAC,IAAI,MAAM,CAAC,IAAI,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC3D,GAAG;KACD,CAAC,IAAI,MAAM,CAAC,IAAI,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CAAE,GAAG,EAAE,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EACL,OAAO,EACP,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/subscribe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EACL,OAAO,EACP,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,qEAUnD;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,OAAO,EAC7C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAClB,GAAG,EAAE,UAAU,EACf,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;;;;EAgBxC"}
|
package/dist/tools/testing.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { LocalNode } from "cojson";
|
2
2
|
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
3
|
-
import { Account, AccountClass, type AnonymousJazzAgent,
|
3
|
+
import { Account, AccountClass, type AnonymousJazzAgent, CoValueFromRaw, CoreAccountSchema, InstanceOfSchema, JazzContextManager, JazzContextManagerAuthProps, JazzContextManagerBaseProps } from "./internal.js";
|
4
4
|
export declare class TestJSCrypto extends PureJSCrypto {
|
5
5
|
static create(): Promise<PureJSCrypto>;
|
6
6
|
}
|
7
7
|
export declare function getPeerConnectedToTestSyncServer(): import("cojson").Peer;
|
8
|
-
export declare function createJazzTestAccount<S extends (AccountClass<Account> & CoValueFromRaw<Account>) |
|
8
|
+
export declare function createJazzTestAccount<S extends (AccountClass<Account> & CoValueFromRaw<Account>) | CoreAccountSchema>(options?: {
|
9
9
|
isCurrentActiveAccount?: boolean;
|
10
10
|
AccountSchema?: S;
|
11
11
|
creationProps?: Record<string, unknown>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/tools/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,KAAK,kBAAkB,
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/tools/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,KAAK,kBAAkB,EAEvB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAM5B,MAAM,eAAe,CAAC;AAOvB,qBAAa,YAAa,SAAQ,YAAY;WAC/B,MAAM;CAoBpB;AAED,wBAAgB,gCAAgC,0BAiC/C;AAKD,wBAAsB,qBAAqB,CACzC,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,iBAAiB,EACrB,OAAO,CAAC,EAAE;IACV,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAuD/B;AAED,wBAAgB,gBAAgB,CAAC,OA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,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,oBAgB/B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAmB,MAAM,QAAQ,CAAC;AACtE,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,OAAO,EACP,YAAY,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAmB,MAAM,QAAQ,CAAC;AACtE,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,KAAK,EACL,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAEpB,KAAK,aAAa,CAChB,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,IAClB;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,iCAAiC;AACjC,wBAAsB,WAAW,CAC/B,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,EACpB,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;YA0EI,gBAAgB,CAAC,CAAC,CAAC;;;uBAJJ,KAAK,CAAC,WAAW,CAAC;;;;0CAWtB,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;GASrE"}
|
package/dist/worker/index.js
CHANGED
@@ -14,7 +14,7 @@ async function startWorker(options) {
|
|
14
14
|
accountID = process.env.JAZZ_WORKER_ACCOUNT,
|
15
15
|
accountSecret = process.env.JAZZ_WORKER_SECRET,
|
16
16
|
syncServer = "wss://cloud.jazz.tools",
|
17
|
-
AccountSchema
|
17
|
+
AccountSchema = Account
|
18
18
|
} = options;
|
19
19
|
let node = void 0;
|
20
20
|
const peersToLoadFrom = [];
|
@@ -50,7 +50,7 @@ async function startWorker(options) {
|
|
50
50
|
accountID,
|
51
51
|
secret: accountSecret
|
52
52
|
},
|
53
|
-
AccountSchema
|
53
|
+
AccountSchema,
|
54
54
|
// TODO: locked sessions similar to browser
|
55
55
|
sessionProvider: randomSessionProvider,
|
56
56
|
peersToLoadFrom,
|
package/dist/worker/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/worker/index.ts"],"sourcesContent":["import { AgentSecret, CryptoProvider, LocalNode, Peer } from \"cojson\";\nimport {\n type AnyWebSocketConstructor,\n WebSocketPeerWithReconnection,\n} from \"cojson-transport-ws\";\nimport { WasmCrypto } from \"cojson/crypto/WasmCrypto\";\nimport {\n Account,\n AccountClass,\n
|
1
|
+
{"version":3,"sources":["../../src/worker/index.ts"],"sourcesContent":["import { AgentSecret, CryptoProvider, LocalNode, Peer } from \"cojson\";\nimport {\n type AnyWebSocketConstructor,\n WebSocketPeerWithReconnection,\n} from \"cojson-transport-ws\";\nimport { WasmCrypto } from \"cojson/crypto/WasmCrypto\";\nimport {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueFromRaw,\n Inbox,\n InstanceOfSchema,\n createJazzContextFromExistingCredentials,\n randomSessionProvider,\n} from \"jazz-tools\";\n\ntype WorkerOptions<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n accountID?: string;\n accountSecret?: string;\n syncServer?: string;\n WebSocket?: AnyWebSocketConstructor;\n AccountSchema?: S;\n crypto?: CryptoProvider;\n};\n\n/** @category Context Creation */\nexport async function startWorker<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n>(options: WorkerOptions<S>) {\n const {\n accountID = process.env.JAZZ_WORKER_ACCOUNT,\n accountSecret = process.env.JAZZ_WORKER_SECRET,\n syncServer = \"wss://cloud.jazz.tools\",\n AccountSchema = Account as unknown as S,\n } = options;\n\n let node: LocalNode | undefined = undefined;\n\n const peersToLoadFrom: Peer[] = [];\n\n const wsPeer = new WebSocketPeerWithReconnection({\n peer: syncServer,\n reconnectionTimeout: 100,\n addPeer: (peer) => {\n if (node) {\n node.syncManager.addPeer(peer);\n } else {\n peersToLoadFrom.push(peer);\n }\n },\n removePeer: () => {},\n WebSocketConstructor: options.WebSocket,\n });\n\n wsPeer.enable();\n\n if (!accountID) {\n throw new Error(\"No accountID provided\");\n }\n if (!accountSecret) {\n throw new Error(\"No accountSecret provided\");\n }\n if (!accountID.startsWith(\"co_\")) {\n throw new Error(\"Invalid accountID\");\n }\n if (!accountSecret?.startsWith(\"sealerSecret_\")) {\n throw new Error(\"Invalid accountSecret\");\n }\n\n const context = await createJazzContextFromExistingCredentials({\n credentials: {\n accountID: accountID,\n secret: accountSecret as AgentSecret,\n },\n AccountSchema,\n // TODO: locked sessions similar to browser\n sessionProvider: randomSessionProvider,\n peersToLoadFrom,\n crypto: options.crypto ?? (await WasmCrypto.create()),\n });\n\n const account = context.account as InstanceOfSchema<S>;\n node = account._raw.core.node;\n\n if (!account._refs.profile?.id) {\n throw new Error(\"Account has no profile\");\n }\n\n const inbox = await Inbox.load(account);\n\n async function done() {\n await context.account.waitForAllCoValuesSync();\n\n wsPeer.disable();\n context.done();\n }\n\n const inboxPublicApi = {\n subscribe: inbox.subscribe.bind(inbox) as Inbox[\"subscribe\"],\n };\n\n return {\n worker: context.account as InstanceOfSchema<S>,\n experimental: {\n inbox: inboxPublicApi,\n },\n waitForConnection() {\n return wsPeer.waitUntilConnected();\n },\n subscribeToConnectionChange(listener: (connected: boolean) => void) {\n wsPeer.subscribe(listener);\n\n return () => {\n wsPeer.unsubscribe(listener);\n };\n },\n done,\n };\n}\n"],"mappings":";AACA;AAAA,EAEE;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EAIA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAgBP,eAAsB,YAIpB,SAA2B;AAC3B,QAAM;AAAA,IACJ,YAAY,QAAQ,IAAI;AAAA,IACxB,gBAAgB,QAAQ,IAAI;AAAA,IAC5B,aAAa;AAAA,IACb,gBAAgB;AAAA,EAClB,IAAI;AAEJ,MAAI,OAA8B;AAElC,QAAM,kBAA0B,CAAC;AAEjC,QAAM,SAAS,IAAI,8BAA8B;AAAA,IAC/C,MAAM;AAAA,IACN,qBAAqB;AAAA,IACrB,SAAS,CAAC,SAAS;AACjB,UAAI,MAAM;AACR,aAAK,YAAY,QAAQ,IAAI;AAAA,MAC/B,OAAO;AACL,wBAAgB,KAAK,IAAI;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,YAAY,MAAM;AAAA,IAAC;AAAA,IACnB,sBAAsB,QAAQ;AAAA,EAChC,CAAC;AAED,SAAO,OAAO;AAEd,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC;AACA,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,MAAI,CAAC,UAAU,WAAW,KAAK,GAAG;AAChC,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACrC;AACA,MAAI,CAAC,eAAe,WAAW,eAAe,GAAG;AAC/C,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC;AAEA,QAAM,UAAU,MAAM,yCAAyC;AAAA,IAC7D,aAAa;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,IACV;AAAA,IACA;AAAA;AAAA,IAEA,iBAAiB;AAAA,IACjB;AAAA,IACA,QAAQ,QAAQ,UAAW,MAAM,WAAW,OAAO;AAAA,EACrD,CAAC;AAED,QAAM,UAAU,QAAQ;AACxB,SAAO,QAAQ,KAAK,KAAK;AAEzB,MAAI,CAAC,QAAQ,MAAM,SAAS,IAAI;AAC9B,UAAM,IAAI,MAAM,wBAAwB;AAAA,EAC1C;AAEA,QAAM,QAAQ,MAAM,MAAM,KAAK,OAAO;AAEtC,iBAAe,OAAO;AACpB,UAAM,QAAQ,QAAQ,uBAAuB;AAE7C,WAAO,QAAQ;AACf,YAAQ,KAAK;AAAA,EACf;AAEA,QAAM,iBAAiB;AAAA,IACrB,WAAW,MAAM,UAAU,KAAK,KAAK;AAAA,EACvC;AAEA,SAAO;AAAA,IACL,QAAQ,QAAQ;AAAA,IAChB,cAAc;AAAA,MACZ,OAAO;AAAA,IACT;AAAA,IACA,oBAAoB;AAClB,aAAO,OAAO,mBAAmB;AAAA,IACnC;AAAA,IACA,4BAA4B,UAAwC;AAClE,aAAO,UAAU,QAAQ;AAEzB,aAAO,MAAM;AACX,eAAO,YAAY,QAAQ;AAAA,MAC7B;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
@@ -139,7 +139,7 @@
|
|
139
139
|
},
|
140
140
|
"type": "module",
|
141
141
|
"license": "MIT",
|
142
|
-
"version": "0.
|
142
|
+
"version": "0.16.1",
|
143
143
|
"dependencies": {
|
144
144
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
145
145
|
"@scure/base": "1.2.1",
|
@@ -157,10 +157,10 @@
|
|
157
157
|
"prosemirror-schema-basic": "^1.2.2",
|
158
158
|
"prosemirror-state": "^1.4.3",
|
159
159
|
"prosemirror-transform": "^1.9.0",
|
160
|
-
"zod": "3.25.
|
161
|
-
"cojson": "0.
|
162
|
-
"cojson-storage-indexeddb": "0.
|
163
|
-
"cojson-transport-ws": "0.
|
160
|
+
"zod": "3.25.76",
|
161
|
+
"cojson": "0.16.1",
|
162
|
+
"cojson-storage-indexeddb": "0.16.1",
|
163
|
+
"cojson-transport-ws": "0.16.1"
|
164
164
|
},
|
165
165
|
"devDependencies": {
|
166
166
|
"@scure/bip39": "^1.3.0",
|
package/src/browser/index.ts
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
Account,
|
3
3
|
CoValue,
|
4
|
-
|
5
|
-
CoValueOrZodSchema,
|
6
|
-
ID,
|
4
|
+
CoValueClassOrSchema,
|
7
5
|
InviteSecret,
|
8
6
|
createInviteLink as baseCreateInviteLink,
|
9
7
|
consumeInviteLink,
|
@@ -36,7 +34,7 @@ export { parseInviteLink } from "jazz-tools";
|
|
36
34
|
|
37
35
|
/** @category Invite Links */
|
38
36
|
export async function consumeInviteLinkFromWindowLocation<
|
39
|
-
S extends
|
37
|
+
S extends CoValueClassOrSchema,
|
40
38
|
>({
|
41
39
|
as,
|
42
40
|
forValueHint,
|
@@ -17,7 +17,7 @@ export async function createImage(
|
|
17
17
|
owner?: Group | Account;
|
18
18
|
maxSize?: 256 | 1024 | 2048;
|
19
19
|
},
|
20
|
-
): Promise<Loaded<typeof ImageDefinition>> {
|
20
|
+
): Promise<Loaded<typeof ImageDefinition, { $each: true }>> {
|
21
21
|
// Get the original size of the image
|
22
22
|
const { width: originalWidth, height: originalHeight } =
|
23
23
|
await getImageSize(imageBlobOrFile);
|
package/src/react/hooks.tsx
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { consumeInviteLinkFromWindowLocation } from "jazz-tools/browser";
|
2
2
|
import { useEffect } from "react";
|
3
3
|
|
4
|
-
import {
|
4
|
+
import { CoValueClassOrSchema } from "jazz-tools";
|
5
5
|
import { useJazzContext } from "jazz-tools/react-core";
|
6
6
|
|
7
7
|
export { useCoState, useAuthSecretStorage } from "jazz-tools/react-core";
|
8
8
|
|
9
|
-
export function useAcceptInvite<S extends
|
9
|
+
export function useAcceptInvite<S extends CoValueClassOrSchema>({
|
10
10
|
invitedObjectSchema,
|
11
11
|
onAccept,
|
12
12
|
forValueHint,
|
package/src/react-core/hooks.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
AnonymousJazzAgent,
|
12
12
|
AnyAccountSchema,
|
13
13
|
CoValue,
|
14
|
-
|
14
|
+
CoValueClassOrSchema,
|
15
15
|
InboxSender,
|
16
16
|
InstanceOfSchema,
|
17
17
|
JazzContextManager,
|
@@ -20,7 +20,7 @@ import {
|
|
20
20
|
ResolveQuery,
|
21
21
|
ResolveQueryStrict,
|
22
22
|
SubscriptionScope,
|
23
|
-
|
23
|
+
coValueClassFromCoValueClassOrSchema,
|
24
24
|
} from "jazz-tools";
|
25
25
|
import { JazzContext, JazzContextManagerContext } from "./provider.js";
|
26
26
|
import { getCurrentAccountFromContextManager } from "./utils.js";
|
@@ -80,7 +80,7 @@ export function useIsAuthenticated() {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
function useCoValueSubscription<
|
83
|
-
S extends
|
83
|
+
S extends CoValueClassOrSchema,
|
84
84
|
const R extends ResolveQuery<S>,
|
85
85
|
>(
|
86
86
|
Schema: S,
|
@@ -107,7 +107,7 @@ function useCoValueSubscription<
|
|
107
107
|
options?.resolve ?? true,
|
108
108
|
id,
|
109
109
|
{
|
110
|
-
ref:
|
110
|
+
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
111
111
|
optional: true,
|
112
112
|
},
|
113
113
|
);
|
@@ -142,7 +142,7 @@ function useCoValueSubscription<
|
|
142
142
|
}
|
143
143
|
|
144
144
|
export function useCoState<
|
145
|
-
S extends
|
145
|
+
S extends CoValueClassOrSchema,
|
146
146
|
const R extends ResolveQuery<S> = true,
|
147
147
|
>(
|
148
148
|
Schema: S,
|
@@ -198,7 +198,7 @@ function useAccountSubscription<
|
|
198
198
|
|
199
199
|
const node = contextManager.getCurrentValue()!.node;
|
200
200
|
const subscription = new SubscriptionScope<any>(node, resolve, agent.id, {
|
201
|
-
ref:
|
201
|
+
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
202
202
|
optional: true,
|
203
203
|
});
|
204
204
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// @vitest-environment happy-dom
|
2
2
|
|
3
|
-
import { RefsToResolve, co, z
|
3
|
+
import { RefsToResolve, co, z } from "jazz-tools";
|
4
4
|
import { beforeEach, describe, expect, it } from "vitest";
|
5
5
|
import { useAccount, useJazzContextManager } from "../hooks.js";
|
6
6
|
import { useIsAuthenticated } from "../index.js";
|
@@ -46,7 +46,7 @@ describe("useAccount", () => {
|
|
46
46
|
});
|
47
47
|
|
48
48
|
const account = await createJazzTestAccount({
|
49
|
-
AccountSchema
|
49
|
+
AccountSchema,
|
50
50
|
});
|
51
51
|
|
52
52
|
const { result } = renderHook(
|
@@ -520,12 +520,13 @@ describe("useCoState", () => {
|
|
520
520
|
const Message = co.map({
|
521
521
|
content: CoRichText,
|
522
522
|
});
|
523
|
+
const Messages = co.list(Message);
|
523
524
|
const Thread = co.map({
|
524
|
-
messages:
|
525
|
+
messages: Messages,
|
525
526
|
});
|
526
527
|
|
527
528
|
const thread = Thread.create({
|
528
|
-
messages:
|
529
|
+
messages: Messages.create([
|
529
530
|
Message.create({
|
530
531
|
content: CoRichText.create("Hello man!"),
|
531
532
|
}),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useEffect } from "react";
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { CoValueClassOrSchema, parseInviteLink } from "jazz-tools";
|
4
4
|
import { useJazzContext } from "jazz-tools/react-core";
|
5
5
|
import { Linking } from "react-native";
|
6
6
|
|
@@ -15,7 +15,7 @@ export {
|
|
15
15
|
useAccount,
|
16
16
|
} from "jazz-tools/react-core";
|
17
17
|
|
18
|
-
export function useAcceptInviteNative<S extends
|
18
|
+
export function useAcceptInviteNative<S extends CoValueClassOrSchema>({
|
19
19
|
invitedObjectSchema,
|
20
20
|
onAccept,
|
21
21
|
forValueHint,
|
@@ -2,21 +2,24 @@ import type {
|
|
2
2
|
Account,
|
3
3
|
AccountClass,
|
4
4
|
AnyAccountSchema,
|
5
|
+
CoValueClassOrSchema,
|
5
6
|
CoValueFromRaw,
|
6
|
-
CoValueOrZodSchema,
|
7
7
|
InstanceOfSchema,
|
8
8
|
Loaded,
|
9
9
|
ResolveQuery,
|
10
10
|
ResolveQueryStrict,
|
11
11
|
} from "jazz-tools";
|
12
|
-
import {
|
12
|
+
import {
|
13
|
+
coValueClassFromCoValueClassOrSchema,
|
14
|
+
subscribeToCoValue,
|
15
|
+
} from "jazz-tools";
|
13
16
|
import { untrack } from "svelte";
|
14
17
|
import { createSubscriber } from "svelte/reactivity";
|
15
18
|
import { useIsAuthenticated } from "./auth/useIsAuthenticated.svelte.js";
|
16
19
|
import { getJazzContext } from "./jazz.svelte";
|
17
20
|
|
18
21
|
export class CoState<
|
19
|
-
V extends
|
22
|
+
V extends CoValueClassOrSchema,
|
20
23
|
R extends ResolveQuery<V> = true,
|
21
24
|
> {
|
22
25
|
#value: Loaded<V, R> | undefined | null = undefined;
|
@@ -47,10 +50,10 @@ export class CoState<
|
|
47
50
|
const agent = "me" in ctx ? ctx.me : ctx.guest;
|
48
51
|
|
49
52
|
const unsubscribe = subscribeToCoValue(
|
50
|
-
|
53
|
+
coValueClassFromCoValueClassOrSchema(Schema),
|
51
54
|
id,
|
52
55
|
{
|
53
|
-
// @ts-expect-error The resolve query type isn't compatible with the
|
56
|
+
// @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
|
54
57
|
resolve: options?.resolve,
|
55
58
|
loadAs: agent,
|
56
59
|
onUnavailable: () => {
|
@@ -112,10 +115,10 @@ export class AccountCoState<
|
|
112
115
|
const me = ctx.me;
|
113
116
|
|
114
117
|
const unsubscribe = subscribeToCoValue(
|
115
|
-
|
118
|
+
coValueClassFromCoValueClassOrSchema(Schema),
|
116
119
|
me.id,
|
117
120
|
{
|
118
|
-
// @ts-expect-error The resolve query type isn't compatible with the
|
121
|
+
// @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
|
119
122
|
resolve: options?.resolve,
|
120
123
|
loadAs: me,
|
121
124
|
onUnavailable: () => {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type {
|
2
2
|
AccountClass,
|
3
3
|
AuthSecretStorage,
|
4
|
-
|
4
|
+
CoValueClassOrSchema,
|
5
5
|
ID,
|
6
6
|
InstanceOfSchema,
|
7
7
|
JazzContextType,
|
@@ -66,7 +66,7 @@ export function getAuthSecretStorage() {
|
|
66
66
|
* @param forValueHint - Hint for the value.
|
67
67
|
* @returns The accept invite hook.
|
68
68
|
*/
|
69
|
-
export class InviteListener<V extends
|
69
|
+
export class InviteListener<V extends CoValueClassOrSchema> {
|
70
70
|
constructor({
|
71
71
|
invitedObjectSchema,
|
72
72
|
onAccept,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ControlledAccount, RawAccount, type RawCoValue } from "cojson";
|
2
|
-
import {
|
2
|
+
import { CoreCoValueSchema } from "../implementation/zodSchema/schemaTypes/CoValueSchema.js";
|
3
3
|
import {
|
4
4
|
AnonymousJazzAgent,
|
5
5
|
CoValue,
|
@@ -8,13 +8,14 @@ import {
|
|
8
8
|
ID,
|
9
9
|
RegisteredSchemas,
|
10
10
|
accessChildById,
|
11
|
-
|
11
|
+
coValueClassFromCoValueClassOrSchema,
|
12
12
|
coValuesCache,
|
13
13
|
inspect,
|
14
14
|
isCoValueSchema,
|
15
15
|
} from "../internal.js";
|
16
16
|
import type {
|
17
17
|
Account,
|
18
|
+
CoValueClassOrSchema,
|
18
19
|
Group,
|
19
20
|
InstanceOfSchemaCoValuesNullable,
|
20
21
|
} from "../internal.js";
|
@@ -46,9 +47,9 @@ export class CoValueBase implements CoValue {
|
|
46
47
|
|
47
48
|
if (agent instanceof ControlledAccount) {
|
48
49
|
return coValuesCache.get(agent.account, () =>
|
49
|
-
|
50
|
-
|
51
|
-
),
|
50
|
+
coValueClassFromCoValueClassOrSchema(
|
51
|
+
RegisteredSchemas["Account"],
|
52
|
+
).fromRaw(agent.account),
|
52
53
|
);
|
53
54
|
}
|
54
55
|
|
@@ -81,24 +82,11 @@ export class CoValueBase implements CoValue {
|
|
81
82
|
}
|
82
83
|
|
83
84
|
/** @category Type Helpers */
|
84
|
-
castAs<
|
85
|
-
S extends
|
86
|
-
| CoValueClass
|
87
|
-
| z.core.$ZodType
|
88
|
-
| (z.core.$ZodObject<any, any> & {
|
89
|
-
builtin: "Account";
|
90
|
-
migration?: (account: any, creationProps?: { name: string }) => void;
|
91
|
-
})
|
92
|
-
| (z.core.$ZodCustom<any, any> & { builtin: "FileStream" })
|
93
|
-
| (z.core.$ZodCustom<any, any> & {
|
94
|
-
builtin: "CoFeed";
|
95
|
-
element: z.core.$ZodType;
|
96
|
-
}),
|
97
|
-
>(
|
85
|
+
castAs<S extends CoValueClassOrSchema>(
|
98
86
|
schema: S,
|
99
87
|
): S extends CoValueClass
|
100
88
|
? InstanceType<S>
|
101
|
-
: S extends
|
89
|
+
: S extends CoreCoValueSchema
|
102
90
|
? NonNullable<InstanceOfSchemaCoValuesNullable<S>>
|
103
91
|
: never {
|
104
92
|
const cl = isCoValueSchema(schema) ? schema.getCoValueClass() : schema;
|
@@ -16,12 +16,12 @@ import {
|
|
16
16
|
} from "cojson";
|
17
17
|
import {
|
18
18
|
AnonymousJazzAgent,
|
19
|
-
AnyAccountSchema,
|
20
19
|
type CoMap,
|
21
20
|
type CoValue,
|
22
21
|
CoValueBase,
|
23
22
|
CoValueClass,
|
24
|
-
|
23
|
+
CoValueClassOrSchema,
|
24
|
+
CoreAccountSchema,
|
25
25
|
type Group,
|
26
26
|
ID,
|
27
27
|
InstanceOfSchema,
|
@@ -40,7 +40,7 @@ import {
|
|
40
40
|
SubscribeRestArgs,
|
41
41
|
accessChildByKey,
|
42
42
|
activeAccountContext,
|
43
|
-
|
43
|
+
coValueClassFromCoValueClassOrSchema,
|
44
44
|
coValuesCache,
|
45
45
|
createInboxRoot,
|
46
46
|
ensureCoValueLoaded,
|
@@ -254,7 +254,7 @@ export class Account extends CoValueBase implements CoValue {
|
|
254
254
|
return value._owner.getRoleOf(this.id) === "admin";
|
255
255
|
}
|
256
256
|
|
257
|
-
async acceptInvite<S extends
|
257
|
+
async acceptInvite<S extends CoValueClassOrSchema>(
|
258
258
|
valueID: string,
|
259
259
|
inviteSecret: InviteSecret,
|
260
260
|
coValueClass: S,
|
@@ -268,9 +268,13 @@ export class Account extends CoValueBase implements CoValue {
|
|
268
268
|
inviteSecret,
|
269
269
|
);
|
270
270
|
|
271
|
-
return loadCoValue(
|
272
|
-
|
273
|
-
|
271
|
+
return loadCoValue(
|
272
|
+
coValueClassFromCoValueClassOrSchema(coValueClass),
|
273
|
+
valueID,
|
274
|
+
{
|
275
|
+
loadAs: this,
|
276
|
+
},
|
277
|
+
) as Resolved<InstanceOrPrimitiveOfSchema<S>, true> | null;
|
274
278
|
}
|
275
279
|
|
276
280
|
/** @private */
|
@@ -447,9 +451,7 @@ export class Account extends CoValueBase implements CoValue {
|
|
447
451
|
*
|
448
452
|
* @category Subscription & Loading
|
449
453
|
*/
|
450
|
-
waitForSync(options?: {
|
451
|
-
timeout?: number;
|
452
|
-
}) {
|
454
|
+
waitForSync(options?: { timeout?: number }) {
|
453
455
|
return this._raw.core.waitForSync(options);
|
454
456
|
}
|
455
457
|
|
@@ -458,9 +460,7 @@ export class Account extends CoValueBase implements CoValue {
|
|
458
460
|
*
|
459
461
|
* @category Subscription & Loading
|
460
462
|
*/
|
461
|
-
waitForAllCoValuesSync(options?: {
|
462
|
-
timeout?: number;
|
463
|
-
}) {
|
463
|
+
waitForAllCoValuesSync(options?: { timeout?: number }) {
|
464
464
|
return this._raw.core.node.syncManager.waitForAllCoValuesSync(
|
465
465
|
options?.timeout,
|
466
466
|
);
|
@@ -502,7 +502,11 @@ export const AccountAndGroupProxyHandler: ProxyHandler<Account | Group> = {
|
|
502
502
|
return true;
|
503
503
|
} else if (key === "root") {
|
504
504
|
if (value) {
|
505
|
-
target._raw.set(
|
505
|
+
target._raw.set(
|
506
|
+
"root",
|
507
|
+
value.id as unknown as CoID<RawCoMap>,
|
508
|
+
"trusting",
|
509
|
+
);
|
506
510
|
}
|
507
511
|
return true;
|
508
512
|
} else {
|