nextly 0.0.1 → 0.0.2-alpha.1
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,117 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Media Types and Schemas
|
|
5
|
+
*
|
|
6
|
+
* Type-safe definitions for media management with Zod validation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Metadata for a single generated image size variant.
|
|
11
|
+
* Stored in the media.sizes JSONB field, keyed by size name.
|
|
12
|
+
*/
|
|
13
|
+
interface ImageSizeVariant {
|
|
14
|
+
url: string;
|
|
15
|
+
path: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
filesize: number;
|
|
19
|
+
mimeType: string;
|
|
20
|
+
filename: string;
|
|
21
|
+
}
|
|
22
|
+
declare const MediaSchema: z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
filename: z.ZodString;
|
|
25
|
+
originalFilename: z.ZodString;
|
|
26
|
+
mimeType: z.ZodString;
|
|
27
|
+
size: z.ZodNumber;
|
|
28
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
29
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
30
|
+
duration: z.ZodNullable<z.ZodNumber>;
|
|
31
|
+
url: z.ZodString;
|
|
32
|
+
thumbnailUrl: z.ZodNullable<z.ZodString>;
|
|
33
|
+
focalX: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
focalY: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
35
|
+
sizes: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
36
|
+
url: z.ZodString;
|
|
37
|
+
path: z.ZodString;
|
|
38
|
+
width: z.ZodNumber;
|
|
39
|
+
height: z.ZodNumber;
|
|
40
|
+
filesize: z.ZodNumber;
|
|
41
|
+
mimeType: z.ZodString;
|
|
42
|
+
filename: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>>>;
|
|
44
|
+
altText: z.ZodNullable<z.ZodString>;
|
|
45
|
+
caption: z.ZodNullable<z.ZodString>;
|
|
46
|
+
tags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
47
|
+
folderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
uploadedBy: z.ZodNullable<z.ZodString>;
|
|
49
|
+
uploadedAt: z.ZodDate;
|
|
50
|
+
updatedAt: z.ZodDate;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
type Media = z.infer<typeof MediaSchema>;
|
|
53
|
+
declare const UploadMediaInputSchema: z.ZodObject<{
|
|
54
|
+
file: z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>;
|
|
55
|
+
filename: z.ZodString;
|
|
56
|
+
mimeType: z.ZodString;
|
|
57
|
+
size: z.ZodNumber;
|
|
58
|
+
uploadedBy: z.ZodNullable<z.ZodString>;
|
|
59
|
+
folderId: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
type UploadMediaInput = z.infer<typeof UploadMediaInputSchema>;
|
|
62
|
+
declare const UpdateMediaInputSchema: z.ZodObject<{
|
|
63
|
+
altText: z.ZodOptional<z.ZodString>;
|
|
64
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
65
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
|
+
focalX: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
focalY: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
type UpdateMediaInput = z.infer<typeof UpdateMediaInputSchema>;
|
|
70
|
+
declare const MediaParamsSchema: z.ZodObject<{
|
|
71
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
72
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
search: z.ZodOptional<z.ZodString>;
|
|
74
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
video: "video";
|
|
76
|
+
image: "image";
|
|
77
|
+
audio: "audio";
|
|
78
|
+
document: "document";
|
|
79
|
+
other: "other";
|
|
80
|
+
}>>;
|
|
81
|
+
folderId: z.ZodOptional<z.ZodString>;
|
|
82
|
+
sortBy: z.ZodDefault<z.ZodEnum<{
|
|
83
|
+
filename: "filename";
|
|
84
|
+
size: "size";
|
|
85
|
+
uploadedAt: "uploadedAt";
|
|
86
|
+
}>>;
|
|
87
|
+
sortOrder: z.ZodDefault<z.ZodEnum<{
|
|
88
|
+
asc: "asc";
|
|
89
|
+
desc: "desc";
|
|
90
|
+
}>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
type MediaParams = z.infer<typeof MediaParamsSchema>;
|
|
93
|
+
interface MediaListResponse {
|
|
94
|
+
success: boolean;
|
|
95
|
+
statusCode: number;
|
|
96
|
+
message: string;
|
|
97
|
+
data: Media[] | null;
|
|
98
|
+
meta?: {
|
|
99
|
+
total: number;
|
|
100
|
+
page: number;
|
|
101
|
+
limit: number;
|
|
102
|
+
totalPages: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
interface MediaResponse {
|
|
106
|
+
success: boolean;
|
|
107
|
+
statusCode: number;
|
|
108
|
+
message: string;
|
|
109
|
+
data: Media | null;
|
|
110
|
+
}
|
|
111
|
+
interface DeleteMediaResponse {
|
|
112
|
+
success: boolean;
|
|
113
|
+
statusCode: number;
|
|
114
|
+
message: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type { DeleteMediaResponse as D, ImageSizeVariant as I, Media as M, UploadMediaInput as U, MediaParams as a, MediaListResponse as b, MediaResponse as c, UpdateMediaInput as d };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { NextlyError } from '../errors/index.d.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Observability hook fired by withErrorHandler / withAction / instrumentation
|
|
5
|
+
* after a NextlyError has been classified and logged.
|
|
6
|
+
*
|
|
7
|
+
* Intended for plugging Sentry, Datadog, Better Stack, or OpenTelemetry. The
|
|
8
|
+
* hook receives the NextlyError plus a discriminated context describing the
|
|
9
|
+
* boundary that caught it.
|
|
10
|
+
*
|
|
11
|
+
* Hook implementations run in try/catch so a failing hook never poisons the
|
|
12
|
+
* response or action result.
|
|
13
|
+
*/
|
|
14
|
+
type OnErrorHook = (err: NextlyError, ctx: {
|
|
15
|
+
kind: "route-handler";
|
|
16
|
+
requestId: string;
|
|
17
|
+
route?: string;
|
|
18
|
+
method?: string;
|
|
19
|
+
request: Request;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "server-action";
|
|
22
|
+
requestId: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "framework";
|
|
25
|
+
requestId: string;
|
|
26
|
+
}) => void | Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Register a process-wide onError hook. Typically called inside
|
|
29
|
+
* `createNextlyInstrumentation({ onError })` from the developer's
|
|
30
|
+
* `app/instrumentation.ts`. A per-call hook on `withErrorHandler` /
|
|
31
|
+
* `withAction` runs before this one for that boundary.
|
|
32
|
+
*/
|
|
33
|
+
declare function setGlobalOnError(hook: OnErrorHook | undefined): void;
|
|
34
|
+
/** The currently registered global onError hook (or undefined). */
|
|
35
|
+
declare function getGlobalOnError(): OnErrorHook | undefined;
|
|
36
|
+
|
|
37
|
+
export { getGlobalOnError as g, setGlobalOnError as s };
|
|
38
|
+
export type { OnErrorHook as O };
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { S as StoragePlugin, I as IStorageAdapter, C as CollectionStorageConfig, U as UploadOptions, c as UploadResult, B as BulkDeleteResult, d as ClientUploadData } from './image-processor.d-OO1PmMrv.d.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unified Media Storage Manager
|
|
5
|
+
*
|
|
6
|
+
* Manages storage adapters and routes uploads to appropriate backends
|
|
7
|
+
* based on collection configuration. Supports:
|
|
8
|
+
* - AWS S3 / Cloudflare R2 / MinIO (via @nextlyhq/storage-s3)
|
|
9
|
+
* - Vercel Blob (via @nextlyhq/storage-vercel-blob)
|
|
10
|
+
* - Collection-specific storage routing
|
|
11
|
+
*
|
|
12
|
+
* @example With Vercel Blob storage (configured in nextly.config.ts)
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { vercelBlobStorage } from '@nextlyhq/storage-vercel-blob';
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* storage: [
|
|
18
|
+
* vercelBlobStorage({
|
|
19
|
+
* collections: { media: true }
|
|
20
|
+
* })
|
|
21
|
+
* ]
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example With S3 storage (configured in nextly.config.ts)
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { s3Storage } from '@nextlyhq/storage-s3';
|
|
28
|
+
*
|
|
29
|
+
* export default defineConfig({
|
|
30
|
+
* storage: [
|
|
31
|
+
* s3Storage({
|
|
32
|
+
* bucket: process.env.S3_BUCKET!,
|
|
33
|
+
* region: process.env.AWS_REGION!,
|
|
34
|
+
* collections: {
|
|
35
|
+
* media: true,
|
|
36
|
+
* 'private-docs': {
|
|
37
|
+
* prefix: 'private/',
|
|
38
|
+
* signedDownloads: true,
|
|
39
|
+
* clientUploads: true
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* })
|
|
43
|
+
* ]
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Configuration for MediaStorage initialization.
|
|
50
|
+
*/
|
|
51
|
+
interface MediaStorageConfig {
|
|
52
|
+
/**
|
|
53
|
+
* Storage plugins from config.
|
|
54
|
+
* Each plugin provides an adapter for specific collections.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* plugins: [
|
|
59
|
+
* s3Storage({ bucket: '...', collections: { media: true } }),
|
|
60
|
+
* vercelBlobStorage({ collections: { videos: true } })
|
|
61
|
+
* ]
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
plugins?: StoragePlugin[];
|
|
65
|
+
/**
|
|
66
|
+
* Local storage configuration.
|
|
67
|
+
* Used as the default fallback when no cloud plugins are configured.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* local: {
|
|
72
|
+
* uploadDir: './public/uploads',
|
|
73
|
+
* publicPath: '/uploads',
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
local?: {
|
|
78
|
+
/** Directory to store uploaded files (default: ./public/uploads) */
|
|
79
|
+
uploadDir?: string;
|
|
80
|
+
/** URL path prefix for serving files (default: /uploads) */
|
|
81
|
+
publicPath?: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Unified Media Storage Manager.
|
|
86
|
+
*
|
|
87
|
+
* Routes uploads to appropriate storage backends based on collection
|
|
88
|
+
* configuration. Supports plugin-based storage adapters for cloud
|
|
89
|
+
* providers (S3, Vercel Blob) with collection-specific routing.
|
|
90
|
+
*
|
|
91
|
+
* Features:
|
|
92
|
+
* - Plugin-based cloud storage (S3, Vercel Blob)
|
|
93
|
+
* - Collection-specific routing
|
|
94
|
+
* - Client-side upload URL generation
|
|
95
|
+
* - Signed download URLs
|
|
96
|
+
*/
|
|
97
|
+
declare class MediaStorage {
|
|
98
|
+
/** Registered storage plugins by name */
|
|
99
|
+
private plugins;
|
|
100
|
+
/** Storage adapter per collection */
|
|
101
|
+
private collectionAdapters;
|
|
102
|
+
/** Storage configuration per collection */
|
|
103
|
+
private collectionConfigs;
|
|
104
|
+
/** Local storage adapter (always available as fallback) */
|
|
105
|
+
private localAdapter;
|
|
106
|
+
/**
|
|
107
|
+
* Create a new MediaStorage instance.
|
|
108
|
+
*
|
|
109
|
+
* @param config - Optional configuration for storage initialization
|
|
110
|
+
*/
|
|
111
|
+
constructor(config?: MediaStorageConfig);
|
|
112
|
+
/**
|
|
113
|
+
* Register a storage plugin.
|
|
114
|
+
*
|
|
115
|
+
* Plugins provide storage adapters for specific collections.
|
|
116
|
+
* When a collection is registered with a plugin, uploads for that
|
|
117
|
+
* collection will be routed to the plugin's adapter.
|
|
118
|
+
*
|
|
119
|
+
* @param plugin - The storage plugin to register
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const storage = new MediaStorage();
|
|
124
|
+
*
|
|
125
|
+
* storage.registerPlugin(s3Storage({
|
|
126
|
+
* bucket: 'my-bucket',
|
|
127
|
+
* region: 'us-east-1',
|
|
128
|
+
* collections: {
|
|
129
|
+
* media: true,
|
|
130
|
+
* 'private-docs': { prefix: 'private/' }
|
|
131
|
+
* }
|
|
132
|
+
* }));
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
registerPlugin(plugin: StoragePlugin): void;
|
|
136
|
+
/**
|
|
137
|
+
* Check if any storage adapter is configured.
|
|
138
|
+
*
|
|
139
|
+
* @returns True if at least one storage plugin is registered
|
|
140
|
+
*/
|
|
141
|
+
hasAdapter(): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Get the storage adapter if available, or null if not configured.
|
|
144
|
+
*
|
|
145
|
+
* Unlike getAdapter(), this method does not throw an error if no storage
|
|
146
|
+
* is configured. Useful for optional storage scenarios.
|
|
147
|
+
*
|
|
148
|
+
* @param collection - The collection slug (optional)
|
|
149
|
+
* @returns The storage adapter instance, or null if not configured
|
|
150
|
+
*/
|
|
151
|
+
getAdapterOrNull(collection?: string): IStorageAdapter | null;
|
|
152
|
+
/**
|
|
153
|
+
* Get the storage adapter for a specific collection.
|
|
154
|
+
*
|
|
155
|
+
* If a plugin is configured for the collection, returns the plugin's adapter.
|
|
156
|
+
* Otherwise, returns the default adapter (first registered plugin).
|
|
157
|
+
*
|
|
158
|
+
* @param collection - The collection slug (optional)
|
|
159
|
+
* @returns The appropriate storage adapter
|
|
160
|
+
* @throws Error if no storage plugin is configured
|
|
161
|
+
*/
|
|
162
|
+
getAdapterForCollection(collection?: string): IStorageAdapter;
|
|
163
|
+
/**
|
|
164
|
+
* Get configuration for a specific collection.
|
|
165
|
+
*
|
|
166
|
+
* @param collection - The collection slug
|
|
167
|
+
* @returns The collection's storage configuration, or undefined
|
|
168
|
+
*/
|
|
169
|
+
getCollectionConfig(collection: string): CollectionStorageConfig | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* Upload file to appropriate storage based on collection.
|
|
172
|
+
*
|
|
173
|
+
* Routes the upload to the correct adapter based on collection
|
|
174
|
+
* configuration. Applies collection-specific prefix if configured.
|
|
175
|
+
*
|
|
176
|
+
* @param buffer - The file buffer to upload
|
|
177
|
+
* @param options - Upload options including filename, mimeType, collection
|
|
178
|
+
* @returns Upload result with URL and path
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const result = await storage.upload(buffer, {
|
|
183
|
+
* filename: 'photo.jpg',
|
|
184
|
+
* mimeType: 'image/jpeg',
|
|
185
|
+
* collection: 'media'
|
|
186
|
+
* });
|
|
187
|
+
* console.log(result.url); // Public URL
|
|
188
|
+
* console.log(result.path); // Storage path for deletion
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
upload(buffer: Buffer, options: UploadOptions): Promise<UploadResult>;
|
|
192
|
+
/**
|
|
193
|
+
* Delete file from storage.
|
|
194
|
+
*
|
|
195
|
+
* Determines correct adapter based on collection.
|
|
196
|
+
*
|
|
197
|
+
* @param filePath - The storage path/key of the file
|
|
198
|
+
* @param collection - The collection slug (optional, for routing)
|
|
199
|
+
*/
|
|
200
|
+
delete(filePath: string, collection?: string): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Bulk delete files from storage.
|
|
203
|
+
* Uses adapter's native bulkDelete if available, otherwise falls back to
|
|
204
|
+
* sequential individual deletes in chunks of 10.
|
|
205
|
+
*/
|
|
206
|
+
bulkDelete(filePaths: string[], collection?: string): Promise<BulkDeleteResult>;
|
|
207
|
+
/**
|
|
208
|
+
* Check if file exists in storage.
|
|
209
|
+
*
|
|
210
|
+
* @param filePath - The storage path/key to check
|
|
211
|
+
* @param collection - The collection slug (optional, for routing)
|
|
212
|
+
* @returns True if file exists
|
|
213
|
+
*/
|
|
214
|
+
exists(filePath: string, collection?: string): Promise<boolean>;
|
|
215
|
+
/**
|
|
216
|
+
* Get public URL for file.
|
|
217
|
+
*
|
|
218
|
+
* @param filePath - The storage path/key
|
|
219
|
+
* @param collection - The collection slug (optional, for routing)
|
|
220
|
+
* @returns Public URL to access the file
|
|
221
|
+
*/
|
|
222
|
+
getPublicUrl(filePath: string, collection?: string): string;
|
|
223
|
+
/**
|
|
224
|
+
* Get storage type for a collection.
|
|
225
|
+
*
|
|
226
|
+
* @param collection - The collection slug (optional)
|
|
227
|
+
* @returns Storage type identifier ('s3', 'vercel-blob')
|
|
228
|
+
*/
|
|
229
|
+
getStorageType(collection?: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Check if collection supports client-side uploads.
|
|
232
|
+
*
|
|
233
|
+
* Client-side uploads allow direct-to-storage uploads, bypassing
|
|
234
|
+
* the server. This is essential for serverless platforms with
|
|
235
|
+
* request body size limits (e.g., Vercel's 4.5MB limit).
|
|
236
|
+
*
|
|
237
|
+
* @param collection - The collection slug
|
|
238
|
+
* @returns True if client uploads are enabled and supported
|
|
239
|
+
*/
|
|
240
|
+
supportsClientUploads(collection: string): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Get client upload URL for direct-to-storage uploads.
|
|
243
|
+
*
|
|
244
|
+
* Generates a pre-signed URL that allows the client to upload
|
|
245
|
+
* directly to the storage backend, bypassing the server.
|
|
246
|
+
*
|
|
247
|
+
* Only available if:
|
|
248
|
+
* 1. Collection is configured with `clientUploads: true`
|
|
249
|
+
* 2. The storage adapter supports client uploads
|
|
250
|
+
*
|
|
251
|
+
* @param filename - Original filename
|
|
252
|
+
* @param mimeType - File MIME type
|
|
253
|
+
* @param collection - Collection slug
|
|
254
|
+
* @returns Client upload data, or null if not supported
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* // Server-side: generate upload URL
|
|
259
|
+
* const uploadData = await storage.getClientUploadUrl(
|
|
260
|
+
* 'photo.jpg',
|
|
261
|
+
* 'image/jpeg',
|
|
262
|
+
* 'media'
|
|
263
|
+
* );
|
|
264
|
+
*
|
|
265
|
+
* // Client-side: upload directly to storage
|
|
266
|
+
* await fetch(uploadData.uploadUrl, {
|
|
267
|
+
* method: uploadData.method,
|
|
268
|
+
* headers: uploadData.headers,
|
|
269
|
+
* body: file
|
|
270
|
+
* });
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
getClientUploadUrl(filename: string, mimeType: string, collection: string): Promise<ClientUploadData | null>;
|
|
274
|
+
/**
|
|
275
|
+
* Check if collection supports signed download URLs.
|
|
276
|
+
*
|
|
277
|
+
* @param collection - The collection slug
|
|
278
|
+
* @returns True if signed downloads are enabled and supported
|
|
279
|
+
*/
|
|
280
|
+
supportsSignedDownloads(collection: string): boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Get signed download URL for secure file access.
|
|
283
|
+
*
|
|
284
|
+
* Generates a time-limited signed URL for accessing files in
|
|
285
|
+
* private storage buckets. Only works if:
|
|
286
|
+
* 1. Collection is configured with `signedDownloads: true`
|
|
287
|
+
* 2. The storage adapter supports signed URLs
|
|
288
|
+
*
|
|
289
|
+
* @param filePath - Storage path/key of the file
|
|
290
|
+
* @param collection - Collection slug
|
|
291
|
+
* @param expiresIn - URL expiry time in seconds (optional)
|
|
292
|
+
* @returns Signed URL, or null if not supported
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* const signedUrl = await storage.getSignedDownloadUrl(
|
|
297
|
+
* 'private/doc.pdf',
|
|
298
|
+
* 'private-docs',
|
|
299
|
+
* 3600 // 1 hour
|
|
300
|
+
* );
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
getSignedDownloadUrl(filePath: string, collection: string, expiresIn?: number): Promise<string | null>;
|
|
304
|
+
/**
|
|
305
|
+
* Get the default storage adapter.
|
|
306
|
+
*
|
|
307
|
+
* @returns The default storage adapter (first registered plugin)
|
|
308
|
+
* @throws Error if no storage plugin is configured
|
|
309
|
+
*/
|
|
310
|
+
getDefaultAdapter(): IStorageAdapter;
|
|
311
|
+
/**
|
|
312
|
+
* Get list of registered plugins.
|
|
313
|
+
*
|
|
314
|
+
* @returns Array of registered storage plugins
|
|
315
|
+
*/
|
|
316
|
+
getPlugins(): StoragePlugin[];
|
|
317
|
+
/**
|
|
318
|
+
* Get the underlying storage adapter for a collection.
|
|
319
|
+
*
|
|
320
|
+
* Useful for passing to registerServices() which requires IStorageAdapter.
|
|
321
|
+
*
|
|
322
|
+
* @param collection - The collection slug (optional)
|
|
323
|
+
* @returns The storage adapter instance
|
|
324
|
+
*/
|
|
325
|
+
getAdapter(collection?: string): IStorageAdapter;
|
|
326
|
+
/**
|
|
327
|
+
* Check if a collection has a configured storage adapter.
|
|
328
|
+
*
|
|
329
|
+
* @param collection - The collection slug
|
|
330
|
+
* @returns True if a plugin is configured for this collection
|
|
331
|
+
*/
|
|
332
|
+
hasCollectionAdapter(collection: string): boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Get list of collections with configured storage.
|
|
335
|
+
*
|
|
336
|
+
* @returns Array of collection slugs that have plugin storage
|
|
337
|
+
*/
|
|
338
|
+
getConfiguredCollections(): string[];
|
|
339
|
+
/**
|
|
340
|
+
* Check if any storage plugin is configured.
|
|
341
|
+
*
|
|
342
|
+
* @returns True if at least one storage plugin is registered
|
|
343
|
+
*/
|
|
344
|
+
hasPlugins(): boolean;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Initialize the global MediaStorage instance with plugins.
|
|
348
|
+
*
|
|
349
|
+
* Called during Nextly initialization to set up storage with
|
|
350
|
+
* configured plugins from nextly.config.ts.
|
|
351
|
+
*
|
|
352
|
+
* @param config - Storage configuration with plugins
|
|
353
|
+
* @returns The initialized MediaStorage instance
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```typescript
|
|
357
|
+
* // In Nextly initialization
|
|
358
|
+
* import { initializeMediaStorage } from 'nextly/storage';
|
|
359
|
+
*
|
|
360
|
+
* const storage = initializeMediaStorage({
|
|
361
|
+
* plugins: config.storage, // From nextly.config.ts
|
|
362
|
+
* });
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
declare function initializeMediaStorage(config?: MediaStorageConfig): MediaStorage;
|
|
366
|
+
/**
|
|
367
|
+
* Get the global MediaStorage instance.
|
|
368
|
+
*
|
|
369
|
+
* Returns the initialized MediaStorage singleton. If not yet initialized,
|
|
370
|
+
* creates a new instance without plugins (which will throw errors on upload).
|
|
371
|
+
*
|
|
372
|
+
* @returns The MediaStorage instance
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```typescript
|
|
376
|
+
* import { getMediaStorage } from 'nextly/storage';
|
|
377
|
+
*
|
|
378
|
+
* const storage = getMediaStorage();
|
|
379
|
+
* const result = await storage.upload(buffer, {
|
|
380
|
+
* filename: 'photo.jpg',
|
|
381
|
+
* mimeType: 'image/jpeg',
|
|
382
|
+
* collection: 'media'
|
|
383
|
+
* });
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
declare function getMediaStorage(): MediaStorage;
|
|
387
|
+
/**
|
|
388
|
+
* Reset storage singleton.
|
|
389
|
+
*
|
|
390
|
+
* Clears the cached MediaStorage instance. Useful for testing
|
|
391
|
+
* or when re-initializing with different configuration.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* // In tests
|
|
396
|
+
* beforeEach(() => {
|
|
397
|
+
* resetMediaStorage();
|
|
398
|
+
* });
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
declare function resetMediaStorage(): void;
|
|
402
|
+
|
|
403
|
+
export { MediaStorage as M, getMediaStorage as g, initializeMediaStorage as i, resetMediaStorage as r };
|
|
404
|
+
export type { MediaStorageConfig as a };
|