@voidhash/mimic 0.0.1-alpha.6 → 0.0.1-alpha.7

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,5 +1,5 @@
1
1
 
2
- > @voidhash/mimic@0.0.1-alpha.6 build /home/runner/work/mimic/mimic/packages/mimic
2
+ > @voidhash/mimic@0.0.1-alpha.7 build /home/runner/work/mimic/mimic/packages/mimic
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.18.2 powered by rolldown v1.0.0-beta.55
@@ -8,16 +8,16 @@
8
8
  ℹ target: es2017
9
9
  ℹ tsconfig: tsconfig.json
10
10
  ℹ Build start
11
- ℹ [CJS] dist/index.cjs 104.81 kB │ gzip: 18.03 kB
12
- ℹ [CJS] 1 files, total: 104.81 kB
13
- ℹ [CJS] dist/index.d.cts.map 17.03 kB │ gzip: 6.98 kB
14
- ℹ [CJS] dist/index.d.cts 47.94 kB │ gzip: 9.92 kB
15
- ℹ [CJS] 2 files, total: 64.97 kB
16
- ✔ Build complete in 5474ms
17
- ℹ [ESM] dist/index.mjs 102.22 kB │ gzip: 17.54 kB
18
- ℹ [ESM] dist/index.mjs.map 252.40 kB │ gzip: 44.92 kB
19
- ℹ [ESM] dist/index.d.mts.map  22.70 kB │ gzip: 9.13 kB
11
+ ℹ [CJS] dist/index.cjs 109.50 kB │ gzip: 18.89 kB
12
+ ℹ [CJS] 1 files, total: 109.50 kB
13
+ ℹ [CJS] dist/index.d.cts.map 21.02 kB │ gzip: 8.61 kB
14
+ ℹ [CJS] dist/index.d.cts 55.20 kB │ gzip: 11.08 kB
15
+ ℹ [CJS] 2 files, total: 76.22 kB
16
+ ✔ Build complete in 5517ms
17
+ ℹ [ESM] dist/index.mjs 106.90 kB │ gzip: 18.40 kB
18
+ ℹ [ESM] dist/index.mjs.map 269.06 kB │ gzip: 48.01 kB
19
+ ℹ [ESM] dist/index.d.mts.map  26.03 kB │ gzip: 10.67 kB
20
20
  ℹ [ESM] dist/chunk-C6wwvPpM.mjs  0.36 kB │ gzip: 0.25 kB
21
- ℹ [ESM] dist/index.d.mts  47.95 kB │ gzip: 9.91 kB
22
- ℹ [ESM] 5 files, total: 425.63 kB
23
- ✔ Build complete in 5485ms
21
+ ℹ [ESM] dist/index.d.mts  55.21 kB │ gzip: 11.07 kB
22
+ ℹ [ESM] 5 files, total: 457.56 kB
23
+ ✔ Build complete in 5525ms
package/dist/index.cjs CHANGED
@@ -83,6 +83,30 @@ function _defineProperty(e, r, t) {
83
83
  }) : e[r] = t, e;
84
84
  }
85
85
 
86
+ //#endregion
87
+ //#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
88
+ function ownKeys(e, r) {
89
+ var t = Object.keys(e);
90
+ if (Object.getOwnPropertySymbols) {
91
+ var o = Object.getOwnPropertySymbols(e);
92
+ r && (o = o.filter(function(r$1) {
93
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
94
+ })), t.push.apply(t, o);
95
+ }
96
+ return t;
97
+ }
98
+ function _objectSpread2(e) {
99
+ for (var r = 1; r < arguments.length; r++) {
100
+ var t = null != arguments[r] ? arguments[r] : {};
101
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
102
+ _defineProperty(e, r$1, t[r$1]);
103
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
104
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
105
+ });
106
+ }
107
+ return e;
108
+ }
109
+
86
110
  //#endregion
87
111
  //#region src/primitives/shared.ts
