@venizia/ignis-kernel 0.4.8-0 → 0.4.8-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/esm/base/applications/abstract.d.ts +1 -0
- package/dist/esm/base/applications/abstract.js +1 -0
- package/dist/esm/base/applications/abstract.js.map +1 -1
- package/dist/esm/base/applications/boot-sequence.d.ts +2 -0
- package/dist/esm/base/applications/boot-sequence.js.map +1 -1
- package/dist/esm/base/applications/common/constants.d.ts +2 -0
- package/dist/esm/base/applications/common/constants.js +1 -0
- package/dist/esm/base/applications/common/constants.js.map +1 -1
- package/dist/esm/base/applications/common/types/application.d.ts +30 -8
- package/dist/esm/base/applications/common/types/application.js.map +1 -1
- package/dist/esm/base/applications/common/types/middlewares.d.ts +16 -1
- package/dist/esm/base/applications/common/types/middlewares.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/codecs.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/common/codecs.js +1 -0
- package/dist/esm/base/auth/authenticate/common/codecs.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/constants/authentication.d.ts +6 -0
- package/dist/esm/base/auth/authenticate/common/constants/authentication.js +4 -0
- package/dist/esm/base/auth/authenticate/common/constants/authentication.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/constants/jose.d.ts +8 -0
- package/dist/esm/base/auth/authenticate/common/constants/jose.js +4 -0
- package/dist/esm/base/auth/authenticate/common/constants/jose.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/keys.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/common/keys.js +1 -0
- package/dist/esm/base/auth/authenticate/common/keys.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/basic.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/common/types/basic.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts +42 -0
- package/dist/esm/base/auth/authenticate/common/types/jwt.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/rest.d.ts +2 -0
- package/dist/esm/base/auth/authenticate/common/types/rest.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/service.d.ts +10 -1
- package/dist/esm/base/auth/authenticate/common/types/service.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/strategy.d.ts +5 -0
- package/dist/esm/base/auth/authenticate/common/types/strategy.js.map +1 -1
- package/dist/esm/base/auth/authenticate/middlewares/authenticate.middleware.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/middlewares/authenticate.middleware.js +1 -0
- package/dist/esm/base/auth/authenticate/middlewares/authenticate.middleware.js.map +1 -1
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.d.ts +5 -0
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.js +5 -0
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.js.map +1 -1
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js +1 -0
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
- package/dist/esm/base/auth/authorize/builders/grant.builder.d.ts +1 -0
- package/dist/esm/base/auth/authorize/builders/grant.builder.js +1 -0
- package/dist/esm/base/auth/authorize/builders/grant.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/builders/policy.builder.d.ts +1 -0
- package/dist/esm/base/auth/authorize/builders/policy.builder.js +1 -0
- package/dist/esm/base/auth/authorize/builders/policy.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts +8 -0
- package/dist/esm/base/auth/authorize/common/constants/authorization.js +5 -0
- package/dist/esm/base/auth/authorize/common/constants/authorization.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/binding-keys.d.ts +1 -0
- package/dist/esm/base/auth/authorize/common/constants/binding-keys.js +1 -0
- package/dist/esm/base/auth/authorize/common/constants/binding-keys.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/enforcer.d.ts +9 -0
- package/dist/esm/base/auth/authorize/common/constants/enforcer.js +4 -0
- package/dist/esm/base/auth/authorize/common/constants/enforcer.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/enforcer.d.ts +21 -3
- package/dist/esm/base/auth/authorize/common/types/enforcer.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/grant.d.ts +1 -0
- package/dist/esm/base/auth/authorize/common/types/grant.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/request.d.ts +3 -0
- package/dist/esm/base/auth/authorize/common/types/request.js.map +1 -1
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.d.ts +1 -0
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js +1 -0
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
- package/dist/esm/base/auth/authorize/middlewares/authorize.middleware.d.ts +1 -0
- package/dist/esm/base/auth/authorize/middlewares/authorize.middleware.js +1 -0
- package/dist/esm/base/auth/authorize/middlewares/authorize.middleware.js.map +1 -1
- package/dist/esm/base/auth/authorize/models/authorization-role.model.d.ts +6 -0
- package/dist/esm/base/auth/authorize/models/authorization-role.model.js +1 -0
- package/dist/esm/base/auth/authorize/models/authorization-role.model.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/authorization.provider.d.ts +1 -0
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js +1 -0
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js.map +1 -1
- package/dist/esm/base/auth/base/abstract-auth-registry.d.ts +2 -0
- package/dist/esm/base/auth/base/abstract-auth-registry.js +1 -0
- package/dist/esm/base/auth/base/abstract-auth-registry.js.map +1 -1
- package/dist/esm/base/auth/models/requests/change-password.schema.d.ts +2 -0
- package/dist/esm/base/auth/models/requests/change-password.schema.js +1 -0
- package/dist/esm/base/auth/models/requests/change-password.schema.js.map +1 -1
- package/dist/esm/base/auth/models/requests/sign-in.schema.d.ts +2 -0
- package/dist/esm/base/auth/models/requests/sign-in.schema.js +1 -0
- package/dist/esm/base/auth/models/requests/sign-in.schema.js.map +1 -1
- package/dist/esm/base/auth/models/requests/sign-up.schema.d.ts +2 -0
- package/dist/esm/base/auth/models/requests/sign-up.schema.js +1 -0
- package/dist/esm/base/auth/models/requests/sign-up.schema.js.map +1 -1
- package/dist/esm/base/components/base.d.ts +1 -0
- package/dist/esm/base/components/base.js +1 -0
- package/dist/esm/base/components/base.js.map +1 -1
- package/dist/esm/base/components/controller/rest/common/types.d.ts +2 -0
- package/dist/esm/base/components/controller/rest/common/types.js +1 -0
- package/dist/esm/base/components/controller/rest/common/types.js.map +1 -1
- package/dist/esm/base/configurations/base.d.ts +1 -0
- package/dist/esm/base/configurations/base.js +1 -0
- package/dist/esm/base/configurations/base.js.map +1 -1
- package/dist/esm/base/configurations/common/types.d.ts +1 -0
- package/dist/esm/base/configurations/common/types.js.map +1 -1
- package/dist/esm/base/controllers/common/constants.d.ts +4 -0
- package/dist/esm/base/controllers/common/constants.js +2 -0
- package/dist/esm/base/controllers/common/constants.js.map +1 -1
- package/dist/esm/base/controllers/common/schema-builders.d.ts +3 -0
- package/dist/esm/base/controllers/common/schema-builders.js +1 -0
- package/dist/esm/base/controllers/common/schema-builders.js.map +1 -1
- package/dist/esm/base/controllers/common/schemas.d.ts +2 -0
- package/dist/esm/base/controllers/common/schemas.js +2 -0
- package/dist/esm/base/controllers/common/schemas.js.map +1 -1
- package/dist/esm/base/controllers/common/types/context.d.ts +2 -0
- package/dist/esm/base/controllers/common/types/context.js.map +1 -1
- package/dist/esm/base/controllers/common/types/controller.d.ts +5 -1
- package/dist/esm/base/controllers/common/types/controller.js.map +1 -1
- package/dist/esm/base/controllers/common/types/route.d.ts +7 -1
- package/dist/esm/base/controllers/common/types/route.js.map +1 -1
- package/dist/esm/base/datasources/common/types.d.ts +5 -0
- package/dist/esm/base/datasources/common/types.js +1 -0
- package/dist/esm/base/datasources/common/types.js.map +1 -1
- package/dist/esm/base/events/common/constants.d.ts +4 -0
- package/dist/esm/base/events/common/constants.js +3 -0
- package/dist/esm/base/events/common/constants.js.map +1 -1
- package/dist/esm/base/events/common/types.d.ts +10 -2
- package/dist/esm/base/events/common/types.js.map +1 -1
- package/dist/esm/base/metadata/injectable.d.ts +46 -0
- package/dist/esm/base/metadata/injectable.js +46 -0
- package/dist/esm/base/metadata/injectable.js.map +1 -1
- package/dist/esm/base/metadata/persistents.d.ts +47 -2
- package/dist/esm/base/metadata/persistents.js +47 -2
- package/dist/esm/base/metadata/persistents.js.map +1 -1
- package/dist/esm/base/metadata/routes/controller.d.ts +17 -0
- package/dist/esm/base/metadata/routes/controller.js +17 -0
- package/dist/esm/base/metadata/routes/controller.js.map +1 -1
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts +1 -0
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js +1 -0
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -1
- package/dist/esm/base/middlewares/not-found/not-found.middleware.d.ts +1 -0
- package/dist/esm/base/middlewares/not-found/not-found.middleware.js +1 -0
- package/dist/esm/base/middlewares/not-found/not-found.middleware.js.map +1 -1
- package/dist/esm/base/mixins/common/types.d.ts +14 -1
- package/dist/esm/base/mixins/common/types.js.map +1 -1
- package/dist/esm/base/models/common/constants.d.ts +2 -0
- package/dist/esm/base/models/common/constants.js +1 -0
- package/dist/esm/base/models/common/constants.js.map +1 -1
- package/dist/esm/base/models/common/schemas.d.ts +1 -0
- package/dist/esm/base/models/common/schemas.js.map +1 -1
- package/dist/esm/base/models/common/types/id.d.ts +4 -0
- package/dist/esm/base/models/common/types/id.js.map +1 -1
- package/dist/esm/base/providers/base.d.ts +1 -0
- package/dist/esm/base/providers/base.js +1 -0
- package/dist/esm/base/providers/base.js.map +1 -1
- package/dist/esm/base/repositories/common/constants.d.ts +2 -2
- package/dist/esm/base/repositories/common/constants.js +2 -2
- package/dist/esm/base/repositories/common/constants.js.map +1 -1
- package/dist/esm/base/repositories/common/scope-through.d.ts +18 -1
- package/dist/esm/base/repositories/common/scope-through.js +18 -1
- package/dist/esm/base/repositories/common/scope-through.js.map +1 -1
- package/dist/esm/base/repositories/common/types/options.d.ts +10 -4
- package/dist/esm/base/repositories/common/types/options.js.map +1 -1
- package/dist/esm/base/repositories/query-schemas/index.d.ts +18 -3
- package/dist/esm/base/repositories/query-schemas/index.js +17 -1
- package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
- package/dist/esm/base/request-context/registry.d.ts +1 -0
- package/dist/esm/base/request-context/registry.js +1 -0
- package/dist/esm/base/request-context/registry.js.map +1 -1
- package/dist/esm/base/services/base.d.ts +1 -0
- package/dist/esm/base/services/base.js +1 -0
- package/dist/esm/base/services/base.js.map +1 -1
- package/dist/esm/base/services/common/types.d.ts +1 -0
- package/dist/esm/base/services/common/types.js.map +1 -1
- package/dist/esm/common/bindings.d.ts +1 -0
- package/dist/esm/common/bindings.js.map +1 -1
- package/dist/esm/common/error-codes.d.ts +2 -0
- package/dist/esm/common/error-codes.js.map +1 -1
- package/dist/esm/helpers/inversion/common/keys.d.ts +1 -0
- package/dist/esm/helpers/inversion/common/keys.js +1 -0
- package/dist/esm/helpers/inversion/common/keys.js.map +1 -1
- package/dist/esm/helpers/inversion/common/relation-builder.d.ts +1 -0
- package/dist/esm/helpers/inversion/common/relation-builder.js +1 -0
- package/dist/esm/helpers/inversion/common/relation-builder.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/artifact.d.ts +9 -2
- package/dist/esm/helpers/inversion/common/types/artifact.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/controller.d.ts +4 -0
- package/dist/esm/helpers/inversion/common/types/controller.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.d.ts +80 -8
- package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/persistence.d.ts +9 -1
- package/dist/esm/helpers/inversion/common/types/persistence.js.map +1 -1
- package/dist/esm/helpers/inversion/container.d.ts +1 -0
- package/dist/esm/helpers/inversion/container.js +1 -0
- package/dist/esm/helpers/inversion/container.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { IAuthorizationRole } from '../common/index.js';
|
|
2
|
+
/** Role with a numeric priority. `identifier` is the zero-padded (3 digits) priority joined to the name by `delimiter`, e.g. `010_user`. */
|
|
2
3
|
export declare class AuthorizationRole implements IAuthorizationRole {
|
|
3
4
|
readonly name: string;
|
|
4
5
|
readonly priority: number;
|
|
6
|
+
/**
|
|
7
|
+
* Joins the padded priority to the name in `identifier`.
|
|
8
|
+
*
|
|
9
|
+
* @default '_'
|
|
10
|
+
*/
|
|
5
11
|
readonly delimiter: string;
|
|
6
12
|
static build(opts: {
|
|
7
13
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-role.model.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/models/authorization-role.model.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;
|
|
1
|
+
{"version":3,"file":"authorization-role.model.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/models/authorization-role.model.ts"],"names":[],"mappings":"AAEA,4IAA4I;AAC5I,MAAM,OAAO,iBAAiB;IAW5B,MAAM,CAAC,KAAK,CAAC,IAA4D;QACvE,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,YAAY,IAA4D;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC;IACzC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,CAAC,IAAoC;QAC1C,OAAO,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAED,YAAY,CAAC,IAAoC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,WAAW,CAAC,IAAoC;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,IAAoC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type { IAuthorizationRole } from '../common';\n\n/** Role with a numeric priority. `identifier` is the zero-padded (3 digits) priority joined to the name by `delimiter`, e.g. `010_user`. */\nexport class AuthorizationRole implements IAuthorizationRole {\n readonly name: string;\n readonly priority: number;\n\n /**\n * Joins the padded priority to the name in `identifier`.\n *\n * @default '_'\n */\n readonly delimiter: string;\n\n static build(opts: { name: string; priority: number; delimiter?: string }): AuthorizationRole {\n return new AuthorizationRole(opts);\n }\n\n constructor(opts: { name: string; priority: number; delimiter?: string }) {\n this.name = opts.name;\n this.priority = opts.priority;\n this.delimiter = opts.delimiter ?? '_';\n }\n\n get identifier(): string {\n return [String(this.priority).padStart(3, '0'), this.name].join(this.delimiter);\n }\n\n compare(opts: { target: IAuthorizationRole }): number {\n return this.priority - opts.target.priority;\n }\n\n isHigherThan(opts: { target: IAuthorizationRole }): boolean {\n return this.compare(opts) > 0;\n }\n\n isLowerThan(opts: { target: IAuthorizationRole }): boolean {\n return this.compare(opts) < 0;\n }\n\n isEqualTo(opts: { target: IAuthorizationRole }): boolean {\n return this.compare(opts) === 0;\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
2
2
|
import type { IProvider } from '@venizia/ignis-inversion';
|
|
3
3
|
import type { TAuthorizeFn } from '../common/index.js';
|
|
4
|
+
/** Provides the `TAuthorizeFn` that builds the per-route authorization middleware: skip flag, always-allow and allowed roles, voters, then the enforcer decision. */
|
|
4
5
|
export declare class AuthorizationProvider extends BaseHelper implements IProvider<TAuthorizeFn> {
|
|
5
6
|
constructor();
|
|
6
7
|
value(): TAuthorizeFn;
|
|
@@ -6,6 +6,7 @@ import { Authentication } from '../../authenticate/common/constants/index.js';
|
|
|
6
6
|
import { Authorization, AuthorizationDecisions, AuthorizationErrors } from '../common/index.js';
|
|
7
7
|
import { AuthorizationEnforcerRegistry } from '../enforcers/enforcer-registry.js';
|
|
8
8
|
import { RequestDomainResolver } from './request-domain.js';
|
|
9
|
+
/** Provides the `TAuthorizeFn` that builds the per-route authorization middleware: skip flag, always-allow and allowed roles, voters, then the enforcer decision. */
|
|
9
10
|
export class AuthorizationProvider extends BaseHelper {
|
|
10
11
|
constructor() {
|
|
11
12
|
super({ scope: AuthorizationProvider.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.provider.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/providers/authorization.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,iMAAiM;AACjM,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,OAA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ACL,CAAC;CACF","sourcesContent":["import { ContextUtility } from '@/base/controllers/context';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { IProvider } from '@venizia/ignis-inversion';\nimport { createMiddleware } from 'hono/factory';\nimport type { IAuthUser } from '../../authenticate/common/types';\n// Deep import (not the authenticate barrel): the barrel re-exports ./controllers, whose factory extends BaseRestController - a value import here forms the base/controllers <-> auth init cycle.\nimport { Authentication } from '../../authenticate/common/constants';\nimport type { IAuthorizationSpec, TAuthorizeFn } from '../common';\nimport { Authorization, AuthorizationDecisions, AuthorizationErrors } from '../common';\nimport { AuthorizationEnforcerRegistry } from '../enforcers/enforcer-registry';\nimport { RequestDomainResolver } from './request-domain';\n\nexport class AuthorizationProvider extends BaseHelper implements IProvider<TAuthorizeFn> {\n constructor() {\n super({ scope: AuthorizationProvider.name });\n }\n\n value(): TAuthorizeFn {\n return (opts) => {\n return this.createAuthorizeMiddleware(opts);\n };\n }\n\n private createAuthorizeMiddleware(opts: { spec: IAuthorizationSpec; enforcerName?: string }) {\n const { spec, enforcerName } = opts;\n const logger = this.logger.for(this.createAuthorizeMiddleware.name);\n\n return createMiddleware(async (context, next) => {\n const registry = AuthorizationEnforcerRegistry.getInstance();\n const options = registry.resolveOptions();\n\n const isSkipAuthorize = context.get(Authorization.SKIP_AUTHORIZATION);\n\n if (isSkipAuthorize) {\n logger.warn('SKIP checking authorization | path: %s', context.req.path);\n\n return next();\n }\n\n const user = context.get(Authentication.CURRENT_USER) as IAuthUser | undefined;\n\n if (!user) {\n throw getError({\n error: AuthorizationErrors.UNAUTHENTICATED,\n message: 'Authorization failed: No authenticated user found',\n });\n }\n\n const needsRoleCheck =\n Boolean(options?.alwaysAllowRoles?.length) || Boolean(spec.allowedRoles?.length);\n\n if (needsRoleCheck) {\n const userRoles = this.extractUserRoles({ user });\n\n if (\n options?.alwaysAllowRoles?.length &&\n userRoles.some((r) => options.alwaysAllowRoles!.includes(r))\n ) {\n logger.warn(\n 'SKIP checking authorization | User has always-allow role | userRoles: %s',\n userRoles,\n );\n\n return next();\n }\n\n if (spec.allowedRoles?.length && userRoles.some((r) => spec.allowedRoles!.includes(r))) {\n logger.warn('GRANT access | User has allowed role for route | userRoles: %s', userRoles);\n\n return next();\n }\n }\n\n const votersList = spec.voters ?? [];\n\n for (const voter of votersList) {\n const decision = await voter({\n user,\n action: spec.action,\n resource: spec.resource,\n context: ContextUtility.asTypedContext({ context }),\n });\n\n if (decision === AuthorizationDecisions.DENY) {\n throw getError({\n error: AuthorizationErrors.DENIED_BY_VOTER,\n message: `Authorization denied by voter | action: ${spec.action} | resource: ${spec.resource}`,\n messageArgs: { action: spec.action, resource: spec.resource },\n });\n }\n\n if (decision === AuthorizationDecisions.ALLOW) {\n await next();\n\n return;\n }\n\n // ABSTAIN → continue to enforcer\n }\n\n if (!registry.hasEnforcers()) {\n const noEnforcerDecision = options?.defaultDecision ?? AuthorizationDecisions.DENY;\n\n if (noEnforcerDecision === AuthorizationDecisions.ALLOW) {\n logger.warn(\n 'ALLOW checking authorization | No enforcers registered | path: %s',\n context.req.path,\n );\n\n return next();\n }\n\n throw getError({\n error: AuthorizationErrors.ENFORCER_NOT_REGISTERED,\n message: `Authorization failed: authorize() was declared for this route but no enforcer is registered | path: ${context.req.path}`,\n });\n }\n\n const resolvedName = enforcerName ?? registry.getDefaultEnforcerName();\n const enforcer = await registry.resolveEnforcer({ name: resolvedName });\n\n // Only resolve domain scope when it is actually in play (per-route domain OR a configured global resolver) - avoids a resolver call (possible DB hit) for legacy enforcers.\n //\n // Held in a LOCAL, not read back out of the context. One middleware is pushed per spec onto\n // the same Hono context, so reading `Authorization.DOMAIN` at decision time meant a\n // domain-less spec inherited the tenant domain a PREVIOUS spec had written - silently\n // widening a check that should have run at SYSTEM_WIDE. The context is still set, for\n // observability, but nothing decides on it.\n let domainScope: string | undefined;\n\n if (spec.domain || options?.domainResolver) {\n const resolvedDomain = await RequestDomainResolver.resolveRequestDomain({\n spec,\n context: ContextUtility.asTypedContext({ context }),\n options,\n });\n domainScope = resolvedDomain;\n }\n\n context.set(Authorization.DOMAIN, domainScope);\n\n // Keyed by enforcer. The slot used to hold one rule set for the whole request, so a second\n // `authorize()` naming a DIFFERENT enforcer evaluated against the first enforcer's rules -\n // granting where its own policy set denies.\n //\n // `instanceof Map`, not a truthiness test: the slot previously held a bare rule set, so\n // anything that pre-populates it with the old shape would otherwise reach `.get` on a value\n // that has no such method and take the request down with a TypeError.\n const existingRules = context.get(Authorization.RULES);\n const rulesByEnforcer =\n existingRules instanceof Map ? existingRules : new Map<string, unknown>();\n let rules = rulesByEnforcer.get(resolvedName);\n\n if (!rules) {\n if (!user.principalType) {\n throw getError({\n error: AuthorizationErrors.PRINCIPAL_TYPE_MISSING,\n message:\n 'Authorization failed: user.principalType is required for enforcer-based authorization',\n });\n }\n\n const result = await enforcer.buildRules({\n user: user as { principalType: string } & IAuthUser,\n context: ContextUtility.asTypedContext({ context }),\n });\n rules = result;\n rulesByEnforcer.set(resolvedName, rules);\n context.set(Authorization.RULES, rulesByEnforcer);\n }\n\n let decision = await enforcer.evaluate({\n rules,\n request: {\n action: spec.action,\n resource: spec.resource,\n conditions: spec.conditions,\n domain: domainScope,\n },\n context: ContextUtility.asTypedContext({ context }),\n });\n\n if (decision === AuthorizationDecisions.ABSTAIN) {\n decision = options?.defaultDecision ?? AuthorizationDecisions.DENY;\n }\n\n if (decision !== AuthorizationDecisions.ALLOW) {\n throw getError({\n error: AuthorizationErrors.DENIED,\n message: `Authorization denied | action: ${spec.action} | resource: ${spec.resource}`,\n messageArgs: { action: spec.action, resource: spec.resource },\n });\n }\n\n await next();\n });\n }\n\n private extractUserRoles(opts: { user: IAuthUser }): string[] {\n const { user } = opts;\n const roles = user.roles;\n\n if (!Array.isArray(roles)) {\n return [];\n }\n\n return roles.map((r: string | { identifier?: string; name?: string; id?: unknown }) => {\n if (typeof r === 'string') {\n return r;\n }\n\n return r.identifier ?? r.name ?? String(r.id ?? '');\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"authorization.provider.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/providers/authorization.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,iMAAiM;AACjM,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,qKAAqK;AACrK,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IACnD;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,EAAE,EAAE;YACd,OAAO,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC;IACJ,CAAC;IAEO,yBAAyB,CAAC,IAAyD;QACzF,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAEpE,OAAO,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YAC9C,MAAM,QAAQ,GAAG,6BAA6B,CAAC,WAAW,EAAE,CAAC;YAC7D,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;YAE1C,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,C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;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,gBAAgB,CAAC,IAAyB;QAChD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAEzB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAgE,EAAE,EAAE;YACpF,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO,CAAC,CAAC;YACX,CAAC;YAED,OAAO,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ContextUtility } from '@/base/controllers/context';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { IProvider } from '@venizia/ignis-inversion';\nimport { createMiddleware } from 'hono/factory';\nimport type { IAuthUser } from '../../authenticate/common/types';\n// Deep import (not the authenticate barrel): the barrel re-exports ./controllers, whose factory extends BaseRestController - a value import here forms the base/controllers <-> auth init cycle.\nimport { Authentication } from '../../authenticate/common/constants';\nimport type { IAuthorizationSpec, TAuthorizeFn } from '../common';\nimport { Authorization, AuthorizationDecisions, AuthorizationErrors } from '../common';\nimport { AuthorizationEnforcerRegistry } from '../enforcers/enforcer-registry';\nimport { RequestDomainResolver } from './request-domain';\n\n/** Provides the `TAuthorizeFn` that builds the per-route authorization middleware: skip flag, always-allow and allowed roles, voters, then the enforcer decision. */\nexport class AuthorizationProvider extends BaseHelper implements IProvider<TAuthorizeFn> {\n constructor() {\n super({ scope: AuthorizationProvider.name });\n }\n\n value(): TAuthorizeFn {\n return (opts) => {\n return this.createAuthorizeMiddleware(opts);\n };\n }\n\n private createAuthorizeMiddleware(opts: { spec: IAuthorizationSpec; enforcerName?: string }) {\n const { spec, enforcerName } = opts;\n const logger = this.logger.for(this.createAuthorizeMiddleware.name);\n\n return createMiddleware(async (context, next) => {\n const registry = AuthorizationEnforcerRegistry.getInstance();\n const options = registry.resolveOptions();\n\n const isSkipAuthorize = context.get(Authorization.SKIP_AUTHORIZATION);\n\n if (isSkipAuthorize) {\n logger.warn('SKIP checking authorization | path: %s', context.req.path);\n\n return next();\n }\n\n const user = context.get(Authentication.CURRENT_USER) as IAuthUser | undefined;\n\n if (!user) {\n throw getError({\n error: AuthorizationErrors.UNAUTHENTICATED,\n message: 'Authorization failed: No authenticated user found',\n });\n }\n\n const needsRoleCheck =\n Boolean(options?.alwaysAllowRoles?.length) || Boolean(spec.allowedRoles?.length);\n\n if (needsRoleCheck) {\n const userRoles = this.extractUserRoles({ user });\n\n if (\n options?.alwaysAllowRoles?.length &&\n userRoles.some((r) => options.alwaysAllowRoles!.includes(r))\n ) {\n logger.warn(\n 'SKIP checking authorization | User has always-allow role | userRoles: %s',\n userRoles,\n );\n\n return next();\n }\n\n if (spec.allowedRoles?.length && userRoles.some((r) => spec.allowedRoles!.includes(r))) {\n logger.warn('GRANT access | User has allowed role for route | userRoles: %s', userRoles);\n\n return next();\n }\n }\n\n const votersList = spec.voters ?? [];\n\n for (const voter of votersList) {\n const decision = await voter({\n user,\n action: spec.action,\n resource: spec.resource,\n context: ContextUtility.asTypedContext({ context }),\n });\n\n if (decision === AuthorizationDecisions.DENY) {\n throw getError({\n error: AuthorizationErrors.DENIED_BY_VOTER,\n message: `Authorization denied by voter | action: ${spec.action} | resource: ${spec.resource}`,\n messageArgs: { action: spec.action, resource: spec.resource },\n });\n }\n\n if (decision === AuthorizationDecisions.ALLOW) {\n await next();\n\n return;\n }\n\n // ABSTAIN → continue to enforcer\n }\n\n if (!registry.hasEnforcers()) {\n const noEnforcerDecision = options?.defaultDecision ?? AuthorizationDecisions.DENY;\n\n if (noEnforcerDecision === AuthorizationDecisions.ALLOW) {\n logger.warn(\n 'ALLOW checking authorization | No enforcers registered | path: %s',\n context.req.path,\n );\n\n return next();\n }\n\n throw getError({\n error: AuthorizationErrors.ENFORCER_NOT_REGISTERED,\n message: `Authorization failed: authorize() was declared for this route but no enforcer is registered | path: ${context.req.path}`,\n });\n }\n\n const resolvedName = enforcerName ?? registry.getDefaultEnforcerName();\n const enforcer = await registry.resolveEnforcer({ name: resolvedName });\n\n // Only resolve domain scope when it is actually in play (per-route domain OR a configured global resolver) - avoids a resolver call (possible DB hit) for legacy enforcers.\n //\n // Held in a LOCAL, not read back out of the context. One middleware is pushed per spec onto\n // the same Hono context, so reading `Authorization.DOMAIN` at decision time meant a\n // domain-less spec inherited the tenant domain a PREVIOUS spec had written - silently\n // widening a check that should have run at SYSTEM_WIDE. The context is still set, for\n // observability, but nothing decides on it.\n let domainScope: string | undefined;\n\n if (spec.domain || options?.domainResolver) {\n const resolvedDomain = await RequestDomainResolver.resolveRequestDomain({\n spec,\n context: ContextUtility.asTypedContext({ context }),\n options,\n });\n domainScope = resolvedDomain;\n }\n\n context.set(Authorization.DOMAIN, domainScope);\n\n // Keyed by enforcer. The slot used to hold one rule set for the whole request, so a second\n // `authorize()` naming a DIFFERENT enforcer evaluated against the first enforcer's rules -\n // granting where its own policy set denies.\n //\n // `instanceof Map`, not a truthiness test: the slot previously held a bare rule set, so\n // anything that pre-populates it with the old shape would otherwise reach `.get` on a value\n // that has no such method and take the request down with a TypeError.\n const existingRules = context.get(Authorization.RULES);\n const rulesByEnforcer =\n existingRules instanceof Map ? existingRules : new Map<string, unknown>();\n let rules = rulesByEnforcer.get(resolvedName);\n\n if (!rules) {\n if (!user.principalType) {\n throw getError({\n error: AuthorizationErrors.PRINCIPAL_TYPE_MISSING,\n message:\n 'Authorization failed: user.principalType is required for enforcer-based authorization',\n });\n }\n\n const result = await enforcer.buildRules({\n user: user as { principalType: string } & IAuthUser,\n context: ContextUtility.asTypedContext({ context }),\n });\n rules = result;\n rulesByEnforcer.set(resolvedName, rules);\n context.set(Authorization.RULES, rulesByEnforcer);\n }\n\n let decision = await enforcer.evaluate({\n rules,\n request: {\n action: spec.action,\n resource: spec.resource,\n conditions: spec.conditions,\n domain: domainScope,\n },\n context: ContextUtility.asTypedContext({ context }),\n });\n\n if (decision === AuthorizationDecisions.ABSTAIN) {\n decision = options?.defaultDecision ?? AuthorizationDecisions.DENY;\n }\n\n if (decision !== AuthorizationDecisions.ALLOW) {\n throw getError({\n error: AuthorizationErrors.DENIED,\n message: `Authorization denied | action: ${spec.action} | resource: ${spec.resource}`,\n messageArgs: { action: spec.action, resource: spec.resource },\n });\n }\n\n await next();\n });\n }\n\n private extractUserRoles(opts: { user: IAuthUser }): string[] {\n const { user } = opts;\n const roles = user.roles;\n\n if (!Array.isArray(roles)) {\n return [];\n }\n\n return roles.map((r: string | { identifier?: string; name?: string; id?: unknown }) => {\n if (typeof r === 'string') {\n return r;\n }\n\n return r.identifier ?? r.name ?? String(r.id ?? '');\n });\n }\n}\n"]}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Container } from '../../../helpers/inversion/container.js';
|
|
2
2
|
import type { TClass } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
4
|
+
/** A registered item: its class and the container that resolves it. */
|
|
4
5
|
export type TRegistryDescriptor<TItem> = {
|
|
5
6
|
container: Container;
|
|
6
7
|
targetClass: TClass<TItem>;
|
|
7
8
|
};
|
|
9
|
+
/** Base of the auth registries. Registers classes under a name as singletons in a container and resolves them by name. Subclasses supply the binding key prefix. */
|
|
8
10
|
export declare abstract class AbstractAuthRegistry<TItem> extends BaseHelper {
|
|
9
11
|
protected descriptors: Map<string, TRegistryDescriptor<TItem>>;
|
|
10
12
|
constructor(opts: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ObjectUtility } from '@venizia/ignis-helpers/common';
|
|
2
2
|
import { BindingScopes } from '@venizia/ignis-inversion';
|
|
3
3
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
4
|
+
/** Base of the auth registries. Registers classes under a name as singletons in a container and resolves them by name. Subclasses supply the binding key prefix. */
|
|
4
5
|
export class AbstractAuthRegistry extends BaseHelper {
|
|
5
6
|
constructor(opts) {
|
|
6
7
|
super(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-auth-registry.js","sourceRoot":"","sources":["../../../../../src/base/auth/base/abstract-auth-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"abstract-auth-registry.js","sourceRoot":"","sources":["../../../../../src/base/auth/base/abstract-auth-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAQnE,oKAAoK;AACpK,MAAM,OAAgB,oBAA4B,SAAQ,UAAU;IAGlE,YAAY,IAAuB;QACjC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;IAC/B,CAAC;IAID,MAAM,CAAC,IAAsB;QAC3B,IAAI,CAAC,IAAI,EAAE,IAAI,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC/D,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,iCAAiC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,gBAAgB,E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AAI,CAAC,CAAC;QAE5C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,2BAA2B,IAAI,EAAE;aACpE,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;QAC/B,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAQ;YACpC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,wBAAwB,IAAI,EAAE;aACjE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { ObjectUtility } from '@venizia/ignis-helpers/common';\nimport { BindingScopes } from '@venizia/ignis-inversion';\nimport type { Container } from '@/helpers/inversion/container';\nimport type { TClass } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** A registered item: its class and the container that resolves it. */\nexport type TRegistryDescriptor<TItem> = {\n container: Container;\n targetClass: TClass<TItem>;\n};\n\n/** Base of the auth registries. Registers classes under a name as singletons in a container and resolves them by name. Subclasses supply the binding key prefix. */\nexport abstract class AbstractAuthRegistry<TItem> extends BaseHelper {\n protected descriptors: Map<string, TRegistryDescriptor<TItem>>;\n\n constructor(opts: { scope: string }) {\n super(opts);\n this.descriptors = new Map();\n }\n\n protected abstract getBindingPrefix(): string;\n\n getKey(opts: { name: string }): string {\n if (!opts?.name || ObjectUtility.isEmpty({ value: opts.name })) {\n throw getError({ message: `[getKey] Invalid name | name: ${opts.name}` });\n }\n\n return [this.getBindingPrefix(), opts.name].join('.');\n }\n\n /**\n * Whether a name resolves. The registry is the only source of truth for that: the strategy type is\n * open (`TAuthStrategy` accepts any string), so nothing upstream can tell a registered name from a\n * typo. `AuthenticateStrategy.isValid` knows the two built-ins only and must not be used here.\n */\n has(opts: { name: string }): boolean {\n return this.descriptors.has(opts.name);\n }\n\n /** Every registered name, for a caller building its own startup check or an error message. */\n getNames(): string[] {\n return [...this.descriptors.keys()];\n }\n\n getDefaultName(): string {\n const firstName = this.descriptors.keys().next().value;\n\n if (!firstName) {\n throw getError({\n message: `[${this.constructor.name}] No items registered`,\n });\n }\n\n return firstName;\n }\n\n protected registerDescriptor(opts: {\n container: Container;\n target: TClass<TItem>;\n name: string;\n }): void {\n const { container, target, name } = opts;\n\n this.descriptors.set(name, { container, targetClass: target });\n container\n .bind({ key: this.getKey({ name }) })\n .toClass(target)\n .setScope(BindingScopes.SINGLETON);\n }\n\n reset(): void {\n this.descriptors.clear();\n }\n\n protected resolveDescriptor(opts: { name: string }): TItem {\n const { name } = opts;\n const metadata = this.descriptors.get(name);\n\n if (!metadata) {\n throw getError({\n message: `[${this.constructor.name}] Descriptor not found: ${name}`,\n });\n }\n\n const { container } = metadata;\n const instance = container.get<TItem>({\n key: this.getKey({ name }),\n });\n\n if (!instance) {\n throw getError({\n message: `[${this.constructor.name}] Failed to resolve: ${name}`,\n });\n }\n\n return instance;\n }\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
+
/** Validates a change-password body: `scheme`, `oldCredential` and `newCredential` (each at least 8 characters) and the `userId`. */
|
|
2
3
|
export declare const ChangePasswordRequestSchema: z.ZodObject<{
|
|
3
4
|
scheme: z.ZodString;
|
|
4
5
|
oldCredential: z.ZodString;
|
|
5
6
|
newCredential: z.ZodString;
|
|
6
7
|
userId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
7
8
|
}, z.core.$strip>;
|
|
9
|
+
/** Parsed body of `ChangePasswordRequestSchema`. */
|
|
8
10
|
export type TChangePasswordRequest = z.infer<typeof ChangePasswordRequestSchema>;
|
|
9
11
|
//# sourceMappingURL=change-password.schema.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenApiSchemas } from '../../../models/common/index.js';
|
|
2
2
|
import { z } from '@hono/zod-openapi';
|
|
3
|
+
/** Validates a change-password body: `scheme`, `oldCredential` and `newCredential` (each at least 8 characters) and the `userId`. */
|
|
3
4
|
export const ChangePasswordRequestSchema = z
|
|
4
5
|
.object({
|
|
5
6
|
scheme: z.string(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-password.schema.js","sourceRoot":"","sources":["../../../../../../src/base/auth/models/requests/change-password.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC;KACzC,MAAM,CAAC;IACN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,aAAa,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACxD,aAAa,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACxD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAClC,CAAC;KACD,OAAO,CAAC;IACP,QAAQ,EAAE;QACR;YACE,MAAM,EAAE,OAAO;YACf,aAAa,EAAE,cAAc;YAC7B,aAAa,EAAE,cAAc;YAC7B,MAAM,EAAE,SAAS;SAClB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { OpenApiSchemas } from '@/base/models/common';\nimport { z } from '@hono/zod-openapi';\n\nexport const ChangePasswordRequestSchema = z\n .object({\n scheme: z.string(),\n oldCredential: OpenApiSchemas.requiredString({ min: 8 }),\n newCredential: OpenApiSchemas.requiredString({ min: 8 }),\n userId: z.string().or(z.number()),\n })\n .openapi({\n examples: [\n {\n scheme: 'basic',\n oldCredential: 'old_password',\n newCredential: 'new_password',\n userId: 'user-id',\n },\n ],\n });\n\nexport type TChangePasswordRequest = z.infer<typeof ChangePasswordRequestSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"change-password.schema.js","sourceRoot":"","sources":["../../../../../../src/base/auth/models/requests/change-password.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,qIAAqI;AACrI,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC;KACzC,MAAM,CAAC;IACN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,aAAa,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACxD,aAAa,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACxD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAClC,CAAC;KACD,OAAO,CAAC;IACP,QAAQ,EAAE;QACR;YACE,MAAM,EAAE,OAAO;YACf,aAAa,EAAE,cAAc;YAC7B,aAAa,EAAE,cAAc;YAC7B,MAAM,EAAE,SAAS;SAClB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { OpenApiSchemas } from '@/base/models/common';\nimport { z } from '@hono/zod-openapi';\n\n/** Validates a change-password body: `scheme`, `oldCredential` and `newCredential` (each at least 8 characters) and the `userId`. */\nexport const ChangePasswordRequestSchema = z\n .object({\n scheme: z.string(),\n oldCredential: OpenApiSchemas.requiredString({ min: 8 }),\n newCredential: OpenApiSchemas.requiredString({ min: 8 }),\n userId: z.string().or(z.number()),\n })\n .openapi({\n examples: [\n {\n scheme: 'basic',\n oldCredential: 'old_password',\n newCredential: 'new_password',\n userId: 'user-id',\n },\n ],\n });\n\n/** Parsed body of `ChangePasswordRequestSchema`. */\nexport type TChangePasswordRequest = z.infer<typeof ChangePasswordRequestSchema>;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
+
/** Validates a sign-in body: an `identifier` and a `credential`, each a `scheme` plus `value`, and an optional `clientId`. */
|
|
2
3
|
export declare const SignInRequestSchema: z.ZodObject<{
|
|
3
4
|
identifier: z.ZodObject<{
|
|
4
5
|
scheme: z.ZodString;
|
|
@@ -10,5 +11,6 @@ export declare const SignInRequestSchema: z.ZodObject<{
|
|
|
10
11
|
}, z.core.$strip>;
|
|
11
12
|
clientId: z.ZodOptional<z.ZodString>;
|
|
12
13
|
}, z.core.$strip>;
|
|
14
|
+
/** Parsed body of `SignInRequestSchema`. */
|
|
13
15
|
export type TSignInRequest = z.infer<typeof SignInRequestSchema>;
|
|
14
16
|
//# sourceMappingURL=sign-in.schema.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenApiSchemas } from '../../../models/common/index.js';
|
|
2
2
|
import { z } from '@hono/zod-openapi';
|
|
3
|
+
/** Validates a sign-in body: an `identifier` and a `credential`, each a `scheme` plus `value`, and an optional `clientId`. */
|
|
3
4
|
export const SignInRequestSchema = z
|
|
4
5
|
.object({
|
|
5
6
|
identifier: z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in.schema.js","sourceRoot":"","sources":["../../../../../../src/base/auth/models/requests/sign-in.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;QACjD,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;KACjD,CAAC;SACD,OAAO,CAAC;QACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC7B,WAAW,EAAE,oBAAoB;KAClC,CAAC;IACJ,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,MAAM,EAAE,cAAc,CAAC,cAAc,EAAE;QACvC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;KACjD,CAAC;SACD,OAAO,CAAC;QACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC7B,WAAW,EAAE,oBAAoB;KAClC,CAAC;IACJ,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;QACtC,WAAW,EAAE,uBAAuB;KACrC,CAAC;CACH,CAAC;KACD,OAAO,CAAC;IACP,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;IACtC,QAAQ,EAAE;QACR;YACE,UAAU,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE;YAC1D,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE;SACxD;QACD;YACE,UAAU,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE;YAC1D,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE;YACvD,QAAQ,EAAE,eAAe;SAC1B;KACF;CACF,CAAC,CAAC","sourcesContent":["import { OpenApiSchemas } from '@/base/models/common';\nimport { z } from '@hono/zod-openapi';\n\nexport const SignInRequestSchema = z\n .object({\n identifier: z\n .object({\n scheme: OpenApiSchemas.requiredString({ min: 4 }),\n value: OpenApiSchemas.requiredString({ min: 8 }),\n })\n .openapi({\n required: ['scheme', 'value'],\n description: 'Sign-In Identifier',\n }),\n credential: z\n .object({\n scheme: OpenApiSchemas.requiredString(),\n value: OpenApiSchemas.requiredString({ min: 8 }),\n })\n .openapi({\n required: ['scheme', 'value'],\n description: 'Sign-In Credential',\n }),\n clientId: z.string().optional().openapi({\n description: 'Authenticate Provider',\n }),\n })\n .openapi({\n required: ['identifier', 'credential'],\n examples: [\n {\n identifier: { scheme: 'username', value: 'test_username' },\n credential: { scheme: 'basic', value: 'test_password' },\n },\n {\n identifier: { scheme: 'username', value: 'test_username' },\n credential: { scheme: 'basic', value: 'test_password' },\n clientId: 'auth-provider',\n },\n ],\n });\n\nexport type TSignInRequest = z.infer<typeof SignInRequestSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"sign-in.schema.js","sourceRoot":"","sources":["../../../../../../src/base/auth/models/requests/sign-in.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,8HAA8H;AAC9H,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;QACjD,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;KACjD,CAAC;SACD,OAAO,CAAC;QACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC7B,WAAW,EAAE,oBAAoB;KAClC,CAAC;IACJ,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,MAAM,EAAE,cAAc,CAAC,cAAc,EAAE;QACvC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;KACjD,CAAC;SACD,OAAO,CAAC;QACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC7B,WAAW,EAAE,oBAAoB;KAClC,CAAC;IACJ,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;QACtC,WAAW,EAAE,uBAAuB;KACrC,CAAC;CACH,CAAC;KACD,OAAO,CAAC;IACP,QAAQ,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC;IACtC,QAAQ,EAAE;QACR;YACE,UAAU,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE;YAC1D,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE;SACxD;QACD;YACE,UAAU,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE;YAC1D,UAAU,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE;YACvD,QAAQ,EAAE,eAAe;SAC1B;KACF;CACF,CAAC,CAAC","sourcesContent":["import { OpenApiSchemas } from '@/base/models/common';\nimport { z } from '@hono/zod-openapi';\n\n/** Validates a sign-in body: an `identifier` and a `credential`, each a `scheme` plus `value`, and an optional `clientId`. */\nexport const SignInRequestSchema = z\n .object({\n identifier: z\n .object({\n scheme: OpenApiSchemas.requiredString({ min: 4 }),\n value: OpenApiSchemas.requiredString({ min: 8 }),\n })\n .openapi({\n required: ['scheme', 'value'],\n description: 'Sign-In Identifier',\n }),\n credential: z\n .object({\n scheme: OpenApiSchemas.requiredString(),\n value: OpenApiSchemas.requiredString({ min: 8 }),\n })\n .openapi({\n required: ['scheme', 'value'],\n description: 'Sign-In Credential',\n }),\n clientId: z.string().optional().openapi({\n description: 'Authenticate Provider',\n }),\n })\n .openapi({\n required: ['identifier', 'credential'],\n examples: [\n {\n identifier: { scheme: 'username', value: 'test_username' },\n credential: { scheme: 'basic', value: 'test_password' },\n },\n {\n identifier: { scheme: 'username', value: 'test_username' },\n credential: { scheme: 'basic', value: 'test_password' },\n clientId: 'auth-provider',\n },\n ],\n });\n\n/** Parsed body of `SignInRequestSchema`. */\nexport type TSignInRequest = z.infer<typeof SignInRequestSchema>;\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
+
/** Validates a sign-up body: `username` and `credential`, each a non-empty string of at least 8 characters. */
|
|
2
3
|
export declare const SignUpRequestSchema: z.ZodObject<{
|
|
3
4
|
username: z.ZodString;
|
|
4
5
|
credential: z.ZodString;
|
|
5
6
|
}, z.core.$strip>;
|
|
7
|
+
/** Parsed body of `SignUpRequestSchema`. */
|
|
6
8
|
export type TSignUpRequest = z.infer<typeof SignUpRequestSchema>;
|
|
7
9
|
//# sourceMappingURL=sign-up.schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-up.schema.js","sourceRoot":"","sources":["../../../../../../src/base/auth/models/requests/sign-up.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzC,CAAC;KACD,OAAO,CAAC;IACP,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;IACpC,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,kBAAkB;YAC5B,UAAU,EAAE,oBAAoB;SACjC;KACF;CACF,CAAC,CAAC","sourcesContent":["import { z } from '@hono/zod-openapi';\n\nexport const SignUpRequestSchema = z\n .object({\n username: z.string().nonempty().min(8),\n credential: z.string().nonempty().min(8),\n })\n .openapi({\n required: ['username', 'credential'],\n examples: [\n {\n username: 'example_username',\n credential: 'example_credential',\n },\n ],\n });\n\nexport type TSignUpRequest = z.infer<typeof SignUpRequestSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"sign-up.schema.js","sourceRoot":"","sources":["../../../../../../src/base/auth/models/requests/sign-up.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,+GAA+G;AAC/G,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzC,CAAC;KACD,OAAO,CAAC;IACP,QAAQ,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;IACpC,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,kBAAkB;YAC5B,UAAU,EAAE,oBAAoB;SACjC;KACF;CACF,CAAC,CAAC","sourcesContent":["import { z } from '@hono/zod-openapi';\n\n/** Validates a sign-up body: `username` and `credential`, each a non-empty string of at least 8 characters. */\nexport const SignUpRequestSchema = z\n .object({\n username: z.string().nonempty().min(8),\n credential: z.string().nonempty().min(8),\n })\n .openapi({\n required: ['username', 'credential'],\n examples: [\n {\n username: 'example_username',\n credential: 'example_credential',\n },\n ],\n });\n\n/** Parsed body of `SignUpRequestSchema`. */\nexport type TSignUpRequest = z.infer<typeof SignUpRequestSchema>;\n"]}
|
|
@@ -7,6 +7,7 @@ type TInitDefault = {
|
|
|
7
7
|
enable: true;
|
|
8
8
|
container: Container;
|
|
9
9
|
};
|
|
10
|
+
/** Base of every component: `configure()` stores the options once, then runs `binding()` to register the component bindings. A second `configure()` call is a no-op. */
|
|
10
11
|
export declare abstract class BaseComponent<ConfigurableOptions extends object = {}> extends BaseHelper implements IConfigurable<ConfigurableOptions> {
|
|
11
12
|
protected bindings: Record<TBindingKey, Binding>;
|
|
12
13
|
protected initDefault: TInitDefault;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/** Base of every component: `configure()` stores the options once, then runs `binding()` to register the component bindings. A second `configure()` call is a no-op. */
|
|
2
3
|
export class BaseComponent extends BaseHelper {
|
|
3
4
|
constructor(opts) {
|
|
4
5
|
super(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/components/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAInE,MAAM,OAAgB,aACpB,SAAQ,UAAU;IAWlB,YAAY,IAIX;QACC,KAAK,CAAC,IAAI,CAAC,CAAC;QAVJ,iBAAY,GAAG,KAAK,CAAC;QAY7B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACzD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACtC,CAAC;IAID,+DAA+D;IAC/D,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAES,mBAAmB,CAAC,IAA8B;QAC1D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAE3B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,uDAAuD;aACjE,CAAC,CAAC;QACL,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChC,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;gBAC/B,SAAS;YACX,CAAC;YAED,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAA0B;QACxC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAE5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,yCAAyC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAE/F,IAAI,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;YAC7B,IAAI,CAAC,mBAAmB,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAErB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;aACtB,IAAI,CAAC,0CAA0C,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import type { Binding, Container, TBindingKey } from '@/helpers/inversion';\nimport type { IConfigurable, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\ntype TInitDefault = { enable: false } | { enable: true; container: Container };\n\nexport abstract class BaseComponent<ConfigurableOptions extends object = {}>\n extends BaseHelper\n implements IConfigurable<ConfigurableOptions>\n{\n protected bindings: Record<TBindingKey, Binding>;\n\n protected initDefault: TInitDefault;\n protected isConfigured = false;\n\n /** What `application.component(Ctor, { options })` handed this instance, set before `binding()` runs. Optional, not defaulted to `{}`: a component registered through `configs.artifacts` gets no options and uses `??` to fall back to its binding, which an empty object would silently defeat. */\n options?: ConfigurableOptions;\n\n constructor(opts: {\n scope: string;\n initDefault?: TInitDefault;\n bindings?: Record<TBindingKey, Binding>;\n }) {\n super(opts);\n\n this.initDefault = opts.initDefault ?? { enable: false };\n this.bindings = opts.bindings ?? {};\n }\n\n abstract binding(): ValueOrPromise<void>;\n\n /** Override this, not the field, to resolve options lazily. */\n getOptions(): ConfigurableOptions | undefined {\n return this.options;\n }\n\n protected initDefaultBindings(opts: { container: Container }) {\n const { container } = opts;\n\n if (!container) {\n throw getError({\n message: '[initBindings] Invalid DI Container to init bindings!',\n });\n }\n\n for (const key in this.bindings) {\n if (container.isBound({ key })) {\n continue;\n }\n\n container.set({ binding: this.bindings[key] });\n }\n }\n\n async configure(opts?: ConfigurableOptions): Promise<void> {\n if (this.isConfigured) {\n return;\n }\n\n const t = performance.now();\n\n this.options = opts;\n\n this.logger.for(this.binding.name).info('START | Binding component | Options: %j', opts ?? {});\n\n if (this.initDefault?.enable) {\n this.initDefaultBindings({ container: this.initDefault.container });\n }\n\n await this.binding();\n\n this.isConfigured = true;\n this.logger\n .for(this.binding.name)\n .info('DONE | Binding component | Took: %s (ms)', performance.now() - t);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/components/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAInE,wKAAwK;AACxK,MAAM,OAAgB,aACpB,SAAQ,UAAU;IAWlB,YAAY,IAIX;QACC,KAAK,CAAC,IAAI,CAAC,CAAC;QAVJ,iBAAY,GAAG,KAAK,CAAC;QAY7B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACzD,IAAI,C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R,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;aACtB,IAAI,CAAC,0CAA0C,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import type { Binding, Container, TBindingKey } from '@/helpers/inversion';\nimport type { IConfigurable, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\ntype TInitDefault = { enable: false } | { enable: true; container: Container };\n\n/** Base of every component: `configure()` stores the options once, then runs `binding()` to register the component bindings. A second `configure()` call is a no-op. */\nexport abstract class BaseComponent<ConfigurableOptions extends object = {}>\n extends BaseHelper\n implements IConfigurable<ConfigurableOptions>\n{\n protected bindings: Record<TBindingKey, Binding>;\n\n protected initDefault: TInitDefault;\n protected isConfigured = false;\n\n /** What `application.component(Ctor, { options })` handed this instance, set before `binding()` runs. Optional, not defaulted to `{}`: a component registered through `configs.artifacts` gets no options and uses `??` to fall back to its binding, which an empty object would silently defeat. */\n options?: ConfigurableOptions;\n\n constructor(opts: {\n scope: string;\n initDefault?: TInitDefault;\n bindings?: Record<TBindingKey, Binding>;\n }) {\n super(opts);\n\n this.initDefault = opts.initDefault ?? { enable: false };\n this.bindings = opts.bindings ?? {};\n }\n\n abstract binding(): ValueOrPromise<void>;\n\n /** Override this, not the field, to resolve options lazily. */\n getOptions(): ConfigurableOptions | undefined {\n return this.options;\n }\n\n protected initDefaultBindings(opts: { container: Container }) {\n const { container } = opts;\n\n if (!container) {\n throw getError({\n message: '[initBindings] Invalid DI Container to init bindings!',\n });\n }\n\n for (const key in this.bindings) {\n if (container.isBound({ key })) {\n continue;\n }\n\n container.set({ binding: this.bindings[key] });\n }\n }\n\n async configure(opts?: ConfigurableOptions): Promise<void> {\n if (this.isConfigured) {\n return;\n }\n\n const t = performance.now();\n\n this.options = opts;\n\n this.logger.for(this.binding.name).info('START | Binding component | Options: %j', opts ?? {});\n\n if (this.initDefault?.enable) {\n this.initDefaultBindings({ container: this.initDefault.container });\n }\n\n await this.binding();\n\n this.isConfigured = true;\n this.logger\n .for(this.binding.name)\n .info('DONE | Binding component | Took: %s (ms)', performance.now() - t);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/base/components/controller/rest/common/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/base/components/controller/rest/common/types.ts"],"names":[],"mappings":"AAGA,0CAA0C;AAC1C,MAAM,OAAO,eAAe;aACV,2BAAsB,GAAG,mBAAmB,CAAC","sourcesContent":["/** Options of the REST component. Currently has no keys. */\nexport interface IRestComponentConfig {}\n\n/** Binding keys of the REST component. */\nexport class RestBindingKeys {\n static readonly REST_COMPONENT_OPTIONS = '@app/rest/options';\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IConfigurable, ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
2
2
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
3
3
|
import type { IConfiguration } from './common/index.js';
|
|
4
|
+
/** Base of every configuration artifact: `configure()` runs `setup()` once and ignores later calls. */
|
|
4
5
|
export declare abstract class BaseConfiguration<ConfigurableOptions extends object = {}> extends BaseHelper implements IConfiguration, IConfigurable<ConfigurableOptions> {
|
|
5
6
|
protected isConfigured: boolean;
|
|
6
7
|
constructor(opts?: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/** Base of every configuration artifact: `configure()` runs `setup()` once and ignores later calls. */
|
|
2
3
|
export class BaseConfiguration extends BaseHelper {
|
|
3
4
|
constructor(opts) {
|
|
4
5
|
super({ scope: opts?.scope ?? BaseConfiguration.name, identifier: opts?.identifier });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/configurations/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,MAAM,OAAgB,iBACpB,SAAQ,UAAU;IAKlB,YAAY,IAA8C;QACxD,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAH9E,iBAAY,GAAG,KAAK,CAAC;IAI/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAA0B;QACxC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,uEAAuE;IAC7D,KAAK,CAAC,KAA2B,IAAyB,CAAC;CACtE","sourcesContent":["import type { IConfigurable, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport type { IConfiguration } from './common';\n\nexport abstract class BaseConfiguration<ConfigurableOptions extends object = {}>\n extends BaseHelper\n implements IConfiguration, IConfigurable<ConfigurableOptions>\n{\n protected isConfigured = false;\n\n constructor(opts?: { scope?: string; identifier?: string }) {\n super({ scope: opts?.scope ?? BaseConfiguration.name, identifier: opts?.identifier });\n }\n\n async configure(opts?: ConfigurableOptions): Promise<void> {\n if (this.isConfigured) {\n return;\n }\n\n await this.setup(opts);\n this.isConfigured = true;\n }\n\n /** Override to perform setup work when the configuration is booted. */\n protected setup(_opts?: ConfigurableOptions): ValueOrPromise<void> {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/configurations/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGzD,uGAAuG;AACvG,MAAM,OAAgB,iBACpB,SAAQ,UAAU;IAKlB,YAAY,IAA8C;QACxD,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,iBAAiB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QAH9E,iBAAY,GAAG,KAAK,CAAC;IAI/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAA0B;QACxC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,uEAAuE;IAC7D,KAAK,CAAC,KAA2B,IAAyB,CAAC;CACtE","sourcesContent":["import type { IConfigurable, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport type { IConfiguration } from './common';\n\n/** Base of every configuration artifact: `configure()` runs `setup()` once and ignores later calls. */\nexport abstract class BaseConfiguration<ConfigurableOptions extends object = {}>\n extends BaseHelper\n implements IConfiguration, IConfigurable<ConfigurableOptions>\n{\n protected isConfigured = false;\n\n constructor(opts?: { scope?: string; identifier?: string }) {\n super({ scope: opts?.scope ?? BaseConfiguration.name, identifier: opts?.identifier });\n }\n\n async configure(opts?: ConfigurableOptions): Promise<void> {\n if (this.isConfigured) {\n return;\n }\n\n await this.setup(opts);\n this.isConfigured = true;\n }\n\n /** Override to perform setup work when the configuration is booted. */\n protected setup(_opts?: ConfigurableOptions): ValueOrPromise<void> {}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/base/configurations/common/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/base/configurations/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Marker contract of a configuration artifact; `BaseConfiguration` implements it. */\nexport interface IConfiguration {}\n"]}
|
|
@@ -10,6 +10,7 @@ export declare class ControllerTransports {
|
|
|
10
10
|
static readonly REST = "rest";
|
|
11
11
|
static readonly GRPC = "grpc";
|
|
12
12
|
}
|
|
13
|
+
/** Union of the `ControllerTransports` values. */
|
|
13
14
|
export type TControllerTransport = TConstValue<typeof ControllerTransports>;
|
|
14
15
|
/** Shape of `data` in a `{ count, data }` response, echoed in the `X-Response-Format` header. */
|
|
15
16
|
export declare class ResponseFormats {
|
|
@@ -18,6 +19,7 @@ export declare class ResponseFormats {
|
|
|
18
19
|
static readonly SCHEME_SET: Set<string>;
|
|
19
20
|
static isValid(value: string): boolean;
|
|
20
21
|
}
|
|
22
|
+
/** Union of the `ResponseFormats` values. */
|
|
21
23
|
export type TResponseFormat = TConstValue<typeof ResponseFormats>;
|
|
22
24
|
/** Standard REST API path constants for CRUD controllers. */
|
|
23
25
|
export declare class RestPaths {
|
|
@@ -25,7 +27,9 @@ export declare class RestPaths {
|
|
|
25
27
|
static readonly COUNT = "/count";
|
|
26
28
|
static readonly FIND_ONE = "/find-one";
|
|
27
29
|
}
|
|
30
|
+
/** OpenAPI response headers every CRUD route documents: the request tracing id, the record count and the response format. */
|
|
28
31
|
export declare const commonResponseHeaders: TResponseHeaders;
|
|
32
|
+
/** OpenAPI response headers of a list route: `commonResponseHeaders` plus `Content-Range` for pagination. */
|
|
29
33
|
export declare const findResponseHeaders: TResponseHeaders;
|
|
30
34
|
/** Which decorator-defined routes `registerRoutesFromRegistry` registers: STATIC (no path parameter), PARAM (a path parameter) or ALL. */
|
|
31
35
|
export declare class RoutePathScopes {
|
|
@@ -24,6 +24,7 @@ export class RestPaths {
|
|
|
24
24
|
static { this.COUNT = '/count'; }
|
|
25
25
|
static { this.FIND_ONE = '/find-one'; }
|
|
26
26
|
}
|
|
27
|
+
/** OpenAPI response headers every CRUD route documents: the request tracing id, the record count and the response format. */
|
|
27
28
|
export const commonResponseHeaders = {
|
|
28
29
|
[HTTP.Headers.REQUEST_TRACING_ID]: {
|
|
29
30
|
description: 'Echo of the request tracing ID',
|
|
@@ -38,6 +39,7 @@ export const commonResponseHeaders = {
|
|
|
38
39
|
schema: { type: 'string', examples: ['array', 'object'] },
|
|
39
40
|
},
|
|
40
41
|
};
|
|
42
|
+
/** OpenAPI response headers of a list route: `commonResponseHeaders` plus `Content-Range` for pagination. */
|
|
41
43
|
export const findResponseHeaders = {
|
|
42
44
|
...commonResponseHeaders,
|
|
43
45
|
[HTTP.Headers.CONTENT_RANGE]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/controllers/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGrD;;;;GAIG;AAEH,oDAAoD;AACpD,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/controllers/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGrD;;;;GAIG;AAEH,oDAAoD;AACpD,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;;AAMhC,iGAAiG;AACjG,MAAM,OAAO,eAAe;aACV,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,6DAA6D;AAC7D,MAAM,OAAO,SAAS;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AM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport type { TResponseHeaders } from './types';\n\n/**\n * Constants with NO zod import, deliberately. The container's controller mixin imports\n * `ControllerTransports` from here, so anything this file pulls in reaches every consumer of\n * `Container` - the request schemas live in `schemas.ts` for exactly that reason.\n */\n\n/** Transport protocol constants for controllers. */\nexport class ControllerTransports {\n static readonly REST = 'rest';\n static readonly GRPC = 'grpc';\n}\n\n/** Union of the `ControllerTransports` values. */\nexport type TControllerTransport = TConstValue<typeof ControllerTransports>;\n\n/** Shape of `data` in a `{ count, data }` response, echoed in the `X-Response-Format` header. */\nexport class ResponseFormats {\n static readonly OBJECT = 'object';\n static readonly ARRAY = 'array';\n\n static readonly SCHEME_SET = new Set<string>([this.OBJECT, this.ARRAY]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Union of the `ResponseFormats` values. */\nexport type TResponseFormat = TConstValue<typeof ResponseFormats>;\n\n/** Standard REST API path constants for CRUD controllers. */\nexport class RestPaths {\n static readonly ROOT = '/';\n static readonly COUNT = '/count';\n static readonly FIND_ONE = '/find-one';\n}\n\n/** OpenAPI response headers every CRUD route documents: the request tracing id, the record count and the response format. */\nexport const commonResponseHeaders: TResponseHeaders = {\n [HTTP.Headers.REQUEST_TRACING_ID]: {\n description: 'Echo of the request tracing ID',\n schema: { type: 'string' },\n },\n [HTTP.Headers.RESPONSE_COUNT_DATA]: {\n description: 'Number of records in response',\n schema: { type: 'string', examples: ['1', '10', '100'] },\n },\n [HTTP.Headers.RESPONSE_FORMAT]: {\n description: 'Response format indicator',\n schema: { type: 'string', examples: ['array', 'object'] },\n },\n};\n\n/** OpenAPI response headers of a list route: `commonResponseHeaders` plus `Content-Range` for pagination. */\nexport const findResponseHeaders: TResponseHeaders = {\n ...commonResponseHeaders,\n [HTTP.Headers.CONTENT_RANGE]: {\n description: 'Content range for pagination (e.g., \"records 0-24/100\")',\n schema: { type: 'string', examples: ['records 0-24/100', 'records 25-49/100'] },\n },\n};\n\n/** Which decorator-defined routes `registerRoutesFromRegistry` registers: STATIC (no path parameter), PARAM (a path parameter) or ALL. */\nexport class RoutePathScopes {\n static readonly STATIC = 'static';\n static readonly PARAM = 'param';\n static readonly ALL = 'all';\n\n static readonly SCHEME_SET = new Set<string>([this.STATIC, this.PARAM, this.ALL]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid route path scope values. */\nexport type TRoutePathScope = TConstValue<typeof RoutePathScopes>;\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
+
/** Zod schema of an object with any keys; the fallback response schema when a route sets none. */
|
|
2
3
|
export declare const AnyObjectSchema: z.ZodObject<{}, z.core.$catchall<z.ZodAny>>;
|
|
4
|
+
/** Zod object type of a plain raw shape, used to type request and response schemas. */
|
|
3
5
|
export type TAnyObjectSchema = z.ZodObject<z.ZodRawShape>;
|
|
6
|
+
/** The output type of a Zod schema `T`. */
|
|
4
7
|
export type TInferSchema<T extends z.ZodType> = z.infer<T>;
|
|
5
8
|
//# sourceMappingURL=schema-builders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-builders.js","sourceRoot":"","sources":["../../../../../src/base/controllers/common/schema-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC;IAClE,WAAW,EAAE,gBAAgB;CAC9B,CAAC,CAAC","sourcesContent":["import { z } from '@hono/zod-openapi';\n\nexport const AnyObjectSchema = z.object().catchall(z.any()).openapi({\n description: 'Unknown schema',\n});\n\nexport type TAnyObjectSchema = z.ZodObject<z.ZodRawShape>;\nexport type TInferSchema<T extends z.ZodType> = z.infer<T>;\n"]}
|
|
1
|
+
{"version":3,"file":"schema-builders.js","sourceRoot":"","sources":["../../../../../src/base/controllers/common/schema-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,kGAAkG;AAClG,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC;IAClE,WAAW,EAAE,gBAAgB;CAC9B,CAAC,CAAC","sourcesContent":["import { z } from '@hono/zod-openapi';\n\n/** Zod schema of an object with any keys; the fallback response schema when a route sets none. */\nexport const AnyObjectSchema = z.object().catchall(z.any()).openapi({\n description: 'Unknown schema',\n});\n\n/** Zod object type of a plain raw shape, used to type request and response schemas. */\nexport type TAnyObjectSchema = z.ZodObject<z.ZodRawShape>;\n/** The output type of a Zod schema `T`. */\nexport type TInferSchema<T extends z.ZodType> = z.infer<T>;\n"]}
|
|
@@ -10,9 +10,11 @@ export declare const trackableHeaders: z.ZodObject<{
|
|
|
10
10
|
"x-request-channel": z.ZodOptional<z.ZodString>;
|
|
11
11
|
"x-device-info": z.ZodOptional<z.ZodString>;
|
|
12
12
|
}, z.core.$strip>;
|
|
13
|
+
/** Request header schema for the `x-request-count-data` header, which switches a response between `{ count, data }` and the raw payload. */
|
|
13
14
|
export declare const countableHeaders: z.ZodObject<{
|
|
14
15
|
"x-request-count": z.ZodOptional<z.ZodString>;
|
|
15
16
|
}, z.core.$strip>;
|
|
17
|
+
/** Default request headers of a CRUD route: the trackable headers plus the count header. */
|
|
16
18
|
export declare const defaultRequestHeaders: z.ZodObject<{
|
|
17
19
|
"x-request-id": z.ZodOptional<z.ZodString>;
|
|
18
20
|
"x-request-channel": z.ZodOptional<z.ZodString>;
|
|
@@ -25,6 +25,7 @@ export const trackableHeaders = z.object({
|
|
|
25
25
|
examples: ['dev-1', 'device-abc', 'd-unique-id'],
|
|
26
26
|
}),
|
|
27
27
|
});
|
|
28
|
+
/** Request header schema for the `x-request-count-data` header, which switches a response between `{ count, data }` and the raw payload. */
|
|
28
29
|
export const countableHeaders = z.object({
|
|
29
30
|
[HTTP.Headers.REQUEST_COUNT_DATA]: z
|
|
30
31
|
.string()
|
|
@@ -34,5 +35,6 @@ export const countableHeaders = z.object({
|
|
|
34
35
|
examples: ['true', '1', 'false', '0'],
|
|
35
36
|
}),
|
|
36
37
|
});
|
|
38
|
+
/** Default request headers of a CRUD route: the trackable headers plus the count header. */
|
|
37
39
|
export const defaultRequestHeaders = trackableHeaders.extend(countableHeaders.shape);
|
|
38
40
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../../src/base/controllers/common/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;QAC/D,WAAW,EAAE,qBAAqB;KACnC,CAAC;IACF,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;SAC9B,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC;QACP,WAAW,EAAE,0BAA0B;QACvC,QAAQ,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC;KACvC,CAAC;IACJ,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;SAClC,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC;QACP,WAAW,EAAE,8BAA8B;QAC3C,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC;KACjD,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;SACjC,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC;QACP,WAAW,EACT,0GAA0G;QAC5G,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC;KACtC,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import { z } from '@hono/zod-openapi';\nimport { HTTP } from '@venizia/ignis-helpers/common';\n\n/**\n * The zod-backed request schemas, kept apart from `constants.ts` ON PURPOSE. `z.object()` runs at\n * module load, so any bundle reaching this file carries the whole of zod. While these lived beside\n * `ControllerTransports`, which the container's controller mixin imports, importing `Container`\n * alone cost 437 KB - 423 KB of it zod - for a four-line const class.\n */\nexport const trackableHeaders = z.object({\n [HTTP.Headers.REQUEST_TRACING_ID]: z.string().optional().openapi({\n description: 'Optional request ID',\n }),\n [HTTP.Headers.REQUEST_CHANNEL]: z\n .string()\n .optional()\n .openapi({\n description: 'Optional request channel',\n examples: ['channel-1', 'web', 'spos'],\n }),\n [HTTP.Headers.REQUEST_DEVICE_INFO]: z\n .string()\n .optional()\n .openapi({\n description: 'Optional request device info',\n examples: ['dev-1', 'device-abc', 'd-unique-id'],\n }),\n});\n\nexport const countableHeaders = z.object({\n [HTTP.Headers.REQUEST_COUNT_DATA]: z\n .string()\n .optional()\n .openapi({\n description:\n 'Controls response format. When \"true\" (default): returns {count, data}. When \"false\": returns data only.',\n examples: ['true', '1', 'false', '0'],\n }),\n});\n\nexport const defaultRequestHeaders = trackableHeaders.extend(countableHeaders.shape);\n"]}
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../../src/base/controllers/common/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;QAC/D,WAAW,EAAE,qBAAqB;KACnC,CAAC;IACF,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;SAC9B,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC;QACP,WAAW,EAAE,0BAA0B;QACvC,QAAQ,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC;KACvC,CAAC;IACJ,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;SAClC,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC;QACP,WAAW,EAAE,8BAA8B;QAC3C,QAAQ,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC;KACjD,CAAC;CACL,CAAC,CAAC;AAEH,4IAA4I;AAC5I,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;SACjC,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC;QACP,WAAW,EACT,0GAA0G;QAC5G,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC;KACtC,CAAC;CACL,CAAC,CAAC;AAEH,4FAA4F;AAC5F,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import { z } from '@hono/zod-openapi';\nimport { HTTP } from '@venizia/ignis-helpers/common';\n\n/**\n * The zod-backed request schemas, kept apart from `constants.ts` ON PURPOSE. `z.object()` runs at\n * module load, so any bundle reaching this file carries the whole of zod. While these lived beside\n * `ControllerTransports`, which the container's controller mixin imports, importing `Container`\n * alone cost 437 KB - 423 KB of it zod - for a four-line const class.\n */\nexport const trackableHeaders = z.object({\n [HTTP.Headers.REQUEST_TRACING_ID]: z.string().optional().openapi({\n description: 'Optional request ID',\n }),\n [HTTP.Headers.REQUEST_CHANNEL]: z\n .string()\n .optional()\n .openapi({\n description: 'Optional request channel',\n examples: ['channel-1', 'web', 'spos'],\n }),\n [HTTP.Headers.REQUEST_DEVICE_INFO]: z\n .string()\n .optional()\n .openapi({\n description: 'Optional request device info',\n examples: ['dev-1', 'device-abc', 'd-unique-id'],\n }),\n});\n\n/** Request header schema for the `x-request-count-data` header, which switches a response between `{ count, data }` and the raw payload. */\nexport const countableHeaders = z.object({\n [HTTP.Headers.REQUEST_COUNT_DATA]: z\n .string()\n .optional()\n .openapi({\n description:\n 'Controls response format. When \"true\" (default): returns {count, data}. When \"false\": returns data only.',\n examples: ['true', '1', 'false', '0'],\n }),\n});\n\n/** Default request headers of a CRUD route: the trackable headers plus the count header. */\nexport const defaultRequestHeaders = trackableHeaders.extend(countableHeaders.shape);\n"]}
|
|
@@ -10,6 +10,7 @@ export interface IValidRequestProps<JsonType = unknown, QueryType = unknown, Par
|
|
|
10
10
|
cookie?: CookieType;
|
|
11
11
|
form?: FormType;
|
|
12
12
|
}
|
|
13
|
+
/** A Hono JSON `Response` typed with its body and status code. */
|
|
13
14
|
export type TJsonResponse<ResponseBody = unknown, ResponseStatusCode extends StatusCode = StatusCode> = Response & TypedResponse<ResponseBody, ResponseStatusCode, 'json'>;
|
|
14
15
|
/** Polymorphic response body for endpoints honoring the `x-request-count-data` header - the count-wrapped `{ count, data }` or the raw payload; pass the unwrapped payload type as `T`. */
|
|
15
16
|
export type TCountResponse<TData = unknown> = TData | {
|
|
@@ -23,6 +24,7 @@ export type TContext<RouteEnv extends Env = Env, ValidTargetKey extends string =
|
|
|
23
24
|
};
|
|
24
25
|
json<TStatusCode extends ContentfulStatusCode = 200>(body: ResponseBody, status?: TStatusCode): TJsonResponse<ResponseBody, TStatusCode>;
|
|
25
26
|
};
|
|
27
|
+
/** A `TContext` whose `req.valid()` targets are the keys of `IValidRequestProps` (`json`, `query`, `param`, `header`, `cookie`, `form`). */
|
|
26
28
|
export type TRouteContext<RouteEnv extends Env = Env, ResponseBody = unknown> = TContext<RouteEnv, keyof IValidRequestProps, ResponseBody>;
|
|
27
29
|
/** Lightweight handler type using TTypedContext to avoid heavy RouteHandler inference. */
|
|
28
30
|
export type TRouteHandler<ResponseType = unknown, RouteEnv extends Env = Env> = (context: TRouteContext<RouteEnv, ResponseType>) => ValueOrPromise<Response | TypedResponse<ResponseType>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/base/controllers/common/types/context.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { Context, Env, TypedResponse } from 'hono';\nimport type { ContentfulStatusCode, StatusCode } from 'hono/utils/http-status';\n\n/** Typed validation results for route handlers. */\nexport interface IValidRequestProps<\n JsonType = unknown,\n QueryType = unknown,\n ParamType = unknown,\n HeaderType = unknown,\n CookieType = unknown,\n FormType = unknown,\n> {\n json?: JsonType;\n query?: QueryType;\n param?: ParamType;\n header?: HeaderType;\n cookie?: CookieType;\n form?: FormType;\n}\n\nexport type TJsonResponse<\n ResponseBody = unknown,\n ResponseStatusCode extends StatusCode = StatusCode,\n> = Response & TypedResponse<ResponseBody, ResponseStatusCode, 'json'>;\n\n/** Polymorphic response body for endpoints honoring the `x-request-count-data` header - the count-wrapped `{ count, data }` or the raw payload; pass the unwrapped payload type as `T`. */\nexport type TCountResponse<TData = unknown> = TData | { count: number; data: TData };\n\n/** Lightweight typed context that bypasses RouteHandler inference. */\nexport type TContext<\n RouteEnv extends Env = Env,\n ValidTargetKey extends string = string,\n ResponseBody = unknown,\n> = Omit<Context<RouteEnv>, 'req' | 'json'> & {\n req: Omit<Context<RouteEnv>['req'], 'valid'> & { valid<T = unknown>(target: ValidTargetKey): T };\n json<TStatusCode extends ContentfulStatusCode = 200>(\n body: ResponseBody,\n status?: TStatusCode,\n ): TJsonResponse<ResponseBody, TStatusCode>;\n};\n\nexport type TRouteContext<RouteEnv extends Env = Env, ResponseBody = unknown> = TContext<\n RouteEnv,\n keyof IValidRequestProps,\n ResponseBody\n>;\n\n/** Lightweight handler type using TTypedContext to avoid heavy RouteHandler inference. */\nexport type TRouteHandler<ResponseType = unknown, RouteEnv extends Env = Env> = (\n context: TRouteContext<RouteEnv, ResponseType>,\n) => ValueOrPromise<Response | TypedResponse<ResponseType>>;\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../src/base/controllers/common/types/context.ts"],"names":[],"mappings":"","sourcesContent":["import type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { Context, Env, TypedResponse } from 'hono';\nimport type { ContentfulStatusCode, StatusCode } from 'hono/utils/http-status';\n\n/** Typed validation results for route handlers. */\nexport interface IValidRequestProps<\n JsonType = unknown,\n QueryType = unknown,\n ParamType = unknown,\n HeaderType = unknown,\n CookieType = unknown,\n FormType = unknown,\n> {\n json?: JsonType;\n query?: QueryType;\n param?: ParamType;\n header?: HeaderType;\n cookie?: CookieType;\n form?: FormType;\n}\n\n/** A Hono JSON `Response` typed with its body and status code. */\nexport type TJsonResponse<\n ResponseBody = unknown,\n ResponseStatusCode extends StatusCode = StatusCode,\n> = Response & TypedResponse<ResponseBody, ResponseStatusCode, 'json'>;\n\n/** Polymorphic response body for endpoints honoring the `x-request-count-data` header - the count-wrapped `{ count, data }` or the raw payload; pass the unwrapped payload type as `T`. */\nexport type TCountResponse<TData = unknown> = TData | { count: number; data: TData };\n\n/** Lightweight typed context that bypasses RouteHandler inference. */\nexport type TContext<\n RouteEnv extends Env = Env,\n ValidTargetKey extends string = string,\n ResponseBody = unknown,\n> = Omit<Context<RouteEnv>, 'req' | 'json'> & {\n req: Omit<Context<RouteEnv>['req'], 'valid'> & { valid<T = unknown>(target: ValidTargetKey): T };\n json<TStatusCode extends ContentfulStatusCode = 200>(\n body: ResponseBody,\n status?: TStatusCode,\n ): TJsonResponse<ResponseBody, TStatusCode>;\n};\n\n/** A `TContext` whose `req.valid()` targets are the keys of `IValidRequestProps` (`json`, `query`, `param`, `header`, `cookie`, `form`). */\nexport type TRouteContext<RouteEnv extends Env = Env, ResponseBody = unknown> = TContext<\n RouteEnv,\n keyof IValidRequestProps,\n ResponseBody\n>;\n\n/** Lightweight handler type using TTypedContext to avoid heavy RouteHandler inference. */\nexport type TRouteHandler<ResponseType = unknown, RouteEnv extends Env = Env> = (\n context: TRouteContext<RouteEnv, ResponseType>,\n) => ValueOrPromise<Response | TypedResponse<ResponseType>>;\n"]}
|
|
@@ -24,7 +24,11 @@ export interface IControllerOptions {
|
|
|
24
24
|
scope: string;
|
|
25
25
|
/** Falls back to @controller decorator path if not provided. */
|
|
26
26
|
path?: string;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* When true, /users and /users/ are different routes.
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
28
32
|
isStrict?: boolean;
|
|
29
33
|
}
|
|
30
34
|
/** Read object inferred from an entity's engine-neutral `$inferData` phantom marker - each family fills it with its own type, so the base layer needs no connector import; falls back to `object`. */
|