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,242 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readJsonBody
|
|
3
|
+
} from "../chunk-VQJQHVEV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
nextlyValidationFromZod
|
|
6
|
+
} from "../chunk-GJNSJU4S.mjs";
|
|
7
|
+
import "../chunk-VWF3JO32.mjs";
|
|
8
|
+
import {
|
|
9
|
+
withErrorHandler
|
|
10
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
11
|
+
import {
|
|
12
|
+
getCachedNextly
|
|
13
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
14
|
+
import "../chunk-2OALJTK6.mjs";
|
|
15
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
16
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
17
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
18
|
+
import {
|
|
19
|
+
getService
|
|
20
|
+
} from "../chunk-X7TXCYYN.mjs";
|
|
21
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
22
|
+
import "../chunk-FQULBZ53.mjs";
|
|
23
|
+
import "../chunk-67GXH6PR.mjs";
|
|
24
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
25
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
26
|
+
import {
|
|
27
|
+
UpdateMediaInputSchema,
|
|
28
|
+
UploadMediaInputSchema
|
|
29
|
+
} from "../chunk-NSEFNNU4.mjs";
|
|
30
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
31
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
32
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
33
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
34
|
+
import "../chunk-INV7QKLG.mjs";
|
|
35
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
36
|
+
import "../chunk-SBACDPNX.mjs";
|
|
37
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
38
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
39
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
40
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
41
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
42
|
+
import "../chunk-DNNG377Z.mjs";
|
|
43
|
+
import "../chunk-5HMZ644B.mjs";
|
|
44
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
45
|
+
import "../chunk-56WO4WX7.mjs";
|
|
46
|
+
import {
|
|
47
|
+
withTimezoneFormatting
|
|
48
|
+
} from "../chunk-2W3DVD7S.mjs";
|
|
49
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
50
|
+
import "../chunk-H26B4FYG.mjs";
|
|
51
|
+
import "../chunk-DP3G27G5.mjs";
|
|
52
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
53
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
54
|
+
import "../chunk-EGXBZCGC.mjs";
|
|
55
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
56
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
57
|
+
import {
|
|
58
|
+
respondAction,
|
|
59
|
+
respondDoc,
|
|
60
|
+
respondList,
|
|
61
|
+
respondMutation
|
|
62
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
63
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
64
|
+
import "../chunk-D5HQBNUB.mjs";
|
|
65
|
+
import {
|
|
66
|
+
NextlyError
|
|
67
|
+
} from "../chunk-NRUWQ5Z7.mjs";
|
|
68
|
+
import "../chunk-VTJADRO3.mjs";
|
|
69
|
+
import "../chunk-5APFUGAD.mjs";
|
|
70
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
71
|
+
|
|
72
|
+
// src/api/media.ts
|
|
73
|
+
import { z } from "zod";
|
|
74
|
+
async function getMediaService() {
|
|
75
|
+
await getCachedNextly();
|
|
76
|
+
return getService("mediaService");
|
|
77
|
+
}
|
|
78
|
+
function createRequestContext() {
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
function createAuthenticatedContext(userId) {
|
|
82
|
+
return {
|
|
83
|
+
user: {
|
|
84
|
+
id: userId,
|
|
85
|
+
email: `${userId}@api.local`,
|
|
86
|
+
role: "user",
|
|
87
|
+
permissions: []
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
var GET = withErrorHandler(
|
|
92
|
+
async (request) => {
|
|
93
|
+
const mediaService = await getMediaService();
|
|
94
|
+
const { searchParams } = new URL(request.url);
|
|
95
|
+
const context = createRequestContext();
|
|
96
|
+
const folderIdParam = searchParams.get("folderId");
|
|
97
|
+
const options = {
|
|
98
|
+
page: searchParams.get("page") ? Number(searchParams.get("page")) : 1,
|
|
99
|
+
limit: searchParams.get("limit") ? Number(searchParams.get("limit")) : 24,
|
|
100
|
+
search: searchParams.get("search") || void 0,
|
|
101
|
+
type: searchParams.get("type") || void 0,
|
|
102
|
+
folderId: folderIdParam === "root" ? "root" : folderIdParam || void 0,
|
|
103
|
+
sortBy: searchParams.get("sortBy") || "uploadedAt",
|
|
104
|
+
sortOrder: searchParams.get("sortOrder") || "desc"
|
|
105
|
+
};
|
|
106
|
+
const result = await mediaService.listMedia(options, context);
|
|
107
|
+
const page = options.page ?? 1;
|
|
108
|
+
const limit = Math.max(1, options.limit ?? 24);
|
|
109
|
+
const total = result.pagination.total;
|
|
110
|
+
const totalPages = limit > 0 ? Math.ceil(total / limit) : 0;
|
|
111
|
+
return withTimezoneFormatting(
|
|
112
|
+
respondList(result.data, {
|
|
113
|
+
total,
|
|
114
|
+
page,
|
|
115
|
+
limit,
|
|
116
|
+
totalPages,
|
|
117
|
+
hasNext: page < totalPages,
|
|
118
|
+
hasPrev: page > 1
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
var POST = withErrorHandler(
|
|
124
|
+
async (request) => {
|
|
125
|
+
const mediaService = await getMediaService();
|
|
126
|
+
const formData = await request.formData();
|
|
127
|
+
const file = formData.get("file");
|
|
128
|
+
const uploadedBy = formData.get("uploadedBy");
|
|
129
|
+
const folderId = formData.get("folderId");
|
|
130
|
+
const errors = [];
|
|
131
|
+
if (!file) {
|
|
132
|
+
errors.push({
|
|
133
|
+
path: "file",
|
|
134
|
+
code: "REQUIRED",
|
|
135
|
+
message: "file is required."
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (!uploadedBy) {
|
|
139
|
+
errors.push({
|
|
140
|
+
path: "uploadedBy",
|
|
141
|
+
code: "REQUIRED",
|
|
142
|
+
message: "uploadedBy is required."
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (errors.length > 0) {
|
|
146
|
+
throw NextlyError.validation({ errors });
|
|
147
|
+
}
|
|
148
|
+
const fileEnsured = file;
|
|
149
|
+
const uploadedByEnsured = uploadedBy;
|
|
150
|
+
const arrayBuffer = await fileEnsured.arrayBuffer();
|
|
151
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
152
|
+
const input = {
|
|
153
|
+
file: buffer,
|
|
154
|
+
filename: fileEnsured.name,
|
|
155
|
+
mimeType: fileEnsured.type,
|
|
156
|
+
size: fileEnsured.size,
|
|
157
|
+
uploadedBy: uploadedByEnsured
|
|
158
|
+
};
|
|
159
|
+
try {
|
|
160
|
+
UploadMediaInputSchema.parse(input);
|
|
161
|
+
} catch (err) {
|
|
162
|
+
if (err instanceof z.ZodError) throw nextlyValidationFromZod(err);
|
|
163
|
+
throw err;
|
|
164
|
+
}
|
|
165
|
+
const context = createAuthenticatedContext(uploadedByEnsured);
|
|
166
|
+
const mediaFile = await mediaService.upload(
|
|
167
|
+
{
|
|
168
|
+
buffer,
|
|
169
|
+
filename: fileEnsured.name,
|
|
170
|
+
mimeType: fileEnsured.type,
|
|
171
|
+
size: fileEnsured.size,
|
|
172
|
+
folderId: folderId || void 0
|
|
173
|
+
},
|
|
174
|
+
context
|
|
175
|
+
);
|
|
176
|
+
return withTimezoneFormatting(
|
|
177
|
+
respondMutation("Media uploaded.", mediaFile, { status: 201 })
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
function getMediaById(request, ctx) {
|
|
182
|
+
return withErrorHandler(
|
|
183
|
+
async (_req, routeCtx) => {
|
|
184
|
+
const mediaService = await getMediaService();
|
|
185
|
+
const { id } = await routeCtx.params;
|
|
186
|
+
const context = createRequestContext();
|
|
187
|
+
const mediaFile = await mediaService.findById(id, context);
|
|
188
|
+
return withTimezoneFormatting(respondDoc(mediaFile));
|
|
189
|
+
}
|
|
190
|
+
)(request, ctx);
|
|
191
|
+
}
|
|
192
|
+
function updateMedia(request, ctx) {
|
|
193
|
+
return withErrorHandler(
|
|
194
|
+
async (req, routeCtx) => {
|
|
195
|
+
const mediaService = await getMediaService();
|
|
196
|
+
const body = await readJsonBody(req);
|
|
197
|
+
let validated;
|
|
198
|
+
try {
|
|
199
|
+
validated = UpdateMediaInputSchema.parse(body);
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (err instanceof z.ZodError) throw nextlyValidationFromZod(err);
|
|
202
|
+
throw err;
|
|
203
|
+
}
|
|
204
|
+
const { id } = await routeCtx.params;
|
|
205
|
+
const context = createRequestContext();
|
|
206
|
+
const mediaFile = await mediaService.update(id, validated, context);
|
|
207
|
+
return withTimezoneFormatting(respondMutation("Media updated.", mediaFile));
|
|
208
|
+
}
|
|
209
|
+
)(request, ctx);
|
|
210
|
+
}
|
|
211
|
+
function deleteMedia(request, ctx) {
|
|
212
|
+
return withErrorHandler(
|
|
213
|
+
async (_req, routeCtx) => {
|
|
214
|
+
const mediaService = await getMediaService();
|
|
215
|
+
const { id } = await routeCtx.params;
|
|
216
|
+
const context = createRequestContext();
|
|
217
|
+
await mediaService.delete(id, context);
|
|
218
|
+
return respondAction("Media deleted.", { id });
|
|
219
|
+
}
|
|
220
|
+
)(request, ctx);
|
|
221
|
+
}
|
|
222
|
+
function moveMediaToFolder(request, ctx) {
|
|
223
|
+
return withErrorHandler(
|
|
224
|
+
async (req, routeCtx) => {
|
|
225
|
+
const mediaService = await getMediaService();
|
|
226
|
+
const { id } = await routeCtx.params;
|
|
227
|
+
const body = await readJsonBody(req);
|
|
228
|
+
const folderId = body.folderId;
|
|
229
|
+
const context = createRequestContext();
|
|
230
|
+
await mediaService.moveToFolder(id, folderId ?? null, context);
|
|
231
|
+
return respondAction("Media moved.", { id, folderId: folderId ?? null });
|
|
232
|
+
}
|
|
233
|
+
)(request, ctx);
|
|
234
|
+
}
|
|
235
|
+
export {
|
|
236
|
+
GET,
|
|
237
|
+
POST,
|
|
238
|
+
deleteMedia,
|
|
239
|
+
getMediaById,
|
|
240
|
+
moveMediaToFolder,
|
|
241
|
+
updateMedia
|
|
242
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singles Detail API Route Handlers for Next.js
|
|
3
|
+
*
|
|
4
|
+
* These route handlers can be re-exported in your Next.js application to provide
|
|
5
|
+
* individual Single management endpoints at /api/singles/[slug].
|
|
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/[slug]/route.ts
|
|
14
|
+
* export { GET, PATCH } from 'nextly/api/singles-detail';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @module api/singles-detail
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Context object for dynamic route handlers.
|
|
21
|
+
* Next.js 15+ requires params to be a Promise.
|
|
22
|
+
*/
|
|
23
|
+
interface RouteContext {
|
|
24
|
+
params: Promise<{
|
|
25
|
+
slug: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* GET handler for retrieving a Single document by slug.
|
|
30
|
+
*
|
|
31
|
+
* This is a public endpoint - no authentication required.
|
|
32
|
+
* If the Single document doesn't exist, it will be auto-created with default
|
|
33
|
+
* field values.
|
|
34
|
+
*
|
|
35
|
+
* Query Parameters:
|
|
36
|
+
* - depth: Relationship expansion depth (reserved for future use)
|
|
37
|
+
* - locale: Locale for localized fields (reserved for future use)
|
|
38
|
+
* - richTextFormat: Output format for rich text fields ("json" | "html" | "both")
|
|
39
|
+
* - "json" (default): Return Lexical JSON structure only
|
|
40
|
+
* - "html": Return HTML string only
|
|
41
|
+
* - "both": Return object with both { json, html } properties
|
|
42
|
+
*
|
|
43
|
+
* Response:
|
|
44
|
+
* - 200 OK: bare document object (canonical `respondDoc` shape).
|
|
45
|
+
* - On error: `application/problem+json` per spec §10.1.
|
|
46
|
+
*/
|
|
47
|
+
declare const GET: (request: Request, context: RouteContext) => Promise<Response>;
|
|
48
|
+
/**
|
|
49
|
+
* PATCH handler for updating a Single document.
|
|
50
|
+
*
|
|
51
|
+
* Requires authentication. If the Single document doesn't exist,
|
|
52
|
+
* it will be auto-created first, then updated with the provided data.
|
|
53
|
+
*
|
|
54
|
+
* Note: Singles cannot be deleted. They represent persistent site-wide
|
|
55
|
+
* configuration that always exists once accessed.
|
|
56
|
+
*
|
|
57
|
+
* Request Body:
|
|
58
|
+
* - Any fields defined in the Single schema
|
|
59
|
+
* - System fields (id, createdAt) are ignored if included
|
|
60
|
+
*
|
|
61
|
+
* Response:
|
|
62
|
+
* - 200 OK: `{ "message": "...", "item": { ... } }` (updated document).
|
|
63
|
+
* - On error: `application/problem+json` per spec §10.1.
|
|
64
|
+
*/
|
|
65
|
+
declare const PATCH: (request: Request, context: RouteContext) => Promise<Response>;
|
|
66
|
+
/**
|
|
67
|
+
* GET handler for retrieving Single schema/metadata by slug.
|
|
68
|
+
*
|
|
69
|
+
* This endpoint returns the Single's schema configuration, not the document data.
|
|
70
|
+
* Useful for Admin UI to understand the field structure.
|
|
71
|
+
*
|
|
72
|
+
* Requires authentication.
|
|
73
|
+
*
|
|
74
|
+
* Response:
|
|
75
|
+
* - 200 OK: bare schema object (canonical `respondDoc` shape).
|
|
76
|
+
* - 401 / 404 / 500: `application/problem+json` per spec §10.1.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```bash
|
|
80
|
+
* curl -H "Authorization: Bearer <token>" \
|
|
81
|
+
* "http://localhost:3000/api/singles/site-settings/schema"
|
|
82
|
+
* # => {"slug":"site-settings","label":"Site Settings","fields":[...]}
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
declare function getSchema(request: Request, slug: string): Promise<Response>;
|
|
86
|
+
|
|
87
|
+
export { GET, PATCH, getSchema };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireAuthHeader
|
|
3
|
+
} from "../chunk-WZBYMYVW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
readJsonBody
|
|
6
|
+
} from "../chunk-VQJQHVEV.mjs";
|
|
7
|
+
import "../chunk-VWF3JO32.mjs";
|
|
8
|
+
import {
|
|
9
|
+
withErrorHandler
|
|
10
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
11
|
+
import {
|
|
12
|
+
getCachedNextly
|
|
13
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
14
|
+
import "../chunk-2OALJTK6.mjs";
|
|
15
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
16
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
17
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
18
|
+
import {
|
|
19
|
+
getService
|
|
20
|
+
} from "../chunk-X7TXCYYN.mjs";
|
|
21
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
22
|
+
import "../chunk-FQULBZ53.mjs";
|
|
23
|
+
import "../chunk-67GXH6PR.mjs";
|
|
24
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
25
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
26
|
+
import {
|
|
27
|
+
transformRichTextFields
|
|
28
|
+
} from "../chunk-NSEFNNU4.mjs";
|
|
29
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
30
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
31
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
32
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
33
|
+
import "../chunk-INV7QKLG.mjs";
|
|
34
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
35
|
+
import "../chunk-SBACDPNX.mjs";
|
|
36
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
37
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
38
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
39
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
40
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
41
|
+
import "../chunk-DNNG377Z.mjs";
|
|
42
|
+
import "../chunk-5HMZ644B.mjs";
|
|
43
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
44
|
+
import "../chunk-56WO4WX7.mjs";
|
|
45
|
+
import {
|
|
46
|
+
withTimezoneFormatting
|
|
47
|
+
} from "../chunk-2W3DVD7S.mjs";
|
|
48
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
49
|
+
import "../chunk-H26B4FYG.mjs";
|
|
50
|
+
import "../chunk-DP3G27G5.mjs";
|
|
51
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
52
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
53
|
+
import "../chunk-EGXBZCGC.mjs";
|
|
54
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
55
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
56
|
+
import {
|
|
57
|
+
respondDoc,
|
|
58
|
+
respondMutation
|
|
59
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
60
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
61
|
+
import "../chunk-D5HQBNUB.mjs";
|
|
62
|
+
import {
|
|
63
|
+
NextlyError
|
|
64
|
+
} from "../chunk-NRUWQ5Z7.mjs";
|
|
65
|
+
import "../chunk-VTJADRO3.mjs";
|
|
66
|
+
import "../chunk-5APFUGAD.mjs";
|
|
67
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
68
|
+
|
|
69
|
+
// src/api/singles-detail.ts
|
|
70
|
+
async function getSingleEntryService() {
|
|
71
|
+
await getCachedNextly();
|
|
72
|
+
return getService("singleEntryService");
|
|
73
|
+
}
|
|
74
|
+
async function getSingleRegistry() {
|
|
75
|
+
await getCachedNextly();
|
|
76
|
+
return getService("singleRegistryService");
|
|
77
|
+
}
|
|
78
|
+
function throwFromSingleResult(result, slug) {
|
|
79
|
+
const logContext = {
|
|
80
|
+
slug,
|
|
81
|
+
legacyStatusCode: result.statusCode,
|
|
82
|
+
legacyMessage: result.message
|
|
83
|
+
};
|
|
84
|
+
if (result.errors) logContext.legacyErrors = result.errors;
|
|
85
|
+
if (result.statusCode === 404) {
|
|
86
|
+
throw NextlyError.notFound({ logContext });
|
|
87
|
+
}
|
|
88
|
+
if (result.statusCode === 400) {
|
|
89
|
+
throw NextlyError.validation({
|
|
90
|
+
errors: (result.errors ?? []).map((e) => ({
|
|
91
|
+
path: e.field ?? "",
|
|
92
|
+
code: "INVALID",
|
|
93
|
+
message: e.message
|
|
94
|
+
})),
|
|
95
|
+
logContext
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
throw NextlyError.internal({ logContext });
|
|
99
|
+
}
|
|
100
|
+
var VALID_RICH_TEXT_FORMATS = ["json", "html", "both"];
|
|
101
|
+
function parseRichTextFormat(value) {
|
|
102
|
+
if (!value) return "json";
|
|
103
|
+
const normalized = value.toLowerCase();
|
|
104
|
+
if (VALID_RICH_TEXT_FORMATS.includes(normalized)) {
|
|
105
|
+
return normalized;
|
|
106
|
+
}
|
|
107
|
+
return "json";
|
|
108
|
+
}
|
|
109
|
+
var GET = withErrorHandler(
|
|
110
|
+
async (request, context) => {
|
|
111
|
+
const { slug } = await context.params;
|
|
112
|
+
const service = await getSingleEntryService();
|
|
113
|
+
const { searchParams } = new URL(request.url);
|
|
114
|
+
const depth = searchParams.get("depth") ? parseInt(searchParams.get("depth"), 10) : void 0;
|
|
115
|
+
const locale = searchParams.get("locale") || void 0;
|
|
116
|
+
const richTextFormat = parseRichTextFormat(
|
|
117
|
+
searchParams.get("richTextFormat")
|
|
118
|
+
);
|
|
119
|
+
const result = await service.get(slug, { depth, locale });
|
|
120
|
+
if (!result.success) {
|
|
121
|
+
throwFromSingleResult(result, slug);
|
|
122
|
+
}
|
|
123
|
+
let responseData = result.data;
|
|
124
|
+
if (richTextFormat !== "json" && result.data) {
|
|
125
|
+
const registry = await getSingleRegistry();
|
|
126
|
+
const single = await registry.getSingleBySlug(slug);
|
|
127
|
+
if (single?.fields && Array.isArray(single.fields)) {
|
|
128
|
+
responseData = transformRichTextFields(
|
|
129
|
+
result.data,
|
|
130
|
+
single.fields,
|
|
131
|
+
richTextFormat
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return withTimezoneFormatting(respondDoc(responseData));
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
var PATCH = withErrorHandler(
|
|
139
|
+
async (request, context) => {
|
|
140
|
+
requireAuthHeader(request);
|
|
141
|
+
const { slug } = await context.params;
|
|
142
|
+
const service = await getSingleEntryService();
|
|
143
|
+
const body = await readJsonBody(request, { slug });
|
|
144
|
+
const { searchParams } = new URL(request.url);
|
|
145
|
+
const locale = searchParams.get("locale") || void 0;
|
|
146
|
+
const result = await service.update(slug, body, { locale });
|
|
147
|
+
if (!result.success) {
|
|
148
|
+
throwFromSingleResult(result, slug);
|
|
149
|
+
}
|
|
150
|
+
return withTimezoneFormatting(
|
|
151
|
+
respondMutation("Single updated.", result.data)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
function getSchema(request, slug) {
|
|
156
|
+
return withErrorHandler(async (req) => {
|
|
157
|
+
requireAuthHeader(req);
|
|
158
|
+
const registry = await getSingleRegistry();
|
|
159
|
+
const single = await registry.getSingleBySlug(slug);
|
|
160
|
+
if (!single) {
|
|
161
|
+
throw NextlyError.notFound({ logContext: { slug } });
|
|
162
|
+
}
|
|
163
|
+
return respondDoc(single);
|
|
164
|
+
})(request);
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
GET,
|
|
168
|
+
PATCH,
|
|
169
|
+
getSchema
|
|
170
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Singles Schema Detail API Route Handlers for Next.js
|
|
3
|
+
*
|
|
4
|
+
* These route handlers can be re-exported in your Next.js application to provide
|
|
5
|
+
* individual Single schema management endpoints at /api/singles/[slug]/schema.
|
|
6
|
+
*
|
|
7
|
+
* This is separate from the document endpoints (/api/singles/[slug]) which
|
|
8
|
+
* handle the actual content/values of a Single.
|
|
9
|
+
*
|
|
10
|
+
* Services are auto-initialized on first request using environment variables:
|
|
11
|
+
* - DB_DIALECT: Database dialect ("postgresql" | "mysql" | "sqlite")
|
|
12
|
+
* - DATABASE_URL: Database connection string
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // In your Next.js app: app/api/singles/[slug]/schema/route.ts
|
|
17
|
+
* export { GET, PATCH, DELETE } from 'nextly/api/singles-schema-detail';
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module api/singles-schema-detail
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Context object for dynamic route handlers.
|
|
24
|
+
* Next.js 15+ requires params to be a Promise.
|
|
25
|
+
*/
|
|
26
|
+
interface RouteContext {
|
|
27
|
+
params: Promise<{
|
|
28
|
+
slug: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* GET handler for retrieving a Single's schema/metadata by slug.
|
|
33
|
+
*
|
|
34
|
+
* Requires authentication.
|
|
35
|
+
*/
|
|
36
|
+
declare const GET: (request: Request, context: RouteContext) => Promise<Response>;
|
|
37
|
+
/**
|
|
38
|
+
* PATCH handler for updating a Single's schema/metadata.
|
|
39
|
+
*
|
|
40
|
+
* Requires authentication. The registry returns 403 if the Single is locked
|
|
41
|
+
* (code-first Singles cannot be modified via API).
|
|
42
|
+
*/
|
|
43
|
+
declare const PATCH: (request: Request, context: RouteContext) => Promise<Response>;
|
|
44
|
+
/**
|
|
45
|
+
* DELETE handler for removing a Single.
|
|
46
|
+
*
|
|
47
|
+
* Requires authentication. The registry returns 403 if the Single is locked
|
|
48
|
+
* (code-first Singles cannot be deleted via API). Singles require
|
|
49
|
+
* `force: true` to delete because they represent persistent site-wide
|
|
50
|
+
* configuration.
|
|
51
|
+
*/
|
|
52
|
+
declare const DELETE: (request: Request, context: RouteContext) => Promise<Response>;
|
|
53
|
+
|
|
54
|
+
export { DELETE, GET, PATCH };
|