nextly 0.0.1 → 0.0.2-alpha.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.
- package/LICENSE +22 -0
- package/README.md +122 -0
- package/dist/_dts-chunks/collections-handler.d-DjgO74Wt.d.ts +20540 -0
- package/dist/_dts-chunks/config.d-DNwsDnjs.d.ts +2589 -0
- package/dist/_dts-chunks/define-component.d-BUgTHmt3.d.ts +1149 -0
- package/dist/_dts-chunks/image-processor.d-OO1PmMrv.d.ts +335 -0
- package/dist/_dts-chunks/index.d-axCAzZ7m.d.ts +17842 -0
- package/dist/_dts-chunks/media.d-DjDOZo4B.d.ts +117 -0
- package/dist/_dts-chunks/on-error.d-CHIKWNxd.d.ts +38 -0
- package/dist/_dts-chunks/storage.d-BUhQ2we_.d.ts +404 -0
- package/dist/actions/index.d.ts +239 -0
- package/dist/actions/index.mjs +281 -0
- package/dist/api/auth-state.d.ts +5 -0
- package/dist/api/auth-state.mjs +131 -0
- package/dist/api/collections-schema-detail.d.ts +56 -0
- package/dist/api/collections-schema-detail.mjs +244 -0
- package/dist/api/collections-schema-export.d.ts +56 -0
- package/dist/api/collections-schema-export.mjs +129 -0
- package/dist/api/collections-schema.d.ts +59 -0
- package/dist/api/collections-schema.mjs +207 -0
- package/dist/api/components-detail.d.ts +50 -0
- package/dist/api/components-detail.mjs +132 -0
- package/dist/api/components.d.ts +69 -0
- package/dist/api/components.mjs +144 -0
- package/dist/api/email-providers-default.d.ts +40 -0
- package/dist/api/email-providers-default.mjs +75 -0
- package/dist/api/email-providers-detail.d.ts +81 -0
- package/dist/api/email-providers-detail.mjs +109 -0
- package/dist/api/email-providers-test.d.ts +43 -0
- package/dist/api/email-providers-test.mjs +114 -0
- package/dist/api/email-providers.d.ts +69 -0
- package/dist/api/email-providers.mjs +110 -0
- package/dist/api/email-send-template.d.ts +41 -0
- package/dist/api/email-send-template.mjs +58 -0
- package/dist/api/email-send.d.ts +42 -0
- package/dist/api/email-send.mjs +58 -0
- package/dist/api/email-templates-detail.d.ts +74 -0
- package/dist/api/email-templates-detail.mjs +112 -0
- package/dist/api/email-templates-layout.d.ts +55 -0
- package/dist/api/email-templates-layout.mjs +92 -0
- package/dist/api/email-templates-preview.d.ts +48 -0
- package/dist/api/email-templates-preview.mjs +93 -0
- package/dist/api/email-templates.d.ts +61 -0
- package/dist/api/email-templates.mjs +118 -0
- package/dist/api/health.d.ts +68 -0
- package/dist/api/health.mjs +67 -0
- package/dist/api/index.d.ts +54 -0
- package/dist/api/index.mjs +16 -0
- package/dist/api/media-bulk.d.ts +74 -0
- package/dist/api/media-bulk.mjs +196 -0
- package/dist/api/media-folders.d.ts +112 -0
- package/dist/api/media-folders.mjs +187 -0
- package/dist/api/media-handlers.d.ts +102 -0
- package/dist/api/media-handlers.mjs +437 -0
- package/dist/api/media.d.ts +117 -0
- package/dist/api/media.mjs +242 -0
- package/dist/api/singles-detail.d.ts +87 -0
- package/dist/api/singles-detail.mjs +170 -0
- package/dist/api/singles-schema-detail.d.ts +54 -0
- package/dist/api/singles-schema-detail.mjs +182 -0
- package/dist/api/singles.d.ts +34 -0
- package/dist/api/singles.mjs +94 -0
- package/dist/api/storage-upload-url.d.ts +48 -0
- package/dist/api/storage-upload-url.mjs +202 -0
- package/dist/api/uploads.d.ts +109 -0
- package/dist/api/uploads.mjs +359 -0
- package/dist/auth/index.d.ts +425 -0
- package/dist/auth/index.mjs +199 -0
- package/dist/boot-apply-PQSYLDIN.mjs +7 -0
- package/dist/chunk-2OALJTK6.mjs +489 -0
- package/dist/chunk-2Q2SX2CS.mjs +365 -0
- package/dist/chunk-2TFX4ND3.mjs +13 -0
- package/dist/chunk-2TWPDSYD.mjs +87 -0
- package/dist/chunk-2W3DVD7S.mjs +647 -0
- package/dist/chunk-2ZFKXPQM.mjs +88 -0
- package/dist/chunk-3FA7FKAV.mjs +832 -0
- package/dist/chunk-3NZ2KMBL.mjs +58 -0
- package/dist/chunk-4MJLT6PZ.mjs +0 -0
- package/dist/chunk-56WO4WX7.mjs +0 -0
- package/dist/chunk-5APFUGAD.mjs +89 -0
- package/dist/chunk-5HMZ644B.mjs +108 -0
- package/dist/chunk-67GXH6PR.mjs +32 -0
- package/dist/chunk-6JNEPWRW.mjs +14368 -0
- package/dist/chunk-6NFHQIJD.mjs +45 -0
- package/dist/chunk-7P6ASYW6.mjs +9 -0
- package/dist/chunk-A3WPLSDT.mjs +1364 -0
- package/dist/chunk-AGJ6F2T3.mjs +144 -0
- package/dist/chunk-AK6Z23OX.mjs +1464 -0
- package/dist/chunk-APKKRD2G.mjs +102 -0
- package/dist/chunk-B2GV2BWH.mjs +73 -0
- package/dist/chunk-D5HQBNUB.mjs +74 -0
- package/dist/chunk-DNNG377Z.mjs +204 -0
- package/dist/chunk-DP3G27G5.mjs +135 -0
- package/dist/chunk-DV6WVX2Q.mjs +0 -0
- package/dist/chunk-DXGGXIUZ.mjs +57 -0
- package/dist/chunk-EGXBZCGC.mjs +943 -0
- package/dist/chunk-ERCNLX3V.mjs +176 -0
- package/dist/chunk-FQULBZ53.mjs +850 -0
- package/dist/chunk-G2AA4QLC.mjs +262 -0
- package/dist/chunk-GDBJ5JCU.mjs +488 -0
- package/dist/chunk-GJNSJU4S.mjs +19 -0
- package/dist/chunk-GZ6DCQKC.mjs +69 -0
- package/dist/chunk-H26B4FYG.mjs +167 -0
- package/dist/chunk-I4JMR3UR.mjs +21 -0
- package/dist/chunk-INV7QKLG.mjs +508 -0
- package/dist/chunk-IUDOC7N7.mjs +46 -0
- package/dist/chunk-IZWPRDC3.mjs +206 -0
- package/dist/chunk-KIMNCZGV.mjs +15 -0
- package/dist/chunk-L6HW2DA7.mjs +15 -0
- package/dist/chunk-LAZXX4HR.mjs +100 -0
- package/dist/chunk-LDKCUMHK.mjs +95 -0
- package/dist/chunk-LRXMECUA.mjs +0 -0
- package/dist/chunk-M52VMPGA.mjs +119 -0
- package/dist/chunk-MGUWEEI6.mjs +160 -0
- package/dist/chunk-NRUWQ5Z7.mjs +419 -0
- package/dist/chunk-NSEFNNU4.mjs +25360 -0
- package/dist/chunk-NTHVDFGO.mjs +138 -0
- package/dist/chunk-O3QHXMOX.mjs +3166 -0
- package/dist/chunk-P7NH2OSC.mjs +2605 -0
- package/dist/chunk-PKMABBB5.mjs +184 -0
- package/dist/chunk-PWS6XGJK.mjs +76 -0
- package/dist/chunk-R6JJQHFC.mjs +20 -0
- package/dist/chunk-RJLLGGPG.mjs +0 -0
- package/dist/chunk-SBACDPNX.mjs +689 -0
- package/dist/chunk-TO5AFLVQ.mjs +124 -0
- package/dist/chunk-TS7GHTG2.mjs +5436 -0
- package/dist/chunk-UJ2IMJ4W.mjs +133 -0
- package/dist/chunk-UOP63Q54.mjs +102 -0
- package/dist/chunk-UUOFWCM6.mjs +78 -0
- package/dist/chunk-V4EQTOA4.mjs +893 -0
- package/dist/chunk-VJ66NCL4.mjs +193 -0
- package/dist/chunk-VQJQHVEV.mjs +29 -0
- package/dist/chunk-VTJADRO3.mjs +141 -0
- package/dist/chunk-VWF3JO32.mjs +0 -0
- package/dist/chunk-W4MGXIRR.mjs +27 -0
- package/dist/chunk-W5KKPZT5.mjs +1204 -0
- package/dist/chunk-WD34YQ6T.mjs +381 -0
- package/dist/chunk-WZBYMYVW.mjs +14 -0
- package/dist/chunk-X23WKS3Z.mjs +50 -0
- package/dist/chunk-X7TXCYYN.mjs +6496 -0
- package/dist/chunk-XGI4EMS3.mjs +140 -0
- package/dist/chunk-XZKLBMN6.mjs +1153 -0
- package/dist/chunk-YB7INWPY.mjs +0 -0
- package/dist/chunk-YV4Y7SDL.mjs +83 -0
- package/dist/chunk-YZNBLFIW.mjs +1688 -0
- package/dist/chunk-YZZCTONM.mjs +263 -0
- package/dist/chunk-ZE6A3FYH.mjs +289 -0
- package/dist/cli/nextly.mjs +68 -0
- package/dist/cli/utils/index.d.ts +449 -0
- package/dist/cli/utils/index.mjs +49 -0
- package/dist/component-schema-service-5577KVW6.mjs +11 -0
- package/dist/config-loader-23YEMC3Z.mjs +23 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.mjs +109 -0
- package/dist/container-ORGFGYSZ.mjs +9 -0
- package/dist/database/index.d.ts +12 -0
- package/dist/database/index.mjs +40 -0
- package/dist/database/seeders/index.d.ts +93 -0
- package/dist/database/seeders/index.mjs +47 -0
- package/dist/db-sync-demote-LJGKLB3S.mjs +117 -0
- package/dist/db-sync-promote-B26VSYQF.mjs +113 -0
- package/dist/dev-reload-broadcaster-B73IQ53V.mjs +25 -0
- package/dist/dist-M2NOU37V.mjs +19 -0
- package/dist/drizzle-kit-lazy-D2M2PXR2.mjs +13 -0
- package/dist/dynamic-collection-schema-service-IEXTPIZ7.mjs +8 -0
- package/dist/errors/index.d.ts +159 -0
- package/dist/errors/index.mjs +10 -0
- package/dist/factory-IWMBKUJM.mjs +15 -0
- package/dist/first-run-QIVKWJIF.mjs +63 -0
- package/dist/fresh-push-NR67DC3R.mjs +8 -0
- package/dist/index.d.ts +4175 -0
- package/dist/index.mjs +1336 -0
- package/dist/local-plugin-PTET4NAT.mjs +7 -0
- package/dist/logger-NU46DXNY.mjs +15 -0
- package/dist/logger-YE4TC7ZN.mjs +9 -0
- package/dist/migration-journal-EP532Y4L.mjs +139 -0
- package/dist/migrations/mysql/0000_eager_sentry.sql +174 -0
- package/dist/migrations/mysql/0001_soft_giant_girl.sql +27 -0
- package/dist/migrations/mysql/0002_media_table.sql +24 -0
- package/dist/migrations/mysql/0003_dynamic_singles.sql +37 -0
- package/dist/migrations/mysql/0004_dynamic_components.sql +35 -0
- package/dist/migrations/mysql/0005_user_management_tables.sql +92 -0
- package/dist/migrations/mysql/0006_api_keys.sql +36 -0
- package/dist/migrations/mysql/0007_general_settings.sql +20 -0
- package/dist/migrations/mysql/0008_site_settings_logo_url.sql +9 -0
- package/dist/migrations/mysql/0009_activity_log.sql +30 -0
- package/dist/migrations/mysql/0010_site_settings_sidebar.sql +13 -0
- package/dist/migrations/mysql/0011_missing_tables_and_columns.sql +54 -0
- package/dist/migrations/mysql/0012_image_sizes_and_focal_point.sql +30 -0
- package/dist/migrations/mysql/0012_media_folders.sql +43 -0
- package/dist/migrations/mysql/0013_user_brute_force_protection.sql +31 -0
- package/dist/migrations/mysql/0014_email_template_attachments.sql +12 -0
- package/dist/migrations/mysql/0015_media_uploaded_by_nullable.sql +15 -0
- package/dist/migrations/mysql/20260429_000000_000_initial_journal.sql +22 -0
- package/dist/migrations/mysql/20260501_000000_journal_batch.sql +17 -0
- package/dist/migrations/mysql/20260501_000001_audit_log.sql +24 -0
- package/dist/migrations/mysql/20260504_000000_nextly_meta.sql +21 -0
- package/dist/migrations/mysql/meta/0000_snapshot.json +1005 -0
- package/dist/migrations/mysql/meta/0001_snapshot.json +1099 -0
- package/dist/migrations/mysql/meta/_journal.json +41 -0
- package/dist/migrations/postgresql/0000_misty_king_bedlam.sql +169 -0
- package/dist/migrations/postgresql/0001_perpetual_captain_marvel.sql +8 -0
- package/dist/migrations/postgresql/0002_sad_spectrum.sql +16 -0
- package/dist/migrations/postgresql/0003_hesitant_ultron.sql +17 -0
- package/dist/migrations/postgresql/0004_media_table.sql +24 -0
- package/dist/migrations/postgresql/0005_media_folders.sql +36 -0
- package/dist/migrations/postgresql/0006_dynamic_collections_update.sql +50 -0
- package/dist/migrations/postgresql/0007_dynamic_singles.sql +38 -0
- package/dist/migrations/postgresql/0008_dynamic_components.sql +37 -0
- package/dist/migrations/postgresql/0009_user_management_tables.sql +95 -0
- package/dist/migrations/postgresql/0010_api_keys.sql +34 -0
- package/dist/migrations/postgresql/0011_general_settings.sql +20 -0
- package/dist/migrations/postgresql/0012_site_settings_logo_url.sql +9 -0
- package/dist/migrations/postgresql/0013_activity_log.sql +29 -0
- package/dist/migrations/postgresql/0014_image_sizes_and_focal_point.sql +33 -0
- package/dist/migrations/postgresql/0014_site_settings_sidebar.sql +13 -0
- package/dist/migrations/postgresql/0015_user_brute_force_protection.sql +29 -0
- package/dist/migrations/postgresql/0016_email_template_attachments.sql +12 -0
- package/dist/migrations/postgresql/0017_media_uploaded_by_nullable.sql +15 -0
- package/dist/migrations/postgresql/20260429_000000_000_initial_journal.sql +24 -0
- package/dist/migrations/postgresql/20260501_000000_journal_batch.sql +17 -0
- package/dist/migrations/postgresql/20260501_000001_audit_log.sql +24 -0
- package/dist/migrations/postgresql/20260504_000000_nextly_meta.sql +22 -0
- package/dist/migrations/postgresql/meta/0000_snapshot.json +1286 -0
- package/dist/migrations/postgresql/meta/0001_snapshot.json +1407 -0
- package/dist/migrations/postgresql/meta/0002_snapshot.json +1552 -0
- package/dist/migrations/postgresql/meta/0003_snapshot.json +1695 -0
- package/dist/migrations/postgresql/meta/0010_snapshot.json +2345 -0
- package/dist/migrations/postgresql/meta/_journal.json +90 -0
- package/dist/migrations/sqlite/0000_api_keys.sql +34 -0
- package/dist/migrations/sqlite/0001_general_settings.sql +20 -0
- package/dist/migrations/sqlite/0002_site_settings_logo_url.sql +9 -0
- package/dist/migrations/sqlite/0003_activity_log.sql +29 -0
- package/dist/migrations/sqlite/0004_image_sizes_and_focal_point.sql +29 -0
- package/dist/migrations/sqlite/0004_site_settings_sidebar.sql +11 -0
- package/dist/migrations/sqlite/0005_user_brute_force_protection.sql +29 -0
- package/dist/migrations/sqlite/0006_email_template_attachments.sql +12 -0
- package/dist/migrations/sqlite/0007_media_uploaded_by_nullable.sql +111 -0
- package/dist/migrations/sqlite/20260429_000000_000_initial_journal.sql +24 -0
- package/dist/migrations/sqlite/20260501_000000_journal_batch.sql +19 -0
- package/dist/migrations/sqlite/20260501_000001_audit_log.sql +24 -0
- package/dist/migrations/sqlite/20260504_000000_nextly_meta.sql +21 -0
- package/dist/migrations/sqlite/20260505_000000_user_management_tables.sql +77 -0
- package/dist/next.d.ts +57 -0
- package/dist/next.mjs +55 -0
- package/dist/observability/index.d.ts +87 -0
- package/dist/observability/index.mjs +57 -0
- package/dist/permissions-3DZZQZMI.mjs +39 -0
- package/dist/pipeline-YOML7SWF.mjs +29 -0
- package/dist/preview-ZZTR3QGS.mjs +9 -0
- package/dist/program-PW6UB2ZC.mjs +5934 -0
- package/dist/reconcile-single-tables-7ENVXJGB.mjs +7 -0
- package/dist/register-SF6E6FVU.mjs +49 -0
- package/dist/reload-config-HWQ4G5MM.mjs +23 -0
- package/dist/resolve-single-table-name-JSOMUB3R.mjs +7 -0
- package/dist/routeHandler-UNMMJIBM.mjs +77 -0
- package/dist/runtime-schema-generator-NRA6A6Z6.mjs +8 -0
- package/dist/runtime.d.ts +120 -0
- package/dist/runtime.mjs +73 -0
- package/dist/schema-hash-FMMG6VPJ.mjs +13 -0
- package/dist/schema-registry-EQ36FZDP.mjs +7 -0
- package/dist/scripts/load-env.mjs +42 -0
- package/dist/storage/index.d.ts +566 -0
- package/dist/storage/index.mjs +45 -0
- package/dist/super-admin-G5ZK5F4T.mjs +39 -0
- package/dist/system-table-service-WGSRVEGT.mjs +17 -0
- package/dist/users-7KELGRYJ.mjs +38 -0
- package/package.json +308 -9
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media Storage Types
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces and types for the unified media storage system.
|
|
5
|
+
* Supports cloud storage adapters via plugins.
|
|
6
|
+
*
|
|
7
|
+
* Storage Backends:
|
|
8
|
+
* - AWS S3 / Cloudflare R2 / MinIO (via @nextlyhq/storage-s3)
|
|
9
|
+
* - Vercel Blob (via @nextlyhq/storage-vercel-blob)
|
|
10
|
+
*/
|
|
11
|
+
interface UploadOptions {
|
|
12
|
+
/** Original filename from user */
|
|
13
|
+
filename: string;
|
|
14
|
+
/** MIME type (e.g., 'image/png', 'video/mp4') */
|
|
15
|
+
mimeType: string;
|
|
16
|
+
/** Optional content type override */
|
|
17
|
+
contentType?: string;
|
|
18
|
+
/** Optional folder/prefix for organizing uploads */
|
|
19
|
+
folder?: string;
|
|
20
|
+
/** Collection slug this upload belongs to (for collection-specific storage) */
|
|
21
|
+
collection?: string;
|
|
22
|
+
/** Optional Content-Disposition header value (e.g., 'attachment' for SVG security) */
|
|
23
|
+
contentDisposition?: "inline" | "attachment";
|
|
24
|
+
}
|
|
25
|
+
interface UploadResult {
|
|
26
|
+
/** Public URL to access the file */
|
|
27
|
+
url: string;
|
|
28
|
+
/** Storage path/key (for deletion and metadata retrieval) */
|
|
29
|
+
path: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extended file metadata returned by getMetadata()
|
|
33
|
+
*
|
|
34
|
+
* Contains comprehensive information about an uploaded file,
|
|
35
|
+
* including dimensions for images and creation timestamps.
|
|
36
|
+
*/
|
|
37
|
+
interface FileMetadata {
|
|
38
|
+
/** Unique identifier (typically the storage path/key) */
|
|
39
|
+
id: string;
|
|
40
|
+
/** Storage filename (may differ from original) */
|
|
41
|
+
filename: string;
|
|
42
|
+
/** Original filename as uploaded by user */
|
|
43
|
+
originalFilename: string;
|
|
44
|
+
/** MIME type (e.g., 'image/jpeg', 'application/pdf') */
|
|
45
|
+
mimeType: string;
|
|
46
|
+
/** File size in bytes */
|
|
47
|
+
size: number;
|
|
48
|
+
/** Public URL to access the file */
|
|
49
|
+
url: string;
|
|
50
|
+
/** Thumbnail URL for images (if generated) */
|
|
51
|
+
thumbnailUrl?: string;
|
|
52
|
+
/** Image width in pixels (for images only) */
|
|
53
|
+
width?: number;
|
|
54
|
+
/** Image height in pixels (for images only) */
|
|
55
|
+
height?: number;
|
|
56
|
+
/** ISO timestamp when file was uploaded */
|
|
57
|
+
createdAt: string;
|
|
58
|
+
/** ISO timestamp when file was last modified */
|
|
59
|
+
updatedAt?: string;
|
|
60
|
+
}
|
|
61
|
+
interface ImageMetadata {
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
format: string;
|
|
65
|
+
size: number;
|
|
66
|
+
}
|
|
67
|
+
interface ProcessedImage {
|
|
68
|
+
buffer: Buffer;
|
|
69
|
+
metadata: ImageMetadata;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Storage type identifier.
|
|
73
|
+
* - "s3": AWS S3 or S3-compatible services (R2, MinIO, DigitalOcean Spaces)
|
|
74
|
+
* - "vercel-blob": Vercel Blob Storage
|
|
75
|
+
* - "local": Local disk storage (default for development)
|
|
76
|
+
* - "uploadthing": Uploadthing cloud storage
|
|
77
|
+
*/
|
|
78
|
+
type StorageType = "s3" | "vercel-blob" | "local" | "uploadthing";
|
|
79
|
+
/**
|
|
80
|
+
* Information about a storage adapter's capabilities.
|
|
81
|
+
* Returned by adapter.getInfo() method.
|
|
82
|
+
*/
|
|
83
|
+
interface StorageAdapterInfo {
|
|
84
|
+
/** Storage type identifier */
|
|
85
|
+
type: StorageType;
|
|
86
|
+
/** Human-readable adapter name */
|
|
87
|
+
name: string;
|
|
88
|
+
/** Whether this adapter supports signed URLs for private access */
|
|
89
|
+
supportsSignedUrls: boolean;
|
|
90
|
+
/** Whether this adapter supports client-side (direct) uploads */
|
|
91
|
+
supportsClientUploads: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Per-collection storage configuration.
|
|
95
|
+
* Allows customizing storage behavior for specific upload collections.
|
|
96
|
+
*/
|
|
97
|
+
interface CollectionStorageConfig {
|
|
98
|
+
/** Prefix/folder for this collection's uploads */
|
|
99
|
+
prefix?: string;
|
|
100
|
+
/** Enable client-side uploads (for serverless platforms with body size limits) */
|
|
101
|
+
clientUploads?: boolean;
|
|
102
|
+
/** Generate signed URLs for downloads (for private buckets) */
|
|
103
|
+
signedDownloads?: boolean;
|
|
104
|
+
/** Signed URL expiry time in seconds (default: 3600) */
|
|
105
|
+
signedUrlExpiresIn?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Collection storage map - maps collection slugs to their config.
|
|
109
|
+
* Used in storage plugin configuration.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* {
|
|
114
|
+
* media: true, // Use default config
|
|
115
|
+
* 'private-docs': {
|
|
116
|
+
* prefix: 'private/',
|
|
117
|
+
* signedDownloads: true,
|
|
118
|
+
* signedUrlExpiresIn: 900
|
|
119
|
+
* }
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
type CollectionStorageMap = Record<string, boolean | CollectionStorageConfig>;
|
|
124
|
+
/**
|
|
125
|
+
* Base configuration for storage plugins.
|
|
126
|
+
* Extended by specific adapter configs (S3StorageConfig, etc.)
|
|
127
|
+
*/
|
|
128
|
+
interface StoragePluginConfig {
|
|
129
|
+
/** Enable/disable the plugin (default: true) */
|
|
130
|
+
enabled?: boolean;
|
|
131
|
+
/** Collections to apply this storage adapter to */
|
|
132
|
+
collections: CollectionStorageMap;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Storage plugin returned by adapter plugin functions.
|
|
136
|
+
* These are processed during Nextly initialization.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* // From @nextlyhq/storage-s3
|
|
141
|
+
* const plugin = s3Storage({
|
|
142
|
+
* bucket: 'my-bucket',
|
|
143
|
+
* region: 'us-east-1',
|
|
144
|
+
* collections: { media: true }
|
|
145
|
+
* });
|
|
146
|
+
* // plugin implements StoragePlugin
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
interface StoragePlugin {
|
|
150
|
+
/** Plugin name for identification */
|
|
151
|
+
name: string;
|
|
152
|
+
/** Storage type */
|
|
153
|
+
type: StorageType;
|
|
154
|
+
/** Collections this plugin handles */
|
|
155
|
+
collections: CollectionStorageMap;
|
|
156
|
+
/** The storage adapter instance */
|
|
157
|
+
adapter: IStorageAdapter;
|
|
158
|
+
/**
|
|
159
|
+
* Handler for generating client-side upload URLs.
|
|
160
|
+
* Called when clientUploads is enabled for a collection.
|
|
161
|
+
*/
|
|
162
|
+
getClientUploadUrl?: (filename: string, mimeType: string, collection: string) => Promise<ClientUploadData>;
|
|
163
|
+
/**
|
|
164
|
+
* Handler for generating signed download URLs.
|
|
165
|
+
* Called when signedDownloads is enabled for a collection.
|
|
166
|
+
*/
|
|
167
|
+
getSignedDownloadUrl?: (path: string, expiresIn?: number) => Promise<string>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Data returned for client-side (direct) uploads.
|
|
171
|
+
* Contains pre-signed URL and headers for direct-to-storage uploads.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* // Usage in frontend
|
|
176
|
+
* const uploadData = await fetch('/api/nextly/storage/upload-url', {
|
|
177
|
+
* method: 'POST',
|
|
178
|
+
* body: JSON.stringify({ filename: 'photo.jpg', mimeType: 'image/jpeg', collection: 'media' })
|
|
179
|
+
* }).then(r => r.json());
|
|
180
|
+
*
|
|
181
|
+
* // Direct upload to storage
|
|
182
|
+
* await fetch(uploadData.uploadUrl, {
|
|
183
|
+
* method: uploadData.method,
|
|
184
|
+
* headers: uploadData.headers,
|
|
185
|
+
* body: file
|
|
186
|
+
* });
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
interface ClientUploadData {
|
|
190
|
+
/** Pre-signed URL for direct upload */
|
|
191
|
+
uploadUrl: string;
|
|
192
|
+
/** Storage path/key that will be used */
|
|
193
|
+
path: string;
|
|
194
|
+
/** HTTP method to use (usually PUT for S3, POST for some services) */
|
|
195
|
+
method: "PUT" | "POST";
|
|
196
|
+
/** Headers to include in upload request */
|
|
197
|
+
headers?: Record<string, string>;
|
|
198
|
+
/** Form fields for multipart uploads (some services require this) */
|
|
199
|
+
fields?: Record<string, string>;
|
|
200
|
+
/** URL expiry timestamp */
|
|
201
|
+
expiresAt: Date;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Base storage adapter interface.
|
|
205
|
+
* All storage adapters must implement this interface.
|
|
206
|
+
*
|
|
207
|
+
* Core methods (required):
|
|
208
|
+
* - upload: Store file buffer
|
|
209
|
+
* - delete: Remove file from storage
|
|
210
|
+
* - exists: Check if file exists
|
|
211
|
+
* - getPublicUrl: Get public URL for file access
|
|
212
|
+
* - getType: Get storage type identifier
|
|
213
|
+
*
|
|
214
|
+
* Optional methods:
|
|
215
|
+
* - getInfo: Get adapter capabilities (recommended)
|
|
216
|
+
* - getMetadata: Retrieve file metadata
|
|
217
|
+
* - getSignedUrl: Generate temporary signed URLs for private access
|
|
218
|
+
* - getPresignedUploadUrl: Generate pre-signed URL for client uploads
|
|
219
|
+
*/
|
|
220
|
+
interface BulkDeleteResult {
|
|
221
|
+
successful: string[];
|
|
222
|
+
failed: Array<{
|
|
223
|
+
filePath: string;
|
|
224
|
+
error: string;
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
interface IStorageAdapter {
|
|
228
|
+
/** Upload file buffer to storage */
|
|
229
|
+
upload(buffer: Buffer, options: UploadOptions): Promise<UploadResult>;
|
|
230
|
+
/** Delete file from storage */
|
|
231
|
+
delete(filePath: string): Promise<void>;
|
|
232
|
+
/** Bulk delete files from storage. Optional — adapters that support batch operations should implement this. */
|
|
233
|
+
bulkDelete?(filePaths: string[]): Promise<BulkDeleteResult>;
|
|
234
|
+
/** Check if file exists in storage */
|
|
235
|
+
exists(filePath: string): Promise<boolean>;
|
|
236
|
+
/** Get public URL for file */
|
|
237
|
+
getPublicUrl(filePath: string): string;
|
|
238
|
+
/** Get storage type identifier */
|
|
239
|
+
getType(): string;
|
|
240
|
+
/** Read file contents from storage (optional - not all adapters support this) */
|
|
241
|
+
read?(filePath: string): Promise<Buffer | null>;
|
|
242
|
+
/** Get adapter info including capabilities (optional but recommended) */
|
|
243
|
+
getInfo?(): StorageAdapterInfo;
|
|
244
|
+
/** Get file metadata (optional - not all adapters support this) */
|
|
245
|
+
getMetadata?(filePath: string): Promise<FileMetadata | null>;
|
|
246
|
+
/** Generate signed URL for temporary private access (optional) */
|
|
247
|
+
getSignedUrl?(filePath: string, expiresIn?: number): Promise<string>;
|
|
248
|
+
/** Generate pre-signed upload URL for client-side uploads (optional) */
|
|
249
|
+
getPresignedUploadUrl?(key: string, mimeType: string, expiresIn?: number): Promise<ClientUploadData>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Image Processor
|
|
254
|
+
*
|
|
255
|
+
* Uses Sharp for high-performance image processing:
|
|
256
|
+
* - Extract metadata (width, height, format)
|
|
257
|
+
* - Generate thumbnails (300x300, cropped to center)
|
|
258
|
+
* - Optimize images (compression, WebP conversion)
|
|
259
|
+
*
|
|
260
|
+
* Sharp is 4-5x faster than ImageMagick/GraphicsMagick
|
|
261
|
+
*
|
|
262
|
+
* NOTE: Sharp is lazy-loaded to work with Next.js serverExternalPackages
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
declare class ImageProcessor {
|
|
266
|
+
/**
|
|
267
|
+
* Get image metadata without loading full image
|
|
268
|
+
*/
|
|
269
|
+
getMetadata(buffer: Buffer): Promise<ImageMetadata>;
|
|
270
|
+
/**
|
|
271
|
+
* Generate thumbnail (300x300 by default, cropped to center)
|
|
272
|
+
*
|
|
273
|
+
* Uses "cover" fit to fill the entire 300x300 area while maintaining aspect ratio
|
|
274
|
+
*/
|
|
275
|
+
generateThumbnail(buffer: Buffer, size?: number): Promise<ProcessedImage>;
|
|
276
|
+
/**
|
|
277
|
+
* Optimize image (compress, convert to WebP if beneficial)
|
|
278
|
+
*
|
|
279
|
+
* Strategy:
|
|
280
|
+
* - Small images (<100KB) and already WebP: return as-is
|
|
281
|
+
* - Otherwise: convert to WebP with quality 80
|
|
282
|
+
*/
|
|
283
|
+
optimize(buffer: Buffer, quality?: number): Promise<ProcessedImage>;
|
|
284
|
+
/**
|
|
285
|
+
* Resize image to specific dimensions
|
|
286
|
+
*
|
|
287
|
+
* @param maxWidth Maximum width (maintains aspect ratio)
|
|
288
|
+
* @param maxHeight Maximum height (maintains aspect ratio)
|
|
289
|
+
*/
|
|
290
|
+
resize(buffer: Buffer, maxWidth?: number, maxHeight?: number): Promise<ProcessedImage>;
|
|
291
|
+
/**
|
|
292
|
+
* Resize an image with focal point awareness and format conversion.
|
|
293
|
+
*
|
|
294
|
+
* When fit is 'cover' and a focal point is set, the crop anchors at that
|
|
295
|
+
* point instead of center. Supports format conversion ('auto' outputs webp
|
|
296
|
+
* for jpeg/png/tiff sources, keeps original for gif).
|
|
297
|
+
*/
|
|
298
|
+
resizeWithFocalPoint(buffer: Buffer, options: {
|
|
299
|
+
width?: number;
|
|
300
|
+
height?: number;
|
|
301
|
+
fit: "cover" | "inside" | "contain" | "fill";
|
|
302
|
+
quality?: number;
|
|
303
|
+
format?: "auto" | "webp" | "jpeg" | "png" | "avif";
|
|
304
|
+
focalX?: number;
|
|
305
|
+
focalY?: number;
|
|
306
|
+
}): Promise<{
|
|
307
|
+
buffer: Buffer;
|
|
308
|
+
width: number;
|
|
309
|
+
height: number;
|
|
310
|
+
format: string;
|
|
311
|
+
size: number;
|
|
312
|
+
}>;
|
|
313
|
+
/**
|
|
314
|
+
* Check if buffer is a valid image
|
|
315
|
+
*/
|
|
316
|
+
isValidImage(buffer: Buffer): Promise<boolean>;
|
|
317
|
+
/**
|
|
318
|
+
* Get image dimensions quickly (without full processing)
|
|
319
|
+
*/
|
|
320
|
+
getDimensions(buffer: Buffer): Promise<{
|
|
321
|
+
width: number;
|
|
322
|
+
height: number;
|
|
323
|
+
} | null>;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Get singleton ImageProcessor instance
|
|
327
|
+
*/
|
|
328
|
+
declare function getImageProcessor(): ImageProcessor;
|
|
329
|
+
/**
|
|
330
|
+
* Reset processor singleton (for testing)
|
|
331
|
+
*/
|
|
332
|
+
declare function resetImageProcessor(): void;
|
|
333
|
+
|
|
334
|
+
export { ImageProcessor as g, getImageProcessor as i, resetImageProcessor as r };
|
|
335
|
+
export type { BulkDeleteResult as B, CollectionStorageConfig as C, FileMetadata as F, IStorageAdapter as I, ProcessedImage as P, StoragePlugin as S, UploadOptions as U, CollectionStorageMap as a, StoragePluginConfig as b, UploadResult as c, ClientUploadData as d, StorageAdapterInfo as e, ImageMetadata as f, StorageType as h };
|