@cloudnux/aws-cloud-provider 0.17.0 → 0.18.0
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/dist/index.js +32 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -126276,6 +126276,16 @@ var PostToConnectionCommand = class extends Command10.classBuilder().ep(commonPa
|
|
|
126276
126276
|
}).s("ApiGatewayManagementApi", "PostToConnection", {}).n("ApiGatewayManagementApiClient", "PostToConnectionCommand").sc(PostToConnection$).build() {
|
|
126277
126277
|
};
|
|
126278
126278
|
|
|
126279
|
+
// ../core/dist/index.js
|
|
126280
|
+
var WebSocketConnectionGoneError = class extends Error {
|
|
126281
|
+
connectionId;
|
|
126282
|
+
constructor(connectionId) {
|
|
126283
|
+
super(`WebSocket connection ${connectionId} is gone`);
|
|
126284
|
+
this.name = "WebSocketConnectionGoneError";
|
|
126285
|
+
this.connectionId = connectionId;
|
|
126286
|
+
}
|
|
126287
|
+
};
|
|
126288
|
+
|
|
126279
126289
|
// src/services/websocket.ts
|
|
126280
126290
|
var _client = null;
|
|
126281
126291
|
function getClient(endpoint) {
|
|
@@ -126286,19 +126296,36 @@ function getClient(endpoint) {
|
|
|
126286
126296
|
}
|
|
126287
126297
|
return _client;
|
|
126288
126298
|
}
|
|
126299
|
+
function isGoneException(error) {
|
|
126300
|
+
return error instanceof Error && error.name === "GoneException";
|
|
126301
|
+
}
|
|
126289
126302
|
function createWebSocketService() {
|
|
126290
126303
|
return {
|
|
126291
126304
|
async sendToClient(connectionId, data) {
|
|
126292
126305
|
const client = getClient();
|
|
126293
126306
|
const payload = typeof data === "string" ? data : JSON.stringify(data);
|
|
126294
|
-
|
|
126295
|
-
|
|
126296
|
-
|
|
126297
|
-
|
|
126307
|
+
try {
|
|
126308
|
+
await client.send(new PostToConnectionCommand({
|
|
126309
|
+
ConnectionId: connectionId,
|
|
126310
|
+
Data: new TextEncoder().encode(payload)
|
|
126311
|
+
}));
|
|
126312
|
+
} catch (error) {
|
|
126313
|
+
if (isGoneException(error)) {
|
|
126314
|
+
throw new WebSocketConnectionGoneError(connectionId);
|
|
126315
|
+
}
|
|
126316
|
+
throw error;
|
|
126317
|
+
}
|
|
126298
126318
|
},
|
|
126299
126319
|
async disconnect(connectionId) {
|
|
126300
126320
|
const client = getClient();
|
|
126301
|
-
|
|
126321
|
+
try {
|
|
126322
|
+
await client.send(new DeleteConnectionCommand({ ConnectionId: connectionId }));
|
|
126323
|
+
} catch (error) {
|
|
126324
|
+
if (isGoneException(error)) {
|
|
126325
|
+
throw new WebSocketConnectionGoneError(connectionId);
|
|
126326
|
+
}
|
|
126327
|
+
throw error;
|
|
126328
|
+
}
|
|
126302
126329
|
}
|
|
126303
126330
|
};
|
|
126304
126331
|
}
|