@fc3/mmcadi 0.1.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 (460) hide show
  1. package/LICENSE +673 -0
  2. package/README.md +5 -0
  3. package/bin/compile +63 -0
  4. package/bin/copy-static-files +13 -0
  5. package/bin/install +5 -0
  6. package/bin/precompile +55 -0
  7. package/bin/prepublish +7 -0
  8. package/bin/remap-paths +113 -0
  9. package/bin/test +9 -0
  10. package/config/tsconfig.json +37 -0
  11. package/package.json +33 -0
  12. package/src/bootstrap/start.ts +12 -0
  13. package/src/client/bootstrap.ts +5 -0
  14. package/src/client/client.ts +54 -0
  15. package/src/client/enum/key-code.ts +34 -0
  16. package/src/client/enum/page-type.ts +19 -0
  17. package/src/client/factory/page.ts +61 -0
  18. package/src/client/page/confirm-delete-block.ts +30 -0
  19. package/src/client/page/create-block.ts +6 -0
  20. package/src/client/page/day.ts +8 -0
  21. package/src/client/page/edit-block.ts +43 -0
  22. package/src/client/page/edit-custom.ts +16 -0
  23. package/src/client/page/home.ts +8 -0
  24. package/src/client/page/login.ts +8 -0
  25. package/src/client/page/logout.ts +8 -0
  26. package/src/client/page/month.ts +8 -0
  27. package/src/client/page/move-block.ts +8 -0
  28. package/src/client/page/select-block-type.ts +56 -0
  29. package/src/client/page/settings.ts +8 -0
  30. package/src/client/page/view-custom.ts +665 -0
  31. package/src/client/page/week.ts +8 -0
  32. package/src/client/page/year.ts +8 -0
  33. package/src/client/page.ts +128 -0
  34. package/src/client/shim/execute.ts +5 -0
  35. package/src/client/shim/logger.ts +44 -0
  36. package/src/client/utility/get-meta-value.ts +23 -0
  37. package/src/common/builder/block/background.ts +25 -0
  38. package/src/common/builder/block/folder.ts +43 -0
  39. package/src/common/builder/block/header.ts +15 -0
  40. package/src/common/builder/block/link.ts +32 -0
  41. package/src/common/builder/block/multicolumn.ts +16 -0
  42. package/src/common/builder/block/note.ts +13 -0
  43. package/src/common/builder/block/whitespace.ts +13 -0
  44. package/src/common/utility/get-parent-path.ts +29 -0
  45. package/src/constant/month-names.ts +16 -0
  46. package/src/enum/action-type.ts +11 -0
  47. package/src/enum/block-type.ts +18 -0
  48. package/src/enum/calendar-view-mode.ts +9 -0
  49. package/src/enum/color.ts +15 -0
  50. package/src/enum/default-role.ts +6 -0
  51. package/src/enum/directory-item-type.ts +6 -0
  52. package/src/enum/emoji.ts +94 -0
  53. package/src/enum/field-type.ts +8 -0
  54. package/src/enum/header-size.ts +7 -0
  55. package/src/enum/permission-type.ts +8 -0
  56. package/src/enum/time-place-visibility.ts +8 -0
  57. package/src/enum/tool-type.ts +14 -0
  58. package/src/index.ts +8 -0
  59. package/src/interface/hydration-callback.ts +7 -0
  60. package/src/interface/provider.ts +8 -0
  61. package/src/interface/repository.ts +12 -0
  62. package/src/lib/array/add.ts +10 -0
  63. package/src/lib/array/assert-is-empty.ts +23 -0
  64. package/src/lib/array/clone.ts +5 -0
  65. package/src/lib/array/difference.ts +8 -0
  66. package/src/lib/array/empty.ts +6 -0
  67. package/src/lib/array/equal.ts +24 -0
  68. package/src/lib/array/get-first-value.ts +5 -0
  69. package/src/lib/array/get-last-value.ts +5 -0
  70. package/src/lib/array/get-max-value.ts +5 -0
  71. package/src/lib/array/get-value-after.ts +23 -0
  72. package/src/lib/array/get-value-before.ts +23 -0
  73. package/src/lib/array/get-values-between.ts +18 -0
  74. package/src/lib/array/index.ts +5 -0
  75. package/src/lib/array/is-empty.ts +6 -0
  76. package/src/lib/array/remove.ts +19 -0
  77. package/src/lib/array/sum.ts +11 -0
  78. package/src/lib/array/unique.ts +13 -0
  79. package/src/lib/environment/bootstrap.ts +1 -0
  80. package/src/lib/environment/enum/environment-type.ts +8 -0
  81. package/src/lib/environment/enum/service-type.ts +5 -0
  82. package/src/lib/environment/index.ts +7 -0
  83. package/src/lib/environment/utility/get-environment-type.ts +28 -0
  84. package/src/lib/environment/utility/is-browser.ts +5 -0
  85. package/src/lib/environment/utility/is-development.ts +10 -0
  86. package/src/lib/environment/utility/is-production-or-staging.ts +8 -0
  87. package/src/lib/environment/utility/is-production.ts +10 -0
  88. package/src/lib/environment/utility/is-staging.ts +10 -0
  89. package/src/lib/errors/enum/error-type.ts +13 -0
  90. package/src/lib/errors/error/base.ts +40 -0
  91. package/src/lib/errors/error/conflict.ts +16 -0
  92. package/src/lib/errors/error/generic.ts +23 -0
  93. package/src/lib/errors/error/invalid.ts +14 -0
  94. package/src/lib/errors/error/invariant-violation.ts +5 -0
  95. package/src/lib/errors/error/not-allowed.ts +14 -0
  96. package/src/lib/errors/error/not-found.ts +16 -0
  97. package/src/lib/errors/error/not-implemented.ts +20 -0
  98. package/src/lib/errors/error/omitted.ts +14 -0
  99. package/src/lib/errors/error/timeout.ts +14 -0
  100. package/src/lib/errors/error/unauthorized.ts +14 -0
  101. package/src/lib/errors/index.ts +18 -0
  102. package/src/lib/errors/sugar/invariant.ts +7 -0
  103. package/src/lib/errors/type/coded-error.ts +7 -0
  104. package/src/lib/errors/type/error-data.ts +11 -0
  105. package/src/lib/errors/utility/create-error-for-error-type.ts +60 -0
  106. package/src/lib/errors/utility/create-error-from-ambiguous-json-data.ts +26 -0
  107. package/src/lib/errors/utility/error-matches.ts +28 -0
  108. package/src/lib/errors/utility/get-error-type-for-posix-error-code.ts +37 -0
  109. package/src/lib/errors/utility/get-error-type-for-status-code.ts +38 -0
  110. package/src/lib/errors/utility/get-message-for-error-type.ts +29 -0
  111. package/src/lib/errors/utility/matches-posix-error-code.ts +11 -0
  112. package/src/lib/errors/utility/wrap-error.ts +39 -0
  113. package/src/lib/event-emitter/index.ts +63 -0
  114. package/src/lib/execution-context/execution-context.ts +90 -0
  115. package/src/lib/execution-context/index.ts +8 -0
  116. package/src/lib/execution-context/type/session.ts +7 -0
  117. package/src/lib/feature/feature.ts +108 -0
  118. package/src/lib/feature/index.ts +3 -0
  119. package/src/lib/filesystem/bootstrap.ts +1 -0
  120. package/src/lib/filesystem/enum/file-extension.ts +19 -0
  121. package/src/lib/filesystem/index.ts +4 -0
  122. package/src/lib/filesystem/utility/exists.ts +21 -0
  123. package/src/lib/filesystem/utility/get-extension-for-filepath.ts +20 -0
  124. package/src/lib/filesystem/utility/strip-extension.ts +26 -0
  125. package/src/lib/grammar/index.ts +3 -0
  126. package/src/lib/grammar/noun-inflector.ts +104 -0
  127. package/src/lib/grammar/utility/get-words-from-identifier.ts +9 -0
  128. package/src/lib/grammar/verb-inflector.ts +344 -0
  129. package/src/lib/http/buffer-stream.ts +76 -0
  130. package/src/lib/http/enum/content-type.ts +19 -0
  131. package/src/lib/http/enum/cookie-attribute.ts +11 -0
  132. package/src/lib/http/enum/header.ts +29 -0
  133. package/src/lib/http/enum/method.ts +11 -0
  134. package/src/lib/http/enum/same-site-policy.ts +7 -0
  135. package/src/lib/http/enum/status-code.ts +9 -0
  136. package/src/lib/http/factory/body-parser.ts +55 -0
  137. package/src/lib/http/index.ts +24 -0
  138. package/src/lib/http/interface/client-request.ts +15 -0
  139. package/src/lib/http/interface/incoming-message.ts +24 -0
  140. package/src/lib/http/interface/network-library.ts +9 -0
  141. package/src/lib/http/interface/request-callback.ts +7 -0
  142. package/src/lib/http/isomorphic/request.ts +77 -0
  143. package/src/lib/http/isomorphic/response.ts +77 -0
  144. package/src/lib/http/isomorphic.ts +20 -0
  145. package/src/lib/http/parser/accept-header.ts +35 -0
  146. package/src/lib/http/parser/basic-auth-header.ts +48 -0
  147. package/src/lib/http/parser/body/json.ts +14 -0
  148. package/src/lib/http/parser/body/multipart.ts +89 -0
  149. package/src/lib/http/parser/body/url-encoded.ts +16 -0
  150. package/src/lib/http/parser/body.ts +44 -0
  151. package/src/lib/http/parser/cookie.ts +114 -0
  152. package/src/lib/http/parser/querystring.ts +92 -0
  153. package/src/lib/http/parser/url.ts +76 -0
  154. package/src/lib/http/request/incoming.ts +299 -0
  155. package/src/lib/http/request/outgoing.ts +276 -0
  156. package/src/lib/http/request.ts +26 -0
  157. package/src/lib/http/response/incoming.ts +243 -0
  158. package/src/lib/http/response/outgoing.ts +160 -0
  159. package/src/lib/http/response.ts +74 -0
  160. package/src/lib/http/serializer/basic-auth-header.ts +27 -0
  161. package/src/lib/http/serializer/cookie.ts +90 -0
  162. package/src/lib/http/serializer/query-data.ts +54 -0
  163. package/src/lib/http/transaction.ts +320 -0
  164. package/src/lib/http/type/basic-auth-credentials.ts +6 -0
  165. package/src/lib/http/type/header-map.ts +5 -0
  166. package/src/lib/http/type/log-attributes.ts +12 -0
  167. package/src/lib/http/type/path-parameters.ts +5 -0
  168. package/src/lib/http/type/query-data.ts +7 -0
  169. package/src/lib/http/type/query-value.ts +11 -0
  170. package/src/lib/http/type/request-options.ts +16 -0
  171. package/src/lib/http/type/transaction-data.ts +4 -0
  172. package/src/lib/http/utility/get-content-type-for-extension.ts +47 -0
  173. package/src/lib/http/utility/get-library-for-protocol.ts +25 -0
  174. package/src/lib/http/utility/get-status-code-for-error-type.ts +37 -0
  175. package/src/lib/http/utility/get-status-code-for-error.ts +13 -0
  176. package/src/lib/http/utility/is-client-error-status.ts +15 -0
  177. package/src/lib/http/utility/is-error-status.ts +9 -0
  178. package/src/lib/http/utility/is-server-error-status.ts +7 -0
  179. package/src/lib/http/utility/is-success-status.ts +7 -0
  180. package/src/lib/http/utility/proxy-request.ts +58 -0
  181. package/src/lib/http/utility/serialize-request-options.ts +9 -0
  182. package/src/lib/http/utility/slug-generator.ts +20 -0
  183. package/src/lib/key-generator/index.ts +3 -0
  184. package/src/lib/key-generator/key-generator.ts +7 -0
  185. package/src/lib/logger/enum/ansi-escape-code.ts +14 -0
  186. package/src/lib/logger/enum/log-level.ts +8 -0
  187. package/src/lib/logger/formatter.ts +59 -0
  188. package/src/lib/logger/index.ts +7 -0
  189. package/src/lib/logger/interface/error-reporter.ts +7 -0
  190. package/src/lib/logger/interface/logger.ts +13 -0
  191. package/src/lib/logger/logger.ts +239 -0
  192. package/src/lib/logger/type/error-parameters.ts +9 -0
  193. package/src/lib/logger/type/loggable-data.ts +5 -0
  194. package/src/lib/logger/type/loggable-value.ts +1 -0
  195. package/src/lib/metrics/dispatcher.ts +264 -0
  196. package/src/lib/metrics/enum/dispatch-mode.ts +6 -0
  197. package/src/lib/metrics/index.ts +2 -0
  198. package/src/lib/metrics/settings-hydrator.ts +51 -0
  199. package/src/lib/metrics/type/dispatcher-settings.ts +12 -0
  200. package/src/lib/metrics/type/tag-map.ts +5 -0
  201. package/src/lib/network/bootstrap.ts +1 -0
  202. package/src/lib/network/enum/connection-status.ts +14 -0
  203. package/src/lib/network/enum/http-status-code.ts +75 -0
  204. package/src/lib/network/enum/network-protocol.ts +10 -0
  205. package/src/lib/network/event-emitter.ts +63 -0
  206. package/src/lib/network/index.ts +7 -0
  207. package/src/lib/network/interface/socket.ts +42 -0
  208. package/src/lib/network/type/socket-options.ts +6 -0
  209. package/src/lib/network/utility/get-protocol-from-url.ts +15 -0
  210. package/src/lib/operation/index.ts +6 -0
  211. package/src/lib/operation/operation/auto-logging.ts +94 -0
  212. package/src/lib/operation/operation/silent.ts +17 -0
  213. package/src/lib/operation/operation.ts +80 -0
  214. package/src/lib/process/bootstrap.ts +1 -0
  215. package/src/lib/process/enum/posix-error-code.ts +138 -0
  216. package/src/lib/process/enum/process-signal.ts +68 -0
  217. package/src/lib/process/error.ts +6 -0
  218. package/src/lib/process/execute.ts +77 -0
  219. package/src/lib/process/index.ts +4 -0
  220. package/src/lib/process/type/command-options.ts +9 -0
  221. package/src/lib/process/utility/bind-process-lifespan-to.ts +10 -0
  222. package/src/lib/promise-wrapper/index.ts +3 -0
  223. package/src/lib/promise-wrapper/promise-wrapper.ts +51 -0
  224. package/src/lib/random/chance.ts +5 -0
  225. package/src/lib/random/element.ts +7 -0
  226. package/src/lib/random/elements.ts +12 -0
  227. package/src/lib/random/enum.ts +34 -0
  228. package/src/lib/random/enums.ts +11 -0
  229. package/src/lib/random/index.ts +3 -0
  230. package/src/lib/random/number.ts +8 -0
  231. package/src/lib/server/base.ts +194 -0
  232. package/src/lib/server/enum/server-event.ts +5 -0
  233. package/src/lib/server/enum/server-status.ts +10 -0
  234. package/src/lib/server/http/endpoint/ping.ts +21 -0
  235. package/src/lib/server/http/endpoint.ts +345 -0
  236. package/src/lib/server/http/interface/endpoint-constructor.ts +12 -0
  237. package/src/lib/server/http/interface/result-serializer.ts +5 -0
  238. package/src/lib/server/http/middleware.ts +18 -0
  239. package/src/lib/server/http/result-serializer/html.ts +92 -0
  240. package/src/lib/server/http/result-serializer/json.ts +23 -0
  241. package/src/lib/server/http/route.ts +104 -0
  242. package/src/lib/server/http/router.ts +125 -0
  243. package/src/lib/server/http/type/session-resolver.ts +8 -0
  244. package/src/lib/server/http/utility/create-server.ts +34 -0
  245. package/src/lib/server/http/utility/path-parser.ts +49 -0
  246. package/src/lib/server/http/utility/standardize-html-indentation.ts +54 -0
  247. package/src/lib/server/http/websocket-wrapper.ts +83 -0
  248. package/src/lib/server/http.ts +301 -0
  249. package/src/lib/server/index.ts +5 -0
  250. package/src/lib/server/tcp.ts +53 -0
  251. package/src/lib/server/type/server-options.ts +10 -0
  252. package/src/lib/string/calculate-length.ts +17 -0
  253. package/src/lib/string/capitalize.ts +8 -0
  254. package/src/lib/string/create-slug.ts +14 -0
  255. package/src/lib/string/enum/ansi-escape-code.ts +14 -0
  256. package/src/lib/string/enum/string-encoding.ts +9 -0
  257. package/src/lib/string/hyphenate.ts +5 -0
  258. package/src/lib/string/index.ts +3 -0
  259. package/src/lib/string/pad.ts +14 -0
  260. package/src/lib/string/trim-multiline.ts +21 -0
  261. package/src/lib/string/trim.ts +8 -0
  262. package/src/lib/tcp/channel.ts +13 -0
  263. package/src/lib/tcp/connection/incoming.ts +72 -0
  264. package/src/lib/tcp/connection/outgoing.ts +219 -0
  265. package/src/lib/tcp/connection.ts +360 -0
  266. package/src/lib/tcp/enum/connection-event.ts +12 -0
  267. package/src/lib/tcp/enum/message-type.ts +9 -0
  268. package/src/lib/tcp/index.ts +1 -0
  269. package/src/lib/tcp/type/connection-parameters.ts +6 -0
  270. package/src/lib/tcp/type/message/channel-close.ts +9 -0
  271. package/src/lib/tcp/type/message/channel-open.ts +9 -0
  272. package/src/lib/tcp/type/message.ts +10 -0
  273. package/src/lib/test/index.ts +2 -0
  274. package/src/lib/test/utility/build-config.ts +17 -0
  275. package/src/lib/test/utility/build-execution-context.ts +11 -0
  276. package/src/lib/time/bootstrap.ts +1 -0
  277. package/src/lib/time/enum/time-interval.ts +12 -0
  278. package/src/lib/time/index.ts +4 -0
  279. package/src/lib/time/utility/format-duration.ts +139 -0
  280. package/src/lib/time/utility/format-relative-duration.ts +22 -0
  281. package/src/lib/time/utility/sleep.ts +9 -0
  282. package/src/operation.ts +18 -0
  283. package/src/server/endpoint/abstract-page.ts +126 -0
  284. package/src/server/endpoint/action/create.ts +545 -0
  285. package/src/server/endpoint/action/get.ts +231 -0
  286. package/src/server/endpoint/base.ts +51 -0
  287. package/src/server/endpoint/day.ts +13 -0
  288. package/src/server/endpoint/generic-page.ts +14 -0
  289. package/src/server/endpoint/index.ts +11 -0
  290. package/src/server/endpoint/login.ts +45 -0
  291. package/src/server/endpoint/logout.ts +38 -0
  292. package/src/server/endpoint/month.ts +35 -0
  293. package/src/server/endpoint/robots.ts +18 -0
  294. package/src/server/endpoint/session/create.ts +62 -0
  295. package/src/server/endpoint/settings/get.ts +40 -0
  296. package/src/server/endpoint/settings/update.ts +44 -0
  297. package/src/server/endpoint/today.ts +15 -0
  298. package/src/server/endpoint/week.ts +34 -0
  299. package/src/server/endpoint/year.ts +34 -0
  300. package/src/server/enum/custom-page-type.ts +10 -0
  301. package/src/server/factory/block-result-serializer.ts +115 -0
  302. package/src/server/middleware/base.ts +6 -0
  303. package/src/server/middleware/error-handler.ts +177 -0
  304. package/src/server/middleware/static-file.ts +83 -0
  305. package/src/server/operation/add-block.ts +110 -0
  306. package/src/server/operation/create-session.ts +43 -0
  307. package/src/server/operation/delete-block.ts +96 -0
  308. package/src/server/operation/demote-block.ts +108 -0
  309. package/src/server/operation/destroy-session.ts +26 -0
  310. package/src/server/operation/load-account.ts +30 -0
  311. package/src/server/operation/load-block.ts +48 -0
  312. package/src/server/operation/load-directory-items.ts +75 -0
  313. package/src/server/operation/load-page.ts +368 -0
  314. package/src/server/operation/promote-block.ts +104 -0
  315. package/src/server/operation/save-page.ts +60 -0
  316. package/src/server/operation/update-account-settings.ts +52 -0
  317. package/src/server/operation/update-block.ts +124 -0
  318. package/src/server/repository/memory.ts +112 -0
  319. package/src/server/result-serializer/action.ts +939 -0
  320. package/src/server/result-serializer/base.ts +1267 -0
  321. package/src/server/result-serializer/block/audio.ts +33 -0
  322. package/src/server/result-serializer/block/background.ts +20 -0
  323. package/src/server/result-serializer/block/calendar.ts +148 -0
  324. package/src/server/result-serializer/block/directory.ts +57 -0
  325. package/src/server/result-serializer/block/ephemeral.ts +14 -0
  326. package/src/server/result-serializer/block/folder.ts +106 -0
  327. package/src/server/result-serializer/block/header.ts +31 -0
  328. package/src/server/result-serializer/block/image.ts +46 -0
  329. package/src/server/result-serializer/block/link.ts +40 -0
  330. package/src/server/result-serializer/block/list.ts +140 -0
  331. package/src/server/result-serializer/block/multi-column.ts +97 -0
  332. package/src/server/result-serializer/block/note.ts +44 -0
  333. package/src/server/result-serializer/block/todo.ts +78 -0
  334. package/src/server/result-serializer/block/whitespace.ts +15 -0
  335. package/src/server/result-serializer/block.ts +248 -0
  336. package/src/server/result-serializer/common/time-place-options.ts +33 -0
  337. package/src/server/result-serializer/login.ts +58 -0
  338. package/src/server/result-serializer/month.ts +170 -0
  339. package/src/server/result-serializer/page.ts +548 -0
  340. package/src/server/result-serializer/settings.ts +85 -0
  341. package/src/server/result-serializer/week.ts +195 -0
  342. package/src/server/result-serializer/year.ts +160 -0
  343. package/src/server/utility/accepts-content-type.ts +16 -0
  344. package/src/server/utility/accepts-html.ts +9 -0
  345. package/src/server/utility/accepts-json.ts +9 -0
  346. package/src/server/utility/add-days.ts +11 -0
  347. package/src/server/utility/create-date.ts +23 -0
  348. package/src/server/utility/create-index-path.ts +5 -0
  349. package/src/server/utility/create-slug.ts +9 -0
  350. package/src/server/utility/create-toast-path.ts +19 -0
  351. package/src/server/utility/date-less-than.ts +5 -0
  352. package/src/server/utility/date-occurs-before.ts +22 -0
  353. package/src/server/utility/date-to-key.ts +7 -0
  354. package/src/server/utility/date-to-label.ts +5 -0
  355. package/src/server/utility/date-to-path.ts +9 -0
  356. package/src/server/utility/dates-are-equal.ts +22 -0
  357. package/src/server/utility/dates-are-in-order.ts +9 -0
  358. package/src/server/utility/dates-are-on-the-same-day.ts +9 -0
  359. package/src/server/utility/dates-in-same-month.ts +8 -0
  360. package/src/server/utility/day-to-date.ts +40 -0
  361. package/src/server/utility/decrement-date.ts +11 -0
  362. package/src/server/utility/get-block-at-index-path.ts +32 -0
  363. package/src/server/utility/get-block-permissions.ts +15 -0
  364. package/src/server/utility/get-compact-label-for-date.ts +8 -0
  365. package/src/server/utility/get-custom-page-type-for-path.ts +37 -0
  366. package/src/server/utility/get-element-id-for-block.ts +15 -0
  367. package/src/server/utility/get-emoji-for-block-type.ts +39 -0
  368. package/src/server/utility/get-emoji-for-tool-type.ts +20 -0
  369. package/src/server/utility/get-end-of-month.ts +13 -0
  370. package/src/server/utility/get-end-of-week.ts +13 -0
  371. package/src/server/utility/get-filepath-for-folder-block.ts +23 -0
  372. package/src/server/utility/get-hex-for-color.ts +31 -0
  373. package/src/server/utility/get-label-for-time-place-visibility.ts +23 -0
  374. package/src/server/utility/get-month-name.ts +18 -0
  375. package/src/server/utility/get-next-day.ts +7 -0
  376. package/src/server/utility/get-next-month.ts +12 -0
  377. package/src/server/utility/get-next-week.ts +12 -0
  378. package/src/server/utility/get-next-year.ts +13 -0
  379. package/src/server/utility/get-ordinal-label-for-week.ts +11 -0
  380. package/src/server/utility/get-ordinal-of-week-within-month.ts +15 -0
  381. package/src/server/utility/get-padded-date.ts +11 -0
  382. package/src/server/utility/get-parent-index-path.ts +18 -0
  383. package/src/server/utility/get-path-for-folder-block.ts +25 -0
  384. package/src/server/utility/get-path-from-url.ts +13 -0
  385. package/src/server/utility/get-previous-index-path.ts +27 -0
  386. package/src/server/utility/get-previous-month.ts +12 -0
  387. package/src/server/utility/get-previous-week.ts +11 -0
  388. package/src/server/utility/get-previous-year.ts +13 -0
  389. package/src/server/utility/get-random-emoji-for-date.ts +109 -0
  390. package/src/server/utility/get-short-label-for-date.ts +11 -0
  391. package/src/server/utility/get-short-month-name.ts +9 -0
  392. package/src/server/utility/get-short-ordinal.ts +26 -0
  393. package/src/server/utility/get-siblings-and-index-for-index-path.ts +67 -0
  394. package/src/server/utility/get-start-of-month.ts +11 -0
  395. package/src/server/utility/get-start-of-week.ts +12 -0
  396. package/src/server/utility/get-start-of-year.ts +12 -0
  397. package/src/server/utility/get-weekday-name.ts +24 -0
  398. package/src/server/utility/increment-date.ts +15 -0
  399. package/src/server/utility/is-index-path.ts +5 -0
  400. package/src/server/utility/key-to-date.ts +25 -0
  401. package/src/server/utility/month-has-week-containing-date.ts +13 -0
  402. package/src/server/utility/month-to-date.ts +28 -0
  403. package/src/server/utility/month-to-path.ts +10 -0
  404. package/src/server/utility/months-are-equal.ts +8 -0
  405. package/src/server/utility/parse-index-path.ts +23 -0
  406. package/src/server/utility/path-is-date.ts +13 -0
  407. package/src/server/utility/path-to-date.ts +24 -0
  408. package/src/server/utility/subtract-days.ts +7 -0
  409. package/src/server/utility/validate-month.ts +10 -0
  410. package/src/server/utility/validate-page.ts +46 -0
  411. package/src/server/utility/validate-path.ts +9 -0
  412. package/src/server/utility/validate-url.ts +12 -0
  413. package/src/server/utility/week-greater-than.ts +10 -0
  414. package/src/server/utility/week-to-date.ts +8 -0
  415. package/src/server/utility/week-to-path.ts +12 -0
  416. package/src/server/utility/weeks-are-equal.ts +8 -0
  417. package/src/server/utility/year-to-date.ts +26 -0
  418. package/src/server/utility/year-to-path.ts +7 -0
  419. package/src/server/utility/years-are-equal.ts +8 -0
  420. package/src/server.ts +140 -0
  421. package/src/test.ts +195 -0
  422. package/src/type/account-settings.ts +9 -0
  423. package/src/type/account.ts +11 -0
  424. package/src/type/action/add-block.ts +74 -0
  425. package/src/type/action/complete-block.ts +10 -0
  426. package/src/type/action/delete-block.ts +11 -0
  427. package/src/type/action/demote-block.ts +9 -0
  428. package/src/type/action/edit-block.ts +11 -0
  429. package/src/type/action/promote-block.ts +9 -0
  430. package/src/type/action.ts +9 -0
  431. package/src/type/block/audio.ts +8 -0
  432. package/src/type/block/background.ts +10 -0
  433. package/src/type/block/directory.ts +18 -0
  434. package/src/type/block/ephemeral.ts +9 -0
  435. package/src/type/block/folder.ts +14 -0
  436. package/src/type/block/header.ts +11 -0
  437. package/src/type/block/image.ts +8 -0
  438. package/src/type/block/link.ts +12 -0
  439. package/src/type/block/list.ts +24 -0
  440. package/src/type/block/multi-column.ts +10 -0
  441. package/src/type/block/note.ts +9 -0
  442. package/src/type/block/todo.ts +10 -0
  443. package/src/type/block/whitespace.ts +9 -0
  444. package/src/type/block-metadata.ts +14 -0
  445. package/src/type/block.ts +18 -0
  446. package/src/type/day.ts +5 -0
  447. package/src/type/field-definition.ts +8 -0
  448. package/src/type/field-value.ts +5 -0
  449. package/src/type/file.ts +6 -0
  450. package/src/type/month.ts +5 -0
  451. package/src/type/page.ts +8 -0
  452. package/src/type/price.ts +11 -0
  453. package/src/type/resource.ts +5 -0
  454. package/src/type/runtime-config.ts +13 -0
  455. package/src/type/server-settings.ts +17 -0
  456. package/src/type/toast.ts +8 -0
  457. package/src/type/week.ts +5 -0
  458. package/src/type/year.ts +5 -0
  459. package/test/unit/index.ts +11 -0
  460. package/test/unit/server/operation/promote-block.ts +84 -0
