openwrangler 0.0.14 → 0.0.16

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 CHANGED
@@ -1,28 +1,27 @@
1
1
  # openwrangler
2
2
 
3
- miniflare의 버그와 한계를 해결하는 Cloudflare 바인딩 구현 라이브러리
3
+ A Cloudflare bindings implementation library that solves miniflare's bugs and limitations
4
4
 
5
- ## 배경
5
+ ## Background
6
6
 
7
- Cloudflare Workers 개발 환경에서 `wrangler dev`는 내부적으로 miniflare를 사용하여 R2, KV, D1 등의 바인딩을 로컬에서 시뮬레이션합니다. 하지만 miniflare 다음과 같은 문제점이 있습니다:
7
+ Cloudflare Workers development environment uses miniflare internally via `wrangler dev` to simulate bindings like R2, KV, and D1 locally. However, miniflare has critical issues:
8
8
 
9
- ### miniflare 문제점
9
+ ### miniflare's Problems
10
10
 
11
- 1. **R2 Buffer 처리 버그**: Node.js Buffer R2에 업로드할 제대로 처리하지 못하는 버그
12
- 2. **remote 옵션 미작동**: `wrangler.toml`의 `remote = true` 옵션이 실제로 작동하지 않음
13
- 3. **프로덕션 환경과의 차이**: 로컬 시뮬레이션 환경이라 실제 프로덕션과 동작이 다를 수 있음
11
+ 1. **R2 Buffer Processing Bug**: Fails to properly handle Node.js Buffer when uploading to R2
12
+ 2. **remote Option Errors**: The `remote = true` option in `wrangler.toml` throws errors, making it completely unusable
14
13
 
15
- ### openwrangler 해결책
14
+ ### openwrangler's Solution
16
15
 
17
- openwrangler miniflare 우회하고 **Cloudflare REST API를 직접 호출**하여 이러한 문제들을 해결합니다:
16
+ openwrangler bypasses miniflare and **directly calls Cloudflare REST APIs** to solve these problems:
18
17
 
19
- - **R2**: S3 호환 API를 통해 실제 Cloudflare R2 버킷에 직접 접근
20
- - **KV**: Cloudflare KV REST API로 실제 KV 네임스페이스 사용
21
- - **D1**: Cloudflare D1 REST API로 실제 D1 데이터베이스 쿼리
18
+ - **R2**: Direct access to actual Cloudflare R2 buckets via S3-compatible API
19
+ - **KV**: Use real KV namespaces via Cloudflare KV REST API
20
+ - **D1**: Query real D1 databases via Cloudflare D1 REST API
22
21
 
23
- 개발 환경에서도 실제 프로덕션 리소스를 사용할 있어, 프로덕션과 동일한 환경에서 개발 테스트가 가능합니다.
22
+ You can use actual production resources in your development environment, enabling development and testing in an environment identical to production.
24
23
 
25
- ## 설치
24
+ ## Installation
26
25
 
27
26
  ```bash
28
27
  npm install openwrangler
@@ -30,9 +29,9 @@ npm install openwrangler
30
29
  pnpm add openwrangler
31
30
  ```
32
31
 
33
- ## 사용법
32
+ ## Usage
34
33
 
35
- ### 1. 직접 사용 (Node.js)
34
+ ### 1. Direct Usage (Node.js)
36
35
 
37
36
  ```typescript
38
37
  import { createR2Binding, createKVBinding, createD1Binding } from 'openwrangler'
@@ -44,7 +43,7 @@ const r2 = createR2Binding({
44
43
  r2SecretAccessKey: 'your-r2-secret-key',
45
44
  }, 'bucket-name')
46
45
 
47
- await r2.put('image.png', buffer) // ✅ Buffer 정상 작동
46
+ await r2.put('image.png', buffer) // ✅ Buffer works correctly
48
47
  const file = await r2.get('image.png')
49
48
 
50
49
  // KV
@@ -65,17 +64,17 @@ const d1 = createD1Binding({
65
64
  const result = await d1.prepare('SELECT * FROM users').all()
66
65
  ```
67
66
 
68
- ### 2. Nitro/Nuxt 통합 (`@bino0216/nitro-cloudflare-dev`)
67
+ ### 2. Nitro/Nuxt Integration (`@bino0216/nitro-cloudflare-dev`)
69
68
 
