@azure-net/kit 0.9.1 → 0.9.2

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.
@@ -1,3 +1,4 @@
1
1
  export * from '../../edges/index.js';
2
2
  export * from './injectableDependencies/index.js';
3
3
  export * from './serverAction/index.js';
4
+ export * from './schema/index.js';
@@ -1,3 +1,4 @@
1
1
  export * from '../../edges/index.js';
2
2
  export * from './injectableDependencies/index.js';
3
3
  export * from './serverAction/index.js';
4
+ export * from './schema/index.js';
@@ -37,8 +37,8 @@ interface SchemaInstance<TransformResult> {
37
37
  validated(): boolean;
38
38
  }
39
39
  type Schema<SchemaData, TransformResult, CustomMethods> = CustomMethods & {
40
- from(data: Partial<SchemaData>): SchemaInstance<TransformResult>;
41
- getSchemaError(e: unknown): RequestErrors<SchemaData>;
40
+ from(data: Partial<SchemaData> | FormData): SchemaInstance<TransformResult>;
41
+ getSchemaError(e: unknown): RequestErrors<SchemaData> | undefined;
42
42
  };
43
43
  export declare const createSchemaFactory: <Rules extends Record<string, unknown>>(rules: Rules) => <SchemaData>() => SchemaBuilder<SchemaData, Rules>;
44
44
  export declare const schema: <SchemaData>() => SchemaBuilder<SchemaData>;
@@ -60,6 +60,7 @@ class SchemaBuilderImpl {
60
60
  if (e instanceof SchemaFail) {
61
61
  return e.getErrors();
62
62
  }
63
+ return undefined;
63
64
  },
64
65
  from(data) {
65
66
  const _preparedData = prepare(data);
@@ -1,7 +1,6 @@
1
- import { RequestContext } from '../../../edges/context/index.js';
2
- import { error, fail, redirect } from '@sveltejs/kit';
1
+ import { error, fail, redirect, type RequestEvent } from '@sveltejs/kit';
3
2
  type Deps = {
4
- context: Required<ReturnType<typeof RequestContext.current>['event']>;
3
+ context: RequestEvent;
5
4
  utils: {
6
5
  fail: typeof fail;
7
6
  redirect: typeof redirect;
@@ -8,13 +8,12 @@ export interface FormConfig<T> {
8
8
  }
9
9
  export interface ActiveForm<T> {
10
10
  data: Partial<T>;
11
- touched: Partial<Record<keyof T, boolean>>;
11
+ submit: () => Promise<void>;
12
+ reset: () => void;
12
13
  pending: boolean;
13
14
  dirty: boolean;
14
- valid: boolean;
15
- submit: () => Promise<void>;
16
15
  validate: (field?: keyof T) => void;
17
- reset: () => void;
18
- setField: <K extends keyof T>(field: K, value: T[K]) => void;
16
+ valid: boolean;
17
+ touched: Partial<Record<keyof T, boolean>>;
19
18
  touchField: (field: keyof T) => void;
20
19
  }
@@ -1,7 +1,8 @@
1
+ //import { ObjectUtil } from 'azure-net-tools';
1
2
  export {};
2
3
  // export function createActiveForm<T extends object>(config: FormConfig<T>): ActiveForm<T> {
3
4
  // const initial: Partial<T> = config.initialData ?? {};
4
- // let data = $state<Partial<T>>(structuredClone(initial));
5
+ // let data = $state<Partial<T>>(ObjectUtil.deepClone(initial));
5
6
  // let errors = $state<RequestErrors<T>>({});
6
7
  // let touched = $state<Partial<Record<keyof T, boolean>>>({});
7
8
  // let pending = $state(false);
@@ -158,6 +159,3 @@ export {};
158
159
  // };
159
160
  // }
160
161
  //
161
- // function structuredClone<T>(obj: T): T {
162
- // return JSON.parse(JSON.stringify(obj));
163
- // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-net/kit",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",