@leonardo-ai/sdk 1.1.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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +17 -0
  5. package/dist/internal/utils/contenttype.d.ts +1 -0
  6. package/dist/internal/utils/contenttype.js +30 -0
  7. package/dist/internal/utils/headers.d.ts +4 -0
  8. package/dist/internal/utils/headers.js +85 -0
  9. package/dist/internal/utils/index.d.ts +8 -0
  10. package/dist/internal/utils/index.js +24 -0
  11. package/dist/internal/utils/pathparams.d.ts +9 -0
  12. package/dist/internal/utils/pathparams.js +58 -0
  13. package/dist/internal/utils/queryparams.d.ts +3 -0
  14. package/dist/internal/utils/queryparams.js +104 -0
  15. package/dist/internal/utils/requestbody.d.ts +1 -0
  16. package/dist/internal/utils/requestbody.js +266 -0
  17. package/dist/internal/utils/retries.d.ts +20 -0
  18. package/dist/internal/utils/retries.js +223 -0
  19. package/dist/internal/utils/security.d.ts +2 -0
  20. package/dist/internal/utils/security.js +156 -0
  21. package/dist/internal/utils/utils.d.ts +19 -0
  22. package/dist/internal/utils/utils.js +202 -0
  23. package/dist/sdk/creatingdatasets.d.ts +41 -0
  24. package/dist/sdk/creatingdatasets.js +235 -0
  25. package/dist/sdk/generatingimages.d.ts +35 -0
  26. package/dist/sdk/generatingimages.js +182 -0
  27. package/dist/sdk/imagevariations.d.ts +23 -0
  28. package/dist/sdk/imagevariations.js +120 -0
  29. package/dist/sdk/index.d.ts +1 -0
  30. package/dist/sdk/index.js +17 -0
  31. package/dist/sdk/initimages.d.ts +29 -0
  32. package/dist/sdk/initimages.js +151 -0
  33. package/dist/sdk/models/operations/deletedatasetsid.d.ts +12 -0
  34. package/dist/sdk/models/operations/deletedatasetsid.js +72 -0
  35. package/dist/sdk/models/operations/deletegenerationsid.d.ts +12 -0
  36. package/dist/sdk/models/operations/deletegenerationsid.js +72 -0
  37. package/dist/sdk/models/operations/deleteinitimageid.d.ts +12 -0
  38. package/dist/sdk/models/operations/deleteinitimageid.js +72 -0
  39. package/dist/sdk/models/operations/deletemodelsid.d.ts +12 -0
  40. package/dist/sdk/models/operations/deletemodelsid.js +72 -0
  41. package/dist/sdk/models/operations/getdatasetsid.d.ts +12 -0
  42. package/dist/sdk/models/operations/getdatasetsid.js +72 -0
  43. package/dist/sdk/models/operations/getgenerationsid.d.ts +12 -0
  44. package/dist/sdk/models/operations/getgenerationsid.js +72 -0
  45. package/dist/sdk/models/operations/getgenerationsuseruserid.d.ts +17 -0
  46. package/dist/sdk/models/operations/getgenerationsuseruserid.js +92 -0
  47. package/dist/sdk/models/operations/getinitimageid.d.ts +12 -0
  48. package/dist/sdk/models/operations/getinitimageid.js +72 -0
  49. package/dist/sdk/models/operations/getme.d.ts +6 -0
  50. package/dist/sdk/models/operations/getme.js +48 -0
  51. package/dist/sdk/models/operations/getmodelsid.d.ts +12 -0
  52. package/dist/sdk/models/operations/getmodelsid.js +72 -0
  53. package/dist/sdk/models/operations/getvariationsid.d.ts +12 -0
  54. package/dist/sdk/models/operations/getvariationsid.js +72 -0
  55. package/dist/sdk/models/operations/index.d.ts +18 -0
  56. package/dist/sdk/models/operations/index.js +34 -0
  57. package/dist/sdk/models/operations/postdatasets.d.ts +13 -0
  58. package/dist/sdk/models/operations/postdatasets.js +76 -0
  59. package/dist/sdk/models/operations/postdatasetsdatasetidupload.d.ts +16 -0
  60. package/dist/sdk/models/operations/postdatasetsdatasetidupload.js +88 -0
  61. package/dist/sdk/models/operations/postdatasetsdatasetiduploadgen.d.ts +16 -0
  62. package/dist/sdk/models/operations/postdatasetsdatasetiduploadgen.js +88 -0
  63. package/dist/sdk/models/operations/postgenerations.d.ts +27 -0
  64. package/dist/sdk/models/operations/postgenerations.js +132 -0
  65. package/dist/sdk/models/operations/postinitimage.d.ts +12 -0
  66. package/dist/sdk/models/operations/postinitimage.js +72 -0
  67. package/dist/sdk/models/operations/postmodels.d.ts +20 -0
  68. package/dist/sdk/models/operations/postmodels.js +104 -0
  69. package/dist/sdk/models/operations/postvariationsupscale.d.ts +12 -0
  70. package/dist/sdk/models/operations/postvariationsupscale.js +72 -0
  71. package/dist/sdk/models/shared/index.d.ts +1 -0
  72. package/dist/sdk/models/shared/index.js +17 -0
  73. package/dist/sdk/models/shared/security.d.ts +7 -0
  74. package/dist/sdk/models/shared/security.js +52 -0
  75. package/dist/sdk/sdk.d.ts +29 -0
  76. package/dist/sdk/sdk.js +68 -0
  77. package/dist/sdk/trainingmodels.d.ts +29 -0
  78. package/dist/sdk/trainingmodels.js +151 -0
  79. package/dist/sdk/userinformation.d.ts +17 -0
  80. package/dist/sdk/userinformation.js +76 -0
  81. package/package.json +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Leonardo.Ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # Leonardo TypeScript SDK
