@joystick.js/node-canary 0.0.0-canary.47 → 0.0.0-canary.471
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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
|
|
4
|
+
function rreaddirSync(directory, allFiles = []) {
|
|
5
|
+
const files = fs.readdirSync(directory).map((file) => join(directory, file));
|
|
6
|
+
allFiles.push(...files);
|
|
7
|
+
files.forEach((f) => {
|
|
8
|
+
fs.statSync(f).isDirectory() && rreaddirSync(f, allFiles);
|
|
9
|
+
});
|
|
10
|
+
return allFiles;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default () => {
|
|
14
|
+
const files = rreaddirSync("./src");
|
|
15
|
+
|
|
16
|
+
const filteredFiles = files.filter((path) => {
|
|
17
|
+
return (
|
|
18
|
+
!fs.lstatSync(path).isDirectory() &&
|
|
19
|
+
!["node_modules", ".DS_Store", "src/tests"].some((excludedPath) => {
|
|
20
|
+
return path.includes(excludedPath);
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return filteredFiles;
|
|
26
|
+
};
|
package/.build/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import child_process from 'child_process';
|
|
3
|
+
import path from "path";
|
|
4
|
+
import esbuild from "esbuild";
|
|
5
|
+
import getFilesToBuild from "./getFilesToBuild.js";
|
|
6
|
+
|
|
7
|
+
const checkIfBrowserFile = (path = "") => {
|
|
8
|
+
const browserPaths = [
|
|
9
|
+
"app/browser/process_polyfill.js",
|
|
10
|
+
"app/browser/hmr_client.js"
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
return browserPaths.some((browserPath) => {
|
|
14
|
+
return path.includes(browserPath);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const buildFile = (fileToBuild) => {
|
|
19
|
+
const [_, file] = fileToBuild.split('src/');
|
|
20
|
+
const isBrowserFile = checkIfBrowserFile(file);
|
|
21
|
+
|
|
22
|
+
return esbuild
|
|
23
|
+
.build({
|
|
24
|
+
entryPoints: [`src/${file}`],
|
|
25
|
+
bundle: isBrowserFile,
|
|
26
|
+
outfile: `./dist/${file}`,
|
|
27
|
+
platform: isBrowserFile ? "browser" : "node",
|
|
28
|
+
format: "esm",
|
|
29
|
+
minify: true,
|
|
30
|
+
plugins: [],
|
|
31
|
+
})
|
|
32
|
+
.catch((error) => {
|
|
33
|
+
console.log(error);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const buildFiles = (filesToBuild = []) => {
|
|
38
|
+
return Promise.all(filesToBuild.map((file) => buildFile(file.path)));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const copyFiles = (filesToCopy = []) => {
|
|
42
|
+
filesToCopy.forEach((fileToCopy) => {
|
|
43
|
+
const [_, file] = fileToCopy.path.split("src/");
|
|
44
|
+
fs.mkdir(`./dist/${path.dirname(file)}`, { recursive: true }, (error) => {
|
|
45
|
+
if (error) {
|
|
46
|
+
console.warn(error);
|
|
47
|
+
}
|
|
48
|
+
fs.writeFileSync(`./dist/${file}`, fs.readFileSync(`src/${file}`));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const filesToBuild = getFilesToBuild();
|
|
54
|
+
|
|
55
|
+
const isNotJavaScript = (path = "") => {
|
|
56
|
+
const extension = path.split('.').pop();
|
|
57
|
+
return extension && !extension.match(/\js$/);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const files = filesToBuild.map((path) => {
|
|
61
|
+
let target = "esm";
|
|
62
|
+
|
|
63
|
+
const platformSafePath = path;
|
|
64
|
+
|
|
65
|
+
const copyPaths = [
|
|
66
|
+
"email/templates/base.html",
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const isCopyPath = isNotJavaScript(platformSafePath) || copyPaths.some((copyPath) => {
|
|
70
|
+
return path.includes(copyPath);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (isCopyPath) {
|
|
74
|
+
target = "copy";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
path: platformSafePath,
|
|
79
|
+
target,
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (fs.existsSync('dist')) {
|
|
84
|
+
child_process.execSync('rm -rf ./dist');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
copyFiles(files.filter(({ target }) => target === "copy"));
|
|
88
|
+
buildFiles(files.filter(({ target }) => target !== "copy"));
|
package/dist/action/class.js
CHANGED
|
@@ -1,82 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import validate from "../validation";
|
|
3
|
-
class Action {
|
|
4
|
-
constructor(input = {}) {
|
|
5
|
-
this.name = input?.name;
|
|
6
|
-
this.config = input?.config;
|
|
7
|
-
this.options = input?.options;
|
|
8
|
-
this.steps = this._serializeSteps();
|
|
9
|
-
this._serializeSteps = this._serializeSteps.bind(this);
|
|
10
|
-
this._logError = this._logError.bind(this);
|
|
11
|
-
this.run = this.run.bind(this);
|
|
12
|
-
}
|
|
13
|
-
_serializeSteps() {
|
|
14
|
-
return Object.entries(this?.config?.steps || {})?.reduce((serializedSteps = {}, [stepName = "", stepOptions = {}]) => {
|
|
15
|
-
serializedSteps[stepName] = async (...args) => {
|
|
16
|
-
try {
|
|
17
|
-
const result = await stepOptions?.run(...args, this);
|
|
18
|
-
if (typeof stepOptions?.onSuccess === "function") {
|
|
19
|
-
stepOptions.onSuccess(result, this);
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
} catch (exception) {
|
|
23
|
-
if (this.options?.logErrors) {
|
|
24
|
-
this._logError(stepName, exception);
|
|
25
|
-
}
|
|
26
|
-
if (typeof stepOptions?.onError === "function") {
|
|
27
|
-
stepOptions.onError(exception, this);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return serializedSteps;
|
|
32
|
-
}, {});
|
|
33
|
-
}
|
|
34
|
-
_logError(location = null, exception = null) {
|
|
35
|
-
let path = "";
|
|
36
|
-
if (this.name && !location) {
|
|
37
|
-
path += `${this.name}`;
|
|
38
|
-
}
|
|
39
|
-
if (this.name && location) {
|
|
40
|
-
path += `${this.name}.${location}`;
|
|
41
|
-
}
|
|
42
|
-
console.log({ path, exception });
|
|
43
|
-
}
|
|
44
|
-
run(input = {}) {
|
|
45
|
-
return new Promise(async (resolve, reject) => {
|
|
46
|
-
try {
|
|
47
|
-
this.abort = (error) => {
|
|
48
|
-
reject(error);
|
|
49
|
-
throw error;
|
|
50
|
-
};
|
|
51
|
-
if (Object.keys(this?.config?.input || {})?.length > 0) {
|
|
52
|
-
const validationErrors = await validate.inputWithSchema(input, this?.config?.input);
|
|
53
|
-
if (validationErrors?.length > 0) {
|
|
54
|
-
for (let i = 0; i < validationErrors?.length; i += 1) {
|
|
55
|
-
const error = validationErrors[i];
|
|
56
|
-
if (this?.options?.logErrors) {
|
|
57
|
-
console.log(`[${this.name}.validation] ${error}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const formattedValidationErrors = validationErrors?.map((validationError) => {
|
|
61
|
-
return validationError?.substring(0, validationError.length - 1);
|
|
62
|
-
}).join(", ");
|
|
63
|
-
return reject(new Error(formattedValidationErrors));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const result = await this.config?.run(input || {}, this?.steps, this);
|
|
67
|
-
return resolve(result);
|
|
68
|
-
} catch (exception) {
|
|
69
|
-
if (this.options?.logErrors) {
|
|
70
|
-
this._logError(null, exception);
|
|
71
|
-
}
|
|
72
|
-
reject(exception);
|
|
73
|
-
}
|
|
74
|
-
}).catch((error) => {
|
|
75
|
-
return Promise.reject(formatAPIError(error, error?.location || this.name));
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
var class_default = Action;
|
|
80
|
-
export {
|
|
81
|
-
class_default as default
|
|
82
|
-
};
|
|
1
|
+
import l from"../app/api/format_api_error.js";import e from"../test/track_function_call.js";import h from"../lib/types.js";import u from"../app/api/validate_input.js";class f{constructor(i={}){this.name=i?.name,this.config=i?.config,this.options=i?.options,this.steps=this._serialize_steps(),this._serialize_steps=this._serialize_steps.bind(this),this._log_error=this._log_error.bind(this),this.run=this.run.bind(this)}_serialize_steps(){return Object.entries(this?.config?.steps||{})?.reduce((i={},[r="",s={}])=>(i[r]=async(...o)=>{try{e(`node.actions.${this?.name}.steps.${r}`,[...o,this]);const t=await s?.run(...o,this);return(h.is_function(s?.onSuccess)||h.is_function(s?.on_success))&&((s.onSuccess||s.on_success)(t,this),e(`node.actions.${this?.name}.steps.${r}.on_success`,[t,this])),t}catch(t){(this.options?.logErrors||this.options?.log_errors)&&this._log_error(r,t),(h.is_function(s.onError)||h.is_function(s.on_error))&&((s.onError||s.on_error)(t,this),e(`node.actions.${this?.name}.steps.${r}.on_error`,[t,this]))}},i),{})}_log_error(i=null,r=null){let s="";this.name&&!i&&(s+=`${this.name}`),this.name&&i&&(s+=`${this.name}.${i}`),console.log({path:s,exception:r})}run(i={}){return new Promise(async(r,s)=>{try{if(this.abort=t=>{throw e(`node.actions.${this?.name}.abort`,[t]),s(t),t},Object.keys(this?.config?.input||{})?.length>0){const t=await u(i,this?.config?.input);if(t?.length>0){for(let n=0;n<t?.length;n+=1){const a=t[n];(this?.options?.logErrors||this?.options?.log_errors)&&console.log(`[${this.name}.validation] ${a}`)}const c=t?.map(n=>n?.substring(0,n.length-1)).join(", ");return s(new Error(c))}}e(`node.actions.${this.name}.run`,[i||{},this.steps,this]);const o=await this.config?.run(i||{},this?.steps,this);return r(o)}catch(o){(this.options?.logErrors||this?.options?.log_errors)&&this._log_error(null,o),s(o)}}).catch(r=>Promise.reject(l(r,r?.location||this.name)))}}var b=f;export{b as default};
|
package/dist/action/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var action_default = (name = "", config = {}, options = {}) => {
|
|
3
|
-
const action = new Action({ name, config, options });
|
|
4
|
-
return action.run;
|
|
5
|
-
};
|
|
6
|
-
export {
|
|
7
|
-
action_default as default
|
|
8
|
-
};
|
|
1
|
+
import c from"./class.js";const i=(n="",t={},o={})=>new c({name:n,config:t,options:o}).run;var r=i;export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=["_id","emailAddress","user_id","email_address"];var d=e;export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../databases/queries/accounts.js";import s from"../../lib/types.js";const t=async(e={})=>{await o("delete_user",{user_id:e?.user_id}),(s.is_function(process.joystick?.app_options?.accounts?.events?.onDeleteUser)||s.is_function(process.joystick?.app_options?.accounts?.events?.on_delete_user))&&(process.joystick?.app_options?.accounts?.events?.onDeleteUser||process.joystick?.app_options?.accounts?.events?.on_delete_user)(e?.user_id)};var p=t;export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"../../lib/generate_id.js";var r=()=>{const e=new Date;return e.setDate(e.getDate()+30),{token:t(64),token_expires_at:e}};export{r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../../lib/generate_id.js";import o from"../databases/queries/accounts.js";const n=(t="",e="")=>o("add_password_reset_token",{email_address:t,token:e}),s=async(t="")=>{const e=r(32);return await n(t,e),e};var d=s;export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"../../lib/types.js";const u=(s=null)=>{if(!s||!n.is_object(s))return null;const t=["password","passwordResetTokens","sessions","oauth","verifyEmailTokens"];return Object.entries(s||{}).filter(([e])=>!t.includes(e)).reduce((e,[r,o])=>(e[r]||(e[r]=o),e),{})};var f=u;export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=(t,n=null,e=null)=>!n||!e?!0:new Date(e)<=new Date;var l=r;export{l as default};
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _unsetAuthenticationCookie from "./unsetAuthenticationCookie.js";
|
|
3
|
-
import defaultUserOutputFields from "./defaultUserOutputFields";
|
|
4
|
-
import getBrowserSafeUser from "./getBrowserSafeUser";
|
|
5
|
-
import login from "./login";
|
|
6
|
-
import recoverPassword from "./recoverPassword";
|
|
7
|
-
import resetPassword from "./resetPassword";
|
|
8
|
-
import roles from "./roles";
|
|
9
|
-
import sendEmailVerification from "./sendEmailVerification";
|
|
10
|
-
import setPassword from "./setPassword";
|
|
11
|
-
import signup from "./signup";
|
|
12
|
-
import verifyEmail from "./verifyEmail.js";
|
|
13
|
-
var accounts_default = {
|
|
14
|
-
_setAuthenticationCookie,
|
|
15
|
-
_unsetAuthenticationCookie,
|
|
16
|
-
defaultUserOutputFields,
|
|
17
|
-
getBrowserSafeUser,
|
|
18
|
-
login,
|
|
19
|
-
recoverPassword,
|
|
20
|
-
resetPassword,
|
|
21
|
-
roles,
|
|
22
|
-
sendEmailVerification,
|
|
23
|
-
setPassword,
|
|
24
|
-
signup,
|
|
25
|
-
verifyEmail
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
accounts_default as default
|
|
29
|
-
};
|
|
1
|
+
import f from"./set_account_cookie.js";import a from"./unset_account_cookie.js";import p from"./default_user_output_fields.js";import r from"./delete_user.js";import o from"./get_browser_safe_user.js";import _ from"./login.js";import e from"./recover_password.js";import t from"./reset_password.js";import c from"./roles/index.js";import s from"./send_email_verification.js";import i from"./set_password.js";import d from"./signup.js";import m from"./verify_email.js";const u={_set_account_cookie:f,_unset_account_cookie:a,default_user_output_fields:p,deleteUser:r,delete_user:r,getBrowserSafeUser:o,get_browser_safe_user:o,login:_,recoverPassword:e,recover_password:e,resetPassword:t,reset_password:t,roles:c,sendEmailVerification:s,send_email_verification:s,setPassword:i,set_password:i,signup:d,verifyEmail:m,verify_email:m};var S=u;export{S as default};
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
import bcrypt from "
|
|
2
|
-
import formatErrorString from "../../lib/formatErrorString";
|
|
3
|
-
import runUserQuery from "./runUserQuery";
|
|
4
|
-
import generateSession from "./generateSession";
|
|
5
|
-
import getOutput from "../getOutput";
|
|
6
|
-
const addSessionToUser = (userId = null, session = null) => {
|
|
7
|
-
try {
|
|
8
|
-
return runUserQuery("addSession", { userId, session });
|
|
9
|
-
} catch (error) {
|
|
10
|
-
throw new Error(formatErrorString("login.addSessionToUser", error));
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const deleteOldSessions = (userId = null) => {
|
|
14
|
-
try {
|
|
15
|
-
return runUserQuery("deleteOldSessions", { userId });
|
|
16
|
-
} catch (error) {
|
|
17
|
-
throw new Error(formatErrorString("login.deleteOldSessions", error));
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const checkIfValidPassword = (passwordFromLogin = null, passwordHashFromUser = null) => {
|
|
21
|
-
try {
|
|
22
|
-
return bcrypt.compareSync(passwordFromLogin, passwordHashFromUser);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
throw new Error(formatErrorString("login.checkIfValidPassword", error));
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const login = async (options, { resolve, reject }) => {
|
|
28
|
-
try {
|
|
29
|
-
const user = await runUserQuery("user", {
|
|
30
|
-
emailAddress: options.emailAddress,
|
|
31
|
-
username: options.username
|
|
32
|
-
});
|
|
33
|
-
if (!user) {
|
|
34
|
-
throw new Error(`A user with the ${options.emailAddress ? "email address" : "username"} ${options.emailAddress || options.username} could not be found.`);
|
|
35
|
-
}
|
|
36
|
-
const isValidPassword = checkIfValidPassword(options.password, user.password);
|
|
37
|
-
if (!isValidPassword) {
|
|
38
|
-
return reject("Incorrect password.");
|
|
39
|
-
}
|
|
40
|
-
await deleteOldSessions(user?._id || user?.user_id);
|
|
41
|
-
const session = await generateSession();
|
|
42
|
-
await addSessionToUser(user?._id || user?.user_id, session);
|
|
43
|
-
const { password, sessions, ...restOfUser } = user;
|
|
44
|
-
return resolve({
|
|
45
|
-
...session,
|
|
46
|
-
user: getOutput({
|
|
47
|
-
...restOfUser
|
|
48
|
-
}, options?.output)
|
|
49
|
-
});
|
|
50
|
-
} catch (error) {
|
|
51
|
-
reject(new Error(formatErrorString("login", error)));
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var login_default = (options) => new Promise((resolve, reject) => {
|
|
55
|
-
login(options, { resolve, reject });
|
|
56
|
-
});
|
|
57
|
-
export {
|
|
58
|
-
login_default as default
|
|
59
|
-
};
|
|
1
|
+
import i from"bcrypt";import t from"../databases/queries/accounts.js";import c from"./generate_account_session.js";import d from"../api/get_output.js";import n from"../../lib/types.js";const u=(s=null,e=null)=>t("add_session",{user_id:s,session:e}),_=(s=null)=>t("get_existing_session",{user_id:s}),p=(s=null)=>t("delete_old_sessions",{user_id:s}),l=(s=null,e=null)=>i.compareSync(s,e),m=async(s={})=>{const e=await t("user",{email_address:s.email_address||s.emailAddress,username:s.username});if(!e)throw new Error(`A user with the ${s.email_address||s.emailAddress?"email address":"username"} ${s.email_address||s.emailAddress||s.username} could not be found.`);if(!l(s.password,e.password))throw new Error("Incorrect password.");const o=e?._id||e?.user_id;await p(o);let r=await _(o);r||(r=c(),await u(o,r));const{password:f,sessions:y,...a}=e;return(n.is_function(process.joystick?.app_options?.accounts?.events?.onLogin)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_login))&&(process.joystick?.app_options?.accounts?.events?.onLogin||process.joystick?.app_options?.accounts?.events?.on_login)({...r,user:e}),{...r,user:d({...a},s?.output)}};var x=m;export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../databases/queries/accounts.js";import n from"./generate_password_reset_token.js";import i from"../settings/load.js";import d from"../email/send.js";import r from"../../lib/types.js";const c=i(),m=(e="")=>o("get_password_reset_token",{user_id:e}),l=(e="")=>o("user",{email_address:e}),u=async(e={})=>{const s=await l(e?.email_address||e?.emailAddress);if(!s)throw new Error(`A user with the email address ${e?.email_address||e?.emailAddress} could not be found.`);const t=await m(s?._id||s?.user_id)||await n(e.email_address||e.emailAddress),a=`${process.env.ROOT_URL||`http://localhost:${process.env.PORT}`}/reset-password/${t}`;return process.env.NODE_ENV==="development"&&console.log(`Reset Password URL: ${a}`),(r.is_function(process.joystick?.app_options?.accounts?.events?.onRecoverPassword)||r.is_function(process.joystick?.app_options?.accounts?.events?.on_recover_password))&&(process.joystick?.app_options?.accounts?.events?.onRecoverPassword||process.joystick?.app_options?.accounts?.events?.on_recover_password)(e?.email_address||e?.emailAddress),await d({to:e.email_address||e?.emailAddress,from:c?.config?.email?.from,subject:"Reset Your Password",template:"reset_password",props:{email_address:e.email_address||e?.emailAddress,url:a}}),t};var y=u;export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../databases/queries/accounts.js";import _ from"./generate_account_session.js";import a from"../api/get_output.js";import i from"../../lib/hash_string.js";import n from"../../lib/types.js";const u=(s=null,e=null)=>o("remove_reset_token",{user_id:s,token:e}),c=(s=null,e=null)=>o("add_session",{user_id:s,session:e}),p=async(s="",e="")=>{const t=i(e);return await o("set_new_password",{user_id:s,hashed_password:t}),t},d=(s="")=>o("reset_user_sessions",{user_id:s}),w=(s="")=>o("user_with_reset_token",{"passwordResetTokens.token":s}),k=async(s={})=>{const e=await w(s.token);if(!e)throw new Error("Invalid password reset token.");await d(e?._id||e?.user_id),await p(e?._id||e?.user_id,s.password);const t=await u(e?._id||e?.user_id,s.token),r=_();return await c(t?._id||t?.user_id,r),(n.is_function(process.joystick?.app_options?.accounts?.events?.onResetPassword)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_reset_password))&&(process.joystick?.app_options?.accounts?.events?.onResetPassword||process.joystick?.app_options?.accounts?.events?.on_reset_password)({user:t,...r}),{user:a(t,s?.output),...r}};var v=k;export{v as default};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var add_default = (role = "") => {
|
|
3
|
-
return runUserQuery("addRole", { role });
|
|
4
|
-
};
|
|
5
|
-
export {
|
|
6
|
-
add_default as default
|
|
7
|
-
};
|
|
1
|
+
import o from"../../databases/queries/accounts.js";const t=(r="")=>o("add_role",{role:r});var e=t;export{e as default};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var grant_default = (userId = "", role = "") => {
|
|
3
|
-
return runUserQuery("grantRole", { userId, role });
|
|
4
|
-
};
|
|
5
|
-
export {
|
|
6
|
-
grant_default as default
|
|
7
|
-
};
|
|
1
|
+
import o from"../../databases/queries/accounts.js";const e=(r="",t="")=>o("grant_role",{user_id:r,role:t});var a=e;export{a as default};
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
import add from "./
|
|
2
|
-
import remove from "./remove";
|
|
3
|
-
import list from "./list";
|
|
4
|
-
import grant from "./grant";
|
|
5
|
-
import revoke from "./revoke";
|
|
6
|
-
import userHasRole from "./userHasRole";
|
|
7
|
-
var roles_default = {
|
|
8
|
-
add,
|
|
9
|
-
remove,
|
|
10
|
-
list,
|
|
11
|
-
grant,
|
|
12
|
-
revoke,
|
|
13
|
-
userHasRole
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
roles_default as default
|
|
17
|
-
};
|
|
1
|
+
import o from"./add.js";import m from"./remove.js";import e from"./list.js";import t from"./grant.js";import f from"./revoke.js";import r from"./user_has_role.js";const i={add:o,remove:m,list:e,grant:t,revoke:f,userHasRole:r,user_has_role:r};var n=i;export{n as default};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var list_default = (role = "") => {
|
|
3
|
-
return runUserQuery("listRoles");
|
|
4
|
-
};
|
|
5
|
-
export {
|
|
6
|
-
list_default as default
|
|
7
|
-
};
|
|
1
|
+
import t from"../../databases/queries/accounts.js";const r=()=>t("list_roles");var e=r;export{e as default};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var remove_default = (role = "") => {
|
|
3
|
-
return runUserQuery("removeRole", { role });
|
|
4
|
-
};
|
|
5
|
-
export {
|
|
6
|
-
remove_default as default
|
|
7
|
-
};
|
|
1
|
+
import r from"../../databases/queries/accounts.js";const o=(e="")=>r("remove_role",{role:e});var m=o;export{m as default};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var revoke_default = (userId = "", role = "") => {
|
|
3
|
-
return runUserQuery("revokeRole", { userId, role });
|
|
4
|
-
};
|
|
5
|
-
export {
|
|
6
|
-
revoke_default as default
|
|
7
|
-
};
|
|
1
|
+
import o from"../../databases/queries/accounts.js";const t=(e="",r="")=>o("revoke_role",{user_id:e,role:r});var c=t;export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../../databases/queries/accounts.js";const s=(r="",e="")=>o("user_has_role",{user_id:r,role:e});var u=s;export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../databases/queries/accounts.js";import o from"../settings/load.js";import a from"../email/send.js";const n=(e="",i="")=>{const t=o();return a({to:e,from:t?.config?.email?.from,subject:t?.config?.email?.verify?.subject||"Verify your email address",template:t?.config?.email?.verify?.template||"verify_email",props:{emailAddress:e,email_address:e,url:process.env.NODE_ENV==="development"?`http://localhost:${process.env.PORT}/api/_accounts/verify_email?token=${i}`:`${process.env.ROOT_URL}/api/_accounts/verify_email?token=${i}`}})},s=(e="")=>r("create_email_verification_token",{user_id:e}),c=(e="")=>r("user",{_id:e}),m=async(e="")=>{const i=await c(e);if(!i?.emailVerified&&!i?.emailVerifiedAt){const t=await s(i?._id||i?.user_id);await n(i?.emailAddress,t)}return!0};var u=m;export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import _ from"../../lib/set_cookie.js";const k=(o=null,e=null)=>!o||!e?null:(_(o,"joystick_login_token",e.token,e.token_expires_at),_(o,"joystick_login_token_expires_at",e.token_expires_at,e.token_expires_at),o);var t=k;export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../databases/queries/accounts.js";import n from"../../lib/hash_string.js";import t from"../../lib/types.js";const i=(s=null)=>e("reset_user_sessions",{user_id:s}),a=async(s="",r="")=>{const o=n(r);return await e("set_new_password",{user_id:s,hashed_password:o}),o},u=(s="")=>e("user",{_id:s}),c=async(s={})=>{if(!s?.user_id||!s?.password)throw new Error("Must provider a user_id and password to set.");const r=await u(s?.user_id);if(!r)throw new Error("Invalid user_id.");return await a(r?._id||r?.user_id,s?.password),await i(r?._id||r?.user_id),(t.is_function(process.joystick?.app_options?.accounts?.events?.onSetPassword)||t.is_function(process.joystick?.app_options?.accounts?.events?.on_set_password))&&(process.joystick?.app_options?.accounts?.events?.onSetPassword||process.joystick?.app_options?.accounts?.events?.on_set_password)(s?.user_id),!0};var w=c;export{w as default};
|
|
@@ -1,97 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import generateSession from "./generateSession";
|
|
3
|
-
import formatErrorString from "../../lib/formatErrorString";
|
|
4
|
-
import runUserQuery from "./runUserQuery";
|
|
5
|
-
import { isObject } from "../../validation/lib/typeValidators";
|
|
6
|
-
import getOutput from "../getOutput";
|
|
7
|
-
import typesMap from "../databases/typesMap";
|
|
8
|
-
import getTargetDatabaseProvider from "../databases/getTargetDatabaseProvider.js";
|
|
9
|
-
const addSessionToUser = (userId = null, session = null) => {
|
|
10
|
-
try {
|
|
11
|
-
return runUserQuery("addSession", { userId, session });
|
|
12
|
-
} catch (error) {
|
|
13
|
-
throw new Error(formatErrorString("signup.addSessionToUser", error));
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const getUserByUserId = (userId = "") => {
|
|
17
|
-
try {
|
|
18
|
-
return runUserQuery("user", { _id: userId });
|
|
19
|
-
} catch (exception) {
|
|
20
|
-
throw new Error(formatErrorString("signup.getUserByUserId", exception));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const insertUserInDatabase = async (user = {}) => {
|
|
24
|
-
try {
|
|
25
|
-
return runUserQuery("createUser", user);
|
|
26
|
-
} catch (exception) {
|
|
27
|
-
throw new Error(formatErrorString("signup.insertUserInDatabase", exception));
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const getUserToCreate = async (options = {}) => {
|
|
31
|
-
try {
|
|
32
|
-
const usersDatabase = getTargetDatabaseProvider("users");
|
|
33
|
-
const usersDatabaseType = typesMap[usersDatabase];
|
|
34
|
-
let user = {
|
|
35
|
-
password: await hashString(options.password)
|
|
36
|
-
};
|
|
37
|
-
if (options?.emailAddress) {
|
|
38
|
-
user.emailAddress = options?.emailAddress;
|
|
39
|
-
}
|
|
40
|
-
if (options?.username) {
|
|
41
|
-
user.username = options?.username;
|
|
42
|
-
}
|
|
43
|
-
if (options?.metadata && isObject(options.metadata) && usersDatabaseType === "sql" && options?.metadata?.language) {
|
|
44
|
-
user.language = options?.metadata?.language;
|
|
45
|
-
}
|
|
46
|
-
if (options?.metadata && isObject(options.metadata) && usersDatabaseType === "nosql") {
|
|
47
|
-
user = {
|
|
48
|
-
...options.metadata,
|
|
49
|
-
...user
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return user;
|
|
53
|
-
} catch (exception) {
|
|
54
|
-
throw new Error(formatErrorString("signup.getUserToCreate", exception));
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const getExistingUser = (emailAddress = "", username = "") => {
|
|
58
|
-
try {
|
|
59
|
-
return runUserQuery("existingUser", { emailAddress, username });
|
|
60
|
-
} catch (exception) {
|
|
61
|
-
throw new Error(formatErrorString("signup.getExistingUser", exception));
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const signup = async (options, { resolve, reject }) => {
|
|
65
|
-
try {
|
|
66
|
-
if (!options.emailAddress) {
|
|
67
|
-
return reject("Email address is required.");
|
|
68
|
-
}
|
|
69
|
-
if (!options.password) {
|
|
70
|
-
return reject("Password is required.");
|
|
71
|
-
}
|
|
72
|
-
const existingUser = await getExistingUser(options.emailAddress, options.metadata?.username);
|
|
73
|
-
if (existingUser) {
|
|
74
|
-
throw new Error(`A user with the ${existingUser.existingUsername ? "username" : "email address"} ${existingUser.existingUsername || existingUser.existingEmailAddress} already exists.`);
|
|
75
|
-
}
|
|
76
|
-
const userToCreate = await getUserToCreate(options);
|
|
77
|
-
const userId = await insertUserInDatabase(userToCreate);
|
|
78
|
-
const user = await getUserByUserId(userId);
|
|
79
|
-
const session = generateSession();
|
|
80
|
-
if (user?._id || user?.user_id) {
|
|
81
|
-
await addSessionToUser(user._id || user?.user_id, session);
|
|
82
|
-
}
|
|
83
|
-
return resolve({
|
|
84
|
-
...session,
|
|
85
|
-
userId,
|
|
86
|
-
user: getOutput(user, options?.output)
|
|
87
|
-
});
|
|
88
|
-
} catch (exception) {
|
|
89
|
-
reject(new Error(formatErrorString("signup", exception)));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
var signup_default = (options) => new Promise((resolve, reject) => {
|
|
93
|
-
signup(options, { resolve, reject });
|
|
94
|
-
});
|
|
95
|
-
export {
|
|
96
|
-
signup_default as default
|
|
97
|
-
};
|
|
1
|
+
import i from"../databases/queries/accounts.js";import m from"../../lib/camel_pascal_to_snake.js";import u from"../databases/postgresql/accounts/create_accounts_metadata_table_columns.js";import l from"../databases/database_type_map.js";import f from"./generate_account_session.js";import w from"../api/get_output.js";import y from"../databases/get_target_database_connection.js";import g from"../../lib/hash_string.js";import p from"./roles/index.js";import n from"../../lib/types.js";const b=(e=null,s=null)=>i("add_session",{user_id:e,session:s}),h=(e="")=>i("user",{_id:e}),x=async(e={})=>i("create_user",e),_=(e={})=>Object.entries(e||{}).reduce((s={},[r,a])=>(s[m(r)]=a,s),{}),E=async(e={})=>{const s=y("users"),r=l[s?.provider];let a={password:g(e.password)};if((e?.email_address||e?.emailAddress)&&(a.emailAddress=e?.email_address||e.emailAddress),e?.username&&(a.username=e?.username),e?.metadata&&n.is_object(e.metadata)&&r==="sql"){const t=_(e.metadata);await u(s,t);const d={...e?.metadata||{}};d?.roles&&delete d.roles,a={..._(d),...a}}if(e?.metadata&&n.is_object(e.metadata)&&r==="nosql"){let t={...e?.metadata||{}};t?.roles&&delete t.roles,a={...t||{},...a}}return a},j=(e="",s="")=>i("existing_user",{email_address:e,username:s}),v=async(e={})=>{if(!e.email_address&&!e.emailAddress)throw new Error("Email address is required.");if(!e.password)throw new Error("Password is required.");const s=await j(e.email_address||e.emailAddress,e?.username);if(s&&process.env.NODE_ENV!=="test")throw new Error(`A user with the ${s.existing_username?"username":"email address"} ${s.existing_username||s.existing_email_address} already exists.`);let r,a=s?._id||s?.user_id;s||(r=await E(e),a=await x(r));const t=await h(a),d=f();if(a&&await b(a,d),e?.metadata?.roles?.length>0&&process.env.NODE_ENV==="test")for(let o=0;o<e?.metadata?.roles?.length;o+=1){const c=e?.metadata?.roles[o];p.grant(t?.user_id,c)}return(n.is_function(process.joystick?.app_options?.accounts?.events?.onSignup)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_signup))&&(process.joystick?.app_options?.accounts?.events?.onSignup||process.joystick?.app_options?.accounts?.events?.on_signup)({...d,user_id:a,userId:a,user:t}),{...d,userId:a,user_id:a,user:w(t,e?.output)}};var z=v;export{z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"../../lib/unset_cookie.js";const n=(o=null)=>o?(t("joystick_login_token",o),t("joystick_login_token_expires_at",o),o):null;var i=n;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../databases/queries/accounts.js";const r=(t="",e="")=>o("mark_email_verified_at",{user_id:t,token:e}),i=(t="")=>o("user_with_verify_email_token",{token:t}),n=async(t={})=>{const e=await i(t?.token);if(!e)throw new Error("A user with this token could not be found.");return await r(e?._id||e?.user_id,t?.token),typeof process.joystick?.app_options?.accounts?.events?.onVerifyEmail=="function"&&process.joystick?.app_options?.accounts?.events?.onVerifyEmail(e?.emailAddress||e?.email_address),!0};var a=n;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"../../accounts/has_login_token_expired.js";const s=(t={},o={})=>{const e=n(o,t?.cookies?.joystick_login_token,t?.cookies?.joystick_login_token_expires_at),i=e?401:200;return o.status(i).send(JSON.stringify({status:i,authenticated:!e}))};var a=s;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"../../accounts/index.js";import i from"../../accounts/default_user_output_fields.js";import r from"../handle_api_error.js";const a=async(t={},e={})=>{try{const o=await n.login({email_address:t?.body?.emailAddress||t?.body?.email_address,username:t?.body?.username,password:t?.body?.password,output:t?.body?.output||i});process.env.NODE_ENV!=="test"&&n._set_account_cookie(e,{token:o?.token,token_expires_at:o?.token_expires_at||o?.tokenExpiresAt});const s={...o?.user||{}};process.env.NODE_ENV==="test"&&(s.joystick_token=o?.token,s.joystick_login_token_expires_at=o?.token_expires_at),e.status(200).send(JSON.stringify(s))}catch(o){r("accounts.login",o,e)}};var c=a;export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"../../accounts/index.js";import t from"../../../lib/types.js";const c=(s={},o={})=>{n._unset_account_cookie(o),(t.is_function(process?.joystick?.app_options?.accounts?.events?.onLogout)||t.is_function(process?.joystick?.app_options?.accounts?.events?.on_logout))&&(process?.joystick?.app_options?.accounts?.events?.onLogout||process?.joystick?.app_options?.accounts?.events?.on_logout)(s?.context?.user),o.status(200).send(JSON.stringify({}))};var i=c;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../../accounts/index.js";import e from"../handle_api_error.js";const d=async(r={},s={})=>{try{await o.recover_password({email_address:r?.body?.emailAddress||r?.body?.email_address}),s.status(200).send(JSON.stringify({}))}catch(a){e("accounts.recover_password",a,s)}};var i=d;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../../accounts/index.js";import r from"../../accounts/default_user_output_fields.js";import a from"../handle_api_error.js";const n=async(o={},s={})=>{try{const t=await e.reset_password({token:o?.body?.token,password:o?.body?.password,output:o?.body?.output||r});e._set_account_cookie(s,{token:t?.token,token_expires_at:t?.token_expires_at}),s.status(200).send(JSON.stringify(t?.user||{}))}catch(t){a("accounts.reset_password",t,s)}};var d=n;export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"../../accounts/index.js";import _ from"../../accounts/default_user_output_fields.js";import c from"../format_api_error.js";import i from"../handle_api_error.js";import d from"../validate_input.js";const u=async(t={},a={})=>{try{const s=process.joystick?.app_options?.accounts?.signup?.metadata,r=s?await d(t?.body?.metadata,s):[];if(r?.length>0)return i("accounts.signup",{errors:r.map(p=>c(new Error(p),"accounts.signup.metadata",401))},a);const o=await n.signup({email_address:t?.body?.emailAddress||t?.body?.email_address,password:t?.body?.password,metadata:t?.body?.metadata,output:t?.body?.output||_});process.env.NODE_ENV!=="test"&&n._set_account_cookie(a,{token:o?.token,token_expires_at:o?.token_expires_at});const e={...o?.user||{}};process.env.NODE_ENV==="test"&&(e.joystick_token=o?.token,e.joystick_login_token_expires_at=o?.token_expires_at),a.status(200).send(JSON.stringify(e))}catch(s){i("accounts.signup",s,a)}};var l=u;export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i from"../../accounts/default_user_output_fields.js";import _ from"../get_output.js";import n from"../../accounts/has_login_token_expired.js";const u=(t={},o={})=>{const e=n(o,t?.cookies?.joystick_login_token,t?.cookies?.joystick_login_token_expires_at)?401:200,s=_(t?.context?.user,t?.body?.output||i);return o.status(e).send(JSON.stringify({status:e,user:s}))};var a=u;export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../../accounts/index.js";const a=async(e={},t={})=>{await r.verify_email({token:e?.query?.token}),t.redirect("/")};var o=a;export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=(r={},a="",e=0)=>({status:e,error:r,message:r?.message||r,location:a});var m=s;export{m as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import p from"./format_api_error.js";import f from"./get_output.js";import h from"../../lib/get_sanitized_context.js";import z from"./sanitize_api_response.js";import d from"../../test/track_function_call.js";import n from"../../lib/types.js";import m from"./validate_input.js";const _=async(o="",t={},r=null,s=null,a={},u={})=>{const l=t?.sanitize===!1,i=(t?.sanitize||u?.sanitize)===!0;d(`node.api.getters.${o}`,[r,h(a)]);const e=await t?.get(r,a),c=s?f(e,s):e;return!l&&i?z(c):c},w=async(o="",t={},r={},s={})=>{d(`node.api.getters.${o}.authorized`,[r,h(s)]);const a=await t?.authorized(r,s);if(typeof a=="boolean")return a;if(n.is_object(a)&&!n.is_array(a)&&!n.is_undefined(a?.authorized))return a?.authorized?!0:a?.message},y=(o=[],t="")=>{console.log(`Input validation for getter "${t}" failed with the following errors:
|
|
2
|
+
`);for(let r=0;r<o?.length;r+=1){const s=o[r];console.log(`${r+1}. ${s}`)}},$=(o={},t={})=>m(o,t),v=async({get_name:o,get_options:t,getter_definition:r,request_context:s,api_schema_options:a})=>{const u=r?.input&&Object.keys(r?.input)?.length>0,l=n.is_function(r?.authorized);if(u){const i=await $(t?.input,r?.input);if(i?.length>0)return y(i,o),Promise.reject({errors:i.map(e=>p(new Error(e),`getters.${o}.input`,400))})}if(l){const i=await w(o,r,t?.input,s);if(!i||n.is_string(i))return Promise.reject({errors:[p(new Error(typeof i=="string"?i:`Not authorized to access ${o}.`),`getters.${o}.authorized`,403)]})}if(n.is_function(r?.get)){const i=await _(o,r,t?.input,t?.output,s,a);return Promise.resolve(i)}};var N=v;export{N as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=(t={},n={},a=null)=>new Promise(async o=>{if(typeof a=="function"){const c=await a(t,n);return o({...c,...t?.context||{},req:t,res:n,...process.databases||{}})}return o({...a,...t?.context||{},req:t,res:n,...process.databases||{}})});var e=s;export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"node-fetch";import i from"./get.js";import f from"./set.js";const s=(o={},r={})=>({fetch:n,get:(t="",e={})=>e?.skip?null:i({get_name:t,get_options:e,getter_definition:r?.getters[t],request_context:o?.context,api_schema_options:r?.options}),set:(t="",e={})=>e?.skip?null:f({set_name:t,set_options:e,setter_definition:r?.setters[t],request_context:o?.context,api_schema_options:r?.options})});var l=s;export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=(e="")=>e.toLowerCase().replace(/\ /g,"-");var o=t;export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../../lib/types.js";const s=(t={},n=[])=>{const i=Object.entries(t||{});for(let r=0;r<i?.length;r+=1){const[a,e]=i[r],l=n.find(_=>_.key===a);if(l||delete t[a],l&&o.is_object(e)&&l.children.length===0)return e;if(l&&o.is_object(e)&&l.children.length>0&&s(e,l.children),l&&o.is_array(e)&&l.children&&l.children.length>0)for(let _=0;_<e?.length;_+=1){const c=e[_];c&&o.is_object(c)&&s(c,l.children)}}return t},f=(t=[])=>t.map(n=>n.split(".")),h=(t=[])=>{const[n,...i]=t;return{head:n,tail:i}},u=(t=[])=>t.map(n=>h(n)),d=(t=[],n=[])=>{for(let i=0;i<n?.length;i+=1){const r=n[i],a=t.find(e=>e.key===r.head);if(!a){const e=r.tail&&r.tail.length>0?h(r.tail):null;t.push({key:r.head,children:e?d([],[e]):[]})}if(a){const e=r.tail&&r.tail.length>0?h(r.tail):null;a.children=[...e?d(a.children,[e]):[]]}}return t},p=(t={},n=[])=>{const i=[],r=f(n),a=u(r);return d(i,a),o.is_array(t)?t.map(e=>s(e,i)):s(t,i)};var y=p;export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=(e,r="")=>{if(!r)return e;if(!e)return;const t=r.split(".");return n(e[t.shift()],t.join("."))};var i=n;export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"./format_api_error.js";import i from"../../lib/types.js";const e=(r="",t="",s={})=>i.is_object(t)&&!(t instanceof Error)?s.status(t?.errors&&t?.errors[0]?.status||500).send(JSON.stringify(t)):t instanceof Error?s.status(500).send(JSON.stringify({errors:[n(t,r,500)]})):s.status(500).send(JSON.stringify({errors:[n(new Error(t),r,500)]}));var o=e;export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i from"../../lib/types.js";import m from"./validate_type.js";import"./is_array_path.js";const l=(r,e,t)=>r.includes(e)?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} only allows the following values: ${r.join(", ")}.`]},n=(r,e,t)=>i.is_array(e)&&e?.length<=r?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} length must be less than or equal to ${r}.`]},d=(r,e,t)=>i.is_array(e)&&e?.length>=r?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} length must be greater than or equal to ${r}.`]},v={types:["any","array","boolean","float","integer","number","object","string"],rules:{allowed_values:l,allowedValues:l,element:async(r,e,t,s)=>{if(e&&(i.is_object(r)||i.is_string(r))&&i.is_array(e)){const a=await Promise.all(e.flatMap(async(o,f)=>(await s(o,i.is_string(r)?{type:r}:r,`${t}.${f}`)).flatMap(c=>c)));return{valid:a.length===0,errors:a.flatMap(o=>o)}}return{valid:!0,errors:[]}},fields:async(r,e,t,s)=>{if(i.is_object(r)&&i.is_object(e)){const a=await s(e,r,t);return{valid:a.length===0,errors:[...a]}}return{valid:!1,errors:[`Field ${t} must be of type object.`]}},max:(r,e,t)=>e<=r?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} must be less than or equal to ${r}.`]},max_length:n,maxLength:n,min:(r,e,t)=>e>=r?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} must be greater than or equal to ${r}.`]},min_length:d,minLength:d,optional:(r,e,t)=>(r===!1?!!e:!0)?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} is required.`]},regex:(r,e,t)=>new RegExp(r).test(e)?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} must conform to regex: ${r}.`]},required:(r,e,t)=>(r===!1?!0:!!e)?{valid:!0,errors:[]}:{valid:!1,errors:[`Field ${t} is required.`]},type:(r,e,t)=>{const s=m(r,e);return e&&!s?{valid:!1,errors:[`Field ${t} must be of type ${r}.`]}:{valid:!0,errors:[]}}}};var b=v;export{b as default};
|