@umituz/web-cloudflare 1.3.0 → 1.4.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/README.md +13 -7
- package/package.json +3 -3
- package/src/domains/ai-gateway/index.ts +10 -0
- package/src/{infrastructure/services/ai-gateway → domains/ai-gateway/services}/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/infrastructure/domain/workflows.entity.ts +0 -108
- /package/src/{infrastructure/domain/ai-gateway.entity.ts → domains/ai-gateway/entities/index.ts} +0 -0
package/README.md
CHANGED
|
@@ -5,12 +5,14 @@ Comprehensive Cloudflare Workers integration with config-based patterns, middlew
|
|
|
5
5
|
## 🚀 Features
|
|
6
6
|
|
|
7
7
|
- ✅ **Config-Based Patterns** - Pre-built configurations for different app types
|
|
8
|
+
- ✅ **Domain-Driven Design** - DDD architecture for better modularity
|
|
8
9
|
- ✅ **Wrangler CLI Integration** - TypeScript wrapper for Wrangler CLI commands
|
|
10
|
+
- ✅ **Workers Service** - HTTP handler with routing and middleware
|
|
11
|
+
- ✅ **AI Gateway** - Multi-provider AI routing with caching and fallback
|
|
12
|
+
- ✅ **Workers AI Integration** - AI content generation with emotion control
|
|
9
13
|
- ✅ **Express-like Router** - Simple, intuitive routing with middleware support
|
|
10
14
|
- ✅ **Comprehensive Middleware** - CORS, caching, rate limiting, security, compression
|
|
11
|
-
- ✅ **Workers AI Integration** - AI content generation with emotion control
|
|
12
15
|
- ✅ **Workflows** - Idempotent, retryable long-running operations
|
|
13
|
-
- ✅ **AI Gateway** - Multi-provider AI routing with caching and fallback
|
|
14
16
|
- ✅ **Utility Functions** - 100+ helper functions for common tasks
|
|
15
17
|
- ✅ **Type-Safe** - Full TypeScript support
|
|
16
18
|
- ✅ **Tree-Shakeable** - Subpath exports for optimal bundle size
|
|
@@ -175,7 +177,7 @@ const versions = await wrangler.versionsList();
|
|
|
175
177
|
await wrangler.versionsRollback(versions[0].id);
|
|
176
178
|
```
|
|
177
179
|
|
|
178
|
-
**Note:** Wrangler CLI and
|
|
180
|
+
**Note:** Wrangler CLI, Workers, and AI Gateway services now follow Domain-Driven Design (DDD) architecture with their own domain structures at `src/domains/wrangler/`, `src/domains/workers/`, and `src/domains/ai-gateway/`.
|
|
179
181
|
|
|
180
182
|
## 📚 Subpath Exports
|
|
181
183
|
|
|
@@ -210,10 +212,10 @@ import { WranglerService } from '@umituz/web-cloudflare/wrangler';
|
|
|
210
212
|
// Workflows orchestration
|
|
211
213
|
import { WorkflowService, WORKFLOW_TEMPLATES } from '@umituz/web-cloudflare/workflows';
|
|
212
214
|
|
|
213
|
-
// AI Gateway
|
|
215
|
+
// AI Gateway (now in domains/)
|
|
214
216
|
import { AIGatewayService } from '@umituz/web-cloudflare/ai-gateway';
|
|
215
217
|
|
|
216
|
-
// Workers AI
|
|
218
|
+
// Workers AI (now in domains/)
|
|
217
219
|
import { WorkersAIService } from '@umituz/web-cloudflare/workers-ai';
|
|
218
220
|
```
|
|
219
221
|
|
|
@@ -654,10 +656,14 @@ Contributions are welcome!
|
|
|
654
656
|
│ │ │ ├── services/ # Domain services
|
|
655
657
|
│ │ │ ├── types/ # Domain types
|
|
656
658
|
│ │ │ └── index.ts # Domain exports
|
|
657
|
-
│ │
|
|
659
|
+
│ │ ├── workers/ # Workers domain
|
|
660
|
+
│ │ │ ├── entities/ # Domain entities
|
|
661
|
+
│ │ │ ├── services/ # Domain services
|
|
662
|
+
│ │ │ ├── types/ # Domain types
|
|
663
|
+
│ │ │ └── index.ts # Domain exports
|
|
664
|
+
│ │ └── ai-gateway/ # AI Gateway domain
|
|
658
665
|
│ │ ├── entities/ # Domain entities
|
|
659
666
|
│ │ ├── services/ # Domain services
|
|
660
|
-
│ │ ├── types/ # Domain types
|
|
661
667
|
│ │ └── index.ts # Domain exports
|
|
662
668
|
│ ├── infrastructure/
|
|
663
669
|
│ │ ├── services/ # Services (kv, r2, d1, etc.)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-cloudflare",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Comprehensive Cloudflare Workers integration with config-based patterns, middleware, router, workflows, and AI",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"./images": "./src/infrastructure/services/images/index.ts",
|
|
15
15
|
"./analytics": "./src/infrastructure/services/analytics/index.ts",
|
|
16
16
|
"./workflows": "./src/infrastructure/services/workflows/index.ts",
|
|
17
|
-
"./ai-gateway": "./src/
|
|
18
|
-
"./workers-ai": "./src/
|
|
17
|
+
"./ai-gateway": "./src/domains/ai-gateway/index.ts",
|
|
18
|
+
"./workers-ai": "./src/domains/ai-gateway/index.ts",
|
|
19
19
|
"./wrangler": "./src/domains/wrangler/index.ts",
|
|
20
20
|
"./router": "./src/infrastructure/router/index.ts",
|
|
21
21
|
"./middleware": "./src/infrastructure/middleware/index.ts",
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
AIResponse,
|
|
10
10
|
AIProvider,
|
|
11
11
|
AIAnalytics,
|
|
12
|
-
} from '
|
|
12
|
+
} from '../entities';
|
|
13
13
|
|
|
14
14
|
export class AIGatewayService {
|
|
15
15
|
private config: AIGatewayConfig;
|
|
@@ -211,7 +211,7 @@ import type {
|
|
|
211
211
|
WorkersAIInputs,
|
|
212
212
|
ScriptGenerationRequest,
|
|
213
213
|
EmotionControl,
|
|
214
|
-
} from '
|
|
214
|
+
} from '../entities';
|
|
215
215
|
|
|
216
216
|
export class WorkersAIService {
|
|
217
217
|
private env: {
|
package/src/index.ts
CHANGED
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
// Domains
|
|
29
29
|
export * from "./domains/wrangler";
|
|
30
30
|
export * from "./domains/workers";
|
|
31
|
+
export * from "./domains/ai-gateway";
|
|
31
32
|
export * from "./infrastructure/services/kv";
|
|
32
33
|
export * from "./infrastructure/services/r2";
|
|
33
34
|
export * from "./infrastructure/services/d1";
|
|
34
35
|
export * from "./infrastructure/services/images";
|
|
35
36
|
export * from "./infrastructure/services/analytics";
|
|
36
37
|
export * from "./infrastructure/services/workflows";
|
|
37
|
-
export * from "./infrastructure/services/ai-gateway";
|
|
38
38
|
|
|
39
39
|
// Infrastructure - Router, Middleware, Utils
|
|
40
40
|
export * from "./infrastructure/router";
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cloudflare Workflows Domain Entity
|
|
3
|
-
* @description Workflow types for long-running, retryable operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export interface WorkflowDefinition {
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
description: string;
|
|
10
|
-
version: string;
|
|
11
|
-
steps: WorkflowStep[];
|
|
12
|
-
retryConfig?: RetryConfig;
|
|
13
|
-
timeout?: number; // seconds
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface WorkflowStep {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
handler: string; // Function name to execute
|
|
20
|
-
inputs?: Record<string, unknown>;
|
|
21
|
-
outputs?: Record<string, unknown>;
|
|
22
|
-
retryPolicy?: StepRetryPolicy;
|
|
23
|
-
timeout?: number; // seconds
|
|
24
|
-
dependencies?: string[]; // Step IDs that must complete first
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface StepRetryPolicy {
|
|
28
|
-
maxAttempts: number;
|
|
29
|
-
backoffMultiplier: number;
|
|
30
|
-
initialDelay: number; // milliseconds
|
|
31
|
-
maxDelay: number; // milliseconds
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface RetryConfig {
|
|
35
|
-
maxRetries: number;
|
|
36
|
-
backoffMultiplier: number;
|
|
37
|
-
initialDelay: number;
|
|
38
|
-
maxDelay: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface WorkflowExecution {
|
|
42
|
-
id: string;
|
|
43
|
-
workflowId: string;
|
|
44
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'retrying';
|
|
45
|
-
currentStep?: string;
|
|
46
|
-
completedSteps: string[];
|
|
47
|
-
failedSteps: string[];
|
|
48
|
-
inputs: Record<string, unknown>;
|
|
49
|
-
outputs?: Record<string, unknown>;
|
|
50
|
-
error?: string;
|
|
51
|
-
startedAt: number;
|
|
52
|
-
completedAt?: number;
|
|
53
|
-
retryCount: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface WorkflowInstanceState {
|
|
57
|
-
executionId: string;
|
|
58
|
-
stepId: string;
|
|
59
|
-
data: Record<string, unknown>;
|
|
60
|
-
timestamp: number;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Predefined workflow templates
|
|
64
|
-
export interface WorkflowTemplate {
|
|
65
|
-
type: 'media-processing' | 'batch-operations' | 'ai-generation' | 'scheduled-tasks';
|
|
66
|
-
definition: Partial<WorkflowDefinition>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface MediaProcessingWorkflow {
|
|
70
|
-
inputs: {
|
|
71
|
-
mediaUrl: string;
|
|
72
|
-
operations: Array<{
|
|
73
|
-
type: 'transcode' | 'optimize' | 'thumbnail' | 'analyze';
|
|
74
|
-
params?: Record<string, unknown>;
|
|
75
|
-
}>;
|
|
76
|
-
};
|
|
77
|
-
outputs: {
|
|
78
|
-
processedUrls: string[];
|
|
79
|
-
metadata?: Record<string, unknown>;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface AIGenerationWorkflow {
|
|
84
|
-
inputs: {
|
|
85
|
-
prompt: string;
|
|
86
|
-
model: string;
|
|
87
|
-
parameters?: Record<string, unknown>;
|
|
88
|
-
};
|
|
89
|
-
outputs: {
|
|
90
|
-
result: string;
|
|
91
|
-
tokens: number;
|
|
92
|
-
model: string;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface BatchOperationWorkflow {
|
|
97
|
-
inputs: {
|
|
98
|
-
operation: string;
|
|
99
|
-
items: unknown[];
|
|
100
|
-
batchSize?: number;
|
|
101
|
-
parallelism?: number;
|
|
102
|
-
};
|
|
103
|
-
outputs: {
|
|
104
|
-
successful: number;
|
|
105
|
-
failed: number;
|
|
106
|
-
results: unknown[];
|
|
107
|
-
};
|
|
108
|
-
}
|
/package/src/{infrastructure/domain/ai-gateway.entity.ts → domains/ai-gateway/entities/index.ts}
RENAMED
|
File without changes
|