hh-contracts 0.0.94 → 0.0.96

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 (110) hide show
  1. package/build/common/constants/icon.constants.js +5 -4
  2. package/build/common/models/domain-name.schema.js +43 -0
  3. package/build/common/models/index.js +2 -0
  4. package/build/common/models/timestamp.schemas.js +4 -1
  5. package/build/common/models/timezone.schema.js +44 -0
  6. package/build/hotels/amenities/hotel-amenity.model.js +43 -0
  7. package/build/hotels/amenities/index.js +17 -0
  8. package/build/hotels/constants/hotel-amenity.constant.js +15 -0
  9. package/build/hotels/constants/hotel-contact-type.constant.js +9 -0
  10. package/build/hotels/constants/hotel-feature.constant.js +11 -0
  11. package/build/hotels/constants/hotel-integration-provider.constant.js +7 -0
  12. package/build/hotels/constants/hotel-policy-type.constant.js +11 -0
  13. package/build/hotels/constants/hotel-rating-source.constant.js +9 -0
  14. package/build/hotels/constants/index.js +22 -0
  15. package/build/hotels/contacts/hotel-contact.model.js +48 -0
  16. package/build/hotels/contacts/index.js +17 -0
  17. package/build/hotels/contracts/create-hotel.contract.js +19 -0
  18. package/build/hotels/contracts/delete-hotel.contract.js +46 -0
  19. package/build/hotels/contracts/find-hotel.contract.js +18 -0
  20. package/build/hotels/contracts/find-many-hotels.contract.js +67 -0
  21. package/build/hotels/contracts/index.js +4 -0
  22. package/build/hotels/contracts/update-hotel.contract.js +15 -0
  23. package/build/hotels/{hotel.model.js → features/hotel-feature.model.js} +8 -9
  24. package/build/hotels/features/index.js +17 -0
  25. package/build/hotels/hotel.models.js +79 -0
  26. package/build/hotels/hotels.api.js +10 -7
  27. package/build/hotels/index.js +10 -1
  28. package/build/hotels/integrations/hotel-integration.model.js +59 -0
  29. package/build/hotels/integrations/hotel-integrations.api.js +17 -0
  30. package/build/hotels/integrations/index.js +18 -0
  31. package/build/hotels/location/hotel-location.model.js +51 -0
  32. package/build/hotels/location/index.js +17 -0
  33. package/build/hotels/policies/hotel-policy.model.js +49 -0
  34. package/build/hotels/policies/index.js +17 -0
  35. package/build/hotels/ratings/hotel-rating.model.js +48 -0
  36. package/build/hotels/ratings/index.js +17 -0
  37. package/build/hotels/settings/contracts/find-hotel-domain-settings.contract.js +13 -0
  38. package/build/hotels/settings/contracts/index.js +18 -0
  39. package/build/hotels/settings/contracts/update-hotel-domain-settings.contract.js +14 -0
  40. package/build/hotels/settings/hotel-domain-settings.api.js +12 -0
  41. package/build/hotels/settings/hotel-domain-settings.schema.js +49 -0
  42. package/build/hotels/settings/index.js +19 -0
  43. package/build/hotels/sites/contracts/find-hotel-site-page-by-lang.contract.js +3 -3
  44. package/build/hotels/sites/hotel-pages.api.js +24 -0
  45. package/build/hotels/sites/index.js +1 -0
  46. package/build/hotels/themes/contracts/find-hotel-theme.contract.js +3 -3
  47. package/build/hotels/themes/hotel-themes.api.js +20 -0
  48. package/build/hotels/themes/index.js +1 -0
  49. package/build/permissions/contracts/delete-permission.contract.js +35 -2
  50. package/build/permissions/contracts/find-permission.contract.js +0 -7
  51. package/build/permissions/permission.models.js +2 -18
  52. package/build/roles/contracts/delete-role.contract.js +35 -2
  53. package/build/translate/contracts/translate-object.contract.js +3 -0
  54. package/common/constants/icon.constants.ts +5 -4
  55. package/common/models/domain-name.schema.ts +15 -0
  56. package/common/models/index.ts +2 -0
  57. package/common/models/timestamp.schemas.ts +4 -0
  58. package/common/models/timezone.schema.ts +11 -0
  59. package/hotels/amenities/hotel-amenity.model.ts +9 -0
  60. package/hotels/amenities/index.ts +1 -0
  61. package/hotels/constants/hotel-amenity.constant.ts +18 -0
  62. package/hotels/constants/hotel-contact-type.constant.ts +12 -0
  63. package/hotels/constants/hotel-feature.constant.ts +14 -0
  64. package/hotels/constants/hotel-integration-provider.constant.ts +11 -0
  65. package/hotels/constants/hotel-policy-type.constant.ts +15 -0
  66. package/hotels/constants/hotel-rating-source.constant.ts +12 -0
  67. package/hotels/constants/index.ts +6 -0
  68. package/hotels/contacts/hotel-contact.model.ts +15 -0
  69. package/hotels/contacts/index.ts +1 -0
  70. package/hotels/contracts/create-hotel.contract.ts +21 -0
  71. package/hotels/contracts/delete-hotel.contract.ts +12 -0
  72. package/hotels/contracts/find-hotel.contract.ts +22 -1
  73. package/hotels/contracts/find-many-hotels.contract.ts +43 -0
  74. package/hotels/contracts/index.ts +4 -0
  75. package/hotels/contracts/update-hotel.contract.ts +17 -0
  76. package/hotels/features/hotel-feature.model.ts +14 -0
  77. package/hotels/features/index.ts +1 -0
  78. package/hotels/hotel.models.ts +60 -0
  79. package/hotels/hotels.api.ts +9 -6
  80. package/hotels/index.ts +10 -1
  81. package/hotels/integrations/hotel-integration.model.ts +29 -0
  82. package/hotels/integrations/hotel-integrations.api.ts +16 -0
  83. package/hotels/integrations/index.ts +2 -0
  84. package/hotels/location/hotel-location.model.ts +17 -0
  85. package/hotels/location/index.ts +1 -0
  86. package/hotels/policies/hotel-policy.model.ts +16 -0
  87. package/hotels/policies/index.ts +1 -0
  88. package/hotels/ratings/hotel-rating.model.ts +15 -0
  89. package/hotels/ratings/index.ts +1 -0
  90. package/hotels/settings/contracts/find-hotel-domain-settings.contract.ts +13 -0
  91. package/hotels/settings/contracts/index.ts +2 -0
  92. package/hotels/settings/contracts/update-hotel-domain-settings.contract.ts +19 -0
  93. package/hotels/settings/hotel-domain-settings.api.ts +11 -0
  94. package/hotels/settings/hotel-domain-settings.schema.ts +24 -0
  95. package/hotels/settings/index.ts +3 -0
  96. package/hotels/sites/contracts/find-hotel-site-page-by-lang.contract.ts +3 -3
  97. package/hotels/sites/hotel-pages.api.ts +24 -0
  98. package/hotels/sites/index.ts +1 -0
  99. package/hotels/themes/contracts/find-hotel-theme.contract.ts +3 -3
  100. package/hotels/themes/hotel-themes.api.ts +20 -0
  101. package/hotels/themes/index.ts +1 -0
  102. package/package.json +1 -1
  103. package/permissions/contracts/delete-permission.contract.ts +1 -2
  104. package/permissions/contracts/find-permission.contract.ts +0 -8
  105. package/permissions/permission.models.ts +1 -19
  106. package/roles/contracts/delete-role.contract.ts +1 -2
  107. package/translate/contracts/translate-object.contract.ts +3 -0
  108. package/build/permissions/permission.response.schema.js +0 -8
  109. package/hotels/hotel.model.ts +0 -14
  110. package/permissions/permission.response.schema.ts +0 -8
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./constants"), exports);
18
18
  __exportStar(require("./theme.models"), exports);
