@mstuercke/api-utils 3.1.1 → 4.0.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.
@@ -1,4 +1,3 @@
1
1
  import { WsApiConnection } from '../types';
2
- export type SendResponseResult = 'SUCCESS' | 'CONNECTION_CLOSED';
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;AAExD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,mBAAmB,CAAA;AAChE,eAAO,MAAM,YAAY,0DAAoE,eAAe,iDAA8C,OAAO,KAAU,QAAQ,kBAAkB,CAepM,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;AAExD,eAAO,MAAM,YAAY,2DAKpB,eAAe,2BAAuB,QAAQ,IAAI,CAOtD,CAAC"}
@@ -1,16 +1,8 @@
1
1
  import { ApiGatewayManagementApiClient, PostToConnectionCommand } from '@aws-sdk/client-apigatewaymanagementapi';
2
- export const sendResponse = async ({ endpoint, connectionId }, response, ignoreClosedConnection = true) => {
3
- try {
4
- await new ApiGatewayManagementApiClient({ endpoint }).send(new PostToConnectionCommand({
5
- ConnectionId: connectionId,
6
- Data: JSON.stringify(response),
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
- }
2
+ export const sendResponse = async ({ endpoint, connectionId, }, response) => {
3
+ await new ApiGatewayManagementApiClient({ endpoint }).send(new PostToConnectionCommand({
4
+ ConnectionId: connectionId,
5
+ Data: JSON.stringify(response),
6
+ }));
15
7
  };
16
8
  //# sourceMappingURL=sendResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendResponse.js","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAE,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAI/G,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAkC,EAAC,QAAQ,EAAE,YAAY,EAAkB,EAAE,QAAkB,EAAE,yBAAkC,IAAI,EAA+B,EAAE;IACvM,IAAI,CAAC;QACH,MAAM,IAAI,6BAA6B,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,IAAI,CACpD,IAAI,uBAAuB,CAAC;YAC1B,YAAY,EAAE,YAAY;YAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;SAC/B,CAAC,CACL,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,sBAAsB,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,EAAE,IAAI,KAAK,eAAe;YACpH,OAAO,mBAAmB,CAAC;QAE7B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
1
+ {"version":3,"file":"sendResponse.js","sourceRoot":"","sources":["../../../src/ws/server/sendResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,6BAA6B,EAAE,uBAAuB,EAAC,MAAM,yCAAyC,CAAC;AAG/G,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAE/B,EACE,QAAQ,EACR,YAAY,GACI,EAAE,QAAkB,EAAiB,EAAE;IACzD,MAAM,IAAI,6BAA6B,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,IAAI,CACpD,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<SendResponseResult>;
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,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAC7C,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,kBAAkB,CAAC,CAAA;IACtG,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mstuercke/api-utils",
3
- "version": "3.1.1",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**/*.js",