@od-oneapp/storage 2026.1.1301
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 +854 -0
- package/dist/client-next.d.mts +61 -0
- package/dist/client-next.d.mts.map +1 -0
- package/dist/client-next.mjs +111 -0
- package/dist/client-next.mjs.map +1 -0
- package/dist/client-utils-Dx6W25iz.d.mts +43 -0
- package/dist/client-utils-Dx6W25iz.d.mts.map +1 -0
- package/dist/client.d.mts +28 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +183 -0
- package/dist/client.mjs.map +1 -0
- package/dist/env-BVHLmQdh.mjs +128 -0
- package/dist/env-BVHLmQdh.mjs.map +1 -0
- package/dist/env.mjs +3 -0
- package/dist/health-check-D7LnnDec.mjs +746 -0
- package/dist/health-check-D7LnnDec.mjs.map +1 -0
- package/dist/health-check-im_huJ59.d.mts +116 -0
- package/dist/health-check-im_huJ59.d.mts.map +1 -0
- package/dist/index.d.mts +60 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/keys.d.mts +37 -0
- package/dist/keys.d.mts.map +1 -0
- package/dist/keys.mjs +253 -0
- package/dist/keys.mjs.map +1 -0
- package/dist/server-edge.d.mts +28 -0
- package/dist/server-edge.d.mts.map +1 -0
- package/dist/server-edge.mjs +88 -0
- package/dist/server-edge.mjs.map +1 -0
- package/dist/server-next.d.mts +183 -0
- package/dist/server-next.d.mts.map +1 -0
- package/dist/server-next.mjs +1353 -0
- package/dist/server-next.mjs.map +1 -0
- package/dist/server.d.mts +70 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +384 -0
- package/dist/server.mjs.map +1 -0
- package/dist/types.d.mts +321 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +3 -0
- package/dist/validation.d.mts +101 -0
- package/dist/validation.d.mts.map +1 -0
- package/dist/validation.mjs +590 -0
- package/dist/validation.mjs.map +1 -0
- package/dist/vercel-blob-07Sx0Akn.d.mts +31 -0
- package/dist/vercel-blob-07Sx0Akn.d.mts.map +1 -0
- package/dist/vercel-blob-DA8HaYuw.mjs +158 -0
- package/dist/vercel-blob-DA8HaYuw.mjs.map +1 -0
- package/package.json +111 -0
- package/src/actions/blob-upload.ts +171 -0
- package/src/actions/index.ts +23 -0
- package/src/actions/mediaActions.ts +1071 -0
- package/src/actions/productMediaActions.ts +538 -0
- package/src/auth-helpers.ts +386 -0
- package/src/capabilities.ts +225 -0
- package/src/client-next.ts +184 -0
- package/src/client-utils.ts +292 -0
- package/src/client.ts +102 -0
- package/src/constants.ts +88 -0
- package/src/health-check.ts +81 -0
- package/src/multi-storage.ts +230 -0
- package/src/multipart.ts +497 -0
- package/src/retry-utils.test.ts +118 -0
- package/src/retry-utils.ts +59 -0
- package/src/server-edge.ts +129 -0
- package/src/server-next.ts +14 -0
- package/src/server.ts +666 -0
- package/src/validation.test.ts +312 -0
- package/src/validation.ts +827 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-side storage exports for Edge Runtime
|
|
3
|
+
*
|
|
4
|
+
* This file provides server-side storage functionality specifically for Edge Runtime environments.
|
|
5
|
+
* Uses Web APIs only - no Node.js APIs allowed.
|
|
6
|
+
*
|
|
7
|
+
* Only Vercel Blob provider is supported in edge runtime.
|
|
8
|
+
*
|
|
9
|
+
* @module @repo/storage/server/edge
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { safeEnv } from '../env';
|
|
13
|
+
import { VercelBlobProvider } from '../providers/vercel-blob';
|
|
14
|
+
|
|
15
|
+
// Re-export edge-compatible types
|
|
16
|
+
export type {
|
|
17
|
+
ListOptions,
|
|
18
|
+
StorageObject,
|
|
19
|
+
StorageProvider,
|
|
20
|
+
StorageProviderType,
|
|
21
|
+
UploadOptions,
|
|
22
|
+
} from '../types';
|
|
23
|
+
|
|
24
|
+
// Re-export environment utilities (edge-safe)
|
|
25
|
+
export { safeEnv } from '../env';
|
|
26
|
+
export { VercelBlobProvider };
|
|
27
|
+
|
|
28
|
+
// Re-export key utilities
|
|
29
|
+
export {
|
|
30
|
+
generateMultipleKeys,
|
|
31
|
+
generateStorageKey,
|
|
32
|
+
isKeyPattern,
|
|
33
|
+
normalizeStorageKey,
|
|
34
|
+
parseStorageKey,
|
|
35
|
+
sanitizeStorageKey,
|
|
36
|
+
validateStorageKey,
|
|
37
|
+
type KeyGenerationOptions,
|
|
38
|
+
type KeyPattern,
|
|
39
|
+
} from '../keys';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Edge-compatible storage factory
|
|
43
|
+
* Only supports Vercel Blob in edge runtime
|
|
44
|
+
*
|
|
45
|
+
* @param token - Vercel Blob token
|
|
46
|
+
* @returns Vercel Blob provider instance
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { createEdgeStorageProvider } from '@repo/storage/server/edge';
|
|
51
|
+
*
|
|
52
|
+
* const storage = createEdgeStorageProvider(process.env.VERCEL_BLOB_READ_WRITE_TOKEN!);
|
|
53
|
+
* await storage.upload('file.jpg', fileData);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function createEdgeStorageProvider(token: string): VercelBlobProvider {
|
|
57
|
+
if (!token) {
|
|
58
|
+
throw new Error('VERCEL_BLOB_READ_WRITE_TOKEN is required for edge storage');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return new VercelBlobProvider(token);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get edge storage provider from environment
|
|
66
|
+
*
|
|
67
|
+
* @returns Vercel Blob provider instance
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* import { getEdgeStorage } from '@repo/storage/server/edge';
|
|
72
|
+
*
|
|
73
|
+
* const storage = getEdgeStorage();
|
|
74
|
+
* await storage.upload('file.jpg', fileData);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export function getEdgeStorage(): VercelBlobProvider {
|
|
78
|
+
const env = safeEnv();
|
|
79
|
+
|
|
80
|
+
if (!env.VERCEL_BLOB_READ_WRITE_TOKEN) {
|
|
81
|
+
throw new Error('VERCEL_BLOB_READ_WRITE_TOKEN is required for edge storage');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return new VercelBlobProvider(env.VERCEL_BLOB_READ_WRITE_TOKEN);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Edge storage helper functions
|
|
89
|
+
* Direct access to Vercel Blob methods
|
|
90
|
+
*/
|
|
91
|
+
import type { ListOptions, UploadOptions } from '../types';
|
|
92
|
+
|
|
93
|
+
export const edgeStorage = {
|
|
94
|
+
delete: (key: string) => getEdgeStorage().delete(key),
|
|
95
|
+
download: (key: string) => getEdgeStorage().download(key),
|
|
96
|
+
exists: (key: string) => getEdgeStorage().exists(key),
|
|
97
|
+
getMetadata: (key: string) => getEdgeStorage().getMetadata(key),
|
|
98
|
+
getUrl: (key: string, options?: { expiresIn?: number }) => getEdgeStorage().getUrl(key, options),
|
|
99
|
+
list: (options?: ListOptions) => getEdgeStorage().list(options),
|
|
100
|
+
upload: (
|
|
101
|
+
key: string,
|
|
102
|
+
data: ArrayBuffer | Blob | Buffer | File | ReadableStream,
|
|
103
|
+
options?: UploadOptions,
|
|
104
|
+
) => getEdgeStorage().upload(key, data, options),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Edge runtime limitations notice
|
|
109
|
+
*
|
|
110
|
+
* Edge Runtime has the following limitations:
|
|
111
|
+
* - Only Vercel Blob is supported (R2 requires Node.js APIs)
|
|
112
|
+
* - No file system access
|
|
113
|
+
* - Limited to Web APIs only
|
|
114
|
+
* - No multipart uploads (use Vercel Blob's built-in multipart)
|
|
115
|
+
* - No presigned URLs (use Vercel Blob's direct upload)
|
|
116
|
+
*
|
|
117
|
+
* For full functionality, use @repo/storage/server/next instead.
|
|
118
|
+
*/
|
|
119
|
+
export const EDGE_LIMITATIONS = {
|
|
120
|
+
supportedProviders: ['vercel-blob'] as const,
|
|
121
|
+
unsupportedFeatures: [
|
|
122
|
+
'Cloudflare R2 (requires Node.js APIs)',
|
|
123
|
+
'Cloudflare Images (requires Node.js APIs)',
|
|
124
|
+
'Custom multipart uploads (use Vercel Blob built-in)',
|
|
125
|
+
'Presigned URL generation (use Vercel Blob direct upload)',
|
|
126
|
+
'File system operations',
|
|
127
|
+
],
|
|
128
|
+
recommendedAlternative: '@repo/storage/server/next',
|
|
129
|
+
} as const;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Server-side storage exports for Next.js
|
|
3
|
+
*
|
|
4
|
+
* This file provides server-side storage functionality specifically for Next.js applications.
|
|
5
|
+
* Includes server actions for file uploads and storage operations.
|
|
6
|
+
*
|
|
7
|
+
* @module @repo/storage/server/next
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Re-export all server functionality
|
|
11
|
+
export * from './server';
|
|
12
|
+
|
|
13
|
+
// Export server actions
|
|
14
|
+
export * from './actions';
|