svelte-reflector 1.0.26 → 1.0.28

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/method.js CHANGED
@@ -55,7 +55,7 @@ export class Method {
55
55
  const paths = this.gee(this.paths);
56
56
  const cookies = this.gee(this.cookies);
57
57
  return `
58
- ${querys.length > 0 ? `const querys = this.querys.bundle()` : ""};
58
+ ${querys.length > 0 ? `const { ${querys} } = this.querys.bundle()` : ""};
59
59
  ${paths.length > 0 ? `const paths = this.paths.bundle()` : ""};
60
60
  ${cookies.length > 0 ? `const cookies = this.cookies.bundle()` : ""};
61
61
  `;
package/dist/module.js CHANGED
@@ -29,15 +29,6 @@ export class Module {
29
29
  moduleName: this.name,
30
30
  });
31
31
  });
32
- // // não vão entrar metodos que não tiverem uma resposta tipada
33
- // this.methods = methods.filter((op) => {
34
- // const responseTypeOk = op.request.responseType;
35
- // if (op.request.apiType === "delete") return true;
36
- // if (!responseTypeOk) {
37
- // createDangerMessage(`Método [ ${op.name} ] do módulo [ ${this.moduleName} ] sem tipagem na resposta.`);
38
- // }
39
- // return responseTypeOk;
40
- // });
41
32
  const { cookies, headers, paths, querys } = this.getParameters();
42
33
  const { moduleAttributes, moduleTypes, moduleInit, moduleClear, form } = this.creator({ cookies, headers, paths, querys });
43
34
  this.moduleConstructor = this.buildConstructor(form);
@@ -6,6 +6,7 @@ export declare class ObjectProp {
6
6
  constructor(params: {
7
7
  referenceObject: ReferenceObject;
8
8
  name: string;
9
+ isRequired?: boolean;
9
10
  });
10
11
  constructorBuild(): string;
11
12
  classBuild(): string;
@@ -3,10 +3,10 @@ export class ObjectProp {
3
3
  type;
4
4
  required;
5
5
  constructor(params) {
6
- const { referenceObject, name } = params;
6
+ const { referenceObject, name, isRequired } = params;
7
7
  this.name = name;
8
8
  this.type = referenceObject.$ref.split("/").at(-1) ?? "";
9
- this.required = true; // tem que ver isso daí
9
+ this.required = isRequired ?? true; // tem que ver isso daí
10
10
  }
11
11
  constructorBuild() {
12
12
  return `this.${this.name} = new ${this.type}(params?.${this.name})`;
@@ -10,9 +10,11 @@ export class PrimitiveProp {
10
10
  const { example: rawExample, type: rawType } = schemaObject;
11
11
  const type = rawType ?? "string";
12
12
  const example = rawExample ?? this.getEmptyExample({ type, schemaObject });
13
+ // const buildedType = required ? type : `${type} | undefined`;
14
+ const buildedType = type;
13
15
  this.name = this.treatName(name);
14
16
  this.rawType = type ?? "any";
15
- this.type = `BuildedInput<${type}>`;
17
+ this.type = `BuildedInput<${buildedType}>`;
16
18
  this.required = required;
17
19
  this.buildedConst = this.buildConst({ example, name: this.name, required, type });
18
20
  }
package/dist/schema.js CHANGED
@@ -17,7 +17,14 @@ export class Schema {
17
17
  this.name = `${isEmpty ? "Empty" : ""}${name}`;
18
18
  for (const [key, value] of Object.entries(properties)) {
19
19
  if ("$ref" in value || !value?.type) {
20
- if ("$ref" in value) {
20
+ if ("allOf" in value) {
21
+ const ref = value.allOf?.[0];
22
+ const isRequired = !!value.nullable;
23
+ if (ref && "$ref" in ref) {
24
+ this.objectProps.push(new ObjectProp({ name: key, referenceObject: ref, isRequired }));
25
+ }
26
+ }
27
+ else if ("$ref" in value) {
21
28
  this.objectProps.push(new ObjectProp({ name: key, referenceObject: value }));
22
29
  }
23
30
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-reflector",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "Reflects zod types from openAPI schemas",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",