@sdk-it/typescript 0.45.0 → 0.46.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 +17 -10
- package/dist/index.js.map +2 -2
- package/dist/lib/emitters/interface.d.ts +1 -1
- package/dist/lib/emitters/interface.d.ts.map +1 -1
- package/dist/lib/emitters/zod.d.ts.map +1 -1
- package/dist/lib/generate.d.ts.map +1 -1
- package/dist/lib/pagination-emit.d.ts.map +1 -1
- package/dist/lib/sdk.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -66,7 +66,7 @@ function createTool(entry, operation) {
|
|
|
66
66
|
inputSchema: schemas.${schemaName},
|
|
67
67
|
execute: async (input, options) => {
|
|
68
68
|
console.log('Executing ${operation.operationId} tool with input:', input);
|
|
69
|
-
const context = coerceContext(options.
|
|
69
|
+
const context = coerceContext(options.context);
|
|
70
70
|
const response = await context.client.request(
|
|
71
71
|
'${entry.method.toUpperCase()} ${entry.path}' ,
|
|
72
72
|
input,
|
|
@@ -117,7 +117,7 @@ function createTool2(entry, operation) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// packages/typescript/src/lib/agent/utils.txt
|
|
120
|
-
var utils_default = "function coerceContext(context?: any) {\n if (!context) {\n throw new Error('Context is required');\n }\n return context as {\n client: any\n };\n}\n/**\n * Takes a Zod object schema and makes all optional properties nullable as well.\n * This is useful for APIs where optional fields can be explicitly set to null.\n *\n * @param schema - The Zod object schema to transform\n * @returns A new Zod schema with optional properties made nullable\n */\nfunction makeOptionalPropsNullable<T extends z.ZodRawShape>(\n schema: z.ZodObject<T>,\n) {\n const shape = schema.shape;\n const newShape = {} as Record<string, z.ZodType>;\n\n for (const [key, value] of Object.entries(shape)) {\n if (value instanceof z.ZodOptional) {\n // Make optional properties also nullable\n newShape[key] = value.
|
|
120
|
+
var utils_default = "function coerceContext(context?: any) {\n if (!context) {\n throw new Error('Context is required');\n }\n return context as {\n client: any\n };\n}\n/**\n * Takes a Zod object schema and makes all optional properties nullable as well.\n * This is useful for APIs where optional fields can be explicitly set to null.\n *\n * @param schema - The Zod object schema to transform\n * @returns A new Zod schema with optional properties made nullable\n */\nfunction makeOptionalPropsNullable<T extends z.ZodRawShape>(\n schema: z.ZodObject<T>,\n) {\n const shape = schema.shape;\n const newShape = {} as Record<string, z.ZodType>;\n\n for (const [key, value] of Object.entries(shape) as [string, z.ZodType][]) {\n if (value instanceof z.ZodOptional) {\n // Make optional properties also nullable\n newShape[key] = value.nullable();\n } else {\n // Keep non-optional properties as they are\n newShape[key] = value;\n }\n }\n\n return z.object(newShape);\n}\n";
|
|
121
121
|
|
|
122
122
|
// packages/typescript/src/lib/client.ts
|
|
123
123
|
import { toLitObject } from "@sdk-it/core";
|
|
@@ -619,7 +619,13 @@ export async function prepare<const E extends keyof typeof schemas>(
|
|
|
619
619
|
};
|
|
620
620
|
|
|
621
621
|
// packages/typescript/src/lib/emitters/interface.ts
|
|
622
|
-
import {
|
|
622
|
+
import {
|
|
623
|
+
followRef as followRef2,
|
|
624
|
+
isRef as isRef2,
|
|
625
|
+
parseRef as parseRef2,
|
|
626
|
+
pascalcase as pascalcase2,
|
|
627
|
+
resolveRef
|
|
628
|
+
} from "@sdk-it/core";
|
|
623
629
|
import { isPrimitiveSchema as isPrimitiveSchema2, sanitizeTag as sanitizeTag2 } from "@sdk-it/spec";
|
|
624
630
|
var TypeScriptEmitter = class {
|
|
625
631
|
#spec;
|
|
@@ -629,7 +635,7 @@ var TypeScriptEmitter = class {
|
|
|
629
635
|
#stringifyKey = (value) => {
|
|
630
636
|
return `'${value}'`;
|
|
631
637
|
};
|
|
632
|
-
object(schema,
|
|
638
|
+
object(schema, _required = false) {
|
|
633
639
|
const properties = schema.properties || {};
|
|
634
640
|
const propEntries = Object.entries(properties).map(([key, propSchema]) => {
|
|
635
641
|
const isRequired = (schema.required ?? []).includes(key);
|
|
@@ -649,7 +655,7 @@ var TypeScriptEmitter = class {
|
|
|
649
655
|
/**
|
|
650
656
|
* Handle arrays (items could be a single schema or a tuple)
|
|
651
657
|
*/
|
|
652
|
-
#array(schema,
|
|
658
|
+
#array(schema, _required = false) {
|
|
653
659
|
const { items } = schema;
|
|
654
660
|
if (!items) {
|
|
655
661
|
return "any[]";
|
|
@@ -855,9 +861,7 @@ function describe(p) {
|
|
|
855
861
|
nextPageMapping: `${p.pageNumberParamName}: nextPageParams.page, ${p.pageSizeParamName}: nextPageParams.pageSize`
|
|
856
862
|
};
|
|
857
863
|
}
|
|
858
|
-
throw new Error(
|
|
859
|
-
`Unknown pagination type: ${p.type}`
|
|
860
|
-
);
|
|
864
|
+
throw new Error(`Unknown pagination type: ${p.type}`);
|
|
861
865
|
}
|
|
862
866
|
function paginationOperation(pagination) {
|
|
863
867
|
const shape = describe(pagination);
|
|
@@ -2695,7 +2699,7 @@ function availablePaginationTypes(spec) {
|
|
|
2695
2699
|
|
|
2696
2700
|
// packages/typescript/src/lib/generate.ts
|
|
2697
2701
|
async function generate(openapi, settings) {
|
|
2698
|
-
const spec = toIR(
|
|
2702
|
+
const spec = await toIR(
|
|
2699
2703
|
{
|
|
2700
2704
|
spec: openapi,
|
|
2701
2705
|
responses: { flattenErrorResponses: true },
|
|
@@ -2860,6 +2864,7 @@ ${utils_default}`
|
|
|
2860
2864
|
name: packageName,
|
|
2861
2865
|
version: "0.0.1",
|
|
2862
2866
|
type: "module",
|
|
2867
|
+
...settings.agentTools === "ai-sdk" ? { engines: { node: ">=22" } } : {},
|
|
2863
2868
|
main: "./src/index.ts",
|
|
2864
2869
|
module: "./src/index.ts",
|
|
2865
2870
|
types: "./src/index.ts",
|
|
@@ -2876,7 +2881,9 @@ ${utils_default}`
|
|
|
2876
2881
|
},
|
|
2877
2882
|
dependencies: {
|
|
2878
2883
|
"fast-content-type-parse": "^3.0.0",
|
|
2879
|
-
zod: "^4.3.0"
|
|
2884
|
+
zod: "^4.3.0",
|
|
2885
|
+
...settings.agentTools === "ai-sdk" ? { ai: "^7.0.29" } : {},
|
|
2886
|
+
...settings.agentTools === "openai-agents" ? { "@openai/agents": "^0.13.4" } : {}
|
|
2880
2887
|
}
|
|
2881
2888
|
},
|
|
2882
2889
|
null,
|