70
- Nitro Nuxt에서는 통합 모듈을 사용하여 쉽게 설정할 수 있습니다.
69
+ For Nitro and Nuxt, use the integration module for easier setup.
71
70
 
72
- #### 설치
71
+ #### Installation
73
72
 
74
73
  ```bash
75
74
  npm install @bino0216/nitro-cloudflare-dev
76
75
  ```
77
76
 
78
- #### Nuxt 설정
77
+ #### Nuxt Configuration
79
78
 
80
79
  ```typescript
81
80
  // nuxt.config.ts
@@ -85,7 +84,7 @@ export default defineNuxtConfig({
85
84
  nitro: {
86
85
  modules: [nitroCloudflareDev],
87
86
  cloudflareDev: {
88
- remote: true, // 실제 Cloudflare 리소스 사용
87
+ remote: true, // Use actual Cloudflare resources
89
88
  remoteCredentials: {
90
89
  accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
91
90
  apiToken: process.env.CLOUDFLARE_API_TOKEN,
@@ -99,7 +98,7 @@ export default defineNuxtConfig({
99
98
  })
100
99
  ```
101
100
 
102
- #### wrangler.toml 설정
101
+ #### wrangler.toml Configuration
103
102
 
104
103
  ```toml
105
104
  [[r2_buckets]]
@@ -116,7 +115,7 @@ database_name = "my-database"
116
115
  database_id = "your-db-id"
117
116
  ```
118
117
 
119
- #### 사용
118
+ #### Usage
120
119
 
121
120
  ```typescript
122
121
  // server/api/example.ts
@@ -136,83 +135,83 @@ export default defineEventHandler(async (event) => {
136
135
  })
137
136
  ```
138
137
 
139
- ### 3. Buffer 호환성 Wrapper (miniflare 사용 )
138
+ ### 3. Buffer Compatibility Wrapper (When Using miniflare)
140
139
 
141
- `remote: false`로 miniflare를 사용하면서 R2 Buffer 문제만 해결하고 싶다면:
140
+ If you want to use miniflare with `remote: false` while only fixing the R2 Buffer issue:
142
141
 
143
142
  ```typescript
144
143
  import { wrapR2BucketForDev } from 'openwrangler'
145
144
 
146
- // miniflare에서 받은 R2 바인딩을 감싸기
145
+ // Wrap the R2 binding from miniflare
147
146
  const r2 = wrapR2BucketForDev(miniflareR2Bucket)
148
147
 
149
- // 이제 Buffer 정상 작동
148
+ // Buffer now works correctly
150
149
  await r2.put('file.bin', Buffer.from([1, 2, 3]))
151
150
  ```
152
151
 
153
- `@bino0216/nitro-cloudflare-dev`는 `remote: false`일 자동으로 모든 R2 바인딩에 wrapper를 적용합니다.
152
+ `@bino0216/nitro-cloudflare-dev` automatically applies this wrapper to all R2 bindings when `remote: false`.
154
153
 
155
- ## 지원 바인딩
154
+ ## Supported Bindings
156
155
 
157
- | 바인딩 | 타입 | REST API | 지원 |
158
- |--------|------|----------|------|
159
- | R2 | `R2Bucket` | S3 호환 API | ✅ |
156
+ | Binding | Type | REST API | Support |
157
+ |---------|------|----------|---------|
158
+ | R2 | `R2Bucket` | S3-compatible API | ✅ |
160
159
  | KV | `KVNamespace` | Cloudflare KV API | ✅ |
161
160
  | D1 | `D1Database` | Cloudflare D1 API | ✅ |
162
161
 
163
- 모든 타입은 `@cloudflare/workers-types`에서 import하여 실제 Cloudflare Workers와 100% 호환됩니다.
162
+ All types are imported from `@cloudflare/workers-types` to ensure 100% compatibility with actual Cloudflare Workers.
164
163
 
165
- ## 사용 사례
164
+ ## Use Cases
166
165
 
167
- ### 개발 환경에서 실제 데이터 사용
168
- 로컬 개발 중에도 실제 프로덕션 리소스에 접근하여 개발 디버깅
166
+ ### Development with Real Data
167
+ Access actual production resources during local development for development and debugging
169
168
 
