@ludeo/cloud-common 1.1.7 → 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.
Files changed (77) hide show
  1. package/dist/decorators/validate-nested-type.decorator.d.ts +2 -1
  2. package/dist/decorators/validate-nested-type.decorator.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/dist/v3/contexts/cloud-pool-context.d.ts +6 -0
  5. package/dist/v3/contexts/cloud-pool-context.js +31 -0
  6. package/dist/v3/contexts/cloud-pool-context.js.map +1 -0
  7. package/dist/v3/contexts/cloud-session-context.d.ts +14 -0
  8. package/dist/v3/contexts/cloud-session-context.js +71 -0
  9. package/dist/v3/contexts/cloud-session-context.js.map +1 -0
  10. package/dist/v3/contexts/getCloudContextType.d.ts +4 -0
  11. package/dist/v3/contexts/getCloudContextType.js +17 -0
  12. package/dist/v3/contexts/getCloudContextType.js.map +1 -0
  13. package/dist/v3/contexts/getCloudContextType.spec.d.ts +1 -0
  14. package/dist/v3/contexts/getCloudContextType.spec.js +95 -0
  15. package/dist/v3/contexts/getCloudContextType.spec.js.map +1 -0
  16. package/dist/v3/contexts/index.d.ts +3 -0
  17. package/dist/v3/contexts/index.js +3 -0
  18. package/dist/v3/contexts/index.js.map +1 -1
  19. package/dist/v3/events/deallocate-machine-request.d.ts +15 -0
  20. package/dist/v3/events/deallocate-machine-request.js +53 -0
  21. package/dist/v3/events/deallocate-machine-request.js.map +1 -0
  22. package/dist/v3/events/game-resource-allocated-response.d.ts +14 -0
  23. package/dist/v3/events/game-resource-allocated-response.js +50 -0
  24. package/dist/v3/events/game-resource-allocated-response.js.map +1 -0
  25. package/dist/v3/events/game-resource-allocation-failed-response.d.ts +13 -0
  26. package/dist/v3/events/game-resource-allocation-failed-response.js +49 -0
  27. package/dist/v3/events/game-resource-allocation-failed-response.js.map +1 -0
  28. package/dist/v3/events/game-resource-created-response.d.ts +15 -0
  29. package/dist/v3/events/game-resource-created-response.js +54 -0
  30. package/dist/v3/events/game-resource-created-response.js.map +1 -0
  31. package/dist/v3/events/game-resource-creation-failed-response.d.ts +13 -0
  32. package/dist/v3/events/game-resource-creation-failed-response.js +49 -0
  33. package/dist/v3/events/game-resource-creation-failed-response.js.map +1 -0
  34. package/dist/v3/events/game-resource-terminated-response.d.ts +12 -0
  35. package/dist/v3/events/game-resource-terminated-response.js +45 -0
  36. package/dist/v3/events/game-resource-terminated-response.js.map +1 -0
  37. package/dist/v3/events/game-resource-termination-failed-response.d.ts +13 -0
  38. package/dist/v3/events/game-resource-termination-failed-response.js +49 -0
  39. package/dist/v3/events/game-resource-termination-failed-response.js.map +1 -0
  40. package/dist/v3/events/index.d.ts +12 -4
  41. package/dist/v3/events/index.js +12 -4
  42. package/dist/v3/events/index.js.map +1 -1
  43. package/dist/v3/events/machine-allocation-failed-response.d.ts +14 -0
  44. package/dist/v3/events/machine-allocation-failed-response.js +53 -0
  45. package/dist/v3/events/machine-allocation-failed-response.js.map +1 -0
  46. package/dist/v3/events/machine-deallocated-response.d.ts +15 -0
  47. package/dist/v3/events/machine-deallocated-response.js +53 -0
  48. package/dist/v3/events/machine-deallocated-response.js.map +1 -0
  49. package/dist/v3/events/machine-deallocation-failed-response.d.ts +16 -0
  50. package/dist/v3/events/machine-deallocation-failed-response.js +57 -0
  51. package/dist/v3/events/machine-deallocation-failed-response.js.map +1 -0
  52. package/dist/v3/events/machine-resource-created-response.d.ts +12 -0
  53. package/dist/v3/events/machine-resource-created-response.js +45 -0
  54. package/dist/v3/events/machine-resource-created-response.js.map +1 -0
  55. package/dist/v3/events/machine-resource-creation-failed-response.d.ts +13 -0
  56. package/dist/v3/events/machine-resource-creation-failed-response.js +49 -0
  57. package/dist/v3/events/machine-resource-creation-failed-response.js.map +1 -0
  58. package/package.json +1 -1
  59. package/src/decorators/validate-nested-type.decorator.ts +4 -2
  60. package/src/v3/contexts/cloud-pool-context.ts +14 -0
  61. package/src/v3/contexts/cloud-session-context.ts +46 -0
  62. package/src/v3/contexts/getCloudContextType.spec.ts +102 -0
  63. package/src/v3/contexts/getCloudContextType.ts +16 -0
  64. package/src/v3/contexts/index.ts +3 -0
  65. package/src/v3/events/deallocate-machine-request.ts +41 -0
  66. package/src/v3/events/{game-allocated-response.ts → game-resource-allocated-response.ts} +4 -3
  67. package/src/v3/events/game-resource-allocation-failed-response.ts +36 -0
  68. package/src/v3/events/{game-created-response.ts → game-resource-created-response.ts} +3 -3
  69. package/src/v3/events/game-resource-creation-failed-response.ts +36 -0
  70. package/src/v3/events/{game-terminated-response.ts → game-resource-terminated-response.ts} +4 -3
  71. package/src/v3/events/game-resource-termination-failed-response.ts +36 -0
  72. package/src/v3/events/index.ts +12 -4
  73. package/src/v3/events/machine-allocation-failed-response.ts +39 -0
  74. package/src/v3/events/machine-deallocated-response.ts +39 -0
  75. package/src/v3/events/machine-deallocation-failed-response.ts +43 -0
  76. package/src/v3/events/{machine-created-response.ts → machine-resource-created-response.ts} +8 -7
  77. package/src/v3/events/machine-resource-creation-failed-response.ts +36 -0
@@ -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(typeFunction: () => any) {
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
+ };
@@ -1 +1,4 @@
1
+ export * from "./cloud-pool-context";
1
2
  export * from "./cloud-resource-context";
3
+ export * from "./cloud-session-context";
4
+ export * from "./getCloudContextType";
@@ -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 GameAllocatedResponse extends LudeoEvent {
20
- static readonly EVENT_NAME = "cloud-resources.game-allocated-response";
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(GameAllocatedResponse.EVENT_NAME);
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 GameCreatedResponse extends LudeoEvent {
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(GameCreatedResponse.EVENT_NAME);
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 GameTerminatedResponse extends LudeoEvent {
16
- static readonly EVENT_NAME = "cloud-resources.game-terminated-response";
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(GameTerminatedResponse.EVENT_NAME);
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
+ }
@@ -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 "./game-allocated-response";
9
- export * from "./game-created-response";
10
- export * from "./game-terminated-response";
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-created-response";
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 MachineCreatedResponsePayload {
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 MachineCreatedResponse extends LudeoEvent {
16
- static readonly EVENT_NAME = "cloud-resources.machine-created-response";
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: MachineCreatedResponsePayload,
20
+ payload: MachineResourceCreatedResponsePayload,
20
21
  context: CloudResourceContext
21
22
  ) {
22
- super(MachineCreatedResponse.EVENT_NAME);
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(() => MachineCreatedResponsePayload)
31
- payload: MachineCreatedResponsePayload;
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
+ }