vsrepo 2.7.2 → 2.7.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/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ All notable changes to this project will be documented in this file.
6
6
 
7
7
  ---
8
8
 
9
+ ## [2.7.3] - 2026-09-29
10
+
11
+ ### Fixed
12
+ - `@DynamicMethod` and `@QueryMethod` no longer leak the methods declared in a subclass into its parent class and its sibling classes. The decorators read the list of declared methods with `Reflect.getMetadata`, which walks the prototype chain, and appended to it — so a subclass's first decorator pushed into the very array owned by its parent, and every class in the hierarchy ended up sharing one list. The visible effects were a parent (or sibling) repository resolving methods it never declared, and redeclaring a method in a subclass (e.g. with a different `injectOrdering`) also changing how the parent resolved it. Each class now writes to its own list, seeded with a copy of what it inherits: a subclass still inherits every dynamic and query method of its parent, at any depth, but never alters it. Repositories that don't extend another decorated repository are unaffected
13
+
14
+ ### Documentation
15
+ - New [Inheriting from another repository](./docs/dynamic-methods.md#inheriting-from-another-repository) section in the Dynamic methods guide (linked from the Query methods guide), describing how `@DynamicMethod`/`@QueryMethod` behave across class inheritance
16
+
17
+ ## [2.7.3] - 2026-09-29 (Português)
18
+
19
+ ### Corrigido
20
+ - `@DynamicMethod` e `@QueryMethod` não vazam mais os métodos declarados numa subclasse para a classe pai nem para as classes irmãs. Os decorators liam a lista de métodos declarados com `Reflect.getMetadata`, que percorre a cadeia de protótipos, e acrescentavam nela — então o primeiro decorator de uma subclasse empurrava para o próprio array do pai, e todas as classes da hierarquia acabavam compartilhando uma única lista. Os efeitos visíveis eram um repository pai (ou irmão) resolvendo métodos que nunca declarou, e redeclarar um método numa subclasse (ex.: com outro `injectOrdering`) também alterando a forma como o pai o resolvia. Agora cada classe escreve na sua própria lista, iniciada com uma cópia do que herda: a subclasse continua herdando todos os métodos dinâmicos e query methods do pai, em qualquer profundidade, mas nunca o altera. Repositories que não estendem outro repository decorado não são afetados
21
+
22
+ ### Documentação
23
+ - Nova seção [Herdando de outro repository](./docs/dynamic-methods.pt-BR.md#herdando-de-outro-repository) no guia de Métodos dinâmicos (com link a partir do guia de Query methods), descrevendo como `@DynamicMethod`/`@QueryMethod` se comportam com herança de classes
24
+
9
25
  ## [2.7.2] - 2026-09-29
10
26
 
11
27
  ### Fixed
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DynamicMethod = DynamicMethod;
4
4
  const dynamic_methods_key_constant_1 = require("../internal/constants/dynamic-methods-key.constant");
5
+ const own_metadata_list_util_1 = require("../internal/utils/own-metadata-list.util");
5
6
  const decorators_validator_1 = require("../internal/validators/decorators.validator");
6
7
  /**
7
8
  * Property decorator used to declare a dynamic method on a `VSRepository` subclass.
@@ -29,7 +30,7 @@ const decorators_validator_1 = require("../internal/validators/decorators.valida
29
30
  function DynamicMethod(options) {
30
31
  const validatedOptions = options ? decorators_validator_1.DecoratorsValidator.validateDynamicMethodOptions(options) : undefined;
31
32
  return (target, propertyKey) => {
32
- const methods = Reflect.getMetadata(dynamic_methods_key_constant_1.DYNAMIC_METHODS_KEY, target) ?? [];
33
+ const methods = (0, own_metadata_list_util_1.getOwnMetadataList)(dynamic_methods_key_constant_1.DYNAMIC_METHODS_KEY, target);
33
34
  methods.push({ ...validatedOptions, propertyKey });
34
35
  Reflect.defineMetadata(dynamic_methods_key_constant_1.DYNAMIC_METHODS_KEY, methods, target);
35
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-method.decorator.js","sourceRoot":"","sources":["../../src/decorators/dynamic-method.decorator.ts"],"names":[],"mappings":";;AA4BA,sCAUC;AAtCD,qGAAyF;AACzF,sFAAkF;AAIlF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,aAAa,CAAU,OAAiC;IACpE,MAAM,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,0CAAmB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEzG,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACpD,MAAM,OAAO,GAAmB,OAAO,CAAC,WAAW,CAAC,kDAAmB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAEvF,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,gBAAgB,EAAE,WAAW,EAAE,CAAC,CAAC;QAEnD,OAAO,CAAC,cAAc,CAAC,kDAAmB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"dynamic-method.decorator.js","sourceRoot":"","sources":["../../src/decorators/dynamic-method.decorator.ts"],"names":[],"mappings":";;AA6BA,sCAUC;AAvCD,qGAAyF;AACzF,qFAA8E;AAC9E,sFAAkF;AAIlF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,aAAa,CAAU,OAAiC;IACpE,MAAM,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,0CAAmB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEzG,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,IAAA,2CAAkB,EAAe,kDAAmB,EAAE,MAAM,CAAC,CAAC;QAE9E,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,gBAAgB,EAAE,WAAW,EAAE,CAAC,CAAC;QAEnD,OAAO,CAAC,cAAc,CAAC,kDAAmB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjE,CAAC,CAAC;AACN,CAAC"}
@@ -4,6 +4,7 @@ exports.QueryMethod = QueryMethod;
4
4
  const VSRepoError_1 = require("../errors/VSRepoError");
5
5
  const query_methods_key_constant_1 = require("../internal/constants/query-methods-key.constant");
6
6
  const vsrepo_error_type_enum_1 = require("../internal/enums/vsrepo-error-type.enum");
7
+ const own_metadata_list_util_1 = require("../internal/utils/own-metadata-list.util");
7
8
  const decorators_validator_1 = require("../internal/validators/decorators.validator");
8
9
  /**
9
10
  * Property decorator used to declare a raw SQL query method on a `VSRepository`
@@ -41,7 +42,7 @@ function QueryMethod(value, options) {
41
42
  }
42
43
  const validatedConfig = decorators_validator_1.DecoratorsValidator.validateQueryMethodOptions(options);
43
44
  return (target, propertyKey) => {
44
- const methods = Reflect.getMetadata(query_methods_key_constant_1.QUERY_METHODS_KEY, target) ?? [];
45
+ const methods = (0, own_metadata_list_util_1.getOwnMetadataList)(query_methods_key_constant_1.QUERY_METHODS_KEY, target);
45
46
  methods.push({ ...validatedConfig, value, propertyKey });
46
47
  Reflect.defineMetadata(query_methods_key_constant_1.QUERY_METHODS_KEY, methods, target);
47
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"query-method.decorator.js","sourceRoot":"","sources":["../../src/decorators/query-method.decorator.ts"],"names":[],"mappings":";;AAqCA,kCAcC;AAnDD,uDAAoD;AACpD,iGAAqF;AACrF,qFAA2E;AAC3E,sFAAkF;AAIlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,OAA4B;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,yBAAW,CAAC,gCAAgC,EAAE,wCAAe,CAAC,SAAS,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,eAAe,GAAuB,0CAAmB,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAEpG,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACpD,MAAM,OAAO,GAAkB,OAAO,CAAC,WAAW,CAAC,8CAAiB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QAEpF,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QAEzD,OAAO,CAAC,cAAc,CAAC,8CAAiB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"query-method.decorator.js","sourceRoot":"","sources":["../../src/decorators/query-method.decorator.ts"],"names":[],"mappings":";;AAsCA,kCAcC;AApDD,uDAAoD;AACpD,iGAAqF;AACrF,qFAA2E;AAC3E,qFAA8E;AAC9E,sFAAkF;AAIlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,OAA4B;IACnE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,yBAAW,CAAC,gCAAgC,EAAE,wCAAe,CAAC,SAAS,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,eAAe,GAAuB,0CAAmB,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAEpG,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,IAAA,2CAAkB,EAAc,8CAAiB,EAAE,MAAM,CAAC,CAAC;QAE3E,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QAEzD,OAAO,CAAC,cAAc,CAAC,8CAAiB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function getOwnMetadataList<V>(key: symbol, target: object): V[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOwnMetadataList = getOwnMetadataList;
4
+ function getOwnMetadataList(key, target) {
5
+ const own = Reflect.getOwnMetadata(key, target);
6
+ if (own)
7
+ return own;
8
+ const inherited = Reflect.getMetadata(key, target);
9
+ return inherited ? [...inherited] : [];
10
+ }
11
+ //# sourceMappingURL=own-metadata-list.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"own-metadata-list.util.js","sourceRoot":"","sources":["../../../src/internal/utils/own-metadata-list.util.ts"],"names":[],"mappings":";;AAAA,gDAMC;AAND,SAAgB,kBAAkB,CAAI,GAAW,EAAE,MAAc;IAC7D,MAAM,GAAG,GAAoB,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjE,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IAEpB,MAAM,SAAS,GAAoB,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpE,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vsrepo",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "ORM-agnostic repository pattern library",
5
5
  "homepage": "https://github.com/jaobrabo123/VSRepository#readme",
6
6
  "repository": {