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,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Templates 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 email template management endpoints at /api/email-templates/[id].
|
|
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/email-templates/[id]/route.ts
|
|
14
|
+
* export { GET, PATCH, DELETE } from 'nextly/api/email-templates-detail';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @module api/email-templates-detail
|
|
18
|
+
*/
|
|
19
|
+
interface RouteContext {
|
|
20
|
+
params: Promise<{
|
|
21
|
+
id: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* GET handler for retrieving a single email template by ID.
|
|
26
|
+
*
|
|
27
|
+
* Requires authentication.
|
|
28
|
+
*
|
|
29
|
+
* Response Codes:
|
|
30
|
+
* - 200 OK: Template retrieved successfully
|
|
31
|
+
* - 401 Unauthorized: Authentication required
|
|
32
|
+
* - 404 Not Found: Template with ID does not exist
|
|
33
|
+
* - 500 Internal Server Error: Failed to fetch template
|
|
34
|
+
*
|
|
35
|
+
* Response: `{ "data": EmailTemplate }`
|
|
36
|
+
*/
|
|
37
|
+
declare const GET: (request: Request, context: RouteContext) => Promise<Response>;
|
|
38
|
+
/**
|
|
39
|
+
* PATCH handler for updating an email template.
|
|
40
|
+
*
|
|
41
|
+
* Requires authentication. Template `slug` cannot be changed after creation.
|
|
42
|
+
*
|
|
43
|
+
* Request Body (all fields optional):
|
|
44
|
+
* - name, subject, htmlContent, plainTextContent, variables, useLayout,
|
|
45
|
+
* isActive, providerId.
|
|
46
|
+
*
|
|
47
|
+
* Response Codes:
|
|
48
|
+
* - 200 OK: Template updated successfully
|
|
49
|
+
* - 400 Bad Request: Invalid JSON body
|
|
50
|
+
* - 401 Unauthorized: Authentication required
|
|
51
|
+
* - 404 Not Found: Template with ID does not exist
|
|
52
|
+
* - 500 Internal Server Error: Update failed
|
|
53
|
+
*
|
|
54
|
+
* Response: `{ "data": EmailTemplate }`
|
|
55
|
+
*/
|
|
56
|
+
declare const PATCH: (request: Request, context: RouteContext) => Promise<Response>;
|
|
57
|
+
/**
|
|
58
|
+
* DELETE handler for removing an email template.
|
|
59
|
+
*
|
|
60
|
+
* Requires authentication. Cannot delete layout templates (`_email-header`,
|
|
61
|
+
* `_email-footer`); use the layout endpoint to modify them.
|
|
62
|
+
*
|
|
63
|
+
* Response Codes:
|
|
64
|
+
* - 200 OK: Template deleted successfully
|
|
65
|
+
* - 401 Unauthorized: Authentication required
|
|
66
|
+
* - 403 Forbidden: Cannot delete layout templates
|
|
67
|
+
* - 404 Not Found: Template with ID does not exist
|
|
68
|
+
* - 500 Internal Server Error: Deletion failed
|
|
69
|
+
*
|
|
70
|
+
* Response: `{ "data": { "success": true } }`
|
|
71
|
+
*/
|
|
72
|
+
declare const DELETE: (request: Request, context: RouteContext) => Promise<Response>;
|
|
73
|
+
|
|
74
|
+
export { DELETE, GET, PATCH };
|
|
@@ -0,0 +1,112 @@
|
|
|
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 "../chunk-X7TXCYYN.mjs";
|
|
19
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
20
|
+
import "../chunk-FQULBZ53.mjs";
|
|
21
|
+
import "../chunk-67GXH6PR.mjs";
|
|
22
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
23
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
24
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
25
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
26
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
27
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
28
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
29
|
+
import "../chunk-INV7QKLG.mjs";
|
|
30
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
31
|
+
import "../chunk-SBACDPNX.mjs";
|
|
32
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
33
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
34
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
35
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
36
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
37
|
+
import "../chunk-DNNG377Z.mjs";
|
|
38
|
+
import "../chunk-5HMZ644B.mjs";
|
|
39
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
40
|
+
import "../chunk-56WO4WX7.mjs";
|
|
41
|
+
import "../chunk-2W3DVD7S.mjs";
|
|
42
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
43
|
+
import "../chunk-H26B4FYG.mjs";
|
|
44
|
+
import "../chunk-DP3G27G5.mjs";
|
|
45
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
46
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
47
|
+
import "../chunk-EGXBZCGC.mjs";
|
|
48
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
49
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
50
|
+
import {
|
|
51
|
+
respondAction,
|
|
52
|
+
respondDoc,
|
|
53
|
+
respondMutation
|
|
54
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
55
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
56
|
+
import {
|
|
57
|
+
container
|
|
58
|
+
} from "../chunk-D5HQBNUB.mjs";
|
|
59
|
+
import "../chunk-NRUWQ5Z7.mjs";
|
|
60
|
+
import "../chunk-VTJADRO3.mjs";
|
|
61
|
+
import "../chunk-5APFUGAD.mjs";
|
|
62
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
63
|
+
|
|
64
|
+
// src/api/email-templates-detail.ts
|
|
65
|
+
async function getEmailTemplateService() {
|
|
66
|
+
await getCachedNextly();
|
|
67
|
+
return container.get("emailTemplateService");
|
|
68
|
+
}
|
|
69
|
+
var GET = withErrorHandler(
|
|
70
|
+
async (request, context) => {
|
|
71
|
+
requireAuthHeader(request);
|
|
72
|
+
const { id } = await context.params;
|
|
73
|
+
const service = await getEmailTemplateService();
|
|
74
|
+
const template = await service.getTemplate(id);
|
|
75
|
+
return respondDoc(template);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
var PATCH = withErrorHandler(
|
|
79
|
+
async (request, context) => {
|
|
80
|
+
requireAuthHeader(request);
|
|
81
|
+
const { id } = await context.params;
|
|
82
|
+
const body = await readJsonBody(request);
|
|
83
|
+
const updateData = {};
|
|
84
|
+
if (body.name !== void 0) updateData.name = body.name;
|
|
85
|
+
if (body.subject !== void 0) updateData.subject = body.subject;
|
|
86
|
+
if (body.htmlContent !== void 0)
|
|
87
|
+
updateData.htmlContent = body.htmlContent;
|
|
88
|
+
if (body.plainTextContent !== void 0)
|
|
89
|
+
updateData.plainTextContent = body.plainTextContent;
|
|
90
|
+
if (body.variables !== void 0) updateData.variables = body.variables;
|
|
91
|
+
if (body.useLayout !== void 0) updateData.useLayout = body.useLayout;
|
|
92
|
+
if (body.isActive !== void 0) updateData.isActive = body.isActive;
|
|
93
|
+
if (body.providerId !== void 0) updateData.providerId = body.providerId;
|
|
94
|
+
const service = await getEmailTemplateService();
|
|
95
|
+
const template = await service.updateTemplate(id, updateData);
|
|
96
|
+
return respondMutation("Email template updated.", template);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
var DELETE = withErrorHandler(
|
|
100
|
+
async (request, context) => {
|
|
101
|
+
requireAuthHeader(request);
|
|
102
|
+
const { id } = await context.params;
|
|
103
|
+
const service = await getEmailTemplateService();
|
|
104
|
+
await service.deleteTemplate(id);
|
|
105
|
+
return respondAction("Email template deleted.", { templateId: id });
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
export {
|
|
109
|
+
DELETE,
|
|
110
|
+
GET,
|
|
111
|
+
PATCH
|
|
112
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Template Layout API Route Handlers for Next.js
|
|
3
|
+
*
|
|
4
|
+
* Manages the shared email header and footer HTML that wraps every
|
|
5
|
+
* template's body content. Layout is stored as two reserved rows in the
|
|
6
|
+
* `email_templates` table with slugs `_email-header` and `_email-footer`.
|
|
7
|
+
*
|
|
8
|
+
* Re-export in your Next.js application at /api/email-templates/layout.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // In your Next.js app: app/api/email-templates/layout/route.ts
|
|
13
|
+
* export { GET, PATCH } from 'nextly/api/email-templates-layout';
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @module api/email-templates-layout
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* GET handler for retrieving the shared email layout (header + footer).
|
|
20
|
+
*
|
|
21
|
+
* Requires authentication. Returns the `htmlContent` of the reserved
|
|
22
|
+
* `_email-header` and `_email-footer` template rows. Returns empty
|
|
23
|
+
* strings if layout templates haven't been created yet.
|
|
24
|
+
*
|
|
25
|
+
* Response Codes:
|
|
26
|
+
* - 200 OK: Layout retrieved successfully
|
|
27
|
+
* - 401 Unauthorized: Authentication required
|
|
28
|
+
* - 500 Internal Server Error: Failed to fetch layout
|
|
29
|
+
*
|
|
30
|
+
* Response: `{ "data": { "header": string, "footer": string } }`
|
|
31
|
+
*/
|
|
32
|
+
declare const GET: (request: Request) => Promise<Response>;
|
|
33
|
+
/**
|
|
34
|
+
* PATCH handler for updating the shared email header and/or footer.
|
|
35
|
+
*
|
|
36
|
+
* Requires authentication. Creates layout templates if they don't exist
|
|
37
|
+
* yet (upsert behavior). Both fields are optional; only provided fields
|
|
38
|
+
* are updated.
|
|
39
|
+
*
|
|
40
|
+
* Request Body (all fields optional):
|
|
41
|
+
* - header: HTML content for the shared email header
|
|
42
|
+
* - footer: HTML content for the shared email footer
|
|
43
|
+
*
|
|
44
|
+
* Response Codes:
|
|
45
|
+
* - 200 OK: Layout updated successfully
|
|
46
|
+
* - 400 Bad Request: Invalid JSON body
|
|
47
|
+
* - 401 Unauthorized: Authentication required
|
|
48
|
+
* - 500 Internal Server Error: Update failed
|
|
49
|
+
*
|
|
50
|
+
* Response: `{ "data": { "header": string, "footer": string } }`; the
|
|
51
|
+
* full layout after update (re-read from the service).
|
|
52
|
+
*/
|
|
53
|
+
declare const PATCH: (request: Request) => Promise<Response>;
|
|
54
|
+
|
|
55
|
+
export { GET, PATCH };
|
|
@@ -0,0 +1,92 @@
|
|
|
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 "../chunk-X7TXCYYN.mjs";
|
|
19
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
20
|
+
import "../chunk-FQULBZ53.mjs";
|
|
21
|
+
import "../chunk-67GXH6PR.mjs";
|
|
22
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
23
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
24
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
25
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
26
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
27
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
28
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
29
|
+
import "../chunk-INV7QKLG.mjs";
|
|
30
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
31
|
+
import "../chunk-SBACDPNX.mjs";
|
|
32
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
33
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
34
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
35
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
36
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
37
|
+
import "../chunk-DNNG377Z.mjs";
|
|
38
|
+
import "../chunk-5HMZ644B.mjs";
|
|
39
|
+
import "../chunk-W5KKPZT5.mjs";
|
|
40
|
+
import "../chunk-56WO4WX7.mjs";
|
|
41
|
+
import "../chunk-2W3DVD7S.mjs";
|
|
42
|
+
import "../chunk-TS7GHTG2.mjs";
|
|
43
|
+
import "../chunk-H26B4FYG.mjs";
|
|
44
|
+
import "../chunk-DP3G27G5.mjs";
|
|
45
|
+
import "../chunk-DV6WVX2Q.mjs";
|
|
46
|
+
import "../chunk-UJ2IMJ4W.mjs";
|
|
47
|
+
import "../chunk-EGXBZCGC.mjs";
|
|
48
|
+
import "../chunk-G2AA4QLC.mjs";
|
|
49
|
+
import "../chunk-4MJLT6PZ.mjs";
|
|
50
|
+
import {
|
|
51
|
+
respondAction,
|
|
52
|
+
respondData
|
|
53
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
54
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
55
|
+
import {
|
|
56
|
+
container
|
|
57
|
+
} from "../chunk-D5HQBNUB.mjs";
|
|
58
|
+
import "../chunk-NRUWQ5Z7.mjs";
|
|
59
|
+
import "../chunk-VTJADRO3.mjs";
|
|
60
|
+
import "../chunk-5APFUGAD.mjs";
|
|
61
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
62
|
+
|
|
63
|
+
// src/api/email-templates-layout.ts
|
|
64
|
+
async function getEmailTemplateService() {
|
|
65
|
+
await getCachedNextly();
|
|
66
|
+
return container.get("emailTemplateService");
|
|
67
|
+
}
|
|
68
|
+
var GET = withErrorHandler(
|
|
69
|
+
async (request) => {
|
|
70
|
+
requireAuthHeader(request);
|
|
71
|
+
const service = await getEmailTemplateService();
|
|
72
|
+
const layout = await service.getLayout();
|
|
73
|
+
return respondData(layout);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
var PATCH = withErrorHandler(
|
|
77
|
+
async (request) => {
|
|
78
|
+
requireAuthHeader(request);
|
|
79
|
+
const service = await getEmailTemplateService();
|
|
80
|
+
const body = await readJsonBody(request);
|
|
81
|
+
const updateData = {};
|
|
82
|
+
if (typeof body.header === "string") updateData.header = body.header;
|
|
83
|
+
if (typeof body.footer === "string") updateData.footer = body.footer;
|
|
84
|
+
await service.updateLayout(updateData);
|
|
85
|
+
const layout = await service.getLayout();
|
|
86
|
+
return respondAction("Email layout updated.", { layout });
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
export {
|
|
90
|
+
GET,
|
|
91
|
+
PATCH
|
|
92
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Template Preview API Route Handler for Next.js
|
|
3
|
+
*
|
|
4
|
+
* Renders a template with sample data to preview the interpolated output.
|
|
5
|
+
* Re-export in your Next.js application at /api/email-templates/[id]/preview.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // In your Next.js app: app/api/email-templates/[id]/preview/route.ts
|
|
10
|
+
* export { POST } from 'nextly/api/email-templates-preview';
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* The rendered subject/html stay JSON-encoded inside `data` (no raw HTML
|
|
14
|
+
* response; admin renders the preview in an iframe sandbox).
|
|
15
|
+
*
|
|
16
|
+
* @module api/email-templates-preview
|
|
17
|
+
*/
|
|
18
|
+
interface RouteContext {
|
|
19
|
+
params: Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* POST handler for previewing an email template with sample data.
|
|
25
|
+
*
|
|
26
|
+
* Renders the template by replacing `{{variable}}` placeholders with values
|
|
27
|
+
* from the provided `data` object. Supports dot-notation for nested values
|
|
28
|
+
* (e.g., `{{user.name}}`). HTML-escapes interpolated values by default.
|
|
29
|
+
* Wraps with shared layout (header/footer) when the template has
|
|
30
|
+
* `useLayout: true`.
|
|
31
|
+
*
|
|
32
|
+
* Requires authentication.
|
|
33
|
+
*
|
|
34
|
+
* Request Body:
|
|
35
|
+
* - data: Object with key-value pairs for variable interpolation (required)
|
|
36
|
+
*
|
|
37
|
+
* Response Codes:
|
|
38
|
+
* - 200 OK: Preview rendered successfully
|
|
39
|
+
* - 400 Bad Request: Invalid input
|
|
40
|
+
* - 401 Unauthorized: Authentication required
|
|
41
|
+
* - 404 Not Found: Template with ID does not exist
|
|
42
|
+
* - 500 Internal Server Error: Preview failed
|
|
43
|
+
*
|
|
44
|
+
* Response: `{ "data": { "subject": string, "html": string } }`
|
|
45
|
+
*/
|
|
46
|
+
declare const POST: (request: Request, context: RouteContext) => Promise<Response>;
|
|
47
|
+
|
|
48
|
+
export { POST };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireAuthHeader
|
|
3
|
+
} from "../chunk-WZBYMYVW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
readJsonBody
|
|
6
|
+
} from "../chunk-VQJQHVEV.mjs";
|
|
7
|
+
import {
|
|
8
|
+
nextlyValidationFromZod
|
|
9
|
+
} from "../chunk-GJNSJU4S.mjs";
|
|
10
|
+
import "../chunk-VWF3JO32.mjs";
|
|
11
|
+
import {
|
|
12
|
+
withErrorHandler
|
|
13
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
14
|
+
import {
|
|
15
|
+
getCachedNextly
|
|
16
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
17
|
+
import "../chunk-2OALJTK6.mjs";
|
|
18
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
19
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
20
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
21
|
+
import "../chunk-X7TXCYYN.mjs";
|
|
22
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
23
|
+
import "../chunk-FQULBZ53.mjs";
|
|
24
|
+
import "../chunk-67GXH6PR.mjs";
|
|
25
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
26
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
27
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
28
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
29
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
30
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
31
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
32
|
+
import "../chunk-INV7QKLG.mjs";
|
|
33
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
34
|
+
import "../chunk-SBACDPNX.mjs";
|
|
35
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
36
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
37
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
38
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
39
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
40
|
+
import "../chunk-DNNG377Z.mjs";
|
|
41
|
+
import "../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
|
+
respondData
|
|
55
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
56
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
57
|
+
import {
|
|
58
|
+
container
|
|
59
|
+
} from "../chunk-D5HQBNUB.mjs";
|
|
60
|
+
import "../chunk-NRUWQ5Z7.mjs";
|
|
61
|
+
import "../chunk-VTJADRO3.mjs";
|
|
62
|
+
import "../chunk-5APFUGAD.mjs";
|
|
63
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
64
|
+
|
|
65
|
+
// src/api/email-templates-preview.ts
|
|
66
|
+
import { z } from "zod";
|
|
67
|
+
async function getEmailTemplateService() {
|
|
68
|
+
await getCachedNextly();
|
|
69
|
+
return container.get("emailTemplateService");
|
|
70
|
+
}
|
|
71
|
+
var previewSchema = z.object({
|
|
72
|
+
data: z.record(z.string(), z.unknown())
|
|
73
|
+
});
|
|
74
|
+
var POST = withErrorHandler(
|
|
75
|
+
async (request, context) => {
|
|
76
|
+
requireAuthHeader(request);
|
|
77
|
+
const { id } = await context.params;
|
|
78
|
+
const service = await getEmailTemplateService();
|
|
79
|
+
const body = await readJsonBody(request);
|
|
80
|
+
let validated;
|
|
81
|
+
try {
|
|
82
|
+
validated = previewSchema.parse(body);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
if (err instanceof z.ZodError) throw nextlyValidationFromZod(err);
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
const preview = await service.previewTemplate(id, validated.data);
|
|
88
|
+
return respondData(preview);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
export {
|
|
92
|
+
POST
|
|
93
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Templates API Route Handlers for Next.js
|
|
3
|
+
*
|
|
4
|
+
* These route handlers can be re-exported in your Next.js application to provide
|
|
5
|
+
* email template management endpoints at /api/email-templates.
|
|
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/email-templates/route.ts
|
|
14
|
+
* export { GET, POST } from 'nextly/api/email-templates';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The list endpoint is not server-paginated; admin code reads the array
|
|
18
|
+
* length directly. There is no synthetic `meta.total`.
|
|
19
|
+
*
|
|
20
|
+
* @module api/email-templates
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* GET handler for listing all email templates.
|
|
24
|
+
*
|
|
25
|
+
* Requires authentication. Returns all templates except layout templates
|
|
26
|
+
* (`_email-header`, `_email-footer`). Use the layout endpoint to access those.
|
|
27
|
+
*
|
|
28
|
+
* Response Codes:
|
|
29
|
+
* - 200 OK: Templates list retrieved successfully
|
|
30
|
+
* - 401 Unauthorized: Authentication required
|
|
31
|
+
* - 500 Internal Server Error: Failed to fetch templates
|
|
32
|
+
*
|
|
33
|
+
* Response: `{ "data": EmailTemplate[] }`; non-paginated list.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```bash
|
|
37
|
+
* curl -H "Authorization: Bearer <token>" \
|
|
38
|
+
* "http://localhost:3000/api/email-templates"
|
|
39
|
+
* # => {"data":[...]}
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare const GET: (request: Request) => Promise<Response>;
|
|
43
|
+
/**
|
|
44
|
+
* POST handler for creating a new email template.
|
|
45
|
+
*
|
|
46
|
+
* Requires authentication. Cannot use reserved slugs (`_email-header`,
|
|
47
|
+
* `_email-footer`); use the layout endpoint instead.
|
|
48
|
+
*
|
|
49
|
+
* Request Body: see `createTemplateSchema` above for the full shape.
|
|
50
|
+
*
|
|
51
|
+
* Response Codes:
|
|
52
|
+
* - 201 Created: Template created successfully
|
|
53
|
+
* - 400 Bad Request: Invalid input or reserved slug
|
|
54
|
+
* - 401 Unauthorized: Authentication required
|
|
55
|
+
* - 500 Internal Server Error: Creation failed
|
|
56
|
+
*
|
|
57
|
+
* Response: `{ "data": EmailTemplate }`; the created template. Status 201.
|
|
58
|
+
*/
|
|
59
|
+
declare const POST: (request: Request) => Promise<Response>;
|
|
60
|
+
|
|
61
|
+
export { GET, POST };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireAuthHeader
|
|
3
|
+
} from "../chunk-WZBYMYVW.mjs";
|
|
4
|
+
import {
|
|
5
|
+
readJsonBody
|
|
6
|
+
} from "../chunk-VQJQHVEV.mjs";
|
|
7
|
+
import {
|
|
8
|
+
nextlyValidationFromZod
|
|
9
|
+
} from "../chunk-GJNSJU4S.mjs";
|
|
10
|
+
import "../chunk-VWF3JO32.mjs";
|
|
11
|
+
import {
|
|
12
|
+
withErrorHandler
|
|
13
|
+
} from "../chunk-TO5AFLVQ.mjs";
|
|
14
|
+
import {
|
|
15
|
+
getCachedNextly
|
|
16
|
+
} from "../chunk-P7NH2OSC.mjs";
|
|
17
|
+
import "../chunk-2OALJTK6.mjs";
|
|
18
|
+
import "../chunk-VJ66NCL4.mjs";
|
|
19
|
+
import "../chunk-R6JJQHFC.mjs";
|
|
20
|
+
import "../chunk-X23WKS3Z.mjs";
|
|
21
|
+
import "../chunk-X7TXCYYN.mjs";
|
|
22
|
+
import "../chunk-YZNBLFIW.mjs";
|
|
23
|
+
import "../chunk-FQULBZ53.mjs";
|
|
24
|
+
import "../chunk-67GXH6PR.mjs";
|
|
25
|
+
import "../chunk-2TFX4ND3.mjs";
|
|
26
|
+
import "../chunk-W4MGXIRR.mjs";
|
|
27
|
+
import "../chunk-NSEFNNU4.mjs";
|
|
28
|
+
import "../chunk-3FA7FKAV.mjs";
|
|
29
|
+
import "../chunk-AGJ6F2T3.mjs";
|
|
30
|
+
import "../chunk-KIMNCZGV.mjs";
|
|
31
|
+
import "../chunk-AK6Z23OX.mjs";
|
|
32
|
+
import "../chunk-INV7QKLG.mjs";
|
|
33
|
+
import "../chunk-GZ6DCQKC.mjs";
|
|
34
|
+
import "../chunk-SBACDPNX.mjs";
|
|
35
|
+
import "../chunk-RJLLGGPG.mjs";
|
|
36
|
+
import "../chunk-V4EQTOA4.mjs";
|
|
37
|
+
import "../chunk-I4JMR3UR.mjs";
|
|
38
|
+
import "../chunk-XZKLBMN6.mjs";
|
|
39
|
+
import "../chunk-IZWPRDC3.mjs";
|
|
40
|
+
import "../chunk-DNNG377Z.mjs";
|
|
41
|
+
import "../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
|
+
respondData,
|
|
55
|
+
respondMutation
|
|
56
|
+
} from "../chunk-IUDOC7N7.mjs";
|
|
57
|
+
import "../chunk-LAZXX4HR.mjs";
|
|
58
|
+
import {
|
|
59
|
+
container
|
|
60
|
+
} from "../chunk-D5HQBNUB.mjs";
|
|
61
|
+
import "../chunk-NRUWQ5Z7.mjs";
|
|
62
|
+
import "../chunk-VTJADRO3.mjs";
|
|
63
|
+
import "../chunk-5APFUGAD.mjs";
|
|
64
|
+
import "../chunk-7P6ASYW6.mjs";
|
|
65
|
+
|
|
66
|
+
// src/api/email-templates.ts
|
|
67
|
+
import { z } from "zod";
|
|
68
|
+
async function getEmailTemplateService() {
|
|
69
|
+
await getCachedNextly();
|
|
70
|
+
return container.get("emailTemplateService");
|
|
71
|
+
}
|
|
72
|
+
var variableSchema = z.object({
|
|
73
|
+
name: z.string().min(1),
|
|
74
|
+
description: z.string(),
|
|
75
|
+
required: z.boolean().optional()
|
|
76
|
+
});
|
|
77
|
+
var createTemplateSchema = z.object({
|
|
78
|
+
name: z.string().min(1, "Name is required").max(255),
|
|
79
|
+
slug: z.string().min(1, "Slug is required").max(255).regex(
|
|
80
|
+
/^[a-z0-9]+(?:-[a-z0-9]+)*$/,
|
|
81
|
+
"Slug must be lowercase alphanumeric with hyphens"
|
|
82
|
+
),
|
|
83
|
+
subject: z.string().min(1, "Subject is required").max(500),
|
|
84
|
+
htmlContent: z.string().min(1, "HTML content is required"),
|
|
85
|
+
plainTextContent: z.string().optional().nullable(),
|
|
86
|
+
variables: z.array(variableSchema).optional().nullable(),
|
|
87
|
+
useLayout: z.boolean().optional(),
|
|
88
|
+
isActive: z.boolean().optional(),
|
|
89
|
+
providerId: z.string().uuid().optional().nullable()
|
|
90
|
+
});
|
|
91
|
+
var GET = withErrorHandler(
|
|
92
|
+
async (request) => {
|
|
93
|
+
requireAuthHeader(request);
|
|
94
|
+
const service = await getEmailTemplateService();
|
|
95
|
+
const templates = await service.listTemplates();
|
|
96
|
+
return respondData({ templates });
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
var POST = withErrorHandler(
|
|
100
|
+
async (request) => {
|
|
101
|
+
requireAuthHeader(request);
|
|
102
|
+
const body = await readJsonBody(request);
|
|
103
|
+
let validated;
|
|
104
|
+
try {
|
|
105
|
+
validated = createTemplateSchema.parse(body);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
if (err instanceof z.ZodError) throw nextlyValidationFromZod(err);
|
|
108
|
+
throw err;
|
|
109
|
+
}
|
|
110
|
+
const service = await getEmailTemplateService();
|
|
111
|
+
const template = await service.createTemplate(validated);
|
|
112
|
+
return respondMutation("Email template created.", template, { status: 201 });
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
export {
|
|
116
|
+
GET,
|
|
117
|
+
POST
|
|
118
|
+
};
|