@mstuercke/api-utils 3.1.1 → 4.1.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/ws/server/closeConnection.d.ts.map +1 -1
- package/dist/ws/server/closeConnection.js +3 -2
- package/dist/ws/server/closeConnection.js.map +1 -1
- package/dist/ws/server/getApiGatewayManagementApiClient.d.ts +3 -0
- package/dist/ws/server/getApiGatewayManagementApiClient.d.ts.map +1 -0
- package/dist/ws/server/getApiGatewayManagementApiClient.js +10 -0
- package/dist/ws/server/getApiGatewayManagementApiClient.js.map +1 -0
- package/dist/ws/server/sendResponse.d.ts +1 -2
- package/dist/ws/server/sendResponse.d.ts.map +1 -1
- package/dist/ws/server/sendResponse.js +7 -14
- package/dist/ws/server/sendResponse.js.map +1 -1
- package/dist/ws/types/WsApiRequestHandler.d.ts +1 -2
- package/dist/ws/types/WsApiRequestHandler.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeConnection.d.ts","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"closeConnection.d.ts","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAGzC,eAAO,MAAM,eAAe,+BAAoC,eAAe,kBAW9E,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeleteConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
|
|
2
|
+
import { getApiGatewayManagementApiClient } from './getApiGatewayManagementApiClient';
|
|
2
3
|
export const closeConnection = async ({ endpoint, connectionId }) => {
|
|
3
4
|
try {
|
|
4
|
-
await
|
|
5
|
+
await getApiGatewayManagementApiClient(endpoint).send(new DeleteConnectionCommand({ ConnectionId: connectionId }));
|
|
5
6
|
}
|
|
6
7
|
catch (err) {
|
|
7
8
|
if (err && typeof err === 'object' && 'name' in err && err?.name === 'GoneException')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeConnection.js","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"closeConnection.js","sourceRoot":"","sources":["../../../src/ws/server/closeConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAEhF,OAAO,EAAC,gCAAgC,EAAC,MAAM,oCAAoC,CAAC;AAEpF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAAC,QAAQ,EAAE,YAAY,EAAkB,EAAE,EAAE;IACjF,IAAI,CAAC;QACH,MAAM,gCAAgC,CAAC,QAAQ,CAAC,CAAC,IAAI,CACjD,IAAI,uBAAuB,CAAC,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC,CAC5D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,IAAI,KAAK,eAAe;YAClF,OAAO;QAET,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getApiGatewayManagementApiClient.d.ts","sourceRoot":"","sources":["../../../src/ws/server/getApiGatewayManagementApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AAGtF,eAAO,MAAM,gCAAgC,aAAc,MAAM,KAAG,6BAOnE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiGatewayManagementApiClient } from '@aws-sdk/client-apigatewaymanagementapi';
|
|
2
|
+
const clients = {};
|
|
3
|
+
export const getApiGatewayManagementApiClient = (endpoint) => {
|
|
4
|
+
if (clients[endpoint])
|
|
5
|
+
return clients[endpoint];
|
|
6
|
+
const client = new ApiGatewayManagementApiClient({ endpoint });
|
|
7
|
+
clients[endpoint] = client;
|
|
8
|
+
return client;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=getApiGatewayManagementApiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getApiGatewayManagementApiClient.js","sourceRoot":"","sources":["../../../src/ws/server/getApiGatewayManagementApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAC,MAAM,yCAAyC,CAAC;AAEtF,MAAM,OAAO,GAA0D,EAAE,CAAC;AAC1E,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,QAAgB,EAAiC,EAAE;IAClG,IAAI,OAAO,CAAC,QAAQ,CAAC;QACnB,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,MAAM,GAAG,IAAI,6BAA6B,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC;IAC7D,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;IAC3B,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { WsApiConnection } from '../types';
|
|
2
|
-
export
|
|
3
|
-
export declare const sendResponse: <Response_1 extends object>({ endpoint, connectionId }: WsApiConnection, response: Response_1, ignoreClosedConnection?: boolean) => Promise<SendResponseResult>;
|
|
2
|
+
export declare const sendResponse: <Response_1 extends object>({ endpoint, connectionId, }: WsApiConnection, response: Response_1) => Promise<void>;
|
|
4
3
|
//# sourceMappingURL=sendResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendResponse.d.ts","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sendResponse.d.ts","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,MAAM,UAAU,CAAC;AAGxD,eAAO,MAAM,YAAY,2DAKpB,eAAe,2BAAuB,QAAQ,IAAI,CAOtD,CAAC"}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return 'SUCCESS';
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
if (ignoreClosedConnection && error && typeof error === 'object' && 'name' in error && error?.name === 'GoneException')
|
|
12
|
-
return 'CONNECTION_CLOSED';
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
1
|
+
import { PostToConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
|
|
2
|
+
import { getApiGatewayManagementApiClient } from './getApiGatewayManagementApiClient';
|
|
3
|
+
export const sendResponse = async ({ endpoint, connectionId, }, response) => {
|
|
4
|
+
await getApiGatewayManagementApiClient(endpoint).send(new PostToConnectionCommand({
|
|
5
|
+
ConnectionId: connectionId,
|
|
6
|
+
Data: JSON.stringify(response),
|
|
7
|
+
}));
|
|
15
8
|
};
|
|
16
9
|
//# sourceMappingURL=sendResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendResponse.js","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"sendResponse.js","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAEhF,OAAO,EAAC,gCAAgC,EAAC,MAAM,oCAAoC,CAAC;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAE/B,EACE,QAAQ,EACR,YAAY,GACI,EAAE,QAAkB,EAAiB,EAAE;IACzD,MAAM,gCAAgC,CAAC,QAAQ,CAAC,CAAC,IAAI,CACjD,IAAI,uBAAuB,CAAC;QAC1B,YAAY,EAAE,YAAY;QAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;KAC/B,CAAC,CACL,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { OmitNever } from '../../types/OmitNever';
|
|
2
|
-
import { SendResponseResult } from '../server';
|
|
3
2
|
import { WsApiConnection } from './WsApiConnection';
|
|
4
3
|
import { WsApiAction, WsApiRequest, WsApiResponse } from './common';
|
|
5
4
|
export type WsApiRequestHandler<Action extends WsApiAction, Request extends WsApiRequest, Response extends WsApiResponse> = (request: Request & {
|
|
6
5
|
action: Action;
|
|
7
6
|
}, responseActions: OmitNever<{
|
|
8
7
|
connection: WsApiConnection;
|
|
9
|
-
sendResponse: [Response] extends [never] ? never : (response: Response) => Promise<
|
|
8
|
+
sendResponse: [Response] extends [never] ? never : (response: Response) => Promise<void>;
|
|
10
9
|
closeConnection: () => Promise<void>;
|
|
11
10
|
}>) => Promise<void>;
|
|
12
11
|
//# sourceMappingURL=WsApiRequestHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WsApiRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/ws/types/WsApiRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"WsApiRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/ws/types/WsApiRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAElE,MAAM,MAAM,mBAAmB,CAC3B,MAAM,SAAS,WAAW,EAC1B,OAAO,SAAS,YAAY,EAC5B,QAAQ,SAAS,aAAa,IAC9B,CAAC,OAAO,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,eAAe,EAAE,SAAS,CAAC;IACrE,UAAU,EAAE,eAAe,CAAA;IAC3B,YAAY,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACxF,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
|