@muhgholy/next-drive 3.5.0 → 3.7.0

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.
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var chunkA65ZAA2Z_cjs = require('./chunk-A65ZAA2Z.cjs');
4
+ require('./chunk-JEQ2X3Z6.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "driveFileSchemaZod", {
9
+ enumerable: true,
10
+ get: function () { return chunkA65ZAA2Z_cjs.driveFileSchemaZod; }
11
+ });
12
+ //# sourceMappingURL=schemas.cjs.map
13
+ //# sourceMappingURL=schemas.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"schemas.cjs"}
@@ -129,7 +129,7 @@ export declare const driveDelete: (source: string | IDatabaseDriveDocument | TDa
129
129
  * Upload a file to the drive system from a file path or readable stream.
130
130
  * @param source - File path (string) or Readable stream
131
131
  * @param key - Owner key (must match the authenticated user's key)
132
- * @param options - Upload options including name, parentId, accountId, and enforce flag
132
+ * @param options - Upload options including name, parentId, accountId, mime, and enforce flag
133
133
  * @returns Promise with the created drive file object
134
134
  * @example
135
135
  * ```typescript
@@ -140,18 +140,27 @@ export declare const driveDelete: (source: string | IDatabaseDriveDocument | TDa
140
140
  * enforce: false
141
141
  * });
142
142
  *
143
- * // Upload from stream
143
+ * // Upload from stream with custom MIME type
144
144
  * const stream = fs.createReadStream('/tmp/video.mp4');
145
145
  * const file = await driveUpload(stream, { userId: '123' }, {
146
146
  * name: 'video.mp4',
147
+ * mime: 'video/mp4',
147
148
  * enforce: true // Skip quota check
148
149
  * });
150
+ *
151
+ * // Upload from Buffer with MIME type
152
+ * const buffer = Buffer.from('data');
153
+ * const file = await driveUpload(buffer, { userId: '123' }, {
154
+ * name: 'data.bin',
155
+ * mime: 'application/octet-stream'
156
+ * });
149
157
  * ```
150
158
  */
151
159
  export declare const driveUpload: (source: string | Readable | Buffer, key: Record<string, unknown> | null, options: {
152
160
  name: string;
153
161
  parentId?: string | null;
154
162
  accountId?: string;
163
+ mime?: string;
155
164
  enforce?: boolean;
156
165
  }) => Promise<TDriveFile>;
157
166
  //# sourceMappingURL=drive.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"drive.d.ts","sourceRoot":"","sources":["../../../src/server/controllers/drive.ts"],"names":[],"mappings":"AAIA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIvC,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,KAAG,MAoBlF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GACtB,MAAM,MAAM,GAAG,sBAAsB,GAAG,cAAc,KACvD,OAAO,CAAC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,C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Ac,EAAE,CA8B1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,GACpB,QAAQ,MAAM,GAAG,sBAAsB,GAAG,cAAc,EACxD,UAAU;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,KAChC,OAAO,CAAC,IAAI,CA8Cd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,WAAW,GACpB,QAAQ,MAAM,GAAG,QAAQ,GAAG,MAAM,EAClC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACnC,SAAS;IACL,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,KACF,OAAO,CAAC,UAAU,CAgKpB,CAAC"}
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var chunk7PTOIRBL_cjs = require('../chunk-7PTOIRBL.cjs');
4
+ require('../chunk-XDAVDVO6.cjs');
5
+ require('../chunk-JEQ2X3Z6.cjs');
6
+
7
+ // src/server/express.ts
8
+ var driveAPIHandlerExpress = chunk7PTOIRBL_cjs.driveAPIHandler;
9
+ var driveConfigurationExpress = chunk7PTOIRBL_cjs.driveConfiguration;
10
+
11
+ Object.defineProperty(exports, "driveDelete", {
12
+ enumerable: true,
13
+ get: function () { return chunk7PTOIRBL_cjs.driveDelete; }
14
+ });
15
+ Object.defineProperty(exports, "driveFilePath", {
16
+ enumerable: true,
17
+ get: function () { return chunk7PTOIRBL_cjs.driveFilePath; }
18
+ });
19
+ Object.defineProperty(exports, "driveFileSchemaZod", {
20
+ enumerable: true,
21
+ get: function () { return chunk7PTOIRBL_cjs.driveFileSchemaZod; }
22
+ });
23
+ Object.defineProperty(exports, "driveGetUrl", {
24
+ enumerable: true,
25
+ get: function () { return chunk7PTOIRBL_cjs.driveGetUrl; }
26
+ });
27
+ Object.defineProperty(exports, "driveList", {
28
+ enumerable: true,
29
+ get: function () { return chunk7PTOIRBL_cjs.driveList; }
30
+ });
31
+ Object.defineProperty(exports, "driveReadFile", {
32
+ enumerable: true,
33
+ get: function () { return chunk7PTOIRBL_cjs.driveReadFile; }
34
+ });
35
+ Object.defineProperty(exports, "driveUpload", {
36
+ enumerable: true,
37
+ get: function () { return chunk7PTOIRBL_cjs.driveUpload; }
38
+ });
39
+ Object.defineProperty(exports, "getDriveConfig", {
40
+ enumerable: true,
41
+ get: function () { return chunk7PTOIRBL_cjs.getDriveConfig; }
42
+ });
43
+ exports.driveAPIHandlerExpress = driveAPIHandlerExpress;
44
+ exports.driveConfigurationExpress = driveConfigurationExpress;
45
+ //# sourceMappingURL=express.cjs.map
46
+ //# sourceMappingURL=express.cjs.map
@@ -0,0 +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) => 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, TImageQuality, TImageFormat } from '@/types/client';\r\n"]}
@@ -1,5 +1,5 @@
1
- import { driveAPIHandler, driveConfiguration } from '../chunk-YYSAE5S2.js';
2
- export { driveDelete, driveFilePath, driveFileSchemaZod, driveGetUrl, driveList, driveReadFile, driveUpload, getDriveConfig } from '../chunk-YYSAE5S2.js';
1
+ import { driveAPIHandler, driveConfiguration } from '../chunk-NKP44P4G.js';
2
+ export { driveDelete, driveFilePath, driveFileSchemaZod, driveGetUrl, driveList, driveReadFile, driveUpload, getDriveConfig } from '../chunk-NKP44P4G.js';
3
3
  import '../chunk-CN3AV3AN.js';
