2 * Copyright 2011 The Closure Compiler Authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @fileoverview Definitions for W3C's IndexedDB API. In Chrome all the
19 * IndexedDB classes are prefixed with 'webkit'. In order to access constants
20 * and static methods of these classes they must be duplicated with the
22 * @see http://www.w3.org/TR/IndexedDB/
25 * @author guido.tapia@picnet.com.au (Guido Tapia)
28 /** @type {IDBFactory} */
29 Window.prototype.moz_indexedDB;
31 /** @type {IDBFactory} */
32 Window.prototype.mozIndexedDB;
34 /** @type {IDBFactory} */
35 Window.prototype.webkitIndexedDB;
37 /** @type {IDBFactory} */
38 Window.prototype.msIndexedDB;
40 /** @type {IDBFactory} */
41 Window.prototype.indexedDB;
45 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBFactory
47 function IDBFactory() {}
50 * @param {string} name The name of the database to open.
51 * @param {number=} opt_version The version at which to open the database.
52 * @return {!IDBOpenDBRequest} The IDBRequest object.
54 IDBFactory.prototype.open = function(name, opt_version) {};
57 * @param {string} name The name of the database to delete.
58 * @return {!IDBOpenDBRequest} The IDBRequest object.
60 IDBFactory.prototype.deleteDatabase = function(name) {};
64 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBDatabaseException
66 function IDBDatabaseException() {}
70 * @extends {IDBDatabaseException}
71 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBDatabaseException
73 function webkitIDBDatabaseException() {}
79 IDBDatabaseException.UNKNOWN_ERR;
85 webkitIDBDatabaseException.UNKNOWN_ERR;
91 IDBDatabaseException.NON_TRANSIENT_ERR;
97 webkitIDBDatabaseException.NON_TRANSIENT_ERR;
103 IDBDatabaseException.NOT_FOUND_ERR;
109 webkitIDBDatabaseException.NOT_FOUND_ERR;
115 IDBDatabaseException.CONSTRAINT_ERR;
121 webkitIDBDatabaseException.CONSTRAINT_ERR;
127 IDBDatabaseException.DATA_ERR;
133 webkitIDBDatabaseException.DATA_ERR;
139 IDBDatabaseException.NOT_ALLOWED_ERR;
145 webkitIDBDatabaseException.NOT_ALLOWED_ERR;
151 IDBDatabaseException.TRANSACTION_INACTIVE_ERR;
157 webkitIDBDatabaseException.TRANSACTION_INACTIVE_ERR;
163 IDBDatabaseException.ABORT_ERR;
169 webkitIDBDatabaseException.ABORT_ERR;
175 IDBDatabaseException.READ_ONLY_ERR;
181 webkitIDBDatabaseException.READ_ONLY_ERR;
187 IDBDatabaseException.TIMEOUT_ERR;
193 webkitIDBDatabaseException.TIMEOUT_ERR;
199 IDBDatabaseException.QUOTA_ERR;
205 webkitIDBDatabaseException.QUOTA_ERR;
211 IDBDatabaseException.prototype.code;
217 webkitIDBDatabaseException.prototype.code;
223 IDBDatabaseException.prototype.message;
229 webkitIDBDatabaseException.prototype.message;
233 * @implements {EventTarget}
234 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBRequest
236 function IDBRequest() {}
239 * @param {boolean=} opt_useCapture
242 IDBRequest.prototype.addEventListener =
243 function(type, listener, opt_useCapture) {};
246 * @param {boolean=} opt_useCapture
249 IDBRequest.prototype.removeEventListener =
250 function(type, listener, opt_useCapture) {};
253 IDBRequest.prototype.dispatchEvent = function(evt) {};
257 * @extends {IDBRequest}
258 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBRequest
260 function webkitIDBRequest() {}
272 webkitIDBRequest.LOADING;
284 webkitIDBRequest.DONE;
286 /** @type {number} */
287 IDBRequest.prototype.readyState; // readonly
289 /** @type {function(!Event)} */
290 IDBRequest.prototype.onsuccess = function(e) {};
292 /** @type {function(!Event)} */
293 IDBRequest.prototype.onerror = function(e) {};
296 IDBRequest.prototype.result; // readonly
300 * @deprecated Use "error"
302 IDBRequest.prototype.errorCode; // readonly
305 /** @type {!DOMError} */
306 IDBRequest.prototype.error; // readonly
308 /** @type {Object} */
309 IDBRequest.prototype.source; // readonly
311 /** @type {IDBTransaction} */
312 IDBRequest.prototype.transaction; // readonly
316 * @extends {IDBRequest}
317 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBOpenDBRequest
319 function IDBOpenDBRequest() {}
322 * @type {function(!IDBVersionChangeEvent)}
324 IDBOpenDBRequest.prototype.onblocked = function(e) {};
327 * @type {function(!IDBVersionChangeEvent)}
329 IDBOpenDBRequest.prototype.onupgradeneeded = function(e) {};
333 * @implements {EventTarget}
334 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBDatabase
336 function IDBDatabase() {}
342 IDBDatabase.prototype.name;
348 IDBDatabase.prototype.description;
354 IDBDatabase.prototype.version;
357 * @type {DOMStringList}
360 IDBDatabase.prototype.objectStoreNames;
363 * @param {string} name The name of the object store.
364 * @param {Object=} opt_parameters Parameters to be passed
365 * creating the object store.
366 * @return {!IDBObjectStore} The created/open object store.
368 IDBDatabase.prototype.createObjectStore =
369 function(name, opt_parameters) {};
372 * @param {string} name The name of the object store to remove.
374 IDBDatabase.prototype.deleteObjectStore = function(name) {};
377 * @param {string} version The new version of the database.
378 * @return {!IDBRequest} The IDBRequest object.
380 IDBDatabase.prototype.setVersion = function(version) {};
383 * @param {Array.<string>} storeNames The stores to open in this transaction.
384 * @param {(number|string)=} mode The mode for opening the object stores.
385 * @return {!IDBTransaction} The IDBRequest object.
387 IDBDatabase.prototype.transaction = function(storeNames, mode) {};
390 * Closes the database connection.
392 IDBDatabase.prototype.close = function() {};
397 IDBDatabase.prototype.onabort = function() {};
402 IDBDatabase.prototype.onerror = function() {};
407 IDBDatabase.prototype.onversionchange = function() {};
410 * @param {boolean=} opt_useCapture
413 IDBDatabase.prototype.addEventListener =
414 function(type, listener, opt_useCapture) {};
417 * @param {boolean=} opt_useCapture
420 IDBDatabase.prototype.removeEventListener =
421 function(type, listener, opt_useCapture) {};
424 IDBDatabase.prototype.dispatchEvent = function(evt) {};
427 * Typedef for valid key types according to the w3 specification. Note that this
428 * is slightly wider than what is actually allowed, as all Array elements must
429 * have a valid key type.
430 * @see http://www.w3.org/TR/IndexedDB/#key-construct
431 * @typedef {number|string|!Date|!Array.<?>}
437 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBObjectStore
439 function IDBObjectStore() {}
444 IDBObjectStore.prototype.name;
449 IDBObjectStore.prototype.keyPath;
452 * @type {DOMStringList}
454 IDBObjectStore.prototype.indexNames;
456 /** @type {IDBTransaction} */
457 IDBObjectStore.prototype.transaction;
459 /** @type {boolean} */
460 IDBObjectStore.prototype.autoIncrement;
463 * @param {*} value The value to put into the object store.
464 * @param {IDBKeyType=} key The key of this value.
465 * @return {!IDBRequest} The IDBRequest object.
467 IDBObjectStore.prototype.put = function(value, key) {};
470 * @param {*} value The value to add into the object store.
471 * @param {IDBKeyType=} key The key of this value.
472 * @return {!IDBRequest} The IDBRequest object.
474 IDBObjectStore.prototype.add = function(value, key) {};
477 * @param {IDBKeyType} key The key of this value.
478 * @return {!IDBRequest} The IDBRequest object.
480 IDBObjectStore.prototype.delete = function(key) {};
483 * @param {IDBKeyType|!IDBKeyRange} key The key of the document to retrieve.
484 * @return {!IDBRequest} The IDBRequest object.
486 IDBObjectStore.prototype.get = function(key) {};
489 * @return {!IDBRequest} The IDBRequest object.
491 IDBObjectStore.prototype.clear = function() {};
494 * @param {IDBKeyRange=} range The range of the cursor.
495 * @param {(number|string)=} direction The direction of cursor enumeration.
496 * @return {!IDBRequest} The IDBRequest object.
498 IDBObjectStore.prototype.openCursor = function(range, direction) {};
501 * @param {string} name The name of the index.
502 * @param {string|!Array.<string>} keyPath The path to the index key.
503 * @param {Object=} opt_paramters Optional parameters
504 * for the created index.
505 * @return {!IDBIndex} The IDBIndex object.
507 IDBObjectStore.prototype.createIndex = function(name, keyPath, opt_paramters) {};
510 * @param {string} name The name of the index to retrieve.
511 * @return {!IDBIndex} The IDBIndex object.
513 IDBObjectStore.prototype.index = function(name) {};
516 * @param {string} indexName The name of the index to remove.
518 IDBObjectStore.prototype.deleteIndex = function(indexName) {};
521 * @param {(IDBKeyType|IDBKeyRange)=} key The key of this value.
522 * @return {!IDBRequest} The IDBRequest object.
523 * @see http://www.w3.org/TR/IndexedDB/#widl-IDBObjectStore-count
525 IDBObjectStore.prototype.count = function(key) {};
529 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBIndex
531 function IDBIndex() {}
537 IDBIndex.prototype.name;
540 * @type {!IDBObjectStore}
543 IDBIndex.prototype.objectStore;
549 IDBIndex.prototype.keyPath;
555 IDBIndex.prototype.unique;
558 * @param {IDBKeyRange=} range The range of the cursor.
559 * @param {(number|string)=} direction The direction of cursor enumeration.
560 * @return {!IDBRequest} The IDBRequest object.
562 IDBIndex.prototype.openCursor = function(range, direction) {};
565 * @param {IDBKeyRange=} range The range of the cursor.
566 * @param {(number|string)=} direction The direction of cursor enumeration.
567 * @return {!IDBRequest} The IDBRequest object.
569 IDBIndex.prototype.openKeyCursor = function(range, direction) {};
572 * @param {IDBKeyType|!IDBKeyRange} key The id of the object to retrieve.
573 * @return {!IDBRequest} The IDBRequest object.
575 IDBIndex.prototype.get = function(key) {};
578 * @param {IDBKeyType|!IDBKeyRange} key The id of the object to retrieve.
579 * @return {!IDBRequest} The IDBRequest object.
581 IDBIndex.prototype.getKey = function(key) {};
585 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBCursor
587 function IDBCursor() {}
591 * @extends {IDBCursor}
592 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBCursor
594 function webkitIDBCursor() {}
606 webkitIDBCursor.NEXT;
612 IDBCursor.NEXT_NO_DUPLICATE;
618 webkitIDBCursor.NEXT_NO_DUPLICATE;
630 webkitIDBCursor.PREV;
636 IDBCursor.PREV_NO_DUPLICATE;
642 webkitIDBCursor.PREV_NO_DUPLICATE;
648 IDBCursor.prototype.source;
654 IDBCursor.prototype.direction;
660 IDBCursor.prototype.key;
666 IDBCursor.prototype.primaryKey;
669 * @param {*} value The new value for the current object in the cursor.
670 * @return {!IDBRequest} The IDBRequest object.
672 IDBCursor.prototype.update = function(value) {};
675 * Note: Must be quoted to avoid parse error.
676 * @param {IDBKeyType=} key Continue enumerating the cursor from the specified
679 IDBCursor.prototype.continue = function(key) {};
682 * @param {number} count Number of times to iterate the cursor.
684 IDBCursor.prototype.advance = function(count) {};
687 * Note: Must be quoted to avoid parse error.
688 * @return {!IDBRequest} The IDBRequest object.
690 IDBCursor.prototype.delete = function() {};
694 * @extends {IDBCursor}
695 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBCursorWithValue
697 function IDBCursorWithValue() {}
700 IDBCursorWithValue.prototype.value; // readonly
704 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBTransaction
706 function IDBTransaction() {}
710 * @extends {IDBTransaction}
711 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBTransaction
713 function webkitIDBTransaction() {}
719 IDBTransaction.READ_WRITE;
725 webkitIDBTransaction.READ_WRITE;
731 IDBTransaction.READ_ONLY;
737 webkitIDBTransaction.READ_ONLY;
743 IDBTransaction.VERSION_CHANGE;
749 webkitIDBTransaction.VERSION_CHANGE;
752 * @type {number|string}
755 IDBTransaction.prototype.mode;
758 * @type {IDBDatabase}
761 IDBTransaction.prototype.db;
764 * @param {string} name The name of the object store to retrieve.
765 * @return {!IDBObjectStore} The object store.
767 IDBTransaction.prototype.objectStore = function(name) {};
770 * Aborts the transaction.
772 IDBTransaction.prototype.abort = function() {};
777 IDBTransaction.prototype.onabort = function() {};
782 IDBTransaction.prototype.oncomplete = function() {};
787 IDBTransaction.prototype.onerror = function() {};
791 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBKeyRange
793 function IDBKeyRange() {}
797 * @extends {IDBKeyRange}
798 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBKeyRange
800 function webkitIDBKeyRange() {}
806 IDBKeyRange.prototype.lower;
812 IDBKeyRange.prototype.upper;
818 IDBKeyRange.prototype.lowerOpen;
824 IDBKeyRange.prototype.upperOpen;
827 * @param {IDBKeyType} value The single key value of this range.
828 * @return {!IDBKeyRange} The key range.
830 IDBKeyRange.only = function(value) {};
833 * @param {IDBKeyType} value The single key value of this range.
834 * @return {!IDBKeyRange} The key range.
836 webkitIDBKeyRange.only = function(value) {};
839 * @param {IDBKeyType} bound Creates a lower bound key range.
840 * @param {boolean=} open Open the key range.
841 * @return {!IDBKeyRange} The key range.
843 IDBKeyRange.lowerBound = function(bound, open) {};
846 * @param {IDBKeyType} bound Creates a lower bound key range.
847 * @param {boolean=} open Open the key range.
848 * @return {!IDBKeyRange} The key range.
850 webkitIDBKeyRange.lowerBound = function(bound, open) {};
853 * @param {IDBKeyType} bound Creates an upper bound key range.
854 * @param {boolean=} open Open the key range.
855 * @return {!IDBKeyRange} The key range.
857 IDBKeyRange.upperBound = function(bound, open) {};
860 * @param {IDBKeyType} bound Creates an upper bound key range.
861 * @param {boolean=} open Open the key range.
862 * @return {!IDBKeyRange} The key range.
864 webkitIDBKeyRange.upperBound = function(bound, open) {};
867 * @param {IDBKeyType} left The left bound value.
868 * @param {IDBKeyType} right The right bound value.
869 * @param {boolean=} openLeft Whether the left bound value should be excluded.
870 * @param {boolean=} openRight Whether the right bound value should be excluded.
871 * @return {!IDBKeyRange} The key range.
873 IDBKeyRange.bound = function(left, right, openLeft, openRight) {};
876 * @param {IDBKeyType} left The left bound value.
877 * @param {IDBKeyType} right The right bound value.
878 * @param {boolean=} openLeft Whether the left bound value should be excluded.
879 * @param {boolean=} openRight Whether the right bound value should be excluded.
880 * @return {!IDBKeyRange} The key range.
882 webkitIDBKeyRange.bound = function(left, right, openLeft, openRight) {};
887 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBVersionChangeEvent
889 function IDBVersionChangeEvent() {}
895 IDBVersionChangeEvent.prototype.oldVersion;
901 IDBVersionChangeEvent.prototype.newVersion;
905 * @extends {IDBVersionChangeEvent}
906 * @see http://www.w3.org/TR/IndexedDB/#idl-def-IDBVersionChangeEvent
908 function webkitIDBVersionChangeEvent() {}
914 webkitIDBVersionChangeEvent.prototype.version;