@webiny/api-websockets-sql 6.6.0-alpha.12 → 6.6.0-alpha.14

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.
@@ -1,5 +1,5 @@
1
1
  import { KnexClient, SqlSchemaConfig, SqlSchemaSetup } from "@webiny/api-core-sql";
2
- import { ConnectionRegistry } from "@webiny/api-websockets/exports/api.js";
2
+ import { ConnectionRegistry } from "@webiny/api-websockets/features/ConnectionRegistry/abstractions.js";
3
3
  import { TableName } from "./TableName/abstractions.js";
4
4
  declare class WebsocketsConnectionRegistryImpl implements ConnectionRegistry.Interface {
5
5
  private readonly schemaConfig?;
@@ -24,7 +24,7 @@ declare class WebsocketsConnectionRegistryImpl implements ConnectionRegistry.Int
24
24
  private toData;
25
25
  }
26
26
  export declare const WebsocketsConnectionRegistry: typeof WebsocketsConnectionRegistryImpl & {
27
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-websockets/features/ConnectionRegistry/abstractions").IWebsocketsConnectionRegistry>;
27
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-websockets/features/ConnectionRegistry/abstractions.js").IWebsocketsConnectionRegistry>;
28
28
  };
29
29
  /** The `websockets` schema setup step: the connections table, created and migrated. */
