@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 @@
1
+ {"version":3,"file":"Document.js","sourceRoot":"","sources":["../../src/Document/Document.ts"],"names":[],"mappings":";;;;;AAAA,+BAA4B;AAC5B,6DAAqC;AACrC,0CAAyE;AAEzE,mCAAqE;AAErE,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AA+C1C,+BAA+B;AAC/B,MAAM,QAAqB,SAAQ,mBAAqB;IAC9C,MAAM,CAAC,WAAW,CAAS;IAE3B,mBAAmB,CAAyB;IAEpD,2CAA2C;IAC3C,MAAM,KAAK,YAAY;QACrB,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,kCAAkC;IAClC,MAAM,KAAK,QAAQ;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,8DAA8D;IAC9D,MAAM,KAAK,WAAW;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,+DAA+D;IAC/D,MAAM,KAAK,gBAAgB;QACzB,O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AEpE,IAAA,YAAG,EAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;CACF;AAED,kBAAe,QAAQ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { QueryMap, MutationMap } from '../Context';
2
+ import Document, { type IndexOptions, type IndexAllOptions } from './Document';
3
+ type Item = {
4
+ id: string;
5
+ [index: string]: unknown;
6
+ };
7
+ /** Example implementation of a document class stored in memory. */
8
+ declare class MemoryDocument<T> extends Document<T> {
9
+ /** Returns collection where documents are stored. */
10
+ static get collection(): Record<string, Item>;
11
+ /** Resets collection. */
12
+ static reset(): Promise<void>;
13
+ /** Implements interface to get documents in batches. */
14
+ static _index<T>(query: QueryMap, options: IndexOptions): Promise<{
15
+ count: number;
16
+ items: T[];
17
+ lastEvaluatedKey?: string;
18
+ }>;
19
+ /** Implements interface to get all documents. */
20
+ static _indexAll<T>(query: QueryMap, options: IndexAllOptions): Promise<{
21
+ count: number;
22
+ items: T[];
23
+ }>;
24
+ /** Implements interface to get a document. */
25
+ static _read<T>(query: QueryMap): Promise<T>;
26
+ /** Implements interface to save a document. */
27
+ static _create<T>(attributes: T): Promise<void>;
28
+ /** Implements interface to update a document. */
29
+ static _update<T>(query: QueryMap, mutation: MutationMap): Promise<T>;
30
+ /** Implements interface to delete a document. */
31
+ static _delete<T>(query: QueryMap): Promise<void>;
32
+ }
33
+ export default MemoryDocument;
34
+ //# sourceMappingURL=MemoryDocument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryDocument.d.ts","sourceRoot":"","sources":["../../src/Document/MemoryDocument.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,QAAQ,EAAE,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/E,KAAK,IAAI,GAAG;IACV,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC;AAIF,mEAAmE;AACnE,cAAM,cAAc,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACzC,qDAAqD;IACrD,MAAM,KAAK,UAAU,yBAUpB;IAED,yBAAyB;WACZ,KAAK;IAMlB,wDAAwD;WAC3C,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC;QACtE,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,CAAC,EAAE,CAAC;QACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IAiDF,iDAAiD;WACpC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC;QAC5E,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,CAAC,EAAE,CAAC;KACZ,CAAC;IASF,8CAA8C;WACjC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAYlD,+CAA+C;WAClC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYrD,iDAAiD;WACpC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAW3E,iDAAiD;WACpC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAQxD;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,103 @@
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 schema_1 = require("@kravc/schema");
7
+ const lodash_1 = require("lodash");
8
+ const Operation_1 = require("../Operation");
9
+ const Document_1 = __importDefault(require("./Document"));
10
+ const _MEMORY_STORE = {};
11
+ /** Example implementation of a document class stored in memory. */
12
+ class MemoryDocument extends Document_1.default {
13
+ /** Returns collection where documents are stored. */
14
+ static get collection() {
15
+ const collectionName = this.name;
16
+ const hasCollection = !!_MEMORY_STORE[collectionName];
17
+ if (!hasCollection) {
18
+ _MEMORY_STORE[collectionName] = {};
19
+ }
20
+ return _MEMORY_STORE[collectionName];
21
+ }
22
+ /** Resets collection. */
23
+ static async reset() {
24
+ const collectionName = this.name;
25
+ delete _MEMORY_STORE[collectionName];
26
+ }
27
+ /** Implements interface to get documents in batches. */
28
+ static async _index(query, options) {
29
+ const { sort, limit, exclusiveStartKey } = options;
30
+ /** Filters result item to match query. */
31
+ const filter = (item) => Object
32
+ .keys(query)
33
+ .every(key => item[key] === query[key]);
34
+ const sortedItems = sort === 'desc'
35
+ ? (0, lodash_1.sortBy)(Object.values(this.collection), this.indexSortBy).reverse()
36
+ : (0, lodash_1.sortBy)(Object.values(this.collection), this.indexSortBy);
37
+ const filteredItems = sortedItems
38
+ .filter(filter)
39
+ .map(lodash_1.cloneDeep);
40
+ let exclusiveStartKeyIndex = -1;
41
+ if (exclusiveStartKey) {
42
+ exclusiveStartKeyIndex = filteredItems
43
+ .findIndex(item => (0, schema_1.got)(item, this.idKey) === exclusiveStartKey);
44
+ }
45
+ const items = limit
46
+ ? filteredItems.slice(exclusiveStartKeyIndex + 1, exclusiveStartKeyIndex + 1 + limit)
47
+ : filteredItems.slice(exclusiveStartKeyIndex + 1, filteredItems.length);
48
+ const count = items.length;
49
+ let lastEvaluatedKey = (0, lodash_1.get)((0, lodash_1.last)(items), this.idKey);
50
+ const isLastItemIncluded = (0, lodash_1.get)((0, lodash_1.last)(sortedItems), this.idKey) === lastEvaluatedKey;
51
+ if (isLastItemIncluded) {
52
+ lastEvaluatedKey = undefined;
53
+ }
54
+ return {
55
+ items,
56
+ count,
57
+ lastEvaluatedKey,
58
+ };
59
+ }
60
+ /** Implements interface to get all documents. */
61
+ static async _indexAll(query, options) {
62
+ const { items, count } = await this._index(query, options);
63
+ return {
64
+ items,
65
+ count,
66
+ };
67
+ }
68
+ /** Implements interface to get a document. */
69
+ static async _read(query) {
70
+ const idValue = (0, schema_1.got)(query, this.idKey, 'Query parameter "$PATH" is required');
71
+ const item = (0, lodash_1.get)(this.collection, idValue);
72
+ if (!item) {
73
+ throw new Operation_1.DocumentNotFoundError(this, query);
74
+ }
75
+ return (0, lodash_1.cloneDeep)(item);
76
+ }
77
+ /** Implements interface to save a document. */
78
+ static async _create(attributes) {
79
+ const idValue = (0, schema_1.got)(attributes, this.idKey, 'Attribute "$PATH" is required');
80
+ const item = (0, lodash_1.get)(this.collection, idValue);
81
+ if (item) {
82
+ throw new Operation_1.DocumentExistsError(this, attributes);
83
+ }
84
+ (0, lodash_1.set)(this.collection, idValue, attributes);
85
+ }
86
+ /** Implements interface to update a document. */
87
+ static async _update(query, mutation) {
88
+ const idValue = (0, schema_1.got)(query, this.idKey, 'Query parameter "$PATH" is required');
89
+ const componentTitle = this.getTitle();
90
+ const item = (0, schema_1.got)(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`);
91
+ (0, lodash_1.set)(this.collection, idValue, { ...item, ...mutation });
92
+ return (0, lodash_1.cloneDeep)({ ...item, ...mutation });
93
+ }
94
+ /** Implements interface to delete a document. */
95
+ static async _delete(query) {
96
+ const idValue = (0, schema_1.got)(query, this.idKey, 'Query parameter "$PATH" is required');
97
+ const componentTitle = this.getTitle();
98
+ (0, schema_1.got)(this.collection, idValue, `${componentTitle} with ID "$PATH" is not found`);
99
+ (0, lodash_1.unset)(this.collection, idValue);
100
+ }
101
+ }
102
+ exports.default = MemoryDocument;
103
+ //# sourceMappingURL=MemoryDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryDocument.js","sourceRoot":"","sources":["../../src/Document/MemoryDocument.ts"],"names":[],"m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E,GAAG,cAAc,+BAA+B,CAAM,CAAC;QAElG,IAAA,YAAG,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;QAExD,OAAO,IAAA,kBAAS,EAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,iDAAiD;IACjD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAI,KAAe;QACrC,MAAM,OAAO,GAAG,IAAA,YAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,qCAAqC,CAAW,CAAC;QAExF,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAA,YAAG,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,cAAc,+BAA+B,CAAM,CAAC;QAErF,IAAA,cAAK,EAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;CACF;AAED,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,18 @@
1
+ import Context, { type MutationMap } from '../../Context';
2
+ import { MemoryDocument, type DefaultAttributes } from '../../';
3
+ interface ProfileAttributes extends DefaultAttributes {
4
+ name: string;
5
+ }
6
+ /** Example of a default document. */
7
+ declare class Profile extends MemoryDocument<ProfileAttributes> {
8
+ /** Returns a profile name. */
9
+ get name(): string;
10
+ }
11
+ /** Example of a document with custom getPartition method. */
12
+ declare class User extends MemoryDocument<ProfileAttributes> {
13
+ /** Returns custom partition based off parameters. */
14
+ static getPartition(_context: Context, parameters: MutationMap): string;
15
+ }
16
+ export { User, Profile, };
17
+ export type { ProfileAttributes, };
18
+ //# sourceMappingURL=__helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__helpers.d.ts","sourceRoot":"","sources":["../../../src/Document/__tests__/__helpers.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhE,UAAU,iBAAkB,SAAQ,iBAAiB;IACnD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qCAAqC;AACrC,cAAM,OAAQ,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IACrD,8BAA8B;IAC9B,IAAI,IAAI,WAEP;CACF;AAID,6DAA6D;AAC7D,cAAM,IAAK,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IAClD,qDAAqD;IACrD,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW;CAM/D;AAID,OAAO,EACL,IAAI,EACJ,OAAO,GACR,CAAC;AAEF,YAAY,EACV,iBAAiB,GAClB,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Profile = exports.User = void 0;
4
+ const schema_1 = require("@kravc/schema");
5
+ const __helpers_1 = require("../../Context/__tests__/__helpers");
6
+ const __1 = require("../../");
7
+ ;
8
+ /** Example of a default document. */
9
+ class Profile extends __1.MemoryDocument {
10
+ /** Returns a profile name. */
11
+ get name() {
12
+ return this.attributes.name;
13
+ }
14
+ }
15
+ exports.Profile = Profile;
16
+ Profile.schema = __helpers_1.profileSchema;
17
+ /** Example of a document with custom getPartition method. */
18
+ class User extends __1.MemoryDocument {
19
+ /** Returns custom partition based off parameters. */
20
+ static getPartition(_context, parameters) {
21
+ const name = (0, schema_1.got)(parameters, 'name');
22
+ const partition = name[0].toUpperCase();
23
+ return partition;
24
+ }
25
+ }
26
+ exports.User = User;
27
+ User.schema = __helpers_1.profileSchema;
28
+ //# sourceMappingURL=__helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__helpers.js","sourceRoot":"","sources":["../../../src/Document/__tests__/__helpers.ts"],"names":[],"mappings":";;;AAAA,0CAAoC;AACpC,iEAAkE;AAElE,8BAAgE;AAI/D,CAAC;AAEF,qCAAqC;AACrC,MAAM,OAAQ,SAAQ,kBAAiC;IACrD,8BAA8B;IAC9B,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAmBC,0BAAO;AAjBT,OAAO,CAAC,MAAM,GAAG,yBAAa,CAAC;AAE/B,6DAA6D;AAC7D,MAAM,IAAK,SAAQ,kBAAiC;IAClD,qDAAqD;IACrD,MAAM,CAAC,YAAY,CAAC,QAAiB,EAAE,UAAuB;QAC5D,MAAM,IAAI,GAAG,IAAA,YAAG,EAAC,UAAU,EAAE,MAAM,CAAW,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAExC,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAKC,oBAAI;AAHN,IAAI,CAAC,MAAM,GAAG,yBAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ import Document from './Document';
2
+ import MemoryDocument from './MemoryDocument';
3
+ export { Document, MemoryDocument, };
4
+ export type * from './Document';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Document/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EACL,QAAQ,EACR,cAAc,GACf,CAAC;AAEF,mBAAmB,YAAY,CAAC"}
@@ -0,0 +1,11 @@
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.MemoryDocument = exports.Document = void 0;
7
+ const Document_1 = __importDefault(require("./Document"));
8
+ exports.Document = Document_1.default;
9
+ const MemoryDocument_1 = __importDefault(require("./MemoryDocument"));
10
+ exports.MemoryDocument = MemoryDocument_1.default;
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Document/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAIhC,mBAJK,kBAAQ,CAIL;AAHV,sEAA8C;AAI5C,yBAJK,wBAAc,CAIL"}
@@ -0,0 +1,95 @@
1
+ import Component from '../Component';
2
+ import { OriginalError } from '../Service/errors';
3
+ import { Schema, type PropertiesSchemaSource } from '@kravc/schema';
4
+ import type { SecurityRequirements, ErrorResponse } from '../Service/authorize';
5
+ import Context, { type QueryMap, type MutationMap } from '../Context';
6
+ export type Result = Record<string, unknown>;
7
+ type ComponentActionMethod = (context: Context, query: QueryMap, mutation: MutationMap) => Promise<Result>;
8
+ export type OperationResponse = {
9
+ result: Record<string, unknown>;
10
+ headers: Record<string, unknown>;
11
+ multiValueHeaders: Record<string, unknown>;
12
+ };
13
+ /** Operation */
14
+ declare class Operation {
15
+ private _context;
16
+ private _headers;
17
+ private _multiValueHeaders;
18
+ /** Creates an instance of operation. */
19
+ constructor(context: Context);
20
+ /** Returns supported operation types. */
21
+ static get types(): {
22
+ READ: string;
23
+ CREATE: string;
24
+ UPDATE: string;
25
+ DELETE: string;
26
+ };
27
+ /** Flags if a component class. */
28
+ static get isComponent(): boolean;
29
+ /** Returns default operation type. */
30
+ static get type(): string;
31
+ /** Flags if operation is of a create type. */
32
+ static get isCreate(): boolean;
33
+ /** Flags if operation is of an update type. */
34
+ static get isUpdate(): boolean;
35
+ /** Returns component class the operations is defined for. */
36
+ static get Component(): null | typeof Component;
37
+ /** Returns related component name. */
38
+ static get componentName(): string | undefined;
39
+ /** Returns component action name for the operation to execute. */
40
+ static get componentAction(): string;
41
+ /** Returns component schema. */
42
+ static get componentSchema(): Schema | undefined;
43
+ /** Returns component mutation schema. */
44
+ static get componentMutationSchema(): Schema | undefined;
45
+ /** Returns operation ID. */
46
+ static get id(): string;
47
+ /** Returns operation tags. */
48
+ static get tags(): string[];
49
+ /** Returns operation summary. */
50
+ static get summary(): string;
51
+ /** Returns a list of permissions to access operation. */
52
+ static get permissions(): null | string[];
53
+ /** Returns operation description. */
54
+ static get description(): string;
55
+ /** Returns operation security requirements. */
56
+ static get security(): SecurityRequirements;
57
+ /** Returns possible operation errors. */
58
+ static get errors(): Record<string, ErrorResponse>;
59
+ /** Returns status code for an error. */
60
+ static getErrorStatusCode(error: OriginalError): number;
61
+ /** Returns operation query schema source. */
62
+ static get query(): null | PropertiesSchemaSource;
63
+ /** Returns operation mutation schema instance or schema source. */
64
+ static get mutation(): null | Schema | PropertiesSchemaSource;
65
+ /** Returns operation mutation schema. */
66
+ static get mutationSchema(): null | Schema;
67
+ /** Returns operation input validation schema. */
68
+ static get inputSchema(): null | Schema;
69
+ /** Returns operation output schema source. */
70
+ static get output(): null | PropertiesSchemaSource;
71
+ /** Returns operation output validation schema. */
72
+ static get outputSchema(): null | Schema;
73
+ /** Flags if operation has output. */
74
+ static get hasOutput(): boolean;
75
+ /** Returns component action method binded to component. */
76
+ static get componentActionMethod(): ComponentActionMethod;
77
+ /** Adds header value to context headers. */
78
+ setHeader(name: string, value: unknown, isMultiValue?: boolean): void;
79
+ /** Returns operation context. */
80
+ get context(): Context;
81
+ /** Pre-processes operation parameters before action. */
82
+ before(parameters: Record<string, unknown>): Promise<Record<string, unknown> | void>;
83
+ /** Executes component action. */
84
+ action(parameters: Record<string, unknown>): Promise<{
85
+ data?: Result;
86
+ }>;
87
+ /** Post-processes operation result after action. */
88
+ after(_parameters: Record<string, unknown>, result?: Record<string, unknown>): Promise<Result | void>;
89
+ /** Creates activity for mutation operation. */
90
+ createActivity(_input: Record<string, unknown>, _data?: Result): Promise<void>;
91
+ /** Executes operation for the request input. */
92
+ exec(input: Record<string, unknown>): Promise<OperationResponse>;
93
+ }
94
+ export default Operation;
95
+ //# sourceMappingURL=Operation.d.ts.map
@@ -0,0 +1 @@
1
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,OAAO,CAE9B;IAED,2DAA2D;IAC3D,MAAM,KAAK,qBAAqB,0BAgB/B;IAED,4CAA4C;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,UAAQ;IAU5D,iCAAiC;IACjC,IAAI,OAAO,YAEV;IAED,wDAAwD;IAClD,MAAM,CACV,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAI1C,iCAAiC;IAC3B,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;eAYlB,MAAM;;IAGpC,oDAAoD;IAC9C,KAAK,CACT,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIzB,+CAA+C;IACzC,cAAc,CAElB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE/B,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAIhB,gDAAgD;IAC1C,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA+BvE;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,301 @@
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 pluralize_1 = __importDefault(require("pluralize"));
7
+ const schema_1 = require("@kravc/schema");
8
+ const lodash_1 = require("lodash");
9
+ const Context_1 = require("../Context");
10
+ /** Operation */
11
+ class Operation {
12
+ _context;
13
+ _headers;
14
+ _multiValueHeaders;
15
+ /** Creates an instance of operation. */
16
+ constructor(context) {
17
+ const className = (0, lodash_1.get)(this.constructor, 'id');
18
+ this._context = context;
19
+ this._headers = {};
20
+ this._multiValueHeaders = {};
21
+ return (0, Context_1.withSafeAttributes)(this, className);
22
+ }
23
+ /** Returns supported operation types. */
24
+ static get types() {
25
+ return {
26
+ READ: 'read',
27
+ CREATE: 'create',
28
+ UPDATE: 'update',
29
+ DELETE: 'delete'
30
+ };
31
+ }
32
+ /** Flags if a component class. */
33
+ static get isComponent() {
34
+ return false;
35
+ }
36
+ /** Returns default operation type. */
37
+ static get type() {
38
+ return Operation.types.READ;
39
+ }
40
+ /** Flags if operation is of a create type. */
41
+ static get isCreate() {
42
+ return this.type === Operation.types.CREATE;
43
+ }
44
+ /** Flags if operation is of an update type. */
45
+ static get isUpdate() {
46
+ return this.type === Operation.types.UPDATE;
47
+ }
48
+ /** Returns component class the operations is defined for. */
49
+ static get Component() {
50
+ return null;
51
+ }
52
+ /** Returns related component name. */
53
+ static get componentName() {
54
+ return this.Component?.name;
55
+ }
56
+ /** Returns component action name for the operation to execute. */
57
+ static get componentAction() {
58
+ return this.type;
59
+ }
60
+ /** Returns component schema. */
61
+ static get componentSchema() {
62
+ return this.Component?.schema;
63
+ }
64
+ /** Returns component mutation schema. */
65
+ static get componentMutationSchema() {
66
+ return this.Component?.mutationSchema;
67
+ }
68
+ /** Returns operation ID. */
69
+ static get id() {
70
+ const hasOperationName = this.name !== 'Operation' &&
71
+ this.name !== '';
72
+ if (hasOperationName) {
73
+ return this.name;
74
+ }
75
+ if (!this.Component) {
76
+ throw new Error('Operation ID is undefined');
77
+ }
78
+ const isIndex = [
79
+ 'index',
80
+ 'indexAll'
81
+ ].includes(this.componentAction);
82
+ const componentAction = this.componentAction.replace('indexAll', 'list');
83
+ const actionName = (0, lodash_1.startCase)(componentAction);
84
+ if (isIndex) {
85
+ const componentTitlePlural = (0, pluralize_1.default)((0, lodash_1.startCase)(this.componentName));
86
+ return `${actionName}${componentTitlePlural}`;
87
+ }
88
+ return `${actionName}${this.componentName}`;
89
+ }
90
+ /** Returns operation tags. */
91
+ static get tags() {
92
+ if (!this.componentName) {
93
+ return [];
94
+ }
95
+ const tag = this.componentName;
96
+ return [tag];
97
+ }
98
+ /** Returns operation summary. */
99
+ static get summary() {
100
+ if (!this.Component) {
101
+ return '';
102
+ }
103
+ const componentName = this.Component.getTitle(false);
104
+ return (0, lodash_1.capitalize)(`${this.componentAction} ${componentName}`);
105
+ }
106
+ /** Returns a list of permissions to access operation. */
107
+ static get permissions() {
108
+ return null;
109
+ }
110
+ /** Returns operation description. */
111
+ static get description() {
112
+ return '';
113
+ }
114
+ /** Returns operation security requirements. */
115
+ static get security() {
116
+ return [];
117
+ }
118
+ /** Returns possible operation errors. */
119
+ static get errors() {
120
+ let errors = {};
121
+ for (const orRequirement of this.security) {
122
+ const andRequirements = Object.values(orRequirement);
123
+ for (const andRequirement of andRequirements) {
124
+ errors = {
125
+ ...andRequirement.errors,
126
+ ...errors
127
+ };
128
+ }
129
+ }
130
+ if (this.inputSchema) {
131
+ errors.InvalidInputError = {
132
+ statusCode: 400,
133
+ description: 'Invalid operation input, make sure operation parameters' +
134
+ ' do match specification'
135
+ };
136
+ errors.InvalidParametersError = {
137
+ statusCode: 400,
138
+ description: 'Invalid operation parameters, input syntax is correct,' +
139
+ ' but input values are not processible'
140
+ };
141
+ }
142
+ errors.UnprocessibleConditionError = {
143
+ statusCode: 422,
144
+ description: 'Operation failed to process the request cause of expected' +
145
+ ' exit condition'
146
+ };
147
+ if (this.outputSchema) {
148
+ errors.InvalidOutputError = {
149
+ statusCode: 500,
150
+ description: 'Invalid output returned by the operation, this issue' +
151
+ ' to be addressed by service developer'
152
+ };
153
+ }
154
+ return errors;
155
+ }
156
+ /** Returns status code for an error. */
157
+ static getErrorStatusCode(error) {
158
+ const { code } = error;
159
+ return (0, lodash_1.get)(this.errors, `${code}.statusCode`, 500);
160
+ }
161
+ /** Returns operation query schema source. */
162
+ static get query() {
163
+ return null;
164
+ }
165
+ /** Returns operation mutation schema instance or schema source. */
166
+ static get mutation() {
167
+ if (this.componentMutationSchema) {
168
+ if (this.isUpdate) {
169
+ return this.componentMutationSchema.pure();
170
+ }
171
+ if (this.isCreate) {
172
+ return this.componentMutationSchema.clone();
173
+ }
174
+ }
175
+ return null;
176
+ }
177
+ /** Returns operation mutation schema. */
178
+ static get mutationSchema() {
179
+ if (!this.mutation) {
180
+ return null;
181
+ }
182
+ return new schema_1.Schema(this.mutation, `${this.id}InputMutation`);
183
+ }
184
+ /** Returns operation input validation schema. */
185
+ static get inputSchema() {
186
+ const source = {
187
+ ...this.query,
188
+ };
189
+ if (this.mutationSchema) {
190
+ source.mutation = {
191
+ $ref: `${this.id}InputMutation`,
192
+ required: true
193
+ };
194
+ }
195
+ if ((0, lodash_1.isEmpty)(source)) {
196
+ return null;
197
+ }
198
+ return new schema_1.Schema(source, `${this.id}Input`);
199
+ }
200
+ /** Returns operation output schema source. */
201
+ static get output() {
202
+ if (!this.componentSchema) {
203
+ return null;
204
+ }
205
+ return {
206
+ data: {
207
+ $ref: this.componentSchema.id,
208
+ required: true
209
+ }
210
+ };
211
+ }
212
+ /** Returns operation output validation schema. */
213
+ static get outputSchema() {
214
+ if (!this.output) {
215
+ return null;
216
+ }
217
+ return new schema_1.Schema(this.output, `${this.id}Output`);
218
+ }
219
+ /** Flags if operation has output. */
220
+ static get hasOutput() {
221
+ return !!this.outputSchema;
222
+ }
223
+ /** Returns component action method binded to component. */
224
+ static get componentActionMethod() {
225
+ const { Component, componentAction } = this;
226
+ if (Component) {
227
+ const componentActionMethod = (0, lodash_1.get)(Component, componentAction);
228
+ if (!componentActionMethod) {
229
+ throw new Error(`Operation "${this.id}" expects component action` +
230
+ ` method "${Component.name}.${componentAction}(context, ...)" to be` +
231
+ ' defined');
232
+ }
233
+ return componentActionMethod.bind(Component);
234
+ }
235
+ throw new Error(`Operation "${this.id}" expects component to be defined`);
236
+ }
237
+ /** Adds header value to context headers. */
238
+ setHeader(name, value, isMultiValue = false) {
239
+ if (isMultiValue) {
240
+ this._multiValueHeaders[name.toLowerCase()] = value;
241
+ return;
242
+ }
243
+ this._headers[name.toLowerCase()] = value;
244
+ }
245
+ /** Returns operation context. */
246
+ get context() {
247
+ return this._context;
248
+ }
249
+ /** Pre-processes operation parameters before action. */
250
+ async before(parameters) {
251
+ return parameters;
252
+ }
253
+ /** Executes component action. */
254
+ async action(parameters) {
255
+ const { Component } = this.constructor;
256
+ if (!Component) {
257
+ return {};
258
+ }
259
+ const { mutation = {}, ...query } = parameters;
260
+ const { componentActionMethod } = this.constructor;
261
+ const data = await componentActionMethod(this.context, query, mutation);
262
+ return { data };
263
+ }
264
+ /** Post-processes operation result after action. */
265
+ async after(_parameters, result) {
266
+ return result;
267
+ }
268
+ /** Creates activity for mutation operation. */
269
+ async createActivity(
270
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
271
+ _input,
272
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
273
+ _data) {
274
+ return;
275
+ }
276
+ /** Executes operation for the request input. */
277
+ async exec(input) {
278
+ let parameters = (0, lodash_1.cloneDeep)(input);
279
+ let result;
280
+ const beforeResult = await this.before(parameters);
281
+ parameters = beforeResult
282
+ ? beforeResult
283
+ : parameters;
284
+ result = await this.action(parameters);
285
+ const afterResult = await this.after(parameters, result.data || result);
286
+ result = afterResult
287
+ ? (result.data
288
+ ? { ...result, data: afterResult }
289
+ : afterResult)
290
+ : result;
291
+ const { data } = result;
292
+ await this.createActivity(input, data);
293
+ return {
294
+ result,
295
+ headers: this._headers,
296
+ multiValueHeaders: this._multiValueHeaders
297
+ };
298
+ }
299
+ }
300
+ exports.default = Operation;
301
+ //# sourceMappingURL=Operation.js.map