@voidhash/mimic 1.0.0-beta.16 → 1.0.0-beta.17

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 (95) hide show
  1. package/dist/EffectSchema.cjs +3 -3
  2. package/dist/EffectSchema.d.cts +5 -5
  3. package/dist/EffectSchema.d.cts.map +1 -1
  4. package/dist/EffectSchema.d.mts +5 -5
  5. package/dist/EffectSchema.d.mts.map +1 -1
  6. package/dist/EffectSchema.mjs +3 -3
  7. package/dist/EffectSchema.mjs.map +1 -1
  8. package/dist/FractionalIndex.mjs.map +1 -1
  9. package/dist/Operation.d.cts +4 -4
  10. package/dist/Operation.d.cts.map +1 -1
  11. package/dist/Operation.d.mts +4 -4
  12. package/dist/Operation.d.mts.map +1 -1
  13. package/dist/Operation.mjs.map +1 -1
  14. package/dist/OperationDefinition.d.cts +2 -2
  15. package/dist/OperationDefinition.d.cts.map +1 -1
  16. package/dist/OperationDefinition.d.mts +2 -2
  17. package/dist/OperationDefinition.d.mts.map +1 -1
  18. package/dist/OperationDefinition.mjs.map +1 -1
  19. package/dist/Presence.mjs.map +1 -1
  20. package/dist/SchemaJSON.cjs +305 -0
  21. package/dist/SchemaJSON.d.cts +11 -0
  22. package/dist/SchemaJSON.d.cts.map +1 -0
  23. package/dist/SchemaJSON.d.mts +11 -0
  24. package/dist/SchemaJSON.d.mts.map +1 -0
  25. package/dist/SchemaJSON.mjs +301 -0
  26. package/dist/SchemaJSON.mjs.map +1 -0
  27. package/dist/index.cjs +7 -0
  28. package/dist/index.d.cts +2 -1
  29. package/dist/index.d.mts +2 -1
  30. package/dist/index.mjs +2 -1
  31. package/dist/primitives/Array.cjs +12 -2
  32. package/dist/primitives/Array.d.cts.map +1 -1
  33. package/dist/primitives/Array.d.mts.map +1 -1
  34. package/dist/primitives/Array.mjs +12 -2
  35. package/dist/primitives/Array.mjs.map +1 -1
  36. package/dist/primitives/Boolean.mjs.map +1 -1
  37. package/dist/primitives/Either.mjs.map +1 -1
  38. package/dist/primitives/Literal.mjs.map +1 -1
  39. package/dist/primitives/Number.cjs +27 -5
  40. package/dist/primitives/Number.d.cts.map +1 -1
  41. package/dist/primitives/Number.d.mts.map +1 -1
  42. package/dist/primitives/Number.mjs +27 -5
  43. package/dist/primitives/Number.mjs.map +1 -1
  44. package/dist/primitives/String.cjs +44 -13
  45. package/dist/primitives/String.d.cts.map +1 -1
  46. package/dist/primitives/String.d.mts.map +1 -1
  47. package/dist/primitives/String.mjs +44 -13
  48. package/dist/primitives/String.mjs.map +1 -1
  49. package/dist/primitives/Union.mjs.map +1 -1
  50. package/dist/primitives/shared.d.cts +2 -0
  51. package/dist/primitives/shared.d.cts.map +1 -1
  52. package/dist/primitives/shared.d.mts +2 -0
  53. package/dist/primitives/shared.d.mts.map +1 -1
  54. package/dist/primitives/shared.mjs.map +1 -1
  55. package/package.json +15 -8
  56. package/src/EffectSchema.ts +3 -3
  57. package/src/FractionalIndex.ts +18 -18
  58. package/src/Operation.ts +5 -5
  59. package/src/OperationDefinition.ts +2 -2
  60. package/src/Presence.ts +3 -3
  61. package/src/SchemaJSON.ts +396 -0
  62. package/src/index.ts +1 -0
  63. package/src/primitives/Array.ts +18 -8
  64. package/src/primitives/Boolean.ts +2 -2
  65. package/src/primitives/Either.ts +2 -2
  66. package/src/primitives/Literal.ts +2 -2
  67. package/src/primitives/Number.ts +44 -22
  68. package/src/primitives/String.ts +61 -34
  69. package/src/primitives/Union.ts +1 -1
  70. package/src/primitives/shared.ts +2 -0
  71. package/.turbo/turbo-build.log +0 -270
  72. package/tests/Document.test.ts +0 -557
  73. package/tests/EffectSchema.test.ts +0 -546
  74. package/tests/FractionalIndex.test.ts +0 -377
  75. package/tests/OperationPath.test.ts +0 -151
  76. package/tests/Presence.test.ts +0 -321
  77. package/tests/Primitive.test.ts +0 -381
  78. package/tests/client/ClientDocument.test.ts +0 -1981
  79. package/tests/client/WebSocketTransport.test.ts +0 -1217
  80. package/tests/primitives/Array.test.ts +0 -526
  81. package/tests/primitives/Boolean.test.ts +0 -126
  82. package/tests/primitives/Either.test.ts +0 -707
  83. package/tests/primitives/Lazy.test.ts +0 -143
  84. package/tests/primitives/Literal.test.ts +0 -122
  85. package/tests/primitives/Number.test.ts +0 -133
  86. package/tests/primitives/String.test.ts +0 -128
  87. package/tests/primitives/Struct.test.ts +0 -1154
  88. package/tests/primitives/Tree.test.ts +0 -1139
  89. package/tests/primitives/TreeNode.test.ts +0 -50
  90. package/tests/primitives/Union.test.ts +0 -554
  91. package/tests/server/ServerDocument.test.ts +0 -903
  92. package/tsconfig.build.json +0 -24
  93. package/tsconfig.json +0 -8
  94. package/tsdown.config.ts +0 -18
  95. package/vitest.mts +0 -11
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaJSON.mjs","names":["json: ValidatorJSON","json: any","fields: Record<string, unknown>","variants: Record<string, unknown>","nodes: Record<string, TreeNodeJSON>","p: StringPrimitive<any, any>","Primitive.String","p: NumberPrimitive<any, any>","Primitive.Number","p: BooleanPrimitive<any, any>","Primitive.Boolean","p: LiteralPrimitive<any, any, any>","Primitive.Literal","fields: Record<string, AnyPrimitive>","p: StructPrimitive<any, any, any>","Primitive.Struct","p: ArrayPrimitive<any, any, any>","Primitive.Array","variants: Record<string, any>","p: UnionPrimitive<any, any, any, any>","Primitive.Union","p: EitherPrimitive<any, any, any>","Primitive.Either","Primitive.TreeNode","p: TreePrimitive<any, any, any>","Primitive.Tree"],"sources":["../src/SchemaJSON.ts"],"sourcesContent":["import type { AnyPrimitive, Validator } from \"./primitives/shared\";\nimport { StringPrimitive } from \"./primitives/String\";\nimport { NumberPrimitive } from \"./primitives/Number\";\nimport { BooleanPrimitive } from \"./primitives/Boolean\";\nimport { LiteralPrimitive } from \"./primitives/Literal\";\nimport { StructPrimitive } from \"./primitives/Struct\";\nimport { ArrayPrimitive } from \"./primitives/Array\";\nimport { LazyPrimitive } from \"./primitives/Lazy\";\nimport { UnionPrimitive } from \"./primitives/Union\";\nimport { EitherPrimitive } from \"./primitives/Either\";\nimport { TreePrimitive } from \"./primitives/Tree\";\nimport { TreeNodePrimitive, type AnyTreeNodePrimitive } from \"./primitives/TreeNode\";\nimport * as Primitive from \"./Primitive\";\n\n// =============================================================================\n// JSON Types\n// =============================================================================\n\ninterface ValidatorJSON {\n readonly kind: string;\n readonly params?: unknown;\n}\n\ninterface ScalarJSON {\n readonly type: \"string\" | \"number\" | \"boolean\";\n readonly required: boolean;\n readonly default?: unknown;\n readonly validators?: readonly ValidatorJSON[];\n}\n\ninterface LiteralJSON {\n readonly type: \"literal\";\n readonly value: string | number | boolean | null;\n readonly required: boolean;\n readonly default?: unknown;\n}\n\ninterface StructJSON {\n readonly type: \"struct\";\n readonly required: boolean;\n readonly default?: unknown;\n readonly fields: Record<string, unknown>;\n}\n\ninterface ArrayJSON {\n readonly type: \"array\";\n readonly required: boolean;\n readonly default?: unknown;\n readonly element: unknown;\n readonly validators?: readonly ValidatorJSON[];\n}\n\ninterface UnionJSON {\n readonly type: \"union\";\n readonly required: boolean;\n readonly default?: unknown;\n readonly discriminator: string;\n readonly variants: Record<string, unknown>;\n}\n\ninterface EitherJSON {\n readonly type: \"either\";\n readonly required: boolean;\n readonly default?: unknown;\n readonly variants: readonly unknown[];\n}\n\ninterface TreeNodeJSON {\n readonly type: \"treeNode\";\n readonly nodeType: string;\n readonly data: unknown;\n readonly children: readonly string[];\n}\n\ninterface TreeJSON {\n readonly type: \"tree\";\n readonly required: boolean;\n readonly default?: unknown;\n readonly root: string;\n readonly nodes: Record<string, TreeNodeJSON>;\n}\n\n// =============================================================================\n// Helper: access private _schema\n// =============================================================================\n\nfunction getSchema(primitive: AnyPrimitive): any {\n return (primitive as any)._schema;\n}\n\n// =============================================================================\n// Serialize validators\n// =============================================================================\n\nfunction serializeValidators(validators: readonly Validator<any>[]): ValidatorJSON[] | undefined {\n const serializable = validators.filter((v) => v.kind != null);\n if (serializable.length === 0) return undefined;\n return serializable.map((v) => {\n const json: ValidatorJSON = { kind: v.kind! };\n if (v.params !== undefined) {\n return { ...json, params: v.params };\n }\n return json;\n });\n}\n\n// =============================================================================\n// toJSON\n// =============================================================================\n\nfunction collectTreeNodes(\n node: AnyTreeNodePrimitive,\n visited: Map<string, AnyTreeNodePrimitive>\n): void {\n if (visited.has(node.type)) return;\n visited.set(node.type, node);\n for (const child of node.children) {\n collectTreeNodes(child, visited);\n }\n}\n\nexport function toJSON(primitive: AnyPrimitive): unknown {\n // Resolve Lazy first\n if (primitive instanceof LazyPrimitive) {\n const resolved = (primitive as any)._resolve();\n return toJSON(resolved);\n }\n\n const schema = getSchema(primitive);\n\n if (primitive instanceof StringPrimitive) {\n const json: any = { type: \"string\", required: schema.required };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n const validators = serializeValidators(schema.validators);\n if (validators) json.validators = validators;\n return json;\n }\n\n if (primitive instanceof NumberPrimitive) {\n const json: any = { type: \"number\", required: schema.required };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n const validators = serializeValidators(schema.validators);\n if (validators) json.validators = validators;\n return json;\n }\n\n if (primitive instanceof BooleanPrimitive) {\n const json: any = { type: \"boolean\", required: schema.required };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n return json;\n }\n\n if (primitive instanceof LiteralPrimitive) {\n const json: any = {\n type: \"literal\",\n value: (primitive as LiteralPrimitive<any>).literal,\n required: schema.required,\n };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n return json;\n }\n\n if (primitive instanceof StructPrimitive) {\n const fields: Record<string, unknown> = {};\n const structFields = (primitive as StructPrimitive<any>).fields;\n for (const key in structFields) {\n fields[key] = toJSON(structFields[key]!);\n }\n const json: any = { type: \"struct\", required: schema.required, fields };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n return json;\n }\n\n if (primitive instanceof ArrayPrimitive) {\n const json: any = {\n type: \"array\",\n required: schema.required,\n element: toJSON((primitive as ArrayPrimitive<any>).element),\n };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n const validators = serializeValidators(schema.validators);\n if (validators) json.validators = validators;\n return json;\n }\n\n if (primitive instanceof UnionPrimitive) {\n const variants: Record<string, unknown> = {};\n const unionVariants = (primitive as UnionPrimitive<any, any>).variants;\n for (const key in unionVariants) {\n variants[key] = toJSON(unionVariants[key]!);\n }\n const json: any = {\n type: \"union\",\n required: schema.required,\n discriminator: (primitive as UnionPrimitive<any, any>).discriminator,\n variants,\n };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n return json;\n }\n\n if (primitive instanceof EitherPrimitive) {\n const variants = (primitive as EitherPrimitive<any>).variants;\n const json: any = {\n type: \"either\",\n required: schema.required,\n variants: variants.map((v: AnyPrimitive) => toJSON(v)),\n };\n if (schema.defaultValue !== undefined) json.default = schema.defaultValue;\n return json;\n }\n\n if (primitive instanceof TreePrimitive) {\n const root = (primitive as TreePrimitive<any>).root;\n const nodeMap = new Map<string, AnyTreeNodePrimitive>();\n collectTreeNodes(root, nodeMap);\n\n const nodes: Record<string, TreeNodeJSON> = {};\n for (const [nodeType, node] of nodeMap) {\n nodes[nodeType] = {\n type: \"treeNode\",\n nodeType,\n data: toJSON(node.data),\n children: node.children.map((c) => c.type),\n };\n }\n\n const json: any = {\n type: \"tree\",\n required: schema.required,\n root: root.type,\n nodes,\n };\n if (schema.defaultInput !== undefined) json.default = schema.defaultInput;\n return json;\n }\n\n throw new Error(`Unknown primitive type: ${primitive._tag}`);\n}\n\n// =============================================================================\n// fromJSON\n// =============================================================================\n\nfunction applyStringValidators(p: StringPrimitive<any, any>, validators: readonly ValidatorJSON[]): StringPrimitive<any, any> {\n let result = p;\n for (const v of validators) {\n const params = v.params as any;\n switch (v.kind) {\n case \"min\": result = result.min(params.value); break;\n case \"max\": result = result.max(params.value); break;\n case \"length\": result = result.length(params.value); break;\n case \"regex\": result = result.regex(new RegExp(params.pattern, params.flags)); break;\n case \"email\": result = result.email(); break;\n case \"url\": result = result.url(); break;\n }\n }\n return result;\n}\n\nfunction applyNumberValidators(p: NumberPrimitive<any, any>, validators: readonly ValidatorJSON[]): NumberPrimitive<any, any> {\n let result = p;\n for (const v of validators) {\n const params = v.params as any;\n switch (v.kind) {\n case \"min\": result = result.min(params.value); break;\n case \"max\": result = result.max(params.value); break;\n case \"positive\": result = result.positive(); break;\n case \"negative\": result = result.negative(); break;\n case \"int\": result = result.int(); break;\n }\n }\n return result;\n}\n\nfunction applyArrayValidators(p: ArrayPrimitive<any, any, any>, validators: readonly ValidatorJSON[]): ArrayPrimitive<any, any, any> {\n let result = p;\n for (const v of validators) {\n const params = v.params as any;\n switch (v.kind) {\n case \"minLength\": result = result.minLength(params.value); break;\n case \"maxLength\": result = result.maxLength(params.value); break;\n }\n }\n return result;\n}\n\nexport function fromJSON(json: unknown): AnyPrimitive {\n const obj = json as any;\n\n switch (obj.type) {\n case \"string\": {\n let p: StringPrimitive<any, any> = Primitive.String();\n if (obj.validators) p = applyStringValidators(p, obj.validators);\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"number\": {\n let p: NumberPrimitive<any, any> = Primitive.Number();\n if (obj.validators) p = applyNumberValidators(p, obj.validators);\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"boolean\": {\n let p: BooleanPrimitive<any, any> = Primitive.Boolean();\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"literal\": {\n let p: LiteralPrimitive<any, any, any> = Primitive.Literal(obj.value);\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"struct\": {\n const fields: Record<string, AnyPrimitive> = {};\n for (const key in obj.fields) {\n fields[key] = fromJSON(obj.fields[key]);\n }\n let p: StructPrimitive<any, any, any> = Primitive.Struct(fields);\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"array\": {\n const element = fromJSON(obj.element);\n let p: ArrayPrimitive<any, any, any> = Primitive.Array(element);\n if (obj.validators) p = applyArrayValidators(p, obj.validators);\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"union\": {\n const variants: Record<string, any> = {};\n for (const key in obj.variants) {\n variants[key] = fromJSON(obj.variants[key]);\n }\n let p: UnionPrimitive<any, any, any, any> = Primitive.Union({\n discriminator: obj.discriminator,\n variants,\n });\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"either\": {\n const variants = obj.variants.map((v: unknown) => fromJSON(v));\n let p: EitherPrimitive<any, any, any> = Primitive.Either(...variants);\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n case \"tree\": {\n const treeJSON = obj as TreeJSON;\n // First pass: create all TreeNode primitives with placeholder children\n const nodeMap = new Map<string, AnyTreeNodePrimitive>();\n const nodeJSONMap = new Map<string, TreeNodeJSON>();\n\n for (const nodeType in treeJSON.nodes) {\n nodeJSONMap.set(nodeType, treeJSON.nodes[nodeType]!);\n }\n\n // Create nodes with lazy children to handle circular references\n for (const [nodeType, nodeJSON] of nodeJSONMap) {\n const data = fromJSON(nodeJSON.data) as StructPrimitive<any>;\n const childTypes = nodeJSON.children;\n\n const node = Primitive.TreeNode(nodeType, {\n data,\n children: () => childTypes.map((ct) => nodeMap.get(ct)!),\n });\n nodeMap.set(nodeType, node);\n }\n\n const root = nodeMap.get(treeJSON.root)!;\n let p: TreePrimitive<any, any, any> = Primitive.Tree({ root });\n if (obj.required) p = p.required();\n if (obj.default !== undefined) p = p.default(obj.default);\n return p;\n }\n\n default:\n throw new Error(`Unknown JSON schema type: ${obj.type}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsFA,SAAS,UAAU,WAA8B;AAC/C,QAAQ,UAAkB;;AAO5B,SAAS,oBAAoB,YAAoE;CAC/F,MAAM,eAAe,WAAW,QAAQ,MA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B,WAAW,KAAK,OAAO,QAAQ,IAAI,GAAG,CAAE;KACzD,CAAC;AACF,YAAQ,IAAI,UAAU,KAAK;;GAG7B,MAAM,OAAO,QAAQ,IAAI,SAAS,KAAK;GACvC,IAAIC,IAAkCC,KAAe,EAAE,MAAM,CAAC;AAC9D,OAAI,IAAI,SAAU,KAAI,EAAE,UAAU;AAClC,OAAI,IAAI,YAAY,OAAW,KAAI,EAAE,QAAQ,IAAI,QAAQ;AACzD,UAAO;;EAGT,QACE,OAAM,IAAI,MAAM,6BAA6B,IAAI,OAAO"}
package/dist/index.cjs CHANGED
@@ -10,6 +10,7 @@ const require_Presence = require('./Presence.cjs');
10
10
  const require_EffectSchema = require('./EffectSchema.cjs');
