@leonardo-ai/sdk 1.2.4 → 1.7.4

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 (55) hide show
  1. package/README.md +8 -4
  2. package/dist/internal/utils/headers.js +4 -4
  3. package/dist/internal/utils/pathparams.d.ts +1 -8
  4. package/dist/internal/utils/pathparams.js +11 -18
  5. package/dist/internal/utils/queryparams.d.ts +1 -2
  6. package/dist/internal/utils/queryparams.js +100 -50
  7. package/dist/internal/utils/requestbody.js +90 -57
  8. package/dist/internal/utils/security.js +69 -57
  9. package/dist/internal/utils/utils.d.ts +11 -2
  10. package/dist/internal/utils/utils.js +51 -15
  11. package/dist/sdk/dataset.js +11 -10
  12. package/dist/sdk/generation.js +11 -11
  13. package/dist/sdk/initimage.js +7 -6
  14. package/dist/sdk/model.js +7 -6
  15. package/dist/sdk/models/operations/createdataset.d.ts +2 -0
  16. package/dist/sdk/models/operations/createdataset.js +14 -4
  17. package/dist/sdk/models/operations/creategeneration.d.ts +2 -0
  18. package/dist/sdk/models/operations/creategeneration.js +42 -18
  19. package/dist/sdk/models/operations/createmodel.d.ts +2 -0
  20. package/dist/sdk/models/operations/createmodel.js +28 -11
  21. package/dist/sdk/models/operations/createvariationupscale.d.ts +2 -0
  22. package/dist/sdk/models/operations/createvariationupscale.js +12 -3
  23. package/dist/sdk/models/operations/deletedatasetbyid.d.ts +2 -0
  24. package/dist/sdk/models/operations/deletedatasetbyid.js +10 -2
  25. package/dist/sdk/models/operations/deletegenerationbyid.d.ts +2 -0
  26. package/dist/sdk/models/operations/deletegenerationbyid.js +10 -2
  27. package/dist/sdk/models/operations/deleteinitimagebyid.d.ts +2 -0
  28. package/dist/sdk/models/operations/deleteinitimagebyid.js +10 -2
  29. package/dist/sdk/models/operations/deletemodelbyid.d.ts +2 -0
  30. package/dist/sdk/models/operations/deletemodelbyid.js +10 -2
  31. package/dist/sdk/models/operations/getdatasetbyid.d.ts +2 -0
  32. package/dist/sdk/models/operations/getdatasetbyid.js +27 -10
  33. package/dist/sdk/models/operations/getgenerationbyid.d.ts +2 -0
  34. package/dist/sdk/models/operations/getgenerationbyid.js +60 -26
  35. package/dist/sdk/models/operations/getgenerationsbyuserid.d.ts +2 -0
  36. package/dist/sdk/models/operations/getgenerationsbyuserid.js +60 -26
  37. package/dist/sdk/models/operations/getinitimagebyid.d.ts +2 -0
  38. package/dist/sdk/models/operations/getinitimagebyid.js +14 -4
  39. package/dist/sdk/models/operations/getmodelbyid.d.ts +2 -0
  40. package/dist/sdk/models/operations/getmodelbyid.js +32 -13
  41. package/dist/sdk/models/operations/getuserself.d.ts +2 -0
  42. package/dist/sdk/models/operations/getuserself.js +17 -5
  43. package/dist/sdk/models/operations/getvariationbyid.d.ts +2 -0
  44. package/dist/sdk/models/operations/getvariationbyid.js +18 -6
  45. package/dist/sdk/models/operations/uploaddatasetimage.d.ts +2 -0
  46. package/dist/sdk/models/operations/uploaddatasetimage.js +18 -6
  47. package/dist/sdk/models/operations/uploaddatasetimagefromgen.d.ts +2 -0
  48. package/dist/sdk/models/operations/uploaddatasetimagefromgen.js +12 -3
  49. package/dist/sdk/models/operations/uploadinitimage.d.ts +2 -0
  50. package/dist/sdk/models/operations/uploadinitimage.js +20 -7
  51. package/dist/sdk/sdk.d.ts +2 -2
  52. package/dist/sdk/sdk.js +5 -4
  53. package/dist/sdk/user.js +4 -2
  54. package/dist/sdk/variation.js +5 -4
  55. package/package.json +2 -3
