@breadstone-infrastructure/prisma-seeds 0.0.231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +284 -0
  4. package/ai/AISeedGenerator.d.ts +127 -0
  5. package/ai/AISeedGenerator.d.ts.map +1 -0
  6. package/ai/AISeedGenerator.js +438 -0
  7. package/ai/AISeedGenerator.js.map +1 -0
  8. package/ai/AISeedTypes.d.ts +138 -0
  9. package/ai/AISeedTypes.d.ts.map +1 -0
  10. package/ai/AISeedTypes.js +3 -0
  11. package/ai/AISeedTypes.js.map +1 -0
  12. package/ai/PrismaModelAnalyzer.d.ts +36 -0
  13. package/ai/PrismaModelAnalyzer.d.ts.map +1 -0
  14. package/ai/PrismaModelAnalyzer.js +110 -0
  15. package/ai/PrismaModelAnalyzer.js.map +1 -0
  16. package/ai/PrismaTypeSchemaGenerator.d.ts +38 -0
  17. package/ai/PrismaTypeSchemaGenerator.d.ts.map +1 -0
  18. package/ai/PrismaTypeSchemaGenerator.js +71 -0
  19. package/ai/PrismaTypeSchemaGenerator.js.map +1 -0
  20. package/ai/createAISeeder.d.ts +11 -0
  21. package/ai/createAISeeder.d.ts.map +1 -0
  22. package/ai/createAISeeder.js +72 -0
  23. package/ai/createAISeeder.js.map +1 -0
  24. package/ai/index.d.ts +6 -0
  25. package/ai/index.d.ts.map +1 -0
  26. package/ai/index.js +5 -0
  27. package/ai/index.js.map +1 -0
  28. package/assets/AssetManager.d.ts +213 -0
  29. package/assets/AssetManager.d.ts.map +1 -0
  30. package/assets/AssetManager.js +460 -0
  31. package/assets/AssetManager.js.map +1 -0
  32. package/assets/IImageTransformOptions.d.ts +42 -0
  33. package/assets/IImageTransformOptions.d.ts.map +1 -0
  34. package/assets/IImageTransformOptions.js +22 -0
  35. package/assets/IImageTransformOptions.js.map +1 -0
  36. package/assets/adapters/BlobAdapterFactory.d.ts +21 -0
  37. package/assets/adapters/BlobAdapterFactory.d.ts.map +1 -0
  38. package/assets/adapters/BlobAdapterFactory.js +3 -0
  39. package/assets/adapters/BlobAdapterFactory.js.map +1 -0
  40. package/assets/adapters/CloudflareR2BlobAdapter.d.ts +97 -0
  41. package/assets/adapters/CloudflareR2BlobAdapter.d.ts.map +1 -0
  42. package/assets/adapters/CloudflareR2BlobAdapter.js +265 -0
  43. package/assets/adapters/CloudflareR2BlobAdapter.js.map +1 -0
  44. package/assets/adapters/EmptyBlobAdapter.d.ts +42 -0
  45. package/assets/adapters/EmptyBlobAdapter.d.ts.map +1 -0
  46. package/assets/adapters/EmptyBlobAdapter.js +65 -0
  47. package/assets/adapters/EmptyBlobAdapter.js.map +1 -0
  48. package/assets/adapters/LocalFileAdapter.d.ts +34 -0
  49. package/assets/adapters/LocalFileAdapter.d.ts.map +1 -0
  50. package/assets/adapters/LocalFileAdapter.js +74 -0
  51. package/assets/adapters/LocalFileAdapter.js.map +1 -0
  52. package/assets/adapters/VercelBlobAdapter.d.ts +73 -0
  53. package/assets/adapters/VercelBlobAdapter.d.ts.map +1 -0
  54. package/assets/adapters/VercelBlobAdapter.js +168 -0
  55. package/assets/adapters/VercelBlobAdapter.js.map +1 -0
  56. package/assets/adapters/abstracts/BlobAdapterBase.d.ts +62 -0
  57. package/assets/adapters/abstracts/BlobAdapterBase.d.ts.map +1 -0
  58. package/assets/adapters/abstracts/BlobAdapterBase.js +58 -0
  59. package/assets/adapters/abstracts/BlobAdapterBase.js.map +1 -0
  60. package/assets/adapters/abstracts/HttpBlobAdapterBase.d.ts +43 -0
  61. package/assets/adapters/abstracts/HttpBlobAdapterBase.d.ts.map +1 -0
  62. package/assets/adapters/abstracts/HttpBlobAdapterBase.js +88 -0
  63. package/assets/adapters/abstracts/HttpBlobAdapterBase.js.map +1 -0
  64. package/assets/adapters/createBlobAdapter.d.ts +47 -0
  65. package/assets/adapters/createBlobAdapter.d.ts.map +1 -0
  66. package/assets/adapters/createBlobAdapter.js +63 -0
  67. package/assets/adapters/createBlobAdapter.js.map +1 -0
  68. package/assets/adapters/index.d.ts +11 -0
  69. package/assets/adapters/index.d.ts.map +1 -0
  70. package/assets/adapters/index.js +7 -0
  71. package/assets/adapters/index.js.map +1 -0
  72. package/assets/adapters/interfaces/IBlobAdapter.d.ts +41 -0
  73. package/assets/adapters/interfaces/IBlobAdapter.d.ts.map +1 -0
  74. package/assets/adapters/interfaces/IBlobAdapter.js +3 -0
  75. package/assets/adapters/interfaces/IBlobAdapter.js.map +1 -0
  76. package/assets/adapters/interfaces/IBlobAdapterConfig.d.ts +16 -0
  77. package/assets/adapters/interfaces/IBlobAdapterConfig.d.ts.map +1 -0
  78. package/assets/adapters/interfaces/IBlobAdapterConfig.js +2 -0
  79. package/assets/adapters/interfaces/IBlobAdapterConfig.js.map +1 -0
  80. package/assets/adapters/interfaces/IBlobUploadResult.d.ts +24 -0
  81. package/assets/adapters/interfaces/IBlobUploadResult.d.ts.map +1 -0
  82. package/assets/adapters/interfaces/IBlobUploadResult.js +2 -0
  83. package/assets/adapters/interfaces/IBlobUploadResult.js.map +1 -0
  84. package/base/BaseSeeder.d.ts +21 -0
  85. package/base/BaseSeeder.d.ts.map +1 -0
  86. package/base/BaseSeeder.js +45 -0
  87. package/base/BaseSeeder.js.map +1 -0
  88. package/base/functionalSeeder.d.ts +31 -0
  89. package/base/functionalSeeder.d.ts.map +1 -0
  90. package/base/functionalSeeder.js +33 -0
  91. package/base/functionalSeeder.js.map +1 -0
  92. package/cli/Cli.d.ts +2 -0
  93. package/cli/Cli.d.ts.map +1 -0
  94. package/cli/Cli.js +32 -0
  95. package/cli/Cli.js.map +1 -0
  96. package/cli/CliArgs.d.ts +2 -0
  97. package/cli/CliArgs.d.ts.map +1 -0
  98. package/cli/CliArgs.js +133 -0
  99. package/cli/CliArgs.js.map +1 -0
  100. package/cli/CliArgsConfig.d.ts +2 -0
  101. package/cli/CliArgsConfig.d.ts.map +1 -0
  102. package/cli/CliArgsConfig.js +15 -0
  103. package/cli/CliArgsConfig.js.map +1 -0
  104. package/cli/CliRun.d.ts +2 -0
  105. package/cli/CliRun.d.ts.map +1 -0
  106. package/cli/CliRun.js +34 -0
  107. package/cli/CliRun.js.map +1 -0
  108. package/cli/commands/SeedCommand.d.ts +2 -0
  109. package/cli/commands/SeedCommand.d.ts.map +1 -0
  110. package/cli/commands/SeedCommand.js +73 -0
  111. package/cli/commands/SeedCommand.js.map +1 -0
  112. package/cli/commands/SeedCommandArgsConfig.d.ts +2 -0
  113. package/cli/commands/SeedCommandArgsConfig.d.ts.map +1 -0
  114. package/cli/commands/SeedCommandArgsConfig.js +31 -0
  115. package/cli/commands/SeedCommandArgsConfig.js.map +1 -0
  116. package/cli/seed.d.ts +2 -0
  117. package/cli/seed.d.ts.map +1 -0
  118. package/cli/seed.js +42 -0
  119. package/cli/seed.js.map +1 -0
  120. package/config/IAssetConfig.d.ts +36 -0
  121. package/config/IAssetConfig.d.ts.map +1 -0
  122. package/config/IAssetConfig.js +3 -0
  123. package/config/IAssetConfig.js.map +1 -0
  124. package/config/IComposedSeedConfig.d.ts +32 -0
  125. package/config/IComposedSeedConfig.d.ts.map +1 -0
  126. package/config/IComposedSeedConfig.js +3 -0
  127. package/config/IComposedSeedConfig.js.map +1 -0
  128. package/config/ISeedConfig.d.ts +75 -0
  129. package/config/ISeedConfig.d.ts.map +1 -0
  130. package/config/ISeedConfig.js +3 -0
  131. package/config/ISeedConfig.js.map +1 -0
  132. package/config/ISeedContext.d.ts +92 -0
  133. package/config/ISeedContext.d.ts.map +1 -0
  134. package/config/ISeedContext.js +3 -0
  135. package/config/ISeedContext.js.map +1 -0
  136. package/config/ISeedDefinition.d.ts +38 -0
  137. package/config/ISeedDefinition.d.ts.map +1 -0
  138. package/config/ISeedDefinition.js +3 -0
  139. package/config/ISeedDefinition.js.map +1 -0
  140. package/config/ISeedFactory.d.ts +15 -0
  141. package/config/ISeedFactory.d.ts.map +1 -0
  142. package/config/ISeedFactory.js +3 -0
  143. package/config/ISeedFactory.js.map +1 -0
  144. package/config/ISeedOptions.d.ts +44 -0
  145. package/config/ISeedOptions.d.ts.map +1 -0
  146. package/config/ISeedOptions.js +2 -0
  147. package/config/ISeedOptions.js.map +1 -0
  148. package/config/ISeedResult.d.ts +44 -0
  149. package/config/ISeedResult.d.ts.map +1 -0
  150. package/config/ISeedResult.js +2 -0
  151. package/config/ISeedResult.js.map +1 -0
  152. package/config/ISeeder.d.ts +37 -0
  153. package/config/ISeeder.d.ts.map +1 -0
  154. package/config/ISeeder.js +3 -0
  155. package/config/ISeeder.js.map +1 -0
  156. package/config/createAdapter.d.ts +13 -0
  157. package/config/createAdapter.d.ts.map +1 -0
  158. package/config/createAdapter.js +16 -0
  159. package/config/createAdapter.js.map +1 -0
  160. package/config/createSeed.d.ts +6 -0
  161. package/config/createSeed.d.ts.map +1 -0
  162. package/config/createSeed.js +16 -0
  163. package/config/createSeed.js.map +1 -0
  164. package/config/defineConfig.d.ts +27 -0
  165. package/config/defineConfig.d.ts.map +1 -0
  166. package/config/defineConfig.js +35 -0
  167. package/config/defineConfig.js.map +1 -0
  168. package/discovery/SeedConfigDiscovery.d.ts +16 -0
  169. package/discovery/SeedConfigDiscovery.d.ts.map +1 -0
  170. package/discovery/SeedConfigDiscovery.js +137 -0
  171. package/discovery/SeedConfigDiscovery.js.map +1 -0
  172. package/index.d.ts +32 -0
  173. package/index.d.ts.map +1 -0
  174. package/index.js +32 -0
  175. package/index.js.map +1 -0
  176. package/json/JsonReferenceResolver.d.ts +23 -0
  177. package/json/JsonReferenceResolver.d.ts.map +1 -0
  178. package/json/JsonReferenceResolver.js +99 -0
  179. package/json/JsonReferenceResolver.js.map +1 -0
  180. package/json/JsonSchemaValidator.d.ts +23 -0
  181. package/json/JsonSchemaValidator.d.ts.map +1 -0
  182. package/json/JsonSchemaValidator.js +98 -0
  183. package/json/JsonSchemaValidator.js.map +1 -0
  184. package/json/JsonSeedLoader.d.ts +33 -0
  185. package/json/JsonSeedLoader.d.ts.map +1 -0
  186. package/json/JsonSeedLoader.js +176 -0
  187. package/json/JsonSeedLoader.js.map +1 -0
  188. package/json/JsonSeedTypes.d.ts +204 -0
  189. package/json/JsonSeedTypes.d.ts.map +1 -0
  190. package/json/JsonSeedTypes.js +3 -0
  191. package/json/JsonSeedTypes.js.map +1 -0
  192. package/json/createJsonSeeder.d.ts +13 -0
  193. package/json/createJsonSeeder.d.ts.map +1 -0
  194. package/json/createJsonSeeder.js +240 -0
  195. package/json/createJsonSeeder.js.map +1 -0
  196. package/json/index.d.ts +6 -0
  197. package/json/index.d.ts.map +1 -0
  198. package/json/index.js +7 -0
  199. package/json/index.js.map +1 -0
  200. package/logging/ISeedLogger.d.ts +55 -0
  201. package/logging/ISeedLogger.d.ts.map +1 -0
  202. package/logging/ISeedLogger.js +3 -0
  203. package/logging/ISeedLogger.js.map +1 -0
  204. package/logging/LogLevel.d.ts +30 -0
  205. package/logging/LogLevel.d.ts.map +1 -0
  206. package/logging/LogLevel.js +37 -0
  207. package/logging/LogLevel.js.map +1 -0
  208. package/logging/SeedLogger.d.ts +24 -0
  209. package/logging/SeedLogger.d.ts.map +1 -0
  210. package/logging/SeedLogger.js +94 -0
  211. package/logging/SeedLogger.js.map +1 -0
  212. package/orchestration/SeedOrchestrator.d.ts +30 -0
  213. package/orchestration/SeedOrchestrator.d.ts.map +1 -0
  214. package/orchestration/SeedOrchestrator.js +262 -0
  215. package/orchestration/SeedOrchestrator.js.map +1 -0
  216. package/package.json +27 -0
  217. package/resolvers/EntityResolver.d.ts +43 -0
  218. package/resolvers/EntityResolver.d.ts.map +1 -0
  219. package/resolvers/EntityResolver.js +95 -0
  220. package/resolvers/EntityResolver.js.map +1 -0
  221. package/utils/AssetReferenceResolver.d.ts +49 -0
  222. package/utils/AssetReferenceResolver.d.ts.map +1 -0
  223. package/utils/AssetReferenceResolver.js +62 -0
  224. package/utils/AssetReferenceResolver.js.map +1 -0
  225. package/utils/EntityLookupCache.d.ts +47 -0
  226. package/utils/EntityLookupCache.d.ts.map +1 -0
  227. package/utils/EntityLookupCache.js +64 -0
  228. package/utils/EntityLookupCache.js.map +1 -0
  229. package/utils/ISeedRandom.d.ts +70 -0
  230. package/utils/ISeedRandom.d.ts.map +1 -0
  231. package/utils/ISeedRandom.js +3 -0
  232. package/utils/ISeedRandom.js.map +1 -0
  233. package/utils/LocalizationToolkit.d.ts +125 -0
  234. package/utils/LocalizationToolkit.d.ts.map +1 -0
  235. package/utils/LocalizationToolkit.js +131 -0
  236. package/utils/LocalizationToolkit.js.map +1 -0
  237. package/utils/SeededRandom.d.ts +15 -0
  238. package/utils/SeededRandom.d.ts.map +1 -0
  239. package/utils/SeededRandom.js +56 -0
  240. package/utils/SeededRandom.js.map +1 -0
  241. package/utils/StringArrayToolkit.d.ts +25 -0
  242. package/utils/StringArrayToolkit.d.ts.map +1 -0
  243. package/utils/StringArrayToolkit.js +56 -0
  244. package/utils/StringArrayToolkit.js.map +1 -0
  245. package/utils/StringValueGuard.d.ts +24 -0
  246. package/utils/StringValueGuard.d.ts.map +1 -0
  247. package/utils/StringValueGuard.js +46 -0
  248. package/utils/StringValueGuard.js.map +1 -0
  249. package/utils/WarningCollector.d.ts +40 -0
  250. package/utils/WarningCollector.d.ts.map +1 -0
  251. package/utils/WarningCollector.js +83 -0
  252. package/utils/WarningCollector.js.map +1 -0
