hh-contracts 0.0.82 → 0.0.83
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/permissions/permission.models.js +3 -3
- package/build/roles/role.models.js +3 -3
- package/build/translations/index.js +1 -0
- package/package.json +1 -1
- package/permissions/permission.models.ts +3 -2
- package/roles/role.models.ts +3 -2
- package/translations/index.ts +1 -0
- package/translations/resolve-translation-value-type.helper.ts +2 -2
- package/translations/translation-value-type-policy.ts +5 -5
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PermissionListItemSchema = exports.PermissionWithTranslationsSchema = exports.
|
|
36
|
+
exports.PermissionListItemSchema = exports.PermissionWithTranslationsSchema = exports.PermissionTranslationsSchema = exports.PermissionPersistedSchema = exports.JsonConditionsSchema = void 0;
|
|
37
37
|
const z = __importStar(require("zod"));
|
|
38
38
|
const common_1 = require("../common");
|
|
39
39
|
exports.JsonConditionsSchema = z
|
|
@@ -61,12 +61,12 @@ exports.PermissionPersistedSchema = z
|
|
|
61
61
|
})
|
|
62
62
|
.extend(common_1.TimestampSchema.shape);
|
|
63
63
|
// V2 translations: all translatable fields are inside per-language translation object
|
|
64
|
-
exports.
|
|
64
|
+
exports.PermissionTranslationsSchema = z.object({
|
|
65
65
|
name: z.string().min(3),
|
|
66
66
|
description: z.string().optional(),
|
|
67
67
|
});
|
|
68
68
|
exports.PermissionWithTranslationsSchema = exports.PermissionPersistedSchema.extend({
|
|
69
|
-
translations: (0, common_1.makeTranslationsByLang)(exports.
|
|
69
|
+
translations: (0, common_1.makeTranslationsByLang)(exports.PermissionTranslationsSchema),
|
|
70
70
|
});
|
|
71
71
|
exports.PermissionListItemSchema = exports.PermissionPersistedSchema.extend({
|
|
72
72
|
name: z.string().nullable(),
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RoleListItemSchema = exports.RoleWithTranslationsSchema = exports.
|
|
36
|
+
exports.RoleListItemSchema = exports.RoleWithTranslationsSchema = exports.RoleTranslationsSchema = exports.RoleWithPermissionsSchema = exports.RolePersistedSchema = void 0;
|
|
37
37
|
const z = __importStar(require("zod"));
|
|
38
38
|
const common_1 = require("../common");
|
|
39
39
|
const permissions_1 = require("../permissions");
|
|
@@ -48,12 +48,12 @@ exports.RolePersistedSchema = z
|
|
|
48
48
|
exports.RoleWithPermissionsSchema = exports.RolePersistedSchema.extend({
|
|
49
49
|
permissionIds: common_1.UuidArraySchema.optional(),
|
|
50
50
|
});
|
|
51
|
-
exports.
|
|
51
|
+
exports.RoleTranslationsSchema = z.object({
|
|
52
52
|
name: z.string().min(3),
|
|
53
53
|
description: z.string().optional(),
|
|
54
54
|
});
|
|
55
55
|
exports.RoleWithTranslationsSchema = exports.RoleWithPermissionsSchema.extend({
|
|
56
|
-
translations: (0, common_1.makeTranslationsByLang)(exports.
|
|
56
|
+
translations: (0, common_1.makeTranslationsByLang)(exports.RoleTranslationsSchema),
|
|
57
57
|
});
|
|
58
58
|
exports.RoleListItemSchema = exports.RolePersistedSchema.extend({
|
|
59
59
|
name: z.string().nullable(),
|
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./translation.models"), exports);
|
|
18
18
|
__exportStar(require("./resolve-translation-value-type.helper"), exports);
|
|
19
19
|
__exportStar(require("./translation-value-types.constant"), exports);
|
|
20
|
+
__exportStar(require("./translation-value-type-policy"), exports);
|
package/package.json
CHANGED
|
@@ -32,13 +32,14 @@ export const PermissionPersistedSchema = z
|
|
|
32
32
|
export type TPermissionPersisted = z.infer<typeof PermissionPersistedSchema>;
|
|
33
33
|
|
|
34
34
|
// V2 translations: all translatable fields are inside per-language translation object
|
|
35
|
-
export const
|
|
35
|
+
export const PermissionTranslationsSchema = z.object({
|
|
36
36
|
name: z.string().min(3),
|
|
37
37
|
description: z.string().optional(),
|
|
38
38
|
});
|
|
39
|
+
export type TPermissionTranslations = z.infer<typeof PermissionTranslationsSchema>;
|
|
39
40
|
|
|
40
41
|
export const PermissionWithTranslationsSchema = PermissionPersistedSchema.extend({
|
|
41
|
-
translations: makeTranslationsByLang(
|
|
42
|
+
translations: makeTranslationsByLang(PermissionTranslationsSchema),
|
|
42
43
|
});
|
|
43
44
|
export type TPermissionWithTranslations = z.infer<typeof PermissionWithTranslationsSchema>;
|
|
44
45
|
|
package/roles/role.models.ts
CHANGED
|
@@ -22,13 +22,14 @@ export const RoleWithPermissionsSchema = RolePersistedSchema.extend({
|
|
|
22
22
|
});
|
|
23
23
|
export type TRoleWithPermissions = z.infer<typeof RoleWithPermissionsSchema>;
|
|
24
24
|
|
|
25
|
-
export const
|
|
25
|
+
export const RoleTranslationsSchema = z.object({
|
|
26
26
|
name: z.string().min(3),
|
|
27
27
|
description: z.string().optional(),
|
|
28
28
|
});
|
|
29
|
+
export type TRoleTranslations = z.infer<typeof RoleTranslationsSchema>;
|
|
29
30
|
|
|
30
31
|
export const RoleWithTranslationsSchema = RoleWithPermissionsSchema.extend({
|
|
31
|
-
translations: makeTranslationsByLang(
|
|
32
|
+
translations: makeTranslationsByLang(RoleTranslationsSchema),
|
|
32
33
|
});
|
|
33
34
|
export type TRoleWithTranslations = z.infer<typeof RoleWithTranslationsSchema>;
|
|
34
35
|
|
package/translations/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TEntity } from '../common';
|
|
2
|
-
import {
|
|
2
|
+
import { TContentPolicyRegistry, defaultPolicy } from './translation-value-type-policy';
|
|
3
3
|
import { TTranslationValueType } from './translation-value-types.constant';
|
|
4
4
|
|
|
5
5
|
export function resolveTranslationValueType<E extends TEntity>(
|
|
6
6
|
entityName: E,
|
|
7
7
|
dotPath: string,
|
|
8
8
|
explicit?: TTranslationValueType | null,
|
|
9
|
-
registry:
|
|
9
|
+
registry: TContentPolicyRegistry<E> = defaultPolicy,
|
|
10
10
|
): TTranslationValueType {
|
|
11
11
|
if (explicit) return explicit;
|
|
12
12
|
const byEntity = registry.byEntity?.[entityName];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TEntity } from '../common';
|
|
2
2
|
import type { TTranslationValueType } from './translation-value-types.constant';
|
|
3
3
|
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
default?:
|
|
7
|
-
byEntity?: Partial<Record<E,
|
|
4
|
+
export type TContentPolicy = Record<string, TTranslationValueType>;
|
|
5
|
+
export type TContentPolicyRegistry<E extends TEntity> = {
|
|
6
|
+
default?: TContentPolicy;
|
|
7
|
+
byEntity?: Partial<Record<E, TContentPolicy>>;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export const defaultPolicy:
|
|
10
|
+
export const defaultPolicy: TContentPolicyRegistry<TEntity> = {
|
|
11
11
|
default: {
|
|
12
12
|
name: 'text',
|
|
13
13
|
description: 'html',
|