Debian Codegraph @

indexeddb/indexeddb.go

raw symbols SCIP
1 // Package indexeddb provides the Chrome DevTools Protocol
2 // commands, types, and events for the IndexedDB domain.
3 //
4 // Generated by the cdproto-gen command.
5 package indexeddb
6
7 // Code generated by cdproto-gen. DO NOT EDIT.
8
9 import (
10 "context"
11
12 "github.com/chromedp/cdproto/cdp"
13 "github.com/chromedp/cdproto/storage"
14 )
15
16 // ClearObjectStoreParams clears all entries from an object store.
17 type ClearObjectStoreParams struct {
18 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
19 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
20 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
21 DatabaseName string `json:"databaseName"` // Database name.
22 ObjectStoreName string `json:"objectStoreName"` // Object store name.
23 }
24
25 // ClearObjectStore clears all entries from an object store.
26 //
27 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-clearObjectStore
28 //
29 // parameters:
30 //
31 // databaseName - Database name.
32 // objectStoreName - Object store name.
33 func ClearObjectStore(databaseName string, objectStoreName string) *ClearObjectStoreParams {
34 return &ClearObjectStoreParams{
35 DatabaseName: databaseName,
36 ObjectStoreName: objectStoreName,
37 }
38 }
39
40 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
41 // or storageBucket must be specified. Security origin.
42 func (p ClearObjectStoreParams) WithSecurityOrigin(securityOrigin string) *ClearObjectStoreParams {
43 p.SecurityOrigin = securityOrigin
44 return &p
45 }
46
47 // WithStorageKey storage key.
48 func (p ClearObjectStoreParams) WithStorageKey(storageKey string) *ClearObjectStoreParams {
49 p.StorageKey = storageKey
50 return &p
51 }
52
53 // WithStorageBucket storage bucket. If not specified, it uses the default
54 // bucket.
55 func (p ClearObjectStoreParams) WithStorageBucket(storageBucket *storage.Bucket) *ClearObjectStoreParams {
56 p.StorageBucket = storageBucket
57 return &p
58 }
59
60 // Do executes IndexedDB.clearObjectStore against the provided context.
61 func (p *ClearObjectStoreParams) Do(ctx context.Context) (err error) {
62 return cdp.Execute(ctx, CommandClearObjectStore, p, nil)
63 }
64
65 // DeleteDatabaseParams deletes a database.
66 type DeleteDatabaseParams struct {
67 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
68 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
69 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
70 DatabaseName string `json:"databaseName"` // Database name.
71 }
72
73 // DeleteDatabase deletes a database.
74 //
75 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-deleteDatabase
76 //
77 // parameters:
78 //
79 // databaseName - Database name.
80 func DeleteDatabase(databaseName string) *DeleteDatabaseParams {
81 return &DeleteDatabaseParams{
82 DatabaseName: databaseName,
83 }
84 }
85
86 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
87 // or storageBucket must be specified. Security origin.
88 func (p DeleteDatabaseParams) WithSecurityOrigin(securityOrigin string) *DeleteDatabaseParams {
89 p.SecurityOrigin = securityOrigin
90 return &p
91 }
92
93 // WithStorageKey storage key.
94 func (p DeleteDatabaseParams) WithStorageKey(storageKey string) *DeleteDatabaseParams {
95 p.StorageKey = storageKey
96 return &p
97 }
98
99 // WithStorageBucket storage bucket. If not specified, it uses the default
100 // bucket.
101 func (p DeleteDatabaseParams) WithStorageBucket(storageBucket *storage.Bucket) *DeleteDatabaseParams {
102 p.StorageBucket = storageBucket
103 return &p
104 }
105
106 // Do executes IndexedDB.deleteDatabase against the provided context.
107 func (p *DeleteDatabaseParams) Do(ctx context.Context) (err error) {
108 return cdp.Execute(ctx, CommandDeleteDatabase, p, nil)
109 }
110
111 // DeleteObjectStoreEntriesParams delete a range of entries from an object
112 // store.
113 type DeleteObjectStoreEntriesParams struct {
114 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
115 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
116 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
117 DatabaseName string `json:"databaseName"`
118 ObjectStoreName string `json:"objectStoreName"`
119 KeyRange *KeyRange `json:"keyRange"` // Range of entry keys to delete
120 }
121
122 // DeleteObjectStoreEntries delete a range of entries from an object store.
123 //
124 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-deleteObjectStoreEntries
125 //
126 // parameters:
127 //
128 // databaseName
129 // objectStoreName
130 // keyRange - Range of entry keys to delete
131 func DeleteObjectStoreEntries(databaseName string, objectStoreName string, keyRange *KeyRange) *DeleteObjectStoreEntriesParams {
132 return &DeleteObjectStoreEntriesParams{
133 DatabaseName: databaseName,
134 ObjectStoreName: objectStoreName,
135 KeyRange: keyRange,
136 }
137 }
138
139 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
140 // or storageBucket must be specified. Security origin.
141 func (p DeleteObjectStoreEntriesParams) WithSecurityOrigin(securityOrigin string) *DeleteObjectStoreEntriesParams {
142 p.SecurityOrigin = securityOrigin
143 return &p
144 }
145
146 // WithStorageKey storage key.
147 func (p DeleteObjectStoreEntriesParams) WithStorageKey(storageKey string) *DeleteObjectStoreEntriesParams {
148 p.StorageKey = storageKey
149 return &p
150 }
151
152 // WithStorageBucket storage bucket. If not specified, it uses the default
153 // bucket.
154 func (p DeleteObjectStoreEntriesParams) WithStorageBucket(storageBucket *storage.Bucket) *DeleteObjectStoreEntriesParams {
155 p.StorageBucket = storageBucket
156 return &p
157 }
158
159 // Do executes IndexedDB.deleteObjectStoreEntries against the provided context.
160 func (p *DeleteObjectStoreEntriesParams) Do(ctx context.Context) (err error) {
161 return cdp.Execute(ctx, CommandDeleteObjectStoreEntries, p, nil)
162 }
163
164 // DisableParams disables events from backend.
165 type DisableParams struct{}
166
167 // Disable disables events from backend.
168 //
169 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-disable
170 func Disable() *DisableParams {
171 return &DisableParams{}
172 }
173
174 // Do executes IndexedDB.disable against the provided context.
175 func (p *DisableParams) Do(ctx context.Context) (err error) {
176 return cdp.Execute(ctx, CommandDisable, nil, nil)
177 }
178
179 // EnableParams enables events from backend.
180 type EnableParams struct{}
181
182 // Enable enables events from backend.
183 //
184 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-enable
185 func Enable() *EnableParams {
186 return &EnableParams{}
187 }
188
189 // Do executes IndexedDB.enable against the provided context.
190 func (p *EnableParams) Do(ctx context.Context) (err error) {
191 return cdp.Execute(ctx, CommandEnable, nil, nil)
192 }
193
194 // RequestDataParams requests data from object store or index.
195 type RequestDataParams struct {
196 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
197 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
198 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
199 DatabaseName string `json:"databaseName"` // Database name.
200 ObjectStoreName string `json:"objectStoreName"` // Object store name.
201 IndexName string `json:"indexName"` // Index name, empty string for object store data requests.
202 SkipCount int64 `json:"skipCount"` // Number of records to skip.
203 PageSize int64 `json:"pageSize"` // Number of records to fetch.
204 KeyRange *KeyRange `json:"keyRange,omitempty,omitzero"` // Key range.
205 }
206
207 // RequestData requests data from object store or index.
208 //
209 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-requestData
210 //
211 // parameters:
212 //
213 // databaseName - Database name.
214 // objectStoreName - Object store name.
215 // indexName - Index name, empty string for object store data requests.
216 // skipCount - Number of records to skip.
217 // pageSize - Number of records to fetch.
218 func RequestData(databaseName string, objectStoreName string, indexName string, skipCount int64, pageSize int64) *RequestDataParams {
219 return &RequestDataParams{
220 DatabaseName: databaseName,
221 ObjectStoreName: objectStoreName,
222 IndexName: indexName,
223 SkipCount: skipCount,
224 PageSize: pageSize,
225 }
226 }
227
228 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
229 // or storageBucket must be specified. Security origin.
230 func (p RequestDataParams) WithSecurityOrigin(securityOrigin string) *RequestDataParams {
231 p.SecurityOrigin = securityOrigin
232 return &p
233 }
234
235 // WithStorageKey storage key.
236 func (p RequestDataParams) WithStorageKey(storageKey string) *RequestDataParams {
237 p.StorageKey = storageKey
238 return &p
239 }
240
241 // WithStorageBucket storage bucket. If not specified, it uses the default
242 // bucket.
243 func (p RequestDataParams) WithStorageBucket(storageBucket *storage.Bucket) *RequestDataParams {
244 p.StorageBucket = storageBucket
245 return &p
246 }
247
248 // WithKeyRange key range.
249 func (p RequestDataParams) WithKeyRange(keyRange *KeyRange) *RequestDataParams {
250 p.KeyRange = keyRange
251 return &p
252 }
253
254 // RequestDataReturns return values.
255 type RequestDataReturns struct {
256 ObjectStoreDataEntries []*DataEntry `json:"objectStoreDataEntries,omitempty,omitzero"` // Array of object store data entries.
257 HasMore bool `json:"hasMore"` // If true, there are more entries to fetch in the given range.
258 }
259
260 // Do executes IndexedDB.requestData against the provided context.
261 //
262 // returns:
263 //
264 // objectStoreDataEntries - Array of object store data entries.
265 // hasMore - If true, there are more entries to fetch in the given range.
266 func (p *RequestDataParams) Do(ctx context.Context) (objectStoreDataEntries []*DataEntry, hasMore bool, err error) {
267 // execute
268 var res RequestDataReturns
269 err = cdp.Execute(ctx, CommandRequestData, p, &res)
270 if err != nil {
271 return nil, false, err
272 }
273
274 return res.ObjectStoreDataEntries, res.HasMore, nil
275 }
276
277 // GetMetadataParams gets metadata of an object store.
278 type GetMetadataParams struct {
279 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
280 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
281 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
282 DatabaseName string `json:"databaseName"` // Database name.
283 ObjectStoreName string `json:"objectStoreName"` // Object store name.
284 }
285
286 // GetMetadata gets metadata of an object store.
287 //
288 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-getMetadata
289 //
290 // parameters:
291 //
292 // databaseName - Database name.
293 // objectStoreName - Object store name.
294 func GetMetadata(databaseName string, objectStoreName string) *GetMetadataParams {
295 return &GetMetadataParams{
296 DatabaseName: databaseName,
297 ObjectStoreName: objectStoreName,
298 }
299 }
300
301 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
302 // or storageBucket must be specified. Security origin.
303 func (p GetMetadataParams) WithSecurityOrigin(securityOrigin string) *GetMetadataParams {
304 p.SecurityOrigin = securityOrigin
305 return &p
306 }
307
308 // WithStorageKey storage key.
309 func (p GetMetadataParams) WithStorageKey(storageKey string) *GetMetadataParams {
310 p.StorageKey = storageKey
311 return &p
312 }
313
314 // WithStorageBucket storage bucket. If not specified, it uses the default
315 // bucket.
316 func (p GetMetadataParams) WithStorageBucket(storageBucket *storage.Bucket) *GetMetadataParams {
317 p.StorageBucket = storageBucket
318 return &p
319 }
320
321 // GetMetadataReturns return values.
322 type GetMetadataReturns struct {
323 EntriesCount float64 `json:"entriesCount,omitempty,omitzero"` // the entries count
324 KeyGeneratorValue float64 `json:"keyGeneratorValue,omitempty,omitzero"` // the current value of key generator, to become the next inserted key into the object store. Valid if objectStore.autoIncrement is true.
325 }
326
327 // Do executes IndexedDB.getMetadata against the provided context.
328 //
329 // returns:
330 //
331 // entriesCount - the entries count
332 // keyGeneratorValue - the current value of key generator, to become the next inserted key into the object store. Valid if objectStore.autoIncrement is true.
333 func (p *GetMetadataParams) Do(ctx context.Context) (entriesCount float64, keyGeneratorValue float64, err error) {
334 // execute
335 var res GetMetadataReturns
336 err = cdp.Execute(ctx, CommandGetMetadata, p, &res)
337 if err != nil {
338 return 0, 0, err
339 }
340
341 return res.EntriesCount, res.KeyGeneratorValue, nil
342 }
343
344 // RequestDatabaseParams requests database with given name in given frame.
345 type RequestDatabaseParams struct {
346 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
347 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
348 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
349 DatabaseName string `json:"databaseName"` // Database name.
350 }
351
352 // RequestDatabase requests database with given name in given frame.
353 //
354 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-requestDatabase
355 //
356 // parameters:
357 //
358 // databaseName - Database name.
359 func RequestDatabase(databaseName string) *RequestDatabaseParams {
360 return &RequestDatabaseParams{
361 DatabaseName: databaseName,
362 }
363 }
364
365 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
366 // or storageBucket must be specified. Security origin.
367 func (p RequestDatabaseParams) WithSecurityOrigin(securityOrigin string) *RequestDatabaseParams {
368 p.SecurityOrigin = securityOrigin
369 return &p
370 }
371
372 // WithStorageKey storage key.
373 func (p RequestDatabaseParams) WithStorageKey(storageKey string) *RequestDatabaseParams {
374 p.StorageKey = storageKey
375 return &p
376 }
377
378 // WithStorageBucket storage bucket. If not specified, it uses the default
379 // bucket.
380 func (p RequestDatabaseParams) WithStorageBucket(storageBucket *storage.Bucket) *RequestDatabaseParams {
381 p.StorageBucket = storageBucket
382 return &p
383 }
384
385 // RequestDatabaseReturns return values.
386 type RequestDatabaseReturns struct {
387 DatabaseWithObjectStores *DatabaseWithObjectStores `json:"databaseWithObjectStores,omitempty,omitzero"` // Database with an array of object stores.
388 }
389
390 // Do executes IndexedDB.requestDatabase against the provided context.
391 //
392 // returns:
393 //
394 // databaseWithObjectStores - Database with an array of object stores.
395 func (p *RequestDatabaseParams) Do(ctx context.Context) (databaseWithObjectStores *DatabaseWithObjectStores, err error) {
396 // execute
397 var res RequestDatabaseReturns
398 err = cdp.Execute(ctx, CommandRequestDatabase, p, &res)
399 if err != nil {
400 return nil, err
401 }
402
403 return res.DatabaseWithObjectStores, nil
404 }
405
406 // RequestDatabaseNamesParams requests database names for given security
407 // origin.
408 type RequestDatabaseNamesParams struct {
409 SecurityOrigin string `json:"securityOrigin,omitempty,omitzero"` // At least and at most one of securityOrigin, storageKey, or storageBucket must be specified. Security origin.
410 StorageKey string `json:"storageKey,omitempty,omitzero"` // Storage key.
411 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket. If not specified, it uses the default bucket.
412 }
413
414 // RequestDatabaseNames requests database names for given security origin.
415 //
416 // See: https://chromedevtools.github.io/devtools-protocol/tot/IndexedDB#method-requestDatabaseNames
417 //
418 // parameters:
419 func RequestDatabaseNames() *RequestDatabaseNamesParams {
420 return &RequestDatabaseNamesParams{}
421 }
422
423 // WithSecurityOrigin at least and at most one of securityOrigin, storageKey,
424 // or storageBucket must be specified. Security origin.
425 func (p RequestDatabaseNamesParams) WithSecurityOrigin(securityOrigin string) *RequestDatabaseNamesParams {
426 p.SecurityOrigin = securityOrigin
427 return &p
428 }
429
430 // WithStorageKey storage key.
431 func (p RequestDatabaseNamesParams) WithStorageKey(storageKey string) *RequestDatabaseNamesParams {
432 p.StorageKey = storageKey
433 return &p
434 }
435
436 // WithStorageBucket storage bucket. If not specified, it uses the default
437 // bucket.
438 func (p RequestDatabaseNamesParams) WithStorageBucket(storageBucket *storage.Bucket) *RequestDatabaseNamesParams {
439 p.StorageBucket = storageBucket
440 return &p
441 }
442
443 // RequestDatabaseNamesReturns return values.
444 type RequestDatabaseNamesReturns struct {
445 DatabaseNames []string `json:"databaseNames,omitempty,omitzero"` // Database names for origin.
446 }
447
448 // Do executes IndexedDB.requestDatabaseNames against the provided context.
449 //
450 // returns:
451 //
452 // databaseNames - Database names for origin.
453 func (p *RequestDatabaseNamesParams) Do(ctx context.Context) (databaseNames []string, err error) {
454 // execute
455 var res RequestDatabaseNamesReturns
456 err = cdp.Execute(ctx, CommandRequestDatabaseNames, p, &res)
457 if err != nil {
458 return nil, err
459 }
460
461 return res.DatabaseNames, nil
462 }
463
464 // Command names.
465 const (
466 CommandClearObjectStore = "IndexedDB.clearObjectStore"
467 CommandDeleteDatabase = "IndexedDB.deleteDatabase"
468 CommandDeleteObjectStoreEntries = "IndexedDB.deleteObjectStoreEntries"
469 CommandDisable = "IndexedDB.disable"
470 CommandEnable = "IndexedDB.enable"
471 CommandRequestData = "IndexedDB.requestData"
472 CommandGetMetadata = "IndexedDB.getMetadata"
473 CommandRequestDatabase = "IndexedDB.requestDatabase"
474 CommandRequestDatabaseNames = "IndexedDB.requestDatabaseNames"
475 )