dexie 4.0.9-alpha.1 → 4.0.10

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/dist/dexie.d.ts CHANGED
@@ -4,13 +4,13 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.9-alpha.1, Fri Aug 23 2024
7
+ * Version 4.0.10, Fri Nov 15 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
11
11
  * Apache License Version 2.0, January 2004, http://www.apache.org/licenses/
12
12
  */
13
- // Generated by dts-bundle-generator v9.3.1
13
+ // Generated by dts-bundle-generator v5.9.0
14
14
 
15
15
  export interface IndexSpec {
16
16
  name: string;
@@ -20,16 +20,11 @@ export interface IndexSpec {
20
20
  auto: boolean | undefined;
21
21
  compound: boolean | undefined;
22
22
  src: string;
23
- type?: string | undefined;
24
23
  }
25
24
  export interface TableSchema {
26
25
  name: string;
27
26
  primKey: IndexSpec;
28
27
  indexes: IndexSpec[];
29
- yProps?: {
30
- prop: string;
31
- updatesTable: string;
32
- }[];
33
28
  mappedClass: Function;
34
29
  idxByName: {
35
30
  [name: string]: IndexSpec;
@@ -364,122 +359,10 @@ export interface PromiseExtended<T = any> extends Promise<T> {
364
359
  finally<U>(onFinally?: () => U | PromiseLike<U>): PromiseExtended<T>;
365
360
  timeout(ms: number, msg?: string): PromiseExtended<T>;
366
361
  }
367
- export interface DucktypedY {
368
- Doc: new (options?: {
369
- guid?: string;
370
- collectionid?: string;
371
- gc?: boolean;
372
- gcFilter?: any;
373
- meta?: any;
374
- autoLoad?: boolean;
375
- shouldLoad?: boolean;
376
- }) => DucktypedYDoc;
377
- applyUpdate: Function;
378
- applyUpdateV2: Function;
379
- encodeStateAsUpdate: Function;
380
- encodeStateAsUpdateV2: Function;
381
- encodeStateVector: Function;
382
- encodeStateVectorFromUpdate: Function;
383
- encodeStateVectorFromUpdateV2: Function;
384
- mergeUpdates: Function;
385
- mergeUpdatesV2: Function;
386
- diffUpdate: Function;
387
- diffUpdateV2: Function;
388
- transact: Function;
389
- }
390
- export interface DucktypedYObservable {
391
- on(name: string, f: (...args: any[]) => any): void;
392
- off(name: string, f: (...args: any[]) => any): void;
393
- once(name: string, f: (...args: any[]) => any): void;
394
- emit(name: string, args: any[]): void;
395
- destroy(): void;
396
- }
397
- /** Dock-typed Y.Doc */
398
- export interface DucktypedYDoc extends DucktypedYObservable {
399
- guid?: any;
400
- collectionid?: any;
401
- collection?: any;
402
- whenLoaded: PromiseLike<any>;
403
- whenSynced: PromiseLike<any>;
404
- isLoaded: any;
405
- isSynced: any;
406
- transact: any;
407
- toJSON: () => any;
408
- destroy: () => void;
409
- meta?: any;
410
- share: Map<any, any>;
411
- }
412
- export interface DexieYDocMeta {
413
- db: Dexie;
414
- parentTable: string;
415
- parentId: any;
416
- parentProp: string;
417
- updatesTable: string;
418
- }
419
- /** Stored in the updates table with auto-incremented number as primary key
420
- *
421
- */
422
- export interface YUpdateRow {
423
- /** The primary key in the update-table
424
- *
425
- */
426
- i: number;
427
- /** The primary key of the row in related table holding the document property.
428
- *
429
- */
430
- k: IndexableType;
431
- /** The Y update
432
- *
433
- */
434
- u: Uint8Array;
435
- /** Optional flag
436
- *
437
- * 1 = LOCAL_CHANGE_MAYBE_UNSYNCED
438
- *
439
- */
440
- f?: number;
441
- }
442
- /** Stored in update tables along with YUpdateRows but with a string representing the syncing enging, as primary key
443
- * A syncing engine can create an YSyncer row with an unsentFrom value set to the a number representing primary key (i)
444
- * of updates that has not been sent to server or peer yet. Dexie will spare all updates that occur after the least
445
- * unsentFrom value in the updates table from being compressed and garbage collected into the main update.
446
- */
447
- export interface YSyncer {
448
- i: string;
449
- unsentFrom: number;
450
- }
451
- /** A stamp of the last compressed and garbage collected update in the update table.
452
- * The garbage collection process will find out which documents have got new updates since the last compressed update
453
- * and compress them into their corresponding main update.
454
- *
455
- * The id of this row is always 0 - which is a reserved id for this purpose.
456
- */
457
- export interface YLastCompressed {
458
- i: 0;
459
- lastCompressed: number;
460
- lastRun?: Date;
461
- }
462
- export interface DexieYProvider<YDoc = any> {
463
- readonly doc: YDoc;
464
- awareness?: any;
465
- whenLoaded: Promise<any>;
466
- whenSynced: Promise<any>;
467
- on: DexieEventSet & ((name: string, f: (...args: any[]) => any) => void);
468
- off(name: string, f: (...args: any[]) => any): void;
469
- destroy(): void;
470
- readonly destroyed: boolean;
471
- }
472
- export interface YDocCache {
473
- readonly size: number;
474
- find: (table: string, primaryKey: any, ydocProp: string) => DucktypedYDoc | undefined;
475
- add: (doc: DucktypedYDoc) => void;
476
- delete: (doc: DucktypedYDoc) => void;
477
- }
478
362
  export type KeyPaths<T> = {
479
363
  [P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends any[] // Array of arrays (issue #2026)
480
364
  ? P | `${P}.${number}` | `${P}.${number}.${number}` : K extends object // only drill into the array element if it's an object
481
365
  ? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<K>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method
482
- ? never : T[P] extends DucktypedYDoc // Not valid in update spec or where clause (+ avoid circular reference)
483
366
  ? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
484
367
  }[keyof T];
485
368
  export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R extends keyof T ? KeyPathValue<T[R], S> : T extends any[] ? PATH extends `${number}.${infer S}` ? KeyPathValue<T[number], S> : void : void : PATH extends `${number}` ? T extends any[] ? T[number] : void : PATH extends keyof T ? T[PATH] : any;
@@ -569,22 +452,6 @@ export interface IntervalTreeNode {
569
452
  export interface EmptyRange {
570
453
  d: 0;
571
454
  }
572
- export interface RangeSetPrototype {
573
- add(rangeSet: IntervalTree | {
574
- from: IndexableType;
575
- to: IndexableType;
576
- }): RangeSet;
577
- addKey(key: IndexableType): RangeSet;
578
- addKeys(keys: IndexableType[]): RangeSet;
579
- hasKey(key: IndexableType): boolean;
580
- [Symbol.iterator](): Iterator<IntervalTreeNode, undefined, IndexableType | undefined>;
581
- }
582
- export type RangeSet = RangeSetPrototype & IntervalTree;
583
- export interface RangeSetConstructor {
584
- (tree: IntervalTree): RangeSet;
585
- new (): RangeSet;
586
- new (from: IndexableType, to?: IndexableType): RangeSet;
587
- }
588
455
  export interface DexieOnReadyEvent {
589
456
  subscribe(fn: (vipDb: Dexie) => any, bSticky: boolean): void;
590
457
  unsubscribe(fn: (vipDb: Dexie) => any): void;
@@ -605,26 +472,17 @@ export interface DexieCloseEvent {
605
472
  unsubscribe(fn: (event: Event) => any): void;
606
473
  fire(event: Event): any;
607
474
  }
608
- export interface DexieYEvent {
609
- subscribe(fn: (provider: DexieYProvider, Y: any) => void): void;
610
- unsubscribe(fn: (provider: DexieYProvider, Y: any) => void): void;
611
- fire(provider: DexieYProvider, Y: any): void;
612
- }
613
- export interface DbEventFns {
475
+ export interface DbEvents extends DexieEventSet {
476
+ (eventName: "ready", subscriber: (vipDb: Dexie) => any, bSticky?: boolean): void;
614
477
  (eventName: "populate", subscriber: (trans: Transaction) => any): void;
615
478
  (eventName: "blocked", subscriber: (event: IDBVersionChangeEvent) => any): void;
616
479
  (eventName: "versionchange", subscriber: (event: IDBVersionChangeEvent) => any): void;
617
480
  (eventName: "close", subscriber: (event: Event) => any): void;
618
- (eventName: "y", subscriber: (provider: DexieYProvider, Y: any) => void): void;
619
- }
620
- export interface DbEvents extends DbEventFns, DexieEventSet {
621
- (eventName: "ready", subscriber: (vipDb: Dexie) => any, bSticky?: boolean): void;
622
481
  ready: DexieOnReadyEvent;
623
482
  populate: DexiePopulateEvent;
624
483
  blocked: DexieEvent;
625
484
  versionchange: DexieVersionChangeEvent;
626
485
  close: DexieCloseEvent;
627
- y: DexieYEvent;
628
486
  }
629
487
  /** Set of mutated parts of the database
630
488
  */
@@ -955,14 +813,12 @@ export interface Dexie {
955
813
  readonly _allTables: {
956
814
  [name: string]: Table<any, IndexableType>;
957
815
  };
958
- readonly _options: DexieOptions;
959
816
  readonly core: DBCore;
960
817
  _createTransaction: (this: Dexie, mode: IDBTransactionMode, storeNames: ArrayLike<string>, dbschema: DbSchema, parentTransaction?: Transaction | null) => Transaction;
961
818
  readonly _novip: Dexie;
962
819
  _dbSchema: DbSchema;
963
820
  version(versionNumber: number): Version;
964
821
  on: DbEvents;
965
- once: DbEventFns;
966
822
  open(): PromiseExtended<Dexie>;
967
823
  table<T = any, TKey = IndexableType, TInsertType = T>(tableName: string): Table<T, TKey, TInsertType>;
968
824
  transaction<U>(mode: TransactionMode, tables: readonly (string | Table)[], scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
@@ -991,7 +847,6 @@ export interface Dexie {
991
847
  stack: keyof DexieStacks;
992
848
  name: string;
993
849
  }): this;
994
- gc(): Promise<void>;
995
850
  // Make it possible to touch physical class constructors where they reside - as properties on db instance.
996
851
  // For example, checking if (x instanceof db.Table). Can't do (x instanceof Dexie.Table because it's just a virtual interface)
997
852
  Table: {
@@ -1150,7 +1005,6 @@ export interface DexieDOMDependencies {
1150
1005
  indexedDB: IDBFactory;
1151
1006
  IDBKeyRange: typeof IDBKeyRange;
1152
1007
  }
1153
- // There typings are extracted from https://github.com/tc39/proposal-observable
1154
1008
  declare global {
1155
1009
  interface SymbolConstructor {
1156
1010
  readonly observable: symbol;
@@ -1226,10 +1080,11 @@ export interface DexieOptions {
1226
1080
  upperBound: Function;
1227
1081
  };
1228
1082
  allowEmptyDB?: boolean;
1229
- modifyChunkSize?: number;
1083
+ modifyChunkSize?: number | {
1084
+ [key: string]: number;
1085
+ };
1230
1086
  chromeTransactionDurability?: ChromeTransactionDurability;
1231
1087
  cache?: "immutable" | "cloned" | "disabled";
1232
- Y?: DucktypedY; // Caller supplies Y from the following: import * as Y from 'yjs';
1233
1088
  }
1234
1089
  export interface DexieConstructor extends DexieExceptionClasses {
1235
1090
  new (databaseName: string, options?: DexieOptions): Dexie;
@@ -1276,24 +1131,16 @@ export class Entity<TDexieSubClass extends Dexie = Dexie> {
1276
1131
  export type IsStrictlyAny<T> = (T extends never ? true : false) extends false ? false : true;
1277
1132
  /** Extract the union of literal method names in T
1278
1133
  */
1279
- export type NonInsertProps<T> = {
1134
+ export type MethodProps<T> = {
1280
1135
  [P in keyof T]: IsStrictlyAny<T[P]> extends true ? never // Plain property of type any (not method)
1281
1136
  : T[P] extends (...args: any[]) => any ? P // a function (method)
1282
- : T[P] extends {
1283
- on: any;
1284
- subdocs: any;
1285
- gc: any;
1286
- isSynced: any;
1287
- isLoaded: any;
1288
- shouldLoad: any;
1289
- } ? P // an YDoc property - should be generated by dexie and not by user
1290
1137
  : never;
1291
1138
  }[keyof T];
1292
1139
  /** Default insert type of T is a subset of T where:
1293
1140
  * * given optional props (such as an auto-generated primary key) are made optional
1294
1141
  * * methods are omitted
1295
1142
  */
1296
- export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps | NonInsertProps<T>> & {
1143
+ export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps | MethodProps<T>> & {
1297
1144
  [P in OptionalProps]?: T[P];
1298
1145
  };
1299
1146
  /** IDType extract the actual type of the primary key:
@@ -1303,13 +1150,10 @@ export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps
1303
1150
  export type IDType<T, TKeyPropNameOrKeyType> = IsStrictlyAny<T> extends true ? TKeyPropNameOrKeyType : TKeyPropNameOrKeyType extends string ? TKeyPropNameOrKeyType extends keyof T ? T[TKeyPropNameOrKeyType] : TKeyPropNameOrKeyType : TKeyPropNameOrKeyType;
1304
1151
  export type EntityTable<T, TKeyPropName extends keyof T = never, TInsertType = InsertType<T, TKeyPropName>> = Table<T, IDType<T, TKeyPropName>, TInsertType>;
1305
1152
  export declare var Dexie: DexieConstructor;
1306
- // Alias of Table and Collection in order to be able to refer them from module below...
1307
1153
  export interface _Table<T, TKey, TInsertType> extends Table<T, TKey, TInsertType> {
1308
1154
  }
1309
1155
  export interface _Collection<T, TKey> extends Collection<T, TKey> {
1310
1156
  }
1311
- // Besides being the only exported value, let Dexie also be
1312
- // a namespace for types...
1313
1157
  export declare module Dexie {
1314
1158
  // The "Dexie.Promise" type.
1315
1159
  type Promise<T = any> = PromiseExtended<T>; // Because many samples have been Dexie.Promise.
@@ -1323,20 +1167,12 @@ export declare module Dexie {
1323
1167
  export function liveQuery<T>(querier: () => T | Promise<T>): Observable<T>;
1324
1168
  export function mergeRanges(target: IntervalTree, newSet: IntervalTree): void;
1325
1169
  export function rangesOverlap(rangeSet1: IntervalTree, rangeSet2: IntervalTree): boolean;
1326
- declare var RangeSet$1: RangeSetConstructor;
1327
1170
  export function cmp(a: any, b: any): number;
1328
1171
  export function replacePrefix(a: string, b: string): PropModification;
1329
1172
  export function add(num: number | bigint | any[]): PropModification;
1330
1173
  export function remove(num: number | bigint | any[]): PropModification;
1331
- export declare var DexieYProvider: {
1332
- (doc: DucktypedYDoc): DexieYProvider;
1333
- new (doc: DucktypedYDoc): DexieYProvider;
1334
- getDocCache: (db: Dexie) => YDocCache;
1335
- };
1336
-
1337
- export {
1338
- Dexie as default,
1339
- RangeSet$1 as RangeSet,
1340
- };
1174
+ /** Exporting 'Dexie' as the default export.
1175
+ **/
1176
+ export default Dexie;
1341
1177
 
1342
1178
  export {};