@truvity/sdk 0.27.9-rc.1 → 0.27.16

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 (298) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +47 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/sdk-typescript-internal.iml +9 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/Client.d.ts +6 -0
  9. package/Client.js +24 -14
  10. package/Makefile +8 -1
  11. package/api/errors/index.d.ts +1 -1
  12. package/api/errors/index.js +1 -1
  13. package/api/resources/apiKeys/client/Client.d.ts +181 -0
  14. package/api/resources/apiKeys/client/Client.js +841 -0
  15. package/api/resources/apiKeys/client/index.d.ts +1 -0
  16. package/api/resources/apiKeys/client/index.js +17 -0
  17. package/api/resources/apiKeys/client/requests/ApiKeyCreateRequest.d.ts +69 -0
  18. package/api/resources/apiKeys/client/requests/ApiKeyDeleteRequest.d.ts +97 -0
  19. package/api/resources/apiKeys/client/requests/ApiKeyHistoryRequest.d.ts +57 -0
  20. package/api/resources/apiKeys/client/requests/ApiKeyHistoryRequest.js +5 -0
  21. package/api/resources/apiKeys/client/requests/ApiKeyLatestRequest.d.ts +57 -0
  22. package/api/resources/apiKeys/client/requests/ApiKeyLatestRequest.js +5 -0
  23. package/api/resources/apiKeys/client/requests/ApiKeyRestoreRequest.d.ts +97 -0
  24. package/api/resources/apiKeys/client/requests/ApiKeyRestoreRequest.js +5 -0
  25. package/api/resources/apiKeys/client/requests/ApiKeyRevisionRequest.d.ts +57 -0
  26. package/api/resources/apiKeys/client/requests/ApiKeyRevisionRequest.js +5 -0
  27. package/api/resources/apiKeys/client/requests/ApiKeySearch.d.ts +32 -0
  28. package/api/resources/apiKeys/client/requests/ApiKeySearch.js +5 -0
  29. package/api/resources/apiKeys/client/requests/ApiKeyUpdateRequest.d.ts +115 -0
  30. package/api/resources/apiKeys/client/requests/ApiKeyUpdateRequest.js +5 -0
  31. package/api/resources/apiKeys/client/requests/index.d.ts +8 -0
  32. package/api/resources/apiKeys/client/requests/index.js +2 -0
  33. package/api/resources/apiKeys/index.d.ts +1 -0
  34. package/api/resources/apiKeys/index.js +17 -0
  35. package/api/resources/gdpr/client/Client.d.ts +41 -0
  36. package/api/resources/gdpr/client/Client.js +142 -0
  37. package/api/resources/gdpr/client/index.d.ts +1 -0
  38. package/api/resources/gdpr/client/index.js +17 -0
  39. package/api/resources/gdpr/client/requests/SupportRequest.d.ts +45 -0
  40. package/api/resources/gdpr/client/requests/SupportRequest.js +5 -0
  41. package/api/resources/gdpr/client/requests/index.d.ts +1 -0
  42. package/api/resources/gdpr/client/requests/index.js +2 -0
  43. package/api/resources/gdpr/index.d.ts +1 -0
  44. package/api/resources/gdpr/index.js +17 -0
  45. package/api/resources/index.d.ts +4 -0
  46. package/api/resources/index.js +5 -1
  47. package/api/resources/keys/client/Client.d.ts +9 -0
  48. package/api/resources/keys/client/Client.js +86 -0
  49. package/api/resources/keys/client/requests/DidcommMessageSignRequest.d.ts +48 -0
  50. package/api/resources/keys/client/requests/DidcommMessageSignRequest.js +5 -0
  51. package/api/resources/keys/client/requests/index.d.ts +1 -0
  52. package/api/types/ApiKey.d.ts +11 -0
  53. package/api/types/ApiKey.js +5 -0
  54. package/api/types/ApiKeyCreateOutput.d.ts +10 -0
  55. package/api/types/ApiKeyCreateOutput.js +5 -0
  56. package/api/types/ApiKeyField.d.ts +17 -0
  57. package/api/types/ApiKeyField.js +16 -0
  58. package/api/types/ApiKeyFilter.d.ts +18 -0
  59. package/api/types/ApiKeyFilter.js +5 -0
  60. package/api/types/ApiKeyFilterData.d.ts +8 -0
  61. package/api/types/ApiKeyFilterData.js +5 -0
  62. package/api/types/ApiKeyFull.d.ts +9 -0
  63. package/api/types/ApiKeyFull.js +5 -0
  64. package/api/types/ApiKeyInput.d.ts +13 -0
  65. package/api/types/ApiKeyInput.js +5 -0
  66. package/api/types/{DraftInputData.d.ts → ApiKeyList.d.ts} +2 -1
  67. package/api/types/ApiKeyList.js +5 -0
  68. package/api/types/ApiKeyResource.d.ts +10 -0
  69. package/api/types/ApiKeyResource.js +5 -0
  70. package/api/types/ApiKeySecret.d.ts +10 -0
  71. package/api/types/ApiKeySecret.js +5 -0
  72. package/api/types/ApiKeySort.d.ts +11 -0
  73. package/api/types/ApiKeySort.js +5 -0
  74. package/api/types/Draft.d.ts +10 -0
  75. package/api/types/Draft.js +5 -0
  76. package/api/types/DraftFilterData.d.ts +2 -0
  77. package/api/types/DraftFind.d.ts +4 -0
  78. package/api/types/DraftInput.d.ts +1 -1
  79. package/api/types/SubjectId.d.ts +7 -0
  80. package/api/types/SubjectId.js +5 -0
  81. package/api/types/SupportRequestType.d.ts +13 -0
  82. package/api/types/SupportRequestType.js +12 -0
  83. package/api/types/index.d.ts +14 -1
  84. package/api/types/index.js +14 -1
  85. package/dist/Client.d.ts +6 -0
  86. package/dist/Client.js +24 -14
  87. package/dist/api/errors/index.d.ts +1 -1
  88. package/dist/api/errors/index.js +1 -1
  89. package/dist/api/resources/apiKeys/client/Client.d.ts +181 -0
  90. package/dist/api/resources/apiKeys/client/Client.js +841 -0
  91. package/dist/api/resources/apiKeys/client/index.d.ts +1 -0
  92. package/dist/api/resources/apiKeys/client/index.js +17 -0
  93. package/dist/api/resources/apiKeys/client/requests/ApiKeyCreateRequest.d.ts +69 -0
  94. package/dist/api/resources/apiKeys/client/requests/ApiKeyCreateRequest.js +5 -0
  95. package/dist/api/resources/apiKeys/client/requests/ApiKeyDeleteRequest.d.ts +97 -0
  96. package/dist/api/resources/apiKeys/client/requests/ApiKeyDeleteRequest.js +5 -0
  97. package/dist/api/resources/apiKeys/client/requests/ApiKeyHistoryRequest.d.ts +57 -0
  98. package/dist/api/resources/apiKeys/client/requests/ApiKeyHistoryRequest.js +5 -0
  99. package/dist/api/resources/apiKeys/client/requests/ApiKeyLatestRequest.d.ts +57 -0
  100. package/dist/api/resources/apiKeys/client/requests/ApiKeyLatestRequest.js +5 -0
  101. package/dist/api/resources/apiKeys/client/requests/ApiKeyRestoreRequest.d.ts +97 -0
  102. package/dist/api/resources/apiKeys/client/requests/ApiKeyRestoreRequest.js +5 -0
  103. package/dist/api/resources/apiKeys/client/requests/ApiKeyRevisionRequest.d.ts +57 -0
  104. package/dist/api/resources/apiKeys/client/requests/ApiKeyRevisionRequest.js +5 -0
  105. package/dist/api/resources/apiKeys/client/requests/ApiKeySearch.d.ts +32 -0
  106. package/dist/api/resources/apiKeys/client/requests/ApiKeySearch.js +5 -0
  107. package/dist/api/resources/apiKeys/client/requests/ApiKeyUpdateRequest.d.ts +115 -0
  108. package/dist/api/resources/apiKeys/client/requests/ApiKeyUpdateRequest.js +5 -0
  109. package/dist/api/resources/apiKeys/client/requests/index.d.ts +8 -0
  110. package/dist/api/resources/apiKeys/client/requests/index.js +2 -0
  111. package/dist/api/resources/apiKeys/index.d.ts +1 -0
  112. package/dist/api/resources/apiKeys/index.js +17 -0
  113. package/dist/api/resources/gdpr/client/Client.d.ts +41 -0
  114. package/dist/api/resources/gdpr/client/Client.js +142 -0
  115. package/dist/api/resources/gdpr/client/index.d.ts +1 -0
  116. package/dist/api/resources/gdpr/client/index.js +17 -0
  117. package/dist/api/resources/gdpr/client/requests/SupportRequest.d.ts +45 -0
  118. package/dist/api/resources/gdpr/client/requests/SupportRequest.js +5 -0
  119. package/dist/api/resources/gdpr/client/requests/index.d.ts +1 -0
  120. package/dist/api/resources/gdpr/client/requests/index.js +2 -0
  121. package/dist/api/resources/gdpr/index.d.ts +1 -0
  122. package/dist/api/resources/gdpr/index.js +17 -0
  123. package/dist/api/resources/index.d.ts +4 -0
  124. package/dist/api/resources/index.js +5 -1
  125. package/dist/api/resources/keys/client/Client.d.ts +9 -0
  126. package/dist/api/resources/keys/client/Client.js +86 -0
  127. package/dist/api/resources/keys/client/requests/DidcommMessageSignRequest.d.ts +48 -0
  128. package/dist/api/resources/keys/client/requests/DidcommMessageSignRequest.js +5 -0
  129. package/dist/api/resources/keys/client/requests/index.d.ts +1 -0
  130. package/dist/api/types/ApiKey.d.ts +11 -0
  131. package/dist/api/types/ApiKey.js +5 -0
  132. package/dist/api/types/ApiKeyCreateOutput.d.ts +10 -0
  133. package/dist/api/types/ApiKeyCreateOutput.js +5 -0
  134. package/dist/api/types/ApiKeyField.d.ts +17 -0
  135. package/dist/api/types/ApiKeyField.js +16 -0
  136. package/dist/api/types/ApiKeyFilter.d.ts +18 -0
  137. package/dist/api/types/ApiKeyFilter.js +5 -0
  138. package/dist/api/types/ApiKeyFilterData.d.ts +8 -0
  139. package/dist/api/types/ApiKeyFilterData.js +5 -0
  140. package/dist/api/types/ApiKeyFull.d.ts +9 -0
  141. package/dist/api/types/ApiKeyFull.js +5 -0
  142. package/dist/api/types/ApiKeyInput.d.ts +13 -0
  143. package/dist/api/types/ApiKeyInput.js +5 -0
  144. package/dist/api/types/{DraftInputData.d.ts → ApiKeyList.d.ts} +2 -1
  145. package/dist/api/types/ApiKeyList.js +5 -0
  146. package/dist/api/types/ApiKeyResource.d.ts +10 -0
  147. package/dist/api/types/ApiKeyResource.js +5 -0
  148. package/dist/api/types/ApiKeySecret.d.ts +10 -0
  149. package/dist/api/types/ApiKeySecret.js +5 -0
  150. package/dist/api/types/ApiKeySort.d.ts +11 -0
  151. package/dist/api/types/ApiKeySort.js +5 -0
  152. package/dist/api/types/Draft.d.ts +10 -0
  153. package/dist/api/types/Draft.js +5 -0
  154. package/dist/api/types/DraftFilterData.d.ts +2 -0
  155. package/dist/api/types/DraftFind.d.ts +4 -0
  156. package/dist/api/types/DraftInput.d.ts +1 -1
  157. package/dist/api/types/SubjectId.d.ts +7 -0
  158. package/dist/api/types/SubjectId.js +5 -0
  159. package/dist/api/types/SupportRequestType.d.ts +13 -0
  160. package/dist/api/types/SupportRequestType.js +12 -0
  161. package/dist/api/types/index.d.ts +14 -1
  162. package/dist/api/types/index.js +14 -1
  163. package/dist/documents/credential/draft.d.ts +3 -3
  164. package/dist/documents/credential/flavor.js +9 -0
  165. package/dist/documents/credential/flavor.spec.js +6 -0
  166. package/dist/documents/credential.d.ts +9 -2
  167. package/dist/documents/credential.js +81 -25
  168. package/dist/documents/types.d.ts +6 -1
  169. package/dist/serialization/resources/apiKeys/client/index.d.ts +1 -0
  170. package/dist/serialization/resources/apiKeys/client/index.js +17 -0
  171. package/dist/serialization/resources/apiKeys/client/requests/ApiKeySearch.d.ts +15 -0
  172. package/dist/serialization/resources/apiKeys/client/requests/ApiKeySearch.js +36 -0
  173. package/dist/serialization/resources/apiKeys/client/requests/index.d.ts +1 -0
  174. package/dist/serialization/resources/apiKeys/client/requests/index.js +5 -0
  175. package/dist/serialization/resources/apiKeys/index.d.ts +1 -0
  176. package/dist/serialization/resources/apiKeys/index.js +17 -0
  177. package/dist/serialization/resources/gdpr/client/index.d.ts +1 -0
  178. package/dist/serialization/resources/gdpr/client/index.js +17 -0
  179. package/dist/serialization/resources/gdpr/client/requests/SupportRequest.d.ts +14 -0
  180. package/dist/serialization/resources/gdpr/client/requests/SupportRequest.js +35 -0
  181. package/dist/serialization/resources/gdpr/client/requests/index.d.ts +1 -0
  182. package/dist/serialization/resources/gdpr/client/requests/index.js +5 -0
  183. package/dist/serialization/resources/gdpr/index.d.ts +1 -0
  184. package/dist/serialization/resources/gdpr/index.js +17 -0
  185. package/dist/serialization/resources/index.d.ts +5 -1
  186. package/dist/serialization/resources/index.js +6 -2
  187. package/dist/serialization/resources/keys/client/didcommMessageSign.d.ts +9 -0
  188. package/dist/serialization/resources/keys/client/didcommMessageSign.js +31 -0
  189. package/dist/serialization/resources/keys/client/index.d.ts +1 -0
  190. package/dist/serialization/resources/keys/client/index.js +14 -0
  191. package/dist/serialization/types/ApiKey.d.ts +15 -0
  192. package/dist/serialization/types/ApiKey.js +36 -0
  193. package/dist/serialization/types/ApiKeyCreateOutput.d.ts +14 -0
  194. package/dist/serialization/types/ApiKeyCreateOutput.js +37 -0
  195. package/dist/serialization/types/ApiKeyField.d.ts +10 -0
  196. package/dist/serialization/types/ApiKeyField.js +40 -0
  197. package/dist/serialization/types/ApiKeyFilter.d.ts +28 -0
  198. package/dist/serialization/types/ApiKeyFilter.js +49 -0
  199. package/dist/serialization/types/ApiKeyFilterData.d.ts +15 -0
  200. package/dist/serialization/types/ApiKeyFilterData.js +36 -0
  201. package/dist/serialization/types/ApiKeyFull.d.ts +13 -0
  202. package/dist/serialization/types/ApiKeyFull.js +33 -0
  203. package/dist/serialization/types/ApiKeyInput.d.ts +15 -0
  204. package/dist/serialization/types/ApiKeyInput.js +36 -0
  205. package/dist/serialization/types/ApiKeyList.d.ts +13 -0
  206. package/dist/serialization/types/ApiKeyList.js +34 -0
  207. package/dist/serialization/types/ApiKeyResource.d.ts +14 -0
  208. package/dist/serialization/types/ApiKeyResource.js +37 -0
  209. package/dist/serialization/types/ApiKeySecret.d.ts +12 -0
  210. package/dist/serialization/types/ApiKeySecret.js +33 -0
  211. package/dist/serialization/types/ApiKeySort.d.ts +15 -0
  212. package/dist/serialization/types/ApiKeySort.js +36 -0
  213. package/dist/serialization/types/Draft.d.ts +14 -0
  214. package/dist/serialization/types/{DraftInputData.js → Draft.js} +7 -3
  215. package/dist/serialization/types/DraftFilterData.d.ts +3 -0
  216. package/dist/serialization/types/DraftFilterData.js +3 -0
  217. package/dist/serialization/types/DraftFind.d.ts +3 -0
  218. package/dist/serialization/types/DraftFind.js +3 -0
  219. package/dist/serialization/types/DraftInput.d.ts +2 -2
  220. package/dist/serialization/types/DraftInput.js +2 -2
  221. package/dist/serialization/types/SubjectId.d.ts +10 -0
  222. package/dist/serialization/types/SubjectId.js +31 -0
  223. package/dist/serialization/types/SupportRequestType.d.ts +10 -0
  224. package/dist/serialization/types/SupportRequestType.js +31 -0
  225. package/dist/serialization/types/index.d.ts +14 -1
  226. package/dist/serialization/types/index.js +14 -1
  227. package/documents/credential/draft.d.ts +3 -3
  228. package/documents/credential/flavor.js +9 -0
  229. package/documents/credential/flavor.spec.js +6 -0
  230. package/documents/credential.d.ts +9 -2
  231. package/documents/credential.js +81 -25
  232. package/documents/types.d.ts +6 -1
  233. package/jest.config.js +25 -0
  234. package/package.json +8 -2
  235. package/publish.sh +11 -2
  236. package/sdk.yaml +648 -9
  237. package/serialization/resources/apiKeys/client/index.d.ts +1 -0
  238. package/serialization/resources/apiKeys/client/index.js +17 -0
  239. package/serialization/resources/apiKeys/client/requests/ApiKeySearch.d.ts +15 -0
  240. package/serialization/resources/apiKeys/client/requests/ApiKeySearch.js +36 -0
  241. package/serialization/resources/apiKeys/client/requests/index.d.ts +1 -0
  242. package/serialization/resources/apiKeys/client/requests/index.js +5 -0
  243. package/serialization/resources/apiKeys/index.d.ts +1 -0
  244. package/serialization/resources/apiKeys/index.js +17 -0
  245. package/serialization/resources/gdpr/client/index.d.ts +1 -0
  246. package/serialization/resources/gdpr/client/index.js +17 -0
  247. package/serialization/resources/gdpr/client/requests/SupportRequest.d.ts +14 -0
  248. package/serialization/resources/gdpr/client/requests/SupportRequest.js +35 -0
  249. package/serialization/resources/gdpr/client/requests/index.d.ts +1 -0
  250. package/serialization/resources/gdpr/client/requests/index.js +5 -0
  251. package/serialization/resources/gdpr/index.d.ts +1 -0
  252. package/serialization/resources/gdpr/index.js +17 -0
  253. package/serialization/resources/index.d.ts +5 -1
  254. package/serialization/resources/index.js +6 -2
  255. package/serialization/resources/keys/client/didcommMessageSign.d.ts +9 -0
  256. package/serialization/resources/keys/client/didcommMessageSign.js +31 -0
  257. package/serialization/resources/keys/client/index.d.ts +1 -0
  258. package/serialization/resources/keys/client/index.js +14 -0
  259. package/serialization/types/ApiKey.d.ts +15 -0
  260. package/serialization/types/ApiKey.js +36 -0
  261. package/serialization/types/ApiKeyCreateOutput.d.ts +14 -0
  262. package/serialization/types/ApiKeyCreateOutput.js +37 -0
  263. package/serialization/types/ApiKeyField.d.ts +10 -0
  264. package/serialization/types/ApiKeyField.js +40 -0
  265. package/serialization/types/ApiKeyFilter.d.ts +28 -0
  266. package/serialization/types/ApiKeyFilter.js +49 -0
  267. package/serialization/types/ApiKeyFilterData.d.ts +15 -0
  268. package/serialization/types/ApiKeyFilterData.js +36 -0
  269. package/serialization/types/ApiKeyFull.d.ts +13 -0
  270. package/serialization/types/ApiKeyFull.js +33 -0
  271. package/serialization/types/ApiKeyInput.d.ts +15 -0
  272. package/serialization/types/ApiKeyInput.js +36 -0
  273. package/serialization/types/ApiKeyList.d.ts +13 -0
  274. package/serialization/types/ApiKeyList.js +34 -0
  275. package/serialization/types/ApiKeyResource.d.ts +14 -0
  276. package/serialization/types/ApiKeyResource.js +37 -0
  277. package/serialization/types/ApiKeySecret.d.ts +12 -0
  278. package/serialization/types/ApiKeySecret.js +33 -0
  279. package/serialization/types/ApiKeySort.d.ts +15 -0
  280. package/serialization/types/ApiKeySort.js +36 -0
  281. package/serialization/types/Draft.d.ts +14 -0
  282. package/serialization/types/{DraftInputData.js → Draft.js} +7 -3
  283. package/serialization/types/DraftFilterData.d.ts +3 -0
  284. package/serialization/types/DraftFilterData.js +3 -0
  285. package/serialization/types/DraftFind.d.ts +3 -0
  286. package/serialization/types/DraftFind.js +3 -0
  287. package/serialization/types/DraftInput.d.ts +2 -2
  288. package/serialization/types/DraftInput.js +2 -2
  289. package/serialization/types/SubjectId.d.ts +10 -0
  290. package/serialization/types/SubjectId.js +31 -0
  291. package/serialization/types/SupportRequestType.d.ts +10 -0
  292. package/serialization/types/SupportRequestType.js +31 -0
  293. package/serialization/types/index.d.ts +14 -1
  294. package/serialization/types/index.js +14 -1
  295. package/dist/serialization/types/DraftInputData.d.ts +0 -13
  296. package/serialization/types/DraftInputData.d.ts +0 -13
  297. /package/api/{types/DraftInputData.js → resources/apiKeys/client/requests/ApiKeyCreateRequest.js} +0 -0
  298. /package/{dist/api/types/DraftInputData.js → api/resources/apiKeys/client/requests/ApiKeyDeleteRequest.js} +0 -0