19
+ __exportStar(require("./hotel-themes.api"), exports);
19
20
  __exportStar(require("./contracts"), exports);
@@ -1,13 +1,46 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.DeletePermissionContract = void 0;
37
+ const z = __importStar(require("zod"));
4
38
  const common_1 = require("../../common");
5
39
  const permissions_api_1 = require("../permissions.api");
6
- const permission_models_1 = require("../permission.models");
7
40
  var DeletePermissionContract;
8
41
  (function (DeletePermissionContract) {
9
42
  DeletePermissionContract.getUrl = permissions_api_1.PERMISSIONS_API.delete;
10
43
  DeletePermissionContract.endpoint = permissions_api_1.PERMISSIONS_CONTROLLER.endpoints.delete;
11
44
  DeletePermissionContract.httpMethod = common_1.HTTP_METHODS.delete;
12
- DeletePermissionContract.ResponseSchema = permission_models_1.PermissionWithTranslationsSchema;
45
+ DeletePermissionContract.ResponseSchema = z.void();
13
46
  })(DeletePermissionContract || (exports.DeletePermissionContract = DeletePermissionContract = {}));
@@ -4,17 +4,10 @@ exports.FindPermissionContract = void 0;
4
4
  const common_1 = require("../../common");
5
5
  const permission_models_1 = require("../permission.models");