4
4
  import '../chunk-DGUM43GV.js';
5
5
 
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var chunk7PTOIRBL_cjs = require('../chunk-7PTOIRBL.cjs');
4
+ var chunkXDAVDVO6_cjs = require('../chunk-XDAVDVO6.cjs');
5
+ require('../chunk-JEQ2X3Z6.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "driveAPIHandler", {
10
+ enumerable: true,
11
+ get: function () { return chunk7PTOIRBL_cjs.driveAPIHandler; }
12
+ });
13
+ Object.defineProperty(exports, "driveConfiguration", {
14
+ enumerable: true,
15
+ get: function () { return chunk7PTOIRBL_cjs.driveConfiguration; }
16
+ });
17
+ Object.defineProperty(exports, "driveDelete", {
18
+ enumerable: true,
19
+ get: function () { return chunk7PTOIRBL_cjs.driveDelete; }
20
+ });
21
+ Object.defineProperty(exports, "driveFilePath", {
22
+ enumerable: true,
23
+ get: function () { return chunk7PTOIRBL_cjs.driveFilePath; }
24
+ });
25
+ Object.defineProperty(exports, "driveFileSchemaZod", {
26
+ enumerable: true,
27
+ get: function () { return chunk7PTOIRBL_cjs.driveFileSchemaZod; }
28
+ });
29
+ Object.defineProperty(exports, "driveGetUrl", {
30
+ enumerable: true,
31
+ get: function () { return chunk7PTOIRBL_cjs.driveGetUrl; }
32
+ });
33
+ Object.defineProperty(exports, "driveInfo", {
34
+ enumerable: true,
35
+ get: function () { return chunk7PTOIRBL_cjs.driveInfo; }
36
+ });
37
+ Object.defineProperty(exports, "driveList", {
38
+ enumerable: true,
39
+ get: function () { return chunk7PTOIRBL_cjs.driveList; }
40
+ });
41
+ Object.defineProperty(exports, "driveReadFile", {
42
+ enumerable: true,
43
+ get: function () { return chunk7PTOIRBL_cjs.driveReadFile; }
44
+ });
45
+ Object.defineProperty(exports, "driveUpload", {
46
+ enumerable: true,
47
+ get: function () { return chunk7PTOIRBL_cjs.driveUpload; }
48
+ });
49
+ Object.defineProperty(exports, "getDriveConfig", {
50
+ enumerable: true,
51
+ get: function () { return chunk7PTOIRBL_cjs.getDriveConfig; }
52
+ });
53
+ Object.defineProperty(exports, "getDriveInformation", {
54
+ enumerable: true,
55
+ get: function () { return chunk7PTOIRBL_cjs.getDriveInformation; }
56
+ });
57
+ Object.defineProperty(exports, "driveCreateSrcSet", {
58
+ enumerable: true,
59
+ get: function () { return chunkXDAVDVO6_cjs.driveCreateSrcSet; }
60
+ });
61
+ Object.defineProperty(exports, "driveCreateUrl", {
62
+ enumerable: true,
63
+ get: function () { return chunkXDAVDVO6_cjs.driveCreateUrl; }
64
+ });
65
+ //# sourceMappingURL=index.cjs.map
66
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -1,4 +1,4 @@
1
- export { driveAPIHandler, driveConfiguration, driveDelete, driveFilePath, driveFileSchemaZod, driveGetUrl, driveInfo, driveList, driveReadFile, driveUpload, getDriveConfig, getDriveInformation } from '../chunk-YYSAE5S2.js';
1
+ export { driveAPIHandler, driveConfiguration, driveDelete, driveFilePath, driveFileSchemaZod, driveGetUrl, driveInfo, driveList, driveReadFile, driveUpload, getDriveConfig, getDriveInformation } from '../chunk-NKP44P4G.js';
2
2
  export { driveCreateSrcSet, driveCreateUrl } from '../chunk-CN3AV3AN.js';
