@joystick.js/node-canary 0.0.0-canary.47 → 0.0.0-canary.470

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 (439) hide show
  1. package/.build/getFilesToBuild.js +26 -0
  2. package/.build/getPlatformSafeFilePath.js +6 -0
  3. package/.build/getPlatformSafePath.js +6 -0
  4. package/.build/index.js +88 -0
  5. package/.build/isWindows.js +3 -0
  6. package/dist/action/class.js +1 -82
  7. package/dist/action/index.js +1 -8
  8. package/dist/app/accounts/default_user_output_fields.js +1 -0
  9. package/dist/app/accounts/delete_user.js +1 -0
  10. package/dist/app/accounts/generate_account_session.js +1 -0
  11. package/dist/app/accounts/generate_password_reset_token.js +1 -0
  12. package/dist/app/accounts/get_browser_safe_user.js +1 -0
  13. package/dist/app/accounts/has_login_token_expired.js +1 -0
  14. package/dist/app/accounts/index.js +1 -29
  15. package/dist/app/accounts/login.js +1 -59
  16. package/dist/app/accounts/recover_password.js +1 -0
  17. package/dist/app/accounts/reset_password.js +1 -0
  18. package/dist/app/accounts/roles/add.js +1 -7
  19. package/dist/app/accounts/roles/grant.js +1 -7
  20. package/dist/app/accounts/roles/index.js +1 -17
  21. package/dist/app/accounts/roles/list.js +1 -7
  22. package/dist/app/accounts/roles/remove.js +1 -7
  23. package/dist/app/accounts/roles/revoke.js +1 -7
  24. package/dist/app/accounts/roles/user_has_role.js +1 -0
  25. package/dist/app/accounts/send_email_verification.js +1 -0
  26. package/dist/app/accounts/set_account_cookie.js +1 -0
  27. package/dist/app/accounts/set_password.js +1 -0
  28. package/dist/app/accounts/signup.js +1 -97
  29. package/dist/app/accounts/unset_account_cookie.js +1 -0
  30. package/dist/app/accounts/verify_email.js +1 -0
  31. package/dist/app/api/accounts/authenticated.js +1 -0
  32. package/dist/app/api/accounts/login.js +1 -0
  33. package/dist/app/api/accounts/logout.js +1 -0
  34. package/dist/app/api/accounts/recover_password.js +1 -0
  35. package/dist/app/api/accounts/reset_password.js +1 -0
  36. package/dist/app/api/accounts/signup.js +1 -0
  37. package/dist/app/api/accounts/user.js +1 -0
  38. package/dist/app/api/accounts/verify_email.js +1 -0
  39. package/dist/app/api/format_api_error.js +1 -0
  40. package/dist/app/api/get.js +2 -0
  41. package/dist/app/api/get_api_context.js +1 -0
  42. package/dist/app/api/get_api_for_data_functions.js +1 -0
  43. package/dist/app/api/get_api_url_component.js +1 -0
  44. package/dist/app/api/get_output.js +1 -0
  45. package/dist/app/api/get_value_from_object.js +1 -0
  46. package/dist/app/api/handle_api_error.js +1 -0
  47. package/dist/app/api/input_validators.js +1 -0
  48. package/dist/app/api/is_array_path.js +1 -0
  49. package/dist/app/api/push/health.js +2 -0
  50. package/dist/app/api/register_getters.js +1 -0
  51. package/dist/app/api/register_setters.js +1 -0
  52. package/dist/app/api/sanitize_api_response.js +1 -0
  53. package/dist/app/api/set.js +2 -0
  54. package/dist/app/api/test/accounts/delete.js +1 -0
  55. package/dist/app/api/test/accounts/signup.js +1 -0
  56. package/dist/app/api/test/bootstrap.js +1 -0
  57. package/dist/app/api/test/process.js +1 -0
  58. package/dist/app/api/test/queues.js +1 -0
  59. package/dist/app/api/validate_input.js +1 -0
  60. package/dist/app/api/validate_session.js +1 -0
  61. package/dist/app/api/validate_type.js +1 -0
  62. package/dist/app/browser/hmr_client.js +1 -0
  63. package/dist/app/browser/process_polyfill.js +1 -0
  64. package/dist/app/cron_jobs/register.js +1 -0
  65. package/dist/app/databases/database_type_map.js +1 -0
  66. package/dist/app/databases/get_target_database_connection.js +1 -0
  67. package/dist/app/databases/mongodb/available_query_parameters.js +1 -0
  68. package/dist/app/databases/mongodb/build_connection_string.js +1 -0
  69. package/dist/app/databases/mongodb/build_query_parameters.js +1 -0
  70. package/dist/app/databases/mongodb/connect.js +6 -0
  71. package/dist/app/databases/mongodb/create_indexes.js +1 -0
  72. package/dist/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +1 -0
  73. package/dist/app/databases/postgresql/connect.js +30 -0
  74. package/dist/app/databases/postgresql/create_indexes.js +1 -0
  75. package/dist/app/databases/postgresql/create_tables.js +1 -0
  76. package/dist/app/databases/postgresql/handle_cleanup_queues.js +5 -0
  77. package/dist/app/databases/postgresql/handle_cleanup_sessions.js +1 -0
  78. package/dist/app/databases/queries/accounts.js +1 -0
  79. package/dist/app/databases/queries/map.js +1 -0
  80. package/dist/app/databases/queries/mongodb/accounts.js +1 -0
  81. package/dist/app/databases/queries/mongodb/queues.js +1 -0
  82. package/dist/app/databases/queries/mongodb/sessions.js +1 -0
  83. package/dist/app/databases/queries/postgresql/accounts.js +1 -0
  84. package/dist/app/databases/queries/postgresql/queues.js +123 -0
  85. package/dist/app/databases/queries/postgresql/sessions.js +14 -0
  86. package/dist/app/databases/queries/sessions.js +1 -0
  87. package/dist/app/databases/register_database.js +1 -0
  88. package/dist/app/databases/sql.js +1 -0
  89. package/dist/app/email/send.js +1 -0
  90. package/dist/app/email/validate_smtp_settings.js +1 -0
  91. package/dist/app/fixture/index.js +1 -0
  92. package/dist/app/generate_machine_id.js +1 -0
  93. package/dist/app/generate_process_id.js +1 -0
  94. package/dist/app/get_ssl_certificates.js +1 -0
  95. package/dist/app/handle_process_errors.js +1 -0
  96. package/dist/app/index.js +1 -656
  97. package/dist/app/middleware/account.js +1 -0
  98. package/dist/app/middleware/body_parser.js +1 -0
  99. package/dist/app/middleware/build_error.js +1 -0
  100. package/dist/app/middleware/built_in.js +1 -0
  101. package/dist/app/middleware/context.js +1 -0
  102. package/dist/app/middleware/cors.js +1 -22
  103. package/dist/app/middleware/csp.js +1 -48
  104. package/dist/app/middleware/generate_insecure_page.js +65 -0
  105. package/dist/app/middleware/generate_joystick_error_page.js +147 -0
  106. package/dist/app/middleware/hmr_client.js +1 -0
  107. package/dist/app/middleware/insecure.js +1 -11
  108. package/dist/app/middleware/process_browser_polyfill.js +1 -0
  109. package/dist/app/middleware/render/get_url.js +1 -0
  110. package/dist/app/middleware/render/index.js +1 -0
  111. package/dist/app/middleware/request_methods.js +1 -0
  112. package/dist/app/middleware/session.js +1 -24
  113. package/dist/app/push_logs.js +1 -0
  114. package/dist/app/queues/index.js +1 -119
  115. package/dist/app/register_app_options.js +1 -0
  116. package/dist/app/routes/register_route_from_function.js +1 -0
  117. package/dist/app/routes/register_route_from_object.js +1 -0
  118. package/dist/app/routes/supported_http_methods.js +1 -0
  119. package/dist/app/settings/load.js +1 -0
  120. package/dist/app/ssr/index.js +33 -0
  121. package/dist/app/ssr/set_base_attributes_in_html.js +1 -0
  122. package/dist/app/ssr/set_head_tags_in_html.js +1 -0
  123. package/dist/app/start_express.js +1 -0
  124. package/dist/app/start_node_as_cluster.js +1 -0
  125. package/dist/app/uploaders/local_upload_progress_middleware.js +1 -0
  126. package/dist/app/uploaders/register.js +1 -0
  127. package/dist/app/uploaders/run_upload.js +1 -0
  128. package/dist/app/uploaders/validate_options.js +1 -0
  129. package/dist/app/uploaders/validate_uploads.js +1 -0
  130. package/dist/app/websockets/emit_event.js +1 -0
  131. package/dist/app/websockets/index.js +1 -0
  132. package/dist/app/websockets/register.js +1 -0
  133. package/dist/index.js +4 -76
  134. package/dist/lib/camel_pascal_to_snake.js +1 -0
  135. package/dist/lib/constants.js +1 -13
  136. package/dist/lib/dynamic_import.js +1 -0
  137. package/dist/lib/escape_html.js +1 -0
  138. package/dist/lib/escape_key_value_pair.js +1 -0
  139. package/dist/lib/float_to_decimal_place.js +1 -0
  140. package/dist/lib/generate_id.js +1 -0
  141. package/dist/lib/get_browser_safe_request.js +1 -0
  142. package/dist/lib/get_joystick_build_path.js +1 -0
  143. package/dist/lib/get_origin.js +1 -0
  144. package/dist/lib/get_platform_safe_path.js +1 -0
  145. package/dist/lib/get_sanitized_context.js +1 -0
  146. package/dist/lib/get_translations.js +1 -0
  147. package/dist/lib/hash_string.js +1 -0
  148. package/dist/lib/is_valid_json.js +1 -0
  149. package/dist/lib/log.js +13 -49
  150. package/dist/lib/node_path_polyfills.js +1 -0
  151. package/dist/lib/parse_json.js +1 -0
  152. package/dist/lib/path_exists.js +1 -0
  153. package/dist/lib/rainbow_road.js +1 -0
  154. package/dist/lib/serialize_query_parameters.js +1 -0
  155. package/dist/lib/set_cookie.js +1 -0
  156. package/dist/lib/string_to_slug.js +1 -0
  157. package/dist/lib/timestamps.js +1 -0
  158. package/dist/lib/types.js +1 -0
  159. package/dist/lib/unset_cookie.js +1 -0
  160. package/dist/lib/wait.js +1 -0
  161. package/dist/test/track_function_call.js +1 -0
  162. package/increment_version.js +3 -0
  163. package/package.json +27 -44
  164. package/src/action/class.js +137 -0
  165. package/src/action/index.js +8 -0
  166. package/src/app/accounts/default_user_output_fields.js +10 -0
  167. package/src/app/accounts/delete_user.js +18 -0
  168. package/src/app/accounts/generate_account_session.js +11 -0
  169. package/src/app/accounts/generate_password_reset_token.js +16 -0
  170. package/src/app/accounts/get_browser_safe_user.js +29 -0
  171. package/src/app/accounts/has_login_token_expired.js +9 -0
  172. package/src/app/accounts/index.js +38 -0
  173. package/src/app/accounts/login.js +82 -0
  174. package/src/app/accounts/recover_password.js +58 -0
  175. package/src/app/accounts/reset_password.js +69 -0
  176. package/src/app/accounts/roles/add.js +7 -0
  177. package/src/app/accounts/roles/grant.js +7 -0
  178. package/src/app/accounts/roles/index.js +18 -0
  179. package/src/app/accounts/roles/list.js +7 -0
  180. package/src/app/accounts/roles/remove.js +7 -0
  181. package/src/app/accounts/roles/revoke.js +7 -0
  182. package/src/app/accounts/roles/user_has_role.js +7 -0
  183. package/src/app/accounts/send_email_verification.js +48 -0
  184. package/src/app/accounts/set_account_cookie.js +12 -0
  185. package/src/app/accounts/set_password.js +46 -0
  186. package/src/app/accounts/signup.js +158 -0
  187. package/src/app/accounts/unset_account_cookie.js +12 -0
  188. package/src/app/accounts/verify_email.js +32 -0
  189. package/src/app/api/accounts/authenticated.js +17 -0
  190. package/src/app/api/accounts/login.js +36 -0
  191. package/src/app/api/accounts/logout.js +20 -0
  192. package/src/app/api/accounts/recover_password.js +16 -0
  193. package/src/app/api/accounts/reset_password.js +24 -0
  194. package/src/app/api/accounts/signup.js +49 -0
  195. package/src/app/api/accounts/user.js +21 -0
  196. package/src/app/api/accounts/verify_email.js +11 -0
  197. package/src/app/api/format_api_error.js +10 -0
  198. package/src/app/api/get.js +119 -0
  199. package/src/app/api/get_api_context.js +27 -0
  200. package/src/app/api/get_api_for_data_functions.js +37 -0
  201. package/src/app/api/get_api_url_component.js +5 -0
  202. package/src/app/api/get_output.js +116 -0
  203. package/src/app/api/get_value_from_object.js +8 -0
  204. package/src/app/api/handle_api_error.js +28 -0
  205. package/src/app/api/input_validators.js +227 -0
  206. package/src/app/api/is_array_path.js +6 -0
  207. package/src/app/api/push/health.js +17 -0
  208. package/src/app/api/register_getters.js +57 -0
  209. package/src/app/api/register_setters.js +55 -0
  210. package/src/app/api/sanitize_api_response.js +35 -0
  211. package/src/app/api/set.js +119 -0
  212. package/src/app/api/test/accounts/delete.js +8 -0
  213. package/src/app/api/test/accounts/signup.js +50 -0
  214. package/src/app/api/test/bootstrap.js +39 -0
  215. package/src/app/api/test/process.js +7 -0
  216. package/src/app/api/test/queues.js +25 -0
  217. package/src/app/api/validate_input.js +130 -0
  218. package/src/app/api/validate_session.js +20 -0
  219. package/src/app/api/validate_type.js +24 -0
  220. package/src/app/browser/hmr_client.js +196 -0
  221. package/src/app/browser/process_polyfill.js +11 -0
  222. package/src/app/cron_jobs/register.js +29 -0
  223. package/src/app/databases/database_type_map.js +6 -0
  224. package/src/app/databases/get_target_database_connection.js +25 -0
  225. package/{dist/app/databases/mongodb/availableQueryParameters.js → src/app/databases/mongodb/available_query_parameters.js} +3 -4
  226. package/src/app/databases/mongodb/build_connection_string.js +30 -0
  227. package/src/app/databases/mongodb/build_query_parameters.js +17 -0
  228. package/src/app/databases/mongodb/connect.js +42 -0
  229. package/src/app/databases/mongodb/create_indexes.js +35 -0
  230. package/src/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +18 -0
  231. package/src/app/databases/postgresql/connect.js +128 -0
  232. package/src/app/databases/postgresql/create_indexes.js +58 -0
  233. package/src/app/databases/postgresql/create_tables.js +70 -0
  234. package/src/app/databases/postgresql/handle_cleanup_queues.js +36 -0
  235. package/src/app/databases/postgresql/handle_cleanup_sessions.js +5 -0
  236. package/src/app/databases/queries/accounts.js +17 -0
  237. package/src/app/databases/queries/map.js +21 -0
  238. package/src/app/databases/queries/mongodb/accounts.js +360 -0
  239. package/src/app/databases/queries/mongodb/queues.js +164 -0
  240. package/src/app/databases/queries/mongodb/sessions.js +22 -0
  241. package/src/app/databases/queries/postgresql/accounts.js +379 -0
  242. package/src/app/databases/queries/postgresql/queues.js +294 -0
  243. package/src/app/databases/queries/postgresql/sessions.js +37 -0
  244. package/src/app/databases/queries/sessions.js +17 -0
  245. package/src/app/databases/register_database.js +30 -0
  246. package/src/app/databases/sql.js +63 -0
  247. package/src/app/email/send.js +108 -0
  248. package/src/app/email/validate_smtp_settings.js +53 -0
  249. package/src/app/fixture/index.js +50 -0
  250. package/src/app/generate_machine_id.js +26 -0
  251. package/src/app/generate_process_id.js +30 -0
  252. package/src/app/get_ssl_certificates.js +23 -0
  253. package/src/app/handle_process_errors.js +101 -0
  254. package/src/app/index.js +253 -0
  255. package/src/app/middleware/account.js +28 -0
  256. package/src/app/middleware/body_parser.js +18 -0
  257. package/src/app/middleware/build_error.js +18 -0
  258. package/src/app/middleware/built_in.js +76 -0
  259. package/src/app/middleware/context.js +34 -0
  260. package/src/app/middleware/cors.js +23 -0
  261. package/src/app/middleware/csp.js +54 -0
  262. package/src/app/middleware/generate_insecure_page.js +71 -0
  263. package/{dist/lib/generateErrorPage.js → src/app/middleware/generate_joystick_error_page.js} +25 -21
  264. package/src/app/middleware/hmr_client.js +12 -0
  265. package/src/app/middleware/insecure.js +22 -0
  266. package/src/app/middleware/process_browser_polyfill.js +12 -0
  267. package/src/app/middleware/render/get_url.js +15 -0
  268. package/src/app/middleware/render/index.js +93 -0
  269. package/src/app/middleware/request_methods.js +21 -0
  270. package/src/app/middleware/session.js +31 -0
  271. package/src/app/push_logs.js +44 -0
  272. package/src/app/queues/index.js +268 -0
  273. package/src/app/register_app_options.js +7 -0
  274. package/src/app/routes/register_route_from_function.js +10 -0
  275. package/src/app/routes/register_route_from_object.js +34 -0
  276. package/src/app/routes/supported_http_methods.js +9 -0
  277. package/src/app/settings/load.js +33 -0
  278. package/src/app/ssr/index.js +133 -0
  279. package/src/app/ssr/set_base_attributes_in_html.js +43 -0
  280. package/src/app/ssr/set_head_tags_in_html.js +104 -0
  281. package/src/app/start_express.js +50 -0
  282. package/src/app/start_node_as_cluster.js +30 -0
  283. package/src/app/uploaders/local_upload_progress_middleware.js +24 -0
  284. package/src/app/uploaders/register.js +169 -0
  285. package/src/app/uploaders/run_upload.js +136 -0
  286. package/src/app/uploaders/validate_options.js +74 -0
  287. package/src/app/uploaders/validate_uploads.js +127 -0
  288. package/src/app/websockets/emit_event.js +14 -0
  289. package/src/app/websockets/index.js +16 -0
  290. package/src/app/websockets/register.js +175 -0
  291. package/src/index.js +81 -0
  292. package/{dist/lib/camelPascalToSnake.js → src/lib/camel_pascal_to_snake.js} +3 -4
  293. package/src/lib/constants.js +21 -0
  294. package/src/lib/dynamic_import.js +8 -0
  295. package/src/lib/escape_html.js +9 -0
  296. package/src/lib/escape_key_value_pair.js +15 -0
  297. package/src/lib/float_to_decimal_place.js +5 -0
  298. package/src/lib/generate_id.js +15 -0
  299. package/src/lib/get_browser_safe_request.js +17 -0
  300. package/src/lib/get_joystick_build_path.js +22 -0
  301. package/src/lib/get_origin.js +7 -0
  302. package/src/lib/get_platform_safe_path.js +8 -0
  303. package/src/lib/get_sanitized_context.js +51 -0
  304. package/src/lib/get_translations.js +109 -0
  305. package/src/lib/hash_string.js +7 -0
  306. package/src/lib/is_valid_json.js +10 -0
  307. package/src/lib/log.js +42 -0
  308. package/src/lib/node_path_polyfills.js +23 -0
  309. package/src/lib/parse_json.js +9 -0
  310. package/src/lib/path_exists.js +12 -0
  311. package/src/lib/rainbow_road.js +7 -0
  312. package/src/lib/serialize_query_parameters.js +7 -0
  313. package/src/lib/set_cookie.js +16 -0
  314. package/src/lib/string_to_slug.js +14 -0
  315. package/src/lib/timestamps.js +48 -0
  316. package/src/lib/types.js +59 -0
  317. package/src/lib/unset_cookie.js +11 -0
  318. package/src/lib/wait.js +9 -0
  319. package/src/test/track_function_call.js +16 -0
  320. package/README.md +0 -8
  321. package/_package.json +0 -63
  322. package/canary.js +0 -12
  323. package/dist/api/get.js +0 -29
  324. package/dist/api/getOrigin.js +0 -6
  325. package/dist/api/index.js +0 -9
  326. package/dist/api/set.js +0 -29
  327. package/dist/app/accounts/defaultUserOutputFields.js +0 -9
  328. package/dist/app/accounts/generateResetToken.js +0 -28
  329. package/dist/app/accounts/generateSession.js +0 -15
  330. package/dist/app/accounts/getBrowserSafeUser.js +0 -24
  331. package/dist/app/accounts/hasLoginTokenExpired.js +0 -17
  332. package/dist/app/accounts/hashString.js +0 -7
  333. package/dist/app/accounts/recoverPassword.js +0 -30
  334. package/dist/app/accounts/resetPassword.js +0 -73
  335. package/dist/app/accounts/roles/userHasRole.js +0 -7
  336. package/dist/app/accounts/runUserQuery.js +0 -15
  337. package/dist/app/accounts/sendEmailVerification.js +0 -65
  338. package/dist/app/accounts/setAuthenticationCookie.js +0 -11
  339. package/dist/app/accounts/setPassword.js +0 -45
  340. package/dist/app/accounts/unsetAuthenticationCookie.js +0 -11
  341. package/dist/app/accounts/verifyEmail.js +0 -46
  342. package/dist/app/databases/getTargetDatabase.js +0 -10
  343. package/dist/app/databases/getTargetDatabaseConnection.js +0 -19
  344. package/dist/app/databases/getTargetDatabaseProvider.js +0 -10
  345. package/dist/app/databases/mongodb/buildConnectionString.js +0 -22
  346. package/dist/app/databases/mongodb/buildQueryParameters.js +0 -14
  347. package/dist/app/databases/mongodb/index.js +0 -40
  348. package/dist/app/databases/mongodb/queries/accounts.js +0 -266
  349. package/dist/app/databases/mongodb/queries/queues.js +0 -111
  350. package/dist/app/databases/postgresql/addColumnToTable.js +0 -6
  351. package/dist/app/databases/postgresql/createAccountsIndexes.js +0 -21
  352. package/dist/app/databases/postgresql/createAccountsTables.js +0 -39
  353. package/dist/app/databases/postgresql/createDatabase.js +0 -0
  354. package/dist/app/databases/postgresql/index.js +0 -55
  355. package/dist/app/databases/postgresql/queries/accounts.js +0 -186
  356. package/dist/app/databases/postgresql/queries/queues.js +0 -211
  357. package/dist/app/databases/queryMap.js +0 -17
  358. package/dist/app/databases/typesMap.js +0 -7
  359. package/dist/app/getAPIContext.js +0 -25
  360. package/dist/app/getAPIURLComponent.js +0 -6
  361. package/dist/app/getBrowserSafeRequest.js +0 -14
  362. package/dist/app/getOutput.js +0 -74
  363. package/dist/app/handleProcessErrors.js +0 -73
  364. package/dist/app/initExpress.js +0 -41
  365. package/dist/app/middleware/bodyParser.js +0 -16
  366. package/dist/app/middleware/hmr/client.js +0 -113
  367. package/dist/app/middleware/index.js +0 -89
  368. package/dist/app/middleware/render.js +0 -213
  369. package/dist/app/middleware/requestMethods.js +0 -19
  370. package/dist/app/registerGetters.js +0 -45
  371. package/dist/app/registerSetters.js +0 -45
  372. package/dist/app/runGetter.js +0 -103
  373. package/dist/app/runSetter.js +0 -103
  374. package/dist/app/runUploader.js +0 -143
  375. package/dist/app/sanitizeAPIResponse.js +0 -27
  376. package/dist/app/utils/process.js +0 -193
  377. package/dist/app/validateSession.js +0 -19
  378. package/dist/app/validateUploaderOptions.js +0 -53
  379. package/dist/app/validateUploads.js +0 -102
  380. package/dist/email/render.js +0 -50
  381. package/dist/email/send.js +0 -55
  382. package/dist/email/templates/base.css +0 -194
  383. package/dist/email/templates/base.html +0 -28
  384. package/dist/email/templates/reset-password.js +0 -13
  385. package/dist/email/validateSMTPSettings.js +0 -27
  386. package/dist/lib/escapeHTML.js +0 -9
  387. package/dist/lib/escapeKeyValuePair.js +0 -13
  388. package/dist/lib/formatAPIError.js +0 -12
  389. package/dist/lib/formatErrorString.js +0 -8
  390. package/dist/lib/generateCookie.js +0 -14
  391. package/dist/lib/generateId.js +0 -13
  392. package/dist/lib/generateMachineId.js +0 -15
  393. package/dist/lib/getBuildPath.js +0 -10
  394. package/dist/lib/getErrorObject.js +0 -9
  395. package/dist/lib/getPlatformSafeFilePath.js +0 -8
  396. package/dist/lib/getPlatformSafePath.js +0 -8
  397. package/dist/lib/getSSLCertificates.js +0 -19
  398. package/dist/lib/isValidHTTPMethod.js +0 -7
  399. package/dist/lib/isValidJSONString.js +0 -11
  400. package/dist/lib/nodeUrlPolyfills.js +0 -14
  401. package/dist/lib/objectToSQLKeysString.js +0 -18
  402. package/dist/lib/objectToSQLValuesString.js +0 -16
  403. package/dist/lib/obscenedb/debounce.js +0 -12
  404. package/dist/lib/obscenedb/index.js +0 -61
  405. package/dist/lib/parseDatabasesFromEnvironment.js +0 -9
  406. package/dist/lib/rainbowRoad.js +0 -7
  407. package/dist/lib/readDirectory.js +0 -24
  408. package/dist/lib/replaceBackslashesWithForwardSlashes.js +0 -8
  409. package/dist/lib/replaceFileProtocol.js +0 -8
  410. package/dist/lib/replaceForwardSlashesWithBackslashes.js +0 -8
  411. package/dist/lib/serializeQueryParameters.js +0 -8
  412. package/dist/lib/serverAvailable.js +0 -0
  413. package/dist/lib/setCookie.js +0 -16
  414. package/dist/lib/supportedHTTPMethods.js +0 -4
  415. package/dist/lib/unsetCookie.js +0 -13
  416. package/dist/push/logs/index.js +0 -55
  417. package/dist/settings/index.js +0 -5
  418. package/dist/settings/load.js +0 -30
  419. package/dist/ssr/compileCSS.js +0 -85
  420. package/dist/ssr/findComponentInTree.js +0 -29
  421. package/dist/ssr/formatCSS.js +0 -6
  422. package/dist/ssr/getCSSFromTree.js +0 -33
  423. package/dist/ssr/index.js +0 -441
  424. package/dist/ssr/replaceWhenTags.js +0 -37
  425. package/dist/ssr/setHeadTagsInHTML.js +0 -84
  426. package/dist/validation/index.js +0 -10
  427. package/dist/validation/index.test.js +0 -463
  428. package/dist/validation/inputWithSchema/index.js +0 -105
  429. package/dist/validation/lib/constants.js +0 -162
  430. package/dist/validation/lib/getValueFromObject.js +0 -12
  431. package/dist/validation/lib/getValueFromObject.test.js +0 -7
  432. package/dist/validation/lib/isArrayPath.js +0 -6
  433. package/dist/validation/lib/throwError.js +0 -6
  434. package/dist/validation/lib/typeValidators.js +0 -38
  435. package/dist/validation/lib/validateType.js +0 -33
  436. package/dist/validation/schema/index.js +0 -44
  437. package/dist/websockets/emitWebsocketEvent.js +0 -12
  438. package/dist/websockets/index.js +0 -12
  439. package/notes +0 -1
