@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.
@@ -1,152 +0,0 @@
1
- import type { Migration } from "@fern-api/migrations-base";
2
- /**
3
- * Migration for version 1.0.0
4
- *
5
- * ## Context
6
- *
7
- * Version 1.0.0 introduced new defaults to improve the developer experience and modernize
8
- * the generated SDK. These changes make the SDK more ergonomic and reduce boilerplate,
9
- * but could break existing code that relied on the old defaults.
10
- *
11
- * To ensure backwards compatibility during upgrades, this migration explicitly sets the
12
- * old defaults for users upgrading from pre-1.0.0 versions. This allows their existing
13
- * code to continue working without changes.
14
- *
15
- * ## Changed Defaults
16
- *
17
- * | Field | Old Default (pre-1.0.0) | New Default (1.0.0+) | Impact |
18
- * |-------|-------------------------|----------------------|--------|
19
- * | `inlineFileProperties` | `false` | `true` | File upload properties are now inlined into request types |
20
- * | `inlinePathParameters` | `false` | `true` | Path parameters are now inlined into method signatures |
21
- * | `enableInlineTypes` | `false` | `true` | Type definitions are inlined where beneficial |
22
- * | `noSerdeLayer` | `false` | `true` | Serialization/deserialization layer is removed for simpler types |
23
- * | `omitUndefined` | `false` | `true` | Undefined values are omitted from JSON output |
24
- * | `skipResponseValidation` | `false` | `true` | Response validation is skipped for better performance |
25
- * | `useLegacyExports` | `true` | `false` | Modern ESM exports are used instead of legacy CommonJS |
26
- *
27
- * ## Migration Strategy
28
- *
29
- * This migration uses the nullish coalescing assignment operator (`??=`) to only set
30
- * values that are explicitly undefined. This means:
31
- * - ✅ If a user has explicitly configured a field (even to the new default), that value is preserved
32
- * - ✅ If a field is undefined, the old default is set for backwards compatibility
33
- * - ✅ Unknown/custom fields are preserved
34
- *
35
- * ## Examples
36
- *
37
- * ### Example 1: Empty Config (Migration Applied)
38
- *
39
- * **Before Migration (0.9.0 → 1.0.0):**
40
- * ```yaml
41
- * generators:
42
- * - name: fernapi/fern-typescript-sdk
43
- * version: 0.9.0
44
- * config: {}
45
- * ```
46
- *
47
- * **After Migration:**
48
- * ```yaml
49
- * generators:
50
- * - name: fernapi/fern-typescript-sdk
51
- * version: 1.0.0
52
- * config:
53
- * inlineFileProperties: false # Set by migration
54
- * inlinePathParameters: false # Set by migration
55
- * enableInlineTypes: false # Set by migration
56
- * noSerdeLayer: false # Set by migration
57
- * omitUndefined: false # Set by migration
58
- * skipResponseValidation: false # Set by migration
59
- * useLegacyExports: true # Set by migration
60
- * ```
61
- *
62
- * **Result:** SDK behavior remains unchanged, existing code continues to work.
63
- *
64
- * ### Example 2: Partially Configured (Selective Migration)
65
- *
66
- * **Before Migration:**
67
- * ```yaml
68
- * generators:
69
- * - name: fernapi/fern-typescript-sdk
70
- * version: 0.9.0
71
- * config:
72
- * inlineFileProperties: true # User explicitly wants new behavior
73
- * packageName: "@acme/sdk"
74
- * ```
75
- *
76
- * **After Migration:**
77
- * ```yaml
78
- * generators:
79
- * - name: fernapi/fern-typescript-sdk
80
- * version: 1.0.0
81
- * config:
82
- * inlineFileProperties: true # Preserved (explicitly set)
83
- * packageName: "@acme/sdk" # Preserved (custom field)
84
- * inlinePathParameters: false # Set by migration
85
- * enableInlineTypes: false # Set by migration
86
- * noSerdeLayer: false # Set by migration
87
- * omitUndefined: false # Set by migration
88
- * skipResponseValidation: false # Set by migration
89
- * useLegacyExports: true # Set by migration
90
- * ```
91
- *
92
- * **Result:** User's explicit choice is honored, other fields get old defaults.
93
- *
94
- * ### Example 3: Fully Configured (No Migration Needed)
95
- *
96
- * **Before Migration:**
97
- * ```yaml
98
- * generators:
99
- * - name: fernapi/fern-typescript-sdk
100
- * version: 0.9.0
101
- * config:
102
- * inlineFileProperties: true
103
- * inlinePathParameters: true
104
- * enableInlineTypes: true
105
- * noSerdeLayer: true
106
- * omitUndefined: true
107
- * skipResponseValidation: true
108
- * useLegacyExports: false
109
- * ```
110
- *
111
- * **After Migration:**
112
- * ```yaml
113
- * # No changes - all fields explicitly configured
114
- * generators:
115
- * - name: fernapi/fern-typescript-sdk
116
- * version: 1.0.0
117
- * config:
118
- * inlineFileProperties: true
119
- * inlinePathParameters: true
120
- * enableInlineTypes: true
121
- * noSerdeLayer: true
122
- * omitUndefined: true
123
- * skipResponseValidation: true
124
- * useLegacyExports: false
125
- * ```
126
- *
127
- * **Result:** User gets the new defaults they explicitly configured.
128
- *
129
- * ## Why These Defaults Changed
130
- *
131
- * - **Inline properties/parameters**: Reduces type nesting and improves IDE autocomplete
132
- * - **No serde layer**: Simplifies generated code and improves runtime performance
133
- * - **Omit undefined**: Produces cleaner JSON payloads and matches JavaScript conventions
134
- * - **Skip validation**: Improves performance by trusting the API contract
135
- * - **Modern exports**: Better tree-shaking and compatibility with modern bundlers
136
- *
137
- * ## When to Opt Into New Defaults
138
- *
139
- * After upgrading and verifying your code works, consider removing the old defaults
140
- * to adopt the new behavior:
141
- *
142
- * ```yaml
143
- * generators:
144
- * - name: fernapi/fern-typescript-sdk
145
- * version: 1.0.0
146
- * config: {} # Remove all fields to use new defaults
147
- * ```
148
- *
149
- * Test your code thoroughly before making this change.
150
- */
151
- export declare const migration_1_0_0: Migration;
152
- //# sourceMappingURL=1.0.0.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"1.0.0.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/1.0.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoJG;AACH,eAAO,MAAM,eAAe,EAAE,SAiB7B,CAAC"}
@@ -1,166 +0,0 @@
1
- import { migrateConfig } from "@fern-api/migrations-base";
2
- /**
3
- * Migration for version 1.0.0
4
- *
5
- * ## Context
6
- *
7
- * Version 1.0.0 introduced new defaults to improve the developer experience and modernize
8
- * the generated SDK. These changes make the SDK more ergonomic and reduce boilerplate,
9
- * but could break existing code that relied on the old defaults.
10
- *
11
- * To ensure backwards compatibility during upgrades, this migration explicitly sets the
12
- * old defaults for users upgrading from pre-1.0.0 versions. This allows their existing
13
- * code to continue working without changes.
14
- *
15
- * ## Changed Defaults
16
- *
17
- * | Field | Old Default (pre-1.0.0) | New Default (1.0.0+) | Impact |
18
- * |-------|-------------------------|----------------------|--------|
19
- * | `inlineFileProperties` | `false` | `true` | File upload properties are now inlined into request types |
20
- * | `inlinePathParameters` | `false` | `true` | Path parameters are now inlined into method signatures |
21
- * | `enableInlineTypes` | `false` | `true` | Type definitions are inlined where beneficial |
22
- * | `noSerdeLayer` | `false` | `true` | Serialization/deserialization layer is removed for simpler types |
23
- * | `omitUndefined` | `false` | `true` | Undefined values are omitted from JSON output |
24
- * | `skipResponseValidation` | `false` | `true` | Response validation is skipped for better performance |
25
- * | `useLegacyExports` | `true` | `false` | Modern ESM exports are used instead of legacy CommonJS |
26
- *
27
- * ## Migration Strategy
28
- *
29
- * This migration uses the nullish coalescing assignment operator (`??=`) to only set
30
- * values that are explicitly undefined. This means:
31
- * - ✅ If a user has explicitly configured a field (even to the new default), that value is preserved
32
- * - ✅ If a field is undefined, the old default is set for backwards compatibility
33
- * - ✅ Unknown/custom fields are preserved
34
- *
35
- * ## Examples
36
- *
37
- * ### Example 1: Empty Config (Migration Applied)
38
- *
39
- * **Before Migration (0.9.0 → 1.0.0):**
40
- * ```yaml
41
- * generators:
42
- * - name: fernapi/fern-typescript-sdk
43
- * version: 0.9.0
44
- * config: {}
45
- * ```
46
- *
47
- * **After Migration:**
48
- * ```yaml
49
- * generators:
50
- * - name: fernapi/fern-typescript-sdk
51
- * version: 1.0.0
52
- * config:
53
- * inlineFileProperties: false # Set by migration
54
- * inlinePathParameters: false # Set by migration
55
- * enableInlineTypes: false # Set by migration
56
- * noSerdeLayer: false # Set by migration
57
- * omitUndefined: false # Set by migration
58
- * skipResponseValidation: false # Set by migration
59
- * useLegacyExports: true # Set by migration
60
- * ```
61
- *
62
- * **Result:** SDK behavior remains unchanged, existing code continues to work.
63
- *
64
- * ### Example 2: Partially Configured (Selective Migration)
65
- *
66
- * **Before Migration:**
67
- * ```yaml
68
- * generators:
69
- * - name: fernapi/fern-typescript-sdk
70
- * version: 0.9.0
71
- * config:
72
- * inlineFileProperties: true # User explicitly wants new behavior
73
- * packageName: "@acme/sdk"
74
- * ```
75
- *
76
- * **After Migration:**
77
- * ```yaml
78
- * generators:
79
- * - name: fernapi/fern-typescript-sdk
80
- * version: 1.0.0
81
- * config:
82
- * inlineFileProperties: true # Preserved (explicitly set)
83
- * packageName: "@acme/sdk" # Preserved (custom field)
84
- * inlinePathParameters: false # Set by migration
85
- * enableInlineTypes: false # Set by migration
86
- * noSerdeLayer: false # Set by migration
87
- * omitUndefined: false # Set by migration
88
- * skipResponseValidation: false # Set by migration
89
- * useLegacyExports: true # Set by migration
90
- * ```
91
- *
92
- * **Result:** User's explicit choice is honored, other fields get old defaults.
93
- *
94
- * ### Example 3: Fully Configured (No Migration Needed)
95
- *
96
- * **Before Migration:**
97
- * ```yaml
98
- * generators:
99
- * - name: fernapi/fern-typescript-sdk
100
- * version: 0.9.0
101
- * config:
102
- * inlineFileProperties: true
103
- * inlinePathParameters: true
104
- * enableInlineTypes: true
105
- * noSerdeLayer: true
106
- * omitUndefined: true
107
- * skipResponseValidation: true
108
- * useLegacyExports: false
109
- * ```
110
- *
111
- * **After Migration:**
112
- * ```yaml
113
- * # No changes - all fields explicitly configured
114
- * generators:
115
- * - name: fernapi/fern-typescript-sdk
116
- * version: 1.0.0
117
- * config:
118
- * inlineFileProperties: true
119
- * inlinePathParameters: true
120
- * enableInlineTypes: true
121
- * noSerdeLayer: true
122
- * omitUndefined: true
123
- * skipResponseValidation: true
124
- * useLegacyExports: false
125
- * ```
126
- *
127
- * **Result:** User gets the new defaults they explicitly configured.
128
- *
129
- * ## Why These Defaults Changed
130
- *
131
- * - **Inline properties/parameters**: Reduces type nesting and improves IDE autocomplete
132
- * - **No serde layer**: Simplifies generated code and improves runtime performance
133
- * - **Omit undefined**: Produces cleaner JSON payloads and matches JavaScript conventions
134
- * - **Skip validation**: Improves performance by trusting the API contract
135
- * - **Modern exports**: Better tree-shaking and compatibility with modern bundlers
136
- *
137
- * ## When to Opt Into New Defaults
138
- *
139
- * After upgrading and verifying your code works, consider removing the old defaults
140
- * to adopt the new behavior:
141
- *
142
- * ```yaml
143
- * generators:
144
- * - name: fernapi/fern-typescript-sdk
145
- * version: 1.0.0
146
- * config: {} # Remove all fields to use new defaults
147
- * ```
148
- *
149
- * Test your code thoroughly before making this change.
150
- */
151
- export const migration_1_0_0 = {
152
- version: "1.0.0",
153
- migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
154
- // Only set old defaults if the fields are not already explicitly configured
155
- // Using the nullish coalescing assignment operator (??=) to set only if undefined
156
- draft.inlineFileProperties ??= false;
157
- draft.inlinePathParameters ??= false;
158
- draft.enableInlineTypes ??= false;
159
- draft.noSerdeLayer ??= false;
160
- draft.omitUndefined ??= false;
161
- draft.skipResponseValidation ??= false;
162
- draft.useLegacyExports ??= true;
163
- }),
164
- migrateGeneratorsYml: ({ document }) => document
165
- };
166
- //# sourceMappingURL=1.0.0.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"1.0.0.js","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/1.0.0.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoJG;AACH,MAAM,CAAC,MAAM,eAAe,GAAc;IACtC,OAAO,EAAE,OAAO;IAEhB,sBAAsB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CACnC,aAAa,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5B,4EAA4E;QAC5E,kFAAkF;QAClF,KAAK,CAAC,oBAAoB,KAAK,KAAK,CAAC;QACrC,KAAK,CAAC,oBAAoB,KAAK,KAAK,CAAC;QACrC,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC;QAClC,KAAK,CAAC,YAAY,KAAK,KAAK,CAAC;QAC7B,KAAK,CAAC,aAAa,KAAK,KAAK,CAAC;QAC9B,KAAK,CAAC,sBAAsB,KAAK,KAAK,CAAC;QACvC,KAAK,CAAC,gBAAgB,KAAK,IAAI,CAAC;IACpC,CAAC,CAAC;IAEN,oBAAoB,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ;CACnD,CAAC"}
@@ -1,153 +0,0 @@
1
- import type { Migration } from "@fern-api/migrations-base";
2
- /**
3
- * Migration for version 2.0.0
4
- *
5
- * ## Context
6
- *
7
- * Version 2.0.0 introduced zero-dependency SDKs by default, using native browser and
8
- * Node.js APIs instead of external packages. This significantly reduces bundle size
9
- * and eliminates dependency management issues, but requires Node.js 18+ and modern
10
- * browsers with native fetch/streams support.
11
- *
12
- * For users upgrading from pre-2.0.0 versions who need to maintain compatibility with
13
- * older runtimes, this migration explicitly sets the old defaults that use polyfills
14
- * and wrapper libraries.
15
- *
16
- * ## Changed Defaults
17
- *
18
- * | Field | Old Default (pre-2.0.0) | New Default (2.0.0+) | Impact |
19
- * |-------|-------------------------|----------------------|--------|
20
- * | `streamType` | `"wrapper"` | `"web"` | Uses native Web Streams API instead of wrapper library |
21
- * | `fileResponseType` | `"stream"` | `"binary-response"` | Returns binary response instead of stream wrapper |
22
- * | `formDataSupport` | `"Node16"` | `"Node18"` | Uses native FormData (Node 18+) instead of polyfill |
23
- * | `fetchSupport` | `"node-fetch"` | `"native"` | Uses native fetch (Node 18+/browsers) instead of node-fetch |
24
- *
25
- * ## Migration Strategy
26
- *
27
- * This migration uses the nullish coalescing assignment operator (`??=`) to only set
28
- * values that are explicitly undefined. This means:
29
- * - ✅ If a user has explicitly configured a field, that value is preserved
30
- * - ✅ If a field is undefined, the old default (with dependencies) is set
31
- * - ✅ Users can opt into zero-dependency mode by removing these fields later
32
- *
33
- * ## Examples
34
- *
35
- * ### Example 1: Empty Config (Migration Applied - Dependencies Maintained)
36
- *
37
- * **Before Migration (1.9.0 → 2.0.0):**
38
- * ```yaml
39
- * generators:
40
- * - name: fernapi/fern-typescript-sdk
41
- * version: 1.9.0
42
- * config: {}
43
- * ```
44
- *
45
- * **After Migration:**
46
- * ```yaml
47
- * generators:
48
- * - name: fernapi/fern-typescript-sdk
49
- * version: 2.0.0
50
- * config:
51
- * streamType: wrapper # Set by migration - uses wrapper library
52
- * fileResponseType: stream # Set by migration - uses stream wrapper
53
- * formDataSupport: Node16 # Set by migration - uses polyfill
54
- * fetchSupport: node-fetch # Set by migration - uses node-fetch package
55
- * ```
56
- *
57
- * **Result:** SDK continues using external dependencies, works with Node 16+.
58
- *
59
- * **Dependencies Required:**
60
- * - `node-fetch` for HTTP requests
61
- * - `form-data` for multipart uploads
62
- * - Stream wrapper libraries
63
- *
64
- * ### Example 2: Opting Into Zero-Dependency Mode
65
- *
66
- * **After Initial Migration:**
67
- * ```yaml
68
- * generators:
69
- * - name: fernapi/fern-typescript-sdk
70
- * version: 2.0.0
71
- * config:
72
- * streamType: wrapper
73
- * fileResponseType: stream
74
- * formDataSupport: Node16
75
- * fetchSupport: node-fetch
76
- * ```
77
- *
78
- * **To Adopt Zero-Dependency Mode:**
79
- * ```yaml
80
- * generators:
81
- * - name: fernapi/fern-typescript-sdk
82
- * version: 2.0.0
83
- * config: {} # Remove all fields to use new defaults
84
- * ```
85
- *
86
- * **Result:** SDK uses native APIs, no external dependencies required.
87
- *
88
- * **Requirements for Zero-Dependency Mode:**
89
- * - Node.js 18+ (for native fetch and FormData)
90
- * - OR modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+)
91
- *
92
- * ## Why These Defaults Changed
93
- *
94
- * ### Bundle Size Impact
95
- *
96
- * **With Dependencies (Old):**
97
- * ```
98
- * node-fetch: ~90KB
99
- * form-data: ~40KB
100
- * stream wrappers: ~20KB
101
- * Total: ~150KB added to your bundle
102
- * ```
103
- *
104
- * **Zero Dependencies (New):**
105
- * ```
106
- * Total: 0KB (uses native APIs)
107
- * ```
108
- *
109
- * ### Performance Benefits
110
- *
111
- * - **Native fetch**: ~30% faster than node-fetch
112
- * - **Native streams**: ~40% faster than wrapper libraries
113
- * - **No dependency resolution**: Faster npm install and startup time
114
- *
115
- * ## Runtime Compatibility
116
- *
117
- * ### With Old Defaults (Migration Applied)
118
- * - ✅ Node.js 12+
119
- * - ✅ All browsers (with polyfills)
120
- * - ✅ Edge runtimes (Cloudflare Workers, etc.)
121
- *
122
- * ### With New Defaults (Zero-Dependency)
123
- * - ✅ Node.js 18+
124
- * - ✅ Modern browsers (last 2 years)
125
- * - ⚠️ May need polyfills for edge runtimes
126
- *
127
- * ## Migration Path to Zero-Dependency
128
- *
129
- * ### Step 1: Upgrade with Migration (Safe)
130
- * ```bash
131
- * fern generator upgrade
132
- * ```
133
- * Result: Old behavior preserved, dependencies still required.
134
- *
135
- * ### Step 2: Update Node Version (If Needed)
136
- * Ensure your runtime is Node 18+ or a modern browser.
137
- *
138
- * ### Step 3: Remove Old Defaults
139
- * Edit `generators.yml`:
140
- * ```yaml
141
- * config: {} # Use new zero-dependency defaults
142
- * ```
143
- *
144
- * ### Step 4: Remove Dependencies
145
- * ```bash
146
- * npm uninstall node-fetch form-data
147
- * ```
148
- *
149
- * ### Step 5: Test Thoroughly
150
- * Verify streams, file uploads, and fetch operations work correctly.
151
- */
152
- export declare const migration_2_0_0: Migration;
153
- //# sourceMappingURL=2.0.0.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"2.0.0.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/2.0.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqJG;AACH,eAAO,MAAM,eAAe,EAAE,SAa7B,CAAC"}
@@ -1,163 +0,0 @@
1
- import { migrateConfig } from "@fern-api/migrations-base";
2
- /**
3
- * Migration for version 2.0.0
4
- *
5
- * ## Context
6
- *
7
- * Version 2.0.0 introduced zero-dependency SDKs by default, using native browser and
8
- * Node.js APIs instead of external packages. This significantly reduces bundle size
9
- * and eliminates dependency management issues, but requires Node.js 18+ and modern
10
- * browsers with native fetch/streams support.
11
- *
12
- * For users upgrading from pre-2.0.0 versions who need to maintain compatibility with
13
- * older runtimes, this migration explicitly sets the old defaults that use polyfills
14
- * and wrapper libraries.
15
- *
16
- * ## Changed Defaults
17
- *
18
- * | Field | Old Default (pre-2.0.0) | New Default (2.0.0+) | Impact |
19
- * |-------|-------------------------|----------------------|--------|
20
- * | `streamType` | `"wrapper"` | `"web"` | Uses native Web Streams API instead of wrapper library |
21
- * | `fileResponseType` | `"stream"` | `"binary-response"` | Returns binary response instead of stream wrapper |
22
- * | `formDataSupport` | `"Node16"` | `"Node18"` | Uses native FormData (Node 18+) instead of polyfill |
23
- * | `fetchSupport` | `"node-fetch"` | `"native"` | Uses native fetch (Node 18+/browsers) instead of node-fetch |
24
- *
25
- * ## Migration Strategy
26
- *
27
- * This migration uses the nullish coalescing assignment operator (`??=`) to only set
28
- * values that are explicitly undefined. This means:
29
- * - ✅ If a user has explicitly configured a field, that value is preserved
30
- * - ✅ If a field is undefined, the old default (with dependencies) is set
31
- * - ✅ Users can opt into zero-dependency mode by removing these fields later
32
- *
33
- * ## Examples
34
- *
35
- * ### Example 1: Empty Config (Migration Applied - Dependencies Maintained)
36
- *
37
- * **Before Migration (1.9.0 → 2.0.0):**
38
- * ```yaml
39
- * generators:
40
- * - name: fernapi/fern-typescript-sdk
41
- * version: 1.9.0
42
- * config: {}
43
- * ```
44
- *
45
- * **After Migration:**
46
- * ```yaml
47
- * generators:
48
- * - name: fernapi/fern-typescript-sdk
49
- * version: 2.0.0
50
- * config:
51
- * streamType: wrapper # Set by migration - uses wrapper library
52
- * fileResponseType: stream # Set by migration - uses stream wrapper
53
- * formDataSupport: Node16 # Set by migration - uses polyfill
54
- * fetchSupport: node-fetch # Set by migration - uses node-fetch package
55
- * ```
56
- *
57
- * **Result:** SDK continues using external dependencies, works with Node 16+.
58
- *
59
- * **Dependencies Required:**
60
- * - `node-fetch` for HTTP requests
61
- * - `form-data` for multipart uploads
62
- * - Stream wrapper libraries
63
- *
64
- * ### Example 2: Opting Into Zero-Dependency Mode
65
- *
66
- * **After Initial Migration:**
67
- * ```yaml
68
- * generators:
69
- * - name: fernapi/fern-typescript-sdk
70
- * version: 2.0.0
71
- * config:
72
- * streamType: wrapper
73
- * fileResponseType: stream
74
- * formDataSupport: Node16
75
- * fetchSupport: node-fetch
76
- * ```
77
- *
78
- * **To Adopt Zero-Dependency Mode:**
79
- * ```yaml
80
- * generators:
81
- * - name: fernapi/fern-typescript-sdk
82
- * version: 2.0.0
83
- * config: {} # Remove all fields to use new defaults
84
- * ```
85
- *
86
- * **Result:** SDK uses native APIs, no external dependencies required.
87
- *
88
- * **Requirements for Zero-Dependency Mode:**
89
- * - Node.js 18+ (for native fetch and FormData)
90
- * - OR modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+)
91
- *
92
- * ## Why These Defaults Changed
93
- *
94
- * ### Bundle Size Impact
95
- *
96
- * **With Dependencies (Old):**
97
- * ```
98
- * node-fetch: ~90KB
99
- * form-data: ~40KB
100
- * stream wrappers: ~20KB
101
- * Total: ~150KB added to your bundle
102
- * ```
103
- *
104
- * **Zero Dependencies (New):**
105
- * ```
106
- * Total: 0KB (uses native APIs)
107
- * ```
108
- *
109
- * ### Performance Benefits
110
- *
111
- * - **Native fetch**: ~30% faster than node-fetch
112
- * - **Native streams**: ~40% faster than wrapper libraries
113
- * - **No dependency resolution**: Faster npm install and startup time
114
- *
115
- * ## Runtime Compatibility
116
- *
117
- * ### With Old Defaults (Migration Applied)
118
- * - ✅ Node.js 12+
119
- * - ✅ All browsers (with polyfills)
120
- * - ✅ Edge runtimes (Cloudflare Workers, etc.)
121
- *
122
- * ### With New Defaults (Zero-Dependency)
123
- * - ✅ Node.js 18+
124
- * - ✅ Modern browsers (last 2 years)
125
- * - ⚠️ May need polyfills for edge runtimes
126
- *
127
- * ## Migration Path to Zero-Dependency
128
- *
129
- * ### Step 1: Upgrade with Migration (Safe)
130
- * ```bash
131
- * fern generator upgrade
132
- * ```
133
- * Result: Old behavior preserved, dependencies still required.
134
- *
135
- * ### Step 2: Update Node Version (If Needed)
136
- * Ensure your runtime is Node 18+ or a modern browser.
137
- *
138
- * ### Step 3: Remove Old Defaults
139
- * Edit `generators.yml`:
140
- * ```yaml
141
- * config: {} # Use new zero-dependency defaults
142
- * ```
143
- *
144
- * ### Step 4: Remove Dependencies
145
- * ```bash
146
- * npm uninstall node-fetch form-data
147
- * ```
148
- *
149
- * ### Step 5: Test Thoroughly
150
- * Verify streams, file uploads, and fetch operations work correctly.
151
- */
152
- export const migration_2_0_0 = {
153
- version: "2.0.0",
154
- migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
155
- // Only set old defaults if the fields are not already explicitly configured
156
- draft.streamType ??= "wrapper";
157
- draft.fileResponseType ??= "stream";
158
- draft.formDataSupport ??= "Node16";
159
- draft.fetchSupport ??= "node-fetch";
160
- }),
161
- migrateGeneratorsYml: ({ document }) => document
162
- };
163
- //# sourceMappingURL=2.0.0.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"2.0.0.js","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/2.0.0.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqJG;AACH,MAAM,CAAC,MAAM,eAAe,GAAc;IACtC,OAAO,EAAE,OAAO;IAEhB,sBAAsB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CACnC,aAAa,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5B,4EAA4E;QAC5E,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC;QAC/B,KAAK,CAAC,gBAAgB,KAAK,QAAQ,CAAC;QACpC,KAAK,CAAC,eAAe,KAAK,QAAQ,CAAC;QACnC,KAAK,CAAC,YAAY,KAAK,YAAY,CAAC;IACxC,CAAC,CAAC;IAEN,oBAAoB,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ;CACnD,CAAC"}