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.
- package/build/common/constants/icon.constants.js +5 -4
- package/build/common/models/domain-name.schema.js +43 -0
- package/build/common/models/index.js +2 -0
- package/build/common/models/timestamp.schemas.js +4 -1
- package/build/common/models/timezone.schema.js +44 -0
- package/build/hotels/amenities/hotel-amenity.model.js +43 -0
- package/build/hotels/amenities/index.js +17 -0
- package/build/hotels/constants/hotel-amenity.constant.js +15 -0
- package/build/hotels/constants/hotel-contact-type.constant.js +9 -0
- package/build/hotels/constants/hotel-feature.constant.js +11 -0
- package/build/hotels/constants/hotel-integration-provider.constant.js +7 -0
- package/build/hotels/constants/hotel-policy-type.constant.js +11 -0
- package/build/hotels/constants/hotel-rating-source.constant.js +9 -0
- package/build/hotels/constants/index.js +22 -0
- package/build/hotels/contacts/hotel-contact.model.js +48 -0
- package/build/hotels/contacts/index.js +17 -0
- package/build/hotels/contracts/create-hotel.contract.js +19 -0
- package/build/hotels/contracts/delete-hotel.contract.js +46 -0
- package/build/hotels/contracts/find-hotel.contract.js +18 -0
- package/build/hotels/contracts/find-many-hotels.contract.js +67 -0
- package/build/hotels/contracts/index.js +4 -0
- package/build/hotels/contracts/update-hotel.contract.js +15 -0
- package/build/hotels/{hotel.model.js → features/hotel-feature.model.js} +8 -9
- package/build/hotels/features/index.js +17 -0
- package/build/hotels/hotel.models.js +79 -0
- package/build/hotels/hotels.api.js +10 -7
- package/build/hotels/index.js +10 -1
- package/build/hotels/integrations/hotel-integration.model.js +59 -0
- package/build/hotels/integrations/hotel-integrations.api.js +17 -0
- package/build/hotels/integrations/index.js +18 -0
- package/build/hotels/location/hotel-location.model.js +51 -0
- package/build/hotels/location/index.js +17 -0
- package/build/hotels/policies/hotel-policy.model.js +49 -0
- package/build/hotels/policies/index.js +17 -0
- package/build/hotels/ratings/hotel-rating.model.js +48 -0
- package/build/hotels/ratings/index.js +17 -0
- package/build/hotels/settings/contracts/find-hotel-domain-settings.contract.js +13 -0
- package/build/hotels/settings/contracts/index.js +18 -0
- package/build/hotels/settings/contracts/update-hotel-domain-settings.contract.js +14 -0
- package/build/hotels/settings/hotel-domain-settings.api.js +12 -0
- package/build/hotels/settings/hotel-domain-settings.schema.js +49 -0
- package/build/hotels/settings/index.js +19 -0
- package/build/hotels/sites/contracts/find-hotel-site-page-by-lang.contract.js +3 -3
- package/build/hotels/sites/hotel-pages.api.js +24 -0
- package/build/hotels/sites/index.js +1 -0
- package/build/hotels/themes/contracts/find-hotel-theme.contract.js +3 -3
- package/build/hotels/themes/hotel-themes.api.js +20 -0
- package/build/hotels/themes/index.js +1 -0
- package/build/permissions/contracts/delete-permission.contract.js +35 -2
- package/build/permissions/contracts/find-permission.contract.js +0 -7
- package/build/permissions/permission.models.js +2 -18
- package/build/roles/contracts/delete-role.contract.js +35 -2
- package/build/translate/contracts/translate-object.contract.js +3 -0
- package/common/constants/icon.constants.ts +5 -4
- package/common/models/domain-name.schema.ts +15 -0
- package/common/models/index.ts +2 -0
- package/common/models/timestamp.schemas.ts +4 -0
- package/common/models/timezone.schema.ts +11 -0
- package/hotels/amenities/hotel-amenity.model.ts +9 -0
- package/hotels/amenities/index.ts +1 -0
- package/hotels/constants/hotel-amenity.constant.ts +18 -0
- package/hotels/constants/hotel-contact-type.constant.ts +12 -0
- package/hotels/constants/hotel-feature.constant.ts +14 -0
- package/hotels/constants/hotel-integration-provider.constant.ts +11 -0
- package/hotels/constants/hotel-policy-type.constant.ts +15 -0
- package/hotels/constants/hotel-rating-source.constant.ts +12 -0
- package/hotels/constants/index.ts +6 -0
- package/hotels/contacts/hotel-contact.model.ts +15 -0
- package/hotels/contacts/index.ts +1 -0
- package/hotels/contracts/create-hotel.contract.ts +21 -0
- package/hotels/contracts/delete-hotel.contract.ts +12 -0
- package/hotels/contracts/find-hotel.contract.ts +22 -1
- package/hotels/contracts/find-many-hotels.contract.ts +43 -0
- package/hotels/contracts/index.ts +4 -0
- package/hotels/contracts/update-hotel.contract.ts +17 -0
- package/hotels/features/hotel-feature.model.ts +14 -0
- package/hotels/features/index.ts +1 -0
- package/hotels/hotel.models.ts +60 -0
- package/hotels/hotels.api.ts +9 -6
- package/hotels/index.ts +10 -1
- package/hotels/integrations/hotel-integration.model.ts +29 -0
- package/hotels/integrations/hotel-integrations.api.ts +16 -0
- package/hotels/integrations/index.ts +2 -0
- package/hotels/location/hotel-location.model.ts +17 -0
- package/hotels/location/index.ts +1 -0
- package/hotels/policies/hotel-policy.model.ts +16 -0
- package/hotels/policies/index.ts +1 -0
- package/hotels/ratings/hotel-rating.model.ts +15 -0
- package/hotels/ratings/index.ts +1 -0
- package/hotels/settings/contracts/find-hotel-domain-settings.contract.ts +13 -0
- package/hotels/settings/contracts/index.ts +2 -0
- package/hotels/settings/contracts/update-hotel-domain-settings.contract.ts +19 -0
- package/hotels/settings/hotel-domain-settings.api.ts +11 -0
- package/hotels/settings/hotel-domain-settings.schema.ts +24 -0
- package/hotels/settings/index.ts +3 -0
- package/hotels/sites/contracts/find-hotel-site-page-by-lang.contract.ts +3 -3
- package/hotels/sites/hotel-pages.api.ts +24 -0
- package/hotels/sites/index.ts +1 -0
- package/hotels/themes/contracts/find-hotel-theme.contract.ts +3 -3
- package/hotels/themes/hotel-themes.api.ts +20 -0
- package/hotels/themes/index.ts +1 -0
- package/package.json +1 -1
- package/permissions/contracts/delete-permission.contract.ts +1 -2
- package/permissions/contracts/find-permission.contract.ts +0 -8
- package/permissions/permission.models.ts +1 -19
- package/roles/contracts/delete-role.contract.ts +1 -2
- package/translate/contracts/translate-object.contract.ts +3 -0
- package/build/permissions/permission.response.schema.js +0 -8
- package/hotels/hotel.model.ts +0 -14
- package/permissions/permission.response.schema.ts +0 -8
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { TimestampSchema } from '../../common';
|
|
3
|
+
import { HOTEL_INTEGRATION_PROVIDER_VALUES } from '../constants';
|
|
4
|
+
|
|
5
|
+
export const HotelIntegrationSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
hotelId: z.uuid(),
|
|
8
|
+
provider: z.enum(HOTEL_INTEGRATION_PROVIDER_VALUES),
|
|
9
|
+
externalHotelId: z.string().min(1),
|
|
10
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
11
|
+
credentialId: z.uuid().optional(),
|
|
12
|
+
})
|
|
13
|
+
.extend(TimestampSchema.shape);
|
|
14
|
+
|
|
15
|
+
export type THotelIntegration = z.infer<typeof HotelIntegrationSchema>;
|
|
16
|
+
|
|
17
|
+
export const HotelIntegrationCredentialSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
id: z.uuid(),
|
|
20
|
+
provider: z.enum(HOTEL_INTEGRATION_PROVIDER_VALUES),
|
|
21
|
+
login: z.string().min(1),
|
|
22
|
+
encryptedSecret: z.string().min(1),
|
|
23
|
+
encryptionVersion: z.string().min(1),
|
|
24
|
+
meta: z.record(z.string(), z.unknown()).optional(),
|
|
25
|
+
rotatedAt: z.date().nullable(),
|
|
26
|
+
})
|
|
27
|
+
.extend(TimestampSchema.shape);
|
|
28
|
+
|
|
29
|
+
export type THotelIntegrationCredential = z.infer<typeof HotelIntegrationCredentialSchema>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createApi, TController } from '../../common/utils';
|
|
2
|
+
|
|
3
|
+
export const HOTEL_INTEGRATIONS_CONTROLLER = {
|
|
4
|
+
prefix: 'hotels/by-id/:hotelId/integrations',
|
|
5
|
+
endpoints: {
|
|
6
|
+
findMany: '',
|
|
7
|
+
findOne: ':integrationId',
|
|
8
|
+
create: '',
|
|
9
|
+
update: ':integrationId',
|
|
10
|
+
delete: ':integrationId',
|
|
11
|
+
enable: ':integrationId/enable',
|
|
12
|
+
disable: ':integrationId/disable',
|
|
13
|
+
},
|
|
14
|
+
} as const satisfies TController;
|
|
15
|
+
|
|
16
|
+
export const HOTEL_INTEGRATIONS_API = createApi(HOTEL_INTEGRATIONS_CONTROLLER);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { TimestampSchema } from '../../common';
|
|
3
|
+
|
|
4
|
+
export const HotelLocationSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
hotelId: z.uuid(),
|
|
7
|
+
countryCode: z.string().length(2),
|
|
8
|
+
regionCode: z.string().max(32).optional(),
|
|
9
|
+
city: z.string().min(1).max(128),
|
|
10
|
+
addressLine1: z.string().min(1).max(256),
|
|
11
|
+
addressLine2: z.string().max(256).optional(),
|
|
12
|
+
postalCode: z.string().max(16).optional(),
|
|
13
|
+
latitude: z.number().min(-90).max(90),
|
|
14
|
+
longitude: z.number().min(-180).max(180),
|
|
15
|
+
})
|
|
16
|
+
.extend(TimestampSchema.shape);
|
|
17
|
+
export type THotelLocation = z.infer<typeof HotelLocationSchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hotel-location.model';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { TimestampSchema } from '../../common';
|
|
3
|
+
import { HOTEL_POLICY_TYPE_VALUES } from '../constants';
|
|
4
|
+
|
|
5
|
+
export const HotelPolicySchema = z
|
|
6
|
+
.object({
|
|
7
|
+
hotelId: z.uuid(),
|
|
8
|
+
policyType: z.enum(HOTEL_POLICY_TYPE_VALUES),
|
|
9
|
+
valueKey: z.string().min(1).optional(),
|
|
10
|
+
valueJson: z.record(z.string(), z.unknown()).optional(),
|
|
11
|
+
effectiveFrom: z.date().optional(),
|
|
12
|
+
effectiveTo: z.date().optional(),
|
|
13
|
+
})
|
|
14
|
+
.extend(TimestampSchema.shape);
|
|
15
|
+
|
|
16
|
+
export type THotelPolicy = z.infer<typeof HotelPolicySchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hotel-policy.model';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { IsoDatetimeSchema, TimestampSchema } from '../../common';
|
|
3
|
+
import { HOTEL_RATING_SOURCE_VALUES } from '../constants';
|
|
4
|
+
|
|
5
|
+
export const HotelRatingSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
hotelId: z.uuid(),
|
|
8
|
+
source: z.enum(HOTEL_RATING_SOURCE_VALUES),
|
|
9
|
+
value: z.number().min(0).max(10),
|
|
10
|
+
reviewsCount: z.number().int().nonnegative().optional(),
|
|
11
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
12
|
+
})
|
|
13
|
+
.extend(TimestampSchema.shape);
|
|
14
|
+
|
|
15
|
+
export type THotelRating = z.infer<typeof HotelRatingSchema>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hotel-rating.model';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { HTTP_METHODS } from '../../../common';
|
|
3
|
+
import { HOTEL_DOMAIN_SETTINGS_API, HOTEL_DOMAIN_SETTINGS_CONTROLLER } from '../hotel-domain-settings.api';
|
|
4
|
+
import { HotelDomainSettingsListSchema } from '../hotel-domain-settings.schema';
|
|
5
|
+
|
|
6
|
+
export namespace FindHotelDomainSettingsContract {
|
|
7
|
+
export const getUrl = HOTEL_DOMAIN_SETTINGS_API.find;
|
|
8
|
+
export const endpoint = HOTEL_DOMAIN_SETTINGS_CONTROLLER.endpoints.find;
|
|
9
|
+
export const httpMethod = HTTP_METHODS.get;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = HotelDomainSettingsListSchema;
|
|
12
|
+
export type TResponse = z.infer<typeof ResponseSchema>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { HTTP_METHODS } from '../../../common';
|
|
3
|
+
import { HOTEL_DOMAIN_SETTINGS_API, HOTEL_DOMAIN_SETTINGS_CONTROLLER } from '../hotel-domain-settings.api';
|
|
4
|
+
import {
|
|
5
|
+
HotelDomainSettingsPersistedSchema,
|
|
6
|
+
HotelDomainSettingsSchema,
|
|
7
|
+
} from '../hotel-domain-settings.schema';
|
|
8
|
+
|
|
9
|
+
export namespace UpdateHotelDomainSettingsContract {
|
|
10
|
+
export const getUrl = HOTEL_DOMAIN_SETTINGS_API.update;
|
|
11
|
+
export const endpoint = HOTEL_DOMAIN_SETTINGS_CONTROLLER.endpoints.update;
|
|
12
|
+
export const httpMethod = HTTP_METHODS.put;
|
|
13
|
+
|
|
14
|
+
export const RequestSchema = HotelDomainSettingsSchema;
|
|
15
|
+
export type TRequest = z.infer<typeof RequestSchema>;
|
|
16
|
+
|
|
17
|
+
export const ResponseSchema = HotelDomainSettingsPersistedSchema;
|
|
18
|
+
export type TResponse = z.infer<typeof ResponseSchema>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createApi, TController } from '../../common/utils';
|
|
2
|
+
|
|
3
|
+
export const HOTEL_DOMAIN_SETTINGS_CONTROLLER = {
|
|
4
|
+
prefix: 'hotels/by-id/:hotelId/settings/domains',
|
|
5
|
+
endpoints: {
|
|
6
|
+
find: '',
|
|
7
|
+
update: '',
|
|
8
|
+
},
|
|
9
|
+
} as const satisfies TController;
|
|
10
|
+
|
|
11
|
+
export const HOTEL_DOMAIN_SETTINGS_API = createApi(HOTEL_DOMAIN_SETTINGS_CONTROLLER);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
DomainNameSchema,
|
|
4
|
+
IsoDatetimeSchema,
|
|
5
|
+
KIND_OF_APP_VALUES,
|
|
6
|
+
TimestampSchema,
|
|
7
|
+
} from '../../common';
|
|
8
|
+
|
|
9
|
+
export const HotelDomainSettingsSchema = z.object({
|
|
10
|
+
kindOfApp: z.enum(KIND_OF_APP_VALUES),
|
|
11
|
+
customDomain: DomainNameSchema.optional(),
|
|
12
|
+
isCustomDomainVerified: z.boolean().default(false),
|
|
13
|
+
customDomainVerifiedAt: IsoDatetimeSchema.optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const HotelDomainSettingsPersistedSchema = HotelDomainSettingsSchema.extend({
|
|
17
|
+
id: z.uuid(),
|
|
18
|
+
hotelId: z.uuid(),
|
|
19
|
+
}).extend(TimestampSchema.shape);
|
|
20
|
+
|
|
21
|
+
export const HotelDomainSettingsListSchema = z.array(HotelDomainSettingsPersistedSchema);
|
|
22
|
+
|
|
23
|
+
export type THotelDomainSettings = z.infer<typeof HotelDomainSettingsSchema>;
|
|
24
|
+
export type THotelDomainSettingsPersisted = z.infer<typeof HotelDomainSettingsPersistedSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { HTTP_METHODS, LanguageKeysSchema } from '../../../common';
|
|
3
|
-
import {
|
|
3
|
+
import { HOTEL_PAGES_PUBLIC_API, HOTEL_PAGES_PUBLIC_CONTROLLER } from '../hotel-pages.api';
|
|
4
4
|
import { PageLangTranslationSchema, PageSchema } from '../../../pages';
|
|
5
5
|
|
|
6
6
|
const FindHotelSitePageByLangContractRequestSchema = z.object({
|
|
@@ -14,8 +14,8 @@ const FindHotelSitePageByLangContractResponseSchema = PageSchema.omit({
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export namespace FindHotelSitePageByLangContract {
|
|
17
|
-
export const getUrl =
|
|
18
|
-
export const endpoint =
|
|
17
|
+
export const getUrl = HOTEL_PAGES_PUBLIC_API.findBySlugAndLang;
|
|
18
|
+
export const endpoint = HOTEL_PAGES_PUBLIC_CONTROLLER.endpoints.findBySlugAndLang;
|
|
19
19
|
export const httpMethod = HTTP_METHODS.get;
|
|
20
20
|
|
|
21
21
|
export const RequestSchema = FindHotelSitePageByLangContractRequestSchema;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createApi, TController } from '../../common/utils';
|
|
2
|
+
|
|
3
|
+
export const HOTEL_PAGES_CONTROLLER = {
|
|
4
|
+
prefix: 'hotels/by-id/:hotelId/sites/pages',
|
|
5
|
+
endpoints: {
|
|
6
|
+
findMany: '',
|
|
7
|
+
findBySlug: ':slug',
|
|
8
|
+
findBySlugAndLang: ':slug/lang/:lang',
|
|
9
|
+
create: '',
|
|
10
|
+
update: ':slug',
|
|
11
|
+
delete: ':slug',
|
|
12
|
+
},
|
|
13
|
+
} as const satisfies TController;
|
|
14
|
+
|
|
15
|
+
export const HOTEL_PAGES_PUBLIC_CONTROLLER = {
|
|
16
|
+
prefix: 'hotels/by-slug/:hotelSlug/sites/pages',
|
|
17
|
+
endpoints: {
|
|
18
|
+
findBySlug: ':slug',
|
|
19
|
+
findBySlugAndLang: ':slug/lang/:lang',
|
|
20
|
+
},
|
|
21
|
+
} as const satisfies TController;
|
|
22
|
+
|
|
23
|
+
export const HOTEL_PAGES_API = createApi(HOTEL_PAGES_CONTROLLER);
|
|
24
|
+
export const HOTEL_PAGES_PUBLIC_API = createApi(HOTEL_PAGES_PUBLIC_CONTROLLER);
|
package/hotels/sites/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { HTTP_METHODS } from '../../../common';
|
|
3
3
|
import { ThemePersistedSchema } from '../theme.models';
|
|
4
|
-
import {
|
|
4
|
+
import { HOTEL_THEMES_PUBLIC_API, HOTEL_THEMES_PUBLIC_CONTROLLER } from '../hotel-themes.api';
|
|
5
5
|
|
|
6
6
|
export namespace FindHotelThemeContract {
|
|
7
|
-
export const getUrl =
|
|
8
|
-
export const endpoint =
|
|
7
|
+
export const getUrl = HOTEL_THEMES_PUBLIC_API.get;
|
|
8
|
+
export const endpoint = HOTEL_THEMES_PUBLIC_CONTROLLER.endpoints.get;
|
|
9
9
|
export const httpMethod = HTTP_METHODS.get;
|
|
10
10
|
|
|
11
11
|
export const ResponseSchema = ThemePersistedSchema;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createApi, TController } from '../../common/utils';
|
|
2
|
+
|
|
3
|
+
export const HOTEL_THEMES_CONTROLLER = {
|
|
4
|
+
prefix: 'hotels/by-id/:hotelId/theme',
|
|
5
|
+
endpoints: {
|
|
6
|
+
get: '',
|
|
7
|
+
upsert: '',
|
|
8
|
+
delete: '',
|
|
9
|
+
},
|
|
10
|
+
} as const satisfies TController;
|
|
11
|
+
|
|
12
|
+
export const HOTEL_THEMES_PUBLIC_CONTROLLER = {
|
|
13
|
+
prefix: 'hotels/by-slug/:hotelSlug/theme',
|
|
14
|
+
endpoints: {
|
|
15
|
+
get: '',
|
|
16
|
+
},
|
|
17
|
+
} as const satisfies TController;
|
|
18
|
+
|
|
19
|
+
export const HOTEL_THEMES_API = createApi(HOTEL_THEMES_CONTROLLER);
|
|
20
|
+
export const HOTEL_THEMES_PUBLIC_API = createApi(HOTEL_THEMES_PUBLIC_CONTROLLER);
|
package/hotels/themes/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { HTTP_METHODS } from '../../common';
|
|
3
3
|
import { PERMISSIONS_API, PERMISSIONS_CONTROLLER } from '../permissions.api';
|
|
4
|
-
import { PermissionWithTranslationsSchema } from '../permission.models';
|
|
5
4
|
|
|
6
5
|
export namespace DeletePermissionContract {
|
|
7
6
|
export const getUrl = PERMISSIONS_API.delete;
|
|
8
7
|
export const endpoint = PERMISSIONS_CONTROLLER.endpoints.delete;
|
|
9
8
|
export const httpMethod = HTTP_METHODS.delete;
|
|
10
9
|
|
|
11
|
-
export const ResponseSchema =
|
|
10
|
+
export const ResponseSchema = z.void();
|
|
12
11
|
export type TResponse = z.infer<typeof ResponseSchema>;
|
|
13
12
|
}
|
|
@@ -3,19 +3,11 @@ import { HTTP_METHODS } from '../../common';
|
|
|
3
3
|
import { PermissionWithTranslationsSchema } from '../permission.models';
|
|
4
4
|
import { PERMISSIONS_API, PERMISSIONS_CONTROLLER } from '../permissions.api';
|
|
5
5
|
|
|
6
|
-
// const FindPermissionContractResponseSchema = PersistedPermissionSchema.transform(
|
|
7
|
-
// ({ conditions, ...permission }) => ({
|
|
8
|
-
// ...permission,
|
|
9
|
-
// conditions: conditions === null ? undefined : conditions,
|
|
10
|
-
// }),
|
|
11
|
-
// );
|
|
12
|
-
|
|
13
6
|
export namespace FindPermissionContract {
|
|
14
7
|
export const getUrl = PERMISSIONS_API.find;
|
|
15
8
|
export const endpoint = PERMISSIONS_CONTROLLER.endpoints.find;
|
|
16
9
|
export const httpMethod = HTTP_METHODS.get;
|
|
17
10
|
|
|
18
|
-
// export const ResponseSchema = FindPermissionContractResponseSchema;
|
|
19
11
|
export const ResponseSchema = PermissionWithTranslationsSchema;
|
|
20
12
|
export type TResponse = z.infer<typeof ResponseSchema>;
|
|
21
13
|
}
|
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { AppAbility, TimestampSchema, makeTranslations } from '../common';
|
|
3
3
|
|
|
4
|
-
export const JsonConditionsSchema = z
|
|
5
|
-
.string()
|
|
6
|
-
.transform(val => (val === '' ? undefined : val))
|
|
7
|
-
.optional()
|
|
8
|
-
.nullable()
|
|
9
|
-
.refine(
|
|
10
|
-
val => {
|
|
11
|
-
if (val === undefined || val === null) return true;
|
|
12
|
-
try {
|
|
13
|
-
JSON.parse(val);
|
|
14
|
-
return true;
|
|
15
|
-
} catch {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{ params: { messageKey: 'errors.validation.invalidJson' } },
|
|
20
|
-
);
|
|
21
|
-
|
|
22
4
|
export const PermissionPersistedSchema = z
|
|
23
5
|
.object({
|
|
24
6
|
id: z.uuid(),
|
|
25
7
|
|
|
26
8
|
action: z.enum(AppAbility.ACTION_VALUES),
|
|
27
9
|
subject: z.enum(AppAbility.SUBJECT_VALUES),
|
|
28
|
-
conditions:
|
|
10
|
+
conditions: z.json().optional().nullable(),
|
|
29
11
|
})
|
|
30
12
|
.extend(TimestampSchema.shape);
|
|
31
13
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { HTTP_METHODS } from '../../common';
|
|
3
|
-
import { RoleWithTranslationsSchema } from '../role.models';
|
|
4
3
|
import { ROLES_API, ROLES_CONTROLLER } from '../roles.api';
|
|
5
4
|
|
|
6
5
|
export namespace DeleteRoleContract {
|
|
@@ -8,6 +7,6 @@ export namespace DeleteRoleContract {
|
|
|
8
7
|
export const endpoint = ROLES_CONTROLLER.endpoints.delete;
|
|
9
8
|
export const httpMethod = HTTP_METHODS.delete;
|
|
10
9
|
|
|
11
|
-
export const ResponseSchema =
|
|
10
|
+
export const ResponseSchema = z.void();
|
|
12
11
|
export type TResponse = z.infer<typeof ResponseSchema>;
|
|
13
12
|
}
|
|
@@ -4,6 +4,7 @@ import { TRANSLATE_API, TRANSLATE_CONTROLLER } from '../translate.api';
|
|
|
4
4
|
import { PermissionTranslationsSchema } from '../../permissions';
|
|
5
5
|
import { RoleTranslationsSchema } from '../../roles';
|
|
6
6
|
import { BaseTranslateSchema } from '../translate.schemas';
|
|
7
|
+
import { HotelTranslationsSchema } from '../../hotels';
|
|
7
8
|
|
|
8
9
|
const makeReqVariant = <E extends TEntity, S extends z.ZodObject>(entity: E, schema: S) =>
|
|
9
10
|
z.object({
|
|
@@ -21,11 +22,13 @@ const makeResVariant = <E extends TEntity, S extends z.ZodTypeAny>(entity: E, sc
|
|
|
21
22
|
const TranslateObjectRequestVariants = [
|
|
22
23
|
makeReqVariant(ENTITIES.permission, PermissionTranslationsSchema),
|
|
23
24
|
makeReqVariant(ENTITIES.role, RoleTranslationsSchema),
|
|
25
|
+
makeReqVariant(ENTITIES.hotel, HotelTranslationsSchema),
|
|
24
26
|
] as const;
|
|
25
27
|
|
|
26
28
|
const TranslateObjectResponseVariants = [
|
|
27
29
|
makeResVariant(ENTITIES.permission, PermissionTranslationsSchema),
|
|
28
30
|
makeResVariant(ENTITIES.role, RoleTranslationsSchema),
|
|
31
|
+
makeResVariant(ENTITIES.hotel, HotelTranslationsSchema),
|
|
29
32
|
] as const;
|
|
30
33
|
|
|
31
34
|
const TranslateObjectContractRequestSchema = BaseTranslateSchema.extend({
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PermissionResponseSchema = void 0;
|
|
4
|
-
const permission_models_1 = require("./permission.models");
|
|
5
|
-
exports.PermissionResponseSchema = permission_models_1.PermissionPersistedSchema.transform(({ conditions, ...rest }) => ({
|
|
6
|
-
...rest,
|
|
7
|
-
conditions: conditions ? JSON.parse(conditions) : undefined,
|
|
8
|
-
}));
|
package/hotels/hotel.model.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
import { LANGUAGE_KEYS, TimestampSchema, AppStatuses, SlugSchema } from '../common';
|
|
3
|
-
|
|
4
|
-
export const HotelPersistedSchema = z
|
|
5
|
-
.object({
|
|
6
|
-
id: z.uuid(),
|
|
7
|
-
slug: SlugSchema,
|
|
8
|
-
status: z.enum(AppStatuses.HOTEL_VALUES),
|
|
9
|
-
hasServices: z.boolean(),
|
|
10
|
-
defaultLang: z.enum(LANGUAGE_KEYS),
|
|
11
|
-
availableLangs: z.array(z.enum(LANGUAGE_KEYS)),
|
|
12
|
-
})
|
|
13
|
-
.extend(TimestampSchema.shape);
|
|
14
|
-
export type THotelPersisted = z.infer<typeof HotelPersistedSchema>;
|