@roarkanalytics/sdk 0.1.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -0
  3. package/README.md +344 -0
  4. package/api-promise.d.mts +47 -0
  5. package/api-promise.d.mts.map +1 -0
  6. package/api-promise.d.ts +47 -0
  7. package/api-promise.d.ts.map +1 -0
  8. package/api-promise.js +84 -0
  9. package/api-promise.js.map +1 -0
  10. package/api-promise.mjs +80 -0
  11. package/api-promise.mjs.map +1 -0
  12. package/client.d.mts +186 -0
  13. package/client.d.mts.map +1 -0
  14. package/client.d.ts +186 -0
  15. package/client.d.ts.map +1 -0
  16. package/client.js +449 -0
  17. package/client.js.map +1 -0
  18. package/client.mjs +422 -0
  19. package/client.mjs.map +1 -0
  20. package/error.d.mts +47 -0
  21. package/error.d.mts.map +1 -0
  22. package/error.d.ts +47 -0
  23. package/error.d.ts.map +1 -0
  24. package/error.js +113 -0
  25. package/error.js.map +1 -0
  26. package/error.mjs +97 -0
  27. package/error.mjs.map +1 -0
  28. package/index.d.mts +6 -0
  29. package/index.d.mts.map +1 -0
  30. package/index.d.ts +6 -0
  31. package/index.d.ts.map +1 -0
  32. package/index.js +30 -0
  33. package/index.js.map +1 -0
  34. package/index.mjs +7 -0
  35. package/index.mjs.map +1 -0
  36. package/internal/builtin-types.d.mts +65 -0
  37. package/internal/builtin-types.d.mts.map +1 -0
  38. package/internal/builtin-types.d.ts +65 -0
  39. package/internal/builtin-types.d.ts.map +1 -0
  40. package/internal/builtin-types.js +4 -0
  41. package/internal/builtin-types.js.map +1 -0
  42. package/internal/builtin-types.mjs +3 -0
  43. package/internal/builtin-types.mjs.map +1 -0
  44. package/internal/detect-platform.d.mts +15 -0
  45. package/internal/detect-platform.d.mts.map +1 -0
  46. package/internal/detect-platform.d.ts +15 -0
  47. package/internal/detect-platform.d.ts.map +1 -0
  48. package/internal/detect-platform.js +162 -0
  49. package/internal/detect-platform.js.map +1 -0
  50. package/internal/detect-platform.mjs +157 -0
  51. package/internal/detect-platform.mjs.map +1 -0
  52. package/internal/errors.d.mts +3 -0
  53. package/internal/errors.d.mts.map +1 -0
  54. package/internal/errors.d.ts +3 -0
  55. package/internal/errors.d.ts.map +1 -0
  56. package/internal/errors.js +26 -0
  57. package/internal/errors.js.map +1 -0
  58. package/internal/errors.mjs +21 -0
  59. package/internal/errors.mjs.map +1 -0
  60. package/internal/headers.d.mts +21 -0
  61. package/internal/headers.d.mts.map +1 -0
  62. package/internal/headers.d.ts +21 -0
  63. package/internal/headers.d.ts.map +1 -0
  64. package/internal/headers.js +77 -0
  65. package/internal/headers.js.map +1 -0
  66. package/internal/headers.mjs +72 -0
  67. package/internal/headers.mjs.map +1 -0
  68. package/internal/parse.d.mts +10 -0
  69. package/internal/parse.d.mts.map +1 -0
  70. package/internal/parse.d.ts +10 -0
  71. package/internal/parse.d.ts.map +1 -0
  72. package/internal/parse.js +28 -0
  73. package/internal/parse.js.map +1 -0
  74. package/internal/parse.mjs +24 -0
  75. package/internal/parse.mjs.map +1 -0
  76. package/internal/polyfill/crypto.node.d.ts +10 -0
  77. package/internal/polyfill/crypto.node.js +11 -0
  78. package/internal/polyfill/crypto.node.mjs +2 -0
  79. package/internal/polyfill/file.node.d.ts +9 -0
  80. package/internal/polyfill/file.node.js +17 -0
  81. package/internal/polyfill/file.node.mjs +9 -0
  82. package/internal/request-options.d.mts +34 -0
  83. package/internal/request-options.d.mts.map +1 -0
  84. package/internal/request-options.d.ts +34 -0
  85. package/internal/request-options.d.ts.map +1 -0
  86. package/internal/request-options.js +39 -0
  87. package/internal/request-options.js.map +1 -0
  88. package/internal/request-options.mjs +34 -0
  89. package/internal/request-options.mjs.map +1 -0
  90. package/internal/shim-types.d.mts +28 -0
  91. package/internal/shim-types.d.ts +28 -0
  92. package/internal/shims.d.mts +61 -0
  93. package/internal/shims.d.mts.map +1 -0
  94. package/internal/shims.d.ts +61 -0
  95. package/internal/shims.d.ts.map +1 -0
  96. package/internal/shims.js +101 -0
  97. package/internal/shims.js.map +1 -0
  98. package/internal/shims.mjs +92 -0
  99. package/internal/shims.mjs.map +1 -0
  100. package/internal/types.d.mts +68 -0
  101. package/internal/types.d.mts.map +1 -0
  102. package/internal/types.d.ts +68 -0
  103. package/internal/types.d.ts.map +1 -0
  104. package/internal/types.js +4 -0
  105. package/internal/types.js.map +1 -0
  106. package/internal/types.mjs +3 -0
  107. package/internal/types.mjs.map +1 -0
  108. package/internal/uploads.d.mts +73 -0
  109. package/internal/uploads.d.mts.map +1 -0
  110. package/internal/uploads.d.ts +73 -0
  111. package/internal/uploads.d.ts.map +1 -0
  112. package/internal/uploads.js +208 -0
  113. package/internal/uploads.js.map +1 -0
  114. package/internal/uploads.mjs +200 -0
  115. package/internal/uploads.mjs.map +1 -0
  116. package/internal/utils/base64.d.mts +3 -0
  117. package/internal/utils/base64.d.mts.map +1 -0
  118. package/internal/utils/base64.d.ts +3 -0
  119. package/internal/utils/base64.d.ts.map +1 -0
  120. package/internal/utils/base64.js +33 -0
  121. package/internal/utils/base64.js.map +1 -0
  122. package/internal/utils/base64.mjs +28 -0
  123. package/internal/utils/base64.mjs.map +1 -0
  124. package/internal/utils/env.d.mts +9 -0
  125. package/internal/utils/env.d.mts.map +1 -0
  126. package/internal/utils/env.d.ts +9 -0
  127. package/internal/utils/env.d.ts.map +1 -0
  128. package/internal/utils/env.js +22 -0
  129. package/internal/utils/env.js.map +1 -0
  130. package/internal/utils/env.mjs +18 -0
  131. package/internal/utils/env.mjs.map +1 -0
  132. package/internal/utils/log.d.mts +4 -0
  133. package/internal/utils/log.d.mts.map +1 -0
  134. package/internal/utils/log.d.ts +4 -0
  135. package/internal/utils/log.d.ts.map +1 -0
  136. package/internal/utils/log.js +47 -0
  137. package/internal/utils/log.js.map +1 -0
  138. package/internal/utils/log.mjs +43 -0
  139. package/internal/utils/log.mjs.map +1 -0
  140. package/internal/utils/sleep.d.mts +2 -0
  141. package/internal/utils/sleep.d.mts.map +1 -0
  142. package/internal/utils/sleep.d.ts +2 -0
  143. package/internal/utils/sleep.d.ts.map +1 -0
  144. package/internal/utils/sleep.js +7 -0
  145. package/internal/utils/sleep.js.map +1 -0
  146. package/internal/utils/sleep.mjs +3 -0
  147. package/internal/utils/sleep.mjs.map +1 -0
  148. package/internal/utils/uuid.d.mts +5 -0
  149. package/internal/utils/uuid.d.mts.map +1 -0
  150. package/internal/utils/uuid.d.ts +5 -0
  151. package/internal/utils/uuid.d.ts.map +1 -0
  152. package/internal/utils/uuid.js +15 -0
  153. package/internal/utils/uuid.js.map +1 -0
  154. package/internal/utils/uuid.mjs +11 -0
  155. package/internal/utils/uuid.mjs.map +1 -0
  156. package/internal/utils/values.d.mts +15 -0
  157. package/internal/utils/values.d.mts.map +1 -0
  158. package/internal/utils/values.d.ts +15 -0
  159. package/internal/utils/values.d.ts.map +1 -0
  160. package/internal/utils/values.js +100 -0
  161. package/internal/utils/values.js.map +1 -0
  162. package/internal/utils/values.mjs +84 -0
  163. package/internal/utils/values.mjs.map +1 -0
  164. package/internal/utils.d.mts +7 -0
  165. package/internal/utils.d.mts.map +1 -0
  166. package/internal/utils.d.ts +7 -0
  167. package/internal/utils.d.ts.map +1 -0
  168. package/internal/utils.js +24 -0
  169. package/internal/utils.js.map +1 -0
  170. package/internal/utils.mjs +8 -0
  171. package/internal/utils.mjs.map +1 -0
  172. package/package.json +119 -0
  173. package/resource.d.mts +6 -0
  174. package/resource.d.mts.map +1 -0
  175. package/resource.d.ts +6 -0
  176. package/resource.d.ts.map +1 -0
  177. package/resource.js +11 -0
  178. package/resource.js.map +1 -0
  179. package/resource.mjs +7 -0
  180. package/resource.mjs.map +1 -0
  181. package/resources/calls.d.mts +85 -0
  182. package/resources/calls.d.mts.map +1 -0
  183. package/resources/calls.d.ts +85 -0
  184. package/resources/calls.d.ts.map +1 -0
  185. package/resources/calls.js +15 -0
  186. package/resources/calls.js.map +1 -0
  187. package/resources/calls.mjs +11 -0
  188. package/resources/calls.mjs.map +1 -0
  189. package/resources/index.d.mts +2 -0
  190. package/resources/index.d.mts.map +1 -0
  191. package/resources/index.d.ts +2 -0
  192. package/resources/index.d.ts.map +1 -0
  193. package/resources/index.js +7 -0
  194. package/resources/index.js.map +1 -0
  195. package/resources/index.mjs +3 -0
  196. package/resources/index.mjs.map +1 -0
  197. package/src/api-promise.ts +92 -0
  198. package/src/client.ts +646 -0
  199. package/src/error.ts +130 -0
  200. package/src/index.ts +22 -0
  201. package/src/internal/builtin-types.ts +79 -0
  202. package/src/internal/detect-platform.ts +196 -0
  203. package/src/internal/errors.ts +22 -0
  204. package/src/internal/headers.ts +96 -0
  205. package/src/internal/parse.ts +41 -0
  206. package/src/internal/polyfill/crypto.node.d.ts +10 -0
  207. package/src/internal/polyfill/crypto.node.js +11 -0
  208. package/src/internal/polyfill/crypto.node.mjs +2 -0
  209. package/src/internal/polyfill/file.node.d.ts +9 -0
  210. package/src/internal/polyfill/file.node.js +17 -0
  211. package/src/internal/polyfill/file.node.mjs +9 -0
  212. package/src/internal/request-options.ts +67 -0
  213. package/src/internal/shim-types.d.ts +28 -0
  214. package/src/internal/shims.ts +145 -0
  215. package/src/internal/types.ts +98 -0
  216. package/src/internal/uploads.ts +307 -0
  217. package/src/internal/utils/base64.ts +37 -0
  218. package/src/internal/utils/env.ts +18 -0
  219. package/src/internal/utils/log.ts +49 -0
  220. package/src/internal/utils/sleep.ts +3 -0
  221. package/src/internal/utils/uuid.ts +13 -0
  222. package/src/internal/utils/values.ts +94 -0
  223. package/src/internal/utils.ts +8 -0
  224. package/src/lib/.keep +4 -0
  225. package/src/resource.ts +11 -0
  226. package/src/resources/calls.ts +118 -0
  227. package/src/resources/index.ts +3 -0
  228. package/src/tsconfig.json +11 -0
  229. package/src/uploads.ts +1 -0
  230. package/src/version.ts +1 -0
  231. package/uploads.d.mts +2 -0
  232. package/uploads.d.mts.map +1 -0
  233. package/uploads.d.ts +2 -0
  234. package/uploads.d.ts.map +1 -0
  235. package/uploads.js +6 -0
  236. package/uploads.js.map +1 -0
  237. package/uploads.mjs +2 -0
  238. package/uploads.mjs.map +1 -0
  239. package/version.d.mts +2 -0
  240. package/version.d.mts.map +1 -0
  241. package/version.d.ts +2 -0
  242. package/version.d.ts.map +1 -0
  243. package/version.js +5 -0
  244. package/version.js.map +1 -0
  245. package/version.mjs +2 -0
  246. package/version.mjs.map +1 -0
