@reldens/cms 0.84.0 → 0.86.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.
@@ -1,171 +1,172 @@
1
- # API Reference
2
-
3
- ## Manager Class
4
-
5
- - `start()` - Initialize and start the CMS
6
- - `isInstalled()` - Check if CMS is installed
7
- - `buildAppServerConfiguration()` - Build server configuration
8
- - `validateCdnMappingsInDevelopment()` - Warn when CDN domains are missing from CSP directives
9
- - `isCdnUrlInDirectives(cdnUrlWithProtocol, cdnHostname)` - Check if a CDN URL appears in any CSP directive
10
- - `initializeCmsAfterInstall(props)` - Post-installation callback
11
-
12
- ## ManagerComponentValidator Class (lib/manager-component-validator.js)
13
-
14
- Static validators called from the Manager constructor:
15
-
16
- - `validateProvidedServer(app, appServer)` - Validate provided Express app and server
17
- - `validateProvidedDataServer(dataServer)` - Validate provided data server
18
- - `validateProvidedAdminManager(adminManager)` - Validate provided admin manager
19
- - `validateProvidedFrontend(frontend)` - Validate provided frontend
20
-
21
- ## ManagerConfigLoader Class (lib/manager-config-loader.js)
22
-
23
- - `loadFromEnv()` - Build config object from `RELDENS_*` environment variables
24
-
25
- ## ManagerServicesInitializer Class (lib/manager-services-initializer.js)
26
-
27
- Receives the Manager instance via constructor and handles all service initialization:
28
-
29
- - `initializeServices()` - Orchestrate full service initialization sequence
30
- - `initializeDataServer()` - Create data server; auto-creates PrismaClient via PrismaClientLoader when driver is `prisma` and no client provided
31
- - `setupEntityAccess()` - Sync entity access rules to database
32
- - `loadProcessedEntities()` - Apply config overrides and process raw entities
33
- - `generateAdminEntities()` - Generate admin panel entity definitions
34
- - `initializeAdminManager()` - Set up admin routes and authentication
35
- - `initializePasswordEncryptionHandler()` - Register password encryption event listeners
36
- - `initializeCmsPagesRouteManager()` - Wire CMS page routes to the data server
37
- - `initializeFrontend()` - Create and initialize Frontend instance
38
- - `renderCallback(template, params)` - Render a template via the configured render engine
39
-
40
- ## Installer Class
41
-
42
- - `isInstalled()` - Check installation status
43
- - `configureAppServerRoutes(app, appServer, appServerFactory, renderEngine)` - Setup installer routes
44
- - `executeInstallProcess(req, res)` - Complete installation process
45
- - `runSubprocessInstallation(dbConfig, templateVariables)` - Handle subprocess operations
46
- - `checkAndInstallPackages(requiredPackages)` - Check and install dependencies
47
- - `generateEntities(server, isOverride, isInstallationMode, isDryPrisma, dbConfig)` - Generate entities
48
- - `createEnvFile(templateVariables)` - Create environment configuration
49
- - `copyAdminDirectory()` - Copy admin assets and templates
50
-
51
- ## Frontend Architecture Classes
52
-
53
- ### Frontend Class (Orchestrator)
54
-
55
- - `initialize()` - Set up frontend routes and templates
56
- - `handleRequest(req, res)` - Main request handler
57
- - `renderRoute(route, domain, res, req)` - Route-based rendering
58
- - `setupStaticAssets()` - Configure static asset serving
59
-
60
- ### TemplateResolver Class
61
-
62
- - `findTemplatePath(templateName, domain)` - Template discovery with domain fallback
63
- - `findLayoutPath(layoutName, domain)` - Layout path resolution
64
- - `findTemplateByPath(path, domain)` - Template lookup by URL path
65
- - `resolveDomainToFolder(domain)` - Domain to folder mapping
66
- - `resolveDomainToSiteKey(domain)` - Domain to site key mapping
67
-
68
- ### TemplateCache Class
69
-
70
- - `loadPartials()` - Load and cache template partials
71
- - `setupDomainTemplates()` - Initialize domain-specific templates
72
- - `getPartialsForDomain(domain)` - Get domain-specific partials with fallback
73
-
74
- ### TemplateReloader Class
75
-
76
- - `checkAndReloadAdminTemplates()` - Check and reload admin templates when changed
77
- - `checkAndReloadFrontendTemplates()` - Check and reload frontend templates when changed
78
- - `trackTemplateFiles(templatesPaths)` - Start tracking template files for changes
79
- - `shouldReloadAdminTemplates(mappedAdminTemplates)` - Check if admin templates need reloading
80
- - `shouldReloadFrontendTemplates(templatesPath, templateExtensions)` - Check if frontend templates need reloading
81
- - `handleAdminTemplateReload(adminManager)` - Complete admin template reload process
82
- - `handleFrontendTemplateReload(templateCache, templateResolver)` - Complete frontend template reload process
83
-
84
- ### RequestProcessor Class
85
-
86
- - `findRouteByPath(path, domain)` - Database route lookup
87
- - `handleRouteRedirect(route, res)` - Handle route redirects
88
- - `getDomainFromRequest(req)` - Extract domain from request
89
- - `buildCacheKey(path, req)` - Generate cache keys
90
-
91
- ### ContentRenderer Class
92
-
93
- - `renderWithTemplateContent(content, data, domain, req, route)` - Main content rendering
94
- - `generateRouteContent(route, domain, req)` - Route-based content generation
95
- - `generateTemplateContent(templatePath, domain, req, data)` - Template-based content generation
96
- - `fetchMetaFields(data)` - Process meta fields for templates
97
-
98
- ### EntityAccessManager Class
99
-
100
- - `loadEntityAccessRules()` - Load entity access configuration
101
- - `isEntityAccessible(entityName)` - Check entity accessibility
102
- - `findEntityByPath(path)` - Entity lookup by URL path
103
-
104
- ### ResponseManager Class
105
-
106
- - `renderWithCacheHandler(contentGenerator, errorHandler, responseHandler, domain, res, path, req)` - Generic cached response handler
107
- - `renderNotFound(domain, res, req)` - 404 error handling
108
-
109
- ### SearchRequestHandler Class
110
-
111
- - `handleSearchRequest(req, res)` - Process search requests with template data support
112
-
113
- ## TemplateEngine Class
114
-
115
- - `render(template, data, partials, domain, req, route, currentEntityData)` - Main template rendering with enhanced context
116
- - `processAllTemplateFunctions(template, domain, req, systemVariables)` - Process all template functions
117
- - `buildEnhancedRenderData(data, systemVariables, currentEntityData)` - Build template context with system variables
118
-
119
- ## SystemVariablesProvider Class
120
-
121
- - `buildSystemVariables(req, route, domain)` - Create system variables for templates
122
- - `buildCurrentRequestData(req, domain)` - Build request context
123
- - `buildCurrentRouteData(route)` - Build route context
124
- - `buildCurrentDomainData(domain)` - Build domain context
125
-
126
- ## Search Classes
127
-
128
- - `Search.parseSearchParameters(query)` - Parse search query parameters including templateData
129
- - `Search.executeSearch(config)` - Execute search with configuration
130
- - `SearchRenderer.renderSearchResults(searchResults, config, domain, req)` - Render search results with template data
131
-
132
- ## Forms System Classes
133
-
134
- ### DynamicForm Class
135
-
136
- - `validateFormSubmission(formKey, submittedValues, req)` - Validate form submission
137
- - `getFormConfig(formKey)` - Load form configuration from database
138
- - `validateHoneypot(submittedValues)` - Check honeypot field for bots
139
- - `validateFields(fieldsSchema, submittedValues)` - Schema-based field validation
140
- - `prepareSubmittedValues(submittedValues, fieldsSchema)` - Process and normalize values
141
- - `saveFormSubmission(formConfig, preparedValues)` - Save to database
142
-
143
- ### DynamicFormRenderer Class
144
-
145
- - `renderForm(formConfig, fieldsToRender, domain, req, attributes)` - Render complete form
146
- - `renderFormFields(fieldsToRender, domain, req)` - Render field set
147
- - `renderFormField(field, domain, submittedValues, errors)` - Render individual field
148
- - `loadFormTemplate(templateName, domain)` - Load form template with domain fallback
149
- - `findFormTemplate(templateName, domain)` - Template discovery for forms
150
-
151
- ### DynamicFormRequestHandler Class
152
-
153
- - `handleFormSubmission(req, res)` - Process POST form submissions
154
- - `handleBadRequest(res, message)` - Handle validation errors
155
- - `handleSuccessResponse(req, res, formKey, result)` - Handle successful submissions
156
- - `buildErrorRedirectPath(req, error, formKey)` - Build error redirect URLs
157
- - `buildSuccessRedirectPath(successRedirect, formKey)` - Build success redirect URLs
158
-
159
- ### FormsTransformer Class
160
-
161
- - `transform(template, domain, req, systemVariables, enhancedData)` - Process cmsForm tags
162
- - `findAllFormTags(template)` - Find cmsForm tags in template
163
- - `parseFormAttributes(fullTag)` - Parse tag attributes
164
- - `parseFieldsFilter(attributes, formConfig)` - Filter fields based on attributes
165
-
166
- ## AdminManager Class
167
-
168
- - `setupAdmin()` - Initialize admin panel
169
- - `generateListRouteContent()` - Entity list pages
170
- - `generateEditRouteContent()` - Entity edit forms
171
- - `processSaveEntity()` - Handle form submissions
1
+ # API Reference
2
+
3
+ ## Manager Class
4
+
5
+ - `start()` - Initialize and start the CMS
6
+ - `isInstalled()` - Check if CMS is installed
7
+ - `buildAppServerConfiguration()` - Build server configuration
8
+ - `validateCdnMappingsInDevelopment()` - Warn when CDN domains are missing from CSP directives
9
+ - `isCdnUrlInDirectives(cdnUrlWithProtocol, cdnHostname)` - Check if a CDN URL appears in any CSP directive
10
+ - `initializeCmsAfterInstall(props)` - Post-installation callback
11
+
12
+ ## ManagerComponentValidator Class (lib/manager-component-validator.js)
13
+
14
+ Static validators called from the Manager constructor:
15
+
16
+ - `validateProvidedServer(app, appServer)` - Validate provided Express app and server
17
+ - `validateProvidedDataServer(dataServer)` - Validate provided data server
18
+ - `validateProvidedAdminManager(adminManager)` - Validate provided admin manager
19
+ - `validateProvidedFrontend(frontend)` - Validate provided frontend
20
+
21
+ ## ManagerConfigLoader Class (lib/manager-config-loader.js)
22
+
23
+ - `loadFromEnv()` - Build config object from `RELDENS_*` environment variables
24
+
25
+ ## ManagerServicesInitializer Class (lib/manager-services-initializer.js)
26
+
27
+ Receives the Manager instance via constructor and handles all service initialization:
28
+
29
+ - `initializeServices()` - Orchestrate full service initialization sequence
30
+ - `loadPrismaModules(projectRoot, clientPath, connectionData, adapterPackage, adapterClass)` - Static; resolves the Prisma adapter from the project and loads the Prisma modules via PrismaClientLoader
31
+ - `initializeDataServer()` - Create data server; auto-loads Prisma modules via `loadPrismaModules()` when driver is `prisma` and no `prismaModules` provided
32
+ - `setupEntityAccess()` - Sync entity access rules to database
33
+ - `loadProcessedEntities()` - Apply config overrides and process raw entities
34
+ - `generateAdminEntities()` - Generate admin panel entity definitions
35
+ - `initializeAdminManager()` - Set up admin routes and authentication
36
+ - `initializePasswordEncryptionHandler()` - Register password encryption event listeners
37
+ - `initializeCmsPagesRouteManager()` - Wire CMS page routes to the data server
38
+ - `initializeFrontend()` - Create and initialize Frontend instance
39
+ - `renderCallback(template, params)` - Render a template via the configured render engine
40
+
41
+ ## Installer Class
42
+
43
+ - `isInstalled()` - Check installation status
44
+ - `configureAppServerRoutes(app, appServer, appServerFactory, renderEngine)` - Setup installer routes
45
+ - `executeInstallProcess(req, res)` - Complete installation process
46
+ - `runSubprocessInstallation(dbConfig, templateVariables)` - Handle subprocess operations
47
+ - `checkAndInstallPackages(requiredPackages)` - Check and install dependencies
48
+ - `generateEntities(server, isOverride, isInstallationMode, isDryPrisma, dbConfig)` - Generate entities
49
+ - `createEnvFile(templateVariables)` - Create environment configuration
50
+ - `copyAdminDirectory()` - Copy admin assets and templates
51
+
52
+ ## Frontend Architecture Classes
53
+
54
+ ### Frontend Class (Orchestrator)
55
+
56
+ - `initialize()` - Set up frontend routes and templates
57
+ - `handleRequest(req, res)` - Main request handler
58
+ - `renderRoute(route, domain, res, req)` - Route-based rendering
59
+ - `setupStaticAssets()` - Configure static asset serving
60
+
61
+ ### TemplateResolver Class
62
+
63
+ - `findTemplatePath(templateName, domain)` - Template discovery with domain fallback
64
+ - `findLayoutPath(layoutName, domain)` - Layout path resolution
65
+ - `findTemplateByPath(path, domain)` - Template lookup by URL path
66
+ - `resolveDomainToFolder(domain)` - Domain to folder mapping
67
+ - `resolveDomainToSiteKey(domain)` - Domain to site key mapping
68
+
69
+ ### TemplateCache Class
70
+
71
+ - `loadPartials()` - Load and cache template partials
72
+ - `setupDomainTemplates()` - Initialize domain-specific templates
73
+ - `getPartialsForDomain(domain)` - Get domain-specific partials with fallback
74
+
75
+ ### TemplateReloader Class
76
+
77
+ - `checkAndReloadAdminTemplates()` - Check and reload admin templates when changed
78
+ - `checkAndReloadFrontendTemplates()` - Check and reload frontend templates when changed
79
+ - `trackTemplateFiles(templatesPaths)` - Start tracking template files for changes
80
+ - `shouldReloadAdminTemplates(mappedAdminTemplates)` - Check if admin templates need reloading
81
+ - `shouldReloadFrontendTemplates(templatesPath, templateExtensions)` - Check if frontend templates need reloading
82
+ - `handleAdminTemplateReload(adminManager)` - Complete admin template reload process
83
+ - `handleFrontendTemplateReload(templateCache, templateResolver)` - Complete frontend template reload process
84
+
85
+ ### RequestProcessor Class
86
+
87
+ - `findRouteByPath(path, domain)` - Database route lookup
88
+ - `handleRouteRedirect(route, res)` - Handle route redirects
89
+ - `getDomainFromRequest(req)` - Extract domain from request
90
+ - `buildCacheKey(path, req)` - Generate cache keys
91
+
92
+ ### ContentRenderer Class
93
+
94
+ - `renderWithTemplateContent(content, data, domain, req, route)` - Main content rendering
95
+ - `generateRouteContent(route, domain, req)` - Route-based content generation
96
+ - `generateTemplateContent(templatePath, domain, req, data)` - Template-based content generation
97
+ - `fetchMetaFields(data)` - Process meta fields for templates
98
+
99
+ ### EntityAccessManager Class
100
+
101
+ - `loadEntityAccessRules()` - Load entity access configuration
102
+ - `isEntityAccessible(entityName)` - Check entity accessibility
103
+ - `findEntityByPath(path)` - Entity lookup by URL path
104
+
105
+ ### ResponseManager Class
106
+
107
+ - `renderWithCacheHandler(contentGenerator, errorHandler, responseHandler, domain, res, path, req)` - Generic cached response handler
108
+ - `renderNotFound(domain, res, req)` - 404 error handling
109
+
110
+ ### SearchRequestHandler Class
111
+
112
+ - `handleSearchRequest(req, res)` - Process search requests with template data support
113
+
114
+ ## TemplateEngine Class
115
+
116
+ - `render(template, data, partials, domain, req, route, currentEntityData)` - Main template rendering with enhanced context
117
+ - `processAllTemplateFunctions(template, domain, req, systemVariables)` - Process all template functions
118
+ - `buildEnhancedRenderData(data, systemVariables, currentEntityData)` - Build template context with system variables
119
+
120
+ ## SystemVariablesProvider Class
121
+
122
+ - `buildSystemVariables(req, route, domain)` - Create system variables for templates
123
+ - `buildCurrentRequestData(req, domain)` - Build request context
124
+ - `buildCurrentRouteData(route)` - Build route context
125
+ - `buildCurrentDomainData(domain)` - Build domain context
126
+
127
+ ## Search Classes
128
+
129
+ - `Search.parseSearchParameters(query)` - Parse search query parameters including templateData
130
+ - `Search.executeSearch(config)` - Execute search with configuration
131
+ - `SearchRenderer.renderSearchResults(searchResults, config, domain, req)` - Render search results with template data
132
+
133
+ ## Forms System Classes
134
+
135
+ ### DynamicForm Class
136
+
137
+ - `validateFormSubmission(formKey, submittedValues, req)` - Validate form submission
138
+ - `getFormConfig(formKey)` - Load form configuration from database
139
+ - `validateHoneypot(submittedValues)` - Check honeypot field for bots
140
+ - `validateFields(fieldsSchema, submittedValues)` - Schema-based field validation
141
+ - `prepareSubmittedValues(submittedValues, fieldsSchema)` - Process and normalize values
142
+ - `saveFormSubmission(formConfig, preparedValues)` - Save to database
143
+
144
+ ### DynamicFormRenderer Class
145
+
146
+ - `renderForm(formConfig, fieldsToRender, domain, req, attributes)` - Render complete form
147
+ - `renderFormFields(fieldsToRender, domain, req)` - Render field set
148
+ - `renderFormField(field, domain, submittedValues, errors)` - Render individual field
149
+ - `loadFormTemplate(templateName, domain)` - Load form template with domain fallback
150
+ - `findFormTemplate(templateName, domain)` - Template discovery for forms
151
+
152
+ ### DynamicFormRequestHandler Class
153
+
154
+ - `handleFormSubmission(req, res)` - Process POST form submissions
155
+ - `handleBadRequest(res, message)` - Handle validation errors
156
+ - `handleSuccessResponse(req, res, formKey, result)` - Handle successful submissions
157
+ - `buildErrorRedirectPath(req, error, formKey)` - Build error redirect URLs
158
+ - `buildSuccessRedirectPath(successRedirect, formKey)` - Build success redirect URLs
159
+
160
+ ### FormsTransformer Class
161
+
162
+ - `transform(template, domain, req, systemVariables, enhancedData)` - Process cmsForm tags
163
+ - `findAllFormTags(template)` - Find cmsForm tags in template
164
+ - `parseFormAttributes(fullTag)` - Parse tag attributes
165
+ - `parseFieldsFilter(attributes, formConfig)` - Filter fields based on attributes
166
+
167
+ ## AdminManager Class
168
+
169
+ - `setupAdmin()` - Initialize admin panel
170
+ - `generateListRouteContent()` - Entity list pages
171
+ - `generateEditRouteContent()` - Entity edit forms
172
+ - `processSaveEntity()` - Handle form submissions
@@ -20,7 +20,7 @@ Responsibilities are split across four files:
20
20
  - `lib/manager.js` — orchestration, server config, lifecycle
