@sparkrewards/sra-sdk 0.0.1

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 (106) hide show
  1. package/LICENSE +201 -0
  2. package/dist-cjs/index.js +8 -0
  3. package/dist-cjs/models/index.js +4 -0
  4. package/dist-cjs/models/models_0.js +1901 -0
  5. package/dist-cjs/openapi.js +7 -0
  6. package/dist-cjs/openapi.json +2864 -0
  7. package/dist-cjs/protocols/Aws_restJson1.js +2939 -0
  8. package/dist-cjs/server/AppAPIService.js +371 -0
  9. package/dist-cjs/server/index.js +5 -0
  10. package/dist-cjs/server/operations/DeleteUser.js +121 -0
  11. package/dist-cjs/server/operations/FavoritePlans.js +125 -0
  12. package/dist-cjs/server/operations/FavoriteShops.js +122 -0
  13. package/dist-cjs/server/operations/GetShop.js +126 -0
  14. package/dist-cjs/server/operations/GetShopPublic.js +127 -0
  15. package/dist-cjs/server/operations/GetUser.js +121 -0
  16. package/dist-cjs/server/operations/LikeOrg.js +124 -0
  17. package/dist-cjs/server/operations/NearbyShops.js +121 -0
  18. package/dist-cjs/server/operations/NearbyShopsPublic.js +122 -0
  19. package/dist-cjs/server/operations/NearestShop.js +126 -0
  20. package/dist-cjs/server/operations/OnboardUser.js +122 -0
  21. package/dist-cjs/server/operations/PinnedShop.js +126 -0
  22. package/dist-cjs/server/operations/PinnedShopPublic.js +127 -0
  23. package/dist-cjs/server/operations/Plan.js +123 -0
  24. package/dist-cjs/server/operations/PlanPublic.js +124 -0
  25. package/dist-cjs/server/operations/Plans.js +124 -0
  26. package/dist-cjs/server/operations/PopularShops.js +122 -0
  27. package/dist-cjs/server/operations/PopularShopsPublic.js +123 -0
  28. package/dist-cjs/server/operations/RadiusShops.js +123 -0
  29. package/dist-cjs/server/operations/RecordVisit.js +129 -0
  30. package/dist-cjs/server/operations/RedeemFirstTimeReward.js +125 -0
  31. package/dist-cjs/server/operations/RedeemPointReward.js +126 -0
  32. package/dist-cjs/server/operations/RedeemVisitReward.js +125 -0
  33. package/dist-cjs/server/operations/SearchShopsPublic.js +125 -0
  34. package/dist-cjs/server/operations/SearchSuggestion.js +126 -0
  35. package/dist-cjs/server/operations/UpdateUser.js +121 -0
  36. package/dist-cjs/server/operations/index.js +29 -0
  37. package/dist-es/index.js +4 -0
  38. package/dist-es/models/index.js +1 -0
  39. package/dist-es/models/models_0.js +1893 -0
  40. package/dist-es/openapi.js +3 -0
  41. package/dist-es/openapi.json +2864 -0
  42. package/dist-es/protocols/Aws_restJson1.js +2878 -0
  43. package/dist-es/server/AppAPIService.js +366 -0
  44. package/dist-es/server/index.js +2 -0
  45. package/dist-es/server/operations/DeleteUser.js +115 -0
  46. package/dist-es/server/operations/FavoritePlans.js +119 -0
  47. package/dist-es/server/operations/FavoriteShops.js +116 -0
  48. package/dist-es/server/operations/GetShop.js +120 -0
  49. package/dist-es/server/operations/GetShopPublic.js +121 -0
  50. package/dist-es/server/operations/GetUser.js +115 -0
  51. package/dist-es/server/operations/LikeOrg.js +118 -0
  52. package/dist-es/server/operations/NearbyShops.js +115 -0
  53. package/dist-es/server/operations/NearbyShopsPublic.js +116 -0
  54. package/dist-es/server/operations/NearestShop.js +120 -0
  55. package/dist-es/server/operations/OnboardUser.js +116 -0
  56. package/dist-es/server/operations/PinnedShop.js +120 -0
  57. package/dist-es/server/operations/PinnedShopPublic.js +121 -0
  58. package/dist-es/server/operations/Plan.js +117 -0
  59. package/dist-es/server/operations/PlanPublic.js +118 -0
  60. package/dist-es/server/operations/Plans.js +118 -0
  61. package/dist-es/server/operations/PopularShops.js +116 -0
  62. package/dist-es/server/operations/PopularShopsPublic.js +117 -0
  63. package/dist-es/server/operations/RadiusShops.js +117 -0
  64. package/dist-es/server/operations/RecordVisit.js +123 -0
  65. package/dist-es/server/operations/RedeemFirstTimeReward.js +119 -0
  66. package/dist-es/server/operations/RedeemPointReward.js +120 -0
  67. package/dist-es/server/operations/RedeemVisitReward.js +119 -0
  68. package/dist-es/server/operations/SearchShopsPublic.js +119 -0
  69. package/dist-es/server/operations/SearchSuggestion.js +120 -0
  70. package/dist-es/server/operations/UpdateUser.js +115 -0
  71. package/dist-es/server/operations/index.js +26 -0
  72. package/dist-types/index.d.ts +9 -0
  73. package/dist-types/models/index.d.ts +1 -0
  74. package/dist-types/models/models_0.d.ts +832 -0
  75. package/dist-types/openapi.d.ts +7 -0
  76. package/dist-types/protocols/Aws_restJson1.d.ts +87 -0
  77. package/dist-types/server/AppAPIService.d.ts +76 -0
  78. package/dist-types/server/index.d.ts +2 -0
  79. package/dist-types/server/operations/DeleteUser.d.ts +41 -0
  80. package/dist-types/server/operations/FavoritePlans.d.ts +41 -0
  81. package/dist-types/server/operations/FavoriteShops.d.ts +41 -0
  82. package/dist-types/server/operations/GetShop.d.ts +41 -0
  83. package/dist-types/server/operations/GetShopPublic.d.ts +41 -0
  84. package/dist-types/server/operations/GetUser.d.ts +41 -0
  85. package/dist-types/server/operations/LikeOrg.d.ts +41 -0
  86. package/dist-types/server/operations/NearbyShops.d.ts +41 -0
  87. package/dist-types/server/operations/NearbyShopsPublic.d.ts +41 -0
  88. package/dist-types/server/operations/NearestShop.d.ts +41 -0
  89. package/dist-types/server/operations/OnboardUser.d.ts +41 -0
  90. package/dist-types/server/operations/PinnedShop.d.ts +41 -0
  91. package/dist-types/server/operations/PinnedShopPublic.d.ts +41 -0
  92. package/dist-types/server/operations/Plan.d.ts +41 -0
  93. package/dist-types/server/operations/PlanPublic.d.ts +41 -0
  94. package/dist-types/server/operations/Plans.d.ts +41 -0
  95. package/dist-types/server/operations/PopularShops.d.ts +41 -0
  96. package/dist-types/server/operations/PopularShopsPublic.d.ts +41 -0
  97. package/dist-types/server/operations/RadiusShops.d.ts +41 -0
  98. package/dist-types/server/operations/RecordVisit.d.ts +41 -0
  99. package/dist-types/server/operations/RedeemFirstTimeReward.d.ts +41 -0
  100. package/dist-types/server/operations/RedeemPointReward.d.ts +41 -0
  101. package/dist-types/server/operations/RedeemVisitReward.d.ts +41 -0
  102. package/dist-types/server/operations/SearchShopsPublic.d.ts +41 -0
  103. package/dist-types/server/operations/SearchSuggestion.d.ts +41 -0
  104. package/dist-types/server/operations/UpdateUser.d.ts +41 -0
  105. package/dist-types/server/operations/index.d.ts +26 -0
  106. package/package.json +66 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PinnedShopPublicHandler = exports.getPinnedShopPublicHandler = exports.PinnedShopPublicSerializer = exports.PinnedShopPublicServerInput = void 0;