@@ -43,11 +43,17 @@ function parseSecurityClass(client, security) {
43
43
  var securityDecorator = parseSecurityDecorator(securityAnn);
44
44
  if (securityDecorator == null)
45
45
  return;
46
+ var value = security[fname];
46
47
  if (securityDecorator.Option) {
47
- return parseSecurityOption(client, security[fname]);
48
+ return parseSecurityOption(client, value);
48
49
  }
49
50
  else if (securityDecorator.Scheme) {
50
- return parseSecurityScheme(client, securityDecorator, security[fname]);
51
+ if (securityDecorator.SubType === "basic" && value !== Object(value)) {
52
+ return parseSecurityScheme(client, securityDecorator, security);
53
+ }
54
+ else {
55
+ client = parseSecurityScheme(client, securityDecorator, value);
56
+ }
51
57
  }
52
58
  });
53
59
  return client;
@@ -59,67 +65,73 @@ function parseSecurityOption(client, optionType) {
59
65
  if (securityAnn == null)
60
66
  return;
61
67
  var securityDecorator = parseSecurityDecorator(securityAnn);
62
- if (securityDecorator != null && securityDecorator.Scheme)
68
+ if (securityDecorator == null || !securityDecorator.Scheme)
63
69
  return;
64
- if (securityDecorator.Scheme) {
65
- return parseSecurityScheme(client, securityDecorator, optionType[fname]);
66
- }
70
+ return parseSecurityScheme(client, securityDecorator, optionType[fname]);
67
71
  });
68
72
  return client;
69
73
  }
