@venizia/ignis-kernel 0.4.2 → 0.4.3
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/cjs/base/applications/common/constants.d.ts +9 -0
- package/dist/cjs/base/applications/common/constants.d.ts.map +1 -1
- package/dist/cjs/base/applications/common/constants.js +11 -1
- package/dist/cjs/base/applications/common/constants.js.map +1 -1
- package/dist/cjs/base/applications/common/types/middlewares.d.ts +2 -2
- package/dist/cjs/base/applications/common/types/middlewares.d.ts.map +1 -1
- package/dist/cjs/base/applications/common/types/middlewares.js.map +1 -1
- package/dist/cjs/base/applications/deprecations.d.ts +2 -2
- package/dist/cjs/base/applications/deprecations.js +7 -7
- package/dist/cjs/base/applications/deprecations.js.map +1 -1
- package/dist/cjs/base/applications/rest.js +1 -1
- package/dist/cjs/base/applications/rest.js.map +1 -1
- package/dist/cjs/base/auth/authenticate/common/constants/jose.d.ts +10 -0
- package/dist/cjs/base/auth/authenticate/common/constants/jose.d.ts.map +1 -1
- package/dist/cjs/base/auth/authenticate/common/constants/jose.js +12 -1
- package/dist/cjs/base/auth/authenticate/common/constants/jose.js.map +1 -1
- package/dist/cjs/base/auth/authenticate/common/types/jwt.d.ts +1 -2
- package/dist/cjs/base/auth/authenticate/common/types/jwt.d.ts.map +1 -1
- package/dist/cjs/base/auth/authenticate/common/types/jwt.js.map +1 -1
- package/dist/cjs/base/auth/authorize/common/constants/authorization.d.ts +11 -0
- package/dist/cjs/base/auth/authorize/common/constants/authorization.d.ts.map +1 -1
- package/dist/cjs/base/auth/authorize/common/constants/authorization.js +13 -1
- package/dist/cjs/base/auth/authorize/common/constants/authorization.js.map +1 -1
- package/dist/cjs/base/auth/authorize/common/types/request.d.ts +2 -1
- package/dist/cjs/base/auth/authorize/common/types/request.d.ts.map +1 -1
- package/dist/cjs/base/auth/authorize/common/types/request.js.map +1 -1
- package/dist/cjs/base/auth/authorize/providers/request-domain.js +4 -4
- package/dist/cjs/base/auth/authorize/providers/request-domain.js.map +1 -1
- package/dist/cjs/base/controllers/common/constants.d.ts +10 -0
- package/dist/cjs/base/controllers/common/constants.d.ts.map +1 -1
- package/dist/cjs/base/controllers/common/constants.js +12 -1
- package/dist/cjs/base/controllers/common/constants.js.map +1 -1
- package/dist/cjs/base/controllers/factory/controller.d.ts +1 -1
- package/dist/cjs/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/cjs/base/controllers/rest/abstract.d.ts +2 -1
- package/dist/cjs/base/controllers/rest/abstract.d.ts.map +1 -1
- package/dist/cjs/base/controllers/rest/abstract.js +6 -4
- package/dist/cjs/base/controllers/rest/abstract.js.map +1 -1
- package/dist/cjs/base/metadata/model-metadata.d.ts +17 -0
- package/dist/cjs/base/metadata/model-metadata.d.ts.map +1 -0
- package/dist/cjs/base/metadata/model-metadata.js +50 -0
- package/dist/cjs/base/metadata/model-metadata.js.map +1 -0
- package/dist/cjs/base/metadata/model-settings.d.ts +7 -17
- package/dist/cjs/base/metadata/model-settings.d.ts.map +1 -1
- package/dist/cjs/base/metadata/model-settings.js +22 -65
- package/dist/cjs/base/metadata/model-settings.js.map +1 -1
- package/dist/cjs/base/metadata/persistents.d.ts +1 -1
- package/dist/cjs/base/metadata/persistents.d.ts.map +1 -1
- package/dist/cjs/base/metadata/persistents.js +5 -12
- package/dist/cjs/base/metadata/persistents.js.map +1 -1
- package/dist/cjs/base/models/common/constants.d.ts +17 -0
- package/dist/cjs/base/models/common/constants.d.ts.map +1 -1
- package/dist/cjs/base/models/common/constants.js +20 -1
- package/dist/cjs/base/models/common/constants.js.map +1 -1
- package/dist/cjs/base/models/common/schemas.d.ts +1 -1
- package/dist/cjs/base/models/common/schemas.d.ts.map +1 -1
- package/dist/cjs/base/models/common/schemas.js.map +1 -1
- package/dist/cjs/base/models/common/types/id.d.ts +0 -2
- package/dist/cjs/base/models/common/types/id.d.ts.map +1 -1
- package/dist/cjs/base/models/common/types/id.js.map +1 -1
- package/dist/cjs/helpers/inversion/common/constants.d.ts +10 -0
- package/dist/cjs/helpers/inversion/common/constants.d.ts.map +1 -1
- package/dist/cjs/helpers/inversion/common/constants.js +11 -1
- package/dist/cjs/helpers/inversion/common/constants.js.map +1 -1
- package/dist/cjs/helpers/inversion/common/types/model.d.ts +17 -29
- package/dist/cjs/helpers/inversion/common/types/model.d.ts.map +1 -1
- package/dist/cjs/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/cjs/helpers/inversion/mixins/model.mixin.d.ts +5 -4
- package/dist/cjs/helpers/inversion/mixins/model.mixin.d.ts.map +1 -1
- package/dist/cjs/helpers/inversion/mixins/model.mixin.js +5 -4
- package/dist/cjs/helpers/inversion/mixins/model.mixin.js.map +1 -1
- package/dist/esm/base/applications/common/constants.d.ts +9 -0
- package/dist/esm/base/applications/common/constants.d.ts.map +1 -1
- package/dist/esm/base/applications/common/constants.js +9 -0
- package/dist/esm/base/applications/common/constants.js.map +1 -1
- package/dist/esm/base/applications/common/types/middlewares.d.ts +2 -2
- package/dist/esm/base/applications/common/types/middlewares.d.ts.map +1 -1
- package/dist/esm/base/applications/common/types/middlewares.js.map +1 -1
- package/dist/esm/base/applications/deprecations.d.ts +2 -2
- package/dist/esm/base/applications/deprecations.js +5 -5
- package/dist/esm/base/applications/deprecations.js.map +1 -1
- package/dist/esm/base/applications/rest.js +2 -2
- package/dist/esm/base/applications/rest.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/constants/jose.d.ts +10 -0
- package/dist/esm/base/auth/authenticate/common/constants/jose.d.ts.map +1 -1
- package/dist/esm/base/auth/authenticate/common/constants/jose.js +10 -0
- package/dist/esm/base/auth/authenticate/common/constants/jose.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts +1 -2
- package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/jwt.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts +11 -0
- package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/authorization.js +11 -0
- package/dist/esm/base/auth/authorize/common/constants/authorization.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/request.d.ts +2 -1
- package/dist/esm/base/auth/authorize/common/types/request.d.ts.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/request.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/request-domain.js +5 -5
- package/dist/esm/base/auth/authorize/providers/request-domain.js.map +1 -1
- package/dist/esm/base/controllers/common/constants.d.ts +10 -0
- package/dist/esm/base/controllers/common/constants.d.ts.map +1 -1
- package/dist/esm/base/controllers/common/constants.js +10 -0
- package/dist/esm/base/controllers/common/constants.js.map +1 -1
- package/dist/esm/base/controllers/factory/controller.d.ts +1 -1
- package/dist/esm/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/esm/base/controllers/rest/abstract.d.ts +2 -1
- package/dist/esm/base/controllers/rest/abstract.d.ts.map +1 -1
- package/dist/esm/base/controllers/rest/abstract.js +6 -4
- package/dist/esm/base/controllers/rest/abstract.js.map +1 -1
- package/dist/esm/base/metadata/model-metadata.d.ts +17 -0
- package/dist/esm/base/metadata/model-metadata.d.ts.map +1 -0
- package/dist/esm/base/metadata/model-metadata.js +46 -0
- package/dist/esm/base/metadata/model-metadata.js.map +1 -0
- package/dist/esm/base/metadata/model-settings.d.ts +7 -17
- package/dist/esm/base/metadata/model-settings.d.ts.map +1 -1
- package/dist/esm/base/metadata/model-settings.js +20 -63
- package/dist/esm/base/metadata/model-settings.js.map +1 -1
- package/dist/esm/base/metadata/persistents.d.ts +1 -1
- package/dist/esm/base/metadata/persistents.d.ts.map +1 -1
- package/dist/esm/base/metadata/persistents.js +6 -13
- package/dist/esm/base/metadata/persistents.js.map +1 -1
- package/dist/esm/base/models/common/constants.d.ts +17 -0
- package/dist/esm/base/models/common/constants.d.ts.map +1 -1
- package/dist/esm/base/models/common/constants.js +17 -0
- package/dist/esm/base/models/common/constants.js.map +1 -1
- package/dist/esm/base/models/common/schemas.d.ts +1 -1
- package/dist/esm/base/models/common/schemas.d.ts.map +1 -1
- package/dist/esm/base/models/common/schemas.js.map +1 -1
- package/dist/esm/base/models/common/types/id.d.ts +0 -2
- package/dist/esm/base/models/common/types/id.d.ts.map +1 -1
- package/dist/esm/base/models/common/types/id.js.map +1 -1
- package/dist/esm/helpers/inversion/common/constants.d.ts +10 -0
- package/dist/esm/helpers/inversion/common/constants.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/common/constants.js +9 -0
- package/dist/esm/helpers/inversion/common/constants.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.d.ts +17 -29
- package/dist/esm/helpers/inversion/common/types/model.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/esm/helpers/inversion/mixins/model.mixin.d.ts +5 -4
- package/dist/esm/helpers/inversion/mixins/model.mixin.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/mixins/model.mixin.js +5 -4
- package/dist/esm/helpers/inversion/mixins/model.mixin.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-domain.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/providers/request-domain.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"request-domain.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authorize/providers/request-domain.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAO5F,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAG/B,EAAqB,EAAE;IACtB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,0BAA0B,CAAC,KAAK,CA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5C,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7D,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,WAAW,CAAC;IACvF,CAAC;IAED,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,IAAI,CAAC;IACvD,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,OAAO,QAAQ;YACb,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACxC,CAAC,CAAC,yBAAyB,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,OAAO,yBAAyB,CAAC,WAAW,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { Env } from 'hono';\nimport { AuthorizationDomainScopes, AuthorizationDomainSources } from '../common/constants';\nimport type {\n IAuthorizationDomainSource,\n IAuthorizationSpec,\n IAuthorizeOptions,\n} from '../common/types';\n\n/** Read a domain value from a declarative source on the Hono context. */\nexport const readDeclarative = (opts: {\n source: IAuthorizationDomainSource;\n context: TContext<Env, string>;\n}): TNullable<string> => {\n const { source, context } = opts;\n switch (source.from) {\n case AuthorizationDomainSources.PARAM: {\n return context.req.param(source.key) ?? null;\n }\n case AuthorizationDomainSources.HEADER: {\n return context.req.header(source.key) ?? null;\n }\n case AuthorizationDomainSources.QUERY: {\n return context.req.query(source.key) ?? null;\n }\n case AuthorizationDomainSources.CONTEXT: {\n const value = context.get(source.key as any);\n return value == null ? null : String(value);\n }\n default: {\n return null;\n }\n }\n};\n\n/** Resolve the request domain, precedence spec.domain (method | declarative) -> options.domainResolver -> SYSTEM_WIDE, as a casbin domain string (\"<type>_<id>\") or the SYSTEM_WIDE sentinel. */\nexport const resolveRequestDomain = async (opts: {\n spec: IAuthorizationSpec;\n context: TContext<Env, string>;\n options: TNullable<IAuthorizeOptions>;\n}): Promise<string> => {\n const { spec, context, options } = opts;\n\n if (typeof spec.domain === 'function') {\n const resolved = await spec.domain({ context });\n return resolved\n ? [resolved.type, resolved.id].join('_')\n : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n if (spec.domain) {\n const id = readDeclarative({ source: spec.domain, context });\n return id ? [spec.domain.type, id].join('_') : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n const globalResolver = options?.domainResolver ?? null;\n if (globalResolver) {\n const resolved = await globalResolver({ context });\n return resolved\n ? [resolved.type, resolved.id].join('_')\n : AuthorizationDomainScopes.SYSTEM_WIDE;\n }\n\n return AuthorizationDomainScopes.SYSTEM_WIDE;\n};\n"]}
|
|
@@ -27,4 +27,14 @@ export declare class RestPaths {
|
|
|
27
27
|
}
|
|
28
28
|
export declare const commonResponseHeaders: TResponseHeaders;
|
|
29
29
|
export declare const findResponseHeaders: TResponseHeaders;
|
|
30
|
+
/** Which decorator-defined routes `registerRoutesFromRegistry` registers: STATIC (no path parameter), PARAM (a path parameter) or ALL. */
|
|
31
|
+
export declare class RoutePathScopes {
|
|
32
|
+
static readonly STATIC = "static";
|
|
33
|
+
static readonly PARAM = "param";
|
|
34
|
+
static readonly ALL = "all";
|
|
35
|
+
static readonly SCHEME_SET: Set<string>;
|
|
36
|
+
static isValid(value: string): boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Valid route path scope values. */
|
|
39
|
+
export type TRoutePathScope = TConstValue<typeof RoutePathScopes>;
|
|
30
40
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/base/controllers/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AAEH,oDAAoD;AACpD,qBAAa,oBAAoB;IAC/B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;CAC/B;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E,iGAAiG;AACjG,qBAAa,eAAe;IAC1B,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAEhC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA8C;IAExE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,eAAe,CAAC,CAAC;AAElE,6DAA6D;AAC7D,qBAAa,SAAS;IACpB,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAO;IAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,YAAY;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,eAAe;CACxC;AAED,eAAO,MAAM,qBAAqB,EAAE,gBAanC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAMjC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/base/controllers/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;GAIG;AAEH,oDAAoD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47
47
|
};
|
|
48
|
+
/** Which decorator-defined routes `registerRoutesFromRegistry` registers: STATIC (no path parameter), PARAM (a path parameter) or ALL. */
|
|
49
|
+
export class RoutePathScopes {
|
|
50
|
+
static { this.STATIC = 'static'; }
|
|
51
|
+
static { this.PARAM = 'param'; }
|
|
52
|
+
static { this.ALL = 'all'; }
|
|
53
|
+
static { this.SCHEME_SET = new Set([this.STATIC, this.PARAM, this.ALL]); }
|
|
54
|
+
static isValid(value) {
|
|
55
|
+
return this.SCHEME_SET.has(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
48
58
|
//# sourceMappingURL=constants.js.map
|
|
@@ -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;;AAKhC,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;;AAKH,6DAA6D;AAC7D,MAAM,OAAO,SAAS;aACJ,SAAI,GAAG,GAAG,CAAC;aACX,UAAK,GAAG,QAAQ,CAAC;aACjB,aAAQ,GAAG,WAAW,CAAC;;AAGzC,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;QACjC,WAAW,EAAE,gCAAgC;QAC7C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC3B;IACD,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE;QAClC,WAAW,EAAE,+BAA+B;QAC5C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE;KACzD;IACD,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QAC9B,WAAW,EAAE,2BAA2B;QACxC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;KAC1D;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACnD,GAAG,qBAAqB;IACxB,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAC5B,WAAW,EAAE,yDAAyD;QACtE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,EAAE;KAChF;CACF,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\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\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\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\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"]}
|
|
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;;AAKhC,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;;AAKH,6DAA6D;AAC7D,MAAM,O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,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\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\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\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\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"]}
|
|
@@ -176,7 +176,7 @@ export declare class ControllerFactory extends BaseHelper {
|
|
|
176
176
|
definitions: Record<string, import("../index.js").IAuthRouteConfig>;
|
|
177
177
|
getRouter(): import("@hono/zod-openapi").OpenAPIHono<RouteEnv, RouteSchema, BasePath>;
|
|
178
178
|
registerRoutesFromRegistry(opts?: {
|
|
179
|
-
paths?: "
|
|
179
|
+
paths?: import("../index.js").TRoutePathScope;
|
|
180
180
|
}): void;
|
|
181
181
|
configure(opts?: ConfigurableOptions | undefined): Promise<import("@hono/zod-openapi").OpenAPIHono<RouteEnv, RouteSchema, BasePath>>;
|
|
182
182
|
buildRouteMiddlewares<RouteConfig extends import("../index.js").IAuthRouteConfig>(opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../../../src/base/controllers/factory/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAY,MAAM,6BAA6B,CAAC;AAEnE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,E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OpenAPIHono } from '@hono/zod-openapi';
|
|
3
4
|
import type { ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
@@ -15,7 +16,7 @@ export declare abstract class AbstractRestController<RouteEnv extends Env = Env,
|
|
|
15
16
|
getRouter(): OpenAPIHono<RouteEnv, RouteSchema, BasePath>;
|
|
16
17
|
/** Registers decorator-defined routes from the metadata registry; `paths` selects them by shape - see the two-phase call in {@link configure}. */
|
|
17
18
|
registerRoutesFromRegistry(opts?: {
|
|
18
|
-
paths?:
|
|
19
|
+
paths?: TRoutePathScope;
|
|
19
20
|
}): void;
|
|
20
21
|
/** Configures the controller by binding all routes and registering decorator-based routes. Idempotent. */
|
|
21
22
|
configure(opts?: ConfigurableOptions): Promise<OpenAPIHono<RouteEnv, RouteSchema, BasePath>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../../../src/base/controllers/rest/abstract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../../../src/base/controllers/rest/abstract.ts"],"names":[],"mappings":"AAQA,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE5F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAY,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAOzB,kHAAkH;AAClH,8BAAsB,sBAAsB,CAC1C,QAAQ,SAAS,GAAG,GAA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AAW,SAAS,gBAAgB,EAAE,IAAI,EAAE;QAC7D,OAAO,EAAE,WAAW,CAAC;KACtB,GAAG,iBAAiB,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC;IAEnE,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,WAAW,SAAS,gBAAgB,EAAE,YAAY,GAAG,OAAO,EAAE,IAAI,EAAE;QACvF,OAAO,EAAE,WAAW,CAAC;QACrB,OAAO,EAAE,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;KACzD,GAAG,mBAAmB,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC;CACtE"}
|
|
@@ -5,6 +5,7 @@ import { formBodyReader, hasFormBody } from '../../middlewares/form-body/form-bo
|
|
|
5
5
|
import { AuthenticationStrategyRegistry } from '../../auth/authenticate/strategies/strategy-registry.js';
|
|
6
6
|
import { DroppedRouteDecorators } from '../../metadata/routes/common.js';
|
|
7
7
|
import { MetadataRegistry } from '../../../helpers/inversion/registry.js';
|
|
8
|
+
import { RoutePathScopes } from '../common/constants.js';
|
|
8
9
|
import { htmlResponse } from '../common/html-response.js';
|
|
9
10
|
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
10
11
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
@@ -43,7 +44,7 @@ export class AbstractRestController extends BaseHelper {
|
|
|
43
44
|
}
|
|
44
45
|
/** Registers decorator-defined routes from the metadata registry; `paths` selects them by shape - see the two-phase call in {@link configure}. */
|
|
45
46
|
registerRoutesFromRegistry(opts) {
|
|
46
|
-
const { paths =
|
|
47
|
+
const { paths = RoutePathScopes.ALL } = opts ?? {};
|
|
47
48
|
const logger = this.logger.for(this.registerRoutesFromRegistry.name);
|
|
48
49
|
DroppedRouteDecorators.report({ logger });
|
|
49
50
|
const routes = MetadataRegistry.getInstance().getRoutes({
|
|
@@ -54,7 +55,8 @@ export class AbstractRestController extends BaseHelper {
|
|
|
54
55
|
}
|
|
55
56
|
const routeDefs = routes.entries();
|
|
56
57
|
for (const [methodName, routeConfigs] of routeDefs) {
|
|
57
|
-
if (paths !==
|
|
58
|
+
if (paths !== RoutePathScopes.ALL &&
|
|
59
|
+
hasPathParam({ path: routeConfigs.path }) !== (paths === RoutePathScopes.PARAM)) {
|
|
58
60
|
continue;
|
|
59
61
|
}
|
|
60
62
|
// Dynamic dispatch by decorator-recorded method name - the controller class has no static index signature, so this read cannot be typed narrower than `unknown`.
|
|
@@ -78,9 +80,9 @@ export class AbstractRestController extends BaseHelper {
|
|
|
78
80
|
const configureOptions = opts ?? {};
|
|
79
81
|
logger.info('START | Binding controller | Options: %j', configureOptions);
|
|
80
82
|
// Hono matches in registration order, so registration runs by SHAPE not source: every static path first, then binding()'s routes, then decorator param routes last (`/{id}` early would eat `/count`).
|
|
81
|
-
this.registerRoutesFromRegistry({ paths:
|
|
83
|
+
this.registerRoutesFromRegistry({ paths: RoutePathScopes.STATIC });
|
|
82
84
|
await this.binding();
|
|
83
|
-
this.registerRoutesFromRegistry({ paths:
|
|
85
|
+
this.registerRoutesFromRegistry({ paths: RoutePathScopes.PARAM });
|
|
84
86
|
this.isConfigured = true;
|
|
85
87
|
logger.info('DONE | Binding controller | Took: %s (ms)', performance.now() - t);
|
|
86
88
|
return this.router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/controllers/rest/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAE9G,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,wDAAwD,CAAC;AAClG,O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,IAAI,CAAC,KAAK,CAAC;YAC3B,QAAQ;SACT,CAAQ,CACV,CAAC;IACJ,CAAC;CAeF","sourcesContent":["import { AuthenticationModes } from '@/base/auth/authenticate/common/constants';\nimport { authenticate as authenticateFn } from '@/base/auth/authenticate/middlewares/authenticate.middleware';\nimport type { IAuthorizationSpec } from '@/base/auth/authorize/common/types';\nimport { authorize as authorizeFn } from '@/base/auth/authorize/middlewares/authorize.middleware';\nimport { formBodyReader, hasFormBody } from '@/base/middlewares/form-body/form-body.middleware';\nimport { AuthenticationStrategyRegistry } from '@/base/auth/authenticate/strategies/strategy-registry';\nimport { DroppedRouteDecorators } from '@/base/metadata/routes/common';\nimport { MetadataRegistry } from '@/helpers/inversion/registry';\nimport { htmlResponse } from '@/base/controllers/common/html-response';\nimport type { Hook } from '@hono/zod-openapi';\nimport { createRoute, OpenAPIHono } from '@hono/zod-openapi';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { Env, Schema } from 'hono';\nimport type {\n IAuthRouteConfig,\n IBindRouteOptions,\n IController,\n IControllerOptions,\n IDefineRouteOptions,\n TRouteHandler,\n} from '../common/types';\n\n/** True for a route path carrying a path parameter, in either supported syntax: `/{id}` or `/:id`. */\nconst hasPathParam = (opts: { path: string }): boolean => {\n return /\\{[^}]+\\}|:[^/]+/.test(opts.path);\n};\n\n/** Abstract base class for all REST controllers, providing route registration and auth middleware integration. */\nexport abstract class AbstractRestController<\n RouteEnv extends Env = Env,\n RouteSchema extends Schema = {},\n BasePath extends string = '/',\n ConfigurableOptions extends object = {},\n Definitions extends Record<string, IAuthRouteConfig> = Record<string, IAuthRouteConfig>,\n>\n extends BaseHelper\n implements IController<RouteEnv, RouteSchema, BasePath, ConfigurableOptions>\n{\n isConfigured = false;\n router: OpenAPIHono<RouteEnv, RouteSchema, BasePath>;\n path: string;\n definitions: Definitions;\n\n constructor(opts: IControllerOptions) {\n super(opts);\n const { isStrict = true } = opts;\n\n const decoratorMetadata = MetadataRegistry.getInstance().getControllerMetadata({\n target: new.target,\n });\n const resolvedPath = decoratorMetadata?.path ?? opts.path;\n\n if (!resolvedPath) {\n throw getError({\n message: `[${new.target.name}] Controller path is required. Provide path via @controller decorator or constructor options.`,\n });\n }\n\n this.path = resolvedPath;\n\n this.router = new OpenAPIHono<RouteEnv, RouteSchema, BasePath>({\n strict: isStrict,\n defaultHook: (result, _context) => {\n if (!result.success) {\n throw result.error;\n }\n },\n });\n }\n\n /** Returns the OpenAPIHono router instance for this controller. */\n getRouter() {\n return this.router;\n }\n\n /** Registers decorator-defined routes from the metadata registry; `paths` selects them by shape - see the two-phase call in {@link configure}. */\n registerRoutesFromRegistry(opts?: { paths?: 'static' | 'param' | 'all' }): void {\n const { paths = 'all' } = opts ?? {};\n\n const logger = this.logger.for(this.registerRoutesFromRegistry.name);\n DroppedRouteDecorators.report({ logger });\n\n const routes = MetadataRegistry.getInstance().getRoutes({\n target: Object.getPrototypeOf(this),\n });\n\n if (!routes?.size) {\n return;\n }\n\n const routeDefs = routes.entries();\n for (const [methodName, routeConfigs] of routeDefs) {\n if (paths !== 'all' && hasPathParam({ path: routeConfigs.path }) !== (paths === 'param')) {\n continue;\n }\n\n // Dynamic dispatch by decorator-recorded method name - the controller class has no static index signature, so this read cannot be typed narrower than `unknown`.\n const handler = (this as Record<string | symbol, unknown>)[methodName];\n if (typeof handler !== 'function') {\n logger.warn('Route method \"%s\" not found on controller', String(methodName));\n continue;\n }\n\n this.bindRoute({ configs: routeConfigs }).to({\n handler: (handler as TRouteHandler<unknown, RouteEnv>).bind(this),\n });\n }\n }\n\n /** Configures the controller by binding all routes and registering decorator-based routes. Idempotent. */\n async configure(\n opts?: ConfigurableOptions,\n ): Promise<OpenAPIHono<RouteEnv, RouteSchema, BasePath>> {\n if (this.isConfigured) {\n return this.router;\n }\n\n const t = performance.now();\n const logger = this.logger.for(this.configure.name);\n\n const configureOptions = opts ?? {};\n logger.info('START | Binding controller | Options: %j', configureOptions);\n\n // Hono matches in registration order, so registration runs by SHAPE not source: every static path first, then binding()'s routes, then decorator param routes last (`/{id}` early would eat `/count`).\n this.registerRoutesFromRegistry({ paths: 'static' });\n await this.binding();\n this.registerRoutesFromRegistry({ paths: 'param' });\n\n this.isConfigured = true;\n logger.info('DONE | Binding controller | Took: %s (ms)', performance.now() - t);\n return this.router;\n }\n\n /** @internal Builds auth + custom middlewares and security specs from route config. */\n buildRouteMiddlewares<RouteConfig extends IAuthRouteConfig>(opts: { configs: RouteConfig }) {\n const { authenticate = {}, authorize, ...restConfig } = opts.configs;\n const { strategies = [], mode = AuthenticationModes.ANY } = authenticate;\n\n // Boot-time and NON-fatal: names a misspelled strategy at error level instead of leaving it as\n // a 401 nobody can explain. Deliberately not a throw - `defineAuthController` hard-codes `jwt`\n // on four routes, and ANY mode tolerates a strategy that does not resolve, so failing here would\n // stop applications booting that work today. `assertRegistered` is there for an application that\n // does want the hard failure.\n AuthenticationStrategyRegistry.getInstance().reportUnregistered({\n names: strategies,\n scope: this.constructor.name,\n });\n\n const security = strategies.map((strategy: string) => ({ [strategy]: [] }));\n const mws: ReturnType<typeof authenticateFn>[] = [];\n\n if (strategies.length > 0) {\n mws.push(authenticateFn({ strategies, mode }));\n }\n\n // Inject authorize middleware AFTER authenticate\n if (authorize) {\n const specs: IAuthorizationSpec[] = Array.isArray(authorize) ? authorize : [authorize];\n for (const spec of specs) {\n mws.push(authorizeFn({ spec }));\n }\n }\n\n const configuredMiddleware = restConfig.middleware;\n const extraMws = Array.isArray(configuredMiddleware)\n ? configuredMiddleware\n : [configuredMiddleware];\n\n for (const mw of extraMws) {\n if (!mw) {\n continue;\n }\n\n mws.push(mw);\n }\n\n // Last: an application middleware and any size check run before the body is read.\n if (hasFormBody({ content: restConfig.request?.body?.content })) {\n mws.push(formBodyReader);\n }\n\n return { restConfig, security, mws };\n }\n\n /** Processes route config, injecting auth middleware and OpenAPI security specs. */\n getRouteConfigs<RouteConfig extends IAuthRouteConfig>(opts: { configs: RouteConfig }) {\n const { restConfig, security, mws } = this.buildRouteMiddlewares(opts);\n const { tags = [] } = restConfig;\n\n // `restConfig` already omitted `authenticate`/`authorize` (this library's fields, not Hono's `createRoute` ones); reassembled with the injected middleware/tags/security it no longer structurally overlaps RouteConfig enough to assert directly.\n return createRoute<string, RouteConfig>(\n Object.assign({}, restConfig, {\n middleware: mws,\n tags: [...tags, this.scope],\n security,\n }) as any,\n );\n }\n\n /** Like getRouteConfigs but adds HTML response schema for JSX rendering. */\n getJSXRouteConfigs<RouteConfig extends IAuthRouteConfig>(opts: { configs: RouteConfig }) {\n const { restConfig, security, mws } = this.buildRouteMiddlewares(opts);\n const { responses, tags = [] } = restConfig;\n\n // Same reassembled-vs-RouteConfig boundary as getRouteConfigs above.\n return createRoute<string, RouteConfig>(\n Object.assign({}, restConfig, {\n middleware: mws,\n responses: Object.assign({}, htmlResponse({ description: 'HTML page' }), responses),\n tags: [...tags, this.scope],\n security,\n }) as any,\n );\n }\n /** Override to register routes using bindRoute or defineRoute. */\n abstract binding(): ValueOrPromise<void>;\n\n /** Creates a fluent binding for registering a route (call .to() to attach handler). */\n abstract bindRoute<RouteConfig extends IAuthRouteConfig>(opts: {\n configs: RouteConfig;\n }): IBindRouteOptions<RouteConfig, RouteEnv, RouteSchema, BasePath>;\n\n /** Defines and registers a route with its handler in a single call. */\n abstract defineRoute<RouteConfig extends IAuthRouteConfig, ResponseType = unknown>(opts: {\n configs: RouteConfig;\n handler: TRouteHandler<ResponseType, RouteEnv>;\n hook?: Hook<any, RouteEnv, string, ValueOrPromise<any>>;\n }): IDefineRouteOptions<RouteConfig, RouteEnv, RouteSchema, BasePath>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/controllers/rest/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,YAAY,IAAI,cAAc,EAAE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AE,EAAE,UAAU,EAAE;YAC5B,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,CAAC;YACnF,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;YAC3B,QAAQ;SACT,CAAQ,CACV,CAAC;IACJ,CAAC;CAeF","sourcesContent":["import { AuthenticationModes } from '@/base/auth/authenticate/common/constants';\nimport { authenticate as authenticateFn } from '@/base/auth/authenticate/middlewares/authenticate.middleware';\nimport type { IAuthorizationSpec } from '@/base/auth/authorize/common/types';\nimport { authorize as authorizeFn } from '@/base/auth/authorize/middlewares/authorize.middleware';\nimport { formBodyReader, hasFormBody } from '@/base/middlewares/form-body/form-body.middleware';\nimport { AuthenticationStrategyRegistry } from '@/base/auth/authenticate/strategies/strategy-registry';\nimport { DroppedRouteDecorators } from '@/base/metadata/routes/common';\nimport { MetadataRegistry } from '@/helpers/inversion/registry';\nimport { RoutePathScopes, type TRoutePathScope } from '@/base/controllers/common/constants';\nimport { htmlResponse } from '@/base/controllers/common/html-response';\nimport type { Hook } from '@hono/zod-openapi';\nimport { createRoute, OpenAPIHono } from '@hono/zod-openapi';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { Env, Schema } from 'hono';\nimport type {\n IAuthRouteConfig,\n IBindRouteOptions,\n IController,\n IControllerOptions,\n IDefineRouteOptions,\n TRouteHandler,\n} from '../common/types';\n\n/** True for a route path carrying a path parameter, in either supported syntax: `/{id}` or `/:id`. */\nconst hasPathParam = (opts: { path: string }): boolean => {\n return /\\{[^}]+\\}|:[^/]+/.test(opts.path);\n};\n\n/** Abstract base class for all REST controllers, providing route registration and auth middleware integration. */\nexport abstract class AbstractRestController<\n RouteEnv extends Env = Env,\n RouteSchema extends Schema = {},\n BasePath extends string = '/',\n ConfigurableOptions extends object = {},\n Definitions extends Record<string, IAuthRouteConfig> = Record<string, IAuthRouteConfig>,\n>\n extends BaseHelper\n implements IController<RouteEnv, RouteSchema, BasePath, ConfigurableOptions>\n{\n isConfigured = false;\n router: OpenAPIHono<RouteEnv, RouteSchema, BasePath>;\n path: string;\n definitions: Definitions;\n\n constructor(opts: IControllerOptions) {\n super(opts);\n const { isStrict = true } = opts;\n\n const decoratorMetadata = MetadataRegistry.getInstance().getControllerMetadata({\n target: new.target,\n });\n const resolvedPath = decoratorMetadata?.path ?? opts.path;\n\n if (!resolvedPath) {\n throw getError({\n message: `[${new.target.name}] Controller path is required. Provide path via @controller decorator or constructor options.`,\n });\n }\n\n this.path = resolvedPath;\n\n this.router = new OpenAPIHono<RouteEnv, RouteSchema, BasePath>({\n strict: isStrict,\n defaultHook: (result, _context) => {\n if (!result.success) {\n throw result.error;\n }\n },\n });\n }\n\n /** Returns the OpenAPIHono router instance for this controller. */\n getRouter() {\n return this.router;\n }\n\n /** Registers decorator-defined routes from the metadata registry; `paths` selects them by shape - see the two-phase call in {@link configure}. */\n registerRoutesFromRegistry(opts?: { paths?: TRoutePathScope }): void {\n const { paths = RoutePathScopes.ALL } = opts ?? {};\n\n const logger = this.logger.for(this.registerRoutesFromRegistry.name);\n DroppedRouteDecorators.report({ logger });\n\n const routes = MetadataRegistry.getInstance().getRoutes({\n target: Object.getPrototypeOf(this),\n });\n\n if (!routes?.size) {\n return;\n }\n\n const routeDefs = routes.entries();\n for (const [methodName, routeConfigs] of routeDefs) {\n if (\n paths !== RoutePathScopes.ALL &&\n hasPathParam({ path: routeConfigs.path }) !== (paths === RoutePathScopes.PARAM)\n ) {\n continue;\n }\n\n // Dynamic dispatch by decorator-recorded method name - the controller class has no static index signature, so this read cannot be typed narrower than `unknown`.\n const handler = (this as Record<string | symbol, unknown>)[methodName];\n if (typeof handler !== 'function') {\n logger.warn('Route method \"%s\" not found on controller', String(methodName));\n continue;\n }\n\n this.bindRoute({ configs: routeConfigs }).to({\n handler: (handler as TRouteHandler<unknown, RouteEnv>).bind(this),\n });\n }\n }\n\n /** Configures the controller by binding all routes and registering decorator-based routes. Idempotent. */\n async configure(\n opts?: ConfigurableOptions,\n ): Promise<OpenAPIHono<RouteEnv, RouteSchema, BasePath>> {\n if (this.isConfigured) {\n return this.router;\n }\n\n const t = performance.now();\n const logger = this.logger.for(this.configure.name);\n\n const configureOptions = opts ?? {};\n logger.info('START | Binding controller | Options: %j', configureOptions);\n\n // Hono matches in registration order, so registration runs by SHAPE not source: every static path first, then binding()'s routes, then decorator param routes last (`/{id}` early would eat `/count`).\n this.registerRoutesFromRegistry({ paths: RoutePathScopes.STATIC });\n await this.binding();\n this.registerRoutesFromRegistry({ paths: RoutePathScopes.PARAM });\n\n this.isConfigured = true;\n logger.info('DONE | Binding controller | Took: %s (ms)', performance.now() - t);\n return this.router;\n }\n\n /** @internal Builds auth + custom middlewares and security specs from route config. */\n buildRouteMiddlewares<RouteConfig extends IAuthRouteConfig>(opts: { configs: RouteConfig }) {\n const { authenticate = {}, authorize, ...restConfig } = opts.configs;\n const { strategies = [], mode = AuthenticationModes.ANY } = authenticate;\n\n // Boot-time and NON-fatal: names a misspelled strategy at error level instead of leaving it as\n // a 401 nobody can explain. Deliberately not a throw - `defineAuthController` hard-codes `jwt`\n // on four routes, and ANY mode tolerates a strategy that does not resolve, so failing here would\n // stop applications booting that work today. `assertRegistered` is there for an application that\n // does want the hard failure.\n AuthenticationStrategyRegistry.getInstance().reportUnregistered({\n names: strategies,\n scope: this.constructor.name,\n });\n\n const security = strategies.map((strategy: string) => ({ [strategy]: [] }));\n const mws: ReturnType<typeof authenticateFn>[] = [];\n\n if (strategies.length > 0) {\n mws.push(authenticateFn({ strategies, mode }));\n }\n\n // Inject authorize middleware AFTER authenticate\n if (authorize) {\n const specs: IAuthorizationSpec[] = Array.isArray(authorize) ? authorize : [authorize];\n for (const spec of specs) {\n mws.push(authorizeFn({ spec }));\n }\n }\n\n const configuredMiddleware = restConfig.middleware;\n const extraMws = Array.isArray(configuredMiddleware)\n ? configuredMiddleware\n : [configuredMiddleware];\n\n for (const mw of extraMws) {\n if (!mw) {\n continue;\n }\n\n mws.push(mw);\n }\n\n // Last: an application middleware and any size check run before the body is read.\n if (hasFormBody({ content: restConfig.request?.body?.content })) {\n mws.push(formBodyReader);\n }\n\n return { restConfig, security, mws };\n }\n\n /** Processes route config, injecting auth middleware and OpenAPI security specs. */\n getRouteConfigs<RouteConfig extends IAuthRouteConfig>(opts: { configs: RouteConfig }) {\n const { restConfig, security, mws } = this.buildRouteMiddlewares(opts);\n const { tags = [] } = restConfig;\n\n // `restConfig` already omitted `authenticate`/`authorize` (this library's fields, not Hono's `createRoute` ones); reassembled with the injected middleware/tags/security it no longer structurally overlaps RouteConfig enough to assert directly.\n return createRoute<string, RouteConfig>(\n Object.assign({}, restConfig, {\n middleware: mws,\n tags: [...tags, this.scope],\n security,\n }) as any,\n );\n }\n\n /** Like getRouteConfigs but adds HTML response schema for JSX rendering. */\n getJSXRouteConfigs<RouteConfig extends IAuthRouteConfig>(opts: { configs: RouteConfig }) {\n const { restConfig, security, mws } = this.buildRouteMiddlewares(opts);\n const { responses, tags = [] } = restConfig;\n\n // Same reassembled-vs-RouteConfig boundary as getRouteConfigs above.\n return createRoute<string, RouteConfig>(\n Object.assign({}, restConfig, {\n middleware: mws,\n responses: Object.assign({}, htmlResponse({ description: 'HTML page' }), responses),\n tags: [...tags, this.scope],\n security,\n }) as any,\n );\n }\n /** Override to register routes using bindRoute or defineRoute. */\n abstract binding(): ValueOrPromise<void>;\n\n /** Creates a fluent binding for registering a route (call .to() to attach handler). */\n abstract bindRoute<RouteConfig extends IAuthRouteConfig>(opts: {\n configs: RouteConfig;\n }): IBindRouteOptions<RouteConfig, RouteEnv, RouteSchema, BasePath>;\n\n /** Defines and registers a route with its handler in a single call. */\n abstract defineRoute<RouteConfig extends IAuthRouteConfig, ResponseType = unknown>(opts: {\n configs: RouteConfig;\n handler: TRouteHandler<ResponseType, RouteEnv>;\n hook?: Hook<any, RouteEnv, string, ValueOrPromise<any>>;\n }): IDefineRouteOptions<RouteConfig, RouteEnv, RouteSchema, BasePath>;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IModelMetadata } from '../../helpers/inversion/index.js';
|
|
2
|
+
/** The release that drops the deprecated `skipMigrate` key. */
|
|
3
|
+
export declare const DEPRECATED_MODEL_METADATA_REMOVED_IN = "0.4.4";
|
|
4
|
+
/**
|
|
5
|
+
* The one place the `@model` metadata outside `settings` is checked and normalised.
|
|
6
|
+
*
|
|
7
|
+
* - `type` is optional; a value must be one of {@link ModelTypes}.
|
|
8
|
+
* - `skipMigrate` (deprecated) becomes `migration: { use: !skipMigrate }`, and is reported so the
|
|
9
|
+
* application warns once at boot. Setting both `skipMigrate` and `migration` throws.
|
|
10
|
+
* - When the model declares either, the registry entry carries BOTH `migration` and a derived
|
|
11
|
+
* `skipMigrate`, so consumer tooling that reads `metadata.skipMigrate` keeps working this release.
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeModelMetadata: (opts: {
|
|
14
|
+
model: string;
|
|
15
|
+
metadata: IModelMetadata;
|
|
16
|
+
}) => IModelMetadata;
|
|
17
|
+
//# sourceMappingURL=model-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-metadata.d.ts","sourceRoot":"","sources":["../../../../src/base/metadata/model-metadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGpF,+DAA+D;AAC/D,eAAO,MAAM,oCAAoC,UAAU,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;CAC1B,KAAG,cAoCH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getError } from '@venizia/ignis-helpers/core';
|
|
2
|
+
import { ModelTypes } from '../models/common/constants.js';
|
|
3
|
+
/** The release that drops the deprecated `skipMigrate` key. */
|
|
4
|
+
export const DEPRECATED_MODEL_METADATA_REMOVED_IN = '0.4.4';
|
|
5
|
+
/**
|
|
6
|
+
* The one place the `@model` metadata outside `settings` is checked and normalised.
|
|
7
|
+
*
|
|
8
|
+
* - `type` is optional; a value must be one of {@link ModelTypes}.
|
|
9
|
+
* - `skipMigrate` (deprecated) becomes `migration: { use: !skipMigrate }`, and is reported so the
|
|
10
|
+
* application warns once at boot. Setting both `skipMigrate` and `migration` throws.
|
|
11
|
+
* - When the model declares either, the registry entry carries BOTH `migration` and a derived
|
|
12
|
+
* `skipMigrate`, so consumer tooling that reads `metadata.skipMigrate` keeps working this release.
|
|
13
|
+
*/
|
|
14
|
+
export const normalizeModelMetadata = (opts) => {
|
|
15
|
+
const { model, metadata } = opts;
|
|
16
|
+
const { type, skipMigrate, migration } = metadata;
|
|
17
|
+
if (type !== undefined && !ModelTypes.isValid(type)) {
|
|
18
|
+
throw getError({
|
|
19
|
+
message: `[model][${model}] Invalid 'type' | Expected one of: ${[...ModelTypes.SCHEME_SET].join(', ')} (or leave it out) | Got: ${String(type)}`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (skipMigrate !== undefined && migration !== undefined) {
|
|
23
|
+
throw getError({
|
|
24
|
+
message: `[model][${model}] skipMigrate and migration are both set | skipMigrate is the deprecated name of migration.use (inverted) | keep migration and remove skipMigrate`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (skipMigrate === undefined && migration === undefined) {
|
|
28
|
+
return metadata;
|
|
29
|
+
}
|
|
30
|
+
const deprecatedMetadata = [];
|
|
31
|
+
let use;
|
|
32
|
+
if (skipMigrate !== undefined) {
|
|
33
|
+
use = !skipMigrate;
|
|
34
|
+
deprecatedMetadata.push({ key: 'skipMigrate', use: 'migration: { use: false }' });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
use = migration?.use !== false;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...metadata,
|
|
41
|
+
migration: { ...migration, use },
|
|
42
|
+
skipMigrate: !use,
|
|
43
|
+
...(deprecatedMetadata.length > 0 ? { deprecatedMetadata } : {}),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=model-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-metadata.js","sourceRoot":"","sources":["../../../../src/base/metadata/model-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAO,CAAC;AAE5D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAGtC,EAAkB,EAAE;IACnB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAElD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,WAAW,KAAK,uCAAuC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,6BAA6B,MAAM,CAAC,IAAI,CAAC,EAAE;SACjJ,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QACzD,MAAM,QAAQ,CAAC;YACb,OAAO,EAAE,WAAW,KAAK,mJAAmJ;SAC7K,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,kBAAkB,GAA+B,EAAE,CAAC;IAC1D,IAAI,GAAY,CAAC;IAEjB,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,GAAG,GAAG,CAAC,WAAW,CAAC;QACnB,kBAAkB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,2BAA2B,EAAE,CAAC,CAAC;IACpF,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,SAAS,EAAE,GAAG,KAAK,KAAK,CAAC;IACjC,CAAC;IAED,OAAO;QACL,GAAG,QAAQ;QACX,SAAS,EAAE,EAAE,GAAG,SAAS,EAAE,GAAG,EAAE;QAChC,WAAW,EAAE,CAAC,GAAG;QACjB,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\nimport type { IDeprecatedModelMetadata, IModelMetadata } from '@/helpers/inversion';\nimport { ModelTypes } from '../models/common/constants';\n\n/** The release that drops the deprecated `skipMigrate` key. */\nexport const DEPRECATED_MODEL_METADATA_REMOVED_IN = '0.4.4';\n\n/**\n * The one place the `@model` metadata outside `settings` is checked and normalised.\n *\n * - `type` is optional; a value must be one of {@link ModelTypes}.\n * - `skipMigrate` (deprecated) becomes `migration: { use: !skipMigrate }`, and is reported so the\n * application warns once at boot. Setting both `skipMigrate` and `migration` throws.\n * - When the model declares either, the registry entry carries BOTH `migration` and a derived\n * `skipMigrate`, so consumer tooling that reads `metadata.skipMigrate` keeps working this release.\n */\nexport const normalizeModelMetadata = (opts: {\n model: string;\n metadata: IModelMetadata;\n}): IModelMetadata => {\n const { model, metadata } = opts;\n const { type, skipMigrate, migration } = metadata;\n\n if (type !== undefined && !ModelTypes.isValid(type)) {\n throw getError({\n message: `[model][${model}] Invalid 'type' | Expected one of: ${[...ModelTypes.SCHEME_SET].join(', ')} (or leave it out) | Got: ${String(type)}`,\n });\n }\n\n if (skipMigrate !== undefined && migration !== undefined) {\n throw getError({\n message: `[model][${model}] skipMigrate and migration are both set | skipMigrate is the deprecated name of migration.use (inverted) | keep migration and remove skipMigrate`,\n });\n }\n\n if (skipMigrate === undefined && migration === undefined) {\n return metadata;\n }\n\n const deprecatedMetadata: IDeprecatedModelMetadata[] = [];\n let use: boolean;\n\n if (skipMigrate !== undefined) {\n use = !skipMigrate;\n deprecatedMetadata.push({ key: 'skipMigrate', use: 'migration: { use: false }' });\n } else {\n use = migration?.use !== false;\n }\n\n return {\n ...metadata,\n migration: { ...migration, use },\n skipMigrate: !use,\n ...(deprecatedMetadata.length > 0 ? { deprecatedMetadata } : {}),\n };\n};\n"]}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import type { IDeprecatedModelSetting, IModelSettings } from '../../helpers/inversion/index.js';
|
|
2
|
-
/** The release that drops the deprecated keys. */
|
|
3
|
-
export declare const DEPRECATED_MODEL_SETTINGS_REMOVED_IN = "0.4.3";
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `query.limit.max`; `scopeFilter` -> `access` (`writeGuard` -> `access.write.mode`, `sharedRows`
|
|
10
|
-
* -> `access.write.sharedRows`).
|
|
11
|
-
* - An old key together with the key that replaces it is an error.
|
|
12
|
-
* - Returns the old keys in use so the application can warn once at boot.
|
|
2
|
+
* Refuses a removed `@model` settings key. A model that still says `scopeFilter` would otherwise
|
|
3
|
+
* lose its row scope without a sound (a plain-JavaScript or `any`-typed model gets no type error),
|
|
4
|
+
* so the decorator throws instead, naming the key to use. `devz codemod model-settings --write` rewrites
|
|
5
|
+
* the keys.
|
|
13
6
|
*/
|
|
14
|
-
export declare const
|
|
7
|
+
export declare const assertNoRemovedModelSettings: (opts: {
|
|
15
8
|
model: string;
|
|
16
|
-
settings:
|
|
17
|
-
}) =>
|
|
18
|
-
settings: IModelSettings | undefined;
|
|
19
|
-
deprecated: IDeprecatedModelSetting[];
|
|
20
|
-
};
|
|
9
|
+
settings: object | undefined;
|
|
10
|
+
}) => void;
|
|
21
11
|
//# sourceMappingURL=model-settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-settings.d.ts","sourceRoot":"","sources":["../../../../src/base/metadata/model-settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-settings.d.ts","sourceRoot":"","sources":["../../../../src/base/metadata/model-settings.ts"],"names":[],"mappings":"AAUA;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GAAI,MAAM;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,KAAG,IAiBH,CAAC"}
|
|
@@ -1,73 +1,30 @@
|
|
|
1
1
|
import { getError } from '@venizia/ignis-helpers/core';
|
|
2
|
-
/** The
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
/** The keys 0.4.2 deprecated and 0.4.3 removed, and the key that replaces each. */
|
|
3
|
+
const REMOVED_MODEL_SETTINGS = {
|
|
4
|
+
defaultFilter: 'query.filter',
|
|
5
|
+
defaultLimit: 'query.limit.default',
|
|
6
|
+
maxLimit: 'query.limit.max',
|
|
7
|
+
scopeFilter: 'access',
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `query.limit.max`; `scopeFilter` -> `access` (`writeGuard` -> `access.write.mode`, `sharedRows`
|
|
15
|
-
* -> `access.write.sharedRows`).
|
|
16
|
-
* - An old key together with the key that replaces it is an error.
|
|
17
|
-
* - Returns the old keys in use so the application can warn once at boot.
|
|
10
|
+
* Refuses a removed `@model` settings key. A model that still says `scopeFilter` would otherwise
|
|
11
|
+
* lose its row scope without a sound (a plain-JavaScript or `any`-typed model gets no type error),
|
|
12
|
+
* so the decorator throws instead, naming the key to use. `devz codemod model-settings --write` rewrites
|
|
13
|
+
* the keys.
|
|
18
14
|
*/
|
|
19
|
-
export const
|
|
15
|
+
export const assertNoRemovedModelSettings = (opts) => {
|
|
20
16
|
const { model, settings } = opts;
|
|
21
17
|
if (!settings) {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
const { defaultFilter, defaultLimit, maxLimit, scopeFilter, ...current } = settings;
|
|
25
|
-
const deprecated = [];
|
|
26
|
-
const normalized = { ...current };
|
|
27
|
-
if (defaultFilter !== undefined) {
|
|
28
|
-
if (current.query?.filter !== undefined) {
|
|
29
|
-
throw conflict({ model, old: 'defaultFilter', use: 'query.filter' });
|
|
30
|
-
}
|
|
31
|
-
normalized.query = { ...normalized.query, filter: defaultFilter };
|
|
32
|
-
deprecated.push({ key: 'defaultFilter', use: 'query.filter' });
|
|
33
|
-
}
|
|
34
|
-
if (defaultLimit !== undefined) {
|
|
35
|
-
if (current.query?.limit?.default !== undefined) {
|
|
36
|
-
throw conflict({ model, old: 'defaultLimit', use: 'query.limit.default' });
|
|
37
|
-
}
|
|
38
|
-
normalized.query = {
|
|
39
|
-
...normalized.query,
|
|
40
|
-
limit: { ...normalized.query?.limit, default: defaultLimit },
|
|
41
|
-
};
|
|
42
|
-
deprecated.push({ key: 'defaultLimit', use: 'query.limit.default' });
|
|
18
|
+
return;
|
|
43
19
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
normalized.query = {
|
|
49
|
-
...normalized.query,
|
|
50
|
-
limit: { ...normalized.query?.limit, max: maxLimit },
|
|
51
|
-
};
|
|
52
|
-
deprecated.push({ key: 'maxLimit', use: 'query.limit.max' });
|
|
20
|
+
const removed = Object.keys(REMOVED_MODEL_SETTINGS).filter((key) => Object.hasOwn(settings, key));
|
|
21
|
+
if (removed.length === 0) {
|
|
22
|
+
return;
|
|
53
23
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const access = { ...rest };
|
|
60
|
-
deprecated.push({ key: 'scopeFilter', use: 'access' });
|
|
61
|
-
if (writeGuard !== undefined) {
|
|
62
|
-
access.write = { ...access.write, mode: writeGuard };
|
|
63
|
-
deprecated.push({ key: 'scopeFilter.writeGuard', use: 'access.write.mode' });
|
|
64
|
-
}
|
|
65
|
-
if (sharedRows !== undefined) {
|
|
66
|
-
access.write = { ...access.write, sharedRows };
|
|
67
|
-
deprecated.push({ key: 'scopeFilter.sharedRows', use: 'access.write.sharedRows' });
|
|
68
|
-
}
|
|
69
|
-
normalized.access = access;
|
|
70
|
-
}
|
|
71
|
-
return { settings: normalized, deprecated };
|
|
24
|
+
throw getError({
|
|
25
|
+
message: `[model][${model}] Removed settings key(s): ${removed
|
|
26
|
+
.map((key) => `settings.${key} (use settings.${REMOVED_MODEL_SETTINGS[key]})`)
|
|
27
|
+
.join(', ')} | removed in 0.4.3 | run 'devz codemod model-settings --write' to rewrite them`,
|
|
28
|
+
});
|
|
72
29
|
};
|
|
73
30
|
//# sourceMappingURL=model-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-settings.js","sourceRoot":"","sources":["../../../../src/base/metadata/model-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"model-settings.js","sourceRoot":"","sources":["../../../../src/base/metadata/model-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,mFAAmF;AACnF,MAAM,sBAAsB,GAA2B;IACrD,aAAa,EAAE,cAAc;IAC7B,YAAY,EAAE,qBAAqB;IACnC,QAAQ,EAAE,iBAAiB;IAC3B,WAAW,EAAE,QAAQ;CACtB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAG5C,EAAQ,EAAE;IACT,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAEjC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAClG,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,CAAC;QACb,OAAO,EAAE,WAAW,KAAK,8BAA8B,OAAO;aAC3D,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,GAAG,kBAAkB,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC;aAC7E,IAAI,CAAC,IAAI,CAAC,iFAAiF;KAC/F,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { getError } from '@venizia/ignis-helpers/core';\n\n/** The keys 0.4.2 deprecated and 0.4.3 removed, and the key that replaces each. */\nconst REMOVED_MODEL_SETTINGS: Record<string, string> = {\n defaultFilter: 'query.filter',\n defaultLimit: 'query.limit.default',\n maxLimit: 'query.limit.max',\n scopeFilter: 'access',\n};\n\n/**\n * Refuses a removed `@model` settings key. A model that still says `scopeFilter` would otherwise\n * lose its row scope without a sound (a plain-JavaScript or `any`-typed model gets no type error),\n * so the decorator throws instead, naming the key to use. `devz codemod model-settings --write` rewrites\n * the keys.\n */\nexport const assertNoRemovedModelSettings = (opts: {\n model: string;\n settings: object | undefined;\n}): void => {\n const { model, settings } = opts;\n\n if (!settings) {\n return;\n }\n\n const removed = Object.keys(REMOVED_MODEL_SETTINGS).filter((key) => Object.hasOwn(settings, key));\n if (removed.length === 0) {\n return;\n }\n\n throw getError({\n message: `[model][${model}] Removed settings key(s): ${removed\n .map((key) => `settings.${key} (use settings.${REMOVED_MODEL_SETTINGS[key]})`)\n .join(', ')} | removed in 0.4.3 | run 'devz codemod model-settings --write' to rewrite them`,\n });\n};\n"]}
|
|
@@ -2,7 +2,7 @@ import type { IDataSourceMetadata, IModelMetadata, TRepositoryMetadata } from '.
|
|
|
2
2
|
import type { IDataSource } from '../datasources/index.js';
|
|
3
3
|
import type { AbstractEntity } from '../models/index.js';
|
|
4
4
|
/** Registers a model class with its static schema and relations. */
|
|
5
|
-
export declare const model: (input
|
|
5
|
+
export declare const model: (input?: IModelMetadata) => ClassDecorator;
|
|
6
6
|
/** Registers a datasource with driver and auto-discovery settings. */
|
|
7
7
|
export declare const datasource: (metadata?: IDataSourceMetadata) => ClassDecorator;
|
|
8
8
|
export declare const repository: <Model extends AbstractEntity = AbstractEntity, DataSource extends IDataSource = IDataSource>(metadata?: TRepositoryMetadata<Model, DataSource>) => ClassDecorator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistents.d.ts","sourceRoot":"","sources":["../../../../src/base/metadata/persistents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EAEnB,cAAc,EAEd,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"persistents.d.ts","sourceRoot":"","sources":["../../../../src/base/metadata/persistents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EAEnB,cAAc,EAEd,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMhD,oEAAoE;AACpE,eAAO,MAAM,KAAK,GAAI,QAAO,cAAmB,KAAG,cAmClD,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,UAAU,GAAI,WAAW,mBAAmB,KAAG,cAQ3D,CAAC;AA0PF,eAAO,MAAM,UAAU,GACrB,KAAK,SAAS,cAAc,GAAG,cAAc,EAC7C,UAAU,SAAS,WAAW,GAAG,WAAW,EAE5C,WAAW,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC,KAChD,cAeF,CAAC"}
|
|
@@ -5,22 +5,15 @@ import { getError } from '@venizia/ignis-helpers/core';
|
|
|
5
5
|
import { isDataSourceClass } from '../datasources/index.js';
|
|
6
6
|
import { RepositoryTypes } from '../repositories/common/constants.js';
|
|
7
7
|
import { injectable, pickRegistrationOptions } from './injectable.js';
|
|
8
|
-
import {
|
|
8
|
+
import { normalizeModelMetadata } from './model-metadata.js';
|
|
9
|
+
import { assertNoRemovedModelSettings } from './model-settings.js';
|
|
9
10
|
/** Registers a model class with its static schema and relations. */
|
|
10
|
-
export const model = (input) => {
|
|
11
|
+
export const model = (input = {}) => {
|
|
11
12
|
return (target) => {
|
|
12
13
|
injectable({ type: ArtifactTypes.MODEL, ...pickRegistrationOptions({ metadata: input }) })(target);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const { settings
|
|
16
|
-
model: target.name,
|
|
17
|
-
settings: input.settings,
|
|
18
|
-
});
|
|
19
|
-
const metadata = {
|
|
20
|
-
...input,
|
|
21
|
-
settings,
|
|
22
|
-
...(deprecated.length > 0 ? { deprecatedSettings: deprecated } : {}),
|
|
23
|
-
};
|
|
14
|
+
const metadata = normalizeModelMetadata({ model: target.name, metadata: input });
|
|
15
|
+
assertNoRemovedModelSettings({ model: target.name, settings: metadata.settings });
|
|
16
|
+
const { settings } = metadata;
|
|
24
17
|
const defaultLimit = settings?.query?.limit?.default;
|
|
25
18
|
if (defaultLimit !== undefined && (!Number.isInteger(defaultLimit) || defaultLimit <= 0)) {
|
|
26
19
|
throw getError({
|