svelte-reflector 1.1.3 → 1.1.4
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.
|
@@ -25,12 +25,12 @@ export class MethodGenerator {
|
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
27
|
${inside}
|
|
28
|
-
onSuccess?.(response)
|
|
28
|
+
await onSuccess?.(response)
|
|
29
29
|
|
|
30
30
|
return ${methodReturn}
|
|
31
31
|
} catch(e) {
|
|
32
32
|
const parsedError = JSON.parse((e as Error).message) as ApiErrorResponse;
|
|
33
|
-
return onError?.(parsedError);
|
|
33
|
+
return await onError?.(parsedError);
|
|
34
34
|
} finally {
|
|
35
35
|
this.loading = false
|
|
36
36
|
}
|
package/dist/reflector.js
CHANGED
|
@@ -8,11 +8,12 @@ export class ReflectorFile {
|
|
|
8
8
|
"type ValidatorResult = string | null",
|
|
9
9
|
"type ValidatorFn<T> = (v: T) => ValidatorResult",
|
|
10
10
|
"type BundleResult<T> = T extends { bundle: () => infer R } ? R : T;",
|
|
11
|
-
`type
|
|
12
|
-
[K in Exclude<keyof T,
|
|
11
|
+
`type PartialBuildedInput<T> = {
|
|
12
|
+
[K in Exclude<keyof T, 'bundle'>]?: BuildedInput<T[K]>;
|
|
13
13
|
} & {
|
|
14
14
|
bundle: unknown;
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
|
+
`,
|
|
16
17
|
`export interface QueryContract {
|
|
17
18
|
event: SvelteEvent;
|
|
18
19
|
key: string;
|
|
@@ -27,14 +28,15 @@ export class ReflectorFile {
|
|
|
27
28
|
message: string;
|
|
28
29
|
}`,
|
|
29
30
|
`export class Behavior<TSuccess = unknown, TError = unknown> {
|
|
30
|
-
onError?: (e: TError) => void;
|
|
31
|
-
onSuccess?: (v: TSuccess) => void;
|
|
31
|
+
onError?: (e: TError) => Promise<void> | void;
|
|
32
|
+
onSuccess?: (v: TSuccess) => Promise<void> | void;
|
|
32
33
|
}`,
|
|
33
34
|
`export class BuildedInput<T> {
|
|
34
35
|
value = $state<T>(null as any);
|
|
35
36
|
display = $state<T>(null as any);
|
|
36
37
|
required: boolean;
|
|
37
38
|
placeholder: T;
|
|
39
|
+
readonly kind = 'builded';
|
|
38
40
|
readonly validator?: ValidatorFn<T>;
|
|
39
41
|
|
|
40
42
|
constructor(params: {
|
|
@@ -102,7 +104,7 @@ export class ReflectorFile {
|
|
|
102
104
|
}): BuildedInput<T> {
|
|
103
105
|
return new BuildedInput(params);
|
|
104
106
|
}`,
|
|
105
|
-
`export function isFormValid<T>(schema:
|
|
107
|
+
`export function isFormValid<T>(schema: PartialBuildedInput<T>): boolean {
|
|
106
108
|
delete schema.bundle;
|
|
107
109
|
|
|
108
110
|
const arrayOfBuildedInputs = Object.values(schema) as BuildedInput<unknown>[];
|
|
@@ -154,6 +156,7 @@ export class ReflectorFile {
|
|
|
154
156
|
export class QueryBuilder<T> {
|
|
155
157
|
private readonly key: string = '';
|
|
156
158
|
value = $state<T | null>(null);
|
|
159
|
+
readonly kind = 'query';
|
|
157
160
|
|
|
158
161
|
constructor(params: { key: string; value: T | null }) {
|
|
159
162
|
const { key, value } = params;
|