21
21
  - `lib/manager-component-validator.js` — static validation of provided server/dataServer/adminManager/frontend instances
22
22
  - `lib/manager-config-loader.js` — static `loadFromEnv()` reading all `RELDENS_*` env vars into a config object
23
- - `lib/manager-services-initializer.js` — data server, admin, frontend, entity and route manager initialization; auto-creates `PrismaClient` via `PrismaClientLoader` from `@reldens/storage` when driver is `prisma` and no client is provided
23
+ - `lib/manager-services-initializer.js` — data server, admin, frontend, entity and route manager initialization; auto-loads the Prisma modules via `PrismaClientLoader` from `@reldens/storage` when driver is `prisma` and no `prismaModules` is provided
24
24
 
25
25
  ### Frontend
26
26
 
@@ -379,6 +379,33 @@ Admin UI builder that:
379
379
  - Form field generation
380
380
  - Branding and styling
381
381
 
382
+ ### Delete Relations Warning
383
+
384
+ **File:** `lib/admin-manager/delete-relations-warning.js`
385
+
386
+ Builds the sentences appended to the delete confirmation dialog, so the admin states what actually happens to the
387
+ records that reference the one being deleted. `ContentsBuilder` owns an instance as `this.relationsWarning` and
388
+ calls `buildReverseRelationsMap()` once per admin contents build, then `fetchWarning(entityId, reverseRelations)`
389
+ per entity.
390
+
391
+ `buildReverseRelationsMap()` walks every resource and, for each `type: 'reference'` property, files the child
392
+ entity label under the referenced entity, grouped by what the foreign key does on delete. The group comes from
393
+ `fetchRelationGroup(property.onDelete)`, where `onDelete` is generated by `@reldens/storage` from the live
394
+ `information_schema` delete rule:
395
+
396
+ - `cascade` goes to `deleted`, rendered with `messages.confirmDeleteRelations`.
397
+ - `setNull` and `setDefault` go to `unlinked`, rendered with `messages.confirmUnlinkRelations`.
398
+ - Everything else, including `restrict`, `noAction` and a missing value, goes to `blocking`, rendered with
399
+ `messages.confirmBlockingRelations`.
400
+
401
+ There is deliberately no default claim: `restrict` and `noAction` neither delete nor unlink, they make the delete
402
+ fail, and a missing `onDelete` means the consumer's entities predate the generated attribute. Reporting either of
403
+ those as "will be deleted" was the original bug this grouping replaced.
404
+
405
+ Only the three sentences are produced here. The cms itself never deletes related rows: `RouterContents`
406
+ `processDeleteEntities()` deletes the entity row alone and the database referential actions do the rest, which is
407
+ exactly why the wording has to follow the foreign keys.
408
+
382
409
  ### Admin Filters Manager
383
410
 
384
411
  **File:** `lib/admin-manager/admin-filters-manager.js`