mol_db 0.0.1730 → 0.0.1732

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_db",
3
- "version": "0.0.1730",
3
+ "version": "0.0.1732",
4
4
  "exports": {
5
5
  "node": {
6
6
  "import": "./node.mjs",
package/web.d.ts CHANGED
@@ -22,29 +22,40 @@ declare namespace $ {
22
22
  }
23
23
 
24
24
  declare namespace $ {
25
+ /** Converts IDBResult to Promise */
25
26
  function $mol_db_response<Result>(request: IDBRequest<Result>): Promise<Result>;
26
27
  }
27
28
 
28
29
  declare namespace $ {
30
+ /** IndexedDB ObjectStore wrapper. */
29
31
  class $mol_db_store<Schema extends $mol_db_store_schema> {
30
32
  readonly native: IDBObjectStore;
31
33
  constructor(native: IDBObjectStore);
32
34
  get name(): string;
33
35
  get path(): string | string[] | null;
34
36
  get incremental(): boolean;
37
+ /** Returns dictionary of all existen Indexes. */
35
38
  get indexes(): { [Name in keyof Schema["Indexes"]]: $mol_db_index<{
36
39
  Key: Schema["Indexes"][Name];
37
40
  Doc: Schema["Doc"];
38
41
  }>; };
42
+ /** Creates new Index */
39
43
  index_make(name: string, path?: string[], unique?: boolean, multiEntry?: boolean): IDBIndex;
44
+ /** Drops existen Index */
40
45
  index_drop(name: string): this;
41
46
  get transaction(): $mol_db_transaction<$mol_db_schema>;
42
47
  get db(): $mol_db_database<$mol_db_schema>;
48
+ /** Deletes all stored Documents */
43
49
  clear(): Promise<undefined>;
50
+ /** Counts Documents by primary key(s) */
44
51
  count(keys?: Schema['Key'] | IDBKeyRange): Promise<number>;
52
+ /** Stores single Document by primary key. */
45
53
  put(doc: Schema['Doc'], key?: Schema['Key']): Promise<IDBValidKey>;
54
+ /** Returns Document by primary key. */
46
55
  get(key: Schema['Key']): Promise<Schema["Doc"] | undefined>;
56
+ /** Selects Documents by primary keys. */
47
57
  select(key?: Schema['Key'] | IDBKeyRange | null, count?: number): Promise<Schema["Doc"][]>;
58
+ /** Deletes Documents by primary key(s). */
48
59
  drop(keys: Schema['Key'] | IDBKeyRange): Promise<undefined>;
49
60
  }
50
61
  }
@@ -62,6 +73,7 @@ declare namespace $ {
62
73
  }
63
74
 
64
75
  declare namespace $ {
76
+ /** IndexedDB Index wrapper. */
65
77
  class $mol_db_index<Schema extends $mol_db_index_schema> {
66
78
  readonly native: IDBIndex;
67
79
  constructor(native: IDBIndex);
@@ -72,8 +84,11 @@ declare namespace $ {
72
84
  get store(): $mol_db_store<$mol_db_store_schema>;
73
85
  get transaction(): $mol_db_transaction<$mol_db_schema>;
74
86
  get db(): $mol_db_database<$mol_db_schema>;
87
+ /** Counts Documents by key(s) */
75
88
  count(keys?: Schema['Key'] | IDBKeyRange): Promise<number>;
89
+ /** Returns Document by primary key. */
76
90
  get(key: Schema['Key']): Promise<Schema["Doc"] | undefined>;
91
+ /** Selects Documents by primary keys. */
77
92
  select(key?: Schema['Key'] | IDBKeyRange | null, count?: number): Promise<Schema["Doc"][]>;
78
93
  }
79
94
  }
@@ -86,6 +101,14 @@ declare namespace $ {
86
101
  }
87
102
 
88
103
  declare namespace $ {
104
+ /**
105
+ * Creates new or returns existen database with automatic schema migration.
106
+ * Schema version is based on migrations count.
107
+ * Migrations code mustn't be changed after deploy.
108
+ * Only adding migrations at the end is allowed.
109
+ * Only new migrations will be applyed to existen DB.
110
+ * Schema changes allowed only through migratios.
111
+ */
89
112
  function $mol_db<Schema extends $mol_db_schema>(this: $, name: string, ...migrations: ((transaction: $mol_db_transaction<$mol_db_schema>) => void)[]): Promise<$mol_db_database<Schema>>;
90
113
  }
91
114
 
@@ -94,15 +117,29 @@ declare namespace $ {
94
117
  }
95
118
 
96
119
  declare namespace $ {
120
+ /** IndexedDB instance wrapper. */
97
121
  class $mol_db_database<Schema extends $mol_db_schema> {
98
122
  readonly native: IDBDatabase;
99
123
  constructor(native: IDBDatabase);
124
+ /** Returns database name. */
100
125
  get name(): string;
126
+ /** Returns database schema version. */
101
127
  get version(): number;
128
+ /** Returns all stores names. */
102
129
  get stores(): (keyof Schema)[];
130
+ /** Create read-only transaction. */
103
131
  read<Names extends Exclude<keyof Schema, symbol | number>>(...names: Names[]): Pick<Schema, Names> extends infer T extends $mol_db_schema ? { [Name in keyof T]: $mol_db_store<T[Name]>; } : never;
132
+ /** Create read/write transaction. */
104
133
  change<Names extends Exclude<keyof Schema, symbol | number>>(...names: Names[]): $mol_db_transaction<Pick<Schema, Names>>;
134
+ /**
135
+ * Deletes database.
136
+ * DB can be deleted only after end of all transactions.
137
+ */
105
138
  kill(): Promise<IDBDatabase>;
139
+ /**
140
+ * Closes DB connection.
141
+ * Connection really be closed only after end of all transactions.
142
+ */
106
143
  destructor(): void;
107
144
  }
108
145
  }
@@ -111,13 +148,19 @@ interface IDBTransaction {
111
148
  commit(): void;
112
149
  }
113
150
  declare namespace $ {
151
+ /** IndexedDB Transaction wrapper. */
114
152
  class $mol_db_transaction<Schema extends $mol_db_schema> {
115
153
  readonly native: IDBTransaction;
116
154
  constructor(native: IDBTransaction);
155
+ /** Returns dictionary of all existen Stores. */
117
156
  get stores(): { [Name in keyof Schema]: $mol_db_store<Schema[Name]>; };
157
+ /** Creates new Store */
118
158
  store_make(name: string): IDBObjectStore;
159
+ /** Drops existen Store */
119
160
  store_drop(name: string): this;
161
+ /** Instant abort transaction. Any errors aborts transactions automatically. */
120
162
  abort(): void;
163
+ /** Instant commits transaction. Without errors commit proceed automatically later. */
121
164
  commit(): Promise<void>;
122
165
  get db(): $mol_db_database<$mol_db_schema>;
123
166
  }
package/web.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../mam.d.ts","../../dom/context/context.d.ts","../../dom/context/context.web.d.ts","../response/response.d.ts","../store/store.d.ts","../store/store_schema.d.ts","../../dom/dom.d.ts","../index/index.d.ts","../index/index_schema.d.ts","../db.d.ts","../db_schema.d.ts","../database/database.d.ts","../transaction/transaction.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;ACHA;AACA;AACA;ACFA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACPA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AChBA;AACA;AACA;AACA;AACA;AACA;AACA;ACNA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null]}
1
+ {"version":3,"sources":["../../../mam.d.ts","../../dom/context/context.d.ts","../../dom/context/context.web.d.ts","../response/response.d.ts","../store/store.d.ts","../store/store_schema.d.ts","../../dom/dom.d.ts","../index/index.d.ts","../index/index_schema.d.ts","../db.d.ts","../db_schema.d.ts","../database/database.d.ts","../transaction/transaction.d.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACfA;AACA;AACA;AACA;ACHA;AACA;AACA;ACFA;AACA;AACA;AACA;AACA;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACPA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACXA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AC3BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null]}
package/web.js CHANGED
@@ -45,6 +45,7 @@ var $;
45
45
  "use strict";
46
46
  var $;
47
47
  (function ($) {
48
+ /** Converts IDBResult to Promise */
48
49
  function $mol_db_response(request) {
49
50
  return new Promise((done, fail) => {
50
51
  request.onerror = () => fail(new Error(request.error.message));
@@ -58,6 +59,7 @@ var $;
58
59
  "use strict";
59
60
  var $;
60
61
  (function ($) {
62
+ /** IndexedDB ObjectStore wrapper. */
61
63
  class $mol_db_store {
62
64
  native;
63
65
  constructor(native) {
@@ -72,6 +74,7 @@ var $;
72
74
  get incremental() {
73
75
  return this.native.autoIncrement;
74
76
  }
77
+ /** Returns dictionary of all existen Indexes. */
75
78
  get indexes() {
76
79
  return new Proxy({}, {
77
80
  ownKeys: () => [...this.native.indexNames],
@@ -79,9 +82,11 @@ var $;
79
82
  get: (_, name) => new $mol_db_index(this.native.index(name))
80
83
  });
81
84
  }
85
+ /** Creates new Index */
82
86
  index_make(name, path = [], unique = false, multiEntry = false) {
83
87
  return this.native.createIndex(name, path, { multiEntry, unique });
84
88
  }
89
+ /** Drops existen Index */
85
90
  index_drop(name) {
86
91
  this.native.deleteIndex(name);
87
92
  return this;
@@ -92,21 +97,27 @@ var $;
92
97
  get db() {
93
98
  return this.transaction.db;
94
99
  }
100
+ /** Deletes all stored Documents */
95
101
  clear() {
96
102
  return $mol_db_response(this.native.clear());
97
103
  }
104
+ /** Counts Documents by primary key(s) */
98
105
  count(keys) {
99
106
  return $mol_db_response(this.native.count(keys));
100
107
  }
108
+ /** Stores single Document by primary key. */
101
109
  put(doc, key) {
102
110
  return $mol_db_response(this.native.put(doc, key));
103
111
  }
112
+ /** Returns Document by primary key. */
104
113
  get(key) {
105
114
  return $mol_db_response(this.native.get(key));
106
115
  }
116
+ /** Selects Documents by primary keys. */
107
117
  select(key, count) {
108
118
  return $mol_db_response(this.native.getAll(key, count));
109
119
  }
120
+ /** Deletes Documents by primary key(s). */
110
121
  drop(keys) {
111
122
  return $mol_db_response(this.native.delete(keys));
112
123
  }
@@ -128,6 +139,7 @@ var $;
128
139
  "use strict";
129
140
  var $;
130
141
  (function ($) {
142
+ /** IndexedDB Index wrapper. */
131
143
  class $mol_db_index {
132
144
  native;
133
145
  constructor(native) {
@@ -154,12 +166,15 @@ var $;
154
166
  get db() {
155
167
  return this.store.db;
156
168
  }
169
+ /** Counts Documents by key(s) */
157
170
  count(keys) {
158
171
  return $mol_db_response(this.native.count(keys));
159
172
  }
173
+ /** Returns Document by primary key. */
160
174
  get(key) {
161
175
  return $mol_db_response(this.native.get(key));
162
176
  }
177
+ /** Selects Documents by primary keys. */
163
178
  select(key, count) {
164
179
  return $mol_db_response(this.native.getAll(key, count));
165
180
  }
@@ -174,6 +189,14 @@ var $;
174
189
  "use strict";
175
190
  var $;
176
191
  (function ($) {
192
+ /**
193
+ * Creates new or returns existen database with automatic schema migration.
194
+ * Schema version is based on migrations count.
195
+ * Migrations code mustn't be changed after deploy.
196
+ * Only adding migrations at the end is allowed.
197
+ * Only new migrations will be applyed to existen DB.
198
+ * Schema changes allowed only through migratios.
199
+ */
177
200
  async function $mol_db(name, ...migrations) {
178
201
  const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
179
202
  request.onupgradeneeded = event => {
@@ -195,32 +218,46 @@ var $;
195
218
  "use strict";
196
219
  var $;
197
220
  (function ($) {
221
+ /** IndexedDB instance wrapper. */
198
222
  class $mol_db_database {
199
223
  native;
200
224
  constructor(native) {
201
225
  this.native = native;
202
226
  }
227
+ /** Returns database name. */
203
228
  get name() {
204
229
  return this.native.name;
205
230
  }
231
+ /** Returns database schema version. */
206
232
  get version() {
207
233
  return this.native.version;
208
234
  }
235
+ /** Returns all stores names. */
209
236
  get stores() {
210
237
  return [...this.native.objectStoreNames];
211
238
  }
239
+ /** Create read-only transaction. */
212
240
  read(...names) {
213
241
  return new $mol_db_transaction(this.native.transaction(names, 'readonly', { durability: 'relaxed' })).stores;
214
242
  }
243
+ /** Create read/write transaction. */
215
244
  change(...names) {
216
245
  return new $mol_db_transaction(this.native.transaction(names, 'readwrite', { durability: 'relaxed' }));
217
246
  }
247
+ /**
248
+ * Deletes database.
249
+ * DB can be deleted only after end of all transactions.
250
+ */
218
251
  kill() {
219
252
  this.native.close();
220
253
  const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
221
254
  request.onblocked = console.warn;
222
255
  return $mol_db_response(request);
223
256
  }
257
+ /**
258
+ * Closes DB connection.
259
+ * Connection really be closed only after end of all transactions.
260
+ */
224
261
  destructor() {
225
262
  this.native.close();
226
263
  }
@@ -232,11 +269,13 @@ var $;
232
269
  "use strict";
233
270
  var $;
234
271
  (function ($) {
272
+ /** IndexedDB Transaction wrapper. */
235
273
  class $mol_db_transaction {
236
274
  native;
237
275
  constructor(native) {
238
276
  this.native = native;
239
277
  }
278
+ /** Returns dictionary of all existen Stores. */
240
279
  get stores() {
241
280
  return new Proxy({}, {
242
281
  ownKeys: () => [...this.native.objectStoreNames],
@@ -246,18 +285,22 @@ var $;
246
285
  : undefined,
247
286
  });
248
287
  }
288
+ /** Creates new Store */
249
289
  store_make(name) {
250
290
  return this.native.db.createObjectStore(name, { autoIncrement: true });
251
291
  }
292
+ /** Drops existen Store */
252
293
  store_drop(name) {
253
294
  this.native.db.deleteObjectStore(name);
254
295
  return this;
255
296
  }
297
+ /** Instant abort transaction. Any errors aborts transactions automatically. */
256
298
  abort() {
257
299
  if (this.native.error)
258
300
  return;
259
301
  this.native.abort();
260
302
  }
303
+ /** Instant commits transaction. Without errors commit proceed automatically later. */
261
304
  commit() {
262
305
  this.native.commit?.();
263
306
  return new Promise((done, fail) => {
package/web.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["-","../../../mam.ts","../../../mol/dom/context/context.ts","../../../mol/dom/context/context.web.ts","../../../mol/db/response/response.ts","../../../mol/db/store/store.ts","../../../mol/dom/dom.ts","../../../mol/db/index/index.ts","../../../mol/db/db.ts","../../../mol/db/database/database.ts","../../../mol/db/transaction/transaction.ts"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAQV;AARD,WAAU,CAAC;AAQX,CAAC,EARS,CAAC,KAAD,CAAC,QAQV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADflB;AACA;AACA;;;;;;;;;;;;;;;AEFA,IAAU,CAAC,CAIV;AAJD,WAAU,CAAC;AAIX,CAAC,EAJS,CAAC,KAAD,CAAC,QAIV;;;;ACJD,IAAU,CAAC,CAIV;AAJD,WAAU,CAAC;IAEV,CAAC,CAAC,gBAAgB,GAAG,IAAW,CAAA;AAEjC,CAAC,EAJS,CAAC,KAAD,CAAC,QAIV;;;;ACJD,IAAU,CAAC,CAcV;AAdD,WAAU,CAAC;IAGV,SAAgB,gBAAgB,CAC/B,OAA6B;QAG7B,OAAO,IAAI,OAAO,CAAY,CAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAC7C,OAAO,CAAC,OAAO,GAAG,GAAE,EAAE,CAAC,IAAI,CAAE,IAAI,KAAK,CAAE,OAAO,CAAC,KAAM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_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {\n\t\tstatic $: $\n\t}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\texport var $mol_dom_context : typeof globalThis\n\t\n}\n","namespace $ {\n\t\n\t$.$mol_dom_context = self as any\n\t\n}\n","namespace $ {\n\t\n\t/** Converts IDBResult to Promise */\n\texport function $mol_db_response< Result >(\n\t\trequest: IDBRequest< Result >\n\t) {\n\t\t\n\t\treturn new Promise< Result >( ( done, fail )=> {\n\t\t\trequest.onerror = ()=> fail( new Error( request.error!.message ) )\n\t\t\trequest.onsuccess = ()=> done( request.result as Result )\n\t\t} )\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/** IndexedDB ObjectStore wrapper. */\n\texport class $mol_db_store< Schema extends $mol_db_store_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBObjectStore,\n\t\t) {}\n\t\t\n\t\tget name() {\n\t\t\treturn this.native.name\n\t\t}\n\t\t\n\t\tget path() {\n\t\t\treturn this.native.keyPath\n\t\t}\n\t\t\n\t\tget incremental() {\n\t\t\treturn this.native.autoIncrement\n\t\t}\n\t\t\n\t\t/** Returns dictionary of all existen Indexes. */\n\t\tget indexes() {\n\t\t\treturn new Proxy(\n\t\t\t\t{} as {\n\t\t\t\t\t[ Name in keyof Schema['Indexes'] ]: $mol_db_index<{\n\t\t\t\t\t\tKey: Schema['Indexes'][ Name ],\n\t\t\t\t\t\tDoc: Schema['Doc'],\n\t\t\t\t\t}>\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\townKeys: ()=> [ ... this.native.indexNames ],\n\t\t\t\t\thas: ( _, name: string )=> this.native.indexNames.contains( name ),\n\t\t\t\t\tget: ( _, name: string )=> new $mol_db_index( this.native.index( name ) )\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** Creates new Index */\n\t\tindex_make(\n\t\t\tname: string,\n\t\t\tpath = [] as string[],\n\t\t\tunique = false,\n\t\t\tmultiEntry = false,\n\t\t) {\n\t\t\treturn this.native.createIndex( name, path, { multiEntry, unique } )\n\t\t}\n\t\t\n\t\t/** Drops existen Index */\n\t\tindex_drop( name: string ) {\n\t\t\tthis.native.deleteIndex( name )\n\t\t\treturn this\n\t\t}\n\t\t\n\t\tget transaction() {\n\t\t\treturn new $mol_db_transaction(\n\t\t\t\tthis.native.transaction\n\t\t\t)\n\t\t}\n\t\t\n\t\tget db() {\n\t\t\treturn this.transaction.db\n\t\t}\n\t\t\n\t\t/** Deletes all stored Documents */\n\t\tclear() {\n\t\t\treturn $mol_db_response( this.native.clear() )\n\t\t}\n\t\t\n\t\t/** Counts Documents by primary key(s) */\n\t\tcount( keys?: Schema['Key'] | IDBKeyRange ) {\n\t\t\treturn $mol_db_response( this.native.count( keys ) )\n\t\t}\n\t\t\n\t\t/** Stores single Document by primary key. */\n\t\tput( doc: Schema['Doc'], key?: Schema['Key'] ) {\n\t\t\treturn $mol_db_response( this.native.put( doc, key ) )\n\t\t}\n\t\t\n\t\t/** Returns Document by primary key. */\n\t\tget( key: Schema['Key'] ) {\n\t\t\treturn $mol_db_response( this.native.get( key ) as IDBRequest< Schema['Doc'] | undefined > )\n\t\t}\n\t\t\n\t\t/** Selects Documents by primary keys. */\n\t\tselect( key?: Schema['Key'] | IDBKeyRange | null, count?: number ) {\n\t\t\treturn $mol_db_response( this.native.getAll( key, count ) as IDBRequest< Schema['Doc'][] > )\n\t\t}\n\t\t\n\t\t/** Deletes Documents by primary key(s). */\n\t\tdrop( keys: Schema['Key'] | IDBKeyRange ) {\n\t\t\treturn $mol_db_response( this.native.delete( keys ) )\n\t\t}\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\texport var $mol_dom = $mol_dom_context\n\t\n}\n","namespace $ {\n\t\n\t/** IndexedDB Index wrapper. */\n\texport class $mol_db_index< Schema extends $mol_db_index_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBIndex,\n\t\t) { }\n\t\t\n\t\tget name() {\n\t\t\treturn this.native.name\n\t\t}\n\t\t\n\t\tget paths() {\n\t\t\treturn this.native.keyPath as string[]\n\t\t}\n\t\t\n\t\tget unique() {\n\t\t\treturn this.native.unique\n\t\t}\n\t\t\n\t\tget multiple() {\n\t\t\treturn this.native.multiEntry\n\t\t}\n\t\t\n\t\tget store() {\n\t\t\treturn new $mol_db_store(\n\t\t\t\tthis.native.objectStore\n\t\t\t)\n\t\t}\n\t\t\n\t\tget transaction() {\n\t\t\treturn this.store.transaction\n\t\t}\n\t\t\n\t\tget db() {\n\t\t\treturn this.store.db\n\t\t}\n\t\t\n\t\t/** Counts Documents by key(s) */\n\t\tcount( keys?: Schema['Key'] | IDBKeyRange ) {\n\t\t\treturn $mol_db_response( this.native.count( keys ) )\n\t\t}\n\t\t\n\t\t/** Returns Document by primary key. */\n\t\tget( key: Schema['Key'] ) {\n\t\t\treturn $mol_db_response( this.native.get( key ) as IDBRequest< Schema['Doc'] | undefined > )\n\t\t}\n\t\t\n\t\t/** Selects Documents by primary keys. */\n\t\tselect( key?: Schema['Key'] | IDBKeyRange | null, count?: number ) {\n\t\t\treturn $mol_db_response( this.native.getAll( key, count ) as IDBRequest< Schema['Doc'][] > )\n\t\t}\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/**\n\t * Creates new or returns existen database with automatic schema migration.\n\t * Schema version is based on migrations count.\n\t * Migrations code mustn't be changed after deploy.\n\t * Only adding migrations at the end is allowed.\n\t * Only new migrations will be applyed to existen DB.\n\t * Schema changes allowed only through migratios. \n\t */\n\texport async function $mol_db< Schema extends $mol_db_schema >(\n\t\tthis: $,\n\t\tname: string,\n\t\t... migrations: ( ( transaction: $mol_db_transaction< $mol_db_schema > )=> void )[]\n\t) {\n\t\t\n\t\tconst request = this.$mol_dom_context.indexedDB.open( name, migrations.length ? migrations.length + 1 : undefined )\n\t\t\n\t\trequest.onupgradeneeded = event => {\n\t\t\t\n\t\t\tmigrations.splice( 0, event.oldVersion - 1 )\n\t\t\tconst transaction = new $mol_db_transaction( request.transaction! )\n\t\t\t\n\t\t\tfor( const migrate of migrations ) migrate( transaction )\n\t\t\t\n\t\t}\n\t\t\n\t\tconst db = await $mol_db_response( request )\n\t\t\n\t\treturn new $mol_db_database< Schema >( db )\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/** IndexedDB instance wrapper. */\n\texport class $mol_db_database< Schema extends $mol_db_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBDatabase,\n\t\t) { }\n\t\t\n\t\t/** Returns database name. */\n\t\tget name() {\n\t\t\treturn this.native.name\n\t\t}\n\t\t\n\t\t/** Returns database schema version. */\n\t\tget version() {\n\t\t\treturn this.native.version\n\t\t}\n\t\t\n\t\t/** Returns all stores names. */\n\t\tget stores() {\n\t\t\treturn [ ... this.native.objectStoreNames ] as ( keyof Schema )[]\n\t\t}\n\t\t\n\t\t/** Create read-only transaction. */\n\t\tread< Names extends Exclude< keyof Schema, symbol | number > >( ... names: Names[] ) {\n\t\t\treturn new $mol_db_transaction< Pick< Schema, Names > >(\n\t\t\t\tthis.native.transaction( names, 'readonly', { durability: 'relaxed' } )\n\t\t\t).stores\n\t\t}\n\t\t\n\t\t/** Create read/write transaction. */\n\t\tchange< Names extends Exclude< keyof Schema, symbol | number > >( ... names: Names[] ) {\n\t\t\treturn new $mol_db_transaction< Pick< Schema, Names > >(\n\t\t\t\tthis.native.transaction( names, 'readwrite', { durability: 'relaxed' } )\n\t\t\t)\n\t\t}\n\t\t\n\t\t/**\n\t\t * Deletes database.\n\t\t * DB can be deleted only after end of all transactions.\n\t\t */\n\t\tkill() {\n\t\t\t\n\t\t\tthis.native.close()\n\t\t\t\n\t\t\tconst request = $mol_dom_context.indexedDB.deleteDatabase( this.name )\n\t\t\t\n\t\t\trequest.onblocked = console.warn\n\t\t\treturn $mol_db_response( request )\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Closes DB connection.\n\t\t * Connection really be closed only after end of all transactions.\n\t\t */\n\t\tdestructor() {\n\t\t\tthis.native.close()\n\t\t}\n\t\t\n\t}\n\t\n}\n","interface IDBTransaction {\n\tcommit(): void\n}\n\nnamespace $ {\n\t\n\t/** IndexedDB Transaction wrapper. */\n\texport class $mol_db_transaction< Schema extends $mol_db_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBTransaction,\n\t\t) {}\n\t\t\n\t\t/** Returns dictionary of all existen Stores. */\n\t\tget stores() {\n\t\t\treturn new Proxy(\n\t\t\t\t{} as {\n\t\t\t\t\t[ Name in keyof Schema ]: $mol_db_store< Schema[ Name ] >\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\townKeys: ()=> [ ... this.native.objectStoreNames ],\n\t\t\t\t\thas: ( _, name: string )=> this.native.objectStoreNames.contains( name ),\n\t\t\t\t\tget: ( _, name: string, proxy )=> ( name in proxy )\n\t\t\t\t\t\t? new $mol_db_store( this.native.objectStore( name ) )\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** Creates new Store */\n\t\tstore_make( name: string ) {\n\t\t\treturn this.native.db.createObjectStore( name, { autoIncrement: true } )\n\t\t}\n\t\t\n\t\t/** Drops existen Store */\n\t\tstore_drop( name: string ) {\n\t\t\tthis.native.db.deleteObjectStore( name )\n\t\t\treturn this\n\t\t}\n\t\t\n\t\t/** Instant abort transaction. Any errors aborts transactions automatically. */\n\t\tabort() {\n\t\t\tif( this.native.error ) return\n\t\t\tthis.native.abort()\n\t\t}\n\t\t\n\t\t/** Instant commits transaction. Without errors commit proceed automatically later. */\n\t\tcommit() {\n\t\t\t\n\t\t\tthis.native.commit?.()\n\t\t\t\n\t\t\treturn new Promise< void >( ( done, fail )=> {\n\t\t\t\tthis.native.onerror = ()=> fail( new Error( this.native.error!.message ) )\n\t\t\t\tthis.native.oncomplete = ()=> done()\n\t\t\t} )\n\t\t\t\n\t\t}\n\t\t\n\t\tget db() {\n\t\t\treturn new $mol_db_database(\n\t\t\t\tthis.native.db\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n}\n"]}
1
+ {"version":3,"sources":["-","../../../mam.ts","../../../mol/dom/context/context.ts","../../../mol/dom/context/context.web.ts","../../../mol/db/response/response.ts","../../../mol/db/store/store.ts","../../../mol/dom/dom.ts","../../../mol/db/index/index.ts","../../../mol/db/db.ts","../../../mol/db/database/database.ts","../../../mol/db/transaction/transaction.ts"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAQV;AARD,WAAU,CAAC;AAQX,CAAC,EARS,CAAC,KAAD,CAAC,QAQV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADflB;AACA;AACA;;;;;;;;;;;;;;;AEFA,IAAU,CAAC,CAIV;AAJD,WAAU,CAAC;AAIX,CAAC,EAJS,CAAC,KAAD,CAAC,QAIV;;;;ACJD,IAAU,CAAC,CAIV;AAJD,WAAU,CAAC;IAEV,CAAC,CAAC,gBAAgB,GAAG,IAAW,CAAA;AAEjC,CAAC,EAJS,CAAC,KAAD,CAAC,QAIV;;;;ACJD,IAAU,CAAC,CAcV;AAdD,WAAU,CAAC;IAEV,oCAAoC;IACpC,SAAgB,gBAAgB,CAC/B,OAA6B;QAG7B,OAAO,IAAI,OAAO,CAAY,CAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAC7C,OAAO,CAAC,OAAO,GAAG,GAAE,EAAE,CAAC,IAAI,CAAE,IAAI,KAAK,CAAE,OAAO,CAAC,KAAM,CAAC,OAAO,CAAE,CAAE,CAAA;YAClE,OAAO,CAAC,SAAS,GAAG,GAAE,EAAE,CAAC,IAAI,CAAE,OAAO,CAAC,MAAgB,CAAE,CAAA;QAC1D,CAAC,CAAE,CAAA;IAEJ,CAAC;IATe,kBAAgB,mB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,IAAI,EAAE;YACL,OAAO,IAAI,gBAAgB,CAC1B,IAAI,CAAC,MAAM,CAAC,EAAE,CACd,CAAA;QACF,CAAC;KAED;IAzDY,qBAAmB,sBAyD/B,CAAA;AAEF,CAAC,EA9DS,CAAC,KAAD,CAAC,QA8DV;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {\n\t\tstatic $: $\n\t}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n","namespace $ {\n\t\n\texport var $mol_dom_context : typeof globalThis\n\t\n}\n","namespace $ {\n\t\n\t$.$mol_dom_context = self as any\n\t\n}\n","namespace $ {\n\t\n\t/** Converts IDBResult to Promise */\n\texport function $mol_db_response< Result >(\n\t\trequest: IDBRequest< Result >\n\t) {\n\t\t\n\t\treturn new Promise< Result >( ( done, fail )=> {\n\t\t\trequest.onerror = ()=> fail( new Error( request.error!.message ) )\n\t\t\trequest.onsuccess = ()=> done( request.result as Result )\n\t\t} )\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/** IndexedDB ObjectStore wrapper. */\n\texport class $mol_db_store< Schema extends $mol_db_store_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBObjectStore,\n\t\t) {}\n\t\t\n\t\tget name() {\n\t\t\treturn this.native.name\n\t\t}\n\t\t\n\t\tget path() {\n\t\t\treturn this.native.keyPath\n\t\t}\n\t\t\n\t\tget incremental() {\n\t\t\treturn this.native.autoIncrement\n\t\t}\n\t\t\n\t\t/** Returns dictionary of all existen Indexes. */\n\t\tget indexes() {\n\t\t\treturn new Proxy(\n\t\t\t\t{} as {\n\t\t\t\t\t[ Name in keyof Schema['Indexes'] ]: $mol_db_index<{\n\t\t\t\t\t\tKey: Schema['Indexes'][ Name ],\n\t\t\t\t\t\tDoc: Schema['Doc'],\n\t\t\t\t\t}>\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\townKeys: ()=> [ ... this.native.indexNames ],\n\t\t\t\t\thas: ( _, name: string )=> this.native.indexNames.contains( name ),\n\t\t\t\t\tget: ( _, name: string )=> new $mol_db_index( this.native.index( name ) )\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** Creates new Index */\n\t\tindex_make(\n\t\t\tname: string,\n\t\t\tpath = [] as string[],\n\t\t\tunique = false,\n\t\t\tmultiEntry = false,\n\t\t) {\n\t\t\treturn this.native.createIndex( name, path, { multiEntry, unique } )\n\t\t}\n\t\t\n\t\t/** Drops existen Index */\n\t\tindex_drop( name: string ) {\n\t\t\tthis.native.deleteIndex( name )\n\t\t\treturn this\n\t\t}\n\t\t\n\t\tget transaction() {\n\t\t\treturn new $mol_db_transaction(\n\t\t\t\tthis.native.transaction\n\t\t\t)\n\t\t}\n\t\t\n\t\tget db() {\n\t\t\treturn this.transaction.db\n\t\t}\n\t\t\n\t\t/** Deletes all stored Documents */\n\t\tclear() {\n\t\t\treturn $mol_db_response( this.native.clear() )\n\t\t}\n\t\t\n\t\t/** Counts Documents by primary key(s) */\n\t\tcount( keys?: Schema['Key'] | IDBKeyRange ) {\n\t\t\treturn $mol_db_response( this.native.count( keys ) )\n\t\t}\n\t\t\n\t\t/** Stores single Document by primary key. */\n\t\tput( doc: Schema['Doc'], key?: Schema['Key'] ) {\n\t\t\treturn $mol_db_response( this.native.put( doc, key ) )\n\t\t}\n\t\t\n\t\t/** Returns Document by primary key. */\n\t\tget( key: Schema['Key'] ) {\n\t\t\treturn $mol_db_response( this.native.get( key ) as IDBRequest< Schema['Doc'] | undefined > )\n\t\t}\n\t\t\n\t\t/** Selects Documents by primary keys. */\n\t\tselect( key?: Schema['Key'] | IDBKeyRange | null, count?: number ) {\n\t\t\treturn $mol_db_response( this.native.getAll( key, count ) as IDBRequest< Schema['Doc'][] > )\n\t\t}\n\t\t\n\t\t/** Deletes Documents by primary key(s). */\n\t\tdrop( keys: Schema['Key'] | IDBKeyRange ) {\n\t\t\treturn $mol_db_response( this.native.delete( keys ) )\n\t\t}\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\texport var $mol_dom = $mol_dom_context\n\t\n}\n","namespace $ {\n\t\n\t/** IndexedDB Index wrapper. */\n\texport class $mol_db_index< Schema extends $mol_db_index_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBIndex,\n\t\t) { }\n\t\t\n\t\tget name() {\n\t\t\treturn this.native.name\n\t\t}\n\t\t\n\t\tget paths() {\n\t\t\treturn this.native.keyPath as string[]\n\t\t}\n\t\t\n\t\tget unique() {\n\t\t\treturn this.native.unique\n\t\t}\n\t\t\n\t\tget multiple() {\n\t\t\treturn this.native.multiEntry\n\t\t}\n\t\t\n\t\tget store() {\n\t\t\treturn new $mol_db_store(\n\t\t\t\tthis.native.objectStore\n\t\t\t)\n\t\t}\n\t\t\n\t\tget transaction() {\n\t\t\treturn this.store.transaction\n\t\t}\n\t\t\n\t\tget db() {\n\t\t\treturn this.store.db\n\t\t}\n\t\t\n\t\t/** Counts Documents by key(s) */\n\t\tcount( keys?: Schema['Key'] | IDBKeyRange ) {\n\t\t\treturn $mol_db_response( this.native.count( keys ) )\n\t\t}\n\t\t\n\t\t/** Returns Document by primary key. */\n\t\tget( key: Schema['Key'] ) {\n\t\t\treturn $mol_db_response( this.native.get( key ) as IDBRequest< Schema['Doc'] | undefined > )\n\t\t}\n\t\t\n\t\t/** Selects Documents by primary keys. */\n\t\tselect( key?: Schema['Key'] | IDBKeyRange | null, count?: number ) {\n\t\t\treturn $mol_db_response( this.native.getAll( key, count ) as IDBRequest< Schema['Doc'][] > )\n\t\t}\n\t\t\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/**\n\t * Creates new or returns existen database with automatic schema migration.\n\t * Schema version is based on migrations count.\n\t * Migrations code mustn't be changed after deploy.\n\t * Only adding migrations at the end is allowed.\n\t * Only new migrations will be applyed to existen DB.\n\t * Schema changes allowed only through migratios. \n\t */\n\texport async function $mol_db< Schema extends $mol_db_schema >(\n\t\tthis: $,\n\t\tname: string,\n\t\t... migrations: ( ( transaction: $mol_db_transaction< $mol_db_schema > )=> void )[]\n\t) {\n\t\t\n\t\tconst request = this.$mol_dom_context.indexedDB.open( name, migrations.length ? migrations.length + 1 : undefined )\n\t\t\n\t\trequest.onupgradeneeded = event => {\n\t\t\t\n\t\t\tmigrations.splice( 0, event.oldVersion - 1 )\n\t\t\tconst transaction = new $mol_db_transaction( request.transaction! )\n\t\t\t\n\t\t\tfor( const migrate of migrations ) migrate( transaction )\n\t\t\t\n\t\t}\n\t\t\n\t\tconst db = await $mol_db_response( request )\n\t\t\n\t\treturn new $mol_db_database< Schema >( db )\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/** IndexedDB instance wrapper. */\n\texport class $mol_db_database< Schema extends $mol_db_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBDatabase,\n\t\t) { }\n\t\t\n\t\t/** Returns database name. */\n\t\tget name() {\n\t\t\treturn this.native.name\n\t\t}\n\t\t\n\t\t/** Returns database schema version. */\n\t\tget version() {\n\t\t\treturn this.native.version\n\t\t}\n\t\t\n\t\t/** Returns all stores names. */\n\t\tget stores() {\n\t\t\treturn [ ... this.native.objectStoreNames ] as ( keyof Schema )[]\n\t\t}\n\t\t\n\t\t/** Create read-only transaction. */\n\t\tread< Names extends Exclude< keyof Schema, symbol | number > >( ... names: Names[] ) {\n\t\t\treturn new $mol_db_transaction< Pick< Schema, Names > >(\n\t\t\t\tthis.native.transaction( names, 'readonly', { durability: 'relaxed' } )\n\t\t\t).stores\n\t\t}\n\t\t\n\t\t/** Create read/write transaction. */\n\t\tchange< Names extends Exclude< keyof Schema, symbol | number > >( ... names: Names[] ) {\n\t\t\treturn new $mol_db_transaction< Pick< Schema, Names > >(\n\t\t\t\tthis.native.transaction( names, 'readwrite', { durability: 'relaxed' } )\n\t\t\t)\n\t\t}\n\t\t\n\t\t/**\n\t\t * Deletes database.\n\t\t * DB can be deleted only after end of all transactions.\n\t\t */\n\t\tkill() {\n\t\t\t\n\t\t\tthis.native.close()\n\t\t\t\n\t\t\tconst request = $mol_dom_context.indexedDB.deleteDatabase( this.name )\n\t\t\t\n\t\t\trequest.onblocked = console.warn\n\t\t\treturn $mol_db_response( request )\n\t\t\t\n\t\t}\n\t\t\n\t\t/**\n\t\t * Closes DB connection.\n\t\t * Connection really be closed only after end of all transactions.\n\t\t */\n\t\tdestructor() {\n\t\t\tthis.native.close()\n\t\t}\n\t\t\n\t}\n\t\n}\n","interface IDBTransaction {\n\tcommit(): void\n}\n\nnamespace $ {\n\t\n\t/** IndexedDB Transaction wrapper. */\n\texport class $mol_db_transaction< Schema extends $mol_db_schema > {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: IDBTransaction,\n\t\t) {}\n\t\t\n\t\t/** Returns dictionary of all existen Stores. */\n\t\tget stores() {\n\t\t\treturn new Proxy(\n\t\t\t\t{} as {\n\t\t\t\t\t[ Name in keyof Schema ]: $mol_db_store< Schema[ Name ] >\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\townKeys: ()=> [ ... this.native.objectStoreNames ],\n\t\t\t\t\thas: ( _, name: string )=> this.native.objectStoreNames.contains( name ),\n\t\t\t\t\tget: ( _, name: string, proxy )=> ( name in proxy )\n\t\t\t\t\t\t? new $mol_db_store( this.native.objectStore( name ) )\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** Creates new Store */\n\t\tstore_make( name: string ) {\n\t\t\treturn this.native.db.createObjectStore( name, { autoIncrement: true } )\n\t\t}\n\t\t\n\t\t/** Drops existen Store */\n\t\tstore_drop( name: string ) {\n\t\t\tthis.native.db.deleteObjectStore( name )\n\t\t\treturn this\n\t\t}\n\t\t\n\t\t/** Instant abort transaction. Any errors aborts transactions automatically. */\n\t\tabort() {\n\t\t\tif( this.native.error ) return\n\t\t\tthis.native.abort()\n\t\t}\n\t\t\n\t\t/** Instant commits transaction. Without errors commit proceed automatically later. */\n\t\tcommit() {\n\t\t\t\n\t\t\tthis.native.commit?.()\n\t\t\t\n\t\t\treturn new Promise< void >( ( done, fail )=> {\n\t\t\t\tthis.native.onerror = ()=> fail( new Error( this.native.error!.message ) )\n\t\t\t\tthis.native.oncomplete = ()=> done()\n\t\t\t} )\n\t\t\t\n\t\t}\n\t\t\n\t\tget db() {\n\t\t\treturn new $mol_db_database(\n\t\t\t\tthis.native.db\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n}\n"]}
package/web.mjs CHANGED
@@ -45,6 +45,7 @@ var $;
45
45
  "use strict";
46
46
  var $;
47
47
  (function ($) {
48
+ /** Converts IDBResult to Promise */
48
49
  function $mol_db_response(request) {
49
50
  return new Promise((done, fail) => {
50
51
  request.onerror = () => fail(new Error(request.error.message));
@@ -58,6 +59,7 @@ var $;
58
59
  "use strict";
59
60
  var $;
60
61
  (function ($) {
62
+ /** IndexedDB ObjectStore wrapper. */
61
63
  class $mol_db_store {
62
64
  native;
63
65
  constructor(native) {
@@ -72,6 +74,7 @@ var $;
72
74
  get incremental() {
73
75
  return this.native.autoIncrement;
74
76
  }
77
+ /** Returns dictionary of all existen Indexes. */
75
78
  get indexes() {
76
79
  return new Proxy({}, {
77
80
  ownKeys: () => [...this.native.indexNames],
@@ -79,9 +82,11 @@ var $;
79
82
  get: (_, name) => new $mol_db_index(this.native.index(name))
80
83
  });
81
84
  }
85
+ /** Creates new Index */
82
86
  index_make(name, path = [], unique = false, multiEntry = false) {
83
87
  return this.native.createIndex(name, path, { multiEntry, unique });
84
88
  }
89
+ /** Drops existen Index */
85
90
  index_drop(name) {
86
91
  this.native.deleteIndex(name);
87
92
  return this;
@@ -92,21 +97,27 @@ var $;
92
97
  get db() {
93
98
  return this.transaction.db;
94
99
  }
100
+ /** Deletes all stored Documents */
95
101
  clear() {
96
102
  return $mol_db_response(this.native.clear());
97
103
  }
104
+ /** Counts Documents by primary key(s) */
98
105
  count(keys) {
99
106
  return $mol_db_response(this.native.count(keys));
100
107
  }
108
+ /** Stores single Document by primary key. */
101
109
  put(doc, key) {
102
110
  return $mol_db_response(this.native.put(doc, key));
103
111
  }
112
+ /** Returns Document by primary key. */
104
113
  get(key) {
105
114
  return $mol_db_response(this.native.get(key));
106
115
  }
116
+ /** Selects Documents by primary keys. */
107
117
  select(key, count) {
108
118
  return $mol_db_response(this.native.getAll(key, count));
109
119
  }
120
+ /** Deletes Documents by primary key(s). */
110
121
  drop(keys) {
111
122
  return $mol_db_response(this.native.delete(keys));
112
123
  }
@@ -128,6 +139,7 @@ var $;
128
139
  "use strict";
129
140
  var $;
130
141
  (function ($) {
142
+ /** IndexedDB Index wrapper. */
131
143
  class $mol_db_index {
132
144
  native;
133
145
  constructor(native) {
@@ -154,12 +166,15 @@ var $;
154
166
  get db() {
155
167
  return this.store.db;
156
168
  }
169
+ /** Counts Documents by key(s) */
157
170
  count(keys) {
158
171
  return $mol_db_response(this.native.count(keys));
159
172
  }
173
+ /** Returns Document by primary key. */
160
174
  get(key) {
161
175
  return $mol_db_response(this.native.get(key));
162
176
  }
177
+ /** Selects Documents by primary keys. */
163
178
  select(key, count) {
164
179
  return $mol_db_response(this.native.getAll(key, count));
165
180
  }
@@ -174,6 +189,14 @@ var $;
174
189
  "use strict";
175
190
  var $;
176
191
  (function ($) {
192
+ /**
193
+ * Creates new or returns existen database with automatic schema migration.
194
+ * Schema version is based on migrations count.
195
+ * Migrations code mustn't be changed after deploy.
196
+ * Only adding migrations at the end is allowed.
197
+ * Only new migrations will be applyed to existen DB.
198
+ * Schema changes allowed only through migratios.
199
+ */
177
200
  async function $mol_db(name, ...migrations) {
178
201
  const request = this.$mol_dom_context.indexedDB.open(name, migrations.length ? migrations.length + 1 : undefined);
179
202
  request.onupgradeneeded = event => {
@@ -195,32 +218,46 @@ var $;
195
218
  "use strict";
196
219
  var $;
197
220
  (function ($) {
221
+ /** IndexedDB instance wrapper. */
198
222
  class $mol_db_database {
199
223
  native;
200
224
  constructor(native) {
201
225
  this.native = native;
202
226
  }
227
+ /** Returns database name. */
203
228
  get name() {
204
229
  return this.native.name;
205
230
  }
231
+ /** Returns database schema version. */
206
232
  get version() {
207
233
  return this.native.version;
208
234
  }
235
+ /** Returns all stores names. */
209
236
  get stores() {
210
237
  return [...this.native.objectStoreNames];
211
238
  }
239
+ /** Create read-only transaction. */
212
240
  read(...names) {
213
241
  return new $mol_db_transaction(this.native.transaction(names, 'readonly', { durability: 'relaxed' })).stores;
214
242
  }
243
+ /** Create read/write transaction. */
215
244
  change(...names) {
216
245
  return new $mol_db_transaction(this.native.transaction(names, 'readwrite', { durability: 'relaxed' }));
217
246
  }
247
+ /**
248
+ * Deletes database.
249
+ * DB can be deleted only after end of all transactions.
250
+ */
218
251
  kill() {
219
252
  this.native.close();
220
253
  const request = $mol_dom_context.indexedDB.deleteDatabase(this.name);
221
254
  request.onblocked = console.warn;
222
255
  return $mol_db_response(request);
223
256
  }
257
+ /**
258
+ * Closes DB connection.
259
+ * Connection really be closed only after end of all transactions.
260
+ */
224
261
  destructor() {
225
262
  this.native.close();
226
263
  }
@@ -232,11 +269,13 @@ var $;
232
269
  "use strict";
233
270
  var $;
234
271
  (function ($) {
272
+ /** IndexedDB Transaction wrapper. */
235
273
  class $mol_db_transaction {
236
274
  native;
237
275
  constructor(native) {
238
276
  this.native = native;
239
277
  }
278
+ /** Returns dictionary of all existen Stores. */
240
279
  get stores() {
241
280
  return new Proxy({}, {
242
281
  ownKeys: () => [...this.native.objectStoreNames],
@@ -246,18 +285,22 @@ var $;
246
285
  : undefined,
247
286
  });
248
287
  }
288
+ /** Creates new Store */
249
289
  store_make(name) {
250
290
  return this.native.db.createObjectStore(name, { autoIncrement: true });
251
291
  }
292
+ /** Drops existen Store */
252
293
  store_drop(name) {
253
294
  this.native.db.deleteObjectStore(name);
254
295
  return this;
255
296
  }
297
+ /** Instant abort transaction. Any errors aborts transactions automatically. */
256
298
  abort() {
257
299
  if (this.native.error)
258
300
  return;
259
301
  this.native.abort();
260
302
  }
303
+ /** Instant commits transaction. Without errors commit proceed automatically later. */
261
304
  commit() {
262
305
  this.native.commit?.();
263
306
  return new Promise((done, fail) => {