@anweather/game-plugin-ssdk 1.2.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.
Files changed (88) hide show
  1. package/dist-cjs/runtime/defaultService.js +18 -0
  2. package/dist-cjs/runtime/express.js +39 -0
  3. package/dist-cjs/runtime/index.js +7 -0
  4. package/dist-cjs/src/endpoint/EndpointParameters.js +12 -0
  5. package/dist-cjs/src/endpoint/endpointResolver.js +16 -0
  6. package/dist-cjs/src/endpoint/ruleset.js +38 -0
  7. package/dist-cjs/src/index.js +7 -0
  8. package/dist-cjs/src/models/index.js +4 -0
  9. package/dist-cjs/src/models/models_0.js +860 -0
  10. package/dist-cjs/src/protocols/Aws_restJson1.js +1077 -0
  11. package/dist-cjs/src/server/GamePluginService.js +231 -0
  12. package/dist-cjs/src/server/index.js +5 -0
  13. package/dist-cjs/src/server/operations/ApplyMove.js +109 -0
  14. package/dist-cjs/src/server/operations/ApplySaveFileEdit.js +109 -0
  15. package/dist-cjs/src/server/operations/AssignParticipants.js +101 -0
  16. package/dist-cjs/src/server/operations/DescribeSaveFile.js +101 -0
  17. package/dist-cjs/src/server/operations/GetGameResult.js +101 -0
  18. package/dist-cjs/src/server/operations/GetGameStatus.js +101 -0
  19. package/dist-cjs/src/server/operations/GetMetadata.js +99 -0
  20. package/dist-cjs/src/server/operations/GetPlayerView.js +101 -0
  21. package/dist-cjs/src/server/operations/GetSaveFileEditorState.js +101 -0
  22. package/dist-cjs/src/server/operations/Health.js +99 -0
  23. package/dist-cjs/src/server/operations/InitializeGame.js +101 -0
  24. package/dist-cjs/src/server/operations/IsConfigMove.js +101 -0
  25. package/dist-cjs/src/server/operations/IsOutOfTurnMove.js +101 -0
  26. package/dist-cjs/src/server/operations/SelectBotMove.js +101 -0
  27. package/dist-cjs/src/server/operations/ValidateMove.js +101 -0
  28. package/dist-cjs/src/server/operations/index.js +18 -0
  29. package/dist-cjs/tsconfig.cjs.tsbuildinfo +1 -0
  30. package/dist-es/runtime/defaultService.js +15 -0
  31. package/dist-es/runtime/express.js +36 -0
  32. package/dist-es/runtime/index.js +2 -0
  33. package/dist-es/src/endpoint/EndpointParameters.js +8 -0
  34. package/dist-es/src/endpoint/endpointResolver.js +12 -0
  35. package/dist-es/src/endpoint/ruleset.js +35 -0
  36. package/dist-es/src/index.js +3 -0
  37. package/dist-es/src/models/index.js +1 -0
  38. package/dist-es/src/models/models_0.js +855 -0
  39. package/dist-es/src/protocols/Aws_restJson1.js +1041 -0
  40. package/dist-es/src/server/GamePluginService.js +226 -0
  41. package/dist-es/src/server/index.js +2 -0
  42. package/dist-es/src/server/operations/ApplyMove.js +103 -0
  43. package/dist-es/src/server/operations/ApplySaveFileEdit.js +103 -0
  44. package/dist-es/src/server/operations/AssignParticipants.js +95 -0
  45. package/dist-es/src/server/operations/DescribeSaveFile.js +95 -0
  46. package/dist-es/src/server/operations/GetGameResult.js +95 -0
  47. package/dist-es/src/server/operations/GetGameStatus.js +95 -0
  48. package/dist-es/src/server/operations/GetMetadata.js +93 -0
  49. package/dist-es/src/server/operations/GetPlayerView.js +95 -0
  50. package/dist-es/src/server/operations/GetSaveFileEditorState.js +95 -0
  51. package/dist-es/src/server/operations/Health.js +93 -0
  52. package/dist-es/src/server/operations/InitializeGame.js +95 -0
  53. package/dist-es/src/server/operations/IsConfigMove.js +95 -0
  54. package/dist-es/src/server/operations/IsOutOfTurnMove.js +95 -0
  55. package/dist-es/src/server/operations/SelectBotMove.js +95 -0
  56. package/dist-es/src/server/operations/ValidateMove.js +95 -0
  57. package/dist-es/src/server/operations/index.js +15 -0
  58. package/dist-es/tsconfig.es.tsbuildinfo +1 -0
  59. package/dist-types/runtime/defaultService.d.ts +9 -0
  60. package/dist-types/runtime/express.d.ts +12 -0
  61. package/dist-types/runtime/index.d.ts +3 -0
  62. package/dist-types/src/endpoint/EndpointParameters.d.ts +20 -0
  63. package/dist-types/src/endpoint/endpointResolver.d.ts +5 -0
  64. package/dist-types/src/endpoint/ruleset.d.ts +2 -0
  65. package/dist-types/src/index.d.ts +22 -0
  66. package/dist-types/src/models/index.d.ts +1 -0
  67. package/dist-types/src/models/models_0.d.ts +402 -0
  68. package/dist-types/src/protocols/Aws_restJson1.d.ts +52 -0
  69. package/dist-types/src/server/GamePluginService.d.ts +54 -0
  70. package/dist-types/src/server/index.d.ts +2 -0
  71. package/dist-types/src/server/operations/ApplyMove.d.ts +41 -0
  72. package/dist-types/src/server/operations/ApplySaveFileEdit.d.ts +41 -0
  73. package/dist-types/src/server/operations/AssignParticipants.d.ts +41 -0
  74. package/dist-types/src/server/operations/DescribeSaveFile.d.ts +41 -0
  75. package/dist-types/src/server/operations/GetGameResult.d.ts +41 -0
  76. package/dist-types/src/server/operations/GetGameStatus.d.ts +41 -0
  77. package/dist-types/src/server/operations/GetMetadata.d.ts +41 -0
  78. package/dist-types/src/server/operations/GetPlayerView.d.ts +41 -0
  79. package/dist-types/src/server/operations/GetSaveFileEditorState.d.ts +41 -0
  80. package/dist-types/src/server/operations/Health.d.ts +41 -0
  81. package/dist-types/src/server/operations/InitializeGame.d.ts +41 -0
  82. package/dist-types/src/server/operations/IsConfigMove.d.ts +41 -0
  83. package/dist-types/src/server/operations/IsOutOfTurnMove.d.ts +41 -0
  84. package/dist-types/src/server/operations/SelectBotMove.d.ts +41 -0
  85. package/dist-types/src/server/operations/ValidateMove.d.ts +41 -0
  86. package/dist-types/src/server/operations/index.d.ts +15 -0
  87. package/package.json +88 -0
  88. package/runtime/package.json +5 -0