11
11
  const require_index = require('./types/index.cjs');
12
12
  const require_tree_helpers = require('./utils/tree-helpers.cjs');
13
+ const require_SchemaJSON = require('./SchemaJSON.cjs');
13
14
 
14
15
  Object.defineProperty(exports, 'Document', {
15
16
  enumerable: true,
@@ -59,6 +60,12 @@ Object.defineProperty(exports, 'ProxyEnvironment', {
59
60
  return require_ProxyEnvironment.ProxyEnvironment_exports;
60
61
  }
61
62
  });
63
+ Object.defineProperty(exports, 'SchemaJSON', {
64
+ enumerable: true,
65
+ get: function () {
66
+ return require_SchemaJSON.SchemaJSON_exports;
67
+ }
68
+ });
62
69
  Object.defineProperty(exports, 'Transaction', {
63
70
  enumerable: true,
64
71
  get: function () {
package/dist/index.d.cts CHANGED
@@ -10,4 +10,5 @@ import { Document_d_exports } from "./Document.cjs";
10
10
  import { EffectSchema_d_exports } from "./EffectSchema.cjs";
11
11
  import { index_d_exports } from "./types/index.cjs";
12
12
  import { tree_helpers_d_exports } from "./utils/tree-helpers.cjs";
13
- export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationDefinition_d_exports as OperationDefinition, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
13
+ import { SchemaJSON_d_exports } from "./SchemaJSON.cjs";
14
+ export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationDefinition_d_exports as OperationDefinition, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, SchemaJSON_d_exports as SchemaJSON, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
package/dist/index.d.mts CHANGED
@@ -10,4 +10,5 @@ import { Document_d_exports } from "./Document.mjs";
10
10
  import { EffectSchema_d_exports } from "./EffectSchema.mjs";
11
11
  import { index_d_exports } from "./types/index.mjs";
12
12
  import { tree_helpers_d_exports } from "./utils/tree-helpers.mjs";
13
- export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationDefinition_d_exports as OperationDefinition, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
13
+ import { SchemaJSON_d_exports } from "./SchemaJSON.mjs";
14
+ export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationDefinition_d_exports as OperationDefinition, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, SchemaJSON_d_exports as SchemaJSON, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
package/dist/index.mjs CHANGED
@@ -10,5 +10,6 @@ import { Presence_exports } from "./Presence.mjs";
10
10
  import { EffectSchema_exports } from "./EffectSchema.mjs";
11
11
  import { types_exports } from "./types/index.mjs";
12
12
  import { tree_helpers_exports } from "./utils/tree-helpers.mjs";
13
+ import { SchemaJSON_exports } from "./SchemaJSON.mjs";
13
14
 
14
- export { Document_exports as Document, EffectSchema_exports as EffectSchema, Operation_exports as Operation, OperationDefinition_exports as OperationDefinition, OperationPath_exports as OperationPath, Presence_exports as Presence, Primitive_exports as Primitive, ProxyEnvironment_exports as ProxyEnvironment, Transaction_exports as Transaction, Transform_exports as Transform, tree_helpers_exports as TreeHelpers, types_exports as Types };
15
+ export { Document_exports as Document, EffectSchema_exports as EffectSchema, Operation_exports as Operation, OperationDefinition_exports as OperationDefinition, OperationPath_exports as OperationPath, Presence_exports as Presence, Primitive_exports as Primitive, ProxyEnvironment_exports as ProxyEnvironment, SchemaJSON_exports as SchemaJSON, Transaction_exports as Transaction, Transform_exports as Transform, tree_helpers_exports as TreeHelpers, types_exports as Types };
@@ -283,11 +283,21 @@ var ArrayPrimitive = class ArrayPrimitive {
283
283
  }
284
284
  /** Minimum array length */
285
285
  minLength(length) {
286
- return this.refine((v) => v.length >= length, `Array must have at least ${length} elements`);
286
+ return new ArrayPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
287
+ validate: (v) => v.length >= length,
288
+ message: `Array must have at least ${length} elements`,
289
+ kind: "minLength",
290
+ params: { value: length }
291
+ }] }));
287
292
  }
288
293
  /** Maximum array length */
289
294
  maxLength(length) {
290
- return this.refine((v) => v.length <= length, `Array must have at most ${length} elements`);
295
+ return new ArrayPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
296
+ validate: (v) => v.length <= length,
297
+ message: `Array must have at most ${length} elements`,
298
+ kind: "maxLength",
299
+ params: { value: length }
300
+ }] }));
291
301
  }
292
302
  };
293
303
  /** Creates a new ArrayPrimitive with the given element type */
@@ -1 +1 @@
1
- {"version":3,"file":"Array.d.cts","names":[],"sources":["../../src/primitives/Array.ts"],"sourcesContent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cAnFT,CAmFwB,QAnFxB,EAmFkC,SAnFlC,EAmF6C,WAnF7C,CAAA;EACI,SAAA,SAAA,EA8FF,iBA9FE,CA8FgB,UA9FhB,CA8F2B,QA9F3B,CAAA,EA8FsC,UA9FtC,CA8FiD,QA9FjD,CAAA,CAAA;;;AAED,cAyYV,KAzYU,EAAA,CAAA,iBAyYgB,YAzYhB,CAAA,CAAA,OAAA,EAyYuC,QAzYvC,EAAA,GAyYkD,cAzYlD,CAyYiE,QAzYjE,EAAA,KAAA,EAAA,KAAA,CAAA"}
@@ -282,11 +282,21 @@ var ArrayPrimitive = class ArrayPrimitive {
282
282
  }
283
283
  /** Minimum array length */
284
284
  minLength(length) {
285
- return this.refine((v) => v.length >= length, `Array must have at least ${length} elements`);
285
+ return new ArrayPrimitive(_objectSpread2(_objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
286
+ validate: (v) => v.length >= length,
287
+ message: `Array must have at least ${length} elements`,
288
+ kind: "minLength",
289
+ params: { value: length }
290
+ }] }));
286
291
  }
287
292
  /** Maximum array length */
288
293
  maxLength(length) {
289
- return this.refine((v) => v.length <= length, `Array must have at most ${length} elements`);
294
+ return new ArrayPrimitive(_objectSpread2(_objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
295
+ validate: (v) => v.length <= length,
296
+ message: `Array must have at most ${length} elements`,
297
+ kind: "maxLength",
298
+ params: { value: length }
299
+ }] }));
290
300
  }
291
301
  };
292
302
  /** Creates a new ArrayPrimitive with the given element type */