30
30
  declare class WebsocketsSchemaSetupImpl implements SqlSchemaSetup.Interface {
@@ -1,6 +1,6 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { KnexClient, SqlSchemaConfig, SqlSchemaSetup } from "@webiny/api-core-sql";
3
- import { ConnectionRegistry } from "@webiny/api-websockets/exports/api.js";
3
+ import { ConnectionRegistry } from "@webiny/api-websockets/features/ConnectionRegistry/abstractions.js";
4
4
  import { TableName } from "./TableName/abstractions.js";
5
5
  import { toIsoString } from "./toIsoString.js";
6
6
  const BASE_TABLE_NAME = "WebsocketsConnections";
@@ -1 +1 @@
1
- {"version":3,"file":"WebsocketsConnectionRegistry.js","sources":["../src/WebsocketsConnectionRegistry.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { KnexClient, SqlSchemaConfig, SqlSchemaSetup } 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(\n knex: KnexClient.Interface,\n tableName: TableName.Interface,\n private readonly schemaConfig?: SqlSchemaConfig.Interface\n ) {\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 /* At runtime: nothing when the schema is managed (`SqlSchemaConfig`). */\n private async prepareTable(): Promise<void> {\n if (this.schemaConfig?.isManaged()) {\n return;\n }\n await this.setupSchema();\n }\n\n /* Creates and migrates the table, whatever the mode (deploy-time schema setup). */\n public async setupSchema(): 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, [SqlSchemaConfig, { optional: true }]]\n});\n\n/** The `websockets` schema setup step: the connections table, created and migrated. */\nclass WebsocketsSchemaSetupImpl implements SqlSchemaSetup.Interface {\n public readonly name = \"websockets\";\n\n public constructor(\n private readonly knex: KnexClient.Interface,\n private readonly tableName: TableName.Interface\n ) {}\n\n public setup(): Promise<void> {\n return new WebsocketsConnectionRegistryImpl(this.knex, this.tableName).setupSchema();\n }\n}\n\nexport const WebsocketsSchemaSetup = SqlSchemaSetup.createImplementation({\n implementation: WebsocketsSchemaSetupImpl,\n dependencies: [KnexClient, TableName]\n});\n"],"names":["BASE_TABLE_NAME","applyOnce","isDone","change","done","error","doneByAnotherCall","WebsocketsConnectionRegistryImpl","knex","tableName","schemaConfig","event","row","Date","err","WebinyError","existing","connections","rows","identity","tenant","connectionId","olderThan","threshold","qb","table","hasEndpoint","toIsoString","undefined","WebsocketsConnectionRegistry","ConnectionRegistry","KnexClient","TableName","SqlSchemaConfig","WebsocketsSchemaSetupImpl","WebsocketsSchemaSetup","SqlSchemaSetup"],"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,YACIC,IAA0B,EAC1BC,SAA8B,EACbC,YAAwC,CAC3D;aADmBA,YAAY,GAAZA;QAEjB,IAAI,CAAC,IAAI,GAAGF;QACZ,IAAI,CAAC,SAAS,GAAGC,UAAU,OAAO,CAACT;IACvC;IAEA,MAAa,SACTW,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;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AAI,GAAG;IAKpB;IAEI,QAAuB;QAC1B,OAAO,IAAIF,iCAAiC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW;IACtF;AACJ;AAEO,MAAM4B,wBAAwBC,eAAe,oBAAoB,CAAC;IACrE,gBAAgBF;IAChB,cAAc;QAACH;QAAYC;KAAU;AACzC"}
1
+ {"version":3,"file":"WebsocketsConnectionRegistry.js","sources":["../src/WebsocketsConnectionRegistry.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { KnexClient, SqlSchemaConfig, SqlSchemaSetup } from \"@webiny/api-core-sql\";\nimport { ConnectionRegistry } from \"@webiny/api-websockets/features/ConnectionRegistry/abstractions.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(\n knex: KnexClient.Interface,\n tableName: TableName.Interface,\n private readonly schemaConfig?: SqlSchemaConfig.Interface\n ) {\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 /* At runtime: nothing when the schema is managed (`SqlSchemaConfig`). */\n private async prepareTable(): Promise<void> {\n if (this.schemaConfig?.isManaged()) {\n return;\n }\n await this.setupSchema();\n }\n\n /* Creates and migrates the table, whatever the mode (deploy-time schema setup). */\n public async setupSchema(): 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, [SqlSchemaConfig, { optional: true }]]\n});\n\n/** The `websockets` schema setup step: the connections table, created and migrated. */\nclass WebsocketsSchemaSetupImpl implements SqlSchemaSetup.Interface {\n public readonly name = \"websockets\";\n\n public constructor(\n private readonly knex: KnexClient.Interface,\n private readonly tableName: TableName.Interface\n ) {}\n\n public setup(): Promise<void> {\n return new WebsocketsConnectionRegistryImpl(this.knex, this.tableName).setupSchema();\n }\n}\n\nexport const WebsocketsSchemaSetup = SqlSchemaSetup.createImplementation({\n implementation: WebsocketsSchemaSetupImpl,\n dependencies: [KnexClient, TableName]\n});\n"],"names":["BASE_TABLE_NAME","applyOnce","isDone","change","done","error","doneByAnotherCall","WebsocketsConnectionRegistryImpl","knex","tableName","schemaConfig","event","row","Date","err","WebinyError","existing","connections","rows","identity","tenant","connectionId","olderThan","threshold","qb","table","hasEndpoint","toIsoString","undefined","WebsocketsConnectionRegistry","ConnectionRegistry","KnexClient","TableName","SqlSchemaConfig","WebsocketsSchemaSetupImpl","WebsocketsSchemaSetup","SqlSchemaSetup"],"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,YACIC,IAA0B,EAC1BC,SAA8B,EACbC,YA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ae,YAAYf,IAAI,WAAW;YACxC,OAAOA,IAAI,KAAK,IAAIgB;QACxB;IACJ;AACJ;AAEO,MAAMC,+BAA+BC,mBAAmB,oBAAoB,CAAC;IAChF,gBAAgBvB;IAChB,cAAc;QAACwB;QAAYC;QAAW;YAACC;YAAiB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAChF;AAGA,MAAMC;IAGF,YACqB1B,IAA0B,EAC1BC,SAA8B,CACjD;aAFmBD,IAAI,GAAJA;aACAC,SAAS,GAATA;aAJL,IAAI,GAAG;IAKpB;IAEI,QAAuB;QAC1B,OAAO,IAAIF,iCAAiC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW;IACtF;AACJ;AAEO,MAAM4B,wBAAwBC,eAAe,oBAAoB,CAAC;IACrE,gBAAgBF;IAChB,cAAc;QAACH;QAAYC;KAAU;AACzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-websockets-sql",
3
- "version": "6.6.0-alpha.12",
3
+ "version": "6.6.0-alpha.14",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "@webiny/api-websockets",
@@ -20,20 +20,20 @@
20
20
  "./*": "./*"
21
21
  },
22
22
  "dependencies": {
23
- "@webiny/api-core-sql": "6.6.0-alpha.12",
24
- "@webiny/api-websockets": "6.6.0-alpha.12",
25
- "@webiny/error": "6.6.0-alpha.12",
26
- "@webiny/feature": "6.6.0-alpha.12",
23
+ "@webiny/api-core-sql": "6.6.0-alpha.14",
24
+ "@webiny/api-websockets": "6.6.0-alpha.14",
25
+ "@webiny/error": "6.6.0-alpha.14",
26
+ "@webiny/feature": "6.6.0-alpha.14",
27
27
  "knex": "3.3.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@webiny/api-core": "6.6.0-alpha.12",
31
- "@webiny/build-tools": "6.6.0-alpha.12",
30
+ "@webiny/api-core": "6.6.0-alpha.14",
31
+ "@webiny/build-tools": "6.6.0-alpha.14",
32
32
  "@webiny/di": "2.0.0",
33
- "better-sqlite3": "13.0.3",
34
- "rimraf": "6.1.3",
33
+ "better-sqlite3": "13.2.0",
34
+ "rimraf": "6.1.4",
35
35
  "typescript": "7.0.2",
36
- "vitest": "5.0.5"
36
+ "vitest": "5.1.1"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"