honeyhive 1.0.19 → 1.0.20

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 (220) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +20 -0
  3. package/dist/internal/utils/contenttype.d.ts +1 -0
  4. package/dist/internal/utils/contenttype.js +33 -0
  5. package/dist/internal/utils/headers.d.ts +4 -0
  6. package/dist/internal/utils/headers.js +92 -0
  7. package/dist/internal/utils/index.d.ts +8 -0
  8. package/dist/internal/utils/index.js +27 -0
  9. package/dist/internal/utils/pathparams.d.ts +2 -0
  10. package/dist/internal/utils/pathparams.js +53 -0
  11. package/dist/internal/utils/queryparams.d.ts +2 -0
  12. package/dist/internal/utils/queryparams.js +182 -0
  13. package/dist/internal/utils/requestbody.d.ts +2 -0
  14. package/dist/internal/utils/requestbody.js +328 -0
  15. package/dist/internal/utils/retries.d.ts +20 -0
  16. package/dist/internal/utils/retries.js +250 -0
  17. package/dist/internal/utils/security.d.ts +5 -0
  18. package/dist/internal/utils/security.js +196 -0
  19. package/dist/internal/utils/utils.d.ts +37 -0
  20. package/dist/internal/utils/utils.js +368 -0
  21. package/dist/models/components/configuration.d.ts +44 -0
  22. package/dist/models/components/configuration.js +94 -0
  23. package/dist/models/components/createdatapointrequest.d.ts +31 -0
  24. package/dist/models/components/createdatapointrequest.js +75 -0
  25. package/dist/models/components/createdatasetrequest.d.ts +50 -0
  26. package/dist/models/components/createdatasetrequest.js +101 -0
  27. package/dist/models/components/createeventrequest.d.ts +87 -0
  28. package/dist/models/components/createeventrequest.js +144 -0
  29. package/dist/models/components/createmodelevent.d.ts +71 -0
  30. package/dist/models/components/createmodelevent.js +125 -0
  31. package/dist/models/components/createprojectrequest.d.ts +5 -0
  32. package/dist/models/components/createprojectrequest.js +50 -0
  33. package/dist/models/components/createrunrequest.d.ts +42 -0
  34. package/dist/models/components/createrunrequest.js +88 -0
  35. package/dist/models/components/createrunresponse.d.ts +6 -0
  36. package/dist/models/components/createrunresponse.js +52 -0
  37. package/dist/models/components/createtoolrequest.d.ts +18 -0
  38. package/dist/models/components/createtoolrequest.js +70 -0
  39. package/dist/models/components/datapoint.d.ts +41 -0
  40. package/dist/models/components/datapoint.js +118 -0
  41. package/dist/models/components/dataset.d.ts +58 -0
  42. package/dist/models/components/dataset.js +119 -0
  43. package/dist/models/components/datasetupdate.d.ts +27 -0
  44. package/dist/models/components/datasetupdate.js +70 -0
  45. package/dist/models/components/deleterunresponse.d.ts +5 -0
  46. package/dist/models/components/deleterunresponse.js +50 -0
  47. package/dist/models/components/evaluationrun.d.ts +50 -0
  48. package/dist/models/components/evaluationrun.js +116 -0
  49. package/dist/models/components/event.d.ts +88 -0
  50. package/dist/models/components/event.js +145 -0
  51. package/dist/models/components/eventfilter.d.ts +38 -0
  52. package/dist/models/components/eventfilter.js +81 -0
  53. package/dist/models/components/getrunresponse.d.ts +5 -0
  54. package/dist/models/components/getrunresponse.js +47 -0
  55. package/dist/models/components/getrunsresponse.d.ts +5 -0
  56. package/dist/models/components/getrunsresponse.js +47 -0
  57. package/dist/models/components/index.d.ts +31 -0
  58. package/dist/models/components/index.js +50 -0
  59. package/dist/models/components/metric.d.ts +86 -0
  60. package/dist/models/components/metric.js +155 -0
  61. package/dist/models/components/metricedit.d.ts +91 -0
  62. package/dist/models/components/metricedit.js +160 -0
  63. package/dist/models/components/postconfigurationrequest.d.ts +29 -0
  64. package/dist/models/components/postconfigurationrequest.js +76 -0
  65. package/dist/models/components/project.d.ts +6 -0
  66. package/dist/models/components/project.js +55 -0
  67. package/dist/models/components/putconfigurationrequest.d.ts +40 -0
  68. package/dist/models/components/putconfigurationrequest.js +89 -0
  69. package/dist/models/components/security.d.ts +4 -0
  70. package/dist/models/components/security.js +45 -0
  71. package/dist/models/components/sessionstartrequest.d.ts +67 -0
  72. package/dist/models/components/sessionstartrequest.js +120 -0
  73. package/dist/models/components/tool.d.ts +19 -0
  74. package/dist/models/components/tool.js +75 -0
  75. package/dist/models/components/updatedatapointrequest.d.ts +27 -0
  76. package/dist/models/components/updatedatapointrequest.js +70 -0
  77. package/dist/models/components/updateprojectrequest.d.ts +6 -0
  78. package/dist/models/components/updateprojectrequest.js +55 -0
  79. package/dist/models/components/updaterunrequest.d.ts +32 -0
  80. package/dist/models/components/updaterunrequest.js +80 -0
  81. package/dist/models/components/updaterunresponse.d.ts +11 -0
  82. package/dist/models/components/updaterunresponse.js +50 -0
  83. package/dist/models/components/updatetoolrequest.d.ts +7 -0
  84. package/dist/models/components/updatetoolrequest.js +60 -0
  85. package/dist/models/errors/createeventbatch.d.ts +14 -0
  86. package/dist/models/errors/createeventbatch.js +70 -0
  87. package/dist/models/errors/createmodeleventbatch.d.ts +14 -0
  88. package/dist/models/errors/createmodeleventbatch.js +70 -0
  89. package/dist/models/errors/index.d.ts +3 -0
  90. package/dist/models/errors/index.js +22 -0
  91. package/dist/models/errors/sdkerror.d.ts +7 -0
  92. package/dist/models/errors/sdkerror.js +40 -0
  93. package/dist/models/operations/adddatapoints.d.ts +68 -0
  94. package/dist/models/operations/adddatapoints.js +143 -0
  95. package/dist/models/operations/createconfiguration.d.ts +16 -0
  96. package/dist/models/operations/createconfiguration.js +51 -0
  97. package/dist/models/operations/createdatapoint.d.ts +29 -0
  98. package/dist/models/operations/createdatapoint.js +86 -0
  99. package/dist/models/operations/createdataset.d.ts +33 -0
  100. package/dist/models/operations/createdataset.js +91 -0
  101. package/dist/models/operations/createevent.d.ts +31 -0
  102. package/dist/models/operations/createevent.js +115 -0
  103. package/dist/models/operations/createeventbatch.d.ts +36 -0
  104. package/dist/models/operations/createeventbatch.js +125 -0
  105. package/dist/models/operations/createmetric.d.ts +16 -0
  106. package/dist/models/operations/createmetric.js +51 -0
  107. package/dist/models/operations/createmodelevent.d.ts +31 -0
  108. package/dist/models/operations/createmodelevent.js +115 -0
  109. package/dist/models/operations/createmodeleventbatch.d.ts +31 -0
  110. package/dist/models/operations/createmodeleventbatch.js +115 -0
  111. package/dist/models/operations/createproject.d.ts +21 -0
  112. package/dist/models/operations/createproject.js +79 -0
  113. package/dist/models/operations/createrun.d.ts +21 -0
  114. package/dist/models/operations/createrun.js +79 -0
  115. package/dist/models/operations/createtool.d.ts +29 -0
  116. package/dist/models/operations/createtool.js +86 -0
  117. package/dist/models/operations/deleteconfiguration.d.ts +22 -0
  118. package/dist/models/operations/deleteconfiguration.js +63 -0
  119. package/dist/models/operations/deletedatapoint.d.ts +32 -0
  120. package/dist/models/operations/deletedatapoint.js +84 -0
  121. package/dist/models/operations/deletedataset.d.ts +22 -0
  122. package/dist/models/operations/deletedataset.js +63 -0
  123. package/dist/models/operations/deletemetric.d.ts +19 -0
  124. package/dist/models/operations/deletemetric.js +63 -0
  125. package/dist/models/operations/deleteproject.d.ts +19 -0
  126. package/dist/models/operations/deleteproject.js +63 -0
  127. package/dist/models/operations/deleterun.d.ts +24 -0
  128. package/dist/models/operations/deleterun.js +91 -0
  129. package/dist/models/operations/deletetool.d.ts +19 -0
  130. package/dist/models/operations/deletetool.js +63 -0
  131. package/dist/models/operations/getconfigurations.d.ts +43 -0
  132. package/dist/models/operations/getconfigurations.js +108 -0
  133. package/dist/models/operations/getdatapoint.d.ts +33 -0
  134. package/dist/models/operations/getdatapoint.js +109 -0
  135. package/dist/models/operations/getdatapoints.d.ts +41 -0
  136. package/dist/models/operations/getdatapoints.js +117 -0
  137. package/dist/models/operations/getdatasets.d.ts +48 -0
  138. package/dist/models/operations/getdatasets.js +125 -0
  139. package/dist/models/operations/getevents.d.ts +57 -0
  140. package/dist/models/operations/getevents.js +155 -0
  141. package/dist/models/operations/getmetrics.d.ts +27 -0
  142. package/dist/models/operations/getmetrics.js +91 -0
  143. package/dist/models/operations/getprojects.d.ts +24 -0
  144. package/dist/models/operations/getprojects.js +91 -0
  145. package/dist/models/operations/getrun.d.ts +24 -0
  146. package/dist/models/operations/getrun.js +91 -0
  147. package/dist/models/operations/getruns.d.ts +24 -0
  148. package/dist/models/operations/getruns.js +91 -0
  149. package/dist/models/operations/getsession.d.ts +24 -0
  150. package/dist/models/operations/getsession.js +91 -0
  151. package/dist/models/operations/gettools.d.ts +21 -0
  152. package/dist/models/operations/gettools.js +79 -0
  153. package/dist/models/operations/index.d.ts +39 -0
  154. package/dist/models/operations/index.js +58 -0
  155. package/dist/models/operations/startsession.d.ts +30 -0
  156. package/dist/models/operations/startsession.js +110 -0
  157. package/dist/models/operations/updateconfiguration.d.ts +24 -0
  158. package/dist/models/operations/updateconfiguration.js +91 -0
  159. package/dist/models/operations/updatedatapoint.d.ts +24 -0
  160. package/dist/models/operations/updatedatapoint.js +91 -0
  161. package/dist/models/operations/updatedataset.d.ts +16 -0
  162. package/dist/models/operations/updatedataset.js +51 -0
  163. package/dist/models/operations/updateevent.d.ts +26 -0
  164. package/dist/models/operations/updateevent.js +100 -0
  165. package/dist/models/operations/updatemetric.d.ts +16 -0
  166. package/dist/models/operations/updatemetric.js +51 -0
  167. package/dist/models/operations/updateproject.d.ts +16 -0
  168. package/dist/models/operations/updateproject.js +51 -0
  169. package/dist/models/operations/updaterun.d.ts +25 -0
  170. package/dist/models/operations/updaterun.js +95 -0
  171. package/dist/models/operations/updatetool.d.ts +16 -0
  172. package/dist/models/operations/updatetool.js +51 -0
  173. package/dist/sdk/configurations.d.ts +24 -0
  174. package/dist/sdk/configurations.js +356 -0
  175. package/dist/sdk/datapoints.d.ts +28 -0
  176. package/dist/sdk/datapoints.js +430 -0
  177. package/dist/sdk/datasets.d.ts +28 -0
  178. package/dist/sdk/datasets.js +435 -0
  179. package/dist/sdk/events.d.ts +43 -0
  180. package/dist/sdk/events.js +567 -0
  181. package/dist/sdk/index.d.ts +2 -0
  182. package/dist/sdk/index.js +21 -0
  183. package/dist/sdk/metrics.d.ts +36 -0
  184. package/dist/sdk/metrics.js +366 -0
  185. package/dist/sdk/projects.d.ts +24 -0
  186. package/dist/sdk/projects.js +361 -0
  187. package/dist/sdk/runs.d.ts +28 -0
  188. package/dist/sdk/runs.js +439 -0
  189. package/dist/sdk/sdk.d.ts +64 -0
  190. package/dist/sdk/sdk.js +90 -0
  191. package/dist/sdk/session.d.ts +15 -0
  192. package/dist/sdk/session.js +237 -0
  193. package/dist/sdk/telemetry.d.ts +21 -0
  194. package/dist/sdk/telemetry.js +243 -0
  195. package/dist/sdk/tools.d.ts +24 -0
  196. package/dist/sdk/tools.js +357 -0
  197. package/dist/sdk/tracer.d.ts +26 -0
  198. package/dist/sdk/tracer.js +308 -0
  199. package/dist/types/index.d.ts +1 -0
  200. package/dist/types/index.js +20 -0
  201. package/dist/types/rfcdate.d.ts +9 -0
  202. package/dist/types/rfcdate.js +59 -0
  203. package/funcs/runsCreateRun.d.ts.map +1 -1
  204. package/funcs/runsCreateRun.js +2 -1
  205. package/funcs/runsCreateRun.js.map +1 -1
  206. package/funcs/runsUpdateRun.d.ts +1 -1
  207. package/funcs/runsUpdateRun.d.ts.map +1 -1
  208. package/funcs/runsUpdateRun.js +2 -2
  209. package/funcs/runsUpdateRun.js.map +1 -1
  210. package/package.json +4 -3
  211. package/sdk/evaluation.d.ts +7 -1
  212. package/sdk/evaluation.d.ts.map +1 -1
  213. package/sdk/evaluation.js +52 -5
  214. package/sdk/evaluation.js.map +1 -1
  215. package/sdk/runs.d.ts +1 -1
  216. package/sdk/runs.d.ts.map +1 -1
  217. package/sdk/runs.js +2 -2
  218. package/sdk/runs.js.map +1 -1
  219. package/src/sdk/evaluation.ts +38 -8
  220. package/tests/openai_test.ts +72 -0
