@sparted/shared-library 1.0.7 → 1.0.8-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 (339) hide show
  1. package/.circleci/config.yml +40 -0
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.js +17 -0
  4. package/.gitignore +37 -0
  5. package/CHANGELOG.md +34 -0
  6. package/README.md +26 -0
  7. package/dist/github/commits/create-git-blob.d.ts +26 -0
  8. package/dist/github/commits/create-git-blob.js +42 -0
  9. package/dist/github/commits/create-git-blob.js.map +1 -0
  10. package/dist/github/commits/create-git-commit.d.ts +23 -0
  11. package/dist/github/commits/create-git-commit.js +39 -0
  12. package/dist/github/commits/create-git-commit.js.map +1 -0
  13. package/dist/github/commits/create-git-tree.d.ts +29 -0
  14. package/dist/github/commits/create-git-tree.js +47 -0
  15. package/dist/github/commits/create-git-tree.js.map +1 -0
  16. package/dist/github/commits/get-sha-last-commit-of-branch.d.ts +21 -0
  17. package/dist/github/commits/get-sha-last-commit-of-branch.js +35 -0
  18. package/dist/github/commits/get-sha-last-commit-of-branch.js.map +1 -0
  19. package/dist/github/commits/get-tree-by-commit-sha.d.ts +23 -0
  20. package/dist/github/commits/get-tree-by-commit-sha.js +37 -0
  21. package/dist/github/commits/get-tree-by-commit-sha.js.map +1 -0
  22. package/dist/github/commits/index.d.ts +6 -0
  23. package/dist/github/commits/index.js +20 -0
  24. package/dist/github/commits/run-new-commit-process.d.ts +27 -0
  25. package/dist/github/commits/run-new-commit-process.js +49 -0
  26. package/dist/github/commits/run-new-commit-process.js.map +1 -0
  27. package/dist/github/commits/utils.d.ts +1 -0
  28. package/dist/github/commits/utils.js +29 -0
  29. package/dist/github/commits/utils.js.map +1 -0
  30. package/dist/github/contents/get-file-content.d.ts +20 -0
  31. package/dist/github/contents/get-file-content.js +38 -0
  32. package/dist/github/contents/get-file-content.js.map +1 -0
  33. package/dist/github/github.d.ts +25 -0
  34. package/dist/github/github.js +53 -0
  35. package/dist/github/github.js.map +1 -0
  36. package/dist/github/index.d.ts +1 -0
  37. package/dist/github/index.js +10 -0
  38. package/dist/index.d.ts +15 -0
  39. package/{index.js → dist/index.js} +2 -0
  40. package/{index.js.map → dist/index.js.map} +1 -1
  41. package/dist/package.json +65 -0
  42. package/dist/string/index.js.map +1 -0
  43. package/dist/time/index.js.map +1 -0
  44. package/global.d.ts +2 -0
  45. package/package.json +7 -3
  46. package/rollup.config.ts +15 -0
  47. package/src/array/__tests__/array-to-map.test.ts +50 -0
  48. package/src/array/__tests__/get-values-from-keys.test.ts +14 -0
  49. package/src/array/array-to-map.ts +32 -0
  50. package/src/array/get-values-from-keys.ts +3 -0
  51. package/src/array/index.ts +2 -0
  52. package/src/cdn/__tests__/cdn.factory.test.ts +120 -0
  53. package/src/cdn/__tests__/utils.test.ts +456 -0
  54. package/src/cdn/cdn.factory.ts +63 -0
  55. package/src/cdn/index.ts +2 -0
  56. package/src/cdn/types/cdn-factory.type.ts +35 -0
  57. package/src/cdn/types/index.ts +1 -0
  58. package/src/cdn/utils/extract-info-from-url.util.ts +21 -0
  59. package/src/cdn/utils/get-cdn-from-s3-url.util.ts +20 -0
  60. package/src/cdn/utils/get-cdn-url.util.ts +26 -0
  61. package/src/formatting/__tests__/format-number.test.ts +11 -0
  62. package/src/formatting/format-number.ts +14 -0
  63. package/src/formatting/index.ts +1 -0
  64. package/src/fp/__tests__/run-while.test.ts +29 -0
  65. package/src/fp/index.ts +1 -0
  66. package/src/fp/run-while.ts +54 -0
  67. package/src/github/commits/create-git-blob.ts +57 -0
  68. package/src/github/commits/create-git-commit.ts +57 -0
  69. package/src/github/commits/create-git-tree.ts +68 -0
  70. package/src/github/commits/get-sha-last-commit-of-branch.ts +50 -0
  71. package/src/github/commits/get-tree-by-commit-sha.ts +52 -0
  72. package/src/github/commits/index.ts +6 -0
  73. package/src/github/commits/run-new-commit-process.ts +88 -0
  74. package/src/github/commits/utils.ts +31 -0
  75. package/src/github/contents/get-file-content.ts +50 -0
  76. package/src/github/github.ts +74 -0
  77. package/src/github/index.ts +1 -0
  78. package/src/http/__tests__/encode-search-object.test.ts +34 -0
  79. package/src/http/__tests__/fetch-with-timeout.test.ts +50 -0
  80. package/src/http/encode-search-object.ts +39 -0
  81. package/src/http/fetch-with-timeout.ts +24 -0
  82. package/src/http/index.ts +2 -0
  83. package/{index.d.ts → src/index.ts} +15 -14
  84. package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +103 -0
  85. package/src/linked-list/__tests__/create-linked-list.test.ts +204 -0
  86. package/src/linked-list/__tests__/find-linked-list.test.ts +40 -0
  87. package/src/linked-list/__tests__/get-linked-list.test.ts +28 -0
  88. package/src/linked-list/__tests__/insert-linked-list.test.ts +186 -0
  89. package/src/linked-list/__tests__/linked-list-utils.test.ts +252 -0
  90. package/src/linked-list/__tests__/reduce-linked-list.test.ts +31 -0
  91. package/src/linked-list/__tests__/remove-linked-list.test.ts +129 -0
  92. package/src/linked-list/__tests__/update-linked-list.test.ts +53 -0
  93. package/src/linked-list/__tests__/while-linked-list.test.ts +58 -0
  94. package/src/linked-list/apply-diff-linked-list.ts +35 -0
  95. package/src/linked-list/create-linked-list.ts +79 -0
  96. package/src/linked-list/find-linked-list.ts +26 -0
  97. package/src/linked-list/get-linked-list.ts +9 -0
  98. package/src/linked-list/index.ts +2 -0
  99. package/src/linked-list/insert-linked-list.ts +50 -0
  100. package/src/linked-list/linked-list-utils.ts +143 -0
  101. package/src/linked-list/reduce-linked-list.ts +18 -0
  102. package/src/linked-list/remove-linked-list.ts +36 -0
  103. package/src/linked-list/type.ts +38 -0
  104. package/src/linked-list/update-linked-list.ts +29 -0
  105. package/src/linked-list/while-linked-list.ts +33 -0
  106. package/src/math/__tests__/clamp-number.test.ts +30 -0
  107. package/src/math/__tests__/interpolate.test.ts +28 -0
  108. package/src/math/__tests__/number-range.test.ts +59 -0
  109. package/src/math/__tests__/random-number.test.ts +11 -0
  110. package/src/math/clamp-number.ts +8 -0
  111. package/src/math/index.ts +4 -0
  112. package/src/math/interpolate.ts +18 -0
  113. package/src/math/number-range.ts +16 -0
  114. package/src/math/random-number.ts +10 -0
  115. package/src/object/__tests__/merge-deep.test.ts +56 -0
  116. package/src/object/index.ts +1 -0
  117. package/src/object/merge-deep.ts +27 -0
  118. package/src/parsing/__tests__/parse-boolean.test.ts +15 -0
  119. package/src/parsing/__tests__/parse-enum.test.ts +19 -0
  120. package/src/parsing/__tests__/parse-number.test.ts +20 -0
  121. package/src/parsing/index.ts +3 -0
  122. package/src/parsing/parse-boolean.ts +10 -0
  123. package/src/parsing/parse-enum.ts +16 -0
  124. package/src/parsing/parse-number.ts +12 -0
  125. package/src/predicates/__tests__/is-function.test.ts +11 -0
  126. package/src/predicates/__tests__/is-null.test.ts +11 -0
  127. package/src/predicates/__tests__/is-object.test.ts +11 -0
  128. package/src/predicates/__tests__/is-primitive.test.ts +42 -0
  129. package/src/predicates/__tests__/is-undefined.test.ts +11 -0
  130. package/src/predicates/__tests__/is-uuid.test.ts +13 -0
  131. package/src/predicates/index.ts +5 -0
  132. package/src/predicates/is-function.ts +3 -0
  133. package/src/predicates/is-null.ts +3 -0
  134. package/src/predicates/is-object.ts +3 -0
  135. package/src/predicates/is-primitive.ts +19 -0
  136. package/src/predicates/is-undefined.ts +3 -0
  137. package/src/predicates/is-uuid.ts +3 -0
  138. package/src/promise/__tests__/delay.test.ts +13 -0
  139. package/src/promise/__tests__/execute-or-resolve-default.test.ts +25 -0
  140. package/src/promise/__tests__/execute-with-delay.test.ts +24 -0
  141. package/src/promise/delay.ts +3 -0
  142. package/src/promise/execute-or-resolve-default.ts +14 -0
  143. package/src/promise/execute-with-delay.ts +6 -0
  144. package/src/promise/index.ts +3 -0
  145. package/src/string/__tests__/replace-in-template.test.ts +52 -0
  146. package/src/string/index.ts +1 -0
  147. package/src/string/replace-in-template.ts +45 -0
  148. package/src/time/__tests__/convert.test.ts +14 -0
  149. package/src/time/__tests__/format-minutes.test.ts +10 -0
  150. package/src/time/__tests__/get-time-diff-as-string.test.ts +128 -0
  151. package/src/time/constants.ts +4 -0
  152. package/src/time/convert.ts +5 -0
  153. package/src/time/format-minutes.ts +9 -0
  154. package/src/time/get-time-diff-as-string.ts +196 -0
  155. package/src/time/index.ts +4 -0
  156. package/src/types/function.ts +1 -0
  157. package/src/types/general.ts +8 -0
  158. package/src/types/index.ts +4 -0
  159. package/src/types/object.ts +33 -0
  160. package/src/types/search.ts +29 -0
  161. package/tsconfig.eslint.json +8 -0
  162. package/tsconfig.json +25 -0
  163. /package/{_virtual → dist/_virtual}/_tslib.js +0 -0
  164. /package/{_virtual → dist/_virtual}/_tslib.js.map +0 -0
  165. /package/{array → dist/array}/array-to-map.d.ts +0 -0
  166. /package/{array → dist/array}/array-to-map.js +0 -0
  167. /package/{array → dist/array}/array-to-map.js.map +0 -0
  168. /package/{array → dist/array}/get-values-from-keys.d.ts +0 -0
  169. /package/{array → dist/array}/get-values-from-keys.js +0 -0
  170. /package/{array → dist/array}/get-values-from-keys.js.map +0 -0
  171. /package/{array → dist/array}/index.d.ts +0 -0
  172. /package/{array → dist/array}/index.js +0 -0
  173. /package/{array → dist/array}/index.js.map +0 -0
  174. /package/{cdn → dist/cdn}/cdn.factory.d.ts +0 -0
  175. /package/{cdn → dist/cdn}/cdn.factory.js +0 -0
  176. /package/{cdn → dist/cdn}/cdn.factory.js.map +0 -0
  177. /package/{cdn → dist/cdn}/index.d.ts +0 -0
  178. /package/{cdn → dist/cdn}/index.js +0 -0
  179. /package/{cdn → dist/cdn}/index.js.map +0 -0
  180. /package/{cdn → dist/cdn}/types/cdn-factory.type.d.ts +0 -0
  181. /package/{cdn → dist/cdn}/types/index.d.ts +0 -0
  182. /package/{cdn → dist/cdn}/types/index.js +0 -0
  183. /package/{cdn → dist/cdn}/types/index.js.map +0 -0
  184. /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.d.ts +0 -0
  185. /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.js +0 -0
  186. /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.js.map +0 -0
  187. /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
  188. /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
  189. /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
  190. /package/{cdn → dist/cdn}/utils/get-cdn-url.util.d.ts +0 -0
  191. /package/{cdn → dist/cdn}/utils/get-cdn-url.util.js +0 -0
  192. /package/{cdn → dist/cdn}/utils/get-cdn-url.util.js.map +0 -0
  193. /package/{formatting → dist/formatting}/format-number.d.ts +0 -0
  194. /package/{formatting → dist/formatting}/format-number.js +0 -0
  195. /package/{formatting → dist/formatting}/format-number.js.map +0 -0
  196. /package/{formatting → dist/formatting}/index.d.ts +0 -0
  197. /package/{formatting → dist/formatting}/index.js +0 -0
  198. /package/{formatting → dist/formatting}/index.js.map +0 -0
  199. /package/{fp → dist/fp}/index.d.ts +0 -0
  200. /package/{fp → dist/fp}/index.js +0 -0
  201. /package/{fp → dist/fp}/index.js.map +0 -0
  202. /package/{fp → dist/fp}/run-while.d.ts +0 -0
  203. /package/{fp → dist/fp}/run-while.js +0 -0
  204. /package/{fp → dist/fp}/run-while.js.map +0 -0
  205. /package/{time → dist/github/commits}/index.js.map +0 -0
  206. /package/{linked-list → dist/github}/index.js.map +0 -0
  207. /package/{http → dist/http}/encode-search-object.d.ts +0 -0
  208. /package/{http → dist/http}/encode-search-object.js +0 -0
  209. /package/{http → dist/http}/encode-search-object.js.map +0 -0
  210. /package/{http → dist/http}/fetch-with-timeout.d.ts +0 -0
  211. /package/{http → dist/http}/fetch-with-timeout.js +0 -0
  212. /package/{http → dist/http}/fetch-with-timeout.js.map +0 -0
  213. /package/{http → dist/http}/index.d.ts +0 -0
  214. /package/{http → dist/http}/index.js +0 -0
  215. /package/{http → dist/http}/index.js.map +0 -0
  216. /package/{linked-list → dist/linked-list}/apply-diff-linked-list.d.ts +0 -0
  217. /package/{linked-list → dist/linked-list}/apply-diff-linked-list.js +0 -0
  218. /package/{linked-list → dist/linked-list}/apply-diff-linked-list.js.map +0 -0
  219. /package/{linked-list → dist/linked-list}/create-linked-list.d.ts +0 -0
  220. /package/{linked-list → dist/linked-list}/create-linked-list.js +0 -0
  221. /package/{linked-list → dist/linked-list}/create-linked-list.js.map +0 -0
  222. /package/{linked-list → dist/linked-list}/find-linked-list.d.ts +0 -0
  223. /package/{linked-list → dist/linked-list}/find-linked-list.js +0 -0
  224. /package/{linked-list → dist/linked-list}/find-linked-list.js.map +0 -0
  225. /package/{linked-list → dist/linked-list}/get-linked-list.d.ts +0 -0
  226. /package/{linked-list → dist/linked-list}/get-linked-list.js +0 -0
  227. /package/{linked-list → dist/linked-list}/get-linked-list.js.map +0 -0
  228. /package/{linked-list → dist/linked-list}/index.d.ts +0 -0
  229. /package/{linked-list → dist/linked-list}/index.js +0 -0
  230. /package/{object → dist/linked-list}/index.js.map +0 -0
  231. /package/{linked-list → dist/linked-list}/insert-linked-list.d.ts +0 -0
  232. /package/{linked-list → dist/linked-list}/insert-linked-list.js +0 -0
  233. /package/{linked-list → dist/linked-list}/insert-linked-list.js.map +0 -0
  234. /package/{linked-list → dist/linked-list}/linked-list-utils.d.ts +0 -0
  235. /package/{linked-list → dist/linked-list}/linked-list-utils.js +0 -0
  236. /package/{linked-list → dist/linked-list}/linked-list-utils.js.map +0 -0
  237. /package/{linked-list → dist/linked-list}/reduce-linked-list.d.ts +0 -0
  238. /package/{linked-list → dist/linked-list}/reduce-linked-list.js +0 -0
  239. /package/{linked-list → dist/linked-list}/reduce-linked-list.js.map +0 -0
  240. /package/{linked-list → dist/linked-list}/remove-linked-list.d.ts +0 -0
  241. /package/{linked-list → dist/linked-list}/remove-linked-list.js +0 -0
  242. /package/{linked-list → dist/linked-list}/remove-linked-list.js.map +0 -0
  243. /package/{linked-list → dist/linked-list}/type.d.ts +0 -0
  244. /package/{linked-list → dist/linked-list}/update-linked-list.d.ts +0 -0
  245. /package/{linked-list → dist/linked-list}/update-linked-list.js +0 -0
  246. /package/{linked-list → dist/linked-list}/update-linked-list.js.map +0 -0
  247. /package/{linked-list → dist/linked-list}/while-linked-list.d.ts +0 -0
  248. /package/{linked-list → dist/linked-list}/while-linked-list.js +0 -0
  249. /package/{linked-list → dist/linked-list}/while-linked-list.js.map +0 -0
  250. /package/{math → dist/math}/clamp-number.d.ts +0 -0
  251. /package/{math → dist/math}/clamp-number.js +0 -0
  252. /package/{math → dist/math}/clamp-number.js.map +0 -0
  253. /package/{math → dist/math}/index.d.ts +0 -0
  254. /package/{math → dist/math}/index.js +0 -0
  255. /package/{math → dist/math}/index.js.map +0 -0
  256. /package/{math → dist/math}/interpolate.d.ts +0 -0
  257. /package/{math → dist/math}/interpolate.js +0 -0
  258. /package/{math → dist/math}/interpolate.js.map +0 -0
  259. /package/{math → dist/math}/number-range.d.ts +0 -0
  260. /package/{math → dist/math}/number-range.js +0 -0
  261. /package/{math → dist/math}/number-range.js.map +0 -0
  262. /package/{math → dist/math}/random-number.d.ts +0 -0
  263. /package/{math → dist/math}/random-number.js +0 -0
  264. /package/{math → dist/math}/random-number.js.map +0 -0
  265. /package/{object → dist/object}/index.d.ts +0 -0
  266. /package/{object → dist/object}/index.js +0 -0
  267. /package/{string → dist/object}/index.js.map +0 -0
  268. /package/{object → dist/object}/merge-deep.d.ts +0 -0
  269. /package/{object → dist/object}/merge-deep.js +0 -0
  270. /package/{object → dist/object}/merge-deep.js.map +0 -0
  271. /package/{parsing → dist/parsing}/index.d.ts +0 -0
  272. /package/{parsing → dist/parsing}/index.js +0 -0
  273. /package/{parsing → dist/parsing}/index.js.map +0 -0
  274. /package/{parsing → dist/parsing}/parse-boolean.d.ts +0 -0
  275. /package/{parsing → dist/parsing}/parse-boolean.js +0 -0
  276. /package/{parsing → dist/parsing}/parse-boolean.js.map +0 -0
  277. /package/{parsing → dist/parsing}/parse-enum.d.ts +0 -0
  278. /package/{parsing → dist/parsing}/parse-enum.js +0 -0
  279. /package/{parsing → dist/parsing}/parse-enum.js.map +0 -0
  280. /package/{parsing → dist/parsing}/parse-number.d.ts +0 -0
  281. /package/{parsing → dist/parsing}/parse-number.js +0 -0
  282. /package/{parsing → dist/parsing}/parse-number.js.map +0 -0
  283. /package/{predicates → dist/predicates}/index.d.ts +0 -0
  284. /package/{predicates → dist/predicates}/index.js +0 -0
  285. /package/{predicates → dist/predicates}/index.js.map +0 -0
  286. /package/{predicates → dist/predicates}/is-function.d.ts +0 -0
  287. /package/{predicates → dist/predicates}/is-function.js +0 -0
  288. /package/{predicates → dist/predicates}/is-function.js.map +0 -0
  289. /package/{predicates → dist/predicates}/is-null.d.ts +0 -0
  290. /package/{predicates → dist/predicates}/is-null.js +0 -0
  291. /package/{predicates → dist/predicates}/is-null.js.map +0 -0
  292. /package/{predicates → dist/predicates}/is-object.d.ts +0 -0
  293. /package/{predicates → dist/predicates}/is-object.js +0 -0
  294. /package/{predicates → dist/predicates}/is-object.js.map +0 -0
  295. /package/{predicates → dist/predicates}/is-primitive.d.ts +0 -0
  296. /package/{predicates → dist/predicates}/is-primitive.js +0 -0
  297. /package/{predicates → dist/predicates}/is-primitive.js.map +0 -0
  298. /package/{predicates → dist/predicates}/is-undefined.d.ts +0 -0
  299. /package/{predicates → dist/predicates}/is-undefined.js +0 -0
  300. /package/{predicates → dist/predicates}/is-undefined.js.map +0 -0
  301. /package/{predicates → dist/predicates}/is-uuid.d.ts +0 -0
  302. /package/{promise → dist/promise}/delay.d.ts +0 -0
  303. /package/{promise → dist/promise}/delay.js +0 -0
  304. /package/{promise → dist/promise}/delay.js.map +0 -0
  305. /package/{promise → dist/promise}/execute-or-resolve-default.d.ts +0 -0
  306. /package/{promise → dist/promise}/execute-or-resolve-default.js +0 -0
  307. /package/{promise → dist/promise}/execute-or-resolve-default.js.map +0 -0
  308. /package/{promise → dist/promise}/execute-with-delay.d.ts +0 -0
  309. /package/{promise → dist/promise}/execute-with-delay.js +0 -0
  310. /package/{promise → dist/promise}/execute-with-delay.js.map +0 -0
  311. /package/{promise → dist/promise}/index.d.ts +0 -0
  312. /package/{promise → dist/promise}/index.js +0 -0
  313. /package/{promise → dist/promise}/index.js.map +0 -0
  314. /package/{string → dist/string}/index.d.ts +0 -0
  315. /package/{string → dist/string}/index.js +0 -0
  316. /package/{string → dist/string}/replace-in-template.d.ts +0 -0
  317. /package/{string → dist/string}/replace-in-template.js +0 -0
  318. /package/{string → dist/string}/replace-in-template.js.map +0 -0
  319. /package/{time → dist/time}/constants.d.ts +0 -0
  320. /package/{time → dist/time}/constants.js +0 -0
  321. /package/{time → dist/time}/constants.js.map +0 -0
  322. /package/{time → dist/time}/convert.d.ts +0 -0
  323. /package/{time → dist/time}/convert.js +0 -0
  324. /package/{time → dist/time}/convert.js.map +0 -0
  325. /package/{time → dist/time}/format-minutes.d.ts +0 -0
  326. /package/{time → dist/time}/format-minutes.js +0 -0
  327. /package/{time → dist/time}/format-minutes.js.map +0 -0
  328. /package/{time → dist/time}/get-time-diff-as-string.d.ts +0 -0
  329. /package/{time → dist/time}/get-time-diff-as-string.js +0 -0
  330. /package/{time → dist/time}/get-time-diff-as-string.js.map +0 -0
  331. /package/{time → dist/time}/index.d.ts +0 -0
  332. /package/{time → dist/time}/index.js +0 -0
  333. /package/{types → dist/types}/function.d.ts +0 -0
  334. /package/{types → dist/types}/general.d.ts +0 -0
  335. /package/{types → dist/types}/index.d.ts +0 -0
  336. /package/{types → dist/types}/index.js +0 -0
  337. /package/{types → dist/types}/index.js.map +0 -0
  338. /package/{types → dist/types}/object.d.ts +0 -0
  339. /package/{types → dist/types}/search.d.ts +0 -0
