cloudflare-d1 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7eb82310f834d6fd83eeb8b8e4052315bcdddc5b70fe894d98007c4bf7005d5f
4
+ data.tar.gz: 16c64ec2ec8950f765eb40b2b6a96ae6b58f773ed9ef3d52f144b246d8ef019f
5
+ SHA512:
6
+ metadata.gz: 5f33ff459fc46e04ea5d144e90fbef6634d64be28aff140a1db19d004767d3e5c30e4e91ede644af8ef299a6a0475babd01d4524e1263a6b3065c21c1da2469b
7
+ data.tar.gz: b0274d888eab689656d4cbd1b3a4f96cd2ff4593a42c1fb4b7f03121f399785fc84070a1c55cc2aa01626cde43b8bc056b85f8401605a097cc402f055d5298ab
data/.claude/d1.yaml ADDED
@@ -0,0 +1,560 @@
1
+ openapi: 3.0.0
2
+ info:
3
+ title: Cloudflare D1 API
4
+ version: 1.0.0
5
+ description: Cloudflare D1 Database API for managing SQLite databases at the edge
6
+
7
+ servers:
8
+ - url: https://api.cloudflare.com/client/v4
9
+ description: Cloudflare API v4
10
+
11
+ security:
12
+ - api_token: []
13
+ - api_key: []
14
+
15
+ components:
16
+ securitySchemes:
17
+ api_token:
18
+ type: http
19
+ scheme: bearer
20
+ description: API Token authentication
21
+ api_key:
22
+ type: apiKey
23
+ in: header
24
+ name: X-Auth-Key
25
+ description: API Key authentication (requires X-Auth-Email header)
26
+
27
+ schemas:
28
+ Database:
29
+ type: object
30
+ properties:
31
+ uuid:
32
+ type: string
33
+ format: uuid
34
+ description: Database unique identifier
35
+ name:
36
+ type: string
37
+ description: Database name
38
+ version:
39
+ type: string
40
+ description: Database version
41
+ created_at:
42
+ type: string
43
+ format: date-time
44
+ description: Creation timestamp
45
+ file_size:
46
+ type: integer
47
+ description: Database file size in bytes
48
+ num_tables:
49
+ type: integer
50
+ description: Number of tables in the database
51
+ required:
52
+ - name
53
+
54
+ DatabaseList:
55
+ type: object
56
+ properties:
57
+ result:
58
+ type: array
59
+ items:
60
+ $ref: "#/components/schemas/Database"
61
+ success:
62
+ type: boolean
63
+ errors:
64
+ type: array
65
+ items:
66
+ type: object
67
+ messages:
68
+ type: array
69
+ items:
70
+ type: object
71
+
72
+ CreateDatabaseRequest:
73
+ type: object
74
+ properties:
75
+ name:
76
+ type: string
77
+ description: Name for the new database
78
+ required:
79
+ - name
80
+
81
+ UpdateDatabaseRequest:
82
+ type: object
83
+ properties:
84
+ name:
85
+ type: string
86
+ description: New name for the database
87
+
88
+ QueryRequest:
89
+ type: object
90
+ properties:
91
+ sql:
92
+ type: string
93
+ description: SQL query to execute
94
+ params:
95
+ type: array
96
+ items: {}
97
+ description: Optional parameters for parameterized queries
98
+ required:
99
+ - sql
100
+
101
+ QueryResponse:
102
+ type: object
103
+ properties:
104
+ success:
105
+ type: boolean
106
+ result:
107
+ type: array
108
+ items:
109
+ type: object
110
+ meta:
111
+ type: object
112
+ properties:
113
+ changed_db:
114
+ type: boolean
115
+ changes:
116
+ type: integer
117
+ duration:
118
+ type: number
119
+ last_row_id:
120
+ type: integer
121
+ rows_read:
122
+ type: integer
123
+ rows_written:
124
+ type: integer
125
+ size_after:
126
+ type: integer
127
+ errors:
128
+ type: array
129
+ items:
130
+ type: object
131
+ messages:
132
+ type: array
133
+ items:
134
+ type: object
135
+
136
+ RawQueryResponse:
137
+ type: object
138
+ properties:
139
+ success:
140
+ type: boolean
141
+ result:
142
+ type: array
143
+ items:
144
+ type: array
145
+ description: Results as arrays instead of objects
146
+ meta:
147
+ type: object
148
+ errors:
149
+ type: array
150
+ items:
151
+ type: object
152
+ messages:
153
+ type: array
154
+ items:
155
+ type: object
156
+
157
+ ErrorResponse:
158
+ type: object
159
+ properties:
160
+ success:
161
+ type: boolean
162
+ example: false
163
+ errors:
164
+ type: array
165
+ items:
166
+ type: object
167
+ properties:
168
+ code:
169
+ type: integer
170
+ message:
171
+ type: string
172
+ messages:
173
+ type: array
174
+ items:
175
+ type: object
176
+ result:
177
+ nullable: true
178
+
179
+ parameters:
180
+ AccountId:
181
+ name: account_id
182
+ in: path
183
+ required: true
184
+ schema:
185
+ type: string
186
+ description: Cloudflare account identifier
187
+
188
+ DatabaseId:
189
+ name: database_id
190
+ in: path
191
+ required: true
192
+ schema:
193
+ type: string
194
+ description: Database identifier (UUID)
195
+
196
+ paths:
197
+ /accounts/{account_id}/d1/database:
198
+ get:
199
+ summary: List Databases
200
+ description: Retrieve a list of all D1 databases in the account
201
+ operationId: listDatabases
202
+ tags:
203
+ - D1 Database
204
+ parameters:
205
+ - $ref: "#/components/parameters/AccountId"
206
+ - name: name
207
+ in: query
208
+ schema:
209
+ type: string
210
+ description: Filter databases by name
211
+ - name: page
212
+ in: query
213
+ schema:
214
+ type: integer
215
+ default: 1
216
+ description: Page number for pagination
217
+ - name: per_page
218
+ in: query
219
+ schema:
220
+ type: integer
221
+ default: 20
222
+ maximum: 100
223
+ description: Number of items per page
224
+ responses:
225
+ "200":
226
+ description: Successful response
227
+ content:
228
+ application/json:
229
+ schema:
230
+ $ref: "#/components/schemas/DatabaseList"
231
+ "400":
232
+ description: Bad request
233
+ content:
234
+ application/json:
235
+ schema:
236
+ $ref: "#/components/schemas/ErrorResponse"
237
+ "401":
238
+ description: Unauthorized
239
+ content:
240
+ application/json:
241
+ schema:
242
+ $ref: "#/components/schemas/ErrorResponse"
243
+
244
+ post:
245
+ summary: Create Database
246
+ description: Create a new D1 database
247
+ operationId: createDatabase
248
+ tags:
249
+ - D1 Database
250
+ parameters:
251
+ - $ref: "#/components/parameters/AccountId"
252
+ requestBody:
253
+ required: true
254
+ content:
255
+ application/json:
256
+ schema:
257
+ $ref: "#/components/schemas/CreateDatabaseRequest"
258
+ responses:
259
+ "200":
260
+ description: Database created successfully
261
+ content:
262
+ application/json:
263
+ schema:
264
+ type: object
265
+ properties:
266
+ success:
267
+ type: boolean
268
+ result:
269
+ $ref: "#/components/schemas/Database"
270
+ errors:
271
+ type: array
272
+ items:
273
+ type: object
274
+ messages:
275
+ type: array
276
+ items:
277
+ type: object
278
+ "400":
279
+ description: Bad request
280
+ content:
281
+ application/json:
282
+ schema:
283
+ $ref: "#/components/schemas/ErrorResponse"
284
+
285
+ /accounts/{account_id}/d1/database/{database_id}:
286
+ get:
287
+ summary: Get Database
288
+ description: Retrieve details of a specific D1 database
289
+ operationId: getDatabase
290
+ tags:
291
+ - D1 Database
292
+ parameters:
293
+ - $ref: "#/components/parameters/AccountId"
294
+ - $ref: "#/components/parameters/DatabaseId"
295
+ responses:
296
+ "200":
297
+ description: Successful response
298
+ content:
299
+ application/json:
300
+ schema:
301
+ type: object
302
+ properties:
303
+ success:
304
+ type: boolean
305
+ result:
306
+ $ref: "#/components/schemas/Database"
307
+ errors:
308
+ type: array
309
+ items:
310
+ type: object
311
+ messages:
312
+ type: array
313
+ items:
314
+ type: object
315
+ "404":
316
+ description: Database not found
317
+ content:
318
+ application/json:
319
+ schema:
320
+ $ref: "#/components/schemas/ErrorResponse"
321
+
322
+ put:
323
+ summary: Update Database
324
+ description: Update a D1 database (full update)
325
+ operationId: updateDatabase
326
+ tags:
327
+ - D1 Database
328
+ parameters:
329
+ - $ref: "#/components/parameters/AccountId"
330
+ - $ref: "#/components/parameters/DatabaseId"
331
+ requestBody:
332
+ required: true
333
+ content:
334
+ application/json:
335
+ schema:
336
+ $ref: "#/components/schemas/UpdateDatabaseRequest"
337
+ responses:
338
+ "200":
339
+ description: Database updated successfully
340
+ content:
341
+ application/json:
342
+ schema:
343
+ type: object
344
+ properties:
345
+ success:
346
+ type: boolean
347
+ result:
348
+ $ref: "#/components/schemas/Database"
349
+
350
+ patch:
351
+ summary: Partial Update Database
352
+ description: Partially update a D1 database
353
+ operationId: patchDatabase
354
+ tags:
355
+ - D1 Database
356
+ parameters:
357
+ - $ref: "#/components/parameters/AccountId"
358
+ - $ref: "#/components/parameters/DatabaseId"
359
+ requestBody:
360
+ required: true
361
+ content:
362
+ application/json:
363
+ schema:
364
+ $ref: "#/components/schemas/UpdateDatabaseRequest"
365
+ responses:
366
+ "200":
367
+ description: Database updated successfully
368
+ content:
369
+ application/json:
370
+ schema:
371
+ type: object
372
+ properties:
373
+ success:
374
+ type: boolean
375
+ result:
376
+ $ref: "#/components/schemas/Database"
377
+
378
+ delete:
379
+ summary: Delete Database
380
+ description: Delete a D1 database
381
+ operationId: deleteDatabase
382
+ tags:
383
+ - D1 Database
384
+ parameters:
385
+ - $ref: "#/components/parameters/AccountId"
386
+ - $ref: "#/components/parameters/DatabaseId"
387
+ responses:
388
+ "200":
389
+ description: Database deleted successfully
390
+ content:
391
+ application/json:
392
+ schema:
393
+ type: object
394
+ properties:
395
+ success:
396
+ type: boolean
397
+ result:
398
+ nullable: true
399
+ "404":
400
+ description: Database not found
401
+ content:
402
+ application/json:
403
+ schema:
404
+ $ref: "#/components/schemas/ErrorResponse"
405
+
406
+ /accounts/{account_id}/d1/database/{database_id}/query:
407
+ post:
408
+ summary: Query Database
409
+ description: Execute SQL queries against a D1 database
410
+ operationId: queryDatabase
411
+ tags:
412
+ - D1 Database
413
+ parameters:
414
+ - $ref: "#/components/parameters/AccountId"
415
+ - $ref: "#/components/parameters/DatabaseId"
416
+ requestBody:
417
+ required: true
418
+ content:
419
+ application/json:
420
+ schema:
421
+ $ref: "#/components/schemas/QueryRequest"
422
+ examples:
423
+ simple_query:
424
+ summary: Simple SELECT query
425
+ value:
426
+ sql: "SELECT * FROM users"
427
+ parameterized_query:
428
+ summary: Parameterized query
429
+ value:
430
+ sql: "SELECT * FROM users WHERE id = ?"
431
+ params: [1]
432
+ responses:
433
+ "200":
434
+ description: Query executed successfully
435
+ content:
436
+ application/json:
437
+ schema:
438
+ $ref: "#/components/schemas/QueryResponse"
439
+ "400":
440
+ description: Bad request or SQL error
441
+ content:
442
+ application/json:
443
+ schema:
444
+ $ref: "#/components/schemas/ErrorResponse"
445
+
446
+ /accounts/{account_id}/d1/database/{database_id}/raw:
447
+ post:
448
+ summary: Raw Query Database
449
+ description: Execute SQL queries and return results as arrays instead of objects
450
+ operationId: rawQueryDatabase
451
+ tags:
452
+ - D1 Database
453
+ parameters:
454
+ - $ref: "#/components/parameters/AccountId"
455
+ - $ref: "#/components/parameters/DatabaseId"
456
+ requestBody:
457
+ required: true
458
+ content:
459
+ application/json:
460
+ schema:
461
+ $ref: "#/components/schemas/QueryRequest"
462
+ responses:
463
+ "200":
464
+ description: Query executed successfully
465
+ content:
466
+ application/json:
467
+ schema:
468
+ $ref: "#/components/schemas/RawQueryResponse"
469
+
470
+ /accounts/{account_id}/d1/database/{database_id}/export:
471
+ post:
472
+ summary: Export Database as SQL
473
+ description: Export the entire database as SQL dump
474
+ operationId: exportDatabase
475
+ tags:
476
+ - D1 Database
477
+ parameters:
478
+ - $ref: "#/components/parameters/AccountId"
479
+ - $ref: "#/components/parameters/DatabaseId"
480
+ requestBody:
481
+ required: false
482
+ content:
483
+ application/json:
484
+ schema:
485
+ type: object
486
+ properties:
487
+ output_format:
488
+ type: string
489
+ enum: [sql]
490
+ default: sql
491
+ responses:
492
+ "200":
493
+ description: Export successful
494
+ content:
495
+ application/sql:
496
+ schema:
497
+ type: string
498
+ description: SQL dump of the database
499
+ application/json:
500
+ schema:
501
+ type: object
502
+ properties:
503
+ success:
504
+ type: boolean
505
+ result:
506
+ type: string
507
+ description: SQL dump content
508
+
509
+ /accounts/{account_id}/d1/database/{database_id}/import:
510
+ post:
511
+ summary: Import SQL into Database
512
+ description: Import SQL statements into a D1 database
513
+ operationId: importDatabase
514
+ tags:
515
+ - D1 Database
516
+ parameters:
517
+ - $ref: "#/components/parameters/AccountId"
518
+ - $ref: "#/components/parameters/DatabaseId"
519
+ requestBody:
520
+ required: true
521
+ content:
522
+ application/sql:
523
+ schema:
524
+ type: string
525
+ description: SQL statements to import
526
+ multipart/form-data:
527
+ schema:
528
+ type: object
529
+ properties:
530
+ file:
531
+ type: string
532
+ format: binary
533
+ description: SQL file to import
534
+ responses:
535
+ "200":
536
+ description: Import successful
537
+ content:
538
+ application/json:
539
+ schema:
540
+ type: object
541
+ properties:
542
+ success:
543
+ type: boolean
544
+ result:
545
+ type: object
546
+ properties:
547
+ meta:
548
+ type: object
549
+ at_line:
550
+ type: integer
551
+ warnings:
552
+ type: array
553
+ items:
554
+ type: string
555
+ "400":
556
+ description: Import failed
557
+ content:
558
+ application/json:
559
+ schema:
560
+ $ref: "#/components/schemas/ErrorResponse"