hh-contracts 0.0.81 → 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/AGENTS.md +66 -0
- package/build/permissions/permission.models.js +3 -3
- package/build/roles/role.models.js +3 -3
- package/build/translations/index.js +1 -0
- package/build/translations/translation-value-types.constant.js +2 -2
- package/build/translations/translation.models.js +1 -1
- 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
- package/translations/translation-value-types.constant.ts +1 -1
- package/translations/translation.models.ts +2 -2
package/AGENTS.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# agents.md — Каркас для Codex/LLM-агентов
|
|
2
|
+
|
|
3
|
+
## 1. Введение
|
|
4
|
+
|
|
5
|
+
Этот документ описывает агентов (AI-ассистентов), их роли, правила и форматы работы.
|
|
6
|
+
Цель — стандартизировать использование Codex/LLM внутри проекта, сделать промптинг воспроизводимым и согласованным.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 2. Таксономия агентов
|
|
11
|
+
|
|
12
|
+
Определены следующие агенты:
|
|
13
|
+
|
|
14
|
+
- **Contracts Agent** — ведёт Zod-схемы, DTO, enums в `hh-contracts`.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 3. Общие принципы
|
|
19
|
+
|
|
20
|
+
1. **Single Source of Truth**: все типы и схемы берутся из `hh-contracts`.
|
|
21
|
+
2. **Чёткие форматы**: каждый агент возвращает только согласованный формат (TSX, SQL, JSON и т.д.).
|
|
22
|
+
3. **ASSUMPTIONS/GAPS**: если данных не хватает, агент явно указывает предположения и пробелы.
|
|
23
|
+
4. **Пошаговость**: сложные задачи делятся на дизайн → реализация → тесты.
|
|
24
|
+
5. **Безопасность**: никаких секретов, токены только через `process.env` и Zod-валидацию.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 4. Описание агентов
|
|
29
|
+
|
|
30
|
+
### Contracts Agent
|
|
31
|
+
|
|
32
|
+
**Назначение**: ведёт контракты (Zod v4 схемы/DTO).
|
|
33
|
+
**Вход**: описание сущностей, версия `hh-contracts`.
|
|
34
|
+
**Выход**: TypeScript-файл со схемами, без README.
|
|
35
|
+
**Стиль**: TS 5.x strict, без `any`.
|
|
36
|
+
**Ограничения**: не использовать class-validator.
|
|
37
|
+
**Инструменты**: zod.
|
|
38
|
+
**Few-shot**:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Запрос: Добавь сущность Permission (id, name, action, subject, conditions?)
|
|
42
|
+
Ответ: TypeScript-файл с Zod-схемой и типом.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 5. Чек-лист качества (для каждого ответа)
|
|
48
|
+
|
|
49
|
+
- [ ] Соответствует контрактам.
|
|
50
|
+
- [ ] Нет магических значений.
|
|
51
|
+
- [ ] Типизировано строго.
|
|
52
|
+
- [ ] Есть тесты или примеры.
|
|
53
|
+
- [ ] Код ≤ 400 строк.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 6. Версионирование
|
|
58
|
+
|
|
59
|
+
- Изменения фиксируются внизу файла (Changelog).
|
|
60
|
+
- MAJOR — при смене форматов, MINOR — при добавлении агентов.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Changelog
|
|
65
|
+
|
|
66
|
+
- 1.0 — первоначальная версия каркаса.
|
|
@@ -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);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TRANSLATION_VALUE_TYPES_VALUES = exports.TRANSLATION_VALUE_TYPES = void 0;
|
|
4
4
|
exports.TRANSLATION_VALUE_TYPES = {
|
|
5
5
|
text: 'text',
|
|
6
6
|
html: 'html',
|
|
7
7
|
};
|
|
8
|
-
exports.
|
|
8
|
+
exports.TRANSLATION_VALUE_TYPES_VALUES = Object.values(exports.TRANSLATION_VALUE_TYPES);
|
|
@@ -42,6 +42,6 @@ exports.TranslationPersistedSchema = z.object({
|
|
|
42
42
|
entityId: z.string(),
|
|
43
43
|
lang: common_1.LanguageKeysSchema,
|
|
44
44
|
path: z.string(),
|
|
45
|
-
valueType: z.enum(translation_value_types_constant_1.
|
|
45
|
+
valueType: z.enum(translation_value_types_constant_1.TRANSLATION_VALUE_TYPES_VALUES),
|
|
46
46
|
value: z.string().min(1),
|
|
47
47
|
});
|
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',
|
|
@@ -4,7 +4,7 @@ export const TRANSLATION_VALUE_TYPES = {
|
|
|
4
4
|
} as const;
|
|
5
5
|
export type TTranslationValueType =
|
|
6
6
|
(typeof TRANSLATION_VALUE_TYPES)[keyof typeof TRANSLATION_VALUE_TYPES];
|
|
7
|
-
export const
|
|
7
|
+
export const TRANSLATION_VALUE_TYPES_VALUES = Object.values(TRANSLATION_VALUE_TYPES) as [
|
|
8
8
|
TTranslationValueType,
|
|
9
9
|
...TTranslationValueType[],
|
|
10
10
|
];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { ENTITY_VALUES, LanguageKeysSchema } from '../common';
|
|
3
|
-
import {
|
|
3
|
+
import { TRANSLATION_VALUE_TYPES_VALUES } from './translation-value-types.constant';
|
|
4
4
|
|
|
5
5
|
export const TranslationPersistedSchema = z.object({
|
|
6
6
|
entityName: z.enum(ENTITY_VALUES),
|
|
7
7
|
entityId: z.string(),
|
|
8
8
|
lang: LanguageKeysSchema,
|
|
9
9
|
path: z.string(),
|
|
10
|
-
valueType: z.enum(
|
|
10
|
+
valueType: z.enum(TRANSLATION_VALUE_TYPES_VALUES),
|
|
11
11
|
value: z.string().min(1),
|
|
12
12
|
});
|
|
13
13
|
export type TTranslationPersisted = z.infer<typeof TranslationPersistedSchema>;
|