@nymphjs/driver-sqlite3 1.0.0-beta.13 → 1.0.0-beta.131
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/CHANGELOG.md +590 -0
- package/README.md +5 -3
- package/dist/SQLite3Driver.d.ts +108 -17
- package/dist/SQLite3Driver.js +1501 -572
- package/dist/SQLite3Driver.js.map +1 -1
- package/dist/SQLite3Driver.test.js +28 -22
- package/dist/SQLite3Driver.test.js.map +1 -1
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +2 -4
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +63 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -24
- package/dist/index.js.map +1 -1
- package/jest.config.js +31 -5
- package/package.json +32 -21
- package/src/SQLite3Driver.test.ts +23 -9
- package/src/SQLite3Driver.ts +2218 -901
- package/src/conf/defaults.ts +2 -2
- package/src/conf/index.ts +63 -2
- package/src/index.ts +2 -2
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -0
- package/dist/conf/d.d.ts +0 -9
- package/dist/conf/d.js +0 -3
- package/dist/conf/d.js.map +0 -1
- package/src/conf/d.ts +0 -52
package/dist/SQLite3Driver.d.ts
CHANGED
|
@@ -1,34 +1,97 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { NymphDriver, EntityConstructor, EntityInterface, FormattedSelector, Options, Selector } from '@nymphjs/nymph';
|
|
3
|
-
import { SQLite3DriverConfig } from './conf';
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { NymphDriver, type EntityConstructor, type EntityObjectType, type EntityInterface, type EntityInstanceType, type SerializedEntityData, type FormattedSelector, type Options, type Selector } from '@nymphjs/nymph';
|
|
3
|
+
import { SQLite3DriverConfig } from './conf/index.js';
|
|
4
4
|
declare class InternalStore {
|
|
5
|
-
link:
|
|
6
|
-
linkWrite?:
|
|
5
|
+
link: DatabaseSync;
|
|
6
|
+
linkWrite?: DatabaseSync;
|
|
7
7
|
connected: boolean;
|
|
8
8
|
transactionsStarted: number;
|
|
9
|
-
constructor(link:
|
|
9
|
+
constructor(link: DatabaseSync);
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* The SQLite3 Nymph database driver.
|
|
13
|
+
*/
|
|
11
14
|
export default class SQLite3Driver extends NymphDriver {
|
|
12
15
|
config: SQLite3DriverConfig;
|
|
13
16
|
protected prefix: string;
|
|
14
17
|
protected store: InternalStore;
|
|
15
18
|
static escape(input: string): string;
|
|
19
|
+
static escapeValue(input: string): string;
|
|
16
20
|
constructor(config: Partial<SQLite3DriverConfig>, store?: InternalStore);
|
|
21
|
+
/**
|
|
22
|
+
* This is used internally by Nymph. Don't call it yourself.
|
|
23
|
+
*
|
|
24
|
+
* @returns A clone of this instance.
|
|
25
|
+
*/
|
|
17
26
|
clone(): SQLite3Driver;
|
|
27
|
+
/**
|
|
28
|
+
* Connect to the SQLite3 database.
|
|
29
|
+
*
|
|
30
|
+
* @returns Whether this instance is connected to a SQLite3 database.
|
|
31
|
+
*/
|
|
18
32
|
connect(): Promise<boolean>;
|
|
19
33
|
private _connect;
|
|
34
|
+
/**
|
|
35
|
+
* Disconnect from the SQLite3 database.
|
|
36
|
+
*
|
|
37
|
+
* @returns Whether this instance is connected to a SQLite3 database.
|
|
38
|
+
*/
|
|
20
39
|
disconnect(): Promise<false>;
|
|
21
40
|
inTransaction(): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Check connection status.
|
|
43
|
+
*
|
|
44
|
+
* @returns Whether this instance is connected to a SQLite3 database.
|
|
45
|
+
*/
|
|
22
46
|
isConnected(): boolean;
|
|
47
|
+
private createEntitiesTable;
|
|
48
|
+
private addTilmeldColumnsAndIndexes;
|
|
49
|
+
private createEntitiesTilmeldIndexes;
|
|
50
|
+
private createDataTable;
|
|
51
|
+
private createReferencesTable;
|
|
52
|
+
private createTokensTable;
|
|
53
|
+
private createUniquesTable;
|
|
54
|
+
/**
|
|
55
|
+
* Create entity tables in the database.
|
|
56
|
+
*
|
|
57
|
+
* @param etype The entity type to create a table for. If this is blank, the default tables are created.
|
|
58
|
+
*/
|
|
23
59
|
private createTables;
|
|
24
60
|
private query;
|
|
25
|
-
private
|
|
61
|
+
private queryArray;
|
|
26
62
|
private queryGet;
|
|
27
63
|
private queryRun;
|
|
28
64
|
commit(name: string): Promise<boolean>;
|
|
29
65
|
deleteEntityByID(guid: string, className?: EntityConstructor | string | null): Promise<boolean>;
|
|
30
66
|
deleteUID(name: string): Promise<boolean>;
|
|
31
|
-
|
|
67
|
+
getIndexes(etype: string): Promise<{
|
|
68
|
+
scope: 'data' | 'references' | 'tokens';
|
|
69
|
+
name: string;
|
|
70
|
+
property: string;
|
|
71
|
+
}[]>;
|
|
72
|
+
addIndex(etype: string, definition: {
|
|
73
|
+
scope: 'data' | 'references' | 'tokens';
|
|
74
|
+
name: string;
|
|
75
|
+
property: string;
|
|
76
|
+
}): Promise<boolean>;
|
|
77
|
+
deleteIndex(etype: string, scope: 'data' | 'references' | 'tokens', name: string): Promise<boolean>;
|
|
78
|
+
getEtypes(): Promise<string[]>;
|
|
79
|
+
exportDataIterator(): AsyncGenerator<{
|
|
80
|
+
type: 'comment' | 'uid' | 'entity';
|
|
81
|
+
content: string;
|
|
82
|
+
}, void, false | undefined>;
|
|
83
|
+
exportEntity(etype: string, guid: string): Promise<string>;
|
|
84
|
+
private exportEntityInternal;
|
|
85
|
+
/**
|
|
86
|
+
* Generate the SQLite3 query.
|
|
87
|
+
* @param options The options array.
|
|
88
|
+
* @param formattedSelectors The formatted selector array.
|
|
89
|
+
* @param etype
|
|
90
|
+
* @param count Used to track internal params.
|
|
91
|
+
* @param params Used to store internal params.
|
|
92
|
+
* @param subquery Whether only a subquery should be returned.
|
|
93
|
+
* @returns The SQL query.
|
|
94
|
+
*/
|
|
32
95
|
private makeEntityQuery;
|
|
33
96
|
protected performQuery(options: Options, formattedSelectors: FormattedSelector[], etype: string): {
|
|
34
97
|
result: any;
|
|
@@ -39,21 +102,49 @@ export default class SQLite3Driver extends NymphDriver {
|
|
|
39
102
|
getEntities<T extends EntityConstructor = EntityConstructor>(options: Options<T> & {
|
|
40
103
|
return: 'guid';
|
|
41
104
|
}, ...selectors: Selector[]): Promise<string[]>;
|
|
42
|
-
getEntities<T extends EntityConstructor = EntityConstructor>(options
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
protected getEntitiesSync<T extends EntityConstructor = EntityConstructor>(options: Options<T> & {
|
|
47
|
-
return: 'guid';
|
|
48
|
-
}, ...selectors: Selector[]): string[];
|
|
49
|
-
protected getEntitiesSync<T extends EntityConstructor = EntityConstructor>(options?: Options<T>, ...selectors: Selector[]): ReturnType<T['factorySync']>[];
|
|
105
|
+
getEntities<T extends EntityConstructor = EntityConstructor>(options: Options<T> & {
|
|
106
|
+
return: 'object';
|
|
107
|
+
}, ...selectors: Selector[]): Promise<EntityObjectType<T>[]>;
|
|
108
|
+
getEntities<T extends EntityConstructor = EntityConstructor>(options?: Options<T>, ...selectors: Selector[]): Promise<EntityInstanceType<T>[]>;
|
|
50
109
|
getUID(name: string): Promise<number | null>;
|
|
51
|
-
|
|
110
|
+
importEntity(entity: {
|
|
111
|
+
guid: string;
|
|
112
|
+
cdate: number;
|
|
113
|
+
mdate: number;
|
|
114
|
+
tags: string[];
|
|
115
|
+
sdata: SerializedEntityData;
|
|
116
|
+
etype: string;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
importEntityTokens(entity: {
|
|
119
|
+
guid: string;
|
|
120
|
+
cdate: number;
|
|
121
|
+
mdate: number;
|
|
122
|
+
tags: string[];
|
|
123
|
+
sdata: SerializedEntityData;
|
|
124
|
+
etype: string;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
importEntityTilmeldAC(entity: {
|
|
127
|
+
guid: string;
|
|
128
|
+
cdate: number;
|
|
129
|
+
mdate: number;
|
|
130
|
+
tags: string[];
|
|
131
|
+
sdata: SerializedEntityData;
|
|
132
|
+
etype: string;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
private importEntityInternal;
|
|
135
|
+
importUID({ name, value }: {
|
|
136
|
+
name: string;
|
|
137
|
+
value: number;
|
|
138
|
+
}): Promise<void>;
|
|
52
139
|
newUID(name: string): Promise<number>;
|
|
53
140
|
renameUID(oldName: string, newName: string): Promise<boolean>;
|
|
54
141
|
rollback(name: string): Promise<boolean>;
|
|
55
142
|
saveEntity(entity: EntityInterface): Promise<boolean>;
|
|
56
143
|
setUID(name: string, curUid: number): Promise<boolean>;
|
|
144
|
+
internalTransaction(name: string): Promise<void>;
|
|
57
145
|
startTransaction(name: string): Promise<import("@nymphjs/nymph").Nymph>;
|
|
146
|
+
private removeTilmeldOldRows;
|
|
147
|
+
needsMigration(): Promise<'json' | 'tokens' | 'tilmeldColumns' | false>;
|
|
148
|
+
liveMigration(migrationType: 'tokenTables' | 'tilmeldColumns' | 'tilmeldRemoveOldRows'): Promise<void>;
|
|
58
149
|
}
|
|
59
150
|
export {};
|