forked from llimllib/chrome-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IndexedDB.py
151 lines (121 loc) · 4.41 KB
/
IndexedDB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
from enum import Enum
from typing import Any, List
from base import ChromeCommand
import Runtime
class DatabaseWithObjectStores:
"""Database with an array of object stores."""
def __init__(self, name: str, version: int, objectStores: List):
# Database name.
self.name = name
# Database version.
self.version = version
# Object stores in this database.
self.objectStores = objectStores
class ObjectStore:
"""Object store."""
def __init__(self, name: str, keyPath: "KeyPath", autoIncrement: bool, indexes: List):
# Object store name.
self.name = name
# Object store key path.
self.keyPath = keyPath
# If true, object store has auto increment flag set.
self.autoIncrement = autoIncrement
# Indexes in this object store.
self.indexes = indexes
class ObjectStoreIndex:
"""Object store index."""
def __init__(self, name: str, keyPath: "KeyPath", unique: bool, multiEntry: bool):
# Index name.
self.name = name
# Index key path.
self.keyPath = keyPath
# If true, index is unique.
self.unique = unique
# If true, index allows multiple entries for a key.
self.multiEntry = multiEntry
class Key:
"""Key."""
def __init__(self, type: str, number: float=None, string: str=None, date: float=None, array: List=None):
# Key type.
self.type = type
# Number value.
self.number = number
# String value.
self.string = string
# Date value.
self.date = date
# Array value.
self.array = array
class KeyRange:
"""Key range."""
def __init__(self, lowerOpen: bool, upperOpen: bool, lower: "Key"=None, upper: "Key"=None):
# If true lower bound is open.
self.lowerOpen = lowerOpen
# If true upper bound is open.
self.upperOpen = upperOpen
# Lower bound.
self.lower = lower
# Upper bound.
self.upper = upper
class DataEntry:
"""Data entry."""
def __init__(self, key: "Runtime.RemoteObject", primaryKey: "Runtime.RemoteObject", value: "Runtime.RemoteObject"):
# Key object.
self.key = key
# Primary key object.
self.primaryKey = primaryKey
# Value object.
self.value = value
class KeyPath:
"""Key path."""
def __init__(self, type: str, string: str=None, array: List=None):
# Key path type.
self.type = type
# String value.
self.string = string
# Array value.
self.array = array
class enable(ChromeCommand):
"""Enables events from backend."""
def __init__(self): pass
class disable(ChromeCommand):
"""Disables events from backend."""
def __init__(self): pass
class requestDatabaseNames(ChromeCommand):
"""Requests database names for given security origin."""
def __init__(self, securityOrigin: str):
# Security origin.
self.securityOrigin = securityOrigin
class requestDatabase(ChromeCommand):
"""Requests database with given name in given frame."""
def __init__(self, securityOrigin: str, databaseName: str):
# Security origin.
self.securityOrigin = securityOrigin
# Database name.
self.databaseName = databaseName
class requestData(ChromeCommand):
"""Requests data from object store or index."""
def __init__(self, securityOrigin: str, databaseName: str, objectStoreName: str, indexName: str, skipCount: int, pageSize: int, keyRange: "KeyRange"=None):
# Security origin.
self.securityOrigin = securityOrigin
# Database name.
self.databaseName = databaseName
# Object store name.
self.objectStoreName = objectStoreName
# Index name, empty string for object store data requests.
self.indexName = indexName
# Number of records to skip.
self.skipCount = skipCount
# Number of records to fetch.
self.pageSize = pageSize
# Key range.
self.keyRange = keyRange
class clearObjectStore(ChromeCommand):
"""Clears all entries from an object store."""
def __init__(self, securityOrigin: str, databaseName: str, objectStoreName: str):
# Security origin.
self.securityOrigin = securityOrigin
# Database name.
self.databaseName = databaseName
# Object store name.
self.objectStoreName = objectStoreName