@@ -1 +1 @@
1
- {"version":3,"file":"Array.mjs","names":["FractionalIndex.base62CharSet","FractionalIndex.generateKeyBetween","OperationDefinition.make","entries: ArrayEntry<InferState<TElement>>[]","prevPos: string | null","Operation.fromDefinition","newState: ArrayState<TElement>","OperationPath.pathsOverlap","clientTokens","serverTokens","OperationPath.pathsEqual","OperationPath.isPrefix"],"sources":["../../src/primitives/Array.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport * as FractionalIndex from \"../FractionalIndex\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, AnyPrimitive, Validator, InferState, InferProxy, InferSnapshot, InferSetInput } from \"../Primitive\";\nimport { ValidationError } from \"../Primitive\";\nimport { runValidators, applyDefaults } from \"./shared\";\nimport { StructPrimitive, StructSetInput } from \"./Struct\";\n\n\n/**\n * Entry in an ordered array with ID and fractional position\n */\nexport interface ArrayEntry<T> {\n readonly id: string; // Unique element identifier (UUID)\n readonly pos: string; // Fractional index for ordering\n readonly value: T; // The element value\n}\n\n/**\n * Sort array entries by their fractional position\n */\nconst sortByPos = <T,>(entries: readonly ArrayEntry<T>[]): ArrayEntry<T>[] =>\n [...entries].sort((a, b) => a.pos < b.pos ? -1 : a.pos > b.pos ? 1 : 0);\n\n/**\n * Generate a fractional position between two positions\n */\nconst generatePosBetween = (left: string | null, right: string | null): string => {\n const charSet = FractionalIndex.base62CharSet();\n return Effect.runSync(FractionalIndex.generateKeyBetween(left, right, charSet));\n};\n\n/**\n * Entry in an array snapshot with ID and value snapshot\n */\nexport interface ArrayEntrySnapshot<TElement extends AnyPrimitive> {\n readonly id: string;\n readonly value: InferSnapshot<TElement>;\n}\n\n/**\n * Snapshot type for arrays - always an array (never undefined)\n */\nexport type ArraySnapshot<TElement extends AnyPrimitive> = readonly ArrayEntrySnapshot<TElement>[];\n\n/**\n * Compute the input type for array element values.\n * Uses StructSetInput directly for struct elements so that:\n * - Fields that are required AND have no default must be provided\n * - Fields that are optional OR have defaults can be omitted\n * \n * For non-struct elements, falls back to InferSetInput.\n */\nexport type ArrayElementSetInput<TElement extends AnyPrimitive> = \n TElement extends StructPrimitive<infer TFields, any, any>\n ? StructSetInput<TFields>\n : InferSetInput<TElement>;\n\nexport interface ArrayProxy<TElement extends AnyPrimitive> {\n /** Gets the current array entries (sorted by position) */\n get(): ArrayState<TElement>;\n /** Replaces the entire array with new values (generates new IDs and positions, applies defaults) */\n set(values: readonly ArrayElementSetInput<TElement>[]): void;\n /** Appends a value to the end of the array (applies defaults for struct elements) */\n push(value: ArrayElementSetInput<TElement>): void;\n /** Inserts a value at the specified visual index (applies defaults for struct elements) */\n insertAt(index: number, value: ArrayElementSetInput<TElement>): void;\n /** Removes the element with the specified ID */\n remove(id: string): void;\n /** Moves an element to a new visual index */\n move(id: string, toIndex: number): void;\n /** Returns a proxy for the element with the specified ID */\n at(id: string): InferProxy<TElement>;\n /** Finds an element by predicate and returns its proxy */\n find(predicate: (value: InferState<TElement>, id: string) => boolean): InferProxy<TElement> | undefined;\n /** Returns a readonly snapshot of the array for rendering (always returns an array, never undefined) */\n toSnapshot(): ArraySnapshot<TElement>;\n}\n\n/** The state type for arrays - an array of entries */\nexport type ArrayState<TElement extends AnyPrimitive> = readonly ArrayEntry<InferState<TElement>>[];\n\ninterface ArrayPrimitiveSchema<TElement extends AnyPrimitive> {\n readonly required: boolean;\n readonly defaultValue: ArrayState<TElement> | undefined;\n readonly element: TElement;\n readonly validators: readonly Validator<ArrayState<TElement>>[];\n}\n\n/** Input type for array set() - an array of element set inputs */\nexport type ArraySetInput<TElement extends AnyPrimitive> = readonly ArrayElementSetInput<TElement>[];\n\n/** Input type for array update() - same as set() for arrays */\nexport type ArrayUpdateInput<TElement extends AnyPrimitive> = readonly ArrayElementSetInput<TElement>[];\n\nexport class ArrayPrimitive<TElement extends AnyPrimitive, TRequired extends boolean = false, THasDefault extends boolean = false>\n implements Primitive<ArrayState<TElement>, ArrayProxy<TElement>, TRequired, THasDefault, ArraySetInput<TElement>, ArrayUpdateInput<TElement>>\n{\n readonly _tag = \"ArrayPrimitive\" as const;\n readonly _State!: ArrayState<TElement>;\n readonly _Proxy!: ArrayProxy<TElement>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TSetInput!: ArraySetInput<TElement>;\n readonly TUpdateInput!: ArrayUpdateInput<TElement>;\n\n private readonly _schema: ArrayPrimitiveSchema<TElement>;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"array.set\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n insert: OperationDefinition.make({\n kind: \"array.insert\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n }),\n remove: OperationDefinition.make({\n kind: \"array.remove\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n }),\n move: OperationDefinition.make({\n kind: \"array.move\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n }),\n };\n\n constructor(schema: ArrayPrimitiveSchema<TElement>) {\n this._schema = schema;\n }\n\n /** Mark this array as required */\n required(): ArrayPrimitive<TElement, true, THasDefault> {\n return new ArrayPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this array */\n default(defaultValue: ArrayState<TElement>): ArrayPrimitive<TElement, TRequired, true> {\n return new ArrayPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Get the element primitive */\n get element(): TElement {\n return this._schema.element;\n }\n\n /** Add a custom validation rule */\n refine(fn: (value: ArrayState<TElement>) => boolean, message: string): ArrayPrimitive<TElement, TRequired, THasDefault> {\n return new ArrayPrimitive({\n ...this._schema,\n validators: [...this._schema.validators, { validate: fn, message }],\n });\n }\n\n /** Minimum array length */\n minLength(length: number): ArrayPrimitive<TElement, TRequired, THasDefault> {\n return this.refine(\n (v) => v.length >= length,\n `Array must have at least ${length} elements`\n );\n }\n\n /** Maximum array length */\n maxLength(length: number): ArrayPrimitive<TElement, TRequired, THasDefault> {\n return this.refine(\n (v) => v.length <= length,\n `Array must have at most ${length} elements`\n );\n }\n\n readonly _internal: PrimitiveInternal<ArrayState<TElement>, ArrayProxy<TElement>> = {\n createProxy: (env: ProxyEnvironment.ProxyEnvironment, operationPath: OperationPath.OperationPath): ArrayProxy<TElement> => {\n const elementPrimitive = this._schema.element;\n\n // Helper to get current state (sorted)\n const getCurrentState = (): ArrayEntry<InferState<TElement>>[] => {\n const state = env.getState(operationPath) as ArrayState<TElement> | undefined;\n if (!state || !globalThis.Array.isArray(state)) return [];\n return sortByPos(state);\n };\n\n // Helper to apply defaults for element values\n const applyElementDefaults = (value: ArrayElementSetInput<TElement>): InferState<TElement> => {\n return applyDefaults(elementPrimitive, value as Partial<InferState<TElement>>) as InferState<TElement>;\n };\n\n return {\n get: (): ArrayState<TElement> => {\n return getCurrentState();\n },\n\n set: (values: readonly ArrayElementSetInput<TElement>[]) => {\n // Generate entries with new IDs and sequential positions\n const entries: ArrayEntry<InferState<TElement>>[] = [];\n let prevPos: string | null = null;\n \n for (const value of values) {\n const id = env.generateId();\n const pos = generatePosBetween(prevPos, null);\n // Apply defaults to element value\n const mergedValue = applyElementDefaults(value);\n entries.push({ id, pos, value: mergedValue });\n prevPos = pos;\n }\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, entries)\n );\n },\n\n push: (value: ArrayElementSetInput<TElement>) => {\n const sorted = getCurrentState();\n const lastPos = sorted.length > 0 ? sorted[sorted.length - 1]!.pos : null;\n const id = env.generateId();\n const pos = generatePosBetween(lastPos, null);\n // Apply defaults to element value\n const mergedValue = applyElementDefaults(value);\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.insert, { id, pos, value: mergedValue })\n );\n },\n\n insertAt: (index: number, value: ArrayElementSetInput<TElement>) => {\n const sorted = getCurrentState();\n const leftPos = index > 0 && sorted[index - 1] ? sorted[index - 1]!.pos : null;\n const rightPos = index < sorted.length && sorted[index] ? sorted[index]!.pos : null;\n \n const id = env.generateId();\n const pos = generatePosBetween(leftPos, rightPos);\n // Apply defaults to element value\n const mergedValue = applyElementDefaults(value);\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.insert, { id, pos, value: mergedValue })\n );\n },\n\n remove: (id: string) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.remove, { id })\n );\n },\n\n move: (id: string, toIndex: number) => {\n const sorted = getCurrentState();\n // Filter out the element being moved\n const without = sorted.filter(e => e.id !== id);\n \n const clampedIndex = Math.max(0, Math.min(toIndex, without.length));\n const leftPos = clampedIndex > 0 && without[clampedIndex - 1] ? without[clampedIndex - 1]!.pos : null;\n const rightPos = clampedIndex < without.length && without[clampedIndex] ? without[clampedIndex]!.pos : null;\n \n const pos = generatePosBetween(leftPos, rightPos);\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.move, { id, pos })\n );\n },\n\n at: (id: string): InferProxy<TElement> => {\n // Use ID in path for element access\n const elementPath = operationPath.append(id);\n return elementPrimitive._internal.createProxy(env, elementPath) as InferProxy<TElement>;\n },\n\n find: (predicate: (value: InferState<TElement>, id: string) => boolean): InferProxy<TElement> | undefined => {\n const sorted = getCurrentState();\n const found = sorted.find(entry => predicate(entry.value, entry.id));\n if (!found) return undefined;\n \n const elementPath = operationPath.append(found.id);\n return elementPrimitive._internal.createProxy(env, elementPath) as InferProxy<TElement>;\n },\n\n toSnapshot: (): ArraySnapshot<TElement> => {\n const sorted = getCurrentState();\n return sorted.map(entry => {\n const elementPath = operationPath.append(entry.id);\n const elementProxy = elementPrimitive._internal.createProxy(env, elementPath);\n return {\n id: entry.id,\n value: (elementProxy as { toSnapshot(): InferSnapshot<TElement> }).toSnapshot(),\n };\n });\n },\n };\n },\n\n applyOperation: (\n state: ArrayState<TElement> | undefined,\n operation: Operation.Operation<any, any, any>\n ): ArrayState<TElement> => {\n const path = operation.path;\n const tokens = path.toTokens().filter((t: string) => t !== \"\");\n const currentState = state ?? [];\n\n let newState: ArrayState<TElement>;\n\n // If path is empty, this is an array-level operation\n if (tokens.length === 0) {\n switch (operation.kind) {\n case \"array.set\": {\n const payload = operation.payload;\n if (!globalThis.Array.isArray(payload)) {\n throw new ValidationError(`ArrayPrimitive.set requires an array payload`);\n }\n newState = payload as ArrayState<TElement>;\n break;\n }\n case \"array.insert\": {\n const { id, pos, value } = operation.payload as { id: string; pos: string; value: InferState<TElement> };\n newState = [...currentState, { id, pos, value }];\n break;\n }\n case \"array.remove\": {\n const { id } = operation.payload as { id: string };\n newState = currentState.filter(entry => entry.id !== id);\n break;\n }\n case \"array.move\": {\n const { id, pos } = operation.payload as { id: string; pos: string };\n newState = currentState.map(entry => \n entry.id === id ? { ...entry, pos } : entry\n );\n break;\n }\n default:\n throw new ValidationError(`ArrayPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n } else {\n // Otherwise, delegate to the element with the specified ID\n const elementId = tokens[0]!;\n const entryIndex = currentState.findIndex(entry => entry.id === elementId);\n \n if (entryIndex === -1) {\n throw new ValidationError(`Array element not found with ID: ${elementId}`);\n }\n\n const elementPrimitive = this._schema.element;\n const remainingPath = path.shift();\n const elementOperation = {\n ...operation,\n path: remainingPath,\n };\n\n const currentEntry = currentState[entryIndex]!;\n const newValue = elementPrimitive._internal.applyOperation(currentEntry.value, elementOperation);\n\n const mutableState = [...currentState];\n mutableState[entryIndex] = { ...currentEntry, value: newValue };\n newState = mutableState;\n }\n\n // Run validators on the new state\n runValidators(newState, this._schema.validators);\n\n return newState;\n },\n\n getInitialState: (): ArrayState<TElement> | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n const clientPath = clientOp.path;\n const serverPath = serverOp.path;\n\n // If paths don't overlap at all, no transformation needed\n if (!OperationPath.pathsOverlap(clientPath, serverPath)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Handle array.remove from server - check if client is operating on removed element\n if (serverOp.kind === \"array.remove\") {\n const removedId = (serverOp.payload as { id: string }).id;\n const clientTokens = clientPath.toTokens().filter((t: string) => t !== \"\");\n const serverTokens = serverPath.toTokens().filter((t: string) => t !== \"\");\n\n // Check if client is operating on the removed element or its children\n if (clientTokens.length > serverTokens.length) {\n const elementId = clientTokens[serverTokens.length];\n if (elementId === removedId) {\n // Client operation targets a removed element - becomes noop\n return { type: \"noop\" };\n }\n }\n }\n\n // Both inserting into same array - no conflict (fractional indexing handles ordering)\n if (serverOp.kind === \"array.insert\" && clientOp.kind === \"array.insert\") {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Both moving elements in same array\n if (serverOp.kind === \"array.move\" && clientOp.kind === \"array.move\") {\n const serverMoveId = (serverOp.payload as { id: string }).id;\n const clientMoveId = (clientOp.payload as { id: string }).id;\n\n if (serverMoveId === clientMoveId) {\n // Client's move supersedes server's move (last-write-wins for position)\n return { type: \"transformed\", operation: clientOp };\n }\n // Different elements - no conflict\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For operations on same exact path: client wins (last-write-wins)\n if (OperationPath.pathsEqual(clientPath, serverPath)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // If server set entire array and client is operating on an element\n if (serverOp.kind === \"array.set\" && OperationPath.isPrefix(serverPath, clientPath)) {\n // Client's element operation may be invalid after array replacement\n // However, for optimistic updates, we let the client op proceed\n // and the server will validate/reject if needed\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Delegate to element primitive for nested operations\n const clientTokens = clientPath.toTokens().filter((t: string) => t !== \"\");\n const serverTokens = serverPath.toTokens().filter((t: string) => t !== \"\");\n\n // Both operations target children of this array\n if (clientTokens.length > 0 && serverTokens.length > 0) {\n const clientElementId = clientTokens[0];\n const serverElementId = serverTokens[0];\n\n // If operating on different elements, no conflict\n if (clientElementId !== serverElementId) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Same element - delegate to element primitive\n const elementPrimitive = this._schema.element;\n const clientOpForElement = {\n ...clientOp,\n path: clientOp.path.shift(),\n };\n const serverOpForElement = {\n ...serverOp,\n path: serverOp.path.shift(),\n };\n\n const result = elementPrimitive._internal.transformOperation(clientOpForElement, serverOpForElement);\n\n if (result.type === \"transformed\") {\n // Restore the original path prefix\n return {\n type: \"transformed\",\n operation: {\n ...result.operation,\n path: clientOp.path,\n },\n };\n }\n\n return result;\n }\n\n // Default: no transformation needed\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/** Creates a new ArrayPrimitive with the given element type */\nexport const Array = <TElement extends AnyPrimitive>(element: TElement): ArrayPrimitive<TElement, false, false> =>\n new ArrayPrimitive({ required: false, defaultValue: undefined, element, validators: [] });\n\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAM,aAAiB,YACrB,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;;;;AAKzE,MAAM,sBAAsB,MAAqB,UAAiC;CAChF,MAAM,UAAUA,eAA+B;AAC/C,QAAO,OAAO,QAAQC,mBAAmC,MAAM,OAAO,QAAQ,CAAC;;AAkEjF,IAAa,iBAAb,MAAa,eAEb;CAuCE,YAAY,QAAwC;wBAtC3C,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB;GAChC,KAAKC,KAAyB;IAC5B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACpB,cAAc;IACf,CAAC;GACF,QAAQA,KAAyB;IAC/B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACrB,CAAC;GACF,QAAQA,KAAyB;IAC/B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACrB,CAAC;GACF,MAAMA,KAAyB;IAC7B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACrB,CAAC;GACH;wBAmDQ,aAA2E;GAClF,cAAc,KAAwC,kBAAqE;IACzH,MAAM,mBAAmB,KAAK,QAAQ;IAGtC,MAAM,wBAA4D;KAChE,MAAM,QAAQ,IAAI,S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,SAAI,OAAO,SAAS,cAElB,QAAO;MACL,MAAM;MACN,6CACK,OAAO,kBACV,MAAM,SAAS;MAElB;AAGH,YAAO;;AAIT,WAAO;KAAE,MAAM;KAAe,WAAW;KAAU;;GAEtD;AAzVC,OAAK,UAAU;;;CAIjB,WAAwD;AACtD,SAAO,IAAI,iDACN,KAAK,gBACR,UAAU,QACV;;;CAIJ,QAAQ,cAA+E;AACrF,SAAO,IAAI,iDACN,KAAK,gBACR,gBACA;;;CAIJ,IAAI,UAAoB;AACtB,SAAO,KAAK,QAAQ;;;CAItB,OAAO,IAA8C,SAAmE;AACtH,SAAO,IAAI,iDACN,KAAK,gBACR,YAAY,CAAC,GAAG,KAAK,QAAQ,YAAY;GAAE,UAAU;GAAI;GAAS,CAAC,IACnE;;;CAIJ,UAAU,QAAkE;AAC1E,SAAO,KAAK,QACT,MAAM,EAAE,UAAU,QACnB,4BAA4B,OAAO,WACpC;;;CAIH,UAAU,QAAkE;AAC1E,SAAO,KAAK,QACT,MAAM,EAAE,UAAU,QACnB,2BAA2B,OAAO,WACnC;;;;AAgTL,MAAa,SAAwC,YACnD,IAAI,eAAe;CAAE,UAAU;CAAO,cAAc;CAAW;CAAS,YAAY,EAAE;CAAE,CAAC"}
1
+ {"version":3,"file":"Array.mjs","names":["FractionalIndex.base62CharSet","FractionalIndex.generateKeyBetween","OperationDefinition.make","entries: ArrayEntry<InferState<TElement>>[]","prevPos: string | null","Operation.fromDefinition","newState: ArrayState<TElement>","OperationPath.pathsOverlap","clientTokens","serverTokens","OperationPath.pathsEqual","OperationPath.isPrefix"],"sources":["../../src/primitives/Array.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport * as FractionalIndex from \"../FractionalIndex\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, AnyPrimitive, Validator, InferState, InferProxy, InferSnapshot, InferSetInput } from \"../Primitive\";\nimport { ValidationError } from \"../Primitive\";\nimport { runValidators, applyDefaults } from \"./shared\";\nimport { StructPrimitive, StructSetInput } from \"./Struct\";\n\n\n/**\n * Entry in an ordered array with ID and fractional position\n */\nexport interface ArrayEntry<T> {\n readonly id: string; // Unique element identifier (UUID)\n readonly pos: string; // Fractional index for ordering\n readonly value: T; // The element value\n}\n\n/**\n * Sort array entries by their fractional position\n */\nconst sortByPos = <T,>(entries: readonly ArrayEntry<T>[]): ArrayEntry<T>[] =>\n [...entries].sort((a, b) => a.pos < b.pos ? -1 : a.pos > b.pos ? 1 : 0);\n\n/**\n * Generate a fractional position between two positions\n */\nconst generatePosBetween = (left: string | null, right: string | null): string => {\n const charSet = FractionalIndex.base62CharSet();\n return Effect.runSync(FractionalIndex.generateKeyBetween(left, right, charSet));\n};\n\n/**\n * Entry in an array snapshot with ID and value snapshot\n */\nexport interface ArrayEntrySnapshot<TElement extends AnyPrimitive> {\n readonly id: string;\n readonly value: InferSnapshot<TElement>;\n}\n\n/**\n * Snapshot type for arrays - always an array (never undefined)\n */\nexport type ArraySnapshot<TElement extends AnyPrimitive> = readonly ArrayEntrySnapshot<TElement>[];\n\n/**\n * Compute the input type for array element values.\n * Uses StructSetInput directly for struct elements so that:\n * - Fields that are required AND have no default must be provided\n * - Fields that are optional OR have defaults can be omitted\n * \n * For non-struct elements, falls back to InferSetInput.\n */\nexport type ArrayElementSetInput<TElement extends AnyPrimitive> = \n TElement extends StructPrimitive<infer TFields, any, any>\n ? StructSetInput<TFields>\n : InferSetInput<TElement>;\n\nexport interface ArrayProxy<TElement extends AnyPrimitive> {\n /** Gets the current array entries (sorted by position) */\n get(): ArrayState<TElement>;\n /** Replaces the entire array with new values (generates new IDs and positions, applies defaults) */\n set(values: readonly ArrayElementSetInput<TElement>[]): void;\n /** Appends a value to the end of the array (applies defaults for struct elements) */\n push(value: ArrayElementSetInput<TElement>): void;\n /** Inserts a value at the specified visual index (applies defaults for struct elements) */\n insertAt(index: number, value: ArrayElementSetInput<TElement>): void;\n /** Removes the element with the specified ID */\n remove(id: string): void;\n /** Moves an element to a new visual index */\n move(id: string, toIndex: number): void;\n /** Returns a proxy for the element with the specified ID */\n at(id: string): InferProxy<TElement>;\n /** Finds an element by predicate and returns its proxy */\n find(predicate: (value: InferState<TElement>, id: string) => boolean): InferProxy<TElement> | undefined;\n /** Returns a readonly snapshot of the array for rendering (always returns an array, never undefined) */\n toSnapshot(): ArraySnapshot<TElement>;\n}\n\n/** The state type for arrays - an array of entries */\nexport type ArrayState<TElement extends AnyPrimitive> = readonly ArrayEntry<InferState<TElement>>[];\n\ninterface ArrayPrimitiveSchema<TElement extends AnyPrimitive> {\n readonly required: boolean;\n readonly defaultValue: ArrayState<TElement> | undefined;\n readonly element: TElement;\n readonly validators: readonly Validator<ArrayState<TElement>>[];\n}\n\n/** Input type for array set() - an array of element set inputs */\nexport type ArraySetInput<TElement extends AnyPrimitive> = readonly ArrayElementSetInput<TElement>[];\n\n/** Input type for array update() - same as set() for arrays */\nexport type ArrayUpdateInput<TElement extends AnyPrimitive> = readonly ArrayElementSetInput<TElement>[];\n\nexport class ArrayPrimitive<TElement extends AnyPrimitive, TRequired extends boolean = false, THasDefault extends boolean = false>\n implements Primitive<ArrayState<TElement>, ArrayProxy<TElement>, TRequired, THasDefault, ArraySetInput<TElement>, ArrayUpdateInput<TElement>>\n{\n readonly _tag = \"ArrayPrimitive\" as const;\n readonly _State!: ArrayState<TElement>;\n readonly _Proxy!: ArrayProxy<TElement>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TSetInput!: ArraySetInput<TElement>;\n readonly TUpdateInput!: ArrayUpdateInput<TElement>;\n\n private readonly _schema: ArrayPrimitiveSchema<TElement>;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"array.set\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n insert: OperationDefinition.make({\n kind: \"array.insert\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n }),\n remove: OperationDefinition.make({\n kind: \"array.remove\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n }),\n move: OperationDefinition.make({\n kind: \"array.move\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n }),\n };\n\n constructor(schema: ArrayPrimitiveSchema<TElement>) {\n this._schema = schema;\n }\n\n /** Mark this array as required */\n required(): ArrayPrimitive<TElement, true, THasDefault> {\n return new ArrayPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this array */\n default(defaultValue: ArrayState<TElement>): ArrayPrimitive<TElement, TRequired, true> {\n return new ArrayPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Get the element primitive */\n get element(): TElement {\n return this._schema.element;\n }\n\n /** Add a custom validation rule */\n refine(fn: (value: ArrayState<TElement>) => boolean, message: string): ArrayPrimitive<TElement, TRequired, THasDefault> {\n return new ArrayPrimitive({\n ...this._schema,\n validators: [...this._schema.validators, { validate: fn, message }],\n });\n }\n\n /** Minimum array length */\n minLength(length: number): ArrayPrimitive<TElement, TRequired, THasDefault> {\n return new ArrayPrimitive({\n ...this._schema,\n validators: [...this._schema.validators, {\n validate: (v) => v.length >= length,\n message: `Array must have at least ${length} elements`,\n kind: \"minLength\",\n params: { value: length },\n }],\n });\n }\n\n /** Maximum array length */\n maxLength(length: number): ArrayPrimitive<TElement, TRequired, THasDefault> {\n return new ArrayPrimitive({\n ...this._schema,\n validators: [...this._schema.validators, {\n validate: (v) => v.length <= length,\n message: `Array must have at most ${length} elements`,\n kind: \"maxLength\",\n params: { value: length },\n }],\n });\n }\n\n readonly _internal: PrimitiveInternal<ArrayState<TElement>, ArrayProxy<TElement>> = {\n createProxy: (env: ProxyEnvironment.ProxyEnvironment, operationPath: OperationPath.OperationPath): ArrayProxy<TElement> => {\n const elementPrimitive = this._schema.element;\n\n // Helper to get current state (sorted)\n const getCurrentState = (): ArrayEntry<InferState<TElement>>[] => {\n const state = env.getState(operationPath) as ArrayState<TElement> | undefined;\n if (!state || !globalThis.Array.isArray(state)) return [];\n return sortByPos(state);\n };\n\n // Helper to apply defaults for element values\n const applyElementDefaults = (value: ArrayElementSetInput<TElement>): InferState<TElement> => {\n return applyDefaults(elementPrimitive, value as Partial<InferState<TElement>>) as InferState<TElement>;\n };\n\n return {\n get: (): ArrayState<TElement> => {\n return getCurrentState();\n },\n\n set: (values: readonly ArrayElementSetInput<TElement>[]) => {\n // Generate entries with new IDs and sequential positions\n const entries: ArrayEntry<InferState<TElement>>[] = [];\n let prevPos: string | null = null;\n \n for (const value of values) {\n const id = env.generateId();\n const pos = generatePosBetween(prevPos, null);\n // Apply defaults to element value\n const mergedValue = applyElementDefaults(value);\n entries.push({ id, pos, value: mergedValue });\n prevPos = pos;\n }\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, entries)\n );\n },\n\n push: (value: ArrayElementSetInput<TElement>) => {\n const sorted = getCurrentState();\n const lastPos = sorted.length > 0 ? sorted[sorted.length - 1]!.pos : null;\n const id = env.generateId();\n const pos = generatePosBetween(lastPos, null);\n // Apply defaults to element value\n const mergedValue = applyElementDefaults(value);\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.insert, { id, pos, value: mergedValue })\n );\n },\n\n insertAt: (index: number, value: ArrayElementSetInput<TElement>) => {\n const sorted = getCurrentState();\n const leftPos = index > 0 && sorted[index - 1] ? sorted[index - 1]!.pos : null;\n const rightPos = index < sorted.length && sorted[index] ? sorted[index]!.pos : null;\n \n const id = env.generateId();\n const pos = generatePosBetween(leftPos, rightPos);\n // Apply defaults to element value\n const mergedValue = applyElementDefaults(value);\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.insert, { id, pos, value: mergedValue })\n );\n },\n\n remove: (id: string) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.remove, { id })\n );\n },\n\n move: (id: string, toIndex: number) => {\n const sorted = getCurrentState();\n // Filter out the element being moved\n const without = sorted.filter(e => e.id !== id);\n \n const clampedIndex = Math.max(0, Math.min(toIndex, without.length));\n const leftPos = clampedIndex > 0 && without[clampedIndex - 1] ? without[clampedIndex - 1]!.pos : null;\n const rightPos = clampedIndex < without.length && without[clampedIndex] ? without[clampedIndex]!.pos : null;\n \n const pos = generatePosBetween(leftPos, rightPos);\n \n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.move, { id, pos })\n );\n },\n\n at: (id: string): InferProxy<TElement> => {\n // Use ID in path for element access\n const elementPath = operationPath.append(id);\n return elementPrimitive._internal.createProxy(env, elementPath) as InferProxy<TElement>;\n },\n\n find: (predicate: (value: InferState<TElement>, id: string) => boolean): InferProxy<TElement> | undefined => {\n const sorted = getCurrentState();\n const found = sorted.find(entry => predicate(entry.value, entry.id));\n if (!found) return undefined;\n \n const elementPath = operationPath.append(found.id);\n return elementPrimitive._internal.createProxy(env, elementPath) as InferProxy<TElement>;\n },\n\n toSnapshot: (): ArraySnapshot<TElement> => {\n const sorted = getCurrentState();\n return sorted.map(entry => {\n const elementPath = operationPath.append(entry.id);\n const elementProxy = elementPrimitive._internal.createProxy(env, elementPath);\n return {\n id: entry.id,\n value: (elementProxy as { toSnapshot(): InferSnapshot<TElement> }).toSnapshot(),\n };\n });\n },\n };\n },\n\n applyOperation: (\n state: ArrayState<TElement> | undefined,\n operation: Operation.Operation<any, any, any>\n ): ArrayState<TElement> => {\n const path = operation.path;\n const tokens = path.toTokens().filter((t: string) => t !== \"\");\n const currentState = state ?? [];\n\n let newState: ArrayState<TElement>;\n\n // If path is empty, this is an array-level operation\n if (tokens.length === 0) {\n switch (operation.kind) {\n case \"array.set\": {\n const payload = operation.payload;\n if (!globalThis.Array.isArray(payload)) {\n throw new ValidationError(`ArrayPrimitive.set requires an array payload`);\n }\n newState = payload as ArrayState<TElement>;\n break;\n }\n case \"array.insert\": {\n const { id, pos, value } = operation.payload as { id: string; pos: string; value: InferState<TElement> };\n newState = [...currentState, { id, pos, value }];\n break;\n }\n case \"array.remove\": {\n const { id } = operation.payload as { id: string };\n newState = currentState.filter(entry => entry.id !== id);\n break;\n }\n case \"array.move\": {\n const { id, pos } = operation.payload as { id: string; pos: string };\n newState = currentState.map(entry => \n entry.id === id ? { ...entry, pos } : entry\n );\n break;\n }\n default:\n throw new ValidationError(`ArrayPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n } else {\n // Otherwise, delegate to the element with the specified ID\n const elementId = tokens[0]!;\n const entryIndex = currentState.findIndex(entry => entry.id === elementId);\n \n if (entryIndex === -1) {\n throw new ValidationError(`Array element not found with ID: ${elementId}`);\n }\n\n const elementPrimitive = this._schema.element;\n const remainingPath = path.shift();\n const elementOperation = {\n ...operation,\n path: remainingPath,\n };\n\n const currentEntry = currentState[entryIndex]!;\n const newValue = elementPrimitive._internal.applyOperation(currentEntry.value, elementOperation);\n\n const mutableState = [...currentState];\n mutableState[entryIndex] = { ...currentEntry, value: newValue };\n newState = mutableState;\n }\n\n // Run validators on the new state\n runValidators(newState, this._schema.validators);\n\n return newState;\n },\n\n getInitialState: (): ArrayState<TElement> | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n const clientPath = clientOp.path;\n const serverPath = serverOp.path;\n\n // If paths don't overlap at all, no transformation needed\n if (!OperationPath.pathsOverlap(clientPath, serverPath)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Handle array.remove from server - check if client is operating on removed element\n if (serverOp.kind === \"array.remove\") {\n const removedId = (serverOp.payload as { id: string }).id;\n const clientTokens = clientPath.toTokens().filter((t: string) => t !== \"\");\n const serverTokens = serverPath.toTokens().filter((t: string) => t !== \"\");\n\n // Check if client is operating on the removed element or its children\n if (clientTokens.length > serverTokens.length) {\n const elementId = clientTokens[serverTokens.length];\n if (elementId === removedId) {\n // Client operation targets a removed element - becomes noop\n return { type: \"noop\" };\n }\n }\n }\n\n // Both inserting into same array - no conflict (fractional indexing handles ordering)\n if (serverOp.kind === \"array.insert\" && clientOp.kind === \"array.insert\") {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Both moving elements in same array\n if (serverOp.kind === \"array.move\" && clientOp.kind === \"array.move\") {\n const serverMoveId = (serverOp.payload as { id: string }).id;\n const clientMoveId = (clientOp.payload as { id: string }).id;\n\n if (serverMoveId === clientMoveId) {\n // Client's move supersedes server's move (last-write-wins for position)\n return { type: \"transformed\", operation: clientOp };\n }\n // Different elements - no conflict\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For operations on same exact path: client wins (last-write-wins)\n if (OperationPath.pathsEqual(clientPath, serverPath)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // If server set entire array and client is operating on an element\n if (serverOp.kind === \"array.set\" && OperationPath.isPrefix(serverPath, clientPath)) {\n // Client's element operation may be invalid after array replacement\n // However, for optimistic updates, we let the client op proceed\n // and the server will validate/reject if needed\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Delegate to element primitive for nested operations\n const clientTokens = clientPath.toTokens().filter((t: string) => t !== \"\");\n const serverTokens = serverPath.toTokens().filter((t: string) => t !== \"\");\n\n // Both operations target children of this array\n if (clientTokens.length > 0 && serverTokens.length > 0) {\n const clientElementId = clientTokens[0];\n const serverElementId = serverTokens[0];\n\n // If operating on different elements, no conflict\n if (clientElementId !== serverElementId) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // Same element - delegate to element primitive\n const elementPrimitive = this._schema.element;\n const clientOpForElement = {\n ...clientOp,\n path: clientOp.path.shift(),\n };\n const serverOpForElement = {\n ...serverOp,\n path: serverOp.path.shift(),\n };\n\n const result = elementPrimitive._internal.transformOperation(clientOpForElement, serverOpForElement);\n\n if (result.type === \"transformed\") {\n // Restore the original path prefix\n return {\n type: \"transformed\",\n operation: {\n ...result.operation,\n path: clientOp.path,\n },\n };\n }\n\n return result;\n }\n\n // Default: no transformation needed\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/** Creates a new ArrayPrimitive with the given element type */\nexport const Array = <TElement extends AnyPrimitive>(element: TElement): ArrayPrimitive<TElement, false, false> =>\n new ArrayPrimitive({ required: false, defaultValue: undefined, element, validators: [] });\n\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAM,aAAiB,YACrB,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE;;;;AAKzE,MAAM,sBAAsB,MAAqB,UAAiC;CAChF,MAAM,UAAUA,eAA+B;AAC/C,QAAO,OAAO,QAAQC,mBAAmC,MAAM,OAAO,QAAQ,CAAC;;AAkEjF,IAAa,iBAAb,MAAa,eAEb;CAuCE,YAAY,QAAwC;wBAtC3C,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB;GAChC,KAAKC,KAAyB;IAC5B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACpB,cAAc;IACf,CAAC;GACF,QAAQA,KAAyB;IAC/B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACrB,CAAC;GACF,QAAQA,KAAyB;IAC/B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACrB,CAAC;GACF,MAAMA,KAAyB;IAC7B,MAAM;IACN,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,YAAY;IACrB,CAAC;GACH;wBA6DQ,aAA2E;GAClF,cAAc,KAAwC,kBAAqE;IACzH,MAAM,mBAAmB,KAAK,QAAQ;IAGtC,MAAM,wBAA4D;KAChE,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,SAAI,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B,QAAO;MACL,MAAM;MACN,6CACK,OAAO,kBACV,MAAM,SAAS;MAElB;AAGH,YAAO;;AAIT,WAAO;KAAE,MAAM;KAAe,WAAW;KAAU;;GAEtD;AAnWC,OAAK,UAAU;;;CAIjB,WAAwD;AACtD,SAAO,IAAI,iDACN,KAAK,gBACR,UAAU,QACV;;;CAIJ,QAAQ,cAA+E;AACrF,SAAO,IAAI,iDACN,KAAK,gBACR,gBACA;;;CAIJ,IAAI,UAAoB;AACtB,SAAO,KAAK,QAAQ;;;CAItB,OAAO,IAA8C,SAAmE;AACtH,SAAO,IAAI,iDACN,KAAK,gBACR,YAAY,CAAC,GAAG,KAAK,QAAQ,YAAY;GAAE,UAAU;GAAI;GAAS,CAAC,IACnE;;;CAIJ,UAAU,QAAkE;AAC1E,SAAO,IAAI,iDACN,KAAK,gBACR,YAAY,CAAC,GAAG,KAAK,QAAQ,YAAY;GACvC,WAAW,MAAM,EAAE,UAAU;GAC7B,SAAS,4BAA4B,OAAO;GAC5C,MAAM;GACN,QAAQ,EAAE,OAAO,QAAQ;GAC1B,CAAC,IACF;;;CAIJ,UAAU,QAAkE;AAC1E,SAAO,IAAI,iDACN,KAAK,gBACR,YAAY,CAAC,GAAG,KAAK,QAAQ,YAAY;GACvC,WAAW,MAAM,EAAE,UAAU;GAC7B,SAAS,2BAA2B,OAAO;GAC3C,MAAM;GACN,QAAQ,EAAE,OAAO,QAAQ;GAC1B,CAAC,IACF;;;;AAgTN,MAAa,SAAwC,YACnD,IAAI,eAAe;CAAE,UAAU;CAAO,cAAc;CAAW;CAAS,YAAY,EAAE;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Boolean.mjs","names":["OperationDefinition.make","Operation.fromDefinition","OperationPath.pathsOverlap"],"sources":["../../src/primitives/Boolean.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, Validator, NeedsValue } from \"./shared\";\nimport { runValidators, isCompatibleOperation, ValidationError } from \"./shared\";\n\n\ntype InferSetInput<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<boolean, TRequired, THasDefault>\ntype InferUpdateInput<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<boolean, TRequired, THasDefault>\n\nexport interface BooleanProxy<TRequired extends boolean = false, THasDefault extends boolean = false> {\n /** Gets the current boolean value */\n get(): MaybeUndefined<boolean, TRequired, THasDefault>;\n /** Sets the boolean value, generating a boolean.set operation */\n set(value: InferSetInput<TRequired, THasDefault>): void;\n /** This is the same as set. Updates the boolean value, generating a boolean.set operation */\n update(value: InferUpdateInput<TRequired, THasDefault>): void;\n /** Returns a readonly snapshot of the boolean value for rendering */\n toSnapshot(): MaybeUndefined<boolean, TRequired, THasDefault>;\n}\n\ninterface BooleanPrimitiveSchema {\n readonly required: boolean;\n readonly defaultValue: boolean | undefined;\n readonly validators: readonly Validator<boolean>[];\n}\n\nexport class BooleanPrimitive<TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<boolean, BooleanProxy<TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<TRequired, THasDefault>, InferUpdateInput<TRequired, THasDefault>> {\n readonly _tag = \"BooleanPrimitive\" as const;\n readonly _State!: boolean;\n readonly _Proxy!: BooleanProxy<TRequired, THasDefault>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TUpdateInput!: InferUpdateInput<TRequired, THasDefault>;\n readonly TSetInput!: InferSetInput<TRequired, THasDefault>;\n\n private readonly _schema: BooleanPrimitiveSchema;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"boolean.set\" as const,\n payload: Schema.Boolean,\n target: Schema.Boolean,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n };\n\n constructor(schema: BooleanPrimitiveSchema) {\n this._schema = schema;\n }\n\n /** Mark this boolean as required */\n required(): BooleanPrimitive<true, THasDefault> {\n return new BooleanPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this boolean */\n default(defaultValue: boolean): BooleanPrimitive<TRequired, true> {\n return new BooleanPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Add a custom validation rule */\n refine(fn: (value: boolean) => boolean, message: string): BooleanPrimitive<TRequired, THasDefault> {\n return new BooleanPrimitive({\n ...this._schema,\n validators: [...this._schema.validators, { validate: fn, message }],\n });\n }\n\n readonly _internal: PrimitiveInternal<boolean, BooleanProxy<TRequired, THasDefault>> = {\n createProxy: (env: ProxyEnvironment.ProxyEnvironment, operationPath: OperationPath.OperationPath): BooleanProxy<TRequired, THasDefault> => {\n const defaultValue = this._schema.defaultValue;\n return {\n get: (): MaybeUndefined<boolean, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as boolean | undefined;\n return (state ?? defaultValue) as MaybeUndefined<boolean, TRequired, THasDefault>;\n },\n set: (value: InferSetInput<TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, value)\n );\n },\n update: (value: InferUpdateInput<TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, value)\n );\n },\n toSnapshot: (): MaybeUndefined<boolean, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as boolean | undefined;\n return (state ?? defaultValue) as MaybeUndefined<boolean, TRequired, THasDefault>;\n },\n };\n },\n\n applyOperation: (_state: boolean | undefined, operation: Operation.Operation<any, any, any>): boolean => {\n if (operation.kind !== \"boolean.set\") {\n throw new ValidationError(`BooleanPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n\n const payload = operation.payload;\n if (typeof payload !== \"boolean\") {\n throw new ValidationError(`BooleanPrimitive.set requires a boolean payload, got: ${typeof payload}`);\n }\n\n // Run validators\n runValidators(payload, this._schema.validators);\n\n return payload;\n },\n\n getInitialState: (): boolean | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n // If paths don't overlap, no transformation needed\n if (!OperationPath.pathsOverlap(clientOp.path, serverOp.path)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For same path, client wins (last-write-wins)\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/** Creates a new BooleanPrimitive */\nexport const Boolean = (): BooleanPrimitive<false, false> =>\n new BooleanPrimitive({ required: false, defaultValue: undefined, validators: [] });\n\n"],"mappings":";;;;;;;;;AA8BA,IAAa,mBAAb,MAAa,iBAAsQ;CAqBjR,YAAY,QAAgC;wBApBnC,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB,EAChC,KAAKA,KAAyB;GAC5B,MAAM;GACN,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,QAAQ,YAAY;GACpB,cAAc;GACf,CAAC,EACH;wBA8BQ,aAA8E;GACrF,cAAc,KAAwC,kBAAqF;IACzI,MAAM,eAAe,KAAK,QAAQ;AAClC,WAAO;KACL,WAA4D;MAC1D,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,aAAQ,6CAAS;;KAEnB,MAAM,UAAiD;AACrD,UAAI,aACFC,eAAyB,eAAe,KAAK,eAAe,KAAK,MAAM,CACxE;;KAEH,SAAS,UAAoD;AAC3D,UAAI,aACFA,eAAyB,eAAe,KAAK,eAAe,KAAK,MAAM,CACxE;;KAEH,kBAAmE;MACjE,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,aAAQ,6CAAS;;KAEpB;;GAGH,iBAAiB,QAA6B,cAA2D;AACvG,QAAI,UAAU,SAAS,cACrB,OAAM,IAAI,gBAAgB,oDAAoD,UAAU,OAAO;IAGjG,MAAM,UAAU,UAAU;AAC1B,QAAI,OAAO,YAAY,UACrB,OAAM,IAAI,gBAAgB,yDAAyD,OAAO,UAAU;AAItG,kBAAc,SAAS,KAAK,QAAQ,WAAW;AAE/C,WAAO;;GAGT,uBAA4C;AAC1C,WAAO,KAAK,QAAQ;;GAGtB,qBACE,UACA,aAC8B;AAE9B,QAAI,CAACC,aAA2B,SAAS,MAAM,SAAS,KAAK,CAC3D,QAAO;KAAE,MAAM;KAAe,WAAW;KAAU;AAIrD,WAAO;KAAE,MAAM;KAAe,WAAW;KAAU;;GAEtD;AApFC,OAAK,UAAU;;;CAIjB,WAAgD;AAC9C,SAAO,IAAI,mDACN,KAAK,gBACR,UAAU,QACV;;;CAIJ,QAAQ,cAA0D;AAChE,SAAO,IAAI,mDACN,KAAK,gBACR,gBACA;;;CAIJ,OAAO,IAAiC,SAA2D;AACjG,SAAO,IAAI,mDACN,KAAK,gBACR,YAAY,CAAC,GAAG,KAAK,QAAQ,YAAY;GAAE,UAAU;GAAI;GAAS,CAAC,IACnE;;;;AAgEN,MAAa,gBACX,IAAI,iBAAiB;CAAE,UAAU;CAAO,cAAc;CAAW,YAAY,EAAE;CAAE,CAAC"}
1
+ {"version":3,"file":"Boolean.mjs","names":["OperationDefinition.make","Operation.fromDefinition","OperationPath.pathsOverlap"],"sources":["../../src/primitives/Boolean.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, Validator, NeedsValue } from \"./shared\";\nimport { runValidators, isCompatibleOperation, ValidationError } from \"./shared\";\n\n\ntype InferSetInput<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<boolean, TRequired, THasDefault>\ntype InferUpdateInput<TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<boolean, TRequired, THasDefault>\n\nexport interface BooleanProxy<TRequired extends boolean = false, THasDefault extends boolean = false> {\n /** Gets the current boolean value */\n get(): MaybeUndefined<boolean, TRequired, THasDefault>;\n /** Sets the boolean value, generating a boolean.set operation */\n set(value: InferSetInput<TRequired, THasDefault>): void;\n /** This is the same as set. Updates the boolean value, generating a boolean.set operation */\n update(value: InferUpdateInput<TRequired, THasDefault>): void;\n /** Returns a readonly snapshot of the boolean value for rendering */\n toSnapshot(): MaybeUndefined<boolean, TRequired, THasDefault>;\n}\n\ninterface BooleanPrimitiveSchema {\n readonly required: boolean;\n readonly defaultValue: boolean | undefined;\n readonly validators: readonly Validator<boolean>[];\n}\n\nexport class BooleanPrimitive<TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<boolean, BooleanProxy<TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<TRequired, THasDefault>, InferUpdateInput<TRequired, THasDefault>> {\n readonly _tag = \"BooleanPrimitive\" as const;\n readonly _State!: boolean;\n readonly _Proxy!: BooleanProxy<TRequired, THasDefault>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TUpdateInput!: InferUpdateInput<TRequired, THasDefault>;\n readonly TSetInput!: InferSetInput<TRequired, THasDefault>;\n\n private readonly _schema: BooleanPrimitiveSchema;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"boolean.set\" as const,\n payload: Schema.Boolean,\n target: Schema.Boolean,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n };\n\n constructor(schema: BooleanPrimitiveSchema) {\n this._schema = schema;\n }\n\n /** Mark this boolean as required */\n required(): BooleanPrimitive<true, THasDefault> {\n return new BooleanPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this boolean */\n default(defaultValue: boolean): BooleanPrimitive<TRequired, true> {\n return new BooleanPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Add a custom validation rule */\n refine(fn: (value: boolean) => boolean, message: string): BooleanPrimitive<TRequired, THasDefault> {\n return new BooleanPrimitive({\n ...this._schema,\n validators: [...this._schema.validators, { validate: fn, message }],\n });\n }\n\n readonly _internal: PrimitiveInternal<boolean, BooleanProxy<TRequired, THasDefault>> = {\n createProxy: (env: ProxyEnvironment.ProxyEnvironment, operationPath: OperationPath.OperationPath): BooleanProxy<TRequired, THasDefault> => {\n const defaultValue = this._schema.defaultValue;\n return {\n get: (): MaybeUndefined<boolean, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as boolean | undefined;\n return (state ?? defaultValue) as MaybeUndefined<boolean, TRequired, THasDefault>;\n },\n set: (value: InferSetInput<TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set as any, value)\n );\n },\n update: (value: InferUpdateInput<TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set as any, value)\n );\n },\n toSnapshot: (): MaybeUndefined<boolean, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as boolean | undefined;\n return (state ?? defaultValue) as MaybeUndefined<boolean, TRequired, THasDefault>;\n },\n };\n },\n\n applyOperation: (_state: boolean | undefined, operation: Operation.Operation<any, any, any>): boolean => {\n if (operation.kind !== \"boolean.set\") {\n throw new ValidationError(`BooleanPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n\n const payload = operation.payload;\n if (typeof payload !== \"boolean\") {\n throw new ValidationError(`BooleanPrimitive.set requires a boolean payload, got: ${typeof payload}`);\n }\n\n // Run validators\n runValidators(payload, this._schema.validators);\n\n return payload;\n },\n\n getInitialState: (): boolean | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n // If paths don't overlap, no transformation needed\n if (!OperationPath.pathsOverlap(clientOp.path, serverOp.path)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For same path, client wins (last-write-wins)\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/** Creates a new BooleanPrimitive */\nexport const Boolean = (): Boo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AAgD;AAC9C,SAAO,IAAI,mDACN,KAAK,gBACR,UAAU,QACV;;;CAIJ,QAAQ,cAA0D;AAChE,SAAO,IAAI,mDACN,KAAK,gBACR,gBACA;;;CAIJ,OAAO,IAAiC,SAA2D;AACjG,SAAO,IAAI,mDACN,KAAK,gBACR,YAAY,CAAC,GAAG,KAAK,QAAQ,YAAY;GAAE,UAAU;GAAI;GAAS,CAAC,IACnE;;;;AAgEN,MAAa,gBACX,IAAI,iBAAiB;CAAE,UAAU;CAAO,cAAc;CAAW,YAAY,EAAE;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Either.mjs","names":["OperationDefinition.make","Operation.fromDefinition","OperationPath.pathsOverlap","syntheticOp: Operation.Operation<any, any, any>"],"sources":["../../src/primitives/Either.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, InferState, NeedsValue } from \"./shared\";\nimport { ValidationError } from \"./shared\";\nimport { StringPrimitive } from \"./String\";\nimport { NumberPrimitive } from \"./Number\";\nimport { BooleanPrimitive } from \"./Boolean\";\nimport { LiteralPrimitive, LiteralValue } from \"./Literal\";\n\n// =============================================================================\n// Either Primitive - Simple Type Union\n// =============================================================================\n\ntype InferSetInput<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<InferEitherState<TVariants>, TRequired, THasDefault>\ntype InferUpdateInput<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<InferEitherState<TVariants>, TRequired, THasDefault>\n\n/**\n * Scalar primitives that can be used as variants in Either\n */\nexport type ScalarPrimitive =\n | StringPrimitive<any, any>\n | NumberPrimitive<any, any>\n | BooleanPrimitive<any, any>\n | LiteralPrimitive<any, any, any>;\n\n/**\n * Infer the union state type from a tuple of scalar primitives\n */\nexport type InferEitherState<TVariants extends readonly ScalarPrimitive[]> =\n InferState<TVariants[number]>;\n\n/**\n * Infer the union snapshot type from a tuple of scalar primitives\n */\nexport type InferEitherSnapshot<TVariants extends readonly ScalarPrimitive[]> =\n InferState<TVariants[number]>;\n\n/**\n * Match handlers for Either - optional handlers for each scalar type\n */\nexport interface EitherMatchHandlers<R> {\n string?: (value: string) => R;\n number?: (value: number) => R;\n boolean?: (value: boolean) => R;\n literal?: (value: LiteralValue) => R;\n}\n\n/**\n * Proxy for accessing Either values\n */\nexport interface EitherProxy<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> {\n /** Gets the current value */\n get(): MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault>;\n\n /** Sets the value to any of the allowed variant types */\n set(value: InferSetInput<TVariants, TRequired, THasDefault>): void;\n\n /** This is the same as set. Updates the value, generating an either.set operation */\n update(value: InferUpdateInput<TVariants, TRequired, THasDefault>): void;\n\n /** Pattern match on the value type */\n match<R>(handlers: EitherMatchHandlers<R>): R | undefined;\n\n /** Returns a readonly snapshot of the value for rendering */\n toSnapshot(): MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault>;\n}\n\ninterface EitherPrimitiveSchema<TVariants extends readonly ScalarPrimitive[]> {\n readonly required: boolean;\n readonly defaultValue: InferEitherState<TVariants> | undefined;\n readonly variants: TVariants;\n}\n\nexport class EitherPrimitive<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false>\n implements Primitive<InferEitherState<TVariants>, EitherProxy<TVariants, TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<TVariants, TRequired, THasDefault>, InferUpdateInput<TVariants, TRequired, THasDefault>>\n{\n readonly _tag = \"EitherPrimitive\" as const;\n readonly _State!: InferEitherState<TVariants>;\n readonly _Proxy!: EitherProxy<TVariants, TRequired, THasDefault>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TUpdateInput!: InferUpdateInput<TVariants, TRequired, THasDefault>;\n readonly TSetInput!: InferSetInput<TVariants, TRequired, THasDefault>;\n\n private readonly _schema: EitherPrimitiveSchema<TVariants>;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"either.set\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n };\n\n constructor(schema: EitherPrimitiveSchema<TVariants>) {\n this._schema = schema;\n }\n\n /** Mark this either as required */\n required(): EitherPrimitive<TVariants, true, THasDefault> {\n return new EitherPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this either */\n default(defaultValue: InferEitherState<TVariants>): EitherPrimitive<TVariants, TRequired, true> {\n return new EitherPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Get the variants */\n get variants(): TVariants {\n return this._schema.variants;\n }\n\n /**\n * Determine the type category of a value based on the variants\n */\n private _getValueType(value: unknown): \"string\" | \"number\" | \"boolean\" | \"literal\" | undefined {\n const valueType = typeof value;\n\n // Check for literal matches first (they take priority)\n for (const variant of this._schema.variants) {\n if (variant._tag === \"LiteralPrimitive\") {\n const literalVariant = variant as LiteralPrimitive<any, any, any>;\n if (value === literalVariant.literal) {\n return \"literal\";\n }\n }\n }\n\n // Check for type matches\n if (valueType === \"string\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"StringPrimitive\") {\n return \"string\";\n }\n }\n }\n\n if (valueType === \"number\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"NumberPrimitive\") {\n return \"number\";\n }\n }\n }\n\n if (valueType === \"boolean\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"BooleanPrimitive\") {\n return \"boolean\";\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Find the matching variant for a value.\n * For literals, matches exact value. For other types, matches by typeof.\n */\n private _findMatchingVariant(value: unknown): ScalarPrimitive | undefined {\n const valueType = typeof value;\n\n // Check for literal matches first (they take priority)\n for (const variant of this._schema.variants) {\n if (variant._tag === \"LiteralPrimitive\") {\n const literalVariant = variant as LiteralPrimitive<any, any, any>;\n if (value === literalVariant.literal) {\n return variant;\n }\n }\n }\n\n // Check for type matches\n if (valueType === \"string\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"StringPrimitive\") {\n return variant;\n }\n }\n }\n\n if (valueType === \"number\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"NumberPrimitive\") {\n return variant;\n }\n }\n }\n\n if (valueType === \"boolean\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"BooleanPrimitive\") {\n return variant;\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Get the operation kind for a variant\n */\n private _getVariantOperationKind(variant: ScalarPrimitive): string {\n switch (variant._tag) {\n case \"StringPrimitive\":\n return \"string.set\";\n case \"NumberPrimitive\":\n return \"number.set\";\n case \"BooleanPrimitive\":\n return \"boolean.set\";\n case \"LiteralPrimitive\":\n return \"literal.set\";\n default:\n return \"unknown.set\";\n }\n }\n\n /**\n * Validate a value against the matching variant, including running its validators.\n * Throws ValidationError if the value doesn't match any variant or fails validation.\n */\n private _validateAndApplyToVariant(value: unknown, path: OperationPath.OperationPath): void {\n const matchingVariant = this._findMatchingVariant(value);\n \n if (!matchingVariant) {\n const allowedTypes = this._schema.variants.map((v) => v._tag).join(\", \");\n throw new ValidationError(\n `EitherPrimitive.set requires a value matching one of: ${allowedTypes}, got: ${typeof value}`\n );\n }\n\n // Create a synthetic operation for the variant's applyOperation\n const variantOpKind = this._getVariantOperationKind(matchingVariant);\n const syntheticOp: Operation.Operation<any, any, any> = {\n kind: variantOpKind,\n path: path,\n payload: value,\n };\n\n // Delegate to the variant's applyOperation which runs its validators\n // This will throw ValidationError if validation fails\n matchingVariant._internal.applyOperation(undefined, syntheticOp);\n }\n\n readonly _internal: PrimitiveInternal<InferEitherState<TVariants>, EitherProxy<TVariants, TRequired, THasDefault>> = {\n createProxy: (\n env: ProxyEnvironment.ProxyEnvironment,\n operationPath: OperationPath.OperationPath\n ): EitherProxy<TVariants, TRequired, THasDefault> => {\n const defaultValue = this._schema.defaultValue;\n\n return {\n get: (): MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as InferEitherState<TVariants> | undefined;\n return (state ?? defaultValue) as MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault>;\n },\n set: (value: InferSetInput<TVariants, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, value)\n );\n },\n update: (value: InferUpdateInput<TVariants, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, value)\n );\n },\n match: <R,>(handlers: EitherMatchHandlers<R>): R | undefined => {\n const currentState = env.getState(operationPath) as InferEitherState<TVariants> | undefined;\n const effectiveState = currentState ?? defaultValue;\n if (effectiveState === undefined) return undefined;\n\n const valueType = this._getValueType(effectiveState);\n if (!valueType) return undefined;\n\n switch (valueType) {\n case \"string\":\n return handlers.string?.(effectiveState as string);\n case \"number\":\n return handlers.number?.(effectiveState as number);\n case \"boolean\":\n return handlers.boolean?.(effectiveState as boolean);\n case \"literal\":\n return handlers.literal?.(effectiveState as LiteralValue);\n default:\n return undefined;\n }\n },\n toSnapshot: (): MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as InferEitherState<TVariants> | undefined;\n return (state ?? defaultValue) as MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault>;\n },\n };\n },\n\n applyOperation: (\n _state: InferEitherState<TVariants> | undefined,\n operation: Operation.Operation<any, any, any>\n ): InferEitherState<TVariants> => {\n if (operation.kind !== \"either.set\") {\n throw new ValidationError(`EitherPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n\n const payload = operation.payload;\n\n // Validate that the payload matches one of the variant types and passes its validators\n this._validateAndApplyToVariant(payload, operation.path);\n\n return payload as InferEitherState<TVariants>;\n },\n\n getInitialState: (): InferEitherState<TVariants> | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n // If paths don't overlap, no transformation needed\n if (!OperationPath.pathsOverlap(clientOp.path, serverOp.path)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For same path, client wins (last-write-wins)\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/**\n * Creates a new EitherPrimitive with the given scalar variant types.\n * Validators defined on the variants are applied when validating values.\n *\n * @example\n * ```typescript\n * // String or number\n * const value = Either(String(), Number());\n *\n * // String, number, or boolean\n * const status = Either(String(), Number(), Boolean()).default(\"pending\");\n *\n * // With literal types\n * const mode = Either(Literal(\"auto\"), Literal(\"manual\"), Number());\n *\n * // With validators - validates string length and number range\n * const constrained = Either(\n * String().min(2).max(50),\n * Number().max(255)\n * );\n * ```\n */\nexport function Either<TVariants extends readonly ScalarPrimitive[]>(\n ...variants: TVariants\n): EitherPrimitive<TVariants, false, false> {\n if (variants.length === 0) {\n throw new ValidationError(\"Either requires at least one variant\");\n }\n\n return new EitherPrimitive({\n required: false,\n defaultValue: undefined,\n variants,\n });\n}\n\n"],"mappings":";;;;;;;;;AA6EA,IAAa,kBAAb,MAAa,gBAEb;CAqBE,YAAY,QAA0C;wBApB7C,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB,EAChC,KAAKA,KAAyB;GAC5B,MAAM;GACN,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,QAAQ,YAAY;GACpB,cAAc;GACf,CAAC,EACH;wBAiKQ,aAA4G;GACnH,cACE,KACA,kBACmD;IACnD,MAAM,eAAe,KAAK,QAAQ;AAElC,WAAO;KACL,WAAgF;MAC9E,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,aAAQ,6CAAS;;KAEnB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AAK,CAAC,KAAK,KAAK,CAEA,SAAS,OAAO,QACvF;EAKH,MAAMC,cAAkD;GACtD,MAFoB,KAAK,yBAAyB,gBAAgB;GAG5D;GACN,SAAS;GACV;AAID,kBAAgB,UAAU,eAAe,QAAW,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;AA8GpE,SAAgB,OACd,GAAG,UACuC;AAC1C,KAAI,SAAS,WAAW,EACtB,OAAM,IAAI,gBAAgB,uCAAuC;AAGnE,QAAO,IAAI,gBAAgB;EACzB,UAAU;EACV,cAAc;EACd;EACD,CAAC"}
1
+ {"version":3,"file":"Either.mjs","names":["OperationDefinition.make","Operation.fromDefinition","OperationPath.pathsOverlap","syntheticOp: Operation.Operation<any, any, any>"],"sources":["../../src/primitives/Either.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, InferState, NeedsValue } from \"./shared\";\nimport { ValidationError } from \"./shared\";\nimport { StringPrimitive } from \"./String\";\nimport { NumberPrimitive } from \"./Number\";\nimport { BooleanPrimitive } from \"./Boolean\";\nimport { LiteralPrimitive, LiteralValue } from \"./Literal\";\n\n// =============================================================================\n// Either Primitive - Simple Type Union\n// =============================================================================\n\ntype InferSetInput<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<InferEitherState<TVariants>, TRequired, THasDefault>\ntype InferUpdateInput<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<InferEitherState<TVariants>, TRequired, THasDefault>\n\n/**\n * Scalar primitives that can be used as variants in Either\n */\nexport type ScalarPrimitive =\n | StringPrimitive<any, any>\n | NumberPrimitive<any, any>\n | BooleanPrimitive<any, any>\n | LiteralPrimitive<any, any, any>;\n\n/**\n * Infer the union state type from a tuple of scalar primitives\n */\nexport type InferEitherState<TVariants extends readonly ScalarPrimitive[]> =\n InferState<TVariants[number]>;\n\n/**\n * Infer the union snapshot type from a tuple of scalar primitives\n */\nexport type InferEitherSnapshot<TVariants extends readonly ScalarPrimitive[]> =\n InferState<TVariants[number]>;\n\n/**\n * Match handlers for Either - optional handlers for each scalar type\n */\nexport interface EitherMatchHandlers<R> {\n string?: (value: string) => R;\n number?: (value: number) => R;\n boolean?: (value: boolean) => R;\n literal?: (value: LiteralValue) => R;\n}\n\n/**\n * Proxy for accessing Either values\n */\nexport interface EitherProxy<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false> {\n /** Gets the current value */\n get(): MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault>;\n\n /** Sets the value to any of the allowed variant types */\n set(value: InferSetInput<TVariants, TRequired, THasDefault>): void;\n\n /** This is the same as set. Updates the value, generating an either.set operation */\n update(value: InferUpdateInput<TVariants, TRequired, THasDefault>): void;\n\n /** Pattern match on the value type */\n match<R>(handlers: EitherMatchHandlers<R>): R | undefined;\n\n /** Returns a readonly snapshot of the value for rendering */\n toSnapshot(): MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault>;\n}\n\ninterface EitherPrimitiveSchema<TVariants extends readonly ScalarPrimitive[]> {\n readonly required: boolean;\n readonly defaultValue: InferEitherState<TVariants> | undefined;\n readonly variants: TVariants;\n}\n\nexport class EitherPrimitive<TVariants extends readonly ScalarPrimitive[], TRequired extends boolean = false, THasDefault extends boolean = false>\n implements Primitive<InferEitherState<TVariants>, EitherProxy<TVariants, TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<TVariants, TRequired, THasDefault>, InferUpdateInput<TVariants, TRequired, THasDefault>>\n{\n readonly _tag = \"EitherPrimitive\" as const;\n readonly _State!: InferEitherState<TVariants>;\n readonly _Proxy!: EitherProxy<TVariants, TRequired, THasDefault>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TUpdateInput!: InferUpdateInput<TVariants, TRequired, THasDefault>;\n readonly TSetInput!: InferSetInput<TVariants, TRequired, THasDefault>;\n\n private readonly _schema: EitherPrimitiveSchema<TVariants>;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"either.set\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n };\n\n constructor(schema: EitherPrimitiveSchema<TVariants>) {\n this._schema = schema;\n }\n\n /** Mark this either as required */\n required(): EitherPrimitive<TVariants, true, THasDefault> {\n return new EitherPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this either */\n default(defaultValue: InferEitherState<TVariants>): EitherPrimitive<TVariants, TRequired, true> {\n return new EitherPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Get the variants */\n get variants(): TVariants {\n return this._schema.variants;\n }\n\n /**\n * Determine the type category of a value based on the variants\n */\n private _getValueType(value: unknown): \"string\" | \"number\" | \"boolean\" | \"literal\" | undefined {\n const valueType = typeof value;\n\n // Check for literal matches first (they take priority)\n for (const variant of this._schema.variants) {\n if (variant._tag === \"LiteralPrimitive\") {\n const literalVariant = variant as LiteralPrimitive<any, any, any>;\n if (value === literalVariant.literal) {\n return \"literal\";\n }\n }\n }\n\n // Check for type matches\n if (valueType === \"string\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"StringPrimitive\") {\n return \"string\";\n }\n }\n }\n\n if (valueType === \"number\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"NumberPrimitive\") {\n return \"number\";\n }\n }\n }\n\n if (valueType === \"boolean\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"BooleanPrimitive\") {\n return \"boolean\";\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Find the matching variant for a value.\n * For literals, matches exact value. For other types, matches by typeof.\n */\n private _findMatchingVariant(value: unknown): ScalarPrimitive | undefined {\n const valueType = typeof value;\n\n // Check for literal matches first (they take priority)\n for (const variant of this._schema.variants) {\n if (variant._tag === \"LiteralPrimitive\") {\n const literalVariant = variant as LiteralPrimitive<any, any, any>;\n if (value === literalVariant.literal) {\n return variant;\n }\n }\n }\n\n // Check for type matches\n if (valueType === \"string\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"StringPrimitive\") {\n return variant;\n }\n }\n }\n\n if (valueType === \"number\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"NumberPrimitive\") {\n return variant;\n }\n }\n }\n\n if (valueType === \"boolean\") {\n for (const variant of this._schema.variants) {\n if (variant._tag === \"BooleanPrimitive\") {\n return variant;\n }\n }\n }\n\n return undefined;\n }\n\n /**\n * Get the operation kind for a variant\n */\n private _getVariantOperationKind(variant: ScalarPrimitive): string {\n switch (variant._tag) {\n case \"StringPrimitive\":\n return \"string.set\";\n case \"NumberPrimitive\":\n return \"number.set\";\n case \"BooleanPrimitive\":\n return \"boolean.set\";\n case \"LiteralPrimitive\":\n return \"literal.set\";\n default:\n return \"unknown.set\";\n }\n }\n\n /**\n * Validate a value against the matching variant, including running its validators.\n * Throws ValidationError if the value doesn't match any variant or fails validation.\n */\n private _validateAndApplyToVariant(value: unknown, path: OperationPath.OperationPath): void {\n const matchingVariant = this._findMatchingVariant(value);\n \n if (!matchingVariant) {\n const allowedTypes = this._schema.variants.map((v) => v._tag).join(\", \");\n throw new ValidationError(\n `EitherPrimitive.set requires a value matching one of: ${allowedTypes}, got: ${typeof value}`\n );\n }\n\n // Create a synthetic operation for the variant's applyOperation\n const variantOpKind = this._getVariantOperationKind(matchingVariant);\n const syntheticOp: Operation.Operation<any, any, any> = {\n kind: variantOpKind,\n path: path,\n payload: value,\n };\n\n // Delegate to the variant's applyOperation which runs its validators\n // This will throw ValidationError if validation fails\n matchingVariant._internal.applyOperation(undefined, syntheticOp);\n }\n\n readonly _internal: PrimitiveInternal<InferEitherState<TVariants>, EitherProxy<TVariants, TRequired, THasDefault>> = {\n createProxy: (\n env: ProxyEnvironment.ProxyEnvironment,\n operationPath: OperationPath.OperationPath\n ): EitherProxy<TVariants, TRequired, THasDefault> => {\n const defaultValue = this._schema.defaultValue;\n\n return {\n get: (): MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as InferEitherState<TVariants> | undefined;\n return (state ?? defaultValue) as MaybeUndefined<InferEitherState<TVariants>, TRequired, THasDefault>;\n },\n set: (value: InferSetInput<TVariants, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set as any, value)\n );\n },\n update: (value: InferUpdateInput<TVariants, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set as any, value)\n );\n },\n match: <R,>(handlers: EitherMatchHandlers<R>): R | undefined => {\n const currentState = env.getState(operationPath) as InferEitherState<TVariants> | undefined;\n const effectiveState = currentState ?? defaultValue;\n if (effectiveState === undefined) return undefined;\n\n const valueType = this._getValueType(effectiveState);\n if (!valueType) return undefined;\n\n switch (valueType) {\n case \"string\":\n return handlers.string?.(effectiveState as string);\n case \"number\":\n return handlers.number?.(effectiveState as number);\n case \"boolean\":\n return handlers.boolean?.(effectiveState as boolean);\n case \"literal\":\n return handlers.literal?.(effectiveState as LiteralValue);\n default:\n return undefined;\n }\n },\n toSnapshot: (): MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as InferEitherState<TVariants> | undefined;\n return (state ?? defaultValue) as MaybeUndefined<InferEitherSnapshot<TVariants>, TRequired, THasDefault>;\n },\n };\n },\n\n applyOperation: (\n _state: InferEitherState<TVariants> | undefined,\n operation: Operation.Operation<any, any, any>\n ): InferEitherState<TVariants> => {\n if (operation.kind !== \"either.set\") {\n throw new ValidationError(`EitherPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n\n const payload = operation.payload;\n\n // Validate that the payload matches one of the variant types and passes its validators\n this._validateAndApplyToVariant(payload, operation.path);\n\n return payload as InferEitherState<TVariants>;\n },\n\n getInitialState: (): InferEitherState<TVariants> | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n // If paths don't overlap, no transformation needed\n if (!OperationPath.pathsOverlap(clientOp.path, serverOp.path)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For same path, client wins (last-write-wins)\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/**\n * Creates a new EitherPrimitive with the given scalar variant types.\n * Validators defined on the variants are applied when validating values.\n *\n * @example\n * ```typescript\n * // String or number\n * const value = Either(String(), Number());\n *\n * // String, number, or boolean\n * const status = Either(String(), Number(), Boolean()).default(\"pending\");\n *\n * // With literal types\n * const mode = Either(Literal(\"auto\"), Literal(\"manual\"), Number());\n *\n * // With validators - validates string length and number range\n * const constrained = Either(\n * String().min(2).max(50),\n * Number().max(255)\n * );\n * ```\n */\nexport function Either<TVariants extends readonly ScalarPrimitive[]>(\n ...variants: TVariants\n): EitherPrimitive<TVariants, false, false> {\n if (variants.length === 0) {\n throw new ValidationError(\"Either requires at least one variant\");\n }\n\n return new EitherPrimitive({\n required: false,\n defaultValue: undefined,\n variants,\n });\n}\n\n"],"mappings":";;;;;;;;;AA6EA,IAAa,kBAAb,MAAa,gBAEb;CAqBE,YAAY,QAA0C;wBApB7C,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB,EAChC,KAAKA,KAAyB;GAC5B,MAAM;GACN,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,QAAQ,YAAY;GACpB,cAAc;GACf,CAAC,EACH;wBAiKQ,aAA4G;GACnH,cACE,KACA,kBACmD;IACnD,MAAM,eAAe,KAAK,QAAQ;AAElC,WAAO;KACL,WAAgF;MAC9E,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,aAAQ,6CAAS;;KAEnB,MAAM,U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AAC,KAAK,KAAK,CAEA,SAAS,OAAO,QACvF;EAKH,MAAMC,cAAkD;GACtD,MAFoB,KAAK,yBAAyB,gBAAgB;GAG5D;GACN,SAAS;GACV;AAID,kBAAgB,UAAU,eAAe,QAAW,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;AA8GpE,SAAgB,OACd,GAAG,UACuC;AAC1C,KAAI,SAAS,WAAW,EACtB,OAAM,IAAI,gBAAgB,uCAAuC;AAGnE,QAAO,IAAI,gBAAgB;EACzB,UAAU;EACV,cAAc;EACd;EACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Literal.mjs","names":["OperationDefinition.make","Operation.fromDefinition","OperationPath.pathsOverlap"],"sources":["../../src/primitives/Literal.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, AnyPrimitive, Validator, NeedsValue } from \"./shared\";\nimport { ValidationError, runValidators, isCompatibleOperation } from \"./shared\";\n\n\n/** Valid literal types */\nexport type LiteralValue = string | number | boolean | null;\n\ntype InferSetInput<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<T, TRequired, THasDefault>\ntype InferUpdateInput<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<T, TRequired, THasDefault>\n\nexport interface LiteralProxy<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> {\n /** Gets the current literal value */\n get(): MaybeUndefined<T, TRequired, THasDefault>;\n /** Sets the literal value (must match the exact literal type) */\n set(value: InferSetInput<T, TRequired, THasDefault>): void;\n /** This is the same as set. Updates the literal value, generating a literal.set operation */\n update(value: InferUpdateInput<T, TRequired, THasDefault>): void;\n /** Returns a readonly snapshot of the literal value for rendering */\n toSnapshot(): MaybeUndefined<T, TRequired, THasDefault>;\n}\n\ninterface LiteralPrimitiveSchema<T extends LiteralValue> {\n readonly required: boolean;\n readonly defaultValue: T | undefined;\n readonly literal: T;\n}\n\nexport class LiteralPrimitive<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<T, LiteralProxy<T, TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<T, TRequired, THasDefault>, InferUpdateInput<T, TRequired, THasDefault>> {\n readonly _tag = \"LiteralPrimitive\" as const;\n readonly _State!: T;\n readonly _Proxy!: LiteralProxy<T, TRequired, THasDefault>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TUpdateInput!: InferUpdateInput<T, TRequired, THasDefault>;\n readonly TSetInput!: InferSetInput<T, TRequired, THasDefault>;\n\n private readonly _schema: LiteralPrimitiveSchema<T>;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"literal.set\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n };\n\n constructor(schema: LiteralPrimitiveSchema<T>) {\n this._schema = schema;\n }\n\n /** Mark this literal as required */\n required(): LiteralPrimitive<T, true, THasDefault> {\n return new LiteralPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this literal */\n default(defaultValue: T): LiteralPrimitive<T, TRequired, true> {\n return new LiteralPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Get the literal value this primitive represents */\n get literal(): T {\n return this._schema.literal;\n }\n\n readonly _internal: PrimitiveInternal<T, LiteralProxy<T, TRequired, THasDefault>> = {\n createProxy: (env: ProxyEnvironment.ProxyEnvironment, operationPath: OperationPath.OperationPath): LiteralProxy<T, TRequired, THasDefault> => {\n const defaultValue = this._schema.defaultValue;\n return {\n get: (): MaybeUndefined<T, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as T | undefined;\n return (state ?? defaultValue) as MaybeUndefined<T, TRequired, THasDefault>;\n },\n set: (value: InferSetInput<T, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, value)\n );\n },\n update: (value: InferUpdateInput<T, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set, value)\n );\n },\n toSnapshot: (): MaybeUndefined<T, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as T | undefined;\n return (state ?? defaultValue) as MaybeUndefined<T, TRequired, THasDefault>;\n },\n };\n },\n\n applyOperation: (_state: T | undefined, operation: Operation.Operation<any, any, any>): T => {\n if (operation.kind !== \"literal.set\") {\n throw new ValidationError(`LiteralPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n\n const payload = operation.payload;\n if (payload !== this._schema.literal) {\n throw new ValidationError(\n `LiteralPrimitive.set requires the exact literal value \"${globalThis.String(this._schema.literal)}\", got: \"${globalThis.String(payload)}\"`\n );\n }\n\n return payload as T;\n },\n\n getInitialState: (): T | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n // If paths don't overlap, no transformation needed\n if (!OperationPath.pathsOverlap(clientOp.path, serverOp.path)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For same path, client wins (last-write-wins)\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/** Creates a new LiteralPrimitive with the given literal value */\nexport const Literal = <T extends LiteralValue>(literal: T): LiteralPrimitive<T, false, false> =>\n new LiteralPrimitive({ required: false, defaultValue: undefined, literal });\n\n"],"mappings":";;;;;;;;;AAiCA,IAAa,mBAAb,MAAa,iBAAiS;CAqB5S,YAAY,QAAmC;wBApBtC,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB,EAChC,KAAKA,KAAyB;GAC5B,MAAM;GACN,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,QAAQ,YAAY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file":"Literal.mjs","names":["OperationDefinition.make","Operation.fromDefinition","OperationPath.pathsOverlap"],"sources":["../../src/primitives/Literal.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport * as OperationDefinition from \"../OperationDefinition\";\nimport * as Operation from \"../Operation\";\nimport * as OperationPath from \"../OperationPath\";\nimport * as ProxyEnvironment from \"../ProxyEnvironment\";\nimport * as Transform from \"../Transform\";\nimport type { Primitive, PrimitiveInternal, MaybeUndefined, AnyPrimitive, Validator, NeedsValue } from \"./shared\";\nimport { ValidationError, runValidators, isCompatibleOperation } from \"./shared\";\n\n\n/** Valid literal types */\nexport type LiteralValue = string | number | boolean | null;\n\ntype InferSetInput<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<T, TRequired, THasDefault>\ntype InferUpdateInput<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> = NeedsValue<T, TRequired, THasDefault>\n\nexport interface LiteralProxy<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> {\n /** Gets the current literal value */\n get(): MaybeUndefined<T, TRequired, THasDefault>;\n /** Sets the literal value (must match the exact literal type) */\n set(value: InferSetInput<T, TRequired, THasDefault>): void;\n /** This is the same as set. Updates the literal value, generating a literal.set operation */\n update(value: InferUpdateInput<T, TRequired, THasDefault>): void;\n /** Returns a readonly snapshot of the literal value for rendering */\n toSnapshot(): MaybeUndefined<T, TRequired, THasDefault>;\n}\n\ninterface LiteralPrimitiveSchema<T extends LiteralValue> {\n readonly required: boolean;\n readonly defaultValue: T | undefined;\n readonly literal: T;\n}\n\nexport class LiteralPrimitive<T extends LiteralValue, TRequired extends boolean = false, THasDefault extends boolean = false> implements Primitive<T, LiteralProxy<T, TRequired, THasDefault>, TRequired, THasDefault, InferSetInput<T, TRequired, THasDefault>, InferUpdateInput<T, TRequired, THasDefault>> {\n readonly _tag = \"LiteralPrimitive\" as const;\n readonly _State!: T;\n readonly _Proxy!: LiteralProxy<T, TRequired, THasDefault>;\n readonly _TRequired!: TRequired;\n readonly _THasDefault!: THasDefault;\n readonly TUpdateInput!: InferUpdateInput<T, TRequired, THasDefault>;\n readonly TSetInput!: InferSetInput<T, TRequired, THasDefault>;\n\n private readonly _schema: LiteralPrimitiveSchema<T>;\n\n private readonly _opDefinitions = {\n set: OperationDefinition.make({\n kind: \"literal.set\" as const,\n payload: Schema.Unknown,\n target: Schema.Unknown,\n apply: (payload) => payload,\n deduplicable: true,\n }),\n };\n\n constructor(schema: LiteralPrimitiveSchema<T>) {\n this._schema = schema;\n }\n\n /** Mark this literal as required */\n required(): LiteralPrimitive<T, true, THasDefault> {\n return new LiteralPrimitive({\n ...this._schema,\n required: true,\n });\n }\n\n /** Set a default value for this literal */\n default(defaultValue: T): LiteralPrimitive<T, TRequired, true> {\n return new LiteralPrimitive({\n ...this._schema,\n defaultValue,\n });\n }\n\n /** Get the literal value this primitive represents */\n get literal(): T {\n return this._schema.literal;\n }\n\n readonly _internal: PrimitiveInternal<T, LiteralProxy<T, TRequired, THasDefault>> = {\n createProxy: (env: ProxyEnvironment.ProxyEnvironment, operationPath: OperationPath.OperationPath): LiteralProxy<T, TRequired, THasDefault> => {\n const defaultValue = this._schema.defaultValue;\n return {\n get: (): MaybeUndefined<T, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as T | undefined;\n return (state ?? defaultValue) as MaybeUndefined<T, TRequired, THasDefault>;\n },\n set: (value: InferSetInput<T, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set as any, value)\n );\n },\n update: (value: InferUpdateInput<T, TRequired, THasDefault>) => {\n env.addOperation(\n Operation.fromDefinition(operationPath, this._opDefinitions.set as any, value)\n );\n },\n toSnapshot: (): MaybeUndefined<T, TRequired, THasDefault> => {\n const state = env.getState(operationPath) as T | undefined;\n return (state ?? defaultValue) as MaybeUndefined<T, TRequired, THasDefault>;\n },\n };\n },\n\n applyOperation: (_state: T | undefined, operation: Operation.Operation<any, any, any>): T => {\n if (operation.kind !== \"literal.set\") {\n throw new ValidationError(`LiteralPrimitive cannot apply operation of kind: ${operation.kind}`);\n }\n\n const payload = operation.payload;\n if (payload !== this._schema.literal) {\n throw new ValidationError(\n `LiteralPrimitive.set requires the exact literal value \"${globalThis.String(this._schema.literal)}\", got: \"${globalThis.String(payload)}\"`\n );\n }\n\n return payload as T;\n },\n\n getInitialState: (): T | undefined => {\n return this._schema.defaultValue;\n },\n\n transformOperation: (\n clientOp: Operation.Operation<any, any, any>,\n serverOp: Operation.Operation<any, any, any>\n ): Transform.TransformResult => {\n // If paths don't overlap, no transformation needed\n if (!OperationPath.pathsOverlap(clientOp.path, serverOp.path)) {\n return { type: \"transformed\", operation: clientOp };\n }\n\n // For same path, client wins (last-write-wins)\n return { type: \"transformed\", operation: clientOp };\n },\n };\n}\n\n/** Creates a new LiteralPrimitive with the given literal value */\nexport const Literal = <T extends LiteralValue>(literal: T): LiteralPrimitive<T, false, false> =>\n new LiteralPrimitive({ required: false, defaultValue: undefined, literal });\n\n"],"mappings":";;;;;;;;;AAiCA,IAAa,mBAAb,MAAa,iBAAiS;CAqB5S,YAAY,QAAmC;wBApBtC,QAAO;wBACP;wBACA;wBACA;wBACA;wBACA;wBACA;wBAEQ;wBAEA,kBAAiB,EAChC,KAAKA,KAAyB;GAC5B,MAAM;GACN,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,QAAQ,YAAY;GACpB,cAAc;GACf,CAAC,EACH;wBA2BQ,aAA2E;GAClF,cAAc,KAAwC,kBAAwF;IAC5I,MAAM,eAAe,KAAK,QAAQ;AAClC,WAAO;KACL,WAAsD;MACpD,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,aAAQ,6CAAS;;KAEnB,MAAM,UAAoD;AACxD,UAAI,aACFC,eAAyB,eAAe,KAAK,eAAe,KAAY,MAAM,CAC/E;;KAEH,SAAS,UAAuD;AAC9D,UAAI,aACFA,eAAyB,eAAe,KAAK,eAAe,KAAY,MAAM,CAC/E;;KAEH,kBAA6D;MAC3D,MAAM,QAAQ,IAAI,SAAS,cAAc;AACzC,aAAQ,6CAAS;;KAEpB;;GAGH,iBAAiB,QAAuB,cAAqD;AAC3F,QAAI,UAAU,SAAS,cACrB,OAAM,IAAI,gBAAgB,oDAAoD,UAAU,OAAO;IAGjG,MAAM,UAAU,UAAU;AAC1B,QAAI,YAAY,KAAK,QAAQ,QAC3B,OAAM,IAAI,gBACR,0DAA0D,WAAW,OAAO,KAAK,QAAQ,QAAQ,CAAC,WAAW,WAAW,OAAO,QAAQ,CAAC,GACzI;AAGH,WAAO;;GAGT,uBAAsC;AACpC,WAAO,KAAK,QAAQ;;GAGtB,qBACE,UACA,aAC8B;AAE9B,QAAI,CAACC,aAA2B,SAAS,MAAM,SAAS,KAAK,CAC3D,QAAO;KAAE,MAAM;KAAe,WAAW;KAAU;AAIrD,WAAO;KAAE,MAAM;KAAe,WAAW;KAAU;;GAEtD;AAhFC,OAAK,UAAU;;;CAIjB,WAAmD;AACjD,SAAO,IAAI,mDACN,KAAK,gBACR,UAAU,QACV;;;CAIJ,QAAQ,cAAuD;AAC7D,SAAO,IAAI,mDACN,KAAK,gBACR,gBACA;;;CAIJ,IAAI,UAAa;AACf,SAAO,KAAK,QAAQ;;;;AA+DxB,MAAa,WAAmC,YAC9C,IAAI,iBAAiB;CAAE,UAAU;CAAO,cAAc;CAAW;CAAS,CAAC"}
@@ -85,23 +85,45 @@ var NumberPrimitive = class NumberPrimitive {
85
85
  }
86
86
  /** Minimum value (inclusive) */
87
87
  min(value) {
88
- return this.refine((v) => v >= value, `Number must be at least ${value}`);
88
+ return new NumberPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
89
+ validate: (v) => v >= value,
90
+ message: `Number must be at least ${value}`,
91
+ kind: "min",
92
+ params: { value }
93
+ }] }));
89
94
  }
90
95
  /** Maximum value (inclusive) */
91
96
  max(value) {
92
- return this.refine((v) => v <= value, `Number must be at most ${value}`);
97
+ return new NumberPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
98
+ validate: (v) => v <= value,
99
+ message: `Number must be at most ${value}`,
100
+ kind: "max",
101
+ params: { value }
102
+ }] }));
93
103
  }
