@ludeo/cloud-common 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/decorators/validate-nested-type.decorator.d.ts +2 -1
- package/dist/decorators/validate-nested-type.decorator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/v3/contexts/cloud-pool-context.d.ts +6 -0
- package/dist/v3/contexts/cloud-pool-context.js +31 -0
- package/dist/v3/contexts/cloud-pool-context.js.map +1 -0
- package/dist/v3/contexts/cloud-session-context.d.ts +14 -0
- package/dist/v3/contexts/cloud-session-context.js +71 -0
- package/dist/v3/contexts/cloud-session-context.js.map +1 -0
- package/dist/v3/contexts/getCloudContextType.d.ts +4 -0
- package/dist/v3/contexts/getCloudContextType.js +17 -0
- package/dist/v3/contexts/getCloudContextType.js.map +1 -0
- package/dist/v3/contexts/getCloudContextType.spec.d.ts +1 -0
- package/dist/v3/contexts/getCloudContextType.spec.js +95 -0
- package/dist/v3/contexts/getCloudContextType.spec.js.map +1 -0
- package/dist/v3/contexts/index.d.ts +3 -0
- package/dist/v3/contexts/index.js +3 -0
- package/dist/v3/contexts/index.js.map +1 -1
- package/dist/v3/events/deallocate-machine-request.d.ts +15 -0
- package/dist/v3/events/deallocate-machine-request.js +53 -0
- package/dist/v3/events/deallocate-machine-request.js.map +1 -0
- package/dist/v3/events/game-resource-allocated-response.d.ts +14 -0
- package/dist/v3/events/game-resource-allocated-response.js +50 -0
- package/dist/v3/events/game-resource-allocated-response.js.map +1 -0
- package/dist/v3/events/game-resource-allocation-failed-response.d.ts +13 -0
- package/dist/v3/events/game-resource-allocation-failed-response.js +49 -0
- package/dist/v3/events/game-resource-allocation-failed-response.js.map +1 -0
- package/dist/v3/events/game-resource-created-response.d.ts +15 -0
- package/dist/v3/events/game-resource-created-response.js +54 -0
- package/dist/v3/events/game-resource-created-response.js.map +1 -0
- package/dist/v3/events/game-resource-creation-failed-response.d.ts +13 -0
- package/dist/v3/events/game-resource-creation-failed-response.js +49 -0
- package/dist/v3/events/game-resource-creation-failed-response.js.map +1 -0
- package/dist/v3/events/game-resource-terminated-response.d.ts +12 -0
- package/dist/v3/events/game-resource-terminated-response.js +45 -0
- package/dist/v3/events/game-resource-terminated-response.js.map +1 -0
- package/dist/v3/events/game-resource-termination-failed-response.d.ts +13 -0
- package/dist/v3/events/game-resource-termination-failed-response.js +49 -0
- package/dist/v3/events/game-resource-termination-failed-response.js.map +1 -0
- package/dist/v3/events/index.d.ts +12 -4
- package/dist/v3/events/index.js +12 -4
- package/dist/v3/events/index.js.map +1 -1
- package/dist/v3/events/machine-allocation-failed-response.d.ts +14 -0
- package/dist/v3/events/machine-allocation-failed-response.js +53 -0
- package/dist/v3/events/machine-allocation-failed-response.js.map +1 -0
- package/dist/v3/events/machine-deallocated-response.d.ts +15 -0
- package/dist/v3/events/machine-deallocated-response.js +53 -0
- package/dist/v3/events/machine-deallocated-response.js.map +1 -0
- package/dist/v3/events/machine-deallocation-failed-response.d.ts +16 -0
- package/dist/v3/events/machine-deallocation-failed-response.js +57 -0
- package/dist/v3/events/machine-deallocation-failed-response.js.map +1 -0
- package/dist/v3/events/machine-resource-created-response.d.ts +12 -0
- package/dist/v3/events/machine-resource-created-response.js +45 -0
- package/dist/v3/events/machine-resource-created-response.js.map +1 -0
- package/dist/v3/events/machine-resource-creation-failed-response.d.ts +13 -0
- package/dist/v3/events/machine-resource-creation-failed-response.js +49 -0
- package/dist/v3/events/machine-resource-creation-failed-response.js.map +1 -0
- package/dist/v3/events/swap-cloud-user-request-failed.d.ts +1 -0
- package/dist/v3/events/swap-cloud-user-request-failed.js +4 -0
- package/dist/v3/events/swap-cloud-user-request-failed.js.map +1 -1
- package/package.json +1 -1
- package/src/decorators/validate-nested-type.decorator.ts +4 -2
- package/src/v3/contexts/cloud-pool-context.ts +14 -0
- package/src/v3/contexts/cloud-session-context.ts +46 -0
- package/src/v3/contexts/getCloudContextType.spec.ts +102 -0
- package/src/v3/contexts/getCloudContextType.ts +16 -0
- package/src/v3/contexts/index.ts +3 -0
- package/src/v3/events/deallocate-machine-request.ts +41 -0
- package/src/v3/events/{game-allocated-response.ts → game-resource-allocated-response.ts} +4 -3
- package/src/v3/events/game-resource-allocation-failed-response.ts +36 -0
- package/src/v3/events/{game-created-response.ts → game-resource-created-response.ts} +3 -3
- package/src/v3/events/game-resource-creation-failed-response.ts +36 -0
- package/src/v3/events/{game-terminated-response.ts → game-resource-terminated-response.ts} +4 -3
- package/src/v3/events/game-resource-termination-failed-response.ts +36 -0
- package/src/v3/events/index.ts +12 -4
- package/src/v3/events/machine-allocation-failed-response.ts +39 -0
- package/src/v3/events/machine-deallocated-response.ts +39 -0
- package/src/v3/events/machine-deallocation-failed-response.ts +43 -0
- package/src/v3/events/{machine-created-response.ts → machine-resource-created-response.ts} +8 -7
- package/src/v3/events/machine-resource-creation-failed-response.ts +36 -0
- package/src/v3/events/swap-cloud-user-request-failed.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap-cloud-user-request-failed.js","sourceRoot":"","sources":["../../../src/v3/events/swap-cloud-user-request-failed.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmD;AAEnD,yDAAqD;AACrD,gDAAwD;AACxD,oGAAqF;AAErF,MAAa,iCAAiC;
|
|
1
|
+
{"version":3,"file":"swap-cloud-user-request-failed.js","sourceRoot":"","sources":["../../../src/v3/events/swap-cloud-user-request-failed.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmD;AAEnD,yDAAqD;AACrD,gDAAwD;AACxD,oGAAqF;AAErF,MAAa,iCAAiC;CAe7C;AAfD,8EAeC;AAbC;IADC,IAAA,wBAAM,GAAE;;uEACY;AAGrB;IADC,IAAA,0BAAQ,GAAE;;kFACqB;AAGhC;IADC,IAAA,0BAAQ,GAAE;;iFACoB;AAG/B;IADC,IAAA,0BAAQ,GAAE;;gEACG;AAGd;IADC,IAAA,0BAAQ,GAAE;;wEACW;AAGxB,MAAa,0BAA2B,SAAQ,wBAAU;IAGxD,YACE,OAA0C,EAC1C,OAA4B;QAE5B,KAAK,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;;AAVH,gEAiBC;AAhBiB,qCAAU,GAAG,+CAA+C,CAAC;AAY7E;IADC,IAAA,mDAAkB,EAAC,GAAG,EAAE,CAAC,8BAAmB,CAAC;8BACrC,8BAAmB;2DAAC;AAG7B;IADC,IAAA,mDAAkB,EAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC;8BAC5C,iCAAiC;2DAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { applyDecorators } from "@nestjs/common";
|
|
2
2
|
import { ValidateNested } from "class-validator";
|
|
3
|
-
import { Type } from "class-transformer";
|
|
3
|
+
import { Type, TypeHelpOptions } from "class-transformer";
|
|
4
4
|
|
|
5
|
-
export function ValidateNestedType(
|
|
5
|
+
export function ValidateNestedType(
|
|
6
|
+
typeFunction: (type: TypeHelpOptions) => any
|
|
7
|
+
) {
|
|
6
8
|
return applyDecorators(ValidateNested(), Type(typeFunction));
|
|
7
9
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IsEnum, IsOptional, IsUUID, IsString } from "class-validator";
|
|
2
|
+
import { CloudProvider } from "../types";
|
|
3
|
+
|
|
4
|
+
export class CloudPoolContext {
|
|
5
|
+
@IsEnum(CloudProvider)
|
|
6
|
+
cloudProvider: CloudProvider;
|
|
7
|
+
|
|
8
|
+
@IsUUID()
|
|
9
|
+
poolId: string;
|
|
10
|
+
|
|
11
|
+
@IsString()
|
|
12
|
+
@IsOptional()
|
|
13
|
+
streamGroupId?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IsEnum, IsOptional, IsString, IsUUID } from "class-validator";
|
|
2
|
+
import { CloudProvider } from "../types";
|
|
3
|
+
|
|
4
|
+
export class CloudSessionContext {
|
|
5
|
+
@IsOptional()
|
|
6
|
+
@IsUUID()
|
|
7
|
+
allocationRequestId?: string;
|
|
8
|
+
|
|
9
|
+
@IsOptional()
|
|
10
|
+
@IsUUID()
|
|
11
|
+
clientRequestId?: string;
|
|
12
|
+
|
|
13
|
+
@IsUUID()
|
|
14
|
+
cloudSessionId: string;
|
|
15
|
+
|
|
16
|
+
@IsOptional()
|
|
17
|
+
@IsUUID()
|
|
18
|
+
userId?: string;
|
|
19
|
+
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@IsUUID()
|
|
22
|
+
gameId?: string;
|
|
23
|
+
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@IsUUID()
|
|
26
|
+
ludeoId?: string;
|
|
27
|
+
|
|
28
|
+
@IsOptional()
|
|
29
|
+
@IsUUID()
|
|
30
|
+
poolId?: string;
|
|
31
|
+
|
|
32
|
+
@IsEnum(CloudProvider)
|
|
33
|
+
cloudProvider: CloudProvider;
|
|
34
|
+
|
|
35
|
+
@IsOptional()
|
|
36
|
+
@IsUUID()
|
|
37
|
+
resourceId?: string;
|
|
38
|
+
|
|
39
|
+
@IsOptional()
|
|
40
|
+
@IsString()
|
|
41
|
+
streamGroupId?: string;
|
|
42
|
+
|
|
43
|
+
@IsOptional()
|
|
44
|
+
@IsString()
|
|
45
|
+
streamSessionId?: string;
|
|
46
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { validate } from "class-validator";
|
|
2
|
+
import { plainToInstance } from "class-transformer";
|
|
3
|
+
|
|
4
|
+
import { ValidateNestedType } from "../../decorators";
|
|
5
|
+
import { getCloudContextType } from "./getCloudContextType";
|
|
6
|
+
import { CloudPoolContext } from "../contexts/cloud-pool-context";
|
|
7
|
+
import { CloudSessionContext } from "../contexts/cloud-session-context";
|
|
8
|
+
import { CloudResourceContext } from "../contexts/cloud-resource-context";
|
|
9
|
+
|
|
10
|
+
describe("getContextType", () => {
|
|
11
|
+
it("should return cloud session context", () => {
|
|
12
|
+
const context = {
|
|
13
|
+
cloudSessionId: "cloudSessionId",
|
|
14
|
+
};
|
|
15
|
+
expect(getCloudContextType({ object: context } as any)).toBe(
|
|
16
|
+
CloudSessionContext
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should return cloud resource context", () => {
|
|
21
|
+
const context = {
|
|
22
|
+
resourceId: "resourceId",
|
|
23
|
+
};
|
|
24
|
+
expect(getCloudContextType({ object: context } as any)).toBe(
|
|
25
|
+
CloudResourceContext
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should return cloud pool context", () => {
|
|
30
|
+
const context = {
|
|
31
|
+
poolId: "poolId",
|
|
32
|
+
};
|
|
33
|
+
expect(getCloudContextType({ object: context } as any)).toBe(
|
|
34
|
+
CloudPoolContext
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("class validator", () => {
|
|
39
|
+
class Context {
|
|
40
|
+
@ValidateNestedType(getCloudContextType)
|
|
41
|
+
context: CloudSessionContext | CloudPoolContext | CloudResourceContext;
|
|
42
|
+
|
|
43
|
+
constructor(context: Record<string, any>) {
|
|
44
|
+
this.context = context as any;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
it("invalid cloud session context", async () => {
|
|
49
|
+
const invalidCloudSessionContext = {
|
|
50
|
+
cloudSessionId: "BA7C9AEE-955D-4155-9220-A4BCB0F0A106",
|
|
51
|
+
poolId: "E738D912-8D00-4E3B-9F0A-A448C9FEAA73",
|
|
52
|
+
cloudProvider: "invalid" as any,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const invalidEvent = plainToInstance(Context, {
|
|
56
|
+
context: invalidCloudSessionContext,
|
|
57
|
+
});
|
|
58
|
+
const validationErrors = await validate(invalidEvent);
|
|
59
|
+
|
|
60
|
+
expect(validationErrors).toHaveLength(1);
|
|
61
|
+
expect(validationErrors[0].children).toHaveLength(1);
|
|
62
|
+
expect(validationErrors[0].children[0].constraints).toEqual({
|
|
63
|
+
isEnum: "cloudProvider must be one of the following values: aws",
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("valid cloud session context", async () => {
|
|
68
|
+
const validCloudSessionContext = {
|
|
69
|
+
cloudSessionId: "BA7C9AEE-955D-4155-9220-A4BCB0F0A106",
|
|
70
|
+
poolId: "E738D912-8D00-4E3B-9F0A-A448C9FEAA73",
|
|
71
|
+
cloudProvider: "aws",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const validEvent = plainToInstance(Context, {
|
|
75
|
+
context: validCloudSessionContext,
|
|
76
|
+
});
|
|
77
|
+
const validationErrors = await validate(validEvent);
|
|
78
|
+
|
|
79
|
+
expect(validationErrors).toHaveLength(0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("invalid cloud resource context", async () => {
|
|
83
|
+
const invalidCloudResourceContext = {
|
|
84
|
+
resourceId: "BA7C9AEE-955D-4155-9220-A4BCB0F0A106",
|
|
85
|
+
poolId: "E738D912-8D00-4E3B-9F0A-A448C9FEAA73",
|
|
86
|
+
cloudProvider: "aws" as any,
|
|
87
|
+
streamGroupId: 123839289312, // should be a string
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const invalidEvent = plainToInstance(Context, {
|
|
91
|
+
context: invalidCloudResourceContext,
|
|
92
|
+
});
|
|
93
|
+
const validationErrors = await validate(invalidEvent);
|
|
94
|
+
|
|
95
|
+
expect(validationErrors).toHaveLength(1);
|
|
96
|
+
expect(validationErrors[0].children).toHaveLength(1);
|
|
97
|
+
expect(validationErrors[0].children[0].constraints).toEqual({
|
|
98
|
+
isString: "streamGroupId must be a string",
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TypeHelpOptions } from "class-transformer";
|
|
2
|
+
import { CloudPoolContext } from "./cloud-pool-context";
|
|
3
|
+
import { CloudResourceContext } from "./cloud-resource-context";
|
|
4
|
+
import { CloudSessionContext } from "./cloud-session-context";
|
|
5
|
+
|
|
6
|
+
export const getCloudContextType = ({ object }: TypeHelpOptions) => {
|
|
7
|
+
if ("cloudSessionId" in object) {
|
|
8
|
+
return CloudSessionContext;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if ("resourceId" in object) {
|
|
12
|
+
return CloudResourceContext;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return CloudPoolContext;
|
|
16
|
+
};
|
package/src/v3/contexts/index.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Type } from "class-transformer";
|
|
2
|
+
import { IsUUID, ValidateNested } from "class-validator";
|
|
3
|
+
|
|
4
|
+
import { CloudPoolContext } from "../contexts";
|
|
5
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
6
|
+
import { CloudSessionContext } from "../../v2/contexts";
|
|
7
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
8
|
+
import { getCloudContextType } from "../contexts/getCloudContextType";
|
|
9
|
+
|
|
10
|
+
export class DeallocateMachineRequestPayload {
|
|
11
|
+
@IsUUID()
|
|
12
|
+
machinePoolId: string;
|
|
13
|
+
|
|
14
|
+
@IsUUID()
|
|
15
|
+
machineResourceId: string;
|
|
16
|
+
|
|
17
|
+
@IsUUID()
|
|
18
|
+
gamePoolId: string;
|
|
19
|
+
|
|
20
|
+
@IsUUID()
|
|
21
|
+
gameResourceId: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class DeallocateMachineRequest extends LudeoEvent {
|
|
25
|
+
static readonly EVENT_NAME = "cloud-pools.deallocate-machine-request";
|
|
26
|
+
|
|
27
|
+
constructor(
|
|
28
|
+
payload: DeallocateMachineRequestPayload,
|
|
29
|
+
context: CloudSessionContext
|
|
30
|
+
) {
|
|
31
|
+
super(DeallocateMachineRequest.EVENT_NAME);
|
|
32
|
+
this.payload = payload;
|
|
33
|
+
this.context = context;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ValidateNestedType(getCloudContextType)
|
|
37
|
+
context: CloudSessionContext | CloudPoolContext;
|
|
38
|
+
|
|
39
|
+
@ValidateNestedType(() => DeallocateMachineRequestPayload)
|
|
40
|
+
payload: DeallocateMachineRequestPayload;
|
|
41
|
+
}
|
|
@@ -16,14 +16,15 @@ export class GameAllocatedResponsePayload {
|
|
|
16
16
|
allocationData: CloudProviderAllocationData;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export class
|
|
20
|
-
static readonly EVENT_NAME =
|
|
19
|
+
export class GameResourceAllocatedResponse extends LudeoEvent {
|
|
20
|
+
static readonly EVENT_NAME =
|
|
21
|
+
"cloud-resources.game-resource-allocated-response";
|
|
21
22
|
|
|
22
23
|
constructor(
|
|
23
24
|
payload: GameAllocatedResponsePayload,
|
|
24
25
|
context: CloudResourceContext
|
|
25
26
|
) {
|
|
26
|
-
super(
|
|
27
|
+
super(GameResourceAllocatedResponse.EVENT_NAME);
|
|
27
28
|
this.payload = payload;
|
|
28
29
|
this.context = context;
|
|
29
30
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IsString, IsUUID } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { CloudResourceContext } from "../contexts";
|
|
4
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
5
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
6
|
+
|
|
7
|
+
export class GameResourceAllocationFailedResponsePayload {
|
|
8
|
+
@IsUUID()
|
|
9
|
+
gameResourceId: string;
|
|
10
|
+
|
|
11
|
+
@IsUUID()
|
|
12
|
+
gamePoolId: string;
|
|
13
|
+
|
|
14
|
+
@IsString()
|
|
15
|
+
errorMessage: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class GameResourceAllocationFailedResponse extends LudeoEvent {
|
|
19
|
+
static readonly EVENT_NAME =
|
|
20
|
+
"cloud-resources.game-resource-allocation-failed-response";
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
payload: GameResourceAllocationFailedResponsePayload,
|
|
24
|
+
context: CloudResourceContext
|
|
25
|
+
) {
|
|
26
|
+
super(GameResourceAllocationFailedResponse.EVENT_NAME);
|
|
27
|
+
this.payload = payload;
|
|
28
|
+
this.context = context;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ValidateNestedType(() => CloudResourceContext)
|
|
32
|
+
context: CloudResourceContext;
|
|
33
|
+
|
|
34
|
+
@ValidateNestedType(() => GameResourceAllocationFailedResponsePayload)
|
|
35
|
+
payload: GameResourceAllocationFailedResponsePayload;
|
|
36
|
+
}
|
|
@@ -23,14 +23,14 @@ export class GameCreatedResponsePayload {
|
|
|
23
23
|
cloudProvider: CloudProvider;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export class
|
|
27
|
-
static readonly EVENT_NAME = "cloud-resources.game-created-response";
|
|
26
|
+
export class GameResourceCreatedResponse extends LudeoEvent {
|
|
27
|
+
static readonly EVENT_NAME = "cloud-resources.game-resource-created-response";
|
|
28
28
|
|
|
29
29
|
constructor(
|
|
30
30
|
payload: GameCreatedResponsePayload,
|
|
31
31
|
context: CloudResourceContext
|
|
32
32
|
) {
|
|
33
|
-
super(
|
|
33
|
+
super(GameResourceCreatedResponse.EVENT_NAME);
|
|
34
34
|
this.payload = payload;
|
|
35
35
|
this.context = context;
|
|
36
36
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IsUUID, IsString } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { CloudResourceContext } from "../contexts";
|
|
4
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
5
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
6
|
+
|
|
7
|
+
export class GameResourceCreationFailedResponsePayload {
|
|
8
|
+
@IsUUID()
|
|
9
|
+
gameResourceId: string;
|
|
10
|
+
|
|
11
|
+
@IsUUID()
|
|
12
|
+
gamePoolId: string;
|
|
13
|
+
|
|
14
|
+
@IsString()
|
|
15
|
+
errorMessage: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class GameResourceCreationFailedResponse extends LudeoEvent {
|
|
19
|
+
static readonly EVENT_NAME =
|
|
20
|
+
"cloud-resources.game-resource-creation-failed-response";
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
payload: GameResourceCreationFailedResponsePayload,
|
|
24
|
+
context: CloudResourceContext
|
|
25
|
+
) {
|
|
26
|
+
super(GameResourceCreationFailedResponse.EVENT_NAME);
|
|
27
|
+
this.payload = payload;
|
|
28
|
+
this.context = context;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ValidateNestedType(() => CloudResourceContext)
|
|
32
|
+
context: CloudResourceContext;
|
|
33
|
+
|
|
34
|
+
@ValidateNestedType(() => GameResourceCreationFailedResponsePayload)
|
|
35
|
+
payload: GameResourceCreationFailedResponsePayload;
|
|
36
|
+
}
|
|
@@ -12,14 +12,15 @@ export class GameTerminatedResponsePayload {
|
|
|
12
12
|
gamePoolId: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export class
|
|
16
|
-
static readonly EVENT_NAME =
|
|
15
|
+
export class GameResourceTerminatedResponse extends LudeoEvent {
|
|
16
|
+
static readonly EVENT_NAME =
|
|
17
|
+
"cloud-resources.game-resource-terminated-response";
|
|
17
18
|
|
|
18
19
|
constructor(
|
|
19
20
|
payload: GameTerminatedResponsePayload,
|
|
20
21
|
context: CloudResourceContext
|
|
21
22
|
) {
|
|
22
|
-
super(
|
|
23
|
+
super(GameResourceTerminatedResponse.EVENT_NAME);
|
|
23
24
|
this.payload = payload;
|
|
24
25
|
this.context = context;
|
|
25
26
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IsUUID, IsString } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { CloudResourceContext } from "../contexts";
|
|
4
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
5
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
6
|
+
|
|
7
|
+
export class GameResourceTerminationFailedResponsePayload {
|
|
8
|
+
@IsUUID()
|
|
9
|
+
gameResourceId: string;
|
|
10
|
+
|
|
11
|
+
@IsUUID()
|
|
12
|
+
gamePoolId: string;
|
|
13
|
+
|
|
14
|
+
@IsString()
|
|
15
|
+
errorMessage: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class GameResourceTerminationFailedResponse extends LudeoEvent {
|
|
19
|
+
static readonly EVENT_NAME =
|
|
20
|
+
"cloud-resources.game-resource-termination-failed-response";
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
payload: GameResourceTerminationFailedResponsePayload,
|
|
24
|
+
context: CloudResourceContext
|
|
25
|
+
) {
|
|
26
|
+
super(GameResourceTerminationFailedResponse.EVENT_NAME);
|
|
27
|
+
this.payload = payload;
|
|
28
|
+
this.context = context;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ValidateNestedType(() => CloudResourceContext)
|
|
32
|
+
context: CloudResourceContext;
|
|
33
|
+
|
|
34
|
+
@ValidateNestedType(() => GameResourceTerminationFailedResponsePayload)
|
|
35
|
+
payload: GameResourceTerminationFailedResponsePayload;
|
|
36
|
+
}
|
package/src/v3/events/index.ts
CHANGED
|
@@ -5,11 +5,19 @@ export * from "./create-game-resource-request";
|
|
|
5
5
|
export * from "./create-games-request";
|
|
6
6
|
export * from "./create-machine-resource-batch-request";
|
|
7
7
|
export * from "./create-machines-request";
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./game-
|
|
10
|
-
export * from "./game-
|
|
8
|
+
export * from "./deallocate-machine-request";
|
|
9
|
+
export * from "./game-resource-allocated-response";
|
|
10
|
+
export * from "./game-resource-allocation-failed-response";
|
|
11
|
+
export * from "./game-resource-created-response";
|
|
12
|
+
export * from "./game-resource-creation-failed-response";
|
|
13
|
+
export * from "./game-resource-terminated-response";
|
|
14
|
+
export * from "./game-resource-termination-failed-response";
|
|
11
15
|
export * from "./machine-allocated-response";
|
|
12
|
-
export * from "./machine-
|
|
16
|
+
export * from "./machine-allocation-failed-response";
|
|
17
|
+
export * from "./machine-deallocated-response";
|
|
18
|
+
export * from "./machine-deallocation-failed-response";
|
|
19
|
+
export * from "./machine-resource-created-response";
|
|
20
|
+
export * from "./machine-resource-creation-failed-response";
|
|
13
21
|
export * from "./set-pool.event";
|
|
14
22
|
export * from "./terminate-game-resource-request";
|
|
15
23
|
export * from "./terminate-games-request";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IsUUID, IsString } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { CloudResourceContext } from "../contexts";
|
|
4
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
5
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
6
|
+
|
|
7
|
+
export class MachineAllocatedFailedResponsePayload {
|
|
8
|
+
@IsUUID()
|
|
9
|
+
gameResourceId: string;
|
|
10
|
+
|
|
11
|
+
@IsUUID()
|
|
12
|
+
machinePoolId: string;
|
|
13
|
+
|
|
14
|
+
@IsUUID()
|
|
15
|
+
gamePoolId: string;
|
|
16
|
+
|
|
17
|
+
@IsString()
|
|
18
|
+
errorMessage: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class MachineAllocationFailedResponse extends LudeoEvent {
|
|
22
|
+
static readonly EVENT_NAME =
|
|
23
|
+
"cloud-resources.machine-allocation-failed-response";
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
payload: MachineAllocatedFailedResponsePayload,
|
|
27
|
+
context: CloudResourceContext
|
|
28
|
+
) {
|
|
29
|
+
super(MachineAllocationFailedResponse.EVENT_NAME);
|
|
30
|
+
this.payload = payload;
|
|
31
|
+
this.context = context;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@ValidateNestedType(() => CloudResourceContext)
|
|
35
|
+
context: CloudResourceContext;
|
|
36
|
+
|
|
37
|
+
@ValidateNestedType(() => MachineAllocatedFailedResponsePayload)
|
|
38
|
+
payload: MachineAllocatedFailedResponsePayload;
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IsUUID } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
4
|
+
import { CloudSessionContext } from "../../v2/contexts";
|
|
5
|
+
import { CloudPoolContext, getCloudContextType } from "../contexts";
|
|
6
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
7
|
+
|
|
8
|
+
export class MachineDeallocatedResponsePayload {
|
|
9
|
+
@IsUUID()
|
|
10
|
+
machinePoolId: string;
|
|
11
|
+
|
|
12
|
+
@IsUUID()
|
|
13
|
+
machineResourceId: string;
|
|
14
|
+
|
|
15
|
+
@IsUUID()
|
|
16
|
+
gamePoolId: string;
|
|
17
|
+
|
|
18
|
+
@IsUUID()
|
|
19
|
+
gameResourceId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class MachineDeallocatedResponse extends LudeoEvent {
|
|
23
|
+
static readonly EVENT_NAME = "cloud-pools.machine-deallocated-response";
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
payload: MachineDeallocatedResponsePayload,
|
|
27
|
+
context: CloudSessionContext
|
|
28
|
+
) {
|
|
29
|
+
super(MachineDeallocatedResponse.EVENT_NAME);
|
|
30
|
+
this.payload = payload;
|
|
31
|
+
this.context = context;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@ValidateNestedType(getCloudContextType)
|
|
35
|
+
context: CloudSessionContext | CloudPoolContext;
|
|
36
|
+
|
|
37
|
+
@ValidateNestedType(() => MachineDeallocatedResponsePayload)
|
|
38
|
+
payload: MachineDeallocatedResponsePayload;
|
|
39
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IsString, IsUUID } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
4
|
+
import { CloudSessionContext } from "../../v2/contexts";
|
|
5
|
+
import { CloudPoolContext, getCloudContextType } from "../contexts";
|
|
6
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
7
|
+
|
|
8
|
+
export class MachineDeallocatedFailedResponsePayload {
|
|
9
|
+
@IsUUID()
|
|
10
|
+
machinePoolId: string;
|
|
11
|
+
|
|
12
|
+
@IsUUID()
|
|
13
|
+
machineResourceId: string;
|
|
14
|
+
|
|
15
|
+
@IsUUID()
|
|
16
|
+
gamePoolId: string;
|
|
17
|
+
|
|
18
|
+
@IsUUID()
|
|
19
|
+
gameResourceId: string;
|
|
20
|
+
|
|
21
|
+
@IsString()
|
|
22
|
+
errorMessage: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class MachineDeallocationFailedResponse extends LudeoEvent {
|
|
26
|
+
static readonly EVENT_NAME =
|
|
27
|
+
"cloud-pools.machine-deallocation-failed-response";
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
payload: MachineDeallocatedFailedResponsePayload,
|
|
31
|
+
context: CloudSessionContext
|
|
32
|
+
) {
|
|
33
|
+
super(MachineDeallocationFailedResponse.EVENT_NAME);
|
|
34
|
+
this.payload = payload;
|
|
35
|
+
this.context = context;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@ValidateNestedType(getCloudContextType)
|
|
39
|
+
context: CloudSessionContext | CloudPoolContext;
|
|
40
|
+
|
|
41
|
+
@ValidateNestedType(() => MachineDeallocatedFailedResponsePayload)
|
|
42
|
+
payload: MachineDeallocatedFailedResponsePayload;
|
|
43
|
+
}
|
|
@@ -4,7 +4,7 @@ import { CloudResourceContext } from "../contexts";
|
|
|
4
4
|
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
5
5
|
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class MachineResourceCreatedResponsePayload {
|
|
8
8
|
@IsUUID()
|
|
9
9
|
machineResourceId: string;
|
|
10
10
|
|
|
@@ -12,14 +12,15 @@ export class MachineCreatedResponsePayload {
|
|
|
12
12
|
machinePoolId: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export class
|
|
16
|
-
static readonly EVENT_NAME =
|
|
15
|
+
export class MachineResourceCreatedResponse extends LudeoEvent {
|
|
16
|
+
static readonly EVENT_NAME =
|
|
17
|
+
"cloud-resources.machine-resource-created-response";
|
|
17
18
|
|
|
18
19
|
constructor(
|
|
19
|
-
payload:
|
|
20
|
+
payload: MachineResourceCreatedResponsePayload,
|
|
20
21
|
context: CloudResourceContext
|
|
21
22
|
) {
|
|
22
|
-
super(
|
|
23
|
+
super(MachineResourceCreatedResponse.EVENT_NAME);
|
|
23
24
|
this.payload = payload;
|
|
24
25
|
this.context = context;
|
|
25
26
|
}
|
|
@@ -27,6 +28,6 @@ export class MachineCreatedResponse extends LudeoEvent {
|
|
|
27
28
|
@ValidateNestedType(() => CloudResourceContext)
|
|
28
29
|
context: CloudResourceContext;
|
|
29
30
|
|
|
30
|
-
@ValidateNestedType(() =>
|
|
31
|
-
payload:
|
|
31
|
+
@ValidateNestedType(() => MachineResourceCreatedResponsePayload)
|
|
32
|
+
payload: MachineResourceCreatedResponsePayload;
|
|
32
33
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IsString, IsUUID } from "class-validator";
|
|
2
|
+
|
|
3
|
+
import { CloudResourceContext } from "../contexts";
|
|
4
|
+
import { LudeoEvent } from "../../infra/ludeo-event";
|
|
5
|
+
import { ValidateNestedType } from "../../decorators/validate-nested-type.decorator";
|
|
6
|
+
|
|
7
|
+
export class MachineResourceCreationFailedResponsePayload {
|
|
8
|
+
@IsUUID()
|
|
9
|
+
machineResourceId: string;
|
|
10
|
+
|
|
11
|
+
@IsUUID()
|
|
12
|
+
machinePoolId: string;
|
|
13
|
+
|
|
14
|
+
@IsString()
|
|
15
|
+
errorMessage: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class MachineResourceCreationFailedResponse extends LudeoEvent {
|
|
19
|
+
static readonly EVENT_NAME =
|
|
20
|
+
"cloud-resources.machine-resource-creation-failed-response";
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
payload: MachineResourceCreationFailedResponsePayload,
|
|
24
|
+
context: CloudResourceContext
|
|
25
|
+
) {
|
|
26
|
+
super(MachineResourceCreationFailedResponse.EVENT_NAME);
|
|
27
|
+
this.payload = payload;
|
|
28
|
+
this.context = context;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ValidateNestedType(() => CloudResourceContext)
|
|
32
|
+
context: CloudResourceContext;
|
|
33
|
+
|
|
34
|
+
@ValidateNestedType(() => MachineResourceCreationFailedResponsePayload)
|
|
35
|
+
payload: MachineResourceCreationFailedResponsePayload;
|
|
36
|
+
}
|