@venizia/ignis 0.4.7 → 0.4.8-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/dist/esm/base/applications/base.d.ts +19 -0
- package/dist/esm/base/applications/base.js +22 -1
- package/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/base/applications/boot-steps.d.ts +1 -0
- package/dist/esm/base/applications/boot-steps.js.map +1 -1
- package/dist/esm/base/applications/common/types.d.ts +21 -4
- package/dist/esm/base/applications/common/types.js.map +1 -1
- package/dist/esm/base/applications/server.js.map +1 -1
- package/dist/esm/base/controllers/grpc/abstract.js.map +1 -1
- package/dist/esm/base/controllers/grpc/adapter.js.map +1 -1
- package/dist/esm/base/controllers/grpc/base.js.map +1 -1
- package/dist/esm/base/metadata/request-context.d.ts +1 -0
- package/dist/esm/base/metadata/request-context.js +1 -0
- package/dist/esm/base/metadata/request-context.js.map +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
- package/dist/esm/components/api-reference/common/constants.d.ts +1 -0
- package/dist/esm/components/api-reference/common/constants.js +1 -0
- package/dist/esm/components/api-reference/common/constants.js.map +1 -1
- package/dist/esm/components/api-reference/common/keys.d.ts +1 -0
- package/dist/esm/components/api-reference/common/keys.js +1 -0
- package/dist/esm/components/api-reference/common/keys.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +18 -1
- package/dist/esm/components/api-reference/common/types.js.map +1 -1
- package/dist/esm/components/api-reference/component.d.ts +14 -0
- package/dist/esm/components/api-reference/component.js +14 -0
- package/dist/esm/components/api-reference/component.js.map +1 -1
- package/dist/esm/components/api-reference/ui/factory.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/factory.js +1 -0
- package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
- package/dist/esm/components/api-reference/ui/scalar.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/scalar.js +1 -0
- package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
- package/dist/esm/components/api-reference/ui/swagger.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/swagger.js +1 -0
- package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/component.js +1 -0
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -0
- package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js +1 -0
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/jose-loader.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts +2 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts +1 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js +1 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js.map +1 -1
- package/dist/esm/components/auth/authorize/component.d.ts +1 -0
- package/dist/esm/components/auth/authorize/component.js +1 -0
- package/dist/esm/components/auth/authorize/component.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts +1 -0
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js +1 -0
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/base.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/membership.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/resource.js.map +1 -1
- package/dist/esm/components/auth/models/entities/columns.d.ts +1 -0
- package/dist/esm/components/auth/models/entities/columns.js.map +1 -1
- package/dist/esm/components/auth/models/entities/permission.model.d.ts +2 -0
- package/dist/esm/components/auth/models/entities/permission.model.js.map +1 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts +1 -0
- package/dist/esm/components/auth/models/entities/policy-definition.model.js.map +1 -1
- package/dist/esm/components/controller/grpc/common/types.d.ts +2 -0
- package/dist/esm/components/controller/grpc/common/types.js +1 -0
- package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
- package/dist/esm/components/controller/grpc/grpc.component.d.ts +1 -0
- package/dist/esm/components/controller/grpc/grpc.component.js +1 -0
- package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
- package/dist/esm/components/health-check/common/constants.d.ts +1 -0
- package/dist/esm/components/health-check/common/constants.js +1 -0
- package/dist/esm/components/health-check/common/constants.js.map +1 -1
- package/dist/esm/components/health-check/common/keys.d.ts +1 -0
- package/dist/esm/components/health-check/common/keys.js +1 -0
- package/dist/esm/components/health-check/common/keys.js.map +1 -1
- package/dist/esm/components/health-check/common/rest-paths.d.ts +1 -0
- package/dist/esm/components/health-check/common/rest-paths.js +1 -0
- package/dist/esm/components/health-check/common/rest-paths.js.map +1 -1
- package/dist/esm/components/health-check/common/types.d.ts +24 -3
- package/dist/esm/components/health-check/common/types.js.map +1 -1
- package/dist/esm/components/health-check/component.d.ts +15 -0
- package/dist/esm/components/health-check/component.js +15 -0
- package/dist/esm/components/health-check/component.js.map +1 -1
- package/dist/esm/components/health-check/controller.d.ts +1 -0
- package/dist/esm/components/health-check/controller.js +1 -0
- package/dist/esm/components/health-check/controller.js.map +1 -1
- package/dist/esm/components/health-check/reporter.js.map +1 -1
- package/dist/esm/components/mail/common/constants.d.ts +6 -0
- package/dist/esm/components/mail/common/constants.js +5 -0
- package/dist/esm/components/mail/common/constants.js.map +1 -1
- package/dist/esm/components/mail/common/keys.d.ts +1 -0
- package/dist/esm/components/mail/common/keys.js +1 -0
- package/dist/esm/components/mail/common/keys.js.map +1 -1
- package/dist/esm/components/mail/common/types/message.d.ts +10 -0
- package/dist/esm/components/mail/common/types/message.js.map +1 -1
- package/dist/esm/components/mail/common/types/options.d.ts +22 -1
- package/dist/esm/components/mail/common/types/options.js.map +1 -1
- package/dist/esm/components/mail/common/types/queue.d.ts +7 -0
- package/dist/esm/components/mail/common/types/queue.js.map +1 -1
- package/dist/esm/components/mail/common/types/template.d.ts +2 -0
- package/dist/esm/components/mail/common/types/template.js.map +1 -1
- package/dist/esm/components/mail/common/types/verification.d.ts +5 -0
- package/dist/esm/components/mail/common/types/verification.js.map +1 -1
- package/dist/esm/components/mail/component.d.ts +1 -0
- package/dist/esm/components/mail/component.js +1 -0
- package/dist/esm/components/mail/component.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -0
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +1 -0
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts +2 -0
- package/dist/esm/components/mail/providers/mail-transporter.provider.js +1 -0
- package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
- package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/numeric-code.js +1 -0
- package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
- package/dist/esm/components/mail/services/generators/random-token.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/random-token.js +1 -0
- package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
- package/dist/esm/components/mail/services/generators/verification-data.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/verification-data.js +1 -0
- package/dist/esm/components/mail/services/generators/verification-data.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.d.ts +1 -0
- package/dist/esm/components/mail/services/mail.service.js +1 -0
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +1 -0
- package/dist/esm/components/mail/services/template.service.js +1 -0
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/address.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/address.utility.js +1 -0
- package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/mime.utility.js +1 -0
- package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/verification.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/verification.utility.js +1 -0
- package/dist/esm/components/mail/utilities/verification.utility.js.map +1 -1
- package/dist/esm/components/request-tracker/component.d.ts +1 -0
- package/dist/esm/components/request-tracker/component.js +1 -0
- package/dist/esm/components/request-tracker/component.js.map +1 -1
- package/dist/esm/components/socket-io/common/keys.d.ts +1 -0
- package/dist/esm/components/socket-io/common/keys.js +1 -0
- package/dist/esm/components/socket-io/common/keys.js.map +1 -1
- package/dist/esm/components/socket-io/component.d.ts +1 -0
- package/dist/esm/components/socket-io/component.js +1 -0
- package/dist/esm/components/socket-io/component.js.map +1 -1
- package/dist/esm/components/static-asset/common/commit-token.js.map +1 -1
- package/dist/esm/components/static-asset/common/constants.d.ts +3 -0
- package/dist/esm/components/static-asset/common/constants.js +1 -0
- package/dist/esm/components/static-asset/common/constants.js.map +1 -1
- package/dist/esm/components/static-asset/common/keys.d.ts +1 -0
- package/dist/esm/components/static-asset/common/keys.js +1 -0
- package/dist/esm/components/static-asset/common/keys.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +42 -6
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/component.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +2 -0
- package/dist/esm/components/static-asset/controller/factory.js +1 -0
- package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
- package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
- package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
- package/dist/esm/components/static-asset/ingest.d.ts +5 -1
- package/dist/esm/components/static-asset/ingest.js.map +1 -1
- package/dist/esm/components/static-asset/models/base.model.d.ts +2 -0
- package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
- package/dist/esm/components/websocket/common/keys.d.ts +1 -0
- package/dist/esm/components/websocket/common/keys.js +1 -0
- package/dist/esm/components/websocket/common/keys.js.map +1 -1
- package/dist/esm/components/websocket/component.d.ts +1 -0
- package/dist/esm/components/websocket/component.js +1 -0
- package/dist/esm/components/websocket/component.js.map +1 -1
- package/dist/esm/testing/assert-application-boots.d.ts +39 -8
- package/dist/esm/testing/assert-application-boots.js +14 -0
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/esm/utilities/drizzle-result.utility.d.ts +1 -0
- package/dist/esm/utilities/drizzle-result.utility.js +1 -0
- package/dist/esm/utilities/drizzle-result.utility.js.map +1 -1
- package/dist/presets/app/files/.configs/builders/compile.ts +3 -1
- package/dist/presets/app/files/_env.example +1 -1
- package/dist/presets/app/files/src/smoke.test.ts +14 -8
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +10 -10
- package/dist/esm/base/applications/base.d.ts.map +0 -1
- package/dist/esm/base/applications/boot-steps.d.ts.map +0 -1
- package/dist/esm/base/applications/common/index.d.ts.map +0 -1
- package/dist/esm/base/applications/common/logger-startup.d.ts.map +0 -1
- package/dist/esm/base/applications/common/types.d.ts.map +0 -1
- package/dist/esm/base/applications/index.d.ts.map +0 -1
- package/dist/esm/base/applications/server.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/abstract.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/adapter.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/base.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/common/index.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/common/types.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/index.d.ts.map +0 -1
- package/dist/esm/base/controllers/index.d.ts.map +0 -1
- package/dist/esm/base/index.d.ts.map +0 -1
- package/dist/esm/base/metadata/index.d.ts.map +0 -1
- package/dist/esm/base/metadata/request-context.d.ts.map +0 -1
- package/dist/esm/base/middlewares/app-error/app-error.middleware.d.ts.map +0 -1
- package/dist/esm/base/middlewares/app-error/index.d.ts.map +0 -1
- package/dist/esm/base/middlewares/index.d.ts.map +0 -1
- package/dist/esm/base/middlewares/request-spy/index.d.ts.map +0 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts.map +0 -1
- package/dist/esm/common/environments.d.ts.map +0 -1
- package/dist/esm/common/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/constants.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/keys.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/types.d.ts.map +0 -1
- package/dist/esm/components/api-reference/component.d.ts.map +0 -1
- package/dist/esm/components/api-reference/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/factory.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/scalar.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/swagger.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/component.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/basic/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/basic/service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/abstract.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/jose-loader.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/service/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/basic.strategy.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/common/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/common/types.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/connector.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/constants.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/component.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/models/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/base.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/membership.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/resource.d.ts.map +0 -1
- package/dist/esm/components/auth/index.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/columns.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/index.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/permission.model.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts.map +0 -1
- package/dist/esm/components/auth/models/index.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/common/index.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/common/types.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/grpc.component.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/index.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/constants.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/index.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/keys.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/rest-paths.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/types.d.ts.map +0 -1
- package/dist/esm/components/health-check/component.d.ts.map +0 -1
- package/dist/esm/components/health-check/controller.d.ts.map +0 -1
- package/dist/esm/components/health-check/index.d.ts.map +0 -1
- package/dist/esm/components/health-check/reporter.d.ts.map +0 -1
- package/dist/esm/components/index.d.ts.map +0 -1
- package/dist/esm/components/mail/common/constants.d.ts.map +0 -1
- package/dist/esm/components/mail/common/errors.d.ts.map +0 -1
- package/dist/esm/components/mail/common/index.d.ts.map +0 -1
- package/dist/esm/components/mail/common/keys.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/index.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/message.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/options.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/queue.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/template.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/verification.d.ts.map +0 -1
- package/dist/esm/components/mail/component.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/index.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/index.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/index.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/index.d.ts.map +0 -1
- package/dist/esm/components/mail/providers/index.d.ts.map +0 -1
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts.map +0 -1
- package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/index.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/numeric-code.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/random-token.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/verification-data.d.ts.map +0 -1
- package/dist/esm/components/mail/services/index.d.ts.map +0 -1
- package/dist/esm/components/mail/services/mail.service.d.ts.map +0 -1
- package/dist/esm/components/mail/services/template.service.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/address.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/attachment.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/body.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/index.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/type.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/verification.utility.d.ts.map +0 -1
- package/dist/esm/components/request-tracker/component.d.ts.map +0 -1
- package/dist/esm/components/request-tracker/index.d.ts.map +0 -1
- package/dist/esm/components/socket-io/common/index.d.ts.map +0 -1
- package/dist/esm/components/socket-io/common/keys.d.ts.map +0 -1
- package/dist/esm/components/socket-io/common/types.d.ts.map +0 -1
- package/dist/esm/components/socket-io/component.d.ts.map +0 -1
- package/dist/esm/components/socket-io/handlers/bun.handler.d.ts.map +0 -1
- package/dist/esm/components/socket-io/handlers/index.d.ts.map +0 -1
- package/dist/esm/components/socket-io/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/commit-token.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/constants.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/errors.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/keys.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/types.d.ts.map +0 -1
- package/dist/esm/components/static-asset/component.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/base.definition.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/key-scope.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/meta-link.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/route-options.d.ts.map +0 -1
- package/dist/esm/components/static-asset/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/ingest.d.ts.map +0 -1
- package/dist/esm/components/static-asset/models/base.model.d.ts.map +0 -1
- package/dist/esm/components/static-asset/models/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/repositories/base.repository.d.ts.map +0 -1
- package/dist/esm/components/static-asset/repositories/index.d.ts.map +0 -1
- package/dist/esm/components/websocket/common/index.d.ts.map +0 -1
- package/dist/esm/components/websocket/common/keys.d.ts.map +0 -1
- package/dist/esm/components/websocket/common/types.d.ts.map +0 -1
- package/dist/esm/components/websocket/component.d.ts.map +0 -1
- package/dist/esm/components/websocket/handlers/bun.handler.d.ts.map +0 -1
- package/dist/esm/components/websocket/handlers/index.d.ts.map +0 -1
- package/dist/esm/components/websocket/index.d.ts.map +0 -1
- package/dist/esm/connectors/index.d.ts.map +0 -1
- package/dist/esm/helpers/base-helper.d.ts.map +0 -1
- package/dist/esm/helpers/index.d.ts.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/testing/assert-application-boots.d.ts.map +0 -1
- package/dist/esm/testing/index.d.ts.map +0 -1
- package/dist/esm/utilities/drizzle-result.utility.d.ts.map +0 -1
- package/dist/esm/utilities/index.d.ts.map +0 -1
- package/dist/esm/utilities/network.utility.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-policy-line-cache.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/user-policy-line-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EACL,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAK/B;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAOjD,YAAY,IAGX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QAP7C,4IAA4I;QAC3H,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAOzE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,uMAAuM;IACvM,KAAK,CAAC,KAAK,CAAC,IAAkC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjE,iNAAiN;QACjN,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"user-policy-line-cache.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/user-policy-line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QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;iBACzB,IAAI,CAAC,8DAA8D,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAE9F,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport {\n AuthorizationErrors,\n type IAuthorizationUser,\n type ICasbinEnforcerCachedRedis,\n} from '@venizia/ignis-kernel';\n\n/** Computes a user's policy lines on a cache miss - CasbinAuthorizationEnforcer wires this to its isolated-enforcer extraction (PolicyLineCodec.extractUserLines). */\nexport type TPolicyLineLoader = (opts: { user: IAuthorizationUser }) => Promise<string[]>;\n\n/**\n * Per-user redis cache of casbin policy lines. Owns the cache key, the TTL, and concurrent-miss\n * de-duplication so N simultaneous misses for the same user collapse onto one extraction.\n */\nexport class UserPolicyLineCache extends BaseHelper {\n private readonly cached: ICasbinEnforcerCachedRedis & { use: true };\n private readonly loadLines: TPolicyLineLoader;\n\n // cacheKey -> in-progress line-fetch; concurrent misses for the same user share one extraction instead of all hitting the DB (see fetch()).\n private readonly pendingLineFetches = new Map<string, Promise<string[]>>();\n\n constructor(opts: {\n cached: ICasbinEnforcerCachedRedis & { use: true };\n loadLines: TPolicyLineLoader;\n }) {\n super({ scope: UserPolicyLineCache.name });\n this.cached = opts.cached;\n this.loadLines = opts.loadLines;\n }\n\n /** Fetch the user's lines, collapsing concurrent misses per key onto one extraction. Best-effort: two misses may race past the cache read and both extract (benign - per-user lines are identical). */\n async fetch(opts: { user: IAuthorizationUser }): Promise<string[]> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n\n // Cache hit - Redis owns expiry (PX on write), so a present key is fresh; an entry that does not decode (corrupted, or not an array of policy lines) must NOT 500 the request, so it is discarded and refetched.\n const raw = await this.cached.options.connection.get({ key: cacheKey });\n\n if (raw) {\n const lines = this.parseLines({ raw, cacheKey });\n\n if (lines) {\n return lines;\n }\n }\n\n const existing = this.pendingLineFetches.get(cacheKey);\n\n if (existing) {\n return existing;\n }\n\n // Cache miss (or discarded corrupt entry) - extract from an ISOLATED enforcer so a concurrent load cannot contaminate the cache, persist it, then return the lines for THIS request.\n const task = async () => {\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n\n return lines;\n };\n\n const promise = task().finally(() => {\n this.pendingLineFetches.delete(cacheKey);\n });\n\n this.pendingLineFetches.set(cacheKey, promise);\n\n return promise;\n }\n\n /** Drop the user's cached entry. */\n async invalidate(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; invalidatedKeys: number }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n const invalidatedKeys = await this.cached.options.connection.del({ keys: [cacheKey] });\n\n return { cacheKey, invalidatedKeys };\n }\n\n /** Drop then recompute the user's cached entry via `loadLines` - an isolated extraction (never a pooled serving enforcer), so a concurrent request cannot make the cache hold another user's lines. */\n async rebuild(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; lines: string[] }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n await this.cached.options.connection.del({ keys: [cacheKey] });\n\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n\n return { cacheKey, lines };\n }\n\n /** Compute the user's cache key and reject an empty result - consistent with the read path. */\n private async resolveCacheKey(opts: { user: IAuthorizationUser }): Promise<string> {\n const cacheKey = await this.cached.options.keyFn({ user: opts.user });\n\n if (!cacheKey) {\n throw getError({\n error: AuthorizationErrors.CACHE_KEY_INVALID,\n message: '[UserPolicyLineCache] keyFn returned an empty cache key.',\n });\n }\n\n return cacheKey;\n }\n\n /** Single source of truth for the cache encoding. Used by the miss path and rebuild(). */\n private async writeLines(opts: { cacheKey: string; lines: string[] }): Promise<void> {\n await this.cached.options.connection.set({\n key: opts.cacheKey,\n value: opts.lines,\n options: { expiresIn: this.cached.options.expiresIn },\n });\n }\n\n /** Decode cached policy lines; on any corruption, log and return null so the caller refetches. */\n private parseLines(opts: { raw: string; cacheKey: string }): TNullable<string[]> {\n try {\n const parsed = JSON.parse(opts.raw);\n\n if (!Array.isArray(parsed) || parsed.some((line) => typeof line !== 'string')) {\n throw getError({\n message: '[UserPolicyLineCache] Cached payload is not an array of policy lines.',\n });\n }\n\n return parsed as string[];\n } catch (error) {\n this.logger\n .for(this.parseLines.name)\n .warn('Discarding corrupted authz cache entry | key: %s | error: %s', opts.cacheKey, error);\n\n return null;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,OAAgB,eAAgB,SAAQ,UAAU;IAAxD;;QACY,kBAAa,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,OAAgB,eAAgB,SAAQ,UAAU;IAAxD;;QACY,kBAAa,GAAG,KAAK,CAAC;IAuFlC,CAAC;IAnFC,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,KAAa;QACxC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,8GAA8G;IAC9G,KAAK,CAAC,UAAU,KAAmB,CAAC;IAEpC,KAAK,CAAC,UAAU;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,8HAA8H;IAC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IAAI,CAAC,CAAC;YAEV,MAAM,OAAO,GAAG,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAEtC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,SAAS;YACX,CAAC;YAED,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;oBACxB,SAAS;gBACX,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers/core';\n\n/**\n * Shared casbin `RoleManager` scaffolding for the resource, domain-hierarchy, and membership\n * role managers: the debug-only interface members (`printRoles`, `getDomains`, `getAllDomains`),\n * the `hasLink` wrapper around the synchronous `syncedHasLink`, the once-per-`clear()`\n * overlay-initialized log line, and the shared ancestor walk both hierarchy-aware managers use.\n */\nexport abstract class BaseRoleManager extends BaseHelper {\n protected graphReported = false;\n\n abstract syncedHasLink(name1: string, name2: string): boolean;\n\n async hasLink(name1: string, name2: string): Promise<boolean> {\n return this.syncedHasLink(name1, name2);\n }\n\n /** casbin calls this after buildRoleLinks purely as a debug hook; none of the role managers log from here. */\n async printRoles(): Promise<void> {}\n\n async getDomains(): Promise<string[]> {\n return [];\n }\n\n async getAllDomains(): Promise<string[]> {\n return [];\n }\n\n /** Logs the initialized-overlay line once per `clear()` cycle; `build` is only invoked the first time so counts stay lazy. */\n protected reportGraphOnce(build: () => { message: string; args: unknown[] }): void {\n if (this.graphReported) {\n return;\n }\n\n this.graphReported = true;\n\n const { message, args } = build();\n this.logger.for(this.syncedHasLink.name).debug(message, ...args);\n }\n\n /** Node and edge counts of a domain-hierarchy overlay, for the once-per-`clear()` debug log. */\n protected static overlayStats(overlay?: Map<string, Set<string>>): {\n nodeCount: number;\n edgeCount: number;\n } {\n if (!overlay) {\n return { nodeCount: 0, edgeCount: 0 };\n }\n\n let edgeCount = 0;\n const overlayValues = overlay.values();\n\n for (const parents of overlayValues) {\n edgeCount += parents.size;\n }\n\n return { nodeCount: overlay.size, edgeCount };\n }\n\n /** `node` itself plus every ancestor reachable by walking the overlay's child->parent edges,\n * node first. Cycle-safe: visited Set + index cursor, never shift(). Static - `ResourceRoleManager`\n * extends this base with no overlay of this shape, so this must not force instance state onto it. */\n protected static collectAncestors(opts: {\n overlay?: Map<string, Set<string>>;\n node: string;\n }): string[] {\n const { overlay, node } = opts;\n const result: string[] = [node];\n const visited = new Set<string>([node]);\n const queue: string[] = [node];\n\n let head = 0;\n\n while (head < queue.length) {\n const current = queue[head];\n head += 1;\n\n const parents = overlay?.get(current);\n\n if (!parents) {\n continue;\n }\n\n for (const parent of parents) {\n if (visited.has(parent)) {\n continue;\n }\n\n visited.add(parent);\n result.push(parent);\n queue.push(parent);\n }\n }\n\n return result;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-hierarchy.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/domain-hierarchy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,OAAO,0BAA2B,SAAQ,eAAe;IAO7D,YAAY,IAAgE;QAC1E,KAAK,CAAC,EAAE,KAAK,EAAE,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,GAAG,EAAuB,CAAC;IAChE,CAAC;IAED,8JAA8J;IAC9J,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,MAAc;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"domain-hierarchy.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/domain-hierarchy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,OAAO,0BAA2B,SAAQ,eAAe;IAO7D,YAAY,IAAgE;QAC1E,KAAK,CAAC,EAAE,KAAK,EAAE,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,GAAG,EAAuB,CAAC;IAChE,CAAC;IAED,8JAA8J;IAC9J,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,MAAc;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEzC,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC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,CAAC;YAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wEAAwE;IAChE,OAAO,CAAC,IAAuC;QACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAE/B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GAAG,0BAA0B,CAAC,gBAAgB,CAAC;YAC5D,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/**\n * Serves the `g3` axis (`g3(r.dom, p.dom)`) and, with `reversed`, casbin's\n * `DefaultRoleManager.addDomainHierarchy()` on `g`, which asks in the opposite argument order.\n * `clear()` wipes only the overlay, never shared across requests: `buildRoleLinksInternal` clears\n * every registered role manager each request. Pass both instances one `overlay` so per-request `g3`\n * edges reach the `g` axis, which casbin never puts in `rmMap` and so never feeds `addLink`.\n */\nexport class DomainHierarchyRoleManager extends BaseRoleManager implements RoleManager {\n private readonly reversed: boolean;\n private readonly overlay: Map<\n string, // child domain\n Set<string> // set of parent domains\n >;\n\n constructor(opts: { reversed?: boolean; overlay?: Map<string, Set<string>> }) {\n super({ scope: DomainHierarchyRoleManager.name });\n this.reversed = opts.reversed ?? false;\n this.overlay = opts.overlay ?? new Map<string, Set<string>>();\n }\n\n /** Mutates the map in place - never reassigns `this.overlay` - so a caller sharing this map with another instance (see `opts.overlay`) sees the clear too. */\n async clear(): Promise<void> {\n this.overlay.clear();\n this.graphReported = false;\n }\n\n async addLink(child: string, parent: string): Promise<void> {\n const existing = this.overlay.get(child);\n\n if (existing) {\n existing.add(parent);\n } else {\n this.overlay.set(child, new Set<string>([parent]));\n }\n\n if (!this.overlay.has(parent)) {\n this.overlay.set(parent, new Set<string>());\n }\n }\n\n async deleteLink(child: string, parent: string): Promise<void> {\n this.overlay.get(child)?.delete(parent);\n }\n\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const { nodeCount, edgeCount } = DomainHierarchyRoleManager.overlayStats(this.overlay);\n\n return {\n message: 'domain-hierarchy role manager initialized | nodes: %d | edges: %d | reversed: %s',\n args: [nodeCount, edgeCount, this.reversed],\n };\n });\n\n const start = this.reversed ? name2 : name1;\n const target = this.reversed ? name1 : name2;\n\n return this.reaches({ start, target });\n }\n\n /** Local overlay only, not the shared graph - correct for hasLink, incomplete for casbin's management API. */\n async getRoles(name: string): Promise<string[]> {\n return [...(this.overlay.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [child, parents] of this.overlay) {\n if (parents.has(name)) {\n users.push(child);\n }\n }\n\n return users;\n }\n\n /** True when `start` is `target`, or reaches it through the overlay. */\n private reaches(opts: { start: string; target: string }): boolean {\n const { start, target } = opts;\n\n if (start === target) {\n return true;\n }\n\n const ancestors = DomainHierarchyRoleManager.collectAncestors({\n overlay: this.overlay,\n node: start,\n });\n\n return ancestors.includes(target);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"membership.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/membership.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;sEAEsE;AACtE,MAAM,OAAO,qBAAsB,SAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"membership.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/membership.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,M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AC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE3C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,SAAS,GAAG,qBAAqB,CAAC,gBAAgB,CAAC;YACvD,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACzB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uHAAuH;IACvH,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/** `g2` axis (`g2(r.sub, r.dom)`): membership holds when the user joined the request domain or any\n * ancestor of it, walking the shared per-request domain-hierarchy overlay. Memberships are\n * per-principal and rebuilt every request, so `clear()` wipes all. */\nexport class MembershipRoleManager extends BaseRoleManager implements RoleManager {\n private readonly overlay?: Map<\n string, // child domain\n Set<string> // set of parent domains\n >;\n\n private memberships = new Map<\n string, // user\n Set<string> // set of joined domains\n >();\n\n constructor(opts: { overlay?: Map<string, Set<string>> }) {\n super({ scope: MembershipRoleManager.name });\n this.overlay = opts.overlay;\n }\n\n async clear(): Promise<void> {\n this.memberships = new Map<string, Set<string>>();\n this.graphReported = false;\n }\n\n async addLink(user: string, domain: string): Promise<void> {\n const existing = this.memberships.get(user);\n\n if (existing) {\n existing.add(domain);\n } else {\n this.memberships.set(user, new Set<string>([domain]));\n }\n }\n\n async deleteLink(user: string, domain: string): Promise<void> {\n this.memberships.get(user)?.delete(domain);\n }\n\n /** True when `name1` (user) joined `name2` (request domain) itself, or any ancestor of it. Walks UP from the request domain only - walking down from every joined domain would fan out over the whole subtree. */\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const { nodeCount, edgeCount } = MembershipRoleManager.overlayStats(this.overlay);\n\n return {\n message: 'membership role manager initialized | nodes: %d | edges: %d',\n args: [nodeCount, edgeCount],\n };\n });\n\n const joined = this.memberships.get(name1);\n\n if (!joined || joined.size === 0) {\n return false;\n }\n\n const ancestors = MembershipRoleManager.collectAncestors({\n overlay: this.overlay,\n node: name2,\n });\n\n for (const ancestor of ancestors) {\n if (joined.has(ancestor)) {\n return true;\n }\n }\n\n return false;\n }\n\n /** Local membership state only, not the shared graph - correct for hasLink, incomplete for casbin's management API. */\n async getRoles(name: string): Promise<string[]> {\n return [...(this.memberships.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [user, domains] of this.memberships) {\n if (domains.has(name)) {\n users.push(user);\n }\n }\n\n return users;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/role-managers/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAA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AC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAElC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtD,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import type { RoleManager } from 'casbin';\nimport { BaseRoleManager } from './base';\n\n/** Resource-axis (`g4`) role manager: `addMatchingFunc` would set `hasPattern` and disable DefaultRoleManager's O(1) fast path, so prefix ancestors are walked manually; `addLink` must stay idempotent because `buildRoleLinks` re-adds every edge once per request. */\nexport class ResourceRoleManager extends BaseRoleManager implements RoleManager {\n private parents = new Map<\n string, // Child module\n Set<string> // Set of Parent modules\n >();\n\n constructor() {\n super({ scope: ResourceRoleManager.name });\n }\n\n async clear(): Promise<void> {\n this.parents = new Map<string, Set<string>>();\n this.graphReported = false;\n }\n\n async addLink(child: string, parent: string): Promise<void> {\n const existing = this.parents.get(child);\n\n if (existing) {\n existing.add(parent);\n } else {\n this.parents.set(child, new Set<string>([parent]));\n }\n\n if (!this.parents.has(parent)) {\n this.parents.set(parent, new Set<string>());\n }\n }\n\n async deleteLink(child: string, parent: string): Promise<void> {\n this.parents.get(child)?.delete(parent);\n }\n\n syncedHasLink(name1: string, name2: string): boolean {\n this.reportGraphOnce(() => {\n const nodeCount = this.parents.size;\n const edgeCount = Array.from(this.parents.values()).reduce((sum, set) => sum + set.size, 0);\n\n return {\n message: 'resource-role initialized | nodes: %d | edges: %d',\n args: [nodeCount, edgeCount],\n };\n });\n\n if (name1 === name2) {\n return true;\n }\n\n const seeds = this.collectStoredAncestors({ name: name1 });\n\n if (seeds.length === 0) {\n return false;\n }\n\n const visited = new Set<string>();\n const queue: string[] = [...seeds];\n\n // Index cursor rather than shift(): shift() is O(n) and would make the walk quadratic.\n let head = 0;\n\n while (head < queue.length) {\n const current = queue[head];\n head += 1;\n\n if (current === name2) {\n return true;\n }\n\n if (visited.has(current)) {\n continue;\n }\n\n visited.add(current);\n\n const parents = this.parents.get(current);\n\n if (parents) {\n queue.push(...parents);\n }\n }\n\n return false;\n }\n\n async getRoles(name: string): Promise<string[]> {\n return [...(this.parents.get(name) ?? [])];\n }\n\n async getUsers(name: string): Promise<string[]> {\n const users: string[] = [];\n\n for (const [child, parents] of this.parents) {\n if (parents.has(name)) {\n users.push(child);\n }\n }\n\n return users;\n }\n\n /** All stored prefix ancestors of a dotted code (`a.b.c` -> `a.b` -> `a`), not only the deepest, plus a literal stored `'*'` node - `objectMatch(anything, '*')` is always true, so a `g4` edge whose child is `'*'` must stay reachable from every request object. */\n private collectStoredAncestors(opts: { name: string }): string[] {\n const ancestors: string[] = [];\n\n if (this.parents.has(opts.name)) {\n ancestors.push(opts.name);\n }\n\n let current = opts.name;\n\n for (;;) {\n const index = current.lastIndexOf('.');\n\n if (index === -1) {\n break;\n }\n\n current = current.slice(0, index);\n\n if (this.parents.has(current)) {\n ancestors.push(current);\n }\n }\n\n if (this.parents.has('*') && !ancestors.includes('*')) {\n ancestors.push('*');\n }\n\n return ancestors;\n }\n}\n"]}
|
|
@@ -28,6 +28,7 @@ declare const buildCommonPolicyDefinitionColumns: <ExtraVariant extends string =
|
|
|
28
28
|
action: PgTextBuilderInitial<"action", [string, ...string[]]>;
|
|
29
29
|
effect: import("drizzle-orm").$Type<PgTextBuilderInitial<"effect", [string, ...string[]]>, TAuthorizationDecision>;
|
|
30
30
|
};
|
|
31
|
+
/** Drizzle column set shared by every policy-definition table; `ExtraVariant` widens the allowed `variant` values and `Metadata` types the `metadata` column. */
|
|
31
32
|
export type TPolicyDefinitionCommonColumns<ExtraVariant extends string = never, Metadata extends object = TSubsetGrantMetadata> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant, Metadata>>;
|
|
32
33
|
type TPolicyDefinitionColumnDef<Opts extends TPolicyDefinitionOptions<string> | undefined = undefined, Metadata extends object = TSubsetGrantMetadata> = Opts extends {
|
|
33
34
|
idType: 'string';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAyB3D,iHAAiH;AACjH,MAAM,kCAAkC,GAAG,GAGvC,EAAE,CAAC,CAAC;IACN,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAY;IAC7C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,EAA8C,CAAC,OAAO,EAAE;IAEtF,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC3C,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IAEzC,6HAA6H;IAC7H,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;IAE/B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC;IACtB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,EAA0B;CACvD,CAAC,CAAC;AAsBH,oIAAoI;AACpI,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,SAAS,CAAC,IAAgC;QAC/C,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,OA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,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF","sourcesContent":["import { isoTimestamp } from '@venizia/ignis-connectors/postgres';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthorizationDomainScopes,\n RoleStatuses,\n UserStatuses,\n UserTypes,\n} from '@venizia/ignis-kernel';\nimport type {\n TAuthorizationDecision,\n TAuthorizationPolicyVariant,\n TIdSchemaType,\n TSubsetGrantMetadata,\n} from '@venizia/ignis-kernel';\nimport type { PgIntegerBuilderInitial, PgTextBuilderInitial } from 'drizzle-orm/pg-core';\nimport { integer, jsonb, text } from 'drizzle-orm/pg-core';\nimport type { TPermissionCommonColumns, TPermissionOptions } from './permission.model';\nimport type { TPolicyDefinitionOptions } from './policy-definition.model';\n\ntype TPermissionColumnDef<Opts extends TPermissionOptions | undefined = undefined> = Opts extends {\n idType: infer IdType;\n}\n ? IdType extends 'string'\n ? TPermissionCommonColumns & {\n parentId: PgTextBuilderInitial<string, [string, ...string[]]>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n };\n\n/** Extracts the app-declared extra variants from `Opts`, or `never` when none were declared. */\ntype TExtraPolicyVariantOf<Opts> = Opts extends {\n extraVariants?: ReadonlyArray<infer ExtraVariant extends string>;\n}\n ? ExtraVariant\n : never;\n\n/** Column shape is inferred, never hand-declared, so it can never drift from the `$type<>()` narrowing below. */\nconst buildCommonPolicyDefinitionColumns = <\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n>() => ({\n metadata: jsonb('metadata').$type<Metadata>(),\n variant: text('variant').$type<TAuthorizationPolicyVariant | ExtraVariant>().notNull(),\n\n subjectType: text('subject_type').notNull(),\n targetType: text('target_type').notNull(),\n\n // `null` IS `ANY_MEMBER`, not \"unknown\"; the literal is refused by `AuthModelColumns.buildPolicyDefinitionDomainShapeCheck`.\n domainType: text('domain_type'),\n\n action: text('action'),\n effect: text('effect').$type<TAuthorizationDecision>(),\n});\n\nexport type TPolicyDefinitionCommonColumns<\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant, Metadata>>;\n\ntype TPolicyDefinitionColumnDef<\n Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n> = Opts extends { idType: 'string' }\n ? TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof text>;\n targetId: ReturnType<typeof text>;\n domainId: ReturnType<typeof text>;\n }\n : TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof integer>;\n targetId: ReturnType<typeof integer>;\n domainId: ReturnType<typeof integer>;\n };\n\n/** The Drizzle column sets of the auth tables, spread into a table the application declares (`...AuthModelColumns.buildUser()`). */\nexport class AuthModelColumns {\n static buildUser(opts?: { idType: TIdSchemaType }) {\n return {\n realm: text('realm').default(''),\n status: text('status')\n .$type<TConstValue<typeof UserStatuses>>()\n .notNull()\n .default(UserStatuses.UNKNOWN),\n type: text('type').$type<TConstValue<typeof UserTypes>>().notNull().default(UserTypes.SYSTEM),\n activatedAt: isoTimestamp('activated_at', { withTimezone: true }),\n lastLoginAt: isoTimestamp('last_login_at', { withTimezone: true }),\n parentId: opts?.idType === 'string' ? text('parent_id') : integer('parent_id'),\n };\n }\n\n static buildRole() {\n return {\n identifier: text('identifier').unique().notNull(),\n name: text('name').notNull(),\n description: text('description'),\n priority: integer('priority').notNull(),\n status: text('status')\n .$type<TConstValue<typeof RoleStatuses>>()\n .notNull()\n .default(RoleStatuses.ACTIVATED),\n };\n }\n\n static buildPermission<Opts extends TPermissionOptions | undefined>(\n opts?: Opts,\n ): TPermissionColumnDef<Opts> {\n const { idType = 'number' } = opts ?? {};\n\n switch (idType) {\n case 'number': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: integer('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n case 'string': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: text('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPermission] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * `Metadata` is a type parameter, not an `opts` field: unlike `extraVariants` there is no runtime\n * value to infer from, so supplying it means spelling `Opts` too (no partial inference):\n * `AuthModelColumns.buildPolicyDefinition<{ idType: 'string' }, IMyMetadata>({ idType: 'string' })`.\n * Keep `ops` in a custom shape if the app also issues subset grants - `customGrant` writes it.\n */\n static buildPolicyDefinition<\n const Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n >(opts?: Opts): TPolicyDefinitionColumnDef<Opts, Metadata> {\n const { idType = 'number' } = opts ?? {};\n\n const common = buildCommonPolicyDefinitionColumns<TExtraPolicyVariantOf<Opts>, Metadata>();\n\n switch (idType) {\n case 'number': {\n return {\n ...common,\n subjectId: integer('subject_id').notNull(),\n targetId: integer('target_id').notNull(),\n domainId: integer('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n case 'string': {\n return {\n ...common,\n subjectId: text('subject_id').notNull(),\n targetId: text('target_id').notNull(),\n domainId: text('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPolicyDefinition] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * The three legal `(domain_type, domain_id)` pairs, as CHECK predicate TEXT for a migration - text,\n * not a Drizzle `SQL`, because a column ref in a `sql` template renders schema-qualified, which a\n * table-level CHECK rejects.\n *\n * The `IS NOT NULL` guard on the last branch looks redundant next to `NOT IN` and is not: a NULL\n * `domain_type` makes `NOT IN` evaluate to NULL, and a CHECK rejects only on FALSE - without it an id\n * with no type passes.\n */\n static buildPolicyDefinitionDomainShapeCheck(opts?: {\n domainTypeColumn?: string;\n domainIdColumn?: string;\n }): string {\n const { domainTypeColumn = 'domain_type', domainIdColumn = 'domain_id' } = opts ?? {};\n const { ANY_MEMBER, SYSTEM_WIDE } = AuthorizationDomainScopes;\n\n return [\n `(${domainTypeColumn} IS NULL AND ${domainIdColumn} IS NULL)`,\n `OR (${domainTypeColumn} = '${SYSTEM_WIDE}' AND ${domainIdColumn} IS NULL)`,\n `OR (\n ${domainTypeColumn} IS NOT NULL\n AND ${domainTypeColumn} NOT IN ('${ANY_MEMBER}', '${SYSTEM_WIDE}')\n AND ${domainIdColumn} IS NOT NULL\n )`,\n ].join('\\n');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"columns.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAyB3D,iHAAiH;AACjH,MAAM,kCAAkC,GAAG,GAGvC,EAAE,CAAC,CAAC;IACN,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAY;IAC7C,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,EAA8C,CAAC,OAAO,EAAE;IAEtF,WAAW,EAAE,IAAI,C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;;;OAQG;IACH,MAAM,CAAC,qCAAqC,CAAC,IAG5C;QACC,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,cAAc,GAAG,WAAW,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QACtF,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,yBAAyB,CAAC;QAE9D,OAAO;YACL,IAAI,gBAAgB,gBAAgB,cAAc,WAAW;YAC7D,OAAO,gBAAgB,OAAO,WAAW,SAAS,cAAc,WAAW;YAC3E;QACE,gBAAgB;YACZ,gBAAgB,aAAa,UAAU,OAAO,WAAW;YACzD,cAAc;MACpB;SACD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF","sourcesContent":["import { isoTimestamp } from '@venizia/ignis-connectors/postgres';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthorizationDomainScopes,\n RoleStatuses,\n UserStatuses,\n UserTypes,\n} from '@venizia/ignis-kernel';\nimport type {\n TAuthorizationDecision,\n TAuthorizationPolicyVariant,\n TIdSchemaType,\n TSubsetGrantMetadata,\n} from '@venizia/ignis-kernel';\nimport type { PgIntegerBuilderInitial, PgTextBuilderInitial } from 'drizzle-orm/pg-core';\nimport { integer, jsonb, text } from 'drizzle-orm/pg-core';\nimport type { TPermissionCommonColumns, TPermissionOptions } from './permission.model';\nimport type { TPolicyDefinitionOptions } from './policy-definition.model';\n\ntype TPermissionColumnDef<Opts extends TPermissionOptions | undefined = undefined> = Opts extends {\n idType: infer IdType;\n}\n ? IdType extends 'string'\n ? TPermissionCommonColumns & {\n parentId: PgTextBuilderInitial<string, [string, ...string[]]>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n }\n : TPermissionCommonColumns & {\n parentId: PgIntegerBuilderInitial<string>;\n };\n\n/** Extracts the app-declared extra variants from `Opts`, or `never` when none were declared. */\ntype TExtraPolicyVariantOf<Opts> = Opts extends {\n extraVariants?: ReadonlyArray<infer ExtraVariant extends string>;\n}\n ? ExtraVariant\n : never;\n\n/** Column shape is inferred, never hand-declared, so it can never drift from the `$type<>()` narrowing below. */\nconst buildCommonPolicyDefinitionColumns = <\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n>() => ({\n metadata: jsonb('metadata').$type<Metadata>(),\n variant: text('variant').$type<TAuthorizationPolicyVariant | ExtraVariant>().notNull(),\n\n subjectType: text('subject_type').notNull(),\n targetType: text('target_type').notNull(),\n\n // `null` IS `ANY_MEMBER`, not \"unknown\"; the literal is refused by `AuthModelColumns.buildPolicyDefinitionDomainShapeCheck`.\n domainType: text('domain_type'),\n\n action: text('action'),\n effect: text('effect').$type<TAuthorizationDecision>(),\n});\n\n/** Drizzle column set shared by every policy-definition table; `ExtraVariant` widens the allowed `variant` values and `Metadata` types the `metadata` column. */\nexport type TPolicyDefinitionCommonColumns<\n ExtraVariant extends string = never,\n Metadata extends object = TSubsetGrantMetadata,\n> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant, Metadata>>;\n\ntype TPolicyDefinitionColumnDef<\n Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n> = Opts extends { idType: 'string' }\n ? TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof text>;\n targetId: ReturnType<typeof text>;\n domainId: ReturnType<typeof text>;\n }\n : TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>, Metadata> & {\n subjectId: ReturnType<typeof integer>;\n targetId: ReturnType<typeof integer>;\n domainId: ReturnType<typeof integer>;\n };\n\n/** The Drizzle column sets of the auth tables, spread into a table the application declares (`...AuthModelColumns.buildUser()`). */\nexport class AuthModelColumns {\n static buildUser(opts?: { idType: TIdSchemaType }) {\n return {\n realm: text('realm').default(''),\n status: text('status')\n .$type<TConstValue<typeof UserStatuses>>()\n .notNull()\n .default(UserStatuses.UNKNOWN),\n type: text('type').$type<TConstValue<typeof UserTypes>>().notNull().default(UserTypes.SYSTEM),\n activatedAt: isoTimestamp('activated_at', { withTimezone: true }),\n lastLoginAt: isoTimestamp('last_login_at', { withTimezone: true }),\n parentId: opts?.idType === 'string' ? text('parent_id') : integer('parent_id'),\n };\n }\n\n static buildRole() {\n return {\n identifier: text('identifier').unique().notNull(),\n name: text('name').notNull(),\n description: text('description'),\n priority: integer('priority').notNull(),\n status: text('status')\n .$type<TConstValue<typeof RoleStatuses>>()\n .notNull()\n .default(RoleStatuses.ACTIVATED),\n };\n }\n\n static buildPermission<Opts extends TPermissionOptions | undefined>(\n opts?: Opts,\n ): TPermissionColumnDef<Opts> {\n const { idType = 'number' } = opts ?? {};\n\n switch (idType) {\n case 'number': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: integer('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n case 'string': {\n return {\n code: text('code').unique().notNull(),\n name: text('name').notNull(),\n subject: text('subject').notNull(),\n method: text('method').notNull(),\n action: text('action').notNull(),\n scope: text('scope').notNull(),\n description: text('description'),\n parentId: text('parent_id'),\n } as TPermissionColumnDef<Opts>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPermission] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * `Metadata` is a type parameter, not an `opts` field: unlike `extraVariants` there is no runtime\n * value to infer from, so supplying it means spelling `Opts` too (no partial inference):\n * `AuthModelColumns.buildPolicyDefinition<{ idType: 'string' }, IMyMetadata>({ idType: 'string' })`.\n * Keep `ops` in a custom shape if the app also issues subset grants - `customGrant` writes it.\n */\n static buildPolicyDefinition<\n const Opts extends TPolicyDefinitionOptions<string> | undefined = undefined,\n Metadata extends object = TSubsetGrantMetadata,\n >(opts?: Opts): TPolicyDefinitionColumnDef<Opts, Metadata> {\n const { idType = 'number' } = opts ?? {};\n\n const common = buildCommonPolicyDefinitionColumns<TExtraPolicyVariantOf<Opts>, Metadata>();\n\n switch (idType) {\n case 'number': {\n return {\n ...common,\n subjectId: integer('subject_id').notNull(),\n targetId: integer('target_id').notNull(),\n domainId: integer('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n case 'string': {\n return {\n ...common,\n subjectId: text('subject_id').notNull(),\n targetId: text('target_id').notNull(),\n domainId: text('domain_id'),\n } as TPolicyDefinitionColumnDef<Opts, Metadata>;\n }\n default: {\n throw getError({\n message: `[AuthModelColumns.buildPolicyDefinition] Invalid idType | idType: ${idType}`,\n });\n }\n }\n }\n\n /**\n * The three legal `(domain_type, domain_id)` pairs, as CHECK predicate TEXT for a migration - text,\n * not a Drizzle `SQL`, because a column ref in a `sql` template renders schema-qualified, which a\n * table-level CHECK rejects.\n *\n * The `IS NOT NULL` guard on the last branch looks redundant next to `NOT IN` and is not: a NULL\n * `domain_type` makes `NOT IN` evaluate to NULL, and a CHECK rejects only on FALSE - without it an id\n * with no type passes.\n */\n static buildPolicyDefinitionDomainShapeCheck(opts?: {\n domainTypeColumn?: string;\n domainIdColumn?: string;\n }): string {\n const { domainTypeColumn = 'domain_type', domainIdColumn = 'domain_id' } = opts ?? {};\n const { ANY_MEMBER, SYSTEM_WIDE } = AuthorizationDomainScopes;\n\n return [\n `(${domainTypeColumn} IS NULL AND ${domainIdColumn} IS NULL)`,\n `OR (${domainTypeColumn} = '${SYSTEM_WIDE}' AND ${domainIdColumn} IS NULL)`,\n `OR (\n ${domainTypeColumn} IS NOT NULL\n AND ${domainTypeColumn} NOT IN ('${ANY_MEMBER}', '${SYSTEM_WIDE}')\n AND ${domainIdColumn} IS NOT NULL\n )`,\n ].join('\\n');\n }\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { TIdSchemaType } from '@venizia/ignis-kernel';
|
|
2
2
|
import type { NotNull } from 'drizzle-orm';
|
|
3
3
|
import type { PgTextBuilderInitial } from 'drizzle-orm/pg-core';
|
|
4
|
+
/** Options of the permission table builder; `idType` selects the primary key type. */
|
|
4
5
|
export type TPermissionOptions = {
|
|
5
6
|
idType?: TIdSchemaType;
|
|
6
7
|
};
|
|
8
|
+
/** Drizzle column set of the permission table: text `code`, `name`, `method`, `subject`, `action`, `scope` (all not null) and a nullable `description`. */
|
|
7
9
|
export type TPermissionCommonColumns = {
|
|
8
10
|
code: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;
|
|
9
11
|
name: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/permission.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\nimport type { NotNull } from 'drizzle-orm';\nimport type { PgTextBuilderInitial } from 'drizzle-orm/pg-core';\n\nexport type TPermissionOptions = {\n idType?: TIdSchemaType;\n};\n\nexport type TPermissionCommonColumns = {\n code: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n name: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n method: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n subject: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n action: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n scope: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n description: PgTextBuilderInitial<string, [string, ...string[]]>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"permission.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/permission.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\nimport type { NotNull } from 'drizzle-orm';\nimport type { PgTextBuilderInitial } from 'drizzle-orm/pg-core';\n\n/** Options of the permission table builder; `idType` selects the primary key type. */\nexport type TPermissionOptions = {\n idType?: TIdSchemaType;\n};\n\n/** Drizzle column set of the permission table: text `code`, `name`, `method`, `subject`, `action`, `scope` (all not null) and a nullable `description`. */\nexport type TPermissionCommonColumns = {\n code: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n name: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n method: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n subject: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n action: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n scope: NotNull<PgTextBuilderInitial<string, [string, ...string[]]>>;\n description: PgTextBuilderInitial<string, [string, ...string[]]>;\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TIdSchemaType } from '@venizia/ignis-kernel';
|
|
2
|
+
/** Options of the policy-definition table builder; `idType` selects the key type and `extraVariants` declares app-defined variants. */
|
|
2
3
|
export type TPolicyDefinitionOptions<ExtraVariant extends string = never> = {
|
|
3
4
|
idType?: TIdSchemaType;
|
|
4
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-definition.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\n\nexport type TPolicyDefinitionOptions<ExtraVariant extends string = never> = {\n idType?: TIdSchemaType;\n /**\n * App-only edge kinds stored in this same table alongside IGNIS's seven (e.g. `merchant_role`).\n * `ScopedCasbinAdapter` never selects an undeclared variant - it is purely the consumer's data.\n * Pass as an inline array literal; the `const` type parameter below infers the literal union\n * from it without needing `as const`.\n */\n extraVariants?: ReadonlyArray<ExtraVariant>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"policy-definition.model.js","sourceRoot":"","sources":["../../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":"","sourcesContent":["import type { TIdSchemaType } from '@venizia/ignis-kernel';\n\n/** Options of the policy-definition table builder; `idType` selects the key type and `extraVariants` declares app-defined variants. */\nexport type TPolicyDefinitionOptions<ExtraVariant extends string = never> = {\n idType?: TIdSchemaType;\n /**\n * App-only edge kinds stored in this same table alongside IGNIS's seven (e.g. `merchant_role`).\n * `ScopedCasbinAdapter` never selects an undeclared variant - it is purely the consumer's data.\n * Pass as an inline array literal; the `const` type parameter below infers the literal union\n * from it without needing `as const`.\n */\n extraVariants?: ReadonlyArray<ExtraVariant>;\n};\n"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { IConnectRpcModule } from '../../../../base/controllers/grpc/common/types.js';
|
|
2
2
|
export type { IConnectRpcModule };
|
|
3
|
+
/** Options of `GrpcComponent`, bound at `GrpcBindingKeys.GRPC_COMPONENT_OPTIONS`. */
|
|
3
4
|
export interface IGrpcComponentConfig {
|
|
4
5
|
interceptors?: unknown[];
|
|
5
6
|
/** The ConnectRPC peer, for a compiled binary that has no `node_modules` to resolve it from. */
|
|
6
7
|
module?: IConnectRpcModule;
|
|
7
8
|
}
|
|
9
|
+
/** Container keys of the gRPC component. */
|
|
8
10
|
export declare class GrpcBindingKeys {
|
|
9
11
|
static readonly GRPC_COMPONENT_OPTIONS = "@app/grpc/options";
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/components/controller/grpc/common/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/components/controller/grpc/common/types.ts"],"names":[],"mappings":"AAYA,4CAA4C;AAC5C,MAAM,OAAO,eAAe;aACV,2BAAsB,GAAG,mBAAmB,CAAC","sourcesContent":["import type { IConnectRpcModule } from '@/base/controllers/grpc/common/types';\n\n// Re-exported so an application can name the type without reaching into the base barrel.\nexport type { IConnectRpcModule };\n\n/** Options of `GrpcComponent`, bound at `GrpcBindingKeys.GRPC_COMPONENT_OPTIONS`. */\nexport interface IGrpcComponentConfig {\n interceptors?: unknown[];\n /** The ConnectRPC peer, for a compiled binary that has no `node_modules` to resolve it from. */\n module?: IConnectRpcModule;\n}\n\n/** Container keys of the gRPC component. */\nexport class GrpcBindingKeys {\n static readonly GRPC_COMPONENT_OPTIONS = '@app/grpc/options';\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BaseApplication } from '../../../base/applications/index.js';
|
|
2
2
|
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
3
|
+
/** Mounts every controller declared with the gRPC transport onto the root router at its metadata `path`, and hands each the `IGrpcComponentConfig` interceptors and ConnectRPC module. A gRPC controller without a service definition is skipped with a warning. */
|
|
3
4
|
export declare class GrpcComponent extends BaseComponent {
|
|
4
5
|
private application;
|
|
5
6
|
constructor(application: BaseApplication);
|
|
@@ -6,6 +6,7 @@ import { getError } from '@venizia/ignis-helpers/core';
|
|
|
6
6
|
import { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';
|
|
7
7
|
import { GrpcBindingKeys } from './common/types.js';
|
|
8
8
|
const DEFAULT_OPTIONS = {};
|
|
9
|
+
/** Mounts every controller declared with the gRPC transport onto the root router at its metadata `path`, and hands each the `IGrpcComponentConfig` interceptors and ConnectRPC module. A gRPC controller without a service definition is skipped with a warning. */
|
|
9
10
|
export class GrpcComponent extends BaseComponent {
|
|
10
11
|
constructor(application) {
|
|
11
12
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.component.js","sourceRoot":"","sources":["../../../../../src/components/controller/grpc/grpc.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,QAAQ,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;gBAClD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAE5B,MAAM,CAAC,IAAI,CAAC,iDAAiD,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7F,CAAC;YAED,iFAAiF;YACjF,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;gBACpC,GAAG,EAAE,iBAAiB,CAAC,UAAU;gBACjC,OAAO,EAAE,UAAU;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport type { AbstractGrpcController } from '@/base/controllers/grpc';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { Binding, BindingValueTypes, MetadataRegistry } from '@venizia/ignis-kernel';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport type { IGrpcComponentConfig } from './common/types';\nimport { GrpcBindingKeys } from './common/types';\n\nconst DEFAULT_OPTIONS: IGrpcComponentConfig = {};\n\n/** Mounts every controller declared with the gRPC transport onto the root router at its metadata `path`, and hands each the `IGrpcComponentConfig` interceptors and ConnectRPC module. A gRPC controller without a service definition is skipped with a warning. */\nexport class GrpcComponent extends BaseComponent {\n constructor(private application: BaseApplication) {\n super({\n scope: GrpcComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [GrpcBindingKeys.GRPC_COMPONENT_OPTIONS]: Binding.bind<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n override async binding(): Promise<void> {\n const logger = this.logger.for(this.binding.name);\n const router = this.application.getRootRouter();\n\n const options = this.application.get<IGrpcComponentConfig>({\n key: GrpcBindingKeys.GRPC_COMPONENT_OPTIONS,\n isOptional: true,\n });\n\n // Batch drained before re-scanning - see `RestApplication.registerDynamicBindings` for why.\n const configured = new Set<string>();\n\n let bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n\n while (bindings.length > 0) {\n for (const binding of bindings) {\n if (configured.has(binding.key)) {\n continue;\n }\n\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n\n if (!target) {\n configured.add(binding.key);\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n\n // Skip non-gRPC controllers — they are configured by RestComponent\n if (metadata?.transport !== ControllerTransports.GRPC) {\n configured.add(binding.key);\n continue;\n }\n\n if (!metadata?.path || ObjectUtility.isEmpty({ value: metadata.path })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] key: '${binding.key}' | Invalid controller metadata, 'path' is required for gRPC controller metadata`,\n });\n }\n\n const instance = this.application.get<AbstractGrpcController>({\n key: binding.key,\n isOptional: false,\n });\n\n if (!instance) {\n logger.debug('No binding instance | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n if (!instance.service) {\n logger.warn('gRPC controller has no service definition, skipping | key: %s', binding.key);\n configured.add(binding.key);\n continue;\n }\n\n instance.basePath = this.application.getProjectConfigs().path.base;\n instance.connectRpcModule = options?.module;\n instance.interceptors = options?.interceptors;\n await instance.configure();\n\n router.route(metadata.path, instance.getRouter());\n configured.add(binding.key);\n\n logger.info('Configured gRPC controller | key: %s | path: %s', binding.key, metadata.path);\n }\n\n // Re-fetch excluding already configured — picks up dynamically added controllers\n bindings = this.application.findByTag({\n tag: BindingNamespaces.CONTROLLER,\n exclude: configured,\n });\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAC7B,mGAAmG;aACnF,eAAU,GAAG,cAAc,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/constants.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,OAAO,kBAAkB;IAC7B,mGAAmG;aACnF,eAAU,GAAG,cAAc,CAAC","sourcesContent":["/** Request headers the health check controller reads. */\nexport class HealthCheckHeaders {\n /** Where a gated stats request carries its key; lowercase because Hono normalises header names. */\n static readonly SECRET_KEY = 'x-health-key';\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container keys of the health check component. */
|
|
1
2
|
export declare class HealthCheckBindingKeys {
|
|
2
3
|
static readonly HEALTH_CHECK_OPTIONS = "@app/health-check/options";
|
|
3
4
|
/** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sBAAsB;aACjB,yBAAoB,GAAG,2BAA2B,CAAC;IACnE,wGAAwG;aACxF,qBAAgB,GAAG,oCAAoC,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/keys.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,OAAO,sBAAsB;aACjB,yBAAoB,GAAG,2BAA2B,CAAC;IACnE,wGAAwG;aACxF,qBAAgB,GAAG,oCAAoC,CAAC","sourcesContent":["/** Container keys of the health check component. */\nexport class HealthCheckBindingKeys {\n static readonly HEALTH_CHECK_OPTIONS = '@app/health-check/options';\n /** The component resolves `getAppInfo()` once (it is async) and binds the result for the controller. */\n static readonly APPLICATION_INFO = '@app/health-check/application-info';\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/rest-paths.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,GAAG,CAAC;aACX,SAAI,GAAG,OAAO,CAAC;aACf,UAAK,GAAG,QAAQ,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"rest-paths.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/rest-paths.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,GAAG,CAAC;aACX,SAAI,GAAG,OAAO,CAAC;aACf,UAAK,GAAG,QAAQ,CAAC","sourcesContent":["/** Routes of the health check controller, relative to the configured base path. */\nexport class HealthCheckRestPaths {\n static readonly ROOT = '/';\n static readonly PING = '/ping';\n static readonly STATS = '/stats';\n}\n"]}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import type { IBuildInfo } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/**
|
|
3
|
+
* Options of `HealthCheckComponent`, bound at `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { HealthCheckBindingKeys, type BaseApplication, type IHealthCheckOptions } from '@venizia/ignis';
|
|
8
|
+
*
|
|
9
|
+
* export const bindHealth = (application: BaseApplication) => {
|
|
10
|
+
* application
|
|
11
|
+
* .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })
|
|
12
|
+
* .toValue({ restOptions: { path: '/status' }, stats: { secretKey: 'change-me' } });
|
|
13
|
+
* };
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
2
16
|
export interface IHealthCheckOptions {
|
|
3
17
|
/** Partially-filled bindings are accepted; every missing field falls back to its default. */
|
|
4
18
|
restOptions?: {
|
|
19
|
+
/**
|
|
20
|
+
* Base path the health routes mount under.
|
|
21
|
+
*
|
|
22
|
+
* @default '/health'
|
|
23
|
+
*/
|
|
5
24
|
path?: string;
|
|
6
25
|
};
|
|
7
26
|
/**
|
|
@@ -11,9 +30,11 @@ export interface IHealthCheckOptions {
|
|
|
11
30
|
*/
|
|
12
31
|
stats?: {
|
|
13
32
|
/**
|
|
14
|
-
*
|
|
15
|
-
* (`Environment.DEVELOPMENT_ENVS`)
|
|
16
|
-
* unset `NODE_ENV` all keep
|
|
33
|
+
* Whether the route is mounted. Left out, it is open only when `NODE_ENV` names a development
|
|
34
|
+
* environment (`Environment.DEVELOPMENT_ENVS`); `staging`, `uat`, `production`, an unrecognised
|
|
35
|
+
* name and an unset `NODE_ENV` all keep it closed.
|
|
36
|
+
*
|
|
37
|
+
* @default true in a development environment, false otherwise
|
|
17
38
|
*/
|
|
18
39
|
enable?: boolean;
|
|
19
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBuildInfo } from '@venizia/ignis-helpers/core';\n\nexport interface IHealthCheckOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: { path?: string
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/health-check/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IBuildInfo } from '@venizia/ignis-helpers/core';\n\n/**\n * Options of `HealthCheckComponent`, bound at `HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS`.\n *\n * @example\n * ```typescript\n * import { HealthCheckBindingKeys, type BaseApplication, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * export const bindHealth = (application: BaseApplication) => {\n * application\n * .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n * .toValue({ restOptions: { path: '/status' }, stats: { secretKey: 'change-me' } });\n * };\n * ```\n */\nexport interface IHealthCheckOptions {\n /** Partially-filled bindings are accepted; every missing field falls back to its default. */\n restOptions?: {\n /**\n * Base path the health routes mount under.\n *\n * @default '/health'\n */\n path?: string;\n };\n /**\n * `GET <path>/stats`: build stamp, process and memory. The runtime and version it reports are\n * exactly what an attacker needs to pick an exploit, so the default is CLOSED on every host that\n * is not provably a development one.\n */\n stats?: {\n /**\n * Whether the route is mounted. Left out, it is open only when `NODE_ENV` names a development\n * environment (`Environment.DEVELOPMENT_ENVS`); `staging`, `uat`, `production`, an unrecognised\n * name and an unset `NODE_ENV` all keep it closed.\n *\n * @default true in a development environment, false otherwise\n */\n enable?: boolean;\n /**\n * When set, the route answers only for a request carrying this value in `X-Health-Key`, and a\n * refusal is indistinguishable from an unmounted route. A blank value fails closed.\n * Without the field the route is open to anything that can reach the port.\n */\n secretKey?: string;\n /** Wins over {@link BuildInfoRegistry}; a host that stamps its own build passes it here. */\n buildInfo?: IBuildInfo;\n };\n}\n"]}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { type BaseApplication } from '../../base/applications/index.js';
|
|
2
2
|
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
3
3
|
import { type IHealthCheckOptions } from './common/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';
|
|
10
|
+
*
|
|
11
|
+
* abstract class App extends BaseApplication {
|
|
12
|
+
* preConfigure(): void {
|
|
13
|
+
* const options: IHealthCheckOptions = { restOptions: { path: '/status' } };
|
|
14
|
+
* this.component(HealthCheckComponent, { options });
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
4
19
|
export declare class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {
|
|
5
20
|
private application;
|
|
6
21
|
constructor(application: BaseApplication);
|
|
@@ -23,6 +23,21 @@ const DEFAULT_REST_PATH = '/health';
|
|
|
23
23
|
const DEFAULT_OPTIONS = {
|
|
24
24
|
restOptions: { path: DEFAULT_REST_PATH },
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';
|
|
32
|
+
*
|
|
33
|
+
* abstract class App extends BaseApplication {
|
|
34
|
+
* preConfigure(): void {
|
|
35
|
+
* const options: IHealthCheckOptions = { restOptions: { path: '/status' } };
|
|
36
|
+
* this.component(HealthCheckComponent, { options });
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
26
41
|
let HealthCheckComponent = HealthCheckComponent_1 = class HealthCheckComponent extends BaseComponent {
|
|
27
42
|
constructor(application) {
|
|
28
43
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/health-check/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAA4B,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,eAAe,GAAwB;IAC3C,WAAW,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;CACzC,CAAC;AAEF,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Aa,EAAE,CAAC,EAAE,CAAC;YACtF,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;iBACtB,IAAI,CACH,4NAA4N,EAC5N,IAAI,EACJ,WAAW,CAAC,OAAO,IAAI,OAAO,CAC/B,CAAC;QACN,CAAC;QAED,0FAA0F;QAC1F,2EAA2E;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAmB;YACtD,GAAG,EAAE,sBAAsB,CAAC,gBAAgB;SAC7C,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEzB,+FAA+F;QAC/F,8FAA8F;QAC9F,2FAA2F;QAC3F,6FAA6F;QAC7F,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AAzEY,oBAAoB;IAE5B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,oBAAoB,CAyEhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { controller, inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { HealthCheckBindingKeys, type IHealthCheckOptions } from './common';\nimport { HealthCheckController } from './controller';\nimport { HealthCheckReporter } from './reporter';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { Binding } from '@venizia/ignis-kernel';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\n\nconst DEFAULT_REST_PATH = '/health';\nconst DEFAULT_OPTIONS: IHealthCheckOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\nexport class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: HealthCheckComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS]: Binding.bind<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /**\n * `application.component(HealthCheckComponent, { options })` lands here. Options given at the\n * call site are the most explicit statement of intent, so they take the binding over anything\n * bound earlier; `initDefaultBindings` then finds the key taken and leaves the default aside.\n */\n override async configure(opts?: IHealthCheckOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application\n .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n .toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override async binding(): Promise<void> {\n const healthOptions = this.application.get<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = healthOptions?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // Legal, occasionally correct, and silent until now: `stats.enable: true` bypasses the\n // environment gate, so the same code that opened the route for a local run opens it in\n // production. Warn rather than refuse - only the operator knows whether the port is reachable.\n if (healthOptions && HealthCheckReporter.isStatsUnguarded({ options: healthOptions })) {\n this.logger\n .for(this.binding.name)\n .warn(\n 'GET %s/stats is ENABLED with no secretKey on env \"%s\" - build stamp, runtime version and memory are readable by anything that reaches this port. Set stats.secretKey, or drop stats.enable and let the environment decide.',\n path,\n Environment.ambient ?? 'unset',\n );\n }\n\n // `getAppInfo()` is async while the container builds the controller synchronously, so the\n // resolved value is bound here rather than resolved inside the controller.\n const binding = this.application.bind<IApplicationInfo>({\n key: HealthCheckBindingKeys.APPLICATION_INFO,\n });\n const appInfo = await this.application.getAppInfo();\n binding.toValue(appInfo);\n\n // The gate and the app identity are per container, but `@controller` writes the PATH onto this\n // one shared class in the process-wide MetadataRegistry, and `RestComponent` reads it back at\n // step 8. Two applications booted one after another are safe; two booted CONCURRENTLY with\n // different `restOptions.path` would race here, and nothing in this component prevents that.\n Reflect.decorate([controller({ path })], HealthCheckController);\n this.application.controller(HealthCheckController);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/health-check/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAA4B,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,eAAe,GAAwB;IAC3C,WAAW,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;CACzC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,IAAa,oBAAoB,4BAAjC,MAAa,oBAAqB,SAAQ,aAAkC;IAC1E,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,sBAAoB,CAAC,IAAI;YAChC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,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ED,0FAA0F;QAC1F,2EAA2E;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAmB;YACtD,GAAG,EAAE,sBAAsB,CAAC,gBAAgB;SAC7C,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEzB,+FAA+F;QAC/F,8FAA8F;QAC9F,2FAA2F;QAC3F,6FAA6F;QAC7F,OAAO,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AAzEY,oBAAoB;IAE5B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,oBAAoB,CAyEhC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { BaseComponent } from '@venizia/ignis-kernel';\nimport { controller, inject } from '@/base/metadata';\nimport { CoreBindings } from '@venizia/ignis-kernel';\nimport { HealthCheckBindingKeys, type IHealthCheckOptions } from './common';\nimport { HealthCheckController } from './controller';\nimport { HealthCheckReporter } from './reporter';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { Binding } from '@venizia/ignis-kernel';\nimport type { IApplicationInfo } from '@venizia/ignis-kernel';\n\nconst DEFAULT_REST_PATH = '/health';\nconst DEFAULT_OPTIONS: IHealthCheckOptions = {\n restOptions: { path: DEFAULT_REST_PATH },\n};\n\n/**\n * Mounts the health check controller (liveness root, `/ping`, and the gated `/stats`).\n *\n * @example\n * ```typescript\n * import { BaseApplication, HealthCheckComponent, type IHealthCheckOptions } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * const options: IHealthCheckOptions = { restOptions: { path: '/status' } };\n * this.component(HealthCheckComponent, { options });\n * }\n * }\n * ```\n */\nexport class HealthCheckComponent extends BaseComponent<IHealthCheckOptions> {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: HealthCheckComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS]: Binding.bind<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n }).toValue(DEFAULT_OPTIONS),\n },\n });\n }\n\n /**\n * `application.component(HealthCheckComponent, { options })` lands here. Options given at the\n * call site are the most explicit statement of intent, so they take the binding over anything\n * bound earlier; `initDefaultBindings` then finds the key taken and leaves the default aside.\n */\n override async configure(opts?: IHealthCheckOptions): Promise<void> {\n // The base short-circuits a second call; binding before that check would swap the options\n // under routes that were already mounted from the first ones.\n if (this.isConfigured) {\n return;\n }\n\n if (opts !== undefined) {\n this.application\n .bind<IHealthCheckOptions>({ key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS })\n .toValue(opts);\n }\n\n await super.configure(opts);\n }\n\n override async binding(): Promise<void> {\n const healthOptions = this.application.get<IHealthCheckOptions>({\n key: HealthCheckBindingKeys.HEALTH_CHECK_OPTIONS,\n isOptional: true,\n });\n\n // A partially filled options binding (env/config driven) must not take the app down at boot.\n const path = healthOptions?.restOptions?.path ?? DEFAULT_REST_PATH;\n\n // Legal, occasionally correct, and silent until now: `stats.enable: true` bypasses the\n // environment gate, so the same code that opened the route for a local run opens it in\n // production. Warn rather than refuse - only the operator knows whether the port is reachable.\n if (healthOptions && HealthCheckReporter.isStatsUnguarded({ options: healthOptions })) {\n this.logger\n .for(this.binding.name)\n .warn(\n 'GET %s/stats is ENABLED with no secretKey on env \"%s\" - build stamp, runtime version and memory are readable by anything that reaches this port. Set stats.secretKey, or drop stats.enable and let the environment decide.',\n path,\n Environment.ambient ?? 'unset',\n );\n }\n\n // `getAppInfo()` is async while the container builds the controller synchronously, so the\n // resolved value is bound here rather than resolved inside the controller.\n const binding = this.application.bind<IApplicationInfo>({\n key: HealthCheckBindingKeys.APPLICATION_INFO,\n });\n const appInfo = await this.application.getAppInfo();\n binding.toValue(appInfo);\n\n // The gate and the app identity are per container, but `@controller` writes the PATH onto this\n // one shared class in the process-wide MetadataRegistry, and `RestComponent` reads it back at\n // step 8. Two applications booted one after another are safe; two booted CONCURRENTLY with\n // different `restOptions.path` would race here, and nothing in this component prevents that.\n Reflect.decorate([controller({ path })], HealthCheckController);\n this.application.controller(HealthCheckController);\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { BaseRestController, type TRouteContext } from '../../base/controllers/i
|
|
|
2
2
|
import type { IApplicationInfo } from '@venizia/ignis-kernel';
|
|
3
3
|
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
4
4
|
import { type IHealthCheckOptions } from './common/index.js';
|
|
5
|
+
/** Serves the health routes: the root summary and `/ping` always, `/stats` only when `IHealthCheckOptions.stats` allows it and the request is authorized. */
|
|
5
6
|
export declare class HealthCheckController extends BaseRestController {
|
|
6
7
|
private readonly healthOptions;
|
|
7
8
|
private readonly appInfo?;
|
|
@@ -92,6 +92,7 @@ const RouteConfigs = {
|
|
|
92
92
|
}),
|
|
93
93
|
},
|
|
94
94
|
};
|
|
95
|
+
/** Serves the health routes: the root summary and `/ping` always, `/stats` only when `IHealthCheckOptions.stats` allows it and the request is authorized. */
|
|
95
96
|
let HealthCheckController = HealthCheckController_1 = class HealthCheckController extends BaseRestController {
|
|
96
97
|
/**
|
|
97
98
|
* Both dependencies arrive through the container, so two applications in one process each get
|