@webiny/api-websockets-sql 0.0.0-unstable.5387e5f7c8 → 0.0.0-unstable.7c2def32a7
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.
|
@@ -13,9 +13,12 @@ declare class WebsocketsConnectionRegistryImpl implements ConnectionRegistry.Int
|
|
|
13
13
|
listAll(): Promise<ConnectionRegistry.Data[]>;
|
|
14
14
|
updateLastSeen(connectionId: string): Promise<void>;
|
|
15
15
|
listStale(olderThan: Date): Promise<ConnectionRegistry.Data[]>;
|
|
16
|
+
private prepareTable;
|
|
16
17
|
private ensureTable;
|
|
18
|
+
private createTable;
|
|
17
19
|
private migrateTable;
|
|
18
20
|
private migrateLastSeen;
|
|
21
|
+
private migrateOwner;
|
|
19
22
|
private toData;
|
|
20
23
|
}
|
|
21
24
|
export declare const WebsocketsConnectionRegistry: typeof WebsocketsConnectionRegistryImpl & {
|
|
@@ -4,6 +4,17 @@ import { ConnectionRegistry } from "@webiny/api-websockets/exports/api.js";
|
|
|
4
4
|
import { TableName } from "./TableName/abstractions.js";
|
|
5
5
|
import { toIsoString } from "./toIsoString.js";
|
|
6
6
|
const BASE_TABLE_NAME = "WebsocketsConnections";
|
|
7
|
+
const applyOnce = async (isDone, change)=>{
|
|
8
|
+
const done = await isDone();
|
|
9
|
+
if (done) return;
|
|
10
|
+
try {
|
|
11
|
+
await change();
|
|
12
|
+
} catch (error) {
|
|
13
|
+
const doneByAnotherCall = await isDone();
|
|
14
|
+
if (doneByAnotherCall) return;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
7
18
|
class WebsocketsConnectionRegistryImpl {
|
|
8
19
|
constructor(knex, tableName){
|
|
9
20
|
this.knex = knex;
|
|
@@ -11,9 +22,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
11
22
|
}
|
|
12
23
|
async register(event) {
|
|
13
24
|
try {
|
|
14
|
-
await this.
|
|
15
|
-
await this.migrateTable();
|
|
16
|
-
await this.migrateLastSeen();
|
|
25
|
+
await this.prepareTable();
|
|
17
26
|
const row = {
|
|
18
27
|
connectionId: event.connectionId,
|
|
19
28
|
identityId: event.identity.id,
|
|
@@ -22,7 +31,8 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
22
31
|
tenant: event.tenant,
|
|
23
32
|
endpoint: event.endpoint,
|
|
24
33
|
connectedOn: event.connectedOn,
|
|
25
|
-
lastSeen: new Date().toISOString()
|
|
34
|
+
lastSeen: new Date().toISOString(),
|
|
35
|
+
owner: event.owner ?? null
|
|
26
36
|
};
|
|
27
37
|
await this.knex.client(this.tableName).insert(row);
|
|
28
38
|
return this.toData(row);
|
|
@@ -38,9 +48,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
38
48
|
}
|
|
39
49
|
async unregister(event) {
|
|
40
50
|
try {
|
|
41
|
-
await this.
|
|
42
|
-
await this.migrateTable();
|
|
43
|
-
await this.migrateLastSeen();
|
|
51
|
+
await this.prepareTable();
|
|
44
52
|
const existing = await this.knex.client(this.tableName).where("connectionId", event.connectionId).first();
|
|
45
53
|
if (!existing) throw new WebinyError(`Connection "${event.connectionId}" does not exist.`, "CONNECTION_NOT_FOUND", {
|
|
46
54
|
connectionId: event.connectionId
|
|
@@ -58,9 +66,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
58
66
|
}
|
|
59
67
|
async listViaConnections(connections) {
|
|
60
68
|
try {
|
|
61
|
-
await this.
|
|
62
|
-
await this.migrateTable();
|
|
63
|
-
await this.migrateLastSeen();
|
|
69
|
+
await this.prepareTable();
|
|
64
70
|
const rows = await this.knex.client(this.tableName).whereIn("connectionId", connections);
|
|
65
71
|
return rows.map((row)=>this.toData(row));
|
|
66
72
|
} catch (err) {
|
|
@@ -75,9 +81,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
75
81
|
}
|
|
76
82
|
async listViaIdentity(identity) {
|
|
77
83
|
try {
|
|
78
|
-
await this.
|
|
79
|
-
await this.migrateTable();
|
|
80
|
-
await this.migrateLastSeen();
|
|
84
|
+
await this.prepareTable();
|
|
81
85
|
const rows = await this.knex.client(this.tableName).where("identityId", identity);
|
|
82
86
|
return rows.map((row)=>this.toData(row));
|
|
83
87
|
} catch (err) {
|
|
@@ -92,9 +96,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
92
96
|
}
|
|
93
97
|
async listViaTenant(tenant) {
|
|
94
98
|
try {
|
|
95
|
-
await this.
|
|
96
|
-
await this.migrateTable();
|
|
97
|
-
await this.migrateLastSeen();
|
|
99
|
+
await this.prepareTable();
|
|
98
100
|
const rows = await this.knex.client(this.tableName).where("tenant", tenant);
|
|
99
101
|
return rows.map((row)=>this.toData(row));
|
|
100
102
|
} catch (err) {
|
|
@@ -109,9 +111,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
109
111
|
}
|
|
110
112
|
async listAll() {
|
|
111
113
|
try {
|
|
112
|
-
await this.
|
|
113
|
-
await this.migrateTable();
|
|
114
|
-
await this.migrateLastSeen();
|
|
114
|
+
await this.prepareTable();
|
|
115
115
|
const rows = await this.knex.client(this.tableName).select("*");
|
|
116
116
|
return rows.map((row)=>this.toData(row));
|
|
117
117
|
} catch (err) {
|
|
@@ -123,9 +123,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
123
123
|
}
|
|
124
124
|
async updateLastSeen(connectionId) {
|
|
125
125
|
try {
|
|
126
|
-
await this.
|
|
127
|
-
await this.migrateTable();
|
|
128
|
-
await this.migrateLastSeen();
|
|
126
|
+
await this.prepareTable();
|
|
129
127
|
await this.knex.client(this.tableName).where("connectionId", connectionId).update({
|
|
130
128
|
lastSeen: new Date().toISOString()
|
|
131
129
|
});
|
|
@@ -141,9 +139,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
141
139
|
}
|
|
142
140
|
async listStale(olderThan) {
|
|
143
141
|
try {
|
|
144
|
-
await this.
|
|
145
|
-
await this.migrateTable();
|
|
146
|
-
await this.migrateLastSeen();
|
|
142
|
+
await this.prepareTable();
|
|
147
143
|
const threshold = olderThan.toISOString();
|
|
148
144
|
const rows = await this.knex.client(this.tableName).where((qb)=>{
|
|
149
145
|
qb.where("lastSeen", "<", threshold).orWhereNull("lastSeen");
|
|
@@ -159,9 +155,16 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
159
155
|
});
|
|
160
156
|
}
|
|
161
157
|
}
|
|
158
|
+
async prepareTable() {
|
|
159
|
+
await this.ensureTable();
|
|
160
|
+
await this.migrateTable();
|
|
161
|
+
await this.migrateLastSeen();
|
|
162
|
+
await this.migrateOwner();
|
|
163
|
+
}
|
|
162
164
|
async ensureTable() {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
await applyOnce(()=>this.knex.client.schema.hasTable(this.tableName), ()=>this.createTable());
|
|
166
|
+
}
|
|
167
|
+
async createTable() {
|
|
165
168
|
await this.knex.client.schema.createTable(this.tableName, (table)=>{
|
|
166
169
|
table.text("connectionId").notNullable().primary();
|
|
167
170
|
table.text("identityId").notNullable();
|
|
@@ -171,6 +174,7 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
171
174
|
table.text("endpoint").notNullable();
|
|
172
175
|
table.datetime("connectedOn").notNullable();
|
|
173
176
|
table.datetime("lastSeen").nullable();
|
|
177
|
+
table.text("owner").nullable();
|
|
174
178
|
table.index([
|
|
175
179
|
"identityId"
|
|
176
180
|
]);
|
|
@@ -195,11 +199,14 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
195
199
|
});
|
|
196
200
|
}
|
|
197
201
|
async migrateLastSeen() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
await applyOnce(()=>this.knex.client.schema.hasColumn(this.tableName, "lastSeen"), ()=>this.knex.client.schema.alterTable(this.tableName, (table)=>{
|
|
203
|
+
table.datetime("lastSeen").nullable();
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
async migrateOwner() {
|
|
207
|
+
await applyOnce(()=>this.knex.client.schema.hasColumn(this.tableName, "owner"), ()=>this.knex.client.schema.alterTable(this.tableName, (table)=>{
|
|
208
|
+
table.text("owner").nullable();
|
|
209
|
+
}));
|
|
203
210
|
}
|
|
204
211
|
toData(row) {
|
|
205
212
|
return {
|
|
@@ -211,7 +218,8 @@ class WebsocketsConnectionRegistryImpl {
|
|
|
211
218
|
},
|
|
212
219
|
tenant: row.tenant,
|
|
213
220
|
endpoint: row.endpoint,
|
|
214
|
-
connectedOn: toIsoString(row.connectedOn)
|
|
221
|
+
connectedOn: toIsoString(row.connectedOn),
|
|
222
|
+
owner: row.owner ?? void 0
|
|
215
223
|
};
|
|
216
224
|
}
|
|
217
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketsConnectionRegistry.js","sources":["../src/WebsocketsConnectionRegistry.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { ConnectionRegistry } from \"@webiny/api-websockets/exports/api.js\";\nimport { TableName } from \"~/TableName/abstractions.js\";\nimport { toIsoString } from \"~/toIsoString.js\";\n\ninterface ConnectionRow {\n connectionId: string;\n identityId: string;\n identityDisplayName: string;\n identityType: string;\n tenant: string;\n endpoint: string;\n connectedOn: string;\n lastSeen: string | null;\n}\n\nconst BASE_TABLE_NAME = \"WebsocketsConnections\";\n\nclass WebsocketsConnectionRegistryImpl implements ConnectionRegistry.Interface {\n private readonly knex;\n private readonly tableName;\n\n public constructor(knex: KnexClient.Interface, tableName: TableName.Interface) {\n this.knex = knex;\n this.tableName = tableName.resolve(BASE_TABLE_NAME);\n }\n\n public async register(\n event: ConnectionRegistry.RegisterParams\n ): Promise<ConnectionRegistry.Data> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const row: ConnectionRow = {\n connectionId: event.connectionId,\n identityId: event.identity.id,\n identityDisplayName: event.identity.displayName,\n identityType: event.identity.type,\n tenant: event.tenant,\n endpoint: event.endpoint,\n connectedOn: event.connectedOn,\n lastSeen: new Date().toISOString()\n };\n\n await this.knex.client<ConnectionRow>(this.tableName).insert(row);\n\n return this.toData(row);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not register websockets connection.\",\n code: \"REGISTER_CONNECTION_ERROR\",\n data: { event }\n });\n }\n }\n\n public async unregister(event: ConnectionRegistry.UnregisterParams): Promise<void> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const existing = await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"connectionId\", event.connectionId)\n .first();\n\n if (!existing) {\n throw new WebinyError(\n `Connection \"${event.connectionId}\" does not exist.`,\n \"CONNECTION_NOT_FOUND\",\n { connectionId: event.connectionId }\n );\n }\n\n await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"connectionId\", event.connectionId)\n .delete();\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not unregister websockets connection.\",\n code: \"UNREGISTER_CONNECTION_ERROR\",\n data: { event }\n });\n }\n }\n\n public async listViaConnections(connections: string[]): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const rows = await this.knex\n .client<ConnectionRow>(this.tableName)\n .whereIn(\"connectionId\", connections);\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list websockets connections by connection IDs.\",\n code: \"LIST_VIA_CONNECTIONS_ERROR\",\n data: { connections }\n });\n }\n }\n\n public async listViaIdentity(identity: string): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const rows = await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"identityId\", identity);\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list websockets connections by identity.\",\n code: \"LIST_VIA_IDENTITY_ERROR\",\n data: { identity }\n });\n }\n }\n\n public async listViaTenant(tenant: string): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const rows = await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"tenant\", tenant);\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list websockets connections by tenant.\",\n code: \"LIST_VIA_TENANT_ERROR\",\n data: { tenant }\n });\n }\n }\n\n public async listAll(): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const rows = await this.knex.client<ConnectionRow>(this.tableName).select(\"*\");\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list all websockets connections.\",\n code: \"LIST_ALL_CONNECTIONS_ERROR\"\n });\n }\n }\n\n public async updateLastSeen(connectionId: string): Promise<void> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"connectionId\", connectionId)\n .update({ lastSeen: new Date().toISOString() });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update lastSeen for websockets connection.\",\n code: \"UPDATE_LAST_SEEN_ERROR\",\n data: { connectionId }\n });\n }\n }\n\n public async listStale(olderThan: Date): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n\n const threshold = olderThan.toISOString();\n\n const rows = await this.knex.client<ConnectionRow>(this.tableName).where(qb => {\n qb.where(\"lastSeen\", \"<\", threshold).orWhereNull(\"lastSeen\");\n });\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list stale websockets connections.\",\n code: \"LIST_STALE_CONNECTIONS_ERROR\",\n data: { olderThan }\n });\n }\n }\n\n private async ensureTable(): Promise<void> {\n const exists = await this.knex.client.schema.hasTable(this.tableName);\n if (exists) {\n return;\n }\n\n await this.knex.client.schema.createTable(this.tableName, table => {\n table.text(\"connectionId\").notNullable().primary();\n table.text(\"identityId\").notNullable();\n table.text(\"identityDisplayName\").notNullable();\n table.text(\"identityType\").notNullable();\n table.text(\"tenant\").notNullable();\n table.text(\"endpoint\").notNullable();\n table.datetime(\"connectedOn\").notNullable();\n table.datetime(\"lastSeen\").nullable();\n table.index([\"identityId\"]);\n table.index([\"tenant\"]);\n });\n }\n\n private async migrateTable(): Promise<void> {\n const hasEndpoint = await this.knex.client.schema.hasColumn(this.tableName, \"endpoint\");\n if (hasEndpoint) {\n return;\n }\n\n await this.knex.client.schema.alterTable(this.tableName, table => {\n table.text(\"endpoint\").nullable();\n });\n\n await this.knex.client(this.tableName).update({\n endpoint: this.knex.client.raw(\"'https://' || \\\"domainName\\\" || '/' || \\\"stage\\\"\")\n });\n\n await this.knex.client.schema.alterTable(this.tableName, table => {\n table.text(\"endpoint\").notNullable().alter();\n table.dropColumn(\"domainName\");\n table.dropColumn(\"stage\");\n });\n }\n\n private async migrateLastSeen(): Promise<void> {\n const hasLastSeen = await this.knex.client.schema.hasColumn(this.tableName, \"lastSeen\");\n if (hasLastSeen) {\n return;\n }\n\n await this.knex.client.schema.alterTable(this.tableName, table => {\n table.datetime(\"lastSeen\").nullable();\n });\n }\n\n private toData(row: ConnectionRow): ConnectionRegistry.Data {\n return {\n connectionId: row.connectionId,\n identity: {\n id: row.identityId,\n displayName: row.identityDisplayName,\n type: row.identityType\n },\n tenant: row.tenant,\n endpoint: row.endpoint,\n connectedOn: toIsoString(row.connectedOn)\n };\n }\n}\n\nexport const WebsocketsConnectionRegistry = ConnectionRegistry.createImplementation({\n implementation: WebsocketsConnectionRegistryImpl,\n dependencies: [KnexClient, TableName]\n});\n"],"names":["BASE_TABLE_NAME","WebsocketsConnectionRegistryImpl","knex","tableName","event","row","Date","err","WebinyError","existing","connections","rows","identity","tenant","connectionId","olderThan","threshold","qb","exists","table","hasEndpoint","hasLastSeen","toIsoString","WebsocketsConnectionRegistry","Connection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AAmB,oBAAoB,CAAC;IAChF,gBAAgBvB;IAChB,cAAc;QAACwB;QAAYC;KAAU;AACzC"}
|
|
1
|
+
{"version":3,"file":"WebsocketsConnectionRegistry.js","sources":["../src/WebsocketsConnectionRegistry.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { ConnectionRegistry } from \"@webiny/api-websockets/exports/api.js\";\nimport { TableName } from \"~/TableName/abstractions.js\";\nimport { toIsoString } from \"~/toIsoString.js\";\n\ninterface ConnectionRow {\n connectionId: string;\n identityId: string;\n identityDisplayName: string;\n identityType: string;\n tenant: string;\n endpoint: string;\n connectedOn: string;\n lastSeen: string | null;\n owner: string | null;\n}\n\nconst BASE_TABLE_NAME = \"WebsocketsConnections\";\n\n/*\n * Runs `change` unless `isDone` already holds. After an upgrade every browser reconnects at once, so\n * several calls, in one process or in several, can find the same table or column missing; all but\n * the first then fail because it exists by now. A failure after which `isDone` holds was one of\n * those and is not an error.\n */\nconst applyOnce = async (\n isDone: () => Promise<boolean>,\n change: () => Promise<unknown>\n): Promise<void> => {\n const done = await isDone();\n if (done) {\n return;\n }\n try {\n await change();\n } catch (error) {\n const doneByAnotherCall = await isDone();\n if (doneByAnotherCall) {\n return;\n }\n throw error;\n }\n};\n\nclass WebsocketsConnectionRegistryImpl implements ConnectionRegistry.Interface {\n private readonly knex;\n private readonly tableName;\n\n public constructor(knex: KnexClient.Interface, tableName: TableName.Interface) {\n this.knex = knex;\n this.tableName = tableName.resolve(BASE_TABLE_NAME);\n }\n\n public async register(\n event: ConnectionRegistry.RegisterParams\n ): Promise<ConnectionRegistry.Data> {\n try {\n await this.prepareTable();\n\n const row: ConnectionRow = {\n connectionId: event.connectionId,\n identityId: event.identity.id,\n identityDisplayName: event.identity.displayName,\n identityType: event.identity.type,\n tenant: event.tenant,\n endpoint: event.endpoint,\n connectedOn: event.connectedOn,\n lastSeen: new Date().toISOString(),\n owner: event.owner ?? null\n };\n\n await this.knex.client<ConnectionRow>(this.tableName).insert(row);\n\n return this.toData(row);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not register websockets connection.\",\n code: \"REGISTER_CONNECTION_ERROR\",\n data: { event }\n });\n }\n }\n\n public async unregister(event: ConnectionRegistry.UnregisterParams): Promise<void> {\n try {\n await this.prepareTable();\n\n const existing = await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"connectionId\", event.connectionId)\n .first();\n\n if (!existing) {\n throw new WebinyError(\n `Connection \"${event.connectionId}\" does not exist.`,\n \"CONNECTION_NOT_FOUND\",\n { connectionId: event.connectionId }\n );\n }\n\n await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"connectionId\", event.connectionId)\n .delete();\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not unregister websockets connection.\",\n code: \"UNREGISTER_CONNECTION_ERROR\",\n data: { event }\n });\n }\n }\n\n public async listViaConnections(connections: string[]): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.prepareTable();\n\n const rows = await this.knex\n .client<ConnectionRow>(this.tableName)\n .whereIn(\"connectionId\", connections);\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list websockets connections by connection IDs.\",\n code: \"LIST_VIA_CONNECTIONS_ERROR\",\n data: { connections }\n });\n }\n }\n\n public async listViaIdentity(identity: string): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.prepareTable();\n\n const rows = await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"identityId\", identity);\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list websockets connections by identity.\",\n code: \"LIST_VIA_IDENTITY_ERROR\",\n data: { identity }\n });\n }\n }\n\n public async listViaTenant(tenant: string): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.prepareTable();\n\n const rows = await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"tenant\", tenant);\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list websockets connections by tenant.\",\n code: \"LIST_VIA_TENANT_ERROR\",\n data: { tenant }\n });\n }\n }\n\n public async listAll(): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.prepareTable();\n\n const rows = await this.knex.client<ConnectionRow>(this.tableName).select(\"*\");\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list all websockets connections.\",\n code: \"LIST_ALL_CONNECTIONS_ERROR\"\n });\n }\n }\n\n public async updateLastSeen(connectionId: string): Promise<void> {\n try {\n await this.prepareTable();\n\n await this.knex\n .client<ConnectionRow>(this.tableName)\n .where(\"connectionId\", connectionId)\n .update({ lastSeen: new Date().toISOString() });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update lastSeen for websockets connection.\",\n code: \"UPDATE_LAST_SEEN_ERROR\",\n data: { connectionId }\n });\n }\n }\n\n public async listStale(olderThan: Date): Promise<ConnectionRegistry.Data[]> {\n try {\n await this.prepareTable();\n\n const threshold = olderThan.toISOString();\n\n const rows = await this.knex.client<ConnectionRow>(this.tableName).where(qb => {\n qb.where(\"lastSeen\", \"<\", threshold).orWhereNull(\"lastSeen\");\n });\n\n return rows.map(row => this.toData(row));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list stale websockets connections.\",\n code: \"LIST_STALE_CONNECTIONS_ERROR\",\n data: { olderThan }\n });\n }\n }\n\n private async prepareTable(): Promise<void> {\n await this.ensureTable();\n await this.migrateTable();\n await this.migrateLastSeen();\n await this.migrateOwner();\n }\n\n /*\n * `schema` is read fresh in each call below: it is a new builder on every read, and one builder\n * reused would run the statements queued on it before.\n */\n private async ensureTable(): Promise<void> {\n await applyOnce(\n () => this.knex.client.schema.hasTable(this.tableName),\n () => this.createTable()\n );\n }\n\n private async createTable(): Promise<void> {\n await this.knex.client.schema.createTable(this.tableName, table => {\n table.text(\"connectionId\").notNullable().primary();\n table.text(\"identityId\").notNullable();\n table.text(\"identityDisplayName\").notNullable();\n table.text(\"identityType\").notNullable();\n table.text(\"tenant\").notNullable();\n table.text(\"endpoint\").notNullable();\n table.datetime(\"connectedOn\").notNullable();\n table.datetime(\"lastSeen\").nullable();\n table.text(\"owner\").nullable();\n table.index([\"identityId\"]);\n table.index([\"tenant\"]);\n });\n }\n\n private async migrateTable(): Promise<void> {\n const hasEndpoint = await this.knex.client.schema.hasColumn(this.tableName, \"endpoint\");\n if (hasEndpoint) {\n return;\n }\n\n await this.knex.client.schema.alterTable(this.tableName, table => {\n table.text(\"endpoint\").nullable();\n });\n\n await this.knex.client(this.tableName).update({\n endpoint: this.knex.client.raw(\"'https://' || \\\"domainName\\\" || '/' || \\\"stage\\\"\")\n });\n\n await this.knex.client.schema.alterTable(this.tableName, table => {\n table.text(\"endpoint\").notNullable().alter();\n table.dropColumn(\"domainName\");\n table.dropColumn(\"stage\");\n });\n }\n\n private async migrateLastSeen(): Promise<void> {\n await applyOnce(\n () => this.knex.client.schema.hasColumn(this.tableName, \"lastSeen\"),\n () => {\n return this.knex.client.schema.alterTable(this.tableName, table => {\n table.datetime(\"lastSeen\").nullable();\n });\n }\n );\n }\n\n private async migrateOwner(): Promise<void> {\n await applyOnce(\n () => this.knex.client.schema.hasColumn(this.tableName, \"owner\"),\n () => {\n return this.knex.client.schema.alterTable(this.tableName, table => {\n table.text(\"owner\").nullable();\n });\n }\n );\n }\n\n private toData(row: ConnectionRow): ConnectionRegistry.Data {\n return {\n connectionId: row.connectionId,\n identity: {\n id: row.identityId,\n displayName: row.identityDisplayName,\n type: row.identityType\n },\n tenant: row.tenant,\n endpoint: row.endpoint,\n connectedOn: toIsoString(row.connectedOn),\n owner: row.owner ?? undefined\n };\n }\n}\n\nexport const WebsocketsConnectionRegistry = ConnectionRegistry.createImplementation({\n implementation: WebsocketsConnectionRegistryImpl,\n dependencies: [KnexClient, TableName]\n});\n"],"names":["BASE_TABLE_NAME","applyOnce","isDone","change","done","error","doneByAnotherCall","WebsocketsConnectionRegistryImpl","knex","tableName","event","row","Date","err","WebinyError","existing","connections","rows","identity","tenant","connectionId","olderThan","threshold","qb","table","hasEndpoint","toIsoString","undefined","WebsocketsConnectionRegistry","ConnectionRegistry","KnexClient","TableName"],"mappings":";;;;;AAkBA,MAAMA,kBAAkB;AAQxB,MAAMC,YAAY,OACdC,QACAC;IAEA,MAAMC,OAAO,MAAMF;IACnB,IAAIE,MACA;IAEJ,IAAI;QACA,MAAMD;IACV,EAAE,OAAOE,OAAO;QACZ,MAAMC,oBAAoB,MAAMJ;QAChC,IAAII,mBACA;QAEJ,MAAMD;IACV;AACJ;AAEA,MAAME;IAIF,YAAmBC,IAA0B,EAAEC,SAA8B,CAAE;QAC3E,IAAI,CAAC,IAAI,GAAGD;QACZ,IAAI,CAAC,SAAS,GAAGC,UAAU,OAAO,CAACT;IACvC;IAEA,MAAa,SACTU,KAAwC,EACR;QAChC,IAAI;YACA,MAAM,IAAI,CAAC,YAAY;YAEvB,MAAMC,MAAqB;gBACvB,cAAcD,MAAM,YAAY;gBAChC,YAAYA,MAAM,QAAQ,CAAC,EAAE;gBAC7B,qBAAqBA,MAAM,QAAQ,CAAC,WAAW;gBAC/C,cAAcA,MAAM,QAAQ,CAAC,IAAI;gBACjC,QAAQA,MAAM,MAAM;gBACpB,UAAUA,MAAM,QAAQ;gBACxB,aAAaA,MAAM,WAAW;gBAC9B,UAAU,IAAIE,OAAO,WAAW;gBAChC,OAAOF,MAAM,KAAK,IAAI;YAC1B;YAEA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,CAACC;YAE7D,OAAO,IAAI,CAAC,MAAM,CAACA;QACvB,EAAE,OAAOE,KAAK;YACV,MAAMC,YAAY,IAAI,CAACD,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAM;oBAAEH;gBAAM;YAClB;QACJ;IACJ;IAEA,MAAa,WAAWA,KAA0C,EAAiB;QAC/E,IAAI;YACA,MAAM,IAAI,CAAC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EuB,CAAAA;gBACtDA,MAAM,IAAI,CAAC,SAAS,QAAQ;YAChC;IAGZ;IAEQ,OAAOb,GAAkB,EAA2B;QACxD,OAAO;YACH,cAAcA,IAAI,YAAY;YAC9B,UAAU;gBACN,IAAIA,IAAI,UAAU;gBAClB,aAAaA,IAAI,mBAAmB;gBACpC,MAAMA,IAAI,YAAY;YAC1B;YACA,QAAQA,IAAI,MAAM;YAClB,UAAUA,IAAI,QAAQ;YACtB,aAAae,YAAYf,IAAI,WAAW;YACxC,OAAOA,IAAI,KAAK,IAAIgB;QACxB;IACJ;AACJ;AAEO,MAAMC,+BAA+BC,mBAAmB,oBAAoB,CAAC;IAChF,gBAAgBtB;IAChB,cAAc;QAACuB;QAAYC;KAAU;AACzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-websockets-sql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7c2def32a7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-websockets",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"./*": "./*"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@webiny/api-core-sql": "0.0.0-unstable.
|
|
24
|
-
"@webiny/api-websockets": "0.0.0-unstable.
|
|
25
|
-
"@webiny/error": "0.0.0-unstable.
|
|
26
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
23
|
+
"@webiny/api-core-sql": "0.0.0-unstable.7c2def32a7",
|
|
24
|
+
"@webiny/api-websockets": "0.0.0-unstable.7c2def32a7",
|
|
25
|
+
"@webiny/error": "0.0.0-unstable.7c2def32a7",
|
|
26
|
+
"@webiny/feature": "0.0.0-unstable.7c2def32a7",
|
|
27
27
|
"knex": "3.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
31
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
30
|
+
"@webiny/api-core": "0.0.0-unstable.7c2def32a7",
|
|
31
|
+
"@webiny/build-tools": "0.0.0-unstable.7c2def32a7",
|
|
32
32
|
"@webiny/di": "2.0.0",
|
|
33
33
|
"better-sqlite3": "13.0.3",
|
|
34
34
|
"rimraf": "6.1.3",
|