svelte-reflector 1.0.4 → 1.0.5

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/main.js CHANGED
@@ -84,6 +84,8 @@ export class Reflector {
84
84
  this.schemaFile.changeData([`import z from 'zod';`, ...this.schemas.map((s) => `${s.schema} ${s.type}`)].join("\n\n"));
85
85
  this.schemaFile.save();
86
86
  for (const module of this.modules) {
87
+ if (module.methods.length === 0)
88
+ continue;
87
89
  module.src.save();
88
90
  }
89
91
  return {};
package/dist/module.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare class Module {
6
6
  readonly endpoint: string;
7
7
  readonly moduleName: string;
8
8
  readonly src: Source;
9
- imports: string[];
9
+ imports: Set<string>;
10
10
  parameters: string[];
11
11
  methods: Method[];
12
12
  constructor(params: {
package/dist/module.js CHANGED
@@ -14,7 +14,7 @@ export class Module {
14
14
  constructor(params) {
15
15
  const { name, operations, endpoint, dir, moduleName } = params;
16
16
  this.moduleName = moduleName;
17
- this.imports = ["// AUTO GERADO. QUEM ALTERAR GOSTA DE RAPAZES!\n", 'import repo from "$repository/main"'];
17
+ this.imports = new Set(["// AUTO GERADO. QUEM ALTERAR GOSTA DE RAPAZES!\n", 'import repo from "$repository/main"']);
18
18
  this.name = capitalizeFirstLetter(name);
19
19
  this.endpoint = endpoint;
20
20
  const methods = operations.map((operation) => {
@@ -63,9 +63,11 @@ export class Module {
63
63
  moduleAtributes.add(`entity = $state<${responseType} | undefined>()`);
64
64
  }
65
65
  else if (attributeType === "list") {
66
- this.imports.push(`import z from "zod";`);
67
66
  moduleAtributes.add(`list = $state<${responseType}[]>([])`);
68
67
  }
68
+ if (attributeType === "list" || this.parameters.length > 0) {
69
+ this.imports.add(`import z from "zod";`);
70
+ }
69
71
  }
70
72
  const formSet = new Set();
71
73
  for (const f of form) {
@@ -141,7 +143,7 @@ export class Module {
141
143
  }
142
144
  buildFile(modulesAttributes, moduleTypes) {
143
145
  return `
144
- ${this.imports.join(";")}
146
+ ${Array.from(this.imports).join(";")}
145
147
  ${this.buildImports()}
146
148
 
147
149
  ${moduleTypes.join(";")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-reflector",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Reflects zod types from openAPI schemas",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",