@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/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;yBAErB,MAAM,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;AAA9C,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;yBAErB,MAAM,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;AAA9C,wBAsNE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../src/lib/emitters/zod.ts"],"names":[],"mappings":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MAAM,EAAE,YAAY,GAAG,MAAM;IA0HpC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM;CAiE1E;AAYD,wBAAgB,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAetE"}
|
package/dist/lib/generate.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
|
2
2
|
import { type MakeImportFn } from './import-utilities.ts';
|
|
3
3
|
import type { TypeScriptGeneratorOptions } from './options.ts';
|
|
4
4
|
import type { Operation } from './sdk.ts';
|
|
5
|
-
export declare function generate(openapi: OpenAPIObject, settings: TypeScriptGeneratorOptions): Promise<
|
|
5
|
+
export declare function generate(openapi: OpenAPIObject, settings: TypeScriptGeneratorOptions): Promise<{
|
|
6
|
+
packageName: string;
|
|
7
|
+
}>;
|
|
6
8
|
export declare function toInputs(operationsSet: Record<string, Operation[]>, commonZod: Map<string, string>, makeImport: MakeImportFn): any;
|
|
7
9
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAgCvD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAmC1C,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAwPlC;AAsDD,wBAAgB,QAAQ,CACtB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAC1C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,UAAU,EAAE,YAAY,OAsDzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/lib/generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,YAAY,EACb,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,KAAK,EAAE,EACP,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,UAAU,CAAC;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAwCxC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACrB;AACD,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACnC;;;OAGG;IACH,IAAI,EAAE,EAAE,CAAC;IACT,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACxC;;;;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/lib/generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,YAAY,E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M,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;KACvC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
package/dist/lib/sdk.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ResponseObject } from 'openapi3-ts/oas31';
|
|
2
2
|
import { type IR, type OurParameter, type TunedOperationObject } from '@sdk-it/spec';
|
|
3
3
|
import { type MakeImportFn } from './import-utilities.ts';
|
|
4
|
-
export type Parser = 'chunked' | 'buffered';
|
|
4
|
+
export type Parser = 'chunked' | 'buffered' | 'sse';
|
|
5
5
|
export interface SdkConfig {
|
|
6
6
|
/**
|
|
7
7
|
* The name of the sdk client
|
package/dist/lib/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/lib/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIvE,OAAO,EACL,KAAK,EAAE,EAEP,KAAK,YAAY,EACjB,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/lib/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,K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nC,SAAS,EAAE,SAAS;;EA2CrB;AA0GD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,EAAE,EACR,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,cAAc,EACxB,YAAY,UAAO,YAqCpB;AAiED,wBAAgB,WAAW,CACzB,SAAS,EAAE,oBAAoB,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC;;;;;EA8BvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-urls.d.ts","sourceRoot":"","sources":["../../src/lib/server-urls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CA0BlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-map.d.ts","sourceRoot":"","sources":["../../src/lib/status-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"status-map.d.ts","sourceRoot":"","sources":["../../src/lib/status-map.ts"],"names":[],"mappings":"wBAwBK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;AAxB3B,wBAwB4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-snippet.d.ts","sourceRoot":"","sources":["../../src/lib/typescript-snippet.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,KAAK,EAAE,EACP,KAAK,cAAc,EAEnB,KAAK,oBAAoB,EAI1B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"typescript-snippet.d.ts","sourceRoot":"","sources":["../../src/lib/typescript-snippet.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,KAAK,EAAE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0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"!**/*.test.*"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@sdk-it/core": "0.
|
|
25
|
+
"@sdk-it/core": "0.41.0",
|
|
26
26
|
"openapi3-ts": "^4.4.0",
|
|
27
27
|
"stringcase": "^4.3.1",
|
|
28
28
|
"lodash-es": "^4.17.21",
|
|
29
29
|
"npm-run-path": "6.0.0",
|
|
30
|
-
"@sdk-it/spec": "0.
|
|
31
|
-
"@sdk-it/readme": "0.
|
|
30
|
+
"@sdk-it/spec": "0.41.0",
|
|
31
|
+
"@sdk-it/readme": "0.41.0"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/connect.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=connect.d.ts.map
|
package/dist/connect.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":""}
|
package/dist/global.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=global.d.js.map
|
package/dist/global.d.js.map
DELETED
package/dist/lib/connect.d.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import type { InjectImport, NaunceResponseAnalyzer, OnOperation, ResponseAnalyzerFn } from '@sdk-it/core';
|
|
3
|
-
import type { TypeScriptGeneratorOptions } from './options.ts';
|
|
4
|
-
/**
|
|
5
|
-
* Options for the connect function
|
|
6
|
-
*/
|
|
7
|
-
export interface ConnectOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Path to the backend project's tsconfig.json
|
|
10
|
-
* This tsconfig should include all source files that contain route definitions
|
|
11
|
-
*/
|
|
12
|
-
tsconfigPath: string;
|
|
13
|
-
/**
|
|
14
|
-
* Framework-specific response analyzer
|
|
15
|
-
*
|
|
16
|
-
* Use the appropriate analyzer for your backend framework:
|
|
17
|
-
* - `@sdk-it/generic` - Generic analyzer (default, works with most frameworks)
|
|
18
|
-
* - `@sdk-it/hono` - Hono framework specific analyzer
|
|
19
|
-
*
|
|
20
|
-
* Or provide a custom analyzer function
|
|
21
|
-
*
|
|
22
|
-
* @default responseAnalyzer from @sdk-it/generic
|
|
23
|
-
*/
|
|
24
|
-
responseAnalyzer?: ResponseAnalyzerFn | NaunceResponseAnalyzer;
|
|
25
|
-
/**
|
|
26
|
-
* Custom type mappings for OpenAPI generation
|
|
27
|
-
* Maps TypeScript types to OpenAPI schema types
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* typesMap: {
|
|
32
|
-
* 'Date': 'string',
|
|
33
|
-
* 'Buffer': 'string'
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
typesMap?: Record<string, string>;
|
|
38
|
-
/**
|
|
39
|
-
* Name for the generated client class
|
|
40
|
-
*
|
|
41
|
-
* @default 'APIClient'
|
|
42
|
-
*/
|
|
43
|
-
clientName?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Custom output directory for generated files
|
|
46
|
-
* If not specified, generates to node_modules/.sdk-it/[hash]
|
|
47
|
-
*
|
|
48
|
-
* The hash is derived from the tsconfigPath to ensure stable location
|
|
49
|
-
* across regenerations while keeping files hidden from the user
|
|
50
|
-
*/
|
|
51
|
-
outputDir?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Additional imports to inject before resolving Zod schemas
|
|
54
|
-
* Useful when your validation schemas reference external types or utilities
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* imports: [
|
|
59
|
-
* { module: '../types', named: ['CustomType'] },
|
|
60
|
-
* { module: 'zod', named: ['z'] }
|
|
61
|
-
* ]
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
imports?: InjectImport[];
|
|
65
|
-
/**
|
|
66
|
-
* Custom operation handler
|
|
67
|
-
* Called for each detected API operation, allowing you to customize
|
|
68
|
-
* the generated OpenAPI operation object
|
|
69
|
-
*/
|
|
70
|
-
onOperation?: OnOperation;
|
|
71
|
-
/**
|
|
72
|
-
* OpenAPI spec metadata
|
|
73
|
-
*/
|
|
74
|
-
info?: {
|
|
75
|
-
/**
|
|
76
|
-
* API title
|
|
77
|
-
* @default clientName or 'API Client'
|
|
78
|
-
*/
|
|
79
|
-
title?: string;
|
|
80
|
-
/**
|
|
81
|
-
* API version
|
|
82
|
-
* @default '1.0.0'
|
|
83
|
-
*/
|
|
84
|
-
version?: string;
|
|
85
|
-
/**
|
|
86
|
-
* API description
|
|
87
|
-
*/
|
|
88
|
-
description?: string;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Generation options (advanced)
|
|
92
|
-
* Allows fine-grained control over SDK generation
|
|
93
|
-
*/
|
|
94
|
-
generatorOptions?: Partial<Pick<TypeScriptGeneratorOptions, 'useTsExtension' | 'pagination' | 'style' | 'formatCode' | 'cleanup'>>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Result of the connect function
|
|
98
|
-
*/
|
|
99
|
-
export interface ConnectResult {
|
|
100
|
-
/**
|
|
101
|
-
* Absolute path to the generated client.ts file
|
|
102
|
-
* Import this to use the API client
|
|
103
|
-
*/
|
|
104
|
-
clientPath: string;
|
|
105
|
-
/**
|
|
106
|
-
* Absolute path to the generated index.ts file
|
|
107
|
-
* Barrel export file that re-exports all public APIs
|
|
108
|
-
*/
|
|
109
|
-
indexPath: string;
|
|
110
|
-
/**
|
|
111
|
-
* Absolute path to the output directory
|
|
112
|
-
* Contains all generated SDK files
|
|
113
|
-
*/
|
|
114
|
-
outputDir: string;
|
|
115
|
-
/**
|
|
116
|
-
* The generated OpenAPI specification
|
|
117
|
-
* Useful for debugging or further processing
|
|
118
|
-
*/
|
|
119
|
-
openapi: OpenAPIObject;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Connect to a backend TypeScript project and generate a typed SDK client
|
|
123
|
-
*
|
|
124
|
-
* This function:
|
|
125
|
-
* 1. Analyzes your backend TypeScript code to extract API routes and types
|
|
126
|
-
* 2. Generates an OpenAPI specification from the analyzed code
|
|
127
|
-
* 3. Generates a fully-typed TypeScript SDK client
|
|
128
|
-
* 4. Outputs the SDK to node_modules/.sdk-it/[hash] (hidden from user)
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```ts
|
|
132
|
-
* import { connect } from '@sdk-it/typescript/connect';
|
|
133
|
-
*
|
|
134
|
-
* // Generate SDK from backend project
|
|
135
|
-
* const result = await connect({
|
|
136
|
-
* tsconfigPath: '../backend/tsconfig.json',
|
|
137
|
-
* clientName: 'MyAPIClient',
|
|
138
|
-
* });
|
|
139
|
-
*
|
|
140
|
-
* // Import and use the generated client
|
|
141
|
-
* const { MyAPIClient } = await import(result.indexPath);
|
|
142
|
-
* const client = new MyAPIClient({ baseUrl: 'http://localhost:3000' });
|
|
143
|
-
* const data = await client.users.getUser({ userId: '123' });
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
146
|
-
* @example With Hono framework
|
|
147
|
-
* ```ts
|
|
148
|
-
* import { connect } from '@sdk-it/typescript/connect';
|
|
149
|
-
* import { responseAnalyzer } from '@sdk-it/hono';
|
|
150
|
-
*
|
|
151
|
-
* const result = await connect({
|
|
152
|
-
* tsconfigPath: '../api/tsconfig.json',
|
|
153
|
-
* responseAnalyzer, // Use Hono-specific analyzer
|
|
154
|
-
* clientName: 'HonoAPIClient',
|
|
155
|
-
* });
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* @param options - Configuration options for SDK generation
|
|
159
|
-
* @returns Promise resolving to paths and metadata of generated SDK
|
|
160
|
-
*/
|
|
161
|
-
export declare function connect(options: ConnectOptions): Promise<ConnectResult>;
|
|
162
|
-
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/lib/connect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAQtB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,kBAAkB,GAAG,sBAAsB,CAAC;IAE/D;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;OAEG;IACH,IAAI,CAAC,EAAE;QACL;;;WAGG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;QAEf;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IAEF;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CACxB,IAAI,CACF,0BAA0B,EAC1B,gBAAgB,GAAG,YAAY,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CACrE,CACF,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,EAAE,aAAa,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CA0D7E"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
|
-
/**
|
|
3
|
-
* Generate README.md documentation directly from OpenAPI spec
|
|
4
|
-
*/
|
|
5
|
-
export declare function generateReadme(spec: OpenAPIObject, settings: {
|
|
6
|
-
name: string;
|
|
7
|
-
}): string;
|
|
8
|
-
//# sourceMappingURL=readme-generator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readme-generator.d.ts","sourceRoot":"","sources":["../../src/lib/readme-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EASd,MAAM,mBAAmB,CAAC;AAK3B;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB,MAAM,CAoFR"}
|
package/dist/lib/statusMap.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statusMap.d.ts","sourceRoot":"","sources":["../../src/lib/statusMap.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuBnD,CAAC"}
|
package/dist/lib/utils.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare function mergeImports(...imports: Import[]): Import[];
|
|
2
|
-
export interface Import {
|
|
3
|
-
isTypeOnly?: boolean;
|
|
4
|
-
moduleSpecifier: string;
|
|
5
|
-
defaultImport?: string | undefined;
|
|
6
|
-
namedImports: NamedImport[];
|
|
7
|
-
namespaceImport?: string | undefined;
|
|
8
|
-
}
|
|
9
|
-
export interface NamedImport {
|
|
10
|
-
name: string;
|
|
11
|
-
alias?: string;
|
|
12
|
-
isTypeOnly?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare function importsToString(...imports: Import[]): string[];
|
|
15
|
-
export declare function useImports(content: string, ...imports: Import[]): string[];
|
|
16
|
-
export type MakeImportFn = (moduleSpecifier: string) => string;
|
|
17
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,YAsBhD;AAED,MAAM,WAAW,MAAM;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,YAenD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,YAe/D;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC"}
|
package/dist/lib/watcher.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/lib/watcher.ts"],"names":[],"mappings":"AAGA,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,2EAOjC"}
|
package/dist/src/index.js
DELETED
package/dist/src/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './lib/generate.js';\nexport * from './lib/generator.js';\nexport * from './lib/sdk.js';\nexport * from './lib/typescript-snippet.js';\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { camelcase } from "stringcase";
|
|
2
|
-
import {
|
|
3
|
-
forEachOperation
|
|
4
|
-
} from "@sdk-it/spec";
|
|
5
|
-
function generateAISDKTools(ir) {
|
|
6
|
-
const groups = {};
|
|
7
|
-
forEachOperation(ir, (entry, operation) => {
|
|
8
|
-
const tagDef = ir.tags.find((tag) => tag.name === entry.tag);
|
|
9
|
-
if (!tagDef) {
|
|
10
|
-
console.warn(`No tag details found for tag: ${entry.tag}`);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
groups[entry.tag] ??= {
|
|
14
|
-
tools: [],
|
|
15
|
-
instructions: "",
|
|
16
|
-
displayName: "",
|
|
17
|
-
name: ""
|
|
18
|
-
};
|
|
19
|
-
groups[entry.tag].tools.push(createTool(entry, operation));
|
|
20
|
-
groups[entry.tag].instructions = tagDef["x-instructions"];
|
|
21
|
-
groups[entry.tag].name = tagDef.name;
|
|
22
|
-
groups[entry.tag].displayName = tagDef["x-name"];
|
|
23
|
-
});
|
|
24
|
-
const imports = [
|
|
25
|
-
`import { z } from 'zod';`,
|
|
26
|
-
`import { tool } from 'ai';`,
|
|
27
|
-
`import * as schemas from './inputs/index.ts';`
|
|
28
|
-
];
|
|
29
|
-
const agent = Object.entries(groups).map(
|
|
30
|
-
([group, { instructions, tools, displayName }]) => {
|
|
31
|
-
return `export const ${camelcase(group)} = {
|
|
32
|
-
name: '${displayName}',
|
|
33
|
-
instructions: \`${instructions}\`,
|
|
34
|
-
tools: { ${tools.join(", ")} }
|
|
35
|
-
}`;
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
return [...imports, ...agent].join("\n\n");
|
|
39
|
-
}
|
|
40
|
-
function createTool(entry, operation) {
|
|
41
|
-
const schemaName = camelcase(`${operation.operationId} schema`);
|
|
42
|
-
const toolInfo = operation["x-tool"];
|
|
43
|
-
return `'${toolInfo?.name || operation["x-fn-name"]}': tool({
|
|
44
|
-
description: \`${toolInfo?.description || operation.description || operation.summary}\`,
|
|
45
|
-
inputSchema: schemas.${schemaName},
|
|
46
|
-
execute: async (input, options) => {
|
|
47
|
-
console.log('Executing ${operation.operationId} tool with input:', input);
|
|
48
|
-
const context = coerceContext(options.experimental_context);
|
|
49
|
-
const response = await context.client.request(
|
|
50
|
-
'${entry.method.toUpperCase()} ${entry.path}' ,
|
|
51
|
-
input,
|
|
52
|
-
);
|
|
53
|
-
return JSON.stringify(response);
|
|
54
|
-
},
|
|
55
|
-
})`;
|
|
56
|
-
}
|
|
57
|
-
export {
|
|
58
|
-
generateAISDKTools
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=ai-sdk.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/agent/ai-sdk.ts"],
|
|
4
|
-
"sourcesContent": ["import { camelcase } from 'stringcase';\n\nimport {\n type IR,\n type OperationEntry,\n type TunedOperationObject,\n forEachOperation,\n} from '@sdk-it/spec';\n\nexport function generateAISDKTools(ir: IR) {\n const groups: Record<\n string,\n {\n tools: string[];\n instructions: string;\n displayName: string;\n name: string;\n }\n > = {};\n forEachOperation(ir, (entry, operation) => {\n const tagDef = ir.tags.find((tag) => tag.name === entry.tag);\n if (!tagDef) {\n console.warn(`No tag details found for tag: ${entry.tag}`);\n return;\n }\n\n groups[entry.tag] ??= {\n tools: [],\n instructions: '',\n displayName: '',\n name: '',\n };\n groups[entry.tag].tools.push(createTool(entry, operation));\n groups[entry.tag].instructions = tagDef['x-instructions'];\n groups[entry.tag].name = tagDef.name;\n groups[entry.tag].displayName = tagDef['x-name'];\n });\n const imports = [\n `import { z } from 'zod';`,\n `import { tool } from 'ai';`,\n `import * as schemas from './inputs/index.ts';`,\n ];\n const agent = Object.entries(groups).map(\n ([group, { instructions, tools, displayName }]) => {\n return `export const ${camelcase(group)} = {\n name: '${displayName}',\n instructions: \\`${instructions}\\`,\n tools: { ${tools.join(', ')} }\n }`;\n },\n );\n\n return [...imports, ...agent].join('\\n\\n');\n}\n\nfunction createTool(entry: OperationEntry, operation: TunedOperationObject) {\n const schemaName = camelcase(`${operation.operationId} schema`);\n const toolInfo = operation['x-tool'];\n return `'${toolInfo?.name || operation['x-fn-name']}': tool({\n description: \\`${toolInfo?.description || operation.description || operation.summary}\\`,\n inputSchema: schemas.${schemaName},\n\t\t\texecute: async (input, options) => {\n\t\t\t\tconsole.log('Executing ${operation.operationId} tool with input:', input);\n const context = coerceContext(options.experimental_context);\n const response = await context.client.request(\n '${entry.method.toUpperCase()} ${entry.path}' ,\n input,\n );\n return JSON.stringify(response);\n },\n })`;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAE1B;AAAA,EAIE;AAAA,OACK;AAEA,SAAS,mBAAmB,IAAQ;AACzC,QAAM,SAQF,CAAC;AACL,mBAAiB,IAAI,CAAC,OAAO,cAAc;AACzC,UAAM,SAAS,GAAG,KAAK,KAAK,CAAC,QAAQ,IAAI,SAAS,MAAM,GAAG;AAC3D,QAAI,CAAC,QAAQ;AACX,cAAQ,KAAK,iCAAiC,MAAM,GAAG,EAAE;AACzD;AAAA,IAC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
|
-
} from "@sdk-it/spec";
|
|
5
|
-
function generateOpenAIAgentTools(spec) {
|
|
6
|
-
const groups = {};
|
|
7
|
-
forEachOperation(spec, (entry, operation) => {
|
|
8
|
-
groups[entry.tag] ??= [];
|
|
9
|
-
groups[entry.tag].push(createTool(entry, operation));
|
|
10
|
-
});
|
|
11
|
-
const imports = [
|
|
12
|
-
`import { z } from 'zod';`,
|
|
13
|
-
`import { tool } from '@openai/agents';`,
|
|
14
|
-
`import * as schemas from './inputs/index.ts';`
|
|
15
|
-
];
|
|
16
|
-
const tools = Object.entries(groups).map(([group, tools2]) => {
|
|
17
|
-
return `export const ${spinalcase(group)} = [${tools2.join(", ")}];`;
|
|
18
|
-
});
|
|
19
|
-
return [...imports, ...tools].join("\n\n");
|
|
20
|
-
}
|
|
21
|
-
function createTool(entry, operation) {
|
|
22
|
-
const schemaName = camelcase(`${operation.operationId} schema`);
|
|
23
|
-
return `tool({
|
|
24
|
-
description: \`${operation.description || operation.summary}\`,
|
|
25
|
-
name: '${operation["x-fn-name"]}',
|
|
26
|
-
parameters: makeOptionalPropsNullable(schemas.${schemaName}),
|
|
27
|
-
execute: async (input, maybeContext) => {
|
|
28
|
-
console.log('Executing ${operation.operationId} tool with input:', input);
|
|
29
|
-
const context = coerceContext(maybeContext?.context);
|
|
30
|
-
const client = context.client;
|
|
31
|
-
const response = await client.request(
|
|
32
|
-
'${entry.method.toUpperCase()} ${entry.path}' ,
|
|
33
|
-
input as any,
|
|
34
|
-
);
|
|
35
|
-
return JSON.stringify(response);
|
|
36
|
-
},
|
|
37
|
-
})`;
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
generateOpenAIAgentTools
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=openai-agents.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/agent/openai-agents.ts"],
|
|
4
|
-
"sourcesContent": ["import { camelcase, spinalcase } from 'stringcase';\n\nimport {\n type IR,\n type OperationEntry,\n type TunedOperationObject,\n forEachOperation,\n} from '@sdk-it/spec';\n\nexport function generateOpenAIAgentTools(spec: IR) {\n const groups: Record<string, string[]> = {};\n forEachOperation(spec, (entry, operation) => {\n groups[entry.tag] ??= [];\n groups[entry.tag].push(createTool(entry, operation));\n });\n const imports = [\n `import { z } from 'zod';`,\n `import { tool } from '@openai/agents';`,\n `import * as schemas from './inputs/index.ts';`,\n ];\n const tools = Object.entries(groups).map(([group, tools]) => {\n return `export const ${spinalcase(group)} = [${tools.join(', ')}];`;\n });\n\n return [...imports, ...tools].join('\\n\\n');\n}\n\nfunction createTool(entry: OperationEntry, operation: TunedOperationObject) {\n const schemaName = camelcase(`${operation.operationId} schema`);\n return `tool({\n description: \\`${operation.description || operation.summary}\\`,\n name: '${operation['x-fn-name']}',\n parameters: makeOptionalPropsNullable(schemas.${schemaName}),\n\t\t\texecute: async (input, maybeContext) => {\n\t\t\t\tconsole.log('Executing ${operation.operationId} tool with input:', input);\n const context = coerceContext(maybeContext?.context);\n const client = context.client;\n const response = await client.request(\n '${entry.method.toUpperCase()} ${entry.path}' ,\n input as any,\n );\n return JSON.stringify(response);\n },\n })`;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,kBAAkB;AAEtC;AAAA,EAIE;AAAA,OACK;AAEA,SAAS,yBAAyB,MAAU;AACjD,QAAM,SAAmC,CAAC;AAC1C,mBAAiB,MAAM,CAAC,OAAO,cAAc;AAC3C,WAAO,MAAM,GAAG,MAAM,CAAC;AACvB,WAAO,MAAM,GAAG,EAAE,KAAK,WAAW,OAAO,SAAS,CAAC;AAAA,EACrD,CAAC;AACD,QAAM,UAAU;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,QAAQ,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,OAAOA,MAAK,MAAM;AAC3D,WAAO,gBAAgB,WAAW,KAAK,CAAC,OAAOA,OAAM,KAAK,IAAI,CAAC;AAAA,EACjE,CAAC;AAED,SAAO,CAAC,GAAG,SAAS,GAAG,KAAK,EAAE,KAAK,MAAM;AAC3C;AAEA,SAAS,WAAW,OAAuB,WAAiC;AAC1E,QAAM,aAAa,UAAU,GAAG,UAAU,WAAW,SAAS;AAC9D,SAAO;AAAA,uBACc,UAAU,eAAe,UAAU,OAAO;AAAA,eAClD,UAAU,WAAW,CAAC;AAAA,sDACiB,UAAU;AAAA;AAAA,6BAEnC,UAAU,WAAW;AAAA;AAAA;AAAA;AAAA,aAIrC,MAAM,OAAO,YAAY,CAAC,IAAI,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAMrD;",
|
|
6
|
-
"names": ["tools"]
|
|
7
|
-
}
|