@lenne.tech/nest-server 12.9.2 → 12.9.4

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.
Files changed (54) hide show
  1. package/.claude/rules/package-management.md +7 -2
  2. package/.claude/rules/testing.md +4 -4
  3. package/FRAMEWORK-API.md +1 -1
  4. package/dist/core/common/helpers/byte-range.helper.d.ts +8 -0
  5. package/dist/core/common/helpers/byte-range.helper.js +71 -0
  6. package/dist/core/common/helpers/byte-range.helper.js.map +1 -0
  7. package/dist/core/common/helpers/gridfs.helper.d.ts +7 -2
  8. package/dist/core/common/helpers/gridfs.helper.js +7 -4
  9. package/dist/core/common/helpers/gridfs.helper.js.map +1 -1
  10. package/dist/core/common/services/core-s3.service.d.ts +3 -0
  11. package/dist/core/common/services/core-s3.service.js +8 -1
  12. package/dist/core/common/services/core-s3.service.js.map +1 -1
  13. package/dist/core/modules/error-code/error-codes.d.ts +9 -0
  14. package/dist/core/modules/error-code/error-codes.js +8 -0
  15. package/dist/core/modules/error-code/error-codes.js.map +1 -1
  16. package/dist/core/modules/file/core-file.controller.d.ts +5 -0
  17. package/dist/core/modules/file/core-file.controller.js +66 -4
  18. package/dist/core/modules/file/core-file.controller.js.map +1 -1
  19. package/dist/core/modules/file/core-file.service.d.ts +2 -0
  20. package/dist/core/modules/file/core-file.service.js +17 -6
  21. package/dist/core/modules/file/core-file.service.js.map +1 -1
  22. package/dist/core/modules/file/filesystem-file.helper.d.ts +2 -1
  23. package/dist/core/modules/file/filesystem-file.helper.js +2 -2
  24. package/dist/core/modules/file/filesystem-file.helper.js.map +1 -1
  25. package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +2 -0
  26. package/dist/core/modules/file/s3-file.helper.d.ts +2 -0
  27. package/dist/core/modules/file/s3-file.helper.js.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/server/modules/error-code/error-codes.d.ts +1 -0
  32. package/dist/test/test.helper.d.ts +1 -0
  33. package/dist/test/test.helper.js +6 -0
  34. package/dist/test/test.helper.js.map +1 -1
  35. package/docs/REQUEST-LIFECYCLE.md +1 -1
  36. package/docs/error-codes.md +14 -0
  37. package/docs/security-overrides.md +44 -10
  38. package/migration-guides/12.9.2-to-12.9.3.md +127 -0
  39. package/migration-guides/12.9.3-to-12.9.4.md +135 -0
  40. package/package.json +27 -27
  41. package/src/core/common/helpers/byte-range.helper.ts +144 -0
  42. package/src/core/common/helpers/gridfs.helper.ts +20 -6
  43. package/src/core/common/services/core-s3.service.ts +16 -2
  44. package/src/core/modules/error-code/error-codes.ts +13 -0
  45. package/src/core/modules/file/INTEGRATION-CHECKLIST.md +1 -0
  46. package/src/core/modules/file/README.md +74 -1
  47. package/src/core/modules/file/core-file.controller.ts +139 -3
  48. package/src/core/modules/file/core-file.service.ts +33 -13
  49. package/src/core/modules/file/filesystem-file.helper.ts +8 -3
  50. package/src/core/modules/file/interfaces/file-service-options.interface.ts +13 -0
  51. package/src/core/modules/file/s3-file.helper.ts +3 -2
  52. package/src/index.ts +1 -0
  53. package/src/test/README.md +8 -4
  54. package/src/test/test.helper.ts +12 -0
@@ -205,10 +205,11 @@ await fs.promises.writeFile('/tmp/downloaded.bin', buffer);
205
205
 
206
206
  The second parameter accepts either a plain token string or a `TestDownloadOptions` object:
207
207
 
208
- | Option | Type | Description |
209
- | --------- | -------- | ------------------------------------------------------------- |
210
- | `token` | `string` | Bearer token via Authorization header (JWT) |
211
- | `cookies` | `string` | Plain session token, converted via `buildBetterAuthCookies()` |
208
+ | Option | Type | Description |
209
+ | --------- | ------------------------ | ------------------------------------------------------------- |
210
+ | `token` | `string` | Bearer token via Authorization header (JWT) |
211
+ | `cookies` | `string` | Plain session token, converted via `buildBetterAuthCookies()` |
212
+ | `headers` | `Record<string, string>` | Additional request headers, e.g. `Range` (since 12.9.3) |
212
213
 
213
214
  Both can be used simultaneously — `token` sets the Authorization header while `cookies` sets the Cookie header.
214
215
 
@@ -224,6 +225,9 @@ await testHelper.download('/files/id/abc123', { cookies: sessionToken });
224
225
 
225
226
  // Both simultaneously
226
227
  await testHelper.download('/files/id/abc123', { cookies: sessionToken, token: jwtToken });
228
+
229
+ // A byte range: 206, `Content-Range: bytes 0-1/<length>`, two bytes in `res.data`
230
+ const res = await testHelper.download('/files/id/abc123', { headers: { Range: 'bytes=0-1' }, token: jwtToken });
227
231
  ```
228
232
 
229
233
  ## GraphQL Testing (`testHelper.graphQl()`)
@@ -190,6 +190,12 @@ export interface TestDownloadOptions {
190
190
  */
191
191
  cookies?: string;
192
192
 
193
+ /**
194
+ * Additional request headers, e.g. `{ Range: 'bytes=0-1' }` for a ranged download or `If-None-Match`.
195
+ * Set before `cookies` and `token`, which win for their own header. Since 12.9.3.
196
+ */
197
+ headers?: Record<string, string>;
198
+
193
199
  /**
194
200
  * Bearer token via Authorization header (JWT authentication).
195
201
  * Can be used simultaneously with `cookies` — token sets the Authorization header
@@ -386,6 +392,9 @@ export class TestHelper {
386
392
  if (typeof tokenOrOptions === 'string') {
387
393
  request.set('Authorization', `bearer ${tokenOrOptions}`);
388
394
  } else if (tokenOrOptions) {
395
+ for (const [name, value] of Object.entries(tokenOrOptions.headers ?? {})) {
396
+ request.set(name, value);
397
+ }
389
398
  if (tokenOrOptions.cookies) {
390
399
  const cookieRecord = TestHelper.buildBetterAuthCookies(tokenOrOptions.cookies);
391
400
  request.set(
@@ -431,6 +440,9 @@ export class TestHelper {
431
440
  if (typeof tokenOrOptions === 'string') {
432
441
  request.set('Authorization', `bearer ${tokenOrOptions}`);
433
442
  } else if (tokenOrOptions) {
443
+ for (const [name, value] of Object.entries(tokenOrOptions.headers ?? {})) {
444
+ request.set(name, value);
445
+ }
434
446
  if (tokenOrOptions.cookies) {
435
447
  const cookieRecord = TestHelper.buildBetterAuthCookies(tokenOrOptions.cookies);
436
448
  request.set(