@webiny/api-websockets 0.0.0-unstable.7be00a75a9 → 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.
Files changed (160) hide show
  1. package/WebsocketsFeature.d.ts +4 -0
  2. package/WebsocketsFeature.js +23 -0
  3. package/WebsocketsFeature.js.map +1 -0
  4. package/exports/api.d.ts +11 -1
  5. package/exports/api.js +10 -5
  6. package/{registry/abstractions/IWebsocketsConnectionRegistry.d.ts → features/ConnectionRegistry/abstractions.d.ts} +15 -8
  7. package/features/ConnectionRegistry/abstractions.js +5 -0
  8. package/features/ConnectionRegistry/abstractions.js.map +1 -0
  9. package/features/Disconnect/DisconnectUseCase.d.ts +17 -0
  10. package/features/Disconnect/DisconnectUseCase.js +45 -0
  11. package/features/Disconnect/DisconnectUseCase.js.map +1 -0
  12. package/features/Disconnect/abstractions.d.ts +13 -0
  13. package/features/Disconnect/abstractions.js +5 -0
  14. package/features/Disconnect/abstractions.js.map +1 -0
  15. package/features/ListConnections/ListConnectionsUseCase.d.ts +13 -0
  16. package/features/ListConnections/ListConnectionsUseCase.js +30 -0
  17. package/features/ListConnections/ListConnectionsUseCase.js.map +1 -0
  18. package/features/ListConnections/abstractions.d.ts +21 -0
  19. package/features/ListConnections/abstractions.js +5 -0
  20. package/features/ListConnections/abstractions.js.map +1 -0
  21. package/features/Routes/abstractions.d.ts +38 -0
  22. package/features/Routes/abstractions.js +5 -0
  23. package/features/Routes/abstractions.js.map +1 -0
  24. package/features/SendToConnections/SendToConnectionsUseCase.d.ts +14 -0
  25. package/features/SendToConnections/SendToConnectionsUseCase.js +26 -0
  26. package/features/SendToConnections/SendToConnectionsUseCase.js.map +1 -0
  27. package/features/SendToConnections/abstractions.d.ts +14 -0
  28. package/features/SendToConnections/abstractions.js +5 -0
  29. package/features/SendToConnections/abstractions.js.map +1 -0
  30. package/features/SendToIdentity/SendToIdentityUseCase.d.ts +18 -0
  31. package/features/SendToIdentity/SendToIdentityUseCase.js +42 -0
  32. package/features/SendToIdentity/SendToIdentityUseCase.js.map +1 -0
  33. package/features/SendToIdentity/abstractions.d.ts +14 -0
  34. package/features/SendToIdentity/abstractions.js +5 -0
  35. package/features/SendToIdentity/abstractions.js.map +1 -0
  36. package/features/feature.d.ts +1 -0
  37. package/features/feature.js +1 -0
  38. package/features/{WebsocketService → shared}/errors.d.ts +1 -0
  39. package/features/shared/errors.js.map +1 -0
  40. package/graphql/WebsocketsGraphQLFactory.d.ts +10 -0
  41. package/graphql/WebsocketsGraphQLFactory.js +196 -0
  42. package/graphql/WebsocketsGraphQLFactory.js.map +1 -0
  43. package/graphql/feature.d.ts +4 -0
  44. package/graphql/feature.js +11 -0
  45. package/graphql/feature.js.map +1 -0
  46. package/graphql/index.d.ts +1 -2
  47. package/graphql/index.js +1 -14
  48. package/handler/headers.js +6 -1
  49. package/handler/headers.js.map +1 -1
  50. package/handler/types.d.ts +6 -17
  51. package/handler/types.js.map +1 -1
  52. package/index.d.ts +4 -5
  53. package/index.js +3 -12
  54. package/package.json +19 -21
  55. package/registry/index.d.ts +1 -2
  56. package/registry/index.js +0 -1
  57. package/response/WebsocketsResponse.d.ts +8 -4
  58. package/response/WebsocketsResponse.js +7 -2
  59. package/response/WebsocketsResponse.js.map +1 -1
  60. package/response/abstractions/{IWebsocketsResponse.d.ts → WebsocketsResponse.d.ts} +9 -0
  61. package/response/abstractions/WebsocketsResponse.js +5 -0
  62. package/response/abstractions/WebsocketsResponse.js.map +1 -0
  63. package/response/index.d.ts +5 -2
  64. package/response/index.js +2 -1
  65. package/runner/WebsocketsRunner.d.ts +16 -10
  66. package/runner/WebsocketsRunner.js +30 -58
  67. package/runner/WebsocketsRunner.js.map +1 -1
  68. package/runner/abstractions/{IWebsocketsRunner.d.ts → WebsocketsRunner.d.ts} +2 -2
  69. package/runner/index.d.ts +2 -1
  70. package/runner/index.js +1 -0
  71. package/runner/routes/connect.d.ts +2 -1
  72. package/runner/routes/connect.js +9 -13
  73. package/runner/routes/connect.js.map +1 -1
  74. package/runner/routes/default.d.ts +2 -1
  75. package/runner/routes/default.js +6 -9
  76. package/runner/routes/default.js.map +1 -1
  77. package/runner/routes/disconnect.d.ts +2 -1
  78. package/runner/routes/disconnect.js +7 -10
  79. package/runner/routes/disconnect.js.map +1 -1
  80. package/runner/routes/index.d.ts +11 -1
  81. package/runner/routes/index.js +10 -9
  82. package/runner/routes/index.js.map +1 -1
  83. package/transport/NullWebsocketsTransport.d.ts +9 -0
  84. package/transport/NullWebsocketsTransport.js +12 -0
  85. package/transport/NullWebsocketsTransport.js.map +1 -0
  86. package/transport/abstractions/{IWebsocketsTransport.d.ts → WebsocketsTransport.d.ts} +15 -3
  87. package/transport/abstractions/WebsocketsTransport.js +5 -0
  88. package/transport/abstractions/WebsocketsTransport.js.map +1 -0
  89. package/transport/index.d.ts +1 -2
  90. package/transport/index.js +1 -1
  91. package/types.d.ts +26 -5
  92. package/validator/abstractions/WebsocketsEventValidator.d.ts +8 -0
  93. package/validator/abstractions/WebsocketsEventValidator.js +5 -0
  94. package/validator/abstractions/WebsocketsEventValidator.js.map +1 -0
  95. package/validator/index.d.ts +2 -2
  96. package/validator/index.js +1 -1
  97. package/context/WebsocketsContext.d.ts +0 -15
  98. package/context/WebsocketsContext.js +0 -66
  99. package/context/WebsocketsContext.js.map +0 -1
  100. package/context/abstractions/IWebsocketsContext.d.ts +0 -23
  101. package/context/index.d.ts +0 -4
  102. package/context/index.js +0 -19
  103. package/context/index.js.map +0 -1
  104. package/exports/api.js.map +0 -1
  105. package/features/WebsocketService/abstractions.d.ts +0 -9
  106. package/features/WebsocketService/abstractions.js +0 -5
  107. package/features/WebsocketService/abstractions.js.map +0 -1
  108. package/features/WebsocketService/errors.js.map +0 -1
  109. package/features/WebsocketService/index.d.ts +0 -1
  110. package/features/WebsocketService/index.js +0 -1
  111. package/graphql/checkPermissions.d.ts +0 -7
  112. package/graphql/checkPermissions.js +0 -10
  113. package/graphql/checkPermissions.js.map +0 -1
  114. package/graphql/createResolvers.d.ts +0 -12
  115. package/graphql/createResolvers.js +0 -59
  116. package/graphql/createResolvers.js.map +0 -1
  117. package/graphql/createTypeDefs.d.ts +0 -1
  118. package/graphql/createTypeDefs.js +0 -68
  119. package/graphql/createTypeDefs.js.map +0 -1
  120. package/graphql/index.js.map +0 -1
  121. package/graphql/utils.d.ts +0 -7
  122. package/graphql/utils.js +0 -12
  123. package/graphql/utils.js.map +0 -1
  124. package/handler/handler.d.ts +0 -2
  125. package/handler/handler.js +0 -73
  126. package/handler/handler.js.map +0 -1
  127. package/handler/register.d.ts +0 -1
  128. package/handler/register.js +0 -16
  129. package/handler/register.js.map +0 -1
  130. package/index.js.map +0 -1
  131. package/plugins/WebsocketsActionPlugin.d.ts +0 -11
  132. package/plugins/WebsocketsActionPlugin.js +0 -18
  133. package/plugins/WebsocketsActionPlugin.js.map +0 -1
  134. package/plugins/WebsocketsRoutePlugin.d.ts +0 -27
  135. package/plugins/WebsocketsRoutePlugin.js +0 -18
  136. package/plugins/WebsocketsRoutePlugin.js.map +0 -1
  137. package/plugins/abstrations/IWebsocketsActionPlugin.d.ts +0 -34
  138. package/plugins/abstrations/IWebsocketsActionPlugin.js +0 -0
  139. package/plugins/index.d.ts +0 -3
  140. package/plugins/index.js +0 -2
  141. package/registry/WebsocketsConnectionRegistry.d.ts +0 -23
  142. package/registry/WebsocketsConnectionRegistry.js +0 -118
  143. package/registry/WebsocketsConnectionRegistry.js.map +0 -1
  144. package/registry/abstractions/IWebsocketsConnectionRegistry.js +0 -0
  145. package/registry/entity.d.ts +0 -3
  146. package/registry/entity.js +0 -48
  147. package/registry/entity.js.map +0 -1
  148. package/response/abstractions/IWebsocketsResponse.js +0 -0
  149. package/runner/abstractions/IWebsocketsRunner.js +0 -0
  150. package/transport/WebsocketsTransport.d.ts +0 -8
  151. package/transport/WebsocketsTransport.js +0 -44
  152. package/transport/WebsocketsTransport.js.map +0 -1
  153. package/transport/abstractions/IWebsocketsTransport.js +0 -0
  154. package/validator/WebsocketsEventValidator.d.ts +0 -5
  155. package/validator/WebsocketsEventValidator.js +0 -68
  156. package/validator/WebsocketsEventValidator.js.map +0 -1
  157. package/validator/abstractions/IWebsocketsEventValidator.d.ts +0 -8
  158. package/validator/abstractions/IWebsocketsEventValidator.js +0 -0
  159. /package/features/{WebsocketService → shared}/errors.js +0 -0
  160. /package/{context/abstractions/IWebsocketsContext.js → runner/abstractions/WebsocketsRunner.js} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins/WebsocketsRoutePlugin.js","sources":["../../src/plugins/WebsocketsRoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type {\n IWebsocketsEvent,\n IWebsocketsEventData,\n WebsocketsEventRoute\n} from \"~/handler/types.js\";\nimport type { Context } from \"~/types.js\";\nimport type { IWebsocketsRunnerResponse } from \"~/runner/index.js\";\nimport type { IWebsocketsConnectionRegistry } from \"~/registry/index.js\";\nimport type { IWebsocketsResponse } from \"~/response/abstractions/IWebsocketsResponse.js\";\nimport type { IWebsocketsIdentity } from \"~/context/index.js\";\n\nexport interface IWebsocketsRoutePluginCallableParams<\n C extends Context = Context,\n R extends IWebsocketsRunnerResponse = IWebsocketsRunnerResponse,\n T extends IWebsocketsEventData = IWebsocketsEventData\n> {\n event: IWebsocketsEvent<T>;\n registry: IWebsocketsConnectionRegistry;\n context: C;\n response: IWebsocketsResponse;\n getTenant: () => string | null;\n getIdentity: () => IWebsocketsIdentity | null;\n next: () => Promise<R>;\n}\n\nexport interface IWebsocketsRoutePluginCallable<\n C extends Context = Context,\n R extends IWebsocketsRunnerResponse = IWebsocketsRunnerResponse,\n T extends IWebsocketsEventData = IWebsocketsEventData\n> {\n (params: IWebsocketsRoutePluginCallableParams<C, R, T>): Promise<R>;\n}\n\nexport class WebsocketsRoutePlugin<\n C extends Context = Context,\n R extends IWebsocketsRunnerResponse = IWebsocketsRunnerResponse,\n T extends IWebsocketsEventData = IWebsocketsEventData\n> extends Plugin {\n public static override readonly type: string = \"websockets.route\";\n\n public readonly route: WebsocketsEventRoute | string;\n private readonly cb: IWebsocketsRoutePluginCallable<C, R, T>;\n\n public constructor(\n route: WebsocketsEventRoute | string,\n cb: IWebsocketsRoutePluginCallable<C, R, T>\n ) {\n super();\n this.route = route;\n this.cb = cb;\n }\n\n public async run(params: IWebsocketsRoutePluginCallableParams<C, R, T>): Promise<R> {\n return this.cb(params);\n }\n}\n\nexport const createWebsocketsRoutePlugin = <\n C extends Context = Context,\n R extends IWebsocketsRunnerResponse = IWebsocketsRunnerResponse,\n T extends IWebsocketsEventData = IWebsocketsEventData\n>(\n route: WebsocketsEventRoute | string,\n cb: IWebsocketsRoutePluginCallable<C, R, T>\n) => {\n return new WebsocketsRoutePlugin<C, R, T>(route, cb);\n};\n"],"names":["WebsocketsRoutePlugin","Plugin","route","cb","params","createWebsocketsRoutePlugin"],"mappings":";AAkCO,MAAMA,8BAIHC;;aAC0B,IAAI,GAAW;;IAK/C,YACIC,KAAoC,EACpCC,EAA2C,CAC7C;QACE,KAAK;QACL,IAAI,CAAC,KAAK,GAAGD;QACb,IAAI,CAAC,EAAE,GAAGC;IACd;IAEA,MAAa,IAAIC,MAAqD,EAAc;QAChF,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAEO,MAAMC,8BAA8B,CAKvCH,OACAC,KAEO,IAAIH,sBAA+BE,OAAOC"}
