@lenne.tech/nest-server 12.9.1 → 12.9.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/.claude/rules/configurable-features.md +1 -1
- package/.claude/rules/testing.md +4 -4
- package/FRAMEWORK-API.md +1 -1
- package/dist/core/common/helpers/byte-range.helper.d.ts +8 -0
- package/dist/core/common/helpers/byte-range.helper.js +71 -0
- package/dist/core/common/helpers/byte-range.helper.js.map +1 -0
- package/dist/core/common/helpers/gridfs.helper.d.ts +7 -2
- package/dist/core/common/helpers/gridfs.helper.js +7 -4
- package/dist/core/common/helpers/gridfs.helper.js.map +1 -1
- package/dist/core/common/services/core-s3.service.d.ts +3 -0
- package/dist/core/common/services/core-s3.service.js +8 -1
- package/dist/core/common/services/core-s3.service.js.map +1 -1
- package/dist/core/modules/error-code/error-codes.d.ts +9 -0
- package/dist/core/modules/error-code/error-codes.js +8 -0
- package/dist/core/modules/error-code/error-codes.js.map +1 -1
- package/dist/core/modules/file/core-file.controller.d.ts +6 -0
- package/dist/core/modules/file/core-file.controller.js +84 -27
- package/dist/core/modules/file/core-file.controller.js.map +1 -1
- package/dist/core/modules/file/core-file.service.d.ts +2 -0
- package/dist/core/modules/file/core-file.service.js +17 -6
- package/dist/core/modules/file/core-file.service.js.map +1 -1
- package/dist/core/modules/file/filesystem-file.helper.d.ts +2 -1
- package/dist/core/modules/file/filesystem-file.helper.js +2 -2
- package/dist/core/modules/file/filesystem-file.helper.js.map +1 -1
- package/dist/core/modules/file/interfaces/file-service-options.interface.d.ts +2 -0
- package/dist/core/modules/file/s3-file.helper.d.ts +2 -0
- package/dist/core/modules/file/s3-file.helper.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server/modules/error-code/error-codes.d.ts +1 -0
- package/dist/test/test.helper.d.ts +1 -0
- package/dist/test/test.helper.js +6 -0
- package/dist/test/test.helper.js.map +1 -1
- package/docs/REQUEST-LIFECYCLE.md +1 -1
- package/docs/error-codes.md +14 -0
- package/migration-guides/12.8.8-to-12.8.9.md +15 -3
- package/migration-guides/12.9.1-to-12.9.2.md +75 -0
- package/migration-guides/12.9.2-to-12.9.3.md +127 -0
- package/package.json +1 -1
- package/src/core/common/helpers/byte-range.helper.ts +144 -0
- package/src/core/common/helpers/gridfs.helper.ts +20 -6
- package/src/core/common/services/core-s3.service.ts +16 -2
- package/src/core/modules/error-code/error-codes.ts +13 -0
- package/src/core/modules/file/INTEGRATION-CHECKLIST.md +17 -15
- package/src/core/modules/file/README.md +90 -3
- package/src/core/modules/file/core-file.controller.ts +185 -32
- package/src/core/modules/file/core-file.service.ts +33 -13
- package/src/core/modules/file/filesystem-file.helper.ts +8 -3
- package/src/core/modules/file/interfaces/file-service-options.interface.ts +13 -0
- package/src/core/modules/file/s3-file.helper.ts +3 -2
- package/src/index.ts +1 -0
- package/src/test/README.md +8 -4
- package/src/test/test.helper.ts +12 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Types } from 'mongoose';
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
3
|
|
|
4
|
+
import type { ByteRange } from '../../common/helpers/byte-range.helper.js';
|
|
4
5
|
import { CoreS3Service } from '../../common/services/core-s3.service.js';
|
|
5
6
|
import {
|
|
6
7
|
ensureFilenameIndex,
|
|
@@ -216,12 +217,12 @@ export class S3FileHelper {
|
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
/**
|
|
219
|
-
* Get the download stream of a file
|
|
220
|
+
* Get the download stream of a file — with `range`, only those bytes (both inclusive)
|
|
220
221
|
*/
|
|
221
222
|
static async getStream(
|
|
222
223
|
s3Service: CoreS3Service,
|
|
223
224
|
id: string | Types.ObjectId,
|
|
224
|
-
options?: { abortSignal?: AbortSignal; idleTimeoutMs?: false | number },
|
|
225
|
+
options?: { abortSignal?: AbortSignal; idleTimeoutMs?: false | number; range?: ByteRange },
|
|
225
226
|
): Promise<Readable> {
|
|
226
227
|
const objectId = typeof id === 'string' ? newObjectId(id) : id;
|
|
227
228
|
return (await s3Service.getObject(objectId.toHexString(), options)).body;
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from './core/common/enums/sort-order.emum.js';
|
|
|
30
30
|
export * from './core/common/exceptions/access-denied.exception.js';
|
|
31
31
|
export * from './core/common/filters/http-exception-log.filter.js';
|
|
32
32
|
export * from './core/common/filters/mongoose-cast-error.filter.js';
|
|
33
|
+
export * from './core/common/helpers/byte-range.helper.js';
|
|
33
34
|
export * from './core/common/helpers/common.helper.js';
|
|
34
35
|
export * from './core/common/helpers/config.helper.js';
|
|
35
36
|
export * from './core/common/helpers/config-endpoint.helper.js';
|
package/src/test/README.md
CHANGED
|
@@ -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
|
|
209
|
-
| --------- |
|
|
210
|
-
| `token` | `string`
|
|
211
|
-
| `cookies` | `string`
|
|
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()`)
|
package/src/test/test.helper.ts
CHANGED
|
@@ -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(
|