@wildix/xbees-kite-client 1.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 (64) hide show
  1. package/dist-cjs/Kite.js +25 -0
  2. package/dist-cjs/KiteClient.js +37 -0
  3. package/dist-cjs/commands/CreateWidgetCommand.js +21 -0
  4. package/dist-cjs/commands/DeleteWidgetCommand.js +21 -0
  5. package/dist-cjs/commands/GetConfigCommand.js +21 -0
  6. package/dist-cjs/commands/GetWidgetCommand.js +21 -0
  7. package/dist-cjs/commands/ListServicesCommand.js +21 -0
  8. package/dist-cjs/commands/ListWidgetsCommand.js +21 -0
  9. package/dist-cjs/commands/UpdateWidgetCommand.js +21 -0
  10. package/dist-cjs/commands/index.js +10 -0
  11. package/dist-cjs/extensionConfiguration.js +2 -0
  12. package/dist-cjs/index.js +10 -0
  13. package/dist-cjs/models/KiteServiceException.js +12 -0
  14. package/dist-cjs/models/index.js +4 -0
  15. package/dist-cjs/models/models_0.js +112 -0
  16. package/dist-cjs/protocols/Aws_restJson1.js +387 -0
  17. package/dist-cjs/runtimeConfig.browser.js +32 -0
  18. package/dist-cjs/runtimeConfig.js +36 -0
  19. package/dist-cjs/runtimeConfig.native.js +15 -0
  20. package/dist-cjs/runtimeConfig.shared.js +21 -0
  21. package/dist-cjs/runtimeExtensions.js +19 -0
  22. package/dist-es/Kite.js +21 -0
  23. package/dist-es/KiteClient.js +33 -0
  24. package/dist-es/commands/CreateWidgetCommand.js +17 -0
  25. package/dist-es/commands/DeleteWidgetCommand.js +17 -0
  26. package/dist-es/commands/GetConfigCommand.js +17 -0
  27. package/dist-es/commands/GetWidgetCommand.js +17 -0
  28. package/dist-es/commands/ListServicesCommand.js +17 -0
  29. package/dist-es/commands/ListWidgetsCommand.js +17 -0
  30. package/dist-es/commands/UpdateWidgetCommand.js +17 -0
  31. package/dist-es/commands/index.js +7 -0
  32. package/dist-es/extensionConfiguration.js +1 -0
  33. package/dist-es/index.js +5 -0
  34. package/dist-es/models/KiteServiceException.js +8 -0
  35. package/dist-es/models/index.js +1 -0
  36. package/dist-es/models/models_0.js +104 -0
  37. package/dist-es/protocols/Aws_restJson1.js +370 -0
  38. package/dist-es/runtimeConfig.browser.js +27 -0
  39. package/dist-es/runtimeConfig.js +31 -0
  40. package/dist-es/runtimeConfig.native.js +11 -0
  41. package/dist-es/runtimeConfig.shared.js +17 -0
  42. package/dist-es/runtimeExtensions.js +15 -0
  43. package/dist-types/Kite.d.ts +60 -0
  44. package/dist-types/KiteClient.d.ts +149 -0
  45. package/dist-types/commands/CreateWidgetCommand.d.ts +199 -0
  46. package/dist-types/commands/DeleteWidgetCommand.d.ts +64 -0
  47. package/dist-types/commands/GetConfigCommand.d.ts +107 -0
  48. package/dist-types/commands/GetWidgetCommand.d.ts +137 -0
  49. package/dist-types/commands/ListServicesCommand.d.ts +94 -0
  50. package/dist-types/commands/ListWidgetsCommand.d.ts +137 -0
  51. package/dist-types/commands/UpdateWidgetCommand.d.ts +200 -0
  52. package/dist-types/commands/index.d.ts +7 -0
  53. package/dist-types/extensionConfiguration.d.ts +7 -0
  54. package/dist-types/index.d.ts +7 -0
  55. package/dist-types/models/KiteServiceException.d.ts +14 -0
  56. package/dist-types/models/index.d.ts +1 -0
  57. package/dist-types/models/models_0.d.ts +617 -0
  58. package/dist-types/protocols/Aws_restJson1.d.ts +65 -0
  59. package/dist-types/runtimeConfig.browser.d.ts +28 -0
  60. package/dist-types/runtimeConfig.d.ts +28 -0
  61. package/dist-types/runtimeConfig.native.d.ts +27 -0
  62. package/dist-types/runtimeConfig.shared.d.ts +15 -0
  63. package/dist-types/runtimeExtensions.d.ts +17 -0
  64. package/package.json +78 -0