70
74
  function parseSecurityScheme(client, schemeDecorator, scheme) {
71
- if (schemeDecorator.Type === "http" && schemeDecorator.SubType === "basic") {
72
- return parseBasicAuthScheme(client, scheme);
73
- }
74
- var fieldNames = Object.getOwnPropertyNames(scheme);
75
- fieldNames.forEach(function (fname) {
76
- var securityAnn = Reflect.getMetadata(securityMetadataKey, scheme, fname);
77
- if (securityAnn == null)
78
- return;
79
- var securityDecorator = parseSecurityDecorator(securityAnn);
80
- if (securityDecorator == null || securityDecorator.Name === "")
81
- return;
82
- switch (schemeDecorator.Type) {
83
- case "apiKey":
84
- switch (schemeDecorator.SubType) {
85
- case "header":
86
- client.defaults.headers.common[securityDecorator.Name] =
87
- scheme[fname];
88
- break;
89
- case "query":
90
- client.defaults.params[securityDecorator.Name] = scheme[fname];
91
- break;
92
- case "cookie":
93
- var securityDecoratorName = securityDecorator.Name;
94
- var val = scheme[fname];
95
- client.defaults.headers.common["Cookie"] = "".concat(securityDecoratorName, "=").concat(val);
96
- break;
97
- default:
98
- throw new Error("not supported");
99
- }
100
- break;
101
- case "openIdConnect":
102
- client.defaults.headers.common[securityDecorator.Name] = scheme[fname];
103
- break;
104
- case "oauth2":
105
- client.defaults.headers.common[securityDecorator.Name] = scheme[fname];
106
- break;
107
- case "http":
108
- switch (schemeDecorator.SubType) {
109
- case "basic":
110
- break;
111
- case "bearer":
112
- client.defaults.headers.common[securityDecorator.Name] =
113
- scheme[fname];
114
- break;
115
- default:
116
- throw new Error("not supported");
117
- }
118
- break;
119
- default:
120
- throw new Error("not supported");
75
+ if (scheme === Object(scheme)) {
76
+ if (schemeDecorator.Type === "http" &&
77
+ schemeDecorator.SubType === "basic") {
78
+ return parseBasicAuthScheme(client, scheme);
121
79
  }
122
- });
80
+ var fieldNames = Object.getOwnPropertyNames(scheme);
81
+ fieldNames.forEach(function (fname) {
82
+ var securityAnn = Reflect.getMetadata(securityMetadataKey, scheme, fname);
83
+ if (securityAnn == null)
84
+ return;
85
+ var securityDecorator = parseSecurityDecorator(securityAnn);
86
+ if (securityDecorator == null || securityDecorator.Name === "")
87
+ return;
88
+ client = parseSecuritySchemeValue(client, schemeDecorator, securityDecorator, scheme[fname]);
89
+ });
90
+ }
91
+ else {
92
+ client = parseSecuritySchemeValue(client, schemeDecorator, schemeDecorator, scheme);
93
+ }
94
+ return client;
95
+ }
96
+ function parseSecuritySchemeValue(client, schemeDecorator, securityDecorator, value) {
97
+ switch (schemeDecorator.Type) {
98
+ case "apiKey":
99
+ switch (schemeDecorator.SubType) {
100
+ case "header":
101
+ client.defaults.headers.common[securityDecorator.Name] = value;
102
+ break;
103
+ case "query":
104
+ client.defaults.params[securityDecorator.Name] = value;
105
+ break;
106
+ case "cookie":
107
+ var securityDecoratorName = securityDecorator.Name;
108
+ var val = value;
109
+ client.defaults.headers.common["Cookie"] = "".concat(securityDecoratorName, "=").concat(val);
110
+ break;
111
+ default:
112
+ throw new Error("not supported");
113
+ }
114
+ break;
115
+ case "openIdConnect":
116
+ client.defaults.headers.common[securityDecorator.Name] = value;
117
+ break;
118
+ case "oauth2":
119
+ client.defaults.headers.common[securityDecorator.Name] = value;
120
+ break;
121
+ case "http":
122
+ switch (schemeDecorator.SubType) {
123
+ case "basic":
124
+ break;
125
+ case "bearer":
126
+ client.defaults.headers.common[securityDecorator.Name] = value;
127
+ break;
128
+ default:
129
+ throw new Error("not supported");
130
+ }
131
+ break;
132
+ default:
133
+ throw new Error("not supported");
134
+ }
123
135
  return client;
124
136
  }
125
137
  function parseBasicAuthScheme(client, scheme) {
@@ -1,8 +1,15 @@
1
1
  import "reflect-metadata";
2
- import { ParamDecorator } from "./pathparams";
3
2
  export declare class SpeakeasyBase {
4
3
  constructor(payload?: Record<string | symbol, unknown>);
5
4
  }
5
+ export declare class ParamDecorator {
6
+ Style: string;
7
+ Explode: boolean;
8
+ ParamName: string;
9
+ Serialization?: string;
10
+ DateTimeFormat?: string;
11
+ constructor(Style: string, Explode: boolean, ParamName: string, Serialization?: string, DateTimeFormat?: string);
12
+ }
6
13
  export declare function SpeakeasyMetadata<T extends SpeakeasyBase = Record<string | symbol, unknown>>(params?: {
7
14
  data?: string;
8
15
  elemType?: {
@@ -10,10 +17,12 @@ export declare function SpeakeasyMetadata<T extends SpeakeasyBase = Record<strin
10
17
  };
11
18
  elemDepth?: number;
12
19
  }): PropertyDecorator;
13
- export declare function replaceParameters(stringWithParams: string, params: Map<string, string>): string;
20
+ export declare function templateUrl(stringWithParams: string, params: Record<string, string>): string;
14
21
  export declare function generateURL(serverURL: string, path: string, pathParams: any): string;
15
22
  export declare function parseParamDecorator(ann: string, fName: string, defaultStyle: string, defaultExplode: boolean): ParamDecorator;
16
23
  export declare function isStringRecord(obj: any): obj is Record<string, string>;
17
24
  export declare function isNumberRecord(obj: any): obj is Record<string, number>;
18
25
  export declare function isBooleanRecord(obj: any): obj is Record<string, boolean>;
19
26
  export declare function isEmpty(value: any): boolean;
27
+ export declare function convertIfDateObjectToISOString(value: any, dateTimeFormat?: string): any;
28
+ export declare function encodeAndConvertPrimitiveVal(value: any, dateTimeFormat?: string): any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmpty = exports.isBooleanRecord = exports.isNumberRecord = exports.isStringRecord = exports.parseParamDecorator = exports.generateURL = exports.replaceParameters = exports.SpeakeasyMetadata = exports.SpeakeasyBase = void 0;
3
+ exports.encodeAndConvertPrimitiveVal = exports.convertIfDateObjectToISOString = exports.isEmpty = exports.isBooleanRecord = exports.isNumberRecord = exports.isStringRecord = exports.parseParamDecorator = exports.generateURL = exports.templateUrl = exports.SpeakeasyMetadata = exports.ParamDecorator = exports.SpeakeasyBase = void 0;
4
4
  require("reflect-metadata");
5
5
  var pathparams_1 = require("./pathparams");
6
6
  function isSpeakeasyBase(type) {
@@ -83,6 +83,17 @@ var SpeakeasyBase = /** @class */ (function () {
83
83
  return SpeakeasyBase;
84
84
  }());
85
85
  exports.SpeakeasyBase = SpeakeasyBase;
86
+ var ParamDecorator = /** @class */ (function () {
87
+ function ParamDecorator(Style, Explode, ParamName, Serialization, DateTimeFormat) {
88
+ this.Style = Style;
89
+ this.Explode = Explode;
90
+ this.ParamName = ParamName;
91
+ this.Serialization = Serialization;
92
+ this.DateTimeFormat = DateTimeFormat;
93
+ }
94
+ return ParamDecorator;
95
+ }());
96
+ exports.ParamDecorator = ParamDecorator;
86
97
  function SpeakeasyMetadata(params) {
87
98
  return function (target, propertyKey) {
88
99
  if (params === null || params === void 0 ? void 0 : params.data) {
@@ -110,18 +121,19 @@ function SpeakeasyMetadata(params) {
110
121
  };
111
122
  }
112
123
  exports.SpeakeasyMetadata = SpeakeasyMetadata;
113
- function replaceParameters(stringWithParams, params) {
124
+ function templateUrl(stringWithParams, params) {
114
125
  var res = stringWithParams;
115
- params.forEach(function (value, key) {
126
+ Object.entries(params).forEach(function (_a) {
127
+ var key = _a[0], value = _a[1];
116
128
  var match = "{" + key + "}";
117
129
  res = res.replaceAll(match, value);
118
130
  });
119
131
  return res;
120
132
  }
121
- exports.replaceParameters = replaceParameters;
133
+ exports.templateUrl = templateUrl;
122
134
  function generateURL(serverURL, path, pathParams) {
123
135
  var url = serverURL.replace(/\/$/, "") + path;
124
- var parsedParameters = new Map();
136
+ var parsedParameters = {};
125
137
  var fieldNames = Object.getOwnPropertyNames(pathParams);
126
138
  fieldNames.forEach(function (fname) {
127
139
  var ppAnn = Reflect.getMetadata(pathparams_1.ppMetadataKey, pathParams, fname);
@@ -132,18 +144,20 @@ function generateURL(serverURL, path, pathParams) {
132
144
  return;
133
145
  switch (ppDecorator.Style) {
134
146
  case "simple":
135
- var simpleParams = (0, pathparams_1.getSimplePathParams)(ppDecorator.ParamName, pathParams[fname], ppDecorator.Explode);
147
+ var simpleParams = (0, pathparams_1.getSimplePathParams)(ppDecorator.ParamName, pathParams[fname], ppDecorator.Explode, ppDecorator.DateTimeFormat);
136
148
  simpleParams.forEach(function (value, key) {
137
- parsedParameters.set(key, value);
149
+ parsedParameters[key] = value;
138
150
  });
139
151
  }
140
152
  });
141
- return replaceParameters(url, parsedParameters);
153
+ return templateUrl(url, parsedParameters);
142
154
  }
143
155
  exports.generateURL = generateURL;
144
156
  function parseParamDecorator(ann, fName, defaultStyle, defaultExplode) {
145
157
  // style=simple;explode=false;name=apiID
146
- var decorator = new pathparams_1.ParamDecorator(defaultStyle, defaultExplode, fName.toLowerCase());
158
+ var decorator = new ParamDecorator(defaultStyle, defaultExplode, fName.toLowerCase());
159
+ if (ann == null)
160
+ return decorator;
147
161
  ann.split(";").forEach(function (annPart) {
148
162
  var _a = annPart.split("="), paramKey = _a[0], paramVal = _a[1];
149
163
  switch (paramKey) {
@@ -158,6 +172,9 @@ function parseParamDecorator(ann, fName, defaultStyle, defaultExplode) {
158
172
  break;
159
173
  case "serialization":
160
174
  decorator.Serialization = paramVal;
175
+ break;
176
+ case "dateTimeFormat":
177
+ decorator.DateTimeFormat = paramVal;
161
178
  }
162
179
  });
163
180
  return decorator;
@@ -168,8 +185,7 @@ function isStringRecord(obj) {
168
185
  return false;
169
186
  if (Object.getOwnPropertySymbols(obj).length > 0)
170
187
  return false;
171
- return Object.getOwnPropertyNames(obj)
172
- .every(function (prop) { return typeof obj[prop] === "string"; });
188
+ return Object.getOwnPropertyNames(obj).every(function (prop) { return typeof obj[prop] === "string"; });
173
189
  }
174
190
  exports.isStringRecord = isStringRecord;
175
191
  function isNumberRecord(obj) {
@@ -177,8 +193,7 @@ function isNumberRecord(obj) {
177
193
  return false;
178
194
  if (Object.getOwnPropertySymbols(obj).length > 0)
179
195
  return false;
180
- return Object.getOwnPropertyNames(obj)
181
- .every(function (prop) { return typeof obj[prop] === "number"; });
196
+ return Object.getOwnPropertyNames(obj).every(function (prop) { return typeof obj[prop] === "number"; });
182
197
  }
183
198
  exports.isNumberRecord = isNumberRecord;
184
199
  function isBooleanRecord(obj) {
@@ -186,8 +201,7 @@ function isBooleanRecord(obj) {
186
201
  return false;
187
202
  if (Object.getOwnPropertySymbols(obj).length > 0)
188
203
  return false;
189
- return Object.getOwnPropertyNames(obj)
190
- .every(function (prop) { return typeof obj[prop] === "boolean"; });
204
+ return Object.getOwnPropertyNames(obj).every(function (prop) { return typeof obj[prop] === "boolean"; });
191
205
  }
192
206
  exports.isBooleanRecord = isBooleanRecord;
193
207
  function isEmpty(value) {
@@ -200,3 +214,25 @@ function isEmpty(value) {
200
214
  return res || value == null;
201
215
  }
202
216
  exports.isEmpty = isEmpty;
217
+ // If value is Date type, serialize as ISO string since Date constructor creates from system clock
218
+ function convertIfDateObjectToISOString(value, dateTimeFormat) {
219
+ var dtFormat = dateTimeFormat !== null && dateTimeFormat !== void 0 ? dateTimeFormat : "YYYY-MM-DDThh:mm:ss.sssZ";
220
+ if (value instanceof Date) {
221
+ if (dtFormat === "YYYY-MM-DD") {
222
+ var dateRegex = /^(\d{4})-(\d{2})-(\d{2})/;
223
+ var _a = value
224
+ .toISOString()
225
+ .match(dateRegex), _ = _a[0], year = _a[1], month = _a[2], day = _a[3];
226
+ return "".concat(year, "-").concat(month, "-").concat(day);
227
+ }
228
+ if (dtFormat === "YYYY-MM-DDThh:mm:ss.sssZ") {
229
+ return value.toISOString();
230
+ }
231
+ }
232
+ return value;
233
+ }
234
+ exports.convertIfDateObjectToISOString = convertIfDateObjectToISOString;
235
+ function encodeAndConvertPrimitiveVal(value, dateTimeFormat) {
236
+ return encodeURIComponent(convertIfDateObjectToISOString(value, dateTimeFormat));
237
+ }
238
+ exports.encodeAndConvertPrimitiveVal = encodeAndConvertPrimitiveVal;
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.Dataset = void 0;
38
38
  var utils = __importStar(require("../internal/utils"));
39
39
  var operations = __importStar(require("./models/operations"));
40
+ var class_transformer_1 = require("class-transformer");
40
41
  var Dataset = /** @class */ (function () {
41
42
  function Dataset(defaultClient, securityClient, serverURL, language, sdkVersion, genVersion) {
42
43
  this._defaultClient = defaultClient;
@@ -77,11 +78,11 @@ var Dataset = /** @class */ (function () {
77
78
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
78
79
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
79
80
  throw new Error("status code not found in response: ".concat(httpRes));
80
- var res = { statusCode: httpRes.status, contentType: contentType };
81
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
81
82
  switch (true) {
82
83
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
83
84
  if (utils.matchContentType(contentType, "application/json")) {
84
- res.createDataset200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
85
+ res.createDataset200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.CreateDataset200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
85
86
  }
86
87
  break;
87
88
  }
@@ -106,11 +107,11 @@ var Dataset = /** @class */ (function () {
106
107
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
107
108
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
108
109
  throw new Error("status code not found in response: ".concat(httpRes));
109
- var res = { statusCode: httpRes.status, contentType: contentType };
110
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
110
111
  switch (true) {
111
112
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
112
113
  if (utils.matchContentType(contentType, "application/json")) {
113
- res.deleteDatasetById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
114
+ res.deleteDatasetById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.DeleteDatasetById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
114
115
  }
115
116
  break;
116
117
  }
@@ -135,11 +136,11 @@ var Dataset = /** @class */ (function () {
135
136
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
136
137
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
137
138
  throw new Error("status code not found in response: ".concat(httpRes));
138
- var res = { statusCode: httpRes.status, contentType: contentType };
139
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
139
140
  switch (true) {
140
141
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
141
142
  if (utils.matchContentType(contentType, "application/json")) {
142
- res.getDatasetById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
143
+ res.getDatasetById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.GetDatasetById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
143
144
  }
144
145
  break;
145
146
  }
@@ -177,11 +178,11 @@ var Dataset = /** @class */ (function () {
177
178
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
178
179
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
179
180
  throw new Error("status code not found in response: ".concat(httpRes));
180
- var res = { statusCode: httpRes.status, contentType: contentType };
181
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
181
182
  switch (true) {
182
183
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
183
184
  if (utils.matchContentType(contentType, "application/json")) {
184
- res.uploadDatasetImage200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
185
+ res.uploadDatasetImage200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.UploadDatasetImage200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
185
186
  }
186
187
  break;
187
188
  }
@@ -219,11 +220,11 @@ var Dataset = /** @class */ (function () {
219
220
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
220
221
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
221
222
  throw new Error("status code not found in response: ".concat(httpRes));
222
- var res = { statusCode: httpRes.status, contentType: contentType };
223
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
223
224
  switch (true) {
224
225
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
225
226
  if (utils.matchContentType(contentType, "application/json")) {
226
- res.uploadDatasetImageFromGen200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
227
+ res.uploadDatasetImageFromGen200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.UploadDatasetImageFromGen200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
227
228
  }
228
229
  break;
229
230
  }
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.Generation = void 0;
38
38
  var utils = __importStar(require("../internal/utils"));
39
39
  var operations = __importStar(require("./models/operations"));
40
+ var class_transformer_1 = require("class-transformer");
40
41
  var Generation = /** @class */ (function () {
41
42
  function Generation(defaultClient, securityClient, serverURL, language, sdkVersion, genVersion) {
42
43
  this._defaultClient = defaultClient;
@@ -77,11 +78,11 @@ var Generation = /** @class */ (function () {
77
78
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
78
79
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
79
80
  throw new Error("status code not found in response: ".concat(httpRes));
80
- var res = { statusCode: httpRes.status, contentType: contentType };
81
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
81
82
  switch (true) {
82
83
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
83
84
  if (utils.matchContentType(contentType, "application/json")) {
84
- res.createGeneration200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
85
+ res.createGeneration200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.CreateGeneration200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
85
86
  }
86
87
  break;
87
88
  }
@@ -106,11 +107,11 @@ var Generation = /** @class */ (function () {
106
107
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
107
108
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
108
109
  throw new Error("status code not found in response: ".concat(httpRes));
109
- var res = { statusCode: httpRes.status, contentType: contentType };
110
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
110
111
  switch (true) {
111
112
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
112
113
  if (utils.matchContentType(contentType, "application/json")) {
113
- res.deleteGenerationById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
114
+ res.deleteGenerationById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.DeleteGenerationById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
114
115
  }
115
116
  break;
116
117
  }
@@ -135,11 +136,11 @@ var Generation = /** @class */ (function () {
135
136
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
136
137
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
137
138
  throw new Error("status code not found in response: ".concat(httpRes));
138
- var res = { statusCode: httpRes.status, contentType: contentType };
139
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
139
140
  switch (true) {
140
141
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
141
142
  if (utils.matchContentType(contentType, "application/json")) {
142
- res.getGenerationById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
143
+ res.getGenerationById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.GetGenerationById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
143
144
  }
144
145
  break;
145
146
  }
@@ -158,19 +159,18 @@ var Generation = /** @class */ (function () {
158
159
  var baseURL = this._serverURL;
159
160
  var url = utils.generateURL(baseURL, "/generations/user/{userId}", req.pathParams);
160
161
  var client = this._securityClient;
161
- var qpSerializer = utils.getQueryParamSerializer(req.queryParams);
162
- var requestConfig = __assign(__assign({}, config), { params: req.queryParams, paramsSerializer: qpSerializer });
163
- var r = client.request(__assign({ url: url, method: "get" }, requestConfig));
162
+ var queryParams = utils.serializeQueryParams(req.queryParams);
163
+ var r = client.request(__assign({ url: url + queryParams, method: "get" }, config));
164
164
  return r.then(function (httpRes) {
165
165
  var _a, _b;
166
166
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
167
167
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
168
168
  throw new Error("status code not found in response: ".concat(httpRes));
169
- var res = { statusCode: httpRes.status, contentType: contentType };
169
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
170
170
  switch (true) {
171
171
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
172
172
  if (utils.matchContentType(contentType, "application/json")) {
173
- res.getGenerationsByUserId200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
173
+ res.getGenerationsByUserId200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.GetGenerationsByUserId200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
174
174
  }
175
175
  break;
176
176
  }
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.InitImage = void 0;
38
38
  var utils = __importStar(require("../internal/utils"));
39
39
  var operations = __importStar(require("./models/operations"));
40
+ var class_transformer_1 = require("class-transformer");
40
41
  var InitImage = /** @class */ (function () {
41
42
  function InitImage(defaultClient, securityClient, serverURL, language, sdkVersion, genVersion) {
42
43
  this._defaultClient = defaultClient;
@@ -64,11 +65,11 @@ var InitImage = /** @class */ (function () {
64
65
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
65
66
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
66
67
  throw new Error("status code not found in response: ".concat(httpRes));
67
- var res = { statusCode: httpRes.status, contentType: contentType };
68
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
68
69
  switch (true) {
69
70
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
70
71
  if (utils.matchContentType(contentType, "application/json")) {
71
- res.deleteInitImageById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
72
+ res.deleteInitImageById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.DeleteInitImageById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
72
73
  }
73
74
  break;
74
75
  }
@@ -93,11 +94,11 @@ var InitImage = /** @class */ (function () {
93
94
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
94
95
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
95
96
  throw new Error("status code not found in response: ".concat(httpRes));
96
- var res = { statusCode: httpRes.status, contentType: contentType };
97
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
97
98
  switch (true) {
98
99
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
99
100
  if (utils.matchContentType(contentType, "application/json")) {
100
- res.getInitImageById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
101
+ res.getInitImageById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.GetInitImageById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
101
102
  }
102
103
  break;
103
104
  }
@@ -135,11 +136,11 @@ var InitImage = /** @class */ (function () {
135
136
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
136
137
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
137
138
  throw new Error("status code not found in response: ".concat(httpRes));
138
- var res = { statusCode: httpRes.status, contentType: contentType };
139
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
139
140
  switch (true) {
140
141
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
141
142
  if (utils.matchContentType(contentType, "application/json")) {
142
- res.uploadInitImage200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
143
+ res.uploadInitImage200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.UploadInitImage200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
143
144
  }
144
145
  break;
145
146
  }
package/dist/sdk/model.js CHANGED
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.Model = void 0;
38
38
  var utils = __importStar(require("../internal/utils"));
39
39
  var operations = __importStar(require("./models/operations"));
40
+ var class_transformer_1 = require("class-transformer");
40
41
  var Model = /** @class */ (function () {
41
42
  function Model(defaultClient, securityClient, serverURL, language, sdkVersion, genVersion) {
42
43
  this._defaultClient = defaultClient;
@@ -77,11 +78,11 @@ var Model = /** @class */ (function () {
77
78
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
78
79
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
79
80
  throw new Error("status code not found in response: ".concat(httpRes));
80
- var res = { statusCode: httpRes.status, contentType: contentType };
81
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
81
82
  switch (true) {
82
83
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
83
84
  if (utils.matchContentType(contentType, "application/json")) {
84
- res.createModel200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
85
+ res.createModel200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.CreateModel200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
85
86
  }
86
87
  break;
87
88
  }
@@ -106,11 +107,11 @@ var Model = /** @class */ (function () {
106
107
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
107
108
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
108
109
  throw new Error("status code not found in response: ".concat(httpRes));
109
- var res = { statusCode: httpRes.status, contentType: contentType };
110
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
110
111
  switch (true) {
111
112
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
112
113
  if (utils.matchContentType(contentType, "application/json")) {
113
- res.deleteModelById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
114
+ res.deleteModelById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.DeleteModelById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
114
115
  }
115
116
  break;
116
117
  }
@@ -135,11 +136,11 @@ var Model = /** @class */ (function () {
135
136
  var contentType = (_b = (_a = httpRes === null || httpRes === void 0 ? void 0 : httpRes.headers) === null || _a === void 0 ? void 0 : _a["content-type"]) !== null && _b !== void 0 ? _b : "";
136
137
  if ((httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == null)
137
138
  throw new Error("status code not found in response: ".concat(httpRes));
138
- var res = { statusCode: httpRes.status, contentType: contentType };
139
+ var res = { statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes };
139
140
  switch (true) {
140
141
  case (httpRes === null || httpRes === void 0 ? void 0 : httpRes.status) == 200:
141
142
  if (utils.matchContentType(contentType, "application/json")) {
142
- res.getModelById200ApplicationJSONObject = httpRes === null || httpRes === void 0 ? void 0 : httpRes.data;
143
+ res.getModelById200ApplicationJSONObject = (0, class_transformer_1.plainToInstance)(operations.GetModelById200ApplicationJSON, httpRes === null || httpRes === void 0 ? void 0 : httpRes.data, { excludeExtraneousValues: true });
143
144
  }
144
145
  break;
145
146
  }
@@ -1,4 +1,5 @@
1
1
  import { SpeakeasyBase } from "../../../internal/utils";
2
+ import { AxiosResponse } from "axios";
2
3
  export declare class CreateDatasetRequestBody extends SpeakeasyBase {
3
4
  description?: string;
4
5
  name: string;
@@ -18,5 +19,6 @@ export declare class CreateDataset200ApplicationJSON extends SpeakeasyBase {
18
19
  export declare class CreateDatasetResponse extends SpeakeasyBase {
19
20
  contentType: string;
20
21
  statusCode: number;
22
+ rawResponse?: AxiosResponse;
21
23
  createDataset200ApplicationJSONObject?: CreateDataset200ApplicationJSON;
22
24
  }
@@ -26,17 +26,20 @@ var __metadata = (this && this.__metadata) || function (k, v) {
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.CreateDatasetResponse = exports.CreateDataset200ApplicationJSON = exports.CreateDataset200ApplicationJSONDatasets = exports.CreateDatasetRequest = exports.CreateDatasetRequestBody = void 0;
28
28
  var utils_1 = require("../../../internal/utils");
29
+ var class_transformer_1 = require("class-transformer");
29
30
  var CreateDatasetRequestBody = /** @class */ (function (_super) {
30
31
  __extends(CreateDatasetRequestBody, _super);
31
32
  function CreateDatasetRequestBody() {
32
33
  return _super !== null && _super.apply(this, arguments) || this;
33
34
  }
34
35
  __decorate([
35
- (0, utils_1.SpeakeasyMetadata)({ data: "json, name=description" }),
36
+ (0, utils_1.SpeakeasyMetadata)(),
37
+ (0, class_transformer_1.Expose)({ name: "description" }),
36
38
  __metadata("design:type", String)
37
39
  ], CreateDatasetRequestBody.prototype, "description", void 0);
38
40
  __decorate([
39
- (0, utils_1.SpeakeasyMetadata)({ data: "json, name=name" }),
41
+ (0, utils_1.SpeakeasyMetadata)(),
42
+ (0, class_transformer_1.Expose)({ name: "name" }),
40
43
  __metadata("design:type", String)
41
44
  ], CreateDatasetRequestBody.prototype, "name", void 0);
42
45
  return CreateDatasetRequestBody;
@@ -64,7 +67,8 @@ var CreateDataset200ApplicationJSONDatasets = /** @class */ (function (_super) {
64
67
  return _super !== null && _super.apply(this, arguments) || this;
65
68
  }
66
69
  __decorate([
67
- (0, utils_1.SpeakeasyMetadata)({ data: "json, name=id" }),
70
+ (0, utils_1.SpeakeasyMetadata)(),
71
+ (0, class_transformer_1.Expose)({ name: "id" }),
68
72
  __metadata("design:type", String)
69
73
  ], CreateDataset200ApplicationJSONDatasets.prototype, "id", void 0);
70
74
  return CreateDataset200ApplicationJSONDatasets;
@@ -76,7 +80,9 @@ var CreateDataset200ApplicationJSON = /** @class */ (function (_super) {
76
80
  return _super !== null && _super.apply(this, arguments) || this;
77
81
  }
78
82
  __decorate([
79
- (0, utils_1.SpeakeasyMetadata)({ data: "json, name=insert_datasets_one" }),
83
+ (0, utils_1.SpeakeasyMetadata)(),
84
+ (0, class_transformer_1.Expose)({ name: "insert_datasets_one" }),
85
+ (0, class_transformer_1.Type)(function () { return CreateDataset200ApplicationJSONDatasets; }),
80
86
  __metadata("design:type", CreateDataset200ApplicationJSONDatasets)
81
87
  ], CreateDataset200ApplicationJSON.prototype, "insertDatasetsOne", void 0);
82
88
  return CreateDataset200ApplicationJSON;
@@ -95,6 +101,10 @@ var CreateDatasetResponse = /** @class */ (function (_super) {
95
101
  (0, utils_1.SpeakeasyMetadata)(),
96
102
  __metadata("design:type", Number)
97
103
  ], CreateDatasetResponse.prototype, "statusCode", void 0);
104
+ __decorate([
105
+ (0, utils_1.SpeakeasyMetadata)(),
106
+ __metadata("design:type", Object)
107
+ ], CreateDatasetResponse.prototype, "rawResponse", void 0);
98
108
  __decorate([
99
109
  (0, utils_1.SpeakeasyMetadata)(),
100
110
  __metadata("design:type", CreateDataset200ApplicationJSON)