170
- ### miniflare 버그 우회
171
- R2 Buffer 처리 miniflare 알려진 버그를 우회
169
+ ### Bypass miniflare Bugs
170
+ Work around known miniflare bugs such as R2 Buffer processing
172
171
 
173
- ### 통합 테스트
174
- 실제 Cloudflare 서비스를 대상으로 통합 테스트 실행
172
+ ### Integration Testing
173
+ Run integration tests against actual Cloudflare services
175
174
 
176
175
  ### CI/CD
177
- GitHub Actions 등에서 실제 Cloudflare 리소스를 사용한 테스트
176
+ Test with real Cloudflare resources in GitHub Actions and other CI/CD pipelines
178
177
 
179
- ## 개발
178
+ ## Development
180
179
 
181
180
  ```bash
182
- # 의존성 설치
181
+ # Install dependencies
183
182
  pnpm install
184
183
 
185
- # 빌드
184
+ # Build
186
185
  pnpm build
187
186
 
188
- # playground 실행 (Nuxt + Nitro 테스트 환경)
187
+ # Run playground (Nuxt + Nitro test environment)
189
188
  pnpm dev
190
189
  ```
191
190
 
192
- ## 프로젝트 구조
191
+ ## Project Structure
193
192
 
194
193
  ```
195
194
  openwrangler/
196
195
  ├── src/
197
- │ ├── index.ts # 메인 export
196
+ │ ├── index.ts # Main export
198
197
  │ ├── bindings/
199
- │ │ ├── r2.ts # R2 바인딩 구현 (S3 API)
198
+ │ │ ├── r2.ts # R2 binding implementation (S3 API)
200
199
  │ │ ├── r2.dev.ts # R2 Buffer wrapper
201
- │ │ ├── kv.ts # KV 바인딩 구현
202
- │ │ └── d1.ts # D1 바인딩 구현
200
+ │ │ ├── kv.ts # KV binding implementation
201
+ │ │ └── d1.ts # D1 binding implementation
203
202
  │ └── utils/
204
- │ ├── http-client.ts # Cloudflare API 클라이언트
205
- │ └── s3-signer.ts # AWS S3 서명 유틸
203
+ │ ├── http-client.ts # Cloudflare API client
204
+ │ └── s3-signer.ts # AWS S3 signing utility
206
205
  ├── packages/
207
- │ └── nitro-cloudflare-dev/ # Nitro/Nuxt 통합 모듈
208
- └── playground/ # Nuxt 테스트 환경
206
+ │ └── nitro-cloudflare-dev/ # Nitro/Nuxt integration module
207
+ └── playground/ # Nuxt test environment
209
208
  ```
210
209
 
211
- ## 라이선스
210
+ ## License
212
211
 
213
212
  MIT
214
213
 
215
- ## 관련 이슈
214
+ ## Related Issues
216
215
 
217
216
  - [miniflare R2 Buffer issue](https://github.com/cloudflare/workers-sdk/issues)
218
- - [wrangler remote binding not working](https://github.com/cloudflare/workers-sdk/issues)
217
+ - [wrangler remote binding errors](https://github.com/cloudflare/workers-sdk/issues)
package/dist/index.mjs CHANGED
@@ -304,7 +304,7 @@ function createKVBinding$1(client, namespaceId) {
304
304
  if (data.list_complete) {
305
305
  return {
306
306
  list_complete: true,
307
- keys: data.keys.map((k) => ({
307
+ keys: (data.keys || []).map((k) => ({
308
308
  name: k.name,
309
309
  expiration: k.expiration,
310
310
  metadata: k.metadata
@@ -314,7 +314,7 @@ function createKVBinding$1(client, namespaceId) {
314
314
  } else {
315
315
  return {
316
316
  list_complete: false,
317
- keys: data.keys.map((k) => ({
317
+ keys: (data.keys || []).map((k) => ({
318
318
  name: k.name,
319
319
  expiration: k.expiration,
320
320
  metadata: k.metadata
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openwrangler",
3
3
  "type": "module",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "typescript": "^5.7.2",
24
24
  "unbuild": "^3.3.1",
25
25
  "wrangler": "^4.54.0",
26
- "@bino0216/nitro-cloudflare-dev": "0.2.15"
26
+ "@bino0216/nitro-cloudflare-dev": "0.2.17"
27
27
  },
28
28
  "scripts": {
29
29
  "dev": "cd ./playground && pnpm dev",