88
112
  var ValidationError = class extends Error {
@@ -107,6 +131,34 @@ function runValidators(value, validators) {
107
131
  function isCompatibleOperation(operation, operationDefinitions) {
108
132
  return Object.values(operationDefinitions).some((value) => value.kind === operation.kind);
109
133
  }
134
+ /**
135
+ * Applies default values to a partial input, recursively handling nested structs.
136
+ *
137
+ * Uses a two-layer approach:
138
+ * 1. First, get the struct's initial state (which includes struct-level defaults)
139
+ * 2. Then, layer the provided values on top
140
+ * 3. Finally, ensure nested structs are recursively processed
141
+ *
142
+ * @param primitive - The primitive definition containing field information
143
+ * @param value - The partial value provided by the user
144
+ * @returns The value with defaults applied for missing fields
145
+ */
146
+ function applyDefaults(primitive, value) {
147
+ if (primitive._tag === "StructPrimitive") {
148
+ var _structPrimitive$_int;
149
+ const structPrimitive = primitive;
150
+ const result = _objectSpread2(_objectSpread2({}, (_structPrimitive$_int = structPrimitive._internal.getInitialState()) !== null && _structPrimitive$_int !== void 0 ? _structPrimitive$_int : {}), value);
151
+ for (const key in structPrimitive.fields) {
152
+ const fieldPrimitive = structPrimitive.fields[key];
153
+ if (result[key] === void 0) {
154
+ const fieldDefault = fieldPrimitive._internal.getInitialState();
155
+ if (fieldDefault !== void 0) result[key] = fieldDefault;
156
+ } else if (fieldPrimitive._tag === "StructPrimitive" && typeof result[key] === "object" && result[key] !== null) result[key] = applyDefaults(fieldPrimitive, result[key]);
157
+ }
158
+ return result;
159
+ }
160
+ return value;
161
+ }
110
162
 
111
163
  //#endregion
112
164
  //#region src/OperationDefinition.ts
@@ -294,30 +346,6 @@ const decode$1 = (encoded) => {
294
346
  };
295
347
  };
296
348
 
297
- //#endregion
298
- //#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
299
- function ownKeys(e, r) {
300
- var t = Object.keys(e);
301
- if (Object.getOwnPropertySymbols) {
302
- var o = Object.getOwnPropertySymbols(e);
303
- r && (o = o.filter(function(r$1) {
304
- return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
305
- })), t.push.apply(t, o);
306
- }
307
- return t;
308
- }
309
- function _objectSpread2(e) {
310
- for (var r = 1; r < arguments.length; r++) {
311
- var t = null != arguments[r] ? arguments[r] : {};
312
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
313
- _defineProperty(e, r$1, t[r$1]);
314
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
315
- Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
316
- });
317
- }
318
- return e;
319
- }
320
-
321
349
  //#endregion
322
350
  //#region src/primitives/String.ts
