hh-contracts 0.0.92 → 0.0.94

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.
@@ -15,7 +15,7 @@ var AppAbility;
15
15
  AppAbility.ACTION_VALUES = Object.values(AppAbility.ACTIONS);
16
16
  AppAbility.SUBJECTS = {
17
17
  ...entity_constant_1.ENTITIES,
18
- hotelsWebsocketClients: 'hotelsWebsocketClients',
18
+ hotelsWebsocketClient: 'hotelsWebsocketClient',
19
19
  all: 'all',
20
20
  };
21
21
  AppAbility.SUBJECT_VALUES = Object.values(AppAbility.SUBJECTS);
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENTITY_VALUES = exports.ENTITIES = void 0;
4
4
  exports.ENTITIES = {
5
- users: 'users',
6
- roles: 'roles',
7
- permissions: 'permissions',
8
- hotels: 'hotels',
9
- rooms: 'rooms',
10
- roomCategories: 'roomCategories',
5
+ user: 'user',
6
+ role: 'role',
7
+ permission: 'permission',
8
+ hotel: 'hotel',
9
+ room: 'room',
10
+ roomCategory: 'roomCategory',
11
11
  };
12
12
  exports.ENTITY_VALUES = Object.values(exports.ENTITIES);
@@ -33,14 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.makeTranslationsByLang = void 0;
36
+ exports.makeTranslations = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  const language_keys_schema_1 = require("./language-keys.schema");
39
- const makeTranslationsByLang = (schema) => z
39
+ const makeTranslations = (schema) => z
40
40
  .partialRecord(language_keys_schema_1.LanguageKeysSchema, schema)
41
41
  .refine(translations => Object.keys(translations).length > 0, {
42
42
  params: {
43
43
  messageKey: 'zod.translations.must_not_be_empty',
44
44
  },
45
45
  });
46
- exports.makeTranslationsByLang = makeTranslationsByLang;
46
+ exports.makeTranslations = makeTranslations;
@@ -52,7 +52,7 @@ exports.PageLangTranslationSchema = z.object({
52
52
  .default({}),
53
53
  blocks: blocks_1.BlocksTranslationSchema.default({}),
54
54
  });
