@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,116 @@
1
+ import { ShopListInput, } from "../../models/models_0";
2
+ import { deserializeFavoriteShopsRequest, serializeFavoriteShopsResponse, serializeFrameworkException, 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 FavoriteShopsServerInput;
8
+ (function (FavoriteShopsServerInput) {
9
+ FavoriteShopsServerInput.validate = ShopListInput.validate;
10
+ })(FavoriteShopsServerInput || (FavoriteShopsServerInput = {}));
11
+ export class FavoriteShopsSerializer {
12
+ constructor() {
13
+ this.serialize = serializeFavoriteShopsResponse;
14
+ this.deserialize = deserializeFavoriteShopsRequest;
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 getFavoriteShopsHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "shops" },
39
+ { type: 'path_literal', value: "favorite" },
40
+ ], [], { service: "AppAPI", operation: "FavoriteShops" }),
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 FavoriteShopsHandler(operation, mux, new FavoriteShopsSerializer(), 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 FavoriteShopsHandler {
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.FavoriteShops. This indicates a misconfiguration.');
112
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
113
+ }
114
+ return handle(request, context, "FavoriteShops", this.serializer, this.operation, this.serializeFrameworkException, FavoriteShopsServerInput.validate, this.validationCustomizer);
115
+ }
116
+ }
@@ -0,0 +1,120 @@
1
+ import { GetShopInput, } from "../../models/models_0";
2
+ import { deserializeGetShopRequest, serializeFrameworkException, serializeGetShopResponse, serializeNotFoundErrorError, 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 GetShopServerInput;
8
+ (function (GetShopServerInput) {
9
+ GetShopServerInput.validate = GetShopInput.validate;
10
+ })(GetShopServerInput || (GetShopServerInput = {}));
11
+ export class GetShopSerializer {
12
+ constructor() {
13
+ this.serialize = serializeGetShopResponse;
14
+ this.deserialize = deserializeGetShopRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError", "NotFoundError"];
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
+ case "NotFoundError": {
30
+ return serializeNotFoundErrorError(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ export const getGetShopHandler = (operation) => {
39
+ const mux = new httpbinding.HttpBindingMux([
40
+ new httpbinding.UriSpec('GET', [
41
+ { type: 'path_literal', value: "shops" },
42
+ { type: 'path_literal', value: "shop" },
43
+ { type: 'path' },
44
+ ], [], { service: "AppAPI", operation: "GetShop" }),
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 GetShopHandler(operation, mux, new GetShopSerializer(), 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 GetShopHandler {
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.GetShop. This indicates a misconfiguration.');
116
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
117
+ }
118
+ return handle(request, context, "GetShop", this.serializer, this.operation, this.serializeFrameworkException, GetShopServerInput.validate, this.validationCustomizer);
119
+ }
120
+ }
@@ -0,0 +1,121 @@
1
+ import { GetShopInput, } from "../../models/models_0";
2
+ import { deserializeGetShopPublicRequest, serializeFrameworkException, serializeGetShopPublicResponse, serializeNotFoundErrorError, 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 GetShopPublicServerInput;
8
+ (function (GetShopPublicServerInput) {
9
+ GetShopPublicServerInput.validate = GetShopInput.validate;
10
+ })(GetShopPublicServerInput || (GetShopPublicServerInput = {}));
11
+ export class GetShopPublicSerializer {
12
+ constructor() {
13
+ this.serialize = serializeGetShopPublicResponse;
14
+ this.deserialize = deserializeGetShopPublicRequest;
15
+ }
16
+ isOperationError(error) {
17
+ const names = ["ValidationException", "RuntimeError", "NotFoundError"];
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
+ case "NotFoundError": {
30
+ return serializeNotFoundErrorError(error, ctx);
31
+ }
32
+ default: {
33
+ throw error;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ export const getGetShopPublicHandler = (operation) => {
39
+ const mux = new httpbinding.HttpBindingMux([
40
+ new httpbinding.UriSpec('GET', [
41
+ { type: 'path_literal', value: "public" },
42
+ { type: 'path_literal', value: "shops" },
43
+ { type: 'path_literal', value: "shop" },
44
+ { type: 'path' },
45
+ ], [], { service: "AppAPI", operation: "GetShopPublic" }),
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 GetShopPublicHandler(operation, mux, new GetShopPublicSerializer(), 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 GetShopPublicHandler {
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.GetShopPublic. This indicates a misconfiguration.');
117
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
118
+ }
119
+ return handle(request, context, "GetShopPublic", this.serializer, this.operation, this.serializeFrameworkException, GetShopPublicServerInput.validate, this.validationCustomizer);
120
+ }
121
+ }
@@ -0,0 +1,115 @@
1
+ import { GetUserInput, } from "../../models/models_0";
2
+ import { deserializeGetUserRequest, serializeFrameworkException, serializeGetUserResponse, 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 GetUserServerInput;
8
+ (function (GetUserServerInput) {
9
+ GetUserServerInput.validate = GetUserInput.validate;
10
+ })(GetUserServerInput || (GetUserServerInput = {}));
11
+ export class GetUserSerializer {
12
+ constructor() {
13
+ this.serialize = serializeGetUserResponse;
14
+ this.deserialize = deserializeGetUserRequest;
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 getGetUserHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('GET', [
38
+ { type: 'path_literal', value: "user" },
39
+ ], [], { service: "AppAPI", operation: "GetUser" }),
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 GetUserHandler(operation, mux, new GetUserSerializer(), 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 GetUserHandler {
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.GetUser. This indicates a misconfiguration.');
111
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
112
+ }
113
+ return handle(request, context, "GetUser", this.serializer, this.operation, this.serializeFrameworkException, GetUserServerInput.validate, this.validationCustomizer);
114
+ }
115
+ }
@@ -0,0 +1,118 @@
1
+ import { LikeOrgInput, } from "../../models/models_0";
2
+ import { deserializeLikeOrgRequest, serializeFrameworkException, serializeLikeOrgResponse, 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 LikeOrgServerInput;
8
+ (function (LikeOrgServerInput) {
9
+ LikeOrgServerInput.validate = LikeOrgInput.validate;
10
+ })(LikeOrgServerInput || (LikeOrgServerInput = {}));
11
+ export class LikeOrgSerializer {
12
+ constructor() {
13
+ this.serialize = serializeLikeOrgResponse;
14
+ this.deserialize = deserializeLikeOrgRequest;
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 getLikeOrgHandler = (operation) => {
36
+ const mux = new httpbinding.HttpBindingMux([
37
+ new httpbinding.UriSpec('PUT', [
38
+ { type: 'path_literal', value: "user" },
39
+ { type: 'path_literal', value: "like" },
40
+ ], [
41
+ { type: 'query', key: "org_id" },
42
+ ], { service: "AppAPI", operation: "LikeOrg" }),
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 LikeOrgHandler(operation, mux, new LikeOrgSerializer(), 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 LikeOrgHandler {
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.LikeOrg. This indicates a misconfiguration.');
114
+ return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
115
+ }
116
+ return handle(request, context, "LikeOrg", this.serializer, this.operation, this.serializeFrameworkException, LikeOrgServerInput.validate, this.validationCustomizer);
117
+ }
118
+ }