2
+
3
+ <div align="center">
4
+ <p>The API for creating stunning game assets with AI.</p>
5
+ <a href="https://github.com/Leonardo-Interactive/leonardo-ts-sdk/actions"><img src="https://img.shields.io/github/actions/workflow/status/Leonardo-Interactive/leonardo-ts-sdk/speakeasy_sdk_generate.yml?style=for-the-badge" /></a>
6
+ <a href="https://docs.leonardo.ai/"><img src="https://img.shields.io/static/v1?label=Docs&message=API Ref&color=000&style=for-the-badge" /></a>
7
+ <a href="https://discord.gg/leonardo-ai"><img src="https://img.shields.io/static/v1?label=Discord&message=Join&color=7289da&style=for-the-badge" /></a>
8
+ </div>
9
+
10
+ <!-- Start SDK Installation -->
11
+ ## SDK Installation
12
+
13
+ ### NPM
14
+
15
+ ```bash
16
+ npm add @leonardo-ai/sdk
17
+ ```
18
+
19
+ ### Yarn
20
+
21
+ ```bash
22
+ yarn add @leonardo-ai/sdk
23
+ ```
24
+ <!-- End SDK Installation -->
25
+
26
+ ## Authentication
27
+
28
+ To get access to the API and fetch an API key, please sign up for [access](https://leonardo.ai/).
29
+
30
+ ## SDK Example Usage
31
+ <!-- Start SDK Example Usage -->
32
+ ```typescript
33
+ import { Leonardo, withSecurity} from "@leonardo-ai/sdk";
34
+ import { DeleteDatasetsIdRequest, DeleteDatasetsIdResponse } from "@leonardo-ai/sdk/src/sdk/models/operations";
35
+ import { AxiosError } from "axios";
36
+
37
+ const sdk = new Leonardo(withSecurity(
38
+ security: {
39
+ bearerAuth: {
40
+ authorization: "Bearer YOUR_BEARER_TOKEN_HERE",
41
+ },
42
+ }
43
+ ));
44
+
45
+ const req: DeleteDatasetsIdRequest = {
46
+ pathParams: {
47
+ id: "unde",
48
+ },
49
+ };
50
+
51
+ sdk.creatingDatasets.deleteDatasetsId(req).then((res: DeleteDatasetsIdResponse | AxiosError) => {
52
+ // handle response
53
+ });
54
+ ```
55
+ <!-- End SDK Example Usage -->
56
+
57
+ <!-- Start SDK Available Operations -->
58
+ ## SDK Available Operations
59
+
60
+
61
+ ### creatingDatasets
62
+
63
+ * `deleteDatasetsId` - Delete a Single Dataset by ID
64
+ * `getDatasetsId` - Get a Single Dataset by ID
65
+ * `postDatasets` - Create a Dataset
66
+ * `postDatasetsDatasetIdUpload` - Upload dataset image
67
+ * `postDatasetsDatasetIdUploadGen` - Upload a Single Generated Image to a Dataset
68
+
69
+ ### generatingImages
70
+
71
+ * `deleteGenerationsId` - Delete a Single Generation
72
+ * `getGenerationsUserUserId` - Get generations by user ID
73
+ * `getGenerationsId` - Get a Single Generation
74
+ * `postGenerations` - Create a Generation of Images
75
+
76
+ ### imageVariations
77
+
78
+ * `getVariationsId` - Get variation by ID
79
+ * `postVariationsUpscale` - Create upscale
80
+
81
+ ### initImages
82
+
83
+ * `deleteInitImageId` - Delete init image
84
+ * `getInitImageId` - Get single init image
85
+ * `postInitImage` - Upload init image
86
+
87
+ ### trainingModels
88
+
89
+ * `deleteModelsId` - Delete a Single Custom Model by ID
90
+ * `getModelsId` - Get a Single Custom Model by ID
91
+ * `postModels` - Train a Custom Model
92
+
93
+ ### userInformation
94
+
95
+ * `getMe` - Get user information
96
+ <!-- End SDK Available Operations -->
97
+
98
+ ### SDK Generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)
@@ -0,0 +1 @@
1
+ export * from "./sdk";
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./sdk"), exports);
@@ -0,0 +1 @@
1
+ export declare function matchContentType(contentType: string, pattern: string): boolean;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchContentType = void 0;
4
+ function matchContentType(contentType, pattern) {
5
+ var res = false;
6
+ contentType
7
+ .split(";")
8
+ .map(function (ctPart) {
9
+ return ctPart.trim();
10
+ })
11
+ .forEach(function (ctPart) {
12
+ if (ctPart === pattern || pattern === "*" || pattern === "*/*") {
13
+ res = true;
14
+ return;
15
+ }
16
+ if (ctPart === pattern) {
17
+ res = true;
18
+ return;
19
+ }
20
+ var parts = ctPart.split("/");
21
+ if (parts.length === 2) {
22
+ if ("".concat(parts[0], "/*") === pattern || "*/".concat(parts[1]) === pattern) {
23
+ res = true;
24
+ return;
25
+ }
26
+ }
27
+ });
28
+ return res;
29
+ }
30
+ exports.matchContentType = matchContentType;
@@ -0,0 +1,4 @@
1
+ import { AxiosResponseHeaders, RawAxiosResponseHeaders } from "axios";
2
+ export declare const headerMetadataKey = "header";
3
+ export declare function getHeadersFromRequest(headerParams: any): any;
4
+ export declare function getHeadersFromResponse(headers: RawAxiosResponseHeaders | AxiosResponseHeaders): Record<string, string[]>;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHeadersFromResponse = exports.getHeadersFromRequest = exports.headerMetadataKey = void 0;
4
+ var utils_1 = require("./utils");
5
+ exports.headerMetadataKey = "header";
6
+ function getHeadersFromRequest(headerParams) {
7
+ if (headerParams == null)
8
+ return;
9
+ var headers = {};
10
+ var fieldNames = Object.getOwnPropertyNames(headerParams);
11
+ fieldNames.forEach(function (fname) {
12
+ var headerAnn = Reflect.getMetadata(exports.headerMetadataKey, headerParams, fname);
13
+ if (headerAnn == null)
14
+ return;
15
+ var headerDecorator = (0, utils_1.parseParamDecorator)(headerAnn, fname, "simple", false);
16
+ if (headerDecorator == null)
17
+ return;
18
+ var value = serializeHeader(headerParams[fname], headerDecorator.Explode);
19
+ if (value != "")
20
+ headers[headerDecorator.ParamName] = value;
21
+ });
22
+ return headers;
23
+ }
24
+ exports.getHeadersFromRequest = getHeadersFromRequest;
25
+ function getHeadersFromResponse(headers) {
26
+ var reponseHeaders = {};
27
+ Object.keys(headers).forEach(function (key) {
28
+ var value = headers[key];
29
+ if (!value)
30
+ return;
31
+ if (Array.isArray(value)) {
32
+ var h_1 = [];
33
+ value.forEach(function (val) {
34
+ if (val) {
35
+ h_1.push(String(val));
36
+ }
37
+ });
38
+ reponseHeaders[key] = h_1;
39
+ }
40
+ else {
41
+ reponseHeaders[key] = [value];
42
+ }
43
+ });
44
+ return reponseHeaders;
45
+ }
46
+ exports.getHeadersFromResponse = getHeadersFromResponse;
47
+ function serializeHeader(header, explode) {
48
+ var headerVals = [];
49
+ if (Array.isArray(header)) {
50
+ header.forEach(function (val) {
51
+ headerVals.push(String(val));
52
+ });
53
+ }
54
+ else if ((0, utils_1.isStringRecord)(header) ||
55
+ (0, utils_1.isNumberRecord)(header) ||
56
+ (0, utils_1.isBooleanRecord)(header)) {
57
+ Object.getOwnPropertyNames(header).forEach(function (headerKey) {
58
+ if (explode)
59
+ headerVals.push("".concat(headerKey, "=").concat(header[headerKey]));
60
+ else
61
+ headerVals.push("".concat(headerKey, ",").concat(header[headerKey]));
62
+ });
63
+ }
64
+ else if (header instanceof Object) {
65
+ Object.getOwnPropertyNames(header).forEach(function (headerKey) {
66
+ var headerAnn = Reflect.getMetadata(exports.headerMetadataKey, header, headerKey);
67
+ if (headerAnn == null)
68
+ return;
69
+ var headerDecorator = (0, utils_1.parseParamDecorator)(headerAnn, headerKey, "simple", explode);
70
+ if (headerDecorator == null)
71
+ return;
72
+ var headerFieldValue = header[headerKey];
73
+ if ((0, utils_1.isEmpty)(headerFieldValue))
74
+ return;
75
+ else if (explode)
76
+ headerVals.push("".concat(headerDecorator.ParamName, "=").concat(headerFieldValue));
77
+ else
78
+ headerVals.push("".concat(headerDecorator.ParamName, ",").concat(headerFieldValue));
79
+ });
80
+ }
81
+ else {
82
+ return String(header);
83
+ }
84
+ return headerVals.join(",");
85
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./contenttype";
2
+ export * from "./headers";
3
+ export * from "./pathparams";
4
+ export * from "./queryparams";
5
+ export * from "./requestbody";
6
+ export * from "./retries";
7
+ export * from "./security";
8
+ export * from "./utils";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./contenttype"), exports);
18
+ __exportStar(require("./headers"), exports);
19
+ __exportStar(require("./pathparams"), exports);
20
+ __exportStar(require("./queryparams"), exports);
21
+ __exportStar(require("./requestbody"), exports);
22
+ __exportStar(require("./retries"), exports);
23
+ __exportStar(require("./security"), exports);
24
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,9 @@
1
+ export declare const ppMetadataKey = "pathParam";
2
+ export declare function getSimplePathParams(paramName: string, paramValue: any, explode: boolean): Map<string, string>;
3
+ export declare class ParamDecorator {
4
+ Style: string;
5
+ Explode: boolean;
6
+ ParamName: string;
7
+ Serialization?: string;
8
+ constructor(Style: string, Explode: boolean, ParamName: string, Serialization?: string);
9
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParamDecorator = exports.getSimplePathParams = exports.ppMetadataKey = void 0;
4
+ var utils_1 = require("./utils");
5
+ var utils_2 = require("./utils");
6
+ exports.ppMetadataKey = "pathParam";
7
+ function getSimplePathParams(paramName, paramValue, explode) {
8
+ var pathParams = new Map();
9
+ var ppVals = [];
10
+ if (Array.isArray(paramValue)) {
11
+ paramValue.forEach(function (param) {
12
+ ppVals.push(String(param));
13
+ });
14
+ pathParams.set(paramName, ppVals.join(","));
15
+ }
16
+ else if ((0, utils_2.isStringRecord)(paramValue) || (0, utils_2.isNumberRecord)(paramValue) || (0, utils_2.isBooleanRecord)(paramValue)) {
17
+ Object.getOwnPropertyNames(paramValue).forEach(function (paramKey) {
18
+ if (explode)
19
+ ppVals.push("".concat(paramKey, "=").concat(paramValue[paramKey]));
20
+ else
21
+ ppVals.push("".concat(paramKey, ",").concat(paramValue[paramKey]));
22
+ });
23
+ pathParams.set(paramName, ppVals.join(","));
24
+ }
25
+ else if (paramValue instanceof Object) {
26
+ Object.getOwnPropertyNames(paramValue).forEach(function (paramKey) {
27
+ var ppAnn = Reflect.getMetadata(exports.ppMetadataKey, paramValue, paramKey);
28
+ if (ppAnn == null)
29
+ return;
30
+ var ppDecorator = (0, utils_1.parseParamDecorator)(ppAnn, paramKey, "simple", explode);
31
+ if (ppDecorator == null)
32
+ return;
33
+ var paramFieldValue = paramValue[paramKey];
34
+ if ((0, utils_2.isEmpty)(paramFieldValue))
35
+ return;
36
+ else if (explode)
37
+ ppVals.push("".concat(ppDecorator.ParamName, "=").concat(paramFieldValue));
38
+ else
39
+ ppVals.push("".concat(ppDecorator.ParamName, ",").concat(paramFieldValue));
40
+ });
41
+ pathParams.set(paramName, ppVals.join(","));
42
+ }
43
+ else {
44
+ pathParams.set(paramName, String(paramValue));
45
+ }
46
+ return pathParams;
47
+ }
48
+ exports.getSimplePathParams = getSimplePathParams;
49
+ var ParamDecorator = /** @class */ (function () {
50
+ function ParamDecorator(Style, Explode, ParamName, Serialization) {
51
+ this.Style = Style;
52
+ this.Explode = Explode;
53
+ this.ParamName = ParamName;
54
+ this.Serialization = Serialization;
55
+ }
56
+ return ParamDecorator;
57
+ }());
58
+ exports.ParamDecorator = ParamDecorator;
@@ -0,0 +1,3 @@
1
+ import { ParamsSerializerOptions } from "axios";
2
+ export declare const qpMetadataKey = "queryParam";
3
+ export declare function getQueryParamSerializer(queryParams: any): ParamsSerializerOptions;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getQueryParamSerializer = exports.qpMetadataKey = void 0;
7
+ var utils_1 = require("./utils");
8
+ var qs_1 = __importDefault(require("qs"));
9
+ exports.qpMetadataKey = "queryParam";
10
+ function getQueryParamSerializer(queryParams) {
11
+ var paramsSerializer = {
12
+ serialize: formSerializerExplode,
13
+ };
14
+ if (!queryParams)
15
+ return paramsSerializer;
16
+ var fieldNames = Object.getOwnPropertyNames(queryParams);
17
+ fieldNames.forEach(function (fname) {
18
+ var qpAnn = Reflect.getMetadata(exports.qpMetadataKey, queryParams, fname);
19
+ if (!qpAnn)
20
+ return { serialize: function (params) { return ""; } };
21
+ var qpDecorator = (0, utils_1.parseParamDecorator)(qpAnn, fname, "form", true);
22
+ if (!qpDecorator)
23
+ return;
24
+ if (qpDecorator.Serialization === "json")
25
+ paramsSerializer = {
26
+ serialize: function (params) { return Object.keys(params).map(function (key) {
27
+ return "".concat(key, "=").concat(JSON.stringify(params[key]));
28
+ }).join("&"); },
29
+ };
30
+ else {
31
+ switch (qpDecorator.Style) {
32
+ case "deepObject":
33
+ paramsSerializer = {
34
+ serialize: function (params) {
35
+ return qs_1.default.stringify(params);
36
+ },
37
+ };
38
+ break;
39
+ case "form":
40
+ if (qpDecorator.Explode) {
41
+ paramsSerializer = {
42
+ serialize: formSerializerExplode,
43
+ };
44
+ }
45
+ else {
46
+ paramsSerializer = {
47
+ serialize: formSerializer,
48
+ };
49
+ }
50
+ break;
51
+ default:
52
+ // go to next query parameter field, assume first implemented serializer will serialize all query parameters for this request
53
+ return;
54
+ }
55
+ }
56
+ });
57
+ return paramsSerializer;
58
+ }
59
+ exports.getQueryParamSerializer = getQueryParamSerializer;
60
+ function formSerializer(params) {
61
+ var query = [];
62
+ Object.entries(Object.assign({}, params)).forEach(function (_a) {
63
+ var key = _a[0], value = _a[1];
64
+ if (!value)
65
+ return;
66
+ if (value !== Object(value))
67
+ query.push("".concat(key, "=").concat(value));
68
+ else if (Array.isArray(value)) {
69
+ var values = value.join(",");
70
+ query.push("".concat(key, "=").concat(values));
71
+ }
72
+ else {
73
+ var values = Object.entries(Object.assign({}, value))
74
+ .map(function (_a) {
75
+ var objKey = _a[0], objValue = _a[1];
76
+ return "".concat(objKey, ",").concat(objValue);
77
+ })
78
+ .join(",");
79
+ query.push("".concat(key, "=").concat(values));
80
+ }
81
+ });
82
+ return query.join("&");
83
+ }
84
+ function formSerializerExplode(params) {
85
+ var query = [];
86
+ Object.entries(Object.assign({}, params)).forEach(function (_a) {
87
+ var key = _a[0], value = _a[1];
88
+ if (!value)
89
+ return;
90
+ if (value !== Object(value))
91
+ query.push("".concat(key, "=").concat(value));
92
+ else if (Array.isArray(value)) {
93
+ query.push(value.map(function (aValue) { return "".concat(key, "=").concat(aValue); }).join("&"));
94
+ }
95
+ else
96
+ query.push(Object.entries(Object.assign({}, value))
97
+ .map(function (_a) {
98
+ var objKey = _a[0], objValue = _a[1];
99
+ return "".concat(objKey, "=").concat(objValue);
100
+ })
101
+ .join("&"));
102
+ });
103
+ return query.join("&");
104
+ }
@@ -0,0 +1 @@
1
+ export declare function serializeRequestBody(request: any): [object, any];