@muhgholy/next-drive 4.23.33 → 4.23.34
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/README.md +79 -3
- package/dist/{chunk-HWNIRA6Y.cjs → chunk-DHIHCER6.cjs} +220 -71
- package/dist/chunk-DHIHCER6.cjs.map +1 -0
- package/dist/{chunk-2DCZENJ2.js → chunk-E72MTT6W.js} +3 -3
- package/dist/{chunk-2DCZENJ2.js.map → chunk-E72MTT6W.js.map} +1 -1
- package/dist/{chunk-WUG4ATLH.cjs → chunk-PKNXKHGS.cjs} +37 -37
- package/dist/{chunk-WUG4ATLH.cjs.map → chunk-PKNXKHGS.cjs.map} +1 -1
- package/dist/{chunk-IWV6G7HQ.js → chunk-QMPV4YSZ.js} +221 -73
- package/dist/chunk-QMPV4YSZ.js.map +1 -0
- package/dist/server/controllers/drive.d.ts +33 -2
- package/dist/server/controllers/drive.d.ts.map +1 -1
- package/dist/server/errors.d.ts +12 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/express.cjs +16 -12
- package/dist/server/express.cjs.map +1 -1
- package/dist/server/express.d.ts +3 -0
- package/dist/server/express.d.ts.map +1 -1
- package/dist/server/express.js +4 -4
- package/dist/server/express.js.map +1 -1
- package/dist/server/hono.cjs +16 -12
- package/dist/server/hono.cjs.map +1 -1
- package/dist/server/hono.d.ts +3 -0
- package/dist/server/hono.d.ts.map +1 -1
- package/dist/server/hono.js +4 -4
- package/dist/server/hono.js.map +1 -1
- package/dist/server/index.cjs +23 -19
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/storage-adapters/google.d.ts.map +1 -1
- package/dist/server/tus.d.ts.map +1 -1
- package/dist/tus-EQ2IXSRE.cjs +20 -0
- package/dist/tus-EQ2IXSRE.cjs.map +1 -0
- package/dist/tus-ODCMFEBZ.js +3 -0
- package/dist/tus-ODCMFEBZ.js.map +1 -0
- package/dist/types/server/storage.d.ts +4 -1
- package/dist/types/server/storage.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HWNIRA6Y.cjs.map +0 -1
- package/dist/chunk-IWV6G7HQ.js.map +0 -1
- package/dist/tus-5LLFMVQK.cjs +0 -20
- package/dist/tus-5LLFMVQK.cjs.map +0 -1
- package/dist/tus-C4T5ZDTG.js +0 -3
- package/dist/tus-C4T5ZDTG.js.map +0 -1
|
@@ -14,6 +14,10 @@ export declare const driveAddSignedUrlTokens: (items: TDatabaseDrive[], config:
|
|
|
14
14
|
/**
|
|
15
15
|
* Read a file and return a readable stream.
|
|
16
16
|
* @param file - Either a file ID (string) or a TDatabaseDrive/IDatabaseDriveDocument object
|
|
17
|
+
* @param options - Optional progress/abort controls. `onProgress` fires for bytes piped through the
|
|
18
|
+
* returned stream (works uniformly for local files and Google Drive files, cache-hit or cache-miss
|
|
19
|
+
* alike). `signal` abort destroys the returned stream mid-read - the caller observes this as an
|
|
20
|
+
* `'error'` event on the stream carrying a `DriveError` with `code: 'ABORTED'`.
|
|
17
21
|
* @returns Promise with readable stream, mime type, and file size
|
|
18
22
|
* @example
|
|
19
23
|
* ```typescript
|
|
@@ -24,9 +28,20 @@ export declare const driveAddSignedUrlTokens: (items: TDatabaseDrive[], config:
|
|
|
24
28
|
* // Using database document
|
|
25
29
|
* const drive = await Drive.findById(fileId);
|
|
26
30
|
* const { stream, mime, size } = await driveReadFile(drive);
|
|
31
|
+
*
|
|
32
|
+
* // With progress and abort
|
|
33
|
+
* const controller = new AbortController();
|
|
34
|
+
* const { stream } = await driveReadFile(fileId, {
|
|
35
|
+
* onProgress: ({ percentage }) => console.log(`${percentage}%`),
|
|
36
|
+
* signal: controller.signal,
|
|
37
|
+
* });
|
|
38
|
+
* stream.on('error', (err) => { if (err instanceof DriveError && err.code === 'ABORTED') { ... } });
|
|
27
39
|
* ```
|
|
28
40
|
*/
|
|
29
|
-
export declare const driveReadFile: (file: string | IDatabaseDriveDocument | TDatabaseDrive
|
|
41
|
+
export declare const driveReadFile: (file: string | IDatabaseDriveDocument | TDatabaseDrive, options?: {
|
|
42
|
+
onProgress?: (info: TDriveTransferProgress) => void;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
}) => Promise<{
|
|
30
45
|
stream: Readable;
|
|
31
46
|
mime: string;
|
|
32
47
|
size: number;
|
|
@@ -47,9 +62,15 @@ export declare const driveReadFile: (file: string | IDatabaseDriveDocument | TDa
|
|
|
47
62
|
* ```
|
|
48
63
|
*/
|
|
49
64
|
export declare const driveInfo: (source: string | TDriveFile) => Promise<import("../../types/client").TDriveInformation>;
|
|
65
|
+
export type TDriveTransferProgress = {
|
|
66
|
+
bytesDownloaded: number;
|
|
67
|
+
totalBytes: number;
|
|
68
|
+
percentage: number;
|
|
69
|
+
};
|
|
50
70
|
/**
|
|
51
71
|
* Get the local file system path for a file. For Google Drive files, downloads them to a local cache first.
|
|
52
72
|
* @param file - Either a file ID (string) or a TDatabaseDrive/IDatabaseDriveDocument object
|
|
73
|
+
* @param options - Optional progress/abort controls, only relevant for a Google Drive cache-miss download
|
|
53
74
|
* @returns Promise with readonly object containing the absolute file path and metadata
|
|
54
75
|
* @example
|
|
55
76
|
* ```typescript
|
|
@@ -61,9 +82,19 @@ export declare const driveInfo: (source: string | TDriveFile) => Promise<import(
|
|
|
61
82
|
* const drive = await Drive.findById(fileId);
|
|
62
83
|
* const { path, name, provider } = await driveFilePath(drive);
|
|
63
84
|
* await processFile(path);
|
|
85
|
+
*
|
|
86
|
+
* // With progress and abort (only fires for an actual Google Drive cache-miss download)
|
|
87
|
+
* const controller = new AbortController();
|
|
88
|
+
* const result = await driveFilePath(fileId, {
|
|
89
|
+
* onProgress: ({ bytesDownloaded, totalBytes, percentage }) => console.log(`${percentage}%`),
|
|
90
|
+
* signal: controller.signal,
|
|
91
|
+
* });
|
|
64
92
|
* ```
|
|
65
93
|
*/
|
|
66
|
-
export declare const driveFilePath: (file: string | IDatabaseDriveDocument | TDatabaseDrive
|
|
94
|
+
export declare const driveFilePath: (file: string | IDatabaseDriveDocument | TDatabaseDrive, options?: {
|
|
95
|
+
onProgress?: (info: TDriveTransferProgress) => void;
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
}) => Promise<Readonly<{
|
|
67
98
|
path: string;
|
|
68
99
|
name: string;
|
|
69
100
|
mime: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drive.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/drive.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"drive.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/drive.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AAGtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,iBAAiB,GAAU,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAG,OAAO,CAAC,MAAM,CAG7F,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,KAAG,OAAO,CAAC,MAAM,CAO1F,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,iBAAa,EAAE,qBAAgB,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAarK,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,UAAU;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,KAA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* Structured error codes for the next-drive server package. Every error thrown directly by
|
|
3
|
+
* `src/server/controllers/drive.ts` uses this class so callers can distinguish failure reasons
|
|
4
|
+
* programmatically (e.g. `err instanceof DriveError && err.code === 'NOT_FOUND'`) instead of
|
|
5
|
+
* matching on message text.
|
|
6
|
+
*/
|
|
7
|
+
export type TDriveErrorCode = 'NOT_FOUND' | 'INVALID_REFERENCE' | 'INVALID_TYPE' | 'FILE_MISSING' | 'UNSUPPORTED_PROVIDER' | 'ACCESS_DENIED' | 'FOLDER_NOT_EMPTY' | 'INVALID_PATH' | 'INVALID_MIME_TYPE' | 'FILE_TOO_LARGE' | 'QUOTA_EXCEEDED' | 'MAX_DEPTH_EXCEEDED' | 'ABORTED' | 'DOWNLOAD_FAILED';
|
|
8
|
+
export declare class DriveError extends Error {
|
|
9
|
+
readonly code: TDriveErrorCode;
|
|
10
|
+
constructor(code: TDriveErrorCode, message: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/server/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACrB,WAAW,GACX,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,SAAS,GACT,iBAAiB,CAAC;AAExB,qBAAa,UAAW,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;gBAEnB,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;CAKrD"}
|
package/dist/server/express.cjs
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPKNXKHGS_cjs = require('../chunk-PKNXKHGS.cjs');
|
|
4
4
|
require('../chunk-HQTC3554.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkDHIHCER6_cjs = require('../chunk-DHIHCER6.cjs');
|
|
6
6
|
|
|
7
7
|
// src/server/express.ts
|
|
8
|
-
var driveAPIHandlerExpress =
|
|
9
|
-
var driveConfigurationExpress =
|
|
8
|
+
var driveAPIHandlerExpress = chunkPKNXKHGS_cjs.driveAPIHandler;
|
|
9
|
+
var driveConfigurationExpress = chunkDHIHCER6_cjs.driveConfiguration;
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "driveFileSchemaZod", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkPKNXKHGS_cjs.driveFileSchemaZod; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "DriveError", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkDHIHCER6_cjs.DriveError; }
|
|
14
18
|
});
|
|
15
19
|
Object.defineProperty(exports, "driveDelete", {
|
|
16
20
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkDHIHCER6_cjs.driveDelete; }
|
|
18
22
|
});
|
|
19
23
|
Object.defineProperty(exports, "driveFilePath", {
|
|
20
24
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkDHIHCER6_cjs.driveFilePath; }
|
|
22
26
|
});
|
|
23
27
|
Object.defineProperty(exports, "driveGetUrl", {
|
|
24
28
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkDHIHCER6_cjs.driveGetUrl; }
|
|
26
30
|
});
|
|
27
31
|
Object.defineProperty(exports, "driveList", {
|
|
28
32
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkDHIHCER6_cjs.driveList; }
|
|
30
34
|
});
|
|
31
35
|
Object.defineProperty(exports, "driveReadFile", {
|
|
32
36
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkDHIHCER6_cjs.driveReadFile; }
|
|
34
38
|
});
|
|
35
39
|
Object.defineProperty(exports, "driveUpload", {
|
|
36
40
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkDHIHCER6_cjs.driveUpload; }
|
|
38
42
|
});
|
|
39
43
|
Object.defineProperty(exports, "getDriveConfig", {
|
|
40
44
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkDHIHCER6_cjs.getDriveConfig; }
|
|
42
46
|
});
|
|
43
47
|
exports.driveAPIHandlerExpress = driveAPIHandlerExpress;
|
|
44
48
|
exports.driveConfigurationExpress = driveConfigurationExpress;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/express.ts"],"names":["driveAPIHandler","driveConfiguration"],"mappings":";;;;;;;AASO,IAAM,sBAAA,GAAyBA;AAI/B,IAAM,yBAAA,GAA4BC","file":"express.cjs","sourcesContent":["// ** Express Adapter for next-drive\r\n// ** Provides Express-compatible types for the drive API handler and configuration\r\nimport type { Request, Response } from 'express';\r\nimport type { TDriveConfigurationExpress } from '@/types/server/express';\r\n\r\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\r\n\r\n// ** Express API Handler\r\n// ** Type-cast wrapper that allows Express Request/Response to be used with the core handler\r\nexport const driveAPIHandlerExpress = driveAPIHandler as unknown as (req: Request, res: Response) => Promise<void>;\r\n\r\n// ** Express Configuration\r\n// ** Type-cast wrapper that accepts Express Request in the information callback\r\nexport const driveConfigurationExpress = driveConfiguration as unknown as (config: TDriveConfigurationExpress) => Promise<TDriveConfigurationExpress>;\r\n\r\n// ** Re-export utilities that work with any framework\r\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\r\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\r\nexport { getDriveConfig } from '@/server/config';\r\n\r\n// ** Re-export types\r\nexport type { TDriveConfigurationExpress, TDriveConfigInformation } from '@/types/server/express';\r\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/server/express.ts"],"names":["driveAPIHandler","driveConfiguration"],"mappings":";;;;;;;AASO,IAAM,sBAAA,GAAyBA;AAI/B,IAAM,yBAAA,GAA4BC","file":"express.cjs","sourcesContent":["// ** Express Adapter for next-drive\r\n// ** Provides Express-compatible types for the drive API handler and configuration\r\nimport type { Request, Response } from 'express';\r\nimport type { TDriveConfigurationExpress } from '@/types/server/express';\r\n\r\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\r\n\r\n// ** Express API Handler\r\n// ** Type-cast wrapper that allows Express Request/Response to be used with the core handler\r\nexport const driveAPIHandlerExpress = driveAPIHandler as unknown as (req: Request, res: Response) => Promise<void>;\r\n\r\n// ** Express Configuration\r\n// ** Type-cast wrapper that accepts Express Request in the information callback\r\nexport const driveConfigurationExpress = driveConfiguration as unknown as (config: TDriveConfigurationExpress) => Promise<TDriveConfigurationExpress>;\r\n\r\n// ** Re-export utilities that work with any framework\r\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\r\nexport type { TDriveTransferProgress } from '@/server/controllers/drive';\r\nexport { DriveError } from '@/server/errors';\r\nexport type { TDriveErrorCode } from '@/server/errors';\r\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\r\nexport { getDriveConfig } from '@/server/config';\r\n\r\n// ** Re-export types\r\nexport type { TDriveConfigurationExpress, TDriveConfigInformation } from '@/types/server/express';\r\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\r\n"]}
|
package/dist/server/express.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import type { TDriveConfigurationExpress } from '../types/server/express';
|
|
|
3
3
|
export declare const driveAPIHandlerExpress: (req: Request, res: Response) => Promise<void>;
|
|
4
4
|
export declare const driveConfigurationExpress: (config: TDriveConfigurationExpress) => Promise<TDriveConfigurationExpress>;
|
|
5
5
|
export { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '../server/controllers/drive';
|
|
6
|
+
export type { TDriveTransferProgress } from '../server/controllers/drive';
|
|
7
|
+
export { DriveError } from '../server/errors';
|
|
8
|
+
export type { TDriveErrorCode } from '../server/errors';
|
|
6
9
|
export { driveFileSchemaZod } from '../server/zod/schemas';
|
|
7
10
|
export { getDriveConfig } from '../server/config';
|
|
8
11
|
export type { TDriveConfigurationExpress, TDriveConfigInformation } from '../types/server/express';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAMzE,eAAO,MAAM,sBAAsB,EAAiC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAInH,eAAO,MAAM,yBAAyB,EAAoC,CAAC,MAAM,EAAE,0BAA0B,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAGtJ,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5H,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,YAAY,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAClG,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAMzE,eAAO,MAAM,sBAAsB,EAAiC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAInH,eAAO,MAAM,yBAAyB,EAAoC,CAAC,MAAM,EAAE,0BAA0B,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAGtJ,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5H,YAAY,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,YAAY,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAClG,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/server/express.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { driveAPIHandler } from '../chunk-
|
|
2
|
-
export { driveFileSchemaZod } from '../chunk-
|
|
1
|
+
import { driveAPIHandler } from '../chunk-E72MTT6W.js';
|
|
2
|
+
export { driveFileSchemaZod } from '../chunk-E72MTT6W.js';
|
|
3
3
|
import '../chunk-OSYRIHH4.js';
|
|
4
|
-
import { driveConfiguration } from '../chunk-
|
|
5
|
-
export { driveDelete, driveFilePath, driveGetUrl, driveList, driveReadFile, driveUpload, getDriveConfig } from '../chunk-
|
|
4
|
+
import { driveConfiguration } from '../chunk-QMPV4YSZ.js';
|
|
5
|
+
export { DriveError, driveDelete, driveFilePath, driveGetUrl, driveList, driveReadFile, driveUpload, getDriveConfig } from '../chunk-QMPV4YSZ.js';
|
|
6
6
|
|
|
7
7
|
// src/server/express.ts
|
|
8
8
|
var driveAPIHandlerExpress = driveAPIHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/express.ts"],"names":[],"mappings":";;;;;;;AASO,IAAM,sBAAA,GAAyB;AAI/B,IAAM,yBAAA,GAA4B","file":"express.js","sourcesContent":["// ** Express Adapter for next-drive\r\n// ** Provides Express-compatible types for the drive API handler and configuration\r\nimport type { Request, Response } from 'express';\r\nimport type { TDriveConfigurationExpress } from '@/types/server/express';\r\n\r\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\r\n\r\n// ** Express API Handler\r\n// ** Type-cast wrapper that allows Express Request/Response to be used with the core handler\r\nexport const driveAPIHandlerExpress = driveAPIHandler as unknown as (req: Request, res: Response) => Promise<void>;\r\n\r\n// ** Express Configuration\r\n// ** Type-cast wrapper that accepts Express Request in the information callback\r\nexport const driveConfigurationExpress = driveConfiguration as unknown as (config: TDriveConfigurationExpress) => Promise<TDriveConfigurationExpress>;\r\n\r\n// ** Re-export utilities that work with any framework\r\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\r\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\r\nexport { getDriveConfig } from '@/server/config';\r\n\r\n// ** Re-export types\r\nexport type { TDriveConfigurationExpress, TDriveConfigInformation } from '@/types/server/express';\r\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/server/express.ts"],"names":[],"mappings":";;;;;;;AASO,IAAM,sBAAA,GAAyB;AAI/B,IAAM,yBAAA,GAA4B","file":"express.js","sourcesContent":["// ** Express Adapter for next-drive\r\n// ** Provides Express-compatible types for the drive API handler and configuration\r\nimport type { Request, Response } from 'express';\r\nimport type { TDriveConfigurationExpress } from '@/types/server/express';\r\n\r\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\r\n\r\n// ** Express API Handler\r\n// ** Type-cast wrapper that allows Express Request/Response to be used with the core handler\r\nexport const driveAPIHandlerExpress = driveAPIHandler as unknown as (req: Request, res: Response) => Promise<void>;\r\n\r\n// ** Express Configuration\r\n// ** Type-cast wrapper that accepts Express Request in the information callback\r\nexport const driveConfigurationExpress = driveConfiguration as unknown as (config: TDriveConfigurationExpress) => Promise<TDriveConfigurationExpress>;\r\n\r\n// ** Re-export utilities that work with any framework\r\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\r\nexport type { TDriveTransferProgress } from '@/server/controllers/drive';\r\nexport { DriveError } from '@/server/errors';\r\nexport type { TDriveErrorCode } from '@/server/errors';\r\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\r\nexport { getDriveConfig } from '@/server/config';\r\n\r\n// ** Re-export types\r\nexport type { TDriveConfigurationExpress, TDriveConfigInformation } from '@/types/server/express';\r\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\r\n"]}
|
package/dist/server/hono.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPKNXKHGS_cjs = require('../chunk-PKNXKHGS.cjs');
|
|
4
4
|
require('../chunk-HQTC3554.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkDHIHCER6_cjs = require('../chunk-DHIHCER6.cjs');
|
|
6
6
|
var stream = require('stream');
|
|
7
7
|
|
|
8
8
|
var HONO_CONTEXT = /* @__PURE__ */ Symbol("honoContext");
|
|
@@ -60,7 +60,7 @@ var buildNodeResponse = () => {
|
|
|
60
60
|
var driveAPIHandlerHono = async (c) => {
|
|
61
61
|
const req = buildNodeRequest(c);
|
|
62
62
|
const { res, toResponse } = buildNodeResponse();
|
|
63
|
-
await
|
|
63
|
+
await chunkPKNXKHGS_cjs.driveAPIHandler(req, res);
|
|
64
64
|
return toResponse();
|
|
65
65
|
};
|
|
66
66
|
var driveConfigurationHono = (config) => {
|
|
@@ -70,40 +70,44 @@ var driveConfigurationHono = (config) => {
|
|
|
70
70
|
const honoContext = input.req[HONO_CONTEXT];
|
|
71
71
|
return userInformation({ method: "REQUEST", req: honoContext });
|
|
72
72
|
} : void 0;
|
|
73
|
-
return
|
|
73
|
+
return chunkDHIHCER6_cjs.driveConfiguration({ ...config, information });
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
Object.defineProperty(exports, "driveFileSchemaZod", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkPKNXKHGS_cjs.driveFileSchemaZod; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "DriveError", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunkDHIHCER6_cjs.DriveError; }
|
|
79
83
|
});
|
|
80
84
|
Object.defineProperty(exports, "driveDelete", {
|
|
81
85
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkDHIHCER6_cjs.driveDelete; }
|
|
83
87
|
});
|
|
84
88
|
Object.defineProperty(exports, "driveFilePath", {
|
|
85
89
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkDHIHCER6_cjs.driveFilePath; }
|
|
87
91
|
});
|
|
88
92
|
Object.defineProperty(exports, "driveGetUrl", {
|
|
89
93
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkDHIHCER6_cjs.driveGetUrl; }
|
|
91
95
|
});
|
|
92
96
|
Object.defineProperty(exports, "driveList", {
|
|
93
97
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkDHIHCER6_cjs.driveList; }
|
|
95
99
|
});
|
|
96
100
|
Object.defineProperty(exports, "driveReadFile", {
|
|
97
101
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkDHIHCER6_cjs.driveReadFile; }
|
|
99
103
|
});
|
|
100
104
|
Object.defineProperty(exports, "driveUpload", {
|
|
101
105
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkDHIHCER6_cjs.driveUpload; }
|
|
103
107
|
});
|
|
104
108
|
Object.defineProperty(exports, "getDriveConfig", {
|
|
105
109
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkDHIHCER6_cjs.getDriveConfig; }
|
|
107
111
|
});
|
|
108
112
|
exports.driveAPIHandlerHono = driveAPIHandlerHono;
|
|
109
113
|
exports.driveConfigurationHono = driveConfigurationHono;
|
package/dist/server/hono.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/hono.ts"],"names":["stream","Readable","driveAPIHandler","driveConfiguration"],"mappings":";;;;;;;AAgBA,IAAM,YAAA,0BAAsB,aAAa,CAAA;AAQzC,IAAM,gBAAA,GAAmB,CAAC,CAAA,KAAwC;AAC9D,EAAA,MAAM,GAAA,GAAM,EAAE,GAAA,CAAI,GAAA;AAClB,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,EAAA,MAAM,QAA2C,EAAC;AAClD,EAAA,KAAA,MAAW,GAAA,IAAO,GAAA,CAAI,YAAA,CAAa,IAAA,EAAK,EAAG;AACvC,IAAA,IAAI,OAAO,KAAA,EAAO;AAClB,IAAA,MAAM,MAAA,GAAS,GAAA,CAAI,YAAA,CAAa,MAAA,CAAO,GAAG,CAAA;AAC1C,IAAA,KAAA,CAAM,GAAG,CAAA,GAAI,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,GAAS,OAAO,CAAC,CAAA;AAAA,EACtD;AAEA,EAAA,MAAM,UAAkC,EAAC;AACzC,EAAA,GAAA,CAAI,OAAA,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M,kBAAkB,MAAA,CAAO,WAAA;AAE/B,EAAA,MAAM,WAAA,GAAc,eAAA,GACd,OAAO,KAAA,KAAoE;AACvE,IAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,EAAO,OAAO,gBAAgB,KAAK,CAAA;AACxD,IAAA,MAAM,WAAA,GAAe,KAAA,CAAM,GAAA,CAAgC,YAAY,CAAA;AACvE,IAAA,OAAO,gBAAgB,EAAE,MAAA,EAAQ,SAAA,EAAW,GAAA,EAAK,aAAa,CAAA;AAAA,EAClE,CAAA,GACA,MAAA;AAEN,EAAA,OAAOC,oCAAA,CAAmB,EAAE,GAAG,MAAA,EAAQ,aAAoE,CAAA;AAC/G","file":"hono.cjs","sourcesContent":["// ** Hono Adapter for next-drive\n// ** Hono's `Context` is fetch-based (web `Request`/`Response`), while the core handler is written\n// ** against the Node `(req, res)` style (`NextApiRequest`/`NextApiResponse`) shared with the Next.js\n// ** and Express adapters. This bridges the two: builds a Node-shaped request/response from the\n// ** `Context`, runs it through the core handler, and returns a web `Response` for Hono to send.\nimport { Readable } from 'stream';\nimport type { Context } from 'hono';\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nimport type { TDriveInformationInput } from '@/types/server/config';\n\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\n\n// ** Marker used to stash the original Hono `Context` on the synthetic Node-style request built below,\n// ** so `driveConfigurationHono`'s `information` callback can hand the user back a real `Context`\n// ** (matching `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped stand-in.\nconst HONO_CONTEXT = Symbol('honoContext');\ntype TNodeRequestWithContext = NextApiRequest & { [HONO_CONTEXT]?: Context };\n\n// ** Builds a Node-`NextApiRequest`-shaped object - a real `Readable` instance carrying `.method`,\n// ** `.url`, `.headers` and `.query` - from a Hono `Context`'s underlying web `Request`. Being a real\n// ** `Readable` (rather than a plain object) matters for `?action=upload`: `handleUpload`\n// ** (src/server/tus.ts) calls `Readable.toWeb(req)` on whatever is passed as `req`, which requires an\n// ** actual stream instance.\nconst buildNodeRequest = (c: Context): TNodeRequestWithContext => {\n const raw = c.req.raw;\n const url = new URL(raw.url);\n\n const query: Record<string, string | string[]> = {};\n for (const key of url.searchParams.keys()) {\n if (key in query) continue;\n const values = url.searchParams.getAll(key);\n query[key] = values.length > 1 ? values : values[0];\n }\n\n const headers: Record<string, string> = {};\n raw.headers.forEach((value, key) => { headers[key] = value; });\n\n const stream = raw.body\n ? (Readable.fromWeb(raw.body as unknown as import('stream/web').ReadableStream) as unknown as Readable)\n : new Readable({ read() { this.push(null); } });\n\n return Object.assign(stream, { method: raw.method, url: url.pathname + url.search, headers, query, [HONO_CONTEXT]: c }) as unknown as TNodeRequestWithContext;\n};\n\n// ** Minimal Node-`ServerResponse`-shaped object that buffers status/headers/body (everything the core\n// ** handler, `applyCorsHeaders` and `handleUpload` call: `.status().json()`, `.setHeader()`, `.send()`,\n// ** `.end()`, and direct `.statusCode =` assignment) so it can be translated into a web `Response`.\nconst buildNodeResponse = (): { res: NextApiResponse; toResponse: () => Response } => {\n const state: { statusCode: number; headers: Headers; body: BodyInit | null; ended: boolean } = { statusCode: 200, headers: new Headers(), body: null, ended: false };\n\n const res = {\n get statusCode() { return state.statusCode; },\n set statusCode(code: number) { state.statusCode = code; },\n status(code: number) { state.statusCode = code; return res; },\n setHeader(name: string, value: string | number | readonly string[]) {\n state.headers.set(name, Array.isArray(value) ? value.join(', ') : String(value));\n return res;\n },\n json(payload: unknown) {\n if (!state.headers.has('content-type')) state.headers.set('content-type', 'application/json; charset=utf-8');\n state.body = JSON.stringify(payload);\n state.ended = true;\n },\n send(payload: unknown) {\n state.body = (payload ?? null) as BodyInit | null;\n state.ended = true;\n },\n end(payload?: unknown) {\n if (payload !== undefined) state.body = payload as BodyInit;\n state.ended = true;\n },\n };\n\n return { res: res as unknown as NextApiResponse, toResponse: () => new Response(state.ended ? state.body : null, { status: state.statusCode, headers: state.headers }) };\n};\n\n// ** Hono API Handler\n// ** Bridges a Hono `Context` into the core Node-style handler and returns a web `Response` - wire it\n// ** up as e.g. `app.all('/api/drive', (c) => driveAPIHandlerHono(c))`.\nexport const driveAPIHandlerHono = async (c: Context): Promise<Response> => {\n const req = buildNodeRequest(c);\n const { res, toResponse } = buildNodeResponse();\n await driveAPIHandler(req, res);\n return toResponse();\n};\n\n// ** Hono Configuration\n// ** Wraps the user's `information` callback so it receives the original Hono `Context` (matching\n// ** `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped request built above.\nexport const driveConfigurationHono = (config: TDriveConfigurationHono): Promise<TDriveConfigurationHono> => {\n const userInformation = config.information;\n\n const information = userInformation\n ? async (input: TDriveInformationInput): Promise<TDriveConfigInformation> => {\n if (input.method === 'KEY') return userInformation(input);\n const honoContext = (input.req as TNodeRequestWithContext)[HONO_CONTEXT] as Context;\n return userInformation({ method: 'REQUEST', req: honoContext });\n }\n : undefined;\n\n return driveConfiguration({ ...config, information } as unknown as Parameters<typeof driveConfiguration>[0]) as unknown as Promise<TDriveConfigurationHono>;\n};\n\n// ** Re-export utilities that work with any framework\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\nexport { getDriveConfig } from '@/server/config';\n\n// ** Re-export types\nexport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/server/hono.ts"],"names":["stream","Readable","driveAPIHandler","driveConfiguration"],"mappings":";;;;;;;AAgBA,IAAM,YAAA,0BAAsB,aAAa,CAAA;AAQzC,IAAM,gBAAA,GAAmB,CAAC,CAAA,KAAwC;AAC9D,EAAA,MAAM,GAAA,GAAM,EAAE,GAAA,CAAI,GAAA;AAClB,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,E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AA,CAAM,UAAA,EAAY,SAAS,KAAA,CAAM,OAAA,EAAS,CAAA,EAAE;AAC3K,CAAA;AAKO,IAAM,mBAAA,GAAsB,OAAO,CAAA,KAAkC;AACxE,EAAA,MAAM,GAAA,GAAM,iBAAiB,CAAC,CAAA;AAC9B,EAAA,MAAM,EAAE,GAAA,EAAK,UAAA,EAAW,GAAI,iBAAA,EAAkB;AAC9C,EAAA,MAAME,iCAAA,CAAgB,KAAK,GAAG,CAAA;AAC9B,EAAA,OAAO,UAAA,EAAW;AACtB;AAKO,IAAM,sBAAA,GAAyB,CAAC,MAAA,KAAsE;AACzG,EAAA,MAAM,kBAAkB,MAAA,CAAO,WAAA;AAE/B,EAAA,MAAM,WAAA,GAAc,eAAA,GACd,OAAO,KAAA,KAAoE;AACvE,IAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,EAAO,OAAO,gBAAgB,KAAK,CAAA;AACxD,IAAA,MAAM,WAAA,GAAe,KAAA,CAAM,GAAA,CAAgC,YAAY,CAAA;AACvE,IAAA,OAAO,gBAAgB,EAAE,MAAA,EAAQ,SAAA,EAAW,GAAA,EAAK,aAAa,CAAA;AAAA,EAClE,CAAA,GACA,MAAA;AAEN,EAAA,OAAOC,oCAAA,CAAmB,EAAE,GAAG,MAAA,EAAQ,aAAoE,CAAA;AAC/G","file":"hono.cjs","sourcesContent":["// ** Hono Adapter for next-drive\n// ** Hono's `Context` is fetch-based (web `Request`/`Response`), while the core handler is written\n// ** against the Node `(req, res)` style (`NextApiRequest`/`NextApiResponse`) shared with the Next.js\n// ** and Express adapters. This bridges the two: builds a Node-shaped request/response from the\n// ** `Context`, runs it through the core handler, and returns a web `Response` for Hono to send.\nimport { Readable } from 'stream';\nimport type { Context } from 'hono';\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nimport type { TDriveInformationInput } from '@/types/server/config';\n\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\n\n// ** Marker used to stash the original Hono `Context` on the synthetic Node-style request built below,\n// ** so `driveConfigurationHono`'s `information` callback can hand the user back a real `Context`\n// ** (matching `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped stand-in.\nconst HONO_CONTEXT = Symbol('honoContext');\ntype TNodeRequestWithContext = NextApiRequest & { [HONO_CONTEXT]?: Context };\n\n// ** Builds a Node-`NextApiRequest`-shaped object - a real `Readable` instance carrying `.method`,\n// ** `.url`, `.headers` and `.query` - from a Hono `Context`'s underlying web `Request`. Being a real\n// ** `Readable` (rather than a plain object) matters for `?action=upload`: `handleUpload`\n// ** (src/server/tus.ts) calls `Readable.toWeb(req)` on whatever is passed as `req`, which requires an\n// ** actual stream instance.\nconst buildNodeRequest = (c: Context): TNodeRequestWithContext => {\n const raw = c.req.raw;\n const url = new URL(raw.url);\n\n const query: Record<string, string | string[]> = {};\n for (const key of url.searchParams.keys()) {\n if (key in query) continue;\n const values = url.searchParams.getAll(key);\n query[key] = values.length > 1 ? values : values[0];\n }\n\n const headers: Record<string, string> = {};\n raw.headers.forEach((value, key) => { headers[key] = value; });\n\n const stream = raw.body\n ? (Readable.fromWeb(raw.body as unknown as import('stream/web').ReadableStream) as unknown as Readable)\n : new Readable({ read() { this.push(null); } });\n\n return Object.assign(stream, { method: raw.method, url: url.pathname + url.search, headers, query, [HONO_CONTEXT]: c }) as unknown as TNodeRequestWithContext;\n};\n\n// ** Minimal Node-`ServerResponse`-shaped object that buffers status/headers/body (everything the core\n// ** handler, `applyCorsHeaders` and `handleUpload` call: `.status().json()`, `.setHeader()`, `.send()`,\n// ** `.end()`, and direct `.statusCode =` assignment) so it can be translated into a web `Response`.\nconst buildNodeResponse = (): { res: NextApiResponse; toResponse: () => Response } => {\n const state: { statusCode: number; headers: Headers; body: BodyInit | null; ended: boolean } = { statusCode: 200, headers: new Headers(), body: null, ended: false };\n\n const res = {\n get statusCode() { return state.statusCode; },\n set statusCode(code: number) { state.statusCode = code; },\n status(code: number) { state.statusCode = code; return res; },\n setHeader(name: string, value: string | number | readonly string[]) {\n state.headers.set(name, Array.isArray(value) ? value.join(', ') : String(value));\n return res;\n },\n json(payload: unknown) {\n if (!state.headers.has('content-type')) state.headers.set('content-type', 'application/json; charset=utf-8');\n state.body = JSON.stringify(payload);\n state.ended = true;\n },\n send(payload: unknown) {\n state.body = (payload ?? null) as BodyInit | null;\n state.ended = true;\n },\n end(payload?: unknown) {\n if (payload !== undefined) state.body = payload as BodyInit;\n state.ended = true;\n },\n };\n\n return { res: res as unknown as NextApiResponse, toResponse: () => new Response(state.ended ? state.body : null, { status: state.statusCode, headers: state.headers }) };\n};\n\n// ** Hono API Handler\n// ** Bridges a Hono `Context` into the core Node-style handler and returns a web `Response` - wire it\n// ** up as e.g. `app.all('/api/drive', (c) => driveAPIHandlerHono(c))`.\nexport const driveAPIHandlerHono = async (c: Context): Promise<Response> => {\n const req = buildNodeRequest(c);\n const { res, toResponse } = buildNodeResponse();\n await driveAPIHandler(req, res);\n return toResponse();\n};\n\n// ** Hono Configuration\n// ** Wraps the user's `information` callback so it receives the original Hono `Context` (matching\n// ** `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped request built above.\nexport const driveConfigurationHono = (config: TDriveConfigurationHono): Promise<TDriveConfigurationHono> => {\n const userInformation = config.information;\n\n const information = userInformation\n ? async (input: TDriveInformationInput): Promise<TDriveConfigInformation> => {\n if (input.method === 'KEY') return userInformation(input);\n const honoContext = (input.req as TNodeRequestWithContext)[HONO_CONTEXT] as Context;\n return userInformation({ method: 'REQUEST', req: honoContext });\n }\n : undefined;\n\n return driveConfiguration({ ...config, information } as unknown as Parameters<typeof driveConfiguration>[0]) as unknown as Promise<TDriveConfigurationHono>;\n};\n\n// ** Re-export utilities that work with any framework\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\nexport type { TDriveTransferProgress } from '@/server/controllers/drive';\nexport { DriveError } from '@/server/errors';\nexport type { TDriveErrorCode } from '@/server/errors';\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\nexport { getDriveConfig } from '@/server/config';\n\n// ** Re-export types\nexport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\n"]}
|
package/dist/server/hono.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import type { TDriveConfigurationHono } from '../types/server/hono';
|
|
|
3
3
|
export declare const driveAPIHandlerHono: (c: Context) => Promise<Response>;
|
|
4
4
|
export declare const driveConfigurationHono: (config: TDriveConfigurationHono) => Promise<TDriveConfigurationHono>;
|
|
5
5
|
export { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '../server/controllers/drive';
|
|
6
|
+
export type { TDriveTransferProgress } from '../server/controllers/drive';
|
|
7
|
+
export { DriveError } from '../server/errors';
|
|
8
|
+
export type { TDriveErrorCode } from '../server/errors';
|
|
6
9
|
export { driveFileSchemaZod } from '../server/zod/schemas';
|
|
7
10
|
export { getDriveConfig } from '../server/config';
|
|
8
11
|
export type { TDriveConfigurationHono, TDriveConfigInformation } from '../types/server/hono';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../src/server/hono.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAA2B,MAAM,qBAAqB,CAAC;AAwE5F,eAAO,MAAM,mBAAmB,GAAU,GAAG,OAAO,KAAG,OAAO,CAAC,QAAQ,CAKtE,CAAC;AAKF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,uBAAuB,KAAG,OAAO,CAAC,uBAAuB,CAYvG,CAAC;AAGF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5H,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../src/server/hono.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAA2B,MAAM,qBAAqB,CAAC;AAwE5F,eAAO,MAAM,mBAAmB,GAAU,GAAG,OAAO,KAAG,OAAO,CAAC,QAAQ,CAKtE,CAAC;AAKF,eAAO,MAAM,sBAAsB,GAAI,QAAQ,uBAAuB,KAAG,OAAO,CAAC,uBAAuB,CAYvG,CAAC;AAGF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5H,YAAY,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,YAAY,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/server/hono.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { driveAPIHandler } from '../chunk-
|
|
2
|
-
export { driveFileSchemaZod } from '../chunk-
|
|
1
|
+
import { driveAPIHandler } from '../chunk-E72MTT6W.js';
|
|
2
|
+
export { driveFileSchemaZod } from '../chunk-E72MTT6W.js';
|
|
3
3
|
import '../chunk-OSYRIHH4.js';
|
|
4
|
-
import { driveConfiguration } from '../chunk-
|
|
5
|
-
export { driveDelete, driveFilePath, driveGetUrl, driveList, driveReadFile, driveUpload, getDriveConfig } from '../chunk-
|
|
4
|
+
import { driveConfiguration } from '../chunk-QMPV4YSZ.js';
|
|
5
|
+
export { DriveError, driveDelete, driveFilePath, driveGetUrl, driveList, driveReadFile, driveUpload, getDriveConfig } from '../chunk-QMPV4YSZ.js';
|
|
6
6
|
import { Readable } from 'stream';
|
|
7
7
|
|
|
8
8
|
var HONO_CONTEXT = /* @__PURE__ */ Symbol("honoContext");
|
package/dist/server/hono.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/hono.ts"],"names":[],"mappings":";;;;;;;AAgBA,IAAM,YAAA,0BAAsB,aAAa,CAAA;AAQzC,IAAM,gBAAA,GAAmB,CAAC,CAAA,KAAwC;AAC9D,EAAA,MAAM,GAAA,GAAM,EAAE,GAAA,CAAI,GAAA;AAClB,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,EAAA,MAAM,QAA2C,EAAC;AAClD,EAAA,KAAA,MAAW,GAAA,IAAO,GAAA,CAAI,YAAA,CAAa,IAAA,EAAK,EAAG;AACvC,IAAA,IAAI,OAAO,KAAA,EAAO;AAClB,IAAA,MAAM,MAAA,GAAS,GAAA,CAAI,YAAA,CAAa,MAAA,CAAO,GAAG,CAAA;AAC1C,IAAA,KAAA,CAAM,GAAG,CAAA,GAAI,MAAA,CAAO,SAAS,CAAA,GAAI,MAAA,GAAS,OAAO,CAAC,CAAA;AAAA,EACtD;AAEA,EAAA,MAAM,UAAkC,EAAC;AACzC,EAAA,GAAA,CAAI,OAAA,CAAQ,OAAA,CAAQ,CAAC,KAAA,EAAO,GAAA,KAAQ;A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c,eAAA,GACd,OAAO,KAAA,KAAoE;AACvE,IAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,EAAO,OAAO,gBAAgB,KAAK,CAAA;AACxD,IAAA,MAAM,WAAA,GAAe,KAAA,CAAM,GAAA,CAAgC,YAAY,CAAA;AACvE,IAAA,OAAO,gBAAgB,EAAE,MAAA,EAAQ,SAAA,EAAW,GAAA,EAAK,aAAa,CAAA;AAAA,EAClE,CAAA,GACA,MAAA;AAEN,EAAA,OAAO,kBAAA,CAAmB,EAAE,GAAG,MAAA,EAAQ,aAAoE,CAAA;AAC/G","file":"hono.js","sourcesContent":["// ** Hono Adapter for next-drive\n// ** Hono's `Context` is fetch-based (web `Request`/`Response`), while the core handler is written\n// ** against the Node `(req, res)` style (`NextApiRequest`/`NextApiResponse`) shared with the Next.js\n// ** and Express adapters. This bridges the two: builds a Node-shaped request/response from the\n// ** `Context`, runs it through the core handler, and returns a web `Response` for Hono to send.\nimport { Readable } from 'stream';\nimport type { Context } from 'hono';\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nimport type { TDriveInformationInput } from '@/types/server/config';\n\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\n\n// ** Marker used to stash the original Hono `Context` on the synthetic Node-style request built below,\n// ** so `driveConfigurationHono`'s `information` callback can hand the user back a real `Context`\n// ** (matching `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped stand-in.\nconst HONO_CONTEXT = Symbol('honoContext');\ntype TNodeRequestWithContext = NextApiRequest & { [HONO_CONTEXT]?: Context };\n\n// ** Builds a Node-`NextApiRequest`-shaped object - a real `Readable` instance carrying `.method`,\n// ** `.url`, `.headers` and `.query` - from a Hono `Context`'s underlying web `Request`. Being a real\n// ** `Readable` (rather than a plain object) matters for `?action=upload`: `handleUpload`\n// ** (src/server/tus.ts) calls `Readable.toWeb(req)` on whatever is passed as `req`, which requires an\n// ** actual stream instance.\nconst buildNodeRequest = (c: Context): TNodeRequestWithContext => {\n const raw = c.req.raw;\n const url = new URL(raw.url);\n\n const query: Record<string, string | string[]> = {};\n for (const key of url.searchParams.keys()) {\n if (key in query) continue;\n const values = url.searchParams.getAll(key);\n query[key] = values.length > 1 ? values : values[0];\n }\n\n const headers: Record<string, string> = {};\n raw.headers.forEach((value, key) => { headers[key] = value; });\n\n const stream = raw.body\n ? (Readable.fromWeb(raw.body as unknown as import('stream/web').ReadableStream) as unknown as Readable)\n : new Readable({ read() { this.push(null); } });\n\n return Object.assign(stream, { method: raw.method, url: url.pathname + url.search, headers, query, [HONO_CONTEXT]: c }) as unknown as TNodeRequestWithContext;\n};\n\n// ** Minimal Node-`ServerResponse`-shaped object that buffers status/headers/body (everything the core\n// ** handler, `applyCorsHeaders` and `handleUpload` call: `.status().json()`, `.setHeader()`, `.send()`,\n// ** `.end()`, and direct `.statusCode =` assignment) so it can be translated into a web `Response`.\nconst buildNodeResponse = (): { res: NextApiResponse; toResponse: () => Response } => {\n const state: { statusCode: number; headers: Headers; body: BodyInit | null; ended: boolean } = { statusCode: 200, headers: new Headers(), body: null, ended: false };\n\n const res = {\n get statusCode() { return state.statusCode; },\n set statusCode(code: number) { state.statusCode = code; },\n status(code: number) { state.statusCode = code; return res; },\n setHeader(name: string, value: string | number | readonly string[]) {\n state.headers.set(name, Array.isArray(value) ? value.join(', ') : String(value));\n return res;\n },\n json(payload: unknown) {\n if (!state.headers.has('content-type')) state.headers.set('content-type', 'application/json; charset=utf-8');\n state.body = JSON.stringify(payload);\n state.ended = true;\n },\n send(payload: unknown) {\n state.body = (payload ?? null) as BodyInit | null;\n state.ended = true;\n },\n end(payload?: unknown) {\n if (payload !== undefined) state.body = payload as BodyInit;\n state.ended = true;\n },\n };\n\n return { res: res as unknown as NextApiResponse, toResponse: () => new Response(state.ended ? state.body : null, { status: state.statusCode, headers: state.headers }) };\n};\n\n// ** Hono API Handler\n// ** Bridges a Hono `Context` into the core Node-style handler and returns a web `Response` - wire it\n// ** up as e.g. `app.all('/api/drive', (c) => driveAPIHandlerHono(c))`.\nexport const driveAPIHandlerHono = async (c: Context): Promise<Response> => {\n const req = buildNodeRequest(c);\n const { res, toResponse } = buildNodeResponse();\n await driveAPIHandler(req, res);\n return toResponse();\n};\n\n// ** Hono Configuration\n// ** Wraps the user's `information` callback so it receives the original Hono `Context` (matching\n// ** `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped request built above.\nexport const driveConfigurationHono = (config: TDriveConfigurationHono): Promise<TDriveConfigurationHono> => {\n const userInformation = config.information;\n\n const information = userInformation\n ? async (input: TDriveInformationInput): Promise<TDriveConfigInformation> => {\n if (input.method === 'KEY') return userInformation(input);\n const honoContext = (input.req as TNodeRequestWithContext)[HONO_CONTEXT] as Context;\n return userInformation({ method: 'REQUEST', req: honoContext });\n }\n : undefined;\n\n return driveConfiguration({ ...config, information } as unknown as Parameters<typeof driveConfiguration>[0]) as unknown as Promise<TDriveConfigurationHono>;\n};\n\n// ** Re-export utilities that work with any framework\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\nexport { getDriveConfig } from '@/server/config';\n\n// ** Re-export types\nexport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/server/hono.ts"],"names":[],"mappings":";;;;;;;AAgBA,IAAM,YAAA,0BAAsB,aAAa,CAAA;AAQzC,IAAM,gBAAA,GAAmB,CAAC,CAAA,KAAwC;AAC9D,EAAA,MAAM,GAAA,GAAM,EAAE,GAAA,CAAI,GAAA;AAClB,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,GAAA,CAAI,GAAG,CAAA;AAE3B,EAAA,MAAM,QAA2C,EAAC;AAClD,EAAA,KAAA,MAAW,GAAA,IAAO,GAAA,CAAI,YAAA,CAAa,IAAA,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A,GAAsB,OAAO,CAAA,KAAkC;AACxE,EAAA,MAAM,GAAA,GAAM,iBAAiB,CAAC,CAAA;AAC9B,EAAA,MAAM,EAAE,GAAA,EAAK,UAAA,EAAW,GAAI,iBAAA,EAAkB;AAC9C,EAAA,MAAM,eAAA,CAAgB,KAAK,GAAG,CAAA;AAC9B,EAAA,OAAO,UAAA,EAAW;AACtB;AAKO,IAAM,sBAAA,GAAyB,CAAC,MAAA,KAAsE;AACzG,EAAA,MAAM,kBAAkB,MAAA,CAAO,WAAA;AAE/B,EAAA,MAAM,WAAA,GAAc,eAAA,GACd,OAAO,KAAA,KAAoE;AACvE,IAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,EAAO,OAAO,gBAAgB,KAAK,CAAA;AACxD,IAAA,MAAM,WAAA,GAAe,KAAA,CAAM,GAAA,CAAgC,YAAY,CAAA;AACvE,IAAA,OAAO,gBAAgB,EAAE,MAAA,EAAQ,SAAA,EAAW,GAAA,EAAK,aAAa,CAAA;AAAA,EAClE,CAAA,GACA,MAAA;AAEN,EAAA,OAAO,kBAAA,CAAmB,EAAE,GAAG,MAAA,EAAQ,aAAoE,CAAA;AAC/G","file":"hono.js","sourcesContent":["// ** Hono Adapter for next-drive\n// ** Hono's `Context` is fetch-based (web `Request`/`Response`), while the core handler is written\n// ** against the Node `(req, res)` style (`NextApiRequest`/`NextApiResponse`) shared with the Next.js\n// ** and Express adapters. This bridges the two: builds a Node-shaped request/response from the\n// ** `Context`, runs it through the core handler, and returns a web `Response` for Hono to send.\nimport { Readable } from 'stream';\nimport type { Context } from 'hono';\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nimport type { TDriveInformationInput } from '@/types/server/config';\n\nimport { driveAPIHandler, driveConfiguration } from '@/server/index';\n\n// ** Marker used to stash the original Hono `Context` on the synthetic Node-style request built below,\n// ** so `driveConfigurationHono`'s `information` callback can hand the user back a real `Context`\n// ** (matching `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped stand-in.\nconst HONO_CONTEXT = Symbol('honoContext');\ntype TNodeRequestWithContext = NextApiRequest & { [HONO_CONTEXT]?: Context };\n\n// ** Builds a Node-`NextApiRequest`-shaped object - a real `Readable` instance carrying `.method`,\n// ** `.url`, `.headers` and `.query` - from a Hono `Context`'s underlying web `Request`. Being a real\n// ** `Readable` (rather than a plain object) matters for `?action=upload`: `handleUpload`\n// ** (src/server/tus.ts) calls `Readable.toWeb(req)` on whatever is passed as `req`, which requires an\n// ** actual stream instance.\nconst buildNodeRequest = (c: Context): TNodeRequestWithContext => {\n const raw = c.req.raw;\n const url = new URL(raw.url);\n\n const query: Record<string, string | string[]> = {};\n for (const key of url.searchParams.keys()) {\n if (key in query) continue;\n const values = url.searchParams.getAll(key);\n query[key] = values.length > 1 ? values : values[0];\n }\n\n const headers: Record<string, string> = {};\n raw.headers.forEach((value, key) => { headers[key] = value; });\n\n const stream = raw.body\n ? (Readable.fromWeb(raw.body as unknown as import('stream/web').ReadableStream) as unknown as Readable)\n : new Readable({ read() { this.push(null); } });\n\n return Object.assign(stream, { method: raw.method, url: url.pathname + url.search, headers, query, [HONO_CONTEXT]: c }) as unknown as TNodeRequestWithContext;\n};\n\n// ** Minimal Node-`ServerResponse`-shaped object that buffers status/headers/body (everything the core\n// ** handler, `applyCorsHeaders` and `handleUpload` call: `.status().json()`, `.setHeader()`, `.send()`,\n// ** `.end()`, and direct `.statusCode =` assignment) so it can be translated into a web `Response`.\nconst buildNodeResponse = (): { res: NextApiResponse; toResponse: () => Response } => {\n const state: { statusCode: number; headers: Headers; body: BodyInit | null; ended: boolean } = { statusCode: 200, headers: new Headers(), body: null, ended: false };\n\n const res = {\n get statusCode() { return state.statusCode; },\n set statusCode(code: number) { state.statusCode = code; },\n status(code: number) { state.statusCode = code; return res; },\n setHeader(name: string, value: string | number | readonly string[]) {\n state.headers.set(name, Array.isArray(value) ? value.join(', ') : String(value));\n return res;\n },\n json(payload: unknown) {\n if (!state.headers.has('content-type')) state.headers.set('content-type', 'application/json; charset=utf-8');\n state.body = JSON.stringify(payload);\n state.ended = true;\n },\n send(payload: unknown) {\n state.body = (payload ?? null) as BodyInit | null;\n state.ended = true;\n },\n end(payload?: unknown) {\n if (payload !== undefined) state.body = payload as BodyInit;\n state.ended = true;\n },\n };\n\n return { res: res as unknown as NextApiResponse, toResponse: () => new Response(state.ended ? state.body : null, { status: state.statusCode, headers: state.headers }) };\n};\n\n// ** Hono API Handler\n// ** Bridges a Hono `Context` into the core Node-style handler and returns a web `Response` - wire it\n// ** up as e.g. `app.all('/api/drive', (c) => driveAPIHandlerHono(c))`.\nexport const driveAPIHandlerHono = async (c: Context): Promise<Response> => {\n const req = buildNodeRequest(c);\n const { res, toResponse } = buildNodeResponse();\n await driveAPIHandler(req, res);\n return toResponse();\n};\n\n// ** Hono Configuration\n// ** Wraps the user's `information` callback so it receives the original Hono `Context` (matching\n// ** `TDriveConfigurationHono`'s declared type) instead of the internal Node-shaped request built above.\nexport const driveConfigurationHono = (config: TDriveConfigurationHono): Promise<TDriveConfigurationHono> => {\n const userInformation = config.information;\n\n const information = userInformation\n ? async (input: TDriveInformationInput): Promise<TDriveConfigInformation> => {\n if (input.method === 'KEY') return userInformation(input);\n const honoContext = (input.req as TNodeRequestWithContext)[HONO_CONTEXT] as Context;\n return userInformation({ method: 'REQUEST', req: honoContext });\n }\n : undefined;\n\n return driveConfiguration({ ...config, information } as unknown as Parameters<typeof driveConfiguration>[0]) as unknown as Promise<TDriveConfigurationHono>;\n};\n\n// ** Re-export utilities that work with any framework\nexport { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList } from '@/server/controllers/drive';\nexport type { TDriveTransferProgress } from '@/server/controllers/drive';\nexport { DriveError } from '@/server/errors';\nexport type { TDriveErrorCode } from '@/server/errors';\nexport { driveFileSchemaZod } from '@/server/zod/schemas';\nexport { getDriveConfig } from '@/server/config';\n\n// ** Re-export types\nexport type { TDriveConfigurationHono, TDriveConfigInformation } from '@/types/server/hono';\nexport type { TDriveFile, TDriveInformation } from '@/types/client';\n"]}
|
package/dist/server/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPKNXKHGS_cjs = require('../chunk-PKNXKHGS.cjs');
|
|
4
4
|
var chunkHQTC3554_cjs = require('../chunk-HQTC3554.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkDHIHCER6_cjs = require('../chunk-DHIHCER6.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "driveAPIHandler", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkPKNXKHGS_cjs.driveAPIHandler; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "driveFileSchemaZod", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkPKNXKHGS_cjs.driveFileSchemaZod; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "driveCreateUrl", {
|
|
18
18
|
enumerable: true,
|
|
@@ -20,63 +20,67 @@ Object.defineProperty(exports, "driveCreateUrl", {
|
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "DatabaseMongoDrive", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkDHIHCER6_cjs.drive_default; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "DriveError", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkDHIHCER6_cjs.DriveError; }
|
|
24
28
|
});
|
|
25
29
|
Object.defineProperty(exports, "driveCleanup", {
|
|
26
30
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkDHIHCER6_cjs.driveCleanup; }
|
|
28
32
|
});
|
|
29
33
|
Object.defineProperty(exports, "driveConfiguration", {
|
|
30
34
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkDHIHCER6_cjs.driveConfiguration; }
|
|
32
36
|
});
|
|
33
37
|
Object.defineProperty(exports, "driveConfirm", {
|
|
34
38
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkDHIHCER6_cjs.driveConfirm; }
|
|
36
40
|
});
|
|
37
41
|
Object.defineProperty(exports, "driveDelete", {
|
|
38
42
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunkDHIHCER6_cjs.driveDelete; }
|
|
40
44
|
});
|
|
41
45
|
Object.defineProperty(exports, "driveFilePath", {
|
|
42
46
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkDHIHCER6_cjs.driveFilePath; }
|
|
44
48
|
});
|
|
45
49
|
Object.defineProperty(exports, "driveGetUrl", {
|
|
46
50
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkDHIHCER6_cjs.driveGetUrl; }
|
|
48
52
|
});
|
|
49
53
|
Object.defineProperty(exports, "driveInfo", {
|
|
50
54
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkDHIHCER6_cjs.driveInfo; }
|
|
52
56
|
});
|
|
53
57
|
Object.defineProperty(exports, "driveList", {
|
|
54
58
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkDHIHCER6_cjs.driveList; }
|
|
56
60
|
});
|
|
57
61
|
Object.defineProperty(exports, "driveListFiles", {
|
|
58
62
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunkDHIHCER6_cjs.driveListFiles; }
|
|
60
64
|
});
|
|
61
65
|
Object.defineProperty(exports, "drivePurgeExpired", {
|
|
62
66
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
67
|
+
get: function () { return chunkDHIHCER6_cjs.drivePurgeExpired; }
|
|
64
68
|
});
|
|
65
69
|
Object.defineProperty(exports, "driveReadFile", {
|
|
66
70
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunkDHIHCER6_cjs.driveReadFile; }
|
|
68
72
|
});
|
|
69
73
|
Object.defineProperty(exports, "driveUpload", {
|
|
70
74
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunkDHIHCER6_cjs.driveUpload; }
|
|
72
76
|
});
|
|
73
77
|
Object.defineProperty(exports, "getDriveConfig", {
|
|
74
78
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
79
|
+
get: function () { return chunkDHIHCER6_cjs.getDriveConfig; }
|
|
76
80
|
});
|
|
77
81
|
Object.defineProperty(exports, "getDriveInformation", {
|
|
78
82
|
enumerable: true,
|
|
79
|
-
get: function () { return
|
|
83
|
+
get: function () { return chunkDHIHCER6_cjs.getDriveInformation; }
|
|
80
84
|
});
|
|
81
85
|
//# sourceMappingURL=index.cjs.map
|
|
82
86
|
//# sourceMappingURL=index.cjs.map
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { getDriveConfig, getDriveInformation, driveConfiguration } from '../serv
|
|
|
3
3
|
export declare const driveAPIHandler: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
4
4
|
export { driveConfiguration, getDriveConfig, getDriveInformation };
|
|
5
5
|
export { driveGetUrl, driveReadFile, driveFilePath, driveUpload, driveDelete, driveList, driveInfo, driveListFiles, driveCleanup, driveConfirm, drivePurgeExpired } from '../server/controllers/drive';
|
|
6
|
+
export type { TDriveTransferProgress } from '../server/controllers/drive';
|
|
7
|
+
export { DriveError } from '../server/errors';
|
|
8
|
+
export type { TDriveErrorCode } from '../server/errors';
|
|
6
9
|
export { default as DatabaseMongoDrive } from '../server/database/mongoose/schema/drive';
|
|
7
10
|
export type { IDatabaseDriveDocument } from '../server/database/mongoose/schema/drive';
|
|
8
11
|
export { driveFileSchemaZod } from '../server/zod/schemas';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA6C1F,eAAO,MAAM,eAAe,GAAU,KAAK,cAAc,EAAE,KAAK,eAAe,KAAG,OAAO,CAAC,IAAI,CAuG7F,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACtM,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AACxF,YAAY,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE,YAAY,EACR,cAAc,EACd,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,cAAc,GACjB,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sB,EACtB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,cAAc,GACjB,MAAM,gBAAgB,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { driveAPIHandler, driveFileSchemaZod } from '../chunk-
|
|
1
|
+
export { driveAPIHandler, driveFileSchemaZod } from '../chunk-E72MTT6W.js';
|
|
2
2
|
export { driveCreateUrl } from '../chunk-OSYRIHH4.js';
|
|
3
|
-
export { drive_default as DatabaseMongoDrive, driveCleanup, driveConfiguration, driveConfirm, driveDelete, driveFilePath, driveGetUrl, driveInfo, driveList, driveListFiles, drivePurgeExpired, driveReadFile, driveUpload, getDriveConfig, getDriveInformation } from '../chunk-
|
|
3
|
+
export { drive_default as DatabaseMongoDrive, DriveError, driveCleanup, driveConfiguration, driveConfirm, driveDelete, driveFilePath, driveGetUrl, driveInfo, driveList, driveListFiles, drivePurgeExpired, driveReadFile, driveUpload, getDriveConfig, getDriveInformation } from '../chunk-QMPV4YSZ.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/server/storage-adapters/google.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,wBAAwB,CAAC;AAuC5E,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/server/storage-adapters/google.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,wBAAwB,CAAC;AAuC5E,eAAO,MAAM,mBAAmB,EAAE,gBA2nBjC,CAAC"}
|
package/dist/server/tus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tus.d.ts","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IAC9B,MAAM,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,uBAAuB,CAAC;IACrC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA+BF,eAAO,MAAM,qBAAqB,GAAI,MAAM,mBAAmB,CAAC,MAAM,CAAC,KAAG;IAAE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,kBAAkB,EAAE,OAAO,CAAA;CAcjI,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,MAkN/B,CAAC;AAKF,eAAO,MAAM,YAAY,GAAU,KAAK,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC,cAAc,EAAE,KAAK,mBAAmB,KAAG,OAAO,CAAC,IAAI,CA0B9H,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDHIHCER6_cjs = require('./chunk-DHIHCER6.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "getTusServer", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkDHIHCER6_cjs.getTusServer; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "handleUpload", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkDHIHCER6_cjs.handleUpload; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "resolveTusCorsOptions", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkDHIHCER6_cjs.resolveTusCorsOptions; }
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=tus-EQ2IXSRE.cjs.map
|
|
20
|
+
//# sourceMappingURL=tus-EQ2IXSRE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"tus-EQ2IXSRE.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"tus-ODCMFEBZ.js"}
|