@postman/sdk-config 0.0.3 → 0.1.0
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/README.md +42 -17
- package/dist/index.cjs +2017 -180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1980 -181
- package/dist/index.js.map +1 -1
- package/dist/sdk-config/index.cjs +2233 -0
- package/dist/sdk-config/index.cjs.map +1 -0
- package/dist/sdk-config/index.d.cts +3 -0
- package/dist/sdk-config/index.d.ts +3 -0
- package/dist/sdk-config/index.js +2192 -0
- package/dist/sdk-config/index.js.map +1 -0
- package/dist/sdk-config/v1/index.cjs +2233 -0
- package/dist/sdk-config/v1/index.cjs.map +1 -0
- package/dist/sdk-config/v1/index.d.cts +8644 -0
- package/dist/sdk-config/v1/index.d.ts +8644 -0
- package/dist/sdk-config/v1/index.js +2192 -0
- package/dist/sdk-config/v1/index.js.map +1 -0
- package/dist/sdk-config-ir/index.cjs +155 -19
- package/dist/sdk-config-ir/index.cjs.map +1 -1
- package/dist/sdk-config-ir/index.d.cts +2 -1
- package/dist/sdk-config-ir/index.d.ts +2 -1
- package/dist/sdk-config-ir/index.js +154 -20
- package/dist/sdk-config-ir/index.js.map +1 -1
- package/dist/sdk-config-ir/v1/index.cjs +155 -19
- package/dist/sdk-config-ir/v1/index.cjs.map +1 -1
- package/dist/sdk-config-ir/v1/index.d.cts +448 -398
- package/dist/sdk-config-ir/v1/index.d.ts +448 -398
- package/dist/sdk-config-ir/v1/index.js +154 -20
- package/dist/sdk-config-ir/v1/index.js.map +1 -1
- package/dist/typescript-ByDbin_v.d.cts +426 -0
- package/dist/typescript-ByDbin_v.d.ts +426 -0
- package/package.json +15 -2
- package/src/sdk-config/v1/README.md +135 -0
- package/src/sdk-config-ir/v1/README.md +46 -27
|
@@ -0,0 +1,2192 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
|
|
4
|
+
// src/sdk-config-domain/v1/api.ts
|
|
5
|
+
var nonEmptyStringSchema = z.string().min(1);
|
|
6
|
+
var exactSemverSchema = z.string().refine(
|
|
7
|
+
(value) => {
|
|
8
|
+
if (value.trim() !== value || !/^\d/.test(value)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const parsed = semver.parse(value, { loose: false });
|
|
12
|
+
return parsed?.raw === value;
|
|
13
|
+
},
|
|
14
|
+
{ message: "must be an exact semantic version" }
|
|
15
|
+
);
|
|
16
|
+
var jsonValueSchema = z.lazy(
|
|
17
|
+
() => z.union([
|
|
18
|
+
z.null(),
|
|
19
|
+
z.boolean(),
|
|
20
|
+
z.number(),
|
|
21
|
+
z.string(),
|
|
22
|
+
z.array(jsonValueSchema),
|
|
23
|
+
z.record(z.string(), jsonValueSchema)
|
|
24
|
+
])
|
|
25
|
+
);
|
|
26
|
+
z.record(z.string(), jsonValueSchema);
|
|
27
|
+
|
|
28
|
+
// src/sdk-config-domain/v1/api.ts
|
|
29
|
+
var authVariableSchema = z.strictObject({
|
|
30
|
+
name: nonEmptyStringSchema.optional(),
|
|
31
|
+
environmentVariable: nonEmptyStringSchema.optional(),
|
|
32
|
+
description: z.string().optional(),
|
|
33
|
+
omit: z.boolean().optional()
|
|
34
|
+
});
|
|
35
|
+
var apiKeyAuthSchema = z.strictObject({
|
|
36
|
+
id: nonEmptyStringSchema,
|
|
37
|
+
type: z.literal("api-key"),
|
|
38
|
+
location: z.enum(["header", "query", "cookie"]),
|
|
39
|
+
name: nonEmptyStringSchema,
|
|
40
|
+
prefix: nonEmptyStringSchema.optional(),
|
|
41
|
+
environmentVariable: nonEmptyStringSchema.optional(),
|
|
42
|
+
description: z.string().optional()
|
|
43
|
+
});
|
|
44
|
+
var bearerAuthSchema = z.strictObject({
|
|
45
|
+
id: nonEmptyStringSchema,
|
|
46
|
+
type: z.literal("bearer"),
|
|
47
|
+
header: nonEmptyStringSchema.optional(),
|
|
48
|
+
prefix: nonEmptyStringSchema.optional(),
|
|
49
|
+
environmentVariable: nonEmptyStringSchema.optional(),
|
|
50
|
+
description: z.string().optional()
|
|
51
|
+
});
|
|
52
|
+
var basicAuthSchema = z.strictObject({
|
|
53
|
+
id: nonEmptyStringSchema,
|
|
54
|
+
type: z.literal("basic"),
|
|
55
|
+
username: authVariableSchema.optional(),
|
|
56
|
+
password: authVariableSchema.optional(),
|
|
57
|
+
description: z.string().optional()
|
|
58
|
+
});
|
|
59
|
+
var oauthScopeSchema = z.strictObject({
|
|
60
|
+
name: nonEmptyStringSchema,
|
|
61
|
+
description: z.string().optional()
|
|
62
|
+
});
|
|
63
|
+
var oauthFlowSchema = z.discriminatedUnion("type", [
|
|
64
|
+
z.strictObject({
|
|
65
|
+
type: z.literal("authorization-code"),
|
|
66
|
+
authorizationUrl: nonEmptyStringSchema,
|
|
67
|
+
tokenUrl: nonEmptyStringSchema,
|
|
68
|
+
refreshUrl: nonEmptyStringSchema.optional(),
|
|
69
|
+
scopes: z.array(oauthScopeSchema).optional()
|
|
70
|
+
}),
|
|
71
|
+
z.strictObject({
|
|
72
|
+
type: z.literal("client-credentials"),
|
|
73
|
+
tokenUrl: nonEmptyStringSchema,
|
|
74
|
+
refreshUrl: nonEmptyStringSchema.optional(),
|
|
75
|
+
scopes: z.array(oauthScopeSchema).optional()
|
|
76
|
+
}),
|
|
77
|
+
z.strictObject({
|
|
78
|
+
type: z.literal("implicit"),
|
|
79
|
+
authorizationUrl: nonEmptyStringSchema,
|
|
80
|
+
refreshUrl: nonEmptyStringSchema.optional(),
|
|
81
|
+
scopes: z.array(oauthScopeSchema).optional()
|
|
82
|
+
}),
|
|
83
|
+
z.strictObject({
|
|
84
|
+
type: z.literal("password"),
|
|
85
|
+
tokenUrl: nonEmptyStringSchema,
|
|
86
|
+
refreshUrl: nonEmptyStringSchema.optional(),
|
|
87
|
+
scopes: z.array(oauthScopeSchema).optional()
|
|
88
|
+
})
|
|
89
|
+
]);
|
|
90
|
+
var oauth2AuthSchema = z.strictObject({
|
|
91
|
+
id: nonEmptyStringSchema,
|
|
92
|
+
type: z.literal("oauth2"),
|
|
93
|
+
flows: z.array(oauthFlowSchema).min(1),
|
|
94
|
+
clientId: authVariableSchema.optional(),
|
|
95
|
+
clientSecret: authVariableSchema.optional(),
|
|
96
|
+
tokenHeader: nonEmptyStringSchema.optional(),
|
|
97
|
+
tokenPrefix: nonEmptyStringSchema.optional(),
|
|
98
|
+
refreshBufferSeconds: z.number().nonnegative().optional(),
|
|
99
|
+
description: z.string().optional()
|
|
100
|
+
});
|
|
101
|
+
var customAuthParameterSchema = z.strictObject({
|
|
102
|
+
location: z.enum(["header", "query", "cookie"]),
|
|
103
|
+
name: nonEmptyStringSchema,
|
|
104
|
+
prefix: nonEmptyStringSchema.optional(),
|
|
105
|
+
environmentVariable: nonEmptyStringSchema.optional()
|
|
106
|
+
});
|
|
107
|
+
var customAuthSchema = z.strictObject({
|
|
108
|
+
id: nonEmptyStringSchema,
|
|
109
|
+
type: z.literal("custom"),
|
|
110
|
+
parameters: z.array(customAuthParameterSchema).min(1),
|
|
111
|
+
description: z.string().optional()
|
|
112
|
+
});
|
|
113
|
+
var authSchemeSchema = z.discriminatedUnion("type", [
|
|
114
|
+
apiKeyAuthSchema,
|
|
115
|
+
bearerAuthSchema,
|
|
116
|
+
basicAuthSchema,
|
|
117
|
+
oauth2AuthSchema,
|
|
118
|
+
customAuthSchema
|
|
119
|
+
]);
|
|
120
|
+
var authRequirementSchema = z.strictObject({
|
|
121
|
+
schemes: z.array(nonEmptyStringSchema).min(1)
|
|
122
|
+
});
|
|
123
|
+
var authConfigSchema = z.strictObject({
|
|
124
|
+
schemes: z.array(authSchemeSchema).min(1),
|
|
125
|
+
requirements: z.array(authRequirementSchema).optional(),
|
|
126
|
+
endpointSecurity: z.boolean().optional()
|
|
127
|
+
}).superRefine(({ requirements, schemes }, context) => {
|
|
128
|
+
const schemeIds = /* @__PURE__ */ new Set();
|
|
129
|
+
schemes.forEach(({ id }, index) => {
|
|
130
|
+
if (schemeIds.has(id)) {
|
|
131
|
+
context.addIssue({
|
|
132
|
+
code: "custom",
|
|
133
|
+
message: `auth scheme id "${id}" must be unique`,
|
|
134
|
+
path: ["schemes", index, "id"]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
schemeIds.add(id);
|
|
138
|
+
});
|
|
139
|
+
requirements?.forEach((requirement, requirementIndex) => {
|
|
140
|
+
requirement.schemes.forEach((schemeId, schemeIndex) => {
|
|
141
|
+
if (!schemeIds.has(schemeId)) {
|
|
142
|
+
context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
message: `auth requirement references unknown scheme "${schemeId}"`,
|
|
145
|
+
path: ["requirements", requirementIndex, "schemes", schemeIndex]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
var environmentUrlSchema = z.strictObject({
|
|
152
|
+
name: nonEmptyStringSchema,
|
|
153
|
+
url: nonEmptyStringSchema,
|
|
154
|
+
serverName: nonEmptyStringSchema.optional()
|
|
155
|
+
});
|
|
156
|
+
var environmentSchema = z.strictObject({
|
|
157
|
+
name: nonEmptyStringSchema,
|
|
158
|
+
urls: z.array(environmentUrlSchema).min(1),
|
|
159
|
+
description: z.string().optional()
|
|
160
|
+
});
|
|
161
|
+
var headerSchema = z.strictObject({
|
|
162
|
+
name: nonEmptyStringSchema,
|
|
163
|
+
value: z.string().optional(),
|
|
164
|
+
description: z.string().optional(),
|
|
165
|
+
environmentVariable: nonEmptyStringSchema.optional()
|
|
166
|
+
});
|
|
167
|
+
var environmentVariableSchema = z.strictObject({
|
|
168
|
+
name: nonEmptyStringSchema,
|
|
169
|
+
description: z.string().optional(),
|
|
170
|
+
defaultValue: z.string().optional()
|
|
171
|
+
});
|
|
172
|
+
var apiConfigSchema = z.strictObject({
|
|
173
|
+
baseUrl: z.string().default(""),
|
|
174
|
+
environments: z.array(environmentSchema).default([]),
|
|
175
|
+
environmentVariables: z.array(environmentVariableSchema).default([]),
|
|
176
|
+
defaultEnvironment: nonEmptyStringSchema.optional(),
|
|
177
|
+
auth: authConfigSchema.optional(),
|
|
178
|
+
headers: z.array(headerSchema).optional(),
|
|
179
|
+
/**
|
|
180
|
+
* Selects the named `x-fern-audiences`.
|
|
181
|
+
*
|
|
182
|
+
* Absent means all audiences. A present empty array selects no tagged audience: untagged nodes
|
|
183
|
+
* remain included, while every audience-tagged node is excluded.
|
|
184
|
+
*/
|
|
185
|
+
audiences: z.array(nonEmptyStringSchema).optional()
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// src/sdk-config/v1/api.ts
|
|
189
|
+
var sdkConfigV1AuthSchemeSchema = authSchemeSchema;
|
|
190
|
+
var sdkConfigV1AuthConfigSchema = authConfigSchema;
|
|
191
|
+
var sdkConfigV1ApiConfigSchema = apiConfigSchema;
|
|
192
|
+
var retryConfigSchema = z.strictObject({
|
|
193
|
+
enabled: z.boolean().default(true),
|
|
194
|
+
maxAttempts: z.number().int().min(1).default(3),
|
|
195
|
+
retryDelayMs: z.number().nonnegative().default(150),
|
|
196
|
+
maxDelayMs: z.number().nonnegative().default(5e3),
|
|
197
|
+
jitterMs: z.number().nonnegative().default(50),
|
|
198
|
+
backoffFactor: z.number().positive().default(2),
|
|
199
|
+
statusCodes: z.array(z.number().int().min(100).max(599)).optional(),
|
|
200
|
+
methods: z.array(nonEmptyStringSchema).default(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]),
|
|
201
|
+
statusCodeProfile: z.enum(["legacy", "recommended"]).optional(),
|
|
202
|
+
maxRetryAfterDelayMs: z.number().nonnegative().default(6e4)
|
|
203
|
+
}).superRefine(({ maxDelayMs, retryDelayMs }, context) => {
|
|
204
|
+
if (maxDelayMs < retryDelayMs) {
|
|
205
|
+
context.addIssue({
|
|
206
|
+
code: "custom",
|
|
207
|
+
message: "maxDelayMs must be greater than or equal to retryDelayMs",
|
|
208
|
+
path: ["maxDelayMs"]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
var constructorParameterSchema = z.strictObject({
|
|
213
|
+
name: nonEmptyStringSchema,
|
|
214
|
+
example: z.string().optional(),
|
|
215
|
+
description: z.string().optional(),
|
|
216
|
+
required: z.boolean().optional()
|
|
217
|
+
});
|
|
218
|
+
var parameterStyleSchema = z.enum(["wrapped", "inline", "language-default"]);
|
|
219
|
+
var tokenRefreshConfigSchema = z.strictObject({
|
|
220
|
+
enabled: z.boolean(),
|
|
221
|
+
endpoint: nonEmptyStringSchema.optional(),
|
|
222
|
+
accessTokenField: nonEmptyStringSchema.optional(),
|
|
223
|
+
refreshTokenField: nonEmptyStringSchema.optional()
|
|
224
|
+
}).superRefine(({ enabled, endpoint }, context) => {
|
|
225
|
+
if (enabled && endpoint === void 0) {
|
|
226
|
+
context.addIssue({
|
|
227
|
+
code: "custom",
|
|
228
|
+
message: "endpoint is required when tokenRefresh is enabled",
|
|
229
|
+
path: ["endpoint"]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
var clientConfigSchema = z.strictObject({
|
|
234
|
+
retry: retryConfigSchema.prefault({}),
|
|
235
|
+
responseHeaders: z.boolean().default(false),
|
|
236
|
+
responseValidation: z.boolean().optional(),
|
|
237
|
+
multiTenant: z.boolean().default(false),
|
|
238
|
+
additionalConstructorParameters: z.array(constructorParameterSchema).default([]),
|
|
239
|
+
timeoutMs: z.union([z.number().nonnegative(), z.literal("infinity")]).optional(),
|
|
240
|
+
requestParameterStyle: parameterStyleSchema.optional(),
|
|
241
|
+
pathParameterStyle: parameterStyleSchema.optional(),
|
|
242
|
+
filePropertyStyle: parameterStyleSchema.optional(),
|
|
243
|
+
useDefaultRequestParameterValues: z.boolean().optional(),
|
|
244
|
+
respectOptionalRequestBody: z.boolean().optional(),
|
|
245
|
+
tokenRefresh: tokenRefreshConfigSchema.optional()
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// src/sdk-config/v1/client.ts
|
|
249
|
+
var sdkConfigV1ClientConfigSchema = clientConfigSchema;
|
|
250
|
+
var goModulePathSchema = nonEmptyStringSchema.regex(
|
|
251
|
+
/^(?!.*(?:^|\/)\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)+$/,
|
|
252
|
+
"Go module path must be a slash-delimited path using letters, numbers, dots, dashes, underscores, or tildes"
|
|
253
|
+
);
|
|
254
|
+
var composerPackageNameSchema = nonEmptyStringSchema.regex(
|
|
255
|
+
/^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$/,
|
|
256
|
+
'Composer package name must be a lowercase "vendor/package" name'
|
|
257
|
+
);
|
|
258
|
+
var authorSchema = z.strictObject({
|
|
259
|
+
name: nonEmptyStringSchema,
|
|
260
|
+
email: z.email().optional()
|
|
261
|
+
});
|
|
262
|
+
var developerSchema = z.strictObject({
|
|
263
|
+
name: nonEmptyStringSchema,
|
|
264
|
+
email: z.email().optional(),
|
|
265
|
+
organization: nonEmptyStringSchema.optional(),
|
|
266
|
+
organizationUrl: nonEmptyStringSchema.optional()
|
|
267
|
+
});
|
|
268
|
+
var licenseSchema = z.strictObject({
|
|
269
|
+
type: nonEmptyStringSchema,
|
|
270
|
+
name: nonEmptyStringSchema.optional(),
|
|
271
|
+
url: nonEmptyStringSchema.optional(),
|
|
272
|
+
path: nonEmptyStringSchema.optional()
|
|
273
|
+
});
|
|
274
|
+
var dependencySourceSchema = z.discriminatedUnion("type", [
|
|
275
|
+
z.strictObject({
|
|
276
|
+
type: z.literal("registry"),
|
|
277
|
+
registry: nonEmptyStringSchema.optional()
|
|
278
|
+
}),
|
|
279
|
+
z.strictObject({
|
|
280
|
+
type: z.literal("git"),
|
|
281
|
+
url: nonEmptyStringSchema,
|
|
282
|
+
ref: nonEmptyStringSchema.optional(),
|
|
283
|
+
subdirectory: nonEmptyStringSchema.optional()
|
|
284
|
+
}),
|
|
285
|
+
z.strictObject({
|
|
286
|
+
type: z.literal("path"),
|
|
287
|
+
path: nonEmptyStringSchema
|
|
288
|
+
})
|
|
289
|
+
]);
|
|
290
|
+
var dependencySchema = z.strictObject({
|
|
291
|
+
name: nonEmptyStringSchema,
|
|
292
|
+
version: nonEmptyStringSchema.optional(),
|
|
293
|
+
source: dependencySourceSchema.optional(),
|
|
294
|
+
packageName: nonEmptyStringSchema.optional(),
|
|
295
|
+
features: z.array(nonEmptyStringSchema).optional(),
|
|
296
|
+
extras: z.array(nonEmptyStringSchema).optional(),
|
|
297
|
+
optional: z.boolean().optional(),
|
|
298
|
+
defaultFeatures: z.boolean().optional(),
|
|
299
|
+
environmentMarker: nonEmptyStringSchema.optional()
|
|
300
|
+
}).refine(({ source, version }) => source !== void 0 || version !== void 0, {
|
|
301
|
+
message: "dependency must define a version or a source"
|
|
302
|
+
});
|
|
303
|
+
var projectUrlSchema = z.strictObject({
|
|
304
|
+
label: nonEmptyStringSchema,
|
|
305
|
+
url: nonEmptyStringSchema
|
|
306
|
+
});
|
|
307
|
+
var packageConfigSchema = z.strictObject({
|
|
308
|
+
packageName: nonEmptyStringSchema.optional(),
|
|
309
|
+
moduleName: nonEmptyStringSchema.optional(),
|
|
310
|
+
modulePath: goModulePathSchema.optional(),
|
|
311
|
+
namespace: nonEmptyStringSchema.optional(),
|
|
312
|
+
groupId: nonEmptyStringSchema.optional(),
|
|
313
|
+
artifactId: nonEmptyStringSchema.optional(),
|
|
314
|
+
description: z.string().optional(),
|
|
315
|
+
repository: nonEmptyStringSchema.optional(),
|
|
316
|
+
homepage: nonEmptyStringSchema.optional(),
|
|
317
|
+
documentationUrl: nonEmptyStringSchema.optional(),
|
|
318
|
+
authors: z.array(authorSchema).optional(),
|
|
319
|
+
developers: z.array(developerSchema).optional(),
|
|
320
|
+
license: licenseSchema.optional(),
|
|
321
|
+
keywords: z.array(nonEmptyStringSchema).optional(),
|
|
322
|
+
classifiers: z.array(nonEmptyStringSchema).optional(),
|
|
323
|
+
projectUrls: z.array(projectUrlSchema).optional(),
|
|
324
|
+
extraDependencies: z.array(dependencySchema).optional(),
|
|
325
|
+
extraDevDependencies: z.array(dependencySchema).optional(),
|
|
326
|
+
extraPeerDependencies: z.array(dependencySchema).optional()
|
|
327
|
+
});
|
|
328
|
+
var httpMethodSchema = z.enum([
|
|
329
|
+
"GET",
|
|
330
|
+
"POST",
|
|
331
|
+
"PUT",
|
|
332
|
+
"PATCH",
|
|
333
|
+
"DELETE",
|
|
334
|
+
"HEAD",
|
|
335
|
+
"OPTIONS",
|
|
336
|
+
"TRACE",
|
|
337
|
+
"CONNECT"
|
|
338
|
+
]);
|
|
339
|
+
var readmeEndpointSchema = z.strictObject({
|
|
340
|
+
method: httpMethodSchema,
|
|
341
|
+
path: nonEmptyStringSchema,
|
|
342
|
+
stream: z.boolean().optional()
|
|
343
|
+
});
|
|
344
|
+
var readmeCustomSectionSchema = z.strictObject({
|
|
345
|
+
title: nonEmptyStringSchema,
|
|
346
|
+
content: z.string()
|
|
347
|
+
});
|
|
348
|
+
var readmeConfigSchema = z.strictObject({
|
|
349
|
+
apiName: nonEmptyStringSchema.optional(),
|
|
350
|
+
introduction: z.string().optional(),
|
|
351
|
+
apiReferenceLink: nonEmptyStringSchema.optional(),
|
|
352
|
+
bannerLink: nonEmptyStringSchema.optional(),
|
|
353
|
+
disabledSections: z.array(nonEmptyStringSchema).optional(),
|
|
354
|
+
customSections: z.array(readmeCustomSectionSchema).optional(),
|
|
355
|
+
defaultEndpoint: readmeEndpointSchema.optional(),
|
|
356
|
+
features: z.record(z.string(), z.array(readmeEndpointSchema)).optional()
|
|
357
|
+
});
|
|
358
|
+
var snippetsConfigSchema = z.strictObject({
|
|
359
|
+
enabled: z.boolean(),
|
|
360
|
+
format: z.enum(["md", "json"]).optional(),
|
|
361
|
+
outputPath: nonEmptyStringSchema.optional()
|
|
362
|
+
});
|
|
363
|
+
var docsConfigSchema = z.strictObject({
|
|
364
|
+
readme: readmeConfigSchema.optional(),
|
|
365
|
+
snippets: snippetsConfigSchema.optional(),
|
|
366
|
+
referenceBaseUrl: nonEmptyStringSchema.optional(),
|
|
367
|
+
includeApiReference: z.boolean().optional()
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// src/sdk-config/v1/docs.ts
|
|
371
|
+
var sdkConfigV1ReadmeEndpointSchema = readmeEndpointSchema;
|
|
372
|
+
var sdkConfigV1ReadmeCustomSectionSchema = readmeCustomSectionSchema;
|
|
373
|
+
var sdkConfigV1DocsConfigSchema = docsConfigSchema;
|
|
374
|
+
|
|
375
|
+
// src/sdk-config/v1/fern-config-mapper-types.ts
|
|
376
|
+
var FernConfigMappingError = class extends Error {
|
|
377
|
+
constructor(issues) {
|
|
378
|
+
super(issues.map(({ path, reason }) => `${path.join(".")}: ${reason}`).join("\n"));
|
|
379
|
+
this.issues = issues;
|
|
380
|
+
this.name = "FernConfigMappingError";
|
|
381
|
+
}
|
|
382
|
+
issues;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// src/sdk-config/v1/fern-config-mapper-helpers.ts
|
|
386
|
+
function fail(code, path, reason, suggestedAction, sdkConfigPath) {
|
|
387
|
+
throw new FernConfigMappingError([
|
|
388
|
+
{
|
|
389
|
+
code,
|
|
390
|
+
severity: "error",
|
|
391
|
+
path,
|
|
392
|
+
reason,
|
|
393
|
+
suggestedAction,
|
|
394
|
+
...optional("sdkConfigPath", sdkConfigPath)
|
|
395
|
+
}
|
|
396
|
+
]);
|
|
397
|
+
}
|
|
398
|
+
function takeTimeoutMs(value, state, basePath) {
|
|
399
|
+
const milliseconds = locate(value, ["defaultTimeout", "defaultTimeoutInMilliseconds"], basePath);
|
|
400
|
+
if (milliseconds && (milliseconds.value === "infinity" || isNonNegativeNumber(milliseconds.value))) {
|
|
401
|
+
consume(state, milliseconds.path);
|
|
402
|
+
return milliseconds.value;
|
|
403
|
+
}
|
|
404
|
+
const seconds = locate(
|
|
405
|
+
value,
|
|
406
|
+
["defaultTimeoutInSeconds", "timeoutInSeconds", "timeout"],
|
|
407
|
+
basePath
|
|
408
|
+
);
|
|
409
|
+
if (seconds && (seconds.value === "infinity" || isNonNegativeNumber(seconds.value))) {
|
|
410
|
+
consume(state, seconds.path);
|
|
411
|
+
return seconds.value === "infinity" ? "infinity" : seconds.value * 1e3;
|
|
412
|
+
}
|
|
413
|
+
return void 0;
|
|
414
|
+
}
|
|
415
|
+
function locate(value, aliases, basePath) {
|
|
416
|
+
for (const [key, child] of Object.entries(value)) {
|
|
417
|
+
if (aliases.some((alias) => normalizeKey(alias) === normalizeKey(key))) {
|
|
418
|
+
return { value: child, path: [...basePath, key] };
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return void 0;
|
|
422
|
+
}
|
|
423
|
+
function takeObject(value, aliases, _state, basePath) {
|
|
424
|
+
const located = locate(value, aliases, basePath);
|
|
425
|
+
return located && isObject(located.value) ? { value: located.value, path: located.path } : void 0;
|
|
426
|
+
}
|
|
427
|
+
function takeString(value, aliases, state, basePath) {
|
|
428
|
+
const located = locate(value, aliases, basePath);
|
|
429
|
+
if (!located || typeof located.value !== "string" || located.value.length === 0) return void 0;
|
|
430
|
+
consume(state, located.path);
|
|
431
|
+
return located.value;
|
|
432
|
+
}
|
|
433
|
+
function takeGoModulePath(value, aliases, state, basePath) {
|
|
434
|
+
const located = locate(value, aliases, basePath);
|
|
435
|
+
if (!located || !goModulePathSchema.safeParse(located.value).success) return void 0;
|
|
436
|
+
consume(state, located.path);
|
|
437
|
+
return located.value;
|
|
438
|
+
}
|
|
439
|
+
function takeBoolean(value, aliases, state, basePath) {
|
|
440
|
+
const located = locate(value, aliases, basePath);
|
|
441
|
+
if (!located || typeof located.value !== "boolean") return void 0;
|
|
442
|
+
consume(state, located.path);
|
|
443
|
+
return located.value;
|
|
444
|
+
}
|
|
445
|
+
function takeNumber(value, aliases, state, basePath) {
|
|
446
|
+
const located = locate(value, aliases, basePath);
|
|
447
|
+
if (!located || !isNonNegativeNumber(located.value) || !Number.isInteger(located.value))
|
|
448
|
+
return void 0;
|
|
449
|
+
consume(state, located.path);
|
|
450
|
+
return located.value;
|
|
451
|
+
}
|
|
452
|
+
function takeEnum(value, aliases, values, state, basePath) {
|
|
453
|
+
const located = locate(value, aliases, basePath);
|
|
454
|
+
if (!located || typeof located.value !== "string" || !values.includes(located.value))
|
|
455
|
+
return void 0;
|
|
456
|
+
consume(state, located.path);
|
|
457
|
+
return located.value;
|
|
458
|
+
}
|
|
459
|
+
function takeEnumArray(value, aliases, values, state, basePath) {
|
|
460
|
+
const located = locate(value, aliases, basePath);
|
|
461
|
+
if (!located || !Array.isArray(located.value) || located.value.some((item) => typeof item !== "string" || !values.includes(item)))
|
|
462
|
+
return void 0;
|
|
463
|
+
consume(state, located.path);
|
|
464
|
+
return located.value;
|
|
465
|
+
}
|
|
466
|
+
function takeStringArray(value, aliases, state, basePath) {
|
|
467
|
+
const located = locate(value, aliases, basePath);
|
|
468
|
+
const strings = located ? stringArrayValue(located.value) : void 0;
|
|
469
|
+
if (!located || !strings) return void 0;
|
|
470
|
+
consume(state, located.path);
|
|
471
|
+
return strings;
|
|
472
|
+
}
|
|
473
|
+
function takeStringArrayRecord(value, aliases, state, basePath) {
|
|
474
|
+
const located = locate(value, aliases, basePath);
|
|
475
|
+
if (!located || !isObject(located.value)) return void 0;
|
|
476
|
+
const entries = Object.entries(located.value);
|
|
477
|
+
if (entries.some(([, item]) => !stringArrayValue(item))) return void 0;
|
|
478
|
+
consume(state, located.path);
|
|
479
|
+
return Object.fromEntries(entries);
|
|
480
|
+
}
|
|
481
|
+
function collectUnsupported(value, basePath, state) {
|
|
482
|
+
return collectLeafPaths(value, basePath).filter((path) => {
|
|
483
|
+
const key = pathKey(path);
|
|
484
|
+
return ![...state.consumedPaths].some(
|
|
485
|
+
(consumed) => key === consumed || key.startsWith(`${consumed}.`)
|
|
486
|
+
);
|
|
487
|
+
}).map((path) => ({
|
|
488
|
+
code: "FERN_CONFIG_FIELD_UNSUPPORTED",
|
|
489
|
+
severity: "warning",
|
|
490
|
+
path,
|
|
491
|
+
reason: "Fern configuration field is not represented by SDK Config v1",
|
|
492
|
+
suggestedAction: "Review this value and set the closest SDK Config field manually, or preserve the setting outside SDK Config if no equivalent exists."
|
|
493
|
+
}));
|
|
494
|
+
}
|
|
495
|
+
function collectLeafPaths(value, path) {
|
|
496
|
+
if (Array.isArray(value))
|
|
497
|
+
return value.flatMap((item, index) => collectLeafPaths(item, [...path, index]));
|
|
498
|
+
if (isObject(value))
|
|
499
|
+
return Object.entries(value).flatMap(([key, child]) => collectLeafPaths(child, [...path, key]));
|
|
500
|
+
return value === void 0 ? [] : [path];
|
|
501
|
+
}
|
|
502
|
+
function consume(state, path) {
|
|
503
|
+
state.consumedPaths.add(pathKey(path));
|
|
504
|
+
}
|
|
505
|
+
function pathKey(path) {
|
|
506
|
+
return path.join(".");
|
|
507
|
+
}
|
|
508
|
+
function normalizeKey(value) {
|
|
509
|
+
return value.replace(/[-_]/g, "").toLowerCase();
|
|
510
|
+
}
|
|
511
|
+
function compact(value) {
|
|
512
|
+
return Object.fromEntries(Object.entries(value).filter(([, child]) => child !== void 0));
|
|
513
|
+
}
|
|
514
|
+
function optional(key, value) {
|
|
515
|
+
return value === void 0 ? {} : { [key]: value };
|
|
516
|
+
}
|
|
517
|
+
function isObject(value) {
|
|
518
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
519
|
+
}
|
|
520
|
+
function isNonNegativeNumber(value) {
|
|
521
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
522
|
+
}
|
|
523
|
+
function stringValue(value) {
|
|
524
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
525
|
+
}
|
|
526
|
+
function stringArrayValue(value) {
|
|
527
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0) ? value : void 0;
|
|
528
|
+
}
|
|
529
|
+
function stableJson(value) {
|
|
530
|
+
return JSON.stringify(sortKeys(value));
|
|
531
|
+
}
|
|
532
|
+
function sortKeys(value) {
|
|
533
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
534
|
+
if (!isObject(value)) return value;
|
|
535
|
+
return Object.fromEntries(
|
|
536
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => [key, sortKeys(child)])
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// src/sdk-config/v1/fern-config-mapper-output.ts
|
|
541
|
+
function mapOutput(generator, language, index) {
|
|
542
|
+
const raw = isObject(generator.raw) ? generator.raw : void 0;
|
|
543
|
+
const rawOutput = raw && isObject(raw.output) ? raw.output : void 0;
|
|
544
|
+
const outputPath = ["group", "generators", index, "outputMode"];
|
|
545
|
+
const state = { consumedPaths: /* @__PURE__ */ new Set() };
|
|
546
|
+
if (rawOutput?.location === "local-file-system") {
|
|
547
|
+
if (isObject(generator.outputMode)) consume(state, [...outputPath, "type"]);
|
|
548
|
+
return finishOutputMapping(
|
|
549
|
+
{
|
|
550
|
+
output: {
|
|
551
|
+
delivery: "files",
|
|
552
|
+
...typeof rawOutput.path === "string" && rawOutput.path ? { path: rawOutput.path } : {}
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
generator.outputMode,
|
|
556
|
+
outputPath,
|
|
557
|
+
state,
|
|
558
|
+
index
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
if (!isObject(generator.outputMode) || typeof generator.outputMode.type !== "string") {
|
|
562
|
+
fail(
|
|
563
|
+
"FERN_OUTPUT_REQUIRED",
|
|
564
|
+
["group", "generators", index, "outputMode"],
|
|
565
|
+
`Cannot map output for Fern generator ${generator.name}`,
|
|
566
|
+
"Set generator.output to a public SDK Config output, or provide the resolved Fern outputMode.",
|
|
567
|
+
["targets", index, "output"]
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
const output = generator.outputMode;
|
|
571
|
+
consume(state, [...outputPath, "type"]);
|
|
572
|
+
switch (output.type) {
|
|
573
|
+
case "downloadFiles":
|
|
574
|
+
return finishOutputMapping({ output: { delivery: "zip" } }, output, outputPath, state, index);
|
|
575
|
+
case "github":
|
|
576
|
+
return finishOutputMapping(
|
|
577
|
+
githubOutput(output, output.publishInfo, language, outputPath, state, index),
|
|
578
|
+
output,
|
|
579
|
+
outputPath,
|
|
580
|
+
state,
|
|
581
|
+
index
|
|
582
|
+
);
|
|
583
|
+
case "githubV2": {
|
|
584
|
+
if (!isObject(output.githubV2))
|
|
585
|
+
fail(
|
|
586
|
+
"FERN_GITHUB_OUTPUT_INVALID",
|
|
587
|
+
["group", "generators", index, "outputMode", "githubV2"],
|
|
588
|
+
"Fern githubV2 output is missing its configuration",
|
|
589
|
+
'Set target.output manually with delivery "github" and the intended repository.',
|
|
590
|
+
["targets", index, "output"]
|
|
591
|
+
);
|
|
592
|
+
const githubPath = [...outputPath, "githubV2"];
|
|
593
|
+
return finishOutputMapping(
|
|
594
|
+
githubOutput(
|
|
595
|
+
output.githubV2,
|
|
596
|
+
output.githubV2.publishInfo,
|
|
597
|
+
language,
|
|
598
|
+
githubPath,
|
|
599
|
+
state,
|
|
600
|
+
index
|
|
601
|
+
),
|
|
602
|
+
output,
|
|
603
|
+
outputPath,
|
|
604
|
+
state,
|
|
605
|
+
index
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
case "publishV2": {
|
|
609
|
+
const publication = mapPublication(
|
|
610
|
+
output.publishV2,
|
|
611
|
+
language,
|
|
612
|
+
[...outputPath, "publishV2"],
|
|
613
|
+
state,
|
|
614
|
+
index
|
|
615
|
+
);
|
|
616
|
+
return finishOutputMapping(
|
|
617
|
+
{
|
|
618
|
+
output: { delivery: "zip", publish: publication.publish },
|
|
619
|
+
...optional("package", publication.package)
|
|
620
|
+
},
|
|
621
|
+
output,
|
|
622
|
+
outputPath,
|
|
623
|
+
state,
|
|
624
|
+
index
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
case "publish": {
|
|
628
|
+
const publication = mapLegacyPublication(
|
|
629
|
+
output.registryOverrides,
|
|
630
|
+
language,
|
|
631
|
+
[...outputPath, "registryOverrides"],
|
|
632
|
+
state,
|
|
633
|
+
index
|
|
634
|
+
);
|
|
635
|
+
return finishOutputMapping(
|
|
636
|
+
{
|
|
637
|
+
output: { delivery: "zip", publish: publication.publish },
|
|
638
|
+
...optional("package", publication.package)
|
|
639
|
+
},
|
|
640
|
+
output,
|
|
641
|
+
outputPath,
|
|
642
|
+
state,
|
|
643
|
+
index
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
default:
|
|
647
|
+
fail(
|
|
648
|
+
"FERN_OUTPUT_UNSUPPORTED",
|
|
649
|
+
["group", "generators", index, "outputMode", "type"],
|
|
650
|
+
`Unsupported Fern output mode "${output.type}"`,
|
|
651
|
+
"Choose the equivalent files, zip, or github SDK Config output manually.",
|
|
652
|
+
["targets", index, "output"]
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function githubOutput(value, publishInfo, language, sourcePath, state, index) {
|
|
657
|
+
const owner = stringValue(value.owner);
|
|
658
|
+
const repo = stringValue(value.repo);
|
|
659
|
+
if (!owner || !repo)
|
|
660
|
+
fail(
|
|
661
|
+
"FERN_GITHUB_REPOSITORY_REQUIRED",
|
|
662
|
+
sourcePath,
|
|
663
|
+
"Fern GitHub output requires owner and repo",
|
|
664
|
+
'Set target.output.github.repository manually as "owner/repository".',
|
|
665
|
+
["targets", index, "output", "github", "repository"]
|
|
666
|
+
);
|
|
667
|
+
consume(state, [...sourcePath, "owner"]);
|
|
668
|
+
consume(state, [...sourcePath, "repo"]);
|
|
669
|
+
const publication = publishInfo ? mapPublication(publishInfo, language, [...sourcePath, "publishInfo"], state, index) : void 0;
|
|
670
|
+
const type = stringValue(value.type);
|
|
671
|
+
const reviewers = mapReviewers(value.reviewers, [...sourcePath, "reviewers"], state);
|
|
672
|
+
if (type) consume(state, [...sourcePath, "type"]);
|
|
673
|
+
if (typeof value.makePr === "boolean") consume(state, [...sourcePath, "makePr"]);
|
|
674
|
+
if (stringValue(value.host)) consume(state, [...sourcePath, "host"]);
|
|
675
|
+
if (stringValue(value.branch)) consume(state, [...sourcePath, "branch"]);
|
|
676
|
+
return {
|
|
677
|
+
output: {
|
|
678
|
+
delivery: "github",
|
|
679
|
+
github: {
|
|
680
|
+
repository: `${owner}/${repo}`,
|
|
681
|
+
...optional("host", stringValue(value.host)),
|
|
682
|
+
...optional("branch", stringValue(value.branch)),
|
|
683
|
+
mode: value.makePr === true || type === "pullRequest" ? "pull-request" : type === "push" ? "push" : "release",
|
|
684
|
+
...optional("reviewers", reviewers)
|
|
685
|
+
},
|
|
686
|
+
...publication ? { publish: publication.publish } : {}
|
|
687
|
+
},
|
|
688
|
+
...optional("package", publication?.package)
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
function mapReviewers(value, sourcePath, state) {
|
|
692
|
+
if (Array.isArray(value)) {
|
|
693
|
+
const teams2 = reviewerNames(value, "team", sourcePath, state);
|
|
694
|
+
const users2 = reviewerNames(value, "user", sourcePath, state);
|
|
695
|
+
return teams2 || users2 ? { ...optional("teams", teams2), ...optional("users", users2) } : void 0;
|
|
696
|
+
}
|
|
697
|
+
if (!isObject(value)) return void 0;
|
|
698
|
+
const teams = reviewerNames(value.teams, "team", [...sourcePath, "teams"], state);
|
|
699
|
+
const users = reviewerNames(value.users, "user", [...sourcePath, "users"], state);
|
|
700
|
+
return teams || users ? { ...optional("teams", teams), ...optional("users", users) } : void 0;
|
|
701
|
+
}
|
|
702
|
+
function reviewerNames(value, expectedType, sourcePath, state) {
|
|
703
|
+
if (!Array.isArray(value)) return void 0;
|
|
704
|
+
const names = value.flatMap((reviewer, index) => {
|
|
705
|
+
if (typeof reviewer === "string") {
|
|
706
|
+
consume(state, [...sourcePath, index]);
|
|
707
|
+
return [reviewer];
|
|
708
|
+
}
|
|
709
|
+
if (!isObject(reviewer) || reviewer.type !== expectedType || typeof reviewer.name !== "string") {
|
|
710
|
+
return [];
|
|
711
|
+
}
|
|
712
|
+
consume(state, [...sourcePath, index, "type"]);
|
|
713
|
+
consume(state, [...sourcePath, index, "name"]);
|
|
714
|
+
return [reviewer.name];
|
|
715
|
+
});
|
|
716
|
+
return names.length ? names : void 0;
|
|
717
|
+
}
|
|
718
|
+
function mapPublication(value, language, sourcePath, state, index) {
|
|
719
|
+
if (!isObject(value))
|
|
720
|
+
fail(
|
|
721
|
+
"FERN_PUBLICATION_INVALID",
|
|
722
|
+
sourcePath,
|
|
723
|
+
"Fern publication output is invalid",
|
|
724
|
+
"Set target.output.publish and target.package manually.",
|
|
725
|
+
["targets", index, "output", "publish"]
|
|
726
|
+
);
|
|
727
|
+
const type = stringValue(value.type);
|
|
728
|
+
if (type) consume(state, [...sourcePath, "type"]);
|
|
729
|
+
const nested = type && isObject(value[type]) ? value[type] : value;
|
|
730
|
+
const nestedPath = nested === value ? sourcePath : [...sourcePath, type];
|
|
731
|
+
const registry = publicationRegistry(type, language, [...sourcePath, "type"], index);
|
|
732
|
+
const registryUrl = stringValue(nested.registryUrl);
|
|
733
|
+
if (registryUrl) consume(state, [...nestedPath, "registryUrl"]);
|
|
734
|
+
if (registry === "maven") {
|
|
735
|
+
const coordinate = stringValue(nested.coordinate);
|
|
736
|
+
if (coordinate) consume(state, [...nestedPath, "coordinate"]);
|
|
737
|
+
return {
|
|
738
|
+
publish: compact({ registry, url: registryUrl }),
|
|
739
|
+
...coordinate ? { package: mavenPackage(coordinate, [...nestedPath, "coordinate"], index) } : {}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
const packageNameField = stringValue(nested.packageName) ? "packageName" : "coordinate";
|
|
743
|
+
const packageName = stringValue(nested[packageNameField]);
|
|
744
|
+
if (packageName) consume(state, [...nestedPath, packageNameField]);
|
|
745
|
+
const metadata = registry === "pypi" ? mapPypiMetadata(nested.pypiMetadata, nestedPath, state) : {};
|
|
746
|
+
return {
|
|
747
|
+
publish: compact({ registry, url: registryUrl }),
|
|
748
|
+
...packageName || Object.keys(metadata).length ? { package: { ...optional("packageName", packageName), ...metadata } } : {}
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
function mapLegacyPublication(value, language, sourcePath, state, index) {
|
|
752
|
+
const registry = defaultRegistry(language, sourcePath, index);
|
|
753
|
+
const overrides = isObject(value) ? value : {};
|
|
754
|
+
const override = isObject(overrides[registry]) ? overrides[registry] : {};
|
|
755
|
+
return mapPublication(override, language, [...sourcePath, registry], state, index);
|
|
756
|
+
}
|
|
757
|
+
function publicationRegistry(type, language, sourcePath, index) {
|
|
758
|
+
if (type === "postman") {
|
|
759
|
+
fail(
|
|
760
|
+
"FERN_POSTMAN_PUBLICATION_UNSUPPORTED",
|
|
761
|
+
sourcePath,
|
|
762
|
+
"Postman collection publication is not an SDK output",
|
|
763
|
+
"Remove this non-SDK target or convert it separately from the SDK Config document."
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
const normalized = type?.replace(/Override$/, "").toLowerCase();
|
|
767
|
+
if (normalized === "rubygems") return "rubygems";
|
|
768
|
+
if (normalized && ["npm", "pypi", "maven", "nuget", "crates"].includes(normalized)) {
|
|
769
|
+
return normalized;
|
|
770
|
+
}
|
|
771
|
+
if (normalized !== void 0) {
|
|
772
|
+
fail(
|
|
773
|
+
"FERN_PUBLICATION_UNSUPPORTED",
|
|
774
|
+
sourcePath,
|
|
775
|
+
`Unsupported Fern publication type "${type}"`,
|
|
776
|
+
"Set target.output.publish and target.package manually if SDK Config supports the registry.",
|
|
777
|
+
["targets", index, "output", "publish"]
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
return defaultRegistry(language, sourcePath, index);
|
|
781
|
+
}
|
|
782
|
+
function defaultRegistry(language, sourcePath, index) {
|
|
783
|
+
const registries = {
|
|
784
|
+
typescript: "npm",
|
|
785
|
+
mcp: "npm",
|
|
786
|
+
python: "pypi",
|
|
787
|
+
java: "maven",
|
|
788
|
+
kotlin: "maven",
|
|
789
|
+
csharp: "nuget",
|
|
790
|
+
ruby: "rubygems",
|
|
791
|
+
rust: "crates",
|
|
792
|
+
go: "go",
|
|
793
|
+
php: "composer"
|
|
794
|
+
};
|
|
795
|
+
const registry = registries[language];
|
|
796
|
+
if (!registry)
|
|
797
|
+
fail(
|
|
798
|
+
"FERN_PUBLICATION_REGISTRY_REQUIRED",
|
|
799
|
+
sourcePath,
|
|
800
|
+
`No publication registry can be inferred for ${language}`,
|
|
801
|
+
"Set target.output.publish.registry manually.",
|
|
802
|
+
["targets", index, "output", "publish", "registry"]
|
|
803
|
+
);
|
|
804
|
+
return registry;
|
|
805
|
+
}
|
|
806
|
+
function mavenPackage(coordinate, sourcePath, index) {
|
|
807
|
+
const parts = coordinate.split(":");
|
|
808
|
+
const [groupId, artifactId] = parts;
|
|
809
|
+
if (parts.length !== 2 || !groupId || !artifactId)
|
|
810
|
+
fail(
|
|
811
|
+
"FERN_MAVEN_COORDINATE_INVALID",
|
|
812
|
+
sourcePath,
|
|
813
|
+
`Invalid Maven coordinate ${coordinate}`,
|
|
814
|
+
"Set target.package.groupId and target.package.artifactId manually.",
|
|
815
|
+
["targets", index, "package"]
|
|
816
|
+
);
|
|
817
|
+
return { groupId, artifactId };
|
|
818
|
+
}
|
|
819
|
+
function mapPypiMetadata(value, sourcePath, state) {
|
|
820
|
+
if (!isObject(value)) return {};
|
|
821
|
+
const metadataPath = [...sourcePath, "pypiMetadata"];
|
|
822
|
+
const description = stringValue(value.description);
|
|
823
|
+
const keywords = stringArrayValue(value.keywords);
|
|
824
|
+
const documentationUrl = stringValue(value.documentationLink);
|
|
825
|
+
const homepage = stringValue(value.homepageLink);
|
|
826
|
+
const authors = mapAuthors(value.authors, [...metadataPath, "authors"], state);
|
|
827
|
+
if (description) consume(state, [...metadataPath, "description"]);
|
|
828
|
+
if (keywords) consume(state, [...metadataPath, "keywords"]);
|
|
829
|
+
if (documentationUrl) consume(state, [...metadataPath, "documentationLink"]);
|
|
830
|
+
if (homepage) consume(state, [...metadataPath, "homepageLink"]);
|
|
831
|
+
return compact({ description, authors, keywords, documentationUrl, homepage });
|
|
832
|
+
}
|
|
833
|
+
function mapAuthors(value, sourcePath, state) {
|
|
834
|
+
if (!Array.isArray(value)) return void 0;
|
|
835
|
+
const authors = value.flatMap((author) => {
|
|
836
|
+
if (!isObject(author)) return [];
|
|
837
|
+
const name = stringValue(author.name);
|
|
838
|
+
const email = stringValue(author.email);
|
|
839
|
+
return name ? [{ name, ...optional("email", email) }] : [];
|
|
840
|
+
});
|
|
841
|
+
if (authors.length !== value.length) return void 0;
|
|
842
|
+
value.forEach((author, index) => {
|
|
843
|
+
consume(state, [...sourcePath, index, "name"]);
|
|
844
|
+
if (isObject(author) && stringValue(author.email)) {
|
|
845
|
+
consume(state, [...sourcePath, index, "email"]);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
return authors;
|
|
849
|
+
}
|
|
850
|
+
function finishOutputMapping(mapping, outputMode, sourcePath, state, index) {
|
|
851
|
+
for (const path of collectLeafPaths(outputMode, sourcePath)) {
|
|
852
|
+
if (path[path.length - 1] === "_visit") consume(state, path);
|
|
853
|
+
}
|
|
854
|
+
return {
|
|
855
|
+
...mapping,
|
|
856
|
+
unsupportedFields: collectUnsupported(outputMode, sourcePath, state).map(
|
|
857
|
+
(diagnostic) => outputDiagnostic(diagnostic.path, index)
|
|
858
|
+
)
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function outputDiagnostic(path, index) {
|
|
862
|
+
const fields = path.filter((part) => typeof part === "string");
|
|
863
|
+
const field = fields[fields.length - 1];
|
|
864
|
+
const credential = fields.some((part) => part === "credentials" || part === "signature") || ["apiKey", "keyId", "password", "secretKey", "token", "username"].includes(field ?? "");
|
|
865
|
+
if (credential) {
|
|
866
|
+
return {
|
|
867
|
+
code: "FERN_OUTPUT_CREDENTIAL_UNSUPPORTED",
|
|
868
|
+
severity: "warning",
|
|
869
|
+
path,
|
|
870
|
+
reason: "Fern output credentials and signatures are not represented by SDK Config v1",
|
|
871
|
+
suggestedAction: "Configure publication credentials and signing secrets outside SDK Config."
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
const guidance = {
|
|
875
|
+
directory: {
|
|
876
|
+
suggestedAction: "Preserve the GitHub output subdirectory outside SDK Config; public v1 has no repository subdirectory field."
|
|
877
|
+
},
|
|
878
|
+
license: {
|
|
879
|
+
sdkConfigPath: ["targets", index, "package", "license"],
|
|
880
|
+
suggestedAction: "Set target.package.license manually using portable license metadata."
|
|
881
|
+
},
|
|
882
|
+
id: {
|
|
883
|
+
sdkConfigPath: ["targets", index, "package", "license"],
|
|
884
|
+
suggestedAction: "Set target.package.license manually using portable license metadata."
|
|
885
|
+
},
|
|
886
|
+
contents: {
|
|
887
|
+
sdkConfigPath: ["targets", index, "package", "license"],
|
|
888
|
+
suggestedAction: "Set target.package.license manually without embedding license contents."
|
|
889
|
+
},
|
|
890
|
+
downloadSnippets: {
|
|
891
|
+
sdkConfigPath: ["docs", "snippets", "enabled"],
|
|
892
|
+
suggestedAction: "Set docs.snippets.enabled manually and choose a portable output path if needed."
|
|
893
|
+
},
|
|
894
|
+
version: {
|
|
895
|
+
sdkConfigPath: ["targets", index, "sdkVersion"],
|
|
896
|
+
suggestedAction: "Set target.sdkVersion manually if this output version identifies the SDK artifact."
|
|
897
|
+
},
|
|
898
|
+
description: {
|
|
899
|
+
sdkConfigPath: ["targets", index, "package", "description"],
|
|
900
|
+
suggestedAction: "Set target.package.description manually to a valid value."
|
|
901
|
+
},
|
|
902
|
+
authors: {
|
|
903
|
+
sdkConfigPath: ["targets", index, "package", "authors"],
|
|
904
|
+
suggestedAction: "Set target.package.authors manually using valid author metadata."
|
|
905
|
+
},
|
|
906
|
+
keywords: {
|
|
907
|
+
sdkConfigPath: ["targets", index, "package", "keywords"],
|
|
908
|
+
suggestedAction: "Set target.package.keywords manually using non-empty strings."
|
|
909
|
+
},
|
|
910
|
+
documentationLink: {
|
|
911
|
+
sdkConfigPath: ["targets", index, "package", "documentationUrl"],
|
|
912
|
+
suggestedAction: "Set target.package.documentationUrl manually to a valid URL."
|
|
913
|
+
},
|
|
914
|
+
homepageLink: {
|
|
915
|
+
sdkConfigPath: ["targets", index, "package", "homepage"],
|
|
916
|
+
suggestedAction: "Set target.package.homepage manually to a valid URL."
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
const fieldGuidance = field ? guidance[field] : void 0;
|
|
920
|
+
const resolvedGuidance = fields.includes("license") ? guidance.license : fieldGuidance;
|
|
921
|
+
return {
|
|
922
|
+
code: "FERN_OUTPUT_FIELD_UNSUPPORTED",
|
|
923
|
+
severity: "warning",
|
|
924
|
+
path,
|
|
925
|
+
reason: "Fern output field is not represented by SDK Config v1",
|
|
926
|
+
...optional("sdkConfigPath", resolvedGuidance?.sdkConfigPath),
|
|
927
|
+
suggestedAction: resolvedGuidance?.suggestedAction ?? "Review this output setting and preserve it outside SDK Config when no equivalent exists."
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
var customerGenerationAssetSchema = z.discriminatedUnion("type", [
|
|
931
|
+
z.strictObject({ type: z.literal("path"), location: nonEmptyStringSchema }),
|
|
932
|
+
z.strictObject({ type: z.literal("url"), location: nonEmptyStringSchema })
|
|
933
|
+
]);
|
|
934
|
+
var hookDependencySchema = z.strictObject({
|
|
935
|
+
name: nonEmptyStringSchema,
|
|
936
|
+
version: nonEmptyStringSchema,
|
|
937
|
+
groupId: nonEmptyStringSchema.optional()
|
|
938
|
+
});
|
|
939
|
+
var hooksConfigSchema = z.strictObject({
|
|
940
|
+
enabled: z.boolean(),
|
|
941
|
+
source: customerGenerationAssetSchema.optional(),
|
|
942
|
+
dependencies: z.array(hookDependencySchema).optional()
|
|
943
|
+
});
|
|
944
|
+
var customCodeConfigSchema = z.strictObject({
|
|
945
|
+
enabled: z.boolean(),
|
|
946
|
+
source: customerGenerationAssetSchema.optional(),
|
|
947
|
+
conflictStrategy: z.enum(["mark", "ours", "theirs"]).optional(),
|
|
948
|
+
trackChanges: z.boolean().optional(),
|
|
949
|
+
protectedFiles: z.array(nonEmptyStringSchema).optional()
|
|
950
|
+
});
|
|
951
|
+
var workflowConfigSchema = z.strictObject({
|
|
952
|
+
path: nonEmptyStringSchema,
|
|
953
|
+
outputName: nonEmptyStringSchema.optional()
|
|
954
|
+
});
|
|
955
|
+
var analyticsHeaderSchema = z.union([
|
|
956
|
+
z.strictObject({ name: nonEmptyStringSchema, value: z.string() }),
|
|
957
|
+
z.strictObject({
|
|
958
|
+
name: nonEmptyStringSchema,
|
|
959
|
+
valueRef: nonEmptyStringSchema
|
|
960
|
+
})
|
|
961
|
+
]);
|
|
962
|
+
var analyticsConfigSchema = z.strictObject({
|
|
963
|
+
enabled: z.boolean(),
|
|
964
|
+
endpoint: nonEmptyStringSchema.optional(),
|
|
965
|
+
exporter: z.enum(["otlp-http", "console"]).optional(),
|
|
966
|
+
headers: z.array(analyticsHeaderSchema).optional(),
|
|
967
|
+
batchSize: z.number().int().positive().optional(),
|
|
968
|
+
scheduledDelayMs: z.number().nonnegative().optional(),
|
|
969
|
+
exportTimeoutMs: z.number().nonnegative().optional()
|
|
970
|
+
}).superRefine(({ enabled, endpoint }, context) => {
|
|
971
|
+
if (enabled && endpoint === void 0) {
|
|
972
|
+
context.addIssue({
|
|
973
|
+
code: "custom",
|
|
974
|
+
message: "endpoint is required when analytics is enabled",
|
|
975
|
+
path: ["endpoint"]
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
});
|
|
979
|
+
var wireTestsSchema = z.strictObject({
|
|
980
|
+
enabled: z.boolean(),
|
|
981
|
+
exclusions: z.array(nonEmptyStringSchema).optional(),
|
|
982
|
+
fallbackToGeneratedErrorExamples: z.boolean().optional(),
|
|
983
|
+
fixtureSource: z.enum(["synthetic", "recorded", "auto"]).optional()
|
|
984
|
+
});
|
|
985
|
+
var unitTestsSchema = z.strictObject({
|
|
986
|
+
enabled: z.boolean(),
|
|
987
|
+
mode: z.enum(["core-runtime", "schema-driven", "both"]).optional(),
|
|
988
|
+
exclusions: z.array(nonEmptyStringSchema).optional()
|
|
989
|
+
});
|
|
990
|
+
var streamsSchema = z.strictObject({
|
|
991
|
+
enabled: z.boolean(),
|
|
992
|
+
responseType: z.enum(["wrapper", "native", "web"]).optional(),
|
|
993
|
+
fileResponseType: z.enum(["stream", "binary-response"]).optional(),
|
|
994
|
+
defaultChunkSizeBytes: z.number().int().positive().optional()
|
|
995
|
+
});
|
|
996
|
+
var namingConfigSchema = z.strictObject({
|
|
997
|
+
clientName: nonEmptyStringSchema.optional(),
|
|
998
|
+
exportedClientName: nonEmptyStringSchema.optional(),
|
|
999
|
+
environmentTypeName: nonEmptyStringSchema.optional(),
|
|
1000
|
+
apiErrorName: nonEmptyStringSchema.optional(),
|
|
1001
|
+
baseErrorName: nonEmptyStringSchema.optional(),
|
|
1002
|
+
pagerName: nonEmptyStringSchema.optional()
|
|
1003
|
+
});
|
|
1004
|
+
var layoutConfigSchema = z.strictObject({
|
|
1005
|
+
outputDirectory: z.enum(["project-root", "source-root"]).optional(),
|
|
1006
|
+
packagePath: nonEmptyStringSchema.optional()
|
|
1007
|
+
});
|
|
1008
|
+
var serializationConfigSchema = z.strictObject({
|
|
1009
|
+
enumRepresentation: z.enum(["enum", "union", "literal", "forward-compatible-enum", "language-default"]).optional(),
|
|
1010
|
+
additionalProperties: z.enum(["allow", "forbid", "ignore", "language-default"]).optional(),
|
|
1011
|
+
inlineTypes: z.boolean().optional(),
|
|
1012
|
+
omitUndefined: z.boolean().optional()
|
|
1013
|
+
});
|
|
1014
|
+
var sdkConfigV1GenerationConfigSchema = z.strictObject({
|
|
1015
|
+
includeWatermark: z.boolean().default(false),
|
|
1016
|
+
ai: z.boolean().default(false),
|
|
1017
|
+
includeOptionalSnippetParameters: z.boolean().optional(),
|
|
1018
|
+
buildAllModels: z.boolean().default(false),
|
|
1019
|
+
inferServiceNames: z.boolean().default(false),
|
|
1020
|
+
includeDeprecatedOperations: z.boolean().default(true),
|
|
1021
|
+
multipleResponses: z.boolean().default(false),
|
|
1022
|
+
devContainer: z.boolean().default(false),
|
|
1023
|
+
allowMockClient: z.boolean().default(false),
|
|
1024
|
+
ignoreFiles: z.array(nonEmptyStringSchema).optional(),
|
|
1025
|
+
reservedKeywords: z.array(nonEmptyStringSchema).optional(),
|
|
1026
|
+
hooks: hooksConfigSchema.optional(),
|
|
1027
|
+
customCode: customCodeConfigSchema.optional(),
|
|
1028
|
+
workflows: z.array(workflowConfigSchema).optional(),
|
|
1029
|
+
customQueryPaths: z.array(nonEmptyStringSchema).optional(),
|
|
1030
|
+
analytics: analyticsConfigSchema.optional(),
|
|
1031
|
+
wireTests: wireTestsSchema.optional(),
|
|
1032
|
+
unitTests: unitTestsSchema.optional(),
|
|
1033
|
+
webSockets: z.boolean().optional(),
|
|
1034
|
+
streams: streamsSchema.optional(),
|
|
1035
|
+
naming: namingConfigSchema.optional(),
|
|
1036
|
+
layout: layoutConfigSchema.optional(),
|
|
1037
|
+
serialization: serializationConfigSchema.optional()
|
|
1038
|
+
});
|
|
1039
|
+
var sdkConfigV1PublishRegistrySchema = z.enum([
|
|
1040
|
+
"npm",
|
|
1041
|
+
"pypi",
|
|
1042
|
+
"maven",
|
|
1043
|
+
"nuget",
|
|
1044
|
+
"rubygems",
|
|
1045
|
+
"crates",
|
|
1046
|
+
"go",
|
|
1047
|
+
"composer"
|
|
1048
|
+
]);
|
|
1049
|
+
var commonPublishShape = {
|
|
1050
|
+
url: nonEmptyStringSchema.optional(),
|
|
1051
|
+
releaseBranch: nonEmptyStringSchema.optional(),
|
|
1052
|
+
tolerateRepublish: z.boolean().optional()
|
|
1053
|
+
};
|
|
1054
|
+
var sdkConfigV1PublishConfigSchema = z.discriminatedUnion("registry", [
|
|
1055
|
+
z.strictObject({ registry: z.literal("npm"), ...commonPublishShape }),
|
|
1056
|
+
z.strictObject({ registry: z.literal("pypi"), ...commonPublishShape }),
|
|
1057
|
+
z.strictObject({ registry: z.literal("maven"), ...commonPublishShape }),
|
|
1058
|
+
z.strictObject({ registry: z.literal("nuget"), ...commonPublishShape }),
|
|
1059
|
+
z.strictObject({ registry: z.literal("rubygems"), ...commonPublishShape }),
|
|
1060
|
+
z.strictObject({ registry: z.literal("crates"), ...commonPublishShape }),
|
|
1061
|
+
z.strictObject({ registry: z.literal("go"), ...commonPublishShape }),
|
|
1062
|
+
z.strictObject({ registry: z.literal("composer"), ...commonPublishShape })
|
|
1063
|
+
]);
|
|
1064
|
+
var reviewersSchema = z.strictObject({
|
|
1065
|
+
teams: z.array(nonEmptyStringSchema).optional(),
|
|
1066
|
+
users: z.array(nonEmptyStringSchema).optional()
|
|
1067
|
+
});
|
|
1068
|
+
var githubOutputSchema = z.strictObject({
|
|
1069
|
+
repository: nonEmptyStringSchema,
|
|
1070
|
+
host: nonEmptyStringSchema.optional(),
|
|
1071
|
+
branch: nonEmptyStringSchema.optional(),
|
|
1072
|
+
mode: z.enum(["release", "pull-request", "push"]).optional(),
|
|
1073
|
+
reviewers: reviewersSchema.optional(),
|
|
1074
|
+
privateRepository: z.boolean().optional()
|
|
1075
|
+
});
|
|
1076
|
+
var filesOutputSchema = z.strictObject({
|
|
1077
|
+
delivery: z.literal("files"),
|
|
1078
|
+
path: nonEmptyStringSchema.optional(),
|
|
1079
|
+
publish: sdkConfigV1PublishConfigSchema.optional()
|
|
1080
|
+
});
|
|
1081
|
+
var zipOutputSchema = z.strictObject({
|
|
1082
|
+
delivery: z.literal("zip"),
|
|
1083
|
+
fileName: nonEmptyStringSchema.optional(),
|
|
1084
|
+
publish: sdkConfigV1PublishConfigSchema.optional()
|
|
1085
|
+
});
|
|
1086
|
+
var githubDeliverySchema = z.strictObject({
|
|
1087
|
+
delivery: z.literal("github"),
|
|
1088
|
+
github: githubOutputSchema,
|
|
1089
|
+
publish: sdkConfigV1PublishConfigSchema.optional()
|
|
1090
|
+
});
|
|
1091
|
+
var sdkConfigV1OutputConfigSchema = z.discriminatedUnion(
|
|
1092
|
+
"delivery",
|
|
1093
|
+
[filesOutputSchema, zipOutputSchema, githubDeliverySchema],
|
|
1094
|
+
{ error: 'output.delivery must be one of "files", "zip", or "github"' }
|
|
1095
|
+
);
|
|
1096
|
+
|
|
1097
|
+
// src/sdk-config/v1/package.ts
|
|
1098
|
+
var sdkConfigV1DependencySchema = dependencySchema;
|
|
1099
|
+
var sdkConfigV1PackageConfigSchema = packageConfigSchema;
|
|
1100
|
+
var cliGenerationConfigSchema = z.strictObject({
|
|
1101
|
+
paginationParameters: z.array(nonEmptyStringSchema).optional(),
|
|
1102
|
+
skills: z.boolean().optional()
|
|
1103
|
+
});
|
|
1104
|
+
var csharpGenerationConfigSchema = z.strictObject({
|
|
1105
|
+
useOptionalWrapper: z.boolean().optional(),
|
|
1106
|
+
simplifyObjectDictionaries: z.boolean().optional(),
|
|
1107
|
+
explicitNamespaces: z.boolean().optional(),
|
|
1108
|
+
rootNamespaceForCoreClasses: z.boolean().optional(),
|
|
1109
|
+
includeExceptionHandler: z.boolean().optional(),
|
|
1110
|
+
experimentalExplicitNullableOptional: z.boolean().optional()
|
|
1111
|
+
});
|
|
1112
|
+
var goGenerationConfigSchema = z.strictObject({
|
|
1113
|
+
legacyComplexModels: z.boolean().optional(),
|
|
1114
|
+
/** Uppercase common initialisms in generated names (`UserID` rather than `UserId`). */
|
|
1115
|
+
smartCasing: z.boolean().optional(),
|
|
1116
|
+
/** Overrides the fern root-client constructor independently from the client type name. */
|
|
1117
|
+
clientConstructorName: nonEmptyStringSchema.optional(),
|
|
1118
|
+
unionVersion: z.enum(["v0", "v1"]).optional(),
|
|
1119
|
+
includeLegacyClientOptions: z.boolean().optional()
|
|
1120
|
+
});
|
|
1121
|
+
var jvmGenerationConfigSchema = z.strictObject({
|
|
1122
|
+
packageLayout: z.enum(["flat", "nested"]).optional(),
|
|
1123
|
+
useLocalDateForDates: z.boolean().optional(),
|
|
1124
|
+
collapseOptionalNullable: z.boolean().optional(),
|
|
1125
|
+
gradleDistributionUrl: z.string().min(1).optional(),
|
|
1126
|
+
gradlePluginManagement: z.string().optional(),
|
|
1127
|
+
gradleCentralDependencyManagement: z.boolean().optional(),
|
|
1128
|
+
/** Selects co-located async methods or a separate async client surface. */
|
|
1129
|
+
asyncStyle: z.enum(["dedicated-client", "twin-methods"]).optional()
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// src/sdk-config-domain/v1/language/java.ts
|
|
1133
|
+
var javaGenerationConfigSchema = jvmGenerationConfigSchema.extend({
|
|
1134
|
+
includeKotlinSnippets: z.boolean().optional()
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
// src/sdk-config-domain/v1/language/kotlin.ts
|
|
1138
|
+
var kotlinGenerationConfigSchema = jvmGenerationConfigSchema;
|
|
1139
|
+
var compilerOptionsSchema = z.strictObject({
|
|
1140
|
+
target: nonEmptyStringSchema.optional(),
|
|
1141
|
+
module: nonEmptyStringSchema.optional(),
|
|
1142
|
+
lib: z.array(nonEmptyStringSchema).optional()
|
|
1143
|
+
});
|
|
1144
|
+
var packageScriptSchema = z.strictObject({
|
|
1145
|
+
name: nonEmptyStringSchema,
|
|
1146
|
+
command: nonEmptyStringSchema
|
|
1147
|
+
});
|
|
1148
|
+
var httpClientSchema = z.strictObject({
|
|
1149
|
+
name: z.enum(["axios", "fetch"])
|
|
1150
|
+
});
|
|
1151
|
+
var typescriptGenerationConfigSchema = z.strictObject({
|
|
1152
|
+
typescriptVersion: nonEmptyStringSchema.optional(),
|
|
1153
|
+
zodVersion: nonEmptyStringSchema.optional(),
|
|
1154
|
+
compilerOptions: compilerOptionsSchema.optional(),
|
|
1155
|
+
httpClient: httpClientSchema.optional(),
|
|
1156
|
+
packageManager: z.enum(["pnpm", "yarn"]).optional(),
|
|
1157
|
+
testFramework: z.enum(["jest", "vitest"]).optional(),
|
|
1158
|
+
namingStrategy: z.enum(["base", "originalPropertyNames"]).optional(),
|
|
1159
|
+
bundle: z.boolean().optional(),
|
|
1160
|
+
exportClassDefault: z.boolean().optional(),
|
|
1161
|
+
allowCustomFetcher: z.boolean().optional(),
|
|
1162
|
+
useBrandedStringAliases: z.boolean().optional(),
|
|
1163
|
+
useLegacyExports: z.boolean().optional(),
|
|
1164
|
+
useBigInt: z.boolean().optional(),
|
|
1165
|
+
serdeLayer: z.boolean().optional(),
|
|
1166
|
+
scripts: z.array(packageScriptSchema).optional()
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
// src/sdk-config-domain/v1/language/mcp.ts
|
|
1170
|
+
var mcpAvailabilityStatuses = [
|
|
1171
|
+
"IN_DEVELOPMENT",
|
|
1172
|
+
"PRE_RELEASE",
|
|
1173
|
+
"GENERAL_AVAILABILITY",
|
|
1174
|
+
"DEPRECATED",
|
|
1175
|
+
"ALPHA",
|
|
1176
|
+
"BETA",
|
|
1177
|
+
"PREVIEW",
|
|
1178
|
+
"LEGACY"
|
|
1179
|
+
];
|
|
1180
|
+
var mcpToolFilterSchema = z.strictObject({
|
|
1181
|
+
include: z.array(nonEmptyStringSchema).optional(),
|
|
1182
|
+
exclude: z.array(nonEmptyStringSchema).optional()
|
|
1183
|
+
});
|
|
1184
|
+
var mcpToolsetNameSchema = nonEmptyStringSchema.refine(
|
|
1185
|
+
(name) => name !== "default" && /^[a-z0-9-]+$/.test(name),
|
|
1186
|
+
'toolset names must match [a-z0-9-]+ and cannot be "default"'
|
|
1187
|
+
);
|
|
1188
|
+
var mcpGenerationConfigSchema = typescriptGenerationConfigSchema.extend({
|
|
1189
|
+
serverName: nonEmptyStringSchema.optional(),
|
|
1190
|
+
serverDescription: nonEmptyStringSchema.optional(),
|
|
1191
|
+
excludeAvailability: z.array(z.enum(mcpAvailabilityStatuses)).optional(),
|
|
1192
|
+
tools: mcpToolFilterSchema.optional(),
|
|
1193
|
+
toolsets: z.record(mcpToolsetNameSchema, mcpToolFilterSchema).optional()
|
|
1194
|
+
});
|
|
1195
|
+
var phpGenerationConfigSchema = z.strictObject({
|
|
1196
|
+
propertyAccess: z.enum(["public", "private"]).optional(),
|
|
1197
|
+
generateClientInterfaces: z.boolean().optional()
|
|
1198
|
+
});
|
|
1199
|
+
var pythonClientSchema = z.strictObject({
|
|
1200
|
+
fileName: nonEmptyStringSchema.optional(),
|
|
1201
|
+
exportedFileName: nonEmptyStringSchema.optional()
|
|
1202
|
+
});
|
|
1203
|
+
var pydanticConfigSchema = z.strictObject({
|
|
1204
|
+
versionCompatibility: z.enum(["v1", "v2", "both", "v1-on-v2"]).optional(),
|
|
1205
|
+
frozen: z.boolean().optional(),
|
|
1206
|
+
requireOptionalFields: z.boolean().optional(),
|
|
1207
|
+
unionNaming: z.enum(["v0", "v1"]).optional(),
|
|
1208
|
+
useFieldAliases: z.boolean().optional()
|
|
1209
|
+
});
|
|
1210
|
+
var pythonGenerationConfigSchema = z.strictObject({
|
|
1211
|
+
pythonVersion: nonEmptyStringSchema.optional(),
|
|
1212
|
+
pydanticVersion: nonEmptyStringSchema.optional(),
|
|
1213
|
+
pydantic: pydanticConfigSchema.optional(),
|
|
1214
|
+
client: pythonClientSchema.optional(),
|
|
1215
|
+
alwaysInitializeOptionals: z.boolean().optional(),
|
|
1216
|
+
useTypedDictRequests: z.boolean().optional()
|
|
1217
|
+
});
|
|
1218
|
+
var rubyGenerationConfigSchema = z.strictObject({
|
|
1219
|
+
requirePaths: z.array(nonEmptyStringSchema).optional()
|
|
1220
|
+
});
|
|
1221
|
+
var rustGenerationConfigSchema = z.strictObject({
|
|
1222
|
+
/**
|
|
1223
|
+
* Rust type for datetime primitives. `offset` maps to `DateTime<FixedOffset>` and preserves the
|
|
1224
|
+
* timezone the payload carried; `utc` maps to `DateTime<Utc>` and normalizes to UTC.
|
|
1225
|
+
*/
|
|
1226
|
+
dateTimeType: z.enum(["offset", "utc"]).optional(),
|
|
1227
|
+
/** Uppercase common initialisms in generated names (`UserID` rather than `UserId`). */
|
|
1228
|
+
capitalizeInitialisms: z.boolean().optional(),
|
|
1229
|
+
/** Cargo features, mapping a feature name to the dependencies or features it enables. */
|
|
1230
|
+
features: z.record(z.string(), z.array(nonEmptyStringSchema)).optional(),
|
|
1231
|
+
/** Overrides which features make up Cargo's `default` feature set. */
|
|
1232
|
+
defaultFeatures: z.array(nonEmptyStringSchema).optional()
|
|
1233
|
+
});
|
|
1234
|
+
var swiftGenerationConfigSchema = z.strictObject({
|
|
1235
|
+
moduleName: nonEmptyStringSchema.optional(),
|
|
1236
|
+
nullableAsOptional: z.boolean().optional()
|
|
1237
|
+
});
|
|
1238
|
+
var planModifierSourceSchema = z.discriminatedUnion("enabled", [
|
|
1239
|
+
z.strictObject({ enabled: z.literal(true), sourceDir: nonEmptyStringSchema }),
|
|
1240
|
+
z.strictObject({ enabled: z.literal(false) })
|
|
1241
|
+
]);
|
|
1242
|
+
var planModifiersSchema = z.strictObject({
|
|
1243
|
+
resources: planModifierSourceSchema,
|
|
1244
|
+
attributes: planModifierSourceSchema
|
|
1245
|
+
});
|
|
1246
|
+
var providerSchemaSchema = z.strictObject({
|
|
1247
|
+
addressKey: nonEmptyStringSchema,
|
|
1248
|
+
authTokenKey: nonEmptyStringSchema
|
|
1249
|
+
});
|
|
1250
|
+
var terraformGenerationConfigSchema = z.strictObject({
|
|
1251
|
+
providerName: nonEmptyStringSchema.optional(),
|
|
1252
|
+
providerVersion: nonEmptyStringSchema.optional(),
|
|
1253
|
+
providerModulePath: goModulePathSchema.optional(),
|
|
1254
|
+
mockAcceptance: z.boolean().optional(),
|
|
1255
|
+
hideComputedDiff: z.boolean().optional(),
|
|
1256
|
+
providerSchema: providerSchemaSchema.optional(),
|
|
1257
|
+
planModifiers: planModifiersSchema.optional()
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
// src/sdk-config/v1/target.ts
|
|
1261
|
+
var targetOverrideShape = {
|
|
1262
|
+
generatorVersion: exactSemverSchema.optional(),
|
|
1263
|
+
sdkName: nonEmptyStringSchema.optional(),
|
|
1264
|
+
sdkVersion: nonEmptyStringSchema.optional(),
|
|
1265
|
+
package: sdkConfigV1PackageConfigSchema.optional(),
|
|
1266
|
+
output: sdkConfigV1OutputConfigSchema.optional()
|
|
1267
|
+
};
|
|
1268
|
+
var sdkConfigV1TargetSchema = z.discriminatedUnion("language", [
|
|
1269
|
+
z.strictObject({
|
|
1270
|
+
language: z.literal("typescript"),
|
|
1271
|
+
generation: typescriptGenerationConfigSchema.optional(),
|
|
1272
|
+
...targetOverrideShape
|
|
1273
|
+
}),
|
|
1274
|
+
z.strictObject({
|
|
1275
|
+
language: z.literal("python"),
|
|
1276
|
+
generation: pythonGenerationConfigSchema.optional(),
|
|
1277
|
+
...targetOverrideShape
|
|
1278
|
+
}),
|
|
1279
|
+
z.strictObject({
|
|
1280
|
+
language: z.literal("java"),
|
|
1281
|
+
generation: javaGenerationConfigSchema.optional(),
|
|
1282
|
+
...targetOverrideShape
|
|
1283
|
+
}),
|
|
1284
|
+
z.strictObject({
|
|
1285
|
+
language: z.literal("kotlin"),
|
|
1286
|
+
generation: kotlinGenerationConfigSchema.optional(),
|
|
1287
|
+
...targetOverrideShape
|
|
1288
|
+
}),
|
|
1289
|
+
z.strictObject({
|
|
1290
|
+
language: z.literal("go"),
|
|
1291
|
+
generation: goGenerationConfigSchema.optional(),
|
|
1292
|
+
...targetOverrideShape
|
|
1293
|
+
}),
|
|
1294
|
+
z.strictObject({
|
|
1295
|
+
language: z.literal("csharp"),
|
|
1296
|
+
generation: csharpGenerationConfigSchema.optional(),
|
|
1297
|
+
...targetOverrideShape
|
|
1298
|
+
}),
|
|
1299
|
+
z.strictObject({
|
|
1300
|
+
language: z.literal("php"),
|
|
1301
|
+
generation: phpGenerationConfigSchema.optional(),
|
|
1302
|
+
...targetOverrideShape
|
|
1303
|
+
}),
|
|
1304
|
+
z.strictObject({
|
|
1305
|
+
language: z.literal("ruby"),
|
|
1306
|
+
generation: rubyGenerationConfigSchema.optional(),
|
|
1307
|
+
...targetOverrideShape
|
|
1308
|
+
}),
|
|
1309
|
+
z.strictObject({
|
|
1310
|
+
language: z.literal("rust"),
|
|
1311
|
+
generation: rustGenerationConfigSchema.optional(),
|
|
1312
|
+
...targetOverrideShape
|
|
1313
|
+
}),
|
|
1314
|
+
z.strictObject({
|
|
1315
|
+
language: z.literal("swift"),
|
|
1316
|
+
generation: swiftGenerationConfigSchema.optional(),
|
|
1317
|
+
...targetOverrideShape
|
|
1318
|
+
}),
|
|
1319
|
+
z.strictObject({
|
|
1320
|
+
language: z.literal("cli"),
|
|
1321
|
+
generation: cliGenerationConfigSchema.optional(),
|
|
1322
|
+
...targetOverrideShape
|
|
1323
|
+
}),
|
|
1324
|
+
z.strictObject({
|
|
1325
|
+
language: z.literal("mcp"),
|
|
1326
|
+
generation: mcpGenerationConfigSchema.optional(),
|
|
1327
|
+
...targetOverrideShape
|
|
1328
|
+
}),
|
|
1329
|
+
z.strictObject({
|
|
1330
|
+
language: z.literal("terraform"),
|
|
1331
|
+
generation: terraformGenerationConfigSchema.optional(),
|
|
1332
|
+
...targetOverrideShape
|
|
1333
|
+
})
|
|
1334
|
+
]);
|
|
1335
|
+
|
|
1336
|
+
// src/sdk-config/v1/sdk-config-v1.ts
|
|
1337
|
+
var SDK_CONFIG_V1_SCHEMA_VERSION = "sdk-config/v1";
|
|
1338
|
+
var publishRegistryLanguages = {
|
|
1339
|
+
npm: ["typescript", "mcp"],
|
|
1340
|
+
pypi: ["python"],
|
|
1341
|
+
maven: ["java", "kotlin"],
|
|
1342
|
+
nuget: ["csharp"],
|
|
1343
|
+
rubygems: ["ruby"],
|
|
1344
|
+
crates: ["rust"],
|
|
1345
|
+
go: ["go"],
|
|
1346
|
+
composer: ["php"]
|
|
1347
|
+
};
|
|
1348
|
+
var packageNameRegistries = /* @__PURE__ */ new Set([
|
|
1349
|
+
"npm",
|
|
1350
|
+
"pypi",
|
|
1351
|
+
"nuget",
|
|
1352
|
+
"rubygems",
|
|
1353
|
+
"crates",
|
|
1354
|
+
"composer"
|
|
1355
|
+
]);
|
|
1356
|
+
function validatePublishingIdentity(packageConfig, registry, targetIndex, context) {
|
|
1357
|
+
const pathPrefix = ["targets", targetIndex, "package"];
|
|
1358
|
+
if (packageNameRegistries.has(registry) && !packageConfig.packageName) {
|
|
1359
|
+
context.addIssue({
|
|
1360
|
+
code: "custom",
|
|
1361
|
+
message: `packageName is required when publishing to "${registry}"`,
|
|
1362
|
+
path: [...pathPrefix, "packageName"]
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
if (registry === "composer" && packageConfig.packageName) {
|
|
1366
|
+
const result = composerPackageNameSchema.safeParse(packageConfig.packageName);
|
|
1367
|
+
if (!result.success) {
|
|
1368
|
+
context.addIssue({
|
|
1369
|
+
code: "custom",
|
|
1370
|
+
message: result.error.issues[0]?.message ?? "Invalid Composer package name",
|
|
1371
|
+
path: [...pathPrefix, "packageName"]
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
if (registry === "go" && !packageConfig.modulePath) {
|
|
1376
|
+
context.addIssue({
|
|
1377
|
+
code: "custom",
|
|
1378
|
+
message: "modulePath is required when publishing a Go module",
|
|
1379
|
+
path: [...pathPrefix, "modulePath"]
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
if (registry === "maven") {
|
|
1383
|
+
["groupId", "artifactId"].forEach((field) => {
|
|
1384
|
+
if (!packageConfig[field]) {
|
|
1385
|
+
context.addIssue({
|
|
1386
|
+
code: "custom",
|
|
1387
|
+
message: `${field} is required when publishing to Maven`,
|
|
1388
|
+
path: [...pathPrefix, field]
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function validateTargetPublishing(target, targetIndex, globalPackage, globalOutput, context) {
|
|
1395
|
+
const output = target.output ?? globalOutput;
|
|
1396
|
+
if (!output.publish) {
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
const registry = output.publish.registry;
|
|
1400
|
+
if (!publishRegistryLanguages[registry].some((language) => language === target.language)) {
|
|
1401
|
+
context.addIssue({
|
|
1402
|
+
code: "custom",
|
|
1403
|
+
message: `registry "${registry}" is not supported for target language "${target.language}"`,
|
|
1404
|
+
path: ["targets", targetIndex, target.output ? "output" : "language"]
|
|
1405
|
+
});
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
validatePublishingIdentity(
|
|
1409
|
+
{ ...globalPackage, ...target.package },
|
|
1410
|
+
registry,
|
|
1411
|
+
targetIndex,
|
|
1412
|
+
context
|
|
1413
|
+
);
|
|
1414
|
+
}
|
|
1415
|
+
var sdkConfigV1Schema = z.strictObject({
|
|
1416
|
+
schemaVersion: z.literal(SDK_CONFIG_V1_SCHEMA_VERSION),
|
|
1417
|
+
sdkName: nonEmptyStringSchema,
|
|
1418
|
+
sdkVersion: nonEmptyStringSchema.default("1.0.0"),
|
|
1419
|
+
apiVersion: nonEmptyStringSchema.optional(),
|
|
1420
|
+
api: sdkConfigV1ApiConfigSchema,
|
|
1421
|
+
client: sdkConfigV1ClientConfigSchema,
|
|
1422
|
+
package: sdkConfigV1PackageConfigSchema,
|
|
1423
|
+
output: sdkConfigV1OutputConfigSchema,
|
|
1424
|
+
docs: sdkConfigV1DocsConfigSchema,
|
|
1425
|
+
generation: sdkConfigV1GenerationConfigSchema,
|
|
1426
|
+
targets: z.array(sdkConfigV1TargetSchema).min(1)
|
|
1427
|
+
}).superRefine(({ output, package: globalPackage, targets }, context) => {
|
|
1428
|
+
const configuredLanguages = /* @__PURE__ */ new Set();
|
|
1429
|
+
targets.forEach((target, targetIndex) => {
|
|
1430
|
+
if (configuredLanguages.has(target.language)) {
|
|
1431
|
+
context.addIssue({
|
|
1432
|
+
code: "custom",
|
|
1433
|
+
message: `target language "${target.language}" must be unique`,
|
|
1434
|
+
path: ["targets", targetIndex, "language"]
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
configuredLanguages.add(target.language);
|
|
1438
|
+
validateTargetPublishing(target, targetIndex, globalPackage, output, context);
|
|
1439
|
+
});
|
|
1440
|
+
});
|
|
1441
|
+
function parseSdkConfigV1(value) {
|
|
1442
|
+
return sdkConfigV1Schema.parse(value);
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
// src/sdk-config/v1/fern-config-mapper.ts
|
|
1446
|
+
var generatorLanguages = {
|
|
1447
|
+
"fernapi/fern-typescript": "typescript",
|
|
1448
|
+
"fernapi/fern-typescript-sdk": "typescript",
|
|
1449
|
+
"fernapi/fern-typescript-node-sdk": "typescript",
|
|
1450
|
+
"fernapi/fern-typescript-browser-sdk": "typescript",
|
|
1451
|
+
"fernapi/fern-python-sdk": "python",
|
|
1452
|
+
"fernapi/fern-java-sdk": "java",
|
|
1453
|
+
"fernapi/fern-kotlin-sdk": "kotlin",
|
|
1454
|
+
"fernapi/fern-go-sdk": "go",
|
|
1455
|
+
"fernapi/fern-csharp-sdk": "csharp",
|
|
1456
|
+
"fernapi/fern-php-sdk": "php",
|
|
1457
|
+
"fernapi/fern-ruby-sdk": "ruby",
|
|
1458
|
+
"fernapi/fern-ruby-sdk-v2": "ruby",
|
|
1459
|
+
"fernapi/fern-rust-sdk": "rust",
|
|
1460
|
+
"fernapi/fern-swift-sdk": "swift",
|
|
1461
|
+
"fernapi/fern-cli": "cli",
|
|
1462
|
+
"fernapi/fern-cli-generator": "cli",
|
|
1463
|
+
"fernapi/fern-mcp-server": "mcp"
|
|
1464
|
+
};
|
|
1465
|
+
function mapFernConfigToSdkConfigV1(input) {
|
|
1466
|
+
if (input.group.generators.length === 0) {
|
|
1467
|
+
fail(
|
|
1468
|
+
"FERN_GENERATORS_REQUIRED",
|
|
1469
|
+
["group", "generators"],
|
|
1470
|
+
"Fern generator group must contain at least one generator",
|
|
1471
|
+
"Select a Fern generator group containing at least one SDK generator."
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
const mapped = input.group.generators.map((generator, index) => {
|
|
1475
|
+
const language = resolveLanguage(generator, index);
|
|
1476
|
+
const invocation = mapInvocation(generator, language, index);
|
|
1477
|
+
const outputMapping = generator.output ? { output: generator.output, unsupportedFields: [] } : mapOutput(generator, language, index);
|
|
1478
|
+
return {
|
|
1479
|
+
generator,
|
|
1480
|
+
language,
|
|
1481
|
+
invocation,
|
|
1482
|
+
...outputMapping
|
|
1483
|
+
};
|
|
1484
|
+
});
|
|
1485
|
+
requireUniqueLanguages(mapped.map(({ language }) => language));
|
|
1486
|
+
const client = requireSharedBlock(
|
|
1487
|
+
mapped.map(({ invocation }) => invocation.client),
|
|
1488
|
+
"client",
|
|
1489
|
+
(value) => sdkConfigV1ClientConfigSchema.parse(value)
|
|
1490
|
+
);
|
|
1491
|
+
const docs = requireSharedBlock(
|
|
1492
|
+
mapped.map(({ invocation }) => invocation.docs),
|
|
1493
|
+
"docs",
|
|
1494
|
+
(value) => sdkConfigV1DocsConfigSchema.parse(value)
|
|
1495
|
+
);
|
|
1496
|
+
const generation = requireSharedBlock(
|
|
1497
|
+
mapped.map(({ invocation }) => invocation.generation),
|
|
1498
|
+
"generation",
|
|
1499
|
+
(value) => sdkConfigV1GenerationConfigSchema.parse(value)
|
|
1500
|
+
);
|
|
1501
|
+
const api = { ...input.api ?? {} };
|
|
1502
|
+
delete api.audiences;
|
|
1503
|
+
if (input.group.audiences.type === "select") {
|
|
1504
|
+
api.audiences = [...input.group.audiences.audiences];
|
|
1505
|
+
}
|
|
1506
|
+
const targets = mapped.map(
|
|
1507
|
+
({ generator, invocation, language, output, package: outputPackage }, index) => {
|
|
1508
|
+
const target = {
|
|
1509
|
+
language,
|
|
1510
|
+
output,
|
|
1511
|
+
...optional("sdkName", generator.sdkName),
|
|
1512
|
+
...optional("sdkVersion", generator.sdkVersion)
|
|
1513
|
+
};
|
|
1514
|
+
if (Object.keys(invocation.package).length > 0 || outputPackage || generator.package) {
|
|
1515
|
+
target.package = { ...invocation.package, ...outputPackage, ...generator.package };
|
|
1516
|
+
}
|
|
1517
|
+
if (Object.keys(invocation.targetGeneration).length > 0) {
|
|
1518
|
+
target.generation = invocation.targetGeneration;
|
|
1519
|
+
}
|
|
1520
|
+
if (generator.version) {
|
|
1521
|
+
if (exactSemverSchema.safeParse(generator.version).success) {
|
|
1522
|
+
target.generatorVersion = generator.version;
|
|
1523
|
+
} else {
|
|
1524
|
+
invocation.unsupportedFields.push({
|
|
1525
|
+
code: "FERN_GENERATOR_VERSION_NOT_EXACT",
|
|
1526
|
+
severity: "warning",
|
|
1527
|
+
path: ["group", "generators", index, "version"],
|
|
1528
|
+
reason: "SDK Config requires an exact generator semantic version",
|
|
1529
|
+
sdkConfigPath: ["targets", index, "generatorVersion"],
|
|
1530
|
+
suggestedAction: "Resolve the Fern generator tag to an exact semantic version and set target.generatorVersion manually, or leave it omitted."
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
return target;
|
|
1535
|
+
}
|
|
1536
|
+
);
|
|
1537
|
+
const parsed = sdkConfigV1Schema.safeParse({
|
|
1538
|
+
schemaVersion: "sdk-config/v1",
|
|
1539
|
+
sdkName: input.apiName,
|
|
1540
|
+
...optional("sdkVersion", input.sdkVersion),
|
|
1541
|
+
...optional("apiVersion", input.apiVersion),
|
|
1542
|
+
api,
|
|
1543
|
+
client,
|
|
1544
|
+
package: {},
|
|
1545
|
+
output: mapped[0].output,
|
|
1546
|
+
docs,
|
|
1547
|
+
generation,
|
|
1548
|
+
targets
|
|
1549
|
+
});
|
|
1550
|
+
if (!parsed.success) {
|
|
1551
|
+
throw new FernConfigMappingError(
|
|
1552
|
+
parsed.error.issues.map((issue) => {
|
|
1553
|
+
const path = issue.path.map(
|
|
1554
|
+
(part) => typeof part === "symbol" ? part.description ?? part.toString() : part
|
|
1555
|
+
);
|
|
1556
|
+
return {
|
|
1557
|
+
code: "SDK_CONFIG_VALIDATION_FAILED",
|
|
1558
|
+
severity: "error",
|
|
1559
|
+
path: ["mappedSdkConfig", ...path],
|
|
1560
|
+
reason: issue.message,
|
|
1561
|
+
sdkConfigPath: path,
|
|
1562
|
+
suggestedAction: `Set ${path.join(".")} manually to a valid SDK Config v1 value.`
|
|
1563
|
+
};
|
|
1564
|
+
})
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
return {
|
|
1568
|
+
sdkConfig: parsed.data,
|
|
1569
|
+
unsupportedFields: mapped.flatMap(({ invocation, unsupportedFields }) => [
|
|
1570
|
+
...invocation.unsupportedFields,
|
|
1571
|
+
...unsupportedFields
|
|
1572
|
+
])
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
function resolveLanguage(generator, index) {
|
|
1576
|
+
const language = generator.sdkLanguage ?? generatorLanguages[generator.name];
|
|
1577
|
+
if (!language || !isFernLanguage(language)) {
|
|
1578
|
+
fail(
|
|
1579
|
+
"FERN_SDK_LANGUAGE_REQUIRED",
|
|
1580
|
+
["group", "generators", index, "name"],
|
|
1581
|
+
`Cannot determine an SDK language for Fern generator ${generator.name}`,
|
|
1582
|
+
"Set sdkLanguage explicitly if this custom generator produces one of the SDK Config v1 target languages.",
|
|
1583
|
+
["targets", index, "language"]
|
|
1584
|
+
);
|
|
1585
|
+
}
|
|
1586
|
+
return language;
|
|
1587
|
+
}
|
|
1588
|
+
function isFernLanguage(value) {
|
|
1589
|
+
return [
|
|
1590
|
+
"typescript",
|
|
1591
|
+
"python",
|
|
1592
|
+
"java",
|
|
1593
|
+
"kotlin",
|
|
1594
|
+
"go",
|
|
1595
|
+
"csharp",
|
|
1596
|
+
"php",
|
|
1597
|
+
"ruby",
|
|
1598
|
+
"rust",
|
|
1599
|
+
"swift",
|
|
1600
|
+
"cli",
|
|
1601
|
+
"mcp",
|
|
1602
|
+
"terraform"
|
|
1603
|
+
].includes(value);
|
|
1604
|
+
}
|
|
1605
|
+
function requireUniqueLanguages(languages) {
|
|
1606
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1607
|
+
for (const language of languages) {
|
|
1608
|
+
if (seen.has(language)) {
|
|
1609
|
+
fail(
|
|
1610
|
+
"FERN_DUPLICATE_TARGET_LANGUAGE",
|
|
1611
|
+
["group", "generators"],
|
|
1612
|
+
`SDK Config v1 cannot represent multiple Fern generators for language "${language}"`,
|
|
1613
|
+
"Create a separate SDK Config document for each generator that targets the same language.",
|
|
1614
|
+
["targets"]
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1617
|
+
seen.add(language);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
function requireSharedBlock(values, name, normalize) {
|
|
1621
|
+
const first = normalize(values[0]);
|
|
1622
|
+
const serialized = stableJson(first);
|
|
1623
|
+
if (values.some((value) => stableJson(normalize(value)) !== serialized)) {
|
|
1624
|
+
fail(
|
|
1625
|
+
"FERN_TARGET_SPECIFIC_SHARED_CONFIG",
|
|
1626
|
+
["group", "generators"],
|
|
1627
|
+
`SDK Config v1 cannot represent target-specific Fern ${name} configuration`,
|
|
1628
|
+
`Choose one shared ${name} configuration manually or create separate SDK Config documents for the differing targets.`,
|
|
1629
|
+
[name]
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
return first;
|
|
1633
|
+
}
|
|
1634
|
+
function mapInvocation(generator, language, index) {
|
|
1635
|
+
const prefix = ["group", "generators", index];
|
|
1636
|
+
const state = { consumedPaths: /* @__PURE__ */ new Set() };
|
|
1637
|
+
const config = isObject(generator.config) ? generator.config : {};
|
|
1638
|
+
const client = {};
|
|
1639
|
+
const generation = {};
|
|
1640
|
+
const packageConfig = {};
|
|
1641
|
+
mapCommonConfig(config, state, client, generation, packageConfig, [...prefix, "config"]);
|
|
1642
|
+
const targetGeneration = mapLanguageConfig(language, config, state, packageConfig, [
|
|
1643
|
+
...prefix,
|
|
1644
|
+
"config"
|
|
1645
|
+
]);
|
|
1646
|
+
mapPublishMetadata(generator.publishMetadata, packageConfig);
|
|
1647
|
+
if (language === "go" && generator.smartCasing !== void 0) {
|
|
1648
|
+
targetGeneration.smartCasing = generator.smartCasing;
|
|
1649
|
+
}
|
|
1650
|
+
if (generator.keywords?.length) {
|
|
1651
|
+
generation.reservedKeywords = [...generator.keywords];
|
|
1652
|
+
}
|
|
1653
|
+
const settings = isObject(generator.settings) ? generator.settings : void 0;
|
|
1654
|
+
if (settings) {
|
|
1655
|
+
const inlinePathParameters = takeBoolean(settings, ["inlinePathParameters"], state, [
|
|
1656
|
+
...prefix,
|
|
1657
|
+
"settings"
|
|
1658
|
+
]);
|
|
1659
|
+
if (inlinePathParameters !== void 0 && client.pathParameterStyle === void 0) {
|
|
1660
|
+
client.pathParameterStyle = inlinePathParameters ? "inline" : "wrapped";
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
const docs = mapReadme(generator.readme, state, [...prefix, "readme"]);
|
|
1664
|
+
const unsupportedFields = [
|
|
1665
|
+
...collectUnsupported(config, [...prefix, "config"], state),
|
|
1666
|
+
...settings ? collectUnsupported(settings, [...prefix, "settings"], state) : [],
|
|
1667
|
+
...isObject(generator.readme) ? collectUnsupported(generator.readme, [...prefix, "readme"], state) : [],
|
|
1668
|
+
...unsupportedResolvedFields(generator, index, language)
|
|
1669
|
+
];
|
|
1670
|
+
return { client, docs, generation, package: packageConfig, targetGeneration, unsupportedFields };
|
|
1671
|
+
}
|
|
1672
|
+
function unsupportedResolvedFields(generator, index, language) {
|
|
1673
|
+
const values = [
|
|
1674
|
+
["automation", isDefaultAutomation(generator.automation) ? void 0 : generator.automation],
|
|
1675
|
+
["containerImage", generator.containerImage],
|
|
1676
|
+
["irVersionOverride", generator.irVersionOverride],
|
|
1677
|
+
["idempotencyKeyGenerationConfig", generator.idempotencyKeyGenerationConfig],
|
|
1678
|
+
["absolutePathToLocalSnippets", generator.absolutePathToLocalSnippets],
|
|
1679
|
+
[
|
|
1680
|
+
"smartCasingDigitWordBoundary",
|
|
1681
|
+
generator.smartCasingDigitWordBoundary === false ? void 0 : generator.smartCasingDigitWordBoundary
|
|
1682
|
+
],
|
|
1683
|
+
[
|
|
1684
|
+
"disableExamples",
|
|
1685
|
+
generator.disableExamples === false ? void 0 : generator.disableExamples
|
|
1686
|
+
],
|
|
1687
|
+
["apiOverride", generator.apiOverride],
|
|
1688
|
+
...language === "go" || generator.smartCasing === true ? [] : [["smartCasing", generator.smartCasing]]
|
|
1689
|
+
];
|
|
1690
|
+
return values.flatMap(([field, value]) => {
|
|
1691
|
+
if (value === void 0) return [];
|
|
1692
|
+
const guidance = resolvedFieldGuidance(field);
|
|
1693
|
+
return [
|
|
1694
|
+
{
|
|
1695
|
+
code: "FERN_RESOLVED_FIELD_UNSUPPORTED",
|
|
1696
|
+
severity: "warning",
|
|
1697
|
+
path: ["group", "generators", index, field],
|
|
1698
|
+
reason: "Resolved Fern field is not represented by SDK Config v1",
|
|
1699
|
+
...optional("sdkConfigPath", guidance.sdkConfigPath),
|
|
1700
|
+
suggestedAction: guidance.suggestedAction
|
|
1701
|
+
}
|
|
1702
|
+
];
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
function resolvedFieldGuidance(field) {
|
|
1706
|
+
if (field === "absolutePathToLocalSnippets") {
|
|
1707
|
+
return {
|
|
1708
|
+
sdkConfigPath: ["docs", "snippets", "outputPath"],
|
|
1709
|
+
suggestedAction: "Choose a portable relative snippet path and set docs.snippets.outputPath manually."
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
if (field === "idempotencyKeyGenerationConfig") {
|
|
1713
|
+
return {
|
|
1714
|
+
suggestedAction: "Preserve this orchestration setting outside SDK Config; public v1 has no idempotency-generation field."
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
return {
|
|
1718
|
+
suggestedAction: "Review this Fern setting and preserve it outside SDK Config, or set an equivalent SDK Config field manually if one is introduced."
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
function isDefaultAutomation(value) {
|
|
1722
|
+
return isObject(value) && value.generate === true && value.upgrade === true && value.preview === true && value.verify === true;
|
|
1723
|
+
}
|
|
1724
|
+
function mapCommonConfig(config, state, client, generation, packageConfig, basePath) {
|
|
1725
|
+
const inlinePath = takeBoolean(config, ["inlinePathParameters"], state, basePath);
|
|
1726
|
+
const inlineFile = takeBoolean(config, ["inlineFileProperties"], state, basePath);
|
|
1727
|
+
const inlineRequest = takeBoolean(config, ["inlineRequestParams"], state, basePath);
|
|
1728
|
+
if (inlinePath !== void 0) client.pathParameterStyle = inlinePath ? "inline" : "wrapped";
|
|
1729
|
+
if (inlineFile !== void 0) client.filePropertyStyle = inlineFile ? "inline" : "wrapped";
|
|
1730
|
+
if (inlineRequest !== void 0)
|
|
1731
|
+
client.requestParameterStyle = inlineRequest ? "inline" : "wrapped";
|
|
1732
|
+
const timeoutMs = takeTimeoutMs(config, state, basePath);
|
|
1733
|
+
if (timeoutMs !== void 0) client.timeoutMs = timeoutMs;
|
|
1734
|
+
const skipValidation = takeBoolean(
|
|
1735
|
+
config,
|
|
1736
|
+
["skipResponseValidation", "skipValidation"],
|
|
1737
|
+
state,
|
|
1738
|
+
basePath
|
|
1739
|
+
);
|
|
1740
|
+
if (skipValidation !== void 0) client.responseValidation = !skipValidation;
|
|
1741
|
+
const useDefaults = takeBoolean(config, ["useDefaultRequestParameterValues"], state, basePath);
|
|
1742
|
+
if (useDefaults !== void 0) client.useDefaultRequestParameterValues = useDefaults;
|
|
1743
|
+
const respectOptionalBody = takeBoolean(config, ["respectOptionalRequestBody"], state, basePath);
|
|
1744
|
+
if (respectOptionalBody !== void 0) client.respectOptionalRequestBody = respectOptionalBody;
|
|
1745
|
+
const maxRetries = takeNumber(config, ["maxRetries"], state, basePath);
|
|
1746
|
+
const statusCodeProfile = takeEnum(
|
|
1747
|
+
config,
|
|
1748
|
+
["retryStatusCodes"],
|
|
1749
|
+
["legacy", "recommended"],
|
|
1750
|
+
state,
|
|
1751
|
+
basePath
|
|
1752
|
+
);
|
|
1753
|
+
if (maxRetries !== void 0 || statusCodeProfile !== void 0) {
|
|
1754
|
+
client.retry = {
|
|
1755
|
+
...maxRetries === void 0 ? {} : { maxAttempts: maxRetries + 1 },
|
|
1756
|
+
...optional("statusCodeProfile", statusCodeProfile)
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
const naming = compact({
|
|
1760
|
+
pagerName: takeString(
|
|
1761
|
+
config,
|
|
1762
|
+
["customPagerName", "customPagerClassname", "customPagerClassName"],
|
|
1763
|
+
state,
|
|
1764
|
+
basePath
|
|
1765
|
+
),
|
|
1766
|
+
clientName: takeString(config, ["clientName", "clientClassName"], state, basePath),
|
|
1767
|
+
exportedClientName: takeString(
|
|
1768
|
+
config,
|
|
1769
|
+
["exportedClientName", "exportedClientClassName"],
|
|
1770
|
+
state,
|
|
1771
|
+
basePath
|
|
1772
|
+
),
|
|
1773
|
+
environmentTypeName: takeString(
|
|
1774
|
+
config,
|
|
1775
|
+
["environmentClassName", "environmentEnumName"],
|
|
1776
|
+
state,
|
|
1777
|
+
basePath
|
|
1778
|
+
),
|
|
1779
|
+
apiErrorName: takeString(config, ["baseApiExceptionClassName"], state, basePath),
|
|
1780
|
+
baseErrorName: takeString(config, ["baseExceptionClassName"], state, basePath)
|
|
1781
|
+
});
|
|
1782
|
+
if (Object.keys(naming).length) generation.naming = naming;
|
|
1783
|
+
const wireTests = takeBoolean(config, ["enableWireTests", "generateWireTests"], state, basePath);
|
|
1784
|
+
if (wireTests !== void 0) generation.wireTests = { enabled: wireTests };
|
|
1785
|
+
const webSockets = takeBoolean(
|
|
1786
|
+
config,
|
|
1787
|
+
["generateWebSocketClients", "shouldGenerateWebsocketClients", "enableWebsockets"],
|
|
1788
|
+
state,
|
|
1789
|
+
basePath
|
|
1790
|
+
);
|
|
1791
|
+
if (webSockets !== void 0) generation.webSockets = webSockets;
|
|
1792
|
+
const inlineTypes = takeBoolean(config, ["enableInlineTypes"], state, basePath);
|
|
1793
|
+
const omitUndefined = takeBoolean(config, ["omitUndefined"], state, basePath);
|
|
1794
|
+
const forwardEnums = takeBoolean(config, ["enableForwardCompatibleEnums"], state, basePath);
|
|
1795
|
+
const serialization = compact({
|
|
1796
|
+
inlineTypes,
|
|
1797
|
+
omitUndefined,
|
|
1798
|
+
enumRepresentation: forwardEnums === void 0 ? void 0 : forwardEnums ? "forward-compatible-enum" : "language-default"
|
|
1799
|
+
});
|
|
1800
|
+
if (Object.keys(serialization).length) generation.serialization = serialization;
|
|
1801
|
+
const namespace = takeString(config, ["namespace", "packagePrefix"], state, basePath);
|
|
1802
|
+
if (namespace !== void 0) packageConfig.namespace = namespace;
|
|
1803
|
+
const packagePath = takeString(config, ["packagePath"], state, basePath);
|
|
1804
|
+
if (packagePath !== void 0) generation.layout = { packagePath };
|
|
1805
|
+
mapDependencies(config, state, packageConfig, basePath);
|
|
1806
|
+
}
|
|
1807
|
+
function mapLanguageConfig(language, config, state, packageConfig, basePath) {
|
|
1808
|
+
switch (language) {
|
|
1809
|
+
case "typescript":
|
|
1810
|
+
return mapTypescript(config, state, packageConfig, basePath);
|
|
1811
|
+
case "mcp":
|
|
1812
|
+
return {
|
|
1813
|
+
...mapTypescript(config, state, packageConfig, basePath),
|
|
1814
|
+
...mapMcp(config, state, basePath)
|
|
1815
|
+
};
|
|
1816
|
+
case "python":
|
|
1817
|
+
return mapPython(config, state, packageConfig, basePath);
|
|
1818
|
+
case "java":
|
|
1819
|
+
case "kotlin":
|
|
1820
|
+
return mapJvm(language, config, state, packageConfig, basePath);
|
|
1821
|
+
case "go":
|
|
1822
|
+
return mapGo(config, state, packageConfig, basePath);
|
|
1823
|
+
case "csharp":
|
|
1824
|
+
return mapCsharp(config, state, packageConfig, basePath);
|
|
1825
|
+
case "php":
|
|
1826
|
+
return mapPhp(config, state, packageConfig, basePath);
|
|
1827
|
+
case "ruby":
|
|
1828
|
+
return mapRuby(config, state, packageConfig, basePath);
|
|
1829
|
+
case "rust":
|
|
1830
|
+
return mapRust(config, state, packageConfig, basePath);
|
|
1831
|
+
case "swift":
|
|
1832
|
+
return compact({ moduleName: takeString(config, ["moduleName"], state, basePath) });
|
|
1833
|
+
case "cli":
|
|
1834
|
+
return mapCli(config, state, packageConfig, basePath);
|
|
1835
|
+
case "terraform":
|
|
1836
|
+
return mapTerraform(config, state, packageConfig, basePath);
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
function mapTypescript(config, state, packageConfig, basePath) {
|
|
1840
|
+
const packageJson = takeObject(config, ["packageJson"], state, basePath);
|
|
1841
|
+
const packageName = packageJson ? takeString(packageJson.value, ["name"], state, packageJson.path) : void 0;
|
|
1842
|
+
if (packageName !== void 0) packageConfig.packageName = packageName;
|
|
1843
|
+
const serdeLayer = takeBoolean(config, ["serdeLayer"], state, basePath);
|
|
1844
|
+
const noSerdeLayer = takeBoolean(config, ["noSerdeLayer"], state, basePath);
|
|
1845
|
+
return compact({
|
|
1846
|
+
typescriptVersion: takeString(config, ["typescriptVersion"], state, basePath),
|
|
1847
|
+
zodVersion: takeString(config, ["zodVersion"], state, basePath),
|
|
1848
|
+
packageManager: takeEnum(config, ["packageManager"], ["pnpm", "yarn"], state, basePath),
|
|
1849
|
+
testFramework: takeEnum(config, ["testFramework"], ["jest", "vitest"], state, basePath),
|
|
1850
|
+
bundle: takeBoolean(config, ["bundle"], state, basePath),
|
|
1851
|
+
exportClassDefault: takeBoolean(config, ["exportClassDefault"], state, basePath),
|
|
1852
|
+
allowCustomFetcher: takeBoolean(config, ["allowCustomFetcher"], state, basePath),
|
|
1853
|
+
useBrandedStringAliases: takeBoolean(config, ["useBrandedStringAliases"], state, basePath),
|
|
1854
|
+
useLegacyExports: takeBoolean(config, ["useLegacyExports"], state, basePath),
|
|
1855
|
+
useBigInt: takeBoolean(config, ["useBigInt"], state, basePath),
|
|
1856
|
+
serdeLayer: serdeLayer ?? (noSerdeLayer === void 0 ? void 0 : !noSerdeLayer)
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
function mapPython(config, state, packageConfig, basePath) {
|
|
1860
|
+
const moduleName = takeString(config, ["packageName"], state, basePath);
|
|
1861
|
+
const packageName = takeString(config, ["pypiPackageName"], state, basePath);
|
|
1862
|
+
if (moduleName !== void 0) packageConfig.moduleName = moduleName;
|
|
1863
|
+
if (packageName !== void 0) packageConfig.packageName = packageName;
|
|
1864
|
+
return compact({
|
|
1865
|
+
pythonVersion: takeString(config, ["pythonVersion", "pyprojectPythonVersion"], state, basePath),
|
|
1866
|
+
pydanticVersion: takeString(config, ["pydanticVersion"], state, basePath),
|
|
1867
|
+
alwaysInitializeOptionals: takeBoolean(config, ["alwaysInitializeOptionals"], state, basePath),
|
|
1868
|
+
useTypedDictRequests: takeBoolean(config, ["useTypedDictRequests"], state, basePath)
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
function mapJvm(language, config, state, packageConfig, basePath) {
|
|
1872
|
+
const namespace = takeString(config, ["packageName", "packagePrefix"], state, basePath);
|
|
1873
|
+
const groupId = takeString(config, ["group", "groupId"], state, basePath);
|
|
1874
|
+
const artifactId = takeString(config, ["artifact", "artifactId"], state, basePath);
|
|
1875
|
+
if (namespace !== void 0) packageConfig.namespace = namespace;
|
|
1876
|
+
if (groupId !== void 0) packageConfig.groupId = groupId;
|
|
1877
|
+
if (artifactId !== void 0) packageConfig.artifactId = artifactId;
|
|
1878
|
+
return compact({
|
|
1879
|
+
packageLayout: takeEnum(config, ["packageLayout"], ["flat", "nested"], state, basePath),
|
|
1880
|
+
useLocalDateForDates: takeBoolean(config, ["useLocalDateForDates"], state, basePath),
|
|
1881
|
+
collapseOptionalNullable: takeBoolean(config, ["collapseOptionalNullable"], state, basePath),
|
|
1882
|
+
gradleDistributionUrl: takeString(config, ["gradleDistributionUrl"], state, basePath),
|
|
1883
|
+
gradlePluginManagement: takeString(config, ["gradlePluginManagement"], state, basePath),
|
|
1884
|
+
gradleCentralDependencyManagement: takeBoolean(
|
|
1885
|
+
config,
|
|
1886
|
+
["gradleCentralDependencyManagement"],
|
|
1887
|
+
state,
|
|
1888
|
+
basePath
|
|
1889
|
+
),
|
|
1890
|
+
asyncStyle: takeEnum(
|
|
1891
|
+
config,
|
|
1892
|
+
["asyncStyle"],
|
|
1893
|
+
["dedicated-client", "twin-methods"],
|
|
1894
|
+
state,
|
|
1895
|
+
basePath
|
|
1896
|
+
),
|
|
1897
|
+
...language === "java" ? {
|
|
1898
|
+
includeKotlinSnippets: takeBoolean(config, ["includeKotlinSnippets"], state, basePath)
|
|
1899
|
+
} : {}
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
function mapGo(config, state, packageConfig, basePath) {
|
|
1903
|
+
const module = takeObject(config, ["module"], state, basePath);
|
|
1904
|
+
const modulePath = module ? takeGoModulePath(module.value, ["path"], state, module.path) : void 0;
|
|
1905
|
+
const packageName = takeString(config, ["packageName"], state, basePath);
|
|
1906
|
+
if (modulePath !== void 0) packageConfig.modulePath = modulePath;
|
|
1907
|
+
if (packageName !== void 0) packageConfig.packageName = packageName;
|
|
1908
|
+
return compact({
|
|
1909
|
+
legacyComplexModels: takeBoolean(config, ["legacyComplexModels"], state, basePath),
|
|
1910
|
+
unionVersion: takeEnum(config, ["union"], ["v0", "v1"], state, basePath),
|
|
1911
|
+
includeLegacyClientOptions: takeBoolean(
|
|
1912
|
+
config,
|
|
1913
|
+
["includeLegacyClientOptions"],
|
|
1914
|
+
state,
|
|
1915
|
+
basePath
|
|
1916
|
+
),
|
|
1917
|
+
clientConstructorName: takeString(config, ["clientConstructorName"], state, basePath)
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
function mapCsharp(config, state, packageConfig, basePath) {
|
|
1921
|
+
const packageName = takeString(config, ["packageId"], state, basePath);
|
|
1922
|
+
if (packageName !== void 0) packageConfig.packageName = packageName;
|
|
1923
|
+
return compact({
|
|
1924
|
+
useOptionalWrapper: takeBoolean(config, ["useOptionalWrapper"], state, basePath),
|
|
1925
|
+
simplifyObjectDictionaries: takeBoolean(
|
|
1926
|
+
config,
|
|
1927
|
+
["simplifyObjectDictionaries"],
|
|
1928
|
+
state,
|
|
1929
|
+
basePath
|
|
1930
|
+
),
|
|
1931
|
+
explicitNamespaces: takeBoolean(config, ["explicitNamespaces"], state, basePath),
|
|
1932
|
+
rootNamespaceForCoreClasses: takeBoolean(
|
|
1933
|
+
config,
|
|
1934
|
+
["rootNamespaceForCoreClasses"],
|
|
1935
|
+
state,
|
|
1936
|
+
basePath
|
|
1937
|
+
),
|
|
1938
|
+
includeExceptionHandler: takeBoolean(config, ["includeExceptionHandler"], state, basePath),
|
|
1939
|
+
experimentalExplicitNullableOptional: takeBoolean(
|
|
1940
|
+
config,
|
|
1941
|
+
["experimentalExplicitNullableOptional"],
|
|
1942
|
+
state,
|
|
1943
|
+
basePath
|
|
1944
|
+
)
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
function mapPhp(config, state, packageConfig, basePath) {
|
|
1948
|
+
const packageName = takeString(config, ["packageName"], state, basePath);
|
|
1949
|
+
if (packageName !== void 0) packageConfig.packageName = packageName;
|
|
1950
|
+
return compact({
|
|
1951
|
+
propertyAccess: takeEnum(config, ["propertyAccess"], ["public", "private"], state, basePath),
|
|
1952
|
+
generateClientInterfaces: takeBoolean(config, ["generateClientInterfaces"], state, basePath)
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
function mapRuby(config, state, packageConfig, basePath) {
|
|
1956
|
+
const moduleName = takeString(config, ["moduleName"], state, basePath);
|
|
1957
|
+
if (moduleName !== void 0) packageConfig.moduleName = moduleName;
|
|
1958
|
+
return compact({ requirePaths: takeStringArray(config, ["requirePaths"], state, basePath) });
|
|
1959
|
+
}
|
|
1960
|
+
function mapRust(config, state, packageConfig, basePath) {
|
|
1961
|
+
const packageName = takeString(config, ["crateName"], state, basePath);
|
|
1962
|
+
const repository = takeString(config, ["packageRepository"], state, basePath);
|
|
1963
|
+
const description = takeString(config, ["packageDescription"], state, basePath);
|
|
1964
|
+
const documentationUrl = takeString(config, ["packageDocumentation"], state, basePath);
|
|
1965
|
+
Object.assign(packageConfig, compact({ packageName, repository, description, documentationUrl }));
|
|
1966
|
+
return compact({
|
|
1967
|
+
dateTimeType: takeEnum(config, ["dateTimeType"], ["offset", "utc"], state, basePath),
|
|
1968
|
+
capitalizeInitialisms: takeBoolean(config, ["capitalizeInitialisms"], state, basePath),
|
|
1969
|
+
features: takeStringArrayRecord(config, ["features"], state, basePath),
|
|
1970
|
+
defaultFeatures: takeStringArray(config, ["defaultFeatures"], state, basePath)
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
function mapCli(config, state, packageConfig, basePath) {
|
|
1974
|
+
const identity = takeObject(config, ["packageIdentity"], state, basePath);
|
|
1975
|
+
if (identity) {
|
|
1976
|
+
Object.assign(
|
|
1977
|
+
packageConfig,
|
|
1978
|
+
compact({
|
|
1979
|
+
packageName: takeString(identity.value, ["name"], state, identity.path),
|
|
1980
|
+
repository: takeString(identity.value, ["repository"], state, identity.path),
|
|
1981
|
+
description: takeString(identity.value, ["description"], state, identity.path)
|
|
1982
|
+
})
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
return compact({
|
|
1986
|
+
paginationParameters: takeStringArray(config, ["paginationParameters"], state, basePath),
|
|
1987
|
+
skills: takeBoolean(config, ["skills"], state, basePath)
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
function mapTerraform(config, state, packageConfig, basePath) {
|
|
1991
|
+
const providerModulePath = takeString(
|
|
1992
|
+
config,
|
|
1993
|
+
["providerModulePath", "providerGoModuleName"],
|
|
1994
|
+
state,
|
|
1995
|
+
basePath
|
|
1996
|
+
);
|
|
1997
|
+
if (providerModulePath !== void 0) packageConfig.modulePath = providerModulePath;
|
|
1998
|
+
return compact({
|
|
1999
|
+
providerName: takeString(config, ["providerName"], state, basePath),
|
|
2000
|
+
providerVersion: takeString(config, ["providerVersion"], state, basePath),
|
|
2001
|
+
providerModulePath,
|
|
2002
|
+
mockAcceptance: takeBoolean(config, ["mockAcceptance"], state, basePath),
|
|
2003
|
+
hideComputedDiff: takeBoolean(config, ["hideComputedDiff"], state, basePath)
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
function mapMcp(config, state, basePath) {
|
|
2007
|
+
return compact({
|
|
2008
|
+
serverName: takeString(config, ["serverName"], state, basePath),
|
|
2009
|
+
serverDescription: takeString(config, ["serverDescription"], state, basePath),
|
|
2010
|
+
excludeAvailability: takeEnumArray(
|
|
2011
|
+
config,
|
|
2012
|
+
["excludeAvailability"],
|
|
2013
|
+
[
|
|
2014
|
+
"IN_DEVELOPMENT",
|
|
2015
|
+
"PRE_RELEASE",
|
|
2016
|
+
"GENERAL_AVAILABILITY",
|
|
2017
|
+
"DEPRECATED",
|
|
2018
|
+
"ALPHA",
|
|
2019
|
+
"BETA",
|
|
2020
|
+
"PREVIEW",
|
|
2021
|
+
"LEGACY"
|
|
2022
|
+
],
|
|
2023
|
+
state,
|
|
2024
|
+
basePath
|
|
2025
|
+
),
|
|
2026
|
+
tools: takeToolFilter(config, ["tools"], state, basePath),
|
|
2027
|
+
toolsets: takeToolsets(config, ["toolsets"], state, basePath)
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
function mapReadme(value, state, basePath) {
|
|
2031
|
+
if (!isObject(value)) return {};
|
|
2032
|
+
const readme = compact({
|
|
2033
|
+
apiName: takeString(value, ["apiName"], state, basePath),
|
|
2034
|
+
introduction: takeString(value, ["introduction"], state, basePath),
|
|
2035
|
+
apiReferenceLink: takeString(value, ["apiReferenceLink"], state, basePath),
|
|
2036
|
+
bannerLink: takeString(value, ["bannerLink"], state, basePath),
|
|
2037
|
+
disabledSections: takeStringArray(value, ["disabledSections"], state, basePath),
|
|
2038
|
+
customSections: takeCustomSections(value, state, basePath),
|
|
2039
|
+
defaultEndpoint: takeReadmeEndpoint(value, ["defaultEndpoint"], state, basePath),
|
|
2040
|
+
features: takeReadmeFeatures(value, state, basePath)
|
|
2041
|
+
});
|
|
2042
|
+
return Object.keys(readme).length ? { readme } : {};
|
|
2043
|
+
}
|
|
2044
|
+
function mapPublishMetadata(value, packageConfig) {
|
|
2045
|
+
if (!isObject(value)) return;
|
|
2046
|
+
const publisherName = stringValue(value.publisherName);
|
|
2047
|
+
const publisherEmail = stringValue(value.publisherEmail);
|
|
2048
|
+
Object.assign(
|
|
2049
|
+
packageConfig,
|
|
2050
|
+
compact({
|
|
2051
|
+
description: stringValue(value.packageDescription),
|
|
2052
|
+
documentationUrl: stringValue(value.referenceUrl),
|
|
2053
|
+
authors: publisherName ? [{ name: publisherName, ...optional("email", publisherEmail) }] : void 0
|
|
2054
|
+
})
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2057
|
+
function mapDependencies(config, state, packageConfig, basePath) {
|
|
2058
|
+
for (const field of [
|
|
2059
|
+
"extraDependencies",
|
|
2060
|
+
"extraDevDependencies",
|
|
2061
|
+
"extraPeerDependencies"
|
|
2062
|
+
]) {
|
|
2063
|
+
const located = takeObject(config, [field], state, basePath);
|
|
2064
|
+
if (!located) continue;
|
|
2065
|
+
const dependencies = Object.entries(located.value).flatMap(
|
|
2066
|
+
([name, dependency]) => mapDependency(name, dependency, state, [...located.path, name])
|
|
2067
|
+
);
|
|
2068
|
+
if (dependencies.length) packageConfig[field] = dependencies;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
function mapDependency(name, value, state, path) {
|
|
2072
|
+
if (typeof value === "string" && value) {
|
|
2073
|
+
consume(state, path);
|
|
2074
|
+
return [{ name, version: value }];
|
|
2075
|
+
}
|
|
2076
|
+
if (!isObject(value)) return [];
|
|
2077
|
+
const version = takeString(value, ["version"], state, path);
|
|
2078
|
+
const gitUrl = takeString(value, ["git"], state, path);
|
|
2079
|
+
const localPath = takeString(value, ["path"], state, path);
|
|
2080
|
+
const source = gitUrl ? {
|
|
2081
|
+
type: "git",
|
|
2082
|
+
url: gitUrl,
|
|
2083
|
+
...optional("ref", takeString(value, ["ref"], state, path))
|
|
2084
|
+
} : localPath ? { type: "path", path: localPath } : void 0;
|
|
2085
|
+
if (!version && !source) return [];
|
|
2086
|
+
return [
|
|
2087
|
+
{
|
|
2088
|
+
name,
|
|
2089
|
+
...optional("version", version),
|
|
2090
|
+
...optional("source", source),
|
|
2091
|
+
...optional("packageName", takeString(value, ["package"], state, path)),
|
|
2092
|
+
...optional("features", takeStringArray(value, ["features"], state, path)),
|
|
2093
|
+
...optional("extras", takeStringArray(value, ["extras"], state, path)),
|
|
2094
|
+
...optional("optional", takeBoolean(value, ["optional"], state, path)),
|
|
2095
|
+
...optional("defaultFeatures", takeBoolean(value, ["defaultFeatures"], state, path)),
|
|
2096
|
+
...optional("environmentMarker", takeString(value, ["python"], state, path))
|
|
2097
|
+
}
|
|
2098
|
+
];
|
|
2099
|
+
}
|
|
2100
|
+
function takeCustomSections(value, state, basePath) {
|
|
2101
|
+
const located = locate(value, ["customSections"], basePath);
|
|
2102
|
+
if (!located || !Array.isArray(located.value)) return void 0;
|
|
2103
|
+
const sections = located.value.flatMap(
|
|
2104
|
+
(section) => isObject(section) && section.language === void 0 && typeof section.title === "string" && typeof section.content === "string" ? [{ title: section.title, content: section.content }] : []
|
|
2105
|
+
);
|
|
2106
|
+
if (sections.length !== located.value.length) return void 0;
|
|
2107
|
+
consume(state, located.path);
|
|
2108
|
+
return sections;
|
|
2109
|
+
}
|
|
2110
|
+
function takeReadmeEndpoint(value, aliases, state, basePath) {
|
|
2111
|
+
const located = locate(value, aliases, basePath);
|
|
2112
|
+
if (!located) return void 0;
|
|
2113
|
+
const endpoint = parseReadmeEndpoint(located.value);
|
|
2114
|
+
if (endpoint) consume(state, located.path);
|
|
2115
|
+
return endpoint;
|
|
2116
|
+
}
|
|
2117
|
+
function takeReadmeFeatures(value, state, basePath) {
|
|
2118
|
+
const located = locate(value, ["features"], basePath);
|
|
2119
|
+
if (!located || !isObject(located.value)) return void 0;
|
|
2120
|
+
const features = {};
|
|
2121
|
+
for (const [name, endpoints] of Object.entries(located.value)) {
|
|
2122
|
+
if (!Array.isArray(endpoints)) return void 0;
|
|
2123
|
+
const parsed = endpoints.map(parseReadmeEndpoint);
|
|
2124
|
+
if (parsed.some((endpoint) => !endpoint)) return void 0;
|
|
2125
|
+
features[name] = parsed;
|
|
2126
|
+
}
|
|
2127
|
+
consume(state, located.path);
|
|
2128
|
+
return features;
|
|
2129
|
+
}
|
|
2130
|
+
function parseReadmeEndpoint(value) {
|
|
2131
|
+
if (typeof value === "string") {
|
|
2132
|
+
const match = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT)\s+(\/\S*)$/.exec(
|
|
2133
|
+
value.trim()
|
|
2134
|
+
);
|
|
2135
|
+
return match ? { method: match[1], path: match[2] } : void 0;
|
|
2136
|
+
}
|
|
2137
|
+
if (!isObject(value) || typeof value.method !== "string" || typeof value.path !== "string") {
|
|
2138
|
+
return void 0;
|
|
2139
|
+
}
|
|
2140
|
+
const method = value.method.toUpperCase();
|
|
2141
|
+
if (!["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "TRACE", "CONNECT"].includes(
|
|
2142
|
+
method
|
|
2143
|
+
)) {
|
|
2144
|
+
return void 0;
|
|
2145
|
+
}
|
|
2146
|
+
return {
|
|
2147
|
+
method,
|
|
2148
|
+
path: value.path,
|
|
2149
|
+
...optional("stream", typeof value.stream === "boolean" ? value.stream : void 0)
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
function takeToolFilter(value, aliases, state, basePath) {
|
|
2153
|
+
const located = takeObject(value, aliases, state, basePath);
|
|
2154
|
+
if (!located) return void 0;
|
|
2155
|
+
const filter = compact({
|
|
2156
|
+
include: stringArrayValue(located.value.include),
|
|
2157
|
+
exclude: stringArrayValue(located.value.exclude)
|
|
2158
|
+
});
|
|
2159
|
+
if (Object.keys(filter).length === 0 && Object.keys(located.value).length > 0) return void 0;
|
|
2160
|
+
consume(state, located.path);
|
|
2161
|
+
return filter;
|
|
2162
|
+
}
|
|
2163
|
+
function takeToolsets(value, aliases, state, basePath) {
|
|
2164
|
+
const located = takeObject(value, aliases, state, basePath);
|
|
2165
|
+
if (!located) return void 0;
|
|
2166
|
+
const entries = Object.entries(located.value).map(([name, filter]) => {
|
|
2167
|
+
if (name === "default" || !/^[a-z0-9-]+$/.test(name)) {
|
|
2168
|
+
fail(
|
|
2169
|
+
"FERN_MCP_TOOLSET_NAME_INVALID",
|
|
2170
|
+
[...located.path, name],
|
|
2171
|
+
`MCP toolset name "${name}" is not valid in SDK Config v1`,
|
|
2172
|
+
'Rename the toolset to lowercase letters, numbers, or hyphens; "default" is reserved.',
|
|
2173
|
+
["targets", basePath[2], "generation", "toolsets", name]
|
|
2174
|
+
);
|
|
2175
|
+
}
|
|
2176
|
+
if (!isObject(filter)) return void 0;
|
|
2177
|
+
return [
|
|
2178
|
+
name,
|
|
2179
|
+
compact({
|
|
2180
|
+
include: stringArrayValue(filter.include),
|
|
2181
|
+
exclude: stringArrayValue(filter.exclude)
|
|
2182
|
+
})
|
|
2183
|
+
];
|
|
2184
|
+
});
|
|
2185
|
+
if (entries.some((entry) => !entry)) return void 0;
|
|
2186
|
+
consume(state, located.path);
|
|
2187
|
+
return Object.fromEntries(entries.filter((entry) => entry !== void 0));
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
export { FernConfigMappingError, SDK_CONFIG_V1_SCHEMA_VERSION, mapFernConfigToSdkConfigV1, parseSdkConfigV1, sdkConfigV1ApiConfigSchema, sdkConfigV1AuthConfigSchema, sdkConfigV1AuthSchemeSchema, cliGenerationConfigSchema as sdkConfigV1CliGenerationConfigSchema, sdkConfigV1ClientConfigSchema, composerPackageNameSchema as sdkConfigV1ComposerPackageNameSchema, csharpGenerationConfigSchema as sdkConfigV1CsharpGenerationConfigSchema, sdkConfigV1DependencySchema, sdkConfigV1DocsConfigSchema, exactSemverSchema as sdkConfigV1ExactSemverSchema, sdkConfigV1GenerationConfigSchema, goGenerationConfigSchema as sdkConfigV1GoGenerationConfigSchema, goModulePathSchema as sdkConfigV1GoModulePathSchema, javaGenerationConfigSchema as sdkConfigV1JavaGenerationConfigSchema, kotlinGenerationConfigSchema as sdkConfigV1KotlinGenerationConfigSchema, mcpGenerationConfigSchema as sdkConfigV1McpGenerationConfigSchema, nonEmptyStringSchema as sdkConfigV1NonEmptyStringSchema, sdkConfigV1OutputConfigSchema, sdkConfigV1PackageConfigSchema, phpGenerationConfigSchema as sdkConfigV1PhpGenerationConfigSchema, sdkConfigV1PublishConfigSchema, sdkConfigV1PublishRegistrySchema, pythonGenerationConfigSchema as sdkConfigV1PythonGenerationConfigSchema, sdkConfigV1ReadmeCustomSectionSchema, sdkConfigV1ReadmeEndpointSchema, rubyGenerationConfigSchema as sdkConfigV1RubyGenerationConfigSchema, rustGenerationConfigSchema as sdkConfigV1RustGenerationConfigSchema, sdkConfigV1Schema, swiftGenerationConfigSchema as sdkConfigV1SwiftGenerationConfigSchema, sdkConfigV1TargetSchema, terraformGenerationConfigSchema as sdkConfigV1TerraformGenerationConfigSchema, typescriptGenerationConfigSchema as sdkConfigV1TypescriptGenerationConfigSchema };
|
|
2191
|
+
//# sourceMappingURL=index.js.map
|
|
2192
|
+
//# sourceMappingURL=index.js.map
|