@tamyla/clodo-framework 2.0.0 → 2.0.2

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.
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Scripts Manager
3
+ *
4
+ * Manages and executes development scripts from the scripts/ directory
5
+ * Provides interactive access to generated deployment and utility scripts
6
+ */
7
+
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import { exec } from 'child_process';
11
+ import { promisify } from 'util';
12
+ const execAsync = promisify(exec);
13
+ class ScriptsManager {
14
+ constructor() {
15
+ this.scriptsDir = path.join(process.cwd(), 'scripts');
16
+ this.scripts = new Map();
17
+ }
18
+
19
+ /**
20
+ * Load available scripts from scripts/ directory
21
+ */
22
+ async loadScripts() {
23
+ if (!fs.existsSync(this.scriptsDir)) {
24
+ return;
25
+ }
26
+ const subdirs = ['database', 'deployment', 'service-management', 'testing', 'utilities'];
27
+ for (const subdir of subdirs) {
28
+ const subdirPath = path.join(this.scriptsDir, subdir);
29
+ if (fs.existsSync(subdirPath)) {
30
+ await this.loadScriptsFromDir(subdirPath, subdir);
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Load scripts from a specific directory
37
+ */
38
+ async loadScriptsFromDir(dirPath, category) {
39
+ const files = fs.readdirSync(dirPath).filter(f => f.endsWith('.js') || f.endsWith('.ps1') || f.endsWith('.sh'));
40
+ for (const file of files) {
41
+ const filePath = path.join(dirPath, file);
42
+ const scriptName = path.basename(file, path.extname(file));
43
+ const scriptKey = `${category}/${scriptName}`;
44
+ this.scripts.set(scriptKey, {
45
+ name: scriptName,
46
+ path: filePath,
47
+ category,
48
+ extension: path.extname(file),
49
+ description: await this.getScriptDescription(filePath)
50
+ });
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Get script description from file content or comments
56
+ */
57
+ async getScriptDescription(filePath) {
58
+ try {
59
+ const content = fs.readFileSync(filePath, 'utf8');
60
+ const lines = content.split('\n').slice(0, 10);
61
+ for (const line of lines) {
62
+ const commentMatch = line.match(/^\s*\/\*\*\s*@description\s+(.+)\s*\*\//) || line.match(/^\s*#\s*@description\s+(.+)/) || line.match(/^\s*\/\/\s*@description\s+(.+)/);
63
+ if (commentMatch) {
64
+ return commentMatch[1].trim();
65
+ }
66
+ }
67
+
68
+ // Fallback: first comment line
69
+ for (const line of lines) {
70
+ const commentMatch = line.match(/^\s*\/\*\*\s*(.+)\s*\*\//) || line.match(/^\s*#\s*(.+)/) || line.match(/^\s*\/\/\s*(.+)/);
71
+ if (commentMatch && !commentMatch[1].includes('@')) {
72
+ return commentMatch[1].trim();
73
+ }
74
+ }
75
+ } catch (error) {
76
+ // Ignore errors
77
+ }
78
+ return 'No description available';
79
+ }
80
+
81
+ /**
82
+ * Get all available scripts
83
+ */
84
+ getAllScripts() {
85
+ return Array.from(this.scripts.values());
86
+ }
87
+
88
+ /**
89
+ * Get scripts by category
90
+ */
91
+ getScriptsByCategory(category) {
92
+ return Array.from(this.scripts.values()).filter(script => script.category === category);
93
+ }
94
+
95
+ /**
96
+ * Execute a script
97
+ */
98
+ async executeScript(scriptKey, args = []) {
99
+ const script = this.scripts.get(scriptKey);
100
+ if (!script) {
101
+ throw new Error(`Script not found: ${scriptKey}`);
102
+ }
103
+ const command = this.buildCommand(script, args);
104
+ try {
105
+ const {
106
+ stdout,
107
+ stderr
108
+ } = await execAsync(command);
109
+ return {
110
+ stdout,
111
+ stderr,
112
+ success: true
113
+ };
114
+ } catch (error) {
115
+ return {
116
+ stdout: error.stdout,
117
+ stderr: error.stderr,
118
+ success: false,
119
+ error: error.message
120
+ };
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Build execution command based on script type
126
+ */
127
+ buildCommand(script, args) {
128
+ const argsStr = args.join(' ');
129
+ switch (script.extension) {
130
+ case '.js':
131
+ return `node "${script.path}" ${argsStr}`;
132
+ case '.ps1':
133
+ return `powershell -ExecutionPolicy Bypass -File "${script.path}" ${argsStr}`;
134
+ case '.sh':
135
+ return `bash "${script.path}" ${argsStr}`;
136
+ default:
137
+ throw new Error(`Unsupported script type: ${script.extension}`);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * List available scripts in a formatted way
143
+ */
144
+ listScripts() {
145
+ const scripts = this.getAllScripts();
146
+ const categories = {};
147
+ scripts.forEach(script => {
148
+ if (!categories[script.category]) {
149
+ categories[script.category] = [];
150
+ }
151
+ categories[script.category].push(script);
152
+ });
153
+ let output = 'Available Scripts:\n\n';
154
+ for (const [category, scripts] of Object.entries(categories)) {
155
+ output += `${category.toUpperCase()}:\n`;
156
+ scripts.forEach(script => {
157
+ output += ` ${script.name}: ${script.description}\n`;
158
+ });
159
+ output += '\n';
160
+ }
161
+ return output;
162
+ }
163
+ }
164
+
165
+ // Export singleton instance
166
+ export const scriptsManager = new ScriptsManager();
167
+ export default scriptsManager;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * UI Structures Loader
3
+ *
4
+ * Loads and provides access to UI templates from ui-structures directory
5
+ * These templates define the interactive data collection workflows
6
+ */
7
+
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ class UIStructuresLoader {
11
+ constructor() {
12
+ this.templates = new Map();
13
+ this.loaded = false;
14
+ }
15
+
16
+ /**
17
+ * Load all UI structure templates
18
+ */
19
+ async loadTemplates() {
20
+ if (this.loaded) return;
21
+ const uiStructuresDir = path.join(process.cwd(), 'ui-structures');
22
+
23
+ // Load creation templates
24
+ const creationDir = path.join(uiStructuresDir, 'creation');
25
+ if (fs.existsSync(creationDir)) {
26
+ const creationFiles = fs.readdirSync(creationDir).filter(f => f.endsWith('.json'));
27
+ for (const file of creationFiles) {
28
+ const filePath = path.join(creationDir, file);
29
+ const content = fs.readFileSync(filePath, 'utf8');
30
+ const template = JSON.parse(content);
31
+ this.templates.set(template.template.name, template);
32
+ }
33
+ }
34
+
35
+ // Load reference templates
36
+ const referenceDir = path.join(uiStructuresDir, 'reference');
37
+ if (fs.existsSync(referenceDir)) {
38
+ const referenceFiles = fs.readdirSync(referenceDir).filter(f => f.endsWith('.json'));
39
+ for (const file of referenceFiles) {
40
+ const filePath = path.join(referenceDir, file);
41
+ const content = fs.readFileSync(filePath, 'utf8');
42
+ const template = JSON.parse(content);
43
+ // Use template.name if available, otherwise filename
44
+ const name = template.template?.name || path.basename(file, '.json');
45
+ this.templates.set(name, template);
46
+ }
47
+ }
48
+ this.loaded = true;
49
+ }
50
+
51
+ /**
52
+ * Get a specific template by name
53
+ */
54
+ getTemplate(name) {
55
+ return this.templates.get(name);
56
+ }
57
+
58
+ /**
59
+ * Get all templates
60
+ */
61
+ getAllTemplates() {
62
+ return Array.from(this.templates.values());
63
+ }
64
+
65
+ /**
66
+ * Get templates by category
67
+ */
68
+ getTemplatesByCategory(category) {
69
+ return Array.from(this.templates.values()).filter(template => template.template?.category === category);
70
+ }
71
+
72
+ /**
73
+ * Get core inputs UI template
74
+ */
75
+ getCoreInputsTemplate() {
76
+ return this.getTemplate('core-inputs-ui');
77
+ }
78
+
79
+ /**
80
+ * Get smart confirmable UI template
81
+ */
82
+ getSmartConfirmableTemplate() {
83
+ return this.getTemplate('smart-confirmable-ui');
84
+ }
85
+
86
+ /**
87
+ * Get automated generation UI template
88
+ */
89
+ getAutomatedGenerationTemplate() {
90
+ return this.getTemplate('automated-generation-ui');
91
+ }
92
+
93
+ /**
94
+ * Get service manifest template
95
+ */
96
+ getServiceManifestTemplate() {
97
+ return this.getTemplate('service-manifest');
98
+ }
99
+
100
+ /**
101
+ * Get absolutely required inputs reference
102
+ */
103
+ getAbsolutelyRequiredInputs() {
104
+ return this.getTemplate('absolutely-required-inputs');
105
+ }
106
+ }
107
+
108
+ // Export singleton instance
109
+ export const uiStructuresLoader = new UIStructuresLoader();
110
+ export default uiStructuresLoader;
package/docs/README.md CHANGED
@@ -1,82 +1,35 @@
1
- # Clodo Framework Documentation
1
+ # CLODO Framework Documentation
2
2
 
3
3
  > A comprehensive framework for building Clodo-style microservices on Cloudflare Workers + D1
4
4
 
5
- ## 📚 Documentation Structure
5
+ ## 📚 Essential Documentation
6
6
 
7
- ### **Getting Started**
8
- - **[Overview](./overview.md)** - Framework philosophy and core concepts
9
- - **[Developer Guide](./guides/developer-guide.md)** - Comprehensive guide for external developers
10
- - **[Quick Start Guide](./guides/getting-started.md)** - Build your first service in 5 minutes
11
- - **[Installation](./guides/installation.md)** - Setup and prerequisites
12
-
13
- ### **Architecture**
14
- - **[Framework Architecture Overview](./FRAMEWORK-ARCHITECTURE-OVERVIEW.md)** - User-friendly architecture guide
15
- - **[Framework Architecture Analysis](./FRAMEWORK-ARCHITECTURE-ANALYSIS.md)** - Detailed technical analysis (internal)
16
- - **[Core Components](./architecture/components.md)** - Deep dive into framework modules
17
- - **[Configuration System](./architecture/configuration.md)** - Domain and feature management
18
- - **[Data Layer](./architecture/data-layer.md)** - Services, schemas, and database integration
19
- - **[Worker Integration](./architecture/worker-integration.md)** - Cloudflare Workers patterns
20
-
21
- ### **Guides**
22
- - **[Creating Services](./guides/creating-services.md)** - Service generation and templates
23
- - **[Domain Configuration](./guides/domain-configuration.md)** - Multi-tenant setup
24
- - **[Feature Management](./guides/feature-flags.md)** - Feature flags and runtime control
25
- - **[Authentication](./guides/authentication.md)** - Security patterns and implementation
26
- - **[Database Operations](./guides/database-operations.md)** - CRUD patterns and data modeling
27
-
28
- ### **Deployment**
29
- - **[Environment Setup](./deployment/environment-setup.md)** - Cloudflare and local development
30
- - **[Deployment Guide](./deployment/deployment-guide.md)** - Production deployment strategies
31
- - **[CI/CD Integration](./deployment/ci-cd.md)** - Automated deployment pipelines
32
- - **[Monitoring](./deployment/monitoring.md)** - Observability and debugging
33
-
34
- ### **API Reference**
35
- - **[Core Classes](./api/core-classes.md)** - Framework class references
36
- - **[Configuration API](./api/configuration.md)** - Domain and feature APIs
37
- - **[Service API](./api/services.md)** - Data service interfaces
38
- - **[Worker Helpers](./api/worker-helpers.md)** - Cloudflare Worker utilities
39
- - **[CLI Tools](./api/cli-tools.md)** - Command-line interface documentation
7
+ This folder contains **only essential, public-facing documentation** that is distributed with the npm package. For comprehensive documentation, examples, and guides, visit the [GitHub repository](https://github.com/tamylaa/clodo-framework).
40
8
 
41
- ### **Examples**
42
- - **[Basic CRUD Service](./examples/basic-crud.md)** - Simple data service example
43
- - **[Multi-Tenant SaaS](./examples/multi-tenant-saas.md)** - Complex multi-domain setup
44
- - **[Authentication Service](./examples/auth-service.md)** - JWT-based authentication
45
- - **[API Gateway](./examples/api-gateway.md)** - Service orchestration patterns
9
+ ### **Core Documentation**
10
+ - **[Overview](./overview.md)** - Framework philosophy and core concepts
11
+ - **[Security](./SECURITY.md)** - Security considerations and best practices
12
+ - **[API Reference](./api-reference.md)** - Complete API documentation
46
13
 
47
- ### **Decision Framework**
48
- - **[When to Use](./decision-framework.md)** - Use cases and anti-patterns
49
- - **[Alternatives](./alternatives.md)** - Other approaches and trade-offs
50
- - **[Migration Guide](./migration-guide.md)** - Moving to/from the framework
14
+ ### **Package Contents**
15
+ This documentation is included in the npm package distribution to provide essential information for developers using the framework.
51
16
 
52
- ## 🚀 Quick Navigation
17
+ ## 🆘 Getting Help
53
18
 
54
- | I want to... | Go to |
55
- |--------------|--------|
56
- | **Understand the framework** | [Overview](./overview.md) |
57
- | **Learn comprehensive usage** | [Developer Guide](./guides/developer-guide.md) |
58
- | **Build my first service** | [Getting Started](./guides/getting-started.md) |
59
- | **Configure domains** | [Domain Configuration](./guides/domain-configuration.md) |
60
- | **Deploy to production** | [Deployment Guide](./deployment/deployment-guide.md) |
61
- | **Find API documentation** | [API Reference](./api/README.md) |
62
- | **See real examples** | [Examples](./examples/README.md) |
63
- | **Decide if this is right for me** | [Decision Framework](./decision-framework.md) |
19
+ - **Framework Issues**: [GitHub Issues](https://github.com/tamylaa/clodo-framework/issues)
20
+ - **Security Concerns**: Review [Security Documentation](./SECURITY.md)
21
+ - **API Questions**: See [API Reference](./api-reference.md)
64
22
 
65
- ## 🆘 Getting Help
23
+ ## 📦 Package Information
66
24
 
67
- - **Documentation Issues**: Open an issue in the repository
68
- - **Framework Bugs**: Report via GitHub Issues
69
- - **Questions**: Check existing issues or create a new discussion
70
- - **Contributing**: See [Contributing Guide](../CONTRIBUTING.md)
25
+ - **Version**: 1.0.0
26
+ - **License**: See repository LICENSE file
27
+ - **Repository**: [GitHub](https://github.com/tamylaa/clodo-framework)
71
28
 
72
- ## 🔗 External Resources
29
+ ---
73
30
 
74
- - **[Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)**
75
- - **[D1 Database Documentation](https://developers.cloudflare.com/d1/)**
76
- - **[Wrangler CLI Documentation](https://developers.cloudflare.com/workers/wrangler/)**
31
+ **For comprehensive documentation, visit the [GitHub repository](https://github.com/tamylaa/clodo-framework).**
77
32
 
78
33
  ---
79
34
 
80
- **Framework Version**: 1.0.0
81
- **Last Updated**: September 27, 2025
82
- **Cloudflare Workers Runtime**: Compatible with 2023-05-18 and later
35
+ **For comprehensive documentation, visit the [GitHub repository](https://github.com/tamylaa/clodo-framework).**