@lyrolab/nest-shared 1.9.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
- ## [1.9.1](https://github.com/lyrolab/nest-shared/compare/v1.9.0...v1.9.1) (2026-03-12)
1
+ # [1.11.0](https://github.com/lyrolab/nest-shared/compare/v1.10.0...v1.11.0) (2026-04-05)
2
2
 
3
3
 
4
- ### Bug Fixes
4
+ ### Features
5
5
 
6
- * quote table names ([824d2fd](https://github.com/lyrolab/nest-shared/commit/824d2fddcffc75b74445f642622b22647d8ede09))
6
+ * add ESLint rules for NestJS architecture to enforce repository usage ([1bb8684](https://github.com/lyrolab/nest-shared/commit/1bb8684791dbecb4db22b541a3949c13e0a1a2e1))
7
7
 
8
8
  ## [1.0.1](https://github.com/lyrolab/nest-shared/compare/v1.0.0...v1.0.1) (2025-04-10)
9
9
 
@@ -23,9 +23,8 @@ let SharedBullModule = SharedBullModule_1 = class SharedBullModule {
23
23
  imports: [config_1.ConfigModule],
24
24
  inject: [redis_config_1.RedisConfig],
25
25
  useFactory: (redisConfig) => ({
26
- connection: {
27
- url: redisConfig.url,
28
- },
26
+ connection: { url: redisConfig.url },
27
+ ...(redisConfig.keyPrefix && { prefix: redisConfig.keyPrefix }),
29
28
  }),
30
29
  }),
31
30
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"shared-bull.module.js","sourceRoot":"","sources":["../../src/bull/shared-bull.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA2C;AAC3C,2CAAsD;AACtD,2CAA6C;AAC7C,sEAAgE;AAChE,wDAAmD;AAG5C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE;gBACP,uCAAiB;gBACjB,mBAAU,CAAC,YAAY,CAAC;oBACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;oBACvB,MAAM,EAAE,CAAC,0BAAW,CAAC;oBACrB,UAAU,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC;wBACzC,UAAU,EAAE;4BACV,GAAG,EAAE,WAAW,CAAC,GAAG;yBACrB;qBACF,CAAC;iBACH,CAAC;aACH;YACD,OAAO,EAAE,CAAC,mBAAU,CAAC;SACtB,CAAA;IACH,CAAC;CACF,CAAA;AAnBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAmB5B"}
1
+ {"version":3,"file":"shared-bull.module.js","sourceRoot":"","sources":["../../src/bull/shared-bull.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA2C;AAC3C,2CAAsD;AACtD,2CAA6C;AAC7C,sEAAgE;AAChE,wDAAmD;AAG5C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE;gBACP,uCAAiB;gBACjB,mBAAU,CAAC,YAAY,CAAC;oBACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;oBACvB,MAAM,EAAE,CAAC,0BAAW,CAAC;oBACrB,UAAU,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC;wBACzC,UAAU,EAAE,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE;wBACpC,GAAG,CAAC,WAAW,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,SAAS,EAAE,CAAC;qBAChE,CAAC;iBACH,CAAC;aACH;YACD,OAAO,EAAE,CAAC,mBAAU,CAAC;SACtB,CAAA;IACH,CAAC;CACF,CAAA;AAlBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAkB5B"}
@@ -26,7 +26,11 @@ let SharedCacheModule = SharedCacheModule_1 = class SharedCacheModule {
26
26
  ttl: configService.get("CACHE_TTL")
27
27
  ? +configService.get("CACHE_TTL") * 1000
28
28
  : undefined,
29
- stores: [new redis_1.default(redisConfig.url)],
29
+ stores: [
30
+ new redis_1.default(redisConfig.url, redisConfig.keyPrefix
31
+ ? { namespace: redisConfig.keyPrefix }
32
+ : {}),
33
+ ],
30
34
  }),
31
35
  inject: [config_1.ConfigService, redis_config_1.RedisConfig],
32
36
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"shared-cache.module.js","sourceRoot":"","sources":["../../src/cache/shared-cache.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uCAAmC;AACnC,yDAAmD;AACnD,2CAAsD;AACtD,2CAA8C;AAC9C,wDAAmD;AACnD,sEAAgE;AAGzD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE;gBACP,uCAAiB;gBACjB,2BAAW,CAAC,aAAa,CAAC;oBACxB,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,CACV,aAA4B,EAC5B,WAAwB,EACxB,EAAE,CAAC,CAAC;wBACJ,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC;4BACjC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,IAAI;4BACxC,CAAC,CAAC,SAAS;wBACb,MAAM,EAAE,CAAC,IAAI,eAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;qBACzC,CAAC;oBACF,MAAM,EAAE,CAAC,sBAAa,EAAE,0BAAW,CAAC;iBACrC,CAAC;aACH;YACD,OAAO,EAAE,CAAC,2BAAW,CAAC;SACvB,CAAA;IACH,CAAC;CACF,CAAA;AAvBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CAuB7B"}
1
+ {"version":3,"file":"shared-cache.module.js","sourceRoot":"","sources":["../../src/cache/shared-cache.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uCAAmC;AACnC,yDAAmD;AACnD,2CAAsD;AACtD,2CAA8C;AAC9C,wDAAmD;AACnD,sEAAgE;AAGzD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE;gBACP,uCAAiB;gBACjB,2BAAW,CAAC,aAAa,CAAC;oBACxB,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,CACV,aAA4B,EAC5B,WAAwB,EACxB,EAAE,CAAC,CAAC;wBACJ,GAAG,EAAE,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC;4BACjC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,IAAI;4BACxC,CAAC,CAAC,SAAS;wBACb,MAAM,EAAE;4BACN,IAAI,eAAS,CACX,WAAW,CAAC,GAAG,EACf,WAAW,CAAC,SAAS;gCACnB,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,EAAE;gCACtC,CAAC,CAAC,EAAE,CACP;yBACF;qBACF,CAAC;oBACF,MAAM,EAAE,CAAC,sBAAa,EAAE,0BAAW,CAAC;iBACrC,CAAC;aACH;YACD,OAAO,EAAE,CAAC,2BAAW,CAAC;SACvB,CAAA;IACH,CAAC;CACF,CAAA;AA9BY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CA8B7B"}
@@ -0,0 +1,9 @@
1
+ import type { TSESLint } from "@typescript-eslint/utils";
2
+ export declare const nestArchitecturePlugin: {
3
+ configs: {
4
+ recommended: TSESLint.FlatConfig.Config;
5
+ };
6
+ meta?: { [K in keyof TSESLint.FlatConfig.PluginMeta]?: TSESLint.FlatConfig.PluginMeta[K] | undefined; };
7
+ processors?: Partial<Record<string, TSESLint.FlatConfig.Processor>> | undefined;
8
+ rules?: Record<string, TSESLint.LooseRuleDefinition> | undefined;
9
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nestArchitecturePlugin = void 0;
4
+ const no_typeorm_in_non_repository_1 = require("./rules/no-typeorm-in-non-repository");
5
+ const no_repository_in_controller_1 = require("./rules/no-repository-in-controller");
6
+ const no_export_repository_in_module_1 = require("./rules/no-export-repository-in-module");
7
+ const plugin = {
8
+ meta: {
9
+ name: "@lyrolab/nestjs-architecture",
10
+ },
11
+ rules: {
12
+ "no-typeorm-in-non-repository": no_typeorm_in_non_repository_1.noTypeormInNonRepository,
13
+ "no-repository-in-controller": no_repository_in_controller_1.noRepositoryInController,
14
+ "no-export-repository-in-module": no_export_repository_in_module_1.noExportRepositoryInModule,
15
+ },
16
+ };
17
+ const recommended = {
18
+ plugins: {
19
+ "@lyrolab/nestjs-architecture": plugin,
20
+ },
21
+ rules: {
22
+ "@lyrolab/nestjs-architecture/no-typeorm-in-non-repository": "error",
23
+ "@lyrolab/nestjs-architecture/no-repository-in-controller": "error",
24
+ "@lyrolab/nestjs-architecture/no-export-repository-in-module": "error",
25
+ },
26
+ };
27
+ exports.nestArchitecturePlugin = { ...plugin, configs: { recommended } };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":";;;AACA,uFAA+E;AAC/E,qFAA8E;AAC9E,2FAAmF;AAEnF,MAAM,MAAM,GAA+B;IACzC,IAAI,EAAE;QACJ,IAAI,EAAE,8BAA8B;KACrC;IACD,KAAK,EAAE;QACL,8BAA8B,EAAE,uDAAwB;QACxD,6BAA6B,EAAE,sDAAwB;QACvD,gCAAgC,EAAE,2DAA0B;KAC7D;CACF,CAAA;AAED,MAAM,WAAW,GAA+B;IAC9C,OAAO,EAAE;QACP,8BAA8B,EAAE,MAAM;KACvC;IACD,KAAK,EAAE;QACL,2DAA2D,EAAE,OAAO;QACpE,0DAA0D,EAAE,OAAO;QACnE,6DAA6D,EAAE,OAAO;KACvE;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAG,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,EAAE,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noExportRepositoryInModule: ESLintUtils.RuleModule<"exportedRepository", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noExportRepositoryInModule = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/lyrolab/nest-shared#${name}`);
6
+ exports.noExportRepositoryInModule = createRule({
7
+ name: "no-export-repository-in-module",
8
+ meta: {
9
+ type: "problem",
10
+ docs: {
11
+ description: "NestJS modules must not export Repository classes. Repositories should stay in providers. Expose a Service instead.",
12
+ },
13
+ messages: {
14
+ exportedRepository: "'{{ repositoryName }}' must not be exported from a module. Keep repositories private and expose a Service method instead.",
15
+ },
16
+ schema: [],
17
+ },
18
+ defaultOptions: [],
19
+ create(context) {
20
+ return {
21
+ ClassDeclaration(node) {
22
+ const decorators = node.decorators ?? [];
23
+ const moduleDecorator = decorators.find((d) => {
24
+ const expr = d.expression;
25
+ return (expr.type === utils_1.AST_NODE_TYPES.CallExpression &&
26
+ expr.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
27
+ expr.callee.name === "Module");
28
+ });
29
+ if (!moduleDecorator)
30
+ return;
31
+ const expr = moduleDecorator.expression;
32
+ if (expr.type !== utils_1.AST_NODE_TYPES.CallExpression)
33
+ return;
34
+ const args = expr.arguments;
35
+ if (!args.length || args[0].type !== utils_1.AST_NODE_TYPES.ObjectExpression)
36
+ return;
37
+ const exportsProperty = args[0].properties.find((prop) => prop.type === utils_1.AST_NODE_TYPES.Property &&
38
+ prop.key.type === utils_1.AST_NODE_TYPES.Identifier &&
39
+ prop.key.name === "exports");
40
+ if (!exportsProperty ||
41
+ exportsProperty.value.type !== utils_1.AST_NODE_TYPES.ArrayExpression)
42
+ return;
43
+ for (const element of exportsProperty.value.elements) {
44
+ if (element?.type === utils_1.AST_NODE_TYPES.Identifier &&
45
+ element.name.endsWith("Repository")) {
46
+ context.report({
47
+ node: element,
48
+ messageId: "exportedRepository",
49
+ data: { repositoryName: element.name },
50
+ });
51
+ }
52
+ }
53
+ },
54
+ };
55
+ },
56
+ });
57
+ //# sourceMappingURL=no-export-repository-in-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-export-repository-in-module.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-export-repository-in-module.ts"],"names":[],"mappings":";;;AAAA,oDAAgF;AAEhF,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,0CAA0C,IAAI,EAAE,CAC3D,CAAA;AAIY,QAAA,0BAA0B,GAAG,UAAU,CAAiB;IACnE,IAAI,EAAE,gCAAgC;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,qHAAqH;SACxH;QACD,QAAQ,EAAE;YACR,kBAAkB,EAChB,2HAA2H;SAC9H;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gBAAgB,CAAC,IAAI;gBACnB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAA;gBACxC,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBAC5C,MAAM,IAAI,GAAG,CAAC,CAAC,UAAU,CAAA;oBACzB,OAAO,CACL,IAAI,CAAC,I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AAE;yBACvC,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noRepositoryInController: ESLintUtils.RuleModule<"repositoryInController", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noRepositoryInController = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/lyrolab/nest-shared#${name}`);
6
+ function getClassName(node) {
7
+ return node.id?.name;
8
+ }
9
+ function getConstructor(node) {
10
+ return node.body.body.find((member) => member.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
11
+ member.kind === "constructor");
12
+ }
13
+ exports.noRepositoryInController = createRule({
14
+ name: "no-repository-in-controller",
15
+ meta: {
16
+ type: "problem",
17
+ docs: {
18
+ description: "Controllers must not inject Repository classes directly. Use a Service as intermediary.",
19
+ },
20
+ messages: {
21
+ repositoryInController: "'{{ repositoryName }}' must not be injected in a Controller. Controllers should depend on Services, not Repositories.",
22
+ },
23
+ schema: [],
24
+ },
25
+ defaultOptions: [],
26
+ create(context) {
27
+ return {
28
+ ClassDeclaration(node) {
29
+ const className = getClassName(node);
30
+ if (!className || !className.endsWith("Controller"))
31
+ return;
32
+ const ctor = getConstructor(node);
33
+ if (!ctor)
34
+ return;
35
+ const ctorValue = ctor.value;
36
+ if (ctorValue.type !== utils_1.AST_NODE_TYPES.FunctionExpression)
37
+ return;
38
+ for (const param of ctorValue.params) {
39
+ const actualParam = param.type === utils_1.AST_NODE_TYPES.TSParameterProperty
40
+ ? param.parameter
41
+ : param;
42
+ const typeAnnotation = "typeAnnotation" in actualParam
43
+ ? actualParam.typeAnnotation?.typeAnnotation
44
+ : undefined;
45
+ if (typeAnnotation?.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
46
+ typeAnnotation.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
47
+ typeAnnotation.typeName.name.endsWith("Repository")) {
48
+ context.report({
49
+ node: param,
50
+ messageId: "repositoryInController",
51
+ data: { repositoryName: typeAnnotation.typeName.name },
52
+ });
53
+ }
54
+ }
55
+ },
56
+ };
57
+ },
58
+ });
59
+ //# sourceMappingURL=no-repository-in-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-repository-in-controller.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-repository-in-controller.ts"],"names":[],"mappings":";;;AAAA,oDAAgF;AAEhF,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,0CAA0C,IAAI,EAAE,CAC3D,CAAA;AAID,SAAS,YAAY,CAAC,IAA+B;IACnD,OAAO,IAAI,CAAC,EAAE,EAAE,IAAI,CAAA;AACtB,CAAC;AAED,SAAS,cAAc,CACrB,IAA+B;IAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACxB,CAAC,MAAM,EAAuC,EAAE,CAC9C,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;QAC/C,MAAM,CAAC,IAAI,KAAK,aAAa,CAChC,CAAA;AACH,CAAC;AAEY,QAAA,wBAAwB,GAAG,UAAU,CAAiB;IACjE,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,yFAAyF;SAC5F;QACD,QAAQ,EAAE;YACR,sBAAsB,EACpB,uHAAuH;SAC1H;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gBAAgB,CAAC,IAAI;gBACnB,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;gBACpC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC;oBAAE,OAAM;gBAE3D,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;gBACjC,IAAI,CAAC,IAAI;oBAAE,OAAM;gBAEjB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAA;gBAC5B,IAAI,SAAS,CAAC,IAAI,KAAK,sBAAc,CAAC,kBAAkB;oBAAE,OAAM;gBAEhE,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;oBACrC,MAAM,WAAW,GACf,KAAK,CAAC,IAAI,KAAK,sBAAc,CAAC,mBAAmB;wBAC/C,CAAC,CAAC,KAAK,CAAC,SAAS;wBACjB,CAAC,CAAC,KAAK,CAAA;oBACX,MAAM,cAAc,GAClB,gBAAgB,IAAI,WAAW;wBAC7B,CAAC,CAAC,WAAW,CAAC,cAAc,EAAE,cAAc;wBAC5C,CAAC,CAAC,SAAS,CAAA;oBAEf,IACE,cAAc,EAAE,IAAI,KAAK,sBAAc,CAAC,eAAe;wBACvD,cAAc,CAAC,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;wBAC1D,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EACnD,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,KAAK;4BACX,SAAS,EAAE,wBAAwB;4BACnC,IAAI,EAAE,EAAE,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE;yBACvD,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ type MessageIds = "injectRepository" | "dataSource";
3
+ export declare const noTypeormInNonRepository: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
4
+ name: string;
5
+ };
6
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noTypeormInNonRepository = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/lyrolab/nest-shared#${name}`);
6
+ function getClassName(node) {
7
+ return node.id?.name;
8
+ }
9
+ function getConstructor(node) {
10
+ return node.body.body.find((member) => member.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
11
+ member.kind === "constructor");
12
+ }
13
+ exports.noTypeormInNonRepository = createRule({
14
+ name: "no-typeorm-in-non-repository",
15
+ meta: {
16
+ type: "problem",
17
+ docs: {
18
+ description: "@InjectRepository() and DataSource injection are only allowed in Repository classes",
19
+ },
20
+ messages: {
21
+ injectRepository: "@InjectRepository() can only be used in classes ending with 'Repository'. Move data access logic to a Repository class.",
22
+ dataSource: "DataSource can only be injected in classes ending with 'Repository'. Move data access logic to a Repository class.",
23
+ },
24
+ schema: [],
25
+ },
26
+ defaultOptions: [],
27
+ create(context) {
28
+ return {
29
+ ClassDeclaration(node) {
30
+ const className = getClassName(node);
31
+ if (!className || className.endsWith("Repository"))
32
+ return;
33
+ const ctor = getConstructor(node);
34
+ if (!ctor)
35
+ return;
36
+ const ctorValue = ctor.value;
37
+ if (ctorValue.type !== utils_1.AST_NODE_TYPES.FunctionExpression)
38
+ return;
39
+ for (const param of ctorValue.params) {
40
+ const actualParam = param.type === utils_1.AST_NODE_TYPES.TSParameterProperty
41
+ ? param.parameter
42
+ : param;
43
+ const decorators = "decorators" in param ? (param.decorators ?? []) : [];
44
+ for (const decorator of decorators) {
45
+ const expr = decorator.expression;
46
+ if (expr.type === utils_1.AST_NODE_TYPES.CallExpression &&
47
+ expr.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
48
+ expr.callee.name === "InjectRepository") {
49
+ context.report({
50
+ node: decorator,
51
+ messageId: "injectRepository",
52
+ });
53
+ }
54
+ }
55
+ const typeAnnotation = "typeAnnotation" in actualParam
56
+ ? actualParam.typeAnnotation?.typeAnnotation
57
+ : undefined;
58
+ if (typeAnnotation?.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
59
+ typeAnnotation.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
60
+ typeAnnotation.typeName.name === "DataSource") {
61
+ context.report({
62
+ node: param,
63
+ messageId: "dataSource",
64
+ });
65
+ }
66
+ }
67
+ },
68
+ };
69
+ },
70
+ });
71
+ //# sourceMappingURL=no-typeorm-in-non-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-typeorm-in-non-repository.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-typeorm-in-non-repository.ts"],"names":[],"mappings":";;;AAAA,oDAAgF;AAEhF,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,0CAA0C,IAAI,EAAE,CAC3D,CAAA;AAID,SAAS,YAAY,CAAC,IAA+B;IACnD,OAAO,IAAI,CAAC,EAAE,EAAE,IAAI,CAAA;AACtB,CAAC;AAED,SAAS,cAAc,CACrB,IAA+B;IAE/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACxB,CAAC,MAAM,EAAuC,EAAE,CAC9C,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;QAC/C,MAAM,CAAC,IAAI,KAAK,aAAa,CAChC,CAAA;AACH,CAAC;AAEY,QAAA,wBAAwB,GAAG,UAAU,CAAiB;IACjE,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,qFAAqF;SACxF;QACD,QAAQ,EAAE;YACR,gBAAgB,EACd,yHAAyH;YAC3H,UAAU,EACR,oHAAoH;SACvH;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MA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Ac,EAAE,cAAc;wBAC5C,CAAC,CAAC,SAAS,CAAA;oBACf,IACE,cAAc,EAAE,IAAI,KAAK,sBAAc,CAAC,eAAe;wBACvD,cAAc,CAAC,QAAQ,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;wBAC1D,cAAc,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EAC7C,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,EAAE,KAAK;4BACX,SAAS,EAAE,YAAY;yBACxB,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export declare class RedisConfig {
2
2
  readonly url: string;
3
- constructor(url: string);
3
+ readonly keyPrefix?: string | undefined;
4
+ constructor(url: string, keyPrefix?: string | undefined);
4
5
  }
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RedisConfig = void 0;
4
4
  class RedisConfig {
5
5
  url;
6
- constructor(url) {
6
+ keyPrefix;
7
+ constructor(url, keyPrefix) {
7
8
  this.url = url;
9
+ this.keyPrefix = keyPrefix;
8
10
  }
9
11
  }
10
12
  exports.RedisConfig = RedisConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"redis.config.js","sourceRoot":"","sources":["../../src/redis/redis.config.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACM;IAA5B,YAA4B,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;CAC5C;AAFD,kCAEC"}
1
+ {"version":3,"file":"redis.config.js","sourceRoot":"","sources":["../../src/redis/redis.config.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IAEJ;IACA;IAFlB,YACkB,GAAW,EACX,SAAkB;QADlB,QAAG,GAAH,GAAG,CAAQ;QACX,cAAS,GAAT,SAAS,CAAS;IACjC,CAAC;CACL;AALD,kCAKC"}
@@ -34,12 +34,13 @@ let SharedRedisModule = SharedRedisModule_1 = class SharedRedisModule {
34
34
  if (!redisUrl) {
35
35
  throw new Error("REDIS_URL environment variable is required for test setup");
36
36
  }
37
+ const poolId = process.env.VITEST_POOL_ID ?? process.env.JEST_WORKER_ID ?? "0";
37
38
  return {
38
39
  module: SharedRedisModule_1,
39
40
  providers: [
40
41
  {
41
42
  provide: redis_config_1.RedisConfig,
42
- useValue: new redis_config_1.RedisConfig(redisUrl),
43
+ useValue: new redis_config_1.RedisConfig(redisUrl, `test_${poolId}`),
43
44
  },
44
45
  ],
45
46
  exports: [redis_config_1.RedisConfig],
@@ -1 +1 @@
1
- {"version":3,"file":"shared-redis.module.js","sourceRoot":"","sources":["../../src/redis/shared-redis.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsD;AACtD,2CAA4D;AAC5D,iDAA4C;AAGrC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,0BAAW;oBACpB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE;wBAC3C,OAAO,IAAI,0BAAW,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAW,CAAC,CAAA;oBAClE,CAAC;oBACD,MAAM,EAAE,CAAC,sBAAa,CAAC;iBACxB;aACF;YACD,OAAO,EAAE,CAAC,0BAAW,CAAC;YACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;YACvB,MAAM,EAAE,IAAI;SACb,CAAA;IACH,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAA;QACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;QACH,CAAC;QAED,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,0BAAW;oBACpB,QAAQ,EAAE,IAAI,0BAAW,CAAC,QAAQ,CAAC;iBACpC;aACF;YACD,OAAO,EAAE,CAAC,0BAAW,CAAC;YACtB,MAAM,EAAE,IAAI;SACb,CAAA;IACH,CAAC;CACF,CAAA;AAvCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CAuC7B"}
1
+ {"version":3,"file":"shared-redis.module.js","sourceRoot":"","sources":["../../src/redis/shared-redis.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsD;AACtD,2CAA4D;AAC5D,iDAA4C;AAGrC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,0BAAW;oBACpB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE;wBAC3C,OAAO,IAAI,0BAAW,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAW,CAAC,CAAA;oBAClE,CAAC;oBACD,MAAM,EAAE,CAAC,sBAAa,CAAC;iBACxB;aACF;YACD,OAAO,EAAE,CAAC,0BAAW,CAAC;YACtB,OAAO,EAAE,CAAC,qBAAY,CAAC;YACvB,MAAM,EAAE,IAAI;SACb,CAAA;IACH,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAA;QACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;QACH,CAAC;QAED,MAAM,MAAM,GACV,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAA;QAEjE,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,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