@tamyla/clodo-framework 4.2.0 → 4.3.1

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/CHANGELOG.md CHANGED
@@ -1,46 +1,43 @@
1
- # [4.2.0](https://github.com/tamylaa/clodo-framework/compare/v4.1.0...v4.2.0) (2026-01-31)
1
+ ## [4.3.1](https://github.com/tamylaa/clodo-framework/compare/v4.3.0...v4.3.1) (2026-02-01)
2
2
 
3
3
 
4
- ### Features
4
+ ### Bug Fixes
5
5
 
6
- * **validation:** integrate ConfigurationValidator into ValidationHandler; add post-generation validation in ServiceOrchestrator; tests ([#5](https://github.com/tamylaa/clodo-framework/issues/5)) ([2889864](https://github.com/tamylaa/clodo-framework/commit/28898641bac4c2d6d206e12dbba8216e1de386a3))
6
+ * validate X_BEARER_TOKEN dry-check workflow added (no-op commit to trigger release) ([b28a539](https://github.com/tamylaa/clodo-framework/commit/b28a539af7174e7716ea4a5d4156d64f67087b8b))
7
7
 
8
- # [4.1.0](https://github.com/tamylaa/clodo-framework/compare/v4.0.15...v4.1.0) (2026-01-31)
8
+ # [4.3.0](https://github.com/tamylaa/clodo-framework/compare/v4.2.0...v4.3.0) (2026-02-01)
9
9
 
10
10
 
11
11
  ### Bug Fixes
12
12
 
13
- * **lint:** remove unnecessary escape in serviceName regex to satisfy no-useless-escape ([ac4dcda](https://github.com/tamylaa/clodo-framework/commit/ac4dcdabb39dda3dba3f4e06022f28936a53d645))
13
+ * ensure programmatic feature normalization and DO middleware support are included ([e2e6867](https://github.com/tamylaa/clodo-framework/commit/e2e6867ed96f0619cfd3a07b117a49717c47ac68))
14
+ * only include D1 binding in wrangler.toml when D1 feature enabled; adjust e2e assertion for forced validation report ([7a7b549](https://github.com/tamylaa/clodo-framework/commit/7a7b549aca3b8359ee76825b1bc64cb0815b35c1))
15
+ * **wrangler:** emit KV and R2 bindings conditionally; add unit tests ([36702f3](https://github.com/tamylaa/clodo-framework/commit/36702f3146ce1f12fef6838010e20d2efbfed306))
14
16
 
15
17
 
16
18
  ### Features
17
19
 
18
- * **programmatic-service-api:** programmatic createService + configurable validation ([#4](https://github.com/tamylaa/clodo-framework/issues/4)) ([040f68b](https://github.com/tamylaa/clodo-framework/commit/040f68b9115b604b3f27d7baa14c63122494c5f3))
20
+ * **generator:** emit Durable Object import/binding into middleware runtime when feature enabled ([22b9b14](https://github.com/tamylaa/clodo-framework/commit/22b9b14567038a0f7f73221f31925ee9a2066736))
21
+ * normalize features (kv -> upstash) and add unit tests ([14e5a56](https://github.com/tamylaa/clodo-framework/commit/14e5a564b5cec4016ddbafd2b39e944eee74d40a))
19
22
 
20
- ## [4.0.15](https://github.com/tamylaa/clodo-framework/compare/v4.0.14...v4.0.15) (2026-01-31)
23
+ # [4.2.0](https://github.com/tamylaa/clodo-framework/compare/v4.1.0...v4.2.0) (2026-01-31)
21
24
 
22
25
 
23
- ### Bug Fixes
26
+ ### Features
24
27
 
25
- * **lint:** remove unnecessary escape in semver regex ([72751bd](https://github.com/tamylaa/clodo-framework/commit/72751bdf9a98b2f6b1f97706b175ea31f3aa0df1))
28
+ * **validation:** integrate ConfigurationValidator into ValidationHandler; add post-generation validation in ServiceOrchestrator; tests ([#5](https://github.com/tamylaa/clodo-framework/issues/5)) ([2889864](https://github.com/tamylaa/clodo-framework/commit/28898641bac4c2d6d206e12dbba8216e1de386a3))
26
29
 
27
- ## [4.0.14](https://github.com/tamylaa/clodo-framework/compare/v4.0.13...v4.0.14) (2026-01-19)
30
+ # [4.1.0](https://github.com/tamylaa/clodo-framework/compare/v4.0.15...v4.1.0) (2026-01-31)
28
31
 
29
32
 
30
33
  ### Bug Fixes
31
34
 
32
- * middleware packaging, generators, tests, and packaged-artifact smoke test ([b001434](https://github.com/tamylaa/clodo-framework/commit/b001434697da2145e8778b5c0afd02275cd1604e))
33
- * resolve Windows filesystem timing issues in tests ([7092ca6](https://github.com/tamylaa/clodo-framework/commit/7092ca6ffc230a19d25c96333c0313ead1739f15))
34
-
35
- ## [4.0.13](https://github.com/tamylaa/clodo-framework/compare/v4.0.12...v4.0.13) (2025-12-17)
35
+ * **lint:** remove unnecessary escape in serviceName regex to satisfy no-useless-escape ([ac4dcda](https://github.com/tamylaa/clodo-framework/commit/ac4dcda))
36
36
 
37
37
 
38
- ### Bug Fixes
38
+ ### Features
39
39
 
40
- * collapse 4-level '../../../../lib/' imports to '../../../lib/' in dist ([e0a329e](https://github.com/tamylaa/clodo-framework/commit/e0a329e94390ddad37c7ccd8e6163410c874d7d0))
41
- * handle deeper dist/service-management imports pointing outside dist ([f70d63c](https://github.com/tamylaa/clodo-framework/commit/f70d63cc24571e9691fe900d6a8384ce7f040992))
42
- * resolve CHANGELOG.md merge conflict ([25a044d](https://github.com/tamylaa/clodo-framework/commit/25a044d0d4e2c8f674f777567de1d812c8b49cfa))
43
- * special-case generators/config deep lib import path ([cb74ab0](https://github.com/tamylaa/clodo-framework/commit/cb74ab0a9fb0958cae5065adc750377f751f0b21))
40
+ * **programmatic-service-api:** programmatic createService + configurable validation ([#4](https://github.com/tamylaa/clodo-framework/issues/4)) ([040f68b](https://github.com/tamylaa/clodo-framework/commit/040f68b9115b604b3f27d7baa14c63122494c5f3))
44
41
 
45
42
  ## [4.0.10](https://github.com/tamylaa/clodo-framework/compare/v4.0.9...v4.0.10) (2025-12-10)
46
43
 
@@ -191,8 +188,14 @@ Benefits:
191
188
  * enable missing exports and remove lib-dependent modules from npm ([1645a58](https://github.com/tamylaa/clodo-framework/commit/1645a58d1e1f5d7126fd02766e9b4d006fa45be7))
192
189
  ## [Unreleased]
193
190
 
191
+ ### Features
192
+
193
+ * **programmatic-service-api:** Improve programmatic createService parity and feature normalization. Programmatic payloads now normalize legacy and plural feature names (for example, `kv` → `upstash`, and `durableObjects` ↔ `durableObject`) and merge normalized features into confirmed configuration values. The service middleware generator now emits Durable Object imports/bindings into the generated middleware runtime when Durable Objects are enabled. (refs: #6; commits: `14e5a56`, `7c0ce37`, `22b9b14`)
194
+
194
195
  ### Bug Fixes
195
196
 
197
+ * **compatibility:** Accept legacy `kv` alias in payload validation and normalize to `upstash` to preserve backward compatibility with older programmatic payloads. (commits: `14e5a56`, `52b8090`)
198
+ * **durable objects:** Accept `durableObjects` plural in allowed feature enums and ensure generated middleware includes Durable Object imports/bindings when enabled; fixed E2E parity tests. (commits: `779040c`, `22b9b14`)
196
199
  * Fix import paths in `dist/` to ensure packaged artifact resolves internal modules correctly (fixed `wrangler-deployer` and `WranglerTomlGenerator`).
197
200
  * Add `scripts/utilities/check-dist-imports.js` and `scripts/utilities/test-packaged-artifact.js` and include packaged-artifact smoke test in release workflow.
198
201
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  let config = {
5
5
  serviceTypes: ['api-service', 'data-service', 'worker', 'pages', 'gateway', 'generic'],
6
- features: ['d1', 'upstash', 'r2', 'pages', 'ws', 'durableObject', 'cron', 'metrics']
6
+ features: ['d1', 'upstash', 'kv', 'r2', 'pages', 'ws', 'durableObject', 'durableObjects', 'cron', 'metrics']
7
7
  };
8
8
  export function getConfig() {
9
9
  return {
@@ -17,6 +17,6 @@ export function setConfig(updates = {}) {
17
17
  export function resetConfig() {
18
18
  config = {
19
19
  serviceTypes: ['api-service', 'data-service', 'worker', 'pages', 'gateway', 'generic'],
20
- features: ['d1', 'upstash', 'r2', 'pages', 'ws', 'durableObject', 'cron', 'metrics']
20
+ features: ['d1', 'upstash', 'kv', 'r2', 'pages', 'ws', 'durableObject', 'durableObjects', 'cron', 'metrics']
21
21
  };
22
22
  }
@@ -13,6 +13,7 @@ import { ConfirmationHandler } from './handlers/ConfirmationHandler.js';
13
13
  import { GenerationHandler } from './handlers/GenerationHandler.js';
14
14
  import { WranglerConfigManager } from '../utils/deployment/wrangler-config-manager.js';
15
15
  import { ValidationHandler } from './handlers/ValidationHandler.js';
16
+ import { normalizeFeatures } from '../validation/payloadNormalization.js';
16
17
 
17
18
  // Legacy imports for backward compatibility
18
19
  import { ErrorTracker } from './ErrorTracker.js';
@@ -126,7 +127,24 @@ export class ServiceOrchestrator {
126
127
  };
127
128
  try {
128
129
  // Generate derived confirmations and run generation
129
- const confirmedValues = await this.confirmationHandler.generateAndConfirm(coreInputs);
130
+ let confirmedValues = await this.confirmationHandler.generateAndConfirm(coreInputs);
131
+
132
+ // Respect features passed in the programmatic payload by merging them into confirmedValues
133
+ if (payload.features && Array.isArray(payload.features)) {
134
+ // Normalize features (e.g., accept legacy 'kv' alias and enable provider flags like 'upstash')
135
+ payload.features = normalizeFeatures(payload.features);
136
+ const featureMap = payload.features.reduce((acc, f) => ({
137
+ ...acc,
138
+ [f]: true
139
+ }), {});
140
+ confirmedValues = {
141
+ ...confirmedValues,
142
+ features: {
143
+ ...(confirmedValues.features || {}),
144
+ ...featureMap
145
+ }
146
+ };
147
+ }
130
148
  const generationResult = await this.generationHandler.generateService(coreInputs, confirmedValues, {
131
149
  outputPath: options.outputDir || this.outputPath,
132
150
  middlewareStrategy: this.middlewareStrategy
@@ -140,7 +140,13 @@ export function registerMiddleware(registry, serviceName) {
140
140
  this.logger.info(`Generated: ${filePath}`);
141
141
 
142
142
  // Also generate a lightweight runtime helper for middleware composition and registry
143
- const runtimeContent = `// Lightweight middleware runtime for generated services
143
+ let runtimeContent = '';
144
+
145
+ // If Durable Objects are enabled (support both singular/plural feature names), inject DO imports/bindings
146
+ if (confirmedValues.features && (confirmedValues.features.durableObjects || confirmedValues.features.durableObject)) {
147
+ runtimeContent += `// Durable Object imports and bindings\nimport { DurableObject } from '@cloudflare/workers-types';\nexport const DURABLE_OBJECT = { type: 'durable_object', className: 'MyDurableObject' };\n\n`;
148
+ }
149
+ runtimeContent += `// Lightweight middleware runtime for generated services
144
150
  export const MiddlewareRegistry = (() => {
145
151
  const map = new Map();
146
152
  return {
@@ -147,6 +147,34 @@ export class WranglerTomlGenerator extends BaseGenerator {
147
147
  // Fall back to default configuration if detection fails
148
148
  console.warn(`⚠️ Wrangler compatibility detection failed, using defaults: ${error.message}`);
149
149
  }
150
+
151
+ // Only include D1/kv/r2 bindings when the confirmed values indicate features are enabled
152
+ const d1Block = confirmedValues.features && confirmedValues.features.d1 ? `
153
+
154
+ # Database bindings
155
+ [[d1_databases]]
156
+ binding = "DB"
157
+ database_name = "${confirmedValues.databaseName}"
158
+ database_id = "" # To be configured during setup
159
+ ` : '';
160
+
161
+ // Support both generic KV flag and provider-specific flag (upstash)
162
+ const kvEnabled = confirmedValues.features && (confirmedValues.features.kv || confirmedValues.features.upstash);
163
+ const kvBlock = kvEnabled ? `
164
+
165
+ # KV namespaces
166
+ [[kv_namespaces]]
167
+ binding = "KV"
168
+ namespace_id = "" # To be configured during setup
169
+ ` : '';
170
+ const r2Block = confirmedValues.features && confirmedValues.features.r2 ? `
171
+
172
+ # R2 buckets
173
+ [[r2_buckets]]
174
+ binding = "R2_STORAGE"
175
+ bucket_name = "${confirmedValues.bucketName || confirmedValues.databaseName || ''}"
176
+ bucket_id = "" # To be configured during setup
177
+ ` : '';
150
178
  return `# Cloudflare Workers Configuration for ${confirmedValues.displayName}
151
179
  name = "${confirmedValues.workerName}"
152
180
  main = "src/worker/index.js"
@@ -169,12 +197,7 @@ name = "${confirmedValues.workerName}-staging"
169
197
  [env.production]
170
198
  name = "${confirmedValues.workerName}"
171
199
 
172
- # Database bindings
173
- [[d1_databases]]
174
- binding = "DB"
175
- database_name = "${confirmedValues.databaseName}"
176
- database_id = "" # To be configured during setup
177
-
200
+ ${d1Block}${kvBlock}${r2Block}
178
201
  # Environment variables
179
202
  [vars]
180
203
  SERVICE_NAME = "${coreInputs.serviceName}"
@@ -13,10 +13,17 @@ export class ServiceManifestGenerator {
13
13
  * @returns {Object} Service manifest
14
14
  */
15
15
  createManifest(coreInputs, confirmedValues, generatedFiles) {
16
+ // Derive explicit top-level feature booleans for quick manifest checks (e.g., D1/KV/R2)
17
+ const features = confirmedValues.features || {};
16
18
  return {
17
19
  manifestVersion: '1.0.0',
18
20
  frameworkVersion: '3.0.0',
19
21
  generatedAt: new Date().toISOString(),
22
+ // Top-level feature flags for ConfigurationValidator compatibility
23
+ d1: !!features.d1,
24
+ // kv may be represented via a provider flag (e.g., upstash) - accept either
25
+ kv: !!(features.kv || features.upstash),
26
+ r2: !!features.r2,
20
27
  service: {
21
28
  name: coreInputs.serviceName,
22
29
  displayName: confirmedValues.displayName,
@@ -0,0 +1,20 @@
1
+ // Normalize feature arrays for consistent internal representation
2
+ export function normalizeFeatures(featuresArray = []) {
3
+ if (!Array.isArray(featuresArray)) return [];
4
+ const normalized = new Set(featuresArray.map(f => f && String(f).trim()));
5
+
6
+ // Backwards compatibility: if 'kv' is present, ensure provider flag 'upstash' is also present
7
+ if (normalized.has('kv') && !normalized.has('upstash')) {
8
+ normalized.add('upstash');
9
+ }
10
+
11
+ // Durable Objects: accept both singular/plural variants for compatibility
12
+ if (normalized.has('durableObject') && !normalized.has('durableObjects')) {
13
+ normalized.add('durableObjects');
14
+ }
15
+ if (normalized.has('durableObjects') && !normalized.has('durableObject')) {
16
+ normalized.add('durableObject');
17
+ }
18
+ return Array.from(normalized);
19
+ }
20
+ export default normalizeFeatures;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamyla/clodo-framework",
3
- "version": "4.2.0",
3
+ "version": "4.3.1",
4
4
  "description": "Reusable framework for Clodo-style software architecture on Cloudflare Workers + D1",
5
5
  "type": "module",
6
6
  "sideEffects": [