package/dist/index.js CHANGED
@@ -1,76 +1,4 @@
1
- import fs from "fs";
2
- import { fileURLToPath } from "url";
3
- import { dirname } from "path";
4
- import sanitizeHTML from "sanitize-html";
5
- import _accounts from "./app/accounts";
6
- import _action from "./action/index.js";
7
- import _websockets from "./websockets";
8
- import api from "./api/index.js";
9
- import app from "./app/index.js";
10
- import generateId from "./lib/generateId.js";
11
- import getOrigin from "./api/getOrigin";
12
- import loadSettings from "./settings/load";
13
- import pushLogs from "./push/logs/index.js";
14
- import nodeUrlPolyfills from "./lib/nodeUrlPolyfills.js";
15
- import sendEmail from "./email/send";
16
- if (process.env.NODE_ENV !== "development" && process.env.IS_PUSH_DEPLOYED) {
17
- pushLogs();
18
- }
19
- const accounts = _accounts;
20
- const action = _action;
21
- const get = api.get;
22
- const set = api.set;
23
- const email = {
24
- send: sendEmail
25
- };
26
- const websockets = _websockets;
27
- const sanitize = {
28
- defaults: {
29
- allowedTags: sanitizeHTML.defaults.allowedTags
30
- }
31
- };
32
- const currentFilePath = fileURLToPath(import.meta.url);
33
- const __package = dirname(currentFilePath);
34
- const __filename = nodeUrlPolyfills.__filename;
35
- const __dirname = nodeUrlPolyfills.__dirname;
36
- const id = generateId;
37
- const origin = getOrigin();
38
- const settings = loadSettings();
39
- global.joystick = {
40
- id: generateId,
41
- emitters: {},
42
- settings,
43
- __package,
44
- __dirname,
45
- __filename
46
- };
47
- var src_default = {
48
- __dirname,
49
- __filename,
50
- accounts,
51
- action,
52
- app,
53
- email,
54
- get,
55
- id,
56
- origin,
57
- sanitize,
58
- set,
59
- settings,
60
- websockets
61
- };
62
- export {
63
- __dirname,
64
- __filename,
65
- __package,
66
- accounts,
67
- action,
68
- src_default as default,
69
- email,
70
- get,
71
- id,
72
- origin,
73
- sanitize,
74
- set,
75
- websockets
76
- };
1
+ import i from"fs";import t from"./app/accounts/index.js";import n from"./action/index.js";import a from"./lib/escape_html.js";import p from"./app/fixture/index.js";import m from"./app/databases/sql.js";import c from"./app/api/validate_input.js";import _ from"./app/websockets/index.js";import l from"./app/index.js";import f from"./lib/generate_id.js";import u from"./lib/get_origin.js";import d from"./app/settings/load.js";import o from"./lib/node_path_polyfills.js";import e from"./lib/path_exists.js";import x from"./app/email/send.js";const{readFile:r}=i.promises,w={...t,deleteUser:t.delete_user,recoverPassword:t.recover_password,resetPassword:t.reset_password,sendEmailVerification:t.send_email_verification,setPassword:t.set_password,verifyEmail:t.verify_email},h=n,N=o.__dirname,v={send:x},g=a,O=o.__filename,k=p,y=u(),b={continent:await e("/root/push/continent.txt")?(await r("/root/push/continent.txt","utf-8"))?.replace(`
2
+ `,""):null,instance_token:await e("/root/push/instance_token.txt")?(await r("/root/push/instance_token.txt","utf-8"))?.replace(`
3
+ `,""):null,current_version:await e("/root/push/versions/current")?(await r("/root/push/versions/current","utf-8"))?.replace(`
4
+ `,""):null},P=d(),j=m,q=c,E=_,s={app:l,accounts:w,action:h,email:v,emitters:{},escape_html:g,fixture:k,id:f,origin:y,push:b,settings:P,sql:j,validate_input:q,websockets:E,...o};global.joystick=s;var Q=s;export{N as __dirname,O as __filename,w as accounts,h as action,Q as default,v as email,g as escape_html,k as fixture,y as origin,b as push,P as settings,j as sql,q as validate_input,E as websockets};
@@ -0,0 +1 @@
1
+ const r=(a="")=>a.replace(/[A-Z]/g,(e,o)=>o==0?e.toLowerCase():`_${e.toLowerCase()}`);var t=r;export{t as default};
@@ -1,13 +1 @@
1
- const HTML_ENTITY_MAP = {
2
- "&": "&",
3
- "<": "&lt;",
4
- ">": "&gt;",
5
- '"': "&quot;",
6
- "'": "&#39;",
7
- "/": "&#x2F;",
8
- "`": "&#x60;",
9
- "=": "&#x3D;"
10
- };
11
- export {
12
- HTML_ENTITY_MAP
13
- };
1
+ const o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},t=1e3,x=t*1e3,n={HTML_ENTITY_MAP:o,KILOBYTE:t,MEGABYTE:x};var s=n;export{o as HTML_ENTITY_MAP,t as KILOBYTE,x as MEGABYTE,s as default};
@@ -0,0 +1 @@
1
+ import"./get_platform_safe_path.js";const e=async(t="")=>(await(process.platform==="win32"?import(`file://${t}`):import(t)))?.default;var f=e;export{f as default};
@@ -0,0 +1 @@
1
+ import e from"./constants.js";const n=(t="")=>String(t).replace(/[&<>"'`=]/g,function(r){return e.HTML_ENTITY_MAP[r]});var c=n;export{c as default};
@@ -0,0 +1 @@
1
+ import r from"./escape_html.js";const c=(e={})=>{const l=Object.entries(e||{});for(let t=0;t<l?.length;t+=1){const[o,s]=l[t];delete e[o],e[r(o)]=r(s)}return e};var p=c;export{p as default};
@@ -0,0 +1 @@
1
+ const a=(t=0,e=2)=>parseFloat(t.toFixed(e),10);var o=a;export{o as default};
@@ -0,0 +1 @@
1
+ const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".split(""),l=(a=16)=>{let t="",e=0;for(;e<a;)t+=r[Math.floor(Math.random()*(r.length-1))],e+=1;return t};var n=l;export{n as default};
@@ -0,0 +1 @@
1
+ import s from"./escape_key_value_pair.js";import t from"../app/accounts/get_browser_safe_user.js";const a=(r={})=>{const e={};return e.headers=r.headers,e.params=s(r.params),e.query=s(r.query),e.context={user:t(r.context.user)},e};var u=a;export{u as default};
@@ -0,0 +1 @@
1
+ import e from"fs";const n=()=>["development","test"].includes(process.env.NODE_ENV)||e.existsSync(".joystick/build")?".joystick/build/":"",o=()=>{const t=n();return`${process.cwd().replace(t,"")}/${t}`};var s=o;export{s as default};
@@ -0,0 +1 @@
1
+ const e=()=>process.env.NODE_ENV==="development"?`http://localhost:${process.env.PORT}`:process.env.ROOT_URL;var o=e;export{o as default};
@@ -0,0 +1 @@
1
+ import t from"os";const e=(r="")=>t.platform()==="win32"?r.replace(/\//g,"\\"):r;var a=e;export{a as default};
@@ -0,0 +1 @@
1
+ const r=(s={})=>{const e={...s};return e?.req&&(delete e.req,e.req={method:s?.req?.method,headers:s?.req?.headers,url:s?.req?.url}),e?.res&&(delete e.res,e.res={method:s?.res?.method,headers:s?.res?.headers,url:s?.res?.url}),e.mongodb&&delete e.mongodb,e.postgresql&&delete e.postgresql,e.redis&&delete e.redis,e._users&&delete e._users,e._queues&&delete e._queues,e._sessions&&delete e._sessions,e};var d=r;export{d as default};
@@ -0,0 +1 @@
1
+ import g from"fs";import p from"./dynamic_import.js";import"./get_platform_safe_path.js";import _ from"../app/settings/load.js";import h from"./path_exists.js";import d from"./types.js";const c=_(),m=async(t="",n="",a="")=>{const r=await p(`${n}/i18n/${t}?v=${new Date().getTime()}`);if(r&&d.is_object(r)){const e=r[a];return e||r}return{}},$=(t="",n=[],a="")=>{let r=[];t&&r.push(t);const i=n?.filter(e=>!e?.includes("*"));return r.push(...i),(c?.config?.i18n?.defaultLanguage||c?.config?.i18n?.default_language)&&r.push(c?.config?.i18n?.defaultLanguage||c?.config?.i18n?.default_language),r?.flatMap(e=>{const s=[e];return e?.length===2&&s.push(`${e.substring(0,2)}-`),e?.length>2&&(s.push(`${e?.split("-")[0]}`),s.push(`${e?.split("-")[0]}-`)),s})?.map(e=>e[e.length-1]==="-"?new RegExp(a?`^${a}_${e}[A-Z]+.js`:`^${e}[A-Z]+.js`,"g"):new RegExp(a?`^${a}_${e}.js`:`^${e}.js`,"g"))},w=(t="")=>t.split(",")?.map(a=>a.split(";")[0]),b=async(t={})=>{const n=t?.is_email?`${t?.joystick_build_path}i18n/email`:`${t?.joystick_build_path}i18n`,a=await h(n)&&g.readdirSync(n)||[],r=t?.is_email?[]:w(t?.req?.headers["accept-language"]),i=$(t?.req?.context?.user?.language,r,t?.email_template_name);let e=null;for(let l=0;l<i.length;l+=1){const u=i[l],f=a.find(o=>!!o.match(u));if(f){e=f;break}}return(e?await m(e,t?.joystick_build_path,t?.render_component_path):null)||{}};var E=b;export{E as default};
@@ -0,0 +1 @@
1
+ import t from"bcrypt";const h=(r="")=>t.hashSync(r,10);var o=h;export{o as default};
@@ -0,0 +1 @@
1
+ const t=(r="")=>{try{return JSON.parse(r),!0}catch{return!1}};var e=t;export{e as default};
package/dist/lib/log.js CHANGED
@@ -1,49 +1,13 @@
1
- import chalk from "chalk";
2
- import rainbowRoad from "./rainbowRoad.js";
3
- var log_default = (message = "", options = {}) => {
4
- const colors = {
5
- info: "blue",
6
- success: "green",
7
- warning: "yellowBright",
8
- danger: "red"
9
- };
10
- const titles = {
11
- info: "\u2771 Info",
12
- success: "\u2771 Ok",
13
- warning: "\u2771 Warning",
14
- danger: "\u2771 Error"
15
- };
16
- const color = options.level ? colors[options.level] : "gray";
17
- const title = options.level ? titles[options.level] : "Log";
18
- const docs = options.docs || "https://github.com/cheatcode/joystick";
19
- console.log(`
20
- ${rainbowRoad()}
21
- `);
22
- console.log(`${chalk[color](`${title}:`)}
23
- `);
24
- console.log(`${chalk.white(message)}
25
- `);
26
- console.log(`${chalk.grey("---")}
27
- `);
28
- console.log(`${chalk.white("Relevant Documentation:")}`);
29
- console.log(`
30
- ${chalk.blue(docs)}
31
- `);
32
- console.log(`${chalk.white("Stuck? Ask a Question:")}
33
- `);
34
- console.log(`${chalk.blue("https://github.com/cheatcode/joystick/discussions")}
35
- `);
36
- if (options.tools && Array.isArray(options.tools)) {
37
- console.log(`${chalk.white("Helpful Tools:")}
38
- `);
39
- options.tools.forEach((tool) => {
40
- console.log(`${chalk.blue(`${tool.title} \u2014 ${tool.url}`)}
41
- `);
42
- });
43
- }
44
- console.log(`${rainbowRoad()}
45
- `);
46
- };
47
- export {
48
- log_default as default
49
- };
1
+ import o from"chalk";import n from"./rainbow_road.js";const i=(c="",l={})=>{const s={info:"blue",success:"green",warning:"yellowBright",danger:"red"},r={info:"\u2771 Info",success:"\u2771 Ok",warning:"\u2771 Warning",danger:"\u2771 Error"},t=l.level?s[l.level]:"gray",g=l.level?r[l.level]:"Log",a=l.docs||"https://github.com/cheatcode/joystick";console.log(`
2
+ ${n()}
3
+ `),console.log(`${o[t](`${g}:`)}
4
+ `),console.log(`${o.white(c)}
5
+ `),console.log(`${o.grey("---")}
6
+ `),console.log(`${o.white("Relevant Documentation:")}`),console.log(`
7
+ ${o.blue(a)}
8
+ `),console.log(`${o.white("Stuck? Ask a Question:")}
9
+ `),console.log(`${o.blue("http://discord.cheatcode.co")}
10
+ `),l.tools&&Array.isArray(l.tools)&&(console.log(`${o.white("Helpful Tools:")}
11
+ `),l.tools.forEach(e=>{console.log(`${o.blue(`${e.title} \u2014 ${e.url}`)}
12
+ `)})),console.log(`${n()}
13
+ `)};var h=i;export{h as default};
@@ -0,0 +1 @@
1
+ import a from"os";import{dirname as e}from"path";import{fileURLToPath as r}from"url";const i=r(import.meta.url),_=e(i),l=a.platform()==="win32",n={__package:_?.replace(l?"\\lib":"/lib",""),__filename:(t="")=>r(t),__dirname:(t="")=>{const o=r(t);return e(o)}};var f=n;export{f as default};
@@ -0,0 +1 @@
1
+ const t=(r="")=>{try{return JSON.parse(r)}catch{return{}}};var e=t;export{e as default};
@@ -0,0 +1 @@
1
+ import t from"fs";import r from"./get_platform_safe_path.js";const a=(s="")=>new Promise(e=>{t.access(r(s),t.constants.F_OK,o=>{e(!o)})});var p=a;export{p as default};
@@ -0,0 +1 @@
1
+ import e from"chalk";const r=()=>`${e.red("=")}${e.green("=")}${e.blue("=")}${e.red("=")}${e.green("=")}${e.blue("=")}`;var $=r;export{$ as default};
@@ -0,0 +1 @@
1
+ const a=(e={})=>Object.entries(e||{}).map(([r,t])=>`${r}=${t}`)?.join("&");var n=a;export{n as default};
@@ -0,0 +1 @@
1
+ const c=(e={},o="",l="",t=null)=>{if(!e||!o)return null;const n={secure:process.env.NODE_ENV!=="development",httpOnly:!0};t&&(n.expires=new Date(t)),e.cookie(o,l,n)};var s=c;export{s as default};
@@ -0,0 +1 @@
1
+ const t=(r="")=>{let e=r.toLowerCase().trim();return e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),e=e.replace(/[^a-z0-9\s-_]/g," ").trim(),e=e.replace(/[\s-]+/g,"-"),e=e.replace(/[\s_]+/g,"_"),e};var l=t;export{l as default};
@@ -0,0 +1 @@
1
+ const S={get_current_time:(n={})=>{const r=new Date().toISOString();return n?.mongodb_ttl?new Date(r):r},get_future_time:(n="",r=0,e={})=>{const t=e?.start_from?new Date(e?.start_from):new Date;switch(n){case"seconds":return t.setSeconds(t.getSeconds()+r),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();case"minutes":return t.setMinutes(t.getMinutes()+r),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();case"hours":return t.setHours(t.getHours()+r),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();case"days":return t.setHours(t.getHours()+r*24),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();default:return e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString()}},get_past_time:(n="",r=0,e={})=>{const t=e?.start_from?new Date(e?.start_from):new Date;switch(n){case"seconds":return t.setSeconds(t.getSeconds()-r),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();case"minutes":return t.setMinutes(t.getMinutes()-r),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();case"hours":return t.setHours(t.getHours()-r),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();case"days":return t.setHours(t.getHours()-r*24),e?.mongodb_ttl?new Date(t.toISOString()):t.toISOString();default:return e?.mongodb_ttl?new Date(new Date().toISOString()):new Date().toISOString()}}};var o=S;export{o as default};
@@ -0,0 +1 @@
1
+ const n=r=>!!r,t=r=>!!Array.isArray(r),s=r=>r===!0||r===!1,e=r=>Number(r)===r&&r%1!==0,o=r=>typeof r=="function",i=r=>Number(r)===r&&r%1===0,c=r=>r===null,u=r=>Number(r)===r,f=r=>!!(r&&typeof r=="object"&&!Array.isArray(r)),y=r=>typeof r=="string",_=r=>typeof r>"u",b={is_any:n,is_array:t,is_boolean:s,is_float:e,is_function:o,is_integer:i,is_null:c,is_number:u,is_object:f,is_string:y,is_undefined:_};var p=b;export{p as default};
@@ -0,0 +1 @@
1
+ const n=(e="",t={})=>{if(!e||!t)return null;t.cookie(e,null,{secure:process.env.NODE_ENV!=="development",httpOnly:!0,expires:new Date})};var l=n;export{l as default};
@@ -0,0 +1 @@
1
+ const o=(e=0)=>new Promise(t=>{setTimeout(()=>{t()},e*1e3)});var r=o;export{r as default};
@@ -0,0 +1 @@
1
+ const c=(t="",s=[])=>{process.env.NODE_ENV==="test"&&(process.test={...process.test||{},function_calls:{...process?.test?.function_calls||{},[t]:[...process?.test?.function_calls&&process?.test?.function_calls[t]||[],{called_at:new Date().toISOString(),args:s}]}})};var e=c;export{e as default};
@@ -0,0 +1,3 @@
1
+ import child_process from 'child_process';
2
+
3
+ child_process.execSync(`npm version prerelease --preid=canary`);
package/package.json CHANGED
@@ -1,62 +1,45 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
- "version": "0.0.0-canary.47",
4
3
  "type": "module",
5
- "description": "A Node.js framework for building web apps.",
4
+ "version": "0.0.0-canary.470",
5
+ "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
8
- "build": "node .build/index.js",
9
- "canary:release": "export NODE_ENV=development && npm run build && node canary.js",
10
- "production:release": "export NODE_ENV=production && npm run build && node release.js",
11
- "win:development:release": "SET NODE_ENV=development&& npm run build && node release.js",
12
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
13
- "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch --detectOpenHandles"
8
+ "build": "node ./.build/index.js",
9
+ "release": "node increment_version.js && npm run build && npm publish",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
14
11
  },
15
12
  "keywords": [],
16
13
  "author": "",
17
- "license": "SAUCR",
14
+ "license": "ISC",
18
15
  "dependencies": {
19
- "@tuskdb/node": "^0.11.0",
20
- "aws-sdk": "^2.1046.0",
21
- "bcrypt": "^5.0.1",
22
- "chalk": "^4.1.2",
16
+ "@aws-sdk/client-s3": "^3.478.0",
17
+ "@aws-sdk/lib-storage": "^3.478.0",
18
+ "bcrypt": "^5.1.1",
19
+ "chalk": "^5.3.0",
23
20
  "compression": "^1.7.4",
24
- "cookie-parser": "^1.4.5",
21
+ "cookie-parser": "^1.4.6",
25
22
  "cors": "^2.8.5",
26
- "crypto-extra": "^1.0.1",
27
- "css": "^3.0.0",
28
- "dayjs": "^1.10.7",
29
- "express": "^4.17.1",
30
- "html-to-text": "^8.0.0",
31
- "juice": "^8.0.0",
32
- "linkedom": "^0.14.12",
23
+ "express": "^4.18.2",
24
+ "html-to-text": "^9.0.5",
25
+ "juice": "^9.1.0",
26
+ "linkedom": "^0.16.4",
33
27
  "mongo-uri-tool": "^1.0.1",
34
- "mongodb": "^4.1.3",
35
- "multer": "^1.4.4",
36
- "node-cron": "^3.0.2",
37
- "node-fetch": "^3.0.0",
38
- "node-html-parser": "^5.1.0",
39
- "nodemailer": "^6.7.0",
40
- "pg": "^8.7.3",
28
+ "mongodb": "^6.3.0",
29
+ "multer": "^1.4.5-lts.1",
30
+ "node-cron": "^3.0.3",
31
+ "node-fetch": "^3.3.2",
32
+ "node-html-parser": "^6.1.11",
33
+ "nodemailer": "^6.9.7",
34
+ "pg": "^8.11.3",
35
+ "pg-escape": "^0.2.0",
41
36
  "process": "^0.11.10",
42
- "query-string": "^7.0.1",
43
- "sanitize-html": "^2.7.3",
37
+ "query-string": "^8.1.0",
44
38
  "serve-favicon": "^2.5.0",
45
- "ws": "^8.4.0"
39
+ "winston": "^3.12.0",
40
+ "ws": "^8.15.1"
46
41
  },
47
42
  "devDependencies": {
48
- "@babel/core": "^7.16.0",
49
- "@babel/preset-env": "^7.16.0",
50
- "@jest/globals": "^27.3.1",
51
- "@joystick.js/ui": "^1.0.0-beta.29",
52
- "babel-jest": "^27.3.1",
53
- "esbuild": "^0.13.9",
54
- "jest": "^27.3.1",
55
- "jest-cli": "^27.3.1",
56
- "jest-express": "^1.12.0",
57
- "jest-mock-req-res": "^1.0.2",
58
- "kill-port-process": "^3.0.1",
59
- "node-port-check": "^2.0.1",
60
- "ps-node": "^0.1.6"
43
+ "esbuild": "^0.19.9"
61
44
  }
62
45
  }
