jazz-tools 0.18.25 → 0.18.26

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.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +44 -44
  2. package/CHANGELOG.md +10 -0
  3. package/dist/{chunk-DOCEAUVD.js → chunk-ZIAN4UY5.js} +338 -9
  4. package/dist/chunk-ZIAN4UY5.js.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/testing.js +1 -1
  7. package/dist/tools/coValues/coVector.d.ts +127 -0
  8. package/dist/tools/coValues/coVector.d.ts.map +1 -0
  9. package/dist/tools/implementation/zodSchema/coExport.d.ts +2 -1
  10. package/dist/tools/implementation/zodSchema/coExport.d.ts.map +1 -1
  11. package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
  12. package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +47 -0
  13. package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -0
  14. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +2 -2
  15. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
  16. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +2 -2
  17. package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
  18. package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -1
  19. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  20. package/dist/tools/implementation/zodSchema/zodSchema.d.ts +3 -2
  21. package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
  22. package/dist/tools/internal.d.ts +2 -0
  23. package/dist/tools/internal.d.ts.map +1 -1
  24. package/dist/tools/tests/coVector.test-d.d.ts +2 -0
  25. package/dist/tools/tests/coVector.test-d.d.ts.map +1 -0
  26. package/dist/tools/tests/coVector.test.d.ts +2 -0
  27. package/dist/tools/tests/coVector.test.d.ts.map +1 -0
  28. package/package.json +4 -4
  29. package/src/tools/coValues/coVector.ts +432 -0
  30. package/src/tools/implementation/zodSchema/coExport.ts +2 -0
  31. package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +13 -0
  32. package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +105 -0
  33. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +9 -5
  34. package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +15 -9
  35. package/src/tools/implementation/zodSchema/zodCo.ts +15 -0
  36. package/src/tools/implementation/zodSchema/zodSchema.ts +15 -6
  37. package/src/tools/internal.ts +2 -0
  38. package/src/tools/tests/coVector.test-d.ts +40 -0
  39. package/src/tools/tests/coVector.test.ts +891 -0
  40. package/dist/chunk-DOCEAUVD.js.map +0 -1
@@ -33,6 +33,10 @@ import {
33
33
  CoreFileStreamSchema,
34
34
  FileStreamSchema,
35
35
  } from "./schemaTypes/FileStreamSchema.js";
36
+ import {
37
+ CoreCoVectorSchema,
38
+ CoVectorSchema,
39
+ } from "./schemaTypes/CoVectorSchema.js";
36
40
  import {
37
41
  CorePlainTextSchema,
38
42
  PlainTextSchema,
@@ -75,11 +79,15 @@ export type CoValueSchemaFromCoreSchema<S extends CoreCoValueSchema> =
75
79
  ? RichTextSchema
76
80
  : S extends CoreFileStreamSchema
77
81
  ? FileStreamSchema
78
- : S extends CoreCoOptionalSchema<infer Inner>
79
- ? CoOptionalSchema<Inner>
80
- : S extends CoreCoDiscriminatedUnionSchema<infer Members>
81
- ? CoDiscriminatedUnionSchema<Members>
82
- : never;
82
+ : S extends CoreCoVectorSchema
83
+ ? CoVectorSchema
84
+ : S extends CoreCoOptionalSchema<infer Inner>
85
+ ? CoOptionalSchema<Inner>
86
+ : S extends CoreCoDiscriminatedUnionSchema<
87
+ infer Members
88
+ >
89
+ ? CoDiscriminatedUnionSchema<Members>
90
+ : never;
83
91
 
84
92
  export type CoValueClassFromAnySchema<S extends CoValueClassOrSchema> =
85
93
  S extends CoValueClass<any>
@@ -104,7 +112,8 @@ export type AnyCoreCoValueSchema =
104
112
  | CoreCoOptionalSchema
105
113
  | CorePlainTextSchema
106
114
  | CoreRichTextSchema
107
- | CoreFileStreamSchema;
115
+ | CoreFileStreamSchema
116
+ | CoreCoVectorSchema;
108
117
 
109
118
  export type AnyZodSchema = z.core.$ZodType;
110
119
 
@@ -16,6 +16,7 @@ export * from "./coValues/inbox.js";
16
16
  export * from "./coValues/coPlainText.js";
17
17
  export * from "./coValues/coRichText.js";
18
18
  export * from "./coValues/schemaUnion.js";
19
+ export * from "./coValues/coVector.js";
19
20
 
20
21
  export type * from "./subscribe/types.js";
21
22
 
@@ -43,6 +44,7 @@ export * from "./implementation/zodSchema/schemaTypes/CoListSchema.js";
43
44
  export * from "./implementation/zodSchema/schemaTypes/CoFeedSchema.js";
44
45
  export * from "./implementation/zodSchema/schemaTypes/AccountSchema.js";
45
46
  export * from "./implementation/zodSchema/schemaTypes/FileStreamSchema.js";
47
+ export * from "./implementation/zodSchema/schemaTypes/CoVectorSchema.js";
46
48
  export * from "./implementation/zodSchema/schemaTypes/PlainTextSchema.js";
47
49
  export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.js";
48
50
  export * from "./implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.js";
@@ -0,0 +1,40 @@
1
+ import { describe, expectTypeOf, test } from "vitest";
2
+ import { Group, co } from "../exports.js";
3
+ import { CoVectorSchema } from "../internal.js";
4
+
5
+ describe("CoVector types", () => {
6
+ test("co.vector() • defines a correct CoVectorSchema", () => {
7
+ type ExpectedType = CoVectorSchema;
8
+
9
+ function matches(value: ExpectedType) {
10
+ return value;
11
+ }
12
+
13
+ matches(co.vector(384));
14
+ });
15
+
16
+ test("co.vector().create() • creates a CoVector with Float32Array-like typing", () => {
17
+ const embedding = co.vector(3).create([1, 2, 3]);
18
+
19
+ type ExpectedType = Readonly<Float32Array>;
20
+
21
+ function matches(value: ExpectedType) {
22
+ return value;
23
+ }
24
+
25
+ matches(embedding);
26
+ });
27
+
28
+ test("CoVector instance • has the owner property", () => {
29
+ const embedding = co.vector(3).create([1, 2, 3]);
30
+
31
+ expectTypeOf(embedding.$jazz.owner).toEqualTypeOf<Group>();
32
+ });
33
+
34
+ test("setting a value via index access • is a type error", () => {
35
+ const embedding = co.vector(3).create([1, 2, 3]);
36
+
37
+ // @ts-expect-error: assignment to index should be disallowed
38
+ embedding[0] = 6;
39
+ });
40
+ });