@@ -0,0 +1,226 @@
1
+ import { serializeFrameworkException } from "../protocols/Aws_restJson1";
2
+ import { ApplyMoveSerializer, ApplyMoveServerInput, } from "./operations/ApplyMove";
3
+ import { ApplySaveFileEditSerializer, ApplySaveFileEditServerInput, } from "./operations/ApplySaveFileEdit";
4
+ import { AssignParticipantsSerializer, AssignParticipantsServerInput, } from "./operations/AssignParticipants";
5
+ import { DescribeSaveFileSerializer, DescribeSaveFileServerInput, } from "./operations/DescribeSaveFile";
6
+ import { GetGameResultSerializer, GetGameResultServerInput, } from "./operations/GetGameResult";
7
+ import { GetGameStatusSerializer, GetGameStatusServerInput, } from "./operations/GetGameStatus";
8
+ import { GetMetadataSerializer, GetMetadataServerInput, } from "./operations/GetMetadata";
9
+ import { GetPlayerViewSerializer, GetPlayerViewServerInput, } from "./operations/GetPlayerView";
10
+ import { GetSaveFileEditorStateSerializer, GetSaveFileEditorStateServerInput, } from "./operations/GetSaveFileEditorState";
11
+ import { HealthSerializer, HealthServerInput, } from "./operations/Health";
12
+ import { InitializeGameSerializer, InitializeGameServerInput, } from "./operations/InitializeGame";
13
+ import { IsConfigMoveSerializer, IsConfigMoveServerInput, } from "./operations/IsConfigMove";
14
+ import { IsOutOfTurnMoveSerializer, IsOutOfTurnMoveServerInput, } from "./operations/IsOutOfTurnMove";
15
+ import { SelectBotMoveSerializer, SelectBotMoveServerInput, } from "./operations/SelectBotMove";
16
+ import { ValidateMoveSerializer, ValidateMoveServerInput, } from "./operations/ValidateMove";
17
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, UnknownOperationException as __UnknownOperationException, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
18
+ import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
19
+ import { fromBase64, toBase64, } from "@smithy/util-base64";
20
+ import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
21
+ const serdeContextBase = {
22
+ base64Encoder: toBase64,
23
+ base64Decoder: fromBase64,
24
+ utf8Encoder: toUtf8,
25
+ utf8Decoder: fromUtf8,
26
+ streamCollector: streamCollector,
27
+ requestHandler: new NodeHttpHandler(),
28
+ disableHostPrefix: true
29
+ };
30
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
31
+ let input;
32
+ try {
33
+ input = await serializer.deserialize(request, {
34
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
35
+ });
36
+ }
37
+ catch (error) {
38
+ if (__isFrameworkException(error)) {
39
+ return serializeFrameworkException(error, serdeContextBase);
40
+ }
41
+ ;
42
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
43
+ }
44
+ try {
45
+ let validationFailures = validationFn(input);
46
+ if (validationFailures && validationFailures.length > 0) {
47
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
48
+ if (validationException) {
49
+ return serializer.serializeError(validationException, serdeContextBase);
50
+ }
51
+ }
52
+ let output = await operation(input, context);
53
+ return serializer.serialize(output, serdeContextBase);
54
+ }
55
+ catch (error) {
56
+ if (serializer.isOperationError(error)) {
57
+ return serializer.serializeError(error, serdeContextBase);
58
+ }
59
+ console.log('Received an unexpected error', error);
60
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
61
+ }
62
+ }
63
+ export class GamePluginServiceHandler {
64
+ service;
65
+ mux;
66
+ serializerFactory;
67
+ serializeFrameworkException;
68
+ validationCustomizer;
69
+ constructor(service, mux, serializerFactory, serializeFrameworkException, validationCustomizer) {
70
+ this.service = service;
71
+ this.mux = mux;
72
+ this.serializerFactory = serializerFactory;
73
+ this.serializeFrameworkException = serializeFrameworkException;
74
+ this.validationCustomizer = validationCustomizer;
75
+ }
76
+ async handle(request, context) {
77
+ const target = this.mux.match(request);
78
+ if (target === undefined) {
79
+ return this.serializeFrameworkException(new __UnknownOperationException(), serdeContextBase);
80
+ }
81
+ switch (target.operation) {
82
+ case "ApplyMove": {
83
+ return handle(request, context, "ApplyMove", this.serializerFactory("ApplyMove"), this.service.ApplyMove, this.serializeFrameworkException, ApplyMoveServerInput.validate, this.validationCustomizer);
84
+ }
85
+ case "ApplySaveFileEdit": {
86
+ return handle(request, context, "ApplySaveFileEdit", this.serializerFactory("ApplySaveFileEdit"), this.service.ApplySaveFileEdit, this.serializeFrameworkException, ApplySaveFileEditServerInput.validate, this.validationCustomizer);
87
+ }
88
+ case "AssignParticipants": {
89
+ return handle(request, context, "AssignParticipants", this.serializerFactory("AssignParticipants"), this.service.AssignParticipants, this.serializeFrameworkException, AssignParticipantsServerInput.validate, this.validationCustomizer);
90
+ }
91
+ case "DescribeSaveFile": {
92
+ return handle(request, context, "DescribeSaveFile", this.serializerFactory("DescribeSaveFile"), this.service.DescribeSaveFile, this.serializeFrameworkException, DescribeSaveFileServerInput.validate, this.validationCustomizer);
93
+ }
94
+ case "GetGameResult": {
95
+ return handle(request, context, "GetGameResult", this.serializerFactory("GetGameResult"), this.service.GetGameResult, this.serializeFrameworkException, GetGameResultServerInput.validate, this.validationCustomizer);
96
+ }
97
+ case "GetGameStatus": {
98
+ return handle(request, context, "GetGameStatus", this.serializerFactory("GetGameStatus"), this.service.GetGameStatus, this.serializeFrameworkException, GetGameStatusServerInput.validate, this.validationCustomizer);
99
+ }
100
+ case "GetMetadata": {
101
+ return handle(request, context, "GetMetadata", this.serializerFactory("GetMetadata"), this.service.GetMetadata, this.serializeFrameworkException, GetMetadataServerInput.validate, this.validationCustomizer);
102
+ }
103
+ case "GetPlayerView": {
104
+ return handle(request, context, "GetPlayerView", this.serializerFactory("GetPlayerView"), this.service.GetPlayerView, this.serializeFrameworkException, GetPlayerViewServerInput.validate, this.validationCustomizer);
105
+ }
106
+ case "GetSaveFileEditorState": {
107
+ return handle(request, context, "GetSaveFileEditorState", this.serializerFactory("GetSaveFileEditorState"), this.service.GetSaveFileEditorState, this.serializeFrameworkException, GetSaveFileEditorStateServerInput.validate, this.validationCustomizer);
108
+ }
109
+ case "Health": {
110
+ return handle(request, context, "Health", this.serializerFactory("Health"), this.service.Health, this.serializeFrameworkException, HealthServerInput.validate, this.validationCustomizer);
111
+ }
112
+ case "InitializeGame": {
113
+ return handle(request, context, "InitializeGame", this.serializerFactory("InitializeGame"), this.service.InitializeGame, this.serializeFrameworkException, InitializeGameServerInput.validate, this.validationCustomizer);
114
+ }
115
+ case "IsConfigMove": {
116
+ return handle(request, context, "IsConfigMove", this.serializerFactory("IsConfigMove"), this.service.IsConfigMove, this.serializeFrameworkException, IsConfigMoveServerInput.validate, this.validationCustomizer);
117
+ }
118
+ case "IsOutOfTurnMove": {
119
+ return handle(request, context, "IsOutOfTurnMove", this.serializerFactory("IsOutOfTurnMove"), this.service.IsOutOfTurnMove, this.serializeFrameworkException, IsOutOfTurnMoveServerInput.validate, this.validationCustomizer);
120
+ }
121
+ case "SelectBotMove": {
122
+ return handle(request, context, "SelectBotMove", this.serializerFactory("SelectBotMove"), this.service.SelectBotMove, this.serializeFrameworkException, SelectBotMoveServerInput.validate, this.validationCustomizer);
123
+ }
124
+ case "ValidateMove": {
125
+ return handle(request, context, "ValidateMove", this.serializerFactory("ValidateMove"), this.service.ValidateMove, this.serializeFrameworkException, ValidateMoveServerInput.validate, this.validationCustomizer);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ export const getGamePluginServiceHandler = (service, customizer) => {
131
+ const mux = new httpbinding.HttpBindingMux([
132
+ new httpbinding.UriSpec('POST', [
133
+ { type: 'path_literal', value: "v1" },
134
+ { type: 'path_literal', value: "moves" },
135
+ { type: 'path_literal', value: "apply" },
136
+ ], [], { service: "GamePlugin", operation: "ApplyMove" }),
137
+ new httpbinding.UriSpec('POST', [
138
+ { type: 'path_literal', value: "v1" },
139
+ { type: 'path_literal', value: "saves" },
140
+ { type: 'path_literal', value: "editor-edit" },
141
+ ], [], { service: "GamePlugin", operation: "ApplySaveFileEdit" }),
142
+ new httpbinding.UriSpec('POST', [
143
+ { type: 'path_literal', value: "v1" },
144
+ { type: 'path_literal', value: "participants" },
145
+ { type: 'path_literal', value: "assign" },
146
+ ], [], { service: "GamePlugin", operation: "AssignParticipants" }),
147
+ new httpbinding.UriSpec('POST', [
148
+ { type: 'path_literal', value: "v1" },
149
+ { type: 'path_literal', value: "saves" },
150
+ { type: 'path_literal', value: "describe" },
151
+ ], [], { service: "GamePlugin", operation: "DescribeSaveFile" }),
152
+ new httpbinding.UriSpec('POST', [
153
+ { type: 'path_literal', value: "v1" },
154
+ { type: 'path_literal', value: "games" },
155
+ { type: 'path_literal', value: "result" },
156
+ ], [], { service: "GamePlugin", operation: "GetGameResult" }),
157
+ new httpbinding.UriSpec('POST', [
158
+ { type: 'path_literal', value: "v1" },
159
+ { type: 'path_literal', value: "games" },
160
+ { type: 'path_literal', value: "status" },
161
+ ], [], { service: "GamePlugin", operation: "GetGameStatus" }),
162
+ new httpbinding.UriSpec('GET', [
163
+ { type: 'path_literal', value: "v1" },
164
+ { type: 'path_literal', value: "metadata" },
165
+ ], [], { service: "GamePlugin", operation: "GetMetadata" }),
166
+ new httpbinding.UriSpec('POST', [
167
+ { type: 'path_literal', value: "v1" },
168
+ { type: 'path_literal', value: "games" },
169
+ { type: 'path_literal', value: "player-view" },
170
+ ], [], { service: "GamePlugin", operation: "GetPlayerView" }),
171
+ new httpbinding.UriSpec('POST', [
172
+ { type: 'path_literal', value: "v1" },
173
+ { type: 'path_literal', value: "saves" },
174
+ { type: 'path_literal', value: "editor-state" },
175
+ ], [], { service: "GamePlugin", operation: "GetSaveFileEditorState" }),
176
+ new httpbinding.UriSpec('GET', [
177
+ { type: 'path_literal', value: "v1" },
178
+ { type: 'path_literal', value: "health" },
179
+ ], [], { service: "GamePlugin", operation: "Health" }),
180
+ new httpbinding.UriSpec('POST', [
181
+ { type: 'path_literal', value: "v1" },
182
+ { type: 'path_literal', value: "games" },
183
+ { type: 'path_literal', value: "initialize" },
184
+ ], [], { service: "GamePlugin", operation: "InitializeGame" }),
185
+ new httpbinding.UriSpec('POST', [
186
+ { type: 'path_literal', value: "v1" },
187
+ { type: 'path_literal', value: "moves" },
188
+ { type: 'path_literal', value: "is-config" },
189
+ ], [], { service: "GamePlugin", operation: "IsConfigMove" }),
190
+ new httpbinding.UriSpec('POST', [
191
+ { type: 'path_literal', value: "v1" },
192
+ { type: 'path_literal', value: "moves" },
193
+ { type: 'path_literal', value: "is-out-of-turn" },
194
+ ], [], { service: "GamePlugin", operation: "IsOutOfTurnMove" }),
195
+ new httpbinding.UriSpec('POST', [
196
+ { type: 'path_literal', value: "v1" },
197
+ { type: 'path_literal', value: "bots" },
198
+ { type: 'path_literal', value: "select-move" },
199
+ ], [], { service: "GamePlugin", operation: "SelectBotMove" }),
200
+ new httpbinding.UriSpec('POST', [
201
+ { type: 'path_literal', value: "v1" },
202
+ { type: 'path_literal', value: "moves" },
203
+ { type: 'path_literal', value: "validate" },
204
+ ], [], { service: "GamePlugin", operation: "ValidateMove" }),
205
+ ]);
206
+ const serFn = (op) => {
207
+ switch (op) {
208
+ case "ApplyMove": return new ApplyMoveSerializer();
209
+ case "ApplySaveFileEdit": return new ApplySaveFileEditSerializer();
210
+ case "AssignParticipants": return new AssignParticipantsSerializer();
211
+ case "DescribeSaveFile": return new DescribeSaveFileSerializer();
212
+ case "GetGameResult": return new GetGameResultSerializer();
213
+ case "GetGameStatus": return new GetGameStatusSerializer();
214
+ case "GetMetadata": return new GetMetadataSerializer();
215
+ case "GetPlayerView": return new GetPlayerViewSerializer();
216
+ case "GetSaveFileEditorState": return new GetSaveFileEditorStateSerializer();
217
+ case "Health": return new HealthSerializer();
218
+ case "InitializeGame": return new InitializeGameSerializer();
219
+ case "IsConfigMove": return new IsConfigMoveSerializer();
220
+ case "IsOutOfTurnMove": return new IsOutOfTurnMoveSerializer();
221
+ case "SelectBotMove": return new SelectBotMoveSerializer();
222
+ case "ValidateMove": return new ValidateMoveSerializer();
223
+ }
224
+ };
225
+ return new GamePluginServiceHandler(service, mux, serFn, serializeFrameworkException, customizer);
226
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./operations";
2
+ export * from "./GamePluginService";
@@ -0,0 +1,103 @@
1
+ import { ApplyMoveInput, } from "../../models/models_0";
2
+ import { deserializeApplyMoveRequest, serializeApplyMoveResponse, serializeFrameworkException, serializeInvalidMoveErrorError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
4
+ import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
5
+ import { fromBase64, toBase64, } from "@smithy/util-base64";
6
+ import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
7
+ export var ApplyMoveServerInput;
8
+ (function (ApplyMoveServerInput) {
9
+ ApplyMoveServerInput.validate = ApplyMoveInput.validate;
10
+ })(ApplyMoveServerInput || (ApplyMoveServerInput = {}));
11
+ export class ApplyMoveSerializer {
12
+ serialize = serializeApplyMoveResponse;
13
+ deserialize = deserializeApplyMoveRequest;
14
+ isOperationError(error) {
15
+ const names = ["InvalidMoveError"];
16
+ return names.includes(error.name);
17
+ }
18
+ ;
19
+ serializeError(error, ctx) {
20
+ switch (error.name) {
21
+ case "InvalidMoveError": {
22
+ return serializeInvalidMoveErrorError(error, ctx);
23
+ }
24
+ default: {
25
+ throw error;
26
+ }
27
+ }
28
+ }
29
+ }
30
+ export const getApplyMoveHandler = (operation, customizer) => {
31
+ const mux = new httpbinding.HttpBindingMux([
32
+ new httpbinding.UriSpec('POST', [
33
+ { type: 'path_literal', value: "v1" },
34
+ { type: 'path_literal', value: "moves" },
35
+ { type: 'path_literal', value: "apply" },
36
+ ], [], { service: "GamePlugin", operation: "ApplyMove" }),
37
+ ]);
38
+ return new ApplyMoveHandler(operation, mux, new ApplyMoveSerializer(), serializeFrameworkException, customizer);
39
+ };
40
+ const serdeContextBase = {
41
+ base64Encoder: toBase64,
42
+ base64Decoder: fromBase64,
43
+ utf8Encoder: toUtf8,
44
+ utf8Decoder: fromUtf8,
45
+ streamCollector: streamCollector,
46
+ requestHandler: new NodeHttpHandler(),
47
+ disableHostPrefix: true
48
+ };
49
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
50
+ let input;
51
+ try {
52
+ input = await serializer.deserialize(request, {
53
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
54
+ });
55
+ }
56
+ catch (error) {
57
+ if (__isFrameworkException(error)) {
58
+ return serializeFrameworkException(error, serdeContextBase);
59
+ }
60
+ ;
61
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
62
+ }
63
+ try {
64
+ let validationFailures = validationFn(input);
65
+ if (validationFailures && validationFailures.length > 0) {
66
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
67
+ if (validationException) {
68
+ return serializer.serializeError(validationException, serdeContextBase);
69
+ }
70
+ }
71
+ let output = await operation(input, context);
72
+ return serializer.serialize(output, serdeContextBase);
73
+ }
74
+ catch (error) {
75
+ if (serializer.isOperationError(error)) {
76
+ return serializer.serializeError(error, serdeContextBase);
77
+ }
78
+ console.log('Received an unexpected error', error);
79
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
80
+ }
81
+ }
82
+ export class ApplyMoveHandler {
83
+ operation;
84
+ mux;
85
+ serializer;
86
+ serializeFrameworkException;
87
+ validationCustomizer;
88
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
89
+ this.operation = operation;
90
+ this.mux = mux;
91
+ this.serializer = serializer;
92
+ this.serializeFrameworkException = serializeFrameworkException;
93
+ this.validationCustomizer = validationCustomizer;
94
+ }
95
+ async handle(request, context) {
96
+ const target = this.mux.match(request);
97
+ if (target === undefined) {
98
+ console.log('Received a request that did not match com.boardgame.plugin#GamePlugin.ApplyMove. This indicates a misconfiguration.');
99
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
100
+ }
101
+ return handle(request, context, "ApplyMove", this.serializer, this.operation, this.serializeFrameworkException, ApplyMoveServerInput.validate, this.validationCustomizer);
102
+ }
103
+ }
@@ -0,0 +1,103 @@
1
+ import { ApplySaveFileEditInput, } from "../../models/models_0";
2
+ import { deserializeApplySaveFileEditRequest, serializeApplySaveFileEditResponse, serializeFrameworkException, serializeSaveFileEditRejectedErrorError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
4
+ import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
5
+ import { fromBase64, toBase64, } from "@smithy/util-base64";
6
+ import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
7
+ export var ApplySaveFileEditServerInput;
8
+ (function (ApplySaveFileEditServerInput) {
9
+ ApplySaveFileEditServerInput.validate = ApplySaveFileEditInput.validate;
10
+ })(ApplySaveFileEditServerInput || (ApplySaveFileEditServerInput = {}));
11
+ export class ApplySaveFileEditSerializer {
12
+ serialize = serializeApplySaveFileEditResponse;
13
+ deserialize = deserializeApplySaveFileEditRequest;
14
+ isOperationError(error) {
15
+ const names = ["SaveFileEditRejectedError"];
16
+ return names.includes(error.name);
17
+ }
18
+ ;
19
+ serializeError(error, ctx) {
20
+ switch (error.name) {
21
+ case "SaveFileEditRejectedError": {
22
+ return serializeSaveFileEditRejectedErrorError(error, ctx);
23
+ }
24
+ default: {
25
+ throw error;
26
+ }
27
+ }
28
+ }
29
+ }
30
+ export const getApplySaveFileEditHandler = (operation, customizer) => {
31
+ const mux = new httpbinding.HttpBindingMux([
32
+ new httpbinding.UriSpec('POST', [
33
+ { type: 'path_literal', value: "v1" },
34
+ { type: 'path_literal', value: "saves" },
35
+ { type: 'path_literal', value: "editor-edit" },
36
+ ], [], { service: "GamePlugin", operation: "ApplySaveFileEdit" }),
37
+ ]);
38
+ return new ApplySaveFileEditHandler(operation, mux, new ApplySaveFileEditSerializer(), serializeFrameworkException, customizer);
39
+ };
40
+ const serdeContextBase = {
41
+ base64Encoder: toBase64,
42
+ base64Decoder: fromBase64,
43
+ utf8Encoder: toUtf8,
44
+ utf8Decoder: fromUtf8,
45
+ streamCollector: streamCollector,
46
+ requestHandler: new NodeHttpHandler(),
47
+ disableHostPrefix: true
48
+ };
49
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
50
+ let input;
51
+ try {
52
+ input = await serializer.deserialize(request, {
53
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
54
+ });
55
+ }
56
+ catch (error) {
57
+ if (__isFrameworkException(error)) {
58
+ return serializeFrameworkException(error, serdeContextBase);
59
+ }
60
+ ;
61
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
62
+ }
63
+ try {
64
+ let validationFailures = validationFn(input);
65
+ if (validationFailures && validationFailures.length > 0) {
66
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
67
+ if (validationException) {
68
+ return serializer.serializeError(validationException, serdeContextBase);
69
+ }
70
+ }
71
+ let output = await operation(input, context);
72
+ return serializer.serialize(output, serdeContextBase);
73
+ }
74
+ catch (error) {
75
+ if (serializer.isOperationError(error)) {
76
+ return serializer.serializeError(error, serdeContextBase);
77
+ }
78
+ console.log('Received an unexpected error', error);
79
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
80
+ }
81
+ }
82
+ export class ApplySaveFileEditHandler {
83
+ operation;
84
+ mux;
85
+ serializer;
86
+ serializeFrameworkException;
87
+ validationCustomizer;
88
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
89
+ this.operation = operation;
90
+ this.mux = mux;
91
+ this.serializer = serializer;
92
+ this.serializeFrameworkException = serializeFrameworkException;
93
+ this.validationCustomizer = validationCustomizer;
94
+ }
95
+ async handle(request, context) {
96
+ const target = this.mux.match(request);
97
+ if (target === undefined) {
98
+ console.log('Received a request that did not match com.boardgame.plugin#GamePlugin.ApplySaveFileEdit. This indicates a misconfiguration.');
99
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
100
+ }
101
+ return handle(request, context, "ApplySaveFileEdit", this.serializer, this.operation, this.serializeFrameworkException, ApplySaveFileEditServerInput.validate, this.validationCustomizer);
102
+ }
103
+ }
@@ -0,0 +1,95 @@
1
+ import { AssignParticipantsInput, } from "../../models/models_0";
2
+ import { deserializeAssignParticipantsRequest, serializeAssignParticipantsResponse, serializeFrameworkException, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
4
+ import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
5
+ import { fromBase64, toBase64, } from "@smithy/util-base64";
6
+ import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
7
+ export var AssignParticipantsServerInput;
8
+ (function (AssignParticipantsServerInput) {
9
+ AssignParticipantsServerInput.validate = AssignParticipantsInput.validate;
10
+ })(AssignParticipantsServerInput || (AssignParticipantsServerInput = {}));
11
+ export class AssignParticipantsSerializer {
12
+ serialize = serializeAssignParticipantsResponse;
13
+ deserialize = deserializeAssignParticipantsRequest;
14
+ isOperationError(error) {
15
+ return false;
16
+ }
17
+ ;
18
+ serializeError(error, ctx) {
19
+ throw error;
20
+ }
21
+ }
22
+ export const getAssignParticipantsHandler = (operation, customizer) => {
23
+ const mux = new httpbinding.HttpBindingMux([
24
+ new httpbinding.UriSpec('POST', [
25
+ { type: 'path_literal', value: "v1" },
26
+ { type: 'path_literal', value: "participants" },
27
+ { type: 'path_literal', value: "assign" },
28
+ ], [], { service: "GamePlugin", operation: "AssignParticipants" }),
29
+ ]);
30
+ return new AssignParticipantsHandler(operation, mux, new AssignParticipantsSerializer(), serializeFrameworkException, customizer);
31
+ };
32
+ const serdeContextBase = {
33
+ base64Encoder: toBase64,
34
+ base64Decoder: fromBase64,
35
+ utf8Encoder: toUtf8,
36
+ utf8Decoder: fromUtf8,
37
+ streamCollector: streamCollector,
38
+ requestHandler: new NodeHttpHandler(),
39
+ disableHostPrefix: true
40
+ };
41
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
42
+ let input;
43
+ try {
44
+ input = await serializer.deserialize(request, {
45
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
46
+ });
47
+ }
48
+ catch (error) {
49
+ if (__isFrameworkException(error)) {
50
+ return serializeFrameworkException(error, serdeContextBase);
51
+ }
52
+ ;
53
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
54
+ }
55
+ try {
56
+ let validationFailures = validationFn(input);
57
+ if (validationFailures && validationFailures.length > 0) {
58
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
59
+ if (validationException) {
60
+ return serializer.serializeError(validationException, serdeContextBase);
61
+ }
62
+ }
63
+ let output = await operation(input, context);
64
+ return serializer.serialize(output, serdeContextBase);
65
+ }
66
+ catch (error) {
67
+ if (serializer.isOperationError(error)) {
68
+ return serializer.serializeError(error, serdeContextBase);
69
+ }
70
+ console.log('Received an unexpected error', error);
71
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
72
+ }
73
+ }
74
+ export class AssignParticipantsHandler {
75
+ operation;
76
+ mux;
77
+ serializer;
78
+ serializeFrameworkException;
79
+ validationCustomizer;
80
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
81
+ this.operation = operation;
82
+ this.mux = mux;
83
+ this.serializer = serializer;
84
+ this.serializeFrameworkException = serializeFrameworkException;
85
+ this.validationCustomizer = validationCustomizer;
86
+ }
87
+ async handle(request, context) {
88
+ const target = this.mux.match(request);
89
+ if (target === undefined) {
90
+ console.log('Received a request that did not match com.boardgame.plugin#GamePlugin.AssignParticipants. This indicates a misconfiguration.');
91
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
92
+ }
93
+ return handle(request, context, "AssignParticipants", this.serializer, this.operation, this.serializeFrameworkException, AssignParticipantsServerInput.validate, this.validationCustomizer);
94
+ }
95
+ }
@@ -0,0 +1,95 @@
1
+ import { DescribeSaveFileInput, } from "../../models/models_0";
2
+ import { deserializeDescribeSaveFileRequest, serializeDescribeSaveFileResponse, serializeFrameworkException, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
4
+ import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
5
+ import { fromBase64, toBase64, } from "@smithy/util-base64";
6
+ import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
7
+ export var DescribeSaveFileServerInput;
8
+ (function (DescribeSaveFileServerInput) {
9
+ DescribeSaveFileServerInput.validate = DescribeSaveFileInput.validate;
10
+ })(DescribeSaveFileServerInput || (DescribeSaveFileServerInput = {}));
11
+ export class DescribeSaveFileSerializer {
12
+ serialize = serializeDescribeSaveFileResponse;
13
+ deserialize = deserializeDescribeSaveFileRequest;
14
+ isOperationError(error) {
15
+ return false;
16
+ }
17
+ ;
18
+ serializeError(error, ctx) {
19
+ throw error;
20
+ }
21
+ }
22
+ export const getDescribeSaveFileHandler = (operation, customizer) => {
23
+ const mux = new httpbinding.HttpBindingMux([
24
+ new httpbinding.UriSpec('POST', [
25
+ { type: 'path_literal', value: "v1" },
26
+ { type: 'path_literal', value: "saves" },
27
+ { type: 'path_literal', value: "describe" },
28
+ ], [], { service: "GamePlugin", operation: "DescribeSaveFile" }),
29
+ ]);
30
+ return new DescribeSaveFileHandler(operation, mux, new DescribeSaveFileSerializer(), serializeFrameworkException, customizer);
31
+ };
32
+ const serdeContextBase = {
33
+ base64Encoder: toBase64,
34
+ base64Decoder: fromBase64,
35
+ utf8Encoder: toUtf8,
36
+ utf8Decoder: fromUtf8,
37
+ streamCollector: streamCollector,
38
+ requestHandler: new NodeHttpHandler(),
39
+ disableHostPrefix: true
40
+ };
41
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
42
+ let input;
43
+ try {
44
+ input = await serializer.deserialize(request, {
45
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
46
+ });
47
+ }
48
+ catch (error) {
49
+ if (__isFrameworkException(error)) {
50
+ return serializeFrameworkException(error, serdeContextBase);
51
+ }
52
+ ;
53
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
54
+ }
55
+ try {
56
+ let validationFailures = validationFn(input);
57
+ if (validationFailures && validationFailures.length > 0) {
58
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
59
+ if (validationException) {
60
+ return serializer.serializeError(validationException, serdeContextBase);
61
+ }
62
+ }
63
+ let output = await operation(input, context);
64
+ return serializer.serialize(output, serdeContextBase);
65
+ }
66
+ catch (error) {
67
+ if (serializer.isOperationError(error)) {
68
+ return serializer.serializeError(error, serdeContextBase);
69
+ }
70
+ console.log('Received an unexpected error', error);
71
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
72
+ }
73
+ }
74
+ export class DescribeSaveFileHandler {
75
+ operation;
76
+ mux;
77
+ serializer;
78
+ serializeFrameworkException;
79
+ validationCustomizer;
80
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
81
+ this.operation = operation;
82
+ this.mux = mux;
83
+ this.serializer = serializer;
84
+ this.serializeFrameworkException = serializeFrameworkException;
85
+ this.validationCustomizer = validationCustomizer;
86
+ }
87
+ async handle(request, context) {
88
+ const target = this.mux.match(request);
89
+ if (target === undefined) {
90
+ console.log('Received a request that did not match com.boardgame.plugin#GamePlugin.DescribeSaveFile. This indicates a misconfiguration.');
91
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
92
+ }
93
+ return handle(request, context, "DescribeSaveFile", this.serializer, this.operation, this.serializeFrameworkException, DescribeSaveFileServerInput.validate, this.validationCustomizer);
94
+ }
95
+ }