svelte-reflector 1.0.4 → 1.0.6
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 +2 -0
- package/dist/module.d.ts +1 -1
- package/dist/module.js +9 -7
- package/package.json +1 -1
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
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) => {
|
|
@@ -30,10 +30,10 @@ export class Module {
|
|
|
30
30
|
if (!responseTypeOk) {
|
|
31
31
|
createDangerMessage(`Método [ ${op.name} ] do módulo [ ${this.moduleName} ] sem tipagem na resposta.`);
|
|
32
32
|
}
|
|
33
|
-
else if (!propertiesOk) {
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return responseTypeOk
|
|
33
|
+
// else if (!propertiesOk) {
|
|
34
|
+
// createDangerMessage(`Método [ ${op.name} ] do módulo [ ${this.moduleName} ] com tipagem incorreta.`);
|
|
35
|
+
// }
|
|
36
|
+
return responseTypeOk;
|
|
37
37
|
});
|
|
38
38
|
this.parameters = this.getParameters();
|
|
39
39
|
const { moduleAtributes, moduleTypes } = this.creator();
|
|
@@ -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(";")}
|