@@ -0,0 +1,17 @@
1
+ import { de_ListWidgetsCommand, se_ListWidgetsCommand, } from "../protocols/Aws_restJson1";
2
+ import { getSerdePlugin } from "@smithy/middleware-serde";
3
+ import { Command as $Command } from "@smithy/smithy-client";
4
+ export { $Command };
5
+ export class ListWidgetsCommand extends $Command.classBuilder()
6
+ .m(function (Command, cs, config, o) {
7
+ return [
8
+ getSerdePlugin(config, this.serialize, this.deserialize),
9
+ ];
10
+ })
11
+ .s("Kite", "ListWidgets", {})
12
+ .n("KiteClient", "ListWidgetsCommand")
13
+ .f(void 0, void 0)
14
+ .ser(se_ListWidgetsCommand)
15
+ .de(de_ListWidgetsCommand)
16
+ .build() {
17
+ }
@@ -0,0 +1,17 @@
1
+ import { de_UpdateWidgetCommand, se_UpdateWidgetCommand, } from "../protocols/Aws_restJson1";
2
+ import { getSerdePlugin } from "@smithy/middleware-serde";
3
+ import { Command as $Command } from "@smithy/smithy-client";
4
+ export { $Command };
5
+ export class UpdateWidgetCommand extends $Command.classBuilder()
6
+ .m(function (Command, cs, config, o) {
7
+ return [
8
+ getSerdePlugin(config, this.serialize, this.deserialize),
9
+ ];
10
+ })
11
+ .s("Kite", "UpdateWidget", {})
12
+ .n("KiteClient", "UpdateWidgetCommand")
13
+ .f(void 0, void 0)
14
+ .ser(se_UpdateWidgetCommand)
15
+ .de(de_UpdateWidgetCommand)
16
+ .build() {
17
+ }
@@ -0,0 +1,7 @@
1
+ export * from "./CreateWidgetCommand";
2
+ export * from "./DeleteWidgetCommand";
3
+ export * from "./GetConfigCommand";
4
+ export * from "./GetWidgetCommand";
5
+ export * from "./ListServicesCommand";
6
+ export * from "./ListWidgetsCommand";
7
+ export * from "./UpdateWidgetCommand";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from "./KiteClient";
2
+ export * from "./Kite";
3
+ export * from "./commands";
4
+ export * from "./models";
5
+ export { KiteServiceException } from "./models/KiteServiceException";
@@ -0,0 +1,8 @@
1
+ import { ServiceException as __ServiceException, } from "@smithy/smithy-client";
2
+ export { __ServiceException };
3
+ export class KiteServiceException extends __ServiceException {
4
+ constructor(options) {
5
+ super(options);
6
+ Object.setPrototypeOf(this, KiteServiceException.prototype);
7
+ }
8
+ }
@@ -0,0 +1 @@
1
+ export * from "./models_0";
@@ -0,0 +1,104 @@
1
+ import { KiteServiceException as __BaseException } from "./KiteServiceException";
2
+ export class ValidationException extends __BaseException {
3
+ constructor(opts) {
4
+ super({
5
+ name: "ValidationException",
6
+ $fault: "client",
7
+ ...opts
8
+ });
9
+ this.name = "ValidationException";
10
+ this.$fault = "client";
11
+ Object.setPrototypeOf(this, ValidationException.prototype);
12
+ }
13
+ }
14
+ export class ForbiddenException extends __BaseException {
15
+ constructor(opts) {
16
+ super({
17
+ name: "ForbiddenException",
18
+ $fault: "client",
19
+ ...opts
20
+ });
21
+ this.name = "ForbiddenException";
22
+ this.$fault = "client";
23
+ Object.setPrototypeOf(this, ForbiddenException.prototype);
24
+ }
25
+ }
26
+ export class LimitExceededException extends __BaseException {
27
+ constructor(opts) {
28
+ super({
29
+ name: "LimitExceededException",
30
+ $fault: "client",
31
+ ...opts
32
+ });
33
+ this.name = "LimitExceededException";
34
+ this.$fault = "client";
35
+ Object.setPrototypeOf(this, LimitExceededException.prototype);
36
+ this.rateLimit = opts.rateLimit;
37
+ this.rateLimitRemaining = opts.rateLimitRemaining;
38
+ this.rateLimitReset = opts.rateLimitReset;
39
+ this.retryAfter = opts.retryAfter;
40
+ }
41
+ }
42
+ export const WidgetRouteTimeFrameDay = {
43
+ EVERY_DAY: "EVERY_DAY",
44
+ FRIDAY: "FRIDAY",
45
+ MONDAY: "MONDAY",
46
+ SATURDAY: "SATURDAY",
47
+ SUNDAY: "SUNDAY",
48
+ THUESDAY: "THUESDAY",
49
+ THURSDAY: "THURSDAY",
50
+ WEDNESDAY: "WEDNESDAY",
51
+ WEEKDAYS: "WEEKDAYS",
52
+ WEEKENDS: "WEEKENDS",
53
+ };
54
+ export var WidgetRouteRule;
55
+ (function (WidgetRouteRule) {
56
+ WidgetRouteRule.visit = (value, visitor) => {
57
+ if (value.timeFrame !== undefined)
58
+ return visitor.timeFrame(value.timeFrame);
59
+ return visitor._(value.$unknown[0], value.$unknown[1]);
60
+ };
61
+ })(WidgetRouteRule || (WidgetRouteRule = {}));
62
+ export var WidgetTarget;
63
+ (function (WidgetTarget) {
64
+ WidgetTarget.visit = (value, visitor) => {
65
+ if (value.service !== undefined)
66
+ return visitor.service(value.service);
67
+ if (value.agent !== undefined)
68
+ return visitor.agent(value.agent);
69
+ if (value.bot !== undefined)
70
+ return visitor.bot(value.bot);
71
+ return visitor._(value.$unknown[0], value.$unknown[1]);
72
+ };
73
+ })(WidgetTarget || (WidgetTarget = {}));
74
+ export const KiteFeatures = {
75
+ SCHEDULING: "scheduling",
76
+ };
77
+ export const KiteVariant = {
78
+ DIRECT: "direct",
79
+ GROUP: "group",
80
+ };
81
+ export class TargetNotFoundException extends __BaseException {
82
+ constructor(opts) {
83
+ super({
84
+ name: "TargetNotFoundException",
85
+ $fault: "client",
86
+ ...opts
87
+ });
88
+ this.name = "TargetNotFoundException";
89
+ this.$fault = "client";
90
+ Object.setPrototypeOf(this, TargetNotFoundException.prototype);
91
+ }
92
+ }
93
+ export class WidgetNotFoundException extends __BaseException {
94
+ constructor(opts) {
95
+ super({
96
+ name: "WidgetNotFoundException",
97
+ $fault: "client",
98
+ ...opts
99
+ });
100
+ this.name = "WidgetNotFoundException";
101
+ this.$fault = "client";
102
+ Object.setPrototypeOf(this, WidgetNotFoundException.prototype);
103
+ }
104
+ }
@@ -0,0 +1,370 @@
1
+ import { KiteServiceException as __BaseException } from "../models/KiteServiceException";
2
+ import { ForbiddenException, LimitExceededException, TargetNotFoundException, ValidationException, WidgetNotFoundException, } from "../models/models_0";
3
+ import { requestBuilder as rb } from "@smithy/core";
4
+ import { decorateServiceException as __decorateServiceException, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, strictParseInt32 as __strictParseInt32, _json, collectBody, map, take, withBaseException, } from "@smithy/smithy-client";
5
+ export const se_CreateWidgetCommand = async (input, context) => {
6
+ const b = rb(input, context);
7
+ const headers = {
8
+ 'content-type': 'application/json',
9
+ };
10
+ b.bp("/v2/kite/widgets");
11
+ const query = map({
12
+ [_c]: [, input[_cI]],
13
+ });
14
+ let body;
15
+ body = JSON.stringify(take(input, {
16
+ 'appearance': _ => _json(_),
17
+ 'name': [],
18
+ 'routes': _ => _json(_),
19
+ 'target': _ => _json(_),
20
+ 'welcomeMessages': _ => _json(_),
21
+ }));
22
+ b.m("POST")
23
+ .h(headers)
24
+ .q(query)
25
+ .b(body);
26
+ return b.build();
27
+ };
28
+ export const se_DeleteWidgetCommand = async (input, context) => {
29
+ const b = rb(input, context);
30
+ const headers = {};
31
+ b.bp("/v2/kite/widgets/{widgetId}");
32
+ b.p('widgetId', () => input.widgetId, '{widgetId}', false);
33
+ let body;
34
+ b.m("DELETE")
35
+ .h(headers)
36
+ .b(body);
37
+ return b.build();
38
+ };
39
+ export const se_GetConfigCommand = async (input, context) => {
40
+ const b = rb(input, context);
41
+ const headers = {};
42
+ b.bp("/v2/kite/config/{targetId}");
43
+ b.p('targetId', () => input.targetId, '{targetId}', false);
44
+ let body;
45
+ b.m("GET")
46
+ .h(headers)
47
+ .b(body);
48
+ return b.build();
49
+ };
50
+ export const se_GetWidgetCommand = async (input, context) => {
51
+ const b = rb(input, context);
52
+ const headers = {};
53
+ b.bp("/v2/kite/widgets/{widgetId}");
54
+ b.p('widgetId', () => input.widgetId, '{widgetId}', false);
55
+ let body;
56
+ b.m("GET")
57
+ .h(headers)
58
+ .b(body);
59
+ return b.build();
60
+ };
61
+ export const se_ListServicesCommand = async (input, context) => {
62
+ const b = rb(input, context);
63
+ const headers = {
64
+ 'content-type': 'application/json',
65
+ };
66
+ b.bp("/v2/kite/services");
67
+ let body;
68
+ body = "";
69
+ b.m("GET")
70
+ .h(headers)
71
+ .b(body);
72
+ return b.build();
73
+ };
74
+ export const se_ListWidgetsCommand = async (input, context) => {
75
+ const b = rb(input, context);
76
+ const headers = {};
77
+ b.bp("/v2/kite/widgets");
78
+ const query = map({
79
+ [_c]: [, input[_cI]],
80
+ });
81
+ let body;
82
+ b.m("GET")
83
+ .h(headers)
84
+ .q(query)
85
+ .b(body);
86
+ return b.build();
87
+ };
88
+ export const se_UpdateWidgetCommand = async (input, context) => {
89
+ const b = rb(input, context);
90
+ const headers = {
91
+ 'content-type': 'application/json',
92
+ };
93
+ b.bp("/v2/kite/widgets/{widgetId}");
94
+ b.p('widgetId', () => input.widgetId, '{widgetId}', false);
95
+ const query = map({
96
+ [_c]: [, input[_cI]],
97
+ });
98
+ let body;
99
+ body = JSON.stringify(take(input, {
100
+ 'appearance': _ => _json(_),
101
+ 'name': [],
102
+ 'routes': _ => _json(_),
103
+ 'target': _ => _json(_),
104
+ 'welcomeMessages': _ => _json(_),
105
+ }));
106
+ b.m("PUT")
107
+ .h(headers)
108
+ .q(query)
109
+ .b(body);
110
+ return b.build();
111
+ };
112
+ export const de_CreateWidgetCommand = async (output, context) => {
113
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
114
+ return de_CommandError(output, context);
115
+ }
116
+ const contents = map({
117
+ $metadata: deserializeMetadata(output),
118
+ });
119
+ const data = __expectNonNull((__expectObject(await parseBody(output.body, context))), "body");
120
+ const doc = take(data, {
121
+ 'widget': _json,
122
+ });
123
+ Object.assign(contents, doc);
124
+ return contents;
125
+ };
126
+ export const de_DeleteWidgetCommand = async (output, context) => {
127
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
128
+ return de_CommandError(output, context);
129
+ }
130
+ const contents = map({
131
+ $metadata: deserializeMetadata(output),
132
+ });
133
+ await collectBody(output.body, context);
134
+ return contents;
135
+ };
136
+ export const de_GetConfigCommand = async (output, context) => {
137
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
138
+ return de_CommandError(output, context);
139
+ }
140
+ const contents = map({
141
+ $metadata: deserializeMetadata(output),
142
+ });
143
+ const data = __expectNonNull((__expectObject(await parseBody(output.body, context))), "body");
144
+ const doc = take(data, {
145
+ 'config': _json,
146
+ });
147
+ Object.assign(contents, doc);
148
+ return contents;
149
+ };
150
+ export const de_GetWidgetCommand = async (output, context) => {
151
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
152
+ return de_CommandError(output, context);
153
+ }
154
+ const contents = map({
155
+ $metadata: deserializeMetadata(output),
156
+ });
157
+ const data = __expectNonNull((__expectObject(await parseBody(output.body, context))), "body");
158
+ const doc = take(data, {
159
+ 'widget': _json,
160
+ });
161
+ Object.assign(contents, doc);
162
+ return contents;
163
+ };
164
+ export const de_ListServicesCommand = async (output, context) => {
165
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
166
+ return de_CommandError(output, context);
167
+ }
168
+ const contents = map({
169
+ $metadata: deserializeMetadata(output),
170
+ });
171
+ const data = __expectNonNull((__expectObject(await parseBody(output.body, context))), "body");
172
+ const doc = take(data, {
173
+ 'services': _json,
174
+ });
175
+ Object.assign(contents, doc);
176
+ return contents;
177
+ };
178
+ export const de_ListWidgetsCommand = async (output, context) => {
179
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
180
+ return de_CommandError(output, context);
181
+ }
182
+ const contents = map({
183
+ $metadata: deserializeMetadata(output),
184
+ });
185
+ const data = __expectNonNull((__expectObject(await parseBody(output.body, context))), "body");
186
+ const doc = take(data, {
187
+ 'widgets': _json,
188
+ });
189
+ Object.assign(contents, doc);
190
+ return contents;
191
+ };
192
+ export const de_UpdateWidgetCommand = async (output, context) => {
193
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
194
+ return de_CommandError(output, context);
195
+ }
196
+ const contents = map({
197
+ $metadata: deserializeMetadata(output),
198
+ });
199
+ const data = __expectNonNull((__expectObject(await parseBody(output.body, context))), "body");
200
+ const doc = take(data, {
201
+ 'widget': _json,
202
+ });
203
+ Object.assign(contents, doc);
204
+ return contents;
205
+ };
206
+ const de_CommandError = async (output, context) => {
207
+ const parsedOutput = {
208
+ ...output,
209
+ body: await parseErrorBody(output.body, context)
210
+ };
211
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
212
+ switch (errorCode) {
213
+ case "ForbiddenException":
214
+ case "smithy.framework#ForbiddenException":
215
+ throw await de_ForbiddenExceptionRes(parsedOutput, context);
216
+ case "LimitExceededException":
217
+ case "smithy.framework#LimitExceededException":
218
+ throw await de_LimitExceededExceptionRes(parsedOutput, context);
219
+ case "ValidationException":
220
+ case "smithy.framework#ValidationException":
221
+ throw await de_ValidationExceptionRes(parsedOutput, context);
222
+ case "TargetNotFoundException":
223
+ case "wildix.xbees.kite#TargetNotFoundException":
224
+ throw await de_TargetNotFoundExceptionRes(parsedOutput, context);
225
+ case "WidgetNotFoundException":
226
+ case "wildix.xbees.kite#WidgetNotFoundException":
227
+ throw await de_WidgetNotFoundExceptionRes(parsedOutput, context);
228
+ default:
229
+ const parsedBody = parsedOutput.body;
230
+ return throwDefaultError({
231
+ output,
232
+ parsedBody,
233
+ errorCode
234
+ });
235
+ }
236
+ };
237
+ const throwDefaultError = withBaseException(__BaseException);
238
+ const de_ForbiddenExceptionRes = async (parsedOutput, context) => {
239
+ const contents = map({});
240
+ const data = parsedOutput.body;
241
+ const doc = take(data, {
242
+ 'message': __expectString,
243
+ });
244
+ Object.assign(contents, doc);
245
+ const exception = new ForbiddenException({
246
+ $metadata: deserializeMetadata(parsedOutput),
247
+ ...contents
248
+ });
249
+ return __decorateServiceException(exception, parsedOutput.body);
250
+ };
251
+ const de_LimitExceededExceptionRes = async (parsedOutput, context) => {
252
+ const contents = map({
253
+ [_rL]: [, parsedOutput.headers[_xrl]],
254
+ [_rLR]: [() => void 0 !== parsedOutput.headers[_xrr], () => __strictParseInt32(parsedOutput.headers[_xrr])],
255
+ [_rLRa]: [() => void 0 !== parsedOutput.headers[_xrr_], () => __strictParseInt32(parsedOutput.headers[_xrr_])],
256
+ [_rA]: [() => void 0 !== parsedOutput.headers[_ra], () => __strictParseInt32(parsedOutput.headers[_ra])],
257
+ });
258
+ const data = parsedOutput.body;
259
+ const doc = take(data, {
260
+ 'message': __expectString,
261
+ });
262
+ Object.assign(contents, doc);
263
+ const exception = new LimitExceededException({
264
+ $metadata: deserializeMetadata(parsedOutput),
265
+ ...contents
266
+ });
267
+ return __decorateServiceException(exception, parsedOutput.body);
268
+ };
269
+ const de_ValidationExceptionRes = async (parsedOutput, context) => {
270
+ const contents = map({});
271
+ const data = parsedOutput.body;
272
+ const doc = take(data, {
273
+ 'message': __expectString,
274
+ });
275
+ Object.assign(contents, doc);
276
+ const exception = new ValidationException({
277
+ $metadata: deserializeMetadata(parsedOutput),
278
+ ...contents
279
+ });
280
+ return __decorateServiceException(exception, parsedOutput.body);
281
+ };
282
+ const de_TargetNotFoundExceptionRes = async (parsedOutput, context) => {
283
+ const contents = map({});
284
+ const data = parsedOutput.body;
285
+ const doc = take(data, {
286
+ 'message': __expectString,
287
+ });
288
+ Object.assign(contents, doc);
289
+ const exception = new TargetNotFoundException({
290
+ $metadata: deserializeMetadata(parsedOutput),
291
+ ...contents
292
+ });
293
+ return __decorateServiceException(exception, parsedOutput.body);
294
+ };
295
+ const de_WidgetNotFoundExceptionRes = async (parsedOutput, context) => {
296
+ const contents = map({});
297
+ const data = parsedOutput.body;
298
+ const doc = take(data, {
299
+ 'message': __expectString,
300
+ });
301
+ Object.assign(contents, doc);
302
+ const exception = new WidgetNotFoundException({
303
+ $metadata: deserializeMetadata(parsedOutput),
304
+ ...contents
305
+ });
306
+ return __decorateServiceException(exception, parsedOutput.body);
307
+ };
308
+ const deserializeMetadata = (output) => ({
309
+ httpStatusCode: output.statusCode,
310
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
311
+ extendedRequestId: output.headers["x-amz-id-2"],
312
+ cfId: output.headers["x-amz-cf-id"],
313
+ });
314
+ const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then(body => context.utf8Encoder(body));
315
+ const isSerializableHeaderValue = (value) => value !== undefined &&
316
+ value !== null &&
317
+ value !== "" &&
318
+ (!Object.getOwnPropertyNames(value).includes("length") ||
319
+ value.length != 0) &&
320
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
321
+ const _c = "company";
322
+ const _cI = "companyId";
323
+ const _rA = "retryAfter";
324
+ const _rL = "rateLimit";
325
+ const _rLR = "rateLimitRemaining";
326
+ const _rLRa = "rateLimitReset";
327
+ const _ra = "retry-after";
328
+ const _xrl = "x-ratelimit-limit";
329
+ const _xrr = "x-ratelimit-remaining";
330
+ const _xrr_ = "x-ratelimit-reset";
331
+ const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then(encoded => {
332
+ if (encoded.length) {
333
+ return JSON.parse(encoded);
334
+ }
335
+ return {};
336
+ });
337
+ const parseErrorBody = async (errorBody, context) => {
338
+ const value = await parseBody(errorBody, context);
339
+ value.message = value.message ?? value.Message;
340
+ return value;
341
+ };
342
+ const loadRestJsonErrorCode = (output, data) => {
343
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
344
+ const sanitizeErrorCode = (rawValue) => {
345
+ let cleanValue = rawValue;
346
+ if (typeof cleanValue === "number") {
347
+ cleanValue = cleanValue.toString();
348
+ }
349
+ if (cleanValue.indexOf(",") >= 0) {
350
+ cleanValue = cleanValue.split(",")[0];
351
+ }
352
+ if (cleanValue.indexOf(":") >= 0) {
353
+ cleanValue = cleanValue.split(":")[0];
354
+ }
355
+ if (cleanValue.indexOf("#") >= 0) {
356
+ cleanValue = cleanValue.split("#")[1];
357
+ }
358
+ return cleanValue;
359
+ };
360
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
361
+ if (headerKey !== undefined) {
362
+ return sanitizeErrorCode(output.headers[headerKey]);
363
+ }
364
+ if (data.code !== undefined) {
365
+ return sanitizeErrorCode(data.code);
366
+ }
367
+ if (data["__type"] !== undefined) {
368
+ return sanitizeErrorCode(data["__type"]);
369
+ }
370
+ };
@@ -0,0 +1,27 @@
1
+ import packageInfo from "../package.json";
2
+ import { Sha256 } from "@aws-crypto/sha256-browser";
3
+ import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
4
+ import { FetchHttpHandler as RequestHandler, streamCollector, } from "@smithy/fetch-http-handler";
5
+ import { calculateBodyLength } from "@smithy/util-body-length-browser";
6
+ import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE, } from "@smithy/util-retry";
7
+ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared";
8
+ import { loadConfigsForDefaultMode } from "@smithy/smithy-client";
9
+ import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-browser";
10
+ export const getRuntimeConfig = (config) => {
11
+ const defaultsMode = resolveDefaultsModeConfig(config);
12
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
13
+ const clientSharedValues = getSharedRuntimeConfig(config);
14
+ return {
15
+ ...clientSharedValues,
16
+ ...config,
17
+ runtime: "browser",
18
+ defaultsMode,
19
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
20
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ?? defaultUserAgent({ serviceId: packageInfo.name, clientVersion: packageInfo.version }),
21
+ maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
22
+ requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
23
+ retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
24
+ sha256: config?.sha256 ?? Sha256,
25
+ streamCollector: config?.streamCollector ?? streamCollector,
26
+ };
27
+ };
@@ -0,0 +1,31 @@
1
+ import packageInfo from "../package.json";
2
+ import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
3
+ import { Hash } from "@smithy/hash-node";
4
+ import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS, } from "@smithy/middleware-retry";
5
+ import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider";
6
+ import { NodeHttpHandler as RequestHandler, streamCollector, } from "@smithy/node-http-handler";
7
+ import { calculateBodyLength } from "@smithy/util-body-length-node";
8
+ import { DEFAULT_RETRY_MODE } from "@smithy/util-retry";
9
+ import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared";
10
+ import { loadConfigsForDefaultMode } from "@smithy/smithy-client";
11
+ import { resolveDefaultsModeConfig } from "@smithy/util-defaults-mode-node";
12
+ import { emitWarningIfUnsupportedVersion } from "@smithy/smithy-client";
13
+ export const getRuntimeConfig = (config) => {
14
+ emitWarningIfUnsupportedVersion(process.version);
15
+ const defaultsMode = resolveDefaultsModeConfig(config);
16
+ const defaultConfigProvider = () => defaultsMode().then(loadConfigsForDefaultMode);
17
+ const clientSharedValues = getSharedRuntimeConfig(config);
18
+ return {
19
+ ...clientSharedValues,
20
+ ...config,
21
+ runtime: "node",
22
+ defaultsMode,
23
+ bodyLengthChecker: config?.bodyLengthChecker ?? calculateBodyLength,
24
+ defaultUserAgentProvider: config?.defaultUserAgentProvider ?? defaultUserAgent({ serviceId: packageInfo.name, clientVersion: packageInfo.version }),
25
+ maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
26
+ requestHandler: RequestHandler.create(config?.requestHandler ?? defaultConfigProvider),
27
+ retryMode: config?.retryMode ?? loadNodeConfig({ ...NODE_RETRY_MODE_CONFIG_OPTIONS, default: async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE, }),
28
+ sha256: config?.sha256 ?? Hash.bind(null, "sha256"),
29
+ streamCollector: config?.streamCollector ?? streamCollector,
30
+ };
31
+ };
@@ -0,0 +1,11 @@
1
+ import { Sha256 } from "@aws-crypto/sha256-js";
2
+ import { getRuntimeConfig as getBrowserRuntimeConfig } from "./runtimeConfig.browser";
3
+ export const getRuntimeConfig = (config) => {
4
+ const browserDefaults = getBrowserRuntimeConfig(config);
5
+ return {
6
+ ...browserDefaults,
7
+ ...config,
8
+ runtime: "react-native",
9
+ sha256: config?.sha256 ?? Sha256,
10
+ };
11
+ };
@@ -0,0 +1,17 @@
1
+ import { NoOpLogger } from "@smithy/smithy-client";
2
+ import { parseUrl } from "@smithy/url-parser";
3
+ import { fromBase64, toBase64, } from "@smithy/util-base64";
4
+ import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
5
+ export const getRuntimeConfig = (config) => {
6
+ return {
7
+ apiVersion: "v2",
8
+ base64Decoder: config?.base64Decoder ?? fromBase64,
9
+ base64Encoder: config?.base64Encoder ?? toBase64,
10
+ disableHostPrefix: config?.disableHostPrefix ?? false,
11
+ extensions: config?.extensions ?? [],
12
+ logger: config?.logger ?? new NoOpLogger(),
13
+ urlParser: config?.urlParser ?? parseUrl,
14
+ utf8Decoder: config?.utf8Decoder ?? fromUtf8,
15
+ utf8Encoder: config?.utf8Encoder ?? toUtf8,
16
+ };
17
+ };
@@ -0,0 +1,15 @@
1
+ import { getHttpHandlerExtensionConfiguration, resolveHttpHandlerRuntimeConfig, } from "@smithy/protocol-http";
2
+ import { getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig, } from "@smithy/smithy-client";
3
+ const asPartial = (t) => t;
4
+ export const resolveRuntimeExtensions = (runtimeConfig, extensions) => {
5
+ const extensionConfiguration = {
6
+ ...asPartial(getDefaultExtensionConfiguration(runtimeConfig)),
7
+ ...asPartial(getHttpHandlerExtensionConfiguration(runtimeConfig)),
8
+ };
9
+ extensions.forEach(extension => extension.configure(extensionConfiguration));
10
+ return {
11
+ ...runtimeConfig,
12
+ ...resolveDefaultRuntimeConfig(extensionConfiguration),
13
+ ...resolveHttpHandlerRuntimeConfig(extensionConfiguration),
14
+ };
15
+ };