@@ -0,0 +1,104 @@
1
+ const SINGULAR_TO_PLURAL_MAP: Record<string, string> = {
2
+ loot: 'loot'
3
+ };
4
+
5
+ class NounInflector {
6
+ public singularize(plural_form: string): string {
7
+ for (const singular_key in SINGULAR_TO_PLURAL_MAP) {
8
+ if (SINGULAR_TO_PLURAL_MAP[singular_key] === plural_form) {
9
+ return singular_key;
10
+ }
11
+ }
12
+
13
+ if (plural_form.slice(-3) === 'ies') {
14
+ return plural_form.slice(0, -3) + 'y';
15
+ }
16
+
17
+ if (plural_form.slice(-1) === 'i') {
18
+ return plural_form.slice(0, -1) + 'us';
19
+ }
20
+
21
+ if (plural_form.slice(-1) === 's') {
22
+ return plural_form.slice(0, -1);
23
+ }
24
+
25
+ return plural_form;
26
+ }
27
+
28
+ public pluralize(singular_form: string): string {
29
+ if (SINGULAR_TO_PLURAL_MAP[singular_form] !== undefined) {
30
+ return SINGULAR_TO_PLURAL_MAP[singular_form];
31
+ }
32
+
33
+ if (singular_form.slice(-1) === 'y') {
34
+ if (!this.isVowel(singular_form.slice(-2, -1))) {
35
+ return singular_form.slice(0, -1) + 'ies';
36
+ }
37
+ }
38
+
39
+ if (singular_form.slice(-2) === 'ch') {
40
+ return singular_form + 'es';
41
+ }
42
+
43
+ if (singular_form.slice(-2) === 'us') {
44
+ return singular_form.slice(0, -2) + 'i';
45
+ }
46
+
47
+ if (singular_form.slice(-2) === 'ss') {
48
+ return singular_form + 'es';
49
+ }
50
+
51
+ if (singular_form === 'life') {
52
+ return 'lives';
53
+ }
54
+
55
+ return singular_form + 's';
56
+ }
57
+
58
+ /**
59
+ * Takes a number, and a singular suffix noun, and returns the correctly
60
+ * formatted result for the given number.
61
+ *
62
+ * Example:
63
+ *
64
+ * singularizeOrPluralize(1, 'account') => '1 account'
65
+ * singularizeOrPluralize(6, 'account') => '6 accounts'
66
+ */
67
+ public singularizeOrPluralize(
68
+ amount: string | number,
69
+ suffix: string
70
+ ): string {
71
+ if (typeof amount === 'string') {
72
+ amount = parseFloat(amount);
73
+ }
74
+
75
+ if (amount === 1) {
76
+ return `${amount} ${suffix}`;
77
+ }
78
+
79
+ const plural_suffix = this.pluralize(suffix);
80
+
81
+ return `${amount} ${plural_suffix}`;
82
+ }
83
+
84
+ public prependArticle(suffix: string): string {
85
+ const first_letter = suffix[0];
86
+ const is_vowel = this.isVowel(first_letter);
87
+
88
+ let article: string;
89
+
90
+ if (is_vowel) {
91
+ article = 'an';
92
+ } else {
93
+ article = 'a';
94
+ }
95
+
96
+ return `${article} ${suffix}`;
97
+ }
98
+
99
+ private isVowel(letter: string): boolean {
100
+ return /[aeiou]/.test(letter.toLowerCase());
101
+ }
102
+ }
103
+
104
+ export default NounInflector;
@@ -0,0 +1,9 @@
1
+ function getWordsFromIdentifier(identifier: string): string[] {
2
+ const delimited_identifier = identifier.replace(/[a-z][A-Z]/g, (match) => {
3
+ return match[0] + '_' + match[1];
4
+ });
5
+
6
+ return delimited_identifier.split('_');
7
+ }
8
+
9
+ export default getWordsFromIdentifier;
@@ -0,0 +1,344 @@
1
+ import {capitalize} from 'lib/string';
2
+ import NounInflector from 'lib/grammar/noun-inflector';
3
+
4
+ class VerbInflector {
5
+ private value: string;
6
+ private verb: string;
7
+ private suffix: string;
8
+ private uppercase: boolean;
9
+
10
+ public constructor(value: string) {
11
+ this.value = value;
12
+
13
+ const index = value.indexOf(' ');
14
+
15
+ if (index !== -1) {
16
+ this.suffix = value.slice(index);
17
+
18
+ value = value.slice(0, index);
19
+ } else {
20
+ this.suffix = '';
21
+ }
22
+
23
+ this.uppercase = value !== value.toLowerCase();
24
+ this.verb = value.toLowerCase();
25
+ }
26
+
27
+ public toPresentParticiple(): string {
28
+ if (this.verb === 'group') {
29
+ return this.finalize('grouping');
30
+ }
31
+
32
+ if (this.verb === 'be') {
33
+ return this.finalize('being');
34
+ }
35
+
36
+ // stop -> stopping
37
+ if (/[aeiou]p$/.test(this.verb)) {
38
+ return this.finalize(this.verb + 'ping');
39
+ }
40
+
41
+ // log -> logging
42
+ if (/[aeiou]g$/.test(this.verb)) {
43
+ return this.finalize(this.verb + 'ging');
44
+ }
45
+
46
+ // free -> freeing
47
+ if (/ee$/.test(this.verb)) {
48
+ return this.finalize(this.verb + 'ing');
49
+ }
50
+
51
+ // wave -> waving
52
+ if (/e$/.test(this.verb)) {
53
+ return this.finalize(this.verb.slice(0, -1) + 'ing');
54
+ }
55
+
56
+ // run -> running
57
+ if (/[aeiou]n$/.test(this.verb)) {
58
+ return this.finalize(this.verb + 'ning');
59
+ }
60
+
61
+ // pet -> petting
62
+ if (/[aeiou]t$/.test(this.verb)) {
63
+ return this.finalize(this.verb + 'ting');
64
+ }
65
+
66
+ return this.finalize(this.verb + 'ing');
67
+ }
68
+
69
+ public toPastParticiple(): string {
70
+ switch (this.verb) {
71
+ case 'choose':
72
+ return this.finalize('chosen');
73
+
74
+ default:
75
+ return this.toPastTense();
76
+ }
77
+ }
78
+
79
+ public toInfinitive(): string {
80
+ return this.finalize(`to ${this.verb}`);
81
+ }
82
+
83
+ public toAdjective(): string {
84
+ if (this.value.startsWith('be ')) {
85
+ return this.value.slice(3);
86
+ } else {
87
+ return this.finalize(this.verb + 'y');
88
+ }
89
+ }
90
+
91
+ public toPresentTense(): string {
92
+ switch (this.verb) {
93
+ case 'be':
94
+ return this.finalize('is');
95
+ default:
96
+ return this.finalize(this.verb);
97
+ }
98
+ }
99
+
100
+ public toImperfectTense(): string {
101
+ const participle = this.toPresentParticiple();
102
+
103
+ return this.finalize(`was ${participle}`);
104
+ }
105
+
106
+ public toPastTense(): string {
107
+ switch (this.verb) {
108
+ case 'find':
109
+ return this.finalize('found');
110
+ case 'get':
111
+ return this.finalize('got');
112
+ case 'run':
113
+ return this.finalize('ran');
114
+ case 'read':
115
+ return this.finalize('read');
116
+ case 'write':
117
+ return this.finalize('wrote');
118
+ case 'choose':
119
+ return this.finalize('chose');
120
+ case 'build':
121
+ return this.finalize('built');
122
+ }
123
+
124
+ // stop -> stopped
125
+ if (/[aeiou]p$/.test(this.verb)) {
126
+ return this.finalize(this.verb + 'ped');
127
+ }
128
+
129
+ // log -> logged
130
+ if (/[aeiou]g$/.test(this.verb)) {
131
+ return this.finalize(this.verb + 'ged');
132
+ }
133
+
134
+ if (this.verb === 'be') {
135
+ return this.finalize('was');
136
+ }
137
+
138
+ if (this.verb === 'draw') {
139
+ return this.finalize('drew');
140
+ }
141
+
142
+ // wave -> waved
143
+ if (/e$/.test(this.verb)) {
144
+ return this.finalize(this.verb + 'd');
145
+ }
146
+
147
+ // destroy -> destroyed
148
+ if (/[aeiou]y$/.test(this.verb)) {
149
+ return this.finalize(this.verb + 'ed');
150
+ }
151
+
152
+ // party -> partied
153
+ if (/y$/.test(this.verb)) {
154
+ return this.finalize(this.verb.slice(0, -1) + 'ied');
155
+ }
156
+
157
+ return this.finalize(this.verb + 'ed');
158
+ }
159
+
160
+ public toFutureTense(): string {
161
+ return this.finalize(`will ${this.verb}`);
162
+ }
163
+
164
+ public toSingularNoun(): string {
165
+ switch (this.verb) {
166
+ case 'cut':
167
+ return this.finalize('cut');
168
+
169
+ case 'die':
170
+ return this.finalize('death');
171
+
172
+ case 'live':
173
+ return this.finalize('life');
174
+
175
+ case 'change':
176
+ return this.finalize('change');
177
+
178
+ case 'make water':
179
+ return this.finalize('water');
180
+
181
+ case 'do':
182
+ return this.finalize('action');
183
+
184
+ case 'protect':
185
+ return this.finalize('protection');
186
+
187
+ case 'affirm':
188
+ return this.finalize('affirmation');
189
+
190
+ case 'choose':
191
+ return this.finalize('choice');
192
+
193
+ case 'collide':
194
+ return this.finalize('collision');
195
+
196
+ case 'encase':
197
+ return this.finalize('casing');
198
+
199
+ case 'darken':
200
+ return this.finalize('shadow');
201
+
202
+ case 'damage':
203
+ return this.finalize('damage');
204
+
205
+ case 'define':
206
+ return this.finalize('definition');
207
+
208
+ case 'describe':
209
+ return this.finalize('description');
210
+
211
+ case 'hear':
212
+ return this.finalize('sound');
213
+
214
+ case 'measure':
215
+ return this.finalize('measurement');
216
+
217
+ case 'rate':
218
+ return this.finalize('rating');
219
+
220
+ case 'move':
221
+ return this.finalize('movement');
222
+
223
+ case 'regard':
224
+ return this.finalize('regard');
225
+
226
+ case 'survey':
227
+ return this.finalize('area');
228
+
229
+ case 'interact':
230
+ return this.finalize('interaction');
231
+
232
+ case 'name':
233
+ return this.finalize('name');
234
+
235
+ case 'speak':
236
+ return this.finalize('speech');
237
+
238
+ case 'count':
239
+ return this.finalize('number');
240
+
241
+ case 'reside':
242
+ return this.finalize('residence');
243
+
244
+ case 'know':
245
+ return this.finalize('knowledge');
246
+
247
+ case 'divide':
248
+ return this.finalize('division');
249
+
250
+ case 'void':
251
+ return this.finalize('void');
252
+
253
+ case 'make':
254
+ switch (this.value) {
255
+ case 'make music':
256
+ return 'music';
257
+ case 'make noise':
258
+ return 'noise';
259
+ default:
260
+ return this.suffix.slice(1);
261
+ }
262
+
263
+ case 'breathe':
264
+ return this.finalize('breath');
265
+
266
+ case 'have':
267
+ return this.finalize('belonging');
268
+
269
+ case 'bear':
270
+ if (this.suffix === ' fruit') {
271
+ return 'fruit';
272
+ }
273
+
274
+ case 'dream':
275
+ return 'dream';
276
+
277
+ case 'test':
278
+ return 'test';
279
+
280
+ case 'prepare':
281
+ return 'preparation';
282
+
283
+ case 'ascend':
284
+ return 'ascension';
285
+
286
+ case 'sleep':
287
+ return 'sleep';
288
+
289
+ default:
290
+ if (this.verb.slice(-2) === 'te') {
291
+ return this.finalize(this.verb.slice(0, -2) + 'tion');
292
+ }
293
+
294
+ return this.finalize(this.toPresentParticiple());
295
+ }
296
+ }
297
+
298
+ public toPluralNoun(): string {
299
+ const inflector = new NounInflector();
300
+ const singular = this.toSingularNoun();
301
+
302
+ return this.finalize(inflector.pluralize(singular));
303
+ }
304
+
305
+ public toSingularActor(): string {
306
+ switch (this.verb) {
307
+ case 'be':
308
+ return this.finalize('being');
309
+ }
310
+
311
+ if (this.verb.endsWith('ate')) {
312
+ return this.finalize(`${this.verb.slice(0, -1)}or`);
313
+ }
314
+
315
+ if (this.verb.endsWith('e')) {
316
+ return this.finalize(`${this.verb}r`);
317
+ }
318
+
319
+ if (this.verb.endsWith('ct')) {
320
+ return this.finalize(`${this.verb}or`);
321
+ }
322
+
323
+ return this.finalize(`${this.verb}er`);
324
+ }
325
+
326
+ public toPluralActor(): string {
327
+ const singular_actor = this.toSingularActor();
328
+ const inflector = new NounInflector();
329
+
330
+ return this.finalize(inflector.pluralize(singular_actor));
331
+ }
332
+
333
+ private finalize(value: string): string {
334
+ value += this.suffix;
335
+
336
+ if (this.uppercase) {
337
+ return capitalize(value);
338
+ } else {
339
+ return value.toLowerCase();
340
+ }
341
+ }
342
+ }
343
+
344
+ export default VerbInflector;
@@ -0,0 +1,76 @@
1
+ import {Duplex} from 'stream';
2
+
3
+ interface Callback {
4
+ (): void;
5
+ }
6
+
7
+ class BufferStream extends Duplex {
8
+ private is_closed: boolean;
9
+ private buffer: Buffer | undefined;
10
+
11
+ public constructor() {
12
+ super();
13
+
14
+ this.is_closed = false;
15
+ this.buffer = Buffer.alloc(0);
16
+
17
+ this.on('finish', this.handleFinished.bind(this));
18
+ }
19
+
20
+ // eslint-disable-next-line @typescript-eslint/naming-convention
21
+ public _read(): void {
22
+ if (this.isBuffering()) {
23
+ this.emptyBuffer();
24
+ }
25
+
26
+ if (this.isClosed()) {
27
+ this.pushClosed();
28
+ }
29
+ }
30
+
31
+ // eslint-disable-next-line @typescript-eslint/naming-convention
32
+ public _write(chunk: Buffer, _encoding: string, callback: Callback): void {
33
+ if (this.isBuffering()) {
34
+ this.addToBuffer(chunk);
35
+ } else {
36
+ this.push(chunk);
37
+ }
38
+
39
+ callback();
40
+ }
41
+
42
+ public handleFinished(): void {
43
+ this.is_closed = true;
44
+
45
+ if (!this.isBuffering()) {
46
+ this.pushClosed();
47
+ }
48
+ }
49
+
50
+ private pushClosed(): void {
51
+ this.push(null);
52
+ }
53
+
54
+ private emptyBuffer(): void {
55
+ this.push(this.buffer);
56
+ this.buffer = undefined;
57
+ }
58
+
59
+ private isClosed(): boolean {
60
+ return this.is_closed;
61
+ }
62
+
63
+ private isBuffering(): boolean {
64
+ return this.buffer !== undefined;
65
+ }
66
+
67
+ private addToBuffer(chunk: Buffer): void {
68
+ if (this.buffer === undefined) {
69
+ throw new Error('Tried to read buffer, but it was not set');
70
+ }
71
+
72
+ this.buffer = Buffer.concat([this.buffer, chunk]);
73
+ }
74
+ }
75
+
76
+ export default BufferStream;
@@ -0,0 +1,19 @@
1
+ enum ContentType {
2
+ ANY = '*/*',
3
+ CSS = 'text/css',
4
+ GIF = 'image/gif',
5
+ HTML = 'text/html',
6
+ // I am loathe to have a hard-coded reference to Microsoft in the codebase...
7
+ ICO = 'image/vnd.microsoft.icon',
8
+ JPEG = 'image/jpeg',
9
+ JS = 'text/javascript',
10
+ JSON = 'application/json',
11
+ MP3 = 'audio/mpeg',
12
+ MULTIPART = 'multipart/form-data',
13
+ PNG = 'image/png',
14
+ TEXT = 'text/plain',
15
+ URL_ENCODED = 'application/x-www-form-urlencoded',
16
+ WAV = 'audio/wav'
17
+ }
18
+
19
+ export default ContentType;
@@ -0,0 +1,11 @@
1
+ enum CookieAttribute {
2
+ DOMAIN = 'domain',
3
+ EXPIRES = 'expires',
4
+ HTTPONLY = 'httponly',
5
+ PATH = 'path',
6
+ SECURE = 'secure',
7
+ SESSION = 'session',
8
+ SAMESITE = 'samesite'
9
+ }
10
+
11
+ export default CookieAttribute;
@@ -0,0 +1,29 @@
1
+ enum HttpHeader {
2
+ ACCEPT = 'accept',
3
+ ACCESS_CONTROL_ALLOW_CREDENTIALS = 'access-control-allow-credentials',
4
+ ACCESS_CONTROL_ALLOW_HEADERS = 'access-control-allow-headers',
5
+ ACCESS_CONTROL_ALLOW_METHODS = 'access-control-allow-methods',
6
+ ACCESS_CONTROL_ALLOW_ORIGIN = 'access-control-allow-origin',
7
+ ACCESS_CONTROL_REQUEST_HEADERS = 'access-control-request-headers',
8
+ AUTHORIZATION = 'authorization',
9
+ CONNECTION = 'connection',
10
+ CONTENT_LENGTH = 'content-length',
11
+ CONTENT_SECURITY_POLICY = 'content-security-policy',
12
+ CONTENT_TYPE = 'content-type',
13
+ COOKIE = 'cookie',
14
+ DATE = 'date',
15
+ ETAG = 'etag',
16
+ HOST = 'host',
17
+ IF_MODIFIED_SINCE = 'if-modified-since',
18
+ IF_NONE_MATCH = 'if-none-match',
19
+ LAST_MODIFIED = 'last-modified',
20
+ LOCATION = 'location',
21
+ ORIGIN = 'origin',
22
+ REFERER = 'referer',
23
+ SET_COOKIE = 'set-cookie',
24
+ TRANSFER_ENCODING = 'transfer-encoding',
25
+ USER_AGENT = 'user-agent',
26
+ X_FORWARDED_FOR = 'x-forwarded-for'
27
+ }
28
+
29
+ export default HttpHeader;
@@ -0,0 +1,11 @@
1
+ enum Method {
2
+ GET = 'GET',
3
+ HEAD = 'HEAD',
4
+ PATCH = 'PATCH',
5
+ POST = 'POST',
6
+ PUT = 'PUT',
7
+ DELETE = 'DELETE',
8
+ OPTIONS = 'OPTIONS'
9
+ }
10
+
11
+ export default Method;
@@ -0,0 +1,7 @@
1
+ enum SameSitePolicy {
2
+ STRICT = 'strict',
3
+ LAX = 'lax',
4
+ NONE = 'none'
5
+ }
6
+
7
+ export default SameSitePolicy;
@@ -0,0 +1,9 @@
1
+ import {HttpStatusCode} from 'lib/network';
2
+
3
+ // Wondering why this is in lib/network instead of here?
4
+ // This module has some dependencies that rely on these status codes.
5
+ // This way, those dependencies can import lib/network instead.
6
+
7
+ export default HttpStatusCode;
8
+
9
+
@@ -0,0 +1,55 @@
1
+ import HTTP from 'http';
2
+ import Stream from 'stream';
3
+
4
+ import BodyParser from 'lib/http/parser/body';
5
+ import ContentType from 'lib/http/enum/content-type';
6
+ import JsonBodyParser from 'lib/http/parser/body/json';
7
+ import MultipartBodyParser from 'lib/http/parser/body/multipart';
8
+ import UrlEncodedBodyParser from 'lib/http/parser/body/url-encoded';
9
+
10
+ class BodyParserFactory {
11
+ private stream: Stream.Readable;
12
+ private content_type: ContentType;
13
+ private native_request: HTTP.IncomingMessage;
14
+
15
+ public constructor(
16
+ stream: Stream.Readable,
17
+ content_type: ContentType,
18
+ native_request: HTTP.IncomingMessage
19
+ ) {
20
+ this.stream = stream;
21
+ this.content_type = content_type;
22
+ this.native_request = native_request;
23
+ }
24
+
25
+ public getParser(): BodyParser {
26
+ const stream = this.getStream();
27
+ const content_type = this.getContentType();
28
+ const native_request = this.getNativeRequest();
29
+
30
+ switch (content_type) {
31
+ case ContentType.URL_ENCODED:
32
+ return new UrlEncodedBodyParser(stream);
33
+ case ContentType.MULTIPART:
34
+ return new MultipartBodyParser(stream, native_request);
35
+
36
+ case ContentType.JSON:
37
+ default:
38
+ return new JsonBodyParser(stream);
39
+ }
40
+ }
41
+
42
+ private getStream(): Stream.Readable {
43
+ return this.stream;
44
+ }
45
+
46
+ private getContentType(): ContentType {
47
+ return this.content_type;
48
+ }
49
+
50
+ private getNativeRequest(): HTTP.IncomingMessage {
51
+ return this.native_request;
52
+ }
53
+ }
54
+
55
+ export default BodyParserFactory;
@@ -0,0 +1,24 @@
1
+ export {default as ContentType} from 'lib/http/enum/content-type';
2
+ export {default as CookieAttribute} from 'lib/http/enum/cookie-attribute';
3
+ export {default as HttpHeader} from 'lib/http/enum/header';
4
+ export {default as HttpMethod} from 'lib/http/enum/method';
5
+ export {default as StatusCode} from 'lib/http/enum/status-code';
6
+
7
+ export {default as IncomingRequest} from 'lib/http/request/incoming';
8
+ export {default as OutgoingRequest} from 'lib/http/request/outgoing';
9
+ export {default as IncomingResponse} from 'lib/http/response/incoming';
10
+ export {default as OutgoingResponse} from 'lib/http/response/outgoing';
11
+
12
+ export {default as HeaderMap} from 'lib/http/type/header-map';
13
+ export {default as QueryData} from 'lib/http/type/query-data';
14
+ export {default as PathParameters} from 'lib/http/type/path-parameters';
15
+ export {default as TransactionData} from 'lib/http/type/transaction-data';
16
+
17
+ export {default as NetworkLibrary} from 'lib/http/interface/network-library';
18
+
19
+ export {default as CookieSerializer} from 'lib/http/serializer/cookie';
20
+ export {default as QueryDataSerializer} from 'lib/http/serializer/query-data';
21
+ export {default as BasicAuthHeaderParser} from 'lib/http/parser/basic-auth-header';
22
+
23
+ export {default as getContentTypeForExtension} from 'lib/http/utility/get-content-type-for-extension';
24
+ export {default as getStatusCodeForError} from 'lib/http/utility/get-status-code-for-error';