@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,115 @@
1
+ import { ShopListInput, } from "../../models/models_0";
2
+ import { deserializeNearbyShopsRequest, serializeFrameworkException, serializeNearbyShopsResponse, 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 NearbyShopsServerInput;
8
+ (function (NearbyShopsServerInput) {
9
+ NearbyShopsServerInput.validate = ShopListInput.validate;
10
+ })(NearbyShopsServerInput || (NearbyShopsServerInput = {}));
11
+ export class NearbyShopsSerializer {
12
+ constructor() {
13
+ this.serialize = serializeNearbyShopsResponse;
14
+ this.deserialize = deserializeNearbyShopsRequest;
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 getNearbyShopsHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "shops" },
39
+ ], [], { service: "AppAPI", operation: "NearbyShops" }),
40
+ ]);
41
+ const customizer = (ctx, failures) => {
42
+ if (!failures) {
43
+ return undefined;
44
+ }
45
+ return {
46
+ name: "ValidationException",
47
+ $fault: "client",
48
+ message: __generateValidationSummary(failures),
49
+ fieldList: failures.map(failure => ({
50
+ path: failure.path,
51
+ message: __generateValidationMessage(failure)
52
+ }))
53
+ };
54
+ };
55
+ return new NearbyShopsHandler(operation, mux, new NearbyShopsSerializer(), serializeFrameworkException, customizer);
56
+ };
57
+ const serdeContextBase = {
58
+ base64Encoder: toBase64,
59
+ base64Decoder: fromBase64,
60
+ utf8Encoder: toUtf8,
61
+ utf8Decoder: fromUtf8,
62
+ streamCollector: streamCollector,
63
+ requestHandler: new NodeHttpHandler(),
64
+ disableHostPrefix: true
65
+ };
66
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
67
+ let input;
68
+ try {
69
+ input = await serializer.deserialize(request, {
70
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
71
+ });
72
+ }
73
+ catch (error) {
74
+ if (__isFrameworkException(error)) {
75
+ return serializeFrameworkException(error, serdeContextBase);
76
+ }
77
+ ;
78
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
79
+ }
80
+ try {
81
+ let validationFailures = validationFn(input);
82
+ if (validationFailures && validationFailures.length > 0) {
83
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
84
+ if (validationException) {
85
+ return serializer.serializeError(validationException, serdeContextBase);
86
+ }
87
+ }
88
+ let output = await operation(input, context);
89
+ return serializer.serialize(output, serdeContextBase);
90
+ }
91
+ catch (error) {
92
+ if (serializer.isOperationError(error)) {
93
+ return serializer.serializeError(error, serdeContextBase);
94
+ }
95
+ console.log('Received an unexpected error', error);
96
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
97
+ }
98
+ }
99
+ export class NearbyShopsHandler {
100
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
101
+ this.operation = operation;
102
+ this.mux = mux;
103
+ this.serializer = serializer;
104
+ this.serializeFrameworkException = serializeFrameworkException;
105
+ this.validationCustomizer = validationCustomizer;
106
+ }
107
+ async handle(request, context) {
108
+ const target = this.mux.match(request);
109
+ if (target === undefined) {
110
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.NearbyShops. This indicates a misconfiguration.');
111
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
112
+ }
113
+ return handle(request, context, "NearbyShops", this.serializer, this.operation, this.serializeFrameworkException, NearbyShopsServerInput.validate, this.validationCustomizer);
114
+ }
115
+ }
@@ -0,0 +1,116 @@
1
+ import { ShopListInput, } from "../../models/models_0";
2
+ import { deserializeNearbyShopsPublicRequest, serializeFrameworkException, serializeNearbyShopsPublicResponse, 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 NearbyShopsPublicServerInput;
8
+ (function (NearbyShopsPublicServerInput) {
9
+ NearbyShopsPublicServerInput.validate = ShopListInput.validate;
10
+ })(NearbyShopsPublicServerInput || (NearbyShopsPublicServerInput = {}));
11
+ export class NearbyShopsPublicSerializer {
12
+ constructor() {
13
+ this.serialize = serializeNearbyShopsPublicResponse;
14
+ this.deserialize = deserializeNearbyShopsPublicRequest;
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 getNearbyShopsPublicHandler = (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
+ ], [], { service: "AppAPI", operation: "NearbyShopsPublic" }),
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 NearbyShopsPublicHandler(operation, mux, new NearbyShopsPublicSerializer(), 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 NearbyShopsPublicHandler {
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.NearbyShopsPublic. This indicates a misconfiguration.');
112
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
113
+ }
114
+ return handle(request, context, "NearbyShopsPublic", this.serializer, this.operation, this.serializeFrameworkException, NearbyShopsPublicServerInput.validate, this.validationCustomizer);
115
+ }
116
+ }
@@ -0,0 +1,120 @@
1
+ import { NearestShopInput, } from "../../models/models_0";
2
+ import { deserializeNearestShopRequest, serializeFrameworkException, serializeNearestShopResponse, 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 NearestShopServerInput;
8
+ (function (NearestShopServerInput) {
9
+ NearestShopServerInput.validate = NearestShopInput.validate;
10
+ })(NearestShopServerInput || (NearestShopServerInput = {}));
11
+ export class NearestShopSerializer {
12
+ constructor() {
13
+ this.serialize = serializeNearestShopResponse;
14
+ this.deserialize = deserializeNearestShopRequest;
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 getNearestShopHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "shops" },
39
+ { type: 'path_literal', value: "nearest" },
40
+ ], [
41
+ { type: 'query', key: "shop_name" },
42
+ { type: 'query', key: "lat" },
43
+ { type: 'query', key: "lon" },
44
+ ], { service: "AppAPI", operation: "NearestShop" }),
45
+ ]);
46
+ const customizer = (ctx, failures) => {
47
+ if (!failures) {
48
+ return undefined;
49
+ }
50
+ return {
51
+ name: "ValidationException",
52
+ $fault: "client",
53
+ message: __generateValidationSummary(failures),
54
+ fieldList: failures.map(failure => ({
55
+ path: failure.path,
56
+ message: __generateValidationMessage(failure)
57
+ }))
58
+ };
59
+ };
60
+ return new NearestShopHandler(operation, mux, new NearestShopSerializer(), serializeFrameworkException, customizer);
61
+ };
62
+ const serdeContextBase = {
63
+ base64Encoder: toBase64,
64
+ base64Decoder: fromBase64,
65
+ utf8Encoder: toUtf8,
66
+ utf8Decoder: fromUtf8,
67
+ streamCollector: streamCollector,
68
+ requestHandler: new NodeHttpHandler(),
69
+ disableHostPrefix: true
70
+ };
71
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
72
+ let input;
73
+ try {
74
+ input = await serializer.deserialize(request, {
75
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
76
+ });
77
+ }
78
+ catch (error) {
79
+ if (__isFrameworkException(error)) {
80
+ return serializeFrameworkException(error, serdeContextBase);
81
+ }
82
+ ;
83
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
84
+ }
85
+ try {
86
+ let validationFailures = validationFn(input);
87
+ if (validationFailures && validationFailures.length > 0) {
88
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
89
+ if (validationException) {
90
+ return serializer.serializeError(validationException, serdeContextBase);
91
+ }
92
+ }
93
+ let output = await operation(input, context);
94
+ return serializer.serialize(output, serdeContextBase);
95
+ }
96
+ catch (error) {
97
+ if (serializer.isOperationError(error)) {
98
+ return serializer.serializeError(error, serdeContextBase);
99
+ }
100
+ console.log('Received an unexpected error', error);
101
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
102
+ }
103
+ }
104
+ export class NearestShopHandler {
105
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
106
+ this.operation = operation;
107
+ this.mux = mux;
108
+ this.serializer = serializer;
109
+ this.serializeFrameworkException = serializeFrameworkException;
110
+ this.validationCustomizer = validationCustomizer;
111
+ }
112
+ async handle(request, context) {
113
+ const target = this.mux.match(request);
114
+ if (target === undefined) {
115
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.NearestShop. This indicates a misconfiguration.');
116
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
117
+ }
118
+ return handle(request, context, "NearestShop", this.serializer, this.operation, this.serializeFrameworkException, NearestShopServerInput.validate, this.validationCustomizer);
119
+ }
120
+ }
@@ -0,0 +1,116 @@
1
+ import { OnboardUserInput, } from "../../models/models_0";
2
+ import { deserializeOnboardUserRequest, serializeFrameworkException, serializeOnboardUserResponse, 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 OnboardUserServerInput;
8
+ (function (OnboardUserServerInput) {
9
+ OnboardUserServerInput.validate = OnboardUserInput.validate;
10
+ })(OnboardUserServerInput || (OnboardUserServerInput = {}));
11
+ export class OnboardUserSerializer {
12
+ constructor() {
13
+ this.serialize = serializeOnboardUserResponse;
14
+ this.deserialize = deserializeOnboardUserRequest;
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 getOnboardUserHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('PUT', [
38
+ { type: 'path_literal', value: "user" },
39
+ { type: 'path_literal', value: "onboard" },
40
+ ], [], { service: "AppAPI", operation: "OnboardUser" }),
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 OnboardUserHandler(operation, mux, new OnboardUserSerializer(), 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 OnboardUserHandler {
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.OnboardUser. This indicates a misconfiguration.');
112
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
113
+ }
114
+ return handle(request, context, "OnboardUser", this.serializer, this.operation, this.serializeFrameworkException, OnboardUserServerInput.validate, this.validationCustomizer);
115
+ }
116
+ }
@@ -0,0 +1,120 @@
1
+ import { PinnedShopInput, } from "../../models/models_0";
2
+ import { deserializePinnedShopRequest, serializeFrameworkException, serializePinnedShopResponse, 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 PinnedShopServerInput;
8
+ (function (PinnedShopServerInput) {
9
+ PinnedShopServerInput.validate = PinnedShopInput.validate;
10
+ })(PinnedShopServerInput || (PinnedShopServerInput = {}));
11
+ export class PinnedShopSerializer {
12
+ constructor() {
13
+ this.serialize = serializePinnedShopResponse;
14
+ this.deserialize = deserializePinnedShopRequest;
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 getPinnedShopHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "shops" },
39
+ { type: 'path_literal', value: "pinned" },
40
+ ], [
41
+ { type: 'query', key: "shop_id" },
42
+ { type: 'query', key: "lat" },
43
+ { type: 'query', key: "lon" },
44
+ ], { service: "AppAPI", operation: "PinnedShop" }),
45
+ ]);
46
+ const customizer = (ctx, failures) => {
47
+ if (!failures) {
48
+ return undefined;
49
+ }
50
+ return {
51
+ name: "ValidationException",
52
+ $fault: "client",
53
+ message: __generateValidationSummary(failures),
54
+ fieldList: failures.map(failure => ({
55
+ path: failure.path,
56
+ message: __generateValidationMessage(failure)
57
+ }))
58
+ };
59
+ };
60
+ return new PinnedShopHandler(operation, mux, new PinnedShopSerializer(), serializeFrameworkException, customizer);
61
+ };
62
+ const serdeContextBase = {
63
+ base64Encoder: toBase64,
64
+ base64Decoder: fromBase64,
65
+ utf8Encoder: toUtf8,
66
+ utf8Decoder: fromUtf8,
67
+ streamCollector: streamCollector,
68
+ requestHandler: new NodeHttpHandler(),
69
+ disableHostPrefix: true
70
+ };
71
+ async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
72
+ let input;
73
+ try {
74
+ input = await serializer.deserialize(request, {
75
+ endpoint: () => Promise.resolve(request), ...serdeContextBase
76
+ });
77
+ }
78
+ catch (error) {
79
+ if (__isFrameworkException(error)) {
80
+ return serializeFrameworkException(error, serdeContextBase);
81
+ }
82
+ ;
83
+ return serializeFrameworkException(new __SerializationException(), serdeContextBase);
84
+ }
85
+ try {
86
+ let validationFailures = validationFn(input);
87
+ if (validationFailures && validationFailures.length > 0) {
88
+ let validationException = validationCustomizer({ operation: operationName }, validationFailures);
89
+ if (validationException) {
90
+ return serializer.serializeError(validationException, serdeContextBase);
91
+ }
92
+ }
93
+ let output = await operation(input, context);
94
+ return serializer.serialize(output, serdeContextBase);
95
+ }
96
+ catch (error) {
97
+ if (serializer.isOperationError(error)) {
98
+ return serializer.serializeError(error, serdeContextBase);
99
+ }
100
+ console.log('Received an unexpected error', error);
101
+ return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
102
+ }
103
+ }
104
+ export class PinnedShopHandler {
105
+ constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
106
+ this.operation = operation;
107
+ this.mux = mux;
108
+ this.serializer = serializer;
109
+ this.serializeFrameworkException = serializeFrameworkException;
110
+ this.validationCustomizer = validationCustomizer;
111
+ }
112
+ async handle(request, context) {
113
+ const target = this.mux.match(request);
114
+ if (target === undefined) {
115
+ console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PinnedShop. This indicates a misconfiguration.');
116
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
117
+ }
118
+ return handle(request, context, "PinnedShop", this.serializer, this.operation, this.serializeFrameworkException, PinnedShopServerInput.validate, this.validationCustomizer);
119
+ }
120
+ }