4
+ const models_0_1 = require("../../models/models_0");
5
+ const Aws_restJson1_1 = require("../../protocols/Aws_restJson1");
6
+ const server_common_1 = require("@aws-smithy/server-common");
7
+ const node_http_handler_1 = require("@smithy/node-http-handler");
8
+ const util_base64_1 = require("@smithy/util-base64");
9
+ const util_utf8_1 = require("@smithy/util-utf8");
10
+ var PinnedShopPublicServerInput;
11
+ (function (PinnedShopPublicServerInput) {
12
+ PinnedShopPublicServerInput.validate = models_0_1.PinnedShopInput.validate;
13
+ })(PinnedShopPublicServerInput = exports.PinnedShopPublicServerInput || (exports.PinnedShopPublicServerInput = {}));
14
+ class PinnedShopPublicSerializer {
15
+ constructor() {
16
+ this.serialize = Aws_restJson1_1.serializePinnedShopPublicResponse;
17
+ this.deserialize = Aws_restJson1_1.deserializePinnedShopPublicRequest;
18
+ }
19
+ isOperationError(error) {
20
+ const names = ["ValidationException", "RuntimeError"];
21
+ return names.includes(error.name);
22
+ }
23
+ ;
24
+ serializeError(error, ctx) {
25
+ switch (error.name) {
26
+ case "ValidationException": {
27
+ return (0, Aws_restJson1_1.serializeValidationExceptionError)(error, ctx);
28
+ }
29
+ case "RuntimeError": {
30
+ return (0, Aws_restJson1_1.serializeRuntimeErrorError)(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ exports.PinnedShopPublicSerializer = PinnedShopPublicSerializer;
39
+ const getPinnedShopPublicHandler = (operation) => {
40
+ const mux = new server_common_1.httpbinding.HttpBindingMux([
41
+ new server_common_1.httpbinding.UriSpec('GET', [
42
+ { type: 'path_literal', value: "public" },
43
+ { type: 'path_literal', value: "shops" },
44
+ { type: 'path_literal', value: "pinned" },
45
+ ], [
46
+ { type: 'query', key: "shop_id" },
47
+ { type: 'query', key: "lat" },
48
+ { type: 'query', key: "lon" },
49
+ ], { service: "AppAPI", operation: "PinnedShopPublic" }),
50
+ ]);
51
+ const customizer = (ctx, failures) => {
52
+ if (!failures) {
53
+ return undefined;
54
+ }
55
+ return {
56
+ name: "ValidationException",
57
+ $fault: "client",
58
+ message: (0, server_common_1.generateValidationSummary)(failures),
59
+ fieldList: failures.map(failure => ({
60
+ path: failure.path,
61
+ message: (0, server_common_1.generateValidationMessage)(failure)
62
+ }))
63
+ };
64
+ };
65
+ return new PinnedShopPublicHandler(operation, mux, new PinnedShopPublicSerializer(), Aws_restJson1_1.serializeFrameworkException, customizer);
66
+ };
67
+ exports.getPinnedShopPublicHandler = getPinnedShopPublicHandler;
68
+ const serdeContextBase = {
69
+ base64Encoder: util_base64_1.toBase64,
70
+ base64Decoder: util_base64_1.fromBase64,
71
+ utf8Encoder: util_utf8_1.toUtf8,
72
+ utf8Decoder: util_utf8_1.fromUtf8,
73
+ streamCollector: node_http_handler_1.streamCollector,
74
+ requestHandler: new node_http_handler_1.NodeHttpHandler(),
75
+ disableHostPrefix: true
76
+ };
77
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
78
+ let input;
79
+ try {
80
+ input = await serializer.deserialize(request, {
81
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
82
+ });
83
+ }
84
+ catch (error) {
85
+ if ((0, server_common_1.isFrameworkException)(error)) {
86
+ return serializeFrameworkException(error, serdeContextBase);
87
+ }
88
+ ;
89
+ return serializeFrameworkException(new server_common_1.SerializationException(), serdeContextBase);
90
+ }
91
+ try {
92
+ let validationFailures = validationFn(input);
93
+ if (validationFailures && validationFailures.length > 0) {
94
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
95
+ if (validationException) {
96
+ return serializer.serializeError(validationException, serdeContextBase);
97
+ }
98
+ }
99
+ let output = await operation(input, context);
100
+ return serializer.serialize(output, serdeContextBase);
101
+ }
102
+ catch (error) {
103
+ if (serializer.isOperationError(error)) {
104
+ return serializer.serializeError(error, serdeContextBase);
105
+ }
106
+ console.log('Received an unexpected error', error);
107
+ return serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
108
+ }
109
+ }
110
+ class PinnedShopPublicHandler {
111
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
112
+ this.operation = operation;
113
+ this.mux = mux;
114
+ this.serializer = serializer;
115
+ this.serializeFrameworkException = serializeFrameworkException;
116
+ this.validationCustomizer = validationCustomizer;
117
+ }
118
+ async handle(request, context) {
119
+ const target = this.mux.match(request);
120
+ if (target === undefined) {
121
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PinnedShopPublic. This indicates a misconfiguration.');
122
+ return this.serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
123
+ }
124
+ return handle(request, context, "PinnedShopPublic", this.serializer, this.operation, this.serializeFrameworkException, PinnedShopPublicServerInput.validate, this.validationCustomizer);
125
+ }
126
+ }
127
+ exports.PinnedShopPublicHandler = PinnedShopPublicHandler;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlanHandler = exports.getPlanHandler = exports.PlanSerializer = exports.PlanServerInput = void 0;
4
+ const models_0_1 = require("../../models/models_0");
5
+ const Aws_restJson1_1 = require("../../protocols/Aws_restJson1");
6
+ const server_common_1 = require("@aws-smithy/server-common");
7
+ const node_http_handler_1 = require("@smithy/node-http-handler");
8
+ const util_base64_1 = require("@smithy/util-base64");
9
+ const util_utf8_1 = require("@smithy/util-utf8");
10
+ var PlanServerInput;
11
+ (function (PlanServerInput) {
12
+ PlanServerInput.validate = models_0_1.PlanGetInput.validate;
13
+ })(PlanServerInput = exports.PlanServerInput || (exports.PlanServerInput = {}));
14
+ class PlanSerializer {
15
+ constructor() {
16
+ this.serialize = Aws_restJson1_1.serializePlanResponse;
17
+ this.deserialize = Aws_restJson1_1.deserializePlanRequest;
18
+ }
19
+ isOperationError(error) {
20
+ const names = ["ValidationException", "RuntimeError"];
21
+ return names.includes(error.name);
22
+ }
23
+ ;
24
+ serializeError(error, ctx) {
25
+ switch (error.name) {
26
+ case "ValidationException": {
27
+ return (0, Aws_restJson1_1.serializeValidationExceptionError)(error, ctx);
28
+ }
29
+ case "RuntimeError": {
30
+ return (0, Aws_restJson1_1.serializeRuntimeErrorError)(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ exports.PlanSerializer = PlanSerializer;
39
+ const getPlanHandler = (operation) => {
40
+ const mux = new server_common_1.httpbinding.HttpBindingMux([
41
+ new server_common_1.httpbinding.UriSpec('GET', [
42
+ { type: 'path_literal', value: "plan" },
43
+ ], [
44
+ { type: 'query', key: "org_id" },
45
+ ], { service: "AppAPI", operation: "Plan" }),
46
+ ]);
47
+ const customizer = (ctx, failures) => {
48
+ if (!failures) {
49
+ return undefined;
50
+ }
51
+ return {
52
+ name: "ValidationException",
53
+ $fault: "client",
54
+ message: (0, server_common_1.generateValidationSummary)(failures),
55
+ fieldList: failures.map(failure => ({
56
+ path: failure.path,
57
+ message: (0, server_common_1.generateValidationMessage)(failure)
58
+ }))
59
+ };
60
+ };
61
+ return new PlanHandler(operation, mux, new PlanSerializer(), Aws_restJson1_1.serializeFrameworkException, customizer);
62
+ };
63
+ exports.getPlanHandler = getPlanHandler;
64
+ const serdeContextBase = {
65
+ base64Encoder: util_base64_1.toBase64,
66
+ base64Decoder: util_base64_1.fromBase64,
67
+ utf8Encoder: util_utf8_1.toUtf8,
68
+ utf8Decoder: util_utf8_1.fromUtf8,
69
+ streamCollector: node_http_handler_1.streamCollector,
70
+ requestHandler: new node_http_handler_1.NodeHttpHandler(),
71
+ disableHostPrefix: true
72
+ };
73
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
74
+ let input;
75
+ try {
76
+ input = await serializer.deserialize(request, {
77
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
78
+ });
79
+ }
80
+ catch (error) {
81
+ if ((0, server_common_1.isFrameworkException)(error)) {
82
+ return serializeFrameworkException(error, serdeContextBase);
83
+ }
84
+ ;
85
+ return serializeFrameworkException(new server_common_1.SerializationException(), serdeContextBase);
86
+ }
87
+ try {
88
+ let validationFailures = validationFn(input);
89
+ if (validationFailures && validationFailures.length > 0) {
90
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
91
+ if (validationException) {
92
+ return serializer.serializeError(validationException, serdeContextBase);
93
+ }
94
+ }
95
+ let output = await operation(input, context);
96
+ return serializer.serialize(output, serdeContextBase);
97
+ }
98
+ catch (error) {
99
+ if (serializer.isOperationError(error)) {
100
+ return serializer.serializeError(error, serdeContextBase);
101
+ }
102
+ console.log('Received an unexpected error', error);
103
+ return serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
104
+ }
105
+ }
106
+ class PlanHandler {
107
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
108
+ this.operation = operation;
109
+ this.mux = mux;
110
+ this.serializer = serializer;
111
+ this.serializeFrameworkException = serializeFrameworkException;
112
+ this.validationCustomizer = validationCustomizer;
113
+ }
114
+ async handle(request, context) {
115
+ const target = this.mux.match(request);
116
+ if (target === undefined) {
117
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.Plan. This indicates a misconfiguration.');
118
+ return this.serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
119
+ }
120
+ return handle(request, context, "Plan", this.serializer, this.operation, this.serializeFrameworkException, PlanServerInput.validate, this.validationCustomizer);
121
+ }
122
+ }
123
+ exports.PlanHandler = PlanHandler;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlanPublicHandler = exports.getPlanPublicHandler = exports.PlanPublicSerializer = exports.PlanPublicServerInput = void 0;
4
+ const models_0_1 = require("../../models/models_0");
5
+ const Aws_restJson1_1 = require("../../protocols/Aws_restJson1");
6
+ const server_common_1 = require("@aws-smithy/server-common");
7
+ const node_http_handler_1 = require("@smithy/node-http-handler");
8
+ const util_base64_1 = require("@smithy/util-base64");
9
+ const util_utf8_1 = require("@smithy/util-utf8");
10
+ var PlanPublicServerInput;
11
+ (function (PlanPublicServerInput) {
12
+ PlanPublicServerInput.validate = models_0_1.PlanGetInput.validate;
13
+ })(PlanPublicServerInput = exports.PlanPublicServerInput || (exports.PlanPublicServerInput = {}));
14
+ class PlanPublicSerializer {
15
+ constructor() {
16
+ this.serialize = Aws_restJson1_1.serializePlanPublicResponse;
17
+ this.deserialize = Aws_restJson1_1.deserializePlanPublicRequest;
18
+ }
19
+ isOperationError(error) {
20
+ const names = ["ValidationException", "RuntimeError"];
21
+ return names.includes(error.name);
22
+ }
23
+ ;
24
+ serializeError(error, ctx) {
25
+ switch (error.name) {
26
+ case "ValidationException": {
27
+ return (0, Aws_restJson1_1.serializeValidationExceptionError)(error, ctx);
28
+ }
29
+ case "RuntimeError": {
30
+ return (0, Aws_restJson1_1.serializeRuntimeErrorError)(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ exports.PlanPublicSerializer = PlanPublicSerializer;
39
+ const getPlanPublicHandler = (operation) => {
40
+ const mux = new server_common_1.httpbinding.HttpBindingMux([
41
+ new server_common_1.httpbinding.UriSpec('GET', [
42
+ { type: 'path_literal', value: "public" },
43
+ { type: 'path_literal', value: "plan" },
44
+ ], [
45
+ { type: 'query', key: "org_id" },
46
+ ], { service: "AppAPI", operation: "PlanPublic" }),
47
+ ]);
48
+ const customizer = (ctx, failures) => {
49
+ if (!failures) {
50
+ return undefined;
51
+ }
52
+ return {
53
+ name: "ValidationException",
54
+ $fault: "client",
55
+ message: (0, server_common_1.generateValidationSummary)(failures),
56
+ fieldList: failures.map(failure => ({
57
+ path: failure.path,
58
+ message: (0, server_common_1.generateValidationMessage)(failure)
59
+ }))
60
+ };
61
+ };
62
+ return new PlanPublicHandler(operation, mux, new PlanPublicSerializer(), Aws_restJson1_1.serializeFrameworkException, customizer);
63
+ };
64
+ exports.getPlanPublicHandler = getPlanPublicHandler;
65
+ const serdeContextBase = {
66
+ base64Encoder: util_base64_1.toBase64,
67
+ base64Decoder: util_base64_1.fromBase64,
68
+ utf8Encoder: util_utf8_1.toUtf8,
69
+ utf8Decoder: util_utf8_1.fromUtf8,
70
+ streamCollector: node_http_handler_1.streamCollector,
71
+ requestHandler: new node_http_handler_1.NodeHttpHandler(),
72
+ disableHostPrefix: true
73
+ };
74
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
75
+ let input;
76
+ try {
77
+ input = await serializer.deserialize(request, {
78
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
79
+ });
80
+ }
81
+ catch (error) {
82
+ if ((0, server_common_1.isFrameworkException)(error)) {
83
+ return serializeFrameworkException(error, serdeContextBase);
84
+ }
85
+ ;
86
+ return serializeFrameworkException(new server_common_1.SerializationException(), serdeContextBase);
87
+ }
88
+ try {
89
+ let validationFailures = validationFn(input);
90
+ if (validationFailures && validationFailures.length > 0) {
91
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
92
+ if (validationException) {
93
+ return serializer.serializeError(validationException, serdeContextBase);
94
+ }
95
+ }
96
+ let output = await operation(input, context);
97
+ return serializer.serialize(output, serdeContextBase);
98
+ }
99
+ catch (error) {
100
+ if (serializer.isOperationError(error)) {
101
+ return serializer.serializeError(error, serdeContextBase);
102
+ }
103
+ console.log('Received an unexpected error', error);
104
+ return serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
105
+ }
106
+ }
107
+ class PlanPublicHandler {
108
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
109
+ this.operation = operation;
110
+ this.mux = mux;
111
+ this.serializer = serializer;
112
+ this.serializeFrameworkException = serializeFrameworkException;
113
+ this.validationCustomizer = validationCustomizer;
114
+ }
115
+ async handle(request, context) {
116
+ const target = this.mux.match(request);
117
+ if (target === undefined) {
118
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PlanPublic. This indicates a misconfiguration.');
119
+ return this.serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
120
+ }
121
+ return handle(request, context, "PlanPublic", this.serializer, this.operation, this.serializeFrameworkException, PlanPublicServerInput.validate, this.validationCustomizer);
122
+ }
123
+ }
124
+ exports.PlanPublicHandler = PlanPublicHandler;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlansHandler = exports.getPlansHandler = exports.PlansSerializer = exports.PlansServerInput = void 0;
4
+ const models_0_1 = require("../../models/models_0");
5
+ const Aws_restJson1_1 = require("../../protocols/Aws_restJson1");
6
+ const server_common_1 = require("@aws-smithy/server-common");
7
+ const node_http_handler_1 = require("@smithy/node-http-handler");
8
+ const util_base64_1 = require("@smithy/util-base64");
9
+ const util_utf8_1 = require("@smithy/util-utf8");
10
+ var PlansServerInput;
11
+ (function (PlansServerInput) {
12
+ PlansServerInput.validate = models_0_1.PlansListInput.validate;
13
+ })(PlansServerInput = exports.PlansServerInput || (exports.PlansServerInput = {}));
14
+ class PlansSerializer {
15
+ constructor() {
16
+ this.serialize = Aws_restJson1_1.serializePlansResponse;
17
+ this.deserialize = Aws_restJson1_1.deserializePlansRequest;
18
+ }
19
+ isOperationError(error) {
20
+ const names = ["ValidationException", "RuntimeError"];
21
+ return names.includes(error.name);
22
+ }
23
+ ;
24
+ serializeError(error, ctx) {
25
+ switch (error.name) {
26
+ case "ValidationException": {
27
+ return (0, Aws_restJson1_1.serializeValidationExceptionError)(error, ctx);
28
+ }
29
+ case "RuntimeError": {
30
+ return (0, Aws_restJson1_1.serializeRuntimeErrorError)(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ exports.PlansSerializer = PlansSerializer;
39
+ const getPlansHandler = (operation) => {
40
+ const mux = new server_common_1.httpbinding.HttpBindingMux([
41
+ new server_common_1.httpbinding.UriSpec('GET', [
42
+ { type: 'path_literal', value: "plans" },
43
+ ], [
44
+ { type: 'query', key: "lat" },
45
+ { type: 'query', key: "lon" },
46
+ ], { service: "AppAPI", operation: "Plans" }),
47
+ ]);
48
+ const customizer = (ctx, failures) => {
49
+ if (!failures) {
50
+ return undefined;
51
+ }
52
+ return {
53
+ name: "ValidationException",
54
+ $fault: "client",
55
+ message: (0, server_common_1.generateValidationSummary)(failures),
56
+ fieldList: failures.map(failure => ({
57
+ path: failure.path,
58
+ message: (0, server_common_1.generateValidationMessage)(failure)
59
+ }))
60
+ };
61
+ };
62
+ return new PlansHandler(operation, mux, new PlansSerializer(), Aws_restJson1_1.serializeFrameworkException, customizer);
63
+ };
64
+ exports.getPlansHandler = getPlansHandler;
65
+ const serdeContextBase = {
66
+ base64Encoder: util_base64_1.toBase64,
67
+ base64Decoder: util_base64_1.fromBase64,
68
+ utf8Encoder: util_utf8_1.toUtf8,
69
+ utf8Decoder: util_utf8_1.fromUtf8,
70
+ streamCollector: node_http_handler_1.streamCollector,
71
+ requestHandler: new node_http_handler_1.NodeHttpHandler(),
72
+ disableHostPrefix: true
73
+ };
74
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
75
+ let input;
76
+ try {
77
+ input = await serializer.deserialize(request, {
78
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
79
+ });
80
+ }
81
+ catch (error) {
82
+ if ((0, server_common_1.isFrameworkException)(error)) {
83
+ return serializeFrameworkException(error, serdeContextBase);
84
+ }
85
+ ;
86
+ return serializeFrameworkException(new server_common_1.SerializationException(), serdeContextBase);
87
+ }
88
+ try {
89
+ let validationFailures = validationFn(input);
90
+ if (validationFailures && validationFailures.length > 0) {
91
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
92
+ if (validationException) {
93
+ return serializer.serializeError(validationException, serdeContextBase);
94
+ }
95
+ }
96
+ let output = await operation(input, context);
97
+ return serializer.serialize(output, serdeContextBase);
98
+ }
99
+ catch (error) {
100
+ if (serializer.isOperationError(error)) {
101
+ return serializer.serializeError(error, serdeContextBase);
102
+ }
103
+ console.log('Received an unexpected error', error);
104
+ return serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
105
+ }
106
+ }
107
+ class PlansHandler {
108
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
109
+ this.operation = operation;
110
+ this.mux = mux;
111
+ this.serializer = serializer;
112
+ this.serializeFrameworkException = serializeFrameworkException;
113
+ this.validationCustomizer = validationCustomizer;
114
+ }
115
+ async handle(request, context) {
116
+ const target = this.mux.match(request);
117
+ if (target === undefined) {
118
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.Plans. This indicates a misconfiguration.');
119
+ return this.serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
120
+ }
121
+ return handle(request, context, "Plans", this.serializer, this.operation, this.serializeFrameworkException, PlansServerInput.validate, this.validationCustomizer);
122
+ }
123
+ }
124
+ exports.PlansHandler = PlansHandler;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PopularShopsHandler = exports.getPopularShopsHandler = exports.PopularShopsSerializer = exports.PopularShopsServerInput = void 0;
4
+ const models_0_1 = require("../../models/models_0");
5
+ const Aws_restJson1_1 = require("../../protocols/Aws_restJson1");
6
+ const server_common_1 = require("@aws-smithy/server-common");
7
+ const node_http_handler_1 = require("@smithy/node-http-handler");
8
+ const util_base64_1 = require("@smithy/util-base64");
9
+ const util_utf8_1 = require("@smithy/util-utf8");
10
+ var PopularShopsServerInput;
11
+ (function (PopularShopsServerInput) {
12
+ PopularShopsServerInput.validate = models_0_1.ShopListInput.validate;
13
+ })(PopularShopsServerInput = exports.PopularShopsServerInput || (exports.PopularShopsServerInput = {}));
14
+ class PopularShopsSerializer {
15
+ constructor() {
16
+ this.serialize = Aws_restJson1_1.serializePopularShopsResponse;
17
+ this.deserialize = Aws_restJson1_1.deserializePopularShopsRequest;
18
+ }
19
+ isOperationError(error) {
20
+ const names = ["ValidationException", "RuntimeError"];
21
+ return names.includes(error.name);
22
+ }
23
+ ;
24
+ serializeError(error, ctx) {
25
+ switch (error.name) {
26
+ case "ValidationException": {
27
+ return (0, Aws_restJson1_1.serializeValidationExceptionError)(error, ctx);
28
+ }
29
+ case "RuntimeError": {
30
+ return (0, Aws_restJson1_1.serializeRuntimeErrorError)(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ exports.PopularShopsSerializer = PopularShopsSerializer;
39
+ const getPopularShopsHandler = (operation) => {
40
+ const mux = new server_common_1.httpbinding.HttpBindingMux([
41
+ new server_common_1.httpbinding.UriSpec('GET', [
42
+ { type: 'path_literal', value: "shops" },
43
+ { type: 'path_literal', value: "popular" },
44
+ ], [], { service: "AppAPI", operation: "PopularShops" }),
45
+ ]);
46
+ const customizer = (ctx, failures) => {
47
+ if (!failures) {
48
+ return undefined;
49
+ }
50
+ return {
51
+ name: "ValidationException",
52
+ $fault: "client",
53
+ message: (0, server_common_1.generateValidationSummary)(failures),
54
+ fieldList: failures.map(failure => ({
55
+ path: failure.path,
56
+ message: (0, server_common_1.generateValidationMessage)(failure)
57
+ }))
58
+ };
59
+ };
60
+ return new PopularShopsHandler(operation, mux, new PopularShopsSerializer(), Aws_restJson1_1.serializeFrameworkException, customizer);
61
+ };
62
+ exports.getPopularShopsHandler = getPopularShopsHandler;
63
+ const serdeContextBase = {
64
+ base64Encoder: util_base64_1.toBase64,
65
+ base64Decoder: util_base64_1.fromBase64,
66
+ utf8Encoder: util_utf8_1.toUtf8,
67
+ utf8Decoder: util_utf8_1.fromUtf8,
68
+ streamCollector: node_http_handler_1.streamCollector,
69
+ requestHandler: new node_http_handler_1.NodeHttpHandler(),
70
+ disableHostPrefix: true
71
+ };
72
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
73
+ let input;
74
+ try {
75
+ input = await serializer.deserialize(request, {
76
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
77
+ });
78
+ }
79
+ catch (error) {
80
+ if ((0, server_common_1.isFrameworkException)(error)) {
81
+ return serializeFrameworkException(error, serdeContextBase);
82
+ }
83
+ ;
84
+ return serializeFrameworkException(new server_common_1.SerializationException(), serdeContextBase);
85
+ }
86
+ try {
87
+ let validationFailures = validationFn(input);
88
+ if (validationFailures && validationFailures.length > 0) {
89
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
90
+ if (validationException) {
91
+ return serializer.serializeError(validationException, serdeContextBase);
92
+ }
93
+ }
94
+ let output = await operation(input, context);
95
+ return serializer.serialize(output, serdeContextBase);
96
+ }
97
+ catch (error) {
98
+ if (serializer.isOperationError(error)) {
99
+ return serializer.serializeError(error, serdeContextBase);
100
+ }
101
+ console.log('Received an unexpected error', error);
102
+ return serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
103
+ }
104
+ }
105
+ class PopularShopsHandler {
106
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
107
+ this.operation = operation;
108
+ this.mux = mux;
109
+ this.serializer = serializer;
110
+ this.serializeFrameworkException = serializeFrameworkException;
111
+ this.validationCustomizer = validationCustomizer;
112
+ }
113
+ async handle(request, context) {
114
+ const target = this.mux.match(request);
115
+ if (target === undefined) {
116
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PopularShops. This indicates a misconfiguration.');
117
+ return this.serializeFrameworkException(new server_common_1.InternalFailureException(), serdeContextBase);
118
+ }
119
+ return handle(request, context, "PopularShops", this.serializer, this.operation, this.serializeFrameworkException, PopularShopsServerInput.validate, this.validationCustomizer);
120
+ }
121
+ }
122
+ exports.PopularShopsHandler = PopularShopsHandler;