@webiny/api-websockets 6.0.0-alpha.5 → 6.0.0-rc.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/README.md +10 -9
- package/context/WebsocketsContext.d.ts +10 -8
- package/context/WebsocketsContext.js +44 -33
- package/context/WebsocketsContext.js.map +1 -1
- package/context/abstractions/IWebsocketsContext.d.ts +10 -9
- package/context/abstractions/IWebsocketsContext.js +1 -5
- package/context/abstractions/IWebsocketsContext.js.map +1 -1
- package/context/index.d.ts +2 -3
- package/context/index.js +11 -42
- package/context/index.js.map +1 -1
- package/features/WebsocketService/abstractions.d.ts +9 -0
- package/features/WebsocketService/abstractions.js +4 -0
- package/features/WebsocketService/abstractions.js.map +1 -0
- package/features/WebsocketService/errors.d.ts +19 -0
- package/features/WebsocketService/errors.js +36 -0
- package/features/WebsocketService/errors.js.map +1 -0
- package/features/WebsocketService/index.d.ts +1 -0
- package/features/WebsocketService/index.js +3 -0
- package/features/WebsocketService/index.js.map +1 -0
- package/graphql/checkPermissions.d.ts +1 -1
- package/graphql/checkPermissions.js +6 -11
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/createResolvers.d.ts +2 -3
- package/graphql/createResolvers.js +41 -29
- package/graphql/createResolvers.js.map +1 -1
- package/graphql/createTypeDefs.js +2 -11
- package/graphql/createTypeDefs.js.map +1 -1
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +7 -14
- package/graphql/index.js.map +1 -1
- package/graphql/utils.js +5 -13
- package/graphql/utils.js.map +1 -1
- package/handler/handler.d.ts +1 -1
- package/handler/handler.js +45 -48
- package/handler/handler.js.map +1 -1
- package/handler/headers.d.ts +1 -2
- package/handler/headers.js +1 -13
- package/handler/headers.js.map +1 -1
- package/handler/register.js +5 -7
- package/handler/register.js.map +1 -1
- package/handler/types.d.ts +5 -8
- package/handler/types.js +2 -8
- package/handler/types.js.map +1 -1
- package/index.d.ts +9 -9
- package/index.js +11 -98
- package/index.js.map +1 -1
- package/package.json +28 -27
- package/plugins/WebsocketsActionPlugin.d.ts +2 -2
- package/plugins/WebsocketsActionPlugin.js +3 -11
- package/plugins/WebsocketsActionPlugin.js.map +1 -1
- package/plugins/WebsocketsRoutePlugin.d.ts +6 -7
- package/plugins/WebsocketsRoutePlugin.js +3 -11
- package/plugins/WebsocketsRoutePlugin.js.map +1 -1
- package/plugins/abstrations/IWebsocketsActionPlugin.d.ts +2 -3
- package/plugins/abstrations/IWebsocketsActionPlugin.js +1 -5
- package/plugins/abstrations/IWebsocketsActionPlugin.js.map +1 -1
- package/plugins/index.d.ts +3 -3
- package/plugins/index.js +2 -38
- package/plugins/index.js.map +1 -1
- package/registry/WebsocketsConnectionRegistry.d.ts +3 -3
- package/registry/WebsocketsConnectionRegistry.js +34 -59
- package/registry/WebsocketsConnectionRegistry.js.map +1 -1
- package/registry/abstractions/IWebsocketsConnectionRegistry.d.ts +2 -4
- package/registry/abstractions/IWebsocketsConnectionRegistry.js +1 -5
- package/registry/abstractions/IWebsocketsConnectionRegistry.js.map +1 -1
- package/registry/entity.d.ts +3 -108
- package/registry/entity.js +18 -33
- package/registry/entity.js.map +1 -1
- package/registry/index.d.ts +2 -2
- package/registry/index.js +1 -27
- package/registry/index.js.map +1 -1
- package/response/WebsocketsResponse.d.ts +1 -1
- package/response/WebsocketsResponse.js +1 -8
- package/response/WebsocketsResponse.js.map +1 -1
- package/response/abstractions/IWebsocketsResponse.d.ts +1 -1
- package/response/abstractions/IWebsocketsResponse.js +1 -5
- package/response/abstractions/IWebsocketsResponse.js.map +1 -1
- package/response/index.d.ts +2 -2
- package/response/index.js +1 -27
- package/response/index.js.map +1 -1
- package/runner/WebsocketsRunner.d.ts +6 -6
- package/runner/WebsocketsRunner.js +10 -23
- package/runner/WebsocketsRunner.js.map +1 -1
- package/runner/abstractions/IWebsocketsRunner.d.ts +2 -2
- package/runner/abstractions/IWebsocketsRunner.js +1 -5
- package/runner/abstractions/IWebsocketsRunner.js.map +1 -1
- package/runner/index.d.ts +2 -2
- package/runner/index.js +1 -27
- package/runner/index.js.map +1 -1
- package/runner/routes/connect.d.ts +1 -1
- package/runner/routes/connect.js +9 -19
- package/runner/routes/connect.js.map +1 -1
- package/runner/routes/default.d.ts +1 -1
- package/runner/routes/default.js +4 -17
- package/runner/routes/default.js.map +1 -1
- package/runner/routes/disconnect.d.ts +1 -1
- package/runner/routes/disconnect.js +4 -11
- package/runner/routes/disconnect.js.map +1 -1
- package/runner/routes/index.d.ts +1 -1
- package/runner/routes/index.js +5 -12
- package/runner/routes/index.js.map +1 -1
- package/transport/WebsocketsTransport.d.ts +2 -2
- package/transport/WebsocketsTransport.js +5 -12
- package/transport/WebsocketsTransport.js.map +1 -1
- package/transport/abstractions/IWebsocketsTransport.d.ts +2 -2
- package/transport/abstractions/IWebsocketsTransport.js +1 -5
- package/transport/abstractions/IWebsocketsTransport.js.map +1 -1
- package/transport/index.d.ts +2 -2
- package/transport/index.js +1 -27
- package/transport/index.js.map +1 -1
- package/types.d.ts +5 -5
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/utils/middleware.d.ts +1 -1
- package/utils/middleware.js +1 -8
- package/utils/middleware.js.map +1 -1
- package/validator/WebsocketsEventValidator.d.ts +2 -2
- package/validator/WebsocketsEventValidator.js +25 -34
- package/validator/WebsocketsEventValidator.js.map +1 -1
- package/validator/abstractions/IWebsocketsEventValidator.d.ts +1 -1
- package/validator/abstractions/IWebsocketsEventValidator.js +1 -5
- package/validator/abstractions/IWebsocketsEventValidator.js.map +1 -1
- package/validator/index.d.ts +2 -2
- package/validator/index.js +1 -27
- package/validator/index.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,101 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
createWebsockets: true
|
|
8
|
-
};
|
|
9
|
-
exports.createWebsockets = void 0;
|
|
10
|
-
require("./handler/register");
|
|
11
|
-
var _context = require("./context");
|
|
12
|
-
Object.keys(_context).forEach(function (key) {
|
|
13
|
-
if (key === "default" || key === "__esModule") return;
|
|
14
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
15
|
-
if (key in exports && exports[key] === _context[key]) return;
|
|
16
|
-
Object.defineProperty(exports, key, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return _context[key];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
var _graphql = require("./graphql");
|
|
24
|
-
var _validator = require("./validator");
|
|
25
|
-
Object.keys(_validator).forEach(function (key) {
|
|
26
|
-
if (key === "default" || key === "__esModule") return;
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
-
if (key in exports && exports[key] === _validator[key]) return;
|
|
29
|
-
Object.defineProperty(exports, key, {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _validator[key];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
var _transport = require("./transport");
|
|
37
|
-
Object.keys(_transport).forEach(function (key) {
|
|
38
|
-
if (key === "default" || key === "__esModule") return;
|
|
39
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
40
|
-
if (key in exports && exports[key] === _transport[key]) return;
|
|
41
|
-
Object.defineProperty(exports, key, {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return _transport[key];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
var _runner = require("./runner");
|
|
49
|
-
Object.keys(_runner).forEach(function (key) {
|
|
50
|
-
if (key === "default" || key === "__esModule") return;
|
|
51
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
52
|
-
if (key in exports && exports[key] === _runner[key]) return;
|
|
53
|
-
Object.defineProperty(exports, key, {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
get: function () {
|
|
56
|
-
return _runner[key];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
var _registry = require("./registry");
|
|
61
|
-
Object.keys(_registry).forEach(function (key) {
|
|
62
|
-
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
64
|
-
if (key in exports && exports[key] === _registry[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _registry[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _plugins = require("./plugins");
|
|
73
|
-
Object.keys(_plugins).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
76
|
-
if (key in exports && exports[key] === _plugins[key]) return;
|
|
77
|
-
Object.defineProperty(exports, key, {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return _plugins[key];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
var _types = require("./types");
|
|
85
|
-
Object.keys(_types).forEach(function (key) {
|
|
86
|
-
if (key === "default" || key === "__esModule") return;
|
|
87
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
88
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
89
|
-
Object.defineProperty(exports, key, {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
get: function () {
|
|
92
|
-
return _types[key];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
const createWebsockets = () => {
|
|
97
|
-
return [(0, _context.createWebsocketsContext)(), (0, _graphql.createWebsocketsGraphQL)()];
|
|
1
|
+
import "./handler/register.js";
|
|
2
|
+
import { createWebsocketsContext } from "./context/index.js";
|
|
3
|
+
import { createWebsocketsGraphQL } from "./graphql/index.js";
|
|
4
|
+
export const createWebsockets = () => {
|
|
5
|
+
return [createWebsocketsContext(), createWebsocketsGraphQL()];
|
|
98
6
|
};
|
|
99
|
-
|
|
7
|
+
export * from "./validator/index.js";
|
|
8
|
+
export * from "./transport/index.js";
|
|
9
|
+
export * from "./runner/index.js";
|
|
10
|
+
export * from "./registry/index.js";
|
|
11
|
+
export * from "./context/index.js";
|
|
12
|
+
export * from "./plugins/index.js";
|
|
100
13
|
|
|
101
14
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createWebsocketsContext","createWebsocketsGraphQL","createWebsockets"],"sources":["index.ts"],"sourcesContent":["import \"./handler/register.js\";\nimport type { Plugin } from \"@webiny/plugins/types.js\";\nimport { createWebsocketsContext } from \"~/context/index.js\";\nimport { createWebsocketsGraphQL } from \"~/graphql/index.js\";\n\nexport const createWebsockets = (): Plugin[] => {\n return [createWebsocketsContext(), createWebsocketsGraphQL()];\n};\n\nexport * from \"./validator/index.js\";\nexport * from \"./transport/index.js\";\nexport * from \"./runner/index.js\";\nexport * from \"./registry/index.js\";\nexport * from \"./context/index.js\";\n\nexport * from \"./plugins/index.js\";\nexport type * from \"./types.js\";\n"],"mappings":"AAAA;AAEA,SAASA,uBAAuB;AAChC,SAASC,uBAAuB;AAEhC,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAgB;EAC5C,OAAO,CAACF,uBAAuB,CAAC,CAAC,EAAEC,uBAAuB,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;AACA;AACA;AACA;AACA;AAEA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-websockets",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -10,39 +11,39 @@
|
|
|
10
11
|
"contributors": [
|
|
11
12
|
"Bruno Zorić <bruno@webiny.com>"
|
|
12
13
|
],
|
|
14
|
+
"exports": {
|
|
15
|
+
"./*": "./*",
|
|
16
|
+
".": "./index.js"
|
|
17
|
+
},
|
|
13
18
|
"license": "MIT",
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@webiny/api": "6.0.0-
|
|
16
|
-
"@webiny/api-
|
|
17
|
-
"@webiny/
|
|
18
|
-
"@webiny/
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/handler": "6.0.0-
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"zod": "3.23.8"
|
|
20
|
+
"@webiny/api": "6.0.0-rc.0",
|
|
21
|
+
"@webiny/api-core": "6.0.0-rc.0",
|
|
22
|
+
"@webiny/aws-sdk": "6.0.0-rc.0",
|
|
23
|
+
"@webiny/db-dynamodb": "6.0.0-rc.0",
|
|
24
|
+
"@webiny/error": "6.0.0-rc.0",
|
|
25
|
+
"@webiny/feature": "6.0.0-rc.0",
|
|
26
|
+
"@webiny/handler": "6.0.0-rc.0",
|
|
27
|
+
"@webiny/handler-aws": "6.0.0-rc.0",
|
|
28
|
+
"@webiny/plugins": "6.0.0-rc.0",
|
|
29
|
+
"@webiny/utils": "6.0.0-rc.0",
|
|
30
|
+
"type-fest": "5.4.4",
|
|
31
|
+
"zod": "3.25.76"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
30
|
-
"@webiny/api-headless-cms": "6.0.0-
|
|
31
|
-
"@webiny/
|
|
32
|
-
"@webiny/handler-db": "6.0.0-
|
|
33
|
-
"@webiny/handler-graphql": "6.0.0-
|
|
34
|
-
"@webiny/project-utils": "6.0.0-
|
|
35
|
-
"graphql": "
|
|
36
|
-
"rimraf": "6.
|
|
37
|
-
"typescript": "5.
|
|
34
|
+
"@webiny/api-headless-cms": "6.0.0-rc.0",
|
|
35
|
+
"@webiny/build-tools": "6.0.0-rc.0",
|
|
36
|
+
"@webiny/handler-db": "6.0.0-rc.0",
|
|
37
|
+
"@webiny/handler-graphql": "6.0.0-rc.0",
|
|
38
|
+
"@webiny/project-utils": "6.0.0-rc.0",
|
|
39
|
+
"graphql": "16.12.0",
|
|
40
|
+
"rimraf": "6.1.3",
|
|
41
|
+
"typescript": "5.9.3",
|
|
42
|
+
"vitest": "4.0.18"
|
|
38
43
|
},
|
|
39
44
|
"publishConfig": {
|
|
40
45
|
"access": "public",
|
|
41
46
|
"directory": "dist"
|
|
42
47
|
},
|
|
43
|
-
"
|
|
44
|
-
"build": "node ../cli/bin.js run build",
|
|
45
|
-
"watch": "node ../cli/bin.js run watch"
|
|
46
|
-
},
|
|
47
|
-
"gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
|
|
48
|
+
"gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
|
|
48
49
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { GenericRecord } from "@webiny/api/types";
|
|
3
|
-
import type { IWebsocketsActionPluginCallable, IWebsocketsActionPluginCallableParams, WebsocketsActionPluginCallableResponse } from "./abstrations/IWebsocketsActionPlugin";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
import type { IWebsocketsActionPluginCallable, IWebsocketsActionPluginCallableParams, WebsocketsActionPluginCallableResponse } from "./abstrations/IWebsocketsActionPlugin.js";
|
|
4
4
|
export declare class WebsocketsActionPlugin<T extends GenericRecord = GenericRecord> extends Plugin {
|
|
5
5
|
static readonly type: string;
|
|
6
6
|
readonly action: string;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createWebsocketsAction = exports.WebsocketsActionPlugin = void 0;
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
8
|
-
class WebsocketsActionPlugin extends _plugins.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
export class WebsocketsActionPlugin extends Plugin {
|
|
9
3
|
static type = "websockets.route.action";
|
|
10
4
|
constructor(action, cb) {
|
|
11
5
|
super();
|
|
@@ -16,10 +10,8 @@ class WebsocketsActionPlugin extends _plugins.Plugin {
|
|
|
16
10
|
return this.cb(params);
|
|
17
11
|
}
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
const createWebsocketsAction = (action, cb) => {
|
|
13
|
+
export const createWebsocketsAction = (action, cb) => {
|
|
21
14
|
return new WebsocketsActionPlugin(action, cb);
|
|
22
15
|
};
|
|
23
|
-
exports.createWebsocketsAction = createWebsocketsAction;
|
|
24
16
|
|
|
25
17
|
//# sourceMappingURL=WebsocketsActionPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","WebsocketsActionPlugin","type","constructor","action","cb","run","params","createWebsocketsAction"],"sources":["WebsocketsActionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type {\n IWebsocketsActionPluginCallable,\n IWebsocketsActionPluginCallableParams,\n WebsocketsActionPluginCallableResponse\n} from \"./abstrations/IWebsocketsActionPlugin.js\";\n\nexport class WebsocketsActionPlugin<T extends GenericRecord = GenericRecord> extends Plugin {\n public static override readonly type: string = \"websockets.route.action\";\n\n public readonly action: string;\n private readonly cb: IWebsocketsActionPluginCallable<T>;\n\n public constructor(action: string, cb: IWebsocketsActionPluginCallable<T>) {\n super();\n this.action = action;\n this.cb = cb;\n }\n\n public run(\n params: IWebsocketsActionPluginCallableParams\n ): Promise<WebsocketsActionPluginCallableResponse<T>> {\n return this.cb(params);\n }\n}\n\nexport const createWebsocketsAction = <T extends GenericRecord = GenericRecord>(\n action: string,\n cb: IWebsocketsActionPluginCallable<T>\n) => {\n return new WebsocketsActionPlugin<T>(action, cb);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAQxC,OAAO,MAAMC,sBAAsB,SAAkDD,MAAM,CAAC;EACxF,OAAgCE,IAAI,GAAW,yBAAyB;EAKjEC,WAAWA,CAACC,MAAc,EAAEC,EAAsC,EAAE;IACvE,KAAK,CAAC,CAAC;IACP,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEOC,GAAGA,CACNC,MAA6C,EACK;IAClD,OAAO,IAAI,CAACF,EAAE,CAACE,MAAM,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMC,sBAAsB,GAAGA,CAClCJ,MAAc,EACdC,EAAsC,KACrC;EACD,OAAO,IAAIJ,sBAAsB,CAAIG,MAAM,EAAEC,EAAE,CAAC;AACpD,CAAC","ignoreList":[]}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { IWebsocketsEvent, IWebsocketsEventData, WebsocketsEventRoute } from "../handler/types";
|
|
3
|
-
import type { Context } from "../types";
|
|
4
|
-
import type { IWebsocketsRunnerResponse } from "../runner";
|
|
5
|
-
import type { IWebsocketsConnectionRegistry } from "../registry";
|
|
6
|
-
import type { IWebsocketsResponse } from "../response/abstractions/IWebsocketsResponse";
|
|
7
|
-
import type { IWebsocketsIdentity } from "../context";
|
|
2
|
+
import type { IWebsocketsEvent, IWebsocketsEventData, WebsocketsEventRoute } from "../handler/types.js";
|
|
3
|
+
import type { Context } from "../types.js";
|
|
4
|
+
import type { IWebsocketsRunnerResponse } from "../runner/index.js";
|
|
5
|
+
import type { IWebsocketsConnectionRegistry } from "../registry/index.js";
|
|
6
|
+
import type { IWebsocketsResponse } from "../response/abstractions/IWebsocketsResponse.js";
|
|
7
|
+
import type { IWebsocketsIdentity } from "../context/index.js";
|
|
8
8
|
export interface IWebsocketsRoutePluginCallableParams<C extends Context = Context, R extends IWebsocketsRunnerResponse = IWebsocketsRunnerResponse, T extends IWebsocketsEventData = IWebsocketsEventData> {
|
|
9
9
|
event: IWebsocketsEvent<T>;
|
|
10
10
|
registry: IWebsocketsConnectionRegistry;
|
|
11
11
|
context: C;
|
|
12
12
|
response: IWebsocketsResponse;
|
|
13
13
|
getTenant: () => string | null;
|
|
14
|
-
getLocale: () => string | null;
|
|
15
14
|
getIdentity: () => IWebsocketsIdentity | null;
|
|
16
15
|
next: () => Promise<R>;
|
|
17
16
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createWebsocketsRoutePlugin = exports.WebsocketsRoutePlugin = void 0;
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
8
|
-
class WebsocketsRoutePlugin extends _plugins.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
export class WebsocketsRoutePlugin extends Plugin {
|
|
9
3
|
static type = "websockets.route";
|
|
10
4
|
constructor(route, cb) {
|
|
11
5
|
super();
|
|
@@ -16,10 +10,8 @@ class WebsocketsRoutePlugin extends _plugins.Plugin {
|
|
|
16
10
|
return this.cb(params);
|
|
17
11
|
}
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
const createWebsocketsRoutePlugin = (route, cb) => {
|
|
13
|
+
export const createWebsocketsRoutePlugin = (route, cb) => {
|
|
21
14
|
return new WebsocketsRoutePlugin(route, cb);
|
|
22
15
|
};
|
|
23
|
-
exports.createWebsocketsRoutePlugin = createWebsocketsRoutePlugin;
|
|
24
16
|
|
|
25
17
|
//# sourceMappingURL=WebsocketsRoutePlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","WebsocketsRoutePlugin","type","constructor","route","cb","run","params","createWebsocketsRoutePlugin"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAkCxC,OAAO,MAAMC,qBAAqB,SAIxBD,MAAM,CAAC;EACb,OAAgCE,IAAI,GAAW,kBAAkB;EAK1DC,WAAWA,CACdC,KAAoC,EACpCC,EAA2C,EAC7C;IACE,KAAK,CAAC,CAAC;IACP,IAAI,CAACD,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,GAAGA,CAACC,MAAqD,EAAc;IAChF,OAAO,IAAI,CAACF,EAAE,CAACE,MAAM,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMC,2BAA2B,GAAGA,CAKvCJ,KAAoC,EACpCC,EAA2C,KAC1C;EACD,OAAO,IAAIJ,qBAAqB,CAAUG,KAAK,EAAEC,EAAE,CAAC;AACxD,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { GenericRecord } from "@webiny/api/types";
|
|
2
|
-
import type { Context } from "../../types";
|
|
1
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
2
|
+
import type { Context } from "../../types.js";
|
|
3
3
|
export interface IWebsocketsActionPluginCallableParamsSend {
|
|
4
4
|
toConnection<T extends GenericRecord = GenericRecord>(connectionId: string, data: T): Promise<void>;
|
|
5
5
|
toTenant<T extends GenericRecord = GenericRecord>(tenant: string, data: T): Promise<void>;
|
|
6
|
-
toTenantAndLocale<T extends GenericRecord = GenericRecord>(tenant: string, locale: string, data: T): Promise<void>;
|
|
7
6
|
toIdentity<T extends GenericRecord = GenericRecord>(identity: string, data: T): Promise<void>;
|
|
8
7
|
}
|
|
9
8
|
export interface IWebsocketsActionPluginCallableParamsRespondError<T extends GenericRecord = GenericRecord> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["IWebsocketsActionPlugin.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types\";\nimport type { Context } from \"~/types\";\n\nexport interface IWebsocketsActionPluginCallableParamsSend {\n toConnection<T extends GenericRecord = GenericRecord>(\n connectionId: string,\n data: T\n ): Promise<void>;\n toTenant<T extends GenericRecord = GenericRecord>(tenant: string, data: T): Promise<void>;\n
|
|
1
|
+
{"version":3,"names":[],"sources":["IWebsocketsActionPlugin.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IWebsocketsActionPluginCallableParamsSend {\n toConnection<T extends GenericRecord = GenericRecord>(\n connectionId: string,\n data: T\n ): Promise<void>;\n toTenant<T extends GenericRecord = GenericRecord>(tenant: string, data: T): Promise<void>;\n toIdentity<T extends GenericRecord = GenericRecord>(identity: string, data: T): Promise<void>;\n}\n\nexport interface IWebsocketsActionPluginCallableParamsRespondError<\n T extends GenericRecord = GenericRecord\n> {\n message: string;\n code: string;\n data: T;\n}\n\nexport interface IWebsocketsActionPluginCallableParamsRespondOkResponse<\n T extends GenericRecord = GenericRecord\n> {\n data: T;\n error?: never;\n}\n\nexport interface IWebsocketsActionPluginCallableParamsRespondErrorResponse<\n T extends GenericRecord = GenericRecord\n> {\n error: IWebsocketsActionPluginCallableParamsRespondError<T>;\n data?: never;\n}\n\nexport interface IWebsocketsActionPluginCallableParamsRespond {\n ok<T extends GenericRecord = GenericRecord>(\n data: T\n ): Promise<IWebsocketsActionPluginCallableParamsRespondOkResponse<T>>;\n error<T extends GenericRecord = GenericRecord>(\n error: IWebsocketsActionPluginCallableParamsRespondError<T>\n ): Promise<IWebsocketsActionPluginCallableParamsRespondErrorResponse<T>>;\n}\n\nexport interface IWebsocketsActionPluginCallableParams<C extends Context = Context> {\n context: C;\n next(): Promise<void>;\n send: IWebsocketsActionPluginCallableParamsSend;\n respond: IWebsocketsActionPluginCallableParamsRespond;\n}\n\nexport type WebsocketsActionPluginCallableResponse<T extends GenericRecord = GenericRecord> =\n | IWebsocketsActionPluginCallableParamsRespondOkResponse<T>\n | IWebsocketsActionPluginCallableParamsRespondErrorResponse<T>;\n\nexport interface IWebsocketsActionPluginCallable<T extends GenericRecord = GenericRecord> {\n (\n params: IWebsocketsActionPluginCallableParams\n ): Promise<WebsocketsActionPluginCallableResponse<T>>;\n}\n"],"mappings":"","ignoreList":[]}
|
package/plugins/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./WebsocketsRoutePlugin";
|
|
2
|
-
export * from "./WebsocketsActionPlugin";
|
|
3
|
-
export * from "./abstrations/IWebsocketsActionPlugin";
|
|
1
|
+
export * from "./WebsocketsRoutePlugin.js";
|
|
2
|
+
export * from "./WebsocketsActionPlugin.js";
|
|
3
|
+
export type * from "./abstrations/IWebsocketsActionPlugin.js";
|
package/plugins/index.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _WebsocketsRoutePlugin = require("./WebsocketsRoutePlugin");
|
|
7
|
-
Object.keys(_WebsocketsRoutePlugin).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _WebsocketsRoutePlugin[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _WebsocketsRoutePlugin[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _WebsocketsActionPlugin = require("./WebsocketsActionPlugin");
|
|
18
|
-
Object.keys(_WebsocketsActionPlugin).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _WebsocketsActionPlugin[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _WebsocketsActionPlugin[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _IWebsocketsActionPlugin = require("./abstrations/IWebsocketsActionPlugin");
|
|
29
|
-
Object.keys(_IWebsocketsActionPlugin).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _IWebsocketsActionPlugin[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _IWebsocketsActionPlugin[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
1
|
+
export * from "./WebsocketsRoutePlugin.js";
|
|
2
|
+
export * from "./WebsocketsActionPlugin.js";
|
|
39
3
|
|
|
40
4
|
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./WebsocketsRoutePlugin.js\";\nexport * from \"./WebsocketsActionPlugin.js\";\nexport type * from \"./abstrations/IWebsocketsActionPlugin.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IWebsocketsConnectionRegistry, IWebsocketsConnectionRegistryData, IWebsocketsConnectionRegistryRegisterParams, IWebsocketsConnectionRegistryUnregisterParams } from "./abstractions/IWebsocketsConnectionRegistry";
|
|
2
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
1
|
+
import type { IWebsocketsConnectionRegistry, IWebsocketsConnectionRegistryData, IWebsocketsConnectionRegistryRegisterParams, IWebsocketsConnectionRegistryUnregisterParams } from "./abstractions/IWebsocketsConnectionRegistry.js";
|
|
2
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
3
|
export declare class WebsocketsConnectionRegistry implements IWebsocketsConnectionRegistry {
|
|
4
4
|
private readonly entity;
|
|
5
5
|
constructor(documentClient: DynamoDBDocument);
|
|
@@ -17,7 +17,7 @@ export declare class WebsocketsConnectionRegistry implements IWebsocketsConnecti
|
|
|
17
17
|
/**
|
|
18
18
|
* Uses GSI2 keys
|
|
19
19
|
*/
|
|
20
|
-
listViaTenant(tenant: string
|
|
20
|
+
listViaTenant(tenant: string): Promise<IWebsocketsConnectionRegistryData[]>;
|
|
21
21
|
listAll(): Promise<IWebsocketsConnectionRegistryData[]>;
|
|
22
22
|
private store;
|
|
23
23
|
}
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.WebsocketsConnectionRegistry = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _entity = require("./entity");
|
|
10
|
-
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { createEntity } from "./entity.js";
|
|
11
3
|
const PK = `WS#CONNECTIONS`;
|
|
12
4
|
const GSI1_PK = "WS#CONNECTIONS#IDENTITY";
|
|
13
|
-
const GSI2_PK = "WS#CONNECTIONS#TENANT
|
|
14
|
-
class WebsocketsConnectionRegistry {
|
|
5
|
+
const GSI2_PK = "WS#CONNECTIONS#TENANT";
|
|
6
|
+
export class WebsocketsConnectionRegistry {
|
|
15
7
|
constructor(documentClient) {
|
|
16
|
-
this.entity =
|
|
8
|
+
this.entity = createEntity(documentClient);
|
|
17
9
|
}
|
|
18
10
|
async register(params) {
|
|
19
11
|
const {
|
|
20
12
|
connectionId,
|
|
21
13
|
tenant,
|
|
22
|
-
locale,
|
|
23
14
|
identity,
|
|
24
15
|
domainName,
|
|
25
16
|
stage,
|
|
@@ -29,7 +20,6 @@ class WebsocketsConnectionRegistry {
|
|
|
29
20
|
connectionId,
|
|
30
21
|
identity,
|
|
31
22
|
tenant,
|
|
32
|
-
locale,
|
|
33
23
|
domainName,
|
|
34
24
|
stage,
|
|
35
25
|
connectedOn
|
|
@@ -49,26 +39,23 @@ class WebsocketsConnectionRegistry {
|
|
|
49
39
|
if (!original) {
|
|
50
40
|
const message = `There is no connection with ID "${connectionId}".`;
|
|
51
41
|
console.error(message);
|
|
52
|
-
throw new
|
|
42
|
+
throw new WebinyError(message, "CONNECTION_NOT_FOUND", keys);
|
|
53
43
|
}
|
|
54
44
|
try {
|
|
55
|
-
await (
|
|
56
|
-
entity: this.entity,
|
|
57
|
-
keys
|
|
58
|
-
});
|
|
45
|
+
await this.entity.delete(keys);
|
|
59
46
|
} catch (ex) {
|
|
60
47
|
console.error(`Could not remove connection from the database: ${original.connectionId}`);
|
|
61
|
-
throw new
|
|
48
|
+
throw new WebinyError(ex.message, ex.code, keys);
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
51
|
async getViaConnection(connectionId) {
|
|
65
|
-
const item = await
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
PK,
|
|
69
|
-
SK: connectionId
|
|
70
|
-
}
|
|
52
|
+
const item = await this.entity.get({
|
|
53
|
+
PK,
|
|
54
|
+
SK: connectionId
|
|
71
55
|
});
|
|
56
|
+
if (!item) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
72
59
|
return item?.data || null;
|
|
73
60
|
}
|
|
74
61
|
|
|
@@ -76,16 +63,15 @@ class WebsocketsConnectionRegistry {
|
|
|
76
63
|
* Uses Primary keys
|
|
77
64
|
*/
|
|
78
65
|
async listViaConnections(connections) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
table: this.entity.table,
|
|
87
|
-
items
|
|
66
|
+
const reader = this.entity.createEntityReader({
|
|
67
|
+
read: connections.map(id => {
|
|
68
|
+
return {
|
|
69
|
+
PK,
|
|
70
|
+
SK: id
|
|
71
|
+
};
|
|
72
|
+
})
|
|
88
73
|
});
|
|
74
|
+
const results = await reader.execute();
|
|
89
75
|
return results.map(item => {
|
|
90
76
|
return item.data;
|
|
91
77
|
});
|
|
@@ -95,8 +81,7 @@ class WebsocketsConnectionRegistry {
|
|
|
95
81
|
* Uses GSI1 keys
|
|
96
82
|
*/
|
|
97
83
|
async listViaIdentity(identity) {
|
|
98
|
-
const items = await
|
|
99
|
-
entity: this.entity,
|
|
84
|
+
const items = await this.entity.queryAll({
|
|
100
85
|
partitionKey: GSI1_PK,
|
|
101
86
|
options: {
|
|
102
87
|
index: "GSI1",
|
|
@@ -111,17 +96,11 @@ class WebsocketsConnectionRegistry {
|
|
|
111
96
|
/**
|
|
112
97
|
* Uses GSI2 keys
|
|
113
98
|
*/
|
|
114
|
-
async listViaTenant(tenant
|
|
115
|
-
|
|
116
|
-
beginsWith: `T#${tenant}
|
|
99
|
+
async listViaTenant(tenant) {
|
|
100
|
+
const options = {
|
|
101
|
+
beginsWith: `T#${tenant}`
|
|
117
102
|
};
|
|
118
|
-
|
|
119
|
-
options = {
|
|
120
|
-
eq: `T#${tenant}#L#${locale}`
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
const items = await (0, _dbDynamodb.queryAll)({
|
|
124
|
-
entity: this.entity,
|
|
103
|
+
const items = await this.entity.queryAll({
|
|
125
104
|
partitionKey: GSI2_PK,
|
|
126
105
|
options: {
|
|
127
106
|
...options,
|
|
@@ -133,8 +112,7 @@ class WebsocketsConnectionRegistry {
|
|
|
133
112
|
});
|
|
134
113
|
}
|
|
135
114
|
async listAll() {
|
|
136
|
-
const items = await
|
|
137
|
-
entity: this.entity,
|
|
115
|
+
const items = await this.entity.queryAll({
|
|
138
116
|
partitionKey: PK,
|
|
139
117
|
options: {
|
|
140
118
|
gte: " "
|
|
@@ -148,7 +126,6 @@ class WebsocketsConnectionRegistry {
|
|
|
148
126
|
const {
|
|
149
127
|
connectionId,
|
|
150
128
|
tenant,
|
|
151
|
-
locale,
|
|
152
129
|
identity
|
|
153
130
|
} = data;
|
|
154
131
|
const item = {
|
|
@@ -158,18 +135,17 @@ class WebsocketsConnectionRegistry {
|
|
|
158
135
|
// to find all connections related to given identity
|
|
159
136
|
GSI1_PK,
|
|
160
137
|
GSI1_SK: identity.id,
|
|
161
|
-
// to find all connections related to given tenant
|
|
138
|
+
// to find all connections related to given tenant
|
|
162
139
|
GSI2_PK,
|
|
163
|
-
GSI2_SK: `T#${tenant}
|
|
140
|
+
GSI2_SK: `T#${tenant}`,
|
|
141
|
+
GSI_TENANT: tenant,
|
|
142
|
+
TYPE: "ws.connection",
|
|
164
143
|
data
|
|
165
144
|
};
|
|
166
145
|
try {
|
|
167
|
-
return await
|
|
168
|
-
entity: this.entity,
|
|
169
|
-
item
|
|
170
|
-
});
|
|
146
|
+
return await this.entity.put(item);
|
|
171
147
|
} catch (err) {
|
|
172
|
-
throw
|
|
148
|
+
throw WebinyError.from(err, {
|
|
173
149
|
message: "Could not store websockets connection data.",
|
|
174
150
|
code: "STORE_WEBSOCKETS_CONNECTION_DATA_ERROR",
|
|
175
151
|
data: item
|
|
@@ -177,6 +153,5 @@ class WebsocketsConnectionRegistry {
|
|
|
177
153
|
}
|
|
178
154
|
}
|
|
179
155
|
}
|
|
180
|
-
exports.WebsocketsConnectionRegistry = WebsocketsConnectionRegistry;
|
|
181
156
|
|
|
182
157
|
//# sourceMappingURL=WebsocketsConnectionRegistry.js.map
|