package/api-promise.js ADDED
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4
+ if (kind === "m") throw new TypeError("Private method is not writable");
5
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8
+ };
9
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13
+ };
14
+ var _APIPromise_client;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.APIPromise = void 0;
17
+ const parse_1 = require("./internal/parse.js");
18
+ /**
19
+ * A subclass of `Promise` providing additional helper methods
20
+ * for interacting with the SDK.
21
+ */
22
+ class APIPromise extends Promise {
23
+ constructor(client, responsePromise, parseResponse = parse_1.defaultParseResponse) {
24
+ super((resolve) => {
25
+ // this is maybe a bit weird but this has to be a no-op to not implicitly
26
+ // parse the response body; instead .then, .catch, .finally are overridden
27
+ // to parse the response
28
+ resolve(null);
29
+ });
30
+ this.responsePromise = responsePromise;
31
+ this.parseResponse = parseResponse;
32
+ _APIPromise_client.set(this, void 0);
33
+ __classPrivateFieldSet(this, _APIPromise_client, client, "f");
34
+ }
35
+ _thenUnwrap(transform) {
36
+ return new APIPromise(__classPrivateFieldGet(this, _APIPromise_client, "f"), this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props));
37
+ }
38
+ /**
39
+ * Gets the raw `Response` instance instead of parsing the response
40
+ * data.
41
+ *
42
+ * If you want to parse the response body but still get the `Response`
43
+ * instance, you can use {@link withResponse()}.
44
+ *
45
+ * 👋 Getting the wrong TypeScript type for `Response`?
46
+ * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
47
+ * to your `tsconfig.json`.
48
+ */
49
+ asResponse() {
50
+ return this.responsePromise.then((p) => p.response);
51
+ }
52
+ /**
53
+ * Gets the parsed response data and the raw `Response` instance.
54
+ *
55
+ * If you just want to get the raw `Response` instance without parsing it,
56
+ * you can use {@link asResponse()}.
57
+ *
58
+ * 👋 Getting the wrong TypeScript type for `Response`?
59
+ * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
60
+ * to your `tsconfig.json`.
61
+ */
62
+ async withResponse() {
63
+ const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
64
+ return { data, response };
65
+ }
66
+ parse() {
67
+ if (!this.parsedPromise) {
68
+ this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(__classPrivateFieldGet(this, _APIPromise_client, "f"), data));
69
+ }
70
+ return this.parsedPromise;
71
+ }
72
+ then(onfulfilled, onrejected) {
73
+ return this.parse().then(onfulfilled, onrejected);
74
+ }
75
+ catch(onrejected) {
76
+ return this.parse().catch(onrejected);
77
+ }
78
+ finally(onfinally) {
79
+ return this.parse().finally(onfinally);
80
+ }
81
+ }
82
+ exports.APIPromise = APIPromise;
83
+ _APIPromise_client = new WeakMap();
84
+ //# sourceMappingURL=api-promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.js","sourceRoot":"","sources":["src/api-promise.ts"],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CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,0BAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;SAClG;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEQ,IAAI,CACX,WAAiF,EACjF,UAAmF;QAEnF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAEQ,KAAK,CACZ,UAAiF;QAEjF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAEQ,OAAO,CAAC,SAA2C;QAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF;AAhFD,gCAgFC"}
@@ -0,0 +1,80 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _APIPromise_client;
14
+ import { defaultParseResponse } from "./internal/parse.mjs";
15
+ /**
16
+ * A subclass of `Promise` providing additional helper methods
17
+ * for interacting with the SDK.
18
+ */
19
+ export class APIPromise extends Promise {
20
+ constructor(client, responsePromise, parseResponse = defaultParseResponse) {
21
+ super((resolve) => {
22
+ // this is maybe a bit weird but this has to be a no-op to not implicitly
23
+ // parse the response body; instead .then, .catch, .finally are overridden
24
+ // to parse the response
25
+ resolve(null);
26
+ });
27
+ this.responsePromise = responsePromise;
28
+ this.parseResponse = parseResponse;
29
+ _APIPromise_client.set(this, void 0);
30
+ __classPrivateFieldSet(this, _APIPromise_client, client, "f");
31
+ }
32
+ _thenUnwrap(transform) {
33
+ return new APIPromise(__classPrivateFieldGet(this, _APIPromise_client, "f"), this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props));
34
+ }
35
+ /**
36
+ * Gets the raw `Response` instance instead of parsing the response
37
+ * data.
38
+ *
39
+ * If you want to parse the response body but still get the `Response`
40
+ * instance, you can use {@link withResponse()}.
41
+ *
42
+ * 👋 Getting the wrong TypeScript type for `Response`?
43
+ * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
44
+ * to your `tsconfig.json`.
45
+ */
46
+ asResponse() {
47
+ return this.responsePromise.then((p) => p.response);
48
+ }
49
+ /**
50
+ * Gets the parsed response data and the raw `Response` instance.
51
+ *
52
+ * If you just want to get the raw `Response` instance without parsing it,
53
+ * you can use {@link asResponse()}.
54
+ *
55
+ * 👋 Getting the wrong TypeScript type for `Response`?
56
+ * Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
57
+ * to your `tsconfig.json`.
58
+ */
59
+ async withResponse() {
60
+ const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
61
+ return { data, response };
62
+ }
63
+ parse() {
64
+ if (!this.parsedPromise) {
65
+ this.parsedPromise = this.responsePromise.then((data) => this.parseResponse(__classPrivateFieldGet(this, _APIPromise_client, "f"), data));
66
+ }
67
+ return this.parsedPromise;
68
+ }
69
+ then(onfulfilled, onrejected) {
70
+ return this.parse().then(onfulfilled, onrejected);
71
+ }
72
+ catch(onrejected) {
73
+ return this.parse().catch(onrejected);
74
+ }
75
+ finally(onfinally) {
76
+ return this.parse().finally(onfinally);
77
+ }
78
+ }
79
+ _APIPromise_client = new WeakMap();
80
+ //# sourceMappingURL=api-promise.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-promise.mjs","sourceRoot":"","sources":["src/api-promise.ts"],"names":[],"mappings":"AAAA,sFAAsF;;;;;;;;;;;;;OAK/E,EAAoB,oBAAoB,EAAE;AAEjD;;;GAGG;AACH,MAAM,OAAO,UAAc,SAAQ,OAAU;IAI3C,YACE,MAAgB,EACR,eAA0C,EAC1C,gBAGiB,oBAAoB;QAE7C,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE;YAChB,yEAAyE;YACzE,0EAA0E;YAC1E,wBAAwB;YACxB,OAAO,CAAC,IAAW,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAXK,oBAAe,GAAf,eAAe,CAA2B;QAC1C,kBAAa,GAAb,aAAa,CAGwB;QAR/C,qCAAkB;QAgBhB,uBAAA,IAAI,sBAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED,WAAW,CAAI,SAAkD;QAC/D,OAAO,IAAI,UAAU,CAAC,uBAAA,IAAI,0BAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAChF,SAAS,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED;;;;;;;;;;OAUG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC9E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,uBAAA,IAAI,0BAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;SAClG;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAEQ,IAAI,CACX,WAAiF,EACjF,UAAmF;QAEnF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAEQ,KAAK,CACZ,UAAiF;QAEjF,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAEQ,OAAO,CAAC,SAA2C;QAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF"}
package/client.d.mts ADDED
@@ -0,0 +1,186 @@
1
+
2
+ import type { RequestInit, RequestInfo } from "./internal/builtin-types.mjs";
3
+ import type { PromiseOrValue, MergedRequestInit } from "./internal/types.mjs";
4
+ import * as Opts from "./internal/request-options.mjs";
5
+ import * as Errors from "./error.mjs";
6
+ import * as Uploads from "./uploads.mjs";
7
+ import * as API from "./resources/index.mjs";
8
+ import { APIPromise } from "./api-promise.mjs";
9
+ import { type Fetch } from "./internal/builtin-types.mjs";
10
+ import { HeadersLike, NullableHeaders } from "./internal/headers.mjs";
11
+ import { FinalRequestOptions, RequestOptions } from "./internal/request-options.mjs";
12
+ import { CallCreateParams, CallCreateResponse, Calls } from "./resources/calls.mjs";
13
+ type LogFn = (message: string, ...rest: unknown[]) => void;
14
+ export type Logger = {
15
+ error: LogFn;
16
+ warn: LogFn;
17
+ info: LogFn;
18
+ debug: LogFn;
19
+ };
20
+ export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
21
+ export interface ClientOptions {
22
+ /**
23
+ * JWT token for authentication
24
+ */
25
+ bearerToken?: string | undefined;
26
+ /**
27
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
28
+ *
29
+ * Defaults to process.env['PETSTORE_BASE_URL'].
30
+ */
31
+ baseURL?: string | null | undefined;
32
+ /**
33
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
34
+ * from the server before timing out a single request.
35
+ *
36
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
37
+ * much longer than this timeout before the promise succeeds or fails.
38
+ */
39
+ timeout?: number | undefined;
40
+ /**
41
+ * Additional `RequestInit` options to be passed to `fetch` calls.
42
+ * Properties will be overridden by per-request `fetchOptions`.
43
+ */
44
+ fetchOptions?: MergedRequestInit | undefined;
45
+ /**
46
+ * Specify a custom `fetch` function implementation.
47
+ *
48
+ * If not provided, we expect that `fetch` is defined globally.
49
+ */
50
+ fetch?: Fetch | undefined;
51
+ /**
52
+ * The maximum number of times that the client will retry a request in case of a
53
+ * temporary failure, like a network error or a 5XX error from the server.
54
+ *
55
+ * @default 2
56
+ */
57
+ maxRetries?: number | undefined;
58
+ /**
59
+ * Default headers to include with every request to the API.
60
+ *
61
+ * These can be removed in individual requests by explicitly setting the
62
+ * header to `null` in request options.
63
+ */
64
+ defaultHeaders?: HeadersLike | undefined;
65
+ /**
66
+ * Default query parameters to include with every request to the API.
67
+ *
68
+ * These can be removed in individual requests by explicitly setting the
69
+ * param to `undefined` in request options.
70
+ */
71
+ defaultQuery?: Record<string, string | undefined> | undefined;
72
+ /**
73
+ * Set the log level.
74
+ *
75
+ * Defaults to process.env['PETSTORE_LOG'].
76
+ */
77
+ logLevel?: LogLevel | undefined | null;
78
+ /**
79
+ * Set the logger.
80
+ *
81
+ * Defaults to globalThis.console.
82
+ */
83
+ logger?: Logger | undefined | null;
84
+ }
85
+ type FinalizedRequestInit = RequestInit & {
86
+ headers: Headers;
87
+ };
88
+ /**
89
+ * API Client for interfacing with the Petstore API.
90
+ */
91
+ export declare class Petstore {
92
+ #private;
93
+ bearerToken: string;
94
+ baseURL: string;
95
+ maxRetries: number;
96
+ timeout: number;
97
+ logger: Logger | undefined;
98
+ logLevel: LogLevel | undefined;
99
+ fetchOptions: MergedRequestInit | undefined;
100
+ private fetch;
101
+ protected idempotencyHeader?: string;
102
+ private _options;
103
+ /**
104
+ * API Client for interfacing with the Petstore API.
105
+ *
106
+ * @param {string | undefined} [opts.bearerToken=process.env['ROARK_API_BEARER_TOKEN'] ?? undefined]
107
+ * @param {string} [opts.baseURL=process.env['PETSTORE_BASE_URL'] ?? https://petstore3.swagger.io/api/v3] - Override the default base URL for the API.
108
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
109
+ * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
110
+ * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
111
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
112
+ * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
113
+ * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
114
+ */
115
+ constructor({ baseURL, bearerToken, ...opts }?: ClientOptions);
116
+ protected defaultQuery(): Record<string, string | undefined> | undefined;
117
+ protected validateHeaders({ values, nulls }: NullableHeaders): void;
118
+ protected authHeaders(opts: FinalRequestOptions): Headers | undefined;
119
+ /**
120
+ * Basic re-implementation of `qs.stringify` for primitive types.
121
+ */
122
+ protected stringifyQuery(query: Record<string, unknown>): string;
123
+ private getUserAgent;
124
+ protected defaultIdempotencyKey(): string;
125
+ protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
126
+ buildURL(path: string, query: Record<string, unknown> | null | undefined): string;
127
+ private calculateContentLength;
128
+ /**
129
+ * Used as a callback for mutating the given `FinalRequestOptions` object.
130
+ */
131
+ protected prepareOptions(options: FinalRequestOptions): Promise<void>;
132
+ /**
133
+ * Used as a callback for mutating the given `RequestInit` object.
134
+ *
135
+ * This is useful for cases where you want to add certain headers based off of
136
+ * the request properties, e.g. `method` or `url`.
137
+ */
138
+ protected prepareRequest(request: RequestInit, { url, options }: {
139
+ url: string;
140
+ options: FinalRequestOptions;
141
+ }): Promise<void>;
142
+ get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
143
+ post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
144
+ patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
145
+ put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
146
+ delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
147
+ private methodRequest;
148
+ request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
149
+ private makeRequest;
150
+ fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
151
+ private shouldRetry;
152
+ private retryRequest;
153
+ private calculateDefaultRetryTimeoutMillis;
154
+ buildRequest(options: FinalRequestOptions, { retryCount }?: {
155
+ retryCount?: number;
156
+ }): {
157
+ req: FinalizedRequestInit;
158
+ url: string;
159
+ timeout: number;
160
+ };
161
+ private buildHeaders;
162
+ private buildBody;
163
+ static Petstore: typeof Petstore;
164
+ static DEFAULT_TIMEOUT: number;
165
+ static PetstoreError: typeof Errors.PetstoreError;
166
+ static APIError: typeof Errors.APIError;
167
+ static APIConnectionError: typeof Errors.APIConnectionError;
168
+ static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
169
+ static APIUserAbortError: typeof Errors.APIUserAbortError;
170
+ static NotFoundError: typeof Errors.NotFoundError;
171
+ static ConflictError: typeof Errors.ConflictError;
172
+ static RateLimitError: typeof Errors.RateLimitError;
173
+ static BadRequestError: typeof Errors.BadRequestError;
174
+ static AuthenticationError: typeof Errors.AuthenticationError;
175
+ static InternalServerError: typeof Errors.InternalServerError;
176
+ static PermissionDeniedError: typeof Errors.PermissionDeniedError;
177
+ static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
178
+ static toFile: typeof Uploads.toFile;
179
+ calls: API.Calls;
180
+ }
181
+ export declare namespace Petstore {
182
+ export type RequestOptions = Opts.RequestOptions;
183
+ export { Calls as Calls, type CallCreateResponse as CallCreateResponse, type CallCreateParams as CallCreateParams, };
184
+ }
185
+ export {};
186
+ //# sourceMappingURL=client.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":";OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE;OAQtD,KAAK,IAAI;OAET,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,KAAK,EAAE;OACd,EAAE,WAAW,EAAE,eAAe,EAAgB;OAC9C,EAAE,mBAAmB,EAAE,cAAc,EAAE;OACvC,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,EAAE;AAatD,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAC3D,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AACF,MAAM,MAA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Y;IAoCpB,OAAO,CAAC,SAAS;IAqCjB,MAAM,CAAC,QAAQ,kBAAQ;IACvB,MAAM,CAAC,eAAe,SAAS;IAE/B,MAAM,CAAC,aAAa,8BAAwB;IAC5C,MAAM,CAAC,QAAQ,yBAAmB;IAClC,MAAM,CAAC,kBAAkB,mCAA6B;IACtD,MAAM,CAAC,yBAAyB,0CAAoC;IACpE,MAAM,CAAC,iBAAiB,kCAA4B;IACpD,MAAM,CAAC,aAAa,8BAAwB;IAC5C,MAAM,CAAC,aAAa,8BAAwB;IAC5C,MAAM,CAAC,cAAc,+BAAyB;IAC9C,MAAM,CAAC,eAAe,gCAA0B;IAChD,MAAM,CAAC,mBAAmB,oCAA8B;IACxD,MAAM,CAAC,mBAAmB,oCAA8B;IACxD,MAAM,CAAC,qBAAqB,sCAAgC;IAC5D,MAAM,CAAC,wBAAwB,yCAAmC;IAElE,MAAM,CAAC,MAAM,wBAAkB;IAE/B,KAAK,EAAE,GAAG,CAAC,KAAK,CAAuB;CACxC;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAEjD,OAAO,EACL,KAAK,IAAI,KAAK,EACd,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,gBAAgB,IAAI,gBAAgB,GAC1C,CAAC;CACH"}
package/client.d.ts ADDED
@@ -0,0 +1,186 @@
1
+
2
+ import type { RequestInit, RequestInfo } from "./internal/builtin-types.js";
3
+ import type { PromiseOrValue, MergedRequestInit } from "./internal/types.js";
4
+ import * as Opts from "./internal/request-options.js";
5
+ import * as Errors from "./error.js";
6
+ import * as Uploads from "./uploads.js";
7
+ import * as API from "./resources/index.js";
8
+ import { APIPromise } from "./api-promise.js";
9
+ import { type Fetch } from "./internal/builtin-types.js";
10
+ import { HeadersLike, NullableHeaders } from "./internal/headers.js";
11
+ import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js";
12
+ import { CallCreateParams, CallCreateResponse, Calls } from "./resources/calls.js";
13
+ type LogFn = (message: string, ...rest: unknown[]) => void;
14
+ export type Logger = {
15
+ error: LogFn;
16
+ warn: LogFn;
17
+ info: LogFn;
18
+ debug: LogFn;
19
+ };
20
+ export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
21
+ export interface ClientOptions {
22
+ /**
23
+ * JWT token for authentication
24
+ */
25
+ bearerToken?: string | undefined;
26
+ /**
27
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
28
+ *
29
+ * Defaults to process.env['PETSTORE_BASE_URL'].
30
+ */
31
+ baseURL?: string | null | undefined;
32
+ /**
33
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
34
+ * from the server before timing out a single request.
35
+ *
36
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
37
+ * much longer than this timeout before the promise succeeds or fails.
38
+ */
39
+ timeout?: number | undefined;
40
+ /**
41
+ * Additional `RequestInit` options to be passed to `fetch` calls.
42
+ * Properties will be overridden by per-request `fetchOptions`.
43
+ */
44
+ fetchOptions?: MergedRequestInit | undefined;
45
+ /**
46
+ * Specify a custom `fetch` function implementation.
47
+ *
48
+ * If not provided, we expect that `fetch` is defined globally.
49
+ */
50
+ fetch?: Fetch | undefined;
51
+ /**
52
+ * The maximum number of times that the client will retry a request in case of a
53
+ * temporary failure, like a network error or a 5XX error from the server.
54
+ *
55
+ * @default 2
56
+ */
57
+ maxRetries?: number | undefined;
58
+ /**
59
+ * Default headers to include with every request to the API.
60
+ *
61
+ * These can be removed in individual requests by explicitly setting the
62
+ * header to `null` in request options.
63
+ */
64
+ defaultHeaders?: HeadersLike | undefined;
65
+ /**
66
+ * Default query parameters to include with every request to the API.
67
+ *
68
+ * These can be removed in individual requests by explicitly setting the
69
+ * param to `undefined` in request options.
70
+ */
71
+ defaultQuery?: Record<string, string | undefined> | undefined;
72
+ /**
73
+ * Set the log level.
74
+ *
75
+ * Defaults to process.env['PETSTORE_LOG'].
76
+ */
77
+ logLevel?: LogLevel | undefined | null;
78
+ /**
79
+ * Set the logger.
80
+ *
81
+ * Defaults to globalThis.console.
82
+ */
83
+ logger?: Logger | undefined | null;
84
+ }
85
+ type FinalizedRequestInit = RequestInit & {
86
+ headers: Headers;
87
+ };
88
+ /**
89
+ * API Client for interfacing with the Petstore API.
90
+ */
91
+ export declare class Petstore {
92
+ #private;
93
+ bearerToken: string;
94
+ baseURL: string;
95
+ maxRetries: number;
96
+ timeout: number;
97
+ logger: Logger | undefined;
98
+ logLevel: LogLevel | undefined;
99
+ fetchOptions: MergedRequestInit | undefined;
100
+ private fetch;
101
+ protected idempotencyHeader?: string;
102
+ private _options;
103
+ /**
104
+ * API Client for interfacing with the Petstore API.
105
+ *
106
+ * @param {string | undefined} [opts.bearerToken=process.env['ROARK_API_BEARER_TOKEN'] ?? undefined]
107
+ * @param {string} [opts.baseURL=process.env['PETSTORE_BASE_URL'] ?? https://petstore3.swagger.io/api/v3] - Override the default base URL for the API.
108
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
109
+ * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
110
+ * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
111
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
112
+ * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
113
+ * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
114
+ */
115
+ constructor({ baseURL, bearerToken, ...opts }?: ClientOptions);
116
+ protected defaultQuery(): Record<string, string | undefined> | undefined;
117
+ protected validateHeaders({ values, nulls }: NullableHeaders): void;
118
+ protected authHeaders(opts: FinalRequestOptions): Headers | undefined;
119
+ /**
120
+ * Basic re-implementation of `qs.stringify` for primitive types.
121
+ */
122
+ protected stringifyQuery(query: Record<string, unknown>): string;
123
+ private getUserAgent;
124
+ protected defaultIdempotencyKey(): string;
125
+ protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
126
+ buildURL(path: string, query: Record<string, unknown> | null | undefined): string;
127
+ private calculateContentLength;
128
+ /**
129
+ * Used as a callback for mutating the given `FinalRequestOptions` object.
130
+ */
131
+ protected prepareOptions(options: FinalRequestOptions): Promise<void>;
132
+ /**
133
+ * Used as a callback for mutating the given `RequestInit` object.
134
+ *
135
+ * This is useful for cases where you want to add certain headers based off of
136
+ * the request properties, e.g. `method` or `url`.
137
+ */
138
+ protected prepareRequest(request: RequestInit, { url, options }: {
139
+ url: string;
140
+ options: FinalRequestOptions;
141
+ }): Promise<void>;
142
+ get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
143
+ post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
144
+ patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
145
+ put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
146
+ delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
147
+ private methodRequest;
148
+ request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
149
+ private makeRequest;
150
+ fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
151
+ private shouldRetry;
152
+ private retryRequest;
153
+ private calculateDefaultRetryTimeoutMillis;
154
+ buildRequest(options: FinalRequestOptions, { retryCount }?: {
155
+ retryCount?: number;
156
+ }): {
157
+ req: FinalizedRequestInit;
158
+ url: string;
159
+ timeout: number;
160
+ };
161
+ private buildHeaders;
162
+ private buildBody;
163
+ static Petstore: typeof Petstore;
164
+ static DEFAULT_TIMEOUT: number;
165
+ static PetstoreError: typeof Errors.PetstoreError;
166
+ static APIError: typeof Errors.APIError;
167
+ static APIConnectionError: typeof Errors.APIConnectionError;
168
+ static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
169
+ static APIUserAbortError: typeof Errors.APIUserAbortError;
170
+ static NotFoundError: typeof Errors.NotFoundError;
171
+ static ConflictError: typeof Errors.ConflictError;
172
+ static RateLimitError: typeof Errors.RateLimitError;
173
+ static BadRequestError: typeof Errors.BadRequestError;
174
+ static AuthenticationError: typeof Errors.AuthenticationError;
175
+ static InternalServerError: typeof Errors.InternalServerError;
176
+ static PermissionDeniedError: typeof Errors.PermissionDeniedError;
177
+ static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
178
+ static toFile: typeof Uploads.toFile;
179
+ calls: API.Calls;
180
+ }
181
+ export declare namespace Petstore {
182
+ export type RequestOptions = Opts.RequestOptions;
183
+ export { Calls as Calls, type CallCreateResponse as CallCreateResponse, type CallCreateParams as CallCreateParams, };
184
+ }
185
+ export {};
186
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":";OAEO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAY;OAC3C,KAAK,EAAc,cAAc,EAAE,iBAAiB,EAAE;OAQtD,KAAK,IAAI;OAET,KAAK,MAAM;OACX,KAAK,OAAO;OACZ,KAAK,GAAG;OACR,EAAE,UAAU,EAAE;OACd,EAAE,KAAK,KAAK,EAAE;OACd,EAAE,WAAW,EAAE,eAAe,EAAgB;OAC9C,EAAE,mBAAmB,EAAE,cAAc,EAAE;OACvC,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,EAAE;AAatD,KAAK,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAC3D,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;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