@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/ssr/compileCSS.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isFunction,
|
|
3
|
-
isString,
|
|
4
|
-
isObject
|
|
5
|
-
} from "../validation/lib/typeValidators.js";
|
|
6
|
-
var compileCSS_default = (css = "", componentInstance = {}) => {
|
|
7
|
-
try {
|
|
8
|
-
let compiledCSS = "";
|
|
9
|
-
if (css && isString(css)) {
|
|
10
|
-
compiledCSS = css;
|
|
11
|
-
return compiledCSS;
|
|
12
|
-
}
|
|
13
|
-
if (css && isFunction(css)) {
|
|
14
|
-
compiledCSS = css(componentInstance);
|
|
15
|
-
return compiledCSS;
|
|
16
|
-
}
|
|
17
|
-
if (css && isObject(css)) {
|
|
18
|
-
const hasPrintRules = css?.print && (isString(css?.print) || isFunction(css?.print));
|
|
19
|
-
const hasMinRules = css?.min && isObject(css?.min);
|
|
20
|
-
const hasMinWidthRules = css?.min?.width && isObject(css?.min?.width);
|
|
21
|
-
const hasMinHeightRules = css?.min?.height && isObject(css?.min?.height);
|
|
22
|
-
const hasMaxRules = css?.max && isObject(css?.max);
|
|
23
|
-
const hasMaxWidthRules = css?.max?.width && isObject(css?.max?.width);
|
|
24
|
-
const hasMaxHeightRules = css?.max?.height && isObject(css?.max?.height);
|
|
25
|
-
if (hasPrintRules) {
|
|
26
|
-
compiledCSS += `
|
|
27
|
-
@media print {
|
|
28
|
-
${typeof css?.print === "function" ? css?.print(componentInstance) : css.print}
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
}
|
|
32
|
-
if (hasMinRules && hasMinWidthRules) {
|
|
33
|
-
const minWidthRules = Object.entries(css?.min?.width);
|
|
34
|
-
for (let i = 0; i < minWidthRules.length; i += 1) {
|
|
35
|
-
const [minWidth, minWidthRule] = minWidthRules[i];
|
|
36
|
-
compiledCSS += `
|
|
37
|
-
@media screen and (min-width: ${minWidth}px) {
|
|
38
|
-
${typeof minWidthRule === "function" ? minWidthRule(componentInstance) : minWidthRule}
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (hasMinRules && hasMinHeightRules) {
|
|
44
|
-
const minHeightRules = Object.entries(css?.min?.height);
|
|
45
|
-
for (let i = 0; i < minHeightRules.length; i += 1) {
|
|
46
|
-
const [minHeight, minHeightRule] = minHeightRules[i];
|
|
47
|
-
compiledCSS += `
|
|
48
|
-
@media screen and (min-height: ${minHeight}px) {
|
|
49
|
-
${typeof minHeightRule === "function" ? minHeightRule(componentInstance) : minHeightRule}
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (hasMaxRules && hasMaxWidthRules) {
|
|
55
|
-
const maxWidthRules = Object.entries(css?.max?.width);
|
|
56
|
-
for (let i = 0; i < maxWidthRules.length; i += 1) {
|
|
57
|
-
const [maxWidth, maxWidthRule] = maxWidthRules[i];
|
|
58
|
-
compiledCSS += `
|
|
59
|
-
@media screen and (max-width: ${maxWidth}px) {
|
|
60
|
-
${typeof maxWidthRule === "function" ? maxWidthRule(componentInstance) : maxWidthRule}
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (hasMaxRules && hasMaxHeightRules) {
|
|
66
|
-
const maxHeightRules = Object.entries(css?.max?.height);
|
|
67
|
-
for (let i = 0; i < maxHeightRules.length; i += 1) {
|
|
68
|
-
const [maxHeight, maxHeightRule] = maxHeightRules[i];
|
|
69
|
-
compiledCSS += `
|
|
70
|
-
@media screen and (max-height: ${maxHeight}px) {
|
|
71
|
-
${typeof maxHeightRule === "function" ? maxHeightRule(componentInstance) : maxHeightRule}
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return compiledCSS;
|
|
77
|
-
}
|
|
78
|
-
return "";
|
|
79
|
-
} catch (exception) {
|
|
80
|
-
throw new Error("ssr.compileCSS", exception);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
export {
|
|
84
|
-
compileCSS_default as default
|
|
85
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const isObject = (value) => {
|
|
2
|
-
return !!(value && typeof value === "object" && !Array.isArray(value));
|
|
3
|
-
};
|
|
4
|
-
const findComponentInTree = (tree = {}, componentId = "", callback = {}) => {
|
|
5
|
-
const isTree = tree && tree.id;
|
|
6
|
-
if (isObject(tree) && isTree) {
|
|
7
|
-
const entries = Object.entries(tree);
|
|
8
|
-
for (let i = 0; i < entries.length; i += 1) {
|
|
9
|
-
const [treeKey, treeValue] = entries[i];
|
|
10
|
-
if (treeKey === "id" && treeValue === componentId) {
|
|
11
|
-
return tree;
|
|
12
|
-
}
|
|
13
|
-
if (treeKey === "children" && Array.isArray(treeValue)) {
|
|
14
|
-
for (let c = 0; c < treeValue.length; c += 1) {
|
|
15
|
-
const childTree = treeValue[c];
|
|
16
|
-
const child = findComponentInTree(childTree, componentId, callback);
|
|
17
|
-
if (child !== null) {
|
|
18
|
-
return child;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
var findComponentInTree_default = findComponentInTree;
|
|
27
|
-
export {
|
|
28
|
-
findComponentInTree_default as default
|
|
29
|
-
};
|
package/dist/ssr/formatCSS.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import compileCSS from "./compileCSS";
|
|
2
|
-
const handlePrefixCSS = (componentId, cssString) => {
|
|
3
|
-
const commentRegex = new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g);
|
|
4
|
-
const selectorRegex = new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g);
|
|
5
|
-
return (cssString || "").replace(commentRegex, (match) => {
|
|
6
|
-
return "";
|
|
7
|
-
}).replace(selectorRegex, (match) => {
|
|
8
|
-
if (["@", ": "].some((skip) => match?.includes(skip))) {
|
|
9
|
-
return match;
|
|
10
|
-
}
|
|
11
|
-
return `[js-c="${componentId}"] ${match.trim()}`;
|
|
12
|
-
})?.trim();
|
|
13
|
-
};
|
|
14
|
-
const getCSSFromTree = (tree = {}, css = []) => {
|
|
15
|
-
if (tree.instance && tree.instance.options && tree.instance.options.css) {
|
|
16
|
-
const componentId = tree.instance.id;
|
|
17
|
-
const rawCSS = tree.instance.options.css;
|
|
18
|
-
const compiledCSS = compileCSS(rawCSS, tree.instance);
|
|
19
|
-
const prefixedCSS = handlePrefixCSS(componentId, compiledCSS);
|
|
20
|
-
css.push(prefixedCSS);
|
|
21
|
-
}
|
|
22
|
-
if (tree.children && tree.children.length > 0) {
|
|
23
|
-
let processed = tree?.children?.length || 0;
|
|
24
|
-
while (processed--) {
|
|
25
|
-
getCSSFromTree(tree.children[processed], css);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return css;
|
|
29
|
-
};
|
|
30
|
-
var getCSSFromTree_default = getCSSFromTree;
|
|
31
|
-
export {
|
|
32
|
-
getCSSFromTree_default as default
|
|
33
|
-
};
|
package/dist/ssr/index.js
DELETED
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { __package } from "../index.js";
|
|
3
|
-
import get from "../api/get";
|
|
4
|
-
import set from "../api/set";
|
|
5
|
-
import getBrowserSafeRequest from "../app/getBrowserSafeRequest";
|
|
6
|
-
import formatCSS from "./formatCSS";
|
|
7
|
-
import getCSSFromTree from "./getCSSFromTree";
|
|
8
|
-
import replaceWhenTags from "./replaceWhenTags";
|
|
9
|
-
import setHeadTagsInHTML from "./setHeadTagsInHTML";
|
|
10
|
-
import { parseHTML } from "linkedom";
|
|
11
|
-
const injectCSSIntoHTML = (html, baseCSS = "", css = "") => {
|
|
12
|
-
try {
|
|
13
|
-
return html.replace("${css}", css).replace("${globalCSS}", `<style>${baseCSS || ""}</style>`).replace("${componentCSS}", css);
|
|
14
|
-
} catch (exception) {
|
|
15
|
-
throw new Error(`[ssr.injectCSSIntoHTML] ${exception.message}`);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const handleHTMLReplacementsForApp = ({
|
|
19
|
-
baseHTML = "",
|
|
20
|
-
componentHTML = "",
|
|
21
|
-
componentInstance = {},
|
|
22
|
-
dataFromComponent,
|
|
23
|
-
dataForClient = {},
|
|
24
|
-
browserSafeRequest = {},
|
|
25
|
-
props = {},
|
|
26
|
-
translations = {},
|
|
27
|
-
url = {},
|
|
28
|
-
layoutComponentPath = "",
|
|
29
|
-
pageComponentPath = ""
|
|
30
|
-
}) => {
|
|
31
|
-
try {
|
|
32
|
-
return baseHTML.replace("${meta}", "").replace("${scripts}", "").replace('<div id="app"></div>', `
|
|
33
|
-
<div id="app">${componentHTML}</div>
|
|
34
|
-
<script>
|
|
35
|
-
window.joystick = {};
|
|
36
|
-
|
|
37
|
-
if (window.joystick) {
|
|
38
|
-
window.joystick.settings = {
|
|
39
|
-
global: ${JSON.stringify(joystick?.settings?.global)},
|
|
40
|
-
public: ${JSON.stringify(joystick?.settings?.public)},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
window.__joystick_ssr__ = true;
|
|
45
|
-
${process.env.NODE_ENV === "development" ? `window.__joystick_hmr_port__ = ${parseInt(process.env.PORT, 10) + 1};` : ""}
|
|
46
|
-
window.__joystick_data__ = ${JSON.stringify({
|
|
47
|
-
[componentInstance.id]: dataFromComponent?.data || {},
|
|
48
|
-
...dataForClient || {}
|
|
49
|
-
})};
|
|
50
|
-
window.__joystick_req__ = ${JSON.stringify(browserSafeRequest)};
|
|
51
|
-
window.__joystick_ssr_props__ = ${JSON.stringify(props)};
|
|
52
|
-
window.__joystick_i18n__ = ${JSON.stringify(translations)};
|
|
53
|
-
window.__joystick_settings__ = ${JSON.stringify({
|
|
54
|
-
global: joystick?.settings?.global,
|
|
55
|
-
public: joystick?.settings?.public
|
|
56
|
-
})};
|
|
57
|
-
window.__joystick_url__ = ${JSON.stringify(url)};
|
|
58
|
-
window.__joystick_layout__ = ${layoutComponentPath ? `"/_joystick/${layoutComponentPath}"` : null};
|
|
59
|
-
window.__joystick_layout_page_url__ = ${layoutComponentPath ? `"/_joystick/${pageComponentPath}"` : null};
|
|
60
|
-
window.__joystick_layout_page__ = ${layoutComponentPath ? `"${pageComponentPath.split(".")[0]}"` : null};
|
|
61
|
-
<\/script>
|
|
62
|
-
<script type="module" src="/_joystick/utils/process.js"><\/script>
|
|
63
|
-
<script type="module" src="/_joystick/index.client.js"><\/script>
|
|
64
|
-
${pageComponentPath ? `<script type="module" src="/_joystick/${pageComponentPath}"><\/script>` : ""}
|
|
65
|
-
${layoutComponentPath ? `<script type="module" src="/_joystick/${layoutComponentPath}"><\/script>` : ""}
|
|
66
|
-
${process.env.NODE_ENV === "development" ? `<script type="module" src="/_joystick/hmr/client.js"><\/script>` : ""}
|
|
67
|
-
`);
|
|
68
|
-
} catch (exception) {
|
|
69
|
-
throw new Error(`[ssr.handleHTMLReplacementsForApp] ${exception.message}`);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const handleHTMLReplacementsForEmail = ({
|
|
73
|
-
subject = "",
|
|
74
|
-
preheader = "",
|
|
75
|
-
baseHTML = "",
|
|
76
|
-
componentHTML = ""
|
|
77
|
-
}) => {
|
|
78
|
-
try {
|
|
79
|
-
return baseHTML.replace("${subject}", subject).replace("${preheader}", preheader || "").replace('<div id="email"></div>', componentHTML);
|
|
80
|
-
} catch (exception) {
|
|
81
|
-
throw new Error(`[ssr.handleHTMLReplacementsForEmail] ${exception.message}`);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const getHTMLWithTargetReplacements = ({
|
|
85
|
-
componentInstance = {},
|
|
86
|
-
componentHTML = "",
|
|
87
|
-
isEmailRender = false,
|
|
88
|
-
emailSubject = "",
|
|
89
|
-
emailPreheader = "",
|
|
90
|
-
baseHTML = "",
|
|
91
|
-
dataFromComponent = {},
|
|
92
|
-
dataForClient = {},
|
|
93
|
-
browserSafeRequest = {},
|
|
94
|
-
props = {},
|
|
95
|
-
translations = {},
|
|
96
|
-
url = {},
|
|
97
|
-
layoutComponentPath = "",
|
|
98
|
-
pageComponentPath = ""
|
|
99
|
-
}) => {
|
|
100
|
-
try {
|
|
101
|
-
if (isEmailRender) {
|
|
102
|
-
return handleHTMLReplacementsForEmail({
|
|
103
|
-
subject: emailSubject,
|
|
104
|
-
preheader: emailPreheader,
|
|
105
|
-
baseHTML,
|
|
106
|
-
componentHTML
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return handleHTMLReplacementsForApp({
|
|
110
|
-
componentInstance,
|
|
111
|
-
baseHTML,
|
|
112
|
-
componentHTML,
|
|
113
|
-
dataFromComponent,
|
|
114
|
-
dataForClient,
|
|
115
|
-
browserSafeRequest,
|
|
116
|
-
props,
|
|
117
|
-
translations,
|
|
118
|
-
url,
|
|
119
|
-
layoutComponentPath,
|
|
120
|
-
pageComponentPath
|
|
121
|
-
});
|
|
122
|
-
} catch (exception) {
|
|
123
|
-
throw new Error(`[ssr.getHTMLWithTargetReplacements] ${exception.message}`);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
const getHTMLWithData = (renderingHTMLWithDataForSSR = false, componentInstance = {}, ssrTree = {}, translations = {}, dataFromComponent = {}, dataFromTree = []) => {
|
|
127
|
-
try {
|
|
128
|
-
return componentInstance.renderToHTML({
|
|
129
|
-
ssrTree,
|
|
130
|
-
translations,
|
|
131
|
-
walkingTreeForSSR: false,
|
|
132
|
-
renderingHTMLWithDataForSSR,
|
|
133
|
-
dataFromSSR: [dataFromComponent, ...dataFromTree]
|
|
134
|
-
});
|
|
135
|
-
} catch (exception) {
|
|
136
|
-
throw new Error(`[ssr.getHTMLWithData] ${exception.message}`);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
const processHTML = ({
|
|
140
|
-
componentInstance = {},
|
|
141
|
-
ssrTree = {},
|
|
142
|
-
dataFromComponent = {},
|
|
143
|
-
dataFromTree = [],
|
|
144
|
-
dataForClient = {},
|
|
145
|
-
baseHTML = "",
|
|
146
|
-
isEmailRender = false,
|
|
147
|
-
emailSubject = "",
|
|
148
|
-
emailPreheader = "",
|
|
149
|
-
browserSafeRequest = {},
|
|
150
|
-
props = {},
|
|
151
|
-
translations = {},
|
|
152
|
-
url = {},
|
|
153
|
-
layoutComponentPath = "",
|
|
154
|
-
pageComponentPath = "",
|
|
155
|
-
head = null,
|
|
156
|
-
renderingHTMLWithDataForSSR = false,
|
|
157
|
-
req
|
|
158
|
-
}) => {
|
|
159
|
-
try {
|
|
160
|
-
const htmlWithData = getHTMLWithData(renderingHTMLWithDataForSSR, componentInstance, ssrTree, translations, dataFromComponent, dataFromTree);
|
|
161
|
-
const htmlWithWhenReplacements = replaceWhenTags(htmlWithData.wrapped);
|
|
162
|
-
const htmlWithTargetReplacements = getHTMLWithTargetReplacements({
|
|
163
|
-
componentInstance,
|
|
164
|
-
componentHTML: htmlWithWhenReplacements,
|
|
165
|
-
isEmailRender,
|
|
166
|
-
emailSubject,
|
|
167
|
-
emailPreheader,
|
|
168
|
-
baseHTML,
|
|
169
|
-
dataFromComponent,
|
|
170
|
-
dataFromTree,
|
|
171
|
-
dataForClient,
|
|
172
|
-
browserSafeRequest,
|
|
173
|
-
props,
|
|
174
|
-
translations,
|
|
175
|
-
url,
|
|
176
|
-
layoutComponentPath,
|
|
177
|
-
pageComponentPath
|
|
178
|
-
});
|
|
179
|
-
return setHeadTagsInHTML(htmlWithTargetReplacements, head, req);
|
|
180
|
-
} catch (exception) {
|
|
181
|
-
throw new Error(`[ssr.processHTML] ${exception.message}`);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
const getBaseCSS = (baseHTMLName = "") => {
|
|
185
|
-
try {
|
|
186
|
-
const customBaseCSSPathForEmail = baseHTMLName ? `${process.cwd()}/email/base_${baseHTMLName}.css` : null;
|
|
187
|
-
const customDefaultBaseCSSPathForEmail = `${process.cwd()}/email/base.css`;
|
|
188
|
-
const defaultBaseCSSPathForEmail = process.env.NODE_ENV === "test" ? `${process.cwd()}/src/email/templates/base.css` : `${__package}/email/templates/base.css`;
|
|
189
|
-
let baseCSSPathToFetch = defaultBaseCSSPathForEmail;
|
|
190
|
-
if (fs.existsSync(customDefaultBaseCSSPathForEmail)) {
|
|
191
|
-
baseCSSPathToFetch = customDefaultBaseCSSPathForEmail;
|
|
192
|
-
}
|
|
193
|
-
if (fs.existsSync(customBaseCSSPathForEmail)) {
|
|
194
|
-
baseCSSPathToFetch = customBaseCSSPathForEmail;
|
|
195
|
-
}
|
|
196
|
-
return fs.existsSync(baseCSSPathToFetch) ? fs.readFileSync(baseCSSPathToFetch, "utf-8") : "";
|
|
197
|
-
} catch (exception) {
|
|
198
|
-
throw new Error(`[ssr.getBaseCSS] ${exception.message}`);
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
const addAttributesToDOM = (dom = {}, attributes = {}) => {
|
|
202
|
-
try {
|
|
203
|
-
const attributeKeys = Object.keys(attributes);
|
|
204
|
-
const attributeKeysWithoutClassList = attributeKeys?.filter((key) => key !== "class");
|
|
205
|
-
if (Array.isArray(attributes?.class?.list)) {
|
|
206
|
-
if (attributes?.class?.method === "replace") {
|
|
207
|
-
dom.setAttribute("class", attributes.class.list.join(" "));
|
|
208
|
-
} else {
|
|
209
|
-
let currentItem = attributes.class.list.length;
|
|
210
|
-
while (currentItem--) {
|
|
211
|
-
const className = attributes.class.list[currentItem];
|
|
212
|
-
dom.classList.add(className);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
let currentAttribute = attributeKeysWithoutClassList.length;
|
|
217
|
-
while (currentAttribute--) {
|
|
218
|
-
const attribute = attributes.class.list[currentAttribute];
|
|
219
|
-
dom.setAttribute(attribute, attributes[attribute]);
|
|
220
|
-
}
|
|
221
|
-
return dom;
|
|
222
|
-
} catch (exception) {
|
|
223
|
-
throw new Error(`[ssr.addAttributesToDOM] ${exception.message}`);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
const addAttributesToBaseHTML = (baseHTML = "", attributes = {}) => {
|
|
227
|
-
try {
|
|
228
|
-
const { document } = parseHTML(baseHTML);
|
|
229
|
-
if (attributes?.html) {
|
|
230
|
-
addAttributesToDOM(document.documentElement, attributes.html);
|
|
231
|
-
}
|
|
232
|
-
if (attributes?.body) {
|
|
233
|
-
addAttributesToDOM(document.body, attributes.body);
|
|
234
|
-
}
|
|
235
|
-
return document.toString();
|
|
236
|
-
} catch (exception) {
|
|
237
|
-
throw new Error(`[ssr.addAttributesToBaseHTML] ${exception.message}`);
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
const getBaseHTML = (isEmailRender = false, baseEmailHTMLName = "") => {
|
|
241
|
-
try {
|
|
242
|
-
let baseHTMLPathToFetch = `${process.cwd()}/index.html`;
|
|
243
|
-
if (isEmailRender) {
|
|
244
|
-
const customBaseHTMLPathForEmail = baseEmailHTMLName ? `${process.cwd()}/email/base_${baseEmailHTMLName}.html` : null;
|
|
245
|
-
const customDefaultBaseHTMLPathForEmail = `${process.cwd()}/email/base.html`;
|
|
246
|
-
const defaultBaseHTMLPathForEmail = process.env.NODE_ENV === "test" ? `${process.cwd()}/src/email/templates/base.html` : `${__package}/email/templates/base.html`;
|
|
247
|
-
baseHTMLPathToFetch = defaultBaseHTMLPathForEmail;
|
|
248
|
-
if (fs.existsSync(customDefaultBaseHTMLPathForEmail)) {
|
|
249
|
-
baseHTMLPathToFetch = customDefaultBaseHTMLPathForEmail;
|
|
250
|
-
}
|
|
251
|
-
if (fs.existsSync(customBaseHTMLPathForEmail)) {
|
|
252
|
-
baseHTMLPathToFetch = customBaseHTMLPathForEmail;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return fs.existsSync(baseHTMLPathToFetch) ? fs.readFileSync(baseHTMLPathToFetch, "utf-8") : "";
|
|
256
|
-
} catch (exception) {
|
|
257
|
-
throw new Error(`[ssr.getBaseHTML] ${exception.message}`);
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
const buildDataForClient = (dataFromTree = []) => {
|
|
261
|
-
try {
|
|
262
|
-
return dataFromTree.reduce((data = {}, dataFromChildComponent) => {
|
|
263
|
-
if (!data[dataFromChildComponent.componentId]) {
|
|
264
|
-
data[dataFromChildComponent.componentId] = dataFromChildComponent.data || JSON.parse(dataFromChildComponent.error);
|
|
265
|
-
}
|
|
266
|
-
return data;
|
|
267
|
-
}, {});
|
|
268
|
-
} catch (exception) {
|
|
269
|
-
throw new Error(`[ssr.buildDataForClient] ${exception.message}`);
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
const getDataFromTree = (ssrTree = {}) => {
|
|
273
|
-
try {
|
|
274
|
-
return Promise.all(ssrTree.dataFunctions.map(async (dataFunction) => {
|
|
275
|
-
return dataFunction();
|
|
276
|
-
}));
|
|
277
|
-
} catch (exception) {
|
|
278
|
-
throw new Error(`[ssr.getDataFromTree] ${exception.message}`);
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
const buildTreeForComponent = (componentInstance = {}, ssrTree = {}, translations = {}) => {
|
|
282
|
-
try {
|
|
283
|
-
componentInstance.renderToHTML({
|
|
284
|
-
ssrTree,
|
|
285
|
-
translations,
|
|
286
|
-
walkingTreeForSSR: true,
|
|
287
|
-
dataFromSSR: []
|
|
288
|
-
});
|
|
289
|
-
} catch (exception) {
|
|
290
|
-
throw new Error(`[ssr.buildTreeForComponent] ${exception.message}`);
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
const getDataFromComponent = async (componentInstance = {}, api = {}, browserSafeRequest = {}) => {
|
|
294
|
-
try {
|
|
295
|
-
const data = await componentInstance.handleFetchData(api, browserSafeRequest, {}, componentInstance);
|
|
296
|
-
return {
|
|
297
|
-
componentId: componentInstance?.id,
|
|
298
|
-
data
|
|
299
|
-
};
|
|
300
|
-
} catch (exception) {
|
|
301
|
-
throw new Error(`[ssr.getDataFromComponent] ${exception.message}`);
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
const getTreeForSSR = (componentInstance = {}) => {
|
|
305
|
-
try {
|
|
306
|
-
return {
|
|
307
|
-
id: componentInstance.id,
|
|
308
|
-
instanceId: componentInstance.instanceId,
|
|
309
|
-
instance: componentInstance,
|
|
310
|
-
children: [],
|
|
311
|
-
dataFunctions: []
|
|
312
|
-
};
|
|
313
|
-
} catch (exception) {
|
|
314
|
-
throw new Error(`[ssr.getTreeForSSR] ${exception.message}`);
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
const getComponentInstance = (Component, options = {}) => {
|
|
318
|
-
try {
|
|
319
|
-
return Component(options);
|
|
320
|
-
} catch (exception) {
|
|
321
|
-
throw new Error(`[ssr.getComponentInstance] ${exception.message}`);
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
const getAPIForDataFunctions = (req = {}, api = {}) => {
|
|
325
|
-
try {
|
|
326
|
-
return {
|
|
327
|
-
get: (getterName = "", getterOptions = {}) => {
|
|
328
|
-
return get({
|
|
329
|
-
getterName,
|
|
330
|
-
getterOptions: api?.getters[getterName] || {},
|
|
331
|
-
input: getterOptions?.input,
|
|
332
|
-
output: getterOptions?.output,
|
|
333
|
-
context: req?.context,
|
|
334
|
-
APIOptions: api?.options
|
|
335
|
-
});
|
|
336
|
-
},
|
|
337
|
-
set: (setterName = "", setterOptions = {}) => {
|
|
338
|
-
return set({
|
|
339
|
-
setterName,
|
|
340
|
-
setterOptions: api?.setters[setterName] || {},
|
|
341
|
-
input: setterOptions?.input,
|
|
342
|
-
output: setterOptions?.output,
|
|
343
|
-
context: req?.context,
|
|
344
|
-
APIOptions: api?.options
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
} catch (exception) {
|
|
349
|
-
throw new Error(`[ssr.getAPIForDataFunctions] ${exception.message}`);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
const validateOptions = (options) => {
|
|
353
|
-
try {
|
|
354
|
-
if (!options)
|
|
355
|
-
throw new Error("options object is required.");
|
|
356
|
-
if (!options.componentFunction)
|
|
357
|
-
throw new Error("options.componentFunction is required.");
|
|
358
|
-
} catch (exception) {
|
|
359
|
-
throw new Error(`[ssr.validateOptions] ${exception.message}`);
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
const ssr = async (options, { resolve, reject }) => {
|
|
363
|
-
try {
|
|
364
|
-
validateOptions(options);
|
|
365
|
-
const apiForDataFunctions = getAPIForDataFunctions(options.req, options?.api);
|
|
366
|
-
const browserSafeRequest = options?.email ? {} : getBrowserSafeRequest({ ...options?.req || {} });
|
|
367
|
-
const componentInstance = getComponentInstance(options.componentFunction, {
|
|
368
|
-
props: options?.props || {},
|
|
369
|
-
url: options?.url || {},
|
|
370
|
-
translations: options?.translations || {},
|
|
371
|
-
api: apiForDataFunctions,
|
|
372
|
-
req: browserSafeRequest
|
|
373
|
-
});
|
|
374
|
-
const ssrTree = getTreeForSSR(componentInstance);
|
|
375
|
-
const ssrTreeForCSS = getTreeForSSR(componentInstance);
|
|
376
|
-
const dataFromComponent = await getDataFromComponent(componentInstance, apiForDataFunctions, browserSafeRequest).then((data) => data).catch((error) => {
|
|
377
|
-
return [{ error }];
|
|
378
|
-
});
|
|
379
|
-
buildTreeForComponent(componentInstance, ssrTree);
|
|
380
|
-
buildTreeForComponent(componentInstance, ssrTreeForCSS);
|
|
381
|
-
const dataFromTree = await getDataFromTree(ssrTree).then((data) => data).catch((error) => {
|
|
382
|
-
return [{ error }];
|
|
383
|
-
});
|
|
384
|
-
const dataForClient = !options?.email ? buildDataForClient(dataFromTree) : null;
|
|
385
|
-
let baseHTML = getBaseHTML(options?.email, options?.baseEmailHTMLName);
|
|
386
|
-
if (options?.attributes?.html || options?.attributes?.body) {
|
|
387
|
-
baseHTML = addAttributesToBaseHTML(baseHTML, options?.attributes);
|
|
388
|
-
}
|
|
389
|
-
const html = processHTML({
|
|
390
|
-
renderingHTMLWithDataForSSR: false,
|
|
391
|
-
componentInstance,
|
|
392
|
-
ssrTree,
|
|
393
|
-
dataFromComponent,
|
|
394
|
-
dataFromTree,
|
|
395
|
-
dataForClient,
|
|
396
|
-
baseHTML,
|
|
397
|
-
isEmailRender: options?.email,
|
|
398
|
-
emailSubject: options?.emailSubject,
|
|
399
|
-
emailPreheader: options?.emailPreheader,
|
|
400
|
-
browserSafeRequest,
|
|
401
|
-
props: options?.props,
|
|
402
|
-
translations: options?.translations,
|
|
403
|
-
url: options?.url,
|
|
404
|
-
layoutComponentPath: options?.layoutComponentPath,
|
|
405
|
-
pageComponentPath: options?.pageComponentPath,
|
|
406
|
-
head: options?.head,
|
|
407
|
-
req: options?.req
|
|
408
|
-
});
|
|
409
|
-
processHTML({
|
|
410
|
-
renderingHTMLWithDataForSSR: true,
|
|
411
|
-
componentInstance,
|
|
412
|
-
ssrTree: ssrTreeForCSS,
|
|
413
|
-
dataFromComponent,
|
|
414
|
-
dataFromTree,
|
|
415
|
-
dataForClient,
|
|
416
|
-
baseHTML,
|
|
417
|
-
isEmailRender: options?.email,
|
|
418
|
-
emailSubject: options?.emailSubject,
|
|
419
|
-
emailPreheader: options?.emailPreheader,
|
|
420
|
-
browserSafeRequest,
|
|
421
|
-
props: options?.props,
|
|
422
|
-
translations: options?.translations,
|
|
423
|
-
url: options?.url,
|
|
424
|
-
layoutComponentPath: options?.layoutComponentPath,
|
|
425
|
-
pageComponentPath: options?.pageComponentPath,
|
|
426
|
-
head: options?.head
|
|
427
|
-
});
|
|
428
|
-
const baseCSS = options?.email ? getBaseCSS(options?.baseEmailHTMLName) : "";
|
|
429
|
-
const css = formatCSS(getCSSFromTree(ssrTreeForCSS));
|
|
430
|
-
const htmlWithCSS = injectCSSIntoHTML(html, baseCSS, css);
|
|
431
|
-
resolve(htmlWithCSS);
|
|
432
|
-
} catch (exception) {
|
|
433
|
-
reject(`[ssr] ${exception.message}`);
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
var ssr_default = (options) => new Promise((resolve, reject) => {
|
|
437
|
-
ssr(options, { resolve, reject });
|
|
438
|
-
});
|
|
439
|
-
export {
|
|
440
|
-
ssr_default as default
|
|
441
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { parseHTML } from "linkedom";
|
|
2
|
-
const flattenAndReplaceWhenElements = (dom = {}, options = {}) => {
|
|
3
|
-
try {
|
|
4
|
-
if (dom?.childNodes?.length > 0) {
|
|
5
|
-
let processed = dom.childNodes.length || 0;
|
|
6
|
-
while (processed--) {
|
|
7
|
-
const childNode = dom.childNodes[processed];
|
|
8
|
-
flattenAndReplaceWhenElements(childNode, {
|
|
9
|
-
rootDocument: options?.rootDocument || dom,
|
|
10
|
-
isChildNode: true
|
|
11
|
-
});
|
|
12
|
-
if (childNode?.tagName === "WHEN" && childNode?.childNodes?.length === 0) {
|
|
13
|
-
const rootDocument = options?.rootDocument || dom;
|
|
14
|
-
childNode.replaceWith(rootDocument.createTextNode(""));
|
|
15
|
-
}
|
|
16
|
-
if (childNode?.tagName === "WHEN" && childNode?.childNodes?.length > 0) {
|
|
17
|
-
childNode.replaceWith(...childNode.childNodes);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return dom;
|
|
22
|
-
} catch (exception) {
|
|
23
|
-
throw new Error(`[ssr.replaceWhenTags.flattenAndReplaceWhenElements] ${exception.message}`);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var replaceWhenTags_default = (html = "") => {
|
|
27
|
-
try {
|
|
28
|
-
const { document: parseHTMLDocument } = parseHTML(html);
|
|
29
|
-
const dom = flattenAndReplaceWhenElements(parseHTMLDocument);
|
|
30
|
-
return dom.toString();
|
|
31
|
-
} catch (exception) {
|
|
32
|
-
throw new Error(`[ssr.replaceWhenTags] ${exception.message}`);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
export {
|
|
36
|
-
replaceWhenTags_default as default
|
|
37
|
-
};
|