♻️Removed unused websockets

This commit is contained in:
Anton SHEPILOV
2024-05-24 00:19:31 +02:00
parent 757a4759f8
commit 6f0bfbcd09
51 changed files with 7 additions and 1620 deletions
@@ -19,7 +19,6 @@ describe("The Documents Browser Window and API", () => {
"user",
"files",
"auth",
"realtime",
"statistics",
"platform-services",
"documents",
@@ -28,10 +28,8 @@ describe("the Drive feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
@@ -45,10 +45,8 @@ describe("the Drive feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
@@ -25,10 +25,8 @@ describe("the Drive Search feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"statistics",
"platform-services",
@@ -39,10 +39,8 @@ describe("the Drive Tdrive tabs feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
@@ -32,10 +32,8 @@ describe("the Drive feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
@@ -44,10 +44,8 @@ describe("the My Drive feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
@@ -44,10 +44,8 @@ describe("the public links feature", () => {
"user",
"search",
"files",
"websocket",
"messages",
"auth",
"realtime",
"channels",
"counter",
"statistics",
@@ -12,16 +12,6 @@
"endpoint": "http://localhost:9200"
}
},
"websocket": {
"path": "/socket",
"adapters": {
"types": ["redis"],
"redis": {
"host": "localhost",
"port": 6379
}
}
},
"auth": {
"jwt": {
"secret": "supersecret"
@@ -22,7 +22,6 @@ describe("The /users/quota API", () => {
"database",
"search",
"message-queue",
"websocket",
"applications",
"webserver",
"user",
@@ -13,7 +13,6 @@ describe("The /users API", () => {
"database",
"search",
"message-queue",
"websocket",
"webserver",
"user",
"auth",
@@ -27,7 +27,6 @@ describe("The /users API", () => {
"database",
"search",
"message-queue",
"websocket",
"applications",
"webserver",
"user",
@@ -1,116 +0,0 @@
import { describe, expect, it, jest } from "@jest/globals";
import { CreateResult } from "../../../../../../../src/core/platform/framework/api/crud-service";
import { RealtimeCreated } from "../../../../../../../src/core/platform/framework/decorators";
import { websocketEventBus } from "../../../../../../../src/core/platform/services/realtime/bus";
import { ResourcePath } from "../../../../../../../src/core/platform/services/realtime/types";
describe("The RealtimeCreated decorator", () => {
it("should call the original method send back original result but do not emit event if result type is wrong", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeCreated({ room: "/foo/bar" })
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
reverseMeBaby(input: string): Promise<string> {
return Promise.resolve(input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(0);
emitSpy.mockRestore();
});
it("should call the original method send back original result and emit event", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeCreated({ room: "/foo/bar", path: "/foo/bar/baz" })
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async reverseMeBaby(input: string): Promise<CreateResult<string>> {
return new CreateResult<string>("string", input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result.entity).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(emitSpy).toHaveBeenCalledWith("created", {
room: {
name: "default",
path: ["/foo/bar"],
} as ResourcePath,
resourcePath: "/foo/bar/baz",
entity: "oloy",
type: "string",
result: {
entity: "oloy",
type: "string",
context: undefined,
operation: "create",
raw: undefined,
} as CreateResult<string>,
});
emitSpy.mockRestore();
});
it("should emit event with path computed from function", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeCreated<string>(input => [
{ room: ResourcePath.get(`/foo/bar/${input}`), path: "/foo/bar/baz" },
])
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async reverseMeBaby(input: string): Promise<CreateResult<string>> {
return new CreateResult<string>("string", input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result.entity).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(emitSpy).toHaveBeenCalledWith("created", {
room: {
name: "default",
path: ["/foo/bar/oloy"],
} as ResourcePath,
resourcePath: "/foo/bar/baz",
entity: "oloy",
type: "string",
result: {
entity: "oloy",
context: undefined,
operation: "create",
type: "string",
raw: undefined,
} as CreateResult<string>,
});
emitSpy.mockRestore();
});
});
@@ -1,116 +0,0 @@
import { describe, expect, it, jest } from "@jest/globals";
import { DeleteResult } from "../../../../../../../src/core/platform/framework/api/crud-service";
import { RealtimeDeleted } from "../../../../../../../src/core/platform/framework/decorators";
import { websocketEventBus } from "../../../../../../../src/core/platform/services/realtime/bus";
import { ResourcePath } from "../../../../../../../src/core/platform/services/realtime/types";
describe("The RealtimeDeleted decorator", () => {
it("should call the original method send back original result but do not emit event if result type is wrong", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeDeleted({ room: "/foo/bar" })
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
reverseMeBaby(input: string): Promise<string> {
return Promise.resolve(input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(0);
emitSpy.mockRestore();
});
it("should call the original method send back original result and emit event", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeDeleted({ room: "/foo/bar", path: "/foo/bar/baz" })
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async reverseMeBaby(input: string): Promise<DeleteResult<string>> {
return new DeleteResult<string>("string", input.split("").reverse().join(""), true);
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result.entity).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(emitSpy).toHaveBeenCalledWith("deleted", {
room: {
name: "default",
path: ["/foo/bar"],
} as ResourcePath,
resourcePath: "/foo/bar/baz",
entity: "oloy",
type: "string",
result: {
entity: "oloy",
context: undefined,
operation: "delete",
deleted: true,
type: "string",
} as DeleteResult<string>,
});
emitSpy.mockRestore();
});
it("should emit event with path computed from function", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeDeleted(result => [
{ room: ResourcePath.get(`/foo/bar/${result}`), path: "/foo/bar/baz" },
])
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async reverseMeBaby(input: string): Promise<DeleteResult<string>> {
return new DeleteResult<string>("string", input.split("").reverse().join(""), true);
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result.entity).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(emitSpy).toHaveBeenCalledWith("deleted", {
room: {
name: "default",
path: ["/foo/bar/oloy"],
} as ResourcePath,
resourcePath: "/foo/bar/baz",
entity: "oloy",
type: "string",
result: {
entity: "oloy",
context: undefined,
operation: "delete",
deleted: true,
type: "string",
} as DeleteResult<string>,
});
emitSpy.mockRestore();
});
});
@@ -1,118 +0,0 @@
import { describe, expect, it, jest } from "@jest/globals";
import { UpdateResult } from "../../../../../../../src/core/platform/framework/api/crud-service";
import { RealtimeUpdated } from "../../../../../../../src/core/platform/framework/decorators";
import { websocketEventBus } from "../../../../../../../src/core/platform/services/realtime/bus";
import { ResourcePath } from "../../../../../../../src/core/platform/services/realtime/types";
describe("The RealtimeUpdated decorator", () => {
it("should call the original method send back original result but do not emit event if result type is wrong", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeUpdated({ room: "/foo/bar" })
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
reverseMeBaby(input: string): Promise<string> {
return Promise.resolve(input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(0);
emitSpy.mockRestore();
});
it("should call the original method send back original result and emit event", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeUpdated({ room: "/foo/bar", path: "/foo/bar/baz" })
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async reverseMeBaby(input: string): Promise<UpdateResult<string>> {
return new UpdateResult<string>("string", input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result.entity).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(emitSpy).toHaveBeenCalledWith("updated", {
entity: "oloy",
room: {
name: "default",
path: ["/foo/bar"],
} as ResourcePath,
resourcePath: "/foo/bar/baz",
type: "string",
result: {
type: "string",
entity: "oloy",
affected: undefined,
context: undefined,
operation: "update",
raw: undefined,
} as UpdateResult<string>,
});
emitSpy.mockRestore();
});
it("should emit event with path computed from function", async () => {
const emitSpy = jest.spyOn(websocketEventBus, "emit");
class TestMe {
@RealtimeUpdated(result => [
{ room: ResourcePath.get(`/foo/bar/${result}`), path: "/foo/bar/baz" },
])
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
async reverseMeBaby(input: string): Promise<UpdateResult<string>> {
return new UpdateResult<string>("string", input.split("").reverse().join(""));
}
}
const test = new TestMe();
const originalSpy = jest.spyOn(test, "reverseMeBaby");
const result = await test.reverseMeBaby("yolo");
expect(result.entity).toEqual("oloy");
expect(originalSpy).toHaveBeenCalledTimes(1);
expect(originalSpy).toHaveBeenCalledWith("yolo");
expect(emitSpy).toHaveBeenCalledTimes(1);
expect(emitSpy).toHaveBeenCalledWith("updated", {
entity: "oloy",
room: {
name: "default",
path: ["/foo/bar/oloy"],
} as ResourcePath,
resourcePath: "/foo/bar/baz",
type: "string",
result: {
type: "string",
context: undefined,
operation: "update",
entity: "oloy",
affected: undefined,
raw: undefined,
} as UpdateResult<string>,
});
emitSpy.mockRestore();
});
});