@@ -1,34 +0,0 @@
1
- import type { GenericRecord } from "@webiny/api/types.js";
2
- import type { Context } from "../../types.js";
3
- export interface IWebsocketsActionPluginCallableParamsSend {
4
- toConnection<T extends GenericRecord = GenericRecord>(connectionId: string, data: T): Promise<void>;
5
- toTenant<T extends GenericRecord = GenericRecord>(tenant: string, data: T): Promise<void>;
6
- toIdentity<T extends GenericRecord = GenericRecord>(identity: string, data: T): Promise<void>;
7
- }
8
- export interface IWebsocketsActionPluginCallableParamsRespondError<T extends GenericRecord = GenericRecord> {
9
- message: string;
10
- code: string;
11
- data: T;
12
- }
13
- export interface IWebsocketsActionPluginCallableParamsRespondOkResponse<T extends GenericRecord = GenericRecord> {
14
- data: T;
15
- error?: never;
16
- }
17
- export interface IWebsocketsActionPluginCallableParamsRespondErrorResponse<T extends GenericRecord = GenericRecord> {
18
- error: IWebsocketsActionPluginCallableParamsRespondError<T>;
19
- data?: never;
20
- }
21
- export interface IWebsocketsActionPluginCallableParamsRespond {
22
- ok<T extends GenericRecord = GenericRecord>(data: T): Promise<IWebsocketsActionPluginCallableParamsRespondOkResponse<T>>;
23
- error<T extends GenericRecord = GenericRecord>(error: IWebsocketsActionPluginCallableParamsRespondError<T>): Promise<IWebsocketsActionPluginCallableParamsRespondErrorResponse<T>>;
24
- }
25
- export interface IWebsocketsActionPluginCallableParams<C extends Context = Context> {
26
- context: C;
27
- next(): Promise<void>;
28
- send: IWebsocketsActionPluginCallableParamsSend;
29
- respond: IWebsocketsActionPluginCallableParamsRespond;
30
- }
31
- export type WebsocketsActionPluginCallableResponse<T extends GenericRecord = GenericRecord> = IWebsocketsActionPluginCallableParamsRespondOkResponse<T> | IWebsocketsActionPluginCallableParamsRespondErrorResponse<T>;
32
- export interface IWebsocketsActionPluginCallable<T extends GenericRecord = GenericRecord> {
33
- (params: IWebsocketsActionPluginCallableParams): Promise<WebsocketsActionPluginCallableResponse<T>>;
34
- }
File without changes
@@ -1,3 +0,0 @@
1
- export * from "./WebsocketsRoutePlugin.js";
2
- export * from "./WebsocketsActionPlugin.js";
3
- export type * from "./abstrations/IWebsocketsActionPlugin.js";
package/plugins/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from "./WebsocketsRoutePlugin.js";
2
- export * from "./WebsocketsActionPlugin.js";
@@ -1,23 +0,0 @@
1
- import type { IWebsocketsConnectionRegistry, IWebsocketsConnectionRegistryData, IWebsocketsConnectionRegistryRegisterParams, IWebsocketsConnectionRegistryUnregisterParams } from "./abstractions/IWebsocketsConnectionRegistry.js";
2
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
3
- export declare class WebsocketsConnectionRegistry implements IWebsocketsConnectionRegistry {
4
- private readonly entity;
5
- constructor(documentClient: DynamoDBDocument);
6
- register(params: IWebsocketsConnectionRegistryRegisterParams): Promise<IWebsocketsConnectionRegistryData>;
7
- unregister(params: IWebsocketsConnectionRegistryUnregisterParams): Promise<void>;
8
- private getViaConnection;
9
- /**
10
- * Uses Primary keys
11
- */
12
- listViaConnections(connections: string[]): Promise<IWebsocketsConnectionRegistryData[]>;
13
- /**
14
- * Uses GSI1 keys
15
- */
16
- listViaIdentity(identity: string): Promise<IWebsocketsConnectionRegistryData[]>;
17
- /**
18
- * Uses GSI2 keys
19
- */
20
- listViaTenant(tenant: string): Promise<IWebsocketsConnectionRegistryData[]>;
21
- listAll(): Promise<IWebsocketsConnectionRegistryData[]>;
22
- private store;
23
- }
@@ -1,118 +0,0 @@
1
- import error from "@webiny/error";
2
- import { createEntity } from "./entity.js";
3
- const PK = "WS#CONNECTIONS";
4
- const GSI1_PK = "WS#CONNECTIONS#IDENTITY";
5
- const GSI2_PK = "WS#CONNECTIONS#TENANT";
6
- class WebsocketsConnectionRegistry {
7
- constructor(documentClient){
8
- this.entity = createEntity(documentClient);
9
- }
10
- async register(params) {
11
- const { connectionId, tenant, identity, domainName, stage, connectedOn } = params;
12
- const data = {
13
- connectionId,
14
- identity,
15
- tenant,
16
- domainName,
17
- stage,
18
- connectedOn
19
- };
20
- await this.store(data);
21
- return data;
22
- }
23
- async unregister(params) {
24
- const { connectionId } = params;
25
- const keys = {
26
- PK: PK,
27
- SK: connectionId
28
- };
29
- const original = await this.getViaConnection(connectionId);
30
- if (!original) {
31
- const message = `There is no connection with ID "${connectionId}".`;
32
- console.error(message);
33
- throw new error(message, "CONNECTION_NOT_FOUND", keys);
34
- }
35
- try {
36
- await this.entity.delete(keys);
37
- } catch (ex) {
38
- console.error(`Could not remove connection from the database: ${original.connectionId}`);
39
- throw new error(ex.message, ex.code, keys);
40
- }
41
- }
42
- async getViaConnection(connectionId) {
43
- const item = await this.entity.get({
44
- PK: PK,
45
- SK: connectionId
46
- });
47
- if (!item) return null;
48
- return item?.data || null;
49
- }
50
- async listViaConnections(connections) {
51
- const reader = this.entity.createEntityReader({
52
- read: connections.map((id)=>({
53
- PK: PK,
54
- SK: id
55
- }))
56
- });
57
- const results = await reader.execute();
58
- return results.map((item)=>item.data);
59
- }
60
- async listViaIdentity(identity) {
61
- const items = await this.entity.queryAll({
62
- partitionKey: GSI1_PK,
63
- options: {
64
- index: "GSI1",
65
- eq: identity
66
- }
67
- });
68
- return items.map((item)=>item.data);
69
- }
70
- async listViaTenant(tenant) {
71
- const options = {
72
- beginsWith: `T#${tenant}`
73
- };
74
- const items = await this.entity.queryAll({
75
- partitionKey: GSI2_PK,
76
- options: {
77
- ...options,
78
- index: "GSI2"
79
- }
80
- });
81
- return items.map((item)=>item.data);
82
- }
83
- async listAll() {
84
- const items = await this.entity.queryAll({
85
- partitionKey: PK,
86
- options: {
87
- gte: " "
88
- }
89
- });
90
- return items.map((item)=>item.data);
91
- }
92
- async store(data) {
93
- const { connectionId, tenant, identity } = data;
94
- const item = {
95
- PK: PK,
96
- SK: connectionId,
97
- GSI1_PK: GSI1_PK,
98
- GSI1_SK: identity.id,
99
- GSI2_PK: GSI2_PK,
100
- GSI2_SK: `T#${tenant}`,
101
- GSI_TENANT: tenant,
102
- TYPE: "ws.connection",
103
- data
104
- };
105
- try {
106
- return await this.entity.put(item);
107
- } catch (err) {
108
- throw error.from(err, {
109
- message: "Could not store websockets connection data.",
110
- code: "STORE_WEBSOCKETS_CONNECTION_DATA_ERROR",
111
- data: item
112
- });
113
- }
114
- }
115
- }
116
- export { WebsocketsConnectionRegistry };
117
-
118
- //# sourceMappingURL=WebsocketsConnectionRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry/WebsocketsConnectionRegistry.js","sources":["../../src/registry/WebsocketsConnectionRegistry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n IWebsocketsConnectionRegistry,\n IWebsocketsConnectionRegistryData,\n IWebsocketsConnectionRegistryRegisterParams,\n IWebsocketsConnectionRegistryUnregisterParams\n} from \"./abstractions/IWebsocketsConnectionRegistry.js\";\nimport { createEntity } from \"~/registry/entity.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { EntityQueryOptions } from \"@webiny/db-dynamodb/toolbox.js\";\n\nconst PK = `WS#CONNECTIONS`;\nconst GSI1_PK = \"WS#CONNECTIONS#IDENTITY\";\nconst GSI2_PK = \"WS#CONNECTIONS#TENANT\";\n\nexport class WebsocketsConnectionRegistry implements IWebsocketsConnectionRegistry {\n private readonly entity;\n\n public constructor(documentClient: DynamoDBDocument) {\n this.entity = createEntity(documentClient);\n }\n\n public async register(\n params: IWebsocketsConnectionRegistryRegisterParams\n ): Promise<IWebsocketsConnectionRegistryData> {\n const { connectionId, tenant, identity, domainName, stage, connectedOn } = params;\n\n const data: IWebsocketsConnectionRegistryData = {\n connectionId,\n identity,\n tenant,\n domainName,\n stage,\n connectedOn\n };\n await this.store(data);\n return data;\n }\n\n public async unregister(params: IWebsocketsConnectionRegistryUnregisterParams): Promise<void> {\n const { connectionId } = params;\n\n const keys = {\n PK,\n SK: connectionId\n };\n const original = await this.getViaConnection(connectionId);\n if (!original) {\n const message = `There is no connection with ID \"${connectionId}\".`;\n console.error(message);\n throw new WebinyError(message, \"CONNECTION_NOT_FOUND\", keys);\n }\n\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n console.error(\n `Could not remove connection from the database: ${original.connectionId}`\n );\n throw new WebinyError(ex.message, ex.code, keys);\n }\n }\n\n private async getViaConnection(\n connectionId: string\n ): Promise<IWebsocketsConnectionRegistryData | null> {\n const item = await this.entity.get({\n PK,\n SK: connectionId\n });\n if (!item) {\n return null;\n }\n return item?.data || null;\n }\n\n /**\n * Uses Primary keys\n */\n public async listViaConnections(\n connections: string[]\n ): Promise<IWebsocketsConnectionRegistryData[]> {\n const reader = this.entity.createEntityReader({\n read: connections.map(id => {\n return {\n PK,\n SK: id\n };\n })\n });\n\n const results = await reader.execute();\n\n return results.map(item => {\n return item.data;\n });\n }\n\n /**\n * Uses GSI1 keys\n */\n public async listViaIdentity(identity: string): Promise<IWebsocketsConnectionRegistryData[]> {\n const items = await this.entity.queryAll({\n partitionKey: GSI1_PK,\n options: {\n index: \"GSI1\",\n eq: identity\n }\n });\n return items.map(item => {\n return item.data;\n });\n }\n\n /**\n * Uses GSI2 keys\n */\n public async listViaTenant(tenant: string): Promise<IWebsocketsConnectionRegistryData[]> {\n const options: Partial<EntityQueryOptions> = {\n beginsWith: `T#${tenant}`\n };\n\n const items = await this.entity.queryAll({\n partitionKey: GSI2_PK,\n options: {\n ...options,\n index: \"GSI2\"\n }\n });\n return items.map(item => {\n return item.data;\n });\n }\n\n public async listAll(): Promise<IWebsocketsConnectionRegistryData[]> {\n const items = await this.entity.queryAll({\n partitionKey: PK,\n options: {\n gte: \" \"\n }\n });\n return items.map(item => {\n return item.data;\n });\n }\n\n private async store(data: IWebsocketsConnectionRegistryData) {\n const { connectionId, tenant, identity } = data;\n const item = {\n // to find specific identity related to given connection\n PK,\n SK: connectionId,\n // to find all connections related to given identity\n GSI1_PK,\n GSI1_SK: identity.id,\n // to find all connections related to given tenant\n GSI2_PK,\n GSI2_SK: `T#${tenant}`,\n GSI_TENANT: tenant,\n TYPE: \"ws.connection\",\n data\n };\n try {\n return await this.entity.put(item);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not store websockets connection data.\",\n code: \"STORE_WEBSOCKETS_CONNECTION_DATA_ERROR\",\n data: item\n });\n }\n }\n}\n"],"names":["PK","GSI1_PK","GSI2_PK","WebsocketsConnectionRegistry","documentClient","createEntity","params","connectionId","tenant","identity","domainName","stage","connectedOn","data","keys","original","message","console","WebinyError","ex","item","connections","reader","id","results","items","options","err"],"mappings":";;AAWA,MAAMA,KAAK;AACX,MAAMC,UAAU;AAChB,MAAMC,UAAU;AAET,MAAMC;IAGT,YAAmBC,cAAgC,CAAE;QACjD,IAAI,CAAC,MAAM,GAAGC,aAAaD;IAC/B;IAEA,MAAa,SACTE,MAAmD,EACT;QAC1C,MAAM,EAAEC,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAEC,WAAW,EAAE,GAAGN;QAE3E,MAAMO,OAA0C;YAC5CN;YACAE;YACAD;YACAE;YACAC;YACAC;QACJ;QACA,MAAM,IAAI,CAAC,KAAK,CAACC;QACjB,OAAOA;IACX;IAEA,MAAa,WAAWP,MAAqD,EAAiB;QAC1F,MAAM,EAAEC,YAAY,EAAE,GAAGD;QAEzB,MAAMQ,OAAO;YACTd,IAAAA;YACA,IAAIO;QACR;QACA,MAAMQ,WAAW,MAAM,IAAI,CAAC,gBAAgB,CAACR;QAC7C,IAAI,CAACQ,UAAU;YACX,MAAMC,UAAU,CAAC,gCAAgC,EAAET,aAAa,EAAE,CAAC;YACnEU,QAAQ,KAAK,CAACD;YACd,MAAM,IAAIE,MAAYF,SAAS,wBAAwBF;QAC3D;QAEA,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAACA;QAC7B,EAAE,OAAOK,IAAI;YACTF,QAAQ,KAAK,CACT,CAAC,+CAA+C,EAAEF,SAAS,YAAY,EAAE;YAE7E,MAAM,IAAIG,MAAYC,GAAG,OAAO,EAAEA,GAAG,IAAI,EAAEL;QAC/C;IACJ;IAEA,MAAc,iBACVP,YAAoB,EAC6B;QACjD,MAAMa,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;YAC/BpB,IAAAA;YACA,IAAIO;QACR;QACA,IAAI,CAACa,MACD,OAAO;QAEX,OAAOA,MAAM,QAAQ;IACzB;IAKA,MAAa,mBACTC,WAAqB,EACuB;QAC5C,MAAMC,SAAS,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC1C,MAAMD,YAAY,GAAG,CAACE,CAAAA,KACX;oBACHvB,IAAAA;oBACA,IAAIuB;gBACR;QAER;QAEA,MAAMC,UAAU,MAAMF,OAAO,OAAO;QAEpC,OAAOE,QAAQ,GAAG,CAACJ,CAAAA,OACRA,KAAK,IAAI;IAExB;IAKA,MAAa,gBAAgBX,QAAgB,EAAgD;QACzF,MAAMgB,QAAQ,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACrC,cAAcxB;YACd,SAAS;gBACL,OAAO;gBACP,IAAIQ;YACR;QACJ;QACA,OAAOgB,MAAM,GAAG,CAACL,CAAAA,OACNA,KAAK,IAAI;IAExB;IAKA,MAAa,cAAcZ,MAAc,EAAgD;QACrF,MAAMkB,UAAuC;YACzC,YAAY,CAAC,EAAE,EAAElB,QAAQ;QAC7B;QAEA,MAAMiB,QAAQ,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACrC,cAAcvB;YACd,SAAS;gBACL,GAAGwB,OAAO;gBACV,OAAO;YACX;QACJ;QACA,OAAOD,MAAM,GAAG,CAACL,CAAAA,OACNA,KAAK,IAAI;IAExB;IAEA,MAAa,UAAwD;QACjE,MAAMK,QAAQ,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACrC,cAAczB;YACd,SAAS;gBACL,KAAK;YACT;QACJ;QACA,OAAOyB,MAAM,GAAG,CAACL,CAAAA,OACNA,KAAK,IAAI;IAExB;IAEA,MAAc,MAAMP,IAAuC,EAAE;QACzD,MAAM,EAAEN,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGI;QAC3C,MAAMO,OAAO;YAETpB,IAAAA;YACA,IAAIO;YAEJN,SAAAA;YACA,SAASQ,SAAS,EAAE;YAEpBP,SAAAA;YACA,SAAS,CAAC,EAAE,EAAEM,QAAQ;YACtB,YAAYA;YACZ,MAAM;YACNK;QACJ;QACA,IAAI;YACA,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAACO;QACjC,EAAE,OAAOO,KAAK;YACV,MAAMT,MAAAA,IAAgB,CAACS,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAMP;YACV;QACJ;IACJ;AACJ"}
@@ -1,3 +0,0 @@
1
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
- import type { IWebsocketsConnectionRegistryData } from "./abstractions/IWebsocketsConnectionRegistry.js";
3
- export declare const createEntity: (documentClient: DynamoDBDocument) => import("@webiny/db-dynamodb").IEntity<import("@webiny/db-dynamodb").IStandardEntityAttributes<IWebsocketsConnectionRegistryData>>;
@@ -1,48 +0,0 @@
1
- import { createStandardEntity, createTable } from "@webiny/db-dynamodb";
2
- const entity_name = "SocketsConnectionRegistry";
3
- const createEntity = (documentClient)=>{
4
- const table = createTable({
5
- name: String(process.env.DB_TABLE),
6
- documentClient
7
- });
8
- return createStandardEntity({
9
- name: entity_name,
10
- table: table.table,
11
- attributes: {
12
- PK: {
13
- partitionKey: true
14
- },
15
- SK: {
16
- sortKey: true
17
- },
18
- GSI1_PK: {
19
- type: "string",
20
- required: true
21
- },
22
- GSI1_SK: {
23
- type: "string",
24
- required: true
25
- },
26
- GSI2_PK: {
27
- type: "string",
28
- required: true
29
- },
30
- GSI2_SK: {
31
- type: "string",
32
- required: true
33
- },
34
- TYPE: {
35
- type: "string",
36
- default: entity_name,
37
- required: true
38
- },
39
- data: {
40
- type: "map",
41
- required: true
42
- }
43
- }
44
- });
45
- };
46
- export { createEntity };
47
-
48
- //# sourceMappingURL=entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry/entity.js","sources":["../../src/registry/entity.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStandardEntity, createTable } from \"@webiny/db-dynamodb\";\nimport type { IWebsocketsConnectionRegistryData } from \"./abstractions/IWebsocketsConnectionRegistry.js\";\n\nconst name = \"SocketsConnectionRegistry\";\n\nexport const createEntity = (documentClient: DynamoDBDocument) => {\n const table = createTable({\n name: String(process.env.DB_TABLE),\n documentClient\n });\n\n return createStandardEntity<IWebsocketsConnectionRegistryData>({\n name,\n table: table.table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\",\n required: true\n },\n GSI1_SK: {\n type: \"string\",\n required: true\n },\n GSI2_PK: {\n type: \"string\",\n required: true\n },\n GSI2_SK: {\n type: \"string\",\n required: true\n },\n TYPE: {\n type: \"string\",\n default: name,\n required: true\n },\n data: {\n type: \"map\",\n required: true\n }\n }\n });\n};\n"],"names":["name","createEntity","documentClient","table","createTable","String","process","createStandardEntity"],"mappings":";AAIA,MAAMA,cAAO;AAEN,MAAMC,eAAe,CAACC;IACzB,MAAMC,QAAQC,YAAY;QACtB,MAAMC,OAAOC,QAAQ,GAAG,CAAC,QAAQ;QACjCJ;IACJ;IAEA,OAAOK,qBAAwD;QAC3DP,MAAAA;QACA,OAAOG,MAAM,KAAK;QAClB,YAAY;YACR,IAAI;gBACA,cAAc;YAClB;YACA,IAAI;gBACA,SAAS;YACb;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,MAAM;gBACF,MAAM;gBACN,SAASH;gBACT,UAAU;YACd;YACA,MAAM;gBACF,MAAM;gBACN,UAAU;YACd;QACJ;IACJ;AACJ"}
File without changes
File without changes
@@ -1,8 +0,0 @@
1
- import type { IWebsocketsTransport, IWebsocketsTransportDisconnectConnection, IWebsocketsTransportSendConnection, IWebsocketsTransportSendData } from "./abstractions/IWebsocketsTransport.js";
2
- import type { GenericRecord } from "@webiny/api/types.js";
3
- export declare class WebsocketsTransport implements IWebsocketsTransport {
4
- private readonly clients;
5
- send<T extends GenericRecord = GenericRecord>(connections: IWebsocketsTransportSendConnection[], data: IWebsocketsTransportSendData<T>): Promise<void>;
6
- disconnect(connections: IWebsocketsTransportDisconnectConnection[]): Promise<void>;
7
- private getClient;
8
- }
@@ -1,44 +0,0 @@
1
- import { ApiGatewayManagementApiClient, DeleteConnectionCommand, PostToConnectionCommand } from "@webiny/aws-sdk/client-apigatewaymanagementapi/index.js";
2
- class WebsocketsTransport {
3
- async send(connections, data) {
4
- for (const connection of connections)try {
5
- const client = this.getClient(connection);
6
- const command = new PostToConnectionCommand({
7
- ConnectionId: connection.connectionId,
8
- Data: JSON.stringify(data)
9
- });
10
- await client.send(command);
11
- } catch (ex) {
12
- console.error(`Failed to send message to connection "${connection.connectionId}". Check logs for more information.`);
13
- console.log(ex);
14
- }
15
- }
16
- async disconnect(connections) {
17
- for (const connection of connections)try {
18
- const client = this.getClient(connection);
19
- const command = new DeleteConnectionCommand({
20
- ConnectionId: connection.connectionId
21
- });
22
- await client.send(command);
23
- } catch (ex) {
24
- console.error(`Failed to disconnect connection "${connection.connectionId}". Check logs for more information.`);
25
- console.log(ex);
26
- }
27
- }
28
- getClient(connection) {
29
- const endpoint = `https://${connection.domainName}/${connection.stage}`;
30
- const client = this.clients.get(endpoint);
31
- if (client) return client;
32
- const newClient = new ApiGatewayManagementApiClient({
33
- endpoint
34
- });
35
- this.clients.set(endpoint, newClient);
36
- return newClient;
37
- }
38
- constructor(){
39
- this.clients = new Map();
40
- }
41
- }
42
- export { WebsocketsTransport };
43
-
44
- //# sourceMappingURL=WebsocketsTransport.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport/WebsocketsTransport.js","sources":["../../src/transport/WebsocketsTransport.ts"],"sourcesContent":["import {\n ApiGatewayManagementApiClient,\n DeleteConnectionCommand,\n PostToConnectionCommand\n} from \"@webiny/aws-sdk/client-apigatewaymanagementapi/index.js\";\nimport type {\n IWebsocketsTransport,\n IWebsocketsTransportDisconnectConnection,\n IWebsocketsTransportSendConnection,\n IWebsocketsTransportSendData\n} from \"./abstractions/IWebsocketsTransport.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport class WebsocketsTransport implements IWebsocketsTransport {\n private readonly clients = new Map<string, ApiGatewayManagementApiClient>();\n\n public async send<T extends GenericRecord = GenericRecord>(\n connections: IWebsocketsTransportSendConnection[],\n data: IWebsocketsTransportSendData<T>\n ): Promise<void> {\n for (const connection of connections) {\n try {\n const client = this.getClient(connection);\n\n const command = new PostToConnectionCommand({\n ConnectionId: connection.connectionId,\n Data: JSON.stringify(data)\n });\n await client.send(command);\n } catch (ex) {\n console.error(\n `Failed to send message to connection \"${connection.connectionId}\". Check logs for more information.`\n );\n console.log(ex);\n }\n }\n }\n\n public async disconnect(connections: IWebsocketsTransportDisconnectConnection[]) {\n for (const connection of connections) {\n try {\n const client = this.getClient(connection);\n const command = new DeleteConnectionCommand({\n ConnectionId: connection.connectionId\n });\n await client.send(command);\n } catch (ex) {\n console.error(\n `Failed to disconnect connection \"${connection.connectionId}\". Check logs for more information.`\n );\n console.log(ex);\n }\n }\n }\n\n private getClient(\n connection: IWebsocketsTransportSendConnection\n ): ApiGatewayManagementApiClient {\n const endpoint = `https://${connection.domainName}/${connection.stage}`;\n const client = this.clients.get(endpoint);\n if (client) {\n return client;\n }\n const newClient = new ApiGatewayManagementApiClient({\n endpoint\n });\n this.clients.set(endpoint, newClient);\n return newClient;\n }\n}\n"],"names":["WebsocketsTransport","connections","data","connection","client","command","PostToConnectionCommand","JSON","ex","console","DeleteConnectionCommand","endpoint","newClient","ApiGatewayManagementApiClient","Map"],"mappings":";AAaO,MAAMA;IAGT,MAAa,KACTC,WAAiD,EACjDC,IAAqC,EACxB;QACb,KAAK,MAAMC,cAAcF,YACrB,IAAI;YACA,MAAMG,SAAS,IAAI,CAAC,SAAS,CAACD;YAE9B,MAAME,UAAU,IAAIC,wBAAwB;gBACxC,cAAcH,WAAW,YAAY;gBACrC,MAAMI,KAAK,SAAS,CAACL;YACzB;YACA,MAAME,OAAO,IAAI,CAACC;QACtB,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CACT,CAAC,sCAAsC,EAAEN,WAAW,YAAY,CAAC,mCAAmC,CAAC;YAEzGM,QAAQ,GAAG,CAACD;QAChB;IAER;IAEA,MAAa,WAAWP,WAAuD,EAAE;QAC7E,KAAK,MAAME,cAAcF,YACrB,IAAI;YACA,MAAMG,SAAS,IAAI,CAAC,SAAS,CAACD;YAC9B,MAAME,UAAU,IAAIK,wBAAwB;gBACxC,cAAcP,WAAW,YAAY;YACzC;YACA,MAAMC,OAAO,IAAI,CAACC;QACtB,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CACT,CAAC,iCAAiC,EAAEN,WAAW,YAAY,CAAC,mCAAmC,CAAC;YAEpGM,QAAQ,GAAG,CAACD;QAChB;IAER;IAEQ,UACJL,UAA8C,EACjB;QAC7B,MAAMQ,WAAW,CAAC,QAAQ,EAAER,WAAW,UAAU,CAAC,CAAC,EAAEA,WAAW,KAAK,EAAE;QACvE,MAAMC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAACO;QAChC,IAAIP,QACA,OAAOA;QAEX,MAAMQ,YAAY,IAAIC,8BAA8B;YAChDF;QACJ;QACA,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA,UAAUC;QAC3B,OAAOA;IACX;;aAtDiB,OAAO,GAAG,IAAIE;;AAuDnC"}
File without changes
@@ -1,5 +0,0 @@
1
- import type { IWebsocketsEvent, IWebsocketsEventData } from "../handler/types.js";
2
- import type { IWebsocketsEventValidator, IWebsocketsEventValidatorValidateParams } from "./abstractions/IWebsocketsEventValidator.js";
3
- export declare class WebsocketsEventValidator implements IWebsocketsEventValidator {
4
- validate<T extends IWebsocketsEventData = IWebsocketsEventData>(input: IWebsocketsEventValidatorValidateParams): Promise<IWebsocketsEvent<T>>;
5
- }
@@ -1,68 +0,0 @@
1
- import zod from "zod";
2
- import { WebsocketsEventRequestContextEventType } from "../handler/types.js";
3
- import { createZodError } from "@webiny/utils";
4
- const validation = zod.object({
5
- headers: zod.looseObject({}).optional(),
6
- requestContext: zod.object({
7
- connectionId: zod.string(),
8
- stage: zod.string(),
9
- connectedAt: zod.number(),
10
- domainName: zod.string(),
11
- eventType: zod["enum"]([
12
- WebsocketsEventRequestContextEventType.connect,
13
- WebsocketsEventRequestContextEventType.message,
14
- WebsocketsEventRequestContextEventType.disconnect
15
- ]),
16
- routeKey: zod.string()
17
- }),
18
- body: zod.string().transform((value, context)=>{
19
- if (!value) return;
20
- try {
21
- return JSON.parse(value);
22
- } catch (ex) {
23
- console.error(`Failed body validation: ${ex.message}`);
24
- console.log(`Body: ${value}`);
25
- context.addIssue({
26
- path: [],
27
- message: `Invalid JSON: ${ex.message}`,
28
- code: zod.ZodIssueCode.custom,
29
- fatal: true
30
- });
31
- }
32
- }).optional()
33
- }).superRefine((output, context)=>{
34
- if (output.requestContext.eventType !== WebsocketsEventRequestContextEventType.message) return;
35
- if (output.body) return;
36
- context.addIssue({
37
- path: [
38
- "body"
39
- ],
40
- message: "There must be a body defined when having a message event.",
41
- code: zod.ZodIssueCode.custom,
42
- fatal: true
43
- });
44
- });
45
- const bodyValidation = zod.looseObject({
46
- token: zod.string(),
47
- tenant: zod.string(),
48
- messageId: zod.string().nullish(),
49
- action: zod.string(),
50
- data: zod.looseObject({}).nullish()
51
- }).optional();
52
- class WebsocketsEventValidator {
53
- async validate(input) {
54
- const result = await validation.safeParseAsync(input);
55
- if (!result.success) throw createZodError(result.error);
56
- const bodyResult = await bodyValidation.safeParseAsync(result.data.body);
57
- if (!bodyResult.success) throw createZodError(bodyResult.error);
58
- return {
59
- ...result.data,
60
- body: {
61
- ...bodyResult.data || {}
62
- }
63
- };
64
- }
65
- }
66
- export { WebsocketsEventValidator };
67
-
68
- //# sourceMappingURL=WebsocketsEventValidator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validator/WebsocketsEventValidator.js","sources":["../../src/validator/WebsocketsEventValidator.ts"],"sourcesContent":["import zod from \"zod\";\nimport type { IWebsocketsEvent, IWebsocketsEventData } from \"~/handler/types.js\";\nimport { WebsocketsEventRequestContextEventType } from \"~/handler/types.js\";\nimport type {\n IWebsocketsEventValidator,\n IWebsocketsEventValidatorValidateParams\n} from \"./abstractions/IWebsocketsEventValidator.js\";\nimport { createZodError } from \"@webiny/utils\";\n\nconst validation = zod\n .object({\n headers: zod.looseObject({}).optional(),\n requestContext: zod.object({\n connectionId: zod.string(),\n stage: zod.string(),\n connectedAt: zod.number(),\n domainName: zod.string(),\n eventType: zod.enum([\n WebsocketsEventRequestContextEventType.connect,\n WebsocketsEventRequestContextEventType.message,\n WebsocketsEventRequestContextEventType.disconnect\n ]),\n routeKey: zod.string()\n }),\n body: zod\n .string()\n .transform<IWebsocketsEventData>((value, context) => {\n if (!value) {\n return undefined;\n }\n try {\n return JSON.parse(value);\n } catch (ex) {\n /**\n * We want to log the error, for easier debugging.\n */\n console.error(`Failed body validation: ${ex.message}`);\n console.log(`Body: ${value}`);\n /**\n * And we want to add an issue to the context, so that the user knows what went wrong.\n */\n context.addIssue({\n path: [],\n message: `Invalid JSON: ${ex.message}`,\n code: zod.ZodIssueCode.custom,\n fatal: true\n });\n }\n })\n .optional()\n })\n .superRefine((output, context) => {\n if (output.requestContext.eventType !== WebsocketsEventRequestContextEventType.message) {\n return;\n } else if (output.body) {\n return;\n }\n context.addIssue({\n path: [\"body\"],\n message: \"There must be a body defined when having a message event.\",\n code: zod.ZodIssueCode.custom,\n fatal: true\n });\n });\n\nconst bodyValidation = zod\n .looseObject({\n token: zod.string(),\n tenant: zod.string(),\n messageId: zod.string().nullish(),\n action: zod.string(),\n data: zod.looseObject({}).nullish()\n })\n .optional();\n\nexport class WebsocketsEventValidator implements IWebsocketsEventValidator {\n public async validate<T extends IWebsocketsEventData = IWebsocketsEventData>(\n input: IWebsocketsEventValidatorValidateParams\n ): Promise<IWebsocketsEvent<T>> {\n const result = await validation.safeParseAsync(input);\n if (!result.success) {\n throw createZodError(result.error);\n }\n const bodyResult = await bodyValidation.safeParseAsync(result.data.body);\n if (!bodyResult.success) {\n throw createZodError(bodyResult.error);\n }\n return {\n ...result.data,\n body: {\n ...((bodyResult.data || {}) as T)\n }\n };\n }\n}\n"],"names":["validation","zod","WebsocketsEventRequestContextEventType","value","context","JSON","ex","console","output","bodyValidation","WebsocketsEventValidator","input","result","createZodError","bodyResult"],"mappings":";;;AASA,MAAMA,aAAaC,IAAAA,MACR,CAAC;IACJ,SAASA,IAAI,WAAW,CAAC,CAAC,GAAG,QAAQ;IACrC,gBAAgBA,IAAI,MAAM,CAAC;QACvB,cAAcA,IAAI,MAAM;QACxB,OAAOA,IAAI,MAAM;QACjB,aAAaA,IAAI,MAAM;QACvB,YAAYA,IAAI,MAAM;QACtB,WAAWA,GAAG,CAAHA,OAAQ,CAAC;YAChBC,uCAAuC,OAAO;YAC9CA,uCAAuC,OAAO;YAC9CA,uCAAuC,UAAU;SACpD;QACD,UAAUD,IAAI,MAAM;IACxB;IACA,MAAMA,IAAAA,MACK,GACN,SAAS,CAAuB,CAACE,OAAOC;QACrC,IAAI,CAACD,OACD;QAEJ,IAAI;YACA,OAAOE,KAAK,KAAK,CAACF;QACtB,EAAE,OAAOG,IAAI;YAITC,QAAQ,KAAK,CAAC,CAAC,wBAAwB,EAAED,GAAG,OAAO,EAAE;YACrDC,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAEJ,OAAO;YAI5BC,QAAQ,QAAQ,CAAC;gBACb,MAAM,EAAE;gBACR,SAAS,CAAC,cAAc,EAAEE,GAAG,OAAO,EAAE;gBACtC,MAAML,IAAI,YAAY,CAAC,MAAM;gBAC7B,OAAO;YACX;QACJ;IACJ,GACC,QAAQ;AACjB,GACC,WAAW,CAAC,CAACO,QAAQJ;IAClB,IAAII,OAAO,cAAc,CAAC,SAAS,KAAKN,uCAAuC,OAAO,EAClF;IACG,IAAIM,OAAO,IAAI,EAClB;IAEJJ,QAAQ,QAAQ,CAAC;QACb,MAAM;YAAC;SAAO;QACd,SAAS;QACT,MAAMH,IAAI,YAAY,CAAC,MAAM;QAC7B,OAAO;IACX;AACJ;AAEJ,MAAMQ,iBAAiBR,IAAAA,WACP,CAAC;IACT,OAAOA,IAAI,MAAM;IACjB,QAAQA,IAAI,MAAM;IAClB,WAAWA,IAAI,MAAM,GAAG,OAAO;IAC/B,QAAQA,IAAI,MAAM;IAClB,MAAMA,IAAI,WAAW,CAAC,CAAC,GAAG,OAAO;AACrC,GACC,QAAQ;AAEN,MAAMS;IACT,MAAa,SACTC,KAA8C,EAClB;QAC5B,MAAMC,SAAS,MAAMZ,WAAW,cAAc,CAACW;QAC/C,IAAI,CAACC,OAAO,OAAO,EACf,MAAMC,eAAeD,OAAO,KAAK;QAErC,MAAME,aAAa,MAAML,eAAe,cAAc,CAACG,OAAO,IAAI,CAAC,IAAI;QACvE,IAAI,CAACE,WAAW,OAAO,EACnB,MAAMD,eAAeC,WAAW,KAAK;QAEzC,OAAO;YACH,GAAGF,OAAO,IAAI;YACd,MAAM;gBACF,GAAKE,WAAW,IAAI,IAAI,CAAC,CAAC;YAC9B;QACJ;IACJ;AACJ"}
@@ -1,8 +0,0 @@
1
- import type { IWebsocketsEvent, IWebsocketsEventData, IWebsocketsIncomingEvent } from "../../handler/types.js";
2
- export type IWebsocketsEventValidatorValidateParams = IWebsocketsIncomingEvent;
3
- export interface IWebsocketsEventValidator {
4
- /**
5
- * @throws {Error}
6
- */
7
- validate<T extends IWebsocketsEventData = IWebsocketsEventData>(params: IWebsocketsEventValidatorValidateParams): Promise<IWebsocketsEvent<T>>;
8
- }
File without changes