oblaka-iac 0.0.1 → 0.0.3

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 (3) hide show
  1. package/README.md +123 -0
  2. package/package.json +7 -4
  3. package/src/types.ts +2 -2
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # Oblaka
2
+
3
+ Infrastructure as Code for Cloudflare. Define Workers, databases, storage, queues, and other Cloudflare resources in TypeScript.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add -d oblaka-iac
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ Create an infrastructure definition file (e.g. `oblaka.ts`):
14
+
15
+ ```typescript
16
+ import {
17
+ D1Database,
18
+ define,
19
+ DurableObject,
20
+ KVNamespace,
21
+ Queue,
22
+ R2Bucket,
23
+ ServiceReference,
24
+ Worker,
25
+ } from 'oblaka-iac'
26
+
27
+ export default define(({ env }) => {
28
+ const uploadsR2 = new R2Bucket({ name: 'uploads', locationHint: 'weur' })
29
+
30
+ return new Worker({
31
+ dir: '.',
32
+ name: 'my-app',
33
+ main: './src/index.ts',
34
+ compatibility_flags: ['nodejs_compat'],
35
+ compatibility_date: '2025-12-02',
36
+ observability: { enabled: true },
37
+ bindings: {
38
+ DB: new D1Database({ name: 'main', migrationsDir: 'migrations' }),
39
+ Cache: new KVNamespace({ name: 'cache' }),
40
+ Uploads: uploadsR2,
41
+ EmailQueue: new Queue({ name: 'email-queue', binding: 'both' }),
42
+ Room: new DurableObject({ name: 'Room', className: 'Room' }),
43
+
44
+ // Sub-worker — gets its own wrangler.jsonc
45
+ Admin: new Worker({
46
+ dir: './packages/admin',
47
+ name: 'my-app-admin',
48
+ main: './src/index.ts',
49
+ compatibility_flags: ['nodejs_compat'],
50
+ compatibility_date: '2025-12-02',
51
+ bindings: {
52
+ Uploads: uploadsR2, // shared R2 bucket
53
+ API: new ServiceReference('my-app'),
54
+ },
55
+ }),
56
+ },
57
+ vars: {
58
+ NODE_ENV: env === 'local' ? 'development' : 'production',
59
+ ENVIRONMENT: env,
60
+ },
61
+ })
62
+ })
63
+ ```
64
+
65
+ ### Generate local config
66
+
67
+ Generates a `wrangler.jsonc` config inside each worker directory:
68
+
69
+ ```bash
70
+ bunx oblaka oblaka.ts
71
+ ```
72
+
73
+ ### Deploy to Cloudflare
74
+
75
+ Creates resources on Cloudflare and generates the config:
76
+
77
+ ```bash
78
+ bunx oblaka oblaka.ts \
79
+ --remote \
80
+ --env production \
81
+ --account-id $CLOUDFLARE_ACCOUNT_ID \
82
+ --api-token $CLOUDFLARE_API_TOKEN
83
+ ```
84
+
85
+ ## Resources
86
+
87
+ | Resource | Description |
88
+ | ------------------ | ------------------------------- |
89
+ | `Worker` | Cloudflare Worker with bindings |
90
+ | `D1Database` | D1 SQL database |
91
+ | `KVNamespace` | KV key-value storage |
92
+ | `R2Bucket` | R2 object storage |
93
+ | `Queue` | Queue (producer/consumer) |
94
+ | `DurableObject` | Durable Object |
95
+ | `Workflow` | Cloudflare Workflow |
96
+ | `Container` | Container |
97
+ | `AnalyticsEngine` | Analytics Engine dataset |
98
+ | `Browser` | Browser Rendering API binding |
99
+ | `Images` | Image Optimization binding |
100
+ | `ServiceReference` | Reference to another worker |
101
+ | `VersionMetadata` | Version metadata binding |
102
+
103
+ ## CLI options
104
+
105
+ | Option | Env variable | Default | Description |
106
+ | ------------------- | ----------------------- | ---------------- | -------------------------------- |
107
+ | `--env` | `CLOUDFLARE_ENV` | `local` | Environment name |
108
+ | `--remote` | | `false` | Deploy resources to Cloudflare |
109
+ | `--dry-run` | | `false` | Preview changes without applying |
110
+ | `--account-id` | `CLOUDFLARE_ACCOUNT_ID` | | Cloudflare account ID |
111
+ | `--api-token` | `CLOUDFLARE_API_TOKEN` | | Cloudflare API token |
112
+ | `--config` | | `wrangler.jsonc` | Output config filename |
113
+ | `--state-namespace` | | `cf-state` | KV namespace for state storage |
114
+ | `--destroy` | | `false` | Destroy managed resources |
115
+ | `--out-state` | | | Export state to a JSON file |
116
+
117
+ ## State management
118
+
119
+ When deploying with `--remote`, Oblaka creates resources (D1 databases, KV namespaces, R2 buckets, etc.) via the Cloudflare API and needs to track their IDs for subsequent runs. This state is stored in a dedicated KV namespace on your Cloudflare account (default: `cf-state`, configurable with `--state-namespace`).
120
+
121
+ ## License
122
+
123
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oblaka-iac",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "main": "./src/index.ts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,6 +8,9 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/contember/oblaka"
10
10
  },
11
+ "bin": {
12
+ "oblaka": "./src/commands/run.ts"
13
+ },
11
14
  "files": [
12
15
  "src/",
13
16
  "LICENSE.md"
@@ -21,15 +24,15 @@
21
24
  },
22
25
  "devDependencies": {
23
26
  "@biomejs/biome": "^2.4.6",
24
- "@cloudflare/workers-types": "^4.20260307.1",
27
+ "@cloudflare/workers-types": "^4.20260312.1",
25
28
  "@types/bun": "latest",
26
- "dprint": "^0.52.0"
29
+ "dprint": "^0.52.0",
30
+ "wrangler": "^4.72.0"
27
31
  },
28
32
  "peerDependencies": {
29
33
  "typescript": "^5"
30
34
  },
31
35
  "dependencies": {
32
- "@cloudflare/workers-utils": "^0.12.0",
33
36
  "jsonc-parser": "^3.3.1"
34
37
  }
35
38
  }
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RawEnvironment } from '@cloudflare/workers-utils'
1
+ import type { Unstable_RawEnvironment } from 'wrangler'
2
2
  import type { CloudflareClient } from './client'
3
3
  import type { Worker } from './resources'
4
4
 
@@ -12,7 +12,7 @@ export interface Context {
12
12
  client: CloudflareClient
13
13
  }
14
14
 
15
- export type Config = RawEnvironment
15
+ export type Config = Unstable_RawEnvironment
16
16
 
17
17
  export type ResourceKind =
18
18
  | 'worker'