@fluojs/http 1.0.0-beta.7 → 1.0.0-beta.9

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.
@@ -6,7 +6,6 @@ import type { Validator } from '../types.js';
6
6
  export declare class HttpDtoValidationAdapter implements Validator {
7
7
  private readonly validator;
8
8
  private throwBadRequestForValidationError;
9
- private getValidationValue;
10
9
  validate(value: unknown, target: Constructor): Promise<void>;
11
10
  materialize<T>(value: unknown, target: Constructor<T>): Promise<T>;
12
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dto-validation-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/dto-validation-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,aAAa,CAAC;AAG9D;;GAEG;AACH,qBAAa,wBAAyB,YAAW,SAAS;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD,OAAO,CAAC,iCAAiC;IAMzC,OAAO,CAAC,kBAAkB;IAIpB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5D,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAWzE"}
1
+ {"version":3,"file":"dto-validation-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/dto-validation-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,aAAa,CAAC;AAG9D;;GAEG;AACH,qBAAa,wBAAyB,YAAW,SAAS;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD,OAAO,CAAC,iCAAiC;IAMnC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5D,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAWzE"}
@@ -13,16 +13,13 @@ export class HttpDtoValidationAdapter {
13
13
  details: error.issues.map(issue => toInputErrorDetail(issue))
14
14
  });
15
15
  }
16
- getValidationValue(value, target) {
17
- return getCompiledDtoBindingPlan(target).toValidationValue(value);
18
- }
19
16
  async validate(value, target) {
20
17
  try {
21
18
  const plan = getCompiledDtoBindingPlan(target);
22
19
  if (!plan.needsValidation) {
23
20
  return;
24
21
  }
25
- await this.validator.validate(this.getValidationValue(value, target), target);
22
+ await this.validator.validate(plan.toValidationValue(value), target);
26
23
  } catch (error) {
27
24
  if (error instanceof DtoValidationError) {
28
25
  this.throwBadRequestForValidationError(error);
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch-routing-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-routing-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQ3G;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAOlH"}
1
+ {"version":3,"file":"dispatch-routing-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-routing-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQ3G;AA2BD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAsBlH"}
@@ -13,6 +13,25 @@ export function matchHandlerOrThrow(handlerMapping, request) {
13
13
  }
14
14
  return match;
15
15
  }
16
+ function defineRequestParams(request, params) {
17
+ Object.defineProperty(request, 'params', {
18
+ configurable: true,
19
+ enumerable: true,
20
+ value: params,
21
+ writable: true
22
+ });
23
+ }
24
+ function findInheritedParamsDescriptor(request) {
25
+ let prototype = Object.getPrototypeOf(request);
26
+ while (prototype) {
27
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, 'params');
28
+ if (descriptor) {
29
+ return descriptor;
30
+ }
31
+ prototype = Object.getPrototypeOf(prototype);
32
+ }
33
+ return undefined;
34
+ }
16
35
 
17
36
  /**
18
37
  * Update request params.
@@ -21,10 +40,20 @@ export function matchHandlerOrThrow(handlerMapping, request) {
21
40
  * @param params The params.
22
41
  */
23
42
  export function updateRequestParams(requestContext, params) {
24
- Object.defineProperty(requestContext.request, 'params', {
25
- configurable: true,
26
- enumerable: true,
27
- value: params,
28
- writable: true
29
- });
43
+ const request = requestContext.request;
44
+ const ownDescriptor = Object.getOwnPropertyDescriptor(request, 'params');
45
+ if (ownDescriptor) {
46
+ if ('value' in ownDescriptor && ownDescriptor.writable) {
47
+ request.params = params;
48
+ return;
49
+ }
50
+ defineRequestParams(request, params);
51
+ return;
52
+ }
53
+ const inheritedDescriptor = findInheritedParamsDescriptor(request);
54
+ if (!inheritedDescriptor || 'value' in inheritedDescriptor && inheritedDescriptor.writable) {
55
+ request.params = params;
56
+ return;
57
+ }
58
+ defineRequestParams(request, params);
30
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eligibility-checker.d.ts","sourceRoot":"","sources":["../../../src/dispatch/fast-path/eligibility-checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,KAAK,mBAAmB,EAAgC,MAAM,kBAAkB,CAAC;AAM1F,UAAU,uBAAuB;IAC/B,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;CACrB;AA0DD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,MAAM,GACd,uBAAuB,CAgEzB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,iBAAiB,GACzB,mBAAmB,GAAG,SAAS,CAIjC;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,iBAAiB,EAC1B,WAAW,EAAE,mBAAmB,GAC/B,IAAI,CAGN;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
1
+ {"version":3,"file":"eligibility-checker.d.ts","sourceRoot":"","sources":["../../../src/dispatch/fast-path/eligibility-checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,KAAK,mBAAmB,EAAgC,MAAM,kBAAkB,CAAC;AAM1F,UAAU,uBAAuB;IAC/B,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;CACrB;AA0DD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,MAAM,GACd,uBAAuB,CA6DzB;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,iBAAiB,GACzB,mBAAmB,GAAG,SAAS,CAIjC;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,iBAAiB,EAC1B,WAAW,EAAE,mBAAmB,GAC/B,IAAI,CAGN;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
@@ -70,9 +70,6 @@ export function compileFastPathEligibility(handler, options, adapter) {
70
70
  if (eligibility.hasInterceptor) {
71
71
  blockingReasons.push('interceptors');
72
72
  }
73
- if (eligibility.hasPipe) {
74
- blockingReasons.push('pipes/DTO binding');
75
- }
76
73
  if (eligibility.hasRequestScopedDI) {
77
74
  blockingReasons.push('request-scoped DI');
78
75
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "controller",
11
11
  "rest"
12
12
  ],
13
- "version": "1.0.0-beta.7",
13
+ "version": "1.0.0-beta.9",
14
14
  "private": false,
15
15
  "license": "MIT",
16
16
  "repository": {
@@ -41,9 +41,9 @@
41
41
  "dist"
42
42
  ],
43
43
  "dependencies": {
44
- "@fluojs/di": "^1.0.0-beta.5",
44
+ "@fluojs/core": "^1.0.0-beta.2",
45
45
  "@fluojs/validation": "^1.0.0-beta.1",
46
- "@fluojs/core": "^1.0.0-beta.2"
46
+ "@fluojs/di": "^1.0.0-beta.5"
47
47
  },
48
48
  "devDependencies": {
49
49
  "vitest": "^3.2.4"