hh-contracts 0.0.73 → 0.0.75

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.
Files changed (64) hide show
  1. package/build/common/constants/{icon-keys.constant.js → icon.constants.js} +7 -1
  2. package/build/common/constants/index.js +1 -1
  3. package/build/common/constants/locales.constant.js +3 -3
  4. package/build/hotels/contracts/find-hotel.contract.js +2 -0
  5. package/build/hotels/contracts/index.js +1 -1
  6. package/build/hotels/hotel.model.js +1 -0
  7. package/build/hotels/hotels.api.js +7 -5
  8. package/build/hotels/index.js +2 -1
  9. package/build/hotels/sites/contracts/find-hotel-site-page-by-lang.contract.js +56 -0
  10. package/build/hotels/sites/contracts/index.js +17 -0
  11. package/build/hotels/sites/index.js +17 -0
  12. package/build/hotels/{contracts → themes/contracts}/find-hotel-theme.contract.js +5 -5
  13. package/build/hotels/themes/contracts/index.js +17 -0
  14. package/build/hotels/themes/index.js +1 -0
  15. package/build/index.js +1 -0
  16. package/build/pages/constants/block-type.constant.js +11 -0
  17. package/build/pages/constants/cta-actions.constant.js +7 -0
  18. package/build/pages/constants/hero.constants.js +15 -0
  19. package/build/pages/constants/image-loading.constant.js +8 -0
  20. package/build/pages/constants/index.js +21 -0
  21. package/build/pages/constants/media.constants.js +17 -0
  22. package/build/pages/index.js +18 -0
  23. package/build/pages/models/blocks/base-block.schema.js +44 -0
  24. package/build/pages/models/blocks/block.schemas.js +69 -0
  25. package/build/pages/models/blocks/cta.schema.js +80 -0
  26. package/build/pages/models/blocks/hero-block.schema.js +58 -0
  27. package/build/pages/models/blocks/html-block.schema.js +46 -0
  28. package/build/pages/models/blocks/index.js +22 -0
  29. package/build/pages/models/blocks/media.schemas.js +84 -0
  30. package/build/pages/models/index.js +18 -0
  31. package/build/pages/models/page.schema.js +62 -0
  32. package/common/constants/{icon-keys.constant.ts → icon.constants.ts} +8 -0
  33. package/common/constants/index.ts +1 -1
  34. package/common/constants/locales.constant.ts +1 -1
  35. package/hotels/contracts/find-hotel.contract.ts +1 -0
  36. package/hotels/contracts/index.ts +1 -1
  37. package/hotels/hotel.model.ts +1 -0
  38. package/hotels/hotels.api.ts +6 -4
  39. package/hotels/index.ts +2 -1
  40. package/hotels/sites/contracts/find-hotel-site-page-by-lang.contract.ts +26 -0
  41. package/hotels/sites/contracts/index.ts +1 -0
  42. package/hotels/sites/index.ts +1 -0
  43. package/hotels/themes/contracts/find-hotel-theme.contract.ts +13 -0
  44. package/hotels/themes/contracts/index.ts +1 -0
  45. package/hotels/themes/index.ts +1 -0
  46. package/index.ts +1 -0
  47. package/package.json +1 -1
  48. package/pages/constants/block-type.constant.ts +11 -0
  49. package/pages/constants/cta-actions.constant.ts +5 -0
  50. package/pages/constants/hero.constants.ts +18 -0
  51. package/pages/constants/image-loading.constant.ts +8 -0
  52. package/pages/constants/index.ts +5 -0
  53. package/pages/constants/media.constants.ts +20 -0
  54. package/pages/index.ts +2 -0
  55. package/pages/models/blocks/base-block.schema.ts +11 -0
  56. package/pages/models/blocks/block.schemas.ts +57 -0
  57. package/pages/models/blocks/cta.schema.ts +58 -0
  58. package/pages/models/blocks/hero-block.schema.ts +27 -0
  59. package/pages/models/blocks/html-block.schema.ts +14 -0
  60. package/pages/models/blocks/index.ts +6 -0
  61. package/pages/models/blocks/media.schemas.ts +66 -0
  62. package/pages/models/index.ts +2 -0
  63. package/pages/models/page.schema.ts +31 -0
  64. package/hotels/contracts/find-hotel-theme.contract.ts +0 -13
@@ -0,0 +1,46 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.HtmlTranslationSchema = exports.HtmlBlockSchema = void 0;
37
+ const z = __importStar(require("zod"));
38
+ const constants_1 = require("../../constants");
39
+ const base_block_schema_1 = require("./base-block.schema");
40
+ exports.HtmlBlockSchema = base_block_schema_1.BaseBlockSchema.extend({
41
+ type: z.literal(constants_1.BLOCK_TYPES.html),
42
+ });
43
+ exports.HtmlTranslationSchema = z.object({
44
+ type: z.literal(constants_1.BLOCK_TYPES.html),
45
+ content: z.string().optional(),
46
+ });
@@ -0,0 +1,22 @@
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("./base-block.schema"), exports);
18
+ __exportStar(require("./block.schemas"), exports);
19
+ __exportStar(require("./hero-block.schema"), exports);
20
+ __exportStar(require("./html-block.schema"), exports);
21
+ __exportStar(require("./media.schemas"), exports);
22
+ __exportStar(require("./cta.schema"), exports);
@@ -0,0 +1,84 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.MediaSchema = exports.SliderMediaSchema = exports.SliderImageSchema = exports.VideoMediaSchema = exports.ImageMediaSchema = exports.MediaSourceSchema = void 0;
37
+ const z = __importStar(require("zod"));
38
+ const constants_1 = require("../../constants");
39
+ // Базовые медиа типы
40
+ const BaseMediaSchema = z.object({
41
+ key: z.string(),
42
+ priority: z.array(z.enum(constants_1.MEDIA_PRIORITY_VALUES)).default([constants_1.MEDIA_PRIORITIES.all]),
43
+ });
44
+ exports.MediaSourceSchema = z.object({
45
+ src: z.url(),
46
+ media: z.string().optional(),
47
+ type: z.string().optional(),
48
+ });
49
+ exports.ImageMediaSchema = BaseMediaSchema.extend({
50
+ type: z.literal(constants_1.MEDIA_TYPES.image),
51
+ sources: z.array(exports.MediaSourceSchema),
52
+ alt: z.string().optional(),
53
+ loading: z.enum(constants_1.IMAGE_LOADING_VALUES).default(constants_1.IMAGE_LOADING.lazy),
54
+ });
55
+ exports.VideoMediaSchema = BaseMediaSchema.extend({
56
+ type: z.literal(constants_1.MEDIA_TYPES.video),
57
+ src: z.url(),
58
+ poster: z.url().optional(),
59
+ muted: z.boolean().default(true),
60
+ loop: z.boolean().default(false),
61
+ autoplay: z.boolean().default(true),
62
+ controls: z.boolean().default(false),
63
+ alt: z.string().optional(),
64
+ });
65
+ exports.SliderImageSchema = z.object({
66
+ key: z.string(),
67
+ src: z.url(),
68
+ alt: z.string().optional(),
69
+ title: z.string().optional(),
70
+ description: z.string().optional(),
71
+ });
72
+ exports.SliderMediaSchema = BaseMediaSchema.extend({
73
+ type: z.literal(constants_1.MEDIA_TYPES.slider),
74
+ images: z.array(exports.SliderImageSchema),
75
+ autoplay: z.boolean().default(true),
76
+ interval: z.number().min(1000).default(5000),
77
+ showDots: z.boolean().default(true),
78
+ showArrows: z.boolean().default(true),
79
+ });
80
+ exports.MediaSchema = z.discriminatedUnion('type', [
81
+ exports.ImageMediaSchema,
82
+ exports.VideoMediaSchema,
83
+ exports.SliderMediaSchema,
84
+ ]);
@@ -0,0 +1,18 @@
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("./blocks"), exports);
18
+ __exportStar(require("./page.schema"), exports);
@@ -0,0 +1,62 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PageSchema = exports.PageLangTranslationSchema = void 0;
37
+ const z = __importStar(require("zod"));
38
+ const common_1 = require("../../common");
39
+ const blocks_1 = require("./blocks");
40
+ const MetaSchema = z.object({
41
+ slug: common_1.SlugSchema,
42
+ status: z.enum(common_1.AppStatuses.PAGE_VALUES),
43
+ revision: z.number().int().nonnegative().default(0),
44
+ revalidate: z.number().int().positive().default(300),
45
+ tags: z.array(z.string()).default([]),
46
+ });
47
+ exports.PageLangTranslationSchema = z.object({
48
+ seo: z
49
+ .object({
50
+ title: z.string().optional(),
51
+ description: z.string().optional(),
52
+ ogImage: z.string().optional(),
53
+ })
54
+ .default({}),
55
+ blocks: blocks_1.BlocksTranslationSchema.default({}),
56
+ });
57
+ const TranslationsSchema = z.record(common_1.LanguageKeysSchema, exports.PageLangTranslationSchema);
58
+ exports.PageSchema = z.object({
59
+ meta: MetaSchema,
60
+ blocks: z.array(blocks_1.BlockSchema),
61
+ translations: TranslationsSchema,
62
+ });
@@ -20,6 +20,7 @@ export const ICON_KEYS = {
20
20
  search: 'search',
21
21
  language: 'language',
22
22
  magic: 'magic',
23
+ play: 'play',
23
24
  // close: 'close',
24
25
  // check: 'check',
25
26
 
@@ -30,3 +31,10 @@ export const ICON_KEYS = {
30
31
  } as const;
31
32
  export type TIconKey = (typeof ICON_KEYS)[keyof typeof ICON_KEYS];
32
33
  export const ICON_KEY_VALUES = Object.values(ICON_KEYS) as [TIconKey];
34
+
35
+ export const ICON_POSITION = {
36
+ start: 'start',
37
+ end: 'end',
38
+ } as const;
39
+ export type TIconPosition = (typeof ICON_POSITION)[keyof typeof ICON_POSITION];
40
+ export const ICON_POSITION_VALUES = Object.values(ICON_POSITION) as [TIconPosition];
@@ -4,7 +4,7 @@ export * from './app-statuses.constant';
4
4
  export * from './default-pagination-config.constant';
5
5
  export * from './entity.constant';
6
6
  export * from './http-method.constant';
7
- export * from './icon-keys.constant';
7
+ export * from './icon.constants';
8
8
  export * from './kind-of-app.constant';
9
9
  export * from './locales.constant';
10
10
  export * from './navigation-item-type.constant';
@@ -1,4 +1,4 @@
1
- import { ICON_KEYS } from './icon-keys.constant';
1
+ import { ICON_KEYS } from './icon.constants';
2
2
 
3
3
  export const LANGUAGES = {
4
4
  en: {
@@ -0,0 +1 @@
1
+ export namespace FindHotelContract {}
@@ -1 +1 @@
1
- export * from './find-hotel-theme.contract';
1
+ export * from './find-hotel.contract';
@@ -4,6 +4,7 @@ import { LANGUAGE_KEYS, TimestampSchema, AppStatuses, SlugSchema } from '../comm
4
4
  export const HotelPersistedSchema = z
5
5
  .object({
6
6
  id: z.uuid(),
7
+ //убрать из модели так как у одного отеля может быть несколько юр лиц
7
8
  companyId: z.uuid(),
8
9
  slug: SlugSchema,
9
10
  status: z.enum(AppStatuses.HOTEL_VALUES),
@@ -1,10 +1,12 @@
1
1
  import { createApi, TController } from '../common/utils';
2
2
 
3
- export const HOTELS_CONTROLLER = {
4
- prefix: 'hotels',
3
+ export const HOTELS_BY_SLUG_CONTROLLER = {
4
+ prefix: 'hotels/by-slug',
5
5
  endpoints: {
6
- findTheme: ':id/theme',
6
+ findTheme: ':hotelSlug/theme',
7
+ findSitePageByLang: ':hotelSlug/sites/pages/:slug',
8
+ findSitePage: ':hotelSlug/sites/pages/:slug',
7
9
  },
8
10
  } as const satisfies TController;
9
11
 
10
- export const HOTELS_API = createApi(HOTELS_CONTROLLER);
12
+ export const HOTELS_BY_SLUG_API = createApi(HOTELS_BY_SLUG_CONTROLLER);
package/hotels/index.ts CHANGED
@@ -1,4 +1,5 @@
1
+ export * from './contracts';
2
+ export * from './sites';
1
3
  export * from './themes';
2
4
  export * from './hotel.model';
3
5
  export * from './hotels.api';
4
- export * from './contracts';
@@ -0,0 +1,26 @@
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS, LanguageKeysSchema } from '../../../common';
3
+ import { HOTELS_BY_SLUG_API, HOTELS_BY_SLUG_CONTROLLER } from '../../hotels.api';
4
+ import { PageLangTranslationSchema, PageSchema } from '../../../pages';
5
+
6
+ const FindHotelSitePageByLangContractRequestSchema = z.object({
7
+ lang: LanguageKeysSchema,
8
+ });
9
+
10
+ const FindHotelSitePageByLangContractResponseSchema = PageSchema.omit({
11
+ translations: true,
12
+ }).extend({
13
+ translation: PageLangTranslationSchema,
14
+ });
15
+
16
+ export namespace FindHotelSitePageByLangContract {
17
+ export const getUrl = HOTELS_BY_SLUG_API.findSitePageByLang;
18
+ export const endpoint = HOTELS_BY_SLUG_CONTROLLER.endpoints.findSitePageByLang;
19
+ export const httpMethod = HTTP_METHODS.get;
20
+
21
+ export const RequestSchema = FindHotelSitePageByLangContractRequestSchema;
22
+ export type TRequest = z.infer<typeof RequestSchema>;
23
+
24
+ export const ResponseSchema = FindHotelSitePageByLangContractResponseSchema;
25
+ export type TResponse = z.infer<typeof ResponseSchema>;
26
+ }
@@ -0,0 +1 @@
1
+ export * from './find-hotel-site-page-by-lang.contract';
@@ -0,0 +1 @@
1
+ export * from './contracts';
@@ -0,0 +1,13 @@
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS } from '../../../common';
3
+ import { ThemePersistedSchema } from '../theme.models';
4
+ import { HOTELS_BY_SLUG_API, HOTELS_BY_SLUG_CONTROLLER } from '../../hotels.api';
5
+
6
+ export namespace FindHotelThemeContract {
7
+ export const getUrl = HOTELS_BY_SLUG_API.findTheme;
8
+ export const endpoint = HOTELS_BY_SLUG_CONTROLLER.endpoints.findTheme;
9
+ export const httpMethod = HTTP_METHODS.get;
10
+
11
+ export const ResponseSchema = ThemePersistedSchema;
12
+ export type TResponse = z.infer<typeof ResponseSchema>;
13
+ }
@@ -0,0 +1 @@
1
+ export * from './find-hotel-theme.contract';
@@ -1,2 +1,3 @@
1
1
  export * from './constants';
2
2
  export * from './theme.models';
3
+ export * from './contracts';
package/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from './hotels';
2
2
  export * from './common';
3
3
  export * from './companies';
4
4
  export * from './app-menu';
5
+ export * from './pages';
5
6
  export * from './permissions';
6
7
  export * from './roles';
7
8
  export * from './tenants';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-contracts",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -0,0 +1,11 @@
1
+ export const BLOCK_TYPES = {
2
+ hero: 'hero',
3
+ html: 'html',
4
+ linkCta: 'link-cta',
5
+ buttonCta: 'button-cta',
6
+ container: 'container',
7
+ } as const;
8
+
9
+ export type TBlockType = (typeof BLOCK_TYPES)[keyof typeof BLOCK_TYPES];
10
+
11
+ export const BLOCK_TYPE_VALUES = Object.values(BLOCK_TYPES) as [TBlockType, ...TBlockType[]];
@@ -0,0 +1,5 @@
1
+ export const CTA_ACTIONS = {
2
+ book: 'book',
3
+ } as const;
4
+ export type TCTAAction = (typeof CTA_ACTIONS)[keyof typeof CTA_ACTIONS];
5
+ export const CTA_ACTIONS_VALUES = Object.values(CTA_ACTIONS) as [TCTAAction];
@@ -0,0 +1,18 @@
1
+ export const HERO_VARIANTS = {
2
+ headerOnMedia: 'header-on-media',
3
+ } as const;
4
+ export type THeroVariants = (typeof HERO_VARIANTS)[keyof typeof HERO_VARIANTS];
5
+ export const HERO_VARIANT_VALUES = Object.values(HERO_VARIANTS) as [
6
+ THeroVariants,
7
+ ...THeroVariants[],
8
+ ];
9
+
10
+ export const HERO_HEIGHT = {
11
+ screen50: '50dvh',
12
+ screen75: '75dvh',
13
+ screen80: '80dvh',
14
+ screen90: '90dvh',
15
+ screen100: '100dvh',
16
+ } as const;
17
+ export type THeroHeight = (typeof HERO_HEIGHT)[keyof typeof HERO_HEIGHT];
18
+ export const HERO_HEIGHT_VALUES = Object.values(HERO_HEIGHT) as [THeroHeight, ...THeroHeight[]];
@@ -0,0 +1,8 @@
1
+ export const IMAGE_LOADING = {
2
+ lazy: 'lazy',
3
+ eager: 'eager',
4
+ } as const;
5
+
6
+ export type TImageLoading = (typeof IMAGE_LOADING)[keyof typeof IMAGE_LOADING];
7
+
8
+ export const IMAGE_LOADING_VALUES = Object.values(IMAGE_LOADING) as [TImageLoading, ...TImageLoading[]];
@@ -0,0 +1,5 @@
1
+ export * from './block-type.constant';
2
+ export * from './cta-actions.constant';
3
+ export * from './hero.constants';
4
+ export * from './image-loading.constant';
5
+ export * from './media.constants';
@@ -0,0 +1,20 @@
1
+ export const MEDIA_TYPES = {
2
+ image: 'image',
3
+ video: 'video',
4
+ slider: 'slider',
5
+ } as const;
6
+ export type TMediaType = (typeof MEDIA_TYPES)[keyof typeof MEDIA_TYPES];
7
+ export const MEDIA_TYPE_VALUES = Object.values(MEDIA_TYPES) as [TMediaType, ...TMediaType[]];
8
+
9
+ // Добавляем приоритеты для адаптивности
10
+ export const MEDIA_PRIORITIES = {
11
+ desktop: 'desktop',
12
+ mobile: 'mobile',
13
+ tablet: 'tablet',
14
+ all: 'all', // универсальное медиа
15
+ } as const;
16
+ export type TMediaPriority = (typeof MEDIA_PRIORITIES)[keyof typeof MEDIA_PRIORITIES];
17
+ export const MEDIA_PRIORITY_VALUES = Object.values(MEDIA_PRIORITIES) as [
18
+ TMediaPriority,
19
+ ...TMediaPriority[],
20
+ ];
package/pages/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './constants';
2
+ export * from './models';
@@ -0,0 +1,11 @@
1
+ import * as z from 'zod';
2
+ import { BLOCK_TYPE_VALUES } from '../../constants';
3
+
4
+ export const BaseBlockSchema = z.object({
5
+ id: z.uuid(),
6
+ key: z.string(),
7
+ order: z.number().int().nonnegative(),
8
+ type: z.enum(BLOCK_TYPE_VALUES),
9
+ });
10
+
11
+ export type TBaseBlock = z.infer<typeof BaseBlockSchema>;
@@ -0,0 +1,57 @@
1
+ import * as z from 'zod';
2
+ import { HeroTranslationSchema, HeroBlockSchema, THeroBlock } from './hero-block.schema';
3
+ import { HtmlBlockSchema, HtmlTranslationSchema, THtmlBlock } from './html-block.schema';
4
+ import {
5
+ ButtonCtaBlockSchema,
6
+ ButtonCtaTranslationSchema,
7
+ CtaBlockSchema,
8
+ CtaTranslationSchema,
9
+ LinkCtaBlockSchema,
10
+ LinkCtaTranslationSchema,
11
+ TCtaBlock,
12
+ } from './cta.schema';
13
+ import { BLOCK_TYPES } from '../../constants';
14
+ import { BaseBlockSchema } from './base-block.schema';
15
+ import { TBaseBlock } from './base-block.schema';
16
+
17
+ // Контейнерный блок: тип с рекурсией по детям
18
+ export type TContainerBlock = TBaseBlock & {
19
+ type: typeof BLOCK_TYPES.container;
20
+ config?: { gap?: number };
21
+ children: TBlock[];
22
+ };
23
+ export const ContainerBlockSchema = BaseBlockSchema.extend({
24
+ type: z.literal(BLOCK_TYPES.container),
25
+ config: z.object({
26
+ gap: z.number().int().nonnegative().default(0),
27
+ }),
28
+ children: z.array(z.lazy(() => BlockSchema)),
29
+ });
30
+ export const ContainerTranslationSchema = z.object({
31
+ type: z.literal(BLOCK_TYPES.container),
32
+ });
33
+
34
+ // Общий тип блока: union с контейнером
35
+ export type TBlock = THeroBlock | TContainerBlock | THtmlBlock | TCtaBlock;
36
+ // Схема блока (union) с явной аннотацией и z.lazy
37
+ export const BlockSchema: z.ZodType<TBlock> = z.lazy(() =>
38
+ z.discriminatedUnion('type', [
39
+ HeroBlockSchema,
40
+ ContainerBlockSchema,
41
+ HtmlBlockSchema,
42
+ LinkCtaBlockSchema,
43
+ ButtonCtaBlockSchema,
44
+ ]),
45
+ );
46
+
47
+ export const BlockTranslationSchema = z.discriminatedUnion('type', [
48
+ HeroTranslationSchema,
49
+ ContainerTranslationSchema,
50
+ HtmlTranslationSchema,
51
+ LinkCtaTranslationSchema,
52
+ ButtonCtaTranslationSchema,
53
+ ]);
54
+ export type TBlockTranslation = z.infer<typeof BlockTranslationSchema>;
55
+ // Переводы по ключу блока (контейнер не имеет собственных переводов)
56
+ export const BlocksTranslationSchema = z.record(z.string(), BlockTranslationSchema);
57
+ export type TBlocksTranslation = z.infer<typeof BlocksTranslationSchema>;
@@ -0,0 +1,58 @@
1
+ import * as z from 'zod';
2
+ import { BLOCK_TYPES, CTA_ACTIONS_VALUES } from '../../constants';
3
+ import { ICON_POSITION_VALUES, IconKeySchema } from '../../../common';
4
+ import { BaseBlockSchema } from './base-block.schema';
5
+
6
+ const BaseCtaConfigSchema = z.object({
7
+ key: z.string(),
8
+ iconKey: IconKeySchema.optional(),
9
+ iconPosition: z.enum(ICON_POSITION_VALUES).optional(),
10
+ });
11
+
12
+ const BaseCtaBlockSchema = BaseBlockSchema.extend({
13
+ ...BaseCtaConfigSchema.omit({ key: true }).shape,
14
+ });
15
+
16
+ const CtaLinkSchema = z.object({
17
+ type: z.literal(BLOCK_TYPES.linkCta),
18
+ href: z.url(),
19
+ });
20
+ const LinkCtaConfigSchema = BaseCtaConfigSchema.extend(CtaLinkSchema.shape);
21
+ export const LinkCtaBlockSchema = BaseCtaBlockSchema.extend(CtaLinkSchema.shape);
22
+
23
+ const CtaButtonSchema = z.object({
24
+ type: z.literal(BLOCK_TYPES.buttonCta),
25
+ action: z.enum(CTA_ACTIONS_VALUES).optional(),
26
+ });
27
+ const ButtonCtaConfigSchema = BaseCtaConfigSchema.extend(CtaButtonSchema.shape);
28
+ export const ButtonCtaBlockSchema = BaseCtaBlockSchema.extend(CtaButtonSchema.shape);
29
+
30
+ export const CtaBlockSchema = z.discriminatedUnion('type', [
31
+ LinkCtaBlockSchema,
32
+ ButtonCtaBlockSchema,
33
+ ]);
34
+ export type TCtaBlock = z.infer<typeof CtaBlockSchema>;
35
+
36
+ export const CtaConfigSchema = z.discriminatedUnion('type', [
37
+ LinkCtaConfigSchema,
38
+ ButtonCtaConfigSchema,
39
+ ]);
40
+ export type TCtaConfig = z.infer<typeof CtaConfigSchema>;
41
+
42
+ export const CtaTranslationSchema = z.object({
43
+ label: z.string().optional(),
44
+ iconAlt: z.string().optional(),
45
+ });
46
+ export type TCtaTranslation = z.infer<typeof CtaTranslationSchema>;
47
+
48
+ export const LinkCtaTranslationSchema = z.object({
49
+ type: z.literal(BLOCK_TYPES.linkCta),
50
+ ...CtaTranslationSchema.shape,
51
+ });
52
+ export type TLinkCtaTranslation = z.infer<typeof LinkCtaTranslationSchema>;
53
+
54
+ export const ButtonCtaTranslationSchema = z.object({
55
+ type: z.literal(BLOCK_TYPES.buttonCta),
56
+ ...CtaTranslationSchema.shape,
57
+ });
58
+ export type TButtonCtaTranslation = z.infer<typeof ButtonCtaTranslationSchema>;
@@ -0,0 +1,27 @@
1
+ import * as z from 'zod';
2
+ import { HERO_VARIANT_VALUES, HERO_HEIGHT_VALUES, BLOCK_TYPES } from '../../constants';
3
+ import { BaseBlockSchema } from './base-block.schema';
4
+ import { MediaSchema } from './media.schemas';
5
+ import { CtaConfigSchema, CtaTranslationSchema } from './cta.schema';
6
+
7
+ export const HeroBlockSchema = BaseBlockSchema.extend({
8
+ type: z.literal(BLOCK_TYPES.hero),
9
+ variant: z.enum(HERO_VARIANT_VALUES),
10
+ config: z.object({
11
+ height: z.enum(HERO_HEIGHT_VALUES),
12
+ media: z.array(MediaSchema),
13
+ ctas: z.array(CtaConfigSchema),
14
+ }),
15
+ });
16
+
17
+ export type THeroBlock = z.infer<typeof HeroBlockSchema>;
18
+
19
+ export const HeroTranslationSchema = z.object({
20
+ type: z.literal(BLOCK_TYPES.hero),
21
+ headline: z.string(),
22
+ subheadline: z.string().optional(),
23
+ description: z.string().optional(),
24
+ media: z.record(z.string(), z.object({ alt: z.string() })).optional(),
25
+ ctas: z.record(z.string(), CtaTranslationSchema).optional(),
26
+ });
27
+ export type THeroTranslation = z.infer<typeof HeroTranslationSchema>;
@@ -0,0 +1,14 @@
1
+ import * as z from 'zod';
2
+ import { BLOCK_TYPES } from '../../constants';
3
+ import { BaseBlockSchema } from './base-block.schema';
4
+
5
+ export const HtmlBlockSchema = BaseBlockSchema.extend({
6
+ type: z.literal(BLOCK_TYPES.html),
7
+ });
8
+
9
+ export const HtmlTranslationSchema = z.object({
10
+ type: z.literal(BLOCK_TYPES.html),
11
+ content: z.string().optional(),
12
+ });
13
+ export type THtmlBlock = z.infer<typeof HtmlBlockSchema>;
14
+ export type THtmlTranslation = z.infer<typeof HtmlTranslationSchema>;
@@ -0,0 +1,6 @@
1
+ export * from './base-block.schema';
2
+ export * from './block.schemas';
3
+ export * from './hero-block.schema';
4
+ export * from './html-block.schema';
5
+ export * from './media.schemas';
6
+ export * from './cta.schema';