@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.
- package/.build/getFilesToBuild.js +26 -0
- package/.build/getPlatformSafeFilePath.js +6 -0
- package/.build/getPlatformSafePath.js +6 -0
- package/.build/index.js +88 -0
- package/.build/isWindows.js +3 -0
- package/dist/action/class.js +1 -82
- package/dist/action/index.js +1 -8
- package/dist/app/accounts/default_user_output_fields.js +1 -0
- package/dist/app/accounts/delete_user.js +1 -0
- package/dist/app/accounts/generate_account_session.js +1 -0
- package/dist/app/accounts/generate_password_reset_token.js +1 -0
- package/dist/app/accounts/get_browser_safe_user.js +1 -0
- package/dist/app/accounts/has_login_token_expired.js +1 -0
- package/dist/app/accounts/index.js +1 -29
- package/dist/app/accounts/login.js +1 -59
- package/dist/app/accounts/recover_password.js +1 -0
- package/dist/app/accounts/reset_password.js +1 -0
- package/dist/app/accounts/roles/add.js +1 -7
- package/dist/app/accounts/roles/grant.js +1 -7
- package/dist/app/accounts/roles/index.js +1 -17
- package/dist/app/accounts/roles/list.js +1 -7
- package/dist/app/accounts/roles/remove.js +1 -7
- package/dist/app/accounts/roles/revoke.js +1 -7
- package/dist/app/accounts/roles/user_has_role.js +1 -0
- package/dist/app/accounts/send_email_verification.js +1 -0
- package/dist/app/accounts/set_account_cookie.js +1 -0
- package/dist/app/accounts/set_password.js +1 -0
- package/dist/app/accounts/signup.js +1 -97
- package/dist/app/accounts/unset_account_cookie.js +1 -0
- package/dist/app/accounts/verify_email.js +1 -0
- package/dist/app/api/accounts/authenticated.js +1 -0
- package/dist/app/api/accounts/login.js +1 -0
- package/dist/app/api/accounts/logout.js +1 -0
- package/dist/app/api/accounts/recover_password.js +1 -0
- package/dist/app/api/accounts/reset_password.js +1 -0
- package/dist/app/api/accounts/signup.js +1 -0
- package/dist/app/api/accounts/user.js +1 -0
- package/dist/app/api/accounts/verify_email.js +1 -0
- package/dist/app/api/format_api_error.js +1 -0
- package/dist/app/api/get.js +2 -0
- package/dist/app/api/get_api_context.js +1 -0
- package/dist/app/api/get_api_for_data_functions.js +1 -0
- package/dist/app/api/get_api_url_component.js +1 -0
- package/dist/app/api/get_output.js +1 -0
- package/dist/app/api/get_value_from_object.js +1 -0
- package/dist/app/api/handle_api_error.js +1 -0
- package/dist/app/api/input_validators.js +1 -0
- package/dist/app/api/is_array_path.js +1 -0
- package/dist/app/api/push/health.js +2 -0
- package/dist/app/api/register_getters.js +1 -0
- package/dist/app/api/register_setters.js +1 -0
- package/dist/app/api/sanitize_api_response.js +1 -0
- package/dist/app/api/set.js +2 -0
- package/dist/app/api/test/accounts/delete.js +1 -0
- package/dist/app/api/test/accounts/signup.js +1 -0
- package/dist/app/api/test/bootstrap.js +1 -0
- package/dist/app/api/test/process.js +1 -0
- package/dist/app/api/test/queues.js +1 -0
- package/dist/app/api/validate_input.js +1 -0
- package/dist/app/api/validate_session.js +1 -0
- package/dist/app/api/validate_type.js +1 -0
- package/dist/app/browser/hmr_client.js +1 -0
- package/dist/app/browser/process_polyfill.js +1 -0
- package/dist/app/cron_jobs/register.js +1 -0
- package/dist/app/databases/database_type_map.js +1 -0
- package/dist/app/databases/get_target_database_connection.js +1 -0
- package/dist/app/databases/mongodb/available_query_parameters.js +1 -0
- package/dist/app/databases/mongodb/build_connection_string.js +1 -0
- package/dist/app/databases/mongodb/build_query_parameters.js +1 -0
- package/dist/app/databases/mongodb/connect.js +6 -0
- package/dist/app/databases/mongodb/create_indexes.js +1 -0
- package/dist/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +1 -0
- package/dist/app/databases/postgresql/connect.js +30 -0
- package/dist/app/databases/postgresql/create_indexes.js +1 -0
- package/dist/app/databases/postgresql/create_tables.js +1 -0
- package/dist/app/databases/postgresql/handle_cleanup_queues.js +5 -0
- package/dist/app/databases/postgresql/handle_cleanup_sessions.js +1 -0
- package/dist/app/databases/queries/accounts.js +1 -0
- package/dist/app/databases/queries/map.js +1 -0
- package/dist/app/databases/queries/mongodb/accounts.js +1 -0
- package/dist/app/databases/queries/mongodb/queues.js +1 -0
- package/dist/app/databases/queries/mongodb/sessions.js +1 -0
- package/dist/app/databases/queries/postgresql/accounts.js +1 -0
- package/dist/app/databases/queries/postgresql/queues.js +123 -0
- package/dist/app/databases/queries/postgresql/sessions.js +14 -0
- package/dist/app/databases/queries/sessions.js +1 -0
- package/dist/app/databases/register_database.js +1 -0
- package/dist/app/databases/sql.js +1 -0
- package/dist/app/email/send.js +1 -0
- package/dist/app/email/validate_smtp_settings.js +1 -0
- package/dist/app/fixture/index.js +1 -0
- package/dist/app/generate_machine_id.js +1 -0
- package/dist/app/generate_process_id.js +1 -0
- package/dist/app/get_ssl_certificates.js +1 -0
- package/dist/app/handle_process_errors.js +1 -0
- package/dist/app/index.js +1 -656
- package/dist/app/middleware/account.js +1 -0
- package/dist/app/middleware/body_parser.js +1 -0
- package/dist/app/middleware/build_error.js +1 -0
- package/dist/app/middleware/built_in.js +1 -0
- package/dist/app/middleware/context.js +1 -0
- package/dist/app/middleware/cors.js +1 -22
- package/dist/app/middleware/csp.js +1 -48
- package/dist/app/middleware/generate_insecure_page.js +65 -0
- package/dist/app/middleware/generate_joystick_error_page.js +147 -0
- package/dist/app/middleware/hmr_client.js +1 -0
- package/dist/app/middleware/insecure.js +1 -11
- package/dist/app/middleware/process_browser_polyfill.js +1 -0
- package/dist/app/middleware/render/get_url.js +1 -0
- package/dist/app/middleware/render/index.js +1 -0
- package/dist/app/middleware/request_methods.js +1 -0
- package/dist/app/middleware/session.js +1 -24
- package/dist/app/push_logs.js +1 -0
- package/dist/app/queues/index.js +1 -119
- package/dist/app/register_app_options.js +1 -0
- package/dist/app/routes/register_route_from_function.js +1 -0
- package/dist/app/routes/register_route_from_object.js +1 -0
- package/dist/app/routes/supported_http_methods.js +1 -0
- package/dist/app/settings/load.js +1 -0
- package/dist/app/ssr/index.js +33 -0
- package/dist/app/ssr/set_base_attributes_in_html.js +1 -0
- package/dist/app/ssr/set_head_tags_in_html.js +1 -0
- package/dist/app/start_express.js +1 -0
- package/dist/app/start_node_as_cluster.js +1 -0
- package/dist/app/uploaders/local_upload_progress_middleware.js +1 -0
- package/dist/app/uploaders/register.js +1 -0
- package/dist/app/uploaders/run_upload.js +1 -0
- package/dist/app/uploaders/validate_options.js +1 -0
- package/dist/app/uploaders/validate_uploads.js +1 -0
- package/dist/app/websockets/emit_event.js +1 -0
- package/dist/app/websockets/index.js +1 -0
- package/dist/app/websockets/register.js +1 -0
- package/dist/index.js +4 -76
- package/dist/lib/camel_pascal_to_snake.js +1 -0
- package/dist/lib/constants.js +1 -13
- package/dist/lib/dynamic_import.js +1 -0
- package/dist/lib/escape_html.js +1 -0
- package/dist/lib/escape_key_value_pair.js +1 -0
- package/dist/lib/float_to_decimal_place.js +1 -0
- package/dist/lib/generate_id.js +1 -0
- package/dist/lib/get_browser_safe_request.js +1 -0
- package/dist/lib/get_joystick_build_path.js +1 -0
- package/dist/lib/get_origin.js +1 -0
- package/dist/lib/get_platform_safe_path.js +1 -0
- package/dist/lib/get_sanitized_context.js +1 -0
- package/dist/lib/get_translations.js +1 -0
- package/dist/lib/hash_string.js +1 -0
- package/dist/lib/is_valid_json.js +1 -0
- package/dist/lib/log.js +13 -49
- package/dist/lib/node_path_polyfills.js +1 -0
- package/dist/lib/parse_json.js +1 -0
- package/dist/lib/path_exists.js +1 -0
- package/dist/lib/rainbow_road.js +1 -0
- package/dist/lib/serialize_query_parameters.js +1 -0
- package/dist/lib/set_cookie.js +1 -0
- package/dist/lib/string_to_slug.js +1 -0
- package/dist/lib/timestamps.js +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/unset_cookie.js +1 -0
- package/dist/lib/wait.js +1 -0
- package/dist/test/track_function_call.js +1 -0
- package/increment_version.js +3 -0
- package/package.json +27 -44
- package/src/action/class.js +137 -0
- package/src/action/index.js +8 -0
- package/src/app/accounts/default_user_output_fields.js +10 -0
- package/src/app/accounts/delete_user.js +18 -0
- package/src/app/accounts/generate_account_session.js +11 -0
- package/src/app/accounts/generate_password_reset_token.js +16 -0
- package/src/app/accounts/get_browser_safe_user.js +29 -0
- package/src/app/accounts/has_login_token_expired.js +9 -0
- package/src/app/accounts/index.js +38 -0
- package/src/app/accounts/login.js +82 -0
- package/src/app/accounts/recover_password.js +58 -0
- package/src/app/accounts/reset_password.js +69 -0
- package/src/app/accounts/roles/add.js +7 -0
- package/src/app/accounts/roles/grant.js +7 -0
- package/src/app/accounts/roles/index.js +18 -0
- package/src/app/accounts/roles/list.js +7 -0
- package/src/app/accounts/roles/remove.js +7 -0
- package/src/app/accounts/roles/revoke.js +7 -0
- package/src/app/accounts/roles/user_has_role.js +7 -0
- package/src/app/accounts/send_email_verification.js +48 -0
- package/src/app/accounts/set_account_cookie.js +12 -0
- package/src/app/accounts/set_password.js +46 -0
- package/src/app/accounts/signup.js +158 -0
- package/src/app/accounts/unset_account_cookie.js +12 -0
- package/src/app/accounts/verify_email.js +32 -0
- package/src/app/api/accounts/authenticated.js +17 -0
- package/src/app/api/accounts/login.js +36 -0
- package/src/app/api/accounts/logout.js +20 -0
- package/src/app/api/accounts/recover_password.js +16 -0
- package/src/app/api/accounts/reset_password.js +24 -0
- package/src/app/api/accounts/signup.js +49 -0
- package/src/app/api/accounts/user.js +21 -0
- package/src/app/api/accounts/verify_email.js +11 -0
- package/src/app/api/format_api_error.js +10 -0
- package/src/app/api/get.js +119 -0
- package/src/app/api/get_api_context.js +27 -0
- package/src/app/api/get_api_for_data_functions.js +37 -0
- package/src/app/api/get_api_url_component.js +5 -0
- package/src/app/api/get_output.js +116 -0
- package/src/app/api/get_value_from_object.js +8 -0
- package/src/app/api/handle_api_error.js +28 -0
- package/src/app/api/input_validators.js +227 -0
- package/src/app/api/is_array_path.js +6 -0
- package/src/app/api/push/health.js +17 -0
- package/src/app/api/register_getters.js +57 -0
- package/src/app/api/register_setters.js +55 -0
- package/src/app/api/sanitize_api_response.js +35 -0
- package/src/app/api/set.js +119 -0
- package/src/app/api/test/accounts/delete.js +8 -0
- package/src/app/api/test/accounts/signup.js +50 -0
- package/src/app/api/test/bootstrap.js +39 -0
- package/src/app/api/test/process.js +7 -0
- package/src/app/api/test/queues.js +25 -0
- package/src/app/api/validate_input.js +130 -0
- package/src/app/api/validate_session.js +20 -0
- package/src/app/api/validate_type.js +24 -0
- package/src/app/browser/hmr_client.js +196 -0
- package/src/app/browser/process_polyfill.js +11 -0
- package/src/app/cron_jobs/register.js +29 -0
- package/src/app/databases/database_type_map.js +6 -0
- package/src/app/databases/get_target_database_connection.js +25 -0
- package/{dist/app/databases/mongodb/availableQueryParameters.js → src/app/databases/mongodb/available_query_parameters.js} +3 -4
- package/src/app/databases/mongodb/build_connection_string.js +30 -0
- package/src/app/databases/mongodb/build_query_parameters.js +17 -0
- package/src/app/databases/mongodb/connect.js +42 -0
- package/src/app/databases/mongodb/create_indexes.js +35 -0
- package/src/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +18 -0
- package/src/app/databases/postgresql/connect.js +128 -0
- package/src/app/databases/postgresql/create_indexes.js +58 -0
- package/src/app/databases/postgresql/create_tables.js +70 -0
- package/src/app/databases/postgresql/handle_cleanup_queues.js +36 -0
- package/src/app/databases/postgresql/handle_cleanup_sessions.js +5 -0
- package/src/app/databases/queries/accounts.js +17 -0
- package/src/app/databases/queries/map.js +21 -0
- package/src/app/databases/queries/mongodb/accounts.js +360 -0
- package/src/app/databases/queries/mongodb/queues.js +164 -0
- package/src/app/databases/queries/mongodb/sessions.js +22 -0
- package/src/app/databases/queries/postgresql/accounts.js +379 -0
- package/src/app/databases/queries/postgresql/queues.js +294 -0
- package/src/app/databases/queries/postgresql/sessions.js +37 -0
- package/src/app/databases/queries/sessions.js +17 -0
- package/src/app/databases/register_database.js +30 -0
- package/src/app/databases/sql.js +63 -0
- package/src/app/email/send.js +108 -0
- package/src/app/email/validate_smtp_settings.js +53 -0
- package/src/app/fixture/index.js +50 -0
- package/src/app/generate_machine_id.js +26 -0
- package/src/app/generate_process_id.js +30 -0
- package/src/app/get_ssl_certificates.js +23 -0
- package/src/app/handle_process_errors.js +101 -0
- package/src/app/index.js +253 -0
- package/src/app/middleware/account.js +28 -0
- package/src/app/middleware/body_parser.js +18 -0
- package/src/app/middleware/build_error.js +18 -0
- package/src/app/middleware/built_in.js +76 -0
- package/src/app/middleware/context.js +34 -0
- package/src/app/middleware/cors.js +23 -0
- package/src/app/middleware/csp.js +54 -0
- package/src/app/middleware/generate_insecure_page.js +71 -0
- package/{dist/lib/generateErrorPage.js → src/app/middleware/generate_joystick_error_page.js} +25 -21
- package/src/app/middleware/hmr_client.js +12 -0
- package/src/app/middleware/insecure.js +22 -0
- package/src/app/middleware/process_browser_polyfill.js +12 -0
- package/src/app/middleware/render/get_url.js +15 -0
- package/src/app/middleware/render/index.js +93 -0
- package/src/app/middleware/request_methods.js +21 -0
- package/src/app/middleware/session.js +31 -0
- package/src/app/push_logs.js +44 -0
- package/src/app/queues/index.js +268 -0
- package/src/app/register_app_options.js +7 -0
- package/src/app/routes/register_route_from_function.js +10 -0
- package/src/app/routes/register_route_from_object.js +34 -0
- package/src/app/routes/supported_http_methods.js +9 -0
- package/src/app/settings/load.js +33 -0
- package/src/app/ssr/index.js +133 -0
- package/src/app/ssr/set_base_attributes_in_html.js +43 -0
- package/src/app/ssr/set_head_tags_in_html.js +104 -0
- package/src/app/start_express.js +50 -0
- package/src/app/start_node_as_cluster.js +30 -0
- package/src/app/uploaders/local_upload_progress_middleware.js +24 -0
- package/src/app/uploaders/register.js +169 -0
- package/src/app/uploaders/run_upload.js +136 -0
- package/src/app/uploaders/validate_options.js +74 -0
- package/src/app/uploaders/validate_uploads.js +127 -0
- package/src/app/websockets/emit_event.js +14 -0
- package/src/app/websockets/index.js +16 -0
- package/src/app/websockets/register.js +175 -0
- package/src/index.js +81 -0
- package/{dist/lib/camelPascalToSnake.js → src/lib/camel_pascal_to_snake.js} +3 -4
- package/src/lib/constants.js +21 -0
- package/src/lib/dynamic_import.js +8 -0
- package/src/lib/escape_html.js +9 -0
- package/src/lib/escape_key_value_pair.js +15 -0
- package/src/lib/float_to_decimal_place.js +5 -0
- package/src/lib/generate_id.js +15 -0
- package/src/lib/get_browser_safe_request.js +17 -0
- package/src/lib/get_joystick_build_path.js +22 -0
- package/src/lib/get_origin.js +7 -0
- package/src/lib/get_platform_safe_path.js +8 -0
- package/src/lib/get_sanitized_context.js +51 -0
- package/src/lib/get_translations.js +109 -0
- package/src/lib/hash_string.js +7 -0
- package/src/lib/is_valid_json.js +10 -0
- package/src/lib/log.js +42 -0
- package/src/lib/node_path_polyfills.js +23 -0
- package/src/lib/parse_json.js +9 -0
- package/src/lib/path_exists.js +12 -0
- package/src/lib/rainbow_road.js +7 -0
- package/src/lib/serialize_query_parameters.js +7 -0
- package/src/lib/set_cookie.js +16 -0
- package/src/lib/string_to_slug.js +14 -0
- package/src/lib/timestamps.js +48 -0
- package/src/lib/types.js +59 -0
- package/src/lib/unset_cookie.js +11 -0
- package/src/lib/wait.js +9 -0
- package/src/test/track_function_call.js +16 -0
- package/README.md +0 -8
- package/_package.json +0 -63
- package/canary.js +0 -12
- package/dist/api/get.js +0 -29
- package/dist/api/getOrigin.js +0 -6
- package/dist/api/index.js +0 -9
- package/dist/api/set.js +0 -29
- package/dist/app/accounts/defaultUserOutputFields.js +0 -9
- package/dist/app/accounts/generateResetToken.js +0 -28
- package/dist/app/accounts/generateSession.js +0 -15
- package/dist/app/accounts/getBrowserSafeUser.js +0 -24
- package/dist/app/accounts/hasLoginTokenExpired.js +0 -17
- package/dist/app/accounts/hashString.js +0 -7
- package/dist/app/accounts/recoverPassword.js +0 -30
- package/dist/app/accounts/resetPassword.js +0 -73
- package/dist/app/accounts/roles/userHasRole.js +0 -7
- package/dist/app/accounts/runUserQuery.js +0 -15
- package/dist/app/accounts/sendEmailVerification.js +0 -65
- package/dist/app/accounts/setAuthenticationCookie.js +0 -11
- package/dist/app/accounts/setPassword.js +0 -45
- package/dist/app/accounts/unsetAuthenticationCookie.js +0 -11
- package/dist/app/accounts/verifyEmail.js +0 -46
- package/dist/app/databases/getTargetDatabase.js +0 -10
- package/dist/app/databases/getTargetDatabaseConnection.js +0 -19
- package/dist/app/databases/getTargetDatabaseProvider.js +0 -10
- package/dist/app/databases/mongodb/buildConnectionString.js +0 -22
- package/dist/app/databases/mongodb/buildQueryParameters.js +0 -14
- package/dist/app/databases/mongodb/index.js +0 -40
- package/dist/app/databases/mongodb/queries/accounts.js +0 -266
- package/dist/app/databases/mongodb/queries/queues.js +0 -111
- package/dist/app/databases/postgresql/addColumnToTable.js +0 -6
- package/dist/app/databases/postgresql/createAccountsIndexes.js +0 -21
- package/dist/app/databases/postgresql/createAccountsTables.js +0 -39
- package/dist/app/databases/postgresql/createDatabase.js +0 -0
- package/dist/app/databases/postgresql/index.js +0 -55
- package/dist/app/databases/postgresql/queries/accounts.js +0 -186
- package/dist/app/databases/postgresql/queries/queues.js +0 -211
- package/dist/app/databases/queryMap.js +0 -17
- package/dist/app/databases/typesMap.js +0 -7
- package/dist/app/getAPIContext.js +0 -25
- package/dist/app/getAPIURLComponent.js +0 -6
- package/dist/app/getBrowserSafeRequest.js +0 -14
- package/dist/app/getOutput.js +0 -74
- package/dist/app/handleProcessErrors.js +0 -73
- package/dist/app/initExpress.js +0 -41
- package/dist/app/middleware/bodyParser.js +0 -16
- package/dist/app/middleware/hmr/client.js +0 -113
- package/dist/app/middleware/index.js +0 -89
- package/dist/app/middleware/render.js +0 -213
- package/dist/app/middleware/requestMethods.js +0 -19
- package/dist/app/registerGetters.js +0 -45
- package/dist/app/registerSetters.js +0 -45
- package/dist/app/runGetter.js +0 -103
- package/dist/app/runSetter.js +0 -103
- package/dist/app/runUploader.js +0 -143
- package/dist/app/sanitizeAPIResponse.js +0 -27
- package/dist/app/utils/process.js +0 -193
- package/dist/app/validateSession.js +0 -19
- package/dist/app/validateUploaderOptions.js +0 -53
- package/dist/app/validateUploads.js +0 -102
- package/dist/email/render.js +0 -50
- package/dist/email/send.js +0 -55
- package/dist/email/templates/base.css +0 -194
- package/dist/email/templates/base.html +0 -28
- package/dist/email/templates/reset-password.js +0 -13
- package/dist/email/validateSMTPSettings.js +0 -27
- package/dist/lib/escapeHTML.js +0 -9
- package/dist/lib/escapeKeyValuePair.js +0 -13
- package/dist/lib/formatAPIError.js +0 -12
- package/dist/lib/formatErrorString.js +0 -8
- package/dist/lib/generateCookie.js +0 -14
- package/dist/lib/generateId.js +0 -13
- package/dist/lib/generateMachineId.js +0 -15
- package/dist/lib/getBuildPath.js +0 -10
- package/dist/lib/getErrorObject.js +0 -9
- package/dist/lib/getPlatformSafeFilePath.js +0 -8
- package/dist/lib/getPlatformSafePath.js +0 -8
- package/dist/lib/getSSLCertificates.js +0 -19
- package/dist/lib/isValidHTTPMethod.js +0 -7
- package/dist/lib/isValidJSONString.js +0 -11
- package/dist/lib/nodeUrlPolyfills.js +0 -14
- package/dist/lib/objectToSQLKeysString.js +0 -18
- package/dist/lib/objectToSQLValuesString.js +0 -16
- package/dist/lib/obscenedb/debounce.js +0 -12
- package/dist/lib/obscenedb/index.js +0 -61
- package/dist/lib/parseDatabasesFromEnvironment.js +0 -9
- package/dist/lib/rainbowRoad.js +0 -7
- package/dist/lib/readDirectory.js +0 -24
- package/dist/lib/replaceBackslashesWithForwardSlashes.js +0 -8
- package/dist/lib/replaceFileProtocol.js +0 -8
- package/dist/lib/replaceForwardSlashesWithBackslashes.js +0 -8
- package/dist/lib/serializeQueryParameters.js +0 -8
- package/dist/lib/serverAvailable.js +0 -0
- package/dist/lib/setCookie.js +0 -16
- package/dist/lib/supportedHTTPMethods.js +0 -4
- package/dist/lib/unsetCookie.js +0 -13
- package/dist/push/logs/index.js +0 -55
- package/dist/settings/index.js +0 -5
- package/dist/settings/load.js +0 -30
- package/dist/ssr/compileCSS.js +0 -85
- package/dist/ssr/findComponentInTree.js +0 -29
- package/dist/ssr/formatCSS.js +0 -6
- package/dist/ssr/getCSSFromTree.js +0 -33
- package/dist/ssr/index.js +0 -441
- package/dist/ssr/replaceWhenTags.js +0 -37
- package/dist/ssr/setHeadTagsInHTML.js +0 -84
- package/dist/validation/index.js +0 -10
- package/dist/validation/index.test.js +0 -463
- package/dist/validation/inputWithSchema/index.js +0 -105
- package/dist/validation/lib/constants.js +0 -162
- package/dist/validation/lib/getValueFromObject.js +0 -12
- package/dist/validation/lib/getValueFromObject.test.js +0 -7
- package/dist/validation/lib/isArrayPath.js +0 -6
- package/dist/validation/lib/throwError.js +0 -6
- package/dist/validation/lib/typeValidators.js +0 -38
- package/dist/validation/lib/validateType.js +0 -33
- package/dist/validation/schema/index.js +0 -44
- package/dist/websockets/emitWebsocketEvent.js +0 -12
- package/dist/websockets/index.js +0 -12
- package/notes +0 -1
package/dist/index.js
CHANGED
|
@@ -1,76 +1,4 @@
|
|
|
1
|
-
import fs from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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};
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
const HTML_ENTITY_MAP =
|
|
2
|
-
"&": "&",
|
|
3
|
-
"<": "<",
|
|
4
|
-
">": ">",
|
|
5
|
-
'"': """,
|
|
6
|
-
"'": "'",
|
|
7
|
-
"/": "/",
|
|
8
|
-
"`": "`",
|
|
9
|
-
"=": "="
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
HTML_ENTITY_MAP
|
|
13
|
-
};
|
|
1
|
+
const o={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},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 "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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};
|
package/dist/lib/wait.js
ADDED
|
@@ -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};
|
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
|
-
"
|
|
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
|
|
9
|
-
"
|
|
10
|
-
"
|
|
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": "
|
|
14
|
+
"license": "ISC",
|
|
18
15
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"aws-sdk": "^
|
|
21
|
-
"bcrypt": "^5.
|
|
22
|
-
"chalk": "^
|
|
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.
|
|
21
|
+
"cookie-parser": "^1.4.6",
|
|
25
22
|
"cors": "^2.8.5",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
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": "^
|
|
35
|
-
"multer": "^1.4.
|
|
36
|
-
"node-cron": "^3.0.
|
|
37
|
-
"node-fetch": "^3.
|
|
38
|
-
"node-html-parser": "^
|
|
39
|
-
"nodemailer": "^6.7
|
|
40
|
-
"pg": "^8.
|
|
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": "^
|
|
43
|
-
"sanitize-html": "^2.7.3",
|
|
37
|
+
"query-string": "^8.1.0",
|
|
44
38
|
"serve-favicon": "^2.5.0",
|
|
45
|
-
"
|
|
39
|
+
"winston": "^3.12.0",
|
|
40
|
+
"ws": "^8.15.1"
|
|
46
41
|
},
|
|
47
42
|
"devDependencies": {
|
|
48
|
-
"
|
|
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,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,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,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;
|