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