hh-contracts 0.0.4 → 0.0.5
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/ types/index.ts +1 -0
- package/ types/zod.type.ts +2 -0
- package/build/ types/index.js +17 -0
- package/build/ types/zod.type.js +2 -0
- package/build/constants/icon-keys.constant.js +1 -0
- package/build/constants/navigation-item-type.constant.js +0 -1
- package/build/dto/app-menu/get.query.js +2 -2
- package/build/index.js +1 -0
- package/build/models/icon-key.schema.js +6 -0
- package/build/models/info.schema.js +10 -0
- package/build/models/navigation-item.schemas.js +7 -10
- package/build/transforms/index.js +17 -0
- package/build/transforms/navigation-item.transform.js +24 -0
- package/constants/icon-keys.constant.ts +1 -0
- package/constants/navigation-item-type.constant.ts +0 -1
- package/dto/app-menu/get.query.ts +2 -2
- package/index.ts +1 -0
- package/models/icon-key.schema.ts +4 -0
- package/models/info.schema.ts +8 -0
- package/models/navigation-item.schemas.ts +13 -18
- package/package.json +1 -1
- package/transforms/index.ts +1 -0
- package/transforms/navigation-item.transform.ts +38 -0
package/ types/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './zod.type';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./zod.type"), exports);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetAppMenuQuery = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const transforms_1 = require("../../transforms");
|
|
6
6
|
const GetAppMenuQueryRequestSchema = zod_1.z.object({
|
|
7
7
|
userUuid: zod_1.z.string().uuid(),
|
|
8
8
|
});
|
|
9
9
|
const GetAppMenuQueryResponseSchema = zod_1.z.object({
|
|
10
|
-
appMenu: zod_1.z.array(
|
|
10
|
+
appMenu: zod_1.z.array(transforms_1.NavigationItem),
|
|
11
11
|
});
|
|
12
12
|
var GetAppMenuQuery;
|
|
13
13
|
(function (GetAppMenuQuery) {
|
package/build/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const icon_key_schema_1 = require("./icon-key.schema");
|
|
6
|
+
exports.InfoSchema = zod_1.z.object({
|
|
7
|
+
iconKey: icon_key_schema_1.IconKeySchema.optional(),
|
|
8
|
+
title: zod_1.z.string().min(1),
|
|
9
|
+
description: zod_1.z.string().min(1),
|
|
10
|
+
});
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.NavigationItemEntitySchema = exports.NavigationItemEntityBaseSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const constants_2 = require("../constants");
|
|
7
|
-
const
|
|
7
|
+
const icon_key_schema_1 = require("./icon-key.schema");
|
|
8
|
+
exports.NavigationItemEntityBaseSchema = zod_1.z.object({
|
|
8
9
|
id: zod_1.z.number().int().positive(),
|
|
9
10
|
parentId: zod_1.z.nullable(zod_1.z.number().int().positive()),
|
|
10
11
|
label: zod_1.z.string().min(1),
|
|
11
12
|
description: zod_1.z.nullable(zod_1.z.string().min(1)),
|
|
12
|
-
iconKey: zod_1.z.nullable(
|
|
13
|
+
iconKey: zod_1.z.nullable(icon_key_schema_1.IconKeySchema),
|
|
13
14
|
link: zod_1.z.nullable(zod_1.z.string().min(1)),
|
|
14
15
|
routeComponentKey: zod_1.z.nullable(zod_1.z.nativeEnum(constants_1.RouteComponentKeys)),
|
|
15
16
|
type: zod_1.z.nativeEnum(constants_2.NavigationItemTypes),
|
|
16
|
-
disabled: zod_1.z.boolean()
|
|
17
|
+
disabled: zod_1.z.boolean(),
|
|
17
18
|
order: zod_1.z.number().int().positive(),
|
|
18
19
|
});
|
|
19
|
-
exports.
|
|
20
|
-
children: zod_1.z.array(NavigationItemEntitySchema).optional(),
|
|
20
|
+
exports.NavigationItemEntitySchema = exports.NavigationItemEntityBaseSchema.extend({
|
|
21
|
+
children: zod_1.z.lazy(() => zod_1.z.array(exports.NavigationItemEntitySchema).optional()),
|
|
21
22
|
});
|
|
22
|
-
exports.NavigationItemSchema = exports.NavigationItemEntityWithChildrenSchema.omit({
|
|
23
|
-
parentId: true,
|
|
24
|
-
order: true,
|
|
25
|
-
}).partial({ description: true, link: true, iconKey: true, routeComponentKey: true });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./navigation-item.transform"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.NavigationItem = void 0;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const models_1 = require("../models");
|
|
17
|
+
const NavigationItemBase = models_1.NavigationItemEntityBaseSchema.transform((_a) => {
|
|
18
|
+
var { parentId, description, iconKey, link, routeComponentKey, type, disabled, order } = _a, rest = __rest(_a, ["parentId", "description", "iconKey", "link", "routeComponentKey", "type", "disabled", "order"]);
|
|
19
|
+
return (Object.assign(Object.assign({}, rest), { description: description || undefined, iconKey: iconKey || undefined, link: link || undefined, routeComponentKey: routeComponentKey || undefined, disabled: disabled === null ? undefined : disabled }));
|
|
20
|
+
});
|
|
21
|
+
exports.NavigationItem = zod_1.z.lazy(() => models_1.NavigationItemEntitySchema.transform((_a) => {
|
|
22
|
+
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
23
|
+
return (Object.assign(Object.assign({}, NavigationItemBase.parse(rest)), { children: (children === null || children === void 0 ? void 0 : children.length) ? children.map(child => exports.NavigationItem.parse(child)) : undefined }));
|
|
24
|
+
}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { NavigationItem } from '../../transforms';
|
|
3
3
|
|
|
4
4
|
const GetAppMenuQueryRequestSchema = z.object({
|
|
5
5
|
userUuid: z.string().uuid(),
|
|
6
6
|
});
|
|
7
7
|
const GetAppMenuQueryResponseSchema = z.object({
|
|
8
|
-
appMenu: z.array(
|
|
8
|
+
appMenu: z.array(NavigationItem),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
export namespace GetAppMenuQuery {
|
package/index.ts
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { RouteComponentKeys } from '../constants';
|
|
3
3
|
import { NavigationItemTypes } from '../constants';
|
|
4
|
+
import { IconKeySchema } from './icon-key.schema';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
export const NavigationItemEntityBaseSchema = z.object({
|
|
6
7
|
id: z.number().int().positive(),
|
|
7
8
|
parentId: z.nullable(z.number().int().positive()),
|
|
8
9
|
label: z.string().min(1),
|
|
9
10
|
description: z.nullable(z.string().min(1)),
|
|
10
|
-
iconKey: z.nullable(
|
|
11
|
+
iconKey: z.nullable(IconKeySchema),
|
|
11
12
|
link: z.nullable(z.string().min(1)),
|
|
12
13
|
routeComponentKey: z.nullable(z.nativeEnum(RouteComponentKeys)),
|
|
13
14
|
type: z.nativeEnum(NavigationItemTypes),
|
|
14
|
-
disabled: z.boolean()
|
|
15
|
+
disabled: z.boolean(),
|
|
15
16
|
order: z.number().int().positive(),
|
|
16
17
|
});
|
|
17
18
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export type TNavigationItemEntity = z.infer<typeof NavigationItemEntitySchema>;
|
|
28
|
-
export type TNavigationItemEntityWithChildren = z.infer<
|
|
29
|
-
typeof NavigationItemEntityWithChildrenSchema
|
|
30
|
-
>;
|
|
31
|
-
export type TNavigationItem = z.infer<typeof NavigationItemSchema>;
|
|
19
|
+
export type TNavigationItemEntityBase = z.infer<typeof NavigationItemEntityBaseSchema>;
|
|
20
|
+
export type TNavigationItemEntity = TNavigationItemEntityBase & {
|
|
21
|
+
children?: TNavigationItemEntity[];
|
|
22
|
+
};
|
|
23
|
+
export const NavigationItemEntitySchema: z.ZodType<TNavigationItemEntity> =
|
|
24
|
+
NavigationItemEntityBaseSchema.extend({
|
|
25
|
+
children: z.lazy(() => z.array(NavigationItemEntitySchema).optional()),
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navigation-item.transform';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { NavigationItemEntityBaseSchema, NavigationItemEntitySchema } from '../models';
|
|
3
|
+
|
|
4
|
+
const NavigationItemBase = NavigationItemEntityBaseSchema.transform(
|
|
5
|
+
({
|
|
6
|
+
parentId,
|
|
7
|
+
description,
|
|
8
|
+
iconKey,
|
|
9
|
+
link,
|
|
10
|
+
routeComponentKey,
|
|
11
|
+
type,
|
|
12
|
+
disabled,
|
|
13
|
+
order,
|
|
14
|
+
...rest
|
|
15
|
+
}) => ({
|
|
16
|
+
...rest,
|
|
17
|
+
description: description || undefined,
|
|
18
|
+
iconKey: iconKey || undefined,
|
|
19
|
+
link: link || undefined,
|
|
20
|
+
routeComponentKey: routeComponentKey || undefined,
|
|
21
|
+
disabled: disabled === null ? undefined : disabled,
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
type TInput = z.input<typeof NavigationItemEntityBaseSchema> & {
|
|
26
|
+
children?: TInput[];
|
|
27
|
+
};
|
|
28
|
+
type TOutput = z.output<typeof NavigationItemBase> & {
|
|
29
|
+
children?: TOutput[];
|
|
30
|
+
};
|
|
31
|
+
export type TNavigationItem = z.ZodType<TOutput, z.ZodTypeDef, TInput>;
|
|
32
|
+
|
|
33
|
+
export const NavigationItem: TNavigationItem = z.lazy(() =>
|
|
34
|
+
NavigationItemEntitySchema.transform(({ children, ...rest }) => ({
|
|
35
|
+
...NavigationItemBase.parse(rest),
|
|
36
|
+
children: children?.length ? children.map(child => NavigationItem.parse(child)) : undefined,
|
|
37
|
+
})),
|
|
38
|
+
);
|