svelte-reflector 1.0.9 → 1.0.12
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/generate-doc.js +3 -0
- package/dist/helpers/helpers.d.ts +4 -0
- package/dist/helpers/helpers.js +38 -2
- package/dist/main.js +11 -8
- package/dist/method.d.ts +9 -4
- package/dist/method.js +68 -53
- package/dist/module.d.ts +8 -1
- package/dist/module.js +89 -23
- package/dist/property.d.ts +8 -1
- package/dist/property.js +55 -22
- package/dist/reflector/controllers/admin/account/admin-account.module.svelte.d.ts +7 -0
- package/dist/reflector/controllers/admin/account/admin-account.module.svelte.js +28 -0
- package/dist/reflector/controllers/admin/account/owner/account-owner.module.svelte.d.ts +15 -0
- package/dist/reflector/controllers/admin/account/owner/account-owner.module.svelte.js +79 -0
- package/dist/reflector/controllers/admin/kyc/config/kyc-config.module.svelte.d.ts +49 -0
- package/dist/reflector/controllers/admin/kyc/config/kyc-config.module.svelte.js +303 -0
- package/dist/reflector/controllers/admin/policy/system/policy-system.module.svelte.d.ts +9 -0
- package/dist/reflector/controllers/admin/policy/system/policy-system.module.svelte.js +36 -0
- package/dist/reflector/controllers/admin/smtp/config/smtp-config.module.svelte.d.ts +19 -0
- package/dist/reflector/controllers/admin/smtp/config/smtp-config.module.svelte.js +82 -0
- package/dist/reflector/controllers/customer/kyc/file-upload/kyc-file-upload.module.svelte.d.ts +37 -0
- package/dist/reflector/controllers/customer/kyc/file-upload/kyc-file-upload.module.svelte.js +228 -0
- package/dist/reflector/controllers/member/account/member-account.module.svelte.d.ts +11 -0
- package/dist/reflector/controllers/member/account/member-account.module.svelte.js +54 -0
- package/dist/reflector/controllers/owner/account/owner-account.module.svelte.d.ts +11 -0
- package/dist/reflector/controllers/owner/account/owner-account.module.svelte.js +54 -0
- package/dist/reflector/controllers/owner/kyc/config/kyc-config.module.svelte.d.ts +49 -0
- package/dist/reflector/controllers/owner/kyc/config/kyc-config.module.svelte.js +303 -0
- package/dist/reflector/controllers/owner/kyc/self/create-or-update/self-create-or-update.module.svelte.d.ts +33 -0
- package/dist/reflector/controllers/owner/kyc/self/create-or-update/self-create-or-update.module.svelte.js +197 -0
- package/dist/reflector/controllers/owner/policy/owner-policy.module.svelte.d.ts +9 -0
- package/dist/reflector/controllers/owner/policy/owner-policy.module.svelte.js +36 -0
- package/dist/reflector/controllers/owner/smtp/config/smtp-config.module.svelte.d.ts +19 -0
- package/dist/reflector/controllers/owner/smtp/config/smtp-config.module.svelte.js +82 -0
- package/dist/reflector/controllers/public/auth/sign-in-firebase/auth-sign-in-firebase.module.svelte.d.ts +29 -0
- package/dist/reflector/controllers/public/auth/sign-in-firebase/auth-sign-in-firebase.module.svelte.js +223 -0
- package/dist/reflector/controllers/public/reset-password/tenant/send-recovery-email/tenant-send-recovery-email.module.svelte.d.ts +13 -0
- package/dist/reflector/controllers/public/reset-password/tenant/send-recovery-email/tenant-send-recovery-email.module.svelte.js +49 -0
- package/dist/reflector/controllers/restricted/account/avatar-file-upload/account-avatar-file-upload.module.svelte.d.ts +19 -0
- package/dist/reflector/controllers/restricted/account/avatar-file-upload/account-avatar-file-upload.module.svelte.js +114 -0
- package/dist/reflector/controllers/restricted/bank/restricted-bank.module.svelte.d.ts +15 -0
- package/dist/reflector/controllers/restricted/bank/restricted-bank.module.svelte.js +78 -0
- package/dist/reflector/controllers/restricted/files/presigned-url/files-presigned-url.module.svelte.d.ts +11 -0
- package/dist/reflector/controllers/restricted/files/presigned-url/files-presigned-url.module.svelte.js +56 -0
- package/dist/reflector/controllers/restricted/notification/restricted-notification.module.svelte.d.ts +9 -0
- package/dist/reflector/controllers/restricted/notification/restricted-notification.module.svelte.js +36 -0
- package/dist/reflector/controllers/restricted/two-factor-auth/status/two-factor-auth-status.module.svelte.d.ts +15 -0
- package/dist/reflector/controllers/restricted/two-factor-auth/status/two-factor-auth-status.module.svelte.js +68 -0
- package/dist/reflector/reflector.types.d.ts +4 -0
- package/dist/reflector/reflector.types.js +4 -0
- package/dist/reflector/schemas.d.ts +357 -0
- package/dist/reflector/schemas.js +1709 -0
- package/dist/request.d.ts +2 -0
- package/dist/request.js +8 -0
- package/dist/schema.d.ts +4 -1
- package/dist/schema.js +24 -6
- package/dist/zodProperty.d.ts +32 -0
- package/dist/zodProperty.js +123 -0
- package/package.json +1 -1
package/dist/request.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ParameterObject } from "./types/open-api-spec.interface.js";
|
|
1
2
|
import type { ApiType, ReflectorOperation } from "./types/types.js";
|
|
2
3
|
type ReflectorRequestType = "entity" | "list" | "pagination" | "form" | "other";
|
|
3
4
|
export declare class Request {
|
|
@@ -5,6 +6,7 @@ export declare class Request {
|
|
|
5
6
|
readonly apiType: ApiType;
|
|
6
7
|
bodyType?: string;
|
|
7
8
|
responseType?: string;
|
|
9
|
+
parameters: ParameterObject[];
|
|
8
10
|
constructor(operation: ReflectorOperation);
|
|
9
11
|
private getTypeFromRequestBody;
|
|
10
12
|
private getTypeFromResponses;
|
package/dist/request.js
CHANGED
|
@@ -6,8 +6,16 @@ export class Request {
|
|
|
6
6
|
apiType;
|
|
7
7
|
bodyType;
|
|
8
8
|
responseType;
|
|
9
|
+
parameters = [];
|
|
10
|
+
// inType:
|
|
9
11
|
constructor(operation) {
|
|
10
12
|
this.apiType = operation.apiMethod;
|
|
13
|
+
const parameters = operation.parameters;
|
|
14
|
+
if (parameters) {
|
|
15
|
+
parameters.forEach((p) => {
|
|
16
|
+
this.parameters.push(p);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
11
19
|
const body = this.getTypeFromRequestBody(operation.requestBody);
|
|
12
20
|
if (body)
|
|
13
21
|
this.bodyType = body;
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ZodProperty } from "./
|
|
1
|
+
import { ZodProperty } from "./zodProperty.js";
|
|
2
2
|
import type { SchemaObject, ReferenceObject } from "./types/open-api-spec.interface.js";
|
|
3
3
|
export declare class Schema {
|
|
4
4
|
name: string;
|
|
5
5
|
properties: ZodProperty[];
|
|
6
6
|
type: string;
|
|
7
7
|
schema: string;
|
|
8
|
+
enums: Set<string>;
|
|
8
9
|
constructor(params: {
|
|
9
10
|
properties: Record<string, SchemaObject | ReferenceObject>;
|
|
10
11
|
name: string;
|
|
11
12
|
requireds: string[];
|
|
13
|
+
isEmpty: boolean;
|
|
12
14
|
});
|
|
15
|
+
private getEnumConst;
|
|
13
16
|
}
|
package/dist/schema.js
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
|
-
import { ZodProperty } from "./
|
|
1
|
+
import { ZodProperty } from "./zodProperty.js";
|
|
2
2
|
export class Schema {
|
|
3
3
|
name;
|
|
4
4
|
properties = [];
|
|
5
5
|
type;
|
|
6
6
|
schema;
|
|
7
|
+
enums = new Set();
|
|
7
8
|
constructor(params) {
|
|
8
|
-
const { name, properties, requireds } = params;
|
|
9
|
-
this.name = name
|
|
9
|
+
const { name, properties, requireds, isEmpty } = params;
|
|
10
|
+
this.name = `${isEmpty ? "Empty" : ""}${name}`;
|
|
10
11
|
for (const [key, value] of Object.entries(properties)) {
|
|
11
12
|
if ("$ref" in value || !value?.type)
|
|
12
13
|
continue;
|
|
13
14
|
const required = requireds.includes(key);
|
|
15
|
+
const teste = value.items;
|
|
16
|
+
if (teste && !("$ref" in teste) && teste.enum) {
|
|
17
|
+
this.enums.add(this.getEnumConst({ enums: teste.enum, schemaName: key }));
|
|
18
|
+
}
|
|
19
|
+
else if (value.enum) {
|
|
20
|
+
this.enums.add(this.getEnumConst({ enums: value.enum, schemaName: key }));
|
|
21
|
+
}
|
|
14
22
|
this.properties.push(new ZodProperty({
|
|
23
|
+
schemaName: this.name,
|
|
15
24
|
name: key,
|
|
16
25
|
schemaObject: value,
|
|
17
26
|
type: value.type,
|
|
18
27
|
example: value.example,
|
|
19
28
|
required,
|
|
29
|
+
isEmpty,
|
|
30
|
+
inParam: "path",
|
|
20
31
|
}));
|
|
21
32
|
}
|
|
22
|
-
this.type = `export type ${name} = z.infer<typeof ${name}Schema>;`;
|
|
23
|
-
this.schema = `export const ${name}Schema = z.object({
|
|
24
|
-
${this.properties.map((p) =>
|
|
33
|
+
this.type = `export type ${this.name} = z.infer<typeof ${this.name}Schema>;`;
|
|
34
|
+
this.schema = `export const ${this.name}Schema = z.object({
|
|
35
|
+
${this.properties.map((p) => {
|
|
36
|
+
return p.buildedProp;
|
|
37
|
+
})}
|
|
25
38
|
});`;
|
|
26
39
|
}
|
|
40
|
+
getEnumConst(params) {
|
|
41
|
+
const { enums, schemaName } = params;
|
|
42
|
+
const enumList = enums.map((en) => `'${en}'`);
|
|
43
|
+
return `export const ${schemaName}EnumSchema = z.enum([${enumList}])`;
|
|
44
|
+
}
|
|
27
45
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ParameterLocation, type SchemaObject } from "./types/open-api-spec.interface.js";
|
|
2
|
+
import { type Example, type ReflectorParamType } from "./types/types.js";
|
|
3
|
+
export declare class ZodProperty {
|
|
4
|
+
schemaName?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
example: Example | undefined;
|
|
7
|
+
type: ReflectorParamType;
|
|
8
|
+
buildedProp: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
inParam: ParameterLocation;
|
|
12
|
+
isEnum: boolean;
|
|
13
|
+
enums: string[];
|
|
14
|
+
constructor(params: {
|
|
15
|
+
schemaName?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
schemaObject: SchemaObject;
|
|
18
|
+
type: ReflectorParamType;
|
|
19
|
+
example: Example | undefined;
|
|
20
|
+
required: boolean;
|
|
21
|
+
description?: string;
|
|
22
|
+
isEmpty: boolean;
|
|
23
|
+
inParam: ParameterLocation;
|
|
24
|
+
});
|
|
25
|
+
private getDtoName;
|
|
26
|
+
private getEmptyExample;
|
|
27
|
+
private getExample;
|
|
28
|
+
private deepValidator;
|
|
29
|
+
private isNullable;
|
|
30
|
+
private treatName;
|
|
31
|
+
private build;
|
|
32
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { sanitizeNumber, splitByUppercase, treatenEnum } from "./helpers/helpers.js";
|
|
2
|
+
import { ReflectorInput } from "./helpers/input.js";
|
|
3
|
+
import {} from "./types/open-api-spec.interface.js";
|
|
4
|
+
import {} from "./types/types.js";
|
|
5
|
+
const inputs = new ReflectorInput();
|
|
6
|
+
export class ZodProperty {
|
|
7
|
+
schemaName;
|
|
8
|
+
name;
|
|
9
|
+
example;
|
|
10
|
+
type;
|
|
11
|
+
buildedProp;
|
|
12
|
+
description;
|
|
13
|
+
required;
|
|
14
|
+
inParam;
|
|
15
|
+
isEnum = false;
|
|
16
|
+
enums = [];
|
|
17
|
+
constructor(params) {
|
|
18
|
+
const { schemaName, name, schemaObject, type, example, required, description, isEmpty, inParam } = params;
|
|
19
|
+
this.inParam = inParam;
|
|
20
|
+
this.isEnum = false;
|
|
21
|
+
const items = schemaObject.items;
|
|
22
|
+
if (items && !("$ref" in items) && items.enum) {
|
|
23
|
+
this.isEnum = true;
|
|
24
|
+
this.enums = items.enum;
|
|
25
|
+
}
|
|
26
|
+
else if (schemaObject.enum) {
|
|
27
|
+
this.isEnum = true;
|
|
28
|
+
this.enums = schemaObject.enum;
|
|
29
|
+
}
|
|
30
|
+
if (schemaName) {
|
|
31
|
+
this.schemaName = schemaName;
|
|
32
|
+
}
|
|
33
|
+
if (name.split("-").length > 1) {
|
|
34
|
+
this.name = `['${name}']`;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.name = name;
|
|
38
|
+
}
|
|
39
|
+
this.required = required;
|
|
40
|
+
this.type = type;
|
|
41
|
+
this.example = isEmpty ? this.getEmptyExample() : this.getExample(example);
|
|
42
|
+
this.buildedProp = this.build(schemaObject);
|
|
43
|
+
if (description)
|
|
44
|
+
this.description = description;
|
|
45
|
+
}
|
|
46
|
+
getDtoName(ref) {
|
|
47
|
+
const cavalos = ref.split("/");
|
|
48
|
+
const dto = cavalos[cavalos.length - 1];
|
|
49
|
+
return dto;
|
|
50
|
+
}
|
|
51
|
+
getEmptyExample() {
|
|
52
|
+
switch (this.type) {
|
|
53
|
+
case "number":
|
|
54
|
+
return 0;
|
|
55
|
+
case "boolean":
|
|
56
|
+
return false;
|
|
57
|
+
case "string":
|
|
58
|
+
return "";
|
|
59
|
+
default:
|
|
60
|
+
return "";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
getExample(example) {
|
|
64
|
+
if (example)
|
|
65
|
+
return example;
|
|
66
|
+
return this.getEmptyExample();
|
|
67
|
+
}
|
|
68
|
+
deepValidator() {
|
|
69
|
+
if (this.name === "email") {
|
|
70
|
+
return `z.email().default('${this.example}')`;
|
|
71
|
+
}
|
|
72
|
+
else if (this.name === "password") {
|
|
73
|
+
return inputs.password;
|
|
74
|
+
}
|
|
75
|
+
else if (this.isEnum) {
|
|
76
|
+
return `${treatenEnum(this.enums)}.default('${this.enums[0]}')`;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
isNullable() {
|
|
83
|
+
return this.required ? "" : ".nullable()";
|
|
84
|
+
}
|
|
85
|
+
treatName(name) {
|
|
86
|
+
return name;
|
|
87
|
+
}
|
|
88
|
+
build(schemaObject) {
|
|
89
|
+
const name = this.treatName(this.name);
|
|
90
|
+
const x = `${name}: z.${this.type}()${this.isNullable()}`;
|
|
91
|
+
switch (this.type) {
|
|
92
|
+
case "string": {
|
|
93
|
+
// console.log(schemaObject.enum);
|
|
94
|
+
const deepValidation = this.deepValidator();
|
|
95
|
+
return deepValidation ? `${name}: ${deepValidation}` : `${x}.default('${this.example}')`;
|
|
96
|
+
}
|
|
97
|
+
case "boolean":
|
|
98
|
+
return `${x}.default(${this.example})`;
|
|
99
|
+
case "number": {
|
|
100
|
+
const number = JSON.stringify(this.example) ?? 0;
|
|
101
|
+
return `${x}.default(${sanitizeNumber(number)})`;
|
|
102
|
+
}
|
|
103
|
+
case "array": {
|
|
104
|
+
if (!schemaObject.items || !("$ref" in schemaObject.items)) {
|
|
105
|
+
let zodType = "z.string()";
|
|
106
|
+
if (schemaObject.items?.enum) {
|
|
107
|
+
zodType = treatenEnum(schemaObject.items.enum);
|
|
108
|
+
}
|
|
109
|
+
else if (schemaObject.items?.type) {
|
|
110
|
+
zodType = `z.${schemaObject.items.type}()`;
|
|
111
|
+
}
|
|
112
|
+
return `${name}: z.${this.type}(${zodType})${this.isNullable()}.default([])`;
|
|
113
|
+
}
|
|
114
|
+
const dto = this.getDtoName(schemaObject.items.$ref);
|
|
115
|
+
return `${name}: z.array(${dto}Schema).default(new Array(10).fill(${dto}Schema.parse({})))`;
|
|
116
|
+
}
|
|
117
|
+
case "object":
|
|
118
|
+
return `${name}: z.any()`;
|
|
119
|
+
default:
|
|
120
|
+
return `${name}: z.any()`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|