6
6
  const permissions_api_1 = require("../permissions.api");
7
- // const FindPermissionContractResponseSchema = PersistedPermissionSchema.transform(
8
- // ({ conditions, ...permission }) => ({
9
- // ...permission,
10
- // conditions: conditions === null ? undefined : conditions,
11
- // }),
12
- // );
13
7
  var FindPermissionContract;
14
8
  (function (FindPermissionContract) {
15
9
  FindPermissionContract.getUrl = permissions_api_1.PERMISSIONS_API.find;
16
10
  FindPermissionContract.endpoint = permissions_api_1.PERMISSIONS_CONTROLLER.endpoints.find;
17
11
  FindPermissionContract.httpMethod = common_1.HTTP_METHODS.get;
18
- // export const ResponseSchema = FindPermissionContractResponseSchema;
19
12
  FindPermissionContract.ResponseSchema = permission_models_1.PermissionWithTranslationsSchema;
20
13
  })(FindPermissionContract || (exports.FindPermissionContract = FindPermissionContract = {}));
@@ -33,31 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.PermissionListItemSchema = exports.PermissionWithTranslationsSchema = exports.PermissionTranslationsSchema = exports.PermissionPersistedSchema = exports.JsonConditionsSchema = void 0;
36
+ exports.PermissionListItemSchema = exports.PermissionWithTranslationsSchema = exports.PermissionTranslationsSchema = exports.PermissionPersistedSchema = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  const common_1 = require("../common");
39
- exports.JsonConditionsSchema = z
40
- .string()
41
- .transform(val => (val === '' ? undefined : val))
42
- .optional()
43
- .nullable()
44
- .refine(val => {
45
- if (val === undefined || val === null)
46
- return true;
47
- try {
48
- JSON.parse(val);
49
- return true;
50
- }
51
- catch {
52
- return false;
53
- }
54
- }, { params: { messageKey: 'errors.validation.invalidJson' } });
55
39
  exports.PermissionPersistedSchema = z
56
40
  .object({
57
41
  id: z.uuid(),
58
42
  action: z.enum(common_1.AppAbility.ACTION_VALUES),
59
43
  subject: z.enum(common_1.AppAbility.SUBJECT_VALUES),
60
- conditions: exports.JsonConditionsSchema,
44
+ conditions: z.json().optional().nullable(),
61
45
  })
62
46
  .extend(common_1.TimestampSchema.shape);
63
47
  // V2 translations: all translatable fields are inside per-language translation object
@@ -1,13 +1,46 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.DeleteRoleContract = void 0;
37
+ const z = __importStar(require("zod"));
4
38
  const common_1 = require("../../common");
5
- const role_models_1 = require("../role.models");
6
39
  const roles_api_1 = require("../roles.api");
7
40
  var DeleteRoleContract;
8
41
  (function (DeleteRoleContract) {
9
42
  DeleteRoleContract.getUrl = roles_api_1.ROLES_API.delete;
10
43
  DeleteRoleContract.endpoint = roles_api_1.ROLES_CONTROLLER.endpoints.delete;
11
44
  DeleteRoleContract.httpMethod = common_1.HTTP_METHODS.delete;
12
- DeleteRoleContract.ResponseSchema = role_models_1.RoleWithTranslationsSchema;
45
+ DeleteRoleContract.ResponseSchema = z.void();
13
46
  })(DeleteRoleContract || (exports.DeleteRoleContract = DeleteRoleContract = {}));