@@ -0,0 +1,137 @@
1
+ import format_api_error from "../app/api/format_api_error.js";
2
+ import track_function_call from "../test/track_function_call.js";
3
+ import types from "../lib/types.js";
4
+ import validate_input from "../app/api/validate_input.js";
5
+
6
+ class Action {
7
+ constructor(input = {}) {
8
+ this.name = input?.name;
9
+ this.config = input?.config;
10
+ this.options = input?.options;
11
+ this.steps = this._serialize_steps();
12
+
13
+ this._serialize_steps = this._serialize_steps.bind(this);
14
+ this._log_error = this._log_error.bind(this);
15
+ this.run = this.run.bind(this);
16
+ }
17
+
18
+ _serialize_steps() {
19
+ return Object.entries(this?.config?.steps || {})?.reduce(
20
+ (serialized_steps = {}, [step_name = "", step_options = {}]) => {
21
+ serialized_steps[step_name] = async (...args) => {
22
+ try {
23
+ track_function_call(`node.actions.${this?.name}.steps.${step_name}`, [
24
+ ...args,
25
+ this,
26
+ ]);
27
+
28
+ const result = await step_options?.run(...args, this);
29
+
30
+ if (types.is_function(step_options?.onSuccess) || types.is_function(step_options?.on_success)) {
31
+ (step_options.onSuccess || step_options.on_success)(result, this);
32
+ track_function_call(`node.actions.${this?.name}.steps.${step_name}.on_success`, [
33
+ result,
34
+ this,
35
+ ]);
36
+ }
37
+
38
+ return result;
39
+ } catch (exception) {
40
+ if (this.options?.logErrors || this.options?.log_errors) {
41
+ this._log_error(step_name, exception);
42
+ }
43
+
44
+ if (types.is_function(step_options.onError) || types.is_function(step_options.on_error)) {
45
+ (step_options.onError || step_options.on_error)(exception, this);
46
+ track_function_call(`node.actions.${this?.name}.steps.${step_name}.on_error`, [
47
+ exception,
48
+ this,
49
+ ]);
50
+ }
51
+ }
52
+ };
53
+
54
+ return serialized_steps;
55
+ },
56
+ {}
57
+ );
58
+ }
59
+
60
+ _log_error(location = null, exception = null) {
61
+ let path = "";
62
+
63
+ if (this.name && !location) {
64
+ path += `${this.name}`;
65
+ }
66
+
67
+ if (this.name && location) {
68
+ path += `${this.name}.${location}`;
69
+ }
70
+
71
+ console.log({ path, exception });
72
+ }
73
+
74
+ run(input = {}) {
75
+ return new Promise(async (resolve, reject) => {
76
+ try {
77
+ this.abort = (error) => {
78
+ track_function_call(`node.actions.${this?.name}.abort`, [
79
+ error,
80
+ ]);
81
+
82
+ reject(error);
83
+ throw error;
84
+ };
85
+
86
+ if (Object.keys(this?.config?.input || {})?.length > 0) {
87
+ const validation_errors = await validate_input(
88
+ input,
89
+ this?.config?.input
90
+ );
91
+
92
+ if (validation_errors?.length > 0) {
93
+ for (let i = 0; i < validation_errors?.length; i += 1) {
94
+ const error = validation_errors[i];
95
+ if (this?.options?.logErrors || this?.options?.log_errors) {
96
+ console.log(`[${this.name}.validation] ${error}`);
97
+ }
98
+ }
99
+
100
+ const formatted_validation_errors = validation_errors?.map((validation_error) => {
101
+ // NOTE: Remove period on the end so we can comma-delimit errors.
102
+ return validation_error?.substring(
103
+ 0,
104
+ validation_error.length - 1
105
+ );
106
+ })
107
+ .join(", ");
108
+
109
+ return reject(new Error(formatted_validation_errors));
110
+ }
111
+ }
112
+
113
+ track_function_call(`node.actions.${this.name}.run`, [
114
+ input || {},
115
+ this.steps,
116
+ this,
117
+ ]);
118
+
119
+ const result = await this.config?.run(input || {}, this?.steps, this);
120
+
121
+ return resolve(result);
122
+ } catch (exception) {
123
+ if (this.options?.logErrors || this?.options?.log_errors) {
124
+ this._log_error(null, exception);
125
+ }
126
+
127
+ reject(exception);
128
+ }
129
+ }).catch((error) => {
130
+ return Promise.reject(
131
+ format_api_error(error, error?.location || this.name)
132
+ );
133
+ });
134
+ }
135
+ }
136
+
137
+ export default Action;
@@ -0,0 +1,8 @@
1
+ import Action from "./class.js";
2
+
3
+ const action = (name = "", config = {}, options = {}) => {
4
+ const action_instance = new Action({ name, config, options });
5
+ return action_instance.run;
6
+ };
7
+
8
+ export default action;
@@ -0,0 +1,10 @@
1
+ const default_user_output_fields = [
2
+ // MongoDB
3
+ '_id',
4
+ 'emailAddress',
5
+ // PostgreSQL
6
+ 'user_id',
7
+ 'email_address',
8
+ ];
9
+
10
+ export default default_user_output_fields;
@@ -0,0 +1,18 @@
1
+ import accounts_query from "../databases/queries/accounts.js";
2
+ import types from "../../lib/types.js";
3
+
4
+ const delete_user = async (delete_user_options = {}) => {
5
+ await accounts_query('delete_user', { user_id: delete_user_options?.user_id });
6
+
7
+ if (
8
+ types.is_function(process.joystick?.app_options?.accounts?.events?.onDeleteUser) ||
9
+ types.is_function(process.joystick?.app_options?.accounts?.events?.on_delete_user)
10
+ ) {
11
+ (
12
+ process.joystick?.app_options?.accounts?.events?.onDeleteUser ||
13
+ process.joystick?.app_options?.accounts?.events?.on_delete_user
14
+ )(delete_user_options?.user_id);
15
+ }
16
+ };
17
+
18
+ export default delete_user;
@@ -0,0 +1,11 @@
1
+ import generate_id from "../../lib/generate_id.js";
2
+
3
+ export default () => {
4
+ const date = new Date();
5
+ date.setDate(date.getDate() + 30);
6
+
7
+ return {
8
+ token: generate_id(64),
9
+ token_expires_at: date,
10
+ };
11
+ };
@@ -0,0 +1,16 @@
1
+ /* eslint-disable consistent-return */
2
+
3
+ import generate_id from "../../lib/generate_id.js";
4
+ import accounts_query from "../databases/queries/accounts.js";
5
+
6
+ const add_reset_token_to_user = (email_address = '', token = '') => {
7
+ return accounts_query("add_password_reset_token", { email_address, token });
8
+ };
9
+
10
+ const generate_password_reset_token = async (email_address = '') => {
11
+ const token = generate_id(32);
12
+ await add_reset_token_to_user(email_address, token);
13
+ return token;
14
+ };
15
+
16
+ export default generate_password_reset_token;
@@ -0,0 +1,29 @@
1
+ import types from "../../lib/types.js";
2
+
3
+ const get_browser_safe_user = (user = null) => {
4
+ if (!user || !types.is_object(user)) {
5
+ return null;
6
+ }
7
+
8
+ const unsafe_fields = [
9
+ 'password',
10
+ 'passwordResetTokens',
11
+ 'sessions',
12
+ 'oauth',
13
+ 'verifyEmailTokens',
14
+ ];
15
+
16
+ const browser_safe_user = Object.entries(user || {}).filter(([field]) => {
17
+ return !unsafe_fields.includes(field);
18
+ }).reduce((fields, [field, value]) => {
19
+ if (!fields[field]) {
20
+ fields[field] = value;
21
+ }
22
+
23
+ return fields;
24
+ }, {});
25
+
26
+ return browser_safe_user;
27
+ };
28
+
29
+ export default get_browser_safe_user;
@@ -0,0 +1,9 @@
1
+ const has_login_token_expired = (res, token = null, token_expires_at = null) => {
2
+ if (!token || !token_expires_at) {
3
+ return true;
4
+ }
5
+
6
+ return new Date(token_expires_at) <= new Date();
7
+ };
8
+
9
+ export default has_login_token_expired;
@@ -0,0 +1,38 @@
1
+ import _set_account_cookie from "./set_account_cookie.js";
2
+ import _unset_account_cookie from "./unset_account_cookie.js";
3
+ import default_user_output_fields from "./default_user_output_fields.js";
4
+ import delete_user from './delete_user.js';
5
+ import get_browser_safe_user from "./get_browser_safe_user.js";
6
+ import login from "./login.js";
7
+ import recover_password from "./recover_password.js";
8
+ import reset_password from "./reset_password.js";
9
+ import roles from "./roles/index.js";
10
+ import send_email_verification from "./send_email_verification.js";
11
+ import set_password from "./set_password.js";
12
+ import signup from "./signup.js";
13
+ import verify_email from "./verify_email.js";
14
+
15
+ const accounts = {
16
+ _set_account_cookie,
17
+ _unset_account_cookie,
18
+ default_user_output_fields,
19
+ deleteUser: delete_user,
20
+ delete_user,
21
+ getBrowserSafeUser: get_browser_safe_user,
22
+ get_browser_safe_user,
23
+ login,
24
+ recoverPassword: recover_password,
25
+ recover_password,
26
+ resetPassword: reset_password,
27
+ reset_password,
28
+ roles,
29
+ sendEmailVerification: send_email_verification,
30
+ send_email_verification,
31
+ setPassword: set_password,
32
+ set_password,
33
+ signup,
34
+ verifyEmail: verify_email,
35
+ verify_email,
36
+ };
37
+
38
+ export default accounts;