@tamyla/clodo-framework 4.3.3 → 4.3.5

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,458 @@
1
+ # Migration Guide
2
+
3
+ This guide helps existing clodo-framework users migrate to the new programmatic APIs and adapt to breaking changes.
4
+
5
+ ## Overview
6
+
7
+ The clodo-framework has introduced comprehensive programmatic APIs that enable seamless integration with clodo-application. This guide covers:
8
+
9
+ - Migrating from CLI-based workflows to programmatic APIs
10
+ - Adapting to enum and validation changes
11
+ - Using new features and capabilities
12
+ - Best practices for integration
13
+
14
+ ## Breaking Changes
15
+
16
+ ### Enum Validation Changes
17
+
18
+ **What Changed:**
19
+ - Service types now use hyphenated names (e.g., `"api-service"` instead of `"api"`)
20
+ - Feature names have been standardized (e.g., `"upstash"` instead of `"kv"`)
21
+
22
+ **Migration:**
23
+ ```javascript
24
+ // Before (may fail validation)
25
+ const payload = {
26
+ serviceType: 'api',
27
+ features: ['kv', 'metrics']
28
+ };
29
+
30
+ // After (correct)
31
+ const payload = {
32
+ serviceType: 'api-service',
33
+ features: ['upstash', 'metrics']
34
+ };
35
+ ```
36
+
37
+ **Detection Script:**
38
+ ```javascript
39
+ import { getFrameworkCapabilities } from '@tamyla/clodo-framework/api';
40
+
41
+ const capabilities = getFrameworkCapabilities();
42
+
43
+ // Check your current usage against supported values
44
+ console.log('Supported service types:', capabilities.supportedServiceTypes);
45
+ console.log('Supported features:', capabilities.supportedFeatures);
46
+ ```
47
+
48
+ ### Feature Name Changes
49
+
50
+ | Legacy Name | New Name | Purpose |
51
+ |-------------|----------|---------|
52
+ | `kv` | `upstash` | Redis database service |
53
+ | `storage` | `r2` | Object storage |
54
+ | `database` | `d1` | SQL database |
55
+
56
+ ### Validation Strictness
57
+
58
+ **What Changed:**
59
+ - Domain validation is now stricter
60
+ - Service name format is enforced
61
+ - Feature validation includes all array elements
62
+
63
+ **Migration:**
64
+ ```javascript
65
+ // Before (may pass but with warnings)
66
+ const payload = {
67
+ serviceName: 'MyService',
68
+ domain: 'localhost',
69
+ features: ['d1', 'unknown-feature']
70
+ };
71
+
72
+ // After (strict validation)
73
+ const payload = {
74
+ serviceName: 'my-service',
75
+ domain: 'my-service.example.com',
76
+ features: ['d1', 'metrics']
77
+ };
78
+ ```
79
+
80
+ ## Migration Steps
81
+
82
+ ### Step 1: Update Dependencies
83
+
84
+ Ensure you're using the latest framework version:
85
+
86
+ ```bash
87
+ npm update @tamyla/clodo-framework
88
+ # or
89
+ yarn upgrade @tamyla/clodo-framework
90
+ ```
91
+
92
+ ### Step 2: Check Compatibility
93
+
94
+ Add version compatibility checking to your application:
95
+
96
+ ```javascript
97
+ import { checkApplicationCompatibility } from '@tamyla/clodo-framework/api';
98
+
99
+ const compatibility = checkApplicationCompatibility('1.0.0');
100
+
101
+ if (!compatibility.compatible) {
102
+ console.error('Framework version incompatibility:');
103
+ compatibility.breakingChanges.forEach(change => console.error(`- ${change}`));
104
+ process.exit(1);
105
+ }
106
+ ```
107
+
108
+ ### Step 3: Migrate CLI Usage
109
+
110
+ **Before (CLI):**
111
+ ```bash
112
+ npx clodo-service create
113
+ # Interactive prompts...
114
+ ```
115
+
116
+ **After (Programmatic):**
117
+ ```javascript
118
+ import { createServiceProgrammatic } from '@tamyla/clodo-framework/programmatic';
119
+
120
+ const result = await createServiceProgrammatic({
121
+ serviceName: 'my-service',
122
+ serviceType: 'api-service',
123
+ domain: 'api.example.com',
124
+ features: ['d1', 'metrics']
125
+ });
126
+
127
+ if (!result.success) {
128
+ console.error('Service creation failed:', result.errors);
129
+ process.exit(1);
130
+ }
131
+
132
+ console.log(`Service created at: ${result.servicePath}`);
133
+ ```
134
+
135
+ ### Step 4: Update Payloads
136
+
137
+ Create a migration utility to update your existing payloads:
138
+
139
+ ```javascript
140
+ function migratePayload(legacyPayload) {
141
+ const migrated = { ...legacyPayload };
142
+
143
+ // Migrate service types
144
+ const serviceTypeMap = {
145
+ 'api': 'api-service',
146
+ 'data': 'data-service',
147
+ 'static': 'pages'
148
+ };
149
+
150
+ if (serviceTypeMap[migrated.serviceType]) {
151
+ migrated.serviceType = serviceTypeMap[migrated.serviceType];
152
+ }
153
+
154
+ // Migrate features
155
+ const featureMap = {
156
+ 'kv': 'upstash',
157
+ 'storage': 'r2',
158
+ 'database': 'd1'
159
+ };
160
+
161
+ if (migrated.features) {
162
+ migrated.features = migrated.features.map(feature =>
163
+ featureMap[feature] || feature
164
+ );
165
+ }
166
+
167
+ // Fix service name format
168
+ if (migrated.serviceName) {
169
+ migrated.serviceName = migrated.serviceName
170
+ .toLowerCase()
171
+ .replace(/[^a-z0-9-]/g, '-')
172
+ .replace(/-+/g, '-')
173
+ .replace(/^-|-$/g, '');
174
+ }
175
+
176
+ // Fix domain format
177
+ if (migrated.domain && !migrated.domain.includes('.')) {
178
+ migrated.domain = `${migrated.domain}.example.com`;
179
+ }
180
+
181
+ return migrated;
182
+ }
183
+ ```
184
+
185
+ ### Step 5: Add Validation
186
+
187
+ Always validate payloads before creation:
188
+
189
+ ```javascript
190
+ import { validateServicePayload } from '@tamyla/clodo-framework/validation';
191
+
192
+ function createServiceSafely(payload) {
193
+ const validation = validateServicePayload(payload);
194
+
195
+ if (!validation.valid) {
196
+ console.error('Payload validation failed:');
197
+ validation.errors.forEach(error => {
198
+ console.error(`- ${error.field}: ${error.message}`);
199
+ });
200
+ return false;
201
+ }
202
+
203
+ if (validation.warnings.length > 0) {
204
+ console.warn('Payload validation warnings:');
205
+ validation.warnings.forEach(warning => {
206
+ console.warn(`- ${warning.field}: ${warning.message}`);
207
+ });
208
+ }
209
+
210
+ return createServiceProgrammatic(payload);
211
+ }
212
+ ```
213
+
214
+ ### Step 6: Update Error Handling
215
+
216
+ Migrate from CLI error handling to programmatic error handling:
217
+
218
+ ```javascript
219
+ // Before (CLI error handling)
220
+ try {
221
+ execSync('npx clodo-service create', { stdio: 'inherit' });
222
+ } catch (error) {
223
+ console.error('Service creation failed');
224
+ process.exit(1);
225
+ }
226
+
227
+ // After (Programmatic error handling)
228
+ const result = await createServiceProgrammatic(payload);
229
+
230
+ if (!result.success) {
231
+ console.error('Service creation failed:');
232
+ result.errors.forEach(error => {
233
+ console.error(`- ${error.message}`);
234
+ });
235
+
236
+ if (result.warnings.length > 0) {
237
+ console.warn('Warnings:');
238
+ result.warnings.forEach(warning => {
239
+ console.warn(`- ${warning.message}`);
240
+ });
241
+ }
242
+
243
+ process.exit(1);
244
+ }
245
+ ```
246
+
247
+ ## Feature Migration Examples
248
+
249
+ ### Database Integration
250
+
251
+ **Before:**
252
+ ```javascript
253
+ const payload = {
254
+ features: ['database', 'kv']
255
+ };
256
+ ```
257
+
258
+ **After:**
259
+ ```javascript
260
+ const payload = {
261
+ features: ['d1', 'upstash']
262
+ };
263
+ ```
264
+
265
+ ### Static Site with API
266
+
267
+ **Before:**
268
+ ```javascript
269
+ const payload = {
270
+ serviceType: 'static',
271
+ features: ['api']
272
+ };
273
+ ```
274
+
275
+ **After:**
276
+ ```javascript
277
+ const payload = {
278
+ serviceType: 'pages',
279
+ features: ['api-service']
280
+ };
281
+ ```
282
+
283
+ ### Worker with Storage
284
+
285
+ **Before:**
286
+ ```javascript
287
+ const payload = {
288
+ serviceType: 'worker',
289
+ features: ['storage', 'kv']
290
+ };
291
+ ```
292
+
293
+ **After:**
294
+ ```javascript
295
+ const payload = {
296
+ serviceType: 'worker',
297
+ features: ['r2', 'upstash']
298
+ };
299
+ ```
300
+
301
+ ## Testing Migration
302
+
303
+ ### Unit Tests
304
+
305
+ Update your tests to use the new APIs:
306
+
307
+ ```javascript
308
+ // Before
309
+ describe('Service Creation', () => {
310
+ it('creates service via CLI', () => {
311
+ // CLI testing...
312
+ });
313
+ });
314
+
315
+ // After
316
+ describe('Service Creation', () => {
317
+ it('creates service programmatically', async () => {
318
+ const payload = {
319
+ serviceName: 'test-service',
320
+ serviceType: 'api-service',
321
+ domain: 'test.example.com'
322
+ };
323
+
324
+ const result = await createServiceProgrammatic(payload, { dryRun: true });
325
+ expect(result.success).toBe(true);
326
+ });
327
+ });
328
+ ```
329
+
330
+ ### Integration Tests
331
+
332
+ Use the mock framework for integration testing:
333
+
334
+ ```javascript
335
+ import { createMockFramework } from '@tamyla/clodo-framework/testing';
336
+
337
+ describe('Service Integration', () => {
338
+ let mockFramework;
339
+
340
+ beforeEach(() => {
341
+ mockFramework = createMockFramework();
342
+ });
343
+
344
+ it('integrates with application layer', async () => {
345
+ const payload = createMigratedPayload(legacyPayload);
346
+ const result = await mockFramework.createService(payload);
347
+
348
+ expect(result.success).toBe(true);
349
+ expect(mockFramework.getCreatedServices()).toHaveLength(1);
350
+ });
351
+ });
352
+ ```
353
+
354
+ ## Rollback Strategy
355
+
356
+ If migration issues occur, you can temporarily use compatibility mode:
357
+
358
+ ```javascript
359
+ // Temporary compatibility mode (if implemented)
360
+ const result = await createServiceProgrammatic(payload, {
361
+ compatibilityMode: true, // Allow legacy enums
362
+ force: false // Still validate but be more lenient
363
+ });
364
+ ```
365
+
366
+ ## Common Migration Issues
367
+
368
+ ### Issue: "Invalid serviceType"
369
+ **Solution:** Update service types to use hyphens:
370
+ - `"api"` → `"api-service"`
371
+ - `"data"` → `"data-service"`
372
+ - `"static"` → `"pages"`
373
+
374
+ ### Issue: "Invalid features"
375
+ **Solution:** Update feature names:
376
+ - `"kv"` → `"upstash"`
377
+ - `"storage"` → `"r2"`
378
+ - `"database"` → `"d1"`
379
+
380
+ ### Issue: "serviceName format invalid"
381
+ **Solution:** Convert to lowercase and replace invalid characters:
382
+ ```javascript
383
+ serviceName = serviceName
384
+ .toLowerCase()
385
+ .replace(/[^a-z0-9-]/g, '-');
386
+ ```
387
+
388
+ ### Issue: "domain format invalid"
389
+ **Solution:** Ensure proper domain format:
390
+ ```javascript
391
+ if (!domain.includes('.')) {
392
+ domain = `${domain}.example.com`;
393
+ }
394
+ ```
395
+
396
+ ## Support and Resources
397
+
398
+ ### Getting Help
399
+
400
+ 1. Check the [Programmatic API Guide](PROGRAMMATIC_API.md)
401
+ 2. Review the [Parameter Reference](parameter_reference.md)
402
+ 3. Check the [Error Reference](errors.md)
403
+ 4. Use framework capabilities API for current supported values
404
+
405
+ ### Validation Tools
406
+
407
+ ```javascript
408
+ import {
409
+ validateServicePayload,
410
+ getParameterDefinitions,
411
+ getFrameworkCapabilities
412
+ } from '@tamyla/clodo-framework';
413
+
414
+ // Validate your migrated payloads
415
+ const validation = validateServicePayload(migratedPayload);
416
+
417
+ // Get current supported values
418
+ const capabilities = getFrameworkCapabilities();
419
+
420
+ // Get parameter metadata
421
+ const parameters = getParameterDefinitions();
422
+ ```
423
+
424
+ ### Automated Migration
425
+
426
+ Consider creating a migration script:
427
+
428
+ ```javascript
429
+ const fs = require('fs');
430
+ const path = require('path');
431
+
432
+ function migrateConfigFiles(configDir) {
433
+ const files = fs.readdirSync(configDir);
434
+
435
+ files.forEach(file => {
436
+ if (file.endsWith('.json')) {
437
+ const filePath = path.join(configDir, file);
438
+ const config = JSON.parse(fs.readFileSync(filePath, 'utf8'));
439
+
440
+ if (config.serviceType || config.features) {
441
+ const migrated = migratePayload(config);
442
+ fs.writeFileSync(filePath, JSON.stringify(migrated, null, 2));
443
+ console.log(`Migrated ${file}`);
444
+ }
445
+ }
446
+ });
447
+ }
448
+ ```
449
+
450
+ ## Next Steps
451
+
452
+ 1. **Audit existing usage** for enum/feature dependencies
453
+ 2. **Create migration plan** with rollback strategy
454
+ 3. **Test migration** in staging environment
455
+ 4. **Deploy gradually** with feature flags if needed
456
+ 5. **Monitor errors** and provide fallback handling
457
+
458
+ The programmatic APIs provide better error handling, validation, and integration capabilities. Migration may require initial effort but provides long-term benefits for automated workflows and integrations.
package/docs/README.md CHANGED
@@ -1,35 +1,145 @@
1
- # CLODO Framework Documentation
1
+ # 📚 Clodo Framework Documentation
2
2
 
