@fern-api/generator-migrations 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,842 @@
1
+ //#region ../../node_modules/.pnpm/immer@10.1.3/node_modules/immer/dist/immer.mjs
2
+ var NOTHING = Symbol.for("immer-nothing");
3
+ var DRAFTABLE = Symbol.for("immer-draftable");
4
+ var DRAFT_STATE = Symbol.for("immer-state");
5
+ var errors = process.env.NODE_ENV !== "production" ? [
6
+ function(plugin) {
7
+ return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
8
+ },
9
+ function(thing) {
10
+ return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
11
+ },
12
+ "This object has been frozen and should not be mutated",
13
+ function(data) {
14
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
15
+ },
16
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
17
+ "Immer forbids circular references",
18
+ "The first or second argument to `produce` must be a function",
19
+ "The third argument to `produce` must be a function or undefined",
20
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
21
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
22
+ function(thing) {
23
+ return `'current' expects a draft, got: ${thing}`;
24
+ },
25
+ "Object.defineProperty() cannot be used on an Immer draft",
26
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
27
+ "Immer only supports deleting array indices",
28
+ "Immer only supports setting array indices and the 'length' property",
29
+ function(thing) {
30
+ return `'original' expects a draft, got: ${thing}`;
31
+ }
32
+ ] : [];
33
+ function die(error, ...args) {
34
+ if (process.env.NODE_ENV !== "production") {
35
+ const e = errors[error];
36
+ const msg = typeof e === "function" ? e.apply(null, args) : e;
37
+ throw new Error(`[Immer] ${msg}`);
38
+ }
39
+ throw new Error(`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`);
40
+ }
41
+ var getPrototypeOf = Object.getPrototypeOf;
42
+ function isDraft(value) {
43
+ return !!value && !!value[DRAFT_STATE];
44
+ }
45
+ function isDraftable(value) {
46
+ if (!value) return false;
47
+ return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
48
+ }
49
+ var objectCtorString = Object.prototype.constructor.toString();
50
+ function isPlainObject(value) {
51
+ if (!value || typeof value !== "object") return false;
52
+ const proto = getPrototypeOf(value);
53
+ if (proto === null) return true;
54
+ const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
55
+ if (Ctor === Object) return true;
56
+ return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
57
+ }
58
+ function each(obj, iter) {
59
+ if (getArchtype(obj) === 0) Reflect.ownKeys(obj).forEach((key) => {
60
+ iter(key, obj[key], obj);
61
+ });
62
+ else obj.forEach((entry, index) => iter(index, entry, obj));
63
+ }
64
+ function getArchtype(thing) {
65
+ const state = thing[DRAFT_STATE];
66
+ return state ? state.type_ : Array.isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
67
+ }
68
+ function has(thing, prop) {
69
+ return getArchtype(thing) === 2 ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
70
+ }
71
+ function set(thing, propOrOldValue, value) {
72
+ const t = getArchtype(thing);
73
+ if (t === 2) thing.set(propOrOldValue, value);
74
+ else if (t === 3) thing.add(value);
75
+ else thing[propOrOldValue] = value;
76
+ }
77
+ function is(x, y) {
78
+ if (x === y) return x !== 0 || 1 / x === 1 / y;
79
+ else return x !== x && y !== y;
80
+ }
81
+ function isMap(target) {
82
+ return target instanceof Map;
83
+ }
84
+ function isSet(target) {
85
+ return target instanceof Set;
86
+ }
87
+ function latest(state) {
88
+ return state.copy_ || state.base_;
89
+ }
90
+ function shallowCopy(base, strict) {
91
+ if (isMap(base)) return new Map(base);
92
+ if (isSet(base)) return new Set(base);
93
+ if (Array.isArray(base)) return Array.prototype.slice.call(base);
94
+ const isPlain = isPlainObject(base);
95
+ if (strict === true || strict === "class_only" && !isPlain) {
96
+ const descriptors = Object.getOwnPropertyDescriptors(base);
97
+ delete descriptors[DRAFT_STATE];
98
+ let keys = Reflect.ownKeys(descriptors);
99
+ for (let i = 0; i < keys.length; i++) {
100
+ const key = keys[i];
101
+ const desc = descriptors[key];
102
+ if (desc.writable === false) {
103
+ desc.writable = true;
104
+ desc.configurable = true;
105
+ }
106
+ if (desc.get || desc.set) descriptors[key] = {
107
+ configurable: true,
108
+ writable: true,
109
+ enumerable: desc.enumerable,
110
+ value: base[key]
111
+ };
112
+ }
113
+ return Object.create(getPrototypeOf(base), descriptors);
114
+ } else {
115
+ const proto = getPrototypeOf(base);
116
+ if (proto !== null && isPlain) return { ...base };
117
+ const obj = Object.create(proto);
118
+ return Object.assign(obj, base);
119
+ }
120
+ }
121
+ function freeze(obj, deep = false) {
122
+ if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj;
123
+ if (getArchtype(obj) > 1) Object.defineProperties(obj, {
124
+ set: { value: dontMutateFrozenCollections },
125
+ add: { value: dontMutateFrozenCollections },
126
+ clear: { value: dontMutateFrozenCollections },
127
+ delete: { value: dontMutateFrozenCollections }
128
+ });
129
+ Object.freeze(obj);
130
+ if (deep) Object.values(obj).forEach((value) => freeze(value, true));
131
+ return obj;
132
+ }
133
+ function dontMutateFrozenCollections() {
134
+ die(2);
135
+ }
136
+ function isFrozen(obj) {
137
+ return Object.isFrozen(obj);
138
+ }
139
+ var plugins = {};
140
+ function getPlugin(pluginKey) {
141
+ const plugin = plugins[pluginKey];
142
+ if (!plugin) die(0, pluginKey);
143
+ return plugin;
144
+ }
145
+ var currentScope;
146
+ function getCurrentScope() {
147
+ return currentScope;
148
+ }
149
+ function createScope(parent_, immer_) {
150
+ return {
151
+ drafts_: [],
152
+ parent_,
153
+ immer_,
154
+ canAutoFreeze_: true,
155
+ unfinalizedDrafts_: 0
156
+ };
157
+ }
158
+ function usePatchesInScope(scope, patchListener) {
159
+ if (patchListener) {
160
+ getPlugin("Patches");
161
+ scope.patches_ = [];
162
+ scope.inversePatches_ = [];
163
+ scope.patchListener_ = patchListener;
164
+ }
165
+ }
166
+ function revokeScope(scope) {
167
+ leaveScope(scope);
168
+ scope.drafts_.forEach(revokeDraft);
169
+ scope.drafts_ = null;
170
+ }
171
+ function leaveScope(scope) {
172
+ if (scope === currentScope) currentScope = scope.parent_;
173
+ }
174
+ function enterScope(immer2) {
175
+ return currentScope = createScope(currentScope, immer2);
176
+ }
177
+ function revokeDraft(draft) {
178
+ const state = draft[DRAFT_STATE];
179
+ if (state.type_ === 0 || state.type_ === 1) state.revoke_();
180
+ else state.revoked_ = true;
181
+ }
182
+ function processResult(result, scope) {
183
+ scope.unfinalizedDrafts_ = scope.drafts_.length;
184
+ const baseDraft = scope.drafts_[0];
185
+ if (result !== void 0 && result !== baseDraft) {
186
+ if (baseDraft[DRAFT_STATE].modified_) {
187
+ revokeScope(scope);
188
+ die(4);
189
+ }
190
+ if (isDraftable(result)) {
191
+ result = finalize(scope, result);
192
+ if (!scope.parent_) maybeFreeze(scope, result);
193
+ }
194
+ if (scope.patches_) getPlugin("Patches").generateReplacementPatches_(baseDraft[DRAFT_STATE].base_, result, scope.patches_, scope.inversePatches_);
195
+ } else result = finalize(scope, baseDraft, []);
196
+ revokeScope(scope);
197
+ if (scope.patches_) scope.patchListener_(scope.patches_, scope.inversePatches_);
198
+ return result !== NOTHING ? result : void 0;
199
+ }
200
+ function finalize(rootScope, value, path) {
201
+ if (isFrozen(value)) return value;
202
+ const state = value[DRAFT_STATE];
203
+ if (!state) {
204
+ each(value, (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path));
205
+ return value;
206
+ }
207
+ if (state.scope_ !== rootScope) return value;
208
+ if (!state.modified_) {
209
+ maybeFreeze(rootScope, state.base_, true);
210
+ return state.base_;
211
+ }
212
+ if (!state.finalized_) {
213
+ state.finalized_ = true;
214
+ state.scope_.unfinalizedDrafts_--;
215
+ const result = state.copy_;
216
+ let resultEach = result;
217
+ let isSet2 = false;
218
+ if (state.type_ === 3) {
219
+ resultEach = new Set(result);
220
+ result.clear();
221
+ isSet2 = true;
222
+ }
223
+ each(resultEach, (key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path, isSet2));
224
+ maybeFreeze(rootScope, result, false);
225
+ if (path && rootScope.patches_) getPlugin("Patches").generatePatches_(state, path, rootScope.patches_, rootScope.inversePatches_);
226
+ }
227
+ return state.copy_;
228
+ }
229
+ function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
230
+ if (process.env.NODE_ENV !== "production" && childValue === targetObject) die(5);
231
+ if (isDraft(childValue)) {
232
+ const res = finalize(rootScope, childValue, rootPath && parentState && parentState.type_ !== 3 && !has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0);
233
+ set(targetObject, prop, res);
234
+ if (isDraft(res)) rootScope.canAutoFreeze_ = false;
235
+ else return;
236
+ } else if (targetIsSet) targetObject.add(childValue);
237
+ if (isDraftable(childValue) && !isFrozen(childValue)) {
238
+ if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) return;
239
+ finalize(rootScope, childValue);
240
+ if ((!parentState || !parentState.scope_.parent_) && typeof prop !== "symbol" && (isMap(targetObject) ? targetObject.has(prop) : Object.prototype.propertyIsEnumerable.call(targetObject, prop))) maybeFreeze(rootScope, childValue);
241
+ }
242
+ }
243
+ function maybeFreeze(scope, value, deep = false) {
244
+ if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) freeze(value, deep);
245
+ }
246
+ function createProxyProxy(base, parent) {
247
+ const isArray = Array.isArray(base);
248
+ const state = {
249
+ type_: isArray ? 1 : 0,
250
+ scope_: parent ? parent.scope_ : getCurrentScope(),
251
+ modified_: false,
252
+ finalized_: false,
253
+ assigned_: {},
254
+ parent_: parent,
255
+ base_: base,
256
+ draft_: null,
257
+ copy_: null,
258
+ revoke_: null,
259
+ isManual_: false
260
+ };
261
+ let target = state;
262
+ let traps = objectTraps;
263
+ if (isArray) {
264
+ target = [state];
265
+ traps = arrayTraps;
266
+ }
267
+ const { revoke, proxy } = Proxy.revocable(target, traps);
268
+ state.draft_ = proxy;
269
+ state.revoke_ = revoke;
270
+ return proxy;
271
+ }
272
+ var objectTraps = {
273
+ get(state, prop) {
274
+ if (prop === DRAFT_STATE) return state;
275
+ const source = latest(state);
276
+ if (!has(source, prop)) return readPropFromProto(state, source, prop);
277
+ const value = source[prop];
278
+ if (state.finalized_ || !isDraftable(value)) return value;
279
+ if (value === peek(state.base_, prop)) {
280
+ prepareCopy(state);
281
+ return state.copy_[prop] = createProxy(value, state);
282
+ }
283
+ return value;
284
+ },
285
+ has(state, prop) {
286
+ return prop in latest(state);
287
+ },
288
+ ownKeys(state) {
289
+ return Reflect.ownKeys(latest(state));
290
+ },
291
+ set(state, prop, value) {
292
+ const desc = getDescriptorFromProto(latest(state), prop);
293
+ if (desc?.set) {
294
+ desc.set.call(state.draft_, value);
295
+ return true;
296
+ }
297
+ if (!state.modified_) {
298
+ const current2 = peek(latest(state), prop);
299
+ const currentState = current2?.[DRAFT_STATE];
300
+ if (currentState && currentState.base_ === value) {
301
+ state.copy_[prop] = value;
302
+ state.assigned_[prop] = false;
303
+ return true;
304
+ }
305
+ if (is(value, current2) && (value !== void 0 || has(state.base_, prop))) return true;
306
+ prepareCopy(state);
307
+ markChanged(state);
308
+ }
309
+ if (state.copy_[prop] === value && (value !== void 0 || prop in state.copy_) || Number.isNaN(value) && Number.isNaN(state.copy_[prop])) return true;
310
+ state.copy_[prop] = value;
311
+ state.assigned_[prop] = true;
312
+ return true;
313
+ },
314
+ deleteProperty(state, prop) {
315
+ if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
316
+ state.assigned_[prop] = false;
317
+ prepareCopy(state);
318
+ markChanged(state);
319
+ } else delete state.assigned_[prop];
320
+ if (state.copy_) delete state.copy_[prop];
321
+ return true;
322
+ },
323
+ getOwnPropertyDescriptor(state, prop) {
324
+ const owner = latest(state);
325
+ const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
326
+ if (!desc) return desc;
327
+ return {
328
+ writable: true,
329
+ configurable: state.type_ !== 1 || prop !== "length",
330
+ enumerable: desc.enumerable,
331
+ value: owner[prop]
332
+ };
333
+ },
334
+ defineProperty() {
335
+ die(11);
336
+ },
337
+ getPrototypeOf(state) {
338
+ return getPrototypeOf(state.base_);
339
+ },
340
+ setPrototypeOf() {
341
+ die(12);
342
+ }
343
+ };
344
+ var arrayTraps = {};
345
+ each(objectTraps, (key, fn) => {
346
+ arrayTraps[key] = function() {
347
+ arguments[0] = arguments[0][0];
348
+ return fn.apply(this, arguments);
349
+ };
350
+ });
351
+ arrayTraps.deleteProperty = function(state, prop) {
352
+ if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop))) die(13);
353
+ return arrayTraps.set.call(this, state, prop, void 0);
354
+ };
355
+ arrayTraps.set = function(state, prop, value) {
356
+ if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop))) die(14);
357
+ return objectTraps.set.call(this, state[0], prop, value, state[0]);
358
+ };
359
+ function peek(draft, prop) {
360
+ const state = draft[DRAFT_STATE];
361
+ return (state ? latest(state) : draft)[prop];
362
+ }
363
+ function readPropFromProto(state, source, prop) {
364
+ const desc = getDescriptorFromProto(source, prop);
365
+ return desc ? `value` in desc ? desc.value : desc.get?.call(state.draft_) : void 0;
366
+ }
367
+ function getDescriptorFromProto(source, prop) {
368
+ if (!(prop in source)) return void 0;
369
+ let proto = getPrototypeOf(source);
370
+ while (proto) {
371
+ const desc = Object.getOwnPropertyDescriptor(proto, prop);
372
+ if (desc) return desc;
373
+ proto = getPrototypeOf(proto);
374
+ }
375
+ }
376
+ function markChanged(state) {
377
+ if (!state.modified_) {
378
+ state.modified_ = true;
379
+ if (state.parent_) markChanged(state.parent_);
380
+ }
381
+ }
382
+ function prepareCopy(state) {
383
+ if (!state.copy_) state.copy_ = shallowCopy(state.base_, state.scope_.immer_.useStrictShallowCopy_);
384
+ }
385
+ var Immer2 = class {
386
+ constructor(config) {
387
+ this.autoFreeze_ = true;
388
+ this.useStrictShallowCopy_ = false;
389
+ /**
390
+ * The `produce` function takes a value and a "recipe function" (whose
391
+ * return value often depends on the base state). The recipe function is
392
+ * free to mutate its first argument however it wants. All mutations are
393
+ * only ever applied to a __copy__ of the base state.
394
+ *
395
+ * Pass only a function to create a "curried producer" which relieves you
396
+ * from passing the recipe function every time.
397
+ *
398
+ * Only plain objects and arrays are made mutable. All other objects are
399
+ * considered uncopyable.
400
+ *
401
+ * Note: This function is __bound__ to its `Immer` instance.
402
+ *
403
+ * @param {any} base - the initial state
404
+ * @param {Function} recipe - function that receives a proxy of the base state as first argument and which can be freely modified
405
+ * @param {Function} patchListener - optional function that will be called with all the patches produced here
406
+ * @returns {any} a new state, or the initial state if nothing was modified
407
+ */
408
+ this.produce = (base, recipe, patchListener) => {
409
+ if (typeof base === "function" && typeof recipe !== "function") {
410
+ const defaultBase = recipe;
411
+ recipe = base;
412
+ const self = this;
413
+ return function curriedProduce(base2 = defaultBase, ...args) {
414
+ return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
415
+ };
416
+ }
417
+ if (typeof recipe !== "function") die(6);
418
+ if (patchListener !== void 0 && typeof patchListener !== "function") die(7);
419
+ let result;
420
+ if (isDraftable(base)) {
421
+ const scope = enterScope(this);
422
+ const proxy = createProxy(base, void 0);
423
+ let hasError = true;
424
+ try {
425
+ result = recipe(proxy);
426
+ hasError = false;
427
+ } finally {
428
+ if (hasError) revokeScope(scope);
429
+ else leaveScope(scope);
430
+ }
431
+ usePatchesInScope(scope, patchListener);
432
+ return processResult(result, scope);
433
+ } else if (!base || typeof base !== "object") {
434
+ result = recipe(base);
435
+ if (result === void 0) result = base;
436
+ if (result === NOTHING) result = void 0;
437
+ if (this.autoFreeze_) freeze(result, true);
438
+ if (patchListener) {
439
+ const p = [];
440
+ const ip = [];
441
+ getPlugin("Patches").generateReplacementPatches_(base, result, p, ip);
442
+ patchListener(p, ip);
443
+ }
444
+ return result;
445
+ } else die(1, base);
446
+ };
447
+ this.produceWithPatches = (base, recipe) => {
448
+ if (typeof base === "function") return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
449
+ let patches, inversePatches;
450
+ return [
451
+ this.produce(base, recipe, (p, ip) => {
452
+ patches = p;
453
+ inversePatches = ip;
454
+ }),
455
+ patches,
456
+ inversePatches
457
+ ];
458
+ };
459
+ if (typeof config?.autoFreeze === "boolean") this.setAutoFreeze(config.autoFreeze);
460
+ if (typeof config?.useStrictShallowCopy === "boolean") this.setUseStrictShallowCopy(config.useStrictShallowCopy);
461
+ }
462
+ createDraft(base) {
463
+ if (!isDraftable(base)) die(8);
464
+ if (isDraft(base)) base = current(base);
465
+ const scope = enterScope(this);
466
+ const proxy = createProxy(base, void 0);
467
+ proxy[DRAFT_STATE].isManual_ = true;
468
+ leaveScope(scope);
469
+ return proxy;
470
+ }
471
+ finishDraft(draft, patchListener) {
472
+ const state = draft && draft[DRAFT_STATE];
473
+ if (!state || !state.isManual_) die(9);
474
+ const { scope_: scope } = state;
475
+ usePatchesInScope(scope, patchListener);
476
+ return processResult(void 0, scope);
477
+ }
478
+ /**
479
+ * Pass true to automatically freeze all copies created by Immer.
480
+ *
481
+ * By default, auto-freezing is enabled.
482
+ */
483
+ setAutoFreeze(value) {
484
+ this.autoFreeze_ = value;
485
+ }
486
+ /**
487
+ * Pass true to enable strict shallow copy.
488
+ *
489
+ * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
490
+ */
491
+ setUseStrictShallowCopy(value) {
492
+ this.useStrictShallowCopy_ = value;
493
+ }
494
+ applyPatches(base, patches) {
495
+ let i;
496
+ for (i = patches.length - 1; i >= 0; i--) {
497
+ const patch = patches[i];
498
+ if (patch.path.length === 0 && patch.op === "replace") {
499
+ base = patch.value;
500
+ break;
501
+ }
502
+ }
503
+ if (i > -1) patches = patches.slice(i + 1);
504
+ const applyPatchesImpl = getPlugin("Patches").applyPatches_;
505
+ if (isDraft(base)) return applyPatchesImpl(base, patches);
506
+ return this.produce(base, (draft) => applyPatchesImpl(draft, patches));
507
+ }
508
+ };
509
+ function createProxy(value, parent) {
510
+ const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
511
+ (parent ? parent.scope_ : getCurrentScope()).drafts_.push(draft);
512
+ return draft;
513
+ }
514
+ function current(value) {
515
+ if (!isDraft(value)) die(10, value);
516
+ return currentImpl(value);
517
+ }
518
+ function currentImpl(value) {
519
+ if (!isDraftable(value) || isFrozen(value)) return value;
520
+ const state = value[DRAFT_STATE];
521
+ let copy;
522
+ if (state) {
523
+ if (!state.modified_) return state.base_;
524
+ state.finalized_ = true;
525
+ copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
526
+ } else copy = shallowCopy(value, true);
527
+ each(copy, (key, childValue) => {
528
+ set(copy, key, currentImpl(childValue));
529
+ });
530
+ if (state) state.finalized_ = false;
531
+ return copy;
532
+ }
533
+ var immer = new Immer2();
534
+ var produce = immer.produce;
535
+
536
+ //#endregion
537
+ //#region ../migrations-base/lib/utils.js
538
+ /**
539
+ * Helper function to safely get config object from generator invocation.
540
+ * Returns an empty object if config is not set or not an object.
541
+ *
542
+ * @param config - The generator invocation schema
543
+ * @returns The config object or an empty object
544
+ *
545
+ * @example
546
+ * ```typescript
547
+ * const configObj = getConfigObject(config);
548
+ * const migratedConfig = {
549
+ * ...configObj,
550
+ * newField: "value"
551
+ * };
552
+ * ```
553
+ */
554
+ function getConfigObject(config) {
555
+ return config.config && typeof config.config === "object" ? config.config : {};
556
+ }
557
+ /**
558
+ * Migrate a generator config using Immer's produce for immutable updates.
559
+ * This is the recommended way to write migrations as it handles nested updates elegantly.
560
+ *
561
+ * @param config - The original generator config
562
+ * @param updater - Function that mutates the config draft (uses Immer)
563
+ * @returns A new generator config with updates applied
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * // Simple field updates
568
+ * return migrateConfig(config, (draft) => {
569
+ * draft.oldField = false; // Set old default
570
+ * draft.newField = true; // Set new default
571
+ * });
572
+ *
573
+ * // Conditional updates (only if undefined)
574
+ * return migrateConfig(config, (draft) => {
575
+ * draft.field1 ??= false; // Only set if undefined
576
+ * draft.field2 ??= true;
577
+ * });
578
+ *
579
+ * // Nested updates
580
+ * return migrateConfig(config, (draft) => {
581
+ * draft.nested ??= {};
582
+ * draft.nested.field = "value";
583
+ * });
584
+ *
585
+ * // Removing fields
586
+ * return migrateConfig(config, (draft) => {
587
+ * delete draft.deprecated;
588
+ * });
589
+ *
590
+ * // Renaming fields
591
+ * return migrateConfig(config, (draft) => {
592
+ * draft.newName = draft.oldName;
593
+ * delete draft.oldName;
594
+ * });
595
+ * ```
596
+ */
597
+ function migrateConfig(config, updater) {
598
+ const migratedConfigObj = produce(getConfigObject(config), updater);
599
+ return {
600
+ ...config,
601
+ config: migratedConfigObj
602
+ };
603
+ }
604
+
605
+ //#endregion
606
+ //#region src/generators/csharp/migrations/1.0.0.ts
607
+ const migration_1_0_0$2 = {
608
+ version: "1.0.0",
609
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
610
+ draft["root-namespace-for-core-classes"] ??= false;
611
+ draft["pascal-case-environments"] ??= false;
612
+ draft["simplify-object-dictionaries"] ??= false;
613
+ }),
614
+ migrateGeneratorsYml: ({ document }) => document
615
+ };
616
+
617
+ //#endregion
618
+ //#region src/generators/csharp/migrations/2.0.0.ts
619
+ const migration_2_0_0$2 = {
620
+ version: "2.0.0",
621
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
622
+ if ("experimental-additional-properties" in draft) {
623
+ const value = draft["experimental-additional-properties"];
624
+ delete draft["experimental-additional-properties"];
625
+ draft["additional-properties"] = value;
626
+ }
627
+ if ("experimental-enable-forward-compatible-enums" in draft) {
628
+ const value = draft["experimental-enable-forward-compatible-enums"];
629
+ delete draft["experimental-enable-forward-compatible-enums"];
630
+ draft["enable-forward-compatible-enums"] = value;
631
+ }
632
+ draft["additional-properties"] ??= false;
633
+ draft["enable-forward-compatible-enums"] ??= false;
634
+ draft["generate-mock-server-tests"] ??= false;
635
+ draft["inline-path-parameters"] ??= false;
636
+ draft["simplify-object-dictionaries"] ??= true;
637
+ draft["use-discriminated-unions"] ??= false;
638
+ }),
639
+ migrateGeneratorsYml: ({ document }) => document
640
+ };
641
+
642
+ //#endregion
643
+ //#region src/generators/csharp/migrations/index.ts
644
+ /**
645
+ * Migration module for C# SDK generator.
646
+ *
647
+ * This module contains migrations for configuration changes for
648
+ * the C# SDK generator:
649
+ * - fernapi/fern-csharp-sdk
650
+ *
651
+ * Each migration is defined in a separate file under this directory.
652
+ * Migrations are automatically applied by the Fern CLI when running:
653
+ * `fern generator upgrade --generator csharp-sdk`
654
+ */
655
+ const migrationModule$4 = { migrations: [migration_1_0_0$2, migration_2_0_0$2] };
656
+ var migrations_default$4 = migrationModule$4;
657
+
658
+ //#endregion
659
+ //#region src/generators/java/migrations/2.0.0.ts
660
+ const migration_2_0_0$1 = {
661
+ version: "2.0.0",
662
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
663
+ draft["disable-required-property-builder-checks"] ??= true;
664
+ }),
665
+ migrateGeneratorsYml: ({ document }) => document
666
+ };
667
+
668
+ //#endregion
669
+ //#region src/generators/java/migrations/3.0.0.ts
670
+ const migration_3_0_0$1 = {
671
+ version: "3.0.0",
672
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
673
+ draft["enable-forward-compatible-enums"] ??= false;
674
+ }),
675
+ migrateGeneratorsYml: ({ document }) => document
676
+ };
677
+
678
+ //#endregion
679
+ //#region src/generators/java/migrations/index.ts
680
+ /**
681
+ * Migration module for Java SDK generator.
682
+ *
683
+ * This module contains migrations for configuration changes for
684
+ * the Java SDK generator:
685
+ * - fernapi/fern-java-sdk
686
+ *
687
+ * Each migration is defined in a separate file under this directory.
688
+ * Migrations are automatically applied by the Fern CLI when running:
689
+ * `fern generator upgrade --generator java-sdk`
690
+ */
691
+ const migrationModule$3 = { migrations: [migration_2_0_0$1, migration_3_0_0$1] };
692
+ var migrations_default$3 = migrationModule$3;
693
+
694
+ //#endregion
695
+ //#region src/generators/java-model/migrations/1.0.0.ts
696
+ const migration_1_0_0$1 = {
697
+ version: "1.0.0",
698
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
699
+ draft["disable-required-property-builder-checks"] ??= true;
700
+ }),
701
+ migrateGeneratorsYml: ({ document }) => document
702
+ };
703
+
704
+ //#endregion
705
+ //#region src/generators/java-model/migrations/index.ts
706
+ /**
707
+ * Migration module for Java Model generators.
708
+ *
709
+ * This module contains migrations for configuration changes for
710
+ * the Java Model generators:
711
+ * - fernapi/fern-java-model
712
+ * - fernapi/fern-java-spring
713
+ *
714
+ * Each migration is defined in a separate file under this directory.
715
+ * Migrations are automatically applied by the Fern CLI when running:
716
+ * `fern generator upgrade --generator java-model`
717
+ * `fern generator upgrade --generator java-spring`
718
+ */
719
+ const migrationModule$2 = { migrations: [migration_1_0_0$1] };
720
+ var migrations_default$2 = migrationModule$2;
721
+
722
+ //#endregion
723
+ //#region src/generators/python/migrations/4.0.0.ts
724
+ const migration_4_0_0 = {
725
+ version: "4.0.0",
726
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
727
+ if (draft.pydantic_config === void 0 || draft.pydantic_config === null) draft.pydantic_config = {};
728
+ if (typeof draft.pydantic_config === "object" && draft.pydantic_config !== null) draft.pydantic_config.use_pydantic_field_aliases ??= true;
729
+ }),
730
+ migrateGeneratorsYml: ({ document }) => document
731
+ };
732
+
733
+ //#endregion
734
+ //#region src/generators/python/migrations/index.ts
735
+ /**
736
+ * Migration module for Python SDK generator.
737
+ *
738
+ * This module contains migrations for configuration changes for
739
+ * the Python SDK generator:
740
+ * - fernapi/fern-python-sdk
741
+ *
742
+ * Each migration is defined in a separate file under this directory.
743
+ * Migrations are automatically applied by the Fern CLI when running:
744
+ * `fern generator upgrade --generator python-sdk`
745
+ *
746
+ * Note: Versions 1.0.0 and 2.0.0 mentioned "breaking configuration changes"
747
+ * but did not document specific configuration options that changed, so they
748
+ * are not included in this migration module.
749
+ */
750
+ const migrationModule$1 = { migrations: [migration_4_0_0] };
751
+ var migrations_default$1 = migrationModule$1;
752
+
753
+ //#endregion
754
+ //#region src/generators/typescript/migrations/1.0.0.ts
755
+ const migration_1_0_0 = {
756
+ version: "1.0.0",
757
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
758
+ draft.inlineFileProperties ??= false;
759
+ draft.inlinePathParameters ??= false;
760
+ draft.enableInlineTypes ??= false;
761
+ draft.noSerdeLayer ??= false;
762
+ draft.omitUndefined ??= false;
763
+ draft.skipResponseValidation ??= false;
764
+ draft.useLegacyExports ??= true;
765
+ }),
766
+ migrateGeneratorsYml: ({ document }) => document
767
+ };
768
+
769
+ //#endregion
770
+ //#region src/generators/typescript/migrations/2.0.0.ts
771
+ const migration_2_0_0 = {
772
+ version: "2.0.0",
773
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
774
+ draft.streamType ??= "wrapper";
775
+ draft.fileResponseType ??= "stream";
776
+ draft.formDataSupport ??= "Node16";
777
+ draft.fetchSupport ??= "node-fetch";
778
+ }),
779
+ migrateGeneratorsYml: ({ document }) => document
780
+ };
781
+
782
+ //#endregion
783
+ //#region src/generators/typescript/migrations/3.0.0.ts
784
+ const migration_3_0_0 = {
785
+ version: "3.0.0",
786
+ migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
787
+ draft.packageManager ??= "yarn";
788
+ draft.testFramework ??= "jest";
789
+ }),
790
+ migrateGeneratorsYml: ({ document }) => document
791
+ };
792
+
793
+ //#endregion
794
+ //#region src/generators/typescript/migrations/index.ts
795
+ /**
796
+ * Migration module for TypeScript SDK generators.
797
+ *
798
+ * This module contains migrations for configuration changes across
799
+ * all TypeScript SDK generator variants:
800
+ * - fernapi/fern-typescript
801
+ * - fernapi/fern-typescript-sdk
802
+ * - fernapi/fern-typescript-node-sdk
803
+ * - fernapi/fern-typescript-browser-sdk
804
+ *
805
+ * Each migration is defined in a separate file under this directory.
806
+ * Migrations are automatically applied by the Fern CLI when running:
807
+ * `fern generator upgrade --generator typescript-sdk`
808
+ */
809
+ const migrationModule = { migrations: [
810
+ migration_1_0_0,
811
+ migration_2_0_0,
812
+ migration_3_0_0
813
+ ] };
814
+ var migrations_default = migrationModule;
815
+
816
+ //#endregion
817
+ //#region src/index.ts
818
+ /**
819
+ * All generator migrations indexed by full generator name.
820
+ *
821
+ * When adding migrations for a new generator:
822
+ * 1. Add migrations under src/generators/{language}/migrations/
823
+ * 2. Import the migration module
824
+ * 3. Add entries for all generator name variants
825
+ */
826
+ const migrations = {
827
+ "fernapi/fern-csharp-sdk": migrations_default$4,
828
+ "fernapi/fern-java-model": migrations_default$2,
829
+ "fernapi/fern-java-spring": migrations_default$2,
830
+ "fernapi/fern-java-sdk": migrations_default$3,
831
+ "fernapi/fern-python-sdk": migrations_default$1,
832
+ "fernapi/fern-fastapi-server": migrations_default$1,
833
+ "fernapi/fern-pydantic-model": migrations_default$1,
834
+ "fernapi/fern-typescript": migrations_default,
835
+ "fernapi/fern-typescript-sdk": migrations_default,
836
+ "fernapi/fern-typescript-node-sdk": migrations_default,
837
+ "fernapi/fern-typescript-browser-sdk": migrations_default
838
+ };
839
+
840
+ //#endregion
841
+ export { migrations };
842
+ //# sourceMappingURL=index.mjs.map