94
104
  /** Must be positive (> 0) */
95
105
  positive() {
96
- return this.refine((v) => v > 0, "Number must be positive");
106
+ return new NumberPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
107
+ validate: (v) => v > 0,
108
+ message: "Number must be positive",
109
+ kind: "positive"
110
+ }] }));
97
111
  }
98
112
  /** Must be negative (< 0) */
99
113
  negative() {
100
- return this.refine((v) => v < 0, "Number must be negative");
114
+ return new NumberPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
115
+ validate: (v) => v < 0,
116
+ message: "Number must be negative",
117
+ kind: "negative"
118
+ }] }));
101
119
  }
102
120
  /** Must be an integer */
103
121
  int() {
104
- return this.refine((v) => globalThis.Number.isInteger(v), "Number must be an integer");
122
+ return new NumberPrimitive(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, this._schema), {}, { validators: [...this._schema.validators, {
123
+ validate: (v) => globalThis.Number.isInteger(v),
124
+ message: "Number must be an integer",
125
+ kind: "int"
126
+ }] }));
105
127
  }
106
128
  };
107
129
  /** Creates a new NumberPrimitive */
@@ -1 +1 @@
1
- {"version":3,"file":"Number.d.cts","names":[],"sources":["../../src/primitives/Number.ts"],"sourcesContent":[],"mappings":";;;KAUK,wFAAwF,mBAAmB,WAAW;KACtH,2FAA2F,mBAAmB,WAAW;AADzH,UAGY,WAHC,CAAA,kBAAA,OAAA,GAAA,KAAA,EAAA,oBAAA,OAAA,GAAA,KAAA,CAAA,CAAA;EAA8F;EAAW,GAAA,EAAA,EAKlH,cALkH,CAAA,MAAA,EAK3F,SAL2F,EAKhF,WALgF,CAAA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