3
- > A comprehensive framework for building Clodo-style microservices on Cloudflare Workers + D1
3
+ > **Public Documentation** - Developer-focused guides and API references for using the Clodo Framework
4
+ > **📦 Included in NPM Package** | **🌐 Developer Portal**
4
5
 
5
- ## 📚 Essential Documentation
6
+ [![npm version](https://badge.fury.io/js/%40tamyla%2Fclodo-framework.svg)](https://badge.fury.io/js/%40tamyla%2Fclodo-framework)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ ![Public](https://img.shields.io/badge/Access-Public-green.svg)
9
+ ![NPM](https://img.shields.io/badge/Included-NPM_Package-blue.svg)
6
10
 
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).
11
+ ## 🚀 Quick Start
8
12
 
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
13
+ ```bash
14
+ npm install @tamyla/clodo-framework
15
+ ```
13
16
 
14
- ### **Package Contents**
15
- This documentation is included in the npm package distribution to provide essential information for developers using the framework.
17
+ ```javascript
18
+ import { createServiceProgrammatic } from '@tamyla/clodo-framework/programmatic';
19
+ import { validateServicePayload } from '@tamyla/clodo-framework/validation';
16
20
 
17
- ## 🆘 Getting Help
21
+ const result = await createServiceProgrammatic({
22
+ serviceName: 'my-api',
23
+ serviceType: 'api-service',
24
+ domain: 'api.example.com',
25
+ features: ['d1', 'metrics']
26
+ });
27
+ ```
18
28
 
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)
29
+ ## 📖 Documentation Guide
22
30
 
23
- ## 📦 Package Information
31
+ ### 🎯 **Start Here**
32
+ - **[Overview](overview.md)** - Framework philosophy and core concepts
33
+ - **[Getting Started](HOWTO_CONSUME_CLODO_FRAMEWORK.md)** - Quick start guide
34
+ - **[Migration Guide](MIGRATION.md)** - Migrating from CLI to programmatic APIs
24
35
 
25
- - **Version**: 1.0.0
26
- - **License**: See repository LICENSE file
27
- - **Repository**: [GitHub](https://github.com/tamylaa/clodo-framework)
36
+ ### 🔧 **API Reference**
37
+ - **[Programmatic API](api/PROGRAMMATIC_API.md)** - Complete programmatic usage guide
38
+ - **[Parameter Reference](api/parameter_reference.md)** - All parameters and validation rules
39
+ - **[API Reference](api-reference.md)** - Traditional API documentation
28
40
 
29
- ---
41
+ ### 🛠️ **Integration & Development**
42
+ - **[Simple API Guide](SIMPLE_API_GUIDE.md)** - Simple API usage patterns
43
+ - **[Integration Guide](integration/README.md)** - Advanced integration patterns
44
+ - **[Security](SECURITY.md)** - Security considerations and best practices
45
+
46
+ ### 📋 **Error Handling**
47
+ - **[Error Reference](errors.md)** - Complete error codes and troubleshooting
48
+
49
+ ### 🏗️ **Architecture & Migration**
50
+ - **[Framework Evolution](FRAMEWORK_EVOLUTION_NARRATIVE.md)** - Development history and validation
51
+ - **[Architecture Overview](architecture/README.md)** - Technical architecture
52
+ - **[Migration Guide](MIGRATION.md)** - Breaking changes and migration steps
53
+
54
+ ## 📂 Directory Structure
55
+
56
+ ```
57
+ docs/
58
+ ├── README.md # This documentation index
59
+ ├── overview.md # Framework overview and philosophy
60
+ ├── HOWTO_CONSUME_...md # Getting started guide
61
+ ├── MIGRATION.md # Migration and breaking changes
62
+ ├── SECURITY.md # Security documentation
63
+ ├── SIMPLE_API_GUIDE.md # Simple API usage
64
+ ├── FRAMEWORK_EVOLUTION...md # Development narrative
65
+ ├── errors.md # Error reference
66
+ ├── api-reference.md # Traditional API docs
67
+ ├── api/ # API documentation
68
+ │ ├── PROGRAMMATIC_API.md # Programmatic API guide
69
+ │ └── parameter_reference.md # Parameter specifications
70
+ ├── integration/ # Integration guides
71
+ ├── architecture/ # Architecture documentation
72
+ └── phases/ # Development phases
73
+ ```
74
+
75
+ ## 🔍 **Finding What You Need**
76
+
77
+ | I want to... | Start with... |
78
+ |-------------|---------------|
79
+ | **Get started quickly** | [HOWTO_CONSUME_CLODO_FRAMEWORK.md](HOWTO_CONSUME_CLODO_FRAMEWORK.md) |
80
+ | **Use programmatic APIs** | [api/PROGRAMMATIC_API.md](api/PROGRAMMATIC_API.md) |
81
+ | **Migrate from CLI** | [MIGRATION.md](MIGRATION.md) |
82
+ | **Handle errors** | [errors.md](errors.md) |
83
+ | **Understand parameters** | [api/parameter_reference.md](api/parameter_reference.md) |
84
+ | **See examples** | [SIMPLE_API_GUIDE.md](SIMPLE_API_GUIDE.md) |
85
+ | **Learn architecture** | [overview.md](overview.md) |
86
+
87
+ ## 🏷️ **Document Types**
88
+
89
+ ### 📘 **Guides** (How-to)
90
+ - **Getting Started**: Step-by-step tutorials
91
+ - **Integration**: Advanced usage patterns
92
+ - **Migration**: Breaking changes and upgrades
93
+
94
+ ### 📖 **References** (What)
95
+ - **API Reference**: Complete API documentation
96
+ - **Parameter Reference**: All parameters and validation
97
+ - **Error Reference**: Error codes and solutions
98
+
99
+ ### 🏛️ **Architecture** (Why)
100
+ - **Overview**: Framework philosophy and concepts
101
+ - **Evolution**: Development history and decisions
102
+ - **Security**: Security considerations
30
103
 
31
- **For comprehensive documentation, visit the [GitHub repository](https://github.com/tamylaa/clodo-framework).**
104
+ ## 🎯 **Developer Experience**
105
+
106
+ ### **Progressive Disclosure**
107
+ - **Quick Start**: Get running in 5 minutes
108
+ - **Deep Dives**: Comprehensive references available
109
+ - **Migration Path**: Clear upgrade guidance
110
+
111
+ ### **Multiple Entry Points**
112
+ - **CLI Users**: Start with migration guide
113
+ - **API Users**: Start with programmatic API guide
114
+ - **New Users**: Start with getting started guide
115
+
116
+ ### **Clear Navigation**
117
+ - **This index** provides overview and navigation
118
+ - **Cross-references** link related documents
119
+ - **Breadcrumbs** show document location in hierarchy
120
+
121
+ ## 📋 **Contributing to Documentation**
122
+
123
+ This documentation is automatically included in the npm package. For comprehensive internal documentation, see the `i-docs/` folder (internal only).
124
+
125
+ ### **Documentation Standards**
126
+ - Public docs focus on **developer usage** and **API reference**
127
+ - Internal docs (`i-docs/`) contain **implementation details** and **planning**
128
+ - Clear separation maintains **professional presentation**
129
+
130
+ ## 🆘 **Getting Help**
131
+
132
+ - **Framework Issues**: [GitHub Issues](https://github.com/tamylaa/clodo-framework/issues)
133
+ - **API Questions**: See [API Reference](api-reference.md)
134
+ - **Security Concerns**: Review [Security Documentation](SECURITY.md)
135
+ - **Migration Help**: See [Migration Guide](MIGRATION.md)
136
+
137
+ ## 📦 **Package Information**
138
+
139
+ - **Version**: See package.json
140
+ - **License**: MIT
141
+ - **Repository**: [GitHub](https://github.com/tamylaa/clodo-framework)
32
142
 
33
143
  ---
34
144
 
35
- **For comprehensive documentation, visit the [GitHub repository](https://github.com/tamylaa/clodo-framework).**
145
+ **For internal documentation and development guides, see the `i-docs/` folder.**