betterstart-cli 0.0.26 → 0.0.28

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,39 @@
1
+ import { randomUUID } from 'node:crypto'
2
+ import type { AdminStorageProvider, AdminStorageUploadInput } from '@admin/actions/storage/types'
3
+ import { put } from '@vercel/blob'
4
+
5
+ function getToken(): string {
6
+ return process.env.BLOB_READ_WRITE_TOKEN?.trim() ?? ''
7
+ }
8
+
9
+ function sanitizeFilename(filename: string): string {
10
+ return filename.replace(/[^a-zA-Z0-9.-]/g, '_')
11
+ }
12
+
13
+ function buildKey(filename: string, prefix = 'uploads'): string {
14
+ return `${prefix}/${Date.now()}-${randomUUID()}-${sanitizeFilename(filename)}`
15
+ }
16
+
17
+ export const vercelBlobStorageProvider: AdminStorageProvider = {
18
+ id: 'vercel-blob',
19
+ isConfigured() {
20
+ return Boolean(getToken())
21
+ },
22
+ async saveFile(input: AdminStorageUploadInput) {
23
+ if (!this.isConfigured()) {
24
+ throw new Error('Vercel Blob is not configured.')
25
+ }
26
+
27
+ const key = buildKey(input.filename, input.prefix)
28
+ const blob = await put(key, input.buffer, {
29
+ access: 'public',
30
+ contentType: input.contentType,
31
+ token: getToken()
32
+ })
33
+
34
+ return {
35
+ key,
36
+ url: blob.url
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,36 @@
1
+ import type { BetterstartIntegrationDefinition } from '@integration-engine/types.js'
2
+
3
+ export const vercelBlobIntegration: BetterstartIntegrationDefinition = {
4
+ id: 'vercel-blob',
5
+ title: 'Vercel Blob',
6
+ description: 'Remote media storage on Vercel Blob',
7
+ kind: 'storage',
8
+ version: '1.0.0',
9
+ dependencies: [],
10
+ conflicts: [],
11
+ files: [
12
+ {
13
+ outputPath: 'lib/actions/vercel-blob/provider.ts',
14
+ templatePath: 'actions/vercel-blob.ts'
15
+ }
16
+ ],
17
+ packageDependencies: ['@vercel/blob'],
18
+ devDependencies: [],
19
+ capabilities: {
20
+ storageProvider: {
21
+ provider: 'vercel-blob',
22
+ importPath: '@admin/actions/vercel-blob/provider',
23
+ exportName: 'vercelBlobStorageProvider'
24
+ }
25
+ },
26
+ envSections: [
27
+ {
28
+ // BLOB_READ_WRITE_TOKEN is deliberately unprefixed: it is the name the
29
+ // @vercel/blob SDK reads by default and the one Vercel injects into
30
+ // deployments when a Blob store is connected to the project.
31
+ header: 'Storage (Vercel Blob)',
32
+ vars: [{ key: 'BLOB_READ_WRITE_TOKEN', value: '' }]
33
+ }
34
+ ],
35
+ configure: 'vercel-blob'
36
+ }