@sdk-it/typescript 0.47.0 → 0.47.2

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 CHANGED
@@ -236,6 +236,29 @@ await generate(spec, {
236
236
  });
237
237
  ```
238
238
 
239
+ ## Regenerate into the same folder
240
+
241
+ Each run writes `metadata.json` into the source folder (`output`, or
242
+ `<output>/src` in `full` mode). It lists the files that the run generated
243
+ (`generatedFiles`) and globs for your own files (`userFiles`, by default
244
+ `/dist/**`, `/build/**` and `/readme.md`), relative to that folder. The next
245
+ run deletes every file that it does not write and that no `userFiles` glob
246
+ matches, an `index.ts` included, so the files of a folder that a newer version
247
+ or a changed spec no longer generates go away. `package.json`, `tsconfig*.json` and
248
+ `metadata.json` stay.
249
+
250
+ To keep a file of your own, add its glob to `userFiles`:
251
+
252
+ ```json
253
+ {
254
+ "userFiles": ["/dist/**", "/build/**", "/readme.md", "/models/extra/**"]
255
+ }
256
+ ```
257
+
258
+ The generated index files export the user files that stay. `cleanup: false`
259
+ keeps every file in the folder, including the ones that the spec no longer
260
+ generates.
261
+
239
262
  ## Framework integrations
240
263
 
241
264
  - [React Query](../../docs/react-query.md)
package/dist/index.js CHANGED
@@ -686,7 +686,7 @@ var ZodEmitter = class {
686
686
  #array(schema, required = false) {
687
687
  const { items } = schema;
688
688
  if (!items) {
689
- return `z.array(z.unknown())${appendOptional2(required)}`;
689
+ return `z.array(z.unknown())${arrayLimits(schema)}${appendOptional2(required)}`;
690
690
  }
691
691
  if (Array.isArray(items)) {
692
692
  const tupleItems = items.map((sub) => this.handle(sub, true));
@@ -694,7 +694,7 @@ var ZodEmitter = class {
694
694
  return `${base}${appendOptional2(required)}`;
695
695
  }
696
696
  const itemsSchema = this.handle(items, true);
697
- return `z.array(${itemsSchema})${this.#suffixes(JSON.stringify(schema.default), required, false)}`;
697
+ return `z.array(${itemsSchema})${arrayLimits(schema)}${this.#suffixes(JSON.stringify(schema.default), required, false)}`;
698
698
  }
699
699
  #suffixes = (defaultValue, required, nullable) => {
700
700
  return `${nullable ? ".nullable()" : ""}${appendOptional2(required)}${appendDefault(defaultValue)}`;
@@ -951,6 +951,16 @@ function appendOptional2(isRequired) {
951
951
  function appendDefault(defaultValue) {
952
952
  return defaultValue !== void 0 || typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
953
953
  }
954
+ function arrayLimits(schema) {
955
+ let limits = "";
956
+ if (typeof schema.minItems === "number") {
957
+ limits += `.min(${schema.minItems})`;
958
+ }
959
+ if (typeof schema.maxItems === "number") {
960
+ limits += `.max(${schema.maxItems})`;
961
+ }
962
+ return limits;
963
+ }
954
964
  function stringLimits(schema) {
955
965
  let limits = "";
956
966
  if (typeof schema.minLength === "number") {
@@ -2738,8 +2748,7 @@ async function generate(openapi, settings) {
2738
2748
  await cleanFiles(metadata, output, [
2739
2749
  "/tsconfig*.json",
2740
2750
  "/package.json",
2741
- "/metadata.json",
2742
- "/**/index.ts"
2751
+ "/metadata.json"
2743
2752
  ]);
2744
2753
  }
2745
2754
  const listed = await readFolder(output, true);
@@ -2787,7 +2796,7 @@ async function generate(openapi, settings) {
2787
2796
  }
2788
2797
  },
2789
2798
  dependencies: {
2790
- "fast-content-type-parse": "^3.0.0",
2799
+ "fast-content-type-parse": "^4.0.1",
2791
2800
  zod: "^4.6.7",
2792
2801
  ...settings.agentTools === "ai-sdk" ? { ai: "^7.0.29" } : {},
2793
2802
  ...settings.agentTools === "openai-agents" ? { "@openai/agents": "^0.21.0" } : {}