@umituz/web-cloudflare 1.4.3 → 1.4.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.
Files changed (44) hide show
  1. package/README.md +24 -29
  2. package/package.json +6 -5
  3. package/src/config/patterns.ts +43 -24
  4. package/src/domain/entities/analytics.entity.ts +18 -35
  5. package/src/domain/entities/d1.entity.ts +27 -0
  6. package/src/domain/entities/image.entity.ts +27 -27
  7. package/src/domain/entities/kv.entity.ts +20 -17
  8. package/src/domain/entities/r2.entity.ts +49 -0
  9. package/src/domain/entities/worker.entity.ts +35 -0
  10. package/src/domains/analytics/entities/index.ts +47 -0
  11. package/src/domains/analytics/index.ts +13 -0
  12. package/src/{infrastructure/services/analytics → domains/analytics/services}/analytics.service.ts +1 -1
  13. package/src/{infrastructure/services/analytics → domains/analytics/services}/index.ts +1 -0
  14. package/src/domains/analytics/types/index.ts +5 -0
  15. package/src/domains/analytics/types/service.interface.ts +12 -0
  16. package/src/domains/images/entities/index.ts +48 -0
  17. package/src/domains/images/index.ts +13 -0
  18. package/src/{infrastructure/services/images → domains/images/services}/images.service.ts +3 -3
  19. package/src/{infrastructure/services/images → domains/images/services}/index.ts +1 -0
  20. package/src/domains/images/types/index.ts +5 -0
  21. package/src/domains/images/types/service.interface.ts +13 -0
  22. package/src/domains/kv/entities/index.ts +34 -0
  23. package/src/domains/kv/index.ts +13 -0
  24. package/src/{infrastructure/services/kv → domains/kv/services}/index.ts +1 -0
  25. package/src/{infrastructure/services/kv → domains/kv/services}/kv.service.ts +2 -2
  26. package/src/domains/kv/types/index.ts +5 -0
  27. package/src/domains/kv/types/service.interface.ts +13 -0
  28. package/src/domains/workers/entities/index.ts +1 -1
  29. package/src/domains/workflows/entities/index.ts +60 -0
  30. package/src/domains/workflows/index.ts +10 -0
  31. package/src/domains/workflows/services/index.ts +6 -0
  32. package/src/{infrastructure/services/workflows/index.ts → domains/workflows/services/workflows.service.ts} +1 -1
  33. package/src/domains/wrangler/entities/index.ts +2 -2
  34. package/src/domains/wrangler/services/wrangler.service.ts +16 -8
  35. package/src/domains/wrangler/types/service.interface.ts +2 -2
  36. package/src/index.ts +4 -4
  37. package/src/infrastructure/middleware/auth.ts +118 -0
  38. package/src/infrastructure/middleware/cache.ts +95 -0
  39. package/src/infrastructure/middleware/cors.ts +95 -0
  40. package/src/infrastructure/middleware/index.ts +20 -3
  41. package/src/infrastructure/middleware/rate-limit.ts +105 -0
  42. package/src/infrastructure/router/index.ts +26 -4
  43. package/src/infrastructure/utils/helpers.ts +25 -11
  44. package/src/infrastructure/utils/utils.util.ts +3 -2
package/README.md CHANGED
@@ -177,7 +177,16 @@ const versions = await wrangler.versionsList();
177
177
  await wrangler.versionsRollback(versions[0].id);