@@ -0,0 +1,841 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.ApiKeys = void 0;
42
+ const environments = __importStar(require("../../../../environments"));
43
+ const core = __importStar(require("../../../../core"));
44
+ const Truvity = __importStar(require("../../../index"));
45
+ const serializers = __importStar(require("../../../../serialization/index"));
46
+ const url_join_1 = __importDefault(require("url-join"));
47
+ const errors = __importStar(require("../../../../errors/index"));
48
+ /**
49
+ * The API to manage Truvity API's keys.
50
+ */
51
+ class ApiKeys {
52
+ constructor(_options) {
53
+ this._options = _options;
54
+ }
55
+ /**
56
+ * Create api-key's resource.
57
+ * @throws {@link Truvity.BadRequestError}
58
+ * @throws {@link Truvity.UnauthorizedError}
59
+ * @throws {@link Truvity.ForbiddenError}
60
+ * @throws {@link Truvity.UnsupportedMediaTypeError}
61
+ * @throws {@link Truvity.InternalServerError}
62
+ *
63
+ * @example
64
+ * await truvity.apiKeys.apiKeyCreate({
65
+ * body: {}
66
+ * })
67
+ *
68
+ * @example
69
+ * await truvity.apiKeys.apiKeyCreate({
70
+ * idempotencyKey: "string",
71
+ * body: {}
72
+ * })
73
+ */
74
+ apiKeyCreate(request, requestOptions) {
75
+ var _a, _b;
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ const { idempotencyKey, body: _body } = request;
78
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
79
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, "api-keys"),
80
+ method: "POST",
81
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": idempotencyKey != null ? idempotencyKey : undefined }, (yield this._getCustomAuthorizationHeaders())),
82
+ contentType: "application/json",
83
+ body: yield serializers.ApiKeyInput.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
84
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
85
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
86
+ });
87
+ if (_response.ok) {
88
+ return yield serializers.ApiKeyCreateOutput.parseOrThrow(_response.body, {
89
+ unrecognizedObjectKeys: "passthrough",
90
+ allowUnrecognizedUnionMembers: true,
91
+ allowUnrecognizedEnumValues: true,
92
+ breadcrumbsPrefix: ["response"],
93
+ });
94
+ }
95
+ if (_response.error.reason === "status-code") {
96
+ switch (_response.error.statusCode) {
97
+ case 400:
98
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
99
+ unrecognizedObjectKeys: "passthrough",
100
+ allowUnrecognizedUnionMembers: true,
101
+ allowUnrecognizedEnumValues: true,
102
+ breadcrumbsPrefix: ["response"],
103
+ }));
104
+ case 401:
105
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
106
+ unrecognizedObjectKeys: "passthrough",
107
+ allowUnrecognizedUnionMembers: true,
108
+ allowUnrecognizedEnumValues: true,
109
+ breadcrumbsPrefix: ["response"],
110
+ }));
111
+ case 403:
112
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
113
+ unrecognizedObjectKeys: "passthrough",
114
+ allowUnrecognizedUnionMembers: true,
115
+ allowUnrecognizedEnumValues: true,
116
+ breadcrumbsPrefix: ["response"],
117
+ }));
118
+ case 415:
119
+ throw new Truvity.UnsupportedMediaTypeError(yield serializers.ProblemUnsupportedMediaType.parseOrThrow(_response.error.body, {
120
+ unrecognizedObjectKeys: "passthrough",
121
+ allowUnrecognizedUnionMembers: true,
122
+ allowUnrecognizedEnumValues: true,
123
+ breadcrumbsPrefix: ["response"],
124
+ }));
125
+ case 500:
126
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
127
+ unrecognizedObjectKeys: "passthrough",
128
+ allowUnrecognizedUnionMembers: true,
129
+ allowUnrecognizedEnumValues: true,
130
+ breadcrumbsPrefix: ["response"],
131
+ }));
132
+ default:
133
+ throw new errors.TruvityError({
134
+ statusCode: _response.error.statusCode,
135
+ body: _response.error.body,
136
+ });
137
+ }
138
+ }
139
+ switch (_response.error.reason) {
140
+ case "non-json":
141
+ throw new errors.TruvityError({
142
+ statusCode: _response.error.statusCode,
143
+ body: _response.error.rawBody,
144
+ });
145
+ case "timeout":
146
+ throw new errors.TruvityTimeoutError();
147
+ case "unknown":
148
+ throw new errors.TruvityError({
149
+ message: _response.error.errorMessage,
150
+ });
151
+ }
152
+ });
153
+ }
154
+ /**
155
+ * Take a look at [GET with body payload](https://opensource.zalando.com/restful-api-guidelines/#get-with-body)
156
+ *
157
+ * - no resources created: Returns all api-keys matching the query passed as request input payload.
158
+ * @throws {@link Truvity.BadRequestError}
159
+ * @throws {@link Truvity.UnauthorizedError}
160
+ * @throws {@link Truvity.ForbiddenError}
161
+ * @throws {@link Truvity.UnsupportedMediaTypeError}
162
+ * @throws {@link Truvity.InternalServerError}
163
+ *
164
+ * @example
165
+ * await truvity.apiKeys.apiKeySearch()
166
+ */
167
+ apiKeySearch(request = {}, requestOptions) {
168
+ var _a, _b;
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
171
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, "api-keys/search"),
172
+ method: "POST",
173
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
174
+ contentType: "application/json",
175
+ body: yield serializers.ApiKeySearch.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
176
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
177
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
178
+ });
179
+ if (_response.ok) {
180
+ return yield serializers.ApiKeyList.parseOrThrow(_response.body, {
181
+ unrecognizedObjectKeys: "passthrough",
182
+ allowUnrecognizedUnionMembers: true,
183
+ allowUnrecognizedEnumValues: true,
184
+ breadcrumbsPrefix: ["response"],
185
+ });
186
+ }
187
+ if (_response.error.reason === "status-code") {
188
+ switch (_response.error.statusCode) {
189
+ case 400:
190
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
191
+ unrecognizedObjectKeys: "passthrough",
192
+ allowUnrecognizedUnionMembers: true,
193
+ allowUnrecognizedEnumValues: true,
194
+ breadcrumbsPrefix: ["response"],
195
+ }));
196
+ case 401:
197
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
198
+ unrecognizedObjectKeys: "passthrough",
199
+ allowUnrecognizedUnionMembers: true,
200
+ allowUnrecognizedEnumValues: true,
201
+ breadcrumbsPrefix: ["response"],
202
+ }));
203
+ case 403:
204
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
205
+ unrecognizedObjectKeys: "passthrough",
206
+ allowUnrecognizedUnionMembers: true,
207
+ allowUnrecognizedEnumValues: true,
208
+ breadcrumbsPrefix: ["response"],
209
+ }));
210
+ case 415:
211
+ throw new Truvity.UnsupportedMediaTypeError(yield serializers.ProblemUnsupportedMediaType.parseOrThrow(_response.error.body, {
212
+ unrecognizedObjectKeys: "passthrough",
213
+ allowUnrecognizedUnionMembers: true,
214
+ allowUnrecognizedEnumValues: true,
215
+ breadcrumbsPrefix: ["response"],
216
+ }));
217
+ case 500:
218
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
219
+ unrecognizedObjectKeys: "passthrough",
220
+ allowUnrecognizedUnionMembers: true,
221
+ allowUnrecognizedEnumValues: true,
222
+ breadcrumbsPrefix: ["response"],
223
+ }));
224
+ default:
225
+ throw new errors.TruvityError({
226
+ statusCode: _response.error.statusCode,
227
+ body: _response.error.body,
228
+ });
229
+ }
230
+ }
231
+ switch (_response.error.reason) {
232
+ case "non-json":
233
+ throw new errors.TruvityError({
234
+ statusCode: _response.error.statusCode,
235
+ body: _response.error.rawBody,
236
+ });
237
+ case "timeout":
238
+ throw new errors.TruvityTimeoutError();
239
+ case "unknown":
240
+ throw new errors.TruvityError({
241
+ message: _response.error.errorMessage,
242
+ });
243
+ }
244
+ });
245
+ }
246
+ /**
247
+ * Read the latest revision of the api-key's resource.
248
+ * @throws {@link Truvity.BadRequestError}
249
+ * @throws {@link Truvity.UnauthorizedError}
250
+ * @throws {@link Truvity.ForbiddenError}
251
+ * @throws {@link Truvity.NotFoundError}
252
+ * @throws {@link Truvity.InternalServerError}
253
+ *
254
+ * @example
255
+ * await truvity.apiKeys.apiKeyLatest("id")
256
+ *
257
+ * @example
258
+ * await truvity.apiKeys.apiKeyLatest("string", {
259
+ * ifNoneMatch: "string"
260
+ * })
261
+ */
262
+ apiKeyLatest(id, request = {}, requestOptions) {
263
+ var _a, _b;
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ const { ifNoneMatch } = request;
266
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
267
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, `api-keys/${yield serializers.ResourceId.jsonOrThrow(id)}`),
268
+ method: "GET",
269
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "If-None-Match": ifNoneMatch != null ? ifNoneMatch : undefined }, (yield this._getCustomAuthorizationHeaders())),
270
+ contentType: "application/json",
271
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
272
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
273
+ });
274
+ if (_response.ok) {
275
+ return yield serializers.ApiKeyResource.parseOrThrow(_response.body, {
276
+ unrecognizedObjectKeys: "passthrough",
277
+ allowUnrecognizedUnionMembers: true,
278
+ allowUnrecognizedEnumValues: true,
279
+ breadcrumbsPrefix: ["response"],
280
+ });
281
+ }
282
+ if (_response.error.reason === "status-code") {
283
+ switch (_response.error.statusCode) {
284
+ case 400:
285
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
286
+ unrecognizedObjectKeys: "passthrough",
287
+ allowUnrecognizedUnionMembers: true,
288
+ allowUnrecognizedEnumValues: true,
289
+ breadcrumbsPrefix: ["response"],
290
+ }));
291
+ case 401:
292
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
293
+ unrecognizedObjectKeys: "passthrough",
294
+ allowUnrecognizedUnionMembers: true,
295
+ allowUnrecognizedEnumValues: true,
296
+ breadcrumbsPrefix: ["response"],
297
+ }));
298
+ case 403:
299
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
300
+ unrecognizedObjectKeys: "passthrough",
301
+ allowUnrecognizedUnionMembers: true,
302
+ allowUnrecognizedEnumValues: true,
303
+ breadcrumbsPrefix: ["response"],
304
+ }));
305
+ case 404:
306
+ throw new Truvity.NotFoundError(_response.error.body);
307
+ case 500:
308
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
309
+ unrecognizedObjectKeys: "passthrough",
310
+ allowUnrecognizedUnionMembers: true,
311
+ allowUnrecognizedEnumValues: true,
312
+ breadcrumbsPrefix: ["response"],
313
+ }));
314
+ default:
315
+ throw new errors.TruvityError({
316
+ statusCode: _response.error.statusCode,
317
+ body: _response.error.body,
318
+ });
319
+ }
320
+ }
321
+ switch (_response.error.reason) {
322
+ case "non-json":
323
+ throw new errors.TruvityError({
324
+ statusCode: _response.error.statusCode,
325
+ body: _response.error.rawBody,
326
+ });
327
+ case "timeout":
328
+ throw new errors.TruvityTimeoutError();
329
+ case "unknown":
330
+ throw new errors.TruvityError({
331
+ message: _response.error.errorMessage,
332
+ });
333
+ }
334
+ });
335
+ }
336
+ /**
337
+ * Delete api-key's resource.
338
+ * @throws {@link Truvity.BadRequestError}
339
+ * @throws {@link Truvity.UnauthorizedError}
340
+ * @throws {@link Truvity.ForbiddenError}
341
+ * @throws {@link Truvity.NotFoundError}
342
+ * @throws {@link Truvity.MethodNotAllowedError}
343
+ * @throws {@link Truvity.PreconditionFailedError}
344
+ * @throws {@link Truvity.InternalServerError}
345
+ *
346
+ * @example
347
+ * await truvity.apiKeys.apiKeyDelete("id", {
348
+ * ifMatch: "If-Match"
349
+ * })
350
+ *
351
+ * @example
352
+ * await truvity.apiKeys.apiKeyDelete("string", {
353
+ * idempotencyKey: "string",
354
+ * ifMatch: "string"
355
+ * })
356
+ */
357
+ apiKeyDelete(id, request, requestOptions) {
358
+ var _a, _b;
359
+ return __awaiter(this, void 0, void 0, function* () {
360
+ const { idempotencyKey, ifMatch } = request;
361
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
362
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, `api-keys/${yield serializers.ResourceId.jsonOrThrow(id)}`),
363
+ method: "DELETE",
364
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": idempotencyKey != null ? idempotencyKey : undefined, "If-Match": ifMatch }, (yield this._getCustomAuthorizationHeaders())),
365
+ contentType: "application/json",
366
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
367
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
368
+ });
369
+ if (_response.ok) {
370
+ return;
371
+ }
372
+ if (_response.error.reason === "status-code") {
373
+ switch (_response.error.statusCode) {
374
+ case 400:
375
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
376
+ unrecognizedObjectKeys: "passthrough",
377
+ allowUnrecognizedUnionMembers: true,
378
+ allowUnrecognizedEnumValues: true,
379
+ breadcrumbsPrefix: ["response"],
380
+ }));
381
+ case 401:
382
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
383
+ unrecognizedObjectKeys: "passthrough",
384
+ allowUnrecognizedUnionMembers: true,
385
+ allowUnrecognizedEnumValues: true,
386
+ breadcrumbsPrefix: ["response"],
387
+ }));
388
+ case 403:
389
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
390
+ unrecognizedObjectKeys: "passthrough",
391
+ allowUnrecognizedUnionMembers: true,
392
+ allowUnrecognizedEnumValues: true,
393
+ breadcrumbsPrefix: ["response"],
394
+ }));
395
+ case 404:
396
+ throw new Truvity.NotFoundError(_response.error.body);
397
+ case 405:
398
+ throw new Truvity.MethodNotAllowedError(_response.error.body);
399
+ case 412:
400
+ throw new Truvity.PreconditionFailedError(yield serializers.ProblemConflictResource.parseOrThrow(_response.error.body, {
401
+ unrecognizedObjectKeys: "passthrough",
402
+ allowUnrecognizedUnionMembers: true,
403
+ allowUnrecognizedEnumValues: true,
404
+ breadcrumbsPrefix: ["response"],
405
+ }));
406
+ case 500:
407
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
408
+ unrecognizedObjectKeys: "passthrough",
409
+ allowUnrecognizedUnionMembers: true,
410
+ allowUnrecognizedEnumValues: true,
411
+ breadcrumbsPrefix: ["response"],
412
+ }));
413
+ default:
414
+ throw new errors.TruvityError({
415
+ statusCode: _response.error.statusCode,
416
+ body: _response.error.body,
417
+ });
418
+ }
419
+ }
420
+ switch (_response.error.reason) {
421
+ case "non-json":
422
+ throw new errors.TruvityError({
423
+ statusCode: _response.error.statusCode,
424
+ body: _response.error.rawBody,
425
+ });
426
+ case "timeout":
427
+ throw new errors.TruvityTimeoutError();
428
+ case "unknown":
429
+ throw new errors.TruvityError({
430
+ message: _response.error.errorMessage,
431
+ });
432
+ }
433
+ });
434
+ }
435
+ /**
436
+ * Update api-key's resource.
437
+ * @throws {@link Truvity.BadRequestError}
438
+ * @throws {@link Truvity.UnauthorizedError}
439
+ * @throws {@link Truvity.ForbiddenError}
440
+ * @throws {@link Truvity.NotFoundError}
441
+ * @throws {@link Truvity.MethodNotAllowedError}
442
+ * @throws {@link Truvity.PreconditionFailedError}
443
+ * @throws {@link Truvity.UnsupportedMediaTypeError}
444
+ * @throws {@link Truvity.InternalServerError}
445
+ *
446
+ * @example
447
+ * await truvity.apiKeys.apiKeyUpdate("id", {
448
+ * ifMatch: "If-Match",
449
+ * body: {}
450
+ * })
451
+ *
452
+ * @example
453
+ * await truvity.apiKeys.apiKeyUpdate("string", {
454
+ * idempotencyKey: "string",
455
+ * ifMatch: "string",
456
+ * body: {}
457
+ * })
458
+ */
459
+ apiKeyUpdate(id, request, requestOptions) {
460
+ var _a, _b;
461
+ return __awaiter(this, void 0, void 0, function* () {
462
+ const { idempotencyKey, ifMatch, body: _body } = request;
463
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
464
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, `api-keys/${yield serializers.ResourceId.jsonOrThrow(id)}`),
465
+ method: "PATCH",
466
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": idempotencyKey != null ? idempotencyKey : undefined, "If-Match": ifMatch }, (yield this._getCustomAuthorizationHeaders())),
467
+ contentType: "application/json",
468
+ body: yield serializers.ApiKeyInput.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
469
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
470
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
471
+ });
472
+ if (_response.ok) {
473
+ return yield serializers.ApiKeyResource.parseOrThrow(_response.body, {
474
+ unrecognizedObjectKeys: "passthrough",
475
+ allowUnrecognizedUnionMembers: true,
476
+ allowUnrecognizedEnumValues: true,
477
+ breadcrumbsPrefix: ["response"],
478
+ });
479
+ }
480
+ if (_response.error.reason === "status-code") {
481
+ switch (_response.error.statusCode) {
482
+ case 400:
483
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
484
+ unrecognizedObjectKeys: "passthrough",
485
+ allowUnrecognizedUnionMembers: true,
486
+ allowUnrecognizedEnumValues: true,
487
+ breadcrumbsPrefix: ["response"],
488
+ }));
489
+ case 401:
490
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
491
+ unrecognizedObjectKeys: "passthrough",
492
+ allowUnrecognizedUnionMembers: true,
493
+ allowUnrecognizedEnumValues: true,
494
+ breadcrumbsPrefix: ["response"],
495
+ }));
496
+ case 403:
497
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
498
+ unrecognizedObjectKeys: "passthrough",
499
+ allowUnrecognizedUnionMembers: true,
500
+ allowUnrecognizedEnumValues: true,
501
+ breadcrumbsPrefix: ["response"],
502
+ }));
503
+ case 404:
504
+ throw new Truvity.NotFoundError(_response.error.body);
505
+ case 405:
506
+ throw new Truvity.MethodNotAllowedError(_response.error.body);
507
+ case 412:
508
+ throw new Truvity.PreconditionFailedError(yield serializers.ProblemConflictResource.parseOrThrow(_response.error.body, {
509
+ unrecognizedObjectKeys: "passthrough",
510
+ allowUnrecognizedUnionMembers: true,
511
+ allowUnrecognizedEnumValues: true,
512
+ breadcrumbsPrefix: ["response"],
513
+ }));
514
+ case 415:
515
+ throw new Truvity.UnsupportedMediaTypeError(yield serializers.ProblemUnsupportedMediaType.parseOrThrow(_response.error.body, {
516
+ unrecognizedObjectKeys: "passthrough",
517
+ allowUnrecognizedUnionMembers: true,
518
+ allowUnrecognizedEnumValues: true,
519
+ breadcrumbsPrefix: ["response"],
520
+ }));
521
+ case 500:
522
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
523
+ unrecognizedObjectKeys: "passthrough",
524
+ allowUnrecognizedUnionMembers: true,
525
+ allowUnrecognizedEnumValues: true,
526
+ breadcrumbsPrefix: ["response"],
527
+ }));
528
+ default:
529
+ throw new errors.TruvityError({
530
+ statusCode: _response.error.statusCode,
531
+ body: _response.error.body,
532
+ });
533
+ }
534
+ }
535
+ switch (_response.error.reason) {
536
+ case "non-json":
537
+ throw new errors.TruvityError({
538
+ statusCode: _response.error.statusCode,
539
+ body: _response.error.rawBody,
540
+ });
541
+ case "timeout":
542
+ throw new errors.TruvityTimeoutError();
543
+ case "unknown":
544
+ throw new errors.TruvityError({
545
+ message: _response.error.errorMessage,
546
+ });
547
+ }
548
+ });
549
+ }
550
+ /**
551
+ * Restore api-key's resource.
552
+ * @throws {@link Truvity.BadRequestError}
553
+ * @throws {@link Truvity.UnauthorizedError}
554
+ * @throws {@link Truvity.ForbiddenError}
555
+ * @throws {@link Truvity.NotFoundError}
556
+ * @throws {@link Truvity.MethodNotAllowedError}
557
+ * @throws {@link Truvity.PreconditionFailedError}
558
+ * @throws {@link Truvity.InternalServerError}
559
+ *
560
+ * @example
561
+ * await truvity.apiKeys.apiKeyRestore("id", {
562
+ * ifMatch: "If-Match"
563
+ * })
564
+ *
565
+ * @example
566
+ * await truvity.apiKeys.apiKeyRestore("string", {
567
+ * idempotencyKey: "string",
568
+ * ifMatch: "string"
569
+ * })
570
+ */
571
+ apiKeyRestore(id, request, requestOptions) {
572
+ var _a, _b;
573
+ return __awaiter(this, void 0, void 0, function* () {
574
+ const { idempotencyKey, ifMatch } = request;
575
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
576
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, `api-keys/${yield serializers.ResourceId.jsonOrThrow(id)}/restore`),
577
+ method: "POST",
578
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "Idempotency-Key": idempotencyKey != null ? idempotencyKey : undefined, "If-Match": ifMatch }, (yield this._getCustomAuthorizationHeaders())),
579
+ contentType: "application/json",
580
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
581
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
582
+ });
583
+ if (_response.ok) {
584
+ return yield serializers.ApiKeyResource.parseOrThrow(_response.body, {
585
+ unrecognizedObjectKeys: "passthrough",
586
+ allowUnrecognizedUnionMembers: true,
587
+ allowUnrecognizedEnumValues: true,
588
+ breadcrumbsPrefix: ["response"],
589
+ });
590
+ }
591
+ if (_response.error.reason === "status-code") {
592
+ switch (_response.error.statusCode) {
593
+ case 400:
594
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
595
+ unrecognizedObjectKeys: "passthrough",
596
+ allowUnrecognizedUnionMembers: true,
597
+ allowUnrecognizedEnumValues: true,
598
+ breadcrumbsPrefix: ["response"],
599
+ }));
600
+ case 401:
601
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
602
+ unrecognizedObjectKeys: "passthrough",
603
+ allowUnrecognizedUnionMembers: true,
604
+ allowUnrecognizedEnumValues: true,
605
+ breadcrumbsPrefix: ["response"],
606
+ }));
607
+ case 403:
608
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
609
+ unrecognizedObjectKeys: "passthrough",
610
+ allowUnrecognizedUnionMembers: true,
611
+ allowUnrecognizedEnumValues: true,
612
+ breadcrumbsPrefix: ["response"],
613
+ }));
614
+ case 404:
615
+ throw new Truvity.NotFoundError(_response.error.body);
616
+ case 405:
617
+ throw new Truvity.MethodNotAllowedError(_response.error.body);
618
+ case 412:
619
+ throw new Truvity.PreconditionFailedError(yield serializers.ProblemConflictResource.parseOrThrow(_response.error.body, {
620
+ unrecognizedObjectKeys: "passthrough",
621
+ allowUnrecognizedUnionMembers: true,
622
+ allowUnrecognizedEnumValues: true,
623
+ breadcrumbsPrefix: ["response"],
624
+ }));
625
+ case 500:
626
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
627
+ unrecognizedObjectKeys: "passthrough",
628
+ allowUnrecognizedUnionMembers: true,
629
+ allowUnrecognizedEnumValues: true,
630
+ breadcrumbsPrefix: ["response"],
631
+ }));
632
+ default:
633
+ throw new errors.TruvityError({
634
+ statusCode: _response.error.statusCode,
635
+ body: _response.error.body,
636
+ });
637
+ }
638
+ }
639
+ switch (_response.error.reason) {
640
+ case "non-json":
641
+ throw new errors.TruvityError({
642
+ statusCode: _response.error.statusCode,
643
+ body: _response.error.rawBody,
644
+ });
645
+ case "timeout":
646
+ throw new errors.TruvityTimeoutError();
647
+ case "unknown":
648
+ throw new errors.TruvityError({
649
+ message: _response.error.errorMessage,
650
+ });
651
+ }
652
+ });
653
+ }
654
+ /**
655
+ * History of the api-keys' resources.
656
+ * @throws {@link Truvity.BadRequestError}
657
+ * @throws {@link Truvity.UnauthorizedError}
658
+ * @throws {@link Truvity.ForbiddenError}
659
+ * @throws {@link Truvity.NotFoundError}
660
+ * @throws {@link Truvity.InternalServerError}
661
+ *
662
+ * @example
663
+ * await truvity.apiKeys.apiKeyHistory("id")
664
+ *
665
+ * @example
666
+ * await truvity.apiKeys.apiKeyHistory("string", {
667
+ * ifNoneMatch: "string"
668
+ * })
669
+ */
670
+ apiKeyHistory(id, request = {}, requestOptions) {
671
+ var _a, _b;
672
+ return __awaiter(this, void 0, void 0, function* () {
673
+ const { ifNoneMatch } = request;
674
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
675
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, `api-keys/${yield serializers.ResourceId.jsonOrThrow(id)}/revisions`),
676
+ method: "GET",
677
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "If-None-Match": ifNoneMatch != null ? ifNoneMatch : undefined }, (yield this._getCustomAuthorizationHeaders())),
678
+ contentType: "application/json",
679
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
680
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
681
+ });
682
+ if (_response.ok) {
683
+ return yield serializers.ApiKeyList.parseOrThrow(_response.body, {
684
+ unrecognizedObjectKeys: "passthrough",
685
+ allowUnrecognizedUnionMembers: true,
686
+ allowUnrecognizedEnumValues: true,
687
+ breadcrumbsPrefix: ["response"],
688
+ });
689
+ }
690
+ if (_response.error.reason === "status-code") {
691
+ switch (_response.error.statusCode) {
692
+ case 400:
693
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
694
+ unrecognizedObjectKeys: "passthrough",
695
+ allowUnrecognizedUnionMembers: true,
696
+ allowUnrecognizedEnumValues: true,
697
+ breadcrumbsPrefix: ["response"],
698
+ }));
699
+ case 401:
700
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
701
+ unrecognizedObjectKeys: "passthrough",
702
+ allowUnrecognizedUnionMembers: true,
703
+ allowUnrecognizedEnumValues: true,
704
+ breadcrumbsPrefix: ["response"],
705
+ }));
706
+ case 403:
707
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
708
+ unrecognizedObjectKeys: "passthrough",
709
+ allowUnrecognizedUnionMembers: true,
710
+ allowUnrecognizedEnumValues: true,
711
+ breadcrumbsPrefix: ["response"],
712
+ }));
713
+ case 404:
714
+ throw new Truvity.NotFoundError(_response.error.body);
715
+ case 500:
716
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
717
+ unrecognizedObjectKeys: "passthrough",
718
+ allowUnrecognizedUnionMembers: true,
719
+ allowUnrecognizedEnumValues: true,
720
+ breadcrumbsPrefix: ["response"],
721
+ }));
722
+ default:
723
+ throw new errors.TruvityError({
724
+ statusCode: _response.error.statusCode,
725
+ body: _response.error.body,
726
+ });
727
+ }
728
+ }
729
+ switch (_response.error.reason) {
730
+ case "non-json":
731
+ throw new errors.TruvityError({
732
+ statusCode: _response.error.statusCode,
733
+ body: _response.error.rawBody,
734
+ });
735
+ case "timeout":
736
+ throw new errors.TruvityTimeoutError();
737
+ case "unknown":
738
+ throw new errors.TruvityError({
739
+ message: _response.error.errorMessage,
740
+ });
741
+ }
742
+ });
743
+ }
744
+ /**
745
+ * Read the specific version of the api-key's resource.
746
+ * @throws {@link Truvity.BadRequestError}
747
+ * @throws {@link Truvity.UnauthorizedError}
748
+ * @throws {@link Truvity.ForbiddenError}
749
+ * @throws {@link Truvity.NotFoundError}
750
+ * @throws {@link Truvity.InternalServerError}
751
+ *
752
+ * @example
753
+ * await truvity.apiKeys.apiKeyRevision("id", 1)
754
+ *
755
+ * @example
756
+ * await truvity.apiKeys.apiKeyRevision("string", 1, {
757
+ * ifNoneMatch: "string"
758
+ * })
759
+ */
760
+ apiKeyRevision(id, revision, request = {}, requestOptions) {
761
+ var _a, _b;
762
+ return __awaiter(this, void 0, void 0, function* () {
763
+ const { ifNoneMatch } = request;
764
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
765
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.TruvityEnvironment.Default, `api-keys/${yield serializers.ResourceId.jsonOrThrow(id)}/revisions/${yield serializers.Revision.jsonOrThrow(revision)}`),
766
+ method: "GET",
767
+ headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@truvity/sdk", "X-Fern-SDK-Version": "0.0.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, "If-None-Match": ifNoneMatch != null ? ifNoneMatch : undefined }, (yield this._getCustomAuthorizationHeaders())),
768
+ contentType: "application/json",
769
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
770
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
771
+ });
772
+ if (_response.ok) {
773
+ return yield serializers.ApiKeyResource.parseOrThrow(_response.body, {
774
+ unrecognizedObjectKeys: "passthrough",
775
+ allowUnrecognizedUnionMembers: true,
776
+ allowUnrecognizedEnumValues: true,
777
+ breadcrumbsPrefix: ["response"],
778
+ });
779
+ }
780
+ if (_response.error.reason === "status-code") {
781
+ switch (_response.error.statusCode) {
782
+ case 400:
783
+ throw new Truvity.BadRequestError(yield serializers.BadRequestErrorBody.parseOrThrow(_response.error.body, {
784
+ unrecognizedObjectKeys: "passthrough",
785
+ allowUnrecognizedUnionMembers: true,
786
+ allowUnrecognizedEnumValues: true,
787
+ breadcrumbsPrefix: ["response"],
788
+ }));
789
+ case 401:
790
+ throw new Truvity.UnauthorizedError(yield serializers.ProblemUnauthorized.parseOrThrow(_response.error.body, {
791
+ unrecognizedObjectKeys: "passthrough",
792
+ allowUnrecognizedUnionMembers: true,
793
+ allowUnrecognizedEnumValues: true,
794
+ breadcrumbsPrefix: ["response"],
795
+ }));
796
+ case 403:
797
+ throw new Truvity.ForbiddenError(yield serializers.ProblemForbidden.parseOrThrow(_response.error.body, {
798
+ unrecognizedObjectKeys: "passthrough",
799
+ allowUnrecognizedUnionMembers: true,
800
+ allowUnrecognizedEnumValues: true,
801
+ breadcrumbsPrefix: ["response"],
802
+ }));
803
+ case 404:
804
+ throw new Truvity.NotFoundError(_response.error.body);
805
+ case 500:
806
+ throw new Truvity.InternalServerError(yield serializers.ProblemInternalServerError.parseOrThrow(_response.error.body, {
807
+ unrecognizedObjectKeys: "passthrough",
808
+ allowUnrecognizedUnionMembers: true,
809
+ allowUnrecognizedEnumValues: true,
810
+ breadcrumbsPrefix: ["response"],
811
+ }));
812
+ default:
813
+ throw new errors.TruvityError({
814
+ statusCode: _response.error.statusCode,
815
+ body: _response.error.body,
816
+ });
817
+ }
818
+ }
819
+ switch (_response.error.reason) {
820
+ case "non-json":
821
+ throw new errors.TruvityError({
822
+ statusCode: _response.error.statusCode,
823
+ body: _response.error.rawBody,
824
+ });
825
+ case "timeout":
826
+ throw new errors.TruvityTimeoutError();
827
+ case "unknown":
828
+ throw new errors.TruvityError({
829
+ message: _response.error.errorMessage,
830
+ });
831
+ }
832
+ });
833
+ }
834
+ _getCustomAuthorizationHeaders() {
835
+ return __awaiter(this, void 0, void 0, function* () {
836
+ const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
837
+ return { "X-API-KEY": apiKeyValue };
838
+ });
839
+ }
840
+ }
841
+ exports.ApiKeys = ApiKeys;