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,182 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireAuthHeader
|
|
3
|
+
} from "../chunk-WZBYMYVW.mjs";
|
|
4
|
+
import "../chunk-VWF3JO32.mjs";
|
|
5
|
+
import {
|
|
6
|
+
withErrorHandler
|
|
7
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
8
|
+
import {
|
|
9
|
+
getCachedNextly
|
|
10
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
11
|
+
import "../chunk-2OALJTK6.mjs";
|
|
12
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
13
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
14
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
15
|
+
import {
|
|
16
|
+
getService
|
|
17
|
+
} from "../chunk-X7TXCYYN.mjs";
|
|
18
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
19
|
+
import "../chunk-FQULBZ53.mjs";
|
|
20
|
+
import "../chunk-67GXH6PR.mjs";
|
|
21
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
22
|
+
import {
|
|
23
|
+
getNextlyLogger
|
|
24
|
+
} from "../chunk-W4MGXIRR.mjs";
|
|
25
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
26
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
27
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
28
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
29
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
30
|
+
import "../chunk-INV7QKLG.mjs";
|
|
31
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
32
|
+
import "../chunk-SBACDPNX.mjs";
|
|
33
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
34
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
35
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
36
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
37
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
38
|
+
import "../chunk-DNNG377Z.mjs";
|
|
39
|
+
import {
|
|
40
|
+
calculateSchemaHash
|
|
41
|
+
} from "../chunk-5HMZ644B.mjs";
|
|
42
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
43
|
+
import "../chunk-56WO4WX7.mjs";
|
|
44
|
+
import "../chunk-2W3DVD7S.mjs";
|
|
45
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
46
|
+
import "../chunk-H26B4FYG.mjs";
|
|
47
|
+
import "../chunk-DP3G27G5.mjs";
|
|
48
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
49
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
50
|
+
import "../chunk-EGXBZCGC.mjs";
|
|
51
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
52
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
53
|
+
import {
|
|
54
|
+
respondDoc,
|
|
55
|
+
respondMutation
|
|
56
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
57
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
58
|
+
import "../chunk-D5HQBNUB.mjs";
|
|
59
|
+
import {
|
|
60
|
+
NextlyError
|
|
61
|
+
} from "../chunk-NRUWQ5Z7.mjs";
|
|
62
|
+
import "../chunk-VTJADRO3.mjs";
|
|
63
|
+
import "../chunk-5APFUGAD.mjs";
|
|
64
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
65
|
+
|
|
66
|
+
// src/api/singles-schema-detail.ts
|
|
67
|
+
async function getSingleRegistry() {
|
|
68
|
+
await getCachedNextly();
|
|
69
|
+
return getService("singleRegistryService");
|
|
70
|
+
}
|
|
71
|
+
async function getComponentRegistry() {
|
|
72
|
+
await getCachedNextly();
|
|
73
|
+
return getService("componentRegistryService");
|
|
74
|
+
}
|
|
75
|
+
var GET = withErrorHandler(
|
|
76
|
+
async (request, context) => {
|
|
77
|
+
requireAuthHeader(request);
|
|
78
|
+
const { slug } = await context.params;
|
|
79
|
+
const registry = await getSingleRegistry();
|
|
80
|
+
const single = await registry.getSingle(slug);
|
|
81
|
+
let enrichedFields = single.fields;
|
|
82
|
+
try {
|
|
83
|
+
const componentRegistry = await getComponentRegistry();
|
|
84
|
+
enrichedFields = await componentRegistry.enrichFieldsWithComponentSchemas(
|
|
85
|
+
single.fields
|
|
86
|
+
);
|
|
87
|
+
} catch (enrichError) {
|
|
88
|
+
getNextlyLogger().warn({
|
|
89
|
+
kind: "single-schema-enrichment-failed",
|
|
90
|
+
slug,
|
|
91
|
+
err: String(enrichError)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return respondDoc({
|
|
95
|
+
...single,
|
|
96
|
+
fields: enrichedFields
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
var PATCH = withErrorHandler(
|
|
101
|
+
async (request, context) => {
|
|
102
|
+
requireAuthHeader(request);
|
|
103
|
+
const { slug } = await context.params;
|
|
104
|
+
const registry = await getSingleRegistry();
|
|
105
|
+
let body;
|
|
106
|
+
try {
|
|
107
|
+
body = await request.json();
|
|
108
|
+
} catch {
|
|
109
|
+
throw NextlyError.validation({
|
|
110
|
+
errors: [
|
|
111
|
+
{
|
|
112
|
+
path: "",
|
|
113
|
+
code: "invalid_json",
|
|
114
|
+
message: "Request body is not valid JSON."
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const updateData = {};
|
|
120
|
+
if (body.label !== void 0) {
|
|
121
|
+
updateData.label = body.label;
|
|
122
|
+
}
|
|
123
|
+
if (body.description !== void 0) {
|
|
124
|
+
updateData.description = body.description;
|
|
125
|
+
}
|
|
126
|
+
if (body.fields !== void 0) {
|
|
127
|
+
updateData.fields = body.fields;
|
|
128
|
+
updateData.schemaHash = calculateSchemaHash(
|
|
129
|
+
body.fields
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const ADMIN_KEYS = [
|
|
133
|
+
"icon",
|
|
134
|
+
"group",
|
|
135
|
+
"order",
|
|
136
|
+
"sidebarGroup",
|
|
137
|
+
"hidden"
|
|
138
|
+
];
|
|
139
|
+
const adminOverrides = {};
|
|
140
|
+
if (body.admin !== void 0) {
|
|
141
|
+
const admin = body.admin;
|
|
142
|
+
for (const key of ADMIN_KEYS) {
|
|
143
|
+
if (admin[key] !== void 0) {
|
|
144
|
+
adminOverrides[key] = admin[key];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
for (const key of ADMIN_KEYS) {
|
|
149
|
+
if (body[key] !== void 0) {
|
|
150
|
+
adminOverrides[key] = body[key];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (Object.keys(adminOverrides).length > 0) {
|
|
154
|
+
const existing = await registry.getSingle(slug);
|
|
155
|
+
updateData.admin = {
|
|
156
|
+
...existing.admin || {},
|
|
157
|
+
...adminOverrides
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (body.accessRules !== void 0) {
|
|
161
|
+
updateData.accessRules = body.accessRules;
|
|
162
|
+
}
|
|
163
|
+
const updated = await registry.updateSingle(slug, updateData, {
|
|
164
|
+
source: "ui"
|
|
165
|
+
});
|
|
166
|
+
return respondMutation("Single schema updated.", updated);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
var DELETE = withErrorHandler(
|
|
170
|
+
async (request, context) => {
|
|
171
|
+
requireAuthHeader(request);
|
|
172
|
+
const { slug } = await context.params;
|
|
173
|
+
const registry = await getSingleRegistry();
|
|
174
|
+
await registry.deleteSingle(slug, { force: true });
|
|
175
|
+
return new Response(null, { status: 204 });
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
export {
|
|
179
|
+
DELETE,
|
|
180
|
+
GET,
|
|
181
|
+
PATCH
|
|
182
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singles API Route Handlers for Next.js
|
|
3
|
+
*
|
|
4
|
+
* These route handlers can be re-exported in your Next.js application to provide
|
|
5
|
+
* Singles listing endpoints at /api/singles.
|
|
6
|
+
*
|
|
7
|
+
* Services are auto-initialized on first request using environment variables:
|
|
8
|
+
* - DB_DIALECT: Database dialect ("postgresql" | "mysql" | "sqlite")
|
|
9
|
+
* - DATABASE_URL: Database connection string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // In your Next.js app: app/api/singles/route.ts
|
|
14
|
+
* export { GET } from 'nextly/api/singles';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @module api/singles
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* GET handler for listing Singles with pagination and filters.
|
|
21
|
+
*
|
|
22
|
+
* Query Parameters:
|
|
23
|
+
* - source: Filter by source type ("code" | "ui" | "built-in")
|
|
24
|
+
* - search: Search query for slug and labels
|
|
25
|
+
* - limit: Maximum results (default: 50, becomes `meta.limit` in response)
|
|
26
|
+
* - offset: Number of results to skip (default: 0, derives `page` in meta)
|
|
27
|
+
*
|
|
28
|
+
* Response:
|
|
29
|
+
* - 200 OK: `{ "items": [...], "meta": { total, page, limit, totalPages, hasNext, hasPrev } }`
|
|
30
|
+
* - On error: `application/problem+json` per spec §10.1.
|
|
31
|
+
*/
|
|
32
|
+
declare const GET: (request: Request) => Promise<Response>;
|
|
33
|
+
|
|
34
|
+
export { GET };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import "../chunk-VWF3JO32.mjs";
|
|
2
|
+
import {
|
|
3
|
+
withErrorHandler
|
|
4
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
getCachedNextly
|
|
7
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
8
|
+
import "../chunk-2OALJTK6.mjs";
|
|
9
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
10
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
11
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
12
|
+
import {
|
|
13
|
+
getService
|
|
14
|
+
} from "../chunk-X7TXCYYN.mjs";
|
|
15
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
16
|
+
import "../chunk-FQULBZ53.mjs";
|
|
17
|
+
import "../chunk-67GXH6PR.mjs";
|
|
18
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
19
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
20
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
21
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
22
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
23
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
24
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
25
|
+
import "../chunk-INV7QKLG.mjs";
|
|
26
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
27
|
+
import "../chunk-SBACDPNX.mjs";
|
|
28
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
29
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
30
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
31
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
32
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
33
|
+
import "../chunk-DNNG377Z.mjs";
|
|
34
|
+
import "../chunk-5HMZ644B.mjs";
|
|
35
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
36
|
+
import "../chunk-56WO4WX7.mjs";
|
|
37
|
+
import {
|
|
38
|
+
withTimezoneFormatting
|
|
39
|
+
} from "../chunk-2W3DVD7S.mjs";
|
|
40
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
41
|
+
import "../chunk-H26B4FYG.mjs";
|
|
42
|
+
import "../chunk-DP3G27G5.mjs";
|
|
43
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
44
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
45
|
+
import "../chunk-EGXBZCGC.mjs";
|
|
46
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
47
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
48
|
+
import {
|
|
49
|
+
respondList
|
|
50
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
51
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
52
|
+
import "../chunk-D5HQBNUB.mjs";
|
|
53
|
+
import "../chunk-NRUWQ5Z7.mjs";
|
|
54
|
+
import "../chunk-VTJADRO3.mjs";
|
|
55
|
+
import "../chunk-5APFUGAD.mjs";
|
|
56
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
57
|
+
|
|
58
|
+
// src/api/singles.ts
|
|
59
|
+
async function getSingleRegistry() {
|
|
60
|
+
await getCachedNextly();
|
|
61
|
+
return getService("singleRegistryService");
|
|
62
|
+
}
|
|
63
|
+
var GET = withErrorHandler(
|
|
64
|
+
async (request) => {
|
|
65
|
+
const registry = await getSingleRegistry();
|
|
66
|
+
const { searchParams } = new URL(request.url);
|
|
67
|
+
const source = searchParams.get("source");
|
|
68
|
+
const search = searchParams.get("search") || void 0;
|
|
69
|
+
const limit = searchParams.get("limit") ? parseInt(searchParams.get("limit"), 10) : 50;
|
|
70
|
+
const offset = searchParams.get("offset") ? parseInt(searchParams.get("offset"), 10) : 0;
|
|
71
|
+
const result = await registry.listSingles({
|
|
72
|
+
source: source || void 0,
|
|
73
|
+
search,
|
|
74
|
+
limit,
|
|
75
|
+
offset
|
|
76
|
+
});
|
|
77
|
+
const safeLimit = Math.max(1, limit);
|
|
78
|
+
const page = Math.floor(offset / safeLimit) + 1;
|
|
79
|
+
const totalPages = Math.ceil(result.total / safeLimit);
|
|
80
|
+
return withTimezoneFormatting(
|
|
81
|
+
respondList(result.data, {
|
|
82
|
+
total: result.total,
|
|
83
|
+
page,
|
|
84
|
+
limit: safeLimit,
|
|
85
|
+
totalPages,
|
|
86
|
+
hasNext: page < totalPages,
|
|
87
|
+
hasPrev: page > 1
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
export {
|
|
93
|
+
GET
|
|
94
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Upload URL API Route Handler
|
|
3
|
+
*
|
|
4
|
+
* Provides an endpoint for generating pre-signed URLs for client-side uploads.
|
|
5
|
+
* This allows direct-to-storage uploads that bypass serverless platform limits
|
|
6
|
+
* (e.g., Vercel's 4.5MB request body limit).
|
|
7
|
+
*
|
|
8
|
+
* Only available when:
|
|
9
|
+
* 1. A storage plugin (S3, etc.) is configured for the collection
|
|
10
|
+
* 2. The collection has `clientUploads: true` in its config
|
|
11
|
+
* 3. The storage adapter supports pre-signed upload URLs
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // In your Next.js app: app/api/nextly/storage/upload-url/route.ts
|
|
16
|
+
* export { POST } from 'nextly/api/storage-upload-url';
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Adapter-specific failures (no plugin, `clientUploads` not enabled,
|
|
20
|
+
* Vercel-Blob `handleUpload` style adapters) collapse to canonical
|
|
21
|
+
* `NextlyError.validation` shapes; per spec §13.8 the public messages
|
|
22
|
+
* carry no collection-slug identifier and the slug lives in `logContext`.
|
|
23
|
+
*
|
|
24
|
+
* @module api/storage-upload-url
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* POST handler for generating client upload URLs.
|
|
28
|
+
*
|
|
29
|
+
* Path: /api/nextly/storage/upload-url
|
|
30
|
+
*
|
|
31
|
+
* Request Body (JSON):
|
|
32
|
+
* - filename: string - Original filename
|
|
33
|
+
* - mimeType: string - File MIME type
|
|
34
|
+
* - collection: string - Collection slug
|
|
35
|
+
* - expiresIn?: number - Optional URL expiry in seconds
|
|
36
|
+
*
|
|
37
|
+
* Response Codes:
|
|
38
|
+
* - 200 OK: Upload URL generated successfully
|
|
39
|
+
* - 400 Bad Request: Invalid input or client uploads not enabled
|
|
40
|
+
* - 500 Internal Server Error: URL generation failed
|
|
41
|
+
*
|
|
42
|
+
* Response: bare `ClientUploadData` (respondData); see the
|
|
43
|
+
* `ClientUploadData` type for the field shape (`uploadUrl`, `path`,
|
|
44
|
+
* `method`, `headers`, `expiresAt`).
|
|
45
|
+
*/
|
|
46
|
+
declare const POST: (request: Request) => Promise<Response>;
|
|
47
|
+
|
|
48
|
+
export { POST };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nextlyValidationFromZod
|
|
3
|
+
} from "../chunk-GJNSJU4S.mjs";
|
|
4
|
+
import {
|
|
5
|
+
withErrorHandler
|
|
6
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
getCachedNextly
|
|
9
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
10
|
+
import "../chunk-2OALJTK6.mjs";
|
|
11
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
12
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
13
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
14
|
+
import "../chunk-X7TXCYYN.mjs";
|
|
15
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
16
|
+
import "../chunk-FQULBZ53.mjs";
|
|
17
|
+
import "../chunk-67GXH6PR.mjs";
|
|
18
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
19
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
20
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
21
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
22
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
23
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
24
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
25
|
+
import "../chunk-INV7QKLG.mjs";
|
|
26
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
27
|
+
import "../chunk-SBACDPNX.mjs";
|
|
28
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
29
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
30
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
31
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
32
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
33
|
+
import "../chunk-DNNG377Z.mjs";
|
|
34
|
+
import "../chunk-5HMZ644B.mjs";
|
|
35
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
36
|
+
import "../chunk-56WO4WX7.mjs";
|
|
37
|
+
import "../chunk-2W3DVD7S.mjs";
|
|
38
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
39
|
+
import "../chunk-H26B4FYG.mjs";
|
|
40
|
+
import "../chunk-DP3G27G5.mjs";
|
|
41
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
42
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
43
|
+
import {
|
|
44
|
+
getMediaStorage
|
|
45
|
+
} from "../chunk-EGXBZCGC.mjs";
|
|
46
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
47
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
48
|
+
import {
|
|
49
|
+
respondData
|
|
50
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
51
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
52
|
+
import "../chunk-D5HQBNUB.mjs";
|
|
53
|
+
import {
|
|
54
|
+
NextlyError
|
|
55
|
+
} from "../chunk-NRUWQ5Z7.mjs";
|
|
56
|
+
import "../chunk-VTJADRO3.mjs";
|
|
57
|
+
import "../chunk-5APFUGAD.mjs";
|
|
58
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
59
|
+
|
|
60
|
+
// src/api/storage-upload-url.ts
|
|
61
|
+
import { z } from "zod";
|
|
62
|
+
async function ensureServicesInitialized() {
|
|
63
|
+
await getCachedNextly();
|
|
64
|
+
}
|
|
65
|
+
var uploadUrlRequestSchema = z.object({
|
|
66
|
+
filename: z.string().min(1, "filename is required"),
|
|
67
|
+
mimeType: z.string().min(1, "mimeType is required"),
|
|
68
|
+
collection: z.string().min(1, "collection is required"),
|
|
69
|
+
expiresIn: z.number().int().positive().optional()
|
|
70
|
+
});
|
|
71
|
+
var POST = withErrorHandler(
|
|
72
|
+
async (request) => {
|
|
73
|
+
await ensureServicesInitialized();
|
|
74
|
+
let raw;
|
|
75
|
+
try {
|
|
76
|
+
raw = await request.json();
|
|
77
|
+
} catch {
|
|
78
|
+
throw new NextlyError({
|
|
79
|
+
code: "VALIDATION_ERROR",
|
|
80
|
+
publicMessage: "Validation failed.",
|
|
81
|
+
publicData: {
|
|
82
|
+
errors: [
|
|
83
|
+
{
|
|
84
|
+
path: "",
|
|
85
|
+
code: "invalid_json",
|
|
86
|
+
message: "Request body is not valid JSON."
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
logContext: { reason: "invalid-json-body" }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
let validated;
|
|
94
|
+
try {
|
|
95
|
+
validated = uploadUrlRequestSchema.parse(raw);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
if (err instanceof z.ZodError) throw nextlyValidationFromZod(err);
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
const { filename, mimeType, collection } = validated;
|
|
101
|
+
const storage = getMediaStorage();
|
|
102
|
+
if (!storage.supportsClientUploads(collection)) {
|
|
103
|
+
const config = storage.getCollectionConfig(collection);
|
|
104
|
+
const adapter = storage.getAdapterForCollection(collection);
|
|
105
|
+
const adapterInfo = adapter.getInfo?.();
|
|
106
|
+
const baseLogContext = {
|
|
107
|
+
collection,
|
|
108
|
+
adapterType: adapterInfo?.type
|
|
109
|
+
};
|
|
110
|
+
if (!config) {
|
|
111
|
+
throw NextlyError.validation({
|
|
112
|
+
errors: [
|
|
113
|
+
{
|
|
114
|
+
path: "collection",
|
|
115
|
+
code: "STORAGE_NOT_CONFIGURED",
|
|
116
|
+
message: "This collection is not configured with a storage plugin."
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
logContext: { ...baseLogContext, reason: "no-storage-plugin" }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (!config.clientUploads) {
|
|
123
|
+
throw NextlyError.validation({
|
|
124
|
+
errors: [
|
|
125
|
+
{
|
|
126
|
+
path: "collection",
|
|
127
|
+
code: "CLIENT_UPLOADS_DISABLED",
|
|
128
|
+
message: "Client uploads are not enabled for this collection."
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
logContext: {
|
|
132
|
+
...baseLogContext,
|
|
133
|
+
reason: "clientUploads-not-enabled"
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (!adapterInfo?.supportsClientUploads) {
|
|
138
|
+
throw NextlyError.validation({
|
|
139
|
+
errors: [
|
|
140
|
+
{
|
|
141
|
+
path: "collection",
|
|
142
|
+
code: "ADAPTER_UNSUPPORTED",
|
|
143
|
+
message: "The configured storage adapter does not support client uploads."
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
logContext: {
|
|
147
|
+
...baseLogContext,
|
|
148
|
+
reason: "adapter-unsupported"
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
throw NextlyError.validation({
|
|
153
|
+
errors: [
|
|
154
|
+
{
|
|
155
|
+
path: "collection",
|
|
156
|
+
code: "CLIENT_UPLOADS_DISABLED",
|
|
157
|
+
message: "Client uploads are not enabled for this collection."
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
logContext: { ...baseLogContext, reason: "unknown" }
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
let uploadData;
|
|
164
|
+
try {
|
|
165
|
+
uploadData = await storage.getClientUploadUrl(
|
|
166
|
+
filename,
|
|
167
|
+
mimeType,
|
|
168
|
+
collection
|
|
169
|
+
);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
if (err instanceof Error && err.message.toLowerCase().includes("handleupload")) {
|
|
172
|
+
throw NextlyError.validation({
|
|
173
|
+
errors: [
|
|
174
|
+
{
|
|
175
|
+
path: "collection",
|
|
176
|
+
code: "ADAPTER_UNSUPPORTED",
|
|
177
|
+
message: "This storage provider does not support pre-signed upload URLs. Use the standard upload endpoint instead."
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
logContext: {
|
|
181
|
+
collection,
|
|
182
|
+
reason: "adapter-no-presigned-urls",
|
|
183
|
+
cause: err.message
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
throw err;
|
|
188
|
+
}
|
|
189
|
+
if (!uploadData) {
|
|
190
|
+
throw NextlyError.internal({
|
|
191
|
+
logContext: {
|
|
192
|
+
collection,
|
|
193
|
+
reason: "presigned-url-generation-returned-null"
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return respondData(uploadData);
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
export {
|
|
201
|
+
POST
|
|
202
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload API Route Handlers for Next.js
|
|
3
|
+
*
|
|
4
|
+
* These route handlers provide collection-specific upload endpoints for the
|
|
5
|
+
* Nextly admin panel. They can be re-exported in your Next.js application
|
|
6
|
+
* to provide file upload functionality at /admin/api/collections/[slug]/uploads.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the global Media API (/api/media), these endpoints are designed for
|
|
9
|
+
* collection upload fields where files belong to specific collections.
|
|
10
|
+
*
|
|
11
|
+
* **IMPORTANT:** For storage plugins to work, initialize Nextly with your config
|
|
12
|
+
* via instrumentation.ts before these routes are called.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // In your Next.js app: app/admin/api/collections/[slug]/uploads/route.ts
|
|
17
|
+
* export { POST, GET as LIST } from 'nextly/api/uploads';
|
|
18
|
+
*
|
|
19
|
+
* // In your Next.js app: app/admin/api/collections/[slug]/uploads/[id]/route.ts
|
|
20
|
+
* export { GET, DELETE } from 'nextly/api/uploads';
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Endpoints:
|
|
24
|
+
* - POST /admin/api/collections/[slug]/uploads - Upload file to collection
|
|
25
|
+
* - GET /admin/api/collections/[slug]/uploads - List uploads for collection
|
|
26
|
+
* - GET /admin/api/collections/[slug]/uploads/[id] - Get upload metadata
|
|
27
|
+
* - DELETE /admin/api/collections/[slug]/uploads/[id] - Delete upload
|
|
28
|
+
*
|
|
29
|
+
* `UploadServiceResult` (a result-shape, not a throw) is unwrapped via
|
|
30
|
+
* `throwFromUploadResult`: 404 to `NextlyError.notFound`, 400 to
|
|
31
|
+
* `NextlyError.validation` with field-level errors, 503 to
|
|
32
|
+
* `NextlyError.serviceUnavailable`, anything else to `NextlyError.internal`.
|
|
33
|
+
*
|
|
34
|
+
* @module api/uploads
|
|
35
|
+
*/
|
|
36
|
+
/** Re-exported for tests that exercise the singleton lifecycle. */
|
|
37
|
+
declare function resetUploadService(): void;
|
|
38
|
+
/**
|
|
39
|
+
* POST handler for uploading files to a collection.
|
|
40
|
+
*
|
|
41
|
+
* Path: /admin/api/collections/[slug]/uploads
|
|
42
|
+
*
|
|
43
|
+
* Accepts multipart/form-data with:
|
|
44
|
+
* - file: File to upload (required)
|
|
45
|
+
* - _payload: JSON string with additional data (optional)
|
|
46
|
+
*
|
|
47
|
+
* Response Codes:
|
|
48
|
+
* - 201 Created: File uploaded successfully
|
|
49
|
+
* - 400 Bad Request: Invalid input or missing file
|
|
50
|
+
* - 401 Unauthorized: Not authenticated
|
|
51
|
+
* - 500 Internal Server Error: Upload failed
|
|
52
|
+
*
|
|
53
|
+
* Response: `{ message, item: UploadResult }` (respondMutation, status 201)
|
|
54
|
+
* post-processed through `withTimezoneFormatting`.
|
|
55
|
+
*/
|
|
56
|
+
declare const POST: (request: Request, context: {
|
|
57
|
+
params: Promise<{
|
|
58
|
+
slug?: string;
|
|
59
|
+
}>;
|
|
60
|
+
}) => Promise<Response>;
|
|
61
|
+
/**
|
|
62
|
+
* GET handler — dual-purpose: with `id` returns metadata for a single
|
|
63
|
+
* upload; without `id` returns the (currently empty) collection list.
|
|
64
|
+
*
|
|
65
|
+
* Path: /admin/api/collections/[slug]/uploads/[id]
|
|
66
|
+
*
|
|
67
|
+
* Response Codes:
|
|
68
|
+
* - 200 OK: Metadata retrieved successfully
|
|
69
|
+
* - 400 Bad Request: Missing collection slug or upload ID
|
|
70
|
+
* - 404 Not Found: Upload not found
|
|
71
|
+
* - 500 Internal Server Error: Failed to get metadata
|
|
72
|
+
*
|
|
73
|
+
* Response: bare `UploadMetadata` (respondDoc) for single; for list see
|
|
74
|
+
* `handleList` (paginated `respondList` shape).
|
|
75
|
+
*/
|
|
76
|
+
declare const GET: (request: Request, context: {
|
|
77
|
+
params: Promise<{
|
|
78
|
+
slug?: string;
|
|
79
|
+
id?: string;
|
|
80
|
+
}>;
|
|
81
|
+
}) => Promise<Response>;
|
|
82
|
+
/**
|
|
83
|
+
* DELETE handler for removing an upload.
|
|
84
|
+
*
|
|
85
|
+
* Path: /admin/api/collections/[slug]/uploads/[id]
|
|
86
|
+
*
|
|
87
|
+
* Response Codes:
|
|
88
|
+
* - 200 OK: Upload deleted successfully
|
|
89
|
+
* - 400 Bad Request: Missing collection slug or upload ID
|
|
90
|
+
* - 404 Not Found: Upload not found
|
|
91
|
+
* - 500 Internal Server Error: Deletion failed
|
|
92
|
+
*
|
|
93
|
+
* Response: `{ message, id }` (respondAction; storage delete returns void).
|
|
94
|
+
*/
|
|
95
|
+
declare const DELETE: (_request: Request, context: {
|
|
96
|
+
params: Promise<{
|
|
97
|
+
slug?: string;
|
|
98
|
+
id?: string;
|
|
99
|
+
}>;
|
|
100
|
+
}) => Promise<Response>;
|
|
101
|
+
/** Alias for GET when used for listing (semantic export). */
|
|
102
|
+
declare const LIST: (request: Request, context: {
|
|
103
|
+
params: Promise<{
|
|
104
|
+
slug?: string;
|
|
105
|
+
id?: string;
|
|
106
|
+
}>;
|
|
107
|
+
}) => Promise<Response>;
|
|
108
|
+
|
|
109
|
+
export { DELETE, GET, LIST, POST, resetUploadService };
|