55
- const TranslationsSchema = (0, common_1.makeTranslationsByLang)(exports.PageLangTranslationSchema);
55
+ const TranslationsSchema = (0, common_1.makeTranslations)(exports.PageLangTranslationSchema);
56
56
  exports.PageSchema = z.object({
57
57
  meta: MetaSchema,
58
58
  blocks: z.array(blocks_1.BlockSchema),
@@ -66,7 +66,7 @@ exports.PermissionTranslationsSchema = z.object({
66
66
  description: z.string().optional(),
67
67
  });
68
68
  exports.PermissionWithTranslationsSchema = exports.PermissionPersistedSchema.extend({
69
- translations: (0, common_1.makeTranslationsByLang)(exports.PermissionTranslationsSchema),
69
+ translations: (0, common_1.makeTranslations)(exports.PermissionTranslationsSchema),
70
70
  });
71
71
  exports.PermissionListItemSchema = exports.PermissionPersistedSchema.extend({
72
72
  name: z.string().nullable(),
@@ -53,7 +53,7 @@ exports.RoleTranslationsSchema = z.object({
53
53
  description: z.string().optional(),
54
54
  });
55
55
  exports.RoleWithTranslationsSchema = exports.RoleWithPermissionsSchema.extend({
56
- translations: (0, common_1.makeTranslationsByLang)(exports.RoleTranslationsSchema),
56
+ translations: (0, common_1.makeTranslations)(exports.RoleTranslationsSchema),
57
57
  });
58
58
  exports.RoleListItemSchema = exports.RolePersistedSchema.extend({
59
59
  name: z.string().nullable(),
@@ -50,12 +50,12 @@ const makeResVariant = (entity, schema) => z.object({
50
50
  translations: z.object({}).catchall(schema),
51
51
  });
52
52
  const TranslateObjectRequestVariants = [
53
- makeReqVariant(common_1.ENTITIES.permissions, permissions_1.PermissionTranslationsSchema),
54
- makeReqVariant(common_1.ENTITIES.roles, roles_1.RoleTranslationsSchema),
53
+ makeReqVariant(common_1.ENTITIES.permission, permissions_1.PermissionTranslationsSchema),
54
+ makeReqVariant(common_1.ENTITIES.role, roles_1.RoleTranslationsSchema),
55
55
  ];
56
56
  const TranslateObjectResponseVariants = [
57
- makeResVariant(common_1.ENTITIES.permissions, permissions_1.PermissionTranslationsSchema),
58
- makeResVariant(common_1.ENTITIES.roles, roles_1.RoleTranslationsSchema),
57
+ makeResVariant(common_1.ENTITIES.permission, permissions_1.PermissionTranslationsSchema),
58
+ makeResVariant(common_1.ENTITIES.role, roles_1.RoleTranslationsSchema),
59
59
  ];
60
60
  const TranslateObjectContractRequestSchema = translate_schemas_1.BaseTranslateSchema.extend({
61
61
  payload: z.discriminatedUnion('entity', TranslateObjectRequestVariants),
@@ -9,7 +9,7 @@ exports.defaultPolicy = {
9
9
  'seo.description': 'text',
10
10
  },
11
11
  byEntity: {
12
- roles: {
12
+ role: {
13
13
  description: 'text',
14
14
  },
15
15
  },
@@ -14,7 +14,7 @@ export namespace AppAbility {
14
14
 
15
15
  export const SUBJECTS = {
16
16
  ...ENTITIES,
17
- hotelsWebsocketClients: 'hotelsWebsocketClients',
17
+ hotelsWebsocketClient: 'hotelsWebsocketClient',
18
18
  all: 'all',
19
19
  } as const;
20
20
  export type TSubject = (typeof SUBJECTS)[keyof typeof SUBJECTS];
@@ -1,10 +1,10 @@
1
1
  export const ENTITIES = {
2
- users: 'users',
3
- roles: 'roles',
4
- permissions: 'permissions',
5
- hotels: 'hotels',
6
- rooms: 'rooms',
7
- roomCategories: 'roomCategories',
2
+ user: 'user',
3
+ role: 'role',
4
+ permission: 'permission',
5
+ hotel: 'hotel',
6
+ room: 'room',
7
+ roomCategory: 'roomCategory',
8
8
  } as const;
9
9
  export type TEntity = (typeof ENTITIES)[keyof typeof ENTITIES];
10
10
  export const ENTITY_VALUES = Object.values(ENTITIES) as [TEntity, ...TEntity[]];
@@ -1,7 +1,7 @@
1
1
  import * as z from 'zod';
2
2
  import { LanguageKeysSchema } from './language-keys.schema';
3
3
 
4
- export const makeTranslationsByLang = <T extends z.ZodObject>(schema: T) =>
4
+ export const makeTranslations = <T extends z.ZodObject>(schema: T) =>
5
5
  z
6
6
  .partialRecord(LanguageKeysSchema, schema)
7
7
  .refine(translations => Object.keys(translations).length > 0, {
@@ -9,6 +9,6 @@ export const makeTranslationsByLang = <T extends z.ZodObject>(schema: T) =>
9
9
  messageKey: 'zod.translations.must_not_be_empty',
10
10
  },
11
11
  });
12
- export type TranslationsByLang<T extends object> = Partial<
12
+ export type TTranslations<T extends object> = Partial<
13
13
  Record<z.infer<typeof LanguageKeysSchema>, T>
14
14
  >;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-contracts",
3
- "version": "0.0.92",
3
+ "version": "0.0.94",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod';
2
- import { AppStatuses, LanguageKeysSchema, makeTranslationsByLang, SlugSchema } from '../../common';
2
+ import { AppStatuses, LanguageKeysSchema, makeTranslations, SlugSchema } from '../../common';
3
3
  import { BlocksTranslationSchema, BlockSchema } from './blocks';
4
4
 
5
5
  const MetaSchema = z.object({
@@ -18,7 +18,7 @@ export const PageLangTranslationSchema = z.object({
18
18
  .default({}),
19
19
  blocks: BlocksTranslationSchema.default({}),
20
20
  });
21
- const TranslationsSchema = makeTranslationsByLang(PageLangTranslationSchema);
21
+ const TranslationsSchema = makeTranslations(PageLangTranslationSchema);
22
22
 
23
23
  export const PageSchema = z.object({
24
24
  meta: MetaSchema,
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod';
2
- import { AppAbility, TimestampSchema, makeTranslationsByLang } from '../common';
2
+ import { AppAbility, TimestampSchema, makeTranslations } from '../common';
3
3
 
4
4
  export const JsonConditionsSchema = z
5
5
  .string()
@@ -39,7 +39,7 @@ export const PermissionTranslationsSchema = z.object({
39
39
  export type TPermissionTranslations = z.infer<typeof PermissionTranslationsSchema>;
40
40
 
41
41
  export const PermissionWithTranslationsSchema = PermissionPersistedSchema.extend({
42
- translations: makeTranslationsByLang(PermissionTranslationsSchema),
42
+ translations: makeTranslations(PermissionTranslationsSchema),
43
43
  });
44
44
  export type TPermissionWithTranslations = z.infer<typeof PermissionWithTranslationsSchema>;
45
45
 
@@ -1,10 +1,5 @@
1
1
  import * as z from 'zod';
2
- import {
3
- ROLE_TYPE_VALUES,
4
- TimestampSchema,
5
- UuidArraySchema,
6
- makeTranslationsByLang,
7
- } from '../common';
2
+ import { ROLE_TYPE_VALUES, TimestampSchema, UuidArraySchema, makeTranslations } from '../common';
8
3
  import { PermissionListItemSchema } from '../permissions';
9
4
 
10
5
  export const RolePersistedSchema = z
@@ -29,7 +24,7 @@ export const RoleTranslationsSchema = z.object({
29
24
  export type TRoleTranslations = z.infer<typeof RoleTranslationsSchema>;
30
25
 
31
26
  export const RoleWithTranslationsSchema = RoleWithPermissionsSchema.extend({
32
- translations: makeTranslationsByLang(RoleTranslationsSchema),
27
+ translations: makeTranslations(RoleTranslationsSchema),
33
28
  });
34
29
  export type TRoleWithTranslations = z.infer<typeof RoleWithTranslationsSchema>;
35
30
 
@@ -19,13 +19,13 @@ const makeResVariant = <E extends TEntity, S extends z.ZodTypeAny>(entity: E, sc
19
19
  });
20
20
 
21
21
  const TranslateObjectRequestVariants = [
22
- makeReqVariant(ENTITIES.permissions, PermissionTranslationsSchema),
23
- makeReqVariant(ENTITIES.roles, RoleTranslationsSchema),
22
+ makeReqVariant(ENTITIES.permission, PermissionTranslationsSchema),
23
+ makeReqVariant(ENTITIES.role, RoleTranslationsSchema),
24
24
  ] as const;
25
25
 
26
26
  const TranslateObjectResponseVariants = [
27
- makeResVariant(ENTITIES.permissions, PermissionTranslationsSchema),
28
- makeResVariant(ENTITIES.roles, RoleTranslationsSchema),
27
+ makeResVariant(ENTITIES.permission, PermissionTranslationsSchema),
28
+ makeResVariant(ENTITIES.role, RoleTranslationsSchema),
29
29
  ] as const;
30
30
 
31
31
  const TranslateObjectContractRequestSchema = BaseTranslateSchema.extend({
@@ -15,7 +15,7 @@ export const defaultPolicy: TContentPolicyRegistry<TEntity> = {
15
15
  'seo.description': 'text',
16
16
  },
17
17
  byEntity: {
18
- roles: {
18
+ role: {
19
19
  description: 'text',
20
20
  },
21
21
  },