178
178
  ```
179
179
 
180
- **Note:** Wrangler CLI, Workers, AI Gateway, R2, and D1 services now follow Domain-Driven Design (DDD) architecture with their own domain structures at `src/domains/wrangler/`, `src/domains/workers/`, `src/domains/ai-gateway/`, `src/domains/r2/`, and `src/domains/d1/`.
180
+ **Note:** All services now follow Domain-Driven Design (DDD) architecture with their own domain structures:
181
+ - Wrangler CLI: `src/domains/wrangler/`
182
+ - Workers: `src/domains/workers/`
183
+ - AI Gateway: `src/domains/ai-gateway/`
184
+ - R2: `src/domains/r2/`
185
+ - D1: `src/domains/d1/`
186
+ - KV: `src/domains/kv/`
187
+ - Images: `src/domains/images/`
188
+ - Analytics: `src/domains/analytics/`
189
+ - Workflows: `src/domains/workflows/`
181
190
 
182
191
  ## 📚 Subpath Exports
183
192
 
@@ -187,8 +196,8 @@ await wrangler.versionsRollback(versions[0].id);
187
196
  // Workers service (now in domains/)
188
197
  import { WorkersService, workersService } from '@umituz/web-cloudflare/workers';
189
198
 
190
- // KV cache
191
- import { KVService } from '@umituz/web-cloudflare/kv';
199
+ // KV cache (now in domains/)
200
+ import { KVService, kvService } from '@umituz/web-cloudflare/kv';
192
201
 
193
202
  // R2 storage (now in domains/)
194
203
  import { R2Service, r2Service } from '@umituz/web-cloudflare/r2';
@@ -196,11 +205,14 @@ import { R2Service, r2Service } from '@umituz/web-cloudflare/r2';
196
205
  // D1 database (now in domains/)
197
206
  import { D1Service, d1Service } from '@umituz/web-cloudflare/d1';
198
207
 
199
- // Images optimization
200
- import { ImagesService } from '@umituz/web-cloudflare/images';
208
+ // Images optimization (now in domains/)
209
+ import { ImagesService, imagesService } from '@umituz/web-cloudflare/images';
201
210
 
202
- // Analytics
203
- import { AnalyticsService } from '@umituz/web-cloudflare/analytics';
211
+ // Analytics (now in domains/)
212
+ import { AnalyticsService, analyticsService } from '@umituz/web-cloudflare/analytics';
213
+
214
+ // Workflows (now in domains/)
215
+ import { WorkflowService } from '@umituz/web-cloudflare/workflows';
204
216
 
205
217
  // Wrangler CLI
206
218
  import { WranglerService } from '@umituz/web-cloudflare/wrangler';
@@ -661,32 +673,15 @@ Contributions are welcome!
661
673
  │ ├── config/ # Config patterns and types
662
674
  │ ├── domains/ # Domain-driven design structure
663
675
  │ │ ├── wrangler/ # Wrangler CLI domain
664
- │ │ │ ├── entities/ # Domain entities
665
- │ │ │ ├── services/ # Domain services
666
- │ │ │ ├── types/ # Domain types
667
- │ │ │ └── index.ts # Domain exports
668
676
  │ │ ├── workers/ # Workers domain
669
- │ │ │ ├── entities/ # Domain entities
670
- │ │ │ ├── services/ # Domain services
671
- │ │ │ ├── types/ # Domain types
672
- │ │ │ ├── examples/ # Example files
673
- │ │ │ └── index.ts # Domain exports
674
677
  │ │ ├── ai-gateway/ # AI Gateway domain
675
- │ │ │ ├── entities/ # Domain entities
676
- │ │ │ ├── services/ # Domain services
677
- │ │ │ └── index.ts # Domain exports
678
678
  │ │ ├── r2/ # R2 storage domain
679
- │ │ ├── entities/ # Domain entities
680
- │ │ ├── services/ # Domain services
681
- │ │ ├── types/ # Domain types
682
- │ │ │ └── index.ts # Domain exports
683
- │ │ └── d1/ # D1 database domain
684
- │ │ ├── entities/ # Domain entities
685
- │ │ ├── services/ # Domain services
686
- │ │ ├── types/ # Domain types
687
- │ │ └── index.ts # Domain exports
679
+ │ │ ├── d1/ # D1 database domain
680
+ │ │ ├── kv/ # KV storage domain
681
+ │ │ ├── images/ # Images optimization domain
682
+ │ │ ├── analytics/ # Analytics domain
683
+ │ │ └── workflows/ # Workflows domain
688
684
  │ ├── infrastructure/
689
- │ │ ├── services/ # Services (kv, images, analytics, workflows)
690
685
  │ │ ├── router/ # Express-like router
691
686
  │ │ ├── middleware/ # Middleware collection
692
687
  │ │ └── utils/ # Helper functions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-cloudflare",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "Comprehensive Cloudflare Workers integration with config-based patterns, middleware, router, workflows, and AI (Patch-only versioning: only z in x.y.z increments)",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -8,12 +8,12 @@
8
8
  "exports": {
9
9
  ".": "./src/index.ts",
10
10
  "./workers": "./src/domains/workers/index.ts",
11
- "./kv": "./src/infrastructure/services/kv/index.ts",
11
+ "./kv": "./src/domains/kv/index.ts",
12
12
  "./r2": "./src/domains/r2/index.ts",
13
13
  "./d1": "./src/domains/d1/index.ts",
14
- "./images": "./src/infrastructure/services/images/index.ts",
15
- "./analytics": "./src/infrastructure/services/analytics/index.ts",
16
- "./workflows": "./src/infrastructure/services/workflows/index.ts",
14
+ "./images": "./src/domains/images/index.ts",
15
+ "./analytics": "./src/domains/analytics/index.ts",
16
+ "./workflows": "./src/domains/workflows/index.ts",
17
17
  "./ai-gateway": "./src/domains/ai-gateway/index.ts",
18
18
  "./workers-ai": "./src/domains/ai-gateway/index.ts",
19
19
  "./wrangler": "./src/domains/wrangler/index.ts",
@@ -75,6 +75,7 @@
75
75
  "typescript": ">=5.0.0"
76
76
  },
77
77
  "devDependencies": {
78
+ "@cloudflare/workers-types": "^4.20260317.1",
78
79
  "@types/node": "~22.13.10",
79
80
  "typescript": "~5.9.2"
80
81
  },
@@ -3,8 +3,8 @@
3
3
  * @description Reusable configuration patterns for different use cases
4
4
  */
5
5
 
6
- import type { AIGatewayConfig } from '../infrastructure/domain/ai-gateway.entity';
7
- import type { WorkflowDefinition } from '../infrastructure/domain/workflows.entity';
6
+ import type { AIGatewayConfig } from '../domains/ai-gateway/entities';
7
+ import type { WorkflowDefinition } from '../domains/workflows/entities';
8
8
  import type { WorkerConfig } from './types';
9
9
 
10
10
  // ============================================================
@@ -106,6 +106,8 @@ export const saasConfig: Partial<WorkerConfig> = {
106
106
  },
107
107
  workflows: {
108
108
  enabled: true,
109
+ maxExecutionTime: 300,
110
+ defaultRetries: 2,
109
111
  },
110
112
  };
111
113
 
@@ -149,6 +151,8 @@ export const cdnConfig: Partial<WorkerConfig> = {
149
151
  },
150
152
  rateLimit: {
151
153
  enabled: false,
154
+ maxRequests: 0,
155
+ window: 0,
152
156
  },
153
157
  compression: {
154
158
  enabled: true,
@@ -194,7 +198,7 @@ export const aiFirstConfig: Partial<WorkerConfig> = {
194
198
  baseURL: 'https://api.openai.com/v1',
195
199
  apiKey: '',
196
200
  models: ['gpt-4', 'gpt-3.5-turbo'],
197
- fallback: 'workers-ai',
201
+ fallbackProvider: 'workers-ai',
198
202
  weight: 1,
199
203
  },
200
204
  ],
@@ -206,6 +210,8 @@ export const aiFirstConfig: Partial<WorkerConfig> = {
206
210
  },
207
211
  workflows: {
208
212
  enabled: true,
213
+ maxExecutionTime: 600,
214
+ defaultRetries: 3,
209
215
  },
210
216
  };
211
217
 
@@ -215,13 +221,18 @@ export const aiFirstConfig: Partial<WorkerConfig> = {
215
221
  export const minimalConfig: Partial<WorkerConfig> = {
216
222
  cache: {
217
223
  enabled: false,
224
+ defaultTTL: 0,
218
225
  },
219
226
  rateLimit: {
220
227
  enabled: false,
228
+ maxRequests: 0,
229
+ window: 0,
221
230
  },
222
231
  cors: {
223
232
  enabled: true,
224
233
  allowedOrigins: ['*'],
234
+ allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
235
+ allowedHeaders: ['*'],
225
236
  },
226
237
  };
227
238
 
@@ -234,26 +245,34 @@ export const minimalConfig: Partial<WorkerConfig> = {
234
245
  */
235
246
  export function mergeConfigs<T extends Record<string, any>>(
236
247
  base: T,
237
- ...overrides: Partial<T>[]
248
+ ...overrides: Array<Partial<Record<string, any>>>
238
249
  ): T {
239
250
  return overrides.reduce((acc, override) => {
240
251
  return deepMerge(acc, override);
241
252
  }, base);
242
253
  }
243
254
 
244
- function deepMerge<T>(target: T, source: Partial<T>): T {
245
- const output = { ...target } as T;
255
+ function deepMerge<T extends Record<string, any>>(
256
+ target: T,
257
+ source: Partial<Record<string, any>>
258
+ ): T {
259
+ const output = { ...target };
246
260
 
247
261
  if (isObject(target) && isObject(source)) {
248
262
  Object.keys(source).forEach((key) => {
249
- if (isObject(source[key as keyof T])) {
263
+ const sourceValue = source[key];
264
+ const targetValue = target[key as keyof T];
265
+
266
+ if (isObject(sourceValue)) {
250
267
  if (!(key in target)) {
251
- Object.assign(output, { [key]: source[key as keyof T] });
268
+ (output as any)[key] = sourceValue;
269
+ } else if (isObject(targetValue)) {
270
+ (output as any)[key] = deepMerge(targetValue, sourceValue);
252
271
  } else {
253
- (output as any)[key] = deepMerge(target[key as keyof T], source[key as keyof T]);
272
+ (output as any)[key] = sourceValue;
254
273
  }
255
274
  } else {
256
- Object.assign(output, { [key]: source[key as keyof T] });
275
+ (output as any)[key] = sourceValue;
257
276
  }
258
277
  });
259
278
  }
@@ -261,7 +280,7 @@ function deepMerge<T>(target: T, source: Partial<T>): T {
261
280
  return output;
262
281
  }
263
282
 
264
- function isObject(item: unknown): item is Record<string, unknown> {
283
+ function isObject(item: unknown): item is Record<string, any> {
265
284
  return Boolean(item && typeof item === 'object' && !Array.isArray(item));
266
285
  }
267
286
 
@@ -316,52 +335,52 @@ export class ConfigBuilder {
316
335
  }
317
336
 
318
337
  withCache(config: Partial<NonNullable<WorkerConfig['cache']>>): ConfigBuilder {
319
- this.config.cache = { ...this.config.cache, ...config };
338
+ this.config.cache = this.config.cache ? { ...this.config.cache, ...config } : config as NonNullable<WorkerConfig['cache']>;
320
339
  return this;
321
340
  }
322
341
 
323
342
  withRateLimit(config: Partial<NonNullable<WorkerConfig['rateLimit']>>): ConfigBuilder {
324
- this.config.rateLimit = { ...this.config.rateLimit, ...config };
343
+ this.config.rateLimit = this.config.rateLimit ? { ...this.config.rateLimit, ...config } : config as NonNullable<WorkerConfig['rateLimit']>;
325
344
  return this;
326
345
  }
327
346
 
328
347
  withAI(config: Partial<NonNullable<WorkerConfig['ai']>>): ConfigBuilder {
329
- this.config.ai = { ...this.config.ai, ...config };
348
+ this.config.ai = this.config.ai ? { ...this.config.ai, ...config } : config as NonNullable<WorkerConfig['ai']>;
330
349
  return this;
331
350
  }
332
351
 
333
352
  withWorkflows(config: Partial<NonNullable<WorkerConfig['workflows']>>): ConfigBuilder {
334
- this.config.workflows = { ...this.config.workflows, ...config };
353
+ this.config.workflows = this.config.workflows ? { ...this.config.workflows, ...config } : config as NonNullable<WorkerConfig['workflows']>;
335
354
  return this;
336
355
  }
337
356
 
338
357
  withCORS(config: Partial<NonNullable<WorkerConfig['cors']>>): ConfigBuilder {
339
- this.config.cors = { ...this.config.cors, ...config };
358
+ this.config.cors = this.config.cors ? { ...this.config.cors, ...config } : config as NonNullable<WorkerConfig['cors']>;
340
359
  return this;
341
360
  }
342
361
 
343
362
  withAnalytics(config: Partial<NonNullable<WorkerConfig['analytics']>>): ConfigBuilder {
344
- this.config.analytics = { ...this.config.analytics, ...config };
363
+ this.config.analytics = this.config.analytics ? { ...this.config.analytics, ...config } : config as NonNullable<WorkerConfig['analytics']>;
345
364
  return this;
346
365
  }
347
366
 
348
367
  withCompression(config: Partial<NonNullable<WorkerConfig['compression']>>): ConfigBuilder {
349
- this.config.compression = { ...this.config.compression, ...config };
368
+ this.config.compression = this.config.compression ? { ...this.config.compression, ...config } : config as NonNullable<WorkerConfig['compression']>;
350
369
  return this;
351
370
  }
352
371
 
353
372
  withImageOptimization(config: Partial<NonNullable<WorkerConfig['imageOptimization']>>): ConfigBuilder {
354
- this.config.imageOptimization = { ...this.config.imageOptimization, ...config };
373
+ this.config.imageOptimization = this.config.imageOptimization ? { ...this.config.imageOptimization, ...config } : config as NonNullable<WorkerConfig['imageOptimization']>;
355
374
  return this;
356
375
  }
357
376
 
358
377
  withQueues(config: Partial<NonNullable<WorkerConfig['queues']>>): ConfigBuilder {
359
- this.config.queues = { ...this.config.queues, ...config };
378
+ this.config.queues = this.config.queues ? { ...this.config.queues, ...config } : config as NonNullable<WorkerConfig['queues']>;
360
379
  return this;
361
380
  }
362
381
 
363
382
  withScheduledTasks(config: Partial<NonNullable<WorkerConfig['scheduledTasks']>>): ConfigBuilder {
364
- this.config.scheduledTasks = { ...this.config.scheduledTasks, ...config };
383
+ this.config.scheduledTasks = this.config.scheduledTasks ? { ...this.config.scheduledTasks, ...config } : config as NonNullable<WorkerConfig['scheduledTasks']>;
365
384
  return this;
366
385
  }
367
386
 
@@ -449,9 +468,9 @@ export function getEnvironmentConfig(
449
468
  switch (environment) {
450
469
  case 'development':
451
470
  return mergeConfigs(minimalConfig, {
452
- cache: { enabled: false },
453
- rateLimit: { enabled: false },
454
- cors: { allowedOrigins: ['*'] },
471
+ cache: { enabled: false, defaultTTL: 0 },
472
+ rateLimit: { enabled: false, maxRequests: 0, window: 0 },
473
+ cors: { enabled: true, allowedOrigins: ['*'], allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], allowedHeaders: ['*'] },
455
474
  });
456
475
 
457
476
  case 'staging':
@@ -1,47 +1,30 @@
1
1
  /**
2
2
  * Analytics Entity
3
- * @description Cloudflare Web Analytics configuration and types
3
+ * @description Basic Analytics entity placeholder
4
4
  */
5
5
 
6
- export interface AnalyticsConfig {
7
- readonly siteId: string;
8
- readonly scriptUrl?: string;
9
- }
10
-
11
- export interface AnalyticsEvent {
12
- readonly timestamp: number;
13
- readonly url: string;
14
- readonly eventType: "pageview" | "custom" | "outbound-link" | "timing";
15
- readonly eventData?: Record<string, unknown>;
16
- }
17
-
18
- export interface AnalyticsPageviewEvent extends AnalyticsEvent {
19
- readonly eventType: "pageview";
20
- readonly title: string;
21
- readonly referrer?: string;
6
+ export interface AnalyticsEntity {
7
+ siteId: string;
8
+ eventCount: number;
22
9
  }
23
10
 
24
- export interface AnalyticsCustomEvent extends AnalyticsEvent {
25
- readonly eventType: "custom";
26
- readonly eventName: string;
11
+ export interface AnalyticsConfig {
12
+ siteId: string;
13
+ scriptUrl?: string;
27
14
  }
28
15
 
29
- export interface AnalyticsTimingEvent extends AnalyticsEvent {
30
- readonly eventType: "timing";
31
- readonly name: string;
32
- readonly value: number;
33
- readonly label?: string;
16
+ export interface AnalyticsEvent {
17
+ timestamp: number;
18
+ url: string;
19
+ eventType: string;
20
+ data?: Record<string, unknown>;
34
21
  }
35
22
 
36
23
  export interface AnalyticsData {
37
- readonly siteId: string;
38
- readonly events: readonly AnalyticsEvent[];
39
- readonly metrics?: AnalyticsMetrics;
40
- }
41
-
42
- export interface AnalyticsMetrics {
43
- readonly pageviews: number;
44
- readonly uniqueVisitors: number;
45
- readonly bounceRate?: number;
46
- readonly avgSessionDuration?: number;
24
+ siteId: string;
25
+ events: AnalyticsEvent[];
26
+ metrics?: {
27
+ pageviews: number;
28
+ uniqueVisitors: number;
29
+ };
47
30
  }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * D1 Entity
3
+ * @description Basic D1 entity placeholder
4
+ */
5
+
6
+ export interface D1Entity {
7
+ databaseId: string;
8
+ name: string;
9
+ }
10
+
11
+ export interface D1DatabaseConfig {
12
+ name: string;
13
+ migrations?: string[];
14
+ }
15
+
16
+ export interface D1QueryResult<T = unknown> {
17
+ rows: T[];
18
+ meta?: {
19
+ duration: number;
20
+ changes?: number;
21
+ };
22
+ }
23
+
24
+ export interface D1BatchResult<T = unknown> {
25
+ success: boolean;
26
+ results?: D1QueryResult<T>[];
27
+ }
@@ -1,48 +1,48 @@
1
1
  /**
2
2
  * Image Entity
3
- * @description Cloudflare Images configuration and types
3
+ * @description Basic Image entity placeholder
4
4
  */
5
5
 
6
+ export interface ImageEntity {
7
+ id: string;
8
+ url: string;
9
+ variant?: string;
10
+ }
11
+
6
12
  export interface ImageConfig {
7
- readonly account: string;
8
- readonly customDomain?: string;
13
+ formats?: Array<'webp' | 'avif' | 'jpeg' | 'png'>;
14
+ quality?: number;
9
15
  }
10
16
 
11
17
  export interface ImageVariant {
12
- readonly variant: string;
13
- readonly width?: number;
14
- readonly height?: number;
15
- readonly fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
16
- readonly format?: "jpeg" | "png" | "gif" | "webp" | "avif";
17
- readonly quality?: number;
18
+ width: number;
19
+ height: number;
20
+ format: string;
21
+ url: string;
18
22
  }
19
23
 
20
24
  export interface ImageUploadResult {
21
- readonly id: string;
22
- readonly filename: string;
23
- readonly uploaded: Date;
24
- readonly variants: readonly string[];
25
- readonly requireSignedURLs: boolean;
25
+ id: string;
26
+ url: string;
27
+ variants: ImageVariant[];
26
28
  }
27
29
 
28
30
  export interface ImageUploadOptions {
29
- readonly metadata?: Record<string, string>;
30
- readonly requireSignedURLs?: boolean;
31
- readonly variants?: readonly ImageVariant[];
31
+ format?: 'webp' | 'avif' | 'jpeg' | 'png';
32
+ quality?: number;
33
+ width?: number;
34
+ height?: number;
32
35
  }
33
36
 
34
37
  export interface ImageTransformation {
35
- readonly width?: number;
36
- readonly height?: number;
37
- readonly fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
38
- readonly format?: "jpeg" | "png" | "gif" | "webp" | "avif";
39
- readonly quality?: number;
40
- readonly rotate?: number;
41
- readonly flip?: boolean;
42
- readonly flop?: boolean;
38
+ width?: number;
39
+ height?: number;
40
+ fit?: 'contain' | 'cover' | 'fill';
41
+ format?: 'webp' | 'avif' | 'jpeg' | 'png';
42
+ quality?: number;
43
43
  }
44
44
 
45
45
  export interface SignedURL {
46
- readonly url: string;
47
- readonly expiresAt: Date;
46
+ url: string;
47
+ expires: number;
48
48
  }
@@ -1,34 +1,37 @@
1
1
  /**
2
2
  * KV Entity
3
- * @description Cloudflare KV configuration and types
3
+ * @description Basic KV entity placeholder
4
4
  */
5
5
 
6
+ export interface KVEntity {
7
+ namespaceId: string;
8
+ key: string;
9
+ value: string;
10
+ }
11
+
6
12
  export interface KVNamespaceConfig {
7
- readonly namespace: string;
8
- readonly ttl?: number;
13
+ id: string;
14
+ ttl?: number;
9
15
  }
10
16
 
11
- export interface KVEntry<T = unknown> {
12
- readonly key: string;
13
- readonly value: T;
14
- readonly metadata?: Record<string, unknown>;
15
- readonly expiration?: number;
17
+ export interface KVEntry {
18
+ key: string;
19
+ value: string;
20
+ metadata?: Record<string, unknown>;
16
21
  }
17
22
 
18
23
  export interface KVListOptions {
19
- readonly limit?: number;
20
- readonly cursor?: string;
21
- readonly prefix?: string;
24
+ limit?: number;
25
+ cursor?: string;
26
+ prefix?: string;
22
27
  }
23
28
 
24
29
  export interface KVListResult {
25
- readonly keys: readonly KVKey[];
26
- readonly list_complete: boolean;
27
- readonly cursor?: string;
30
+ keys: KVEntry[];
31
+ cursor?: string;
28
32
  }
29
33
 
30
34
  export interface KVKey {
31
- readonly name: string;
32
- readonly metadata?: Record<string, unknown>;
33
- readonly expiration?: number;
35
+ name: string;
36
+ metadata?: Record<string, unknown>;
34
37
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * R2 Entity
3
+ * @description Basic R2 entity placeholder
4
+ */
5
+
6
+ export interface R2Entity {
7
+ bucketName: string;
8
+ key: string;
9
+ }
10
+
11
+ export interface R2BucketConfig {
12
+ name: string;
13
+ location?: string;
14
+ }
15
+
16
+ export interface R2Object {
17
+ key: string;
18
+ size: number;
19
+ uploaded: Date;
20
+ }
21
+
22
+ export interface R2UploadResult {
23
+ key: string;
24
+ etag?: string;
25
+ }
26
+
27
+ export interface R2ListOptions {
28
+ limit?: number;
29
+ cursor?: string;
30
+ prefix?: string;
31
+ }
32
+
33
+ export interface R2ListResult {
34
+ objects: R2Object[];
35
+ cursor?: string;
36
+ }
37
+
38
+ export interface R2PutOptions {
39
+ customMetadata?: Record<string, string>;
40
+ httpMetadata?: {
41
+ contentType?: string;
42
+ cacheControl?: string;
43
+ };
44
+ }
45
+
46
+ export interface R2PresignedURL {
47
+ url: string;
48
+ expires: number;
49
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Worker Entity
3
+ * @description Basic Worker entity placeholder
4
+ */
5
+
6
+ export interface WorkerEntity {
7
+ id: string;
8
+ name: string;
9
+ }
10
+
11
+ export interface WorkerConfig {
12
+ name: string;
13
+ routes?: string[];
14
+ schedule?: string;
15
+ bindings?: Record<string, unknown>;
16
+ }
17
+
18
+ export interface WorkerResponse {
19
+ status: number;
20
+ body?: BodyInit | null;
21
+ }
22
+
23
+ export interface IncomingRequestCfProperties {
24
+ colo?: string;
25
+ country?: string;
26
+ httpProtocol?: string;
27
+ tlsVersion?: string;
28
+ tlsCipher?: string;
29
+ asn?: number;
30
+ requestPriority?: number;
31
+ }
32
+
33
+ export type { WorkerRequest as _WorkerRequest } from '../../domains/workers/entities';
34
+ // Re-export WorkerRequest from workers domain
35
+ export { WorkerRequest } from '../../domains/workers/entities';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Analytics Entity
3
+ * @description Cloudflare Web Analytics configuration and types
4
+ */
5
+
6
+ export interface WebAnalyticsConfig {
7
+ readonly siteId: string;
8
+ readonly scriptUrl?: string;
9
+ }
10
+
11
+ export interface AnalyticsEvent {
12
+ readonly timestamp: number;
13
+ readonly url: string;
14
+ readonly eventType: "pageview" | "custom" | "outbound-link" | "timing";
15
+ readonly eventData?: Record<string, unknown>;
16
+ }
17
+
18
+ export interface AnalyticsPageviewEvent extends AnalyticsEvent {
19
+ readonly eventType: "pageview";
20
+ readonly title: string;
21
+ readonly referrer?: string;
22
+ }
23
+
24
+ export interface AnalyticsCustomEvent extends AnalyticsEvent {
25
+ readonly eventType: "custom";
26
+ readonly eventName: string;
27
+ }
28
+
29
+ export interface AnalyticsTimingEvent extends AnalyticsEvent {
30
+ readonly eventType: "timing";
31
+ readonly name: string;
32
+ readonly value: number;
33
+ readonly label?: string;
34
+ }
35
+
36
+ export interface WebAnalyticsData {
37
+ readonly siteId: string;
38
+ readonly events: readonly AnalyticsEvent[];
39
+ readonly metrics?: AnalyticsMetrics;
40
+ }
41
+
42
+ export interface AnalyticsMetrics {
43
+ readonly pageviews: number;
44
+ readonly uniqueVisitors: number;
45
+ readonly bounceRate?: number;
46
+ readonly avgSessionDuration?: number;
47
+ }