dexie 4.0.1-beta.8 → 4.0.1-beta.9

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,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-beta.8, Wed Feb 07 2024
7
+ * Version 4.0.1-beta.9, Thu Feb 08 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -85,7 +85,7 @@ export interface DeletingHookContext<T, Key> {
85
85
  onsuccess?: () => void;
86
86
  onerror?: (err: any) => void;
87
87
  }
88
- export interface TableHooks<T = any, TKey = IndexableType> extends DexieEventSet {
88
+ export interface TableHooks<T = any, TKey = IndexableType, TInsertType = T> extends DexieEventSet {
89
89
  (eventName: "creating", subscriber: (this: CreatingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => void | undefined | TKey): void;
90
90
  (eventName: "reading", subscriber: (obj: T) => T | any): void;
91
91
  (eventName: "updating", subscriber: (this: UpdatingHookContext<T, TKey>, modifications: Object, primKey: TKey, obj: T, transaction: Transaction) => any): void;
@@ -96,33 +96,33 @@ export interface TableHooks<T = any, TKey = IndexableType> extends DexieEventSet
96
96
  deleting: DexieEvent;
97
97
  }
98
98
  export type ThenShortcut<T, TResult> = (value: T) => TResult | PromiseLike<TResult>;
99
- export interface WhereClause<T = any, TKey = IndexableType> {
100
- above(key: any): Collection<T, TKey>;
101
- aboveOrEqual(key: any): Collection<T, TKey>;
102
- anyOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey>;
103
- anyOf(...keys: Array<IndexableType>): Collection<T, TKey>;
104
- anyOfIgnoreCase(keys: string[]): Collection<T, TKey>;
105
- anyOfIgnoreCase(...keys: string[]): Collection<T, TKey>;
106
- below(key: any): Collection<T, TKey>;
107
- belowOrEqual(key: any): Collection<T, TKey>;
108
- between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): Collection<T, TKey>;
109
- equals(key: IndexableType): Collection<T, TKey>;
110
- equalsIgnoreCase(key: string): Collection<T, TKey>;
99
+ export interface WhereClause<T = any, TKey = IndexableType, TInsertType = T> {
100
+ above(key: any): Collection<T, TKey, TInsertType>;
101
+ aboveOrEqual(key: any): Collection<T, TKey, TInsertType>;
102
+ anyOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey, TInsertType>;
103
+ anyOf(...keys: Array<IndexableType>): Collection<T, TKey, TInsertType>;
104
+ anyOfIgnoreCase(keys: string[]): Collection<T, TKey, TInsertType>;
105
+ anyOfIgnoreCase(...keys: string[]): Collection<T, TKey, TInsertType>;
106
+ below(key: any): Collection<T, TKey, TInsertType>;
107
+ belowOrEqual(key: any): Collection<T, TKey, TInsertType>;
108
+ between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): Collection<T, TKey, TInsertType>;
109
+ equals(key: IndexableType): Collection<T, TKey, TInsertType>;
110
+ equalsIgnoreCase(key: string): Collection<T, TKey, TInsertType>;
111
111
  inAnyRange(ranges: ReadonlyArray<{
112
112
  0: any;
113
113
  1: any;
114
114
  }>, options?: {
115
115
  includeLowers?: boolean;
116
116
  includeUppers?: boolean;
117
- }): Collection<T, TKey>;
118
- startsWith(key: string): Collection<T, TKey>;
119
- startsWithAnyOf(prefixes: string[]): Collection<T, TKey>;
120
- startsWithAnyOf(...prefixes: string[]): Collection<T, TKey>;
121
- startsWithIgnoreCase(key: string): Collection<T, TKey>;
122
- startsWithAnyOfIgnoreCase(prefixes: string[]): Collection<T, TKey>;
123
- startsWithAnyOfIgnoreCase(...prefixes: string[]): Collection<T, TKey>;
124
- noneOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey>;
125
- notEqual(key: IndexableType): Collection<T, TKey>;
117
+ }): Collection<T, TKey, TInsertType>;
118
+ startsWith(key: string): Collection<T, TKey, TInsertType>;
119
+ startsWithAnyOf(prefixes: string[]): Collection<T, TKey, TInsertType>;
120
+ startsWithAnyOf(...prefixes: string[]): Collection<T, TKey, TInsertType>;
121
+ startsWithIgnoreCase(key: string): Collection<T, TKey, TInsertType>;
122
+ startsWithAnyOfIgnoreCase(prefixes: string[]): Collection<T, TKey, TInsertType>;
123
+ startsWithAnyOfIgnoreCase(...prefixes: string[]): Collection<T, TKey, TInsertType>;
124
+ noneOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey, TInsertType>;
125
+ notEqual(key: IndexableType): Collection<T, TKey, TInsertType>;
126
126
  }
