@kravc/dos 1.12.5 → 2.0.0-alpha.0

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 (497) 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/dist/Service/errors/OperationNotFoundError.d.ts +38 -0
  183. package/dist/Service/errors/OperationNotFoundError.d.ts.map +1 -0
  184. package/dist/Service/errors/OperationNotFoundError.js +45 -0
  185. package/dist/Service/errors/OperationNotFoundError.js.map +1 -0
  186. package/dist/Service/errors/index.d.ts +8 -0
  187. package/dist/Service/errors/index.d.ts.map +1 -0
  188. package/dist/Service/errors/index.js +15 -0
  189. package/dist/Service/errors/index.js.map +1 -0
  190. package/dist/Service/errors/logOperationError.d.ts +35 -0
  191. package/dist/Service/errors/logOperationError.d.ts.map +1 -0
  192. package/dist/Service/errors/logOperationError.js +47 -0
  193. package/dist/Service/errors/logOperationError.js.map +1 -0
  194. package/dist/Service/errors/maskSecrets.d.ts +13 -0
  195. package/dist/Service/errors/maskSecrets.d.ts.map +1 -0
  196. package/dist/Service/errors/maskSecrets.js +57 -0
  197. package/dist/Service/errors/maskSecrets.js.map +1 -0
  198. package/dist/Service/index.d.ts +5 -0
  199. package/dist/Service/index.d.ts.map +1 -0
  200. package/dist/Service/index.js +25 -0
  201. package/dist/Service/index.js.map +1 -0
  202. package/dist/Service/logRequest.d.ts +5 -0
  203. package/dist/Service/logRequest.d.ts.map +1 -0
  204. package/dist/Service/logRequest.js +26 -0
  205. package/dist/Service/logRequest.js.map +1 -0
  206. package/dist/Service/spec/createSpec.d.ts +7 -0
  207. package/dist/Service/spec/createSpec.d.ts.map +1 -0
  208. package/dist/Service/spec/createSpec.js +56 -0
  209. package/dist/Service/spec/createSpec.js.map +1 -0
  210. package/dist/Service/spec/getErrorResponseDescription.d.ts +8 -0
  211. package/dist/Service/spec/getErrorResponseDescription.d.ts.map +1 -0
  212. package/dist/Service/spec/getErrorResponseDescription.js +15 -0
  213. package/dist/Service/spec/getErrorResponseDescription.js.map +1 -0
  214. package/dist/Service/spec/getHttpMethod.d.ts +4 -0
  215. package/dist/Service/spec/getHttpMethod.d.ts.map +1 -0
  216. package/dist/Service/spec/getHttpMethod.js +21 -0
  217. package/dist/Service/spec/getHttpMethod.js.map +1 -0
  218. package/dist/Service/spec/getOperation.d.ts +6 -0
  219. package/dist/Service/spec/getOperation.d.ts.map +1 -0
  220. package/dist/Service/spec/getOperation.js +71 -0
  221. package/dist/Service/spec/getOperation.js.map +1 -0
  222. package/dist/Service/spec/getOperationParameters.d.ts +6 -0
  223. package/dist/Service/spec/getOperationParameters.d.ts.map +1 -0
  224. package/dist/Service/spec/getOperationParameters.js +32 -0
  225. package/dist/Service/spec/getOperationParameters.js.map +1 -0
  226. package/dist/Service/spec/getServiceDefinitions.d.ts +6 -0
  227. package/dist/Service/spec/getServiceDefinitions.d.ts.map +1 -0
  228. package/dist/Service/spec/getServiceDefinitions.js +18 -0
  229. package/dist/Service/spec/getServiceDefinitions.js.map +1 -0
  230. package/dist/Service/spec/getServiceInfo.d.ts +7 -0
  231. package/dist/Service/spec/getServiceInfo.d.ts.map +1 -0
  232. package/dist/Service/spec/getServiceInfo.js +15 -0
  233. package/dist/Service/spec/getServiceInfo.js.map +1 -0
  234. package/dist/Service/spec/getServiceSecurityDefinitions.d.ts +6 -0
  235. package/dist/Service/spec/getServiceSecurityDefinitions.d.ts.map +1 -0
  236. package/dist/Service/spec/getServiceSecurityDefinitions.js +21 -0
  237. package/dist/Service/spec/getServiceSecurityDefinitions.js.map +1 -0
  238. package/dist/Service/spec/getServiceTags.d.ts +7 -0
  239. package/dist/Service/spec/getServiceTags.d.ts.map +1 -0
  240. package/dist/Service/spec/getServiceTags.js +19 -0
  241. package/dist/Service/spec/getServiceTags.js.map +1 -0
  242. package/dist/Service/spec/getSuccessStatusCode.d.ts +4 -0
  243. package/dist/Service/spec/getSuccessStatusCode.d.ts.map +1 -0
  244. package/dist/Service/spec/getSuccessStatusCode.js +14 -0
  245. package/dist/Service/spec/getSuccessStatusCode.js.map +1 -0
  246. package/dist/Service/spec/index.d.ts +3 -0
  247. package/dist/Service/spec/index.d.ts.map +1 -0
  248. package/dist/Service/spec/index.js +9 -0
  249. package/dist/Service/spec/index.js.map +1 -0
  250. package/dist/Service/spec/validateSpec.d.ts +5 -0
  251. package/dist/Service/spec/validateSpec.d.ts.map +1 -0
  252. package/dist/Service/spec/validateSpec.js +21 -0
  253. package/dist/Service/spec/validateSpec.js.map +1 -0
  254. package/dist/Service/test/createAccessToken.d.ts +9 -0
  255. package/dist/Service/test/createAccessToken.d.ts.map +1 -0
  256. package/dist/Service/test/createAccessToken.js +16 -0
  257. package/dist/Service/test/createAccessToken.js.map +1 -0
  258. package/dist/Service/test/ensureItem.d.ts +5 -0
  259. package/dist/Service/test/ensureItem.d.ts.map +1 -0
  260. package/dist/Service/test/ensureItem.js +13 -0
  261. package/dist/Service/test/ensureItem.js.map +1 -0
  262. package/dist/Service/test/ensureNoItem.d.ts +5 -0
  263. package/dist/Service/test/ensureNoItem.d.ts.map +1 -0
  264. package/dist/Service/test/ensureNoItem.js +13 -0
  265. package/dist/Service/test/ensureNoItem.js.map +1 -0
  266. package/dist/Service/test/execute.d.ts +44 -0
  267. package/dist/Service/test/execute.d.ts.map +1 -0
  268. package/dist/Service/test/execute.js +65 -0
  269. package/dist/Service/test/execute.js.map +1 -0
  270. package/dist/Service/test/findItem.d.ts +7 -0
  271. package/dist/Service/test/findItem.d.ts.map +1 -0
  272. package/dist/Service/test/findItem.js +16 -0
  273. package/dist/Service/test/findItem.js.map +1 -0
  274. package/dist/Service/test/firstItemGet.d.ts +5 -0
  275. package/dist/Service/test/firstItemGet.d.ts.map +1 -0
  276. package/dist/Service/test/firstItemGet.js +15 -0
  277. package/dist/Service/test/firstItemGet.js.map +1 -0
  278. package/dist/Service/test/index.d.ts +10 -0
  279. package/dist/Service/test/index.d.ts.map +1 -0
  280. package/dist/Service/test/index.js +36 -0
  281. package/dist/Service/test/index.js.map +1 -0
  282. package/dist/Service/test/keys.d.ts +5 -0
  283. package/dist/Service/test/keys.d.ts.map +1 -0
  284. package/dist/Service/test/keys.js +74 -0
  285. package/dist/Service/test/keys.js.map +1 -0
  286. package/dist/Service/test/wait.d.ts +4 -0
  287. package/dist/Service/test/wait.d.ts.map +1 -0
  288. package/dist/Service/test/wait.js +6 -0
  289. package/dist/Service/test/wait.js.map +1 -0
  290. package/dist/Service/useComposerMiddleware.d.ts +11 -0
  291. package/dist/Service/useComposerMiddleware.d.ts.map +1 -0
  292. package/dist/Service/useComposerMiddleware.js +41 -0
  293. package/dist/Service/useComposerMiddleware.js.map +1 -0
  294. package/dist/Service/useOasMiddleware.d.ts +16 -0
  295. package/dist/Service/useOasMiddleware.d.ts.map +1 -0
  296. package/dist/Service/useOasMiddleware.js +53 -0
  297. package/dist/Service/useOasMiddleware.js.map +1 -0
  298. package/dist/index.d.ts +11 -0
  299. package/dist/index.d.ts.map +1 -0
  300. package/dist/index.js +25 -0
  301. package/dist/index.js.map +1 -0
  302. package/eslint.config.mjs +32 -52
  303. package/example/documents/Profile/Profile.ts +8 -0
  304. package/example/documents/Profile/Profile.yaml +6 -0
  305. package/example/documents/Profile/ProfileAttributes.d.ts +5 -0
  306. package/example/documents/Profile/index.ts +3 -0
  307. package/example/documents/index.ts +5 -0
  308. package/example/index.ts +38 -0
  309. package/example/lib/createActivity.ts +28 -0
  310. package/example/lib/index.ts +24 -0
  311. package/example/operations/Profile/CreateProfile.ts +9 -0
  312. package/example/operations/Profile/DeleteProfile.ts +9 -0
  313. package/example/operations/Profile/IndexProfiles.ts +9 -0
  314. package/example/operations/Profile/ReadProfile.ts +9 -0
  315. package/example/operations/Profile/ReadProfileSystem.ts +9 -0
  316. package/example/operations/Profile/UpdateProfile.ts +9 -0
  317. package/example/operations/Service/Health.ts +11 -0
  318. package/example/operations/index.ts +22 -0
  319. package/example/security/index.ts +25 -0
  320. package/jest.config.mjs +7 -0
  321. package/package.json +34 -24
  322. package/src/Component/Component.ts +120 -0
  323. package/src/Component/__tests__/Component.test.ts +161 -0
  324. package/src/Component/index.ts +7 -0
  325. package/src/Context/Context.ts +217 -0
  326. package/src/Context/Request.ts +41 -0
  327. package/src/Context/__tests__/Context.test.ts +271 -0
  328. package/src/Context/__tests__/__helpers.ts +86 -0
  329. package/src/Context/getHttpMethod.ts +21 -0
  330. package/src/Context/getHttpPath.ts +34 -0
  331. package/src/Context/getMutationParameters.ts +35 -0
  332. package/src/Context/getOperationId.ts +23 -0
  333. package/src/Context/getQueryParameters.ts +45 -0
  334. package/src/Context/index.ts +12 -0
  335. package/src/Context/withSafeAttributes.ts +39 -0
  336. package/src/Document/Document.ts +448 -0
  337. package/src/Document/MemoryDocument.ts +152 -0
  338. package/src/Document/__tests__/MemoryDocument.test.ts +406 -0
  339. package/src/Document/__tests__/__helpers.ts +40 -0
  340. package/src/Document/index.ts +11 -0
  341. package/src/Operation/Operation.ts +401 -0
  342. package/src/Operation/__tests__/Operation.test.ts +142 -0
  343. package/src/Operation/errors/AccessDeniedError.ts +25 -0
  344. package/src/Operation/errors/CommonError.ts +41 -0
  345. package/src/Operation/errors/DocumentExistsError.ts +33 -0
  346. package/src/Operation/errors/DocumentNotFoundError.ts +34 -0
  347. package/src/Operation/errors/InvalidParametersError.ts +30 -0
  348. package/src/Operation/errors/UnauthorizedError.ts +28 -0
  349. package/src/Operation/errors/UnprocessibleConditionError.ts +32 -0
  350. package/src/Operation/errors/__tests__/InvalidParametersError.test.ts +20 -0
  351. package/src/Operation/errors/__tests__/UnprocessibleConditionError.test.ts +20 -0
  352. package/src/Operation/errors/index.ts +17 -0
  353. package/src/Operation/helpers/index.ts +9 -0
  354. package/src/Operation/helpers/withActivity.ts +43 -0
  355. package/src/Operation/index.ts +29 -0
  356. package/src/Operation/operations/Create.ts +49 -0
  357. package/src/Operation/operations/Delete.ts +65 -0
  358. package/src/Operation/operations/Index.ts +164 -0
  359. package/src/Operation/operations/List.ts +62 -0
  360. package/src/Operation/operations/Read.ts +55 -0
  361. package/src/Operation/operations/Update.ts +60 -0
  362. package/src/Operation/operations/__tests__/Create.test.ts +153 -0
  363. package/src/Operation/operations/__tests__/Delete.test.ts +163 -0
  364. package/src/Operation/operations/__tests__/Index.test.ts +209 -0
  365. package/src/Operation/operations/__tests__/List.test.ts +146 -0
  366. package/src/Operation/operations/__tests__/Read.test.ts +152 -0
  367. package/src/Operation/operations/__tests__/Update.test.ts +158 -0
  368. package/src/Operation/security/JwtAuthorization.ts +247 -0
  369. package/src/Operation/security/LambdaAuthorization.ts +103 -0
  370. package/src/Operation/security/__tests__/JwtAuthorization.test.ts +230 -0
  371. package/src/Operation/security/__tests__/LambdaAuthorization.test.ts +63 -0
  372. package/src/Operation/security/__tests__/userAuthorization.test.ts +42 -0
  373. package/src/Operation/security/index.ts +15 -0
  374. package/src/Operation/security/systemAuthorization.ts +23 -0
  375. package/src/Operation/security/userAuthorization.ts +47 -0
  376. package/src/Operation/security/verifyToken.ts +22 -0
  377. package/src/Service/Service.ts +317 -0
  378. package/src/Service/__tests__/Service.test.ts +229 -0
  379. package/src/Service/authorize.ts +80 -0
  380. package/src/Service/errors/InvalidInputError.ts +40 -0
  381. package/src/Service/errors/InvalidOutputError.ts +40 -0
  382. package/src/Service/errors/OperationError.ts +74 -0
  383. package/src/{errors → Service/errors}/OperationError.yaml +7 -10
  384. package/src/Service/errors/OperationErrorAttributes.d.ts +12 -0
  385. package/src/Service/errors/OperationNotFoundError.ts +45 -0
  386. package/src/Service/errors/__tests__/OperationError.test.ts +17 -0
  387. package/src/Service/errors/__tests__/maskSecrets.test.ts +92 -0
  388. package/src/Service/errors/index.ts +18 -0
  389. package/src/Service/errors/logOperationError.ts +72 -0
  390. package/src/Service/errors/maskSecrets.ts +65 -0
  391. package/src/Service/index.ts +9 -0
  392. package/src/Service/logRequest.ts +50 -0
  393. package/src/Service/spec/__tests__/validateSpec.test.ts +10 -0
  394. package/src/Service/spec/createSpec.ts +68 -0
  395. package/src/Service/spec/getErrorResponseDescription.ts +20 -0
  396. package/src/Service/spec/getHttpMethod.ts +20 -0
  397. package/src/Service/spec/getOperation.ts +99 -0
  398. package/src/Service/spec/getOperationParameters.ts +43 -0
  399. package/src/Service/spec/getServiceDefinitions.ts +23 -0
  400. package/src/Service/spec/getServiceInfo.ts +18 -0
  401. package/src/Service/spec/getServiceSecurityDefinitions.ts +26 -0
  402. package/src/Service/spec/getServiceTags.ts +23 -0
  403. package/src/Service/spec/getSuccessStatusCode.ts +15 -0
  404. package/src/Service/spec/index.ts +5 -0
  405. package/src/Service/spec/validateSpec.ts +22 -0
  406. package/src/Service/test/__tests__/createAccessToken.test.ts +104 -0
  407. package/src/Service/test/__tests__/ensureItem.test.ts +41 -0
  408. package/src/Service/test/__tests__/ensureNoItem.test.ts +49 -0
  409. package/src/Service/test/__tests__/execute.test.ts +125 -0
  410. package/src/Service/test/__tests__/findItem.test.ts +45 -0
  411. package/src/Service/test/__tests__/firstItemGet.test.ts +50 -0
  412. package/src/Service/test/__tests__/wait.test.ts +66 -0
  413. package/src/Service/test/createAccessToken.ts +28 -0
  414. package/src/Service/test/ensureItem.ts +9 -0
  415. package/src/Service/test/ensureNoItem.ts +9 -0
  416. package/src/Service/test/execute.ts +112 -0
  417. package/src/Service/test/findItem.ts +22 -0
  418. package/src/Service/test/firstItemGet.ts +18 -0
  419. package/src/Service/test/index.ts +19 -0
  420. package/src/Service/test/keys.ts +75 -0
  421. package/src/Service/test/wait.ts +5 -0
  422. package/src/Service/useComposerMiddleware.ts +56 -0
  423. package/src/Service/useOasMiddleware.ts +69 -0
  424. package/src/index.ts +12 -0
  425. package/tsconfig.json +26 -0
  426. package/examples/CreateProfile.js +0 -40
  427. package/examples/DeleteProfile.js +0 -6
  428. package/examples/Health.js +0 -8
  429. package/examples/IndexProfiles.js +0 -6
  430. package/examples/Profile.js +0 -8
  431. package/examples/Profile.yaml +0 -4
  432. package/examples/ReadProfile.js +0 -18
  433. package/examples/UpdateProfile.js +0 -25
  434. package/examples/index.js +0 -29
  435. package/src/Component.js +0 -59
  436. package/src/Component.spec.js +0 -65
  437. package/src/Document.js +0 -310
  438. package/src/Document.spec.js +0 -331
  439. package/src/Operation.js +0 -258
  440. package/src/Operation.spec.js +0 -474
  441. package/src/Service.js +0 -207
  442. package/src/Service.spec.js +0 -388
  443. package/src/errors/AccessDeniedError.js +0 -11
  444. package/src/errors/CommonError.js +0 -19
  445. package/src/errors/DocumentExistsError.js +0 -15
  446. package/src/errors/DocumentNotFoundError.js +0 -15
  447. package/src/errors/InvalidInputError.js +0 -19
  448. package/src/errors/InvalidOutputError.js +0 -20
  449. package/src/errors/InvalidParametersError.js +0 -11
  450. package/src/errors/OperationError.js +0 -44
  451. package/src/errors/OperationNotFoundError.js +0 -16
  452. package/src/errors/UnauthorizedError.js +0 -11
  453. package/src/errors/UnprocessibleConditionError.js +0 -11
  454. package/src/errors/index.js +0 -11
  455. package/src/helpers/asSafeClass.js +0 -22
  456. package/src/helpers/authorize.js +0 -44
  457. package/src/helpers/createContext.js +0 -96
  458. package/src/helpers/createSchemasMap.js +0 -37
  459. package/src/helpers/createSpec.js +0 -196
  460. package/src/helpers/defaultId.js +0 -30
  461. package/src/helpers/defaultSummary.js +0 -15
  462. package/src/helpers/defaultTags.js +0 -16
  463. package/src/helpers/getComponentTitle.js +0 -22
  464. package/src/helpers/getDefaultSchemaAttributes.js +0 -32
  465. package/src/helpers/getHttpMethod.js +0 -19
  466. package/src/helpers/getIdPrefix.js +0 -7
  467. package/src/helpers/getOrFail.js +0 -24
  468. package/src/helpers/getOrFail.spec.js +0 -17
  469. package/src/helpers/getSuccessStatusCode.js +0 -15
  470. package/src/helpers/handler.js +0 -21
  471. package/src/helpers/loadSync.js +0 -14
  472. package/src/helpers/logError.js +0 -33
  473. package/src/helpers/logRequest.js +0 -36
  474. package/src/helpers/maskSecrets.js +0 -42
  475. package/src/helpers/specMiddleware.js +0 -81
  476. package/src/index.d.ts +0 -350
  477. package/src/index.js +0 -35
  478. package/src/operations/Create.js +0 -39
  479. package/src/operations/Delete.js +0 -54
  480. package/src/operations/Index.js +0 -107
  481. package/src/operations/Read.js +0 -46
  482. package/src/operations/Update.js +0 -50
  483. package/src/security/JwtAuthorization.js +0 -125
  484. package/src/security/SystemAuthorization.js +0 -73
  485. package/src/security/index.js +0 -9
  486. package/src/security/verifyToken.js +0 -17
  487. package/src/test/createAccessToken.js +0 -23
  488. package/src/test/execute.js +0 -84
  489. package/src/test/index.js +0 -11
  490. package/src/test/keys.js +0 -39
  491. package/src/test/wait.js +0 -5
  492. /package/{specs → .composer}/Documents.yaml +0 -0
  493. /package/{specs → .composer}/Enums.yaml +0 -0
  494. /package/{specs → .composer}/Operations.yaml +0 -0
  495. /package/{specs → .composer}/Parameters.yaml +0 -0
  496. /package/{specs → .composer}/Scenarios.yaml +0 -0
  497. /package/{specs → .composer}/Schemas.yaml +0 -0
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /** Extends operation with a custom create activity method. */
4
+ const withActivity = (baseAction, createActivity) => {
5
+ return (ComponentClass, componentAction) => {
6
+ /** Operation class with create activity method. */
7
+ return class extends baseAction(ComponentClass, componentAction) {
8
+ /** Creates activity after default exec is done */
9
+ async createActivity(parameters, result) {
10
+ const context = this.context;
11
+ const { componentName } = this.constructor;
12
+ await createActivity({
13
+ result,
14
+ context,
15
+ parameters,
16
+ componentName,
17
+ });
18
+ }
19
+ };
20
+ };
21
+ };
22
+ exports.default = withActivity;
23
+ //# sourceMappingURL=withActivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withActivity.js","sourceRoot":"","sources":["../../../src/Operation/helpers/withActivity.ts"],"names":[],"mappings":";;AAeA,8DAA8D;AAC9D,MAAM,YAAY,GAAG,CACnB,UAAsB,EACtB,cAA6D,EACY,EAAE;IAC3E,OAAO,CAAC,cAAc,EAAE,eAAe,EAAE,EAAE;QACzC,mDAAmD;QACnD,OAAO,KAAM,SAAQ,UAAU,CAAC,cAAc,EAAE,eAAe,CAAC;YAC9D,kDAAkD;YAClD,KAAK,CAAC,cAAc,CAClB,UAAmC,EACnC,MAAe;gBAEf,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;gBAC7B,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,WAA+B,CAAC;gBAE/D,MAAM,cAAc,CAAC;oBACnB,MAAM;oBACN,OAAO;oBACP,UAAU;oBACV,aAAa;iBACd,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,14 @@
1
+ import Operation from './Operation';
2
+ import Read from './operations/Read';
3
+ import List from './operations/List';
4
+ import Index from './operations/Index';
5
+ import Create from './operations/Create';
6
+ import Update from './operations/Update';
7
+ import Delete from './operations/Delete';
8
+ import { withActivity, type CreateActivityProps } from './helpers';
9
+ export default Operation;
10
+ export { Read, List, Index, Create, Update, Delete, Operation, withActivity, };
11
+ export * from './errors';
12
+ export * from './security';
13
+ export type { CreateActivityProps };
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Operation/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC,OAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEnE,eAAe,SAAS,CAAC;AAEzB,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,SAAS,EACT,YAAY,GACb,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,YAAY,EACV,mBAAmB,EACpB,CAAC"}
@@ -0,0 +1,40 @@
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.withActivity = exports.Operation = exports.Delete = exports.Update = exports.Create = exports.Index = exports.List = exports.Read = void 0;
21
+ const Operation_1 = __importDefault(require("./Operation"));
22
+ exports.Operation = Operation_1.default;
23
+ const Read_1 = __importDefault(require("./operations/Read"));
24
+ exports.Read = Read_1.default;
25
+ const List_1 = __importDefault(require("./operations/List"));
26
+ exports.List = List_1.default;
27
+ const Index_1 = __importDefault(require("./operations/Index"));
28
+ exports.Index = Index_1.default;
29
+ const Create_1 = __importDefault(require("./operations/Create"));
30
+ exports.Create = Create_1.default;
31
+ const Update_1 = __importDefault(require("./operations/Update"));
32
+ exports.Update = Update_1.default;
33
+ const Delete_1 = __importDefault(require("./operations/Delete"));
34
+ exports.Delete = Delete_1.default;
35
+ const helpers_1 = require("./helpers");
36
+ Object.defineProperty(exports, "withActivity", { enumerable: true, get: function () { return helpers_1.withActivity; } });
37
+ exports.default = Operation_1.default;
38
+ __exportStar(require("./errors"), exports);
39
+ __exportStar(require("./security"), exports);
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Operation/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,4DAAoC;AAmBlC,oBAnBK,mBAAS,CAmBL;AAjBX,6DAAqC;AAWnC,eAXK,cAAI,CAWL;AAVN,6DAAqC;AAWnC,eAXK,cAAI,CAWL;AAVN,+DAAuC;AAWrC,gBAXK,eAAK,CAWL;AAVP,iEAAyC;AAWvC,iBAXK,gBAAM,CAWL;AAVR,iEAAyC;AAWvC,iBAXK,gBAAM,CAWL;AAVR,iEAAyC;AAWvC,iBAXK,gBAAM,CAWL;AAVR,uCAAmE;AAYjE,6FAZO,sBAAY,OAYP;AAVd,kBAAe,mBAAS,CAAC;AAazB,2CAAyB;AACzB,6CAA2B"}
@@ -0,0 +1,5 @@
1
+ import Operation from '../Operation';
2
+ /** Returns class for a create operation. */
3
+ declare const Create: (ComponentClass: any, componentAction?: string) => typeof Operation;
4
+ export default Create;
5
+ //# sourceMappingURL=Create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Create.d.ts","sourceRoot":"","sources":["../../../src/Operation/operations/Create.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,4CAA4C;AAC5C,QAAA,MAAM,MAAM,GAEV,gBAAgB,GAAG,EACnB,kBAAiB,MAA+B,KAC/C,OAAO,SAsCT,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,44 @@
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 class for a create operation. */
8
+ const Create = (
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ ComponentClass, componentAction = Operation_1.default.types.CREATE) => {
11
+ if (!ComponentClass?.isComponent) {
12
+ throw new Error('Argument "ComponentClass" is undefined for "Create" operation' +
13
+ ' function');
14
+ }
15
+ ComponentClass = ComponentClass;
16
+ const componentTitle = ComponentClass.getTitle();
17
+ /** Create operation class */
18
+ return class extends Operation_1.default {
19
+ /** Returns component class for a create operation. */
20
+ static get Component() {
21
+ return ComponentClass;
22
+ }
23
+ /** Returns component action name for a create operation. */
24
+ static get componentAction() {
25
+ return componentAction;
26
+ }
27
+ /** Returns create operation type. */
28
+ static get type() {
29
+ return Operation_1.default.types.CREATE;
30
+ }
31
+ /** Returns possible errors for a create operation. */
32
+ static get errors() {
33
+ return {
34
+ ...super.errors,
35
+ DocumentExistsError: {
36
+ statusCode: 422,
37
+ description: `${componentTitle} could not be created, it already exists`
38
+ }
39
+ };
40
+ }
41
+ };
42
+ };
43
+ exports.default = Create;
44
+ //# sourceMappingURL=Create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Create.js","sourceRoot":"","sources":["../../../src/Operation/operations/Create.ts"],"names":[],"mappings":";;;;;AAAA,6DAAqC;AAGrC,4CAA4C;AAC5C,MAAM,MAAM,GAAG;AACb,8DAA8D;AAC9D,cAAmB,EACnB,kBAA0B,mBAAS,CAAC,KAAK,CAAC,MAAM,EAC9B,EAAE;IACpB,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,+DAA+D;YAC7E,WAAW,CAAC,CAAC;IACjB,CAAC;IAED,cAAc,GAAG,cAA6C,CAAC;IAE/D,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAEjD,6BAA6B;IAC7B,OAAO,KAAM,SAAQ,mBAAS;QAC5B,sDAAsD;QACtD,MAAM,KAAK,SAAS;YAClB,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,4DAA4D;QAC5D,MAAM,KAAK,eAAe;YACxB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,qCAAqC;QACrC,MAAM,KAAK,IAAI;YACb,OAAO,mBAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,CAAC;QAED,sDAAsD;QACtD,MAAM,KAAK,MAAM;YACf,OAAO;gBACL,GAAG,KAAK,CAAC,MAAM;gBACf,mBAAmB,EAAE;oBACnB,UAAU,EAAE,GAAG;oBACf,WAAW,EAAE,GAAG,cAAc,0CAA0C;iBACzE;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,5 @@
1
+ import Operation from '../Operation';
2
+ /** Returns class for a delete operation. */
3
+ declare const Delete: (ComponentClass: any, componentAction?: string) => typeof Operation;
4
+ export default Delete;
5
+ //# sourceMappingURL=Delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Delete.d.ts","sourceRoot":"","sources":["../../../src/Operation/operations/Delete.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,4CAA4C;AAC5C,QAAA,MAAM,MAAM,GAEV,gBAAgB,GAAG,EACnB,kBAAiB,MAA+B,KAC/C,OAAO,SAsDT,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,58 @@
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 class for a delete operation. */
8
+ const Delete = (
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ ComponentClass, componentAction = Operation_1.default.types.DELETE) => {
11
+ if (!ComponentClass?.isComponent) {
12
+ throw new Error('Argument "ComponentClass" is undefined for "Delete" operation' +
13
+ ' function');
14
+ }
15
+ ComponentClass = ComponentClass;
16
+ const componentTitle = ComponentClass.getTitle();
17
+ const componentTitleLower = componentTitle.toLowerCase();
18
+ /** Delete operation class */
19
+ return class extends Operation_1.default {
20
+ /** Returns component class for a delete operation. */
21
+ static get Component() {
22
+ return ComponentClass;
23
+ }
24
+ /** Returns component action name for a delete operation. */
25
+ static get componentAction() {
26
+ return componentAction;
27
+ }
28
+ /** Returns delete operation type. */
29
+ static get type() {
30
+ return Operation_1.default.types.DELETE;
31
+ }
32
+ /** Returns possible errors for a delete operation. */
33
+ static get errors() {
34
+ return {
35
+ ...super.errors,
36
+ DocumentNotFoundError: {
37
+ statusCode: 404,
38
+ description: `${componentTitle} is not found`
39
+ }
40
+ };
41
+ }
42
+ /** Returns query schema with a component ID. */
43
+ static get query() {
44
+ return {
45
+ id: {
46
+ description: `ID of ${componentTitleLower} to be deleted`,
47
+ required: true
48
+ }
49
+ };
50
+ }
51
+ /** No output for a delete operation. */
52
+ static get output() {
53
+ return null;
54
+ }
55
+ };
56
+ };
57
+ exports.default = Delete;
58
+ //# sourceMappingURL=Delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Delete.js","sourceRoot":"","sources":["../../../src/Operation/operations/Delete.ts"],"names":[],"mappings":";;;;;AAAA,6DAAqC;AAGrC,4CAA4C;AAC5C,MAAM,MAAM,GAAG;AACb,8DAA8D;AAC9D,cAAmB,EACnB,kBAA0B,mBAAS,CAAC,KAAK,CAAC,MAAM,EAC9B,EAAE;IACpB,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,+DAA+D;YAC7E,WAAW,CAAC,CAAC;IACjB,CAAC;IAED,cAAc,GAAG,cAA6C,CAAC;IAE/D,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IACjD,MAAM,mBAAmB,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAEzD,6BAA6B;IAC7B,OAAO,KAAM,SAAQ,mBAAS;QAC5B,sDAAsD;QACtD,MAAM,KAAK,SAAS;YAClB,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,4DAA4D;QAC5D,MAAM,KAAK,eAAe;YACxB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,qCAAqC;QACrC,MAAM,KAAK,IAAI;YACb,OAAO,mBAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,CAAC;QAED,sDAAsD;QACtD,MAAM,KAAK,MAAM;YACf,OAAO;gBACL,GAAG,KAAK,CAAC,MAAM;gBACf,qBAAqB,EAAE;oBACrB,UAAU,EAAE,GAAG;oBACf,WAAW,EAAE,GAAG,cAAc,eAAe;iBAC9C;aACF,CAAC;QACJ,CAAC;QAED,gDAAgD;QAChD,MAAM,KAAK,KAAK;YACd,OAAO;gBACL,EAAE,EAAE;oBACF,WAAW,EAAE,SAAS,mBAAmB,gBAAgB;oBACzD,QAAQ,EAAE,IAAI;iBACf;aACF,CAAC;QACJ,CAAC;QAED,wCAAwC;QACxC,MAAM,KAAK,MAAM;YACf,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ import Operation from '../Operation';
2
+ export type PageInfo = {
3
+ sort: 'asc' | 'desc';
4
+ count: number;
5
+ limit: number;
6
+ lastEvaluatedKey?: string;
7
+ };
8
+ /** Returns class for an index operation. */
9
+ declare const Index: (ComponentClass: any, componentAction?: string) => typeof Operation;
10
+ export default Index;
11
+ //# sourceMappingURL=Index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../../src/Operation/operations/Index.ts"],"names":[],"mappings":"AAEA,OAAO,SAA0B,MAAM,cAAc,CAAC;AAYtD,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAA;AAED,4CAA4C;AAC5C,QAAA,MAAM,KAAK,GAET,gBAAgB,GAAG,EACnB,kBAAiB,MAAgB,KAChC,OAAO,SAuIT,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -0,0 +1,128 @@
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 Operation_1 = __importDefault(require("../Operation"));
8
+ const SORT_ORDER = {
9
+ ASC: 'asc',
10
+ DESC: 'desc',
11
+ };
12
+ const DEFAULT_LIMIT = 20;
13
+ const DEFAULT_LIMIT_MAX = 999;
14
+ const DEFAULT_SORT_ORDER = SORT_ORDER.DESC;
15
+ /** Returns class for an index operation. */
16
+ const Index = (
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ ComponentClass, componentAction = 'index') => {
19
+ if (!ComponentClass?.isComponent) {
20
+ throw new Error('Argument "ComponentClass" is undefined for "Index"' +
21
+ ' operation function');
22
+ }
23
+ ComponentClass = ComponentClass;
24
+ const documentTitle = ComponentClass.getTitle(false, true);
25
+ /** Index operation class */
26
+ return class extends Operation_1.default {
27
+ /** Returns summary for an index operation. */
28
+ static get summary() {
29
+ return (0, lodash_1.capitalize)(`${componentAction} ${documentTitle}`);
30
+ }
31
+ /** Returns component class for an index operation. */
32
+ static get Component() {
33
+ return ComponentClass;
34
+ }
35
+ /** Returns component action name for an index operation. */
36
+ static get componentAction() {
37
+ return componentAction;
38
+ }
39
+ /** Returns default value for a limit parameter. */
40
+ static get defaultLimit() {
41
+ return DEFAULT_LIMIT;
42
+ }
43
+ /** Returns maximum number for a limit parameter. */
44
+ static get limitMax() {
45
+ return DEFAULT_LIMIT_MAX;
46
+ }
47
+ /** Returns default value for a sort parameter. */
48
+ static get defaultSort() {
49
+ return DEFAULT_SORT_ORDER;
50
+ }
51
+ /** Returns query schema for pagination parameters. */
52
+ static get query() {
53
+ return {
54
+ limit: {
55
+ type: 'integer',
56
+ example: this.defaultLimit,
57
+ default: this.defaultLimit,
58
+ minimum: 1,
59
+ maximum: this.limitMax,
60
+ description: `Limit number of ${documentTitle} to be returned`,
61
+ },
62
+ sort: {
63
+ enum: Object.values(SORT_ORDER),
64
+ default: this.defaultSort,
65
+ description: 'Sort direction',
66
+ },
67
+ exclusiveStartKey: {
68
+ description: `Exclusive start key to return next batch of ${documentTitle}`,
69
+ }
70
+ };
71
+ }
72
+ /** Returns schema source for the operation output with pagination. */
73
+ static get output() {
74
+ return {
75
+ data: {
76
+ items: {
77
+ $ref: ComponentClass.schema.id
78
+ },
79
+ required: true,
80
+ },
81
+ pageInfo: {
82
+ required: true,
83
+ properties: {
84
+ sort: {
85
+ enum: Object.values(SORT_ORDER),
86
+ description: 'Sort direction',
87
+ },
88
+ count: {
89
+ type: 'integer',
90
+ example: 0,
91
+ description: `Number of ${documentTitle}`,
92
+ },
93
+ limit: {
94
+ type: 'integer',
95
+ example: 100,
96
+ description: `Limit number of ${documentTitle} to be returned`,
97
+ },
98
+ lastEvaluatedKey: {
99
+ description: `Last evaluated key to get next batch of ${documentTitle}`,
100
+ },
101
+ }
102
+ }
103
+ };
104
+ }
105
+ /** Executes components index action. */
106
+ async action(parameters) {
107
+ const { sort, limit, index, exclusiveStartKey, ...query } = parameters;
108
+ const options = {
109
+ sort,
110
+ limit,
111
+ index,
112
+ exclusiveStartKey,
113
+ };
114
+ const { componentActionMethod } = this.constructor;
115
+ const result = await componentActionMethod(this.context, query, options);
116
+ const { objects: data, count, lastEvaluatedKey, } = result;
117
+ const pageInfo = {
118
+ sort,
119
+ count,
120
+ limit,
121
+ lastEvaluatedKey,
122
+ };
123
+ return { data, pageInfo };
124
+ }
125
+ };
126
+ };
127
+ exports.default = Index;
128
+ //# sourceMappingURL=Index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../src/Operation/operations/Index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ import Operation from '../Operation';
2
+ /** Returns class for an list operation. */
3
+ declare const List: (ComponentClass: any, componentAction?: string) => typeof Operation;
4
+ export default List;
5
+ //# sourceMappingURL=List.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/Operation/operations/List.ts"],"names":[],"mappings":"AAEA,OAAO,SAA0B,MAAM,cAAc,CAAC;AAEtD,2CAA2C;AAC3C,QAAA,MAAM,IAAI,GAER,gBAAgB,GAAG,EACnB,kBAAiB,MAAmB,KACnC,OAAO,SAkDT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,48 @@
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 Operation_1 = __importDefault(require("../Operation"));
8
+ /** Returns class for an list operation. */
9
+ const List = (
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ ComponentClass, componentAction = 'indexAll') => {
12
+ if (!ComponentClass?.isComponent) {
13
+ throw new Error('Argument "ComponentClass" is undefined for "List"' +
14
+ ' operation function');
15
+ }
16
+ ComponentClass = ComponentClass;
17
+ const documentTitle = ComponentClass.getTitle(false, true);
18
+ /** List operation class */
19
+ return class extends Operation_1.default {
20
+ /** Returns summary for an index operation. */
21
+ static get summary() {
22
+ const action = componentAction.replace('indexAll', 'list');
23
+ return (0, lodash_1.capitalize)(`${action} ${documentTitle}`);
24
+ }
25
+ /** Returns component class for an index operation. */
26
+ static get Component() {
27
+ return ComponentClass;
28
+ }
29
+ /** Returns component action name for an index operation. */
30
+ static get componentAction() {
31
+ return componentAction;
32
+ }
33
+ /** Executes components list action. */
34
+ async action(parameters) {
35
+ const { sort, index, ...query } = parameters;
36
+ const options = {
37
+ sort,
38
+ index,
39
+ };
40
+ const { componentActionMethod } = this.constructor;
41
+ const result = await componentActionMethod(this.context, query, options);
42
+ const { objects } = result;
43
+ return { data: objects };
44
+ }
45
+ };
46
+ };
47
+ exports.default = List;
48
+ //# sourceMappingURL=List.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/Operation/operations/List.ts"],"names":[],"mappings":";;;;;AACA,mCAAoC;AACpC,6DAAsD;AAEtD,2CAA2C;AAC3C,MAAM,IAAI,GAAG;AACX,8DAA8D;AAC9D,cAAmB,EACnB,kBAA0B,UAAU,EAClB,EAAE;IACpB,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,mDAAmD;YACjE,qBAAqB,CAAC,CAAC;IAC3B,CAAC;IAED,cAAc,GAAG,cAA6C,CAAC;IAE/D,MAAM,aAAa,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAE3D,2BAA2B;IAC3B,OAAO,KAAM,SAAQ,mBAAS;QAC5B,8CAA8C;QAC9C,MAAM,KAAK,OAAO;YAChB,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC3D,OAAO,IAAA,mBAAU,EAAC,GAAG,MAAM,IAAI,aAAa,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,sDAAsD;QACtD,MAAM,KAAK,SAAS;YAClB,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,4DAA4D;QAC5D,MAAM,KAAK,eAAe;YACxB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,uCAAuC;QACvC,KAAK,CAAC,MAAM,CAAC,UAAmC;YAC9C,MAAM,EACJ,IAAI,EACJ,KAAK,EACL,GAAG,KAAK,EACT,GAAG,UAAU,CAAC;YAEf,MAAM,OAAO,GAAG;gBACd,IAAI;gBACJ,KAAK;aACN,CAAC;YAEF,MAAM,EAAE,qBAAqB,EAAE,GAAG,IAAI,CAAC,WAA+B,CAAC;YAEvE,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAEzE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;YAE3B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAsB,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,5 @@
1
+ import Operation from '../Operation';
2
+ /** Returns class for a read operation. */
3
+ declare const Read: (ComponentClass: any, componentAction?: string) => typeof Operation;
4
+ export default Read;
5
+ //# sourceMappingURL=Read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Read.d.ts","sourceRoot":"","sources":["../../../src/Operation/operations/Read.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,0CAA0C;AAC1C,QAAA,MAAM,IAAI,GAER,gBAAgB,GAAG,EACnB,kBAAiB,MAA6B,KAC7C,OAAO,SA4CT,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,50 @@
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 class for a read operation. */
8
+ const Read = (
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ ComponentClass, componentAction = Operation_1.default.types.READ) => {
11
+ if (!ComponentClass?.isComponent) {
12
+ throw new Error('Argument "ComponentClass" is undefined for "Read" operation' +
13
+ ' function');
14
+ }
15
+ ComponentClass = ComponentClass;
16
+ const componentTitle = ComponentClass.getTitle();
17
+ const componentTitleLower = componentTitle.toLowerCase();
18
+ /** Read operation class */
19
+ return class extends Operation_1.default {
20
+ /** Returns component class for a read operation. */
21
+ static get Component() {
22
+ return ComponentClass;
23
+ }
24
+ /** Returns component action name for a read operation. */
25
+ static get componentAction() {
26
+ return componentAction;
27
+ }
28
+ /** Returns possible errors for a read operation. */
29
+ static get errors() {
30
+ return {
31
+ ...super.errors,
32
+ DocumentNotFoundError: {
33
+ statusCode: 404,
34
+ description: `${componentTitle} is not found`
35
+ }
36
+ };
37
+ }
38
+ /** Returns query schema with a component ID. */
39
+ static get query() {
40
+ return {
41
+ id: {
42
+ description: `ID of ${componentTitleLower} to be returned`,
43
+ required: true
44
+ }
45
+ };
46
+ }
47
+ };
48
+ };
49
+ exports.default = Read;
50
+ //# sourceMappingURL=Read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Read.js","sourceRoot":"","sources":["../../../src/Operation/operations/Read.ts"],"names":[],"mappings":";;;;;AAAA,6DAAqC;AAGrC,0CAA0C;AAC1C,MAAM,IAAI,GAAG;AACX,8DAA8D;AAC9D,cAAmB,EACnB,kBAA0B,mBAAS,CAAC,KAAK,CAAC,IAAI,EAC5B,EAAE;IACpB,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,6DAA6D;YAC3E,WAAW,CAAC,CAAC;IACjB,CAAC;IAED,cAAc,GAAG,cAA6C,CAAC;IAE/D,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IACjD,MAAM,mBAAmB,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAEzD,2BAA2B;IAC3B,OAAO,KAAM,SAAQ,mBAAS;QAC5B,oDAAoD;QACpD,MAAM,KAAK,SAAS;YAClB,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,0DAA0D;QAC1D,MAAM,KAAK,eAAe;YACxB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,oDAAoD;QACpD,MAAM,KAAK,MAAM;YACf,OAAO;gBACL,GAAG,KAAK,CAAC,MAAM;gBACf,qBAAqB,EAAE;oBACrB,UAAU,EAAG,GAAG;oBAChB,WAAW,EAAE,GAAG,cAAc,eAAe;iBAC9C;aACF,CAAC;QACJ,CAAC;QAED,gDAAgD;QAChD,MAAM,KAAK,KAAK;YACd,OAAO;gBACL,EAAE,EAAE;oBACF,WAAW,EAAE,SAAS,mBAAmB,iBAAiB;oBAC1D,QAAQ,EAAE,IAAI;iBACf;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
@@ -0,0 +1,5 @@
1
+ import Operation from '../Operation';
2
+ /** Returns class for an update operation. */
3
+ declare const Update: (ComponentClass: any, componentAction?: string) => typeof Operation;
4
+ export default Update;
5
+ //# sourceMappingURL=Update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Update.d.ts","sourceRoot":"","sources":["../../../src/Operation/operations/Update.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,6CAA6C;AAC7C,QAAA,MAAM,MAAM,GAEV,gBAAgB,GAAG,EACnB,kBAAiB,MAA+B,KAC/C,OAAO,SAiDT,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,54 @@
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 class for an update operation. */
8
+ const Update = (
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ ComponentClass, componentAction = Operation_1.default.types.UPDATE) => {
11
+ if (!ComponentClass?.isComponent) {
12
+ throw new Error('Argument "ComponentClass" is undefined for "Update" operation' +
13
+ ' function');
14
+ }
15
+ ComponentClass = ComponentClass;
16
+ const componentTitle = ComponentClass.getTitle();
17
+ const componentTitleLower = componentTitle.toLowerCase();
18
+ /** Update operation class */
19
+ return class extends Operation_1.default {
20
+ /** Returns component class for an update operation. */
21
+ static get Component() {
22
+ return ComponentClass;
23
+ }
24
+ /** Returns component action name for an update operation. */
25
+ static get componentAction() {
26
+ return componentAction;
27
+ }
28
+ /** Returns update operation type. */
29
+ static get type() {
30
+ return Operation_1.default.types.UPDATE;
31
+ }
32
+ /** Returns possible errors for a read operation. */
33
+ static get errors() {
34
+ return {
35
+ ...super.errors,
36
+ DocumentNotFoundError: {
37
+ statusCode: 404,
38
+ description: `${componentTitle} is not found`
39
+ }
40
+ };
41
+ }
42
+ /** Returns query schema with a component ID. */
43
+ static get query() {
44
+ return {
45
+ id: {
46
+ description: `ID of ${componentTitleLower} to be updated`,
47
+ required: true
48
+ }
49
+ };
50
+ }
51
+ };
52
+ };
53
+ exports.default = Update;
54
+ //# sourceMappingURL=Update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Update.js","sourceRoot":"","sources":["../../../src/Operation/operations/Update.ts"],"names":[],"mappings":";;;;;AAAA,6DAAqC;AAGrC,6CAA6C;AAC7C,MAAM,MAAM,GAAG;AACb,8DAA8D;AAC9D,cAAmB,EACnB,kBAA0B,mBAAS,CAAC,KAAK,CAAC,MAAM,EAC9B,EAAE;IACpB,IAAI,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,+DAA+D;YAC7E,WAAW,CAAC,CAAC;IACjB,CAAC;IAED,cAAc,GAAG,cAA6C,CAAC;IAE/D,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IACjD,MAAM,mBAAmB,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAEzD,6BAA6B;IAC7B,OAAO,KAAM,SAAQ,mBAAS;QAC5B,uDAAuD;QACvD,MAAM,KAAK,SAAS;YAClB,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,6DAA6D;QAC7D,MAAM,KAAK,eAAe;YACxB,OAAO,eAAe,CAAC;QACzB,CAAC;QAED,qCAAqC;QACrC,MAAM,KAAK,IAAI;YACb,OAAO,mBAAS,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,CAAC;QAED,oDAAoD;QACpD,MAAM,KAAK,MAAM;YACf,OAAO;gBACL,GAAG,KAAK,CAAC,MAAM;gBACf,qBAAqB,EAAE;oBACrB,UAAU,EAAG,GAAG;oBAChB,WAAW,EAAE,GAAG,cAAc,eAAe;iBAC9C;aACF,CAAC;QACJ,CAAC;QAED,gDAAgD;QAChD,MAAM,KAAK,KAAK;YACd,OAAO;gBACL,EAAE,EAAE;oBACF,WAAW,EAAE,SAAS,mBAAmB,gBAAgB;oBACzD,QAAQ,EAAE,IAAI;iBACf;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,MAAM,CAAC"}
@@ -0,0 +1,67 @@
1
+ import Context from '../../Context';
2
+ import { type Algorithm } from 'jsonwebtoken';
3
+ import type { VerificationResult, Requirement } from '../../Service/authorize';
4
+ type Claims = {
5
+ sub?: string;
6
+ iss?: string;
7
+ permissions?: string[];
8
+ [x: string]: unknown;
9
+ };
10
+ type TokenVerificationMethod = (context: Context, token: string, publicKey: string, algorithm: Algorithm) => Promise<[true] | [false, string]>;
11
+ type AccessVerificationMethod = (context: Context, claims: Claims, permissions?: Permissions) => Promise<[true] | [false, string]>;
12
+ type NormalizeClaimsMethod = (claims: Claims) => Claims;
13
+ type RequirementOptions = {
14
+ name?: string;
15
+ issuer?: string;
16
+ publicKey: string;
17
+ cookieName?: string;
18
+ description?: string;
19
+ permissions?: Permissions;
20
+ requirementName?: string;
21
+ algorithm?: Algorithm;
22
+ normalizeClaimsMethod?: NormalizeClaimsMethod;
23
+ tokenVerificationMethod?: TokenVerificationMethod;
24
+ accessVerificationMethod?: AccessVerificationMethod;
25
+ };
26
+ export type Permissions = Record<string, string[]>;
27
+ /** JWT Authorization */
28
+ declare class JwtAuthorization {
29
+ private _name;
30
+ private _issuer?;
31
+ private _publicKey;
32
+ private _algorithm;
33
+ private _cookieName;
34
+ private _permissions?;
35
+ private _verifyToken;
36
+ private _verifyAccess;
37
+ private _normalizeClaims;
38
+ /** Creates an instance of JWT authorization security. */
39
+ constructor({ name, issuer, publicKey, cookieName, permissions, algorithm, normalizeClaimsMethod, tokenVerificationMethod, accessVerificationMethod, }: {
40
+ name: string;
41
+ issuer?: string;
42
+ publicKey: string;
43
+ algorithm?: Algorithm;
44
+ cookieName?: string;
45
+ permissions?: Permissions;
46
+ normalizeClaimsMethod?: NormalizeClaimsMethod;
47
+ tokenVerificationMethod?: TokenVerificationMethod;
48
+ accessVerificationMethod?: AccessVerificationMethod;
49
+ });
50
+ /** Returns specification for JWT authorization security requirement. */
51
+ static createRequirement(options: RequirementOptions): Record<string, Requirement>;
52
+ /** Returns security related errors. */
53
+ static get errors(): {
54
+ UnauthorizedError: {
55
+ statusCode: number;
56
+ description: string;
57
+ };
58
+ AccessDeniedError: {
59
+ statusCode: number;
60
+ description: string;
61
+ };
62
+ };
63
+ /** Verifies JWT authorization. */
64
+ verify(context: Context): Promise<VerificationResult>;
65
+ }
66
+ export default JwtAuthorization;
67
+ //# sourceMappingURL=JwtAuthorization.d.ts.map