@sisques-labs/nestjs-kit 0.1.0
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/README.md +770 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/application/commands/base/base-command.handler.d.ts +6 -0
- package/dist/shared/application/commands/base/base-command.handler.js +14 -0
- package/dist/shared/application/commands/base/base-command.handler.js.map +1 -0
- package/dist/shared/application/commands/interfaces/base-command-handler.interface.d.ts +3 -0
- package/dist/shared/application/commands/interfaces/base-command-handler.interface.js +3 -0
- package/dist/shared/application/commands/interfaces/base-command-handler.interface.js.map +1 -0
- package/dist/shared/application/commands/update/base-update/base-update.command-handler.d.ts +9 -0
- package/dist/shared/application/commands/update/base-update/base-update.command-handler.js +25 -0
- package/dist/shared/application/commands/update/base-update/base-update.command-handler.js.map +1 -0
- package/dist/shared/application/dtos/commands/field-changed/base-field-changed-command.dto.d.ts +5 -0
- package/dist/shared/application/dtos/commands/field-changed/base-field-changed-command.dto.js +3 -0
- package/dist/shared/application/dtos/commands/field-changed/base-field-changed-command.dto.js.map +1 -0
- package/dist/shared/application/services/base-service/base-service.interface.d.ts +3 -0
- package/dist/shared/application/services/base-service/base-service.interface.js +3 -0
- package/dist/shared/application/services/base-service/base-service.interface.js.map +1 -0
- package/dist/shared/domain/aggregates/base-aggregate/base.aggregate.d.ts +9 -0
- package/dist/shared/domain/aggregates/base-aggregate/base.aggregate.js +19 -0
- package/dist/shared/domain/aggregates/base-aggregate/base.aggregate.js.map +1 -0
- package/dist/shared/domain/entities/criteria.d.ts +21 -0
- package/dist/shared/domain/entities/criteria.js +12 -0
- package/dist/shared/domain/entities/criteria.js.map +1 -0
- package/dist/shared/domain/entities/paginated-result.entity.d.ts +8 -0
- package/dist/shared/domain/entities/paginated-result.entity.js +16 -0
- package/dist/shared/domain/entities/paginated-result.entity.js.map +1 -0
- package/dist/shared/domain/enums/filter-operator.enum.d.ts +10 -0
- package/dist/shared/domain/enums/filter-operator.enum.js +15 -0
- package/dist/shared/domain/enums/filter-operator.enum.js.map +1 -0
- package/dist/shared/domain/enums/length-unit/length-unit.enum.d.ts +7 -0
- package/dist/shared/domain/enums/length-unit/length-unit.enum.js +12 -0
- package/dist/shared/domain/enums/length-unit/length-unit.enum.js.map +1 -0
- package/dist/shared/domain/enums/sort-direction.enum.d.ts +4 -0
- package/dist/shared/domain/enums/sort-direction.enum.js +9 -0
- package/dist/shared/domain/enums/sort-direction.enum.js.map +1 -0
- package/dist/shared/domain/enums/user-context/user/user-role/user-role.enum.d.ts +4 -0
- package/dist/shared/domain/enums/user-context/user/user-role/user-role.enum.js +9 -0
- package/dist/shared/domain/enums/user-context/user/user-role/user-role.enum.js.map +1 -0
- package/dist/shared/domain/enums/user-context/user/user-status/user-status.enum.d.ts +5 -0
- package/dist/shared/domain/enums/user-context/user/user-status/user-status.enum.js +10 -0
- package/dist/shared/domain/enums/user-context/user/user-status/user-status.enum.js.map +1 -0
- package/dist/shared/domain/events/base-event.interface.d.ts +13 -0
- package/dist/shared/domain/events/base-event.interface.js +21 -0
- package/dist/shared/domain/events/base-event.interface.js.map +1 -0
- package/dist/shared/domain/exceptions/base.exception.d.ts +6 -0
- package/dist/shared/domain/exceptions/base.exception.js +23 -0
- package/dist/shared/domain/exceptions/base.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-boolean/invalid-boolean.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-boolean/invalid-boolean.exception.js +12 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-boolean/invalid-boolean.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-color/invalid-color.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-color/invalid-color.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-color/invalid-color.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-dimensions/invalid-dimensions.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-dimensions/invalid-dimensions.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-dimensions/invalid-dimensions.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-email/invalid-email.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-email/invalid-email.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-email/invalid-email.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-enum-value/invalid-enum-value.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-enum-value/invalid-enum-value.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-enum-value/invalid-enum-value.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-hex/invalid-hex.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-hex/invalid-hex.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-hex/invalid-hex.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-ip/invalid-ip.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-ip/invalid-ip.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-ip/invalid-ip.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-json/invalid-json.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-json/invalid-json.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-json/invalid-json.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-locale/invalid-locale.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-locale/invalid-locale.exception.js +12 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-locale/invalid-locale.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-number/invalid-number.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-number/invalid-number.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-number/invalid-number.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-numeric-range/invalid-numeric-range.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-numeric-range/invalid-numeric-range.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-numeric-range/invalid-numeric-range.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-password/invalid-password.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-password/invalid-password.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-password/invalid-password.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-phone/invalid-phone.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-phone/invalid-phone.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-phone/invalid-phone.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-string/invalid-string.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-string/invalid-string.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-string/invalid-string.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-timezone/invalid-timezone.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-timezone/invalid-timezone.exception.js +12 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-timezone/invalid-timezone.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-url/invalid-url.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-url/invalid-url.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-url/invalid-url.exception.js.map +1 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-uuid/invalid-uuid.exception.d.ts +4 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-uuid/invalid-uuid.exception.js +11 -0
- package/dist/shared/domain/exceptions/value-objects/invalid-uuid/invalid-uuid.exception.js.map +1 -0
- package/dist/shared/domain/interfaces/base-aggregate-dto.interface.d.ts +5 -0
- package/dist/shared/domain/interfaces/base-aggregate-dto.interface.js +3 -0
- package/dist/shared/domain/interfaces/base-aggregate-dto.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/base-view-model-dto.interface.d.ts +5 -0
- package/dist/shared/domain/interfaces/base-view-model-dto.interface.js +3 -0
- package/dist/shared/domain/interfaces/base-view-model-dto.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/event-metadata.interface.d.ts +7 -0
- package/dist/shared/domain/interfaces/event-metadata.interface.js +3 -0
- package/dist/shared/domain/interfaces/event-metadata.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/events/base-event-data.interface.d.ts +4 -0
- package/dist/shared/domain/interfaces/events/base-event-data.interface.js +3 -0
- package/dist/shared/domain/interfaces/events/base-event-data.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/factories/read-factory.interface.d.ts +5 -0
- package/dist/shared/domain/interfaces/factories/read-factory.interface.js +3 -0
- package/dist/shared/domain/interfaces/factories/read-factory.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/factories/write-factory.interface.d.ts +4 -0
- package/dist/shared/domain/interfaces/factories/write-factory.interface.js +3 -0
- package/dist/shared/domain/interfaces/factories/write-factory.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/numeric-range.interface.d.ts +4 -0
- package/dist/shared/domain/interfaces/numeric-range.interface.js +3 -0
- package/dist/shared/domain/interfaces/numeric-range.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/repository/base-read-repository.interface.d.ts +8 -0
- package/dist/shared/domain/interfaces/repository/base-read-repository.interface.js +3 -0
- package/dist/shared/domain/interfaces/repository/base-read-repository.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/repository/base-write-repository.interface.d.ts +5 -0
- package/dist/shared/domain/interfaces/repository/base-write-repository.interface.js +3 -0
- package/dist/shared/domain/interfaces/repository/base-write-repository.interface.js.map +1 -0
- package/dist/shared/domain/interfaces/updated-field.interface.d.ts +5 -0
- package/dist/shared/domain/interfaces/updated-field.interface.js +3 -0
- package/dist/shared/domain/interfaces/updated-field.interface.js.map +1 -0
- package/dist/shared/domain/primitives/base-primitives/base.primitives.d.ts +4 -0
- package/dist/shared/domain/primitives/base-primitives/base.primitives.js +3 -0
- package/dist/shared/domain/primitives/base-primitives/base.primitives.js.map +1 -0
- package/dist/shared/domain/value-objects/base/value-object.base.d.ts +11 -0
- package/dist/shared/domain/value-objects/base/value-object.base.js +40 -0
- package/dist/shared/domain/value-objects/base/value-object.base.js.map +1 -0
- package/dist/shared/domain/value-objects/boolean/boolean.vo.d.ts +26 -0
- package/dist/shared/domain/value-objects/boolean/boolean.vo.js +102 -0
- package/dist/shared/domain/value-objects/boolean/boolean.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/color/color.vo.d.ts +21 -0
- package/dist/shared/domain/value-objects/color/color.vo.js +127 -0
- package/dist/shared/domain/value-objects/color/color.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/date/date.vo.d.ts +9 -0
- package/dist/shared/domain/value-objects/date/date.vo.js +23 -0
- package/dist/shared/domain/value-objects/date/date.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/dimensions/dimensions.vo.d.ts +68 -0
- package/dist/shared/domain/value-objects/dimensions/dimensions.vo.js +182 -0
- package/dist/shared/domain/value-objects/dimensions/dimensions.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/email/email.vo.d.ts +12 -0
- package/dist/shared/domain/value-objects/email/email.vo.js +48 -0
- package/dist/shared/domain/value-objects/email/email.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/enum/enum.vo.d.ts +35 -0
- package/dist/shared/domain/value-objects/enum/enum.vo.js +137 -0
- package/dist/shared/domain/value-objects/enum/enum.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/hex/hex.vo.d.ts +11 -0
- package/dist/shared/domain/value-objects/hex/hex.vo.js +38 -0
- package/dist/shared/domain/value-objects/hex/hex.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/ip/ip.vo.d.ts +19 -0
- package/dist/shared/domain/value-objects/ip/ip.vo.js +90 -0
- package/dist/shared/domain/value-objects/ip/ip.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/json/json.vo.d.ts +43 -0
- package/dist/shared/domain/value-objects/json/json.vo.js +224 -0
- package/dist/shared/domain/value-objects/json/json.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/length-unit/length-unit.vo.d.ts +5 -0
- package/dist/shared/domain/value-objects/length-unit/length-unit.vo.js +12 -0
- package/dist/shared/domain/value-objects/length-unit/length-unit.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/locale/locale.vo.d.ts +27 -0
- package/dist/shared/domain/value-objects/locale/locale.vo.js +292 -0
- package/dist/shared/domain/value-objects/locale/locale.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/number/number.vo.d.ts +23 -0
- package/dist/shared/domain/value-objects/number/number.vo.js +77 -0
- package/dist/shared/domain/value-objects/number/number.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/numeric-range/numeric-range.vo.d.ts +13 -0
- package/dist/shared/domain/value-objects/numeric-range/numeric-range.vo.js +35 -0
- package/dist/shared/domain/value-objects/numeric-range/numeric-range.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/password/password.vo.d.ts +14 -0
- package/dist/shared/domain/value-objects/password/password.vo.js +90 -0
- package/dist/shared/domain/value-objects/password/password.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/phone/phone.vo.d.ts +13 -0
- package/dist/shared/domain/value-objects/phone/phone.vo.js +56 -0
- package/dist/shared/domain/value-objects/phone/phone.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/phone-code/phone-code.vo.d.ts +25 -0
- package/dist/shared/domain/value-objects/phone-code/phone-code.vo.js +344 -0
- package/dist/shared/domain/value-objects/phone-code/phone-code.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/slug/slug.vo.d.ts +25 -0
- package/dist/shared/domain/value-objects/slug/slug.vo.js +87 -0
- package/dist/shared/domain/value-objects/slug/slug.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/string/string.vo.d.ts +38 -0
- package/dist/shared/domain/value-objects/string/string.vo.js +146 -0
- package/dist/shared/domain/value-objects/string/string.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/timezone/timezone.vo.d.ts +23 -0
- package/dist/shared/domain/value-objects/timezone/timezone.vo.js +116 -0
- package/dist/shared/domain/value-objects/timezone/timezone.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/url/url.vo.d.ts +9 -0
- package/dist/shared/domain/value-objects/url/url.vo.js +31 -0
- package/dist/shared/domain/value-objects/url/url.vo.js.map +1 -0
- package/dist/shared/domain/value-objects/uuid/uuid.vo.d.ts +13 -0
- package/dist/shared/domain/value-objects/uuid/uuid.vo.js +49 -0
- package/dist/shared/domain/value-objects/uuid/uuid.vo.js.map +1 -0
- package/dist/shared/domain/view-models/base-view-model/base-view-model.d.ts +14 -0
- package/dist/shared/domain/view-models/base-view-model/base-view-model.js +24 -0
- package/dist/shared/domain/view-models/base-view-model/base-view-model.js.map +1 -0
- package/dist/shared/infrastructure/database/base-database.repository.d.ts +11 -0
- package/dist/shared/infrastructure/database/base-database.repository.js +14 -0
- package/dist/shared/infrastructure/database/base-database.repository.js.map +1 -0
- package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-database.repository.d.ts +9 -0
- package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-database.repository.js +78 -0
- package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-database.repository.js.map +1 -0
- package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-master/base-mongo-master.repository.d.ts +6 -0
- package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-master/base-mongo-master.repository.js +12 -0
- package/dist/shared/infrastructure/database/mongodb/base-mongo/base-mongo-master/base-mongo-master.repository.js.map +1 -0
- package/dist/shared/infrastructure/database/mongodb/dtos/base-mongo.dto.d.ts +5 -0
- package/dist/shared/infrastructure/database/mongodb/dtos/base-mongo.dto.js +3 -0
- package/dist/shared/infrastructure/database/mongodb/dtos/base-mongo.dto.js.map +1 -0
- package/dist/shared/infrastructure/database/mongodb/mongodb.module.d.ts +2 -0
- package/dist/shared/infrastructure/database/mongodb/mongodb.module.js +23 -0
- package/dist/shared/infrastructure/database/mongodb/mongodb.module.js.map +1 -0
- package/dist/shared/infrastructure/database/mongodb/services/mongo-master/mongo-master.service.d.ts +14 -0
- package/dist/shared/infrastructure/database/mongodb/services/mongo-master/mongo-master.service.js +57 -0
- package/dist/shared/infrastructure/database/mongodb/services/mongo-master/mongo-master.service.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/base-typeorm/base-typeorm-master/base-typeorm-master.repository.d.ts +9 -0
- package/dist/shared/infrastructure/database/typeorm/base-typeorm/base-typeorm-master/base-typeorm-master.repository.js +18 -0
- package/dist/shared/infrastructure/database/typeorm/base-typeorm/base-typeorm-master/base-typeorm-master.repository.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/data-source.d.ts +4 -0
- package/dist/shared/infrastructure/database/typeorm/data-source.js +33 -0
- package/dist/shared/infrastructure/database/typeorm/data-source.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/dtos/base-typeorm.dto.d.ts +4 -0
- package/dist/shared/infrastructure/database/typeorm/dtos/base-typeorm.dto.js +3 -0
- package/dist/shared/infrastructure/database/typeorm/dtos/base-typeorm.dto.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/entities/base-typeorm.entity.d.ts +6 -0
- package/dist/shared/infrastructure/database/typeorm/entities/base-typeorm.entity.js +36 -0
- package/dist/shared/infrastructure/database/typeorm/entities/base-typeorm.entity.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/services/typeorm-master/typeorm-master.service.d.ts +9 -0
- package/dist/shared/infrastructure/database/typeorm/services/typeorm-master/typeorm-master.service.js +42 -0
- package/dist/shared/infrastructure/database/typeorm/services/typeorm-master/typeorm-master.service.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/typeorm-module-options.factory.d.ts +3 -0
- package/dist/shared/infrastructure/database/typeorm/typeorm-module-options.factory.js +32 -0
- package/dist/shared/infrastructure/database/typeorm/typeorm-module-options.factory.js.map +1 -0
- package/dist/shared/infrastructure/database/typeorm/typeorm.module.d.ts +2 -0
- package/dist/shared/infrastructure/database/typeorm/typeorm.module.js +34 -0
- package/dist/shared/infrastructure/database/typeorm/typeorm.module.js.map +1 -0
- package/dist/shared/infrastructure/logging/factories/create-shared-winston-logger-options.d.ts +6 -0
- package/dist/shared/infrastructure/logging/factories/create-shared-winston-logger-options.js +92 -0
- package/dist/shared/infrastructure/logging/factories/create-shared-winston-logger-options.js.map +1 -0
- package/dist/shared/infrastructure/logging/formats/shared-winston.formats.d.ts +3 -0
- package/dist/shared/infrastructure/logging/formats/shared-winston.formats.js +30 -0
- package/dist/shared/infrastructure/logging/formats/shared-winston.formats.js.map +1 -0
- package/dist/shared/infrastructure/logging/interfaces/shared-winston-logger-factory-options.interface.d.ts +21 -0
- package/dist/shared/infrastructure/logging/interfaces/shared-winston-logger-factory-options.interface.js +3 -0
- package/dist/shared/infrastructure/logging/interfaces/shared-winston-logger-factory-options.interface.js.map +1 -0
- package/dist/shared/shared.module.d.ts +3 -0
- package/dist/shared/shared.module.js +51 -0
- package/dist/shared/shared.module.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/requests/base-filter/base-filter.input.d.ts +6 -0
- package/dist/shared/transport/graphql/dtos/requests/base-filter/base-filter.input.js +40 -0
- package/dist/shared/transport/graphql/dtos/requests/base-filter/base-filter.input.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/requests/base-find-by-criteria/base-find-by-criteria.input.d.ts +8 -0
- package/dist/shared/transport/graphql/dtos/requests/base-find-by-criteria/base-find-by-criteria.input.js +56 -0
- package/dist/shared/transport/graphql/dtos/requests/base-find-by-criteria/base-find-by-criteria.input.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/requests/base-pagination/base-pagination.input.d.ts +4 -0
- package/dist/shared/transport/graphql/dtos/requests/base-pagination/base-pagination.input.js +33 -0
- package/dist/shared/transport/graphql/dtos/requests/base-pagination/base-pagination.input.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/requests/base-sort/base-sort.input.d.ts +5 -0
- package/dist/shared/transport/graphql/dtos/requests/base-sort/base-sort.input.js +34 -0
- package/dist/shared/transport/graphql/dtos/requests/base-sort/base-sort.input.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/requests/numeric-range/numeric-range.input.d.ts +4 -0
- package/dist/shared/transport/graphql/dtos/requests/numeric-range/numeric-range.input.js +31 -0
- package/dist/shared/transport/graphql/dtos/requests/numeric-range/numeric-range.input.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/responses/base-paginated-result/base-paginated-result.dto.d.ts +6 -0
- package/dist/shared/transport/graphql/dtos/responses/base-paginated-result/base-paginated-result.dto.js +36 -0
- package/dist/shared/transport/graphql/dtos/responses/base-paginated-result/base-paginated-result.dto.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/responses/numeric-range/numeric-range.dto.d.ts +4 -0
- package/dist/shared/transport/graphql/dtos/responses/numeric-range/numeric-range.dto.js +31 -0
- package/dist/shared/transport/graphql/dtos/responses/numeric-range/numeric-range.dto.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/responses/success-response/success-response.dto.d.ts +5 -0
- package/dist/shared/transport/graphql/dtos/responses/success-response/success-response.dto.js +32 -0
- package/dist/shared/transport/graphql/dtos/responses/success-response/success-response.dto.js.map +1 -0
- package/dist/shared/transport/graphql/dtos/success-response-array.dto.d.ts +5 -0
- package/dist/shared/transport/graphql/dtos/success-response-array.dto.js +32 -0
- package/dist/shared/transport/graphql/dtos/success-response-array.dto.js.map +1 -0
- package/dist/shared/transport/graphql/enums/shared-registered-enums.graphql.d.ts +1 -0
- package/dist/shared/transport/graphql/enums/shared-registered-enums.graphql.js +15 -0
- package/dist/shared/transport/graphql/enums/shared-registered-enums.graphql.js.map +1 -0
- package/dist/shared/transport/graphql/mappers/mutation-response/mutation-response.mapper.d.ts +6 -0
- package/dist/shared/transport/graphql/mappers/mutation-response/mutation-response.mapper.js +31 -0
- package/dist/shared/transport/graphql/mappers/mutation-response/mutation-response.mapper.js.map +1 -0
- package/dist/shared/transport/graphql/plugins/complexity.plugin.d.ts +4 -0
- package/dist/shared/transport/graphql/plugins/complexity.plugin.js +40 -0
- package/dist/shared/transport/graphql/plugins/complexity.plugin.js.map +1 -0
- package/dist/shared/transport/graphql/registered-enums/registered-enums.graphql.d.ts +1 -0
- package/dist/shared/transport/graphql/registered-enums/registered-enums.graphql.js +33 -0
- package/dist/shared/transport/graphql/registered-enums/registered-enums.graphql.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +152 -0
package/README.md
ADDED
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
# @sisques-labs/nestjs-kit
|
|
2
|
+
|
|
3
|
+
**NestJS Kit** — a shared NestJS library providing **Domain-Driven Design (DDD)** and **CQRS** building blocks, **validated value objects**, **repository abstractions**, optional **MongoDB** and **TypeORM** helpers, **GraphQL** DTOs and plugins, and optional **Winston logger configuration** (for use with `nest-winston` in consuming apps) for microservices and modular monoliths.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Publishing](#publishing)
|
|
8
|
+
- [CI](#ci)
|
|
9
|
+
- [Release workflow](#release-workflow)
|
|
10
|
+
- [Publish from your machine](#publish-from-your-machine)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
13
|
+
- [Local development](#local-development)
|
|
14
|
+
- [Module Setup](#module-setup)
|
|
15
|
+
- [Domain Layer](#domain-layer)
|
|
16
|
+
- [Base Aggregate](#base-aggregate)
|
|
17
|
+
- [Value Objects](#value-objects)
|
|
18
|
+
- [Aggregate and entity IDs](#aggregate-and-entity-ids)
|
|
19
|
+
- [Domain Exceptions](#domain-exceptions)
|
|
20
|
+
- [Criteria & Pagination](#criteria--pagination)
|
|
21
|
+
- [Repository Interfaces](#repository-interfaces)
|
|
22
|
+
- [Factory Interfaces](#factory-interfaces)
|
|
23
|
+
- [View Models](#view-models)
|
|
24
|
+
- [Domain Events](#domain-events)
|
|
25
|
+
- [Application Layer](#application-layer)
|
|
26
|
+
- [Command Handlers](#command-handlers)
|
|
27
|
+
- [Service Interface](#service-interface)
|
|
28
|
+
- [Infrastructure Layer](#infrastructure-layer)
|
|
29
|
+
- [Logging (Winston)](#logging-winston)
|
|
30
|
+
- [MongoDB](#mongodb)
|
|
31
|
+
- [TypeORM](#typeorm)
|
|
32
|
+
- [Transport Layer (GraphQL)](#transport-layer-graphql)
|
|
33
|
+
- [Input DTOs](#input-dtos)
|
|
34
|
+
- [Response DTOs](#response-dtos)
|
|
35
|
+
- [Mappers](#mappers)
|
|
36
|
+
- [Complexity Plugin](#complexity-plugin)
|
|
37
|
+
- [Enums](#enums)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Publishing
|
|
42
|
+
|
|
43
|
+
The package is published to the public npm registry as [`@sisques-labs/nestjs-kit`](https://www.npmjs.com/package/@sisques-labs/nestjs-kit) (see `publishConfig` in `package.json`). Releases are automated with GitHub Actions.
|
|
44
|
+
|
|
45
|
+
| Workflow | File | Trigger |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| **CI** | `.github/workflows/ci.yml` | Push and pull requests targeting `main` |
|
|
48
|
+
| **Release** | `.github/workflows/release.yml` | Manual (`workflow_dispatch`) |
|
|
49
|
+
|
|
50
|
+
### CI
|
|
51
|
+
|
|
52
|
+
Runs `pnpm install --frozen-lockfile`, **`pnpm lint`** (ESLint with `--fix`), **`pnpm build`**, and **`pnpm test`**.
|
|
53
|
+
|
|
54
|
+
### Release workflow
|
|
55
|
+
|
|
56
|
+
Open **GitHub → Actions → Release → Run workflow** and choose:
|
|
57
|
+
|
|
58
|
+
| Input | Purpose |
|
|
59
|
+
|---|---|
|
|
60
|
+
| **version** | `patch`, `minor`, or `major` ([SemVer](https://semver.org)) |
|
|
61
|
+
| **release_type** | `stable` (default dist-tag) or prerelease **`alpha`** / **`beta`** (separate dist-tags) |
|
|
62
|
+
|
|
63
|
+
The job then: runs lint and tests, bumps the version with `npm version`, builds, publishes with **`pnpm publish`** using the **`NPM_TOKEN`** repository secret, commits `package.json` / lockfile, creates a git tag, pushes to `main`, and creates a GitHub Release with generated notes.
|
|
64
|
+
|
|
65
|
+
**Repository setup:** add an [npm automation token](https://docs.npmjs.com/creating-and-viewing-access-tokens) with publish rights as the **`NPM_TOKEN`** secret (GitHub → Settings → Secrets and variables → Actions).
|
|
66
|
+
|
|
67
|
+
### Publish from your machine
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm login
|
|
71
|
+
pnpm build
|
|
72
|
+
pnpm publish
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The `prepublishOnly` script runs **`npm run build`** before publish so `dist/` is current.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
The package is **public** on npm; a normal install is enough:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pnpm add @sisques-labs/nestjs-kit
|
|
85
|
+
# or: npm install / yarn add @sisques-labs/nestjs-kit
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Use your organization’s registry or mirror policy if applicable.
|
|
89
|
+
|
|
90
|
+
If you previously used **`@sisques-labs/shared-nestjs`**, uninstall it and depend on **`@sisques-labs/nestjs-kit`** instead; replace every import path from `'@sisques-labs/shared-nestjs'` to `'@sisques-labs/nestjs-kit'` (API unchanged).
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Peer Dependencies
|
|
95
|
+
|
|
96
|
+
Install only what your app uses. Peers marked **optional** in `peerDependenciesMeta` can be omitted if you do not import that part of the library.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Core NestJS (required for any integration)
|
|
100
|
+
pnpm add @nestjs/common @nestjs/core reflect-metadata rxjs
|
|
101
|
+
|
|
102
|
+
# CQRS (command handlers, EventBus)
|
|
103
|
+
pnpm add @nestjs/cqrs
|
|
104
|
+
|
|
105
|
+
# MongoDB module + repositories in this package
|
|
106
|
+
pnpm add mongodb @nestjs/config
|
|
107
|
+
|
|
108
|
+
# TypeORM module + repositories in this package
|
|
109
|
+
pnpm add typeorm @nestjs/typeorm @nestjs/config
|
|
110
|
+
|
|
111
|
+
# GraphQL DTOs, Apollo, complexity plugin
|
|
112
|
+
pnpm add graphql @nestjs/graphql @nestjs/apollo @apollo/server graphql-query-complexity
|
|
113
|
+
|
|
114
|
+
# class-validator / class-transformer (typical for GraphQL inputs)
|
|
115
|
+
pnpm add class-validator class-transformer
|
|
116
|
+
|
|
117
|
+
# Winston logging (shared config + nest-winston in your app)
|
|
118
|
+
pnpm add nest-winston winston winston-daily-rotate-file
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Local development
|
|
124
|
+
|
|
125
|
+
For contributors working on this repository:
|
|
126
|
+
|
|
127
|
+
| Script | Description |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `pnpm install` | Installs dependencies; **`prepare`** runs Husky and **`pnpm build`**. |
|
|
130
|
+
| `pnpm build` | Compiles TypeScript to `dist/` (`nest build`). |
|
|
131
|
+
| `pnpm lint` | ESLint with `--fix` on `src`, `apps`, `libs`, `test`. |
|
|
132
|
+
| `pnpm lint:check` | ESLint without autofix (used by **Husky pre-commit**). |
|
|
133
|
+
| `pnpm test` | Jest unit tests (`*.spec.ts` under `src/`). |
|
|
134
|
+
| `pnpm test:cov` | Tests with coverage. |
|
|
135
|
+
| `pnpm format` | Prettier on `src` and `test` TypeScript. |
|
|
136
|
+
|
|
137
|
+
**Git hooks:** [Husky](https://typicode.github.io/husky/) runs **`pnpm lint:check`** and **`pnpm test`** on **pre-commit** (see `.husky/pre-commit`). To skip hooks for a one-off commit: `HUSKY=0 git commit ...`.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## Module Setup
|
|
143
|
+
|
|
144
|
+
Import **`SharedModule`** in your root or core module. It is **`@Global()`** and only registers cross-cutting pieces that do not require a database (for example **`MutationResponseGraphQLMapper`** and shared GraphQL enum registration). It does **not** import MongoDB or TypeORM—you add those only if you need them.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { Module } from '@nestjs/common';
|
|
148
|
+
import { SharedModule } from '@sisques-labs/nestjs-kit';
|
|
149
|
+
|
|
150
|
+
@Module({
|
|
151
|
+
imports: [SharedModule],
|
|
152
|
+
})
|
|
153
|
+
export class AppModule {}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Optional database modules** (import alongside `SharedModule` when you use them):
|
|
157
|
+
|
|
158
|
+
- **`MongoModule`** — provides `MongoMasterService` (`MONGODB_URI`, `MONGODB_DATABASE` via `ConfigService`).
|
|
159
|
+
- **`TypeOrmModule`** — registers `TypeOrmModule.forRootAsync` using `DATABASE_*` config; requires **`ConfigModule`** in the app (for example `ConfigModule.forRoot({ isGlobal: true })`).
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { Module } from '@nestjs/common';
|
|
163
|
+
import { ConfigModule } from '@nestjs/config';
|
|
164
|
+
import {
|
|
165
|
+
SharedModule,
|
|
166
|
+
MongoModule,
|
|
167
|
+
TypeOrmModule,
|
|
168
|
+
} from '@sisques-labs/nestjs-kit';
|
|
169
|
+
|
|
170
|
+
@Module({
|
|
171
|
+
imports: [
|
|
172
|
+
ConfigModule.forRoot({ isGlobal: true }),
|
|
173
|
+
SharedModule,
|
|
174
|
+
MongoModule, // omit if you do not use MongoDB
|
|
175
|
+
TypeOrmModule, // omit if you do not use TypeORM
|
|
176
|
+
],
|
|
177
|
+
})
|
|
178
|
+
export class AppModule {}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Logging is separate:** this library does **not** register `WinstonModule`. Import **`WinstonModule`** from `nest-winston` in your app and pass **`createSharedWinstonLoggerOptions()`** or **`defaultSharedWinstonLoggerOptions`**—see [Logging (Winston)](#logging-winston).
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Domain Layer
|
|
186
|
+
|
|
187
|
+
### Base Aggregate
|
|
188
|
+
|
|
189
|
+
`BaseAggregate` extends `@nestjs/cqrs` **`AggregateRoot`** and wires **`createdAt`** and **`updatedAt`** as `DateValueObject` properties. Add identity and domain fields in your subclass (for example a `UuidValueObject` or app-specific id type).
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import {
|
|
193
|
+
BaseAggregate,
|
|
194
|
+
DateValueObject,
|
|
195
|
+
EmailValueObject,
|
|
196
|
+
UuidValueObject,
|
|
197
|
+
} from '@sisques-labs/nestjs-kit';
|
|
198
|
+
|
|
199
|
+
export class UserAggregate extends BaseAggregate {
|
|
200
|
+
constructor(
|
|
201
|
+
private readonly _id: UuidValueObject,
|
|
202
|
+
private _email: EmailValueObject,
|
|
203
|
+
createdAt: DateValueObject,
|
|
204
|
+
updatedAt: DateValueObject,
|
|
205
|
+
) {
|
|
206
|
+
super(createdAt, updatedAt);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
get id(): UuidValueObject {
|
|
210
|
+
return this._id;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Use `apply()`, `commit()`, and related `AggregateRoot` APIs for domain events as usual.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
### Value Objects
|
|
220
|
+
|
|
221
|
+
All value objects are immutable and validate their input on construction, throwing a typed domain exception on invalid data.
|
|
222
|
+
|
|
223
|
+
#### Basic Scalars
|
|
224
|
+
|
|
225
|
+
| Class | Description |
|
|
226
|
+
|---|---|
|
|
227
|
+
| `StringValueObject` | String with optional min/max length, pattern, and trim |
|
|
228
|
+
| `NumberValueObject` | Numeric value with validation |
|
|
229
|
+
| `BooleanValueObject` | Boolean wrapper |
|
|
230
|
+
| `DateValueObject` | Date wrapper |
|
|
231
|
+
| `JsonValueObject` | Valid JSON value |
|
|
232
|
+
| `EnumValueObject<T>` | Typed enum wrapper |
|
|
233
|
+
|
|
234
|
+
#### Format-Specific
|
|
235
|
+
|
|
236
|
+
| Class | Description |
|
|
237
|
+
|---|---|
|
|
238
|
+
| `EmailValueObject` | RFC 5322 compliant. Methods: `getLocalPart()`, `getDomain()` |
|
|
239
|
+
| `UuidValueObject` | RFC 4122. Methods: `getVersion()`, `isNil()`, static `generate()` |
|
|
240
|
+
| `PhoneValueObject` | E.164 format. Methods: `getCountryCode()`, `toE164()` |
|
|
241
|
+
| `UrlValueObject` | Valid URL |
|
|
242
|
+
| `IpValueObject` | IPv4/IPv6 validation |
|
|
243
|
+
| `HexValueObject` | Hexadecimal string |
|
|
244
|
+
| `ColorValueObject` | Hex, RGB, HSL, and named colors with conversion methods |
|
|
245
|
+
| `SlugValueObject` | URL-friendly slug. Methods: `toHumanReadable()`, `addPrefix()`, `addSuffix()`, static `generateSlug()` |
|
|
246
|
+
| `PasswordValueObject` | Strength scoring, common password detection. Methods: `getStrengthScore()`, `meetsRequirements()` |
|
|
247
|
+
| `LocaleValueObject` | BCP 47 locale (50+ supported). Methods: `getLanguageCode()`, `getCountryCode()`, `getDisplayName()` |
|
|
248
|
+
| `TimezoneValueObject` | IANA timezone |
|
|
249
|
+
| `PhoneCodeValueObject` | Phone dial code |
|
|
250
|
+
| `LengthUnitValueObject` | Unit of length measurement |
|
|
251
|
+
| `DimensionsValueObject` | Length, width, height with unit and optional bounds |
|
|
252
|
+
| `NumericRangeValueObject` | Min/max numeric range |
|
|
253
|
+
|
|
254
|
+
**Usage example:**
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import {
|
|
258
|
+
EmailValueObject,
|
|
259
|
+
UuidValueObject,
|
|
260
|
+
PasswordValueObject,
|
|
261
|
+
} from '@sisques-labs/nestjs-kit';
|
|
262
|
+
|
|
263
|
+
const email = new EmailValueObject('user@example.com');
|
|
264
|
+
console.log(email.getDomain()); // 'example.com'
|
|
265
|
+
|
|
266
|
+
const id = UuidValueObject.generate();
|
|
267
|
+
console.log(id.getVersion()); // 4
|
|
268
|
+
|
|
269
|
+
const password = new PasswordValueObject('MyS3cur3P@ss!');
|
|
270
|
+
console.log(password.getStrengthScore()); // number 0-5
|
|
271
|
+
console.log(password.meetsRequirements()); // boolean
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Many value objects also have a **folder-level `README.md`** under `src/shared/domain/value-objects/<name>/` with API tables and examples.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
### Aggregate and entity IDs
|
|
279
|
+
|
|
280
|
+
The library exports **`UuidValueObject`** for validated RFC 4122 UUID strings (construction, `generate()`, `getVersion()`, `isNil()`, etc.).
|
|
281
|
+
|
|
282
|
+
For **aggregate- or entity-specific** identifiers (nominal typing per bounded context), define thin subclasses or wrappers **in your application**, for example:
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { UuidValueObject } from '@sisques-labs/nestjs-kit';
|
|
286
|
+
|
|
287
|
+
export class UserId extends UuidValueObject {
|
|
288
|
+
// optional: narrow type or factory methods for your domain
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
### Domain Exceptions
|
|
295
|
+
|
|
296
|
+
`BaseException` is the root exception class. Each value object has a corresponding typed exception thrown on validation failure.
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { BaseException } from '@sisques-labs/nestjs-kit';
|
|
300
|
+
|
|
301
|
+
// BaseException provides:
|
|
302
|
+
// - timestamp: Date
|
|
303
|
+
// - getDetailedMessage(): string → "[ClassName]: message"
|
|
304
|
+
// - toJSON(): object
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Available typed exceptions (all extend `BaseException`):
|
|
308
|
+
|
|
309
|
+
`InvalidBooleanException`, `InvalidColorException`, `InvalidDimensionsException`, `InvalidEmailException`, `InvalidEnumValueException`, `InvalidHexException`, `InvalidIpException`, `InvalidJsonException`, `InvalidLocaleException`, `InvalidNumberException`, `InvalidNumericRangeException`, `InvalidPasswordException`, `InvalidPhoneException`, `InvalidStringException`, `InvalidTimezoneException`, `InvalidUrlException`, `InvalidUuidException`
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
### Criteria & Pagination
|
|
314
|
+
|
|
315
|
+
Use `Criteria` to build type-safe query parameters with filters, sorts, and pagination.
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import {
|
|
319
|
+
Criteria,
|
|
320
|
+
FilterOperator,
|
|
321
|
+
SortDirection,
|
|
322
|
+
} from '@sisques-labs/nestjs-kit';
|
|
323
|
+
|
|
324
|
+
const criteria = new Criteria(
|
|
325
|
+
[{ field: 'email', operator: FilterOperator.EQUALS, value: 'user@example.com' }],
|
|
326
|
+
[{ field: 'createdAt', direction: SortDirection.DESC }],
|
|
327
|
+
{ page: 1, perPage: 20 },
|
|
328
|
+
);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
`PaginatedResult<T>` wraps paginated query results:
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
import { PaginatedResult } from '@sisques-labs/nestjs-kit';
|
|
335
|
+
|
|
336
|
+
// { data: T[], total: number, page: number, perPage: number }
|
|
337
|
+
const result: PaginatedResult<User> = await repository.findByCriteria(criteria);
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
### Repository Interfaces
|
|
343
|
+
|
|
344
|
+
Implement these interfaces in your infrastructure layer to keep the domain free of database concerns.
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
import {
|
|
348
|
+
IBaseReadRepository,
|
|
349
|
+
IBaseWriteRepository,
|
|
350
|
+
} from '@sisques-labs/nestjs-kit';
|
|
351
|
+
|
|
352
|
+
// Read side: findById, findByCriteria, save, delete
|
|
353
|
+
interface IUserReadRepository extends IBaseReadRepository<UserAggregate> {}
|
|
354
|
+
|
|
355
|
+
// Write side: findById, save, delete
|
|
356
|
+
interface IUserWriteRepository extends IBaseWriteRepository<UserAggregate> {}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
### Factory Interfaces
|
|
362
|
+
|
|
363
|
+
Factories handle deserialization of aggregates from different sources.
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { IReadFactory, IWriteFactory } from '@sisques-labs/nestjs-kit';
|
|
367
|
+
|
|
368
|
+
// Read factory: creates view models from aggregates, DTOs, or primitives
|
|
369
|
+
class UserReadFactory implements IReadFactory<UserViewModel, UserAggregate, UserDto> {
|
|
370
|
+
create(data: UserDto): UserViewModel { ... }
|
|
371
|
+
fromAggregate(aggregate: UserAggregate): UserViewModel { ... }
|
|
372
|
+
fromPrimitives(primitives: object): UserViewModel { ... }
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Write factory: creates aggregates from commands or primitives
|
|
376
|
+
class UserWriteFactory implements IWriteFactory<UserAggregate, CreateUserCommand, UserPrimitives> {
|
|
377
|
+
create(command: CreateUserCommand): UserAggregate { ... }
|
|
378
|
+
fromPrimitives(primitives: UserPrimitives): UserAggregate { ... }
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
### View Models
|
|
385
|
+
|
|
386
|
+
`BaseViewModel` provides a base for read-side projections with typed accessors for `id`, `createdAt`, and `updatedAt`.
|
|
387
|
+
|
|
388
|
+
```typescript
|
|
389
|
+
import { BaseViewModel } from '@sisques-labs/nestjs-kit';
|
|
390
|
+
|
|
391
|
+
export class UserViewModel extends BaseViewModel {
|
|
392
|
+
// Inherited: getId(), getCreatedAt(), getUpdatedAt()
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
### Domain Events
|
|
399
|
+
|
|
400
|
+
`IBaseEventData` and `IEventMetadata` provide a structured shape for domain events with aggregate and entity metadata.
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
import { IBaseEventData, IEventMetadata } from '@sisques-labs/nestjs-kit';
|
|
404
|
+
|
|
405
|
+
// IEventMetadata shape:
|
|
406
|
+
// {
|
|
407
|
+
// aggregateRootId: string;
|
|
408
|
+
// aggregateRootType: string;
|
|
409
|
+
// entityId: string;
|
|
410
|
+
// entityType: string;
|
|
411
|
+
// eventType: string;
|
|
412
|
+
// }
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Application Layer
|
|
418
|
+
|
|
419
|
+
### Command Handlers
|
|
420
|
+
|
|
421
|
+
`BaseCommandHandler` integrates the `EventBus` to publish domain events automatically after command execution.
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
import { BaseCommandHandler } from '@sisques-labs/nestjs-kit';
|
|
425
|
+
import { CommandHandler, EventBus } from '@nestjs/cqrs';
|
|
426
|
+
|
|
427
|
+
@CommandHandler(CreateUserCommand)
|
|
428
|
+
export class CreateUserCommandHandler extends BaseCommandHandler<CreateUserCommand> {
|
|
429
|
+
constructor(
|
|
430
|
+
private readonly repository: IUserWriteRepository,
|
|
431
|
+
eventBus: EventBus,
|
|
432
|
+
) {
|
|
433
|
+
super(eventBus);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async execute(command: CreateUserCommand): Promise<void> {
|
|
437
|
+
const user = UserWriteFactory.create(command);
|
|
438
|
+
await this.repository.save(user);
|
|
439
|
+
this.publishEvents(user); // publishes domain events from the aggregate
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
`BaseUpdateCommandHandler` adds utilities to extract changed fields from update commands, useful for partial updates.
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
### Service Interface
|
|
449
|
+
|
|
450
|
+
`IBaseService` is a marker interface for application services.
|
|
451
|
+
|
|
452
|
+
```typescript
|
|
453
|
+
import { IBaseService } from '@sisques-labs/nestjs-kit';
|
|
454
|
+
|
|
455
|
+
@Injectable()
|
|
456
|
+
export class UserService implements IBaseService {}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
## Infrastructure Layer
|
|
462
|
+
|
|
463
|
+
### Logging (Winston)
|
|
464
|
+
|
|
465
|
+
Optional **Winston `LoggerOptions`** (JSON file rotation + console formats) for use with **`WinstonModule.forRoot`** from **`nest-winston`** in the consuming app. Install `nest-winston`, `winston`, and `winston-daily-rotate-file` there; this package lists `winston` and `winston-daily-rotate-file` as optional peers.
|
|
466
|
+
|
|
467
|
+
**Main exports:** `createSharedWinstonLoggerOptions`, `defaultSharedWinstonLoggerOptions`, `mergeSharedWinstonLoggerOptions`, `createSharedJsonLogFormat`, `createSharedConsoleLogFormat`, and `SharedWinstonLoggerFactoryOptions`.
|
|
468
|
+
|
|
469
|
+
**Full guide:** [src/shared/infrastructure/logging/README.md](src/shared/infrastructure/logging/README.md)
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
### MongoDB
|
|
474
|
+
|
|
475
|
+
Import **`MongoModule`** from this package when you use MongoDB repositories. It is **not** part of **`SharedModule`**.
|
|
476
|
+
|
|
477
|
+
#### Environment Variables
|
|
478
|
+
|
|
479
|
+
The shared `MongoMasterService` reads:
|
|
480
|
+
|
|
481
|
+
```env
|
|
482
|
+
MONGODB_URI=mongodb://localhost:27017
|
|
483
|
+
MONGODB_DATABASE=my_database
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
#### Base Repository
|
|
487
|
+
|
|
488
|
+
Extend `BaseMongoMasterRepository` to get filter, sort, and pagination support out of the box.
|
|
489
|
+
|
|
490
|
+
```typescript
|
|
491
|
+
import {
|
|
492
|
+
BaseMongoMasterRepository,
|
|
493
|
+
MongoMasterService,
|
|
494
|
+
Criteria,
|
|
495
|
+
PaginatedResult,
|
|
496
|
+
} from '@sisques-labs/nestjs-kit';
|
|
497
|
+
|
|
498
|
+
@Injectable()
|
|
499
|
+
export class UserMongoRepository extends BaseMongoMasterRepository<UserMongoDto> {
|
|
500
|
+
constructor(mongoService: MongoMasterService) {
|
|
501
|
+
super(mongoService, 'users'); // collection name
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
async findByCriteria(criteria: Criteria): Promise<PaginatedResult<UserAggregate>> {
|
|
505
|
+
return this.executeQueryWithPagination(criteria);
|
|
506
|
+
// Automatically maps FilterOperator → MongoDB $operators
|
|
507
|
+
// Applies sorts and pagination (skip/limit)
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
`FilterOperator` → MongoDB operator mapping:
|
|
513
|
+
|
|
514
|
+
| Enum value | MongoDB operator |
|
|
515
|
+
|---|---|
|
|
516
|
+
| `EQUALS` | `$eq` |
|
|
517
|
+
| `NOT_EQUALS` | `$ne` |
|
|
518
|
+
| `LIKE` | `$regex` |
|
|
519
|
+
| `IN` | `$in` |
|
|
520
|
+
| `GT` | `$gt` |
|
|
521
|
+
| `LT` | `$lt` |
|
|
522
|
+
| `GTE` | `$gte` |
|
|
523
|
+
| `LTE` | `$lte` |
|
|
524
|
+
|
|
525
|
+
#### Base DTO
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
import { BaseMongoDto } from '@sisques-labs/nestjs-kit';
|
|
529
|
+
|
|
530
|
+
// Type: { id: string; createdAt: Date; updatedAt: Date }
|
|
531
|
+
type UserMongoDto = BaseMongoDto & {
|
|
532
|
+
email: string;
|
|
533
|
+
name: string;
|
|
534
|
+
};
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
### TypeORM
|
|
540
|
+
|
|
541
|
+
Import **`TypeOrmModule`** when you use TypeORM. It is **not** part of **`SharedModule`**. Use **`ConfigModule.forRoot`** (global or imported) so `ConfigService` is available; options are built at runtime via **`buildTypeOrmModuleOptions`** inside `forRootAsync`—no database env is read when you merely `import` the package.
|
|
542
|
+
|
|
543
|
+
#### Environment Variables
|
|
544
|
+
|
|
545
|
+
```env
|
|
546
|
+
DATABASE_DRIVER=postgres
|
|
547
|
+
DATABASE_HOST=localhost
|
|
548
|
+
DATABASE_PORT=5432
|
|
549
|
+
DATABASE_USERNAME=postgres
|
|
550
|
+
DATABASE_PASSWORD=secret
|
|
551
|
+
DATABASE_DATABASE=my_database
|
|
552
|
+
DATABASE_SYNCHRONIZE=false
|
|
553
|
+
DATABASE_MIGRATIONS_TABLE_NAME=migrations
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
Optional: `NODE_ENV` (affects query logging). For TypeORM CLI migrations that use `data-source.ts`, the same variables must be set in the environment when the CLI runs.
|
|
557
|
+
|
|
558
|
+
#### Base Entity
|
|
559
|
+
|
|
560
|
+
```typescript
|
|
561
|
+
import { BaseTypeormEntity } from '@sisques-labs/nestjs-kit';
|
|
562
|
+
import { Entity, Column } from 'typeorm';
|
|
563
|
+
|
|
564
|
+
@Entity('users')
|
|
565
|
+
export class UserTypeormEntity extends BaseTypeormEntity {
|
|
566
|
+
// Inherited: id (UUID, primary key), createdAt, updatedAt, deletedAt (soft delete)
|
|
567
|
+
|
|
568
|
+
@Column()
|
|
569
|
+
email: string;
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### Base Repository
|
|
574
|
+
|
|
575
|
+
```typescript
|
|
576
|
+
import {
|
|
577
|
+
BaseTypeormMasterRepository,
|
|
578
|
+
TypeormMasterService,
|
|
579
|
+
} from '@sisques-labs/nestjs-kit';
|
|
580
|
+
|
|
581
|
+
@Injectable()
|
|
582
|
+
export class UserTypeormRepository extends BaseTypeormMasterRepository {
|
|
583
|
+
constructor(typeormService: TypeormMasterService) {
|
|
584
|
+
super(typeormService);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async findById(id: string): Promise<UserAggregate | null> {
|
|
588
|
+
const repo = this.getRepository(UserTypeormEntity);
|
|
589
|
+
const entity = await repo.findOneBy({ id });
|
|
590
|
+
return entity ? UserWriteFactory.fromPrimitives(entity) : null;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
#### Base DTO
|
|
596
|
+
|
|
597
|
+
```typescript
|
|
598
|
+
import { BaseTypeormDto } from '@sisques-labs/nestjs-kit';
|
|
599
|
+
|
|
600
|
+
// Type: { id: string; createdAt: Date; updatedAt: Date }
|
|
601
|
+
type UserTypeormDto = BaseTypeormDto & {
|
|
602
|
+
email: string;
|
|
603
|
+
};
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
---
|
|
607
|
+
|
|
608
|
+
## Transport Layer (GraphQL)
|
|
609
|
+
|
|
610
|
+
### Input DTOs
|
|
611
|
+
|
|
612
|
+
#### `BaseFindByCriteriaInput`
|
|
613
|
+
|
|
614
|
+
Composite input for list queries combining filters, sorts, and pagination.
|
|
615
|
+
|
|
616
|
+
```graphql
|
|
617
|
+
query {
|
|
618
|
+
users(
|
|
619
|
+
criteria: {
|
|
620
|
+
filters: [{ field: "email", operator: EQUALS, value: "user@example.com" }]
|
|
621
|
+
sorts: [{ field: "createdAt", direction: DESC }]
|
|
622
|
+
pagination: { page: 1, perPage: 20 }
|
|
623
|
+
}
|
|
624
|
+
) {
|
|
625
|
+
total
|
|
626
|
+
page
|
|
627
|
+
perPage
|
|
628
|
+
totalPages
|
|
629
|
+
data { id email }
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
```typescript
|
|
635
|
+
import { BaseFindByCriteriaInput } from '@sisques-labs/nestjs-kit';
|
|
636
|
+
|
|
637
|
+
@Resolver()
|
|
638
|
+
export class UserResolver {
|
|
639
|
+
@Query(() => UsersPaginatedResult)
|
|
640
|
+
users(@Args('criteria') criteria: BaseFindByCriteriaInput) {
|
|
641
|
+
return this.userService.findByCriteria(criteria);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
Individual input types: `BaseFilterInput`, `BaseSortInput`, `BasePaginationInput`, `NumericRangeInput`.
|
|
647
|
+
|
|
648
|
+
---
|
|
649
|
+
|
|
650
|
+
### Response DTOs
|
|
651
|
+
|
|
652
|
+
#### `BasePaginatedResultDto`
|
|
653
|
+
|
|
654
|
+
```typescript
|
|
655
|
+
import { BasePaginatedResultDto } from '@sisques-labs/nestjs-kit';
|
|
656
|
+
import { ObjectType, Field } from '@nestjs/graphql';
|
|
657
|
+
|
|
658
|
+
@ObjectType()
|
|
659
|
+
export class UsersPaginatedResult extends BasePaginatedResultDto {
|
|
660
|
+
@Field(() => [UserDto])
|
|
661
|
+
data: UserDto[];
|
|
662
|
+
// Inherited: total, page, perPage, totalPages (computed automatically)
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
#### `MutationResponseDto`
|
|
667
|
+
|
|
668
|
+
```typescript
|
|
669
|
+
import { MutationResponseDto } from '@sisques-labs/nestjs-kit';
|
|
670
|
+
|
|
671
|
+
// Shape: { success: boolean; message?: string; id?: string }
|
|
672
|
+
|
|
673
|
+
@Mutation(() => MutationResponseDto)
|
|
674
|
+
createUser(@Args('input') input: CreateUserInput): Promise<MutationResponseDto> { ... }
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
#### `MutationResponseArrayDto`
|
|
678
|
+
|
|
679
|
+
```typescript
|
|
680
|
+
import { MutationResponseArrayDto } from '@sisques-labs/nestjs-kit';
|
|
681
|
+
|
|
682
|
+
// Shape: { success: boolean; message?: string; ids: string[] }
|
|
683
|
+
|
|
684
|
+
@Mutation(() => MutationResponseArrayDto)
|
|
685
|
+
deleteUsers(@Args('ids', { type: () => [String] }) ids: string[]): Promise<MutationResponseArrayDto> { ... }
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
---
|
|
689
|
+
|
|
690
|
+
### Mappers
|
|
691
|
+
|
|
692
|
+
`MutationResponseGraphQLMapper` is a NestJS injectable service provided by `SharedModule` that maps domain results to `MutationResponseDto`.
|
|
693
|
+
|
|
694
|
+
```typescript
|
|
695
|
+
import { MutationResponseGraphQLMapper } from '@sisques-labs/nestjs-kit';
|
|
696
|
+
|
|
697
|
+
@Resolver()
|
|
698
|
+
export class UserResolver {
|
|
699
|
+
constructor(private readonly mutationMapper: MutationResponseGraphQLMapper) {}
|
|
700
|
+
|
|
701
|
+
@Mutation(() => MutationResponseDto)
|
|
702
|
+
async createUser(@Args('input') input: CreateUserInput) {
|
|
703
|
+
const result = await this.commandBus.execute(new CreateUserCommand(input));
|
|
704
|
+
return this.mutationMapper.map(result);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
---
|
|
710
|
+
|
|
711
|
+
### Complexity Plugin
|
|
712
|
+
|
|
713
|
+
`ComplexityPlugin` is an **Apollo Server plugin** (`@Plugin()` from `@nestjs/apollo`) that rejects operations whose estimated complexity exceeds **1000** (see `graphql-query-complexity`). It is **exported** from this package but **not** registered inside `SharedModule`—add it to your GraphQL module’s **`providers`** (or equivalent) so Nest discovers the plugin.
|
|
714
|
+
|
|
715
|
+
To assign complexity weights to fields use the `@Complexity` decorator from `@nestjs/graphql`:
|
|
716
|
+
|
|
717
|
+
```typescript
|
|
718
|
+
import { Field, ObjectType, Complexity } from '@nestjs/graphql';
|
|
719
|
+
|
|
720
|
+
@ObjectType()
|
|
721
|
+
export class UserDto {
|
|
722
|
+
@Field()
|
|
723
|
+
@Complexity(1)
|
|
724
|
+
id: string;
|
|
725
|
+
}
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Register the plugin (for example next to your GraphQL module):
|
|
729
|
+
|
|
730
|
+
```typescript
|
|
731
|
+
import { Module } from '@nestjs/common';
|
|
732
|
+
import { ComplexityPlugin } from '@sisques-labs/nestjs-kit';
|
|
733
|
+
|
|
734
|
+
@Module({
|
|
735
|
+
providers: [ComplexityPlugin],
|
|
736
|
+
})
|
|
737
|
+
export class GraphqlPluginsModule {}
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
---
|
|
741
|
+
|
|
742
|
+
## Enums
|
|
743
|
+
|
|
744
|
+
```typescript
|
|
745
|
+
import {
|
|
746
|
+
FilterOperator,
|
|
747
|
+
SortDirection,
|
|
748
|
+
LengthUnitEnum,
|
|
749
|
+
UserRoleEnum,
|
|
750
|
+
UserStatusEnum,
|
|
751
|
+
} from '@sisques-labs/nestjs-kit';
|
|
752
|
+
|
|
753
|
+
FilterOperator.EQUALS // 'eq'
|
|
754
|
+
FilterOperator.NOT_EQUALS // 'ne'
|
|
755
|
+
FilterOperator.LIKE // 'like'
|
|
756
|
+
FilterOperator.IN // 'in'
|
|
757
|
+
FilterOperator.GT // 'gt'
|
|
758
|
+
FilterOperator.LT // 'lt'
|
|
759
|
+
FilterOperator.GTE // 'gte'
|
|
760
|
+
FilterOperator.LTE // 'lte'
|
|
761
|
+
|
|
762
|
+
SortDirection.ASC
|
|
763
|
+
SortDirection.DESC
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
---
|
|
767
|
+
|
|
768
|
+
## License
|
|
769
|
+
|
|
770
|
+
MIT — [Sisques Labs](https://github.com/JSisques)
|