hh-contracts 0.0.5 → 0.0.6
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/build/constants/icon-keys.constant.js +3 -0
- package/build/index.js +1 -0
- package/build/models/navigation-item.schemas.js +2 -0
- package/build/{ types/index.js → types/index.js} +1 -0
- package/build/types/zod.type.js +2 -0
- package/constants/icon-keys.constant.ts +3 -0
- package/index.ts +1 -0
- package/models/navigation-item.schemas.ts +3 -0
- package/package.json +1 -1
- package/transforms/navigation-item.transform.ts +3 -2
- package/types/index.ts +2 -0
- package/types/optionalized.type.ts +40 -0
- package/ types/index.ts +0 -1
- /package/build/{ types/zod.type.js → types/optionalized.type.js} +0 -0
- /package/{ types → types}/zod.type.ts +0 -0
package/build/index.js
CHANGED
|
@@ -16,6 +16,8 @@ exports.NavigationItemEntityBaseSchema = zod_1.z.object({
|
|
|
16
16
|
type: zod_1.z.nativeEnum(constants_2.NavigationItemTypes),
|
|
17
17
|
disabled: zod_1.z.boolean(),
|
|
18
18
|
order: zod_1.z.number().int().positive(),
|
|
19
|
+
createdAt: zod_1.z.date(),
|
|
20
|
+
updatedAt: zod_1.z.date(),
|
|
19
21
|
});
|
|
20
22
|
exports.NavigationItemEntitySchema = exports.NavigationItemEntityBaseSchema.extend({
|
|
21
23
|
children: zod_1.z.lazy(() => zod_1.z.array(exports.NavigationItemEntitySchema).optional()),
|
|
@@ -2,6 +2,9 @@ export const IconKeys = {
|
|
|
2
2
|
EyeIcon: 'EyeIcon',
|
|
3
3
|
EyeSlashIcon: 'EyeSlashIcon',
|
|
4
4
|
ChevronRightIcon: 'ChevronRightIcon',
|
|
5
|
+
LogoIcon: 'LogoIcon',
|
|
6
|
+
HousekeepingIcon: 'HousekeepingIcon',
|
|
7
|
+
Bars3CenterLeftIcon: 'Bars3CenterLeftIcon',
|
|
5
8
|
} as const;
|
|
6
9
|
|
|
7
10
|
export type TIconKey = (typeof IconKeys)[keyof typeof IconKeys];
|
package/index.ts
CHANGED
|
@@ -14,6 +14,9 @@ export const NavigationItemEntityBaseSchema = z.object({
|
|
|
14
14
|
type: z.nativeEnum(NavigationItemTypes),
|
|
15
15
|
disabled: z.boolean(),
|
|
16
16
|
order: z.number().int().positive(),
|
|
17
|
+
|
|
18
|
+
createdAt: z.date(),
|
|
19
|
+
updatedAt: z.date(),
|
|
17
20
|
});
|
|
18
21
|
|
|
19
22
|
export type TNavigationItemEntityBase = z.infer<typeof NavigationItemEntityBaseSchema>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { NavigationItemEntityBaseSchema, NavigationItemEntitySchema } from '../models';
|
|
3
|
+
import { TDeepOptionalize } from '../types';
|
|
3
4
|
|
|
4
5
|
const NavigationItemBase = NavigationItemEntityBaseSchema.transform(
|
|
5
6
|
({
|
|
@@ -28,11 +29,11 @@ type TInput = z.input<typeof NavigationItemEntityBaseSchema> & {
|
|
|
28
29
|
type TOutput = z.output<typeof NavigationItemBase> & {
|
|
29
30
|
children?: TOutput[];
|
|
30
31
|
};
|
|
31
|
-
export type TNavigationItem = z.ZodType<TOutput, z.ZodTypeDef, TInput>;
|
|
32
32
|
|
|
33
|
-
export const NavigationItem:
|
|
33
|
+
export const NavigationItem: z.ZodType<TOutput, z.ZodTypeDef, TInput> = z.lazy(() =>
|
|
34
34
|
NavigationItemEntitySchema.transform(({ children, ...rest }) => ({
|
|
35
35
|
...NavigationItemBase.parse(rest),
|
|
36
36
|
children: children?.length ? children.map(child => NavigationItem.parse(child)) : undefined,
|
|
37
37
|
})),
|
|
38
38
|
);
|
|
39
|
+
export type TNavigationItem = TDeepOptionalize<z.infer<typeof NavigationItem>>;
|
package/types/index.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility type that converts properties of T that include undefined to optional properties.
|
|
3
|
+
*
|
|
4
|
+
* Для каждого ключа K, если undefined расширяет T[K] (то есть T[K] содержит undefined),
|
|
5
|
+
* то в результирующем типе свойство K становится опциональным, а его тип – Exclude<T[K], undefined>.
|
|
6
|
+
*/
|
|
7
|
+
export type TOptionalize<T> = {
|
|
8
|
+
[K in keyof T as undefined extends T[K] ? K : never]?: T[K];
|
|
9
|
+
} & {
|
|
10
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Helper type to merge intersections into a single object type.
|
|
15
|
+
*/
|
|
16
|
+
export type TMerge<T> = { [K in keyof T]: T[K] };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Итоговый утилитарный тип, который превращает свойства с undefined в опциональные.
|
|
20
|
+
*/
|
|
21
|
+
export type TOptionalized<T> = TMerge<TOptionalize<T>>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* DeepOptionalize: Рекурсивно применяет Optionalize ко всем вложенным объектам и массивам.
|
|
25
|
+
*/
|
|
26
|
+
export type TDeepOptionalize<T> = T extends Date | null
|
|
27
|
+
? T
|
|
28
|
+
: T extends Array<infer U>
|
|
29
|
+
? Array<TDeepOptionalize<U>>
|
|
30
|
+
: T extends object
|
|
31
|
+
? TMerge<
|
|
32
|
+
{
|
|
33
|
+
// Если свойство не допускает undefined, оставляем его обязательным
|
|
34
|
+
[K in keyof T as undefined extends T[K] ? never : K]: TDeepOptionalize<T[K]>;
|
|
35
|
+
} & {
|
|
36
|
+
// Если свойство допускает undefined, делаем его опциональным
|
|
37
|
+
[K in keyof T as undefined extends T[K] ? K : never]?: TDeepOptionalize<T[K]>;
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
: T;
|
package/ types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './zod.type';
|
|
File without changes
|
|
File without changes
|