fuma 0.2.3 → 0.3.0
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/api/client.d.ts +3 -0
- package/dist/api/client.js +24 -0
- package/dist/api/config.d.ts +46 -0
- package/dist/api/config.js +7 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/server.d.ts +11 -0
- package/dist/api/server.js +17 -0
- package/dist/{Meta.svelte → private/Meta.svelte} +4 -4
- package/dist/private/api.d.ts +47 -0
- package/dist/private/api.js +9 -0
- package/dist/private/model.d.ts +40 -0
- package/dist/private/model.js +17 -0
- package/dist/server/auth.js +1 -1
- package/dist/server/formAction.d.ts +14 -0
- package/dist/server/formAction.js +8 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/parseFormData.d.ts +7 -17
- package/dist/server/parseFormData.js +11 -6
- package/dist/server/parseQuery.d.ts +1 -10
- package/dist/server/parseQuery.js +4 -5
- package/dist/server/try.d.ts +5 -2
- package/dist/server/try.js +15 -4
- package/dist/ui/drawer/Drawer.svelte +19 -11
- package/dist/ui/drawer/Drawer.svelte.d.ts +42 -7
- package/dist/ui/drawer/layers.d.ts +2 -1
- package/dist/ui/drawer/layers.js +5 -5
- package/dist/ui/form/Form.svelte +50 -25
- package/dist/ui/form/Form.svelte.d.ts +23 -13
- package/dist/ui/form/FormInput.svelte +4 -2
- package/dist/ui/form/FormInput.svelte.d.ts +116 -0
- package/dist/ui/form/form.d.ts +22 -9
- package/dist/ui/form/form.js +38 -0
- package/dist/ui/form/formInput.d.ts +1 -1
- package/dist/ui/input/FormControl.svelte.d.ts +1 -1
- package/dist/ui/input/InputBoolean.svelte.d.ts +2 -2
- package/dist/ui/input/InputCheckboxs.svelte.d.ts +2 -2
- package/dist/ui/input/InputCheckboxsMenu.svelte +5 -5
- package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +2 -2
- package/dist/ui/input/InputCombo.svelte.d.ts +2 -2
- package/dist/ui/input/InputNumber.svelte.d.ts +1 -1
- package/dist/ui/input/InputPassword.svelte.d.ts +2 -2
- package/dist/ui/input/InputRadio.svelte.d.ts +2 -2
- package/dist/ui/input/InputRelation.svelte +7 -2
- package/dist/ui/input/InputRelations.svelte +7 -3
- package/dist/ui/input/InputText.svelte.d.ts +2 -2
- package/dist/ui/input/RelationAfter.svelte +7 -1
- package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +1 -1
- package/dist/ui/input/types.d.ts +2 -2
- package/dist/ui/login/Login.svelte +7 -3
- package/dist/ui/menu/DropDownMenu.svelte +2 -1
- package/dist/ui/menu/DropDownMenu.svelte.d.ts +2 -0
- package/dist/ui/slot/Slot.svelte +3 -1
- package/dist/ui/slot/Slot.svelte.d.ts +22 -0
- package/dist/ui/table/field.d.ts +1 -1
- package/dist/utils/constant.d.ts +1 -0
- package/dist/utils/constant.js +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/jsonParse.d.ts +1 -1
- package/dist/utils/jsonParse.js +5 -3
- package/dist/validation/form.d.ts +6 -5
- package/dist/validation/form.js +8 -8
- package/dist/validation/zod.d.ts +79 -19
- package/dist/validation/zod.js +16 -18
- package/package.json +12 -7
- /package/dist/{Meta.svelte.d.ts → private/Meta.svelte.d.ts} +0 -0
- /package/dist/{server → private}/prisma.d.ts +0 -0
- /package/dist/{server → private}/prisma.js +0 -0
|
@@ -3,6 +3,7 @@ import { slide } from "svelte/transition";
|
|
|
3
3
|
import { toast } from "svelte-sonner";
|
|
4
4
|
import { mdiClose } from "@mdi/js";
|
|
5
5
|
import debounce from "debounce";
|
|
6
|
+
import { USE_JSON_PARSER } from "../../utils/constant.js";
|
|
6
7
|
import { Icon } from "../icon/index.js";
|
|
7
8
|
import { Slot } from "../slot/index.js";
|
|
8
9
|
import { FormControl, SelectorList } from "./index.js";
|
|
@@ -111,7 +112,6 @@ async function handleBlur() {
|
|
|
111
112
|
<input
|
|
112
113
|
type="text"
|
|
113
114
|
id={key}
|
|
114
|
-
name={key}
|
|
115
115
|
bind:this={inputSearch}
|
|
116
116
|
bind:value={searchValue}
|
|
117
117
|
on:input={(e) => searchItemsDebounce(e.currentTarget.value)}
|
|
@@ -128,7 +128,11 @@ async function handleBlur() {
|
|
|
128
128
|
</div>
|
|
129
129
|
</div>
|
|
130
130
|
|
|
131
|
-
<input
|
|
131
|
+
<input
|
|
132
|
+
type="hidden"
|
|
133
|
+
name={key}
|
|
134
|
+
value="{USE_JSON_PARSER}{JSON.stringify(items?.map(({ id }) => ({ id })) || [])}"
|
|
135
|
+
/>
|
|
132
136
|
</FormControl>
|
|
133
137
|
</div>
|
|
134
138
|
|
|
@@ -139,7 +143,7 @@ async function handleBlur() {
|
|
|
139
143
|
{isLoading}
|
|
140
144
|
{focusIndex}
|
|
141
145
|
let:index
|
|
142
|
-
class="w-full {classList}"
|
|
146
|
+
class="w-full min-w-40 {classList}"
|
|
143
147
|
on:select={({ detail }) => select(detail)}
|
|
144
148
|
>
|
|
145
149
|
<slot name="suggestion" item={proposedItems[index]}>
|
|
@@ -18,7 +18,13 @@ const dispatch = createEventDispatcher();
|
|
|
18
18
|
/>
|
|
19
19
|
</div>
|
|
20
20
|
{:else if createUrl}
|
|
21
|
-
<a
|
|
21
|
+
<a
|
|
22
|
+
href={createUrl}
|
|
23
|
+
class="btn btn-square btn-sm"
|
|
24
|
+
in:fade|local={{ duration: 200 }}
|
|
25
|
+
data-sveltekit-noscroll
|
|
26
|
+
data-sveltekit-replacestate
|
|
27
|
+
>
|
|
22
28
|
<Icon path={createIcon} on:click={() => dispatch('create')} title={createTitle} />
|
|
23
29
|
</a>
|
|
24
30
|
{/if}
|
|
@@ -10,7 +10,7 @@ declare const __propDef: {
|
|
|
10
10
|
prefix?: string | number | undefined;
|
|
11
11
|
prefixFor?: string | number | undefined;
|
|
12
12
|
enhanceDisabled?: boolean | undefined;
|
|
13
|
-
labelPosition?: ("top" | "
|
|
13
|
+
labelPosition?: ("top" | "left" | "right") | undefined;
|
|
14
14
|
} & {
|
|
15
15
|
value?: string | undefined;
|
|
16
16
|
classToolbar?: string | undefined;
|
package/dist/ui/input/types.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ export type InputProps<T = string> = ComponentProps<FormControl> & {
|
|
|
5
5
|
input?: HTMLInputAttributes;
|
|
6
6
|
inputElement?: HTMLInputElement;
|
|
7
7
|
wrapperClass?: string;
|
|
8
|
-
value?: T;
|
|
8
|
+
value?: T | null;
|
|
9
9
|
bindWithParams?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export type TextareaProps = ComponentProps<FormControl> & {
|
|
12
12
|
textarea?: HTMLTextareaAttributes;
|
|
13
|
-
value?: string;
|
|
13
|
+
value?: string | null;
|
|
14
14
|
bindWithParams?: boolean;
|
|
15
15
|
};
|
|
@@ -36,7 +36,7 @@ let recorverDialog;
|
|
|
36
36
|
<span
|
|
37
37
|
role="button"
|
|
38
38
|
tabindex="0"
|
|
39
|
-
class="tab-lg tab grow
|
|
39
|
+
class="tab-lg tab h-10 grow"
|
|
40
40
|
class:tab-active={state === 'login'}
|
|
41
41
|
on:click={() => (state = 'login')}
|
|
42
42
|
on:keyup={() => (state = 'login')}
|
|
@@ -46,7 +46,7 @@ let recorverDialog;
|
|
|
46
46
|
<span
|
|
47
47
|
role="button"
|
|
48
48
|
tabindex="0"
|
|
49
|
-
class="tab-lg tab-
|
|
49
|
+
class="tab-lg tab h-10 grow"
|
|
50
50
|
class:tab-active={state === 'register'}
|
|
51
51
|
on:click={() => (state = 'register')}
|
|
52
52
|
on:keyup={() => (state = 'register')}
|
|
@@ -55,7 +55,11 @@ let recorverDialog;
|
|
|
55
55
|
</span>
|
|
56
56
|
</div>
|
|
57
57
|
|
|
58
|
-
<form
|
|
58
|
+
<form
|
|
59
|
+
class="card-body rounded-b-lg border border-t-0 border-base-300 bg-base-100"
|
|
60
|
+
method="post"
|
|
61
|
+
use:enhance
|
|
62
|
+
>
|
|
59
63
|
<InputText key="username" label="Nom d'utilisateur" input={{ autocomplete: 'username' }} />
|
|
60
64
|
|
|
61
65
|
{#if state === 'register'}
|
|
@@ -5,6 +5,7 @@ import { DropDown } from "./index.js";
|
|
|
5
5
|
import { SelectorList } from "../input/index.js";
|
|
6
6
|
import { parseOptions } from "../../utils/options.js";
|
|
7
7
|
export let options;
|
|
8
|
+
export let tippyProps = {};
|
|
8
9
|
$:
|
|
9
10
|
_options = parseOptions(options);
|
|
10
11
|
let trigger;
|
|
@@ -17,7 +18,7 @@ function onSelect(index) {
|
|
|
17
18
|
}
|
|
18
19
|
</script>
|
|
19
20
|
|
|
20
|
-
<DropDown bind:this={dropDown}>
|
|
21
|
+
<DropDown bind:this={dropDown} {tippyProps}>
|
|
21
22
|
<div class="contents" bind:this={trigger} slot="activator">
|
|
22
23
|
<slot>
|
|
23
24
|
<button type="button" class="flex h-12 items-center gap-2 rounded-lg border pl-4 pr-2">
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
import { type Options } from '../../utils/options.js';
|
|
3
|
+
import type { TippyProps } from '../../utils/tippy.js';
|
|
3
4
|
declare const __propDef: {
|
|
4
5
|
props: {
|
|
5
6
|
options: Options;
|
|
7
|
+
tippyProps?: Partial<TippyProps> | undefined;
|
|
6
8
|
};
|
|
7
9
|
events: {
|
|
8
10
|
select: CustomEvent<string>;
|
package/dist/ui/slot/Slot.svelte
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
type _Slot = ((...args: any) => ComponentAndProps | ComponentType | string) | ComponentAndProps | ComponentType | string;
|
|
3
|
+
import { type ComponentType } from 'svelte';
|
|
4
|
+
import { type ComponentAndProps } from '../../utils/component.js';
|
|
5
|
+
declare class __sveltets_Render<Slot extends _Slot> {
|
|
6
|
+
props(): {
|
|
7
|
+
slot?: Slot | null | undefined;
|
|
8
|
+
args?: (Slot extends (...args: any) => any ? Parameters<Slot>[0] : undefined) | null | undefined;
|
|
9
|
+
};
|
|
10
|
+
events(): {} & {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots(): {
|
|
14
|
+
default: {};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type SlotProps<Slot extends _Slot> = ReturnType<__sveltets_Render<Slot>['props']>;
|
|
18
|
+
export type SlotEvents<Slot extends _Slot> = ReturnType<__sveltets_Render<Slot>['events']>;
|
|
19
|
+
export type SlotSlots<Slot extends _Slot> = ReturnType<__sveltets_Render<Slot>['slots']>;
|
|
20
|
+
export default class Slot<Slot extends _Slot> extends SvelteComponent<SlotProps<Slot>, SlotEvents<Slot>, SlotSlots<Slot>> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/dist/ui/table/field.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare function syncFieldsWithParams(tablekey: string, fields: TableFiel
|
|
|
49
49
|
$visible: boolean;
|
|
50
50
|
key: string;
|
|
51
51
|
label: string;
|
|
52
|
-
type: "string" | "number" | "boolean" | "
|
|
52
|
+
type: "string" | "number" | "boolean" | "date" | "textarea";
|
|
53
53
|
options?: Options | undefined;
|
|
54
54
|
hint?: string | undefined;
|
|
55
55
|
locked?: boolean | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const USE_JSON_PARSER = "USE_JSON_PARSER_nXFVwk03nRbmhFukfyZLuzkEd43LXIKs_";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const USE_JSON_PARSER = 'USE_JSON_PARSER_nXFVwk03nRbmhFukfyZLuzkEd43LXIKs_';
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function jsonParse<Type>(
|
|
1
|
+
export declare function jsonParse<Type>(content: string | null | undefined | Type, defaultValue: Type): Type;
|
package/dist/utils/jsonParse.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export function jsonParse(
|
|
1
|
+
export function jsonParse(content, defaultValue) {
|
|
2
2
|
try {
|
|
3
|
-
if (!
|
|
3
|
+
if (!content)
|
|
4
4
|
return defaultValue;
|
|
5
|
-
|
|
5
|
+
if (typeof content !== 'string')
|
|
6
|
+
return content;
|
|
7
|
+
return JSON.parse(content);
|
|
6
8
|
}
|
|
7
9
|
catch {
|
|
8
10
|
return defaultValue;
|
|
@@ -8,14 +8,15 @@ export type FormContext = {
|
|
|
8
8
|
export declare const formContext: {
|
|
9
9
|
get: () => FormContext;
|
|
10
10
|
};
|
|
11
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
11
12
|
type SuccessMessage = false | string | ((action: URL) => string);
|
|
12
13
|
type BooleanOrFunction = boolean | ((action: URL) => boolean);
|
|
13
14
|
export type UseFormOptions<ReturnData> = {
|
|
14
|
-
onSubmit?: (...args: Parameters<SubmitFunction>) => any
|
|
15
|
-
onSuccess?: (action: URL, data?: ReturnData) => any
|
|
15
|
+
onSubmit?: (...args: Parameters<SubmitFunction>) => MaybePromise<any>;
|
|
16
|
+
onSuccess?: (action: URL, data?: ReturnData) => MaybePromise<any>;
|
|
16
17
|
onResetError?: () => unknown;
|
|
17
|
-
onError?: (err: any) => unknown
|
|
18
|
-
onFail?: (failure: Record<string, any> | undefined) => unknown
|
|
18
|
+
onError?: (err: any) => MaybePromise<unknown>;
|
|
19
|
+
onFail?: (failure: Record<string, any> | undefined) => MaybePromise<unknown>;
|
|
19
20
|
successUpdate?: BooleanOrFunction;
|
|
20
21
|
successReset?: BooleanOrFunction;
|
|
21
22
|
successMessage?: SuccessMessage;
|
|
@@ -25,7 +26,7 @@ export declare function useForm<ReturnData extends Record<string, unknown>>({ on
|
|
|
25
26
|
destroy(): void;
|
|
26
27
|
};
|
|
27
28
|
submit: SubmitFunction<ReturnData>;
|
|
28
|
-
resetErrors: () => void
|
|
29
|
+
resetErrors: () => Promise<void>;
|
|
29
30
|
setError(key: string, value: string): void;
|
|
30
31
|
};
|
|
31
32
|
export {};
|
package/dist/validation/form.js
CHANGED
|
@@ -12,7 +12,7 @@ export const formContext = {
|
|
|
12
12
|
};
|
|
13
13
|
export function useForm({ onSubmit, onSuccess, onResetError, onError, onFail, successUpdate = true, successReset = true, successMessage = 'Succès' } = {}) {
|
|
14
14
|
const { setError } = formContext.get();
|
|
15
|
-
function resetErrors() {
|
|
15
|
+
async function resetErrors() {
|
|
16
16
|
for (const key in setError)
|
|
17
17
|
setError[key]('');
|
|
18
18
|
if (onResetError)
|
|
@@ -48,14 +48,14 @@ export function useForm({ onSubmit, onSuccess, onResetError, onError, onFail, su
|
|
|
48
48
|
event.submitter?.classList.remove('btn-disabled');
|
|
49
49
|
if (result.type === 'error') {
|
|
50
50
|
if (onError)
|
|
51
|
-
onError(result.error.message);
|
|
51
|
+
await onError(result.error.message);
|
|
52
52
|
const { message } = result.error;
|
|
53
53
|
toast.error(message || 'Erreur');
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
if (result.type === 'failure') {
|
|
57
57
|
if (onFail)
|
|
58
|
-
onFail(result.data);
|
|
58
|
+
await onFail(result.data);
|
|
59
59
|
if (result.data)
|
|
60
60
|
handleFailure(result.data);
|
|
61
61
|
return;
|
|
@@ -68,18 +68,18 @@ export function useForm({ onSubmit, onSuccess, onResetError, onError, onFail, su
|
|
|
68
68
|
if (result.type === 'success') {
|
|
69
69
|
if (successMessage !== false)
|
|
70
70
|
toast.success(tryToRun(successMessage));
|
|
71
|
-
if (onSuccess)
|
|
72
|
-
onSuccess(action, result.data);
|
|
73
71
|
if (successUpdate)
|
|
74
|
-
update({ reset: tryToRun(successReset) });
|
|
72
|
+
await update({ reset: tryToRun(successReset) });
|
|
73
|
+
if (onSuccess)
|
|
74
|
+
await onSuccess(action, result.data);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
if (result.type === 'redirect') {
|
|
78
78
|
if (successMessage !== false)
|
|
79
79
|
toast.success(tryToRun(successMessage));
|
|
80
|
+
await goto(result.location, { replaceState: true, invalidateAll: tryToRun(successUpdate) });
|
|
80
81
|
if (onSuccess)
|
|
81
|
-
onSuccess(action);
|
|
82
|
-
return goto(result.location, { replaceState: true, invalidateAll: tryToRun(successUpdate) });
|
|
82
|
+
await onSuccess(action);
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
};
|
package/dist/validation/zod.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import zod from 'zod';
|
|
2
|
-
declare function json<T extends zod.ZodRawShape>(shap: T): zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodObject<T, "strip", zod.ZodTypeAny, { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k_2 in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k_2] ? never : k_2; }[keyof T]>[k_1]; }, { [k_2_1 in keyof zod.baseObjectInputType<T>]: zod.baseObjectInputType<T>[k_2_1]; }
|
|
3
|
-
declare function array<T extends zod.ZodTypeAny>(shap: T): zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodArray<T, "many"
|
|
2
|
+
declare function json<T extends zod.ZodRawShape>(shap: T): zod.ZodUnion<[zod.ZodObject<T, "strip", zod.ZodTypeAny, { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k_2 in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k_2] ? never : k_2; }[keyof T]>[k_1]; }, { [k_2_1 in keyof zod.baseObjectInputType<T>]: zod.baseObjectInputType<T>[k_2_1]; }>, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodObject<T, "strip", zod.ZodTypeAny, { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T>, { [k_2 in keyof zod.baseObjectOutputType<T>]: undefined extends zod.baseObjectOutputType<T>[k_2] ? never : k_2; }[keyof T]>[k_1]; }, { [k_2_1 in keyof zod.baseObjectInputType<T>]: zod.baseObjectInputType<T>[k_2_1]; }>>]>;
|
|
3
|
+
declare function array<T extends zod.ZodTypeAny>(shap: T): zod.ZodUnion<[zod.ZodArray<T, "many">, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodArray<T, "many">>]>;
|
|
4
4
|
declare function booleanAsString(): zod.ZodEffects<zod.ZodEnum<["true", "false"]>, boolean, "true" | "false">;
|
|
5
|
-
declare function dateOptional():
|
|
5
|
+
declare function dateOptional(): void;
|
|
6
6
|
type RelationsOperation = 'set' | 'disconnect' | 'delete' | 'connect';
|
|
7
7
|
export declare const z: {
|
|
8
8
|
json: typeof json;
|
|
9
9
|
array: typeof array;
|
|
10
10
|
arrayRaw: <T extends zod.ZodTypeAny>(schema: T, params?: zod.RawCreateParams) => zod.ZodArray<T, "many">;
|
|
11
11
|
relation: {
|
|
12
|
-
connect: zod.ZodEffects<zod.
|
|
12
|
+
connect: zod.ZodEffects<zod.ZodObject<{
|
|
13
|
+
id: zod.ZodString;
|
|
14
|
+
}, "strip", zod.ZodTypeAny, {
|
|
15
|
+
id: string;
|
|
16
|
+
}, {
|
|
17
|
+
id: string;
|
|
18
|
+
}>, {
|
|
13
19
|
connect: {
|
|
14
20
|
id: string;
|
|
15
21
|
};
|
|
16
|
-
},
|
|
22
|
+
}, {
|
|
23
|
+
id: string;
|
|
24
|
+
}>;
|
|
17
25
|
create<T_1 extends zod.ZodRawShape>(shap: T_1): zod.ZodEffects<zod.ZodObject<T_1, "strip", zod.ZodTypeAny, { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_1>, { [k in keyof zod.baseObjectOutputType<T_1>]: undefined extends zod.baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_1>, { [k_2 in keyof zod.baseObjectOutputType<T_1>]: undefined extends zod.baseObjectOutputType<T_1>[k_2] ? never : k_2; }[keyof T_1]>[k_1]; }, { [k_2_1 in keyof zod.baseObjectInputType<T_1>]: zod.baseObjectInputType<T_1>[k_2_1]; }>, {
|
|
18
26
|
create: { [k_1 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_1>, { [k in keyof zod.baseObjectOutputType<T_1>]: undefined extends zod.baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_1>, { [k_2 in keyof zod.baseObjectOutputType<T_1>]: undefined extends zod.baseObjectOutputType<T_1>[k_2] ? never : k_2; }[keyof T_1]>[k_1]; };
|
|
19
27
|
}, { [k_2_1 in keyof zod.baseObjectInputType<T_1>]: zod.baseObjectInputType<T_1>[k_2_1]; }>;
|
|
@@ -28,18 +36,50 @@ export declare const z: {
|
|
|
28
36
|
}, { [k_2_4 in keyof zod.baseObjectInputType<T_4>]: zod.baseObjectInputType<T_4>[k_2_4]; }>;
|
|
29
37
|
};
|
|
30
38
|
relations: {
|
|
31
|
-
set: zod.ZodEffects<zod.
|
|
39
|
+
set: zod.ZodEffects<zod.ZodArray<zod.ZodObject<{
|
|
40
|
+
id: zod.ZodString;
|
|
41
|
+
}, "strip", zod.ZodTypeAny, {
|
|
42
|
+
id: string;
|
|
43
|
+
}, {
|
|
44
|
+
id: string;
|
|
45
|
+
}>, "many">, Partial<Record<RelationsOperation, {
|
|
46
|
+
id: string;
|
|
47
|
+
}[]>>, {
|
|
48
|
+
id: string;
|
|
49
|
+
}[]>;
|
|
50
|
+
disconnect: zod.ZodEffects<zod.ZodArray<zod.ZodObject<{
|
|
51
|
+
id: zod.ZodString;
|
|
52
|
+
}, "strip", zod.ZodTypeAny, {
|
|
53
|
+
id: string;
|
|
54
|
+
}, {
|
|
55
|
+
id: string;
|
|
56
|
+
}>, "many">, Partial<Record<RelationsOperation, {
|
|
57
|
+
id: string;
|
|
58
|
+
}[]>>, {
|
|
59
|
+
id: string;
|
|
60
|
+
}[]>;
|
|
61
|
+
delete: zod.ZodEffects<zod.ZodArray<zod.ZodObject<{
|
|
62
|
+
id: zod.ZodString;
|
|
63
|
+
}, "strip", zod.ZodTypeAny, {
|
|
64
|
+
id: string;
|
|
65
|
+
}, {
|
|
32
66
|
id: string;
|
|
33
|
-
}
|
|
34
|
-
disconnect: zod.ZodEffects<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodArray<zod.ZodString, "many">>, Partial<Record<RelationsOperation, {
|
|
67
|
+
}>, "many">, Partial<Record<RelationsOperation, {
|
|
35
68
|
id: string;
|
|
36
|
-
}[]>>,
|
|
37
|
-
delete: zod.ZodEffects<zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodArray<zod.ZodString, "many">>, Partial<Record<RelationsOperation, {
|
|
69
|
+
}[]>>, {
|
|
38
70
|
id: string;
|
|
39
|
-
}[]
|
|
40
|
-
connect: zod.ZodEffects<zod.
|
|
71
|
+
}[]>;
|
|
72
|
+
connect: zod.ZodEffects<zod.ZodArray<zod.ZodObject<{
|
|
73
|
+
id: zod.ZodString;
|
|
74
|
+
}, "strip", zod.ZodTypeAny, {
|
|
75
|
+
id: string;
|
|
76
|
+
}, {
|
|
41
77
|
id: string;
|
|
42
|
-
}
|
|
78
|
+
}>, "many">, Partial<Record<RelationsOperation, {
|
|
79
|
+
id: string;
|
|
80
|
+
}[]>>, {
|
|
81
|
+
id: string;
|
|
82
|
+
}[]>;
|
|
43
83
|
create<T_5 extends zod.ZodRawShape>(shap: T_5): zod.ZodEffects<zod.ZodUnion<[zod.ZodArray<zod.ZodObject<T_5, "strip", zod.ZodTypeAny, { [k_1_4 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_9 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_9] ? never : k_9; }[keyof T_5]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_10 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_10] ? never : k_10; }[keyof T_5]>[k_1_4]; }, { [k_2_5 in keyof zod.baseObjectInputType<T_5>]: zod.baseObjectInputType<T_5>[k_2_5]; }>, "many">, zod.ZodObject<T_5, "strip", zod.ZodTypeAny, { [k_1_4 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_9 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_9] ? never : k_9; }[keyof T_5]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_10 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_10] ? never : k_10; }[keyof T_5]>[k_1_4]; }, { [k_2_5 in keyof zod.baseObjectInputType<T_5>]: zod.baseObjectInputType<T_5>[k_2_5]; }>]>, {
|
|
44
84
|
create: { [k_1_4 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_9 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_9] ? never : k_9; }[keyof T_5]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_10 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_10] ? never : k_10; }[keyof T_5]>[k_1_4]; } | { [k_1_4 in keyof zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_9 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_9] ? never : k_9; }[keyof T_5]>]: zod.objectUtil.addQuestionMarks<zod.baseObjectOutputType<T_5>, { [k_10 in keyof zod.baseObjectOutputType<T_5>]: undefined extends zod.baseObjectOutputType<T_5>[k_10] ? never : k_10; }[keyof T_5]>[k_1_4]; }[];
|
|
45
85
|
}, { [k_2_5 in keyof zod.baseObjectInputType<T_5>]: zod.baseObjectInputType<T_5>[k_2_5]; } | { [k_2_5 in keyof zod.baseObjectInputType<T_5>]: zod.baseObjectInputType<T_5>[k_2_5]; }[]>;
|
|
@@ -63,7 +103,7 @@ export declare const z: {
|
|
|
63
103
|
}, { [k_2_11 in keyof zod.baseObjectInputType<T_11>]: zod.baseObjectInputType<T_11>[k_2_11]; } | { [k_2_11 in keyof zod.baseObjectInputType<T_11>]: zod.baseObjectInputType<T_11>[k_2_11]; }[]>;
|
|
64
104
|
};
|
|
65
105
|
filter: {
|
|
66
|
-
number: zod.ZodOptional<zod.
|
|
106
|
+
number: zod.ZodOptional<zod.ZodUnion<[zod.ZodObject<{
|
|
67
107
|
min: zod.ZodOptional<zod.ZodNumber>;
|
|
68
108
|
max: zod.ZodOptional<zod.ZodNumber>;
|
|
69
109
|
}, "strip", zod.ZodTypeAny, {
|
|
@@ -72,9 +112,27 @@ export declare const z: {
|
|
|
72
112
|
}, {
|
|
73
113
|
min?: number | undefined;
|
|
74
114
|
max?: number | undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
115
|
+
}>, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodObject<{
|
|
116
|
+
min: zod.ZodOptional<zod.ZodNumber>;
|
|
117
|
+
max: zod.ZodOptional<zod.ZodNumber>;
|
|
118
|
+
}, "strip", zod.ZodTypeAny, {
|
|
119
|
+
min?: number | undefined;
|
|
120
|
+
max?: number | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
min?: number | undefined;
|
|
123
|
+
max?: number | undefined;
|
|
124
|
+
}>>]>>;
|
|
125
|
+
multiselect: zod.ZodOptional<zod.ZodUnion<[zod.ZodArray<zod.ZodString, "many">, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodArray<zod.ZodString, "many">>]>>;
|
|
126
|
+
range: zod.ZodOptional<zod.ZodUnion<[zod.ZodObject<{
|
|
127
|
+
start: zod.ZodOptional<zod.ZodDate>;
|
|
128
|
+
end: zod.ZodOptional<zod.ZodDate>;
|
|
129
|
+
}, "strip", zod.ZodTypeAny, {
|
|
130
|
+
start?: Date | undefined;
|
|
131
|
+
end?: Date | undefined;
|
|
132
|
+
}, {
|
|
133
|
+
start?: Date | undefined;
|
|
134
|
+
end?: Date | undefined;
|
|
135
|
+
}>, zod.ZodPipeline<zod.ZodEffects<zod.ZodString, zod.RefinementCtx, string>, zod.ZodObject<{
|
|
78
136
|
start: zod.ZodOptional<zod.ZodDate>;
|
|
79
137
|
end: zod.ZodOptional<zod.ZodDate>;
|
|
80
138
|
}, "strip", zod.ZodTypeAny, {
|
|
@@ -83,7 +141,7 @@ export declare const z: {
|
|
|
83
141
|
}, {
|
|
84
142
|
start?: Date | undefined;
|
|
85
143
|
end?: Date | undefined;
|
|
86
|
-
}
|
|
144
|
+
}>>]>>;
|
|
87
145
|
boolean: zod.ZodOptional<zod.ZodEffects<zod.ZodEnum<["true", "false"]>, boolean, "true" | "false">>;
|
|
88
146
|
};
|
|
89
147
|
dateOptional: typeof dateOptional;
|
|
@@ -164,7 +222,7 @@ export declare const z: {
|
|
|
164
222
|
map: "map";
|
|
165
223
|
set: "set";
|
|
166
224
|
};
|
|
167
|
-
getParsedType: (data: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "
|
|
225
|
+
getParsedType: (data: any) => "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "map" | "nan" | "integer" | "float" | "date" | "null" | "array" | "unknown" | "promise" | "void" | "never" | "set";
|
|
168
226
|
ZodType: typeof zod.ZodType;
|
|
169
227
|
ZodString: typeof zod.ZodString;
|
|
170
228
|
ZodNumber: typeof zod.ZodNumber;
|
|
@@ -325,6 +383,8 @@ export declare const z: {
|
|
|
325
383
|
quotelessJson: (obj: any) => string;
|
|
326
384
|
ZodError: typeof zod.ZodError;
|
|
327
385
|
};
|
|
386
|
+
export type ZodInfer<T extends zod.ZodType<any, any, any>> = T['_output'];
|
|
387
|
+
export type SuperRefinement<T> = zod.SuperRefinement<T>;
|
|
328
388
|
/**
|
|
329
389
|
* @example type MyModel = {name: z.string()} satisfies ZodObj<{name: string}>
|
|
330
390
|
*/
|
package/dist/validation/zod.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import zod from 'zod';
|
|
2
2
|
import { jsonParse } from '../utils/index.js';
|
|
3
3
|
function json(shap) {
|
|
4
|
-
return zod.string().transform(jsonParse).pipe(zod.object(shap));
|
|
4
|
+
return zod.union([zod.object(shap), zod.string().transform(jsonParse).pipe(zod.object(shap))]);
|
|
5
5
|
}
|
|
6
6
|
function array(shap) {
|
|
7
|
-
return zod.string().transform(jsonParse).pipe(zod.array(shap));
|
|
7
|
+
return zod.union([zod.array(shap), zod.string().transform(jsonParse).pipe(zod.array(shap))]);
|
|
8
8
|
}
|
|
9
9
|
function booleanAsString() {
|
|
10
10
|
return zod.enum(['true', 'false']).transform((value) => value === 'true');
|
|
11
11
|
}
|
|
12
12
|
function dateOptional() {
|
|
13
|
-
|
|
14
|
-
.
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
zod.union([
|
|
14
|
+
zod.date(),
|
|
15
|
+
zod
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.transform((v) => (v ? new Date(v) : v === '' ? null : undefined))
|
|
19
|
+
]);
|
|
17
20
|
}
|
|
18
21
|
const relation = {
|
|
19
|
-
connect: zod
|
|
20
|
-
.string()
|
|
21
|
-
.min(1, 'Required')
|
|
22
|
-
.transform((value) => ({ connect: { id: value } })),
|
|
22
|
+
connect: zod.object({ id: zod.string() }).transform((item) => ({ connect: item })),
|
|
23
23
|
create(shap) {
|
|
24
24
|
return zod.object(shap).transform((value) => ({ create: value }));
|
|
25
25
|
},
|
|
@@ -35,10 +35,8 @@ const relation = {
|
|
|
35
35
|
};
|
|
36
36
|
function relationsUniqueInput(operation = 'set') {
|
|
37
37
|
return zod
|
|
38
|
-
.string()
|
|
39
|
-
.transform(
|
|
40
|
-
.pipe(zod.array(zod.string()))
|
|
41
|
-
.transform((ids) => ({ [operation]: ids.map((id) => ({ id })) }));
|
|
38
|
+
.array(zod.object({ id: zod.string() }))
|
|
39
|
+
.transform((items) => ({ [operation]: items.map(({ id }) => ({ id })) }));
|
|
42
40
|
}
|
|
43
41
|
function objectOrArray(shap) {
|
|
44
42
|
return zod.union([zod.array(zod.object(shap)), zod.object(shap)]);
|
|
@@ -84,14 +82,14 @@ const filter = {
|
|
|
84
82
|
};
|
|
85
83
|
export const z = {
|
|
86
84
|
...zod,
|
|
87
|
-
json,
|
|
88
|
-
array,
|
|
89
|
-
arrayRaw: zod.array,
|
|
85
|
+
json, // TODO: rename stringAsObject
|
|
86
|
+
array, // TODO: rename stringAsArray
|
|
87
|
+
arrayRaw: zod.array, // TODO: remove
|
|
90
88
|
relation,
|
|
91
89
|
relations,
|
|
92
90
|
filter,
|
|
93
91
|
dateOptional,
|
|
94
|
-
booleanAsString,
|
|
92
|
+
booleanAsString, // TODO: rename stringAsBoolean
|
|
95
93
|
date: zod.coerce.date,
|
|
96
94
|
number: zod.coerce.number,
|
|
97
95
|
bigint: zod.coerce.bigint,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fuma",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "My fullstack material build with sveltekit, daisyui, zod
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jonas Voisard",
|
|
7
7
|
"email": "jonas.voisard@gmail.com"
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"types": "./dist/utils/index.d.ts",
|
|
25
25
|
"default": "./dist/utils/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./api": {
|
|
28
|
+
"types": "./dist/api/index.d.ts",
|
|
29
|
+
"default": "./dist/api/index.js"
|
|
30
|
+
},
|
|
27
31
|
"./store": {
|
|
28
32
|
"types": "./dist/store/index.d.ts",
|
|
29
33
|
"default": "./dist/store/index.js"
|
|
@@ -52,9 +56,9 @@
|
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@sveltejs/adapter-auto": "^3.0.0",
|
|
55
|
-
"@sveltejs/kit": "^2.5.
|
|
56
|
-
"@sveltejs/package": "^2.
|
|
57
|
-
"@sveltejs/vite-plugin-svelte": "^3.
|
|
59
|
+
"@sveltejs/kit": "^2.5.7",
|
|
60
|
+
"@sveltejs/package": "^2.3.1",
|
|
61
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.0",
|
|
58
62
|
"@tailwindcss/typography": "^0.5.13",
|
|
59
63
|
"@types/debounce": "^1.2.4",
|
|
60
64
|
"@types/eslint": "^8.56.0",
|
|
@@ -73,12 +77,12 @@
|
|
|
73
77
|
"prettier-plugin-tailwindcss": "^0.5.9",
|
|
74
78
|
"prisma": "^5.13.0",
|
|
75
79
|
"publint": "^0.1.9",
|
|
76
|
-
"svelte": "^4.2.
|
|
80
|
+
"svelte": "^4.2.15",
|
|
77
81
|
"svelte-check": "^3.6.0",
|
|
78
82
|
"tailwindcss": "^3.3.6",
|
|
79
83
|
"tslib": "^2.4.1",
|
|
80
84
|
"typescript": "^5.0.0",
|
|
81
|
-
"vite": "^5.2.
|
|
85
|
+
"vite": "^5.2.11",
|
|
82
86
|
"vitest": "^1.2.0"
|
|
83
87
|
},
|
|
84
88
|
"dependencies": {
|
|
@@ -99,6 +103,7 @@
|
|
|
99
103
|
"@tiptap/pm": "^2.3.0",
|
|
100
104
|
"@tiptap/starter-kit": "^2.3.0",
|
|
101
105
|
"@tiptap/suggestion": "^2.3.0",
|
|
106
|
+
"axios": "^1.6.8",
|
|
102
107
|
"dayjs": "^1.11.10",
|
|
103
108
|
"debounce": "^2.0.0",
|
|
104
109
|
"devalue": "^4.3.2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|