@application-kit/audit-log 0.0.0-stage → 0.1.1
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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +52 -2
- package/dist/cjs/audit-log.wire.d.ts +10 -0
- package/dist/cjs/audit-log.wire.js +2 -0
- package/dist/cjs/constants.d.ts +8 -0
- package/dist/cjs/constants.js +4 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/nest/application/index.d.ts +2 -0
- package/dist/cjs/nest/application/index.js +18 -0
- package/dist/cjs/nest/application/ports/audit-log-read.interface.d.ts +3 -0
- package/dist/cjs/nest/application/ports/audit-log-read.interface.js +2 -0
- package/dist/cjs/nest/application/ports/audit-log-write.interface.d.ts +4 -0
- package/dist/cjs/nest/application/ports/audit-log-write.interface.js +2 -0
- package/dist/cjs/nest/application/ports/index.d.ts +2 -0
- package/dist/cjs/nest/application/ports/index.js +18 -0
- package/dist/cjs/nest/application/queries/dtos/audit-record.dto.d.ts +21 -0
- package/dist/cjs/nest/application/queries/dtos/audit-record.dto.js +24 -0
- package/dist/cjs/nest/application/queries/dtos/index.d.ts +1 -0
- package/dist/cjs/nest/application/queries/dtos/index.js +17 -0
- package/dist/cjs/nest/application/queries/get-audit-records.query.d.ts +6 -0
- package/dist/cjs/nest/application/queries/get-audit-records.query.js +7 -0
- package/dist/cjs/nest/application/queries/handlers/get-audit-records.handler.d.ts +9 -0
- package/dist/cjs/nest/application/queries/handlers/get-audit-records.handler.js +35 -0
- package/dist/cjs/nest/application/queries/handlers/index.d.ts +1 -0
- package/dist/cjs/nest/application/queries/handlers/index.js +17 -0
- package/dist/cjs/nest/application/queries/index.d.ts +3 -0
- package/dist/cjs/nest/application/queries/index.js +19 -0
- package/dist/cjs/nest/audit-log-consumers.module.d.ts +2 -0
- package/dist/cjs/nest/audit-log-consumers.module.js +22 -0
- package/dist/cjs/nest/audit-log-request-facts.module.d.ts +2 -0
- package/dist/cjs/nest/audit-log-request-facts.module.js +22 -0
- package/dist/cjs/nest/audit-log-web.module.d.ts +8 -0
- package/dist/cjs/nest/audit-log-web.module.js +39 -0
- package/dist/cjs/nest/audit-log.module.d.ts +2 -0
- package/dist/cjs/nest/audit-log.module.js +37 -0
- package/dist/cjs/nest/constants.d.ts +3 -0
- package/dist/cjs/nest/constants.js +6 -0
- package/dist/cjs/nest/domain/audit-record.d.ts +15 -0
- package/dist/cjs/nest/domain/audit-record.js +15 -0
- package/dist/cjs/nest/domain/index.d.ts +1 -0
- package/dist/cjs/nest/domain/index.js +17 -0
- package/dist/cjs/nest/index.d.ts +11 -0
- package/dist/cjs/nest/index.js +27 -0
- package/dist/cjs/nest/infrastructure/database/index.d.ts +1 -0
- package/dist/cjs/nest/infrastructure/database/index.js +17 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/entities/audit-record.entity.d.ts +11 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/entities/audit-record.entity.js +69 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/entities/index.d.ts +1 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/entities/index.js +17 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/index.d.ts +5 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/index.js +21 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/mappers/audit-record.mapper.d.ts +10 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/mappers/audit-record.mapper.js +35 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/mappers/index.d.ts +1 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/mappers/index.js +17 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/migrations/audit-records-append-only.migration.d.ts +6 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/migrations/audit-records-append-only.migration.js +28 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/migrations/index.d.ts +1 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/migrations/index.js +17 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/orm.d.ts +6 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/orm.js +9 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/repositories/audit-record.repository.d.ts +14 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/repositories/audit-record.repository.js +47 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/repositories/index.d.ts +1 -0
- package/dist/cjs/nest/infrastructure/database/typeorm/repositories/index.js +17 -0
- package/dist/cjs/nest/infrastructure/index.d.ts +1 -0
- package/dist/cjs/nest/infrastructure/index.js +17 -0
- package/dist/cjs/nest/libs/audit-request-context.d.ts +25 -0
- package/dist/cjs/nest/libs/audit-request-context.js +23 -0
- package/dist/cjs/nest/libs/index.d.ts +1 -0
- package/dist/cjs/nest/libs/index.js +17 -0
- package/dist/cjs/nest/policy-handlers.d.ts +2 -0
- package/dist/cjs/nest/policy-handlers.js +5 -0
- package/dist/cjs/nest/user-interface/consumers/audit-facts.dto.d.ts +6 -0
- package/dist/cjs/nest/user-interface/consumers/audit-facts.dto.js +40 -0
- package/dist/cjs/nest/user-interface/consumers/audited-fact.dto.d.ts +5 -0
- package/dist/cjs/nest/user-interface/consumers/audited-fact.dto.js +30 -0
- package/dist/cjs/nest/user-interface/consumers/index.d.ts +3 -0
- package/dist/cjs/nest/user-interface/consumers/index.js +19 -0
- package/dist/cjs/nest/user-interface/consumers/record-audit-fact.handler.d.ts +13 -0
- package/dist/cjs/nest/user-interface/consumers/record-audit-fact.handler.js +44 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/audit-record-item.type.d.ts +11 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/audit-record-item.type.js +59 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/audit-records.resolver.d.ts +8 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/audit-records.resolver.js +58 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/audit-records.type.d.ts +8 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/audit-records.type.js +36 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/index.d.ts +3 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/audit-records/index.js +19 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/index.d.ts +1 -0
- package/dist/cjs/nest/user-interface/controllers/graphql/index.js +17 -0
- package/dist/cjs/nest/user-interface/controllers/index.d.ts +1 -0
- package/dist/cjs/nest/user-interface/controllers/index.js +17 -0
- package/dist/cjs/nest/user-interface/index.d.ts +3 -0
- package/dist/cjs/nest/user-interface/index.js +19 -0
- package/dist/cjs/nest/user-interface/interceptors/audit-request-context.interceptor.d.ts +8 -0
- package/dist/cjs/nest/user-interface/interceptors/audit-request-context.interceptor.js +36 -0
- package/dist/cjs/nest/user-interface/interceptors/index.d.ts +1 -0
- package/dist/cjs/nest/user-interface/interceptors/index.js +17 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/testing/audit-log-read.fake.d.ts +14 -0
- package/dist/cjs/testing/audit-log-read.fake.js +16 -0
- package/dist/cjs/testing/audit-log-write.fake.d.ts +8 -0
- package/dist/cjs/testing/audit-log-write.fake.js +18 -0
- package/dist/cjs/testing/index.d.ts +2 -0
- package/dist/cjs/testing/index.js +18 -0
- package/dist/esm/audit-log.wire.d.ts +10 -0
- package/dist/esm/audit-log.wire.js +1 -0
- package/dist/esm/constants.d.ts +8 -0
- package/dist/esm/constants.js +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/nest/application/index.d.ts +2 -0
- package/dist/esm/nest/application/index.js +2 -0
- package/dist/esm/nest/application/ports/audit-log-read.interface.d.ts +3 -0
- package/dist/esm/nest/application/ports/audit-log-read.interface.js +1 -0
- package/dist/esm/nest/application/ports/audit-log-write.interface.d.ts +4 -0
- package/dist/esm/nest/application/ports/audit-log-write.interface.js +1 -0
- package/dist/esm/nest/application/ports/index.d.ts +2 -0
- package/dist/esm/nest/application/ports/index.js +2 -0
- package/dist/esm/nest/application/queries/dtos/audit-record.dto.d.ts +21 -0
- package/dist/esm/nest/application/queries/dtos/audit-record.dto.js +20 -0
- package/dist/esm/nest/application/queries/dtos/index.d.ts +1 -0
- package/dist/esm/nest/application/queries/dtos/index.js +1 -0
- package/dist/esm/nest/application/queries/get-audit-records.query.d.ts +6 -0
- package/dist/esm/nest/application/queries/get-audit-records.query.js +3 -0
- package/dist/esm/nest/application/queries/handlers/get-audit-records.handler.d.ts +9 -0
- package/dist/esm/nest/application/queries/handlers/get-audit-records.handler.js +32 -0
- package/dist/esm/nest/application/queries/handlers/index.d.ts +1 -0
- package/dist/esm/nest/application/queries/handlers/index.js +1 -0
- package/dist/esm/nest/application/queries/index.d.ts +3 -0
- package/dist/esm/nest/application/queries/index.js +3 -0
- package/dist/esm/nest/audit-log-consumers.module.d.ts +2 -0
- package/dist/esm/nest/audit-log-consumers.module.js +19 -0
- package/dist/esm/nest/audit-log-request-facts.module.d.ts +2 -0
- package/dist/esm/nest/audit-log-request-facts.module.js +19 -0
- package/dist/esm/nest/audit-log-web.module.d.ts +8 -0
- package/dist/esm/nest/audit-log-web.module.js +36 -0
- package/dist/esm/nest/audit-log.module.d.ts +2 -0
- package/dist/esm/nest/audit-log.module.js +34 -0
- package/dist/esm/nest/constants.d.ts +3 -0
- package/dist/esm/nest/constants.js +3 -0
- package/dist/esm/nest/domain/audit-record.d.ts +15 -0
- package/dist/esm/nest/domain/audit-record.js +11 -0
- package/dist/esm/nest/domain/index.d.ts +1 -0
- package/dist/esm/nest/domain/index.js +1 -0
- package/dist/esm/nest/index.d.ts +11 -0
- package/dist/esm/nest/index.js +11 -0
- package/dist/esm/nest/infrastructure/database/index.d.ts +1 -0
- package/dist/esm/nest/infrastructure/database/index.js +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/entities/audit-record.entity.d.ts +11 -0
- package/dist/esm/nest/infrastructure/database/typeorm/entities/audit-record.entity.js +66 -0
- package/dist/esm/nest/infrastructure/database/typeorm/entities/index.d.ts +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/entities/index.js +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/index.d.ts +5 -0
- package/dist/esm/nest/infrastructure/database/typeorm/index.js +5 -0
- package/dist/esm/nest/infrastructure/database/typeorm/mappers/audit-record.mapper.d.ts +10 -0
- package/dist/esm/nest/infrastructure/database/typeorm/mappers/audit-record.mapper.js +31 -0
- package/dist/esm/nest/infrastructure/database/typeorm/mappers/index.d.ts +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/mappers/index.js +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/migrations/audit-records-append-only.migration.d.ts +6 -0
- package/dist/esm/nest/infrastructure/database/typeorm/migrations/audit-records-append-only.migration.js +24 -0
- package/dist/esm/nest/infrastructure/database/typeorm/migrations/index.d.ts +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/migrations/index.js +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/orm.d.ts +6 -0
- package/dist/esm/nest/infrastructure/database/typeorm/orm.js +6 -0
- package/dist/esm/nest/infrastructure/database/typeorm/repositories/audit-record.repository.d.ts +14 -0
- package/dist/esm/nest/infrastructure/database/typeorm/repositories/audit-record.repository.js +44 -0
- package/dist/esm/nest/infrastructure/database/typeorm/repositories/index.d.ts +1 -0
- package/dist/esm/nest/infrastructure/database/typeorm/repositories/index.js +1 -0
- package/dist/esm/nest/infrastructure/index.d.ts +1 -0
- package/dist/esm/nest/infrastructure/index.js +1 -0
- package/dist/esm/nest/libs/audit-request-context.d.ts +25 -0
- package/dist/esm/nest/libs/audit-request-context.js +18 -0
- package/dist/esm/nest/libs/index.d.ts +1 -0
- package/dist/esm/nest/libs/index.js +1 -0
- package/dist/esm/nest/policy-handlers.d.ts +2 -0
- package/dist/esm/nest/policy-handlers.js +1 -0
- package/dist/esm/nest/user-interface/consumers/audit-facts.dto.d.ts +6 -0
- package/dist/esm/nest/user-interface/consumers/audit-facts.dto.js +36 -0
- package/dist/esm/nest/user-interface/consumers/audited-fact.dto.d.ts +5 -0
- package/dist/esm/nest/user-interface/consumers/audited-fact.dto.js +26 -0
- package/dist/esm/nest/user-interface/consumers/index.d.ts +3 -0
- package/dist/esm/nest/user-interface/consumers/index.js +3 -0
- package/dist/esm/nest/user-interface/consumers/record-audit-fact.handler.d.ts +13 -0
- package/dist/esm/nest/user-interface/consumers/record-audit-fact.handler.js +41 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/audit-record-item.type.d.ts +11 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/audit-record-item.type.js +56 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/audit-records.resolver.d.ts +8 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/audit-records.resolver.js +55 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/audit-records.type.d.ts +8 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/audit-records.type.js +33 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/index.d.ts +3 -0
- package/dist/esm/nest/user-interface/controllers/graphql/audit-records/index.js +3 -0
- package/dist/esm/nest/user-interface/controllers/graphql/index.d.ts +1 -0
- package/dist/esm/nest/user-interface/controllers/graphql/index.js +1 -0
- package/dist/esm/nest/user-interface/controllers/index.d.ts +1 -0
- package/dist/esm/nest/user-interface/controllers/index.js +1 -0
- package/dist/esm/nest/user-interface/index.d.ts +3 -0
- package/dist/esm/nest/user-interface/index.js +3 -0
- package/dist/esm/nest/user-interface/interceptors/audit-request-context.interceptor.d.ts +8 -0
- package/dist/esm/nest/user-interface/interceptors/audit-request-context.interceptor.js +33 -0
- package/dist/esm/nest/user-interface/interceptors/index.d.ts +1 -0
- package/dist/esm/nest/user-interface/interceptors/index.js +1 -0
- package/dist/esm/testing/audit-log-read.fake.d.ts +14 -0
- package/dist/esm/testing/audit-log-read.fake.js +12 -0
- package/dist/esm/testing/audit-log-write.fake.d.ts +8 -0
- package/dist/esm/testing/audit-log-write.fake.js +14 -0
- package/dist/esm/testing/index.d.ts +2 -0
- package/dist/esm/testing/index.js +2 -0
- package/package.json +125 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @application-kit/audit-log
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3a2f7ed: `graphql`: класс аргументов листинга `Payload` (`@ArgsType`) переименован в `ListingArgs` — имя говорит, чьи это аргументы.
|
|
8
|
+
**Ломающее:** потребителю — заменить импорт и тип `Payload` на `ListingArgs`; схема GraphQL не меняется, имя класса в неё не попадает.
|
|
9
|
+
|
|
10
|
+
`audit-log`: резолвер `auditRecords` принимает `ListingArgs`.
|
|
11
|
+
- Updated dependencies [3a2f7ed]
|
|
12
|
+
- Updated dependencies [79a405c]
|
|
13
|
+
- Updated dependencies [c5a41d7]
|
|
14
|
+
- @application-kit/graphql@0.8.0
|
|
15
|
+
- @application-kit/typeorm@0.5.2
|
|
16
|
+
|
|
17
|
+
## 0.1.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- fb8e06d: Новый пакет `@application-kit/audit-log`: журнал аудита с append-only таблицей, записью из событий и чтением через GraphQL.
|
|
22
|
+
Вся схема — одной миграцией `AuditRecordsAppendOnly1789712401337`: база с полной прежней цепочкой считает её применённой,
|
|
23
|
+
база с неполной цепочкой падает на `CREATE TABLE`, такую базу пересоздают. Подключение и право на чтение — в README пакета.
|
|
24
|
+
|
|
25
|
+
В `transaction-outbox` хук `TRANSACTION_OUTBOX_REQUEST_FACTS` стал необязательным: без него события с
|
|
26
|
+
`carriesRequestFacts` пишутся без `facts`. Приложениям, которые хук регистрируют, ничего менять не нужно.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [fb8e06d]
|
|
31
|
+
- @application-kit/transaction-outbox@0.4.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 application-kit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @application-kit/audit-log
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Журнал аудита для NestJS-приложений: append-only таблица с триггерами, запись из событий, чтение через GraphQL и
|
|
4
|
+
факты запроса для `@application-kit/transaction-outbox`. Пакет не знает ролей и действий продукта: журнал хранит их
|
|
5
|
+
строками, а кому читать журнал, решает карта грантов приложения.
|
|
6
|
+
|
|
7
|
+
## Входы
|
|
8
|
+
|
|
9
|
+
| Вход | Для чего | Тянет |
|
|
10
|
+
|------|----------|-------|
|
|
11
|
+
| `@application-kit/audit-log` | сервер и браузер: `AuditRecordWireInterface`, `AUDIT_LOG_MODULE_NAME`, право `AuditRecord` | только типы `@application-kit/authorization` |
|
|
12
|
+
| `@application-kit/audit-log/nest` | сервер: модули, порты, `RecordAuditFactHandler`, `orm` | `@nestjs/*`, `typeorm`, `class-validator` |
|
|
13
|
+
| `@application-kit/audit-log/testing` | фейки портов чтения и записи | — |
|
|
14
|
+
|
|
15
|
+
## Подключение
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { AuditLogConsumersModule, AuditLogModule, AuditLogWebModule, orm as auditLogOrm } from '@application-kit/audit-log/nest'
|
|
19
|
+
|
|
20
|
+
// Web-процесс. Каким заголовкам верить, знает только продукт: это зависит от прокси перед его подами.
|
|
21
|
+
AuditLogWebModule.forRoot({ resolveRequestFacts: (request) => resolveRequestFacts(request, { trustedHeaders: ['cf-connecting-ip'] }) })
|
|
22
|
+
|
|
23
|
+
// Консьюмер-процесс: владелец событий держит `@MessagePattern` и зовёт `RecordAuditFactHandler`.
|
|
24
|
+
AuditLogConsumersModule
|
|
25
|
+
|
|
26
|
+
// CLI миграций.
|
|
27
|
+
createCliDataSource({ ..., packages: [auditLogOrm] }) // @application-kit/typeorm/nest
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Таблица называется по naming strategy продукта: миграция рассчитана на `TypeormPluralNamingStrategy` (`audit_records`, snake_case).
|
|
31
|
+
|
|
32
|
+
`AuditLogModule` регистрирует хук `TRANSACTION_OUTBOX_REQUEST_FACTS` глобально. Продукт без журнала его не подключает:
|
|
33
|
+
outbox пишет события без `facts`.
|
|
34
|
+
|
|
35
|
+
## Право на чтение
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { AUDIT_LOG_MODULE_NAME } from '@application-kit/audit-log'
|
|
39
|
+
|
|
40
|
+
export const auditLogGrants = {
|
|
41
|
+
grants: { ADMIN: (builder) => { builder.can('read', 'AuditRecord') } },
|
|
42
|
+
name: AUDIT_LOG_MODULE_NAME,
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Миграция
|
|
47
|
+
|
|
48
|
+
Одна: `AuditRecordsAppendOnly1789712401337`. Её имя совпадает с последней миграцией прежней цепочки, поэтому на базе с полной
|
|
49
|
+
цепочкой она считается применённой. База с неполной цепочкой падает на `CREATE TABLE`, такую базу пересоздают.
|
|
50
|
+
`down` удаляет таблицу вместе с записями.
|
|
51
|
+
|
|
52
|
+
Журнал: `UPDATE` и `DELETE` по таблице останавливают триггеры с ошибкой. Это защита от бага приложения и tamper-evidence, а не
|
|
53
|
+
от владельца БД: он может удалить триггер тем же соединением.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AuditRecordWireInterface<TDate = string, TRole extends string = string> {
|
|
2
|
+
action: string;
|
|
3
|
+
actorId: null | string;
|
|
4
|
+
actorRole: null | TRole;
|
|
5
|
+
createdAt: TDate;
|
|
6
|
+
id: string;
|
|
7
|
+
ip: null | string;
|
|
8
|
+
subjectId: string;
|
|
9
|
+
userAgent: null | string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Subject } from '@application-kit/authorization';
|
|
2
|
+
export declare const AUDIT_LOG_MODULE_NAME = "audit-log";
|
|
3
|
+
declare module '@application-kit/authorization' {
|
|
4
|
+
interface SubjectRegistryInterface {
|
|
5
|
+
AuditRecord: 'read';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export type AuditLogSubject = Extract<Subject, 'AuditRecord'>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./audit-log.wire.js"), exports);
|
|
18
|
+
__exportStar(require("./constants.js"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ports/index.js"), exports);
|
|
18
|
+
__exportStar(require("./queries/index.js"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./audit-log-read.interface.js"), exports);
|
|
18
|
+
__exportStar(require("./audit-log-write.interface.js"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface AuditRecordDtoOptionsInterface {
|
|
2
|
+
readonly action: string;
|
|
3
|
+
readonly actorId: null | string;
|
|
4
|
+
readonly actorRole: null | string;
|
|
5
|
+
readonly createdAt: Date;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly ip: null | string;
|
|
8
|
+
readonly subjectId: string;
|
|
9
|
+
readonly userAgent: null | string;
|
|
10
|
+
}
|
|
11
|
+
export declare class AuditRecordDto {
|
|
12
|
+
readonly action: string;
|
|
13
|
+
readonly actorId: null | string;
|
|
14
|
+
readonly actorRole: null | string;
|
|
15
|
+
readonly createdAt: Date;
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly ip: null | string;
|
|
18
|
+
readonly subjectId: string;
|
|
19
|
+
readonly userAgent: null | string;
|
|
20
|
+
constructor(options: AuditRecordDtoOptionsInterface);
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditRecordDto = void 0;
|
|
4
|
+
class AuditRecordDto {
|
|
5
|
+
action;
|
|
6
|
+
actorId;
|
|
7
|
+
actorRole;
|
|
8
|
+
createdAt;
|
|
9
|
+
id;
|
|
10
|
+
ip;
|
|
11
|
+
subjectId;
|
|
12
|
+
userAgent;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.action = options.action;
|
|
15
|
+
this.actorId = options.actorId;
|
|
16
|
+
this.actorRole = options.actorRole;
|
|
17
|
+
this.createdAt = options.createdAt;
|
|
18
|
+
this.id = options.id;
|
|
19
|
+
this.ip = options.ip;
|
|
20
|
+
this.subjectId = options.subjectId;
|
|
21
|
+
this.userAgent = options.userAgent;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AuditRecordDto = AuditRecordDto;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './audit-record.dto.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./audit-record.dto.js"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ListingQueryResultInterface } from '@application-kit/typeorm/nest';
|
|
2
|
+
import { ListingQuery } from '@application-kit/typeorm/nest';
|
|
3
|
+
import type { AuditRecordDto } from './dtos/audit-record.dto.js';
|
|
4
|
+
export type GetAuditRecordsQueryResult = ListingQueryResultInterface<AuditRecordDto>;
|
|
5
|
+
export declare class GetAuditRecordsQuery extends ListingQuery {
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAuditRecordsQuery = void 0;
|
|
4
|
+
const nest_1 = require("@application-kit/typeorm/nest");
|
|
5
|
+
class GetAuditRecordsQuery extends nest_1.ListingQuery {
|
|
6
|
+
}
|
|
7
|
+
exports.GetAuditRecordsQuery = GetAuditRecordsQuery;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IQueryHandler } from '@nestjs/cqrs';
|
|
2
|
+
import { ListingHandler } from '@application-kit/typeorm/nest';
|
|
3
|
+
import type { AuditLogReadInterface } from '../../ports/audit-log-read.interface.js';
|
|
4
|
+
import { AuditRecordDto } from '../dtos/audit-record.dto.js';
|
|
5
|
+
import { GetAuditRecordsQuery, GetAuditRecordsQueryResult } from '../get-audit-records.query.js';
|
|
6
|
+
export declare class GetAuditRecordsHandler extends ListingHandler<AuditRecordDto> implements IQueryHandler<GetAuditRecordsQuery, GetAuditRecordsQueryResult> {
|
|
7
|
+
constructor(auditLogRepository: AuditLogReadInterface);
|
|
8
|
+
execute(query: GetAuditRecordsQuery): Promise<GetAuditRecordsQueryResult>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.GetAuditRecordsHandler = void 0;
|
|
16
|
+
const nest_1 = require("@application-kit/typeorm/nest");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const cqrs_1 = require("@nestjs/cqrs");
|
|
19
|
+
const constants_js_1 = require("../../../constants.js");
|
|
20
|
+
const get_audit_records_query_js_1 = require("../get-audit-records.query.js");
|
|
21
|
+
const MAX_LIMIT = 200;
|
|
22
|
+
let GetAuditRecordsHandler = class GetAuditRecordsHandler extends nest_1.ListingHandler {
|
|
23
|
+
constructor(auditLogRepository) {
|
|
24
|
+
super(auditLogRepository);
|
|
25
|
+
}
|
|
26
|
+
async execute(query) {
|
|
27
|
+
return super.execute(new get_audit_records_query_js_1.GetAuditRecordsQuery({ ...query.paginator, limit: Math.min(query.paginator.limit, MAX_LIMIT) }, query.filters, query.sorting));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.GetAuditRecordsHandler = GetAuditRecordsHandler;
|
|
31
|
+
exports.GetAuditRecordsHandler = GetAuditRecordsHandler = __decorate([
|
|
32
|
+
(0, cqrs_1.QueryHandler)(get_audit_records_query_js_1.GetAuditRecordsQuery),
|
|
33
|
+
__param(0, (0, common_1.Inject)(constants_js_1.AUDIT_LOG_READ_PORT)),
|
|
34
|
+
__metadata("design:paramtypes", [Object])
|
|
35
|
+
], GetAuditRecordsHandler);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-audit-records.handler.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./get-audit-records.handler.js"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dtos/index.js"), exports);
|
|
18
|
+
__exportStar(require("./handlers/index.js"), exports);
|
|
19
|
+
__exportStar(require("./get-audit-records.query.js"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuditLogConsumersModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const audit_log_module_js_1 = require("./audit-log.module.js");
|
|
12
|
+
const record_audit_fact_handler_js_1 = require("./user-interface/consumers/record-audit-fact.handler.js");
|
|
13
|
+
let AuditLogConsumersModule = class AuditLogConsumersModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AuditLogConsumersModule = AuditLogConsumersModule;
|
|
16
|
+
exports.AuditLogConsumersModule = AuditLogConsumersModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
exports: [record_audit_fact_handler_js_1.RecordAuditFactHandler],
|
|
19
|
+
imports: [audit_log_module_js_1.AuditLogModule],
|
|
20
|
+
providers: [record_audit_fact_handler_js_1.RecordAuditFactHandler],
|
|
21
|
+
})
|
|
22
|
+
], AuditLogConsumersModule);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuditLogRequestFactsModule = void 0;
|
|
10
|
+
const transaction_outbox_1 = require("@application-kit/transaction-outbox");
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const audit_request_context_js_1 = require("./libs/audit-request-context.js");
|
|
13
|
+
let AuditLogRequestFactsModule = class AuditLogRequestFactsModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AuditLogRequestFactsModule = AuditLogRequestFactsModule;
|
|
16
|
+
exports.AuditLogRequestFactsModule = AuditLogRequestFactsModule = __decorate([
|
|
17
|
+
(0, common_1.Global)(),
|
|
18
|
+
(0, common_1.Module)({
|
|
19
|
+
exports: [transaction_outbox_1.TRANSACTION_OUTBOX_REQUEST_FACTS],
|
|
20
|
+
providers: [{ provide: transaction_outbox_1.TRANSACTION_OUTBOX_REQUEST_FACTS, useValue: audit_request_context_js_1.auditRequestFacts }],
|
|
21
|
+
})
|
|
22
|
+
], AuditLogRequestFactsModule);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { AuditRequestFactsResolver } from './libs/audit-request-context.js';
|
|
3
|
+
export interface AuditLogWebOptionsInterface {
|
|
4
|
+
resolveRequestFacts: AuditRequestFactsResolver;
|
|
5
|
+
}
|
|
6
|
+
export declare class AuditLogWebModule {
|
|
7
|
+
static forRoot(options: AuditLogWebOptionsInterface): DynamicModule;
|
|
8
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuditLogWebModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const core_1 = require("@nestjs/core");
|
|
12
|
+
const cqrs_1 = require("@nestjs/cqrs");
|
|
13
|
+
const audit_log_module_js_1 = require("./audit-log.module.js");
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const audit_records_resolver_js_1 = require("./user-interface/controllers/graphql/audit-records/audit-records.resolver.js");
|
|
16
|
+
const audit_request_context_interceptor_js_1 = require("./user-interface/interceptors/audit-request-context.interceptor.js");
|
|
17
|
+
let AuditLogWebModule = class AuditLogWebModule {
|
|
18
|
+
static forRoot(options) {
|
|
19
|
+
return {
|
|
20
|
+
imports: [audit_log_module_js_1.AuditLogModule, cqrs_1.CqrsModule],
|
|
21
|
+
module: this,
|
|
22
|
+
providers: [
|
|
23
|
+
audit_records_resolver_js_1.AuditRecordsResolver,
|
|
24
|
+
{
|
|
25
|
+
provide: core_1.APP_INTERCEPTOR,
|
|
26
|
+
useClass: audit_request_context_interceptor_js_1.AuditRequestContextInterceptor,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
provide: constants_js_1.AUDIT_REQUEST_FACTS_RESOLVER,
|
|
30
|
+
useValue: options.resolveRequestFacts,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.AuditLogWebModule = AuditLogWebModule;
|
|
37
|
+
exports.AuditLogWebModule = AuditLogWebModule = __decorate([
|
|
38
|
+
(0, common_1.Module)({})
|
|
39
|
+
], AuditLogWebModule);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuditLogModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const cqrs_1 = require("@nestjs/cqrs");
|
|
12
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
13
|
+
const get_audit_records_handler_js_1 = require("./application/queries/handlers/get-audit-records.handler.js");
|
|
14
|
+
const audit_log_request_facts_module_js_1 = require("./audit-log-request-facts.module.js");
|
|
15
|
+
const constants_js_1 = require("./constants.js");
|
|
16
|
+
const audit_record_entity_js_1 = require("./infrastructure/database/typeorm/entities/audit-record.entity.js");
|
|
17
|
+
const audit_record_repository_js_1 = require("./infrastructure/database/typeorm/repositories/audit-record.repository.js");
|
|
18
|
+
let AuditLogModule = class AuditLogModule {
|
|
19
|
+
};
|
|
20
|
+
exports.AuditLogModule = AuditLogModule;
|
|
21
|
+
exports.AuditLogModule = AuditLogModule = __decorate([
|
|
22
|
+
(0, common_1.Module)({
|
|
23
|
+
exports: [constants_js_1.AUDIT_LOG_READ_PORT, constants_js_1.AUDIT_LOG_WRITE_PORT],
|
|
24
|
+
imports: [audit_log_request_facts_module_js_1.AuditLogRequestFactsModule, cqrs_1.CqrsModule, typeorm_1.TypeOrmModule.forFeature([audit_record_entity_js_1.AuditRecordEntity])],
|
|
25
|
+
providers: [
|
|
26
|
+
get_audit_records_handler_js_1.GetAuditRecordsHandler,
|
|
27
|
+
{
|
|
28
|
+
provide: constants_js_1.AUDIT_LOG_READ_PORT,
|
|
29
|
+
useClass: audit_record_repository_js_1.AuditRecordRepository,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
provide: constants_js_1.AUDIT_LOG_WRITE_PORT,
|
|
33
|
+
useClass: audit_record_repository_js_1.AuditRecordRepository,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
], AuditLogModule);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUDIT_REQUEST_FACTS_RESOLVER = exports.AUDIT_LOG_WRITE_PORT = exports.AUDIT_LOG_READ_PORT = void 0;
|
|
4
|
+
exports.AUDIT_LOG_READ_PORT = Symbol('AUDIT_LOG_READ_PORT');
|
|
5
|
+
exports.AUDIT_LOG_WRITE_PORT = Symbol('AUDIT_LOG_WRITE_PORT');
|
|
6
|
+
exports.AUDIT_REQUEST_FACTS_RESOLVER = Symbol('AUDIT_REQUEST_FACTS_RESOLVER');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AbstractEntity, Uuid } from '@libs-for-dev/nestjs-ddd-library';
|
|
2
|
+
export interface AuditRecordPropsInterface {
|
|
3
|
+
action: string;
|
|
4
|
+
actorId: null | string;
|
|
5
|
+
actorRole: null | string;
|
|
6
|
+
eventId: null | string;
|
|
7
|
+
ip: null | string;
|
|
8
|
+
subjectId: string;
|
|
9
|
+
userAgent: null | string;
|
|
10
|
+
}
|
|
11
|
+
export declare const AUDIT_IP_MAX_LENGTH = 64;
|
|
12
|
+
export declare const AUDIT_USER_AGENT_MAX_LENGTH = 512;
|
|
13
|
+
export declare class AuditRecord extends AbstractEntity<Uuid, AuditRecordPropsInterface> {
|
|
14
|
+
static create: (properties: AuditRecordPropsInterface) => AuditRecord;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuditRecord = exports.AUDIT_USER_AGENT_MAX_LENGTH = exports.AUDIT_IP_MAX_LENGTH = void 0;
|
|
4
|
+
const nestjs_ddd_library_1 = require("@libs-for-dev/nestjs-ddd-library");
|
|
5
|
+
exports.AUDIT_IP_MAX_LENGTH = 64;
|
|
6
|
+
exports.AUDIT_USER_AGENT_MAX_LENGTH = 512;
|
|
7
|
+
const truncate = (value, maxLength) => (value === null ? null : value.slice(0, maxLength));
|
|
8
|
+
class AuditRecord extends nestjs_ddd_library_1.AbstractEntity {
|
|
9
|
+
static create = (properties) => new AuditRecord(nestjs_ddd_library_1.Uuid.generate(), {
|
|
10
|
+
...properties,
|
|
11
|
+
ip: truncate(properties.ip, exports.AUDIT_IP_MAX_LENGTH),
|
|
12
|
+
userAgent: truncate(properties.userAgent, exports.AUDIT_USER_AGENT_MAX_LENGTH),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.AuditRecord = AuditRecord;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './audit-record.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./audit-record.js"), exports);
|