@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,121 @@
1
+ import { PinnedShopInput, } from "../../models/models_0";
2
+ import { deserializePinnedShopPublicRequest, serializeFrameworkException, serializePinnedShopPublicResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, 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 PinnedShopPublicServerInput;
8
+ (function (PinnedShopPublicServerInput) {
9
+ PinnedShopPublicServerInput.validate = PinnedShopInput.validate;
10
+ })(PinnedShopPublicServerInput || (PinnedShopPublicServerInput = {}));
11
+ export class PinnedShopPublicSerializer {
12
+ constructor() {
13
+ this.serialize = serializePinnedShopPublicResponse;
14
+ this.deserialize = deserializePinnedShopPublicRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError"];
18
+ return names.includes(error.name);
19
+ }
20
+ ;
21
+ serializeError(error, ctx) {
22
+ switch (error.name) {
23
+ case "ValidationException": {
24
+ return serializeValidationExceptionError(error, ctx);
25
+ }
26
+ case "RuntimeError": {
27
+ return serializeRuntimeErrorError(error, ctx);
28
+ }
29
+ default: {
30
+ throw error;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ export const getPinnedShopPublicHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "public" },
39
+ { type: 'path_literal', value: "shops" },
40
+ { type: 'path_literal', value: "pinned" },
41
+ ], [
42
+ { type: 'query', key: "shop_id" },
43
+ { type: 'query', key: "lat" },
44
+ { type: 'query', key: "lon" },
45
+ ], { service: "AppAPI", operation: "PinnedShopPublic" }),
46
+ ]);
47
+ const customizer = (ctx, failures) => {
48
+ if (!failures) {
49
+ return undefined;
50
+ }
51
+ return {
52
+ name: "ValidationException",
53
+ $fault: "client",
54
+ message: __generateValidationSummary(failures),
55
+ fieldList: failures.map(failure => ({
56
+ path: failure.path,
57
+ message: __generateValidationMessage(failure)
58
+ }))
59
+ };
60
+ };
61
+ return new PinnedShopPublicHandler(operation, mux, new PinnedShopPublicSerializer(), serializeFrameworkException, customizer);
62
+ };
63
+ const serdeContextBase = {
64
+ base64Encoder: toBase64,
65
+ base64Decoder: fromBase64,
66
+ utf8Encoder: toUtf8,
67
+ utf8Decoder: fromUtf8,
68
+ streamCollector: streamCollector,
69
+ requestHandler: new 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 (__isFrameworkException(error)) {
81
+ return serializeFrameworkException(error, serdeContextBase);
82
+ }
83
+ ;
84
+ return serializeFrameworkException(new __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 __InternalFailureException(), serdeContextBase);
103
+ }
104
+ }
105
+ export class PinnedShopPublicHandler {
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.PinnedShopPublic. This indicates a misconfiguration.');
117
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
118
+ }
119
+ return handle(request, context, "PinnedShopPublic", this.serializer, this.operation, this.serializeFrameworkException, PinnedShopPublicServerInput.validate, this.validationCustomizer);
120
+ }
121
+ }
@@ -0,0 +1,117 @@
1
+ import { PlanGetInput, } from "../../models/models_0";
2
+ import { deserializePlanRequest, serializeFrameworkException, serializePlanResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, 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 PlanServerInput;
8
+ (function (PlanServerInput) {
9
+ PlanServerInput.validate = PlanGetInput.validate;
10
+ })(PlanServerInput || (PlanServerInput = {}));
11
+ export class PlanSerializer {
12
+ constructor() {
13
+ this.serialize = serializePlanResponse;
14
+ this.deserialize = deserializePlanRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError"];
18
+ return names.includes(error.name);
19
+ }
20
+ ;
21
+ serializeError(error, ctx) {
22
+ switch (error.name) {
23
+ case "ValidationException": {
24
+ return serializeValidationExceptionError(error, ctx);
25
+ }
26
+ case "RuntimeError": {
27
+ return serializeRuntimeErrorError(error, ctx);
28
+ }
29
+ default: {
30
+ throw error;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ export const getPlanHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "plan" },
39
+ ], [
40
+ { type: 'query', key: "org_id" },
41
+ ], { service: "AppAPI", operation: "Plan" }),
42
+ ]);
43
+ const customizer = (ctx, failures) => {
44
+ if (!failures) {
45
+ return undefined;
46
+ }
47
+ return {
48
+ name: "ValidationException",
49
+ $fault: "client",
50
+ message: __generateValidationSummary(failures),
51
+ fieldList: failures.map(failure => ({
52
+ path: failure.path,
53
+ message: __generateValidationMessage(failure)
54
+ }))
55
+ };
56
+ };
57
+ return new PlanHandler(operation, mux, new PlanSerializer(), serializeFrameworkException, customizer);
58
+ };
59
+ const serdeContextBase = {
60
+ base64Encoder: toBase64,
61
+ base64Decoder: fromBase64,
62
+ utf8Encoder: toUtf8,
63
+ utf8Decoder: fromUtf8,
64
+ streamCollector: streamCollector,
65
+ requestHandler: new NodeHttpHandler(),
66
+ disableHostPrefix: true
67
+ };
68
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
69
+ let input;
70
+ try {
71
+ input = await serializer.deserialize(request, {
72
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
73
+ });
74
+ }
75
+ catch (error) {
76
+ if (__isFrameworkException(error)) {
77
+ return serializeFrameworkException(error, serdeContextBase);
78
+ }
79
+ ;
80
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
81
+ }
82
+ try {
83
+ let validationFailures = validationFn(input);
84
+ if (validationFailures && validationFailures.length > 0) {
85
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
86
+ if (validationException) {
87
+ return serializer.serializeError(validationException, serdeContextBase);
88
+ }
89
+ }
90
+ let output = await operation(input, context);
91
+ return serializer.serialize(output, serdeContextBase);
92
+ }
93
+ catch (error) {
94
+ if (serializer.isOperationError(error)) {
95
+ return serializer.serializeError(error, serdeContextBase);
96
+ }
97
+ console.log('Received an unexpected error', error);
98
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
99
+ }
100
+ }
101
+ export class PlanHandler {
102
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
103
+ this.operation = operation;
104
+ this.mux = mux;
105
+ this.serializer = serializer;
106
+ this.serializeFrameworkException = serializeFrameworkException;
107
+ this.validationCustomizer = validationCustomizer;
108
+ }
109
+ async handle(request, context) {
110
+ const target = this.mux.match(request);
111
+ if (target === undefined) {
112
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.Plan. This indicates a misconfiguration.');
113
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
114
+ }
115
+ return handle(request, context, "Plan", this.serializer, this.operation, this.serializeFrameworkException, PlanServerInput.validate, this.validationCustomizer);
116
+ }
117
+ }
@@ -0,0 +1,118 @@
1
+ import { PlanGetInput, } from "../../models/models_0";
2
+ import { deserializePlanPublicRequest, serializeFrameworkException, serializePlanPublicResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, 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 PlanPublicServerInput;
8
+ (function (PlanPublicServerInput) {
9
+ PlanPublicServerInput.validate = PlanGetInput.validate;
10
+ })(PlanPublicServerInput || (PlanPublicServerInput = {}));
11
+ export class PlanPublicSerializer {
12
+ constructor() {
13
+ this.serialize = serializePlanPublicResponse;
14
+ this.deserialize = deserializePlanPublicRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError"];
18
+ return names.includes(error.name);
19
+ }
20
+ ;
21
+ serializeError(error, ctx) {
22
+ switch (error.name) {
23
+ case "ValidationException": {
24
+ return serializeValidationExceptionError(error, ctx);
25
+ }
26
+ case "RuntimeError": {
27
+ return serializeRuntimeErrorError(error, ctx);
28
+ }
29
+ default: {
30
+ throw error;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ export const getPlanPublicHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "public" },
39
+ { type: 'path_literal', value: "plan" },
40
+ ], [
41
+ { type: 'query', key: "org_id" },
42
+ ], { service: "AppAPI", operation: "PlanPublic" }),
43
+ ]);
44
+ const customizer = (ctx, failures) => {
45
+ if (!failures) {
46
+ return undefined;
47
+ }
48
+ return {
49
+ name: "ValidationException",
50
+ $fault: "client",
51
+ message: __generateValidationSummary(failures),
52
+ fieldList: failures.map(failure => ({
53
+ path: failure.path,
54
+ message: __generateValidationMessage(failure)
55
+ }))
56
+ };
57
+ };
58
+ return new PlanPublicHandler(operation, mux, new PlanPublicSerializer(), serializeFrameworkException, customizer);
59
+ };
60
+ const serdeContextBase = {
61
+ base64Encoder: toBase64,
62
+ base64Decoder: fromBase64,
63
+ utf8Encoder: toUtf8,
64
+ utf8Decoder: fromUtf8,
65
+ streamCollector: streamCollector,
66
+ requestHandler: new NodeHttpHandler(),
67
+ disableHostPrefix: true
68
+ };
69
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
70
+ let input;
71
+ try {
72
+ input = await serializer.deserialize(request, {
73
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
74
+ });
75
+ }
76
+ catch (error) {
77
+ if (__isFrameworkException(error)) {
78
+ return serializeFrameworkException(error, serdeContextBase);
79
+ }
80
+ ;
81
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
82
+ }
83
+ try {
84
+ let validationFailures = validationFn(input);
85
+ if (validationFailures && validationFailures.length > 0) {
86
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
87
+ if (validationException) {
88
+ return serializer.serializeError(validationException, serdeContextBase);
89
+ }
90
+ }
91
+ let output = await operation(input, context);
92
+ return serializer.serialize(output, serdeContextBase);
93
+ }
94
+ catch (error) {
95
+ if (serializer.isOperationError(error)) {
96
+ return serializer.serializeError(error, serdeContextBase);
97
+ }
98
+ console.log('Received an unexpected error', error);
99
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
100
+ }
101
+ }
102
+ export class PlanPublicHandler {
103
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
104
+ this.operation = operation;
105
+ this.mux = mux;
106
+ this.serializer = serializer;
107
+ this.serializeFrameworkException = serializeFrameworkException;
108
+ this.validationCustomizer = validationCustomizer;
109
+ }
110
+ async handle(request, context) {
111
+ const target = this.mux.match(request);
112
+ if (target === undefined) {
113
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PlanPublic. This indicates a misconfiguration.');
114
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
115
+ }
116
+ return handle(request, context, "PlanPublic", this.serializer, this.operation, this.serializeFrameworkException, PlanPublicServerInput.validate, this.validationCustomizer);
117
+ }
118
+ }
@@ -0,0 +1,118 @@
1
+ import { PlansListInput, } from "../../models/models_0";
2
+ import { deserializePlansRequest, serializeFrameworkException, serializePlansResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, 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 PlansServerInput;
8
+ (function (PlansServerInput) {
9
+ PlansServerInput.validate = PlansListInput.validate;
10
+ })(PlansServerInput || (PlansServerInput = {}));
11
+ export class PlansSerializer {
12
+ constructor() {
13
+ this.serialize = serializePlansResponse;
14
+ this.deserialize = deserializePlansRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError"];
18
+ return names.includes(error.name);
19
+ }
20
+ ;
21
+ serializeError(error, ctx) {
22
+ switch (error.name) {
23
+ case "ValidationException": {
24
+ return serializeValidationExceptionError(error, ctx);
25
+ }
26
+ case "RuntimeError": {
27
+ return serializeRuntimeErrorError(error, ctx);
28
+ }
29
+ default: {
30
+ throw error;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ export const getPlansHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "plans" },
39
+ ], [
40
+ { type: 'query', key: "lat" },
41
+ { type: 'query', key: "lon" },
42
+ ], { service: "AppAPI", operation: "Plans" }),
43
+ ]);
44
+ const customizer = (ctx, failures) => {
45
+ if (!failures) {
46
+ return undefined;
47
+ }
48
+ return {
49
+ name: "ValidationException",
50
+ $fault: "client",
51
+ message: __generateValidationSummary(failures),
52
+ fieldList: failures.map(failure => ({
53
+ path: failure.path,
54
+ message: __generateValidationMessage(failure)
55
+ }))
56
+ };
57
+ };
58
+ return new PlansHandler(operation, mux, new PlansSerializer(), serializeFrameworkException, customizer);
59
+ };
60
+ const serdeContextBase = {
61
+ base64Encoder: toBase64,
62
+ base64Decoder: fromBase64,
63
+ utf8Encoder: toUtf8,
64
+ utf8Decoder: fromUtf8,
65
+ streamCollector: streamCollector,
66
+ requestHandler: new NodeHttpHandler(),
67
+ disableHostPrefix: true
68
+ };
69
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
70
+ let input;
71
+ try {
72
+ input = await serializer.deserialize(request, {
73
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
74
+ });
75
+ }
76
+ catch (error) {
77
+ if (__isFrameworkException(error)) {
78
+ return serializeFrameworkException(error, serdeContextBase);
79
+ }
80
+ ;
81
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
82
+ }
83
+ try {
84
+ let validationFailures = validationFn(input);
85
+ if (validationFailures && validationFailures.length > 0) {
86
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
87
+ if (validationException) {
88
+ return serializer.serializeError(validationException, serdeContextBase);
89
+ }
90
+ }
91
+ let output = await operation(input, context);
92
+ return serializer.serialize(output, serdeContextBase);
93
+ }
94
+ catch (error) {
95
+ if (serializer.isOperationError(error)) {
96
+ return serializer.serializeError(error, serdeContextBase);
97
+ }
98
+ console.log('Received an unexpected error', error);
99
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
100
+ }
101
+ }
102
+ export class PlansHandler {
103
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
104
+ this.operation = operation;
105
+ this.mux = mux;
106
+ this.serializer = serializer;
107
+ this.serializeFrameworkException = serializeFrameworkException;
108
+ this.validationCustomizer = validationCustomizer;
109
+ }
110
+ async handle(request, context) {
111
+ const target = this.mux.match(request);
112
+ if (target === undefined) {
113
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.Plans. This indicates a misconfiguration.');
114
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
115
+ }
116
+ return handle(request, context, "Plans", this.serializer, this.operation, this.serializeFrameworkException, PlansServerInput.validate, this.validationCustomizer);
117
+ }
118
+ }
@@ -0,0 +1,116 @@
1
+ import { ShopListInput, } from "../../models/models_0";
2
+ import { deserializePopularShopsRequest, serializeFrameworkException, serializePopularShopsResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
3
+ import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, 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 PopularShopsServerInput;
8
+ (function (PopularShopsServerInput) {
9
+ PopularShopsServerInput.validate = ShopListInput.validate;
10
+ })(PopularShopsServerInput || (PopularShopsServerInput = {}));
11
+ export class PopularShopsSerializer {
12
+ constructor() {
13
+ this.serialize = serializePopularShopsResponse;
14
+ this.deserialize = deserializePopularShopsRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError"];
18
+ return names.includes(error.name);
19
+ }
20
+ ;
21
+ serializeError(error, ctx) {
22
+ switch (error.name) {
23
+ case "ValidationException": {
24
+ return serializeValidationExceptionError(error, ctx);
25
+ }
26
+ case "RuntimeError": {
27
+ return serializeRuntimeErrorError(error, ctx);
28
+ }
29
+ default: {
30
+ throw error;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ export const getPopularShopsHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "shops" },
39
+ { type: 'path_literal', value: "popular" },
40
+ ], [], { service: "AppAPI", operation: "PopularShops" }),
41
+ ]);
42
+ const customizer = (ctx, failures) => {
43
+ if (!failures) {
44
+ return undefined;
45
+ }
46
+ return {
47
+ name: "ValidationException",
48
+ $fault: "client",
49
+ message: __generateValidationSummary(failures),
50
+ fieldList: failures.map(failure => ({
51
+ path: failure.path,
52
+ message: __generateValidationMessage(failure)
53
+ }))
54
+ };
55
+ };
56
+ return new PopularShopsHandler(operation, mux, new PopularShopsSerializer(), serializeFrameworkException, customizer);
57
+ };
58
+ const serdeContextBase = {
59
+ base64Encoder: toBase64,
60
+ base64Decoder: fromBase64,
61
+ utf8Encoder: toUtf8,
62
+ utf8Decoder: fromUtf8,
63
+ streamCollector: streamCollector,
64
+ requestHandler: new NodeHttpHandler(),
65
+ disableHostPrefix: true
66
+ };
67
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
68
+ let input;
69
+ try {
70
+ input = await serializer.deserialize(request, {
71
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
72
+ });
73
+ }
74
+ catch (error) {
75
+ if (__isFrameworkException(error)) {
76
+ return serializeFrameworkException(error, serdeContextBase);
77
+ }
78
+ ;
79
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
80
+ }
81
+ try {
82
+ let validationFailures = validationFn(input);
83
+ if (validationFailures && validationFailures.length > 0) {
84
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
85
+ if (validationException) {
86
+ return serializer.serializeError(validationException, serdeContextBase);
87
+ }
88
+ }
89
+ let output = await operation(input, context);
90
+ return serializer.serialize(output, serdeContextBase);
91
+ }
92
+ catch (error) {
93
+ if (serializer.isOperationError(error)) {
94
+ return serializer.serializeError(error, serdeContextBase);
95
+ }
96
+ console.log('Received an unexpected error', error);
97
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
98
+ }
99
+ }
100
+ export class PopularShopsHandler {
101
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
102
+ this.operation = operation;
103
+ this.mux = mux;
104
+ this.serializer = serializer;
105
+ this.serializeFrameworkException = serializeFrameworkException;
106
+ this.validationCustomizer = validationCustomizer;
107
+ }
108
+ async handle(request, context) {
109
+ const target = this.mux.match(request);
110
+ if (target === undefined) {
111
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PopularShops. This indicates a misconfiguration.');
112
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
113
+ }
114
+ return handle(request, context, "PopularShops", this.serializer, this.operation, this.serializeFrameworkException, PopularShopsServerInput.validate, this.validationCustomizer);
115
+ }
116
+ }