@kravc/dos 1.12.6 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (498) hide show
  1. package/README.md +31 -994
  2. package/dist/Component/Component.d.ts +43 -0
  3. package/dist/Component/Component.d.ts.map +1 -0
  4. package/dist/Component/Component.js +99 -0
  5. package/dist/Component/Component.js.map +1 -0
  6. package/dist/Component/index.d.ts +4 -0
  7. package/dist/Component/index.d.ts.map +1 -0
  8. package/dist/Component/index.js +10 -0
  9. package/dist/Component/index.js.map +1 -0
  10. package/dist/Context/Context.d.ts +86 -0
  11. package/dist/Context/Context.d.ts.map +1 -0
  12. package/dist/Context/Context.js +148 -0
  13. package/dist/Context/Context.js.map +1 -0
  14. package/dist/Context/Request.d.ts +35 -0
  15. package/dist/Context/Request.d.ts.map +1 -0
  16. package/dist/Context/Request.js +3 -0
  17. package/dist/Context/Request.js.map +1 -0
  18. package/dist/Context/__tests__/__helpers.d.ts +14 -0
  19. package/dist/Context/__tests__/__helpers.d.ts.map +1 -0
  20. package/dist/Context/__tests__/__helpers.js +69 -0
  21. package/dist/Context/__tests__/__helpers.js.map +1 -0
  22. package/dist/Context/getHttpMethod.d.ts +6 -0
  23. package/dist/Context/getHttpMethod.d.ts.map +1 -0
  24. package/dist/Context/getHttpMethod.js +16 -0
  25. package/dist/Context/getHttpMethod.js.map +1 -0
  26. package/dist/Context/getHttpPath.d.ts +6 -0
  27. package/dist/Context/getHttpPath.d.ts.map +1 -0
  28. package/dist/Context/getHttpPath.js +25 -0
  29. package/dist/Context/getHttpPath.js.map +1 -0
  30. package/dist/Context/getMutationParameters.d.ts +8 -0
  31. package/dist/Context/getMutationParameters.d.ts.map +1 -0
  32. package/dist/Context/getMutationParameters.js +25 -0
  33. package/dist/Context/getMutationParameters.js.map +1 -0
  34. package/dist/Context/getOperationId.d.ts +6 -0
  35. package/dist/Context/getOperationId.d.ts.map +1 -0
  36. package/dist/Context/getOperationId.js +21 -0
  37. package/dist/Context/getOperationId.js.map +1 -0
  38. package/dist/Context/getQueryParameters.d.ts +5 -0
  39. package/dist/Context/getQueryParameters.d.ts.map +1 -0
  40. package/dist/Context/getQueryParameters.js +33 -0
  41. package/dist/Context/getQueryParameters.js.map +1 -0
  42. package/dist/Context/index.d.ts +7 -0
  43. package/dist/Context/index.d.ts.map +1 -0
  44. package/dist/Context/index.js +12 -0
  45. package/dist/Context/index.js.map +1 -0
  46. package/dist/Context/withSafeAttributes.d.ts +23 -0
  47. package/dist/Context/withSafeAttributes.d.ts.map +1 -0
  48. package/dist/Context/withSafeAttributes.js +39 -0
  49. package/dist/Context/withSafeAttributes.js.map +1 -0
  50. package/dist/Document/Document.d.ts +114 -0
  51. package/dist/Document/Document.d.ts.map +1 -0
  52. package/dist/Document/Document.js +285 -0
  53. package/dist/Document/Document.js.map +1 -0
  54. package/dist/Document/MemoryDocument.d.ts +34 -0
  55. package/dist/Document/MemoryDocument.d.ts.map +1 -0
  56. package/dist/Document/MemoryDocument.js +103 -0
  57. package/dist/Document/MemoryDocument.js.map +1 -0
  58. package/dist/Document/__tests__/__helpers.d.ts +18 -0
  59. package/dist/Document/__tests__/__helpers.d.ts.map +1 -0
  60. package/dist/Document/__tests__/__helpers.js +28 -0
  61. package/dist/Document/__tests__/__helpers.js.map +1 -0
  62. package/dist/Document/index.d.ts +5 -0
  63. package/dist/Document/index.d.ts.map +1 -0
  64. package/dist/Document/index.js +11 -0
  65. package/dist/Document/index.js.map +1 -0
  66. package/dist/Operation/Operation.d.ts +95 -0
  67. package/dist/Operation/Operation.d.ts.map +1 -0
  68. package/dist/Operation/Operation.js +301 -0
  69. package/dist/Operation/Operation.js.map +1 -0
  70. package/dist/Operation/errors/AccessDeniedError.d.ts +22 -0
  71. package/dist/Operation/errors/AccessDeniedError.d.ts.map +1 -0
  72. package/dist/Operation/errors/AccessDeniedError.js +29 -0
  73. package/dist/Operation/errors/AccessDeniedError.js.map +1 -0
  74. package/dist/Operation/errors/CommonError.d.ts +30 -0
  75. package/dist/Operation/errors/CommonError.d.ts.map +1 -0
  76. package/dist/Operation/errors/CommonError.js +39 -0
  77. package/dist/Operation/errors/CommonError.js.map +1 -0
  78. package/dist/Operation/errors/DocumentExistsError.d.ts +27 -0
  79. package/dist/Operation/errors/DocumentExistsError.d.ts.map +1 -0
  80. package/dist/Operation/errors/DocumentExistsError.js +35 -0
  81. package/dist/Operation/errors/DocumentExistsError.js.map +1 -0
  82. package/dist/Operation/errors/DocumentNotFoundError.d.ts +28 -0
  83. package/dist/Operation/errors/DocumentNotFoundError.d.ts.map +1 -0
  84. package/dist/Operation/errors/DocumentNotFoundError.js +36 -0
  85. package/dist/Operation/errors/DocumentNotFoundError.js.map +1 -0
  86. package/dist/Operation/errors/InvalidParametersError.d.ts +27 -0
  87. package/dist/Operation/errors/InvalidParametersError.d.ts.map +1 -0
  88. package/dist/Operation/errors/InvalidParametersError.js +34 -0
  89. package/dist/Operation/errors/InvalidParametersError.js.map +1 -0
  90. package/dist/Operation/errors/UnauthorizedError.d.ts +25 -0
  91. package/dist/Operation/errors/UnauthorizedError.d.ts.map +1 -0
  92. package/dist/Operation/errors/UnauthorizedError.js +32 -0
  93. package/dist/Operation/errors/UnauthorizedError.js.map +1 -0
  94. package/dist/Operation/errors/UnprocessibleConditionError.d.ts +29 -0
  95. package/dist/Operation/errors/UnprocessibleConditionError.d.ts.map +1 -0
  96. package/dist/Operation/errors/UnprocessibleConditionError.js +36 -0
  97. package/dist/Operation/errors/UnprocessibleConditionError.js.map +1 -0
  98. package/dist/Operation/errors/index.d.ts +9 -0
  99. package/dist/Operation/errors/index.d.ts.map +1 -0
  100. package/dist/Operation/errors/index.js +21 -0
  101. package/dist/Operation/errors/index.js.map +1 -0
  102. package/dist/Operation/helpers/index.d.ts +4 -0
  103. package/dist/Operation/helpers/index.d.ts.map +1 -0
  104. package/dist/Operation/helpers/index.js +9 -0
  105. package/dist/Operation/helpers/index.js.map +1 -0
  106. package/dist/Operation/helpers/withActivity.d.ts +16 -0
  107. package/dist/Operation/helpers/withActivity.d.ts.map +1 -0
  108. package/dist/Operation/helpers/withActivity.js +23 -0
  109. package/dist/Operation/helpers/withActivity.js.map +1 -0
  110. package/dist/Operation/index.d.ts +14 -0
  111. package/dist/Operation/index.d.ts.map +1 -0
  112. package/dist/Operation/index.js +40 -0
  113. package/dist/Operation/index.js.map +1 -0
  114. package/dist/Operation/operations/Create.d.ts +5 -0
  115. package/dist/Operation/operations/Create.d.ts.map +1 -0
  116. package/dist/Operation/operations/Create.js +44 -0
  117. package/dist/Operation/operations/Create.js.map +1 -0
  118. package/dist/Operation/operations/Delete.d.ts +5 -0
  119. package/dist/Operation/operations/Delete.d.ts.map +1 -0
  120. package/dist/Operation/operations/Delete.js +58 -0
  121. package/dist/Operation/operations/Delete.js.map +1 -0
  122. package/dist/Operation/operations/Index.d.ts +11 -0
  123. package/dist/Operation/operations/Index.d.ts.map +1 -0
  124. package/dist/Operation/operations/Index.js +128 -0
  125. package/dist/Operation/operations/Index.js.map +1 -0
  126. package/dist/Operation/operations/List.d.ts +5 -0
  127. package/dist/Operation/operations/List.d.ts.map +1 -0
  128. package/dist/Operation/operations/List.js +48 -0
  129. package/dist/Operation/operations/List.js.map +1 -0
  130. package/dist/Operation/operations/Read.d.ts +5 -0
  131. package/dist/Operation/operations/Read.d.ts.map +1 -0
  132. package/dist/Operation/operations/Read.js +50 -0
  133. package/dist/Operation/operations/Read.js.map +1 -0
  134. package/dist/Operation/operations/Update.d.ts +5 -0
  135. package/dist/Operation/operations/Update.d.ts.map +1 -0
  136. package/dist/Operation/operations/Update.js +54 -0
  137. package/dist/Operation/operations/Update.js.map +1 -0
  138. package/dist/Operation/security/JwtAuthorization.d.ts +67 -0
  139. package/dist/Operation/security/JwtAuthorization.d.ts.map +1 -0
  140. package/dist/Operation/security/JwtAuthorization.js +148 -0
  141. package/dist/Operation/security/JwtAuthorization.js.map +1 -0
  142. package/dist/Operation/security/LambdaAuthorization.d.ts +30 -0
  143. package/dist/Operation/security/LambdaAuthorization.d.ts.map +1 -0
  144. package/dist/Operation/security/LambdaAuthorization.js +77 -0
  145. package/dist/Operation/security/LambdaAuthorization.js.map +1 -0
  146. package/dist/Operation/security/index.d.ts +8 -0
  147. package/dist/Operation/security/index.d.ts.map +1 -0
  148. package/dist/Operation/security/index.js +17 -0
  149. package/dist/Operation/security/index.js.map +1 -0
  150. package/dist/Operation/security/systemAuthorization.d.ts +5 -0
  151. package/dist/Operation/security/systemAuthorization.d.ts.map +1 -0
  152. package/dist/Operation/security/systemAuthorization.js +24 -0
  153. package/dist/Operation/security/systemAuthorization.js.map +1 -0
  154. package/dist/Operation/security/userAuthorization.d.ts +11 -0
  155. package/dist/Operation/security/userAuthorization.d.ts.map +1 -0
  156. package/dist/Operation/security/userAuthorization.js +36 -0
  157. package/dist/Operation/security/userAuthorization.js.map +1 -0
  158. package/dist/Operation/security/verifyToken.d.ts +6 -0
  159. package/dist/Operation/security/verifyToken.d.ts.map +1 -0
  160. package/dist/Operation/security/verifyToken.js +15 -0
  161. package/dist/Operation/security/verifyToken.js.map +1 -0
  162. package/dist/Service/Service.d.ts +62 -0
  163. package/dist/Service/Service.d.ts.map +1 -0
  164. package/dist/Service/Service.js +213 -0
  165. package/dist/Service/Service.js.map +1 -0
  166. package/dist/Service/authorize.d.ts +26 -0
  167. package/dist/Service/authorize.d.ts.map +1 -0
  168. package/dist/Service/authorize.js +40 -0
  169. package/dist/Service/authorize.js.map +1 -0
  170. package/dist/Service/errors/InvalidInputError.d.ts +29 -0
  171. package/dist/Service/errors/InvalidInputError.d.ts.map +1 -0
  172. package/dist/Service/errors/InvalidInputError.js +36 -0
  173. package/dist/Service/errors/InvalidInputError.js.map +1 -0
  174. package/dist/Service/errors/InvalidOutputError.d.ts +29 -0
  175. package/dist/Service/errors/InvalidOutputError.d.ts.map +1 -0
  176. package/dist/Service/errors/InvalidOutputError.js +36 -0
  177. package/dist/Service/errors/InvalidOutputError.js.map +1 -0
  178. package/dist/Service/errors/OperationError.d.ts +30 -0
  179. package/dist/Service/errors/OperationError.d.ts.map +1 -0
  180. package/dist/Service/errors/OperationError.js +61 -0
  181. package/dist/Service/errors/OperationError.js.map +1 -0
  182. package/{src → dist/Service}/errors/OperationError.yaml +7 -10
  183. package/dist/Service/errors/OperationNotFoundError.d.ts +38 -0
  184. package/dist/Service/errors/OperationNotFoundError.d.ts.map +1 -0
  185. package/dist/Service/errors/OperationNotFoundError.js +45 -0
  186. package/dist/Service/errors/OperationNotFoundError.js.map +1 -0
  187. package/dist/Service/errors/index.d.ts +8 -0
  188. package/dist/Service/errors/index.d.ts.map +1 -0
  189. package/dist/Service/errors/index.js +15 -0
  190. package/dist/Service/errors/index.js.map +1 -0
  191. package/dist/Service/errors/logOperationError.d.ts +35 -0
  192. package/dist/Service/errors/logOperationError.d.ts.map +1 -0
  193. package/dist/Service/errors/logOperationError.js +47 -0
  194. package/dist/Service/errors/logOperationError.js.map +1 -0
  195. package/dist/Service/errors/maskSecrets.d.ts +13 -0
  196. package/dist/Service/errors/maskSecrets.d.ts.map +1 -0
  197. package/dist/Service/errors/maskSecrets.js +57 -0
  198. package/dist/Service/errors/maskSecrets.js.map +1 -0
  199. package/dist/Service/index.d.ts +5 -0
  200. package/dist/Service/index.d.ts.map +1 -0
  201. package/dist/Service/index.js +25 -0
  202. package/dist/Service/index.js.map +1 -0
  203. package/dist/Service/logRequest.d.ts +5 -0
  204. package/dist/Service/logRequest.d.ts.map +1 -0
  205. package/dist/Service/logRequest.js +26 -0
  206. package/dist/Service/logRequest.js.map +1 -0
  207. package/dist/Service/spec/createSpec.d.ts +7 -0
  208. package/dist/Service/spec/createSpec.d.ts.map +1 -0
  209. package/dist/Service/spec/createSpec.js +56 -0
  210. package/dist/Service/spec/createSpec.js.map +1 -0
  211. package/dist/Service/spec/getErrorResponseDescription.d.ts +8 -0
  212. package/dist/Service/spec/getErrorResponseDescription.d.ts.map +1 -0
  213. package/dist/Service/spec/getErrorResponseDescription.js +15 -0
  214. package/dist/Service/spec/getErrorResponseDescription.js.map +1 -0
  215. package/dist/Service/spec/getHttpMethod.d.ts +4 -0
  216. package/dist/Service/spec/getHttpMethod.d.ts.map +1 -0
  217. package/dist/Service/spec/getHttpMethod.js +21 -0
  218. package/dist/Service/spec/getHttpMethod.js.map +1 -0
  219. package/dist/Service/spec/getOperation.d.ts +6 -0
  220. package/dist/Service/spec/getOperation.d.ts.map +1 -0
  221. package/dist/Service/spec/getOperation.js +71 -0
  222. package/dist/Service/spec/getOperation.js.map +1 -0
  223. package/dist/Service/spec/getOperationParameters.d.ts +6 -0
  224. package/dist/Service/spec/getOperationParameters.d.ts.map +1 -0
  225. package/dist/Service/spec/getOperationParameters.js +32 -0
  226. package/dist/Service/spec/getOperationParameters.js.map +1 -0
  227. package/dist/Service/spec/getServiceDefinitions.d.ts +6 -0
  228. package/dist/Service/spec/getServiceDefinitions.d.ts.map +1 -0
  229. package/dist/Service/spec/getServiceDefinitions.js +18 -0
  230. package/dist/Service/spec/getServiceDefinitions.js.map +1 -0
  231. package/dist/Service/spec/getServiceInfo.d.ts +7 -0
  232. package/dist/Service/spec/getServiceInfo.d.ts.map +1 -0
  233. package/dist/Service/spec/getServiceInfo.js +15 -0
  234. package/dist/Service/spec/getServiceInfo.js.map +1 -0
  235. package/dist/Service/spec/getServiceSecurityDefinitions.d.ts +6 -0
  236. package/dist/Service/spec/getServiceSecurityDefinitions.d.ts.map +1 -0
  237. package/dist/Service/spec/getServiceSecurityDefinitions.js +21 -0
  238. package/dist/Service/spec/getServiceSecurityDefinitions.js.map +1 -0
  239. package/dist/Service/spec/getServiceTags.d.ts +7 -0
  240. package/dist/Service/spec/getServiceTags.d.ts.map +1 -0
  241. package/dist/Service/spec/getServiceTags.js +19 -0
  242. package/dist/Service/spec/getServiceTags.js.map +1 -0
  243. package/dist/Service/spec/getSuccessStatusCode.d.ts +4 -0
  244. package/dist/Service/spec/getSuccessStatusCode.d.ts.map +1 -0
  245. package/dist/Service/spec/getSuccessStatusCode.js +14 -0
  246. package/dist/Service/spec/getSuccessStatusCode.js.map +1 -0
  247. package/dist/Service/spec/index.d.ts +3 -0
  248. package/dist/Service/spec/index.d.ts.map +1 -0
  249. package/dist/Service/spec/index.js +9 -0
  250. package/dist/Service/spec/index.js.map +1 -0
  251. package/dist/Service/spec/validateSpec.d.ts +5 -0
  252. package/dist/Service/spec/validateSpec.d.ts.map +1 -0
  253. package/dist/Service/spec/validateSpec.js +21 -0
  254. package/dist/Service/spec/validateSpec.js.map +1 -0
  255. package/dist/Service/test/createAccessToken.d.ts +9 -0
  256. package/dist/Service/test/createAccessToken.d.ts.map +1 -0
  257. package/dist/Service/test/createAccessToken.js +16 -0
  258. package/dist/Service/test/createAccessToken.js.map +1 -0
  259. package/dist/Service/test/ensureItem.d.ts +5 -0
  260. package/dist/Service/test/ensureItem.d.ts.map +1 -0
  261. package/dist/Service/test/ensureItem.js +13 -0
  262. package/dist/Service/test/ensureItem.js.map +1 -0
  263. package/dist/Service/test/ensureNoItem.d.ts +5 -0
  264. package/dist/Service/test/ensureNoItem.d.ts.map +1 -0
  265. package/dist/Service/test/ensureNoItem.js +13 -0
  266. package/dist/Service/test/ensureNoItem.js.map +1 -0
  267. package/dist/Service/test/execute.d.ts +44 -0
  268. package/dist/Service/test/execute.d.ts.map +1 -0
  269. package/dist/Service/test/execute.js +65 -0
  270. package/dist/Service/test/execute.js.map +1 -0
  271. package/dist/Service/test/findItem.d.ts +7 -0
  272. package/dist/Service/test/findItem.d.ts.map +1 -0
  273. package/dist/Service/test/findItem.js +16 -0
  274. package/dist/Service/test/findItem.js.map +1 -0
  275. package/dist/Service/test/firstItemGet.d.ts +5 -0
  276. package/dist/Service/test/firstItemGet.d.ts.map +1 -0
  277. package/dist/Service/test/firstItemGet.js +15 -0
  278. package/dist/Service/test/firstItemGet.js.map +1 -0
  279. package/dist/Service/test/index.d.ts +10 -0
  280. package/dist/Service/test/index.d.ts.map +1 -0
  281. package/dist/Service/test/index.js +36 -0
  282. package/dist/Service/test/index.js.map +1 -0
  283. package/dist/Service/test/keys.d.ts +5 -0
  284. package/dist/Service/test/keys.d.ts.map +1 -0
  285. package/dist/Service/test/keys.js +74 -0
  286. package/dist/Service/test/keys.js.map +1 -0
  287. package/dist/Service/test/wait.d.ts +4 -0
  288. package/dist/Service/test/wait.d.ts.map +1 -0
  289. package/dist/Service/test/wait.js +6 -0
  290. package/dist/Service/test/wait.js.map +1 -0
  291. package/dist/Service/useComposerMiddleware.d.ts +11 -0
  292. package/dist/Service/useComposerMiddleware.d.ts.map +1 -0
  293. package/dist/Service/useComposerMiddleware.js +41 -0
  294. package/dist/Service/useComposerMiddleware.js.map +1 -0
  295. package/dist/Service/useOasMiddleware.d.ts +16 -0
  296. package/dist/Service/useOasMiddleware.d.ts.map +1 -0
  297. package/dist/Service/useOasMiddleware.js +53 -0
  298. package/dist/Service/useOasMiddleware.js.map +1 -0
  299. package/dist/index.d.ts +11 -0
  300. package/dist/index.d.ts.map +1 -0
  301. package/dist/index.js +25 -0
  302. package/dist/index.js.map +1 -0
  303. package/eslint.config.mjs +32 -52
  304. package/example/documents/Profile/Profile.ts +8 -0
  305. package/example/documents/Profile/Profile.yaml +6 -0
  306. package/example/documents/Profile/ProfileAttributes.d.ts +5 -0
  307. package/example/documents/Profile/index.ts +3 -0
  308. package/example/documents/index.ts +5 -0
  309. package/example/index.ts +38 -0
  310. package/example/lib/createActivity.ts +28 -0
  311. package/example/lib/index.ts +24 -0
  312. package/example/operations/Profile/CreateProfile.ts +9 -0
  313. package/example/operations/Profile/DeleteProfile.ts +9 -0
  314. package/example/operations/Profile/IndexProfiles.ts +9 -0
  315. package/example/operations/Profile/ReadProfile.ts +9 -0
  316. package/example/operations/Profile/ReadProfileSystem.ts +9 -0
  317. package/example/operations/Profile/UpdateProfile.ts +9 -0
  318. package/example/operations/Service/Health.ts +11 -0
  319. package/example/operations/index.ts +22 -0
  320. package/example/security/index.ts +25 -0
  321. package/jest.config.mjs +7 -0
  322. package/package.json +35 -24
  323. package/src/Component/Component.ts +120 -0
  324. package/src/Component/__tests__/Component.test.ts +161 -0
  325. package/src/Component/index.ts +7 -0
  326. package/src/Context/Context.ts +217 -0
  327. package/src/Context/Request.ts +41 -0
  328. package/src/Context/__tests__/Context.test.ts +271 -0
  329. package/src/Context/__tests__/__helpers.ts +86 -0
  330. package/src/Context/getHttpMethod.ts +21 -0
  331. package/src/Context/getHttpPath.ts +34 -0
  332. package/src/Context/getMutationParameters.ts +35 -0
  333. package/src/Context/getOperationId.ts +23 -0
  334. package/src/Context/getQueryParameters.ts +45 -0
  335. package/src/Context/index.ts +12 -0
  336. package/src/Context/withSafeAttributes.ts +39 -0
  337. package/src/Document/Document.ts +448 -0
  338. package/src/Document/MemoryDocument.ts +152 -0
  339. package/src/Document/__tests__/MemoryDocument.test.ts +406 -0
  340. package/src/Document/__tests__/__helpers.ts +40 -0
  341. package/src/Document/index.ts +9 -0
  342. package/src/Operation/Operation.ts +401 -0
  343. package/src/Operation/__tests__/Operation.test.ts +142 -0
  344. package/src/Operation/errors/AccessDeniedError.ts +25 -0
  345. package/src/Operation/errors/CommonError.ts +41 -0
  346. package/src/Operation/errors/DocumentExistsError.ts +33 -0
  347. package/src/Operation/errors/DocumentNotFoundError.ts +34 -0
  348. package/src/Operation/errors/InvalidParametersError.ts +30 -0
  349. package/src/Operation/errors/UnauthorizedError.ts +28 -0
  350. package/src/Operation/errors/UnprocessibleConditionError.ts +32 -0
  351. package/src/Operation/errors/__tests__/InvalidParametersError.test.ts +20 -0
  352. package/src/Operation/errors/__tests__/UnprocessibleConditionError.test.ts +20 -0
  353. package/src/Operation/errors/index.ts +17 -0
  354. package/src/Operation/helpers/index.ts +9 -0
  355. package/src/Operation/helpers/withActivity.ts +43 -0
  356. package/src/Operation/index.ts +29 -0
  357. package/src/Operation/operations/Create.ts +49 -0
  358. package/src/Operation/operations/Delete.ts +65 -0
  359. package/src/Operation/operations/Index.ts +164 -0
  360. package/src/Operation/operations/List.ts +62 -0
  361. package/src/Operation/operations/Read.ts +55 -0
  362. package/src/Operation/operations/Update.ts +60 -0
  363. package/src/Operation/operations/__tests__/Create.test.ts +153 -0
  364. package/src/Operation/operations/__tests__/Delete.test.ts +163 -0
  365. package/src/Operation/operations/__tests__/Index.test.ts +209 -0
  366. package/src/Operation/operations/__tests__/List.test.ts +146 -0
  367. package/src/Operation/operations/__tests__/Read.test.ts +152 -0
  368. package/src/Operation/operations/__tests__/Update.test.ts +158 -0
  369. package/src/Operation/security/JwtAuthorization.ts +247 -0
  370. package/src/Operation/security/LambdaAuthorization.ts +103 -0
  371. package/src/Operation/security/__tests__/JwtAuthorization.test.ts +230 -0
  372. package/src/Operation/security/__tests__/LambdaAuthorization.test.ts +63 -0
  373. package/src/Operation/security/__tests__/userAuthorization.test.ts +42 -0
  374. package/src/Operation/security/index.ts +15 -0
  375. package/src/Operation/security/systemAuthorization.ts +23 -0
  376. package/src/Operation/security/userAuthorization.ts +47 -0
  377. package/src/Operation/security/verifyToken.ts +22 -0
  378. package/src/Service/Service.ts +317 -0
  379. package/src/Service/__tests__/Service.test.ts +229 -0
  380. package/src/Service/authorize.ts +80 -0
  381. package/src/Service/errors/InvalidInputError.ts +40 -0
  382. package/src/Service/errors/InvalidOutputError.ts +40 -0
  383. package/src/Service/errors/OperationError.ts +74 -0
  384. package/src/Service/errors/OperationError.yaml +29 -0
  385. package/src/Service/errors/OperationErrorAttributes.d.ts +12 -0
  386. package/src/Service/errors/OperationNotFoundError.ts +45 -0
  387. package/src/Service/errors/__tests__/OperationError.test.ts +17 -0
  388. package/src/Service/errors/__tests__/maskSecrets.test.ts +92 -0
  389. package/src/Service/errors/index.ts +18 -0
  390. package/src/Service/errors/logOperationError.ts +72 -0
  391. package/src/Service/errors/maskSecrets.ts +65 -0
  392. package/src/Service/index.ts +9 -0
  393. package/src/Service/logRequest.ts +50 -0
  394. package/src/Service/spec/__tests__/validateSpec.test.ts +10 -0
  395. package/src/Service/spec/createSpec.ts +68 -0
  396. package/src/Service/spec/getErrorResponseDescription.ts +20 -0
  397. package/src/Service/spec/getHttpMethod.ts +20 -0
  398. package/src/Service/spec/getOperation.ts +99 -0
  399. package/src/Service/spec/getOperationParameters.ts +43 -0
  400. package/src/Service/spec/getServiceDefinitions.ts +23 -0
  401. package/src/Service/spec/getServiceInfo.ts +18 -0
  402. package/src/Service/spec/getServiceSecurityDefinitions.ts +26 -0
  403. package/src/Service/spec/getServiceTags.ts +23 -0
  404. package/src/Service/spec/getSuccessStatusCode.ts +15 -0
  405. package/src/Service/spec/index.ts +5 -0
  406. package/src/Service/spec/validateSpec.ts +22 -0
  407. package/src/Service/test/__tests__/createAccessToken.test.ts +104 -0
  408. package/src/Service/test/__tests__/ensureItem.test.ts +41 -0
  409. package/src/Service/test/__tests__/ensureNoItem.test.ts +49 -0
  410. package/src/Service/test/__tests__/execute.test.ts +125 -0
  411. package/src/Service/test/__tests__/findItem.test.ts +45 -0
  412. package/src/Service/test/__tests__/firstItemGet.test.ts +50 -0
  413. package/src/Service/test/__tests__/wait.test.ts +66 -0
  414. package/src/Service/test/createAccessToken.ts +28 -0
  415. package/src/Service/test/ensureItem.ts +9 -0
  416. package/src/Service/test/ensureNoItem.ts +9 -0
  417. package/src/Service/test/execute.ts +112 -0
  418. package/src/Service/test/findItem.ts +22 -0
  419. package/src/Service/test/firstItemGet.ts +18 -0
  420. package/src/Service/test/index.ts +19 -0
  421. package/src/Service/test/keys.ts +75 -0
  422. package/src/Service/test/wait.ts +5 -0
  423. package/src/Service/useComposerMiddleware.ts +56 -0
  424. package/src/Service/useOasMiddleware.ts +69 -0
  425. package/src/index.ts +12 -0
  426. package/tsconfig.json +26 -0
  427. package/examples/CreateProfile.js +0 -40
  428. package/examples/DeleteProfile.js +0 -6
  429. package/examples/Health.js +0 -8
  430. package/examples/IndexProfiles.js +0 -6
  431. package/examples/Profile.js +0 -8
  432. package/examples/Profile.yaml +0 -4
  433. package/examples/ReadProfile.js +0 -18
  434. package/examples/UpdateProfile.js +0 -25
  435. package/examples/index.js +0 -29
  436. package/src/Component.js +0 -59
  437. package/src/Component.spec.js +0 -65
  438. package/src/Document.js +0 -310
  439. package/src/Document.spec.js +0 -331
  440. package/src/Operation.js +0 -258
  441. package/src/Operation.spec.js +0 -474
  442. package/src/Service.js +0 -207
  443. package/src/Service.spec.js +0 -388
  444. package/src/errors/AccessDeniedError.js +0 -11
  445. package/src/errors/CommonError.js +0 -19
  446. package/src/errors/DocumentExistsError.js +0 -15
  447. package/src/errors/DocumentNotFoundError.js +0 -15
  448. package/src/errors/InvalidInputError.js +0 -19
  449. package/src/errors/InvalidOutputError.js +0 -20
  450. package/src/errors/InvalidParametersError.js +0 -11
  451. package/src/errors/OperationError.js +0 -44
  452. package/src/errors/OperationNotFoundError.js +0 -16
  453. package/src/errors/UnauthorizedError.js +0 -11
  454. package/src/errors/UnprocessibleConditionError.js +0 -11
  455. package/src/errors/index.js +0 -11
  456. package/src/helpers/asSafeClass.js +0 -22
  457. package/src/helpers/authorize.js +0 -44
  458. package/src/helpers/createContext.js +0 -96
  459. package/src/helpers/createSchemasMap.js +0 -37
  460. package/src/helpers/createSpec.js +0 -196
  461. package/src/helpers/defaultId.js +0 -30
  462. package/src/helpers/defaultSummary.js +0 -15
  463. package/src/helpers/defaultTags.js +0 -16
  464. package/src/helpers/getComponentTitle.js +0 -22
  465. package/src/helpers/getDefaultSchemaAttributes.js +0 -32
  466. package/src/helpers/getHttpMethod.js +0 -19
  467. package/src/helpers/getIdPrefix.js +0 -7
  468. package/src/helpers/getOrFail.js +0 -24
  469. package/src/helpers/getOrFail.spec.js +0 -17
  470. package/src/helpers/getSuccessStatusCode.js +0 -15
  471. package/src/helpers/handler.js +0 -21
  472. package/src/helpers/loadSync.js +0 -14
  473. package/src/helpers/logError.js +0 -33
  474. package/src/helpers/logRequest.js +0 -36
  475. package/src/helpers/maskSecrets.js +0 -42
  476. package/src/helpers/specMiddleware.js +0 -81
  477. package/src/index.d.ts +0 -352
  478. package/src/index.js +0 -35
  479. package/src/operations/Create.js +0 -39
  480. package/src/operations/Delete.js +0 -54
  481. package/src/operations/Index.js +0 -107
  482. package/src/operations/Read.js +0 -46
  483. package/src/operations/Update.js +0 -50
  484. package/src/security/JwtAuthorization.js +0 -125
  485. package/src/security/SystemAuthorization.js +0 -73
  486. package/src/security/index.js +0 -9
  487. package/src/security/verifyToken.js +0 -17
  488. package/src/test/createAccessToken.js +0 -23
  489. package/src/test/execute.js +0 -84
  490. package/src/test/index.js +0 -11
  491. package/src/test/keys.js +0 -39
  492. package/src/test/wait.js +0 -5
  493. /package/{specs → .composer}/Documents.yaml +0 -0
  494. /package/{specs → .composer}/Enums.yaml +0 -0
  495. /package/{specs → .composer}/Operations.yaml +0 -0
  496. /package/{specs → .composer}/Parameters.yaml +0 -0
  497. /package/{specs → .composer}/Scenarios.yaml +0 -0
  498. /package/{specs → .composer}/Schemas.yaml +0 -0
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Operation_1 = require("../../Operation");
4
+ /**
5
+ * Operation Not Found Error
6
+ *
7
+ * `OperationNotFoundError` represents a **404 Not Found** error that occurs when a requested
8
+ * operation cannot be found in the service. This error is thrown by `Service.process()` when
9
+ * no operation matches the provided `operationId`, `httpMethod`, and `httpPath` combination.
10
+ *
11
+ * This error signals that:
12
+ *
13
+ * - The requested operation does not exist in the service's operations map
14
+ * - The operation may have been removed, renamed, or the request is using incorrect identifiers
15
+ * - The client should verify the operation ID, HTTP method, and path
16
+ *
17
+ * The error message includes the parameters used to search for the operation (operationId,
18
+ * httpMethod, httpPath) formatted as JSON, which helps with debugging incorrect operation
19
+ * requests or routing issues.
20
+ */
21
+ class OperationNotFoundError extends Operation_1.CommonError {
22
+ /**
23
+ * Creates an instance of operation not found error.
24
+ *
25
+ * @param parameters - Record containing the operation search parameters:
26
+ * - `operationId`: The operation identifier that was requested
27
+ * - `httpMethod`: The HTTP method (GET, POST, PUT, DELETE, etc.)
28
+ * - `httpPath`: The HTTP path that was requested
29
+ * These are included in the error message as formatted JSON for debugging.
30
+ */
31
+ constructor(parameters) {
32
+ const parametersJson = JSON.stringify(parameters, null, 2);
33
+ super('OperationNotFoundError', `Operation not found, ${parametersJson}`);
34
+ }
35
+ /**
36
+ * Returns the HTTP status code for this error (404 Not Found).
37
+ *
38
+ * @returns 404
39
+ */
40
+ get statusCode() {
41
+ return 404;
42
+ }
43
+ }
44
+ exports.default = OperationNotFoundError;
45
+ //# sourceMappingURL=OperationNotFoundError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OperationNotFoundError.js","sourceRoot":"","sources":["../../../src/Service/errors/OperationNotFoundError.ts"],"names":[],"mappings":";;AAAA,+CAA8C;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,sBAAuB,SAAQ,uBAAW;IAC9C;;;;;;;;OAQG;IACH,YAAY,UAAmC;QAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3D,KAAK,CAAC,wBAAwB,EAAE,wBAAwB,cAAc,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;OAIG;IACH,IAAI,UAAU;QACZ,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,kBAAe,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import OperationError from './OperationError';
2
+ import InvalidInputError from './InvalidInputError';
3
+ import InvalidOutputError from './InvalidOutputError';
4
+ import OperationNotFoundError from './OperationNotFoundError';
5
+ import type { OriginalError, ErrorAttributes } from './logOperationError';
6
+ export { OperationError, InvalidInputError, InvalidOutputError, OperationNotFoundError, };
7
+ export type { OriginalError, ErrorAttributes };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,CAAC;AAEF,YAAY,EACV,aAAa,EACb,eAAe,EAChB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OperationNotFoundError = exports.InvalidOutputError = exports.InvalidInputError = exports.OperationError = void 0;
7
+ const OperationError_1 = __importDefault(require("./OperationError"));
8
+ exports.OperationError = OperationError_1.default;
9
+ const InvalidInputError_1 = __importDefault(require("./InvalidInputError"));
10
+ exports.InvalidInputError = InvalidInputError_1.default;
11
+ const InvalidOutputError_1 = __importDefault(require("./InvalidOutputError"));
12
+ exports.InvalidOutputError = InvalidOutputError_1.default;
13
+ const OperationNotFoundError_1 = __importDefault(require("./OperationNotFoundError"));
14
+ exports.OperationNotFoundError = OperationNotFoundError_1.default;
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Service/errors/index.ts"],"names":[],"mappings":";;;;;;AAAA,sEAA8C;AAQ5C,yBARK,wBAAc,CAQL;AAPhB,4EAAoD;AAQlD,4BARK,2BAAiB,CAQL;AAPnB,8EAAsD;AAQpD,6BARK,4BAAkB,CAQL;AAPpB,sFAA8D;AAQ5D,iCARK,gCAAsB,CAQL"}
@@ -0,0 +1,35 @@
1
+ import Context from '../../Context';
2
+ import { ValidationError } from '@kravc/schema';
3
+ export type OriginalError = {
4
+ code?: string;
5
+ stack?: string;
6
+ message: string;
7
+ isCommonError?: boolean;
8
+ validationErrors?: ValidationError[];
9
+ };
10
+ export type ErrorAttributes = {
11
+ code: string;
12
+ message: string;
13
+ context: Record<string, unknown>;
14
+ statusCode: number;
15
+ validationErrors?: ValidationError[];
16
+ originalError?: OriginalError;
17
+ };
18
+ /**
19
+ * Logs operation internal error with sanitized context and structured error information.
20
+ *
21
+ * Provides centralized, secure error logging for operation failures. Extracts relevant
22
+ * context fields from the operation context, masks any secrets (passwords, tokens, etc.),
23
+ * and logs structured error information. Distinguishes between expected/common errors
24
+ * (which include full error details) and unexpected errors (which append stack traces
25
+ * for debugging).
26
+ *
27
+ * This ensures that:
28
+ * - Sensitive information is never logged in plain text
29
+ * - Error logs contain sufficient context for debugging (request ID, operation ID, etc.)
30
+ * - Unexpected errors are clearly marked with stack traces
31
+ * - Common errors preserve their original error structure for analysis
32
+ */
33
+ declare const logOperationError: (context: Context, errorAttributes: ErrorAttributes, originalError: OriginalError) => void;
34
+ export default logOperationError;
35
+ //# sourceMappingURL=logOperationError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logOperationError.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/logOperationError.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAA;AAWD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,iBAAiB,GACrB,SAAS,OAAO,EAChB,iBAAiB,eAAe,EAChC,eAAe,aAAa,SAoB7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_1 = require("lodash");
7
+ const maskSecrets_1 = __importDefault(require("./maskSecrets"));
8
+ const ERROR_CONTEXT_FIELDS = [
9
+ 'query',
10
+ 'mutation',
11
+ 'identity',
12
+ 'requestId',
13
+ 'operationId',
14
+ 'requestReceivedAt'
15
+ ];
16
+ /**
17
+ * Logs operation internal error with sanitized context and structured error information.
18
+ *
19
+ * Provides centralized, secure error logging for operation failures. Extracts relevant
20
+ * context fields from the operation context, masks any secrets (passwords, tokens, etc.),
21
+ * and logs structured error information. Distinguishes between expected/common errors
22
+ * (which include full error details) and unexpected errors (which append stack traces
23
+ * for debugging).
24
+ *
25
+ * This ensures that:
26
+ * - Sensitive information is never logged in plain text
27
+ * - Error logs contain sufficient context for debugging (request ID, operation ID, etc.)
28
+ * - Unexpected errors are clearly marked with stack traces
29
+ * - Common errors preserve their original error structure for analysis
30
+ */
31
+ const logOperationError = (context, errorAttributes, originalError) => {
32
+ const { logger } = context;
33
+ const unmaskedContext = (0, lodash_1.pick)(context, ERROR_CONTEXT_FIELDS);
34
+ errorAttributes.context = (0, maskSecrets_1.default)(unmaskedContext);
35
+ let unexpectedErrorMessage = '';
36
+ const { isCommonError } = originalError;
37
+ if (isCommonError) {
38
+ errorAttributes.originalError = originalError;
39
+ }
40
+ else {
41
+ unexpectedErrorMessage = `, Unexpected ${originalError.stack}`;
42
+ }
43
+ const errorAttributesJson = JSON.stringify(errorAttributes, null, 2);
44
+ logger.error(`OperationError ${errorAttributesJson}${unexpectedErrorMessage}`);
45
+ };
46
+ exports.default = logOperationError;
47
+ //# sourceMappingURL=logOperationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logOperationError.js","sourceRoot":"","sources":["../../../src/Service/errors/logOperationError.ts"],"names":[],"mappings":";;;;;AACA,mCAA8B;AAC9B,gEAAwC;AAoBxC,MAAM,oBAAoB,GAAG;IAC3B,OAAO;IACP,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,mBAAmB;CACpB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,CACxB,OAAgB,EAChB,eAAgC,EAChC,aAA4B,EAC5B,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,eAAe,GAAG,IAAA,aAAI,EAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAC5D,eAAe,CAAC,OAAO,GAAG,IAAA,qBAAW,EAAC,eAAe,CAAC,CAAC;IAEvD,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAEhC,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;IAExC,IAAI,aAAa,EAAE,CAAC;QAClB,eAAe,CAAC,aAAa,GAAG,aAAa,CAAC;IAEhD,CAAC;SAAM,CAAC;QACN,sBAAsB,GAAG,gBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC;IACjE,CAAC;IAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,KAAK,CAAC,kBAAkB,mBAAmB,GAAG,sBAAsB,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Clones an object and recursively masks its secret attributes.
3
+ *
4
+ * Produces a deep copy of the input with sensitive values replaced by `[MASKED]`.
5
+ * Keys matching `password`, `code`, `token`, `authorization`, `authentication`, or
6
+ * `cookie` (case‑insensitive, including substrings like `authToken` or `reset_code`)
7
+ * are masked regardless of value type. The original object is never mutated.
8
+ *
9
+ * This enables safe logging and serialization of context, request payloads, or
10
+ * config that may contain credentials, tokens, or other secrets.
11
+ */
12
+ export default function maskSecrets(input: Record<string, unknown>): Record<string, unknown>;
13
+ //# sourceMappingURL=maskSecrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maskSecrets.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/maskSecrets.ts"],"names":[],"mappings":"AA+CA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = maskSecrets;
4
+ const lodash_1 = require("lodash");
5
+ const { isArray } = Array;
6
+ const SECRET_REGEXP = /(password|code|token|authorization|authentication|cookie)/i;
7
+ const MASK_VALUE = '[MASKED]';
8
+ /** Recursively masks secret attributes in objects and arrays. */
9
+ function applyMasking(value) {
10
+ if (!(0, lodash_1.isObject)(value)) {
11
+ return;
12
+ }
13
+ if (isArray(value)) {
14
+ for (const item of value) {
15
+ if ((0, lodash_1.isObject)(item)) {
16
+ applyMasking(item);
17
+ }
18
+ }
19
+ return;
20
+ }
21
+ const object = value;
22
+ for (const key of Object.keys(object)) {
23
+ if (SECRET_REGEXP.test(key)) {
24
+ object[key] = MASK_VALUE;
25
+ continue;
26
+ }
27
+ const val = object[key];
28
+ if (isArray(val)) {
29
+ for (const item of val) {
30
+ if ((0, lodash_1.isObject)(item)) {
31
+ applyMasking(item);
32
+ }
33
+ }
34
+ continue;
35
+ }
36
+ if ((0, lodash_1.isObject)(val)) {
37
+ applyMasking(val);
38
+ }
39
+ }
40
+ }
41
+ /**
42
+ * Clones an object and recursively masks its secret attributes.
43
+ *
44
+ * Produces a deep copy of the input with sensitive values replaced by `[MASKED]`.
45
+ * Keys matching `password`, `code`, `token`, `authorization`, `authentication`, or
46
+ * `cookie` (case‑insensitive, including substrings like `authToken` or `reset_code`)
47
+ * are masked regardless of value type. The original object is never mutated.
48
+ *
49
+ * This enables safe logging and serialization of context, request payloads, or
50
+ * config that may contain credentials, tokens, or other secrets.
51
+ */
52
+ function maskSecrets(input) {
53
+ const object = (0, lodash_1.cloneDeep)(input);
54
+ applyMasking(object);
55
+ return object;
56
+ }
57
+ //# sourceMappingURL=maskSecrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maskSecrets.js","sourceRoot":"","sources":["../../../src/Service/errors/maskSecrets.ts"],"names":[],"mappings":";;AA0DA,8BAMC;AAhED,mCAA6C;AAE7C,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AAE1B,MAAM,aAAa,GAAG,4DAA4D,CAAC;AACnF,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B,iEAAiE;AACjE,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC,IAAA,iBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,KAAgC,CAAC;IAEhD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;YACzB,SAAS;QACX,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAExB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;gBACvB,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;oBACnB,YAAY,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,IAAA,iBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;YAClB,YAAY,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAwB,WAAW,CACjC,KAA8B;IAE9B,MAAM,MAAM,GAAG,IAAA,kBAAS,EAAC,KAAK,CAAC,CAAC;IAChC,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import Service from './Service';
2
+ export default Service;
3
+ export { Service, };
4
+ export * from './test';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Service/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,eAAe,OAAO,CAAC;AAEvB,OAAO,EACL,OAAO,GACR,CAAC;AAEF,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Service = void 0;
21
+ const Service_1 = __importDefault(require("./Service"));
22
+ exports.Service = Service_1.default;
23
+ exports.default = Service_1.default;
24
+ __exportStar(require("./test"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,wDAAgC;AAK9B,kBALK,iBAAO,CAKL;AAHT,kBAAe,iBAAO,CAAC;AAMvB,yCAAuB"}
@@ -0,0 +1,5 @@
1
+ import type { Context } from '../Context';
2
+ /** Logs request metadata in the non test environment. */
3
+ declare const logRequest: (context: Context) => void;
4
+ export default logRequest;
5
+ //# sourceMappingURL=logRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logRequest.d.ts","sourceRoot":"","sources":["../../src/Service/logRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,YAAY,CAAC;AAUjE,yDAAyD;AACzD,QAAA,MAAM,UAAU,GAAI,SAAS,OAAO,SAoCnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Logs request metadata in the non test environment. */
4
+ const logRequest = (context) => {
5
+ const { isTest } = context;
6
+ if (isTest) {
7
+ return;
8
+ }
9
+ const { operationId, query, logger, mutation, httpPath, requestId, headers, requestReceivedAt } = context;
10
+ const { host } = headers;
11
+ const metadata = {
12
+ host,
13
+ requestId,
14
+ requestReceivedAt,
15
+ query,
16
+ };
17
+ if (mutation) {
18
+ metadata.mutation = mutation;
19
+ }
20
+ const prefix = operationId === 'undefined'
21
+ ? httpPath
22
+ : operationId;
23
+ logger.info(`${prefix}: ${JSON.stringify(metadata, null, 2)}`);
24
+ };
25
+ exports.default = logRequest;
26
+ //# sourceMappingURL=logRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logRequest.js","sourceRoot":"","sources":["../../src/Service/logRequest.ts"],"names":[],"mappings":";;AAUA,yDAAyD;AACzD,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,MAAM,EACJ,WAAW,EACX,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,iBAAiB,EAClB,GAAG,OAAO,CAAC;IAEZ,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzB,MAAM,QAAQ,GAAG;QACf,IAAI;QACJ,SAAS;QACT,iBAAiB;QACjB,KAAK;KACa,CAAC;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,KAAK,WAAW;QACxC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,WAAW,CAAC;IAEhB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ import Operation from '../../Operation';
2
+ import { Schema } from '@kravc/schema';
3
+ import { OpenAPIV2 } from 'openapi-types';
4
+ /** Creates a specification for a service. */
5
+ declare const createSpec: (operations: (typeof Operation)[], schemasMap: Record<string, Schema>, url: string) => OpenAPIV2.Document;
6
+ export default createSpec;
7
+ //# sourceMappingURL=createSpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSpec.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/createSpec.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO1C,6CAA6C;AAC7C,QAAA,MAAM,UAAU,GACd,YAAY,CAAC,OAAO,SAAS,CAAC,EAAE,EAChC,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,KAAK,MAAM,KACV,SAAS,CAAC,QAgDZ,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_1 = require("lodash");
7
+ const getOperation_1 = __importDefault(require("./getOperation"));
8
+ const validateSpec_1 = __importDefault(require("./validateSpec"));
9
+ const getHttpMethod_1 = __importDefault(require("./getHttpMethod"));
10
+ const getServiceInfo_1 = __importDefault(require("./getServiceInfo"));
11
+ const getServiceTags_1 = __importDefault(require("./getServiceTags"));
12
+ const getServiceDefinitions_1 = __importDefault(require("./getServiceDefinitions"));
13
+ const getServiceSecurityDefinitions_1 = __importDefault(require("./getServiceSecurityDefinitions"));
14
+ /** Creates a specification for a service. */
15
+ const createSpec = (operations, schemasMap, url) => {
16
+ const _url = new URL(url);
17
+ const host = _url.host;
18
+ const basePath = (0, lodash_1.get)(_url, 'pathname', '/');
19
+ const protocol = _url.protocol.replace(':', '');
20
+ const info = (0, getServiceInfo_1.default)();
21
+ const tags = (0, getServiceTags_1.default)(operations);
22
+ const swagger = '2.0';
23
+ const schemes = [protocol];
24
+ const consumes = ['application/json'];
25
+ const produces = ['application/json'];
26
+ const definitions = (0, getServiceDefinitions_1.default)(schemasMap);
27
+ const securityDefinitions = (0, getServiceSecurityDefinitions_1.default)(operations);
28
+ const paths = {};
29
+ for (const OperationClass of operations) {
30
+ const httpPath = `/${OperationClass.id}`;
31
+ const httpMethod = (0, getHttpMethod_1.default)(OperationClass.type);
32
+ paths[httpPath] = {
33
+ [httpMethod]: (0, getOperation_1.default)(OperationClass)
34
+ };
35
+ }
36
+ const spec = {
37
+ swagger,
38
+ info,
39
+ host,
40
+ basePath,
41
+ consumes,
42
+ produces,
43
+ tags,
44
+ paths,
45
+ schemes,
46
+ definitions,
47
+ securityDefinitions,
48
+ };
49
+ const specJson = JSON
50
+ .stringify(spec, null, 2)
51
+ .replace(/"\$ref": "/g, '"$ref": "#/definitions/');
52
+ const result = (0, validateSpec_1.default)(specJson);
53
+ return result;
54
+ };
55
+ exports.default = createSpec;
56
+ //# sourceMappingURL=createSpec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSpec.js","sourceRoot":"","sources":["../../../src/Service/spec/createSpec.ts"],"names":[],"mappings":";;;;;AAAA,mCAA6B;AAG7B,kEAA0C;AAC1C,kEAA0C;AAE1C,oEAA4C;AAC5C,sEAA8C;AAC9C,sEAA8C;AAC9C,oFAA4D;AAC5D,oGAA4E;AAE5E,6CAA6C;AAC7C,MAAM,UAAU,GAAG,CACjB,UAAgC,EAChC,UAAkC,EAClC,GAAW,EACS,EAAE;IACtB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAE1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,MAAM,QAAQ,GAAG,IAAA,YAAG,EAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAEhD,MAAM,IAAI,GAAG,IAAA,wBAAc,GAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAA,wBAAc,EAAC,UAAU,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,KAAK,CAAC;IACtB,MAAM,OAAO,GAAG,CAAE,QAAQ,CAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,CAAE,kBAAkB,CAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,CAAE,kBAAkB,CAAE,CAAC;IACxC,MAAM,WAAW,GAAG,IAAA,+BAAqB,EAAC,UAAU,CAAC,CAAC;IACtD,MAAM,mBAAmB,GAAG,IAAA,uCAA6B,EAAC,UAAU,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,EAA2B,CAAC;IAE1C,KAAK,MAAM,cAAc,IAAI,UAAU,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAEtD,KAAK,CAAC,QAAQ,CAAC,GAAG;YAChB,CAAC,UAAU,CAAC,EAAE,IAAA,sBAAY,EAAC,cAAc,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG;QACX,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,IAAI;QACJ,KAAK;QACL,OAAO;QACP,WAAW;QACX,mBAAmB;KACE,CAAC;IAExB,MAAM,QAAQ,GAAG,IAAI;SAClB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;SACxB,OAAO,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type Error = {
2
+ code: string;
3
+ description: string;
4
+ };
5
+ /** Returns description for a number of error responses. */
6
+ declare const getErrorResponseDescription: (errors: Error[]) => string;
7
+ export default getErrorResponseDescription;
8
+ //# sourceMappingURL=getErrorResponseDescription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getErrorResponseDescription.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getErrorResponseDescription.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,2DAA2D;AAC3D,QAAA,MAAM,2BAA2B,GAAI,QAAQ,KAAK,EAAE,WASnD,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const lodash_1 = require("lodash");
4
+ /** Returns description for a number of error responses. */
5
+ const getErrorResponseDescription = (errors) => {
6
+ return errors
7
+ .map(error => {
8
+ const code = (0, lodash_1.get)(error, 'code');
9
+ const description = (0, lodash_1.get)(error, 'description', 'No error description');
10
+ return `\`${code}\` — ${description}`;
11
+ })
12
+ .join('\n');
13
+ };
14
+ exports.default = getErrorResponseDescription;
15
+ //# sourceMappingURL=getErrorResponseDescription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getErrorResponseDescription.js","sourceRoot":"","sources":["../../../src/Service/spec/getErrorResponseDescription.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAO7B,2DAA2D;AAC3D,MAAM,2BAA2B,GAAG,CAAC,MAAe,EAAE,EAAE;IACtD,OAAO,MAAM;SACV,GAAG,CAAC,KAAK,CAAC,EAAE;QACX,MAAM,IAAI,GAAG,IAAA,YAAG,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,IAAA,YAAG,EAAC,KAAK,EAAE,aAAa,EAAE,sBAAsB,CAAC,CAAC;QAEtE,OAAO,KAAK,IAAI,QAAQ,WAAW,EAAE,CAAC;IACxC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,2BAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Returns HTTP method for an operation type. */
2
+ declare const getHttpMethod: (type: string) => "delete" | "post" | "patch" | "get";
3
+ export default getHttpMethod;
4
+ //# sourceMappingURL=getHttpMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getHttpMethod.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getHttpMethod.ts"],"names":[],"mappings":"AAEA,iDAAiD;AACjD,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,wCAclC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Operation_1 = __importDefault(require("../../Operation"));
7
+ /** Returns HTTP method for an operation type. */
8
+ const getHttpMethod = (type) => {
9
+ switch (type) {
10
+ case Operation_1.default.types.CREATE:
11
+ return 'post';
12
+ case Operation_1.default.types.DELETE:
13
+ return 'delete';
14
+ case Operation_1.default.types.UPDATE:
15
+ return 'patch';
16
+ default:
17
+ return 'get';
18
+ }
19
+ };
20
+ exports.default = getHttpMethod;
21
+ //# sourceMappingURL=getHttpMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getHttpMethod.js","sourceRoot":"","sources":["../../../src/Service/spec/getHttpMethod.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAExC,iDAAiD;AACjD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE;IACrC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,mBAAS,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,MAAM,CAAC;QAEhB,KAAK,mBAAS,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,QAAQ,CAAC;QAElB,KAAK,mBAAS,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,OAAO,CAAC;QAEjB;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ import Operation from '../../Operation';
2
+ import { OpenAPIV2 } from 'openapi-types';
3
+ /** Returns operation specification for an operation class. */
4
+ declare const getOperation: (OperationClass: typeof Operation) => OpenAPIV2.OperationObject;
5
+ export default getOperation;
6
+ //# sourceMappingURL=getOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOperation.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getOperation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM1C,8DAA8D;AAC9D,QAAA,MAAM,YAAY,GAAI,gBAAgB,OAAO,SAAS,KAAG,SAAS,CAAC,eAwFlE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getServiceTags_1 = __importDefault(require("./getServiceTags"));
7
+ const getSuccessStatusCode_1 = __importDefault(require("./getSuccessStatusCode"));
8
+ const getOperationParameters_1 = __importDefault(require("./getOperationParameters"));
9
+ const getErrorResponseDescription_1 = __importDefault(require("./getErrorResponseDescription"));
10
+ /** Returns operation specification for an operation class. */
11
+ const getOperation = (OperationClass) => {
12
+ const operationId = OperationClass.id;
13
+ const operationTags = (0, getServiceTags_1.default)([OperationClass]).map(({ name }) => name);
14
+ const { errors, summary, security, isCreate, hasOutput, description, permissions, outputSchema, } = OperationClass;
15
+ const operationSummary = permissions
16
+ ? `[${permissions.join(',')}] ${summary}`
17
+ : summary;
18
+ const operationSpec = {
19
+ tags: operationTags,
20
+ summary: operationSummary,
21
+ description,
22
+ operationId,
23
+ };
24
+ const parameters = (0, getOperationParameters_1.default)(OperationClass);
25
+ const hasParameters = parameters.length > 0;
26
+ if (hasParameters) {
27
+ operationSpec.parameters = parameters;
28
+ }
29
+ const successStatusCode = (0, getSuccessStatusCode_1.default)(isCreate, hasOutput);
30
+ const success = {
31
+ description: 'Successful operation execution response'
32
+ };
33
+ if (outputSchema) {
34
+ success.schema = { $ref: outputSchema.id };
35
+ }
36
+ const responses = {
37
+ [successStatusCode]: success,
38
+ default: {
39
+ description: '`OperationError` — Default operation error',
40
+ schema: { $ref: 'OperationError' }
41
+ }
42
+ };
43
+ const errorsMap = {};
44
+ for (const code in errors) {
45
+ const { statusCode, description } = errors[code];
46
+ errorsMap[`${statusCode}`] = errorsMap[`${statusCode}`] || [];
47
+ errorsMap[`${statusCode}`].push({ code, description });
48
+ }
49
+ for (const statusCode in errorsMap) {
50
+ const description = (0, getErrorResponseDescription_1.default)(errorsMap[statusCode]);
51
+ responses[`${statusCode}`] = {
52
+ schema: { $ref: 'OperationError' },
53
+ description
54
+ };
55
+ }
56
+ operationSpec.responses = responses;
57
+ const hasSecurityRequirements = security.length > 0;
58
+ if (hasSecurityRequirements) {
59
+ operationSpec.security = [];
60
+ for (const requirements of security) {
61
+ const config = {};
62
+ for (const name in requirements) {
63
+ config[name] = [];
64
+ }
65
+ operationSpec.security.push(config);
66
+ }
67
+ }
68
+ return operationSpec;
69
+ };
70
+ exports.default = getOperation;
71
+ //# sourceMappingURL=getOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOperation.js","sourceRoot":"","sources":["../../../src/Service/spec/getOperation.ts"],"names":[],"mappings":";;;;;AAEA,sEAA8C;AAC9C,kFAA0D;AAC1D,sFAA8D;AAC9D,gGAAwF;AAExF,8DAA8D;AAC9D,MAAM,YAAY,GAAG,CAAC,cAAgC,EAA6B,EAAE;IACnF,MAAM,WAAW,GAAG,cAAc,CAAC,EAAE,CAAC;IACtC,MAAM,aAAa,GAAG,IAAA,wBAAc,EAAC,CAAE,cAAc,CAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAEjF,MAAM,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,GACb,GAAG,cAAc,CAAC;IAEnB,MAAM,gBAAgB,GAAG,WAAW;QAClC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE;QACzC,CAAC,CAAC,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG;QACpB,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,gBAAgB;QACzB,WAAW;QACX,WAAW;KACiB,CAAC;IAE/B,MAAM,UAAU,GAAG,IAAA,gCAAsB,EAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IAE5C,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC;IACxC,CAAC;IAED,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG;QACd,WAAW,EAAE,yCAAyC;KAC3B,CAAC;IAE9B,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,SAAS,GAAG;QAChB,CAAC,iBAAiB,CAAC,EAAE,OAAO;QAC5B,OAAO,EAAE;YACP,WAAW,EAAE,4CAA4C;YACzD,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;SACnC;KACF,CAAC;IAEF,MAAM,SAAS,GAAG,EAA6B,CAAC;IAEhD,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAEjD,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9D,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,SAAS,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,IAAA,qCAA2B,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;QAEvE,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG;YAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;YAClC,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,SAAS,GAAG,SAAS,CAAC;IAEpC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAEpD,IAAI,uBAAuB,EAAE,CAAC;QAC5B,aAAa,CAAC,QAAQ,GAAG,EAAE,CAAC;QAE5B,KAAK,MAAM,YAAY,IAAI,QAAQ,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,EAAyC,CAAC;YAEzD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACpB,CAAC;YAED,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ import Operation from '../../Operation';
2
+ import { OpenAPIV2 } from 'openapi-types';
3
+ /** Returns operation parameters. */
4
+ declare const getOperationParameters: (OperationClass: typeof Operation) => OpenAPIV2.Parameter[];
5
+ export default getOperationParameters;
6
+ //# sourceMappingURL=getOperationParameters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOperationParameters.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getOperationParameters.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,oCAAoC;AACpC,QAAA,MAAM,sBAAsB,GAAI,gBAAgB,OAAO,SAAS,0BAoC/D,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Returns operation parameters. */
4
+ const getOperationParameters = (OperationClass) => {
5
+ const parameters = [];
6
+ const { query, mutationSchema } = OperationClass;
7
+ for (const name in query) {
8
+ const _queryParameter = query[name];
9
+ const queryParameter = {
10
+ in: 'query',
11
+ type: 'string',
12
+ name,
13
+ ..._queryParameter
14
+ };
15
+ if (queryParameter.example) {
16
+ queryParameter['x-example'] = queryParameter.example;
17
+ delete queryParameter.example;
18
+ }
19
+ parameters.push(queryParameter);
20
+ }
21
+ if (mutationSchema) {
22
+ parameters.push({
23
+ in: 'body',
24
+ name: 'mutation',
25
+ schema: { $ref: mutationSchema.id },
26
+ required: true
27
+ });
28
+ }
29
+ return parameters;
30
+ };
31
+ exports.default = getOperationParameters;
32
+ //# sourceMappingURL=getOperationParameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOperationParameters.js","sourceRoot":"","sources":["../../../src/Service/spec/getOperationParameters.ts"],"names":[],"mappings":";;AAGA,oCAAoC;AACpC,MAAM,sBAAsB,GAAG,CAAC,cAAgC,EAAE,EAAE;IAClE,MAAM,UAAU,GAAG,EAA2B,CAAC;IAE/C,MAAM,EACJ,KAAK,EACL,cAAc,EACf,GAAG,cAAc,CAAC;IAEnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpC,MAAM,cAAc,GAAG;YACrB,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,QAAQ;YACd,IAAI;YACJ,GAAG,eAAe;SACiB,CAAC;QAEtC,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;YAC3B,cAAc,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC;YACrD,OAAO,cAAc,CAAC,OAAO,CAAC;QAChC,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,UAAU,CAAC,IAAI,CAAC;YACd,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE;YACnC,QAAQ,EAAE,IAAI;SACoB,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,sBAAsB,CAAC"}