@@ -40,6 +40,7 @@ const translate_api_1 = require("../translate.api");
40
40
  const permissions_1 = require("../../permissions");
41
41
  const roles_1 = require("../../roles");
42
42
  const translate_schemas_1 = require("../translate.schemas");
43
+ const hotels_1 = require("../../hotels");
43
44
  const makeReqVariant = (entity, schema) => z.object({
44
45
  entity: z.literal(entity),
45
46
  object: schema,
@@ -52,10 +53,12 @@ const makeResVariant = (entity, schema) => z.object({
52
53
  const TranslateObjectRequestVariants = [
53
54
  makeReqVariant(common_1.ENTITIES.permission, permissions_1.PermissionTranslationsSchema),
54
55
  makeReqVariant(common_1.ENTITIES.role, roles_1.RoleTranslationsSchema),
56
+ makeReqVariant(common_1.ENTITIES.hotel, hotels_1.HotelTranslationsSchema),
55
57
  ];
56
58
  const TranslateObjectResponseVariants = [
57
59
  makeResVariant(common_1.ENTITIES.permission, permissions_1.PermissionTranslationsSchema),
58
60
  makeResVariant(common_1.ENTITIES.role, roles_1.RoleTranslationsSchema),
61
+ makeResVariant(common_1.ENTITIES.hotel, hotels_1.HotelTranslationsSchema),
59
62
  ];
60
63
  const TranslateObjectContractRequestSchema = translate_schemas_1.BaseTranslateSchema.extend({
61
64
  payload: z.discriminatedUnion('entity', TranslateObjectRequestVariants),
@@ -5,16 +5,17 @@ export const ICON_KEYS = {
5
5
  chevronRight: 'chevronRight',
6
6
  arrowDown: 'arrowDown',
7
7
  arrowUp: 'arrowUp',
8
+ ellipsis: 'ellipsis',
9
+ plus: 'plus',
8
10
  moon: 'moon',
9
11
  sun: 'sun',
10
12
  menu: 'menu',
11
- ellipsis: 'ellipsis',
12
13
  filter: 'filter',
13
14
  resetFilter: 'resetFilter',
14
15
  sorting: 'sorting',
15
- create: 'create',
16
- edit: 'edit',
17
- delete: 'delete',
16
+ circlePlus: 'circlePlus',
17
+ squarePen: 'squarePen',
18
+ trash: 'trash',
18
19
  search: 'search',
19
20
  language: 'language',
20
21
  magic: 'magic',
@@ -0,0 +1,15 @@
1
+ import * as z from 'zod';
2
+
3
+ const DOMAIN_NAME_REGEXP =
4
+ /^(?!-)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
5
+
6
+ export const DomainNameSchema = z
7
+ .string()
8
+ .min(1)
9
+ .max(253)
10
+ .regex(
11
+ DOMAIN_NAME_REGEXP,
12
+ 'Domain must be a valid hostname like example.com or app.example.com',
13
+ );
14
+
15
+ export type TDomainName = z.infer<typeof DomainNameSchema>;
@@ -7,6 +7,8 @@ export * from './pagination.schema';
7
7
  export * from './search.schema';
8
8
  export * from './slug.schema';
9
9
  export * from './timestamp.schemas';
10
+ export * from './timezone.schema';
10
11
  export * from './language-keys.schema';
11
12
  export * from './translations.schemas';
12
13
  export * from './uuid-array.schema';
14
+ export * from './domain-name.schema';
@@ -8,3 +8,7 @@ export const TimestampSchema = z.object({
8
8
  export const TimestampWithDeletedSchema = TimestampSchema.extend({
9
9
  deletedAt: z.date().nullable(),
10
10
  });
11
+
12
+ export const IsoDatetimeSchema = z.iso.datetime();
13
+ export const IsoDateSchema = z.iso.date();
14
+ export const IsoTimeSchema = z.iso.time();
@@ -0,0 +1,11 @@
1
+ import * as z from 'zod';
2
+
3
+ export const TimezoneSchema = z
4
+ .string()
5
+ .refine(value => /^[A-Za-z]+(?:[_-][A-Za-z]+)?\/[A-Za-z]+(?:[_-][A-Za-z]+)?$/.test(value), {
6
+ params: {
7
+ messageKey: 'z.timezone.invalidFormat',
8
+ },
9
+ });
10
+
11
+ export type TTimezone = z.infer<typeof TimezoneSchema>;
@@ -0,0 +1,9 @@
1
+ import * as z from 'zod';
2
+ import { HOTEL_AMENITY_VALUES } from '../constants';
3
+
4
+ export const HotelAmenitySchema = z.object({
5
+ hotelId: z.uuid(),
6
+ amenityCode: z.enum(HOTEL_AMENITY_VALUES),
7
+ isPrimary: z.boolean().default(false),
8
+ });
9
+ export type THotelAmenity = z.infer<typeof HotelAmenitySchema>;
@@ -0,0 +1 @@
1
+ export * from './hotel-amenity.model';
@@ -0,0 +1,18 @@
1
+ export const HOTEL_AMENITIES = {
2
+ wifi: 'wifi',
3
+ parking: 'parking',
4
+ pool: 'pool',
5
+ spa: 'spa',
6
+ gym: 'gym',
7
+ restaurant: 'restaurant',
8
+ bar: 'bar',
9
+ conferenceRoom: 'conferenceRoom',
10
+ businessCenter: 'businessCenter',
11
+ } as const;
12
+
13
+ export type THotelAmenityCode = (typeof HOTEL_AMENITIES)[keyof typeof HOTEL_AMENITIES];
14
+
15
+ export const HOTEL_AMENITY_VALUES = Object.values(HOTEL_AMENITIES) as [
16
+ THotelAmenityCode,
17
+ ...THotelAmenityCode[],
18
+ ];
@@ -0,0 +1,12 @@
1
+ export const HOTEL_CONTACT_TYPES = {
2
+ mainPhone: 'mainPhone',
3
+ reservations: 'reservations',
4
+ sales: 'sales',
5
+ } as const;
6
+
7
+ export type THotelContactType = (typeof HOTEL_CONTACT_TYPES)[keyof typeof HOTEL_CONTACT_TYPES];
8
+
9
+ export const HOTEL_CONTACT_TYPE_VALUES = Object.values(HOTEL_CONTACT_TYPES) as [
10
+ THotelContactType,
11
+ ...THotelContactType[],
12
+ ];
@@ -0,0 +1,14 @@
1
+ export const HOTEL_FEATURES = {
2
+ site: 'site',
3
+ services: 'services',
4
+ digitalSignage: 'digitalSignage',
5
+ hskRoomStatus: 'hskRoomStatus',
6
+ fbBreakfastCheckin: 'fbBreakfastCheckin',
7
+ } as const;
8
+
9
+ export type THotelFeatureKey = (typeof HOTEL_FEATURES)[keyof typeof HOTEL_FEATURES];
10
+
11
+ export const HOTEL_FEATURE_VALUES = Object.values(HOTEL_FEATURES) as [
12
+ THotelFeatureKey,
13
+ ...THotelFeatureKey[],
14
+ ];
@@ -0,0 +1,11 @@
1
+ export const HOTEL_INTEGRATION_PROVIDERS = {
2
+ opera: 'opera',
3
+ } as const;
4
+
5
+ export type THotelIntegrationProvider =
6
+ (typeof HOTEL_INTEGRATION_PROVIDERS)[keyof typeof HOTEL_INTEGRATION_PROVIDERS];
7
+
8
+ export const HOTEL_INTEGRATION_PROVIDER_VALUES = Object.values(HOTEL_INTEGRATION_PROVIDERS) as [
9
+ THotelIntegrationProvider,
10
+ ...THotelIntegrationProvider[],
11
+ ];
@@ -0,0 +1,15 @@
1
+ export const HOTEL_POLICY_TYPES = {
2
+ cancellation: 'cancellation',
3
+ deposit: 'deposit',
4
+ meal: 'meal',
5
+ pet: 'pet',
6
+ smoking: 'smoking',
7
+ } as const;
8
+
9
+ export type THotelPolicyType =
10
+ (typeof HOTEL_POLICY_TYPES)[keyof typeof HOTEL_POLICY_TYPES];
11
+
12
+ export const HOTEL_POLICY_TYPE_VALUES = Object.values(HOTEL_POLICY_TYPES) as [
13
+ THotelPolicyType,
14
+ ...THotelPolicyType[],
15
+ ];
@@ -0,0 +1,12 @@
1
+ export const HOTEL_RATING_SOURCES = {
2
+ google: 'google',
3
+ yandexMaps: 'yandexMaps',
4
+ ostrovok: 'ostrovok',
5
+ } as const;
6
+
7
+ export type THotelRatingSource = (typeof HOTEL_RATING_SOURCES)[keyof typeof HOTEL_RATING_SOURCES];
8
+
9
+ export const HOTEL_RATING_SOURCE_VALUES = Object.values(HOTEL_RATING_SOURCES) as [
10
+ THotelRatingSource,
11
+ ...THotelRatingSource[],
12
+ ];
@@ -0,0 +1,6 @@
1
+ export * from './hotel-amenity.constant';
2
+ export * from './hotel-contact-type.constant';
3
+ export * from './hotel-feature.constant';
4
+ export * from './hotel-integration-provider.constant';
5
+ export * from './hotel-policy-type.constant';
6
+ export * from './hotel-rating-source.constant';
@@ -0,0 +1,15 @@
1
+ import * as z from 'zod';
2
+ import { HOTEL_CONTACT_TYPE_VALUES } from '../constants';
3
+ import { TimestampSchema } from '../../common';
4
+
5
+ export const HotelContactSchema = z
6
+ .object({
7
+ hotelId: z.uuid(),
8
+ contactType: z.enum(HOTEL_CONTACT_TYPE_VALUES),
9
+ value: z.string().min(1),
10
+ isPublic: z.boolean().default(true),
11
+ metadata: z.record(z.string(), z.unknown()).optional(),
12
+ })
13
+ .extend(TimestampSchema.shape);
14
+
15
+ export type THotelContact = z.infer<typeof HotelContactSchema>;
@@ -0,0 +1 @@
1
+ export * from './hotel-contact.model';
@@ -0,0 +1,21 @@
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS } from '../../common';
3
+ import { HOTELS_API, HOTELS_CONTROLLER } from '../hotels.api';
4
+ import { HotelWithTranslationsSchema } from '../hotel.models';
5
+
6
+ export namespace CreateHotelContract {
7
+ export const getUrl = HOTELS_API.create;
8
+ export const endpoint = HOTELS_CONTROLLER.endpoints.create;
9
+ export const httpMethod = HTTP_METHODS.post;
10
+
11
+ export const RequestSchema = HotelWithTranslationsSchema.omit({
12
+ id: true,
13
+ version: true,
14
+ createdAt: true,
15
+ updatedAt: true,
16
+ });
17
+ export type TRequest = z.infer<typeof RequestSchema>;
18
+
19
+ export const ResponseSchema = HotelWithTranslationsSchema;
20
+ export type TResponse = z.infer<typeof ResponseSchema>;
21
+ }
@@ -0,0 +1,12 @@
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS } from '../../common';
3
+ import { HOTELS_API, HOTELS_CONTROLLER } from '../hotels.api';
4
+
5
+ export namespace DeleteHotelContract {
6
+ export const getUrl = HOTELS_API.deleteById;
7
+ export const endpoint = HOTELS_CONTROLLER.endpoints.deleteById;
8
+ export const httpMethod = HTTP_METHODS.delete;
9
+
10
+ export const ResponseSchema = z.void();
11
+ export type TResponse = z.infer<typeof ResponseSchema>;
12
+ }
@@ -1 +1,22 @@
1
- export namespace FindHotelContract {}
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS } from '../../common';
3
+ import { HotelWithTranslationsSchema } from '../hotel.models';
4
+ import { HOTELS_API, HOTELS_CONTROLLER } from '../hotels.api';
5
+
6
+ export namespace FindHotelByIdContract {
7
+ export const getUrl = HOTELS_API.findById;
8
+ export const endpoint = HOTELS_CONTROLLER.endpoints.findById;
9
+ export const httpMethod = HTTP_METHODS.get;
10
+
11
+ export const ResponseSchema = HotelWithTranslationsSchema;
12
+ export type TResponse = z.infer<typeof ResponseSchema>;
13
+ }
14
+
15
+ export namespace FindHotelBySlugContract {
16
+ export const getUrl = HOTELS_API.findBySlug;
17
+ export const endpoint = HOTELS_CONTROLLER.endpoints.findBySlug;
18
+ export const httpMethod = HTTP_METHODS.get;
19
+
20
+ export const ResponseSchema = HotelWithTranslationsSchema;
21
+ export type TResponse = z.infer<typeof ResponseSchema>;
22
+ }
@@ -0,0 +1,43 @@
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS, CommonQueryParamsSchema, PaginationResponseSchema } from '../../common';
3
+ import { HotelListItemSchema } from '../hotel.models';
4
+ import { HOTELS_API, HOTELS_CONTROLLER } from '../hotels.api';
5
+
6
+ const BaseQuerySchema = HotelListItemSchema.pick({
7
+ status: true,
8
+ category: true,
9
+ stars: true,
10
+ }).partial();
11
+
12
+ const OrderBySchema = HotelListItemSchema.omit({
13
+ id: true,
14
+ }).keyof();
15
+
16
+ const FindManyHotelsContractRequestSchema = BaseQuerySchema.extend({
17
+ ...CommonQueryParamsSchema.shape,
18
+ orderBy: OrderBySchema.optional(),
19
+ });
20
+
21
+ const FindManyHotelsContractResponseSchema = z
22
+ .object({
23
+ hotels: z.array(HotelListItemSchema),
24
+ })
25
+ .extend(PaginationResponseSchema.shape);
26
+
27
+ export namespace FindManyHotelsContract {
28
+ export const getUrl = HOTELS_API.findMany;
29
+ export const endpoint = HOTELS_CONTROLLER.endpoints.findMany;
30
+ export const httpMethod = HTTP_METHODS.get;
31
+
32
+ export const BaseFilterSchema = BaseQuerySchema;
33
+ export type TBaseFilter = z.infer<typeof BaseFilterSchema>;
34
+
35
+ export const SORTING_KEYS = OrderBySchema.options;
36
+ export type TSortingKey = z.infer<typeof OrderBySchema>;
37
+
38
+ export const RequestSchema = FindManyHotelsContractRequestSchema;
39
+ export type TRequest = z.infer<typeof RequestSchema>;
40
+
41
+ export const ResponseSchema = FindManyHotelsContractResponseSchema;
42
+ export type TResponse = z.infer<typeof ResponseSchema>;
43
+ }
@@ -1 +1,5 @@
1
1
  export * from './find-hotel.contract';
2
+ export * from './find-many-hotels.contract';
3
+ export * from './update-hotel.contract';
4
+ export * from './delete-hotel.contract';
5
+ export * from './create-hotel.contract';
@@ -0,0 +1,17 @@
1
+ import * as z from 'zod';
2
+ import { HTTP_METHODS } from '../../common';
3
+ import { HOTELS_API, HOTELS_CONTROLLER } from '../hotels.api';
4
+ import { HotelWithTranslationsSchema } from '../hotel.models';
5
+ import { CreateHotelContract } from './create-hotel.contract';
6
+
7
+ export namespace UpdateHotelContract {
8
+ export const getUrl = HOTELS_API.updateById;
9
+ export const endpoint = HOTELS_CONTROLLER.endpoints.updateById;
10
+ export const httpMethod = HTTP_METHODS.put;
11
+
12
+ export const RequestSchema = CreateHotelContract.RequestSchema;
13
+ export type TRequest = z.infer<typeof RequestSchema>;
14
+
15
+ export const ResponseSchema = HotelWithTranslationsSchema;
16
+ export type TResponse = z.infer<typeof ResponseSchema>;
17
+ }
@@ -0,0 +1,14 @@
1
+ import * as z from 'zod';
2
+ import { TimestampSchema } from '../../common';
3
+ import { HOTEL_FEATURE_VALUES } from '../constants';
4
+
5
+ export const HotelFeatureSchema = z
6
+ .object({
7
+ hotelId: z.uuid(),
8
+ feature: z.enum(HOTEL_FEATURE_VALUES),
9
+ enabled: z.boolean(),
10
+ metadata: z.record(z.string(), z.unknown()).optional(),
11
+ })
12
+ .extend(TimestampSchema.shape);
13
+
14
+ export type THotelFeature = z.infer<typeof HotelFeatureSchema>;
@@ -0,0 +1 @@
1
+ export * from './hotel-feature.model';
@@ -0,0 +1,60 @@
1
+ import * as z from 'zod';
2
+ import {
3
+ LANGUAGE_KEYS,
4
+ TimestampSchema,
5
+ AppStatuses,
6
+ SlugSchema,
7
+ makeTranslations,
8
+ IsoTimeSchema,
9
+ TimezoneSchema,
10
+ } from '../common';
11
+
12
+ export const HotelPersistedSchema = z
13
+ .object({
14
+ id: z.uuid(),
15
+ slug: SlugSchema,
16
+ //принадлежность к сети
17
+ chainId: z.uuid().optional(),
18
+ status: z.enum(AppStatuses.HOTEL_VALUES).default(AppStatuses.HOTEL.pending),
19
+ //категория отеля
20
+ category: z.string().min(1).max(64).optional(),
21
+ timezone: TimezoneSchema,
22
+ currency: z.string().length(3),
23
+ defaultLang: z.enum(LANGUAGE_KEYS),
24
+ availableLangs: z.array(z.enum(LANGUAGE_KEYS)),
25
+ stars: z.number().int().min(1).max(5).optional(),
26
+ checkInFrom: IsoTimeSchema,
27
+ checkOutUntil: IsoTimeSchema,
28
+ // добавить тип настроек
29
+ metadata: z.record(z.string(), z.unknown()).optional(),
30
+ version: z.number().int().nonnegative(),
31
+ })
32
+ .extend(TimestampSchema.shape);
33
+
34
+ export type THotelPersisted = z.infer<typeof HotelPersistedSchema>;
35
+
36
+ export const HotelTranslationsSchema = z.object({
37
+ name: z.string().min(3),
38
+ description: z.string().optional(),
39
+ });
40
+ export type THotelTranslations = z.infer<typeof HotelTranslationsSchema>;
41
+
42
+ export const HotelWithTranslationsSchema = HotelPersistedSchema.extend({
43
+ translations: makeTranslations(HotelTranslationsSchema),
44
+ });
45
+ export type THotelWithTranslations = z.infer<typeof HotelWithTranslationsSchema>;
46
+
47
+ export const HotelListItemSchema = HotelPersistedSchema.omit({
48
+ chainId: true,
49
+ metadata: true,
50
+ timezone: true,
51
+ currency: true,
52
+ defaultLang: true,
53
+ availableLangs: true,
54
+ checkInFrom: true,
55
+ checkOutUntil: true,
56
+ version: true,
57
+ }).extend({
58
+ name: z.string().nullable(),
59
+ });
60
+ export type THotelListItem = z.infer<typeof HotelListItemSchema>;
@@ -1,12 +1,15 @@
1
1
  import { createApi, TController } from '../common/utils';
2
2
 
3
- export const HOTELS_BY_SLUG_CONTROLLER = {
4
- prefix: 'hotels/by-slug',
3
+ export const HOTELS_CONTROLLER = {
4
+ prefix: 'hotels',
5
5
  endpoints: {
6
- findTheme: ':hotelSlug/theme',
7
- findSitePageByLang: ':hotelSlug/sites/pages/:slug',
8
- findSitePage: ':hotelSlug/sites/pages/:slug',
6
+ create: '',
7
+ findMany: '',
8
+ findById: 'by-id/:hotelId',
9
+ updateById: 'by-id/:hotelId',
10
+ deleteById: 'by-id/:hotelId',
11
+ findBySlug: 'by-slug/:hotelSlug',
9
12
  },
10
13
  } as const satisfies TController;
11
14
 
12
- export const HOTELS_BY_SLUG_API = createApi(HOTELS_BY_SLUG_CONTROLLER);
15
+ export const HOTELS_API = createApi(HOTELS_CONTROLLER);
package/hotels/index.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  export * from './contracts';
2
+ export * from './constants';
3
+ export * from './amenities';
4
+ export * from './contacts';
5
+ export * from './features';
6
+ export * from './integrations';
7
+ export * from './location';
8
+ export * from './policies';
9
+ export * from './ratings';
2
10
  export * from './sites';
11
+ export * from './settings';
3
12
  export * from './themes';
4
- export * from './hotel.model';
13
+ export * from './hotel.models';
5
14
  export * from './hotels.api';