323
351
  var StringPrimitive = class StringPrimitive {
@@ -325,6 +353,8 @@ var StringPrimitive = class StringPrimitive {
325
353
  _defineProperty(this, "_tag", "StringPrimitive");
326
354
  _defineProperty(this, "_State", void 0);
327
355
  _defineProperty(this, "_Proxy", void 0);
356
+ _defineProperty(this, "_TDefined", void 0);
357
+ _defineProperty(this, "_THasDefault", void 0);
328
358
  _defineProperty(this, "_schema", void 0);
329
359
  _defineProperty(this, "_opDefinitions", { set: make$5({
330
360
  kind: "string.set",
@@ -434,6 +464,8 @@ var StructPrimitive = class StructPrimitive {
434
464
  _defineProperty(this, "_tag", "StructPrimitive");
435
465
  _defineProperty(this, "_State", void 0);
436
466
  _defineProperty(this, "_Proxy", void 0);
467
+ _defineProperty(this, "_TDefined", void 0);
468
+ _defineProperty(this, "_THasDefault", void 0);
437
469
  _defineProperty(this, "_schema", void 0);
438
470
  _defineProperty(this, "_opDefinitions", { set: make$5({
439
471
  kind: "struct.set",
@@ -465,7 +497,20 @@ var StructPrimitive = class StructPrimitive {
465
497
  return state !== null && state !== void 0 ? state : defaultValue;
466
498
  },
467
499
  set: (value) => {
468
- env.addOperation(fromDefinition(operationPath, this._opDefinitions.set, value));
500
+ const merged = applyDefaults(this, value);
501
+ env.addOperation(fromDefinition(operationPath, this._opDefinitions.set, merged));
502
+ },
503
+ update: (value) => {
504
+ for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) {
505
+ const fieldValue = value[key];
506
+ if (fieldValue === void 0) continue;
507
+ const fieldPrimitive = fields[key];
508
+ if (!fieldPrimitive) continue;
509
+ const fieldPath = operationPath.append(key);
510
+ const fieldProxy = fieldPrimitive._internal.createProxy(env, fieldPath);
511
+ if (fieldPrimitive._tag === "StructPrimitive" && typeof fieldValue === "object" && fieldValue !== null && !Array.isArray(fieldValue)) fieldProxy.update(fieldValue);
512
+ else fieldProxy.set(fieldValue);
513
+ }
469
514
  },
470
515
  toSnapshot: () => {
471
516
  return buildSnapshot();
@@ -474,6 +519,7 @@ var StructPrimitive = class StructPrimitive {
474
519
  get: (target, prop, _receiver) => {
475
520
  if (prop === "get") return target.get;
476
521
  if (prop === "set") return target.set;
522
+ if (prop === "update") return target.update;
477
523
  if (prop === "toSnapshot") return target.toSnapshot;
478
524
  if (typeof prop === "symbol") return;
479
525
  if (prop in fields) {
@@ -483,7 +529,7 @@ var StructPrimitive = class StructPrimitive {
483
529
  }
484
530
  },
485
531
  has: (_target, prop) => {
486
- if (prop === "get" || prop === "set" || prop === "toSnapshot") return true;
532
+ if (prop === "get" || prop === "set" || prop === "update" || prop === "toSnapshot") return true;
487
533
  if (typeof prop === "string" && prop in fields) return true;
488
534
  return false;
489
535
  }
@@ -581,7 +627,8 @@ var StructPrimitive = class StructPrimitive {
581
627
  }
582
628
  /** Set a default value for this struct */
583
629
  default(defaultValue) {
584
- return new StructPrimitive(_objectSpread2(_objectSpread2({}, this._schema), {}, { defaultValue }));
630
+ const merged = applyDefaults(this, defaultValue);
631
+ return new StructPrimitive(_objectSpread2(_objectSpread2({}, this._schema), {}, { defaultValue: merged }));
585
632
  }
586
633
  /** Get the fields schema */
587
634
  get fields() {
@@ -610,6 +657,8 @@ var BooleanPrimitive = class BooleanPrimitive {
610
657
  _defineProperty(this, "_tag", "BooleanPrimitive");
611
658
  _defineProperty(this, "_State", void 0);
612
659
  _defineProperty(this, "_Proxy", void 0);
660
+ _defineProperty(this, "_TDefined", void 0);
661
+ _defineProperty(this, "_THasDefault", void 0);
613
662
  _defineProperty(this, "_schema", void 0);
614
663
  _defineProperty(this, "_opDefinitions", { set: make$5({
615
664
  kind: "boolean.set",
@@ -687,6 +736,8 @@ var NumberPrimitive = class NumberPrimitive {
687
736
  _defineProperty(this, "_tag", "NumberPrimitive");
688
737
  _defineProperty(this, "_State", void 0);
689
738
  _defineProperty(this, "_Proxy", void 0);
739
+ _defineProperty(this, "_TDefined", void 0);
740
+ _defineProperty(this, "_THasDefault", void 0);
690
741
  _defineProperty(this, "_schema", void 0);
691
742
  _defineProperty(this, "_opDefinitions", { set: make$5({
692
743
  kind: "number.set",
@@ -784,6 +835,8 @@ var LiteralPrimitive = class LiteralPrimitive {
784
835
  _defineProperty(this, "_tag", "LiteralPrimitive");
785
836
  _defineProperty(this, "_State", void 0);
786
837
  _defineProperty(this, "_Proxy", void 0);
838
+ _defineProperty(this, "_TDefined", void 0);
839
+ _defineProperty(this, "_THasDefault", void 0);
787
840
  _defineProperty(this, "_schema", void 0);
788
841
  _defineProperty(this, "_opDefinitions", { set: make$5({
789
842
  kind: "literal.set",
@@ -1228,6 +1281,8 @@ var ArrayPrimitive = class ArrayPrimitive {
1228
1281
  _defineProperty(this, "_tag", "ArrayPrimitive");
1229
1282
  _defineProperty(this, "_State", void 0);
1230
1283
  _defineProperty(this, "_Proxy", void 0);
1284
+ _defineProperty(this, "_TDefined", void 0);
1285
+ _defineProperty(this, "_THasDefault", void 0);
1231
1286
  _defineProperty(this, "_schema", void 0);
1232
1287
  _defineProperty(this, "_opDefinitions", {
1233
1288
  set: make$5({
@@ -1263,6 +1318,9 @@ var ArrayPrimitive = class ArrayPrimitive {
1263
1318
  if (!state || !globalThis.Array.isArray(state)) return [];
1264
1319
  return sortByPos(state);
1265
1320
  };
1321
+ const applyElementDefaults = (value) => {
1322
+ return applyDefaults(elementPrimitive, value);
1323
+ };
1266
1324
  return {
1267
1325
  get: () => {
1268
1326
  return getCurrentState();
@@ -1273,10 +1331,11 @@ var ArrayPrimitive = class ArrayPrimitive {
1273
1331
  for (const value of values) {
1274
1332
  const id = env.generateId();
1275
1333
  const pos = generatePosBetween(prevPos, null);
1334
+ const mergedValue = applyElementDefaults(value);
1276
1335
  entries.push({
1277
1336
  id,
1278
1337
  pos,
1279
- value
1338
+ value: mergedValue
1280
1339
  });
1281
1340
  prevPos = pos;
1282
1341
  }
@@ -1287,10 +1346,11 @@ var ArrayPrimitive = class ArrayPrimitive {
1287
1346
  const lastPos = sorted.length > 0 ? sorted[sorted.length - 1].pos : null;
1288
1347
  const id = env.generateId();
1289
1348
  const pos = generatePosBetween(lastPos, null);
1349
+ const mergedValue = applyElementDefaults(value);
1290
1350
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
1291
1351
  id,
1292
1352
  pos,
1293
- value
1353
+ value: mergedValue
1294
1354
  }));
1295
1355
  },
1296
1356
  insertAt: (index, value) => {
@@ -1299,10 +1359,11 @@ var ArrayPrimitive = class ArrayPrimitive {
1299
1359
  const rightPos = index < sorted.length && sorted[index] ? sorted[index].pos : null;
1300
1360
  const id = env.generateId();
1301
1361
  const pos = generatePosBetween(leftPos, rightPos);
1362
+ const mergedValue = applyElementDefaults(value);
1302
1363
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
1303
1364
  id,
1304
1365
  pos,
1305
- value
1366
+ value: mergedValue
1306
1367
  }));
1307
1368
  },
1308
1369
  remove: (id) => {
@@ -1534,6 +1595,8 @@ var UnionPrimitive = class UnionPrimitive {
1534
1595
  _defineProperty(this, "_tag", "UnionPrimitive");
1535
1596
  _defineProperty(this, "_State", void 0);
1536
1597
  _defineProperty(this, "_Proxy", void 0);
1598
+ _defineProperty(this, "_TDefined", void 0);
1599
+ _defineProperty(this, "_THasDefault", void 0);
1537
1600
  _defineProperty(this, "_schema", void 0);
1538
1601
  _defineProperty(this, "_opDefinitions", { set: make$5({
1539
1602
  kind: "union.set",
@@ -1551,7 +1614,8 @@ var UnionPrimitive = class UnionPrimitive {
1551
1614
  return state !== null && state !== void 0 ? state : defaultValue;
1552
1615
  },
1553
1616
  set: (value) => {
1554
- env.addOperation(fromDefinition(operationPath, this._opDefinitions.set, value));
1617
+ const merged = this._applyVariantDefaults(value);
1618
+ env.addOperation(fromDefinition(operationPath, this._opDefinitions.set, merged));
1555
1619
  },
1556
1620
  as: (variant) => {
1557
1621
  const variantPrimitive = variants[variant];
@@ -1640,7 +1704,8 @@ var UnionPrimitive = class UnionPrimitive {
1640
1704
  }
1641
1705
  /** Set a default value for this union */
1642
1706
  default(defaultValue) {
1643
- return new UnionPrimitive(_objectSpread2(_objectSpread2({}, this._schema), {}, { defaultValue }));
1707
+ const merged = this._applyVariantDefaults(defaultValue);
1708
+ return new UnionPrimitive(_objectSpread2(_objectSpread2({}, this._schema), {}, { defaultValue: merged }));
1644
1709
  }
1645
1710
  /** Get the discriminator field name */
1646
1711
  get discriminator() {
@@ -1661,6 +1726,13 @@ var UnionPrimitive = class UnionPrimitive {
1661
1726
  }
1662
1727
  }
1663
1728
  }
1729
+ /** Apply defaults to a variant value based on the discriminator */
1730
+ _applyVariantDefaults(value) {
1731
+ const variantKey = this._findVariantKey(value);
1732
+ if (!variantKey) return value;
1733
+ const variantPrimitive = this._schema.variants[variantKey];
1734
+ return applyDefaults(variantPrimitive, value);
1735
+ }
1664
1736
  };
1665
1737
  function Union(options) {
1666
1738
  var _options$discriminato;
@@ -1679,6 +1751,8 @@ var EitherPrimitive = class EitherPrimitive {
1679
1751
  _defineProperty(this, "_tag", "EitherPrimitive");
1680
1752
  _defineProperty(this, "_State", void 0);
1681
1753
  _defineProperty(this, "_Proxy", void 0);
1754
+ _defineProperty(this, "_TDefined", void 0);
1755
+ _defineProperty(this, "_THasDefault", void 0);
1682
1756
  _defineProperty(this, "_schema", void 0);
1683
1757
  _defineProperty(this, "_opDefinitions", { set: make$5({
1684
1758
  kind: "either.set",
@@ -1960,6 +2034,8 @@ var TreePrimitive = class TreePrimitive {
1960
2034
  _defineProperty(this, "_tag", "TreePrimitive");
1961
2035
  _defineProperty(this, "_State", void 0);
1962
2036
  _defineProperty(this, "_Proxy", void 0);
2037
+ _defineProperty(this, "_TDefined", void 0);
2038
+ _defineProperty(this, "_THasDefault", void 0);
1963
2039
  _defineProperty(this, "_schema", void 0);
1964
2040
  _defineProperty(this, "_nodeTypeRegistry", void 0);
1965
2041
  _defineProperty(this, "_opDefinitions", {
@@ -2010,11 +2086,15 @@ var TreePrimitive = class TreePrimitive {
2010
2086
  as: (nodeType) => {
2011
2087
  if (nodeState.type !== nodeType.type) throw new ValidationError(`Node is of type "${nodeState.type}", not "${nodeType.type}"`);
2012
2088
  const nodePath = operationPath.append(nodeState.id);
2089
+ const dataProxy = nodeType.data._internal.createProxy(env, nodePath);
2013
2090
  return {
2014
2091
  id: nodeState.id,
2015
2092
  type: nodeType.type,
2016
- data: nodeType.data._internal.createProxy(env, nodePath),
2017
- get: () => nodeState
2093
+ data: dataProxy,
2094
+ get: () => nodeState,
2095
+ update: (value) => {
2096
+ dataProxy.update(value);
2097
+ }
2018
2098
  };
2019
2099
  },
2020
2100
  get: () => nodeState
@@ -2061,12 +2141,13 @@ var TreePrimitive = class TreePrimitive {
2061
2141
  const parentType = getParentType(parentId);
2062
2142
  this._validateChildType(parentType, nodeType.type);
2063
2143
  if (parentId === null && state.some((n) => n.parentId === null)) throw new ValidationError("Tree already has a root node");
2144
+ const mergedData = applyDefaults(nodeType.data, data);
2064
2145
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
2065
2146
  id,
2066
2147
  type: nodeType.type,
2067
2148
  parentId,
2068
2149
  pos,
2069
- data
2150
+ data: mergedData
2070
2151
  }));
2071
2152
  return id;
2072
2153
  },
@@ -2079,12 +2160,13 @@ var TreePrimitive = class TreePrimitive {
2079
2160
  const parentType = getParentType(parentId);
2080
2161
  this._validateChildType(parentType, nodeType.type);
2081
2162
  if (parentId === null && state.some((n) => n.parentId === null)) throw new ValidationError("Tree already has a root node");
2163
+ const mergedData = applyDefaults(nodeType.data, data);
2082
2164
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
2083
2165
  id,
2084
2166
  type: nodeType.type,
2085
2167
  parentId,
2086
2168
  pos,
2087
- data
2169
+ data: mergedData
2088
2170
  }));
2089
2171
  return id;
2090
2172
  },
@@ -2098,12 +2180,13 @@ var TreePrimitive = class TreePrimitive {
2098
2180
  const parentType = getParentType(parentId);
2099
2181
  this._validateChildType(parentType, nodeType.type);
2100
2182
  if (parentId === null && state.some((n) => n.parentId === null)) throw new ValidationError("Tree already has a root node");
2183
+ const mergedData = applyDefaults(nodeType.data, data);
2101
2184
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
2102
2185
  id,
2103
2186
  type: nodeType.type,
2104
2187
  parentId,
2105
2188
  pos,
2106
- data
2189
+ data: mergedData
2107
2190
  }));
2108
2191
  return id;
2109
2192
  },
@@ -2119,12 +2202,13 @@ var TreePrimitive = class TreePrimitive {
2119
2202
  const id = env.generateId();
2120
2203
  const parentType = getParentType(parentId);
2121
2204
  this._validateChildType(parentType, nodeType.type);
2205
+ const mergedData = applyDefaults(nodeType.data, data);
2122
2206
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
2123
2207
  id,
2124
2208
  type: nodeType.type,
2125
2209
  parentId,
2126
2210
  pos,
2127
- data
2211
+ data: mergedData
2128
2212
  }));
2129
2213
  return id;
2130
2214
  },
@@ -2140,12 +2224,13 @@ var TreePrimitive = class TreePrimitive {
2140
2224
  const id = env.generateId();
2141
2225
  const parentType = getParentType(parentId);
2142
2226
  this._validateChildType(parentType, nodeType.type);
2227
+ const mergedData = applyDefaults(nodeType.data, data);
2143
2228
  env.addOperation(fromDefinition(operationPath, this._opDefinitions.insert, {
2144
2229
  id,
2145
2230
  type: nodeType.type,
2146
2231
  parentId,
2147
2232
  pos,
2148
- data
2233
+ data: mergedData
2149
2234
  }));
2150
2235
  return id;
2151
2236
  },
@@ -2256,6 +2341,13 @@ var TreePrimitive = class TreePrimitive {
2256
2341
  const nodePath = operationPath.append(id);
2257
2342
  return nodeType.data._internal.createProxy(env, nodePath);
2258
2343
  },
2344
+ updateAt: (id, nodeType, value) => {
2345
+ const node = getCurrentState().find((n) => n.id === id);
2346
+ if (!node) throw new ValidationError(`Node not found: ${id}`);
2347
+ if (node.type !== nodeType.type) throw new ValidationError(`Node is of type "${node.type}", not "${nodeType.type}"`);
2348
+ const nodePath = operationPath.append(id);
2349
+ nodeType.data._internal.createProxy(env, nodePath).update(value);
2350
+ },
2259
2351
  toSnapshot: () => {
2260
2352
  const state = getCurrentState();
2261
2353
  const rootNode = state.find((n) => n.parentId === null);
@@ -2490,6 +2582,7 @@ var Primitive_exports = /* @__PURE__ */ __export({
2490
2582
  Union: () => Union,
2491
2583
  UnionPrimitive: () => UnionPrimitive,
2492
2584
  ValidationError: () => ValidationError,
2585
+ applyDefaults: () => applyDefaults,
2493
2586
  isCompatibleOperation: () => isCompatibleOperation,
2494
2587
  runValidators: () => runValidators
2495
2588
  });