@voidhash/mimic 0.0.1-alpha.9 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { a as InferState, h as __export, n as AnyPrimitive, u as Transaction } from "../Primitive-Cyvy7zvF.cjs";
1
+ import { p as Transaction, r as AnyPrimitive, s as InferState, v as __export } from "../Primitive-CvFVxR8_.cjs";
2
2
 
3
3
  //#region src/server/ServerDocument.d.ts
4
4
  declare namespace ServerDocument_d_exports {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/server/ServerDocument.ts","../../src/server/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAWiB,kBAAA;;wBAEO;;;;;;AAFxB;AAUiB,UAAA,YAAA,CAAY;EASZ,SAAA,IAAA,EAAA,OAAe;EASpB,SAAA,aAAa,EAAA,MAAA;EAAG,SAAA,MAAA,EAAA,MAAA;;;;AAS5B;AAWiB,UA7BA,eAAA,CA6BqB;EAAiB,SAAA,IAAA,EAAA,UAAA;EAEpC,SAAA,KAAA,EAAA,OAAA;EAE4B,SAAA,OAAA,EAAA,MAAA;;;;AAc/C;AAAgD,KAtCpC,aAAA,GAAgB,kBAsCoB,GAtCC,YAsCD,GAtCgB,eAsChB;;;;AAgB1B,KA7CV,YAAA,GA6CU;EAA0B,SAAA,OAAA,EAAA,IAAA;EAM/B,SAAA,OAAA,EAAA,MAAA;CAAe,GAAA;EAgBnB,SAuJZ,OAAA,EAAA,KAAA;EAvJoC,SAAA,MAAA,EAAA,MAAA;CACJ;;;;AAChB,UA1DA,qBA0DA,CAAA,gBA1DsC,YA0DtC,CAAA,CAAA;;mBAxDE;;ECpDN,SAAA,YAAiB,CAAA,EDsDJ,UCtDiB,CDsDI,OCtDJ,CAAA;EAW9B;EAcA,SAAA,cAAA,CAAsB,EAAA,MAAA;EAgBtB;EAGe,SAAA,WAAA,EAAA,CAAA,OAAA,EDcM,kB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EAAA,MAEX,EAAA,OAAA,EAAuB,MAAA;AAQ/C;AASA;AASA;;AAAiD,cCLpC,qBAAA,SAA8B,gBAAA,CDKM;EAAe,SAAA,IAAA,GAAA,uBAAA;EAAe,SAAA,aAAA,EAAA,MAAA;EASnE,SAAA,IAAA,EAAY,MAAA;EAWP,WAAA,CAAA,aAAqB,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA;;;;;AAQJ,cCjBrB,oBAAA,SAA6B,gBAAA,CDiBR;EAAkB,SAAA,IAAA,GAAA,sBAAA;EAUnC,SAAA,aAAc,EAAA,MAAA;EAAiB,SAAA,KAAA,CAAA,ECxBpB,KDwBoB;EAE7B,WAAA,CAAA,aAAA,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,EAAA,KAAA,CAAA,ECxB2C,KDwB3C;;;;;AAoBF,cCjCJ,qBAAA,SAA8B,gBAAA,CDiC1B;EAAe,SAAA,IAAA,GAAA,uBAAA;EAgBnB,SAuJZ,aAAA,EAAA,MAAA;EAvJoC,WAAA,CAAA,aAAA,EAAA,MAAA;;;;;AAEpB,cCrCJ,yBAAA,SAAkC,gBAAA,CDqC9B;;;;AC5GjB"}
@@ -1,4 +1,4 @@
1
- import { a as InferState, n as AnyPrimitive, u as Transaction } from "../Primitive-CasheIbX.mjs";
1
+ import { p as Transaction, r as AnyPrimitive, s as InferState } from "../Primitive-lEhQyGVL.mjs";
2
2
 
3
3
  //#region src/server/ServerDocument.d.ts
4
4
  declare namespace ServerDocument_d_exports {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidhash/mimic",
3
- "version": "0.0.1-alpha.9",
3
+ "version": "0.0.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "typescript": "5.8.3",
32
32
  "vite-tsconfig-paths": "^5.1.4",
33
33
  "vitest": "^3.2.4",
34
- "@voidhash/tsconfig": "0.0.1-alpha.9"
34
+ "@voidhash/tsconfig": "0.0.1"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "effect": "^3.19.12"
@@ -0,0 +1,374 @@
1
+ /**
2
+ * Effect.Schema utilities for converting Mimic primitives to Effect.Schema schemas.
3
+ *
4
+ * @since 0.0.1
5
+ */
6
+ import { Schema } from "effect";
7
+ import type { AnyPrimitive, InferSetInput, InferUpdateInput } from "./primitives/shared";
8
+ import type { LiteralPrimitive, LiteralValue } from "./primitives/Literal";
9
+ import type { StructPrimitive } from "./primitives/Struct";
10
+ import type { ArrayPrimitive } from "./primitives/Array";
11
+ import type { UnionPrimitive, UnionVariants } from "./primitives/Union";
12
+ import type { EitherPrimitive, ScalarPrimitive } from "./primitives/Either";
13
+ import type { LazyPrimitive } from "./primitives/Lazy";
14
+ import type { TreeNodePrimitive, AnyTreeNodePrimitive } from "./primitives/TreeNode";
15
+
16
+ // =============================================================================
17
+ // Type-level Schema Inference
18
+ // =============================================================================
19
+
20
+ /**
21
+ * Infer the Effect.Schema type for a primitive's set input.
22
+ */
23
+ export type ToSetSchema<T extends AnyPrimitive> = Schema.Schema<InferSetInput<T>>;
24
+
25
+ /**
26
+ * Infer the Effect.Schema type for a primitive's update input.
27
+ */
28
+ export type ToUpdateSchema<T extends AnyPrimitive> = Schema.Schema<InferUpdateInput<T>>;
29
+
30
+ /**
31
+ * Type for TreeNode set schema - uses the node's data set input type
32
+ */
33
+ export type ToTreeNodeSetSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferSetInput<T["data"]>>;
34
+
35
+ /**
36
+ * Type for TreeNode update schema - uses the node's data update input type
37
+ */
38
+ export type ToTreeNodeUpdateSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferUpdateInput<T["data"]>>;
39
+
40
+ // =============================================================================
41
+ // Schema for TreeNodeState
42
+ // =============================================================================
43
+
44
+ /**
45
+ * Schema for a tree node state (flat storage format).
46
+ */
47
+ export const TreeNodeStateSchema = Schema.Struct({
48
+ id: Schema.String,
49
+ type: Schema.String,
50
+ parentId: Schema.NullOr(Schema.String),
51
+ pos: Schema.String,
52
+ data: Schema.Unknown,
53
+ });
54
+
55
+ // =============================================================================
56
+ // Internal type for primitives (including those that don't implement full Primitive interface)
57
+ // =============================================================================
58
+
59
+ /**
60
+ * Internal type for anything that can be converted to a schema.
61
+ * This includes both AnyPrimitive and AnyTreeNodePrimitive.
62
+ */
63
+ type ConvertiblePrimitive = { _tag: string };
64
+
65
+ // =============================================================================
66
+ // Runtime Conversion Functions
67
+ // =============================================================================
68
+
69
+ /**
70
+ * Check if a field is required for set operations.
71
+ * A field is required if: TRequired is true AND THasDefault is false.
72
+ *
73
+ * We determine this by checking the primitive's schema properties.
74
+ */
75
+ function isRequiredForSet(primitive: ConvertiblePrimitive): boolean {
76
+ // Access the private schema to check required and default status
77
+ const schema = (primitive as any)._schema;
78
+ if (!schema) return false;
79
+
80
+ return schema.required === true && schema.defaultValue === undefined;
81
+ }
82
+
83
+ /**
84
+ * Get the base Effect.Schema for a primitive type (without optional wrapper).
85
+ */
86
+ function getBaseSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {
87
+ switch (primitive._tag) {
88
+ case "StringPrimitive":
89
+ return Schema.String;
90
+
91
+ case "NumberPrimitive":
92
+ return Schema.Number;
93
+
94
+ case "BooleanPrimitive":
95
+ return Schema.Boolean;
96
+
97
+ case "LiteralPrimitive": {
98
+ const literalPrimitive = primitive as unknown as LiteralPrimitive<LiteralValue, any, any>;
99
+ const literalValue = (literalPrimitive as any)._schema?.literal ?? (literalPrimitive as any).literal;
100
+ return Schema.Literal(literalValue);
101
+ }
102
+
103
+ case "StructPrimitive": {
104
+ const structPrimitive = primitive as unknown as StructPrimitive<Record<string, AnyPrimitive>, any, any>;
105
+ return buildStructSetSchema(structPrimitive);
106
+ }
107
+
108
+ case "ArrayPrimitive": {
109
+ const arrayPrimitive = primitive as unknown as ArrayPrimitive<AnyPrimitive, any, any>;
110
+ const elementSchema = buildElementSetSchema(arrayPrimitive.element);
111
+ return Schema.Array(elementSchema);
112
+ }
113
+
114
+ case "UnionPrimitive": {
115
+ const unionPrimitive = primitive as unknown as UnionPrimitive<UnionVariants, any, any, any>;
116
+ return buildUnionSetSchema(unionPrimitive);
117
+ }
118
+
119
+ case "EitherPrimitive": {
120
+ const eitherPrimitive = primitive as unknown as EitherPrimitive<readonly ScalarPrimitive[], any, any>;
121
+ return buildEitherSchema(eitherPrimitive);
122
+ }
123
+
124
+ case "LazyPrimitive": {
125
+ const lazyPrimitive = primitive as unknown as LazyPrimitive<() => AnyPrimitive>;
126
+ // Resolve the lazy primitive and get its schema
127
+ const resolved = (lazyPrimitive as any)._resolve?.() ?? (lazyPrimitive as any)._thunk();
128
+ return getBaseSchema(resolved);
129
+ }
130
+
131
+ case "TreeNodePrimitive": {
132
+ const treeNodePrimitive = primitive as unknown as TreeNodePrimitive<string, StructPrimitive<any>, any>;
133
+ // TreeNode delegates to its data struct
134
+ return buildStructSetSchema(treeNodePrimitive.data);
135
+ }
136
+
137
+ case "TreePrimitive": {
138
+ // Tree returns an array of TreeNodeState
139
+ return Schema.Array(TreeNodeStateSchema);
140
+ }
141
+
142
+ default:
143
+ return Schema.Unknown;
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Build the set schema for a struct primitive.
149
+ * Required fields (required=true, no default) are non-optional.
150
+ * Other fields are wrapped with Schema.optional.
151
+ */
152
+ function buildStructSetSchema(structPrimitive: StructPrimitive<Record<string, AnyPrimitive>, any, any>): Schema.Schema<any> {
153
+ const fields = structPrimitive.fields;
154
+ // Use any to avoid complex Schema type constraints
155
+ const schemaFields: Record<string, any> = {};
156
+
157
+ for (const key in fields) {
158
+ const fieldPrimitive = fields[key]!;
159
+ const baseSchema = getBaseSchema(fieldPrimitive);
160
+
161
+ if (isRequiredForSet(fieldPrimitive)) {
162
+ // Required field - use base schema directly
163
+ schemaFields[key] = baseSchema;
164
+ } else {
165
+ // Optional field - wrap with Schema.optional
166
+ schemaFields[key] = Schema.optional(baseSchema);
167
+ }
168
+ }
169
+
170
+ return Schema.Struct(schemaFields) as any;
171
+ }
172
+
173
+ /**
174
+ * Build the update schema for a struct primitive.
175
+ * All fields are optional for partial updates.
176
+ */
177
+ function buildStructUpdateSchema(structPrimitive: StructPrimitive<Record<string, AnyPrimitive>, any, any>): Schema.Schema<any> {
178
+ const fields = structPrimitive.fields;
179
+ // Use any to avoid complex Schema type constraints
180
+ const schemaFields: Record<string, any> = {};
181
+
182
+ for (const key in fields) {
183
+ const fieldPrimitive = fields[key]!;
184
+ // For update, use the update schema for nested structs, otherwise base schema
185
+ let fieldSchema: Schema.Schema<any>;
186
+
187
+ if (fieldPrimitive._tag === "StructPrimitive") {
188
+ fieldSchema = buildStructUpdateSchema(fieldPrimitive as StructPrimitive<Record<string, AnyPrimitive>, any, any>);
189
+ } else {
190
+ fieldSchema = getBaseSchema(fieldPrimitive);
191
+ }
192
+
193
+ // All fields are optional in update
194
+ schemaFields[key] = Schema.optional(fieldSchema);
195
+ }
196
+
197
+ return Schema.Struct(schemaFields) as any;
198
+ }
199
+
200
+ /**
201
+ * Build the set schema for an array element.
202
+ * For struct elements, uses the struct's set input schema.
203
+ */
204
+ function buildElementSetSchema(elementPrimitive: AnyPrimitive): Schema.Schema<any> {
205
+ if (elementPrimitive._tag === "StructPrimitive") {
206
+ return buildStructSetSchema(elementPrimitive as StructPrimitive<Record<string, AnyPrimitive>, any, any>);
207
+ }
208
+ return getBaseSchema(elementPrimitive);
209
+ }
210
+
211
+ /**
212
+ * Build the set schema for a union primitive.
213
+ * Creates a Schema.Union of all variant schemas.
214
+ */
215
+ function buildUnionSetSchema(unionPrimitive: UnionPrimitive<UnionVariants, any, any, any>): Schema.Schema<any> {
216
+ const variants = unionPrimitive.variants;
217
+ const variantSchemas: Schema.Schema<any>[] = [];
218
+
219
+ for (const key in variants) {
220
+ const variantPrimitive = variants[key]!;
221
+ variantSchemas.push(buildStructSetSchema(variantPrimitive));
222
+ }
223
+
224
+ if (variantSchemas.length === 0) {
225
+ return Schema.Unknown;
226
+ }
227
+
228
+ if (variantSchemas.length === 1) {
229
+ return variantSchemas[0]!;
230
+ }
231
+
232
+ return Schema.Union(...variantSchemas as [Schema.Schema<any>, Schema.Schema<any>, ...Schema.Schema<any>[]]);
233
+ }
234
+
235
+ /**
236
+ * Build the schema for an either primitive.
237
+ * Creates a Schema.Union of all scalar variant types.
238
+ */
239
+ function buildEitherSchema(eitherPrimitive: EitherPrimitive<readonly ScalarPrimitive[], any, any>): Schema.Schema<any> {
240
+ const variants = eitherPrimitive.variants;
241
+ const variantSchemas: Schema.Schema<any>[] = [];
242
+
243
+ for (const variant of variants) {
244
+ variantSchemas.push(getBaseSchema(variant as unknown as ConvertiblePrimitive));
245
+ }
246
+
247
+ if (variantSchemas.length === 0) {
248
+ return Schema.Unknown;
249
+ }
250
+
251
+ if (variantSchemas.length === 1) {
252
+ return variantSchemas[0]!;
253
+ }
254
+
255
+ return Schema.Union(...variantSchemas as [Schema.Schema<any>, Schema.Schema<any>, ...Schema.Schema<any>[]]);
256
+ }
257
+
258
+ /**
259
+ * Build the update schema for a union primitive.
260
+ * Creates a Schema.Union of all variant update schemas.
261
+ */
262
+ function buildUnionUpdateSchema(unionPrimitive: UnionPrimitive<UnionVariants, any, any, any>): Schema.Schema<any> {
263
+ const variants = unionPrimitive.variants;
264
+ const variantSchemas: Schema.Schema<any>[] = [];
265
+
266
+ for (const key in variants) {
267
+ const variantPrimitive = variants[key]!;
268
+ variantSchemas.push(buildStructUpdateSchema(variantPrimitive));
269
+ }
270
+
271
+ if (variantSchemas.length === 0) {
272
+ return Schema.Unknown;
273
+ }
274
+
275
+ if (variantSchemas.length === 1) {
276
+ return variantSchemas[0]!;
277
+ }
278
+
279
+ return Schema.Union(...variantSchemas as [Schema.Schema<any>, Schema.Schema<any>, ...Schema.Schema<any>[]]);
280
+ }
281
+
282
+ /**
283
+ * Get the update schema for a primitive.
284
+ * For structs, all fields are optional (partial updates).
285
+ * For simple primitives, same as set schema.
286
+ */
287
+ function getUpdateSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {
288
+ switch (primitive._tag) {
289
+ case "StructPrimitive": {
290
+ const structPrimitive = primitive as unknown as StructPrimitive<Record<string, AnyPrimitive>, any, any>;
291
+ return buildStructUpdateSchema(structPrimitive);
292
+ }
293
+
294
+ case "UnionPrimitive": {
295
+ const unionPrimitive = primitive as unknown as UnionPrimitive<UnionVariants, any, any, any>;
296
+ return buildUnionUpdateSchema(unionPrimitive);
297
+ }
298
+
299
+ case "TreeNodePrimitive": {
300
+ const treeNodePrimitive = primitive as unknown as TreeNodePrimitive<string, StructPrimitive<any>, any>;
301
+ // TreeNode update delegates to data struct's update schema (all fields optional)
302
+ return buildStructUpdateSchema(treeNodePrimitive.data);
303
+ }
304
+
305
+ case "LazyPrimitive": {
306
+ const lazyPrimitive = primitive as unknown as LazyPrimitive<() => AnyPrimitive>;
307
+ const resolved = (lazyPrimitive as any)._resolve?.() ?? (lazyPrimitive as any)._thunk();
308
+ return getUpdateSchema(resolved);
309
+ }
310
+
311
+ default:
312
+ // For simple primitives, update schema is same as set schema
313
+ return getBaseSchema(primitive);
314
+ }
315
+ }
316
+
317
+ // =============================================================================
318
+ // Public API
319
+ // =============================================================================
320
+
321
+ /**
322
+ * Convert a Mimic primitive to an Effect.Schema for set operations.
323
+ *
324
+ * The resulting schema:
325
+ * - For structs: required fields (required=true, no default) are non-optional, others are optional
326
+ * - For arrays: uses the element's set schema
327
+ * - For unions: creates a Schema.Union of variant schemas
328
+ * - For TreeNode: delegates to the node's data struct schema
329
+ * - For Tree: returns Schema.Array of TreeNodeState
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * const UserSchema = Primitive.Struct({
334
+ * name: Primitive.String().required(),
335
+ * age: Primitive.Number().default(0),
336
+ * email: Primitive.String(),
337
+ * });
338
+ *
339
+ * const SetSchema = toSetSchema(UserSchema);
340
+ * // { name: string, age?: number, email?: string }
341
+ * ```
342
+ */
343
+ export function toSetSchema<T extends AnyPrimitive>(primitive: T): ToSetSchema<T>;
344
+ export function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeSetSchema<T>;
345
+ export function toSetSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {
346
+ return getBaseSchema(primitive);
347
+ }
348
+
349
+ /**
350
+ * Convert a Mimic primitive to an Effect.Schema for update operations.
351
+ *
352
+ * The resulting schema:
353
+ * - For structs: all fields are optional (partial updates)
354
+ * - For unions: all variant fields are optional
355
+ * - For TreeNode: delegates to the node's data struct update schema
356
+ * - For simple primitives: same as set schema
357
+ *
358
+ * @example
359
+ * ```typescript
360
+ * const UserSchema = Primitive.Struct({
361
+ * name: Primitive.String().required(),
362
+ * age: Primitive.Number().default(0),
363
+ * email: Primitive.String(),
364
+ * });
365
+ *
366
+ * const UpdateSchema = toUpdateSchema(UserSchema);
367
+ * // { name?: string, age?: string, email?: string }
368
+ * ```
369
+ */
370
+ export function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
371
+ export function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
372
+ export function toUpdateSchema(primitive: ConvertiblePrimitive): Schema.Schema<any> {
373
+ return getUpdateSchema(primitive);
374
+ }
package/src/index.ts CHANGED
@@ -10,3 +10,4 @@ export * as OperationPath from "./OperationPath.js";
10
10
  export * as ProxyEnvironment from "./ProxyEnvironment.js";
11
11
  export * as Transform from "./Transform.js";
12
12
  export * as Presence from "./Presence.js";
13
+ export * as EffectSchema from "./EffectSchema.js";