@@ -0,0 +1,73 @@
1
+ import { HttpBlobAdapterBase } from './abstracts/HttpBlobAdapterBase.js';
2
+ import type { IBlobAdapter } from './interfaces/IBlobAdapter.js';
3
+ import type { IBlobAdapterConfig } from './interfaces/IBlobAdapterConfig.js';
4
+ import type { IBlobUploadResult } from './interfaces/IBlobUploadResult.js';
5
+ export interface IVercelBlobAdapterConfig extends IBlobAdapterConfig {
6
+ /**
7
+ * Vercel Blob API token (BLOB_READ_WRITE_TOKEN)
8
+ */
9
+ token?: string;
10
+ /**
11
+ * Base URL for Vercel Blob API endpoints (defaults to https://vercel.com/api/blob)
12
+ */
13
+ baseUrl?: string;
14
+ /**
15
+ * Force deterministic pathnames (no random suffix)
16
+ */
17
+ addRandomSuffix?: boolean;
18
+ /**
19
+ * Default max-age (seconds) for cache-control on uploads
20
+ */
21
+ cacheControlMaxAge?: number;
22
+ }
23
+ /**
24
+ * Blob adapter for Vercel Blob storage using direct HTTP API calls.
25
+ * This adapter is completely standalone and makes direct requests to Vercel Blob API.
26
+ *
27
+ * @public
28
+ */
29
+ export declare class VercelBlobAdapter extends HttpBlobAdapterBase<IVercelBlobAdapterConfig> implements IBlobAdapter {
30
+ private readonly _http;
31
+ /**
32
+ * Creates a new Vercel Blob adapter instance.
33
+ *
34
+ * @param config Configuration for the adapter
35
+ */
36
+ constructor(config: IVercelBlobAdapterConfig);
37
+ get name(): string;
38
+ /**
39
+ * Upload a file to Vercel Blob storage via direct API call.
40
+ *
41
+ * @param key The unique key/path for the file
42
+ * @param buffer The file content as a buffer
43
+ * @param mimeType The MIME type of the file
44
+ * @returns Promise with upload result containing metadata and public URL
45
+ */
46
+ upload(key: string, buffer: Buffer, mimeType: string): Promise<IBlobUploadResult>;
47
+ /**
48
+ * Generate (resolve) a public URL for accessing the uploaded file.
49
+ * Uses the List API to resolve the unguessable blob URL by pathname.
50
+ *
51
+ * @param key The unique key/path of the file
52
+ * @returns Promise with the public URL
53
+ */
54
+ getPublicUrl(key: string): Promise<string>;
55
+ /**
56
+ * Check if a file exists in Vercel Blob storage.
57
+ *
58
+ * @param key The unique key/path of the file
59
+ * @returns Promise with boolean indicating if file exists
60
+ */
61
+ exists(key: string): Promise<boolean>;
62
+ /**
63
+ * Delete a file from Vercel Blob storage.
64
+ * Requires posting JSON { "urls": [ "<blob.url>" ] } to /delete.
65
+ *
66
+ * @param key The unique key/path of the file
67
+ * @returns Promise that resolves when file is deleted
68
+ */
69
+ delete(key: string): Promise<void>;
70
+ private buildUploadHeaders;
71
+ private resolveByPathname;
72
+ }
73
+ //# sourceMappingURL=VercelBlobAdapter.d.ts.map
@@ -0,0 +1 @@
1
+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@ -0,0 +1,168 @@
1
+ // #region Imports
2
+ import axios from 'axios';
3
+ import { HttpBlobAdapterBase } from './abstracts/HttpBlobAdapterBase.js';
4
+ // #endregion
5
+ /**
6
+ * Blob adapter for Vercel Blob storage using direct HTTP API calls.
7
+ * This adapter is completely standalone and makes direct requests to Vercel Blob API.
8
+ *
9
+ * @public
10
+ */
11
+ export class VercelBlobAdapter extends HttpBlobAdapterBase {
12
+ // #region Fields
13
+ _http;
14
+ // #endregion
15
+ // #region Ctor
16
+ /**
17
+ * Creates a new Vercel Blob adapter instance.
18
+ *
19
+ * @param config Configuration for the adapter
20
+ */
21
+ constructor(config) {
22
+ if (!config) {
23
+ throw new Error('Vercel Blob configuration is required');
24
+ }
25
+ const resolvedConfig = {
26
+ baseUrl: 'https://vercel.com/api/blob',
27
+ ...config
28
+ };
29
+ super(resolvedConfig);
30
+ if (!resolvedConfig.token) {
31
+ throw new Error('Vercel Blob API token is required');
32
+ }
33
+ // Ensure baseURL is always set
34
+ const baseURL = resolvedConfig.baseUrl || 'https://vercel.com/api/blob';
35
+ this._http = axios.create({
36
+ baseURL,
37
+ headers: {
38
+ 'Authorization': `Bearer ${resolvedConfig.token}`,
39
+ 'x-api-version': '11'
40
+ },
41
+ maxBodyLength: Infinity,
42
+ timeout: 30000
43
+ });
44
+ }
45
+ // #endregion
46
+ // #region Properties
47
+ get name() {
48
+ return 'vercel';
49
+ }
50
+ // #endregion
51
+ // #region Methods
52
+ /**
53
+ * Upload a file to Vercel Blob storage via direct API call.
54
+ *
55
+ * @param key The unique key/path for the file
56
+ * @param buffer The file content as a buffer
57
+ * @param mimeType The MIME type of the file
58
+ * @returns Promise with upload result containing metadata and public URL
59
+ */
60
+ async upload(key, buffer, mimeType) {
61
+ const fullKey = this.resolveKey(key);
62
+ try {
63
+ const params = new URLSearchParams({ pathname: fullKey });
64
+ const url = `/?${params.toString()}`;
65
+ const response = await this._http.put(url, buffer, {
66
+ headers: {
67
+ 'Content-Type': mimeType,
68
+ 'x-content-length': String(buffer.byteLength),
69
+ ...this.buildUploadHeaders()
70
+ }
71
+ });
72
+ return {
73
+ key: fullKey,
74
+ url: response.data.url,
75
+ size: response.data.size ?? buffer.byteLength,
76
+ metadata: {
77
+ pathname: response.data.pathname,
78
+ contentType: response.data.contentType ?? mimeType,
79
+ downloadUrl: response.data.downloadUrl
80
+ }
81
+ };
82
+ }
83
+ catch (error) {
84
+ throw this.toError(error, `Failed to upload file to Vercel Blob: ${fullKey}`);
85
+ }
86
+ }
87
+ /**
88
+ * Generate (resolve) a public URL for accessing the uploaded file.
89
+ * Uses the List API to resolve the unguessable blob URL by pathname.
90
+ *
91
+ * @param key The unique key/path of the file
92
+ * @returns Promise with the public URL
93
+ */
94
+ async getPublicUrl(key) {
95
+ const fullKey = this.resolveKey(key);
96
+ const resolved = await this.resolveByPathname(fullKey);
97
+ if (!resolved?.url) {
98
+ throw new Error(`Blob not found for key: ${fullKey}`);
99
+ }
100
+ return resolved.url;
101
+ }
102
+ /**
103
+ * Check if a file exists in Vercel Blob storage.
104
+ *
105
+ * @param key The unique key/path of the file
106
+ * @returns Promise with boolean indicating if file exists
107
+ */
108
+ async exists(key) {
109
+ const fullKey = this.resolveKey(key);
110
+ const resolved = await this.resolveByPathname(fullKey);
111
+ return resolved !== null;
112
+ }
113
+ /**
114
+ * Delete a file from Vercel Blob storage.
115
+ * Requires posting JSON { "urls": [ "<blob.url>" ] } to /delete.
116
+ *
117
+ * @param key The unique key/path of the file
118
+ * @returns Promise that resolves when file is deleted
119
+ */
120
+ async delete(key) {
121
+ const fullKey = this.resolveKey(key);
122
+ const resolved = await this.resolveByPathname(fullKey);
123
+ if (!resolved?.url) {
124
+ return;
125
+ }
126
+ try {
127
+ await this._http.post('/delete', { urls: [resolved.url] }, {
128
+ headers: {
129
+ 'Content-Type': 'application/json'
130
+ }
131
+ });
132
+ }
133
+ catch (error) {
134
+ throw this.toError(error, `Failed to delete file from Vercel Blob: ${fullKey}`);
135
+ }
136
+ }
137
+ buildUploadHeaders() {
138
+ const headers = {
139
+ 'x-access': 'public',
140
+ 'x-allow-overwrite': '1'
141
+ };
142
+ const config = this.config;
143
+ if (config.addRandomSuffix === false) {
144
+ headers['x-add-random-suffix'] = '0';
145
+ }
146
+ if (config.cacheControlMaxAge !== undefined && config.cacheControlMaxAge >= 0) {
147
+ headers['x-cache-control-max-age'] = String(config.cacheControlMaxAge);
148
+ }
149
+ return headers;
150
+ }
151
+ async resolveByPathname(pathname) {
152
+ try {
153
+ const params = new URLSearchParams({
154
+ prefix: pathname,
155
+ limit: '1'
156
+ });
157
+ const response = await this._http.get(`/?${params.toString()}`);
158
+ return response.data?.blobs?.find((blob) => blob.pathname === pathname) ?? null;
159
+ }
160
+ catch (error) {
161
+ if (this.isNotFoundError(error)) {
162
+ return null;
163
+ }
164
+ throw this.toError(error, `Failed to resolve blob by pathname: ${pathname}`);
165
+ }
166
+ }
167
+ }
168
+ //# sourceMappingURL=VercelBlobAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VercelBlobAdapter.js","sourceRoot":"","sources":["../../../src/assets/adapters/VercelBlobAdapter.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAiDzE,aAAa;AAEb;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,mBAA6C;IAEhF,iBAAiB;IAEA,KAAK,CAAgB;IAEtC,aAAa;IAEb,eAAe;IAEf;;;;OAIG;IACH,YAAmB,MAAgC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,cAAc,GAA6B;YAC7C,OAAO,EAAE,6BAA6B;YACtC,GAAG,MAAM;SACZ,CAAC;QACF,KAAK,CAAC,cAAc,CAAC,CAAC;QAEtB,IAAI,CAAC,cAAc,CAAC,K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,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC;QACpF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9B,OAAO,IAAI,CAAC;YAChB,CAAC;YACD,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,uCAAuC,QAAQ,EAAE,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;CAIJ"}
@@ -0,0 +1,62 @@
1
+ import type { IBlobAdapter } from '../interfaces/IBlobAdapter.js';
2
+ import type { IBlobAdapterConfig } from '../interfaces/IBlobAdapterConfig.js';
3
+ import type { IBlobUploadResult } from '../interfaces/IBlobUploadResult.js';
4
+ /**
5
+ * Abstract base class for all blob adapters providing configuration access and
6
+ * key normalization helpers.
7
+ *
8
+ * @public
9
+ */
10
+ export declare abstract class BlobAdapterBase<TConfig extends IBlobAdapterConfig> implements IBlobAdapter {
11
+ private readonly _config;
12
+ protected constructor(config: TConfig);
13
+ /**
14
+ * Gets the adapter configuration instance.
15
+ */
16
+ protected get config(): TConfig;
17
+ /**
18
+ * Gets the unique adapter name.
19
+ */
20
+ abstract get name(): string;
21
+ /**
22
+ * Uploads content to the underlying storage provider.
23
+ *
24
+ * @param key Upload key relative to the configured prefix.
25
+ * @param buffer File contents.
26
+ * @param mimeType MIME type for the stored content.
27
+ */
28
+ abstract upload(key: string, buffer: Buffer, mimeType: string): Promise<IBlobUploadResult>;
29
+ /**
30
+ * Resolves a public URL for a stored blob.
31
+ *
32
+ * @param key Blob key relative to the configured prefix.
33
+ */
34
+ abstract getPublicUrl(key: string): Promise<string>;
35
+ /**
36
+ * Determines whether the provided blob key exists.
37
+ *
38
+ * @param key Blob key relative to the configured prefix.
39
+ */
40
+ abstract exists(key: string): Promise<boolean>;
41
+ /**
42
+ * Deletes the provided blob when present.
43
+ *
44
+ * @param key Blob key relative to the configured prefix.
45
+ */
46
+ abstract delete(key: string): Promise<void>;
47
+ /**
48
+ * Applies the configured key prefix and normalizes path separators.
49
+ *
50
+ * @param key Raw key supplied by the caller.
51
+ * @returns Normalized key with prefix applied.
52
+ */
53
+ protected resolveKey(key: string): string;
54
+ /**
55
+ * Sanitizes arbitrary path values by trimming redundant separators.
56
+ *
57
+ * @param value Path value that may contain duplicate separators.
58
+ * @returns Sanitized path without leading or trailing separators.
59
+ */
60
+ protected sanitizePath(value: string): string;
61
+ }
62
+ //# sourceMappingURL=BlobAdapterBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlobAdapterBase.d.ts","sourceRoot":"","sources":["../../../../src/assets/adapters/abstracts/BlobAdapterBase.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAI5E;;;;;GAKG;AACH,8BAAsB,eAAe,CAAC,OAAO,SAAS,kBAAkB,CAAE,YAAW,YAAY;IAI7F,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAMlC,SAAS,aAAa,MAAM,EAAE,OAAO;IAQrC;;OAEG;IACH,SAAS,KAAK,MAAM,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,aAAoB,IAAI,IAAI,MAAM,CAAC;IAMnC;;;;;;OAMG;aACa,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAEjG;;;;OAIG;aACa,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAE1D;;;;OAIG;aACa,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAErD;;;;OAIG;aACa,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlD;;;;;OAKG;IACH,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAgBzC;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAShD"}
@@ -0,0 +1,58 @@
1
+ /* eslint-disable no-unused-vars */
2
+ // #endregion
3
+ /**
4
+ * Abstract base class for all blob adapters providing configuration access and
5
+ * key normalization helpers.
6
+ *
7
+ * @public
8
+ */
9
+ export class BlobAdapterBase {
10
+ // #region Fields
11
+ _config;
12
+ // #endregion
13
+ // #region Ctor
14
+ constructor(config) {
15
+ this._config = config;
16
+ }
17
+ // #endregion
18
+ // #region Properties
19
+ /**
20
+ * Gets the adapter configuration instance.
21
+ */
22
+ get config() {
23
+ return this._config;
24
+ }
25
+ // #endregion
26
+ // #region Protected Methods
27
+ /**
28
+ * Applies the configured key prefix and normalizes path separators.
29
+ *
30
+ * @param key Raw key supplied by the caller.
31
+ * @returns Normalized key with prefix applied.
32
+ */
33
+ resolveKey(key) {
34
+ const segments = [];
35
+ const sanitize = (value) => value
36
+ .split(/[\\/]+/)
37
+ .map((segment) => segment.trim())
38
+ .filter((segment) => segment.length > 0);
39
+ if (this._config.keyPrefix) {
40
+ segments.push(...sanitize(this._config.keyPrefix));
41
+ }
42
+ segments.push(...sanitize(key));
43
+ return segments.join('/');
44
+ }
45
+ /**
46
+ * Sanitizes arbitrary path values by trimming redundant separators.
47
+ *
48
+ * @param value Path value that may contain duplicate separators.
49
+ * @returns Sanitized path without leading or trailing separators.
50
+ */
51
+ sanitizePath(value) {
52
+ return value.split(/[\\/]+/)
53
+ .map((segment) => segment.trim())
54
+ .filter((segment) => segment.length > 0)
55
+ .join('/');
56
+ }
57
+ }
58
+ //# sourceMappingURL=BlobAdapterBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlobAdapterBase.js","sourceRoot":"","sources":["../../../../src/assets/adap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AC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;aACvC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CAIJ"}
@@ -0,0 +1,43 @@
1
+ import { BlobAdapterBase } from './BlobAdapterBase.js';
2
+ import type { IBlobAdapterConfig } from '../interfaces/IBlobAdapterConfig.js';
3
+ /**
4
+ * Error representation that captures HTTP status codes from adapter operations.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class HttpStatusError extends Error {
9
+ readonly status: number;
10
+ readonly responseBody?: string;
11
+ constructor(status: number, message: string, responseBody?: string);
12
+ }
13
+ /**
14
+ * Shared helper base class for HTTP blob adapters.
15
+ *
16
+ * @public
17
+ */
18
+ export declare abstract class HttpBlobAdapterBase<TConfig extends IBlobAdapterConfig> extends BlobAdapterBase<TConfig> {
19
+ protected constructor(config: TConfig);
20
+ /**
21
+ * Encodes a normalized key for safe inclusion in HTTP URLs.
22
+ *
23
+ * @param path Normalized key.
24
+ * @returns URL-encoded representation.
25
+ */
26
+ protected encodeKey(path: string): string;
27
+ /**
28
+ * Wraps provider specific errors into descriptive {@link Error} instances.
29
+ *
30
+ * @param error Original error.
31
+ * @param message Prefix message that explains the context.
32
+ * @returns Error containing provider status information when available.
33
+ */
34
+ protected toError(error: unknown, message: string): Error;
35
+ /**
36
+ * Determines whether the supplied error represents a not-found response.
37
+ *
38
+ * @param error Error produced by an adapter operation.
39
+ * @returns True when the error indicates HTTP 404.
40
+ */
41
+ protected isNotFoundError(error: unknown): boolean;
42
+ }
43
+ //# sourceMappingURL=HttpBlobAdapterBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpBlobAdapterBase.d.ts","sourceRoot":"","sources":["../../../../src/assets/adapters/abstracts/HttpBlobAdapterBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAM9E;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAItC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,YAAY,CAAC,EAAE,MAAM,CAAC;gBAMnB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CAQ5E;AAID;;;;GAIG;AACH,8BAAsB,mBAAmB,CAAC,OAAO,SAAS,kBAAkB,CAAE,SAAQ,eAAe,CAAC,OAAO,CAAC;IAI1G,SAAS,aAAa,MAAM,EAAE,OAAO;IAQrC;;;;;OAKG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAOzC;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK;IAqBzD;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;CAcrD"}
@@ -0,0 +1,88 @@
1
+ // #region Imports
2
+ import axios from 'axios';
3
+ import { BlobAdapterBase } from './BlobAdapterBase.js';
4
+ // #endregion
5
+ // #region Types
6
+ /**
7
+ * Error representation that captures HTTP status codes from adapter operations.
8
+ *
9
+ * @public
10
+ */
11
+ export class HttpStatusError extends Error {
12
+ // #region Fields
13
+ status;
14
+ responseBody;
15
+ // #endregion
16
+ // #region Ctor
17
+ constructor(status, message, responseBody) {
18
+ super(`HttpStatusError(${status}): ${message}`);
19
+ this.status = status;
20
+ this.responseBody = responseBody;
21
+ }
22
+ }
23
+ // #endregion
24
+ /**
25
+ * Shared helper base class for HTTP blob adapters.
26
+ *
27
+ * @public
28
+ */
29
+ export class HttpBlobAdapterBase extends BlobAdapterBase {
30
+ // #region Ctor
31
+ constructor(config) {
32
+ super(config);
33
+ }
34
+ // #endregion
35
+ // #region Protected Methods
36
+ /**
37
+ * Encodes a normalized key for safe inclusion in HTTP URLs.
38
+ *
39
+ * @param path Normalized key.
40
+ * @returns URL-encoded representation.
41
+ */
42
+ encodeKey(path) {
43
+ return path.split('/')
44
+ .filter((segment) => segment.length > 0)
45
+ .map((segment) => encodeURIComponent(segment))
46
+ .join('/');
47
+ }
48
+ /**
49
+ * Wraps provider specific errors into descriptive {@link Error} instances.
50
+ *
51
+ * @param error Original error.
52
+ * @param message Prefix message that explains the context.
53
+ * @returns Error containing provider status information when available.
54
+ */
55
+ toError(error, message) {
56
+ if (error instanceof HttpStatusError) {
57
+ const bodySegment = error.responseBody ? `: ${error.responseBody}` : '';
58
+ return new Error(`${message} (status ${error.status})${bodySegment}`);
59
+ }
60
+ if (axios.isAxiosError(error)) {
61
+ const statusSegment = error.response?.status ? ` (status ${error.response.status})` : '';
62
+ const responsePayload = typeof error.response?.data === 'string'
63
+ ? error.response.data
64
+ : JSON.stringify(error.response?.data ?? {});
65
+ return new Error(`${message}${statusSegment}: ${responsePayload}`);
66
+ }
67
+ if (error instanceof Error) {
68
+ return new Error(`${message}: ${error.message}`);
69
+ }
70
+ return new Error(message);
71
+ }
72
+ /**
73
+ * Determines whether the supplied error represents a not-found response.
74
+ *
75
+ * @param error Error produced by an adapter operation.
76
+ * @returns True when the error indicates HTTP 404.
77
+ */
78
+ isNotFoundError(error) {
79
+ if (error instanceof HttpStatusError) {
80
+ return error.status === 404;
81
+ }
82
+ if (axios.isAxiosError(error)) {
83
+ return error.response?.status === 404;
84
+ }
85
+ return false;
86
+ }
87
+ }
88
+ //# sourceMappingURL=HttpBlobAdapterBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpBlobAdapterBase.js","sourceRoot":"","sources":["../../../../src/assets/adapters/abstracts/HttpBlobAdapterBase.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,aAAa;AAEb,gBAAgB;AAEhB;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,K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KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACzF,MAAM,eAAe,GAAG,OAAO,KAAK,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ;gBAC5D,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI;gBACrB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;YACjD,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,GAAG,aAAa,KAAK,eAAe,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YACzB,OAAO,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACO,eAAe,CAAC,KAAc;QACpC,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;YACnC,OAAO,KAAK,CAAC,MAAM,KAAK,GAAG,CAAC;QAChC,CAAC;QAED,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC;QAC1C,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAIJ"}
@@ -0,0 +1,47 @@
1
+ import { ICloudflareR2AdapterConfig } from './CloudflareR2BlobAdapter.js';
2
+ import type { IBlobAdapter } from './interfaces/IBlobAdapter.js';
3
+ import { ILocalFileAdapterConfig } from './LocalFileAdapter.js';
4
+ import { IVercelBlobAdapterConfig } from './VercelBlobAdapter.js';
5
+ /**
6
+ * Supported blob adapter types.
7
+ *
8
+ * @public
9
+ */
10
+ export type BlobAdapterType = 'empty' | 'local' | 'vercel' | 'cloudflare-r2';
11
+ /**
12
+ * Factory function to create a blob adapter based on type and configuration.
13
+ *
14
+ * @param type - The type of blob adapter to create.
15
+ * @param config - The configuration object for the adapter.
16
+ * @returns An instance of the requested blob adapter.
17
+ * @throws Error if the adapter type is unsupported.
18
+ */
19
+ export declare function createBlobAdapter(type: BlobAdapterType, config: any): IBlobAdapter;
20
+ /**
21
+ * Create an empty blob adapter for development.
22
+ *
23
+ * @returns Empty blob adapter instance.
24
+ */
25
+ export declare function createEmptyBlobAdapter(): IBlobAdapter;
26
+ /**
27
+ * Create a local file adapter for development and testing.
28
+ *
29
+ * @param config - Local file adapter configuration.
30
+ * @returns Local file adapter instance.
31
+ */
32
+ export declare function createLocalBlobAdapter(config: ILocalFileAdapterConfig): IBlobAdapter;
33
+ /**
34
+ * Create a Vercel blob adapter for production.
35
+ *
36
+ * @param config - Vercel adapter configuration.
37
+ * @returns Vercel blob adapter instance.
38
+ */
39
+ export declare function createVercelBlobAdapter(config: IVercelBlobAdapterConfig): IBlobAdapter;
40
+ /**
41
+ * Create a Cloudflare R2 blob adapter for production usage.
42
+ *
43
+ * @param config - Cloudflare R2 adapter configuration.
44
+ * @returns Cloudflare R2 blob adapter instance.
45
+ */
46
+ export declare function createCloudflareR2BlobAdapter(config: ICloudflareR2AdapterConfig): IBlobAdapter;
47
+ //# sourceMappingURL=createBlobAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBlobAdapter.d.ts","sourceRoot":"","sources":["../../../src/assets/adapters/createBlobAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAA2B,MAAM,8BAA8B,CAAC;AAEnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAoB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAqB,MAAM,wBAAwB,CAAC;AAIrF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE7E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,GAAG,YAAY,CAalF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,uBAAuB,GAAG,YAAY,CAEpF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,wBAAwB,GAAG,YAAY,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,0BAA0B,GAAG,YAAY,CAE9F"}
@@ -0,0 +1,63 @@
1
+ // #region Imports
2
+ import { CloudflareR2BlobAdapter } from './CloudflareR2BlobAdapter.js';
3
+ import { EmptyBlobAdapter } from './EmptyBlobAdapter.js';
4
+ import { LocalFileAdapter } from './LocalFileAdapter.js';
5
+ import { VercelBlobAdapter } from './VercelBlobAdapter.js';
6
+ /**
7
+ * Factory function to create a blob adapter based on type and configuration.
8
+ *
9
+ * @param type - The type of blob adapter to create.
10
+ * @param config - The configuration object for the adapter.
11
+ * @returns An instance of the requested blob adapter.
12
+ * @throws Error if the adapter type is unsupported.
13
+ */
14
+ export function createBlobAdapter(type, config) {
15
+ switch (type) {
16
+ case 'empty':
17
+ return createEmptyBlobAdapter();
18
+ case 'local':
19
+ return createLocalBlobAdapter(config);
20
+ case 'vercel':
21
+ return createVercelBlobAdapter(config);
22
+ case 'cloudflare-r2':
23
+ return createCloudflareR2BlobAdapter(config);
24
+ default:
25
+ throw new Error(`Unsupported blob adapter type: ${type}`);
26
+ }
27
+ }
28
+ /**
29
+ * Create an empty blob adapter for development.
30
+ *
31
+ * @returns Empty blob adapter instance.
32
+ */
33
+ export function createEmptyBlobAdapter() {
34
+ return new EmptyBlobAdapter();
35
+ }
36
+ /**
37
+ * Create a local file adapter for development and testing.
38
+ *
39
+ * @param config - Local file adapter configuration.
40
+ * @returns Local file adapter instance.
41
+ */
42
+ export function createLocalBlobAdapter(config) {
43
+ return new LocalFileAdapter(config);
44
+ }
45
+ /**
46
+ * Create a Vercel blob adapter for production.
47
+ *
48
+ * @param config - Vercel adapter configuration.
49
+ * @returns Vercel blob adapter instance.
50
+ */
51
+ export function createVercelBlobAdapter(config) {
52
+ return new VercelBlobAdapter(config);
53
+ }
54
+ /**
55
+ * Create a Cloudflare R2 blob adapter for production usage.
56
+ *
57
+ * @param config - Cloudflare R2 adapter configuration.
58
+ * @returns Cloudflare R2 blob adapter instance.
59
+ */
60
+ export function createCloudflareR2BlobAdapter(config) {
61
+ return new CloudflareR2BlobAdapter(config);
62
+ }
63
+ //# sourceMappingURL=createBlobAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBlobAdapter.js","sourceRoot":"","sources":["../../../src/assets/adapters/createBlobAdapter.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAA8B,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAA2B,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAA4B,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAWrF;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAqB,EAAE,MAAW;IAChE,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,OAAO;YACR,OAAO,sBAAsB,EAAE,CAAC;QACpC,KAAK,OAAO;YACR,OAAO,sBAAsB,CAAC,MAAiC,CAAC,CAAC;QACrE,KAAK,QAAQ;YACT,OAAO,uBAAuB,CAAC,MAAkC,CAAC,CAAC;QACvE,KAAK,eAAe;YAChB,OAAO,6BAA6B,CAAC,MAAoC,CAAC,CAAC;QAC/E;YACI,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IAClC,OAAO,IAAI,gBAAgB,EAAE,CAAC;AAClC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAA+B;IAClE,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAgC;IACpE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,MAAkC;IAC5E,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,11 @@
1
+ export { BlobAdapterBase } from './abstracts/BlobAdapterBase.js';
2
+ export type { IBlobAdapter } from './interfaces/IBlobAdapter.js';
3
+ export type { IBlobAdapterConfig } from './interfaces/IBlobAdapterConfig.js';
4
+ export type { IBlobUploadResult } from './interfaces/IBlobUploadResult.js';
5
+ export { EmptyBlobAdapter } from './EmptyBlobAdapter.js';
6
+ export { LocalFileAdapter, type ILocalFileAdapterConfig } from './LocalFileAdapter.js';
7
+ export { type BlobAdapterConfiguration } from './BlobAdapterFactory.js';
8
+ export { VercelBlobAdapter, type IVercelBlobAdapterConfig } from './VercelBlobAdapter.js';
9
+ export { CloudflareR2BlobAdapter, type ICloudflareR2AdapterConfig } from './CloudflareR2BlobAdapter.js';
10
+ export { createCloudflareR2BlobAdapter, createEmptyBlobAdapter, createLocalBlobAdapter, createVercelBlobAdapter, createBlobAdapter, BlobAdapterType } from './createBlobAdapter.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/assets/adapters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,KAAK,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}