localdb-ces6q 0.2.23 → 0.2.24
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 +10 -1
- package/publish.js +21 -0
- package/LocalDB.d.ts +0 -103
- package/LocalDB.js +0 -980
- package/LocalDBDocument.d.ts +0 -18
- package/LocalDBDocument.js +0 -55
- package/LocalDBState.d.ts +0 -14
- package/LocalDBState.js +0 -46
- package/comparators.d.ts +0 -15
- package/comparators.js +0 -105
- package/hooks.d.ts +0 -5
- package/hooks.js +0 -34
- package/types.d.ts +0 -104
- package/types.js +0 -1
package/package.json
CHANGED
@@ -1,14 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"name": "localdb-ces6q",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.24",
|
4
4
|
"description": "TypeScript ECMAScript Module Library Template",
|
5
5
|
"type": "module",
|
6
6
|
"module": "dist/index.js",
|
7
|
+
"exports": {
|
8
|
+
"./*": "./dist/*"
|
9
|
+
},
|
7
10
|
"scripts": {
|
8
11
|
"build": "tsc",
|
12
|
+
"build:clean": "npm run clean:build && npm run build",
|
9
13
|
"build:watch": "tsc -w",
|
14
|
+
"clean:build": "shx rm -rf ./dist",
|
10
15
|
"format": "prettier --write {src,test}/**/*.{ts,tsx,js,jsx}",
|
11
16
|
"pub": "node publish.js",
|
17
|
+
"release": "release-it",
|
18
|
+
"release:major:ci": "release-it major --ci",
|
19
|
+
"release:minor:ci": "release-it minor --ci",
|
20
|
+
"release:patch:ci": "release-it patch --ci",
|
12
21
|
"test": "jest",
|
13
22
|
"test:cov": "jest --collect-coverage",
|
14
23
|
"test:cov:watch": "jest --collect-coverage --watch",
|
package/publish.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/node
|
2
|
+
import shell from 'shelljs';
|
3
|
+
|
4
|
+
shell.rm('-rf', 'dist');
|
5
|
+
|
6
|
+
if (shell.exec('npm run test').code !== 0) {
|
7
|
+
shell.echo('Error: test failed');
|
8
|
+
shell.exit(1);
|
9
|
+
}
|
10
|
+
|
11
|
+
if (shell.exec('npm run build').code !== 0) {
|
12
|
+
shell.echo('Error: build failed');
|
13
|
+
shell.exit(1);
|
14
|
+
}
|
15
|
+
|
16
|
+
shell.cp('LICENSE', 'dist');
|
17
|
+
shell.cp('README.md', 'dist');
|
18
|
+
shell.cp('package.json', 'dist');
|
19
|
+
|
20
|
+
shell.cd('./dist');
|
21
|
+
shell.exec('npm publish');
|
package/LocalDB.d.ts
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
import { BTree } from 'bplustree-mq4uj/btree.js';
|
2
|
-
import { Debounce } from 'util-3gcvv/class/Debounce.js';
|
3
|
-
import { LocalDBState } from './LocalDBState.js';
|
4
|
-
import type { KeyOf } from 'util-3gcvv/types/types.js';
|
5
|
-
import type { Collection, Collections, CollectionsChange, CollectionsChangeMap, ColListener, DBListener, DocListener, FieldListener, ICollectionConfig, ICollectionsConfig, ICollectionsFields, IDBOperation, IDBOperationHistoryItem, IDBQuery, IDBTxOptions, IDocument } from './types.js';
|
6
|
-
export declare class LocalDB<CollectionTypes extends Record<string, IDocument>> {
|
7
|
-
protected _options?: IDBTxOptions;
|
8
|
-
protected _collectionNames: Array<KeyOf<CollectionTypes>>;
|
9
|
-
protected _collections: Collections<CollectionTypes>;
|
10
|
-
protected _config: ICollectionsConfig<CollectionTypes>;
|
11
|
-
protected _fields: ICollectionsFields<CollectionTypes>;
|
12
|
-
protected _saveCols: {
|
13
|
-
[ColName in KeyOf<CollectionTypes>]: Debounce<() => void>;
|
14
|
-
};
|
15
|
-
protected _indexes: {
|
16
|
-
[ColName in KeyOf<CollectionTypes>]: Record<string, BTree<CollectionTypes[ColName], CollectionTypes[ColName]>>;
|
17
|
-
};
|
18
|
-
protected _txChangedFields: CollectionsChangeMap<CollectionTypes>;
|
19
|
-
protected _txChanges: CollectionsChange<CollectionTypes>;
|
20
|
-
protected _txKey: string | null;
|
21
|
-
protected _txOps: IDBOperationHistoryItem[];
|
22
|
-
protected _txRollbacks: VoidFunction[];
|
23
|
-
protected _txSnapshot: Collections<CollectionTypes> | null;
|
24
|
-
protected _txOptions: IDBTxOptions | null;
|
25
|
-
protected _noEvent: boolean;
|
26
|
-
protected _undoable: boolean;
|
27
|
-
protected _inUndoOrRedo: boolean;
|
28
|
-
protected _opQueue: IDBOperation[];
|
29
|
-
protected _commiting: boolean;
|
30
|
-
protected _listenerId: number;
|
31
|
-
protected _dbListeners: Array<{
|
32
|
-
lid: number;
|
33
|
-
handler: DBListener<CollectionTypes>;
|
34
|
-
}>;
|
35
|
-
protected _colListeners: Array<{
|
36
|
-
lid: number;
|
37
|
-
collection: KeyOf<CollectionTypes>;
|
38
|
-
handler: ColListener<CollectionTypes, any>;
|
39
|
-
}>;
|
40
|
-
protected _docListeners: Array<{
|
41
|
-
lid: number;
|
42
|
-
collection: KeyOf<CollectionTypes>;
|
43
|
-
id: string;
|
44
|
-
handler: DocListener<CollectionTypes, any>;
|
45
|
-
}>;
|
46
|
-
protected _fieldListeners: Array<{
|
47
|
-
lid: number;
|
48
|
-
collection: KeyOf<CollectionTypes>;
|
49
|
-
id: string;
|
50
|
-
field: string;
|
51
|
-
handler: FieldListener<CollectionTypes, any, any>;
|
52
|
-
}>;
|
53
|
-
state: LocalDBState;
|
54
|
-
constructor(config: ICollectionsConfig<CollectionTypes>, initialData?: Collections<CollectionTypes>, options?: IDBTxOptions);
|
55
|
-
destroy(): void;
|
56
|
-
toJSON(): Collections<CollectionTypes>;
|
57
|
-
equals(other: Collections<CollectionTypes>): boolean;
|
58
|
-
defineCollection<Data extends IDocument>(colName: string, config: ICollectionConfig<CollectionTypes, Data>, initialData?: {
|
59
|
-
[id in string]: Data;
|
60
|
-
}): void;
|
61
|
-
deleteCollection<ColName extends KeyOf<CollectionTypes>>(col: ColName): void;
|
62
|
-
existsCollection(col: string): boolean;
|
63
|
-
get collectionNames(): Array<KeyOf<CollectionTypes>>;
|
64
|
-
beginTx(options?: IDBTxOptions | undefined): string | null;
|
65
|
-
endTx(txKey: string | null): void;
|
66
|
-
protected _rollback(): void;
|
67
|
-
tx(fn: () => void, options?: IDBTxOptions): void;
|
68
|
-
undoableTx(fn: () => void, options?: IDBTxOptions): void;
|
69
|
-
subToDB(handler: DBListener<CollectionTypes>): () => void;
|
70
|
-
unsubFromDB(lid: number): void;
|
71
|
-
subToCol<ColName extends KeyOf<CollectionTypes>>(collection: ColName, handler: ColListener<CollectionTypes, ColName>): () => void;
|
72
|
-
unsubFromCol(lid: number): void;
|
73
|
-
subToDoc<ColName extends KeyOf<CollectionTypes>>(collection: ColName, id: string, handler: DocListener<CollectionTypes, ColName>): () => void;
|
74
|
-
unsubFromDoc(lid: number): void;
|
75
|
-
subToField<ColName extends KeyOf<CollectionTypes>, Field extends KeyOf<CollectionTypes[ColName]>>(collection: ColName, id: string, field: Field, handler: FieldListener<CollectionTypes, ColName, Field>): () => void;
|
76
|
-
unsubFromField(lid: number): void;
|
77
|
-
collection<ColName extends KeyOf<CollectionTypes>>(colName: ColName): Collection<CollectionTypes, ColName>;
|
78
|
-
doc<ColName extends KeyOf<CollectionTypes>>(colName: ColName, id: string): CollectionTypes[ColName] | undefined;
|
79
|
-
docs<ColName extends KeyOf<CollectionTypes>>(colName: ColName, ids: string[]): Array<CollectionTypes[ColName] | undefined>;
|
80
|
-
getIndex<ColName extends KeyOf<CollectionTypes>>(colName: ColName, index: string): BTree<CollectionTypes[ColName], CollectionTypes[ColName]>;
|
81
|
-
docsOrderBy<ColName extends KeyOf<CollectionTypes>>(colName: ColName, index: string): Array<CollectionTypes[ColName]>;
|
82
|
-
query<ColName extends KeyOf<CollectionTypes>>({ collection, orderBy, limit, startAfter, startAt, endAfter, endAt, }: IDBQuery<CollectionTypes, ColName>): Array<CollectionTypes[ColName]>;
|
83
|
-
setDoc<ColName extends KeyOf<CollectionTypes>>(colName: ColName, doc: CollectionTypes[ColName], options?: IDBTxOptions): void;
|
84
|
-
setDocs<ColName extends KeyOf<CollectionTypes>>(colName: ColName, docs: Array<CollectionTypes[ColName]>, options?: IDBTxOptions): void;
|
85
|
-
protected _updateDoc<ColName extends KeyOf<CollectionTypes>>(colName: ColName, prev: CollectionTypes[ColName], update: Partial<CollectionTypes[ColName]>): {
|
86
|
-
next: CollectionTypes[ColName];
|
87
|
-
changedKeys: Array<KeyOf<CollectionTypes[ColName]>>;
|
88
|
-
} | null;
|
89
|
-
updateDoc<ColName extends KeyOf<CollectionTypes>>(colName: ColName, id: string, updater: Partial<CollectionTypes[ColName]> | ((prev: CollectionTypes[ColName]) => Partial<CollectionTypes[ColName]> | null | undefined), options?: IDBTxOptions): void;
|
90
|
-
updateDocs<ColName extends KeyOf<CollectionTypes>>(colName: ColName, updater: Record<string, Partial<CollectionTypes[ColName]>> | ((prev: Collections<CollectionTypes>[ColName]) => Record<string, Partial<CollectionTypes[ColName]> | null | undefined> | null | undefined), options?: IDBTxOptions): void;
|
91
|
-
deleteDoc<ColName extends KeyOf<CollectionTypes>>(colName: ColName, id: string, options?: IDBTxOptions): void;
|
92
|
-
deleteDocs<ColName extends KeyOf<CollectionTypes>>(colName: ColName, ids: string[], options?: IDBTxOptions): void;
|
93
|
-
protected _commitChanges(): void;
|
94
|
-
protected _flushQueue(): void;
|
95
|
-
protected _pushHistory(): void;
|
96
|
-
undo(): void;
|
97
|
-
redo(): void;
|
98
|
-
loadCollectionFromStorage<ColName extends KeyOf<CollectionTypes>>(collection: ColName): Record<string, CollectionTypes[ColName]> | undefined;
|
99
|
-
saveCollectionToStorage<ColName extends KeyOf<CollectionTypes>>(collection: ColName): void;
|
100
|
-
protected loadFromStorage(): void;
|
101
|
-
saveToStorage(): void;
|
102
|
-
saveDebounced: Debounce<() => void>;
|
103
|
-
}
|