3
3
  import '../chunk-DGUM43GV.js';
4
4
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,24 +1,28 @@
1
1
  {
2
2
  "name": "@muhgholy/next-drive",
3
- "version": "3.5.0",
3
+ "version": "3.7.0",
4
4
  "description": "File storage and management for Next.js applications",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./server": {
8
8
  "types": "./dist/server/index.d.ts",
9
- "import": "./dist/server/index.js"
9
+ "import": "./dist/server/index.js",
10
+ "require": "./dist/server/index.cjs"
10
11
  },
11
12
  "./server/express": {
12
13
  "types": "./dist/server/express.d.ts",
13
- "import": "./dist/server/express.js"
14
+ "import": "./dist/server/express.js",
15
+ "require": "./dist/server/express.cjs"
14
16
  },
15
17
  "./client": {
16
18
  "types": "./dist/client/index.d.ts",
17
- "import": "./dist/client/index.js"
19
+ "import": "./dist/client/index.js",
20
+ "require": "./dist/client/index.cjs"
18
21
  },
19
22
  "./schemas": {
20
23
  "types": "./dist/schemas.d.ts",
21
- "import": "./dist/schemas.js"
24
+ "import": "./dist/schemas.js",
25
+ "require": "./dist/schemas.cjs"
22
26
  },
23
27
  "./client/styles.css": "./dist/client/styles.css"
24
28
  },