@@ -0,0 +1 @@
1
+ export * from "./sdk";
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./sdk"), exports);
@@ -0,0 +1 @@
1
+ export declare function matchContentType(contentType: string, pattern: string): boolean;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.matchContentType = void 0;
7
+ function matchContentType(contentType, pattern) {
8
+ var res = false;
9
+ contentType
10
+ .split(";")
11
+ .map(function (ctPart) {
12
+ return ctPart.trim();
13
+ })
14
+ .forEach(function (ctPart) {
15
+ if (ctPart === pattern || pattern === "*" || pattern === "*/*") {
16
+ res = true;
17
+ return;
18
+ }
19
+ if (ctPart === pattern) {
20
+ res = true;
21
+ return;
22
+ }
23
+ var parts = ctPart.split("/");
24
+ if (parts.length === 2) {
25
+ if ("".concat(parts[0], "/*") === pattern || "*/".concat(parts[1]) === pattern) {
26
+ res = true;
27
+ return;
28
+ }
29
+ }
30
+ });
31
+ return res;
32
+ }
33
+ 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,92 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getHeadersFromResponse = exports.getHeadersFromRequest = exports.headerMetadataKey = void 0;
7
+ var utils_1 = require("./utils");
8
+ var requestbody_1 = require("./requestbody");
9
+ exports.headerMetadataKey = "header";
10
+ function getHeadersFromRequest(headerParams) {
11
+ if (headerParams == null)
12
+ return;
13
+ var headers = {};
14
+ var fieldNames = Object.getOwnPropertyNames(headerParams);
15
+ fieldNames.forEach(function (fname) {
16
+ var requestBodyAnn = Reflect.getMetadata(requestbody_1.requestMetadataKey, headerParams, fname);
17
+ if (requestBodyAnn)
18
+ return;
19
+ var headerAnn = Reflect.getMetadata(exports.headerMetadataKey, headerParams, fname);
20
+ if (headerAnn == null)
21
+ return;
22
+ var headerDecorator = (0, utils_1.parseParamDecorator)(headerAnn, fname, "simple", false);
23
+ if (headerDecorator == null)
24
+ return;
25
+ var value = serializeHeader(headerParams[fname], headerDecorator.Explode);
26
+ if (value != "")
27
+ headers[headerDecorator.ParamName] = value;
28
+ });
29
+ return headers;
30
+ }
31
+ exports.getHeadersFromRequest = getHeadersFromRequest;
32
+ function getHeadersFromResponse(headers) {
33
+ var reponseHeaders = {};
34
+ Object.keys(headers).forEach(function (key) {
35
+ var value = headers[key];
36
+ if (!value)
37
+ return;
38
+ if (Array.isArray(value)) {
39
+ var h_1 = [];
40
+ value.forEach(function (val) {
41
+ if (val) {
42
+ h_1.push(String(val));
43
+ }
44
+ });
45
+ reponseHeaders[key] = h_1;
46
+ }
47
+ else {
48
+ reponseHeaders[key] = [value];
49
+ }
50
+ });
51
+ return reponseHeaders;
52
+ }
53
+ exports.getHeadersFromResponse = getHeadersFromResponse;
54
+ function serializeHeader(header, explode) {
55
+ var headerVals = [];
56
+ if (Array.isArray(header)) {
57
+ header.forEach(function (val) {
58
+ headerVals.push((0, utils_1.valToString)(val));
59
+ });
60
+ }
61
+ else if ((0, utils_1.isStringRecord)(header) ||
62
+ (0, utils_1.isNumberRecord)(header) ||
63
+ (0, utils_1.isBooleanRecord)(header)) {
64
+ Object.getOwnPropertyNames(header).forEach(function (headerKey) {
65
+ if (explode)
66
+ headerVals.push("".concat(headerKey, "=").concat((0, utils_1.valToString)(header[headerKey])));
67
+ else
68
+ headerVals.push("".concat(headerKey, ",").concat((0, utils_1.valToString)(header[headerKey])));
69
+ });
70
+ }
71
+ else if (header instanceof Object) {
72
+ Object.getOwnPropertyNames(header).forEach(function (headerKey) {
73
+ var headerAnn = Reflect.getMetadata(exports.headerMetadataKey, header, headerKey);
74
+ if (headerAnn == null)
75
+ return;
76
+ var headerDecorator = (0, utils_1.parseParamDecorator)(headerAnn, headerKey, "simple", explode);
77
+ if (headerDecorator == null)
78
+ return;
79
+ var headerFieldValue = (0, utils_1.valToString)(header[headerKey]);
80
+ if ((0, utils_1.isEmpty)(headerFieldValue))
81
+ return;
82
+ else if (explode)
83
+ headerVals.push("".concat(headerDecorator.ParamName, "=").concat(headerFieldValue));
84
+ else
85
+ headerVals.push("".concat(headerDecorator.ParamName, ",").concat(headerFieldValue));
86
+ });
87
+ }
88
+ else {
89
+ return String(header);
90
+ }
91
+ return headerVals.join(",");
92
+ }
@@ -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,27 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./contenttype"), exports);
21
+ __exportStar(require("./headers"), exports);
22
+ __exportStar(require("./pathparams"), exports);
23
+ __exportStar(require("./queryparams"), exports);
24
+ __exportStar(require("./requestbody"), exports);
25
+ __exportStar(require("./retries"), exports);
26
+ __exportStar(require("./security"), exports);
27
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,2 @@
1
+ export declare const ppMetadataKey = "pathParam";
2
+ export declare function getSimplePathParams(paramName: string, paramValue: any, explode: boolean): Map<string, string>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSimplePathParams = exports.ppMetadataKey = void 0;
7
+ var utils_1 = require("./utils");
8
+ exports.ppMetadataKey = "pathParam";
9
+ function getSimplePathParams(paramName, paramValue, explode) {
10
+ var pathParams = new Map();
11
+ var ppVals = [];
12
+ if (Array.isArray(paramValue)) {
13
+ paramValue.forEach(function (param) {
14
+ ppVals.push(encodeURIComponent((0, utils_1.valToString)(param)));
15
+ });
16
+ pathParams.set(paramName, ppVals.join(","));
17
+ }
18
+ else if ((0, utils_1.isStringRecord)(paramValue) ||
19
+ (0, utils_1.isNumberRecord)(paramValue) ||
20
+ (0, utils_1.isBooleanRecord)(paramValue)) {
21
+ Object.getOwnPropertyNames(paramValue).forEach(function (paramKey) {
22
+ var paramFieldValue = encodeURIComponent((0, utils_1.valToString)(paramValue[paramKey]));
23
+ if (explode)
24
+ ppVals.push("".concat(paramKey, "=").concat(paramFieldValue));
25
+ else
26
+ ppVals.push("".concat(paramKey, ",").concat(paramFieldValue));
27
+ });
28
+ pathParams.set(paramName, ppVals.join(","));
29
+ }
30
+ else if (paramValue instanceof Object) {
31
+ Object.getOwnPropertyNames(paramValue).forEach(function (paramKey) {
32
+ var ppAnn = Reflect.getMetadata(exports.ppMetadataKey, paramValue, paramKey);
33
+ if (ppAnn == null)
34
+ return;
35
+ var ppDecorator = (0, utils_1.parseParamDecorator)(ppAnn, paramKey, "simple", explode);
36
+ if (ppDecorator == null)
37
+ return;
38
+ var paramFieldValue = encodeURIComponent((0, utils_1.valToString)(paramValue[paramKey]));
39
+ if ((0, utils_1.isEmpty)(paramFieldValue))
40
+ return;
41
+ else if (explode)
42
+ ppVals.push("".concat(ppDecorator.ParamName, "=").concat(paramFieldValue));
43
+ else
44
+ ppVals.push("".concat(ppDecorator.ParamName, ",").concat(paramFieldValue));
45
+ });
46
+ pathParams.set(paramName, ppVals.join(","));
47
+ }
48
+ else {
49
+ pathParams.set(paramName, encodeURIComponent((0, utils_1.valToString)(paramValue)));
50
+ }
51
+ return pathParams;
52
+ }
53
+ exports.getSimplePathParams = getSimplePathParams;
@@ -0,0 +1,2 @@
1
+ export declare const qpMetadataKey = "queryParam";
2
+ export declare function serializeQueryParams(queryParams: any, globals?: any): string;
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
4
+ */
5
+ var __read = (this && this.__read) || function (o, n) {
6
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
7
+ if (!m) return o;
8
+ var i = m.call(o), r, ar = [], e;
9
+ try {
10
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11
+ }
12
+ catch (error) { e = { error: error }; }
13
+ finally {
14
+ try {
15
+ if (r && !r.done && (m = i["return"])) m.call(i);
16
+ }
17
+ finally { if (e) throw e.error; }
18
+ }
19
+ return ar;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.serializeQueryParams = exports.qpMetadataKey = void 0;
23
+ var utils_1 = require("./utils");
24
+ var requestbody_1 = require("./requestbody");
25
+ exports.qpMetadataKey = "queryParam";
26
+ var queryStringPrefix = "?";
27
+ var filterAndJoin = function (strings) {
28
+ return strings.filter(function (s) { return !!s; }).join("&");
29
+ };
30
+ function serializeQueryParams(queryParams, globals) {
31
+ var queryStringParts = [];
32
+ if (!queryParams)
33
+ return filterAndJoin(queryStringParts);
34
+ var fieldNames = "__props__" in queryParams
35
+ ? queryParams["__props__"].map(function (prop) { return prop.key; })
36
+ : Object.getOwnPropertyNames(queryParams);
37
+ fieldNames.forEach(function (fname) {
38
+ var _a, _b, _c, _d, _e, _f, _g;
39
+ var requestBodyAnn = Reflect.getMetadata(requestbody_1.requestMetadataKey, queryParams, fname);
40
+ if (requestBodyAnn)
41
+ return;
42
+ var qpAnn = Reflect.getMetadata(exports.qpMetadataKey, queryParams, fname);
43
+ if (!qpAnn)
44
+ return { serialize: function () { return ""; } };
45
+ var qpDecorator = (0, utils_1.parseParamDecorator)(qpAnn, fname, "form", true);
46
+ if (!qpDecorator)
47
+ return;
48
+ var value = queryParams[fname];
49
+ value = (0, utils_1.populateFromGlobals)(value, fname, "queryParam", globals);
50
+ if (qpDecorator.Serialization === "json")
51
+ queryStringParts.push(jsonSerializer((_a = {}, _a[qpDecorator.ParamName] = value, _a)));
52
+ else {
53
+ switch (qpDecorator.Style) {
54
+ case "deepObject":
55
+ queryStringParts.push(deepObjectSerializer((_b = {}, _b[qpDecorator.ParamName] = value, _b)));
56
+ return;
57
+ case "form":
58
+ if (!qpDecorator.Explode)
59
+ queryStringParts.push(noExplodeSerializer((_c = {}, _c[qpDecorator.ParamName] = value, _c)));
60
+ else
61
+ queryStringParts.push(formSerializerExplode((_d = {}, _d[qpDecorator.ParamName] = value, _d)));
62
+ return;
63
+ case "pipeDelimited":
64
+ if (!qpDecorator.Explode) {
65
+ queryStringParts.push(noExplodeSerializer((_e = {}, _e[qpDecorator.ParamName] = value, _e), "|"));
66
+ }
67
+ else {
68
+ queryStringParts.push(formSerializerExplode((_f = {}, _f[qpDecorator.ParamName] = value, _f)));
69
+ }
70
+ return;
71
+ default:
72
+ queryStringParts.push(formSerializerExplode((_g = {}, _g[qpDecorator.ParamName] = value, _g)));
73
+ }
74
+ }
75
+ });
76
+ return queryStringPrefix + filterAndJoin(queryStringParts);
77
+ }
78
+ exports.serializeQueryParams = serializeQueryParams;
79
+ // TODO: Add support for disabling percent encoding for reserved characters
80
+ function jsonSerializer(params) {
81
+ var query = [];
82
+ Object.entries(Object.assign({}, params)).forEach(function (_a) {
83
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
84
+ query.push("".concat(key, "=").concat(encodeURIComponent(JSON.stringify(value))));
85
+ });
86
+ return filterAndJoin(query);
87
+ }
88
+ // TODO: Add support for disabling percent encoding for reserved characters
89
+ function noExplodeSerializer(params, delimiter) {
90
+ if (delimiter === void 0) { delimiter = ","; }
91
+ var query = [];
92
+ Object.entries(Object.assign({}, params)).forEach(function (_a) {
93
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
94
+ if (!(0, utils_1.shouldQueryParamSerialize)(value))
95
+ return;
96
+ if (value !== Object(value))
97
+ query.push("".concat(key, "=").concat(encodeURIComponent((0, utils_1.valToString)(value))));
98
+ else if (Array.isArray(value)) {
99
+ var values = value.map(function (aValue) { return aValue; }).join(delimiter);
100
+ query.push("".concat(key, "=").concat(encodeURIComponent(values)));
101
+ }
102
+ else {
103
+ var values = Object.getOwnPropertyNames(value)
104
+ .map(function (paramKey) {
105
+ var qpAnn = Reflect.getMetadata(exports.qpMetadataKey, value, paramKey);
106
+ var qpDecorator = (0, utils_1.parseParamDecorator)(qpAnn, paramKey, "form", true);
107
+ if (qpDecorator == null)
108
+ return;
109
+ var key = qpDecorator.ParamName || paramKey;
110
+ return "".concat(key).concat(delimiter).concat((0, utils_1.valToString)(value[paramKey]));
111
+ })
112
+ .join(delimiter);
113
+ query.push("".concat(key, "=").concat(encodeURIComponent(values)));
114
+ }
115
+ });
116
+ return filterAndJoin(query);
117
+ }
118
+ // TODO: Add support for disabling percent encoding for reserved characters
119
+ function formSerializerExplode(params) {
120
+ var query = [];
121
+ Object.entries(Object.assign({}, params)).forEach(function (_a) {
122
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
123
+ if (!(0, utils_1.shouldQueryParamSerialize)(value))
124
+ return;
125
+ if (value !== Object(value))
126
+ query.push("".concat(key, "=").concat(encodeURIComponent(value)));
127
+ else if (Array.isArray(value)) {
128
+ query.push(value
129
+ .map(function (aValue) { return "".concat(key, "=").concat(encodeURIComponent((0, utils_1.valToString)(aValue))); })
130
+ .join("&"));
131
+ }
132
+ else
133
+ query.push(Object.getOwnPropertyNames(value)
134
+ .map(function (paramKey) {
135
+ var qpAnn = Reflect.getMetadata(exports.qpMetadataKey, value, paramKey);
136
+ var qpDecorator = (0, utils_1.parseParamDecorator)(qpAnn, paramKey, "form", true);
137
+ if (qpDecorator == null)
138
+ return;
139
+ var key = qpDecorator.ParamName || paramKey;
140
+ return "".concat(key, "=").concat(encodeURIComponent((0, utils_1.valToString)(value[paramKey])));
141
+ })
142
+ .join("&"));
143
+ });
144
+ return filterAndJoin(query);
145
+ }
146
+ // TODO: Add support for disabling percent encoding for reserved characters
147
+ function deepObjectSerializer(params) {
148
+ var query = [];
149
+ Object.entries(Object.assign({}, params)).forEach(function (_a) {
150
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
151
+ if (!(0, utils_1.shouldQueryParamSerialize)(value))
152
+ return;
153
+ if (value !== Object(value))
154
+ query.push("".concat(key, "=").concat(encodeURIComponent(value)));
155
+ else if (Array.isArray(value)) {
156
+ query.push(value
157
+ .map(function (_a) {
158
+ var _b = __read(_a, 2), objKey = _b[0], objValue = _b[1];
159
+ return "".concat(key, "[").concat(objKey, "]=").concat(encodeURIComponent((0, utils_1.valToString)(objValue)));
160
+ })
161
+ .join("&"));
162
+ }
163
+ else
164
+ query.push(Object.getOwnPropertyNames(value)
165
+ .map(function (paramKey) {
166
+ var qpAnn = Reflect.getMetadata(exports.qpMetadataKey, value, paramKey);
167
+ var qpDecorator = (0, utils_1.parseParamDecorator)(qpAnn, paramKey, "form", true);
168
+ if (qpDecorator == null)
169
+ return;
170
+ // For deep objects, arr is wrapped inside object
171
+ if (Array.isArray(value[paramKey]))
172
+ return value[paramKey]
173
+ .map(function (arrValue) {
174
+ return "".concat(key, "[").concat(paramKey, "]=").concat(encodeURIComponent((0, utils_1.valToString)(arrValue)));
175
+ })
176
+ .join("&");
177
+ return "".concat(key, "[").concat(paramKey, "]=").concat(encodeURIComponent((0, utils_1.valToString)(value[paramKey])));
178
+ })
179
+ .join("&"));
180
+ });
181
+ return filterAndJoin(query);
182
+ }
@@ -0,0 +1,2 @@
1
+ export declare const requestMetadataKey = "request";
2
+ export declare function serializeRequestBody(request: any, requestFieldName: string, serializationMethod: string): [Record<string, any>, any];