127
127
  export interface PromiseExtendedConstructor extends PromiseConstructor {
128
128
  readonly prototype: PromiseExtended;
@@ -366,13 +366,13 @@ export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R ext
366
366
  export type UpdateSpec<T> = {
367
367
  [KP in KeyPaths<T>]?: KeyPathValue<T, KP>;
368
368
  };
369
- export interface Collection<T = any, TKey = IndexableType> {
369
+ export interface Collection<T = any, TKey = IndexableType, TInsertType = T> {
370
370
  db: Dexie;
371
- and(filter: (x: T) => boolean): Collection<T, TKey>;
372
- clone(props?: Object): Collection<T, TKey>;
371
+ and(filter: (x: T) => boolean): Collection<T, TKey, TInsertType>;
372
+ clone(props?: Object): Collection<T, TKey, TInsertType>;
373
373
  count(): PromiseExtended<number>;
374
374
  count<R>(thenShortcut: ThenShortcut<number, R>): PromiseExtended<R>;
375
- distinct(): Collection<T, TKey>;
375
+ distinct(): Collection<T, TKey, TInsertType>;
376
376
  each(callback: (obj: T, cursor: {
377
377
  key: IndexableType;
378
378
  primaryKey: TKey;
@@ -390,7 +390,7 @@ export interface Collection<T = any, TKey = IndexableType> {
390
390
  primaryKey: TKey;
391
391
  }) => any): PromiseExtended<void>;
392
392
  filter<S extends T>(filter: (x: T) => x is S): Collection<S, TKey>;
393
- filter(filter: (x: T) => boolean): Collection<T, TKey>;
393
+ filter(filter: (x: T) => boolean): Collection<T, TKey, TInsertType>;
394
394
  first(): PromiseExtended<T | undefined>;
395
395
  first<R>(thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>;
396
396
  keys(): PromiseExtended<IndexableTypeArray>;
@@ -399,24 +399,24 @@ export interface Collection<T = any, TKey = IndexableType> {
399
399
  primaryKeys<R>(thenShortcut: ThenShortcut<TKey[], R>): PromiseExtended<R>;
400
400
  last(): PromiseExtended<T | undefined>;
401
401
  last<R>(thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>;
402
- limit(n: number): Collection<T, TKey>;
403
- offset(n: number): Collection<T, TKey>;
404
- or(indexOrPrimayKey: string): WhereClause<T, TKey>;
405
- raw(): Collection<T, TKey>;
406
- reverse(): Collection<T, TKey>;
402
+ limit(n: number): Collection<T, TKey, TInsertType>;
403
+ offset(n: number): Collection<T, TKey, TInsertType>;
404
+ or(indexOrPrimayKey: string): WhereClause<T, TKey, TInsertType>;
405
+ raw(): Collection<T, TKey, TInsertType>;
406
+ reverse(): Collection<T, TKey, TInsertType>;
407
407
  sortBy(keyPath: string): PromiseExtended<T[]>;
408
408
  sortBy<R>(keyPath: string, thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>;
409
409
  toArray(): PromiseExtended<Array<T>>;
410
410
  toArray<R>(thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>;
411
411
  uniqueKeys(): PromiseExtended<IndexableTypeArray>;
412
412
  uniqueKeys<R>(thenShortcut: ThenShortcut<IndexableTypeArray, R>): PromiseExtended<R>;
413
- until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection<T, TKey>;
413
+ until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection<T, TKey, TInsertType>;
414
414
  // Mutating methods
415
415
  delete(): PromiseExtended<number>;
416
416
  modify(changeCallback: (obj: T, ctx: {
417
- value: T;
417
+ value: TInsertType;
418
418
  }) => void | boolean): PromiseExtended<number>;
419
- modify(changes: UpdateSpec<T>): PromiseExtended<number>;
419
+ modify(changes: UpdateSpec<TInsertType>): PromiseExtended<number>;
420
420
  }
421
421
  export type IntervalTree = IntervalTreeNode | EmptyRange;
422
422
  export interface IntervalTreeNode {
@@ -683,7 +683,7 @@ export interface Table<T = any, TKey = any, TInsertType = T> {
683
683
  db: Dexie;
684
684
  name: string;
685
685
  schema: TableSchema;
686
- hook: TableHooks<T, TKey>;
686
+ hook: TableHooks<T, TKey, TInsertType>;
687
687
  core: DBCoreTable;
688
688
  get(key: TKey): PromiseExtended<T | undefined>;
689
689
  get<R>(key: TKey, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>;
@@ -693,27 +693,27 @@ export interface Table<T = any, TKey = any, TInsertType = T> {
693
693
  get<R>(equalityCriterias: {
694
694
  [key: string]: any;
695
695
  }, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>;
696
- where(index: string | string[]): WhereClause<T, TKey>;
696
+ where(index: string | string[]): WhereClause<T, TKey, TInsertType>;
697
697
  where(equalityCriterias: {
698
698
  [key: string]: any;
699
- }): Collection<T, TKey>;
700
- filter(fn: (obj: T) => boolean): Collection<T, TKey>;
699
+ }): Collection<T, TKey, TInsertType>;
700
+ filter(fn: (obj: T) => boolean): Collection<T, TKey, TInsertType>;
701
701
  count(): PromiseExtended<number>;
702
702
  count<R>(thenShortcut: ThenShortcut<number, R>): PromiseExtended<R>;
703
- offset(n: number): Collection<T, TKey>;
704
- limit(n: number): Collection<T, TKey>;
703
+ offset(n: number): Collection<T, TKey, TInsertType>;
704
+ limit(n: number): Collection<T, TKey, TInsertType>;
705
705
  each(callback: (obj: T, cursor: {
706
706
  key: any;
707
707
  primaryKey: TKey;
708
708
  }) => any): PromiseExtended<void>;
709
709
  toArray(): PromiseExtended<Array<T>>;
710
710
  toArray<R>(thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>;
711
- toCollection(): Collection<T, TKey>;
712
- orderBy(index: string | string[]): Collection<T, TKey>;
713
- reverse(): Collection<T, TKey>;
711
+ toCollection(): Collection<T, TKey, TInsertType>;
712
+ orderBy(index: string | string[]): Collection<T, TKey, TInsertType>;
713
+ reverse(): Collection<T, TKey, TInsertType>;
714
714
  mapToClass(constructor: Function): Function;
715
715
  add(item: TInsertType, key?: TKey): PromiseExtended<TKey>;
716
- update(key: TKey | T, changes: UpdateSpec<T> | ((obj: T, ctx: {
716
+ update(key: TKey | T, changes: UpdateSpec<TInsertType> | ((obj: T, ctx: {
717
717
  value: any;
718
718
  primKey: IndexableType;
719
719
  }) => void | boolean)): PromiseExtended<number>;
@@ -1022,7 +1022,6 @@ export interface TblQueryCache {
1022
1022
  objs: Map<string | number, object>;
1023
1023
  optimisticOps: DBCoreMutateRequest[];
1024
1024
  unsignaledParts: ObservabilitySet;
1025
- signalTimer?: number;
1026
1025
  }
1027
1026
  export interface CacheEntryCommon {
1028
1027
  subscribers: Set<() => void>;