@sdk-it/typescript 0.39.0 → 0.41.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/dist/index.js +169 -59
- package/dist/index.js.map +3 -3
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/emitters/zod.d.ts.map +1 -1
- package/dist/lib/generate.d.ts +3 -1
- package/dist/lib/generate.d.ts.map +1 -1
- package/dist/lib/generator.d.ts.map +1 -1
- package/dist/lib/options.d.ts +1 -0
- package/dist/lib/options.d.ts.map +1 -1
- package/dist/lib/sdk.d.ts +1 -1
- package/dist/lib/sdk.d.ts.map +1 -1
- package/dist/lib/server-urls.d.ts +3 -0
- package/dist/lib/server-urls.d.ts.map +1 -0
- package/dist/lib/status-map.d.ts.map +1 -1
- package/dist/lib/typescript-snippet.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/connect.d.ts +0 -1
- package/dist/connect.d.ts.map +0 -1
- package/dist/global.d.js +0 -1
- package/dist/global.d.js.map +0 -7
- package/dist/lib/connect.d.ts +0 -162
- package/dist/lib/connect.d.ts.map +0 -1
- package/dist/lib/readme-generator.d.ts +0 -8
- package/dist/lib/readme-generator.d.ts.map +0 -1
- package/dist/lib/statusMap.d.ts +0 -2
- package/dist/lib/statusMap.d.ts.map +0 -1
- package/dist/lib/utils.d.ts +0 -17
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/watcher.d.ts +0 -2
- package/dist/lib/watcher.d.ts.map +0 -1
- package/dist/src/index.js +0 -5
- package/dist/src/index.js.map +0 -7
- package/dist/src/lib/agent/ai-sdk.js +0 -60
- package/dist/src/lib/agent/ai-sdk.js.map +0 -7
- package/dist/src/lib/agent/openai-agents.js +0 -42
- package/dist/src/lib/agent/openai-agents.js.map +0 -7
- package/dist/src/lib/client.js +0 -152
- package/dist/src/lib/client.js.map +0 -7
- package/dist/src/lib/emitters/interface.js +0 -169
- package/dist/src/lib/emitters/interface.js.map +0 -7
- package/dist/src/lib/emitters/snippet.js +0 -191
- package/dist/src/lib/emitters/snippet.js.map +0 -7
- package/dist/src/lib/emitters/zod.js +0 -271
- package/dist/src/lib/emitters/zod.js.map +0 -7
- package/dist/src/lib/generate.js +0 -382
- package/dist/src/lib/generate.js.map +0 -7
- package/dist/src/lib/generator.js +0 -268
- package/dist/src/lib/generator.js.map +0 -7
- package/dist/src/lib/import-utilities.js +0 -56
- package/dist/src/lib/import-utilities.js.map +0 -7
- package/dist/src/lib/options.js +0 -3
- package/dist/src/lib/options.js.map +0 -7
- package/dist/src/lib/readme/prop.emitter.js +0 -283
- package/dist/src/lib/readme/prop.emitter.js.map +0 -7
- package/dist/src/lib/readme/readme.js +0 -105
- package/dist/src/lib/readme/readme.js.map +0 -7
- package/dist/src/lib/sdk.js +0 -236
- package/dist/src/lib/sdk.js.map +0 -7
- package/dist/src/lib/status-map.js +0 -28
- package/dist/src/lib/status-map.js.map +0 -7
- package/dist/src/lib/style.js +0 -1
- package/dist/src/lib/style.js.map +0 -7
- package/dist/src/lib/typescript-snippet.js +0 -738
- package/dist/src/lib/typescript-snippet.js.map +0 -7
package/dist/src/lib/generate.js
DELETED
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
import { template } from "lodash-es";
|
|
2
|
-
import { readdir } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { npmRunPathEnv } from "npm-run-path";
|
|
5
|
-
import { camelcase, spinalcase } from "stringcase";
|
|
6
|
-
import { methods, pascalcase, toLitObject } from "@sdk-it/core";
|
|
7
|
-
import {
|
|
8
|
-
createWriterProxy,
|
|
9
|
-
getFolderExports,
|
|
10
|
-
writeFiles
|
|
11
|
-
} from "@sdk-it/core/file-system.js";
|
|
12
|
-
import {
|
|
13
|
-
cleanFiles,
|
|
14
|
-
readWriteMetadata,
|
|
15
|
-
sanitizeTag,
|
|
16
|
-
securityToOptions,
|
|
17
|
-
toIR
|
|
18
|
-
} from "@sdk-it/spec";
|
|
19
|
-
import { generateAISDKTools } from "./agent/ai-sdk.ts";
|
|
20
|
-
import { generateOpenAIAgentTools } from "./agent/openai-agents.ts";
|
|
21
|
-
import utilsTxt from "./agent/utils.txt";
|
|
22
|
-
import backend from "./client.ts";
|
|
23
|
-
import { TypeScriptEmitter } from "./emitters/interface.ts";
|
|
24
|
-
import { generateCode } from "./generator.ts";
|
|
25
|
-
import dispatcherTxt from "./http/dispatcher.txt";
|
|
26
|
-
import interceptors from "./http/interceptors.txt";
|
|
27
|
-
import parseResponse from "./http/parse-response.txt";
|
|
28
|
-
import parserTxt from "./http/parser.txt";
|
|
29
|
-
import requestTxt from "./http/request.txt";
|
|
30
|
-
import responseTxt from "./http/response.txt";
|
|
31
|
-
import {} from "./import-utilities.ts";
|
|
32
|
-
import cursorPaginationTxt from "./paginations/cursor-pagination.txt";
|
|
33
|
-
import offsetPaginationTxt from "./paginations/offset-pagination.txt";
|
|
34
|
-
import paginationTxt from "./paginations/page-pagination.txt";
|
|
35
|
-
import { toReadme } from "./readme/readme.ts";
|
|
36
|
-
import { TypeScriptSnippet } from "./typescript-snippet.ts";
|
|
37
|
-
function security(spec) {
|
|
38
|
-
const security2 = spec.security || [];
|
|
39
|
-
const components = spec.components || {};
|
|
40
|
-
const securitySchemes = components.securitySchemes || {};
|
|
41
|
-
const paths = Object.values(spec.paths ?? {});
|
|
42
|
-
const options = securityToOptions(spec, security2, securitySchemes);
|
|
43
|
-
for (const it of paths) {
|
|
44
|
-
for (const method of methods) {
|
|
45
|
-
const operation = it[method];
|
|
46
|
-
if (!operation) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
Object.assign(
|
|
50
|
-
options,
|
|
51
|
-
securityToOptions(
|
|
52
|
-
spec,
|
|
53
|
-
operation.security || [],
|
|
54
|
-
securitySchemes,
|
|
55
|
-
"input"
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return options;
|
|
61
|
-
}
|
|
62
|
-
async function generate(openapi, settings) {
|
|
63
|
-
const spec = toIR(
|
|
64
|
-
{
|
|
65
|
-
spec: openapi,
|
|
66
|
-
responses: { flattenErrorResponses: true },
|
|
67
|
-
pagination: settings.pagination
|
|
68
|
-
},
|
|
69
|
-
false
|
|
70
|
-
);
|
|
71
|
-
const style = Object.assign(
|
|
72
|
-
{},
|
|
73
|
-
{
|
|
74
|
-
errorAsValue: false,
|
|
75
|
-
name: "github",
|
|
76
|
-
outputType: "default"
|
|
77
|
-
},
|
|
78
|
-
settings.style ?? {}
|
|
79
|
-
);
|
|
80
|
-
const output = settings.mode === "full" ? join(settings.output, "src") : settings.output;
|
|
81
|
-
settings.useTsExtension ??= true;
|
|
82
|
-
settings.readme ??= true;
|
|
83
|
-
const { writer, files: writtenFiles } = createWriterProxy(
|
|
84
|
-
settings.writer ?? writeFiles,
|
|
85
|
-
output
|
|
86
|
-
);
|
|
87
|
-
settings.writer = writer;
|
|
88
|
-
settings.readFolder ??= async (folder) => {
|
|
89
|
-
const files = await readdir(folder, { withFileTypes: true });
|
|
90
|
-
return files.map((file) => ({
|
|
91
|
-
fileName: file.name,
|
|
92
|
-
filePath: join(file.parentPath, file.name),
|
|
93
|
-
isFolder: file.isDirectory()
|
|
94
|
-
}));
|
|
95
|
-
};
|
|
96
|
-
const makeImport = (moduleSpecifier) => {
|
|
97
|
-
return settings.useTsExtension ? `${moduleSpecifier}.ts` : moduleSpecifier;
|
|
98
|
-
};
|
|
99
|
-
const { endpoints, groups, commonZod } = generateCode({
|
|
100
|
-
spec,
|
|
101
|
-
style,
|
|
102
|
-
makeImport
|
|
103
|
-
});
|
|
104
|
-
const clientName = pascalcase((settings.name || "client").trim());
|
|
105
|
-
const packageName = settings.name ? `@${spinalcase(settings.name.trim().toLowerCase())}/sdk` : "sdk";
|
|
106
|
-
const inputs = toInputs(groups, commonZod, makeImport);
|
|
107
|
-
const models = serializeModels(spec);
|
|
108
|
-
await settings.writer(output, {
|
|
109
|
-
"outputs/.gitkeep": "",
|
|
110
|
-
"inputs/.gitkeep": "",
|
|
111
|
-
"models/.getkeep": ""
|
|
112
|
-
});
|
|
113
|
-
await settings.writer(join(output, "http"), {
|
|
114
|
-
"parse-response.ts": parseResponse,
|
|
115
|
-
"response.ts": responseTxt,
|
|
116
|
-
"parser.ts": parserTxt,
|
|
117
|
-
"request.ts": requestTxt,
|
|
118
|
-
"dispatcher.ts": `import z from 'zod';
|
|
119
|
-
import { type Interceptor } from '${makeImport("../http/interceptors")}';
|
|
120
|
-
import { type RequestConfig } from '${makeImport("../http/request")}';
|
|
121
|
-
import { buffered } from '${makeImport("./parse-response")}';
|
|
122
|
-
import { APIError, APIResponse, type SuccessfulResponse, type ProblematicResponse } from '${makeImport("./response")}';
|
|
123
|
-
|
|
124
|
-
${template(dispatcherTxt, {})({ throwError: !style.errorAsValue, outputType: style.outputType })}`,
|
|
125
|
-
"interceptors.ts": `
|
|
126
|
-
import type { RequestConfig, HeadersInit } from './${makeImport("request")}';
|
|
127
|
-
${interceptors}`
|
|
128
|
-
});
|
|
129
|
-
await settings.writer(output, {
|
|
130
|
-
"client.ts": backend(
|
|
131
|
-
{
|
|
132
|
-
name: clientName,
|
|
133
|
-
servers: (spec.servers ?? []).map((server) => server.url) || [],
|
|
134
|
-
options: security(spec),
|
|
135
|
-
makeImport
|
|
136
|
-
},
|
|
137
|
-
style
|
|
138
|
-
),
|
|
139
|
-
...inputs,
|
|
140
|
-
...endpoints
|
|
141
|
-
});
|
|
142
|
-
await settings.writer(output, models);
|
|
143
|
-
await settings.writer(join(output, "pagination"), {
|
|
144
|
-
"cursor-pagination.ts": cursorPaginationTxt,
|
|
145
|
-
"offset-pagination.ts": offsetPaginationTxt,
|
|
146
|
-
"page-pagination.ts": paginationTxt
|
|
147
|
-
});
|
|
148
|
-
const metadata = await readWriteMetadata(output, Array.from(writtenFiles));
|
|
149
|
-
if (settings.cleanup !== false && writtenFiles.size > 0) {
|
|
150
|
-
await cleanFiles(metadata.content, output, [
|
|
151
|
-
"/tsconfig*.json",
|
|
152
|
-
"/package.json",
|
|
153
|
-
"/metadata.json",
|
|
154
|
-
"/**/index.ts"
|
|
155
|
-
]);
|
|
156
|
-
}
|
|
157
|
-
const folders = [
|
|
158
|
-
getFolderExports(
|
|
159
|
-
join(output, "outputs"),
|
|
160
|
-
settings.readFolder,
|
|
161
|
-
settings.useTsExtension
|
|
162
|
-
),
|
|
163
|
-
getFolderExports(
|
|
164
|
-
join(output, "inputs"),
|
|
165
|
-
settings.readFolder,
|
|
166
|
-
settings.useTsExtension,
|
|
167
|
-
["ts"],
|
|
168
|
-
(dirent) => dirent.isFolder && ["schemas"].includes(dirent.fileName)
|
|
169
|
-
),
|
|
170
|
-
getFolderExports(
|
|
171
|
-
join(output, "api"),
|
|
172
|
-
settings.readFolder,
|
|
173
|
-
settings.useTsExtension
|
|
174
|
-
),
|
|
175
|
-
getFolderExports(
|
|
176
|
-
join(output, "http"),
|
|
177
|
-
settings.readFolder,
|
|
178
|
-
settings.useTsExtension,
|
|
179
|
-
["ts"],
|
|
180
|
-
(dirent) => !["response.ts", "parser.ts"].includes(dirent.fileName)
|
|
181
|
-
),
|
|
182
|
-
getFolderExports(
|
|
183
|
-
join(output, "models"),
|
|
184
|
-
settings.readFolder,
|
|
185
|
-
settings.useTsExtension
|
|
186
|
-
)
|
|
187
|
-
];
|
|
188
|
-
const [outputIndex, inputsIndex, apiIndex, httpIndex, modelsIndex] = await Promise.all(folders);
|
|
189
|
-
await settings.writer(join(output, "pagination"), {
|
|
190
|
-
"index.ts": await getFolderExports(
|
|
191
|
-
join(output, "pagination"),
|
|
192
|
-
settings.readFolder,
|
|
193
|
-
settings.useTsExtension,
|
|
194
|
-
["ts"]
|
|
195
|
-
)
|
|
196
|
-
});
|
|
197
|
-
await settings.writer(output, {
|
|
198
|
-
"api/index.ts": apiIndex,
|
|
199
|
-
"outputs/index.ts": outputIndex,
|
|
200
|
-
"inputs/index.ts": inputsIndex || null,
|
|
201
|
-
"http/index.ts": httpIndex,
|
|
202
|
-
"models/index.ts": modelsIndex
|
|
203
|
-
// ...(modelsImports.length ? { 'models/index.ts': modelsIndex } : {}),
|
|
204
|
-
});
|
|
205
|
-
switch (settings.agentTools) {
|
|
206
|
-
case "openai-agents":
|
|
207
|
-
await settings.writer(output, {
|
|
208
|
-
"agents.ts": `${generateOpenAIAgentTools(spec)}
|
|
209
|
-
${utilsTxt}`
|
|
210
|
-
});
|
|
211
|
-
break;
|
|
212
|
-
case "ai-sdk":
|
|
213
|
-
await settings.writer(output, {
|
|
214
|
-
"agents.ts": `${generateAISDKTools(spec)}
|
|
215
|
-
${utilsTxt}`
|
|
216
|
-
});
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
await settings.writer(output, {
|
|
220
|
-
"index.ts": await getFolderExports(
|
|
221
|
-
output,
|
|
222
|
-
settings.readFolder,
|
|
223
|
-
settings.useTsExtension,
|
|
224
|
-
["ts"],
|
|
225
|
-
(config) => config.fileName.endsWith("pagination") || config.fileName.endsWith("agents")
|
|
226
|
-
)
|
|
227
|
-
});
|
|
228
|
-
if (settings.mode === "full") {
|
|
229
|
-
const configFiles = {
|
|
230
|
-
"package.json": {
|
|
231
|
-
ignoreIfExists: true,
|
|
232
|
-
content: JSON.stringify(
|
|
233
|
-
{
|
|
234
|
-
name: packageName,
|
|
235
|
-
version: "0.0.1",
|
|
236
|
-
type: "module",
|
|
237
|
-
main: "./src/index.ts",
|
|
238
|
-
module: "./src/index.ts",
|
|
239
|
-
types: "./src/index.ts",
|
|
240
|
-
publishConfig: {
|
|
241
|
-
access: "public"
|
|
242
|
-
},
|
|
243
|
-
exports: {
|
|
244
|
-
"./package.json": "./package.json",
|
|
245
|
-
".": {
|
|
246
|
-
types: "./src/index.ts",
|
|
247
|
-
import: "./src/index.ts",
|
|
248
|
-
default: "./src/index.ts"
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
dependencies: {
|
|
252
|
-
"fast-content-type-parse": "^3.0.0",
|
|
253
|
-
zod: "^3.25.76"
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
null,
|
|
257
|
-
2
|
|
258
|
-
)
|
|
259
|
-
},
|
|
260
|
-
"tsconfig.json": {
|
|
261
|
-
ignoreIfExists: true,
|
|
262
|
-
content: JSON.stringify(
|
|
263
|
-
{
|
|
264
|
-
compilerOptions: {
|
|
265
|
-
skipLibCheck: true,
|
|
266
|
-
skipDefaultLibCheck: true,
|
|
267
|
-
target: "ESNext",
|
|
268
|
-
module: "ESNext",
|
|
269
|
-
noEmit: true,
|
|
270
|
-
strict: true,
|
|
271
|
-
allowImportingTsExtensions: true,
|
|
272
|
-
verbatimModuleSyntax: true,
|
|
273
|
-
baseUrl: ".",
|
|
274
|
-
moduleResolution: "bundler"
|
|
275
|
-
},
|
|
276
|
-
include: ["**/*.ts"]
|
|
277
|
-
},
|
|
278
|
-
null,
|
|
279
|
-
2
|
|
280
|
-
)
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
await settings.writer(settings.output, configFiles);
|
|
284
|
-
}
|
|
285
|
-
if (settings.readme) {
|
|
286
|
-
const path = typeof settings.readme === "string" ? settings.readme : "README.md";
|
|
287
|
-
await settings.writer(settings.output, {
|
|
288
|
-
[path]: toReadme(spec, new TypeScriptSnippet(spec, settings))
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
await settings.formatCode?.({
|
|
292
|
-
output,
|
|
293
|
-
env: npmRunPathEnv()
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
function serializeModels(spec) {
|
|
297
|
-
const filesMap = {};
|
|
298
|
-
const files = {};
|
|
299
|
-
for (const [name, schema] of Object.entries(spec.components.schemas)) {
|
|
300
|
-
const isResponseBody = schema["x-responsebody"];
|
|
301
|
-
const isRequestBody = schema["x-requestbody"];
|
|
302
|
-
const responseGroup = schema["x-response-group"];
|
|
303
|
-
const stream = schema["x-stream"];
|
|
304
|
-
if (isRequestBody) {
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
const folder = isResponseBody ? "outputs" : "models";
|
|
308
|
-
let typeContent = "ReadableStream";
|
|
309
|
-
if (!stream) {
|
|
310
|
-
const serializer = new TypeScriptEmitter(spec);
|
|
311
|
-
typeContent = serializer.handle(schema, true);
|
|
312
|
-
}
|
|
313
|
-
const fileContent = [
|
|
314
|
-
`
|
|
315
|
-
${schema.description ? `
|
|
316
|
-
/**
|
|
317
|
-
* ${schema.description}
|
|
318
|
-
*/
|
|
319
|
-
` : ""}`,
|
|
320
|
-
`export type ${pascalcase(sanitizeTag(name))} = ${typeContent};`
|
|
321
|
-
];
|
|
322
|
-
const fileName = responseGroup ? join(folder, `${spinalcase(responseGroup)}.ts`) : join(folder, `${spinalcase(name)}.ts`);
|
|
323
|
-
filesMap[fileName] ??= [];
|
|
324
|
-
filesMap[fileName].push(fileContent.join("\n"));
|
|
325
|
-
}
|
|
326
|
-
for (const [group, contents] of Object.entries(filesMap)) {
|
|
327
|
-
let fileContent = contents.join("\n");
|
|
328
|
-
if (fileContent.includes("models.")) {
|
|
329
|
-
fileContent = `import type * as models from '../index.ts';
|
|
330
|
-
${fileContent}`;
|
|
331
|
-
}
|
|
332
|
-
files[group] = fileContent;
|
|
333
|
-
}
|
|
334
|
-
return files;
|
|
335
|
-
}
|
|
336
|
-
function toInputs(operationsSet, commonZod, makeImport) {
|
|
337
|
-
const commonImports = commonZod.keys().toArray();
|
|
338
|
-
const inputs = {};
|
|
339
|
-
for (const [name, operations] of Object.entries(operationsSet)) {
|
|
340
|
-
const output = [];
|
|
341
|
-
const imports = /* @__PURE__ */ new Set(['import { z } from "zod";']);
|
|
342
|
-
for (const operation of operations) {
|
|
343
|
-
const schemaName = camelcase(`${operation.operationId} schema`);
|
|
344
|
-
const schema = `export const ${schemaName} = ${Object.keys(operation.schemas).length === 1 ? Object.values(operation.schemas)[0] : toLitObject(operation.schemas)};`;
|
|
345
|
-
for (const it of commonImports) {
|
|
346
|
-
if (schema.includes(it)) {
|
|
347
|
-
imports.add(
|
|
348
|
-
`import { ${it} } from './schemas/${makeImport(spinalcase(it))}';`
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
output.push(schema);
|
|
353
|
-
}
|
|
354
|
-
inputs[`inputs/${spinalcase(name)}.ts`] = [...imports, ...output].join("\n") + "\n";
|
|
355
|
-
}
|
|
356
|
-
const schemas = commonZod.entries().reduce((acc, [name, schema]) => {
|
|
357
|
-
const output = [`import { z } from 'zod';`];
|
|
358
|
-
const content = `export const ${name} = ${schema};`;
|
|
359
|
-
for (const schema2 of commonImports) {
|
|
360
|
-
const preciseMatch = new RegExp(`\\b${schema2}\\b`);
|
|
361
|
-
if (preciseMatch.test(content) && schema2 !== name) {
|
|
362
|
-
output.push(
|
|
363
|
-
`import { ${schema2} } from './${makeImport(spinalcase(schema2))}';`
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
output.push(content);
|
|
368
|
-
return [
|
|
369
|
-
[`inputs/schemas/${spinalcase(name)}.ts`, output.join("\n")],
|
|
370
|
-
...acc
|
|
371
|
-
];
|
|
372
|
-
}, []);
|
|
373
|
-
return {
|
|
374
|
-
...Object.fromEntries(schemas),
|
|
375
|
-
...inputs
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
export {
|
|
379
|
-
generate,
|
|
380
|
-
toInputs
|
|
381
|
-
};
|
|
382
|
-
//# sourceMappingURL=generate.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/lib/generate.ts"],
|
|
4
|
-
"sourcesContent": ["import { template } from 'lodash-es';\nimport { readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { npmRunPathEnv } from 'npm-run-path';\nimport type { OpenAPIObject } from 'openapi3-ts/oas31';\nimport { camelcase, spinalcase } from 'stringcase';\n\nimport { methods, pascalcase, toLitObject } from '@sdk-it/core';\nimport {\n type WriteContent,\n createWriterProxy,\n getFolderExports,\n writeFiles,\n} from '@sdk-it/core/file-system.js';\nimport {\n type IR,\n cleanFiles,\n readWriteMetadata,\n sanitizeTag,\n securityToOptions,\n toIR,\n} from '@sdk-it/spec';\n\nimport { generateAISDKTools } from './agent/ai-sdk.ts';\nimport { generateOpenAIAgentTools } from './agent/openai-agents.ts';\nimport utilsTxt from './agent/utils.txt';\nimport backend from './client.ts';\nimport { TypeScriptEmitter } from './emitters/interface.ts';\nimport { generateCode } from './generator.ts';\nimport dispatcherTxt from './http/dispatcher.txt';\nimport interceptors from './http/interceptors.txt';\nimport parseResponse from './http/parse-response.txt';\nimport parserTxt from './http/parser.txt';\nimport requestTxt from './http/request.txt';\nimport responseTxt from './http/response.txt';\nimport { type MakeImportFn } from './import-utilities.ts';\nimport type { TypeScriptGeneratorOptions } from './options.ts';\nimport cursorPaginationTxt from './paginations/cursor-pagination.txt';\nimport offsetPaginationTxt from './paginations/offset-pagination.txt';\nimport paginationTxt from './paginations/page-pagination.txt';\nimport { toReadme } from './readme/readme.ts';\nimport type { Operation } from './sdk.ts';\nimport { TypeScriptSnippet } from './typescript-snippet.ts';\n\nfunction security(spec: IR) {\n const security = spec.security || [];\n const components = spec.components || {};\n const securitySchemes = components.securitySchemes || {};\n const paths = Object.values(spec.paths ?? {});\n\n const options = securityToOptions(spec, security, securitySchemes);\n\n for (const it of paths) {\n for (const method of methods) {\n const operation = it[method];\n if (!operation) {\n continue;\n }\n Object.assign(\n options,\n securityToOptions(\n spec,\n operation.security || [],\n securitySchemes,\n 'input',\n ),\n );\n }\n }\n return options;\n}\n\n// FIXME: there should not be default here\n// instead export this function from the cli package with\n// defaults for programmatic usage\nexport async function generate(\n openapi: OpenAPIObject,\n settings: TypeScriptGeneratorOptions,\n) {\n const spec = toIR(\n {\n spec: openapi,\n responses: { flattenErrorResponses: true },\n pagination: settings.pagination,\n },\n false,\n );\n\n const style = Object.assign(\n {},\n {\n errorAsValue: false,\n name: 'github',\n outputType: 'default',\n },\n settings.style ?? {},\n );\n const output =\n settings.mode === 'full' ? join(settings.output, 'src') : settings.output;\n\n settings.useTsExtension ??= true;\n settings.readme ??= true;\n const { writer, files: writtenFiles } = createWriterProxy(\n settings.writer ?? writeFiles,\n output,\n );\n settings.writer = writer;\n settings.readFolder ??= async (folder: string) => {\n const files = await readdir(folder, { withFileTypes: true });\n return files.map((file) => ({\n fileName: file.name,\n filePath: join(file.parentPath, file.name),\n isFolder: file.isDirectory(),\n }));\n };\n const makeImport = (moduleSpecifier: string) => {\n return settings.useTsExtension ? `${moduleSpecifier}.ts` : moduleSpecifier;\n };\n const { endpoints, groups, commonZod } = generateCode({\n spec,\n style,\n makeImport,\n });\n\n const clientName = pascalcase((settings.name || 'client').trim());\n\n const packageName = settings.name\n ? `@${spinalcase(settings.name.trim().toLowerCase())}/sdk`\n : 'sdk';\n\n const inputs = toInputs(groups, commonZod, makeImport);\n const models = serializeModels(spec);\n\n await settings.writer(output, {\n 'outputs/.gitkeep': '',\n 'inputs/.gitkeep': '',\n 'models/.getkeep': '',\n });\n\n await settings.writer(join(output, 'http'), {\n 'parse-response.ts': parseResponse,\n 'response.ts': responseTxt,\n 'parser.ts': parserTxt,\n 'request.ts': requestTxt,\n 'dispatcher.ts': `import z from 'zod';\nimport { type Interceptor } from '${makeImport('../http/interceptors')}';\nimport { type RequestConfig } from '${makeImport('../http/request')}';\nimport { buffered } from '${makeImport('./parse-response')}';\nimport { APIError, APIResponse, type SuccessfulResponse, type ProblematicResponse } from '${makeImport('./response')}';\n\n${template(dispatcherTxt, {})({ throwError: !style.errorAsValue, outputType: style.outputType })}`,\n\n 'interceptors.ts': `\n import type { RequestConfig, HeadersInit } from './${makeImport('request')}';\n ${interceptors}`,\n });\n\n await settings.writer(output, {\n 'client.ts': backend(\n {\n name: clientName,\n servers: (spec.servers ?? []).map((server) => server.url) || [],\n options: security(spec),\n makeImport,\n },\n style,\n ),\n ...inputs,\n ...endpoints,\n });\n\n await settings.writer(output, models);\n\n await settings.writer(join(output, 'pagination'), {\n 'cursor-pagination.ts': cursorPaginationTxt,\n 'offset-pagination.ts': offsetPaginationTxt,\n 'page-pagination.ts': paginationTxt,\n });\n\n const metadata = await readWriteMetadata(output, Array.from(writtenFiles));\n if (settings.cleanup !== false && writtenFiles.size > 0) {\n await cleanFiles(metadata.content, output, [\n '/tsconfig*.json',\n '/package.json',\n '/metadata.json',\n '/**/index.ts',\n ]);\n }\n\n const folders = [\n getFolderExports(\n join(output, 'outputs'),\n settings.readFolder,\n settings.useTsExtension,\n ),\n getFolderExports(\n join(output, 'inputs'),\n settings.readFolder,\n settings.useTsExtension,\n ['ts'],\n (dirent) => dirent.isFolder && ['schemas'].includes(dirent.fileName),\n ),\n getFolderExports(\n join(output, 'api'),\n settings.readFolder,\n settings.useTsExtension,\n ),\n getFolderExports(\n join(output, 'http'),\n settings.readFolder,\n settings.useTsExtension,\n ['ts'],\n (dirent) => !['response.ts', 'parser.ts'].includes(dirent.fileName),\n ),\n getFolderExports(\n join(output, 'models'),\n settings.readFolder,\n settings.useTsExtension,\n ),\n ];\n const [outputIndex, inputsIndex, apiIndex, httpIndex, modelsIndex] =\n await Promise.all(folders);\n\n await settings.writer(join(output, 'pagination'), {\n 'index.ts': await getFolderExports(\n join(output, 'pagination'),\n settings.readFolder,\n settings.useTsExtension,\n ['ts'],\n ),\n });\n await settings.writer(output, {\n 'api/index.ts': apiIndex,\n 'outputs/index.ts': outputIndex,\n 'inputs/index.ts': inputsIndex || null,\n 'http/index.ts': httpIndex,\n 'models/index.ts': modelsIndex,\n // ...(modelsImports.length ? { 'models/index.ts': modelsIndex } : {}),\n });\n\n switch (settings.agentTools) {\n case 'openai-agents':\n await settings.writer(output, {\n 'agents.ts': `${generateOpenAIAgentTools(spec)}\\n${utilsTxt}`,\n });\n break;\n case 'ai-sdk':\n await settings.writer(output, {\n 'agents.ts': `${generateAISDKTools(spec)}\\n${utilsTxt}`,\n });\n break;\n }\n await settings.writer(output, {\n 'index.ts': await getFolderExports(\n output,\n settings.readFolder,\n settings.useTsExtension,\n ['ts'],\n (config) =>\n config.fileName.endsWith('pagination') ||\n config.fileName.endsWith('agents'),\n ),\n });\n if (settings.mode === 'full') {\n const configFiles: WriteContent = {\n 'package.json': {\n ignoreIfExists: true,\n content: JSON.stringify(\n {\n name: packageName,\n version: '0.0.1',\n type: 'module',\n main: './src/index.ts',\n module: './src/index.ts',\n types: './src/index.ts',\n publishConfig: {\n access: 'public',\n },\n exports: {\n './package.json': './package.json',\n '.': {\n types: './src/index.ts',\n import: './src/index.ts',\n default: './src/index.ts',\n },\n },\n dependencies: {\n 'fast-content-type-parse': '^3.0.0',\n zod: '^3.25.76',\n },\n },\n null,\n 2,\n ),\n },\n 'tsconfig.json': {\n ignoreIfExists: true,\n content: JSON.stringify(\n {\n compilerOptions: {\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n target: 'ESNext',\n module: 'ESNext',\n noEmit: true,\n strict: true,\n allowImportingTsExtensions: true,\n verbatimModuleSyntax: true,\n baseUrl: '.',\n moduleResolution: 'bundler',\n },\n include: ['**/*.ts'],\n },\n null,\n 2,\n ),\n },\n };\n await settings.writer(settings.output, configFiles);\n }\n\n if (settings.readme) {\n const path =\n typeof settings.readme === 'string' ? settings.readme : 'README.md';\n await settings.writer(settings.output, {\n [path]: toReadme(spec, new TypeScriptSnippet(spec, settings)),\n });\n }\n\n await settings.formatCode?.({\n output: output,\n env: npmRunPathEnv(),\n });\n}\n\nfunction serializeModels(spec: IR) {\n const filesMap: Record<string, string[]> = {};\n const files: Record<string, string> = {};\n for (const [name, schema] of Object.entries(spec.components.schemas)) {\n // if (isRef(schema)) {\n // continue;\n // }\n const isResponseBody = (schema as any)['x-responsebody'];\n const isRequestBody = (schema as any)['x-requestbody'];\n const responseGroup = (schema as any)['x-response-group'];\n const stream = (schema as any)['x-stream'];\n if (isRequestBody) {\n // we do not generate interfaces for request bodies. we use zod for that.\n // bewary that the sometimes request body content schema is used as model somewhere else.\n // so we need to till the augmenter to create completeley separate model for request body suffixed by `Input`\n continue;\n }\n const folder = isResponseBody ? 'outputs' : 'models';\n let typeContent = 'ReadableStream';\n if (!stream) {\n const serializer = new TypeScriptEmitter(spec);\n typeContent = serializer.handle(schema, true);\n }\n\n const fileContent = [\n `\\n${schema.description ? `\\n/** \\n * ${schema.description}\\n */\\n` : ''}`,\n `export type ${pascalcase(sanitizeTag(name))} = ${typeContent};`,\n ];\n const fileName = responseGroup\n ? join(folder, `${spinalcase(responseGroup)}.ts`)\n : join(folder, `${spinalcase(name)}.ts`);\n filesMap[fileName] ??= [];\n filesMap[fileName].push(fileContent.join('\\n'));\n }\n\n for (const [group, contents] of Object.entries(filesMap)) {\n let fileContent = contents.join('\\n');\n if (fileContent.includes('models.')) {\n fileContent = `import type * as models from '../index.ts';\\n${fileContent}`;\n }\n files[group] = fileContent;\n }\n return files;\n}\n\nexport function toInputs(\n operationsSet: Record<string, Operation[]>,\n commonZod: Map<string, string>,\n makeImport: MakeImportFn,\n) {\n const commonImports = commonZod.keys().toArray();\n const inputs: Record<string, string> = {};\n for (const [name, operations] of Object.entries(operationsSet)) {\n const output: string[] = [];\n const imports = new Set(['import { z } from \"zod\";']);\n\n for (const operation of operations) {\n const schemaName = camelcase(`${operation.operationId} schema`);\n\n const schema = `export const ${schemaName} = ${\n Object.keys(operation.schemas).length === 1\n ? Object.values(operation.schemas)[0]\n : toLitObject(operation.schemas)\n };`;\n\n for (const it of commonImports) {\n if (schema.includes(it)) {\n imports.add(\n `import { ${it} } from './schemas/${makeImport(spinalcase(it))}';`,\n );\n }\n }\n output.push(schema);\n }\n inputs[`inputs/${spinalcase(name)}.ts`] =\n [...imports, ...output].join('\\n') + '\\n';\n }\n\n const schemas = commonZod\n .entries()\n .reduce<string[][]>((acc, [name, schema]) => {\n const output = [`import { z } from 'zod';`];\n const content = `export const ${name} = ${schema};`;\n for (const schema of commonImports) {\n const preciseMatch = new RegExp(`\\\\b${schema}\\\\b`);\n if (preciseMatch.test(content) && schema !== name) {\n output.push(\n `import { ${schema} } from './${makeImport(spinalcase(schema))}';`,\n );\n }\n }\n output.push(content);\n return [\n [`inputs/schemas/${spinalcase(name)}.ts`, output.join('\\n')],\n ...acc,\n ];\n }, []);\n\n return {\n ...Object.fromEntries(schemas),\n ...inputs,\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAE9B,SAAS,WAAW,kBAAkB;AAEtC,SAAS,SAAS,YAAY,mBAAmB;AACjD;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AACzC,OAAO,cAAc;AACrB,OAAO,aAAa;AACpB,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,OAAO,mBAAmB;AAC1B,OAAO,kBAAkB;AACzB,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,iBAAiB;AACxB,eAAkC;AAElC,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAChC,OAAO,mBAAmB;AAC1B,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAElC,SAAS,SAAS,MAAU;AAC1B,QAAMA,YAAW,KAAK,YAAY,CAAC;AACnC,QAAM,aAAa,KAAK,cAAc,CAAC;AACvC,QAAM,kBAAkB,WAAW,mBAAmB,CAAC;AACvD,QAAM,QAAQ,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC;AAE5C,QAAM,UAAU,kBAAkB,MAAMA,WAAU,eAAe;AAEjE,aAAW,MAAM,OAAO;AACtB,eAAW,UAAU,SAAS;AAC5B,YAAM,YAAY,GAAG,MAAM;AAC3B,UAAI,CAAC,WAAW;AACd;AAAA,MACF;AACA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE;AAAA,UACA,UAAU,YAAY,C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