@@ -0,0 +1,40 @@
1
+ # Javascript Node CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4
+ #
5
+ version: 2.1
6
+ jobs:
7
+ test:
8
+ docker:
9
+ - image: cimg/node:18.10.0
10
+
11
+ steps:
12
+ - checkout
13
+
14
+ - run:
15
+ name: Set npm token
16
+ command: 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc'
17
+
18
+ - run:
19
+ name: Install node modules
20
+ command: yarn
21
+
22
+ - run:
23
+ name: Check lint
24
+ command: yarn lint
25
+
26
+ - run:
27
+ name: Run tests
28
+ # Limit resources as the default parameters overload the CPU of the machine and makes tests hang
29
+ command: yarn test --maxWorkers=50%
30
+
31
+ - run:
32
+ name: Build
33
+ command: yarn build
34
+
35
+ workflows:
36
+ version: 2
37
+
38
+ autodeploy:
39
+ jobs:
40
+ - test
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ dist/
package/.eslintrc.js ADDED
@@ -0,0 +1,17 @@
1
+ module.exports = {
2
+ env: {
3
+ es2021: true,
4
+ node: true,
5
+ },
6
+ extends: '@sparted',
7
+ parserOptions: {
8
+ project: './tsconfig.eslint.json',
9
+ },
10
+ rules: {
11
+ // Preference for this project
12
+ 'import/prefer-default-export': 'off',
13
+
14
+ // Preference for this project
15
+ 'object-curly-newline': 'off',
16
+ },
17
+ };
package/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.dat
2
+ *.iml
3
+ *.log
4
+ *.out
5
+ *.pid
6
+ *.seed
7
+ *.sublime-*
8
+ *.swo
9
+ *.swp
10
+ *.tgz
11
+ *.xml
12
+ .tmp
13
+ .env
14
+ doc/*.json
15
+
16
+ # Mac Related files
17
+ .DS_Store
18
+
19
+ # IDE Related Files
20
+ .idea
21
+ .project
22
+
23
+ # eslint
24
+ .eslintcache
25
+
26
+ # jest
27
+ jest-stare
28
+
29
+ # JS Related files
30
+ bower_components
31
+ npm-debug.log
32
+ node_modules
33
+ nestjs/node_modules
34
+ .npmrc
35
+
36
+ # Build
37
+ dist
package/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ ## 1.0.7
2
+ - Fix Twicpics resizing
3
+
4
+ ## 1.0.6
5
+ - Add current map to `dataModifier` function on `arrayToMap`
6
+
7
+ ## 1.0.5
8
+ - CDN abstraction for Imgix and Twicpics
9
+
10
+ ## 1.0.0
11
+ - Breaking change: rename date folder into time
12
+ - Export convertion functions from time
13
+
14
+ ## 0.0.18
15
+ - Change update behavior to fully replace updated items
16
+
17
+ ## 0.0.17
18
+ - Remove error thrown when not every items have been visisted
19
+
20
+ ## 0.0.16
21
+ - Fix an issue when initializing an empty linked list
22
+
23
+ ## 0.0.15
24
+ - Rollback target version, change output format
25
+
26
+ ## 0.0.14
27
+ - Bump target version in tsconfig
28
+
29
+ ## 0.0.13
30
+ - Bring most utilities from the back-office, mobile-app and nest to this package (#32q6ude)
31
+
32
+ ## 0.0.1
33
+ - Library initialisation (#2ykhvcg)
34
+ - Fix files taken as packaged
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Shared-library
2
+
3
+ Regroup low levels utils to share across Sparted's projects. Nothing should be platform specific and it should ideally not depend on any external library.
4
+
5
+ # Publishing
6
+
7
+ Since we want to be able to do the following sub imports when using the library:
8
+
9
+ ```ts
10
+ import { function1, function2 } from '@sparted/shared-library/array';
11
+ import { function3, function4 } from '@sparted/shared-library/strings';
12
+ ```
13
+
14
+ While also being able to import everything from the root.
15
+
16
+ We'll need to do some rollup/npm trickery to keep everything tree-shakable and intuitive.
17
+
18
+ To do so, we copy the package.json inside the generated dist folder when building the library. Then we run `npm publish` from inside the dist folder.
19
+
20
+ What this do, is take everything inside the dist folder and publish as its standalone package. This enables us to import directly from `@sparted/shared-library/array` without adding `dist` since `dist/array` becomes a root folder. If we do not do this and instead run `npm publish` in the root directory, the package would keep the folder structure and we would need to add `dist` in imports. eg: `@sparted/shared-library/dist/array`.
21
+
22
+ ## How to publish
23
+
24
+ 1. Update the `package.json` version
25
+ 2. Run `yarn build-and-publish` (this command assumes the `package.json` version was not already published)
26
+ 3. The new version should be commited and pushed
@@ -0,0 +1,26 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare type CreateGitBlobArgs = {
3
+ content: string;
4
+ encoding: 'utf-8' | 'base64';
5
+ };
6
+ export declare type CreateGitBlobResponse = {
7
+ sha: string;
8
+ url: string;
9
+ };
10
+ export declare type CreateGitBlob = (args: CreateGitBlobArgs) => Promise<CreateGitBlobResponse>;
11
+ export declare type CreateGitBlobFactory = (instance: AxiosInstance) => CreateGitBlob;
12
+ /**
13
+ * Create a git blob
14
+ *
15
+ * @param owner the owner of the repository
16
+ * @param repo the name of the repository
17
+ * @param token the github token
18
+ * @param content the content of the file
19
+ * @param encoding the encoding of the content. Default: utf-8
20
+ * @returns CreateGitBlobResponse
21
+ * @throws forbidden
22
+ * @throws resource-not-found
23
+ * @throws conflict
24
+ * @throws validation-failed-or-the-endpoint-has-been-spammed
25
+ */
26
+ export declare const createGitBlobFactory: CreateGitBlobFactory;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.js');
6
+ var zod = require('zod');
7
+ var utils = require('./utils.js');
8
+
9
+ const createGitBlobResponseSchema = zod.z.object({
10
+ sha: zod.z.string(),
11
+ url: zod.z.string(),
12
+ });
13
+ /**
14
+ * Create a git blob
15
+ *
16
+ * @param owner the owner of the repository
17
+ * @param repo the name of the repository
18
+ * @param token the github token
19
+ * @param content the content of the file
20
+ * @param encoding the encoding of the content. Default: utf-8
21
+ * @returns CreateGitBlobResponse
22
+ * @throws forbidden
23
+ * @throws resource-not-found
24
+ * @throws conflict
25
+ * @throws validation-failed-or-the-endpoint-has-been-spammed
26
+ */
27
+ const createGitBlobFactory = (instance) => (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
28
+ const { content, encoding = 'utf-8' } = args;
29
+ try {
30
+ const { data } = yield instance.post('/git/blobs', {
31
+ content,
32
+ encoding,
33
+ });
34
+ return createGitBlobResponseSchema.parse(data);
35
+ }
36
+ catch (error) {
37
+ throw utils.handleError(error);
38
+ }
39
+ });
40
+
41
+ exports.createGitBlobFactory = createGitBlobFactory;
42
+ //# sourceMappingURL=create-git-blob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-git-blob.js","sources":["../../../src/github/commits/create-git-blob.ts"],"sourcesContent":["import type { AxiosInstance } from 'axios';\nimport { z } from 'zod';\n\nimport { handleError } from './utils';\n\nexport type CreateGitBlobArgs = {\n content: string;\n encoding: 'utf-8' | 'base64';\n};\n\nexport type CreateGitBlobResponse = {\n sha: string;\n url: string;\n};\n\nconst createGitBlobResponseSchema = z.object({\n sha: z.string(),\n url: z.string(),\n});\n\nexport type CreateGitBlob = (\n args: CreateGitBlobArgs\n) => Promise<CreateGitBlobResponse>;\n\nexport type CreateGitBlobFactory = (instance: AxiosInstance) => CreateGitBlob;\n\n/**\n * Create a git blob\n *\n * @param owner the owner of the repository\n * @param repo the name of the repository\n * @param token the github token\n * @param content the content of the file\n * @param encoding the encoding of the content. Default: utf-8\n * @returns CreateGitBlobResponse\n * @throws forbidden\n * @throws resource-not-found\n * @throws conflict\n * @throws validation-failed-or-the-endpoint-has-been-spammed\n */\nexport const createGitBlobFactory: CreateGitBlobFactory = (instance) => async (args) => {\n const { content, encoding = 'utf-8' } = args;\n\n try {\n const { data } = await instance.post<CreateGitBlobResponse>(\n '/git/blobs',\n {\n content,\n encoding,\n },\n );\n\n return createGitBlobResponseSchema.parse(data);\n } catch (error) {\n throw handleError(error);\n }\n};\n"],"names":["z","__awaiter","handleError"],"mappings":";;;;;;;;AAeA,MAAM,2BAA2B,GAAGA,KAAC,CAAC,MAAM,CAAC;AAC3C,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AACf,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AAChB,CAAA,CAAC,CAAC;AAQH;;;;;;;;;;;;;AAaG;AACI,MAAM,oBAAoB,GAAyB,CAAC,QAAQ,KAAK,CAAO,IAAI,KAAIC,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;IACrF,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;IAE7C,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAClC,YAAY,EACZ;YACE,OAAO;YACP,QAAQ;AACT,SAAA,CACF,CAAC;AAEF,QAAA,OAAO,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChD,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACd,QAAA,MAAMC,iBAAW,CAAC,KAAK,CAAC,CAAC;AAC1B,KAAA;AACH,CAAC;;;;"}
@@ -0,0 +1,23 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare type CreateGitCommitArgs = {
3
+ message: string;
4
+ treeSha: string;
5
+ parents: string[];
6
+ };
7
+ export declare type CreateGitCommitResponse = {
8
+ sha: string;
9
+ url: string;
10
+ };
11
+ export declare type CreateGitCommit = (args: CreateGitCommitArgs) => Promise<CreateGitCommitResponse>;
12
+ export declare type CreateGitCommitFactory = (instance: AxiosInstance) => CreateGitCommit;
13
+ /**
14
+ * Create a git commit
15
+ * @param owner the owner of the repository
16
+ * @param repo the name of the repository
17
+ * @param token the github token
18
+ * @param message the commit message
19
+ * @param treeSha the sha of the tree
20
+ * @param parents the parents of the commit
21
+ * @returns CreateGitCommitResponse
22
+ */
23
+ export declare const createGitCommitFactory: CreateGitCommitFactory;
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.js');
6
+ var zod = require('zod');
7
+ var utils = require('./utils.js');
8
+
9
+ const createGitCommitSchema = zod.z.object({
10
+ sha: zod.z.string(),
11
+ url: zod.z.string(),
12
+ });
13
+ /**
14
+ * Create a git commit
15
+ * @param owner the owner of the repository
16
+ * @param repo the name of the repository
17
+ * @param token the github token
18
+ * @param message the commit message
19
+ * @param treeSha the sha of the tree
20
+ * @param parents the parents of the commit
21
+ * @returns CreateGitCommitResponse
22
+ */
23
+ const createGitCommitFactory = (instance) => (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
24
+ const { message, treeSha, parents } = args;
25
+ try {
26
+ const { data } = yield instance.post('/git/commits', {
27
+ message,
28
+ tree: treeSha,
29
+ parents,
30
+ });
31
+ return createGitCommitSchema.parse(data);
32
+ }
33
+ catch (error) {
34
+ throw utils.handleError(error);
35
+ }
36
+ });
37
+
38
+ exports.createGitCommitFactory = createGitCommitFactory;
39
+ //# sourceMappingURL=create-git-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-git-commit.js","sources":["../../../src/github/commits/create-git-commit.ts"],"sourcesContent":["import type { AxiosInstance } from 'axios';\nimport { z } from 'zod';\n\nimport { handleError } from './utils';\n\nexport type CreateGitCommitArgs = {\n message: string;\n treeSha: string;\n parents: string[];\n};\n\nexport type CreateGitCommitResponse = {\n sha: string;\n url: string;\n};\n\nconst createGitCommitSchema = z.object({\n sha: z.string(),\n url: z.string(),\n});\n\nexport type CreateGitCommit = (\n args: CreateGitCommitArgs\n) => Promise<CreateGitCommitResponse>;\n\nexport type CreateGitCommitFactory = (\n instance: AxiosInstance\n) => CreateGitCommit;\n\n/**\n * Create a git commit\n * @param owner the owner of the repository\n * @param repo the name of the repository\n * @param token the github token\n * @param message the commit message\n * @param treeSha the sha of the tree\n * @param parents the parents of the commit\n * @returns CreateGitCommitResponse\n */\nexport const createGitCommitFactory: CreateGitCommitFactory = (instance) => async (args) => {\n const { message, treeSha, parents } = args;\n\n try {\n const { data } = await instance.post<CreateGitCommitResponse>(\n '/git/commits',\n {\n message,\n tree: treeSha,\n parents,\n },\n );\n\n return createGitCommitSchema.parse(data);\n } catch (error) {\n throw handleError(error);\n }\n};\n"],"names":["z","__awaiter","handleError"],"mappings":";;;;;;;;AAgBA,MAAM,qBAAqB,GAAGA,KAAC,CAAC,MAAM,CAAC;AACrC,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AACf,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AAChB,CAAA,CAAC,CAAC;AAUH;;;;;;;;;AASG;AACI,MAAM,sBAAsB,GAA2B,CAAC,QAAQ,KAAK,CAAO,IAAI,KAAIC,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;IACzF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE3C,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAClC,cAAc,EACd;YACE,OAAO;AACP,YAAA,IAAI,EAAE,OAAO;YACb,OAAO;AACR,SAAA,CACF,CAAC;AAEF,QAAA,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1C,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACd,QAAA,MAAMC,iBAAW,CAAC,KAAK,CAAC,CAAC;AAC1B,KAAA;AACH,CAAC;;;;"}
@@ -0,0 +1,29 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare type Blob = {
3
+ path: string;
4
+ sha: string;
5
+ };
6
+ export declare type CreateGitTreeArgs = {
7
+ baseTreeSha: string;
8
+ blobs: Blob[];
9
+ };
10
+ export declare type CreateGitTreeResponse = {
11
+ sha: string;
12
+ url: string;
13
+ };
14
+ export declare type CreateGitTree = (args: CreateGitTreeArgs) => Promise<CreateGitTreeResponse>;
15
+ export declare type CreateGitTreeFactory = (instance: AxiosInstance) => CreateGitTree;
16
+ /**
17
+ * Create a git tree
18
+ *
19
+ * @param owner the owner of the repository
20
+ * @param repo the name of the repository
21
+ * @param token the github token
22
+ * @param baseTreeSha the sha of the base tree
23
+ * @param blobs the blobs to add to the tree
24
+ * @returns CreateGitTreeResponse
25
+ * @throws forbidden
26
+ * @throws resource-not-found
27
+ * @throws validation-failed-or-the-endpoint-has-been-spammed
28
+ */
29
+ export declare const createGitTreeFactory: CreateGitTreeFactory;
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.js');
6
+ var zod = require('zod');
7
+ var utils = require('./utils.js');
8
+
9
+ const createGitTreeSchema = zod.z.object({
10
+ sha: zod.z.string(),
11
+ url: zod.z.string(),
12
+ });
13
+ /**
14
+ * Create a git tree
15
+ *
16
+ * @param owner the owner of the repository
17
+ * @param repo the name of the repository
18
+ * @param token the github token
19
+ * @param baseTreeSha the sha of the base tree
20
+ * @param blobs the blobs to add to the tree
21
+ * @returns CreateGitTreeResponse
22
+ * @throws forbidden
23
+ * @throws resource-not-found
24
+ * @throws validation-failed-or-the-endpoint-has-been-spammed
25
+ */
26
+ const createGitTreeFactory = (instance) => (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
27
+ const { baseTreeSha, blobs } = args;
28
+ const tree = blobs.map((blob) => ({
29
+ path: blob.path,
30
+ mode: '100644',
31
+ type: 'blob',
32
+ sha: blob.sha,
33
+ }));
34
+ try {
35
+ const { data } = yield instance.post('/git/trees', {
36
+ base_tree: baseTreeSha,
37
+ tree,
38
+ });
39
+ return createGitTreeSchema.parse(data);
40
+ }
41
+ catch (error) {
42
+ throw utils.handleError(error);
43
+ }
44
+ });
45
+
46
+ exports.createGitTreeFactory = createGitTreeFactory;
47
+ //# sourceMappingURL=create-git-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-git-tree.js","sources":["../../../src/github/commits/create-git-tree.ts"],"sourcesContent":["import type { AxiosInstance } from 'axios';\nimport { z } from 'zod';\n\nimport { handleError } from './utils';\n\nexport type Blob = {\n path: string;\n sha: string;\n};\n\nexport type CreateGitTreeArgs = {\n baseTreeSha: string;\n blobs: Blob[];\n};\n\nexport type CreateGitTreeResponse = {\n sha: string;\n url: string;\n};\n\nconst createGitTreeSchema = z.object({\n sha: z.string(),\n url: z.string(),\n});\n\nexport type CreateGitTree = (\n args: CreateGitTreeArgs\n) => Promise<CreateGitTreeResponse>;\n\nexport type CreateGitTreeFactory = (instance: AxiosInstance) => CreateGitTree;\n\n/**\n * Create a git tree\n *\n * @param owner the owner of the repository\n * @param repo the name of the repository\n * @param token the github token\n * @param baseTreeSha the sha of the base tree\n * @param blobs the blobs to add to the tree\n * @returns CreateGitTreeResponse\n * @throws forbidden\n * @throws resource-not-found\n * @throws validation-failed-or-the-endpoint-has-been-spammed\n */\nexport const createGitTreeFactory: CreateGitTreeFactory = (instance) => async (args) => {\n const { baseTreeSha, blobs } = args;\n\n const tree = blobs.map((blob) => ({\n path: blob.path,\n mode: '100644',\n type: 'blob',\n sha: blob.sha,\n }));\n\n try {\n const { data } = await instance.post<CreateGitTreeResponse>(\n '/git/trees',\n {\n base_tree: baseTreeSha,\n tree,\n },\n );\n\n return createGitTreeSchema.parse(data);\n } catch (error) {\n throw handleError(error);\n }\n};\n"],"names":["z","__awaiter","handleError"],"mappings":";;;;;;;;AAoBA,MAAM,mBAAmB,GAAGA,KAAC,CAAC,MAAM,CAAC;AACnC,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AACf,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AAChB,CAAA,CAAC,CAAC;AAQH;;;;;;;;;;;;AAYG;AACI,MAAM,oBAAoB,GAAyB,CAAC,QAAQ,KAAK,CAAO,IAAI,KAAIC,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACrF,IAAA,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAEpC,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM;QAChC,IAAI,EAAE,IAAI,CAAC,IAAI;AACf,QAAA,IAAI,EAAE,QAAQ;AACd,QAAA,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,IAAI,CAAC,GAAG;AACd,KAAA,CAAC,CAAC,CAAC;IAEJ,IAAI;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAClC,YAAY,EACZ;AACE,YAAA,SAAS,EAAE,WAAW;YACtB,IAAI;AACL,SAAA,CACF,CAAC;AAEF,QAAA,OAAO,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACxC,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACd,QAAA,MAAMC,iBAAW,CAAC,KAAK,CAAC,CAAC;AAC1B,KAAA;AACH,CAAC;;;;"}
@@ -0,0 +1,21 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare type GetShaLastCommitOfBranchArgs = {
3
+ ref: `/heads/${string}`;
4
+ };
5
+ export declare type GetShaLastCommitOfBranchResponse = {
6
+ sha: string;
7
+ url: string;
8
+ };
9
+ export declare type GetShaLastCommitOfBranch = (args: GetShaLastCommitOfBranchArgs) => Promise<GetShaLastCommitOfBranchResponse>;
10
+ export declare type GetShaLastCommitOfBranchFactory = (instance: AxiosInstance) => GetShaLastCommitOfBranch;
11
+ /**
12
+ * Get the sha of the last commit of a branch
13
+ *
14
+ * @param owner the owner of the repository
15
+ * @param repo the name of the repository
16
+ * @param ref the reference to a branch. Example: /heads/master
17
+ * @param token the github token
18
+ * @returns GetShaLastCommitOfBranchResponse
19
+ * @throws ref-not-found
20
+ */
21
+ export declare const getShaLastCommitOfBranchFactory: GetShaLastCommitOfBranchFactory;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.js');
6
+ var zod = require('zod');
7
+ var utils = require('./utils.js');
8
+
9
+ const getShaLastCommitOfBranchSchema = zod.z.object({
10
+ sha: zod.z.string(),
11
+ url: zod.z.string(),
12
+ });
13
+ /**
14
+ * Get the sha of the last commit of a branch
15
+ *
16
+ * @param owner the owner of the repository
17
+ * @param repo the name of the repository
18
+ * @param ref the reference to a branch. Example: /heads/master
19
+ * @param token the github token
20
+ * @returns GetShaLastCommitOfBranchResponse
21
+ * @throws ref-not-found
22
+ */
23
+ const getShaLastCommitOfBranchFactory = (instance) => (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
24
+ const { ref } = args;
25
+ try {
26
+ const { data } = yield instance.get(`/git/refs/${ref}`);
27
+ return getShaLastCommitOfBranchSchema.parse(data.object);
28
+ }
29
+ catch (error) {
30
+ throw utils.handleError(error);
31
+ }
32
+ });
33
+
34
+ exports.getShaLastCommitOfBranchFactory = getShaLastCommitOfBranchFactory;
35
+ //# sourceMappingURL=get-sha-last-commit-of-branch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sha-last-commit-of-branch.js","sources":["../../../src/github/commits/get-sha-last-commit-of-branch.ts"],"sourcesContent":["import type { AxiosInstance } from 'axios';\nimport { z } from 'zod';\n\nimport { handleError } from './utils';\n\nexport type GetShaLastCommitOfBranchArgs = {\n ref: `/heads/${string}`;\n};\n\nexport type GetShaLastCommitOfBranchResponse = {\n sha: string;\n url: string;\n};\n\nconst getShaLastCommitOfBranchSchema = z.object({\n sha: z.string(),\n url: z.string(),\n});\n\nexport type GetShaLastCommitOfBranch = (\n args: GetShaLastCommitOfBranchArgs\n) => Promise<GetShaLastCommitOfBranchResponse>;\n\nexport type GetShaLastCommitOfBranchFactory = (\n instance: AxiosInstance\n) => GetShaLastCommitOfBranch;\n\n/**\n * Get the sha of the last commit of a branch\n *\n * @param owner the owner of the repository\n * @param repo the name of the repository\n * @param ref the reference to a branch. Example: /heads/master\n * @param token the github token\n * @returns GetShaLastCommitOfBranchResponse\n * @throws ref-not-found\n */\nexport const getShaLastCommitOfBranchFactory: GetShaLastCommitOfBranchFactory = (instance) => async (args) => {\n const { ref } = args;\n\n try {\n const { data } = await instance.get<{\n object: GetShaLastCommitOfBranchResponse;\n }>(`/git/refs/${ref}`);\n\n return getShaLastCommitOfBranchSchema.parse(data.object);\n } catch (error) {\n throw handleError(error);\n }\n};\n"],"names":["z","__awaiter","handleError"],"mappings":";;;;;;;;AAcA,MAAM,8BAA8B,GAAGA,KAAC,CAAC,MAAM,CAAC;AAC9C,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AACf,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AAChB,CAAA,CAAC,CAAC;AAUH;;;;;;;;;AASG;AACI,MAAM,+BAA+B,GAAoC,CAAC,QAAQ,KAAK,CAAO,IAAI,KAAIC,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AAC3G,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAErB,IAAI;AACF,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,GAAG,CAEhC,CAAA,UAAA,EAAa,GAAG,CAAA,CAAE,CAAC,CAAC;QAEvB,OAAO,8BAA8B,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC1D,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACd,QAAA,MAAMC,iBAAW,CAAC,KAAK,CAAC,CAAC;AAC1B,KAAA;AACH,CAAC;;;;"}
@@ -0,0 +1,23 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ export declare type GetTreeFromCommitShaArgs = {
3
+ sha: string;
4
+ };
5
+ export declare type GetTreeFromCommitShaResponse = {
6
+ url: string;
7
+ sha: string;
8
+ };
9
+ export declare type GetTreeByCommitSha = (args: GetTreeFromCommitShaArgs) => Promise<GetTreeFromCommitShaResponse>;
10
+ export declare type GetTreeByCommitShaFactory = (instance: AxiosInstance) => GetTreeByCommitSha;
11
+ /**
12
+ * Get the tree of a commit
13
+ *
14
+ * @param owner the owner of the repository
15
+ * @param repo the name of the repository
16
+ * @param sha the sha of the commit
17
+ * @param token the github token
18
+ * @returns GetTreeFromCommitShaResponse
19
+ * @throws sha-not-found
20
+ * @throws validation-failed-or-the-endpoint-has-been-spammed
21
+ * @throws internal-server-error
22
+ */
23
+ export declare const getTreeByCommitShaFactory: GetTreeByCommitShaFactory;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.js');
6
+ var zod = require('zod');
7
+ var utils = require('./utils.js');
8
+
9
+ const getTreeFromCommitShaSchema = zod.z.object({
10
+ url: zod.z.string(),
11
+ sha: zod.z.string(),
12
+ });
13
+ /**
14
+ * Get the tree of a commit
15
+ *
16
+ * @param owner the owner of the repository
17
+ * @param repo the name of the repository
18
+ * @param sha the sha of the commit
19
+ * @param token the github token
20
+ * @returns GetTreeFromCommitShaResponse
21
+ * @throws sha-not-found
22
+ * @throws validation-failed-or-the-endpoint-has-been-spammed
23
+ * @throws internal-server-error
24
+ */
25
+ const getTreeByCommitShaFactory = (instance) => (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
26
+ const { sha } = args;
27
+ try {
28
+ const { data } = yield instance.get(`/git/commits/${sha}`);
29
+ return getTreeFromCommitShaSchema.parse(data.tree);
30
+ }
31
+ catch (error) {
32
+ throw utils.handleError(error);
33
+ }
34
+ });
35
+
36
+ exports.getTreeByCommitShaFactory = getTreeByCommitShaFactory;
37
+ //# sourceMappingURL=get-tree-by-commit-sha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-tree-by-commit-sha.js","sources":["../../../src/github/commits/get-tree-by-commit-sha.ts"],"sourcesContent":["import type { AxiosInstance } from 'axios';\nimport { z } from 'zod';\n\nimport { handleError } from './utils';\n\nexport type GetTreeFromCommitShaArgs = {\n sha: string;\n};\n\nexport type GetTreeFromCommitShaResponse = {\n url: string;\n sha: string;\n};\n\nconst getTreeFromCommitShaSchema = z.object({\n url: z.string(),\n sha: z.string(),\n});\n\nexport type GetTreeByCommitSha = (\n args: GetTreeFromCommitShaArgs\n) => Promise<GetTreeFromCommitShaResponse>;\n\nexport type GetTreeByCommitShaFactory = (\n instance: AxiosInstance\n) => GetTreeByCommitSha;\n\n/**\n * Get the tree of a commit\n *\n * @param owner the owner of the repository\n * @param repo the name of the repository\n * @param sha the sha of the commit\n * @param token the github token\n * @returns GetTreeFromCommitShaResponse\n * @throws sha-not-found\n * @throws validation-failed-or-the-endpoint-has-been-spammed\n * @throws internal-server-error\n */\nexport const getTreeByCommitShaFactory: GetTreeByCommitShaFactory = (instance) => async (args) => {\n const { sha } = args;\n\n try {\n const { data } = await instance.get<{\n tree: GetTreeFromCommitShaResponse;\n }>(`/git/commits/${sha}`);\n\n return getTreeFromCommitShaSchema.parse(data.tree);\n } catch (error) {\n throw handleError(error);\n }\n};\n"],"names":["z","__awaiter","handleError"],"mappings":";;;;;;;;AAcA,MAAM,0BAA0B,GAAGA,KAAC,CAAC,MAAM,CAAC;AAC1C,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AACf,IAAA,GAAG,EAAEA,KAAC,CAAC,MAAM,EAAE;AAChB,CAAA,CAAC,CAAC;AAUH;;;;;;;;;;;AAWG;AACI,MAAM,yBAAyB,GAA8B,CAAC,QAAQ,KAAK,CAAO,IAAI,KAAIC,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AAC/F,IAAA,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAErB,IAAI;AACF,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,GAAG,CAEhC,CAAA,aAAA,EAAgB,GAAG,CAAA,CAAE,CAAC,CAAC;QAE1B,OAAO,0BAA0B,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpD,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;AACd,QAAA,MAAMC,iBAAW,CAAC,KAAK,CAAC,CAAC;AAC1B,KAAA;AACH,CAAC;;;;"}
@@ -0,0 +1,6 @@
1
+ export * from './create-git-blob';
2
+ export * from './create-git-commit';
3
+ export * from './create-git-tree';
4
+ export * from './get-sha-last-commit-of-branch';
5
+ export * from './get-tree-by-commit-sha';
6
+ export * from './run-new-commit-process';
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createGitBlob = require('./create-git-blob.js');
6
+ var createGitCommit = require('./create-git-commit.js');
7
+ var createGitTree = require('./create-git-tree.js');
8
+ var getShaLastCommitOfBranch = require('./get-sha-last-commit-of-branch.js');
9
+ var getTreeByCommitSha = require('./get-tree-by-commit-sha.js');
10
+ var runNewCommitProcess = require('./run-new-commit-process.js');
11
+
12
+
13
+
14
+ exports.createGitBlobFactory = createGitBlob.createGitBlobFactory;
15
+ exports.createGitCommitFactory = createGitCommit.createGitCommitFactory;
16
+ exports.createGitTreeFactory = createGitTree.createGitTreeFactory;
17
+ exports.getShaLastCommitOfBranchFactory = getShaLastCommitOfBranch.getShaLastCommitOfBranchFactory;
18
+ exports.getTreeByCommitShaFactory = getTreeByCommitSha.getTreeByCommitShaFactory;
19
+ exports.runNewCommitProcessFactory = runNewCommitProcess.runNewCommitProcessFactory;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,27 @@
1
+ import type { CreateGitBlob } from './create-git-blob';
2
+ import type { CreateGitCommit } from './create-git-commit';
3
+ import type { CreateGitTree } from './create-git-tree';
4
+ import type { GetShaLastCommitOfBranch } from './get-sha-last-commit-of-branch';
5
+ import type { GetTreeByCommitSha } from './get-tree-by-commit-sha';
6
+ export declare type VersionedFile = {
7
+ path: string;
8
+ content: string;
9
+ };
10
+ export declare type RunNewCommitProcessArgs = {
11
+ message: string;
12
+ ref: `/heads/${string}`;
13
+ files: VersionedFile[];
14
+ };
15
+ export declare type RunNewCommitProcessResponse = {
16
+ sha: string;
17
+ url: string;
18
+ };
19
+ export declare type RunNewCommitProcess = (args: RunNewCommitProcessArgs, updateState?: (state: string) => void) => Promise<RunNewCommitProcessResponse>;
20
+ export declare type RunNewCommitProcessFactory = (args: {
21
+ createGitBlob: CreateGitBlob;
22
+ createGitCommit: CreateGitCommit;
23
+ createGitTree: CreateGitTree;
24
+ getShaLastCommitOfBranch: GetShaLastCommitOfBranch;
25
+ getTreeByCommitSha: GetTreeByCommitSha;
26
+ }) => RunNewCommitProcess;
27
+ export declare const runNewCommitProcessFactory: RunNewCommitProcessFactory;
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.js');
6
+
7
+ const runNewCommitProcessFactory = (args) => (runNewCommitProcessArgs, updateState = () => { }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
8
+ const { createGitBlob, createGitCommit, createGitTree, getShaLastCommitOfBranch, getTreeByCommitSha } = args;
9
+ const { message, ref, files } = runNewCommitProcessArgs;
10
+ updateState('retrieving-sha-last-commit-of-branch');
11
+ const { sha: shaLastCommit } = yield getShaLastCommitOfBranch({
12
+ ref,
13
+ });
14
+ updateState('retrieved-sha-last-commit-of-branch');
15
+ updateState('creating-blobs-from-file');
16
+ const blobs = yield Promise.all(files.map((file) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
17
+ const blob = yield createGitBlob({
18
+ content: file.content,
19
+ encoding: 'utf-8',
20
+ });
21
+ return {
22
+ path: file.path,
23
+ sha: blob.sha,
24
+ };
25
+ })));
26
+ updateState('created-blobs-from-file');
27
+ updateState('retrieving-branch-current-tree');
28
+ const { sha: lastCommitTreeSha } = yield getTreeByCommitSha({
29
+ sha: shaLastCommit,
30
+ });
31
+ updateState('retrieved-branch-current-tree');
32
+ updateState('creating-new-tree-with-changes');
33
+ const tree = yield createGitTree({
34
+ baseTreeSha: lastCommitTreeSha,
35
+ blobs,
36
+ });
37
+ updateState('created-new-tree-with-changes');
38
+ updateState('creating-new-commit');
39
+ const commit = yield createGitCommit({
40
+ message,
41
+ treeSha: tree.sha,
42
+ parents: [shaLastCommit],
43
+ });
44
+ updateState('created-new-commit');
45
+ return commit;
46
+ });
47
+
48
+ exports.runNewCommitProcessFactory = runNewCommitProcessFactory;
49
+ //# sourceMappingURL=run-new-commit-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-new-commit-process.js","sources":["../../../src/github/commits/run-new-commit-process.ts"],"sourcesContent":["import type { CreateGitBlob } from './create-git-blob';\nimport type { CreateGitCommit } from './create-git-commit';\nimport type { CreateGitTree } from './create-git-tree';\nimport type { GetShaLastCommitOfBranch } from './get-sha-last-commit-of-branch';\nimport type { GetTreeByCommitSha } from './get-tree-by-commit-sha';\n\nexport type VersionedFile = {\n path: string;\n content: string;\n};\n\nexport type RunNewCommitProcessArgs = {\n message: string;\n ref: `/heads/${string}`;\n files: VersionedFile[];\n};\n\nexport type RunNewCommitProcessResponse = {\n sha: string;\n url: string;\n};\n\nexport type RunNewCommitProcess = (\n args: RunNewCommitProcessArgs,\n updateState?: (state: string) => void\n) => Promise<RunNewCommitProcessResponse>;\n\nexport type RunNewCommitProcessFactory = (args: {\n createGitBlob: CreateGitBlob;\n createGitCommit: CreateGitCommit;\n createGitTree: CreateGitTree;\n getShaLastCommitOfBranch: GetShaLastCommitOfBranch;\n getTreeByCommitSha: GetTreeByCommitSha;\n}) => RunNewCommitProcess;\n\nexport const runNewCommitProcessFactory: RunNewCommitProcessFactory = (args) => async (\n runNewCommitProcessArgs,\n updateState = () => {},\n) => {\n const { createGitBlob, createGitCommit, createGitTree, getShaLastCommitOfBranch, getTreeByCommitSha } = args;\n\n const { message, ref, files } = runNewCommitProcessArgs;\n\n updateState('retrieving-sha-last-commit-of-branch');\n const { sha: shaLastCommit } = await getShaLastCommitOfBranch({\n ref,\n });\n updateState('retrieved-sha-last-commit-of-branch');\n\n updateState('creating-blobs-from-file');\n const blobs = await Promise.all(\n files.map(async (file) => {\n const blob = await createGitBlob({\n content: file.content,\n encoding: 'utf-8',\n });\n\n return {\n path: file.path,\n sha: blob.sha,\n };\n }),\n );\n updateState('created-blobs-from-file');\n\n updateState('retrieving-branch-current-tree');\n const { sha: lastCommitTreeSha } = await getTreeByCommitSha({\n sha: shaLastCommit,\n });\n updateState('retrieved-branch-current-tree');\n\n updateState('creating-new-tree-with-changes');\n const tree = await createGitTree({\n baseTreeSha: lastCommitTreeSha,\n blobs,\n });\n updateState('created-new-tree-with-changes');\n\n updateState('creating-new-commit');\n const commit = await createGitCommit({\n message,\n treeSha: tree.sha,\n parents: [shaLastCommit],\n });\n updateState('created-new-commit');\n\n return commit;\n};\n"],"names":["__awaiter"],"mappings":";;;;;;AAmCa,MAAA,0BAA0B,GAA+B,CAAC,IAAI,KAAK,CAC9E,uBAAuB,EACvB,WAAW,GAAG,MAAO,GAAC,KACpBA,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACF,IAAA,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAE7G,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,uBAAuB,CAAC;IAExD,WAAW,CAAC,sCAAsC,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,MAAM,wBAAwB,CAAC;QAC5D,GAAG;AACJ,KAAA,CAAC,CAAC;IACH,WAAW,CAAC,qCAAqC,CAAC,CAAC;IAEnD,WAAW,CAAC,0BAA0B,CAAC,CAAC;AACxC,IAAA,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,KAAK,CAAC,GAAG,CAAC,CAAO,IAAI,KAAIA,gBAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACvB,QAAA,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC;YAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,YAAA,QAAQ,EAAE,OAAO;AAClB,SAAA,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;KACH,CAAA,CAAC,CACH,CAAC;IACF,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAEvC,WAAW,CAAC,gCAAgC,CAAC,CAAC;IAC9C,MAAM,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,MAAM,kBAAkB,CAAC;AAC1D,QAAA,GAAG,EAAE,aAAa;AACnB,KAAA,CAAC,CAAC;IACH,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAE7C,WAAW,CAAC,gCAAgC,CAAC,CAAC;AAC9C,IAAA,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC;AAC/B,QAAA,WAAW,EAAE,iBAAiB;QAC9B,KAAK;AACN,KAAA,CAAC,CAAC;IACH,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAE7C,WAAW,CAAC,qBAAqB,CAAC,CAAC;AACnC,IAAA,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;QACnC,OAAO;QACP,OAAO,EAAE,IAAI,CAAC,GAAG;QACjB,OAAO,EAAE,CAAC,aAAa,CAAC;AACzB,KAAA,CAAC,CAAC;IACH,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAElC,IAAA,OAAO,MAAM,CAAC;AAChB,CAAC;;;;"}
@@ -0,0 +1 @@
1
+ export declare const handleError: (error: unknown) => Error;