procbay-schema 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/package.json +77 -0
- package/prisma/.env +13 -0
- package/prisma/migrations/20250116142512_init_user_table/migration.sql +38 -0
- package/prisma/migrations/20250116142709_init_role_table/migration.sql +20 -0
- package/prisma/migrations/20250116143847_init_user_role_table/migration.sql +20 -0
- package/prisma/migrations/20250116144035_init_permission_table/migration.sql +21 -0
- package/prisma/migrations/20250116144140_init_role_permission_table/migration.sql +21 -0
- package/prisma/migrations/20250116144233_init_department_table/migration.sql +20 -0
- package/prisma/migrations/20250116144345_init_user_department_table/migration.sql +20 -0
- package/prisma/migrations/20250116152941_init_serial_number_table/migration.sql +17 -0
- package/prisma/migrations/20250116153048_init_category_table/migration.sql +22 -0
- package/prisma/migrations/20250116153415_init_attributes_table/migration.sql +28 -0
- package/prisma/migrations/20250116153628_init_attribute_values_table/migration.sql +27 -0
- package/prisma/migrations/20250116153900_init_purchase_intake_table/migration.sql +32 -0
- package/prisma/migrations/20250116154038_init_purchase_intake_item_table/migration.sql +15 -0
- package/prisma/migrations/20250120090355_added_reset_token_column_in_user_table/migration.sql +10 -0
- package/prisma/migrations/20250120100616_init_item_table/migration.sql +42 -0
- package/prisma/migrations/20250120123720_init_vendor_table/migration.sql +39 -0
- package/prisma/migrations/20250120124526_init_vendor_categories_table/migration.sql +20 -0
- package/prisma/migrations/20250122114935_added_email_template_and_smtp_config_table/migration.sql +41 -0
- package/prisma/migrations/20250123095637_chnages_in_vendr_table/migration.sql +3 -0
- package/prisma/migrations/20250123103705_added_delated_filed_in_email_template_table/migration.sql +4 -0
- package/prisma/migrations/20250123103810_added_delated_filed_in_smtp_config_table/migration.sql +13 -0
- package/prisma/migrations/20250127123900_create_approval_heirarchy_table/migration.sql +72 -0
- package/prisma/migrations/20250128054523_make_optional_role_and_user_in_approval_hierachy/migration.sql +3 -0
- package/prisma/migrations/20250129084223_item_table_chnages/migration.sql +151 -0
- package/prisma/migrations/20250130115331_chnages_in_item_table/migration.sql +9 -0
- package/prisma/migrations/20250131054132_added_approval_journey_table/migration.sql +22 -0
- package/prisma/migrations/20250131064653_added_default_for_product_id_in_item_table/migration.sql +2 -0
- package/prisma/migrations/20250204101253_chnages_in_approval_table/migration.sql +39 -0
- package/prisma/migrations/20250206091422_added_item_document_table/migration.sql +17 -0
- package/prisma/migrations/20250207113110_added_new_column_media/migration.sql +9 -0
- package/prisma/migrations/20250207125224_added_chnages_in_pr_table/migration.sql +12 -0
- package/prisma/migrations/20250212092048_vendor_contact_table/migration.sql +30 -0
- package/prisma/migrations/20250212133620_added_tamplate_master_table/migration.sql +43 -0
- package/prisma/migrations/20250213111908_created_faq_catgory_and_faq_table/migration.sql +58 -0
- package/prisma/migrations/20250214065142_chnages_in_uom_table/migration.sql +50 -0
- package/prisma/migrations/20250217061122_corrected_email_teamplate_table/migration.sql +11 -0
- package/prisma/migrations/20250218073530_init_events/migration.sql +120 -0
- package/prisma/migrations/20250218092119_corrected_table_name/migration.sql +37 -0
- package/prisma/migrations/20250218120935_chnages_in_event_table/migration.sql +5 -0
- package/prisma/migrations/20250219083326_added_new_table_for_event_startegy/migration.sql +60 -0
- package/prisma/migrations/20250219083416_added_cms_table/migration.sql +29 -0
- package/prisma/migrations/20250219092918_alter_event_table/migration.sql +5 -0
- package/prisma/migrations/20250219093046_alter_event_to_draft/migration.sql +2 -0
- package/prisma/migrations/20250220080337_altered_event_table/migration.sql +9 -0
- package/prisma/migrations/20250221105922_added_unique_to_email_in_user_table/migration.sql +8 -0
- package/prisma/migrations/20250225063838_created_vendor_kyc_table/migration.sql +23 -0
- package/prisma/migrations/20250227060646_template_field_types_added_enum/migration.sql +14 -0
- package/prisma/migrations/20250227110306_updated_event_items_and_event_vendor_table/migration.sql +7 -0
- package/prisma/migrations/20250228060440_added_country_code_in_vendor_contact_person/migration.sql +2 -0
- package/prisma/migrations/20250228095319_init_currencies_table/migration.sql +23 -0
- package/prisma/migrations/20250303082614_added_support_ticket_table/migration.sql +89 -0
- package/prisma/migrations/20250304050248_alter_support_ticket_relations/migration.sql +35 -0
- package/prisma/migrations/20250304050613_alter_support_ticket_realtions/migration.sql +36 -0
- package/prisma/migrations/20250304061954_init_support_category_table/migration.sql +261 -0
- package/prisma/migrations/20250304092346_alter_event_vendor_table/migration.sql +2 -0
- package/prisma/migrations/20250305065430_alter_vendor_kyc_table/migration.sql +2 -0
- package/prisma/migrations/20250305111735_alter_vendor_and_user_table/migration.sql +5 -0
- package/prisma/migrations/20250307033751_alter_token_version_in_user_and_vendor_token/migration.sql +5 -0
- package/prisma/migrations/20250307034907_alter_user_and_vendor_table/migration.sql +14 -0
- package/prisma/migrations/20250307064359_chnages_in_approval_herarcy_table/migration.sql +2 -0
- package/prisma/migrations/20250307105352_alter_itme_and_vendorkyc_table/migration.sql +21 -0
- package/prisma/migrations/20250310103914_init_vendor_status_table/migration.sql +21 -0
- package/prisma/migrations/20250310105209_alter_vendor_status_table/migration.sql +18 -0
- package/prisma/migrations/20250310105413_init_vendor_kyc_status_table/migration.sql +23 -0
- package/prisma/migrations/20250311090552_alter_vendor_kyc_status_table/migration.sql +2 -0
- package/prisma/migrations/20250312055258_alter_status_column_in_event_vendors/migration.sql +12 -0
- package/prisma/migrations/20250312072145_init_vendor_event_watchlist_table/migration.sql +26 -0
- package/prisma/migrations/20250312083842_alter_vendor_event_watchlisst_table/migration.sql +41 -0
- package/prisma/migrations/20250312134730_added_chnages_in_kyc_table/migration.sql +19 -0
- package/prisma/migrations/20250317040841_init_admin_and_vendor_tables/migration.sql +38 -0
- package/prisma/migrations/20250317044110_alter_event_vendor_table/migration.sql +2 -0
- package/prisma/migrations/20250317071807_alter_rejected_reason_in_approval_journey_and_purchase_intak_table/migration.sql +5 -0
- package/prisma/migrations/20250318085504_init_customer_notification_table/migration.sql +31 -0
- package/prisma/migrations/20250318085856_alter_purchase_intake_table/migration.sql +18 -0
- package/prisma/migrations/20250319085159_alter_purchase_intake_table/migration.sql +12 -0
- package/prisma/migrations/20250320093356_init_bid_and_bidlog_table/migration.sql +75 -0
- package/prisma/migrations/20250320095501_alter_email_template_table/migration.sql +2 -0
- package/prisma/migrations/20250321053926_alter_approval_journey_table/migration.sql +2 -0
- package/prisma/migrations/20250324040851_alter_bidlog_table/migration.sql +2 -0
- package/prisma/migrations/20250324091328_init_form_master_and_dynamic_form_table/migration.sql +53 -0
- package/prisma/migrations/20250324103742_alter_bidlog_table/migration.sql +5 -0
- package/prisma/migrations/20250325052714_alter_form_master_table/migration.sql +27 -0
- package/prisma/migrations/20250327011625_init_module_and_tenant_configuration_table/migration.sql +39 -0
- package/prisma/migrations/20250403054008_alter_purchase_intake_table/migration.sql +5 -0
- package/prisma/migrations/20250404115613_init_approval_level_user/migration.sql +98 -0
- package/prisma/migrations/20250410060521_alter_approval_journey_enums/migration.sql +12 -0
- package/prisma/migrations/20250410110823_alter_purchase_intake/migration.sql +2 -0
- package/prisma/migrations/20250411062955_alter_template_field_table/migration.sql +2 -0
- package/prisma/migrations/20250414065640_alter_template/migration.sql +2 -0
- package/prisma/migrations/20250414111856_alter_event_vendors/migration.sql +2 -0
- package/prisma/migrations/20250414125356_alter_event_vendor/migration.sql +9 -0
- package/prisma/migrations/20250415063558_alter_alert_type_enum/migration.sql +2 -0
- package/prisma/migrations/20250416062508_alter_purchase_intake_table/migration.sql +15 -0
- package/prisma/migrations/20250417090325_alter_purchase_intake_table_updated_enum/migration.sql +13 -0
- package/prisma/migrations/20250417111024_alter_purchase_intake_and_purchase_intake_item/migration.sql +16 -0
- package/prisma/migrations/20250421061732_init_quotation_and_quotation_log_tables/migration.sql +96 -0
- package/prisma/migrations/20250421112331_alter_item_table_added_unique_to_slug/migration.sql +8 -0
- package/prisma/migrations/20250422060655_init_user_activity_table/migration.sql +17 -0
- package/prisma/migrations/20250423053027_/migration.sql +9 -0
- package/prisma/migrations/20250423103233_alter_user_login_activity_table/migration.sql +5 -0
- package/prisma/migrations/20250423111141_init_location_tables/migration.sql +141 -0
- package/prisma/migrations/20250424120106_alter_event_table_added_user_relation/migration.sql +2 -0
- package/prisma/migrations/20250424141637_alter_states_table/migration.sql +11 -0
- package/prisma/migrations/20250425105131_alter_user_login_activity_table/migration.sql +9 -0
- package/prisma/migrations/20250428092626_alter_location_tables/migration.sql +34 -0
- package/prisma/migrations/20250428114301_alter_location_table/migration.sql +14 -0
- package/prisma/migrations/20250429103436_alter_event_vendor_table/migration.sql +14 -0
- package/prisma/migrations/20250429135621_alter_event_vendor_table/migration.sql +5 -0
- package/prisma/migrations/20250430094809_alter_form_master_table_added_user_relation/migration.sql +2 -0
- package/prisma/migrations/20250430103440_alter_event_table/migration.sql +3 -0
- package/prisma/migrations/20250501125411_alter_strategies_table/migration.sql +2 -0
- package/prisma/migrations/20250502065554_init_location_table/migration.sql +41 -0
- package/prisma/migrations/20250505104038_alter_bid_quotation_and_dynamic_form/migration.sql +22 -0
- package/prisma/migrations/20250505105253_alter_quotation/migration.sql +5 -0
- package/prisma/migrations/20250505124851_alter_alert_enum/migration.sql +56 -0
- package/prisma/migrations/20250505133250_init_sub_module_table/migration.sql +17 -0
- package/prisma/migrations/20250506054325_alter_event_vendor_bid_status/migration.sql +14 -0
- package/prisma/migrations/20250506102135_init_counter_offer_table/migration.sql +38 -0
- package/prisma/migrations/20250506103355_alter_bid_and_quotaion_table/migration.sql +5 -0
- package/prisma/migrations/20250506110309_alter_tenant_configuration_table/migration.sql +3 -0
- package/prisma/migrations/20250506123527_alter_vendor_kyu_infor_verification_status/migration.sql +2 -0
- package/prisma/migrations/20250507055536_alter_dynamic_form_table/migration.sql +2 -0
- package/prisma/migrations/20250507070518_alter_bid_log_and_quotation_log/migration.sql +15 -0
- package/prisma/migrations/20250507130834_alter_bid_status/migration.sql +10 -0
- package/prisma/migrations/20250508065503_alter_purchase_intake_item_table/migration.sql +16 -0
- package/prisma/migrations/20250508130119_alter_purchase_intake_item/migration.sql +13 -0
- package/prisma/migrations/20250512082244_altered_template_table_to_add_currency_id/migration.sql +12 -0
- package/prisma/migrations/20250512100817_alter_approval_journey_table/migration.sql +3 -0
- package/prisma/migrations/20250513083700_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250514100915_alter_event_table_added_template_realtion/migration.sql +2 -0
- package/prisma/migrations/20250514103503_alter_vendor_table_added_is_kyc_approved_column/migration.sql +2 -0
- package/prisma/migrations/20250520131556_init_purchase_order_table/migration.sql +52 -0
- package/prisma/migrations/20250521113946_alter_purchase_order_status_enum/migration.sql +16 -0
- package/prisma/migrations/20250522083917_alter_event_vendor_bid_status_enum/migration.sql +17 -0
- package/prisma/migrations/20250522131610_updated_vendor_table/migration.sql +16 -0
- package/prisma/migrations/20250523051058_alter_vendor_kyc_verificaiton_status_enum/migration.sql +2 -0
- package/prisma/migrations/20250526072120_alter_vendor_table/migration.sql +16 -0
- package/prisma/migrations/20250527055351_init_purchase_order_activity_log/migration.sql +41 -0
- package/prisma/migrations/20250528060657_alter_item_tale/migration.sql +14 -0
- package/prisma/migrations/20250528061946_alter_event_item_table/migration.sql +5 -0
- package/prisma/migrations/20250528081337_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250528081524_removed_item_id_from_item_table/migration.sql +11 -0
- package/prisma/migrations/20250528081843_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250528094057_alter_alert_type_enum/migration.sql +11 -0
- package/prisma/migrations/20250529053721_alter_added_quantity_in_purchase_order/migration.sql +2 -0
- package/prisma/migrations/20250602055114_alter_approval_journey_parent_id_to_string/migration.sql +2 -0
- package/prisma/migrations/20250602055748_alter_event_configuration_added_rule_slug/migration.sql +2 -0
- package/prisma/migrations/20250602111042_init_user_vendor_socket_token_table/migration.sql +17 -0
- package/prisma/migrations/20250602125833_alter_bidlog_and_quoatationlog_tableto_add_json_field/migration.sql +5 -0
- package/prisma/migrations/20250603063501_alter_bid_and_quoatation_table/migration.sql +29 -0
- package/prisma/migrations/20250606015045_alter_quotation_log_table/migration.sql +2 -0
- package/prisma/migrations/20250606020918_alter_quotation_table/migration.sql +2 -0
- package/prisma/migrations/20250606022901_alter_quotation_log_table/migration.sql +3 -0
- package/prisma/migrations/20250606054914_init_event_activity_logs_table/migration.sql +35 -0
- package/prisma/migrations/20250606100634_alter_added_counter_offer_status/migration.sql +5 -0
- package/prisma/migrations/20250606100908_alter_counter_offer_table/migration.sql +2 -0
- package/prisma/migrations/20250610055710_alter_enum/migration.sql +16 -0
- package/prisma/migrations/20250610060558_alter_event_and_event_vendor_db/migration.sql +14 -0
- package/prisma/migrations/20250610091013_alter_purchase_intak_item_table/migration.sql +4 -0
- package/prisma/migrations/20250610100156_alter_purchase_intake_item_table/migration.sql +19 -0
- package/prisma/migrations/20250610125706_alter_event_table/migration.sql +6 -0
- package/prisma/migrations/20250610133613_added_timestamp/migration.sql +319 -0
- package/prisma/migrations/20250611090439_init_contact_us_table/migration.sql +23 -0
- package/prisma/migrations/20250611121005_alter_event_vendor_table/migration.sql +10 -0
- package/prisma/migrations/20250612064335_alter_tenant_configuration/migration.sql +3 -0
- package/prisma/migrations/20250612094643_alter_event_vendor_bid_status_enum/migration.sql +2 -0
- package/prisma/migrations/20250618074558_alter_updated_bid_status_and_quotation_status/migration.sql +21 -0
- package/prisma/migrations/20250618122242_alter_added_event_phase_closed/migration.sql +2 -0
- package/prisma/migrations/20250620054518_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250620062723_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250620063056_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250620100507_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250627104958_alter_counter_offer_status/migration.sql +2 -0
- package/prisma/migrations/20250702095923_alter_item_table/migration.sql +74 -0
- package/prisma/migrations/20250702120134_/migration.sql +14 -0
- package/prisma/migrations/20250702150717_alter_attribute_table/migration.sql +9 -0
- package/prisma/migrations/20250703090321_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250707054625_alter_purchase_order_table/migration.sql +15 -0
- package/prisma/migrations/20250707111354_alter_purchase_order_table_and_init_purchase_order_item_table/migration.sql +39 -0
- package/prisma/migrations/20250707111522_alter_purchase_order_item_table/migration.sql +17 -0
- package/prisma/migrations/20250710054113_alter_bid_and_quotation_status/migration.sql +31 -0
- package/prisma/migrations/20250710070813_alter_event_status/migration.sql +2 -0
- package/prisma/migrations/20250710082332_alter_bid_and_quotations_table/migration.sql +36 -0
- package/prisma/migrations/20250714102325_init_upload_log_table/migration.sql +27 -0
- package/prisma/migrations/20250716061012_alter_event_activity_logs_to_activity_logs/migration.sql +48 -0
- package/prisma/migrations/20250716071839_init_chat_thread_chat_message_and_ai_models/migration.sql +56 -0
- package/prisma/migrations/20250716135548_alter_admin_alerts_enum/migration.sql +2 -0
- package/prisma/migrations/20250717100515_init_user_event_configuration/migration.sql +21 -0
- package/prisma/migrations/20250717101037_alter_user_event_configuration_table/migration.sql +19 -0
- package/prisma/migrations/20250718071630_alter_added_module_in_upload_logs_table/migration.sql +5 -0
- package/prisma/migrations/20250718071732_alter_module_enum/migration.sql +15 -0
- package/prisma/migrations/20250721054851_init_export_log_table/migration.sql +34 -0
- package/prisma/migrations/20250722054549_init_fiscal_year_table/migration.sql +22 -0
- package/prisma/migrations/20250722072051_alter_fiscal_year_table_added_uuid/migration.sql +14 -0
- package/prisma/migrations/20250722095259_alter_fiscal_table/migration.sql +9 -0
- package/prisma/migrations/20250723071050_alter_department_table/migration.sql +14 -0
- package/prisma/migrations/20250724071201_alter_export_upload_log_enum/migration.sql +8 -0
- package/prisma/migrations/20250725094759_new_migrate/migration.sql +2 -0
- package/prisma/migrations/20250725095012_alter_migration/migration.sql +2 -0
- package/prisma/migrations/20250728072402_init_budget_management_tables/migration.sql +80 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +2609 -0
- package/prisma/seeders/approval-hierarchy.seed.js +340 -0
- package/prisma/seeders/attribute-value.seed.js +64 -0
- package/prisma/seeders/attribute.seed.js +61 -0
- package/prisma/seeders/category.seed.js +133 -0
- package/prisma/seeders/city.seed.js +147 -0
- package/prisma/seeders/country.seed.js +282 -0
- package/prisma/seeders/currency.seed.js +41 -0
- package/prisma/seeders/customer-notification.seed.js +83 -0
- package/prisma/seeders/department.seed.js +38 -0
- package/prisma/seeders/docs/CORE_SEEDER_OPTIMIZATIONS.md +270 -0
- package/prisma/seeders/docs/GEOGRAPHIC_PERFORMANCE_OPTIMIZATIONS.md +175 -0
- package/prisma/seeders/dynamic-form.seed.js +135 -0
- package/prisma/seeders/email-template.seed.js +68 -0
- package/prisma/seeders/faq-category.seed.js +56 -0
- package/prisma/seeders/faq.seed.js +61 -0
- package/prisma/seeders/form-master.seed.js +55 -0
- package/prisma/seeders/item.seed.js +133 -0
- package/prisma/seeders/permission.seed.js +102 -0
- package/prisma/seeders/region.seed.js +78 -0
- package/prisma/seeders/role-permission.seed.js +70 -0
- package/prisma/seeders/role.seed.js +38 -0
- package/prisma/seeders/seed.js +553 -0
- package/prisma/seeders/serial-number-config.seed.js +58 -0
- package/prisma/seeders/smtp-config.seed.js +61 -0
- package/prisma/seeders/state.seed.js +170 -0
- package/prisma/seeders/strategies.seed.js +54 -0
- package/prisma/seeders/subregion.seed.js +88 -0
- package/prisma/seeders/support-category.seed.js +56 -0
- package/prisma/seeders/template.seed.js +87 -0
- package/prisma/seeders/test-core-seeders.js +276 -0
- package/prisma/seeders/user-department.seed.js +66 -0
- package/prisma/seeders/user-event-configuration.seed.js +47 -0
- package/prisma/seeders/user-role.seed.js +74 -0
- package/prisma/seeders/user.seed.js +114 -0
- package/prisma/seeders/utils/bulk-seeder.js +300 -0
- package/prisma/seeders/utils/config.js +103 -0
- package/prisma/seeders/utils/connection-manager.js +380 -0
- package/prisma/seeders/utils/content-seeder.js +472 -0
- package/prisma/seeders/utils/core-seeder.js +330 -0
- package/prisma/seeders/utils/json-loader.js +69 -0
- package/prisma/seeders/utils/performance-config.js +341 -0
- package/prisma/seeders/utils/performance-helpers.js +206 -0
- package/prisma/seeders/utils/progress-tracker.js +364 -0
- package/prisma/seeders/utils/seeder-config-mapper.js +316 -0
- package/scripts/seed-databases.js +873 -0
- package/scripts/sync-schemas.js +865 -0
- package/scripts/truncate-tables.js +1048 -0
- package/src/prisma/client.d.ts +1 -0
- package/src/prisma/client.js +4 -0
- package/src/prisma/default.d.ts +1 -0
- package/src/prisma/default.js +4 -0
- package/src/prisma/edge.d.ts +1 -0
- package/src/prisma/edge.js +2084 -0
- package/src/prisma/index-browser.js +2043 -0
- package/src/prisma/index.d.ts +202051 -0
- package/src/prisma/index.js +2113 -0
- package/src/prisma/libquery_engine-darwin.dylib.node +0 -0
- package/src/prisma/libquery_engine-darwin.dylib.node.tmp24628 +0 -0
- package/src/prisma/libquery_engine-darwin.dylib.node.tmp29464 +0 -0
- package/src/prisma/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
- package/src/prisma/package.json +140 -0
- package/src/prisma/query_engine-windows.dll.node +0 -0
- package/src/prisma/query_engine-windows.dll.node.tmp4144 +0 -0
- package/src/prisma/runtime/edge-esm.js +34 -0
- package/src/prisma/runtime/edge.js +34 -0
- package/src/prisma/runtime/index-browser.d.ts +370 -0
- package/src/prisma/runtime/index-browser.js +16 -0
- package/src/prisma/runtime/library.d.ts +3647 -0
- package/src/prisma/runtime/library.js +146 -0
- package/src/prisma/runtime/react-native.js +83 -0
- package/src/prisma/runtime/wasm.js +35 -0
- package/src/prisma/schema.prisma +2609 -0
- package/src/prisma/wasm.d.ts +1 -0
- package/src/prisma/wasm.js +2043 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import colors from "colors";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a progress tracker for seeding operations
|
|
5
|
+
* @param {number} total - Total number of items to process
|
|
6
|
+
* @param {string} entityName - Name of the entity being processed (e.g., "users", "roles")
|
|
7
|
+
* @returns {Object} - Progress tracker object with update and complete methods
|
|
8
|
+
*/
|
|
9
|
+
export function createProgressTracker(total, entityName) {
|
|
10
|
+
let processed = 0;
|
|
11
|
+
let lastPercent = -1; // Track last percentage to reduce unnecessary updates
|
|
12
|
+
|
|
13
|
+
// Create a normalized entity name for display
|
|
14
|
+
const displayName = entityName.charAt(0).toUpperCase() + entityName.slice(1);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Updates the progress bar
|
|
18
|
+
* @param {number} increment - Amount to increment progress by (default: 1)
|
|
19
|
+
*/
|
|
20
|
+
const update = (increment = 1) => {
|
|
21
|
+
processed += increment;
|
|
22
|
+
const percent = Math.floor((processed / total) * 100);
|
|
23
|
+
|
|
24
|
+
// For large datasets, update less frequently to improve performance
|
|
25
|
+
const updateThreshold = total > 100000 ? Math.max(Math.floor(total / 50), 1000) : Math.max(Math.floor(total / 100), 10);
|
|
26
|
+
|
|
27
|
+
// Only update display when percentage changes or at regular intervals for large data
|
|
28
|
+
if (
|
|
29
|
+
percent !== lastPercent ||
|
|
30
|
+
processed % updateThreshold === 0 ||
|
|
31
|
+
processed === total
|
|
32
|
+
) {
|
|
33
|
+
lastPercent = percent;
|
|
34
|
+
const filled = Math.floor((40 * processed) / total);
|
|
35
|
+
const bar =
|
|
36
|
+
colors.magenta("█".repeat(filled)) +
|
|
37
|
+
colors.gray("░".repeat(40 - filled));
|
|
38
|
+
|
|
39
|
+
// Add processing rate for large datasets
|
|
40
|
+
const progressText = total > 10000
|
|
41
|
+
? `\rProcessing ${entityName}: ${bar} ${colors.bold(`${percent}%`)} (${processed.toLocaleString()}/${total.toLocaleString()})`
|
|
42
|
+
: `\rProcessing ${entityName}: ${bar} ${colors.bold(`${percent}%`)} (${processed}/${total})`;
|
|
43
|
+
|
|
44
|
+
process.stdout.write(progressText);
|
|
45
|
+
|
|
46
|
+
if (processed === total) {
|
|
47
|
+
process.stdout.write("\n");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Forces completion of the progress bar
|
|
54
|
+
*/
|
|
55
|
+
const complete = () => {
|
|
56
|
+
if (processed < total) {
|
|
57
|
+
processed = total;
|
|
58
|
+
const percent = 100;
|
|
59
|
+
const bar = colors.magenta("█".repeat(40));
|
|
60
|
+
|
|
61
|
+
process.stdout.write(
|
|
62
|
+
`\rProcessing ${entityName}: ${bar} ${colors.bold(
|
|
63
|
+
`${percent}%`
|
|
64
|
+
)} (${processed.toLocaleString()}/${total.toLocaleString()})`
|
|
65
|
+
);
|
|
66
|
+
process.stdout.write("\n");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Logs a message with the current progress context
|
|
72
|
+
* @param {string} message - Message to log
|
|
73
|
+
* @param {string} type - Type of message (info, success, warning, error)
|
|
74
|
+
*/
|
|
75
|
+
const log = (message, type = "info") => {
|
|
76
|
+
// First clear the current line if we're showing a progress bar
|
|
77
|
+
if (processed > 0) {
|
|
78
|
+
process.stdout.write("\r" + " ".repeat(100) + "\r");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let formattedMessage;
|
|
82
|
+
|
|
83
|
+
switch (type) {
|
|
84
|
+
case "success":
|
|
85
|
+
formattedMessage = colors.green(message);
|
|
86
|
+
break;
|
|
87
|
+
case "warning":
|
|
88
|
+
formattedMessage = colors.yellow(message);
|
|
89
|
+
break;
|
|
90
|
+
case "error":
|
|
91
|
+
formattedMessage = colors.red(message);
|
|
92
|
+
break;
|
|
93
|
+
case "info":
|
|
94
|
+
default:
|
|
95
|
+
formattedMessage = colors.gray(message);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
console.log(formattedMessage);
|
|
100
|
+
|
|
101
|
+
// Redraw the progress bar if we're in the middle of displaying it
|
|
102
|
+
if (processed > 0 && processed < total) {
|
|
103
|
+
const percent = Math.floor((processed / total) * 100);
|
|
104
|
+
const filled = Math.floor((40 * processed) / total);
|
|
105
|
+
const bar =
|
|
106
|
+
colors.magenta("█".repeat(filled)) +
|
|
107
|
+
colors.gray("░".repeat(40 - filled));
|
|
108
|
+
|
|
109
|
+
process.stdout.write(
|
|
110
|
+
`\rProcessing ${entityName}: ${bar} ${colors.bold(
|
|
111
|
+
`${percent}%`
|
|
112
|
+
)} (${processed.toLocaleString()}/${total.toLocaleString()})`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
update,
|
|
119
|
+
complete,
|
|
120
|
+
log,
|
|
121
|
+
get progress() {
|
|
122
|
+
return processed;
|
|
123
|
+
},
|
|
124
|
+
get total() {
|
|
125
|
+
return total;
|
|
126
|
+
},
|
|
127
|
+
get percentage() {
|
|
128
|
+
return Math.floor((processed / total) * 100);
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Logs a seeder start message
|
|
135
|
+
* @param {string} entityName - Name of the entity being seeded
|
|
136
|
+
*/
|
|
137
|
+
export function logSeederStart(entityName) {
|
|
138
|
+
console.log(colors.cyan(`Seeding ${entityName} table...`));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Logs a seeder completion message
|
|
143
|
+
* @param {string} entityName - Name of the entity that was seeded
|
|
144
|
+
*/
|
|
145
|
+
export function logSeederComplete(entityName) {
|
|
146
|
+
console.log(colors.green(`${entityName} table seeded successfully`));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Logs a seeder error message
|
|
151
|
+
* @param {string} entityName - Name of the entity that was being seeded
|
|
152
|
+
* @param {Error} error - Error object
|
|
153
|
+
*/
|
|
154
|
+
export function logSeederError(entityName, error) {
|
|
155
|
+
console.error(colors.red(`Error seeding ${entityName}: ${error.message}`));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Global error tracking and skipped records system
|
|
159
|
+
const globalErrorTracker = {
|
|
160
|
+
totalErrors: 0,
|
|
161
|
+
errorsByEntity: new Map(),
|
|
162
|
+
skippedRecords: new Map(),
|
|
163
|
+
processingSummary: new Map()
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Enhanced entity error logging with detailed tracking
|
|
168
|
+
* @param {string} entityType - Type of entity (e.g., "user", "role")
|
|
169
|
+
* @param {string} entityName - Name of the specific entity instance
|
|
170
|
+
* @param {string} errorMessage - Error message
|
|
171
|
+
* @param {Object} errorDetails - Additional error context
|
|
172
|
+
* @param {Object} options - Logging options
|
|
173
|
+
*/
|
|
174
|
+
export function logEntityError(entityType, entityName, errorMessage, errorDetails = {}, options = {}) {
|
|
175
|
+
const timestamp = new Date().toISOString();
|
|
176
|
+
const errorId = `${entityType}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
177
|
+
|
|
178
|
+
// Track the error globally
|
|
179
|
+
globalErrorTracker.totalErrors++;
|
|
180
|
+
|
|
181
|
+
if (!globalErrorTracker.errorsByEntity.has(entityType)) {
|
|
182
|
+
globalErrorTracker.errorsByEntity.set(entityType, []);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const errorRecord = {
|
|
186
|
+
id: errorId,
|
|
187
|
+
timestamp,
|
|
188
|
+
entityType,
|
|
189
|
+
entityName,
|
|
190
|
+
errorMessage,
|
|
191
|
+
errorDetails,
|
|
192
|
+
severity: errorDetails.severity || 'error',
|
|
193
|
+
recoverable: errorDetails.recoverable !== false,
|
|
194
|
+
batchIndex: errorDetails.batchIndex,
|
|
195
|
+
attemptNumber: errorDetails.attemptNumber || 1
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
globalErrorTracker.errorsByEntity.get(entityType).push(errorRecord);
|
|
199
|
+
|
|
200
|
+
// Log based on severity and options
|
|
201
|
+
const logMessage = options.includeTimestamp
|
|
202
|
+
? `[${timestamp}] Error creating ${entityType} ${colors.bold(entityName)}: ${errorMessage}`
|
|
203
|
+
: `Error creating ${entityType} ${colors.bold(entityName)}: ${errorMessage}`;
|
|
204
|
+
|
|
205
|
+
if (errorDetails.severity === 'critical') {
|
|
206
|
+
console.error(colors.red(logMessage));
|
|
207
|
+
if (errorDetails.stackTrace) {
|
|
208
|
+
console.error(colors.gray(`Stack: ${errorDetails.stackTrace}`));
|
|
209
|
+
}
|
|
210
|
+
} else if (errorDetails.severity === 'warning') {
|
|
211
|
+
console.warn(colors.yellow(logMessage));
|
|
212
|
+
} else {
|
|
213
|
+
console.error(colors.yellow(logMessage));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Log additional context if provided
|
|
217
|
+
if (errorDetails.batchIndex !== undefined) {
|
|
218
|
+
console.error(colors.gray(` Batch: ${errorDetails.batchIndex}, Attempt: ${errorDetails.attemptNumber || 1}`));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (errorDetails.context) {
|
|
222
|
+
console.error(colors.gray(` Context: ${JSON.stringify(errorDetails.context)}`));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return errorId;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Track skipped records with reason
|
|
230
|
+
* @param {string} entityType - Type of entity
|
|
231
|
+
* @param {string} entityName - Name of the entity
|
|
232
|
+
* @param {string} reason - Reason for skipping
|
|
233
|
+
* @param {Object} record - The actual record that was skipped
|
|
234
|
+
*/
|
|
235
|
+
export function trackSkippedRecord(entityType, entityName, reason, record = {}) {
|
|
236
|
+
if (!globalErrorTracker.skippedRecords.has(entityType)) {
|
|
237
|
+
globalErrorTracker.skippedRecords.set(entityType, []);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const skippedRecord = {
|
|
241
|
+
timestamp: new Date().toISOString(),
|
|
242
|
+
entityType,
|
|
243
|
+
entityName,
|
|
244
|
+
reason,
|
|
245
|
+
record: record || {},
|
|
246
|
+
id: `${entityType}_skip_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
globalErrorTracker.skippedRecords.get(entityType).push(skippedRecord);
|
|
250
|
+
|
|
251
|
+
console.warn(colors.cyan(`Skipped ${entityType} ${colors.bold(entityName)}: ${reason}`));
|
|
252
|
+
|
|
253
|
+
return skippedRecord.id;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Get error summary for an entity type
|
|
258
|
+
* @param {string} entityType - Type of entity
|
|
259
|
+
* @returns {Object} Error summary
|
|
260
|
+
*/
|
|
261
|
+
export function getErrorSummary(entityType = null) {
|
|
262
|
+
if (entityType) {
|
|
263
|
+
return {
|
|
264
|
+
errors: globalErrorTracker.errorsByEntity.get(entityType) || [],
|
|
265
|
+
skipped: globalErrorTracker.skippedRecords.get(entityType) || [],
|
|
266
|
+
totalErrors: (globalErrorTracker.errorsByEntity.get(entityType) || []).length,
|
|
267
|
+
totalSkipped: (globalErrorTracker.skippedRecords.get(entityType) || []).length
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
totalErrors: globalErrorTracker.totalErrors,
|
|
273
|
+
errorsByEntity: Object.fromEntries(globalErrorTracker.errorsByEntity),
|
|
274
|
+
skippedRecords: Object.fromEntries(globalErrorTracker.skippedRecords),
|
|
275
|
+
summary: generateGlobalErrorSummary()
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Generate a comprehensive error summary
|
|
281
|
+
*/
|
|
282
|
+
function generateGlobalErrorSummary() {
|
|
283
|
+
const summary = {
|
|
284
|
+
totalEntitiesWithErrors: globalErrorTracker.errorsByEntity.size,
|
|
285
|
+
totalEntitiesWithSkipped: globalErrorTracker.skippedRecords.size,
|
|
286
|
+
totalErrors: globalErrorTracker.totalErrors,
|
|
287
|
+
totalSkipped: 0,
|
|
288
|
+
errorsByEntityType: {},
|
|
289
|
+
skippedByEntityType: {}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// Count errors by entity type
|
|
293
|
+
for (const [entityType, errors] of globalErrorTracker.errorsByEntity) {
|
|
294
|
+
summary.errorsByEntityType[entityType] = errors.length;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Count skipped by entity type
|
|
298
|
+
for (const [entityType, skipped] of globalErrorTracker.skippedRecords) {
|
|
299
|
+
summary.skippedByEntityType[entityType] = skipped.length;
|
|
300
|
+
summary.totalSkipped += skipped.length;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return summary;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Reset error tracking (useful for testing or multiple runs)
|
|
308
|
+
*/
|
|
309
|
+
export function resetErrorTracking() {
|
|
310
|
+
globalErrorTracker.totalErrors = 0;
|
|
311
|
+
globalErrorTracker.errorsByEntity.clear();
|
|
312
|
+
globalErrorTracker.skippedRecords.clear();
|
|
313
|
+
globalErrorTracker.processingSummary.clear();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Log final validation summary comparing source vs processed counts
|
|
318
|
+
* @param {Object} validationData - Validation data
|
|
319
|
+
*/
|
|
320
|
+
export function logValidationSummary(validationData) {
|
|
321
|
+
console.log(colors.cyan("\n📊 FINAL VALIDATION SUMMARY"));
|
|
322
|
+
console.log(colors.cyan("================================"));
|
|
323
|
+
|
|
324
|
+
const summary = getErrorSummary();
|
|
325
|
+
|
|
326
|
+
// Source vs processed counts
|
|
327
|
+
if (validationData.sourceData) {
|
|
328
|
+
for (const [entityType, sourceCount] of Object.entries(validationData.sourceData)) {
|
|
329
|
+
const processed = validationData.processedData?.[entityType] || 0;
|
|
330
|
+
const created = validationData.createdData?.[entityType] || 0;
|
|
331
|
+
const errors = summary.errorsByEntityType[entityType] || 0;
|
|
332
|
+
const skipped = summary.skippedByEntityType[entityType] || 0;
|
|
333
|
+
|
|
334
|
+
console.log(colors.white(`\n${entityType.toUpperCase()}:`));
|
|
335
|
+
console.log(colors.gray(` Source records: ${sourceCount.toLocaleString()}`));
|
|
336
|
+
console.log(colors.gray(` Processed: ${processed.toLocaleString()}`));
|
|
337
|
+
console.log(colors.green(` Created: ${created.toLocaleString()}`));
|
|
338
|
+
|
|
339
|
+
if (errors > 0) {
|
|
340
|
+
console.log(colors.red(` Errors: ${errors.toLocaleString()}`));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (skipped > 0) {
|
|
344
|
+
console.log(colors.yellow(` Skipped: ${skipped.toLocaleString()}`));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const successRate = sourceCount > 0 ? ((created / sourceCount) * 100).toFixed(2) : '0.00';
|
|
348
|
+
console.log(colors.cyan(` Success rate: ${successRate}%`));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
console.log(colors.cyan("\n📈 OVERALL SUMMARY:"));
|
|
353
|
+
console.log(colors.gray(`Total errors: ${summary.totalErrors.toLocaleString()}`));
|
|
354
|
+
console.log(colors.gray(`Total skipped: ${summary.totalSkipped.toLocaleString()}`));
|
|
355
|
+
console.log(colors.gray(`Entities with issues: ${summary.totalEntitiesWithErrors}`));
|
|
356
|
+
|
|
357
|
+
if (summary.totalErrors > 0 || summary.totalSkipped > 0) {
|
|
358
|
+
console.log(colors.yellow("\n⚠️ Some records had issues. Check logs above for details."));
|
|
359
|
+
} else {
|
|
360
|
+
console.log(colors.green("\n✅ All records processed successfully!"));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
console.log(colors.cyan("================================\n"));
|
|
364
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeder Configuration Mapping System
|
|
3
|
+
*
|
|
4
|
+
* This module provides:
|
|
5
|
+
* 1. Mapping of seeders to categories (Geographic, Core, Content)
|
|
6
|
+
* 2. Auto-config selection based on data volume
|
|
7
|
+
* 3. Fallback config for unmapped seeders
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createPerformanceConfig, PERFORMANCE_PRESETS } from './performance-config.js';
|
|
11
|
+
import { getCurrentEnvironmentConfig } from './config.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Seeder category mappings
|
|
15
|
+
*/
|
|
16
|
+
export const SEEDER_CATEGORIES = {
|
|
17
|
+
GEOGRAPHIC: 'geographic',
|
|
18
|
+
CORE: 'core',
|
|
19
|
+
CONTENT: 'content'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Map each seeder to its category and configuration key
|
|
24
|
+
*/
|
|
25
|
+
export const SEEDER_MAPPING = {
|
|
26
|
+
// Geographic seeders
|
|
27
|
+
'country': { category: SEEDER_CATEGORIES.GEOGRAPHIC, configKey: 'countries' },
|
|
28
|
+
'state': { category: SEEDER_CATEGORIES.GEOGRAPHIC, configKey: 'states' },
|
|
29
|
+
'city': { category: SEEDER_CATEGORIES.GEOGRAPHIC, configKey: 'cities' },
|
|
30
|
+
'region': { category: SEEDER_CATEGORIES.GEOGRAPHIC, configKey: 'regions' },
|
|
31
|
+
'subregion': { category: SEEDER_CATEGORIES.GEOGRAPHIC, configKey: 'subregions' },
|
|
32
|
+
|
|
33
|
+
// Core seeders
|
|
34
|
+
'user': { category: SEEDER_CATEGORIES.CORE, configKey: 'users' },
|
|
35
|
+
'role': { category: SEEDER_CATEGORIES.CORE, configKey: 'roles' },
|
|
36
|
+
'permission': { category: SEEDER_CATEGORIES.CORE, configKey: 'permissions' },
|
|
37
|
+
'department': { category: SEEDER_CATEGORIES.CORE, configKey: 'departments' },
|
|
38
|
+
'currency': { category: SEEDER_CATEGORIES.CORE, configKey: 'currencies' },
|
|
39
|
+
'role-permission': { category: SEEDER_CATEGORIES.CORE, configKey: 'permissions' },
|
|
40
|
+
'user-role': { category: SEEDER_CATEGORIES.CORE, configKey: 'users' },
|
|
41
|
+
'user-department': { category: SEEDER_CATEGORIES.CORE, configKey: 'users' },
|
|
42
|
+
'serial-number-config': { category: SEEDER_CATEGORIES.CORE, configKey: 'departments' },
|
|
43
|
+
|
|
44
|
+
// Content seeders
|
|
45
|
+
'category': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'categories' },
|
|
46
|
+
'item': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'items' },
|
|
47
|
+
'attribute': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'attributes' },
|
|
48
|
+
'attribute-value': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'attributes' },
|
|
49
|
+
'template': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'templates' },
|
|
50
|
+
'email-template': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'templates' },
|
|
51
|
+
'dynamic-form': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'templates' },
|
|
52
|
+
'form-master': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'templates' },
|
|
53
|
+
'faq': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'categories' },
|
|
54
|
+
'faq-category': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'categories' },
|
|
55
|
+
'support-category': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'categories' },
|
|
56
|
+
'approval-hierarchy': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'categories' },
|
|
57
|
+
'customer-notification': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'templates' },
|
|
58
|
+
'smtp-config': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'templates' },
|
|
59
|
+
'strategies': { category: SEEDER_CATEGORIES.CONTENT, configKey: 'categories' }
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Data volume thresholds for auto-config selection
|
|
64
|
+
*/
|
|
65
|
+
const DATA_VOLUME_THRESHOLDS = {
|
|
66
|
+
// Number of records thresholds
|
|
67
|
+
HIGH_VOLUME: 50000,
|
|
68
|
+
MEDIUM_VOLUME: 5000,
|
|
69
|
+
LOW_VOLUME: 500,
|
|
70
|
+
|
|
71
|
+
// Memory usage thresholds (in MB)
|
|
72
|
+
HIGH_MEMORY: 1024,
|
|
73
|
+
MEDIUM_MEMORY: 512,
|
|
74
|
+
LOW_MEMORY: 128
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Fallback configuration for unmapped seeders
|
|
79
|
+
*/
|
|
80
|
+
const FALLBACK_CONFIG = {
|
|
81
|
+
batchSize: 100,
|
|
82
|
+
maxConcurrentBatches: 2,
|
|
83
|
+
memoryThreshold: 0.4,
|
|
84
|
+
connectionPoolSize: 5,
|
|
85
|
+
queryTimeout: 30000,
|
|
86
|
+
retryAttempts: 3,
|
|
87
|
+
retryDelay: 1000,
|
|
88
|
+
exponentialBackoff: true
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Auto-determine data volume based on various factors
|
|
93
|
+
*
|
|
94
|
+
* @param {Object} options - Options for volume determination
|
|
95
|
+
* @param {number} options.expectedRecords - Expected number of records
|
|
96
|
+
* @param {number} options.availableMemory - Available memory in bytes
|
|
97
|
+
* @param {string[]} options.countryFilter - Country filter array
|
|
98
|
+
* @returns {string} 'High', 'Medium', or 'Low'
|
|
99
|
+
*/
|
|
100
|
+
export function determineDataVolume(options = {}) {
|
|
101
|
+
const {
|
|
102
|
+
expectedRecords = 0,
|
|
103
|
+
availableMemory = 0,
|
|
104
|
+
countryFilter = [],
|
|
105
|
+
seederType = 'unknown'
|
|
106
|
+
} = options;
|
|
107
|
+
|
|
108
|
+
// Convert memory to MB
|
|
109
|
+
const availableMemoryMB = availableMemory / (1024 * 1024);
|
|
110
|
+
|
|
111
|
+
// Geographic data volume is heavily influenced by country filtering
|
|
112
|
+
if (seederType === 'geographic') {
|
|
113
|
+
if (countryFilter.length === 0) {
|
|
114
|
+
// All countries - high volume
|
|
115
|
+
return 'High';
|
|
116
|
+
} else if (countryFilter.length <= 3) {
|
|
117
|
+
// Few countries - medium volume
|
|
118
|
+
return 'Medium';
|
|
119
|
+
} else {
|
|
120
|
+
// Many countries but filtered - medium to high
|
|
121
|
+
return countryFilter.length > 10 ? 'High' : 'Medium';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// For other types, use record count and memory
|
|
126
|
+
if (expectedRecords > DATA_VOLUME_THRESHOLDS.HIGH_VOLUME ||
|
|
127
|
+
availableMemoryMB > DATA_VOLUME_THRESHOLDS.HIGH_MEMORY) {
|
|
128
|
+
return 'High';
|
|
129
|
+
} else if (expectedRecords > DATA_VOLUME_THRESHOLDS.MEDIUM_VOLUME ||
|
|
130
|
+
availableMemoryMB > DATA_VOLUME_THRESHOLDS.MEDIUM_MEMORY) {
|
|
131
|
+
return 'Medium';
|
|
132
|
+
} else {
|
|
133
|
+
return 'Low';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Select appropriate configuration preset based on data volume and environment
|
|
139
|
+
*
|
|
140
|
+
* @param {string} dataVolume - 'High', 'Medium', or 'Low'
|
|
141
|
+
* @param {string} environment - Environment name
|
|
142
|
+
* @returns {Object} Performance preset configuration
|
|
143
|
+
*/
|
|
144
|
+
export function selectConfigPreset(dataVolume, environment = 'development') {
|
|
145
|
+
// Environment takes precedence
|
|
146
|
+
if (environment === 'production') {
|
|
147
|
+
return PERFORMANCE_PRESETS.PRODUCTION;
|
|
148
|
+
} else if (environment === 'test') {
|
|
149
|
+
return PERFORMANCE_PRESETS.CI_CD;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// For development, adjust based on data volume
|
|
153
|
+
switch (dataVolume) {
|
|
154
|
+
case 'High':
|
|
155
|
+
return {
|
|
156
|
+
...PERFORMANCE_PRESETS.PRODUCTION,
|
|
157
|
+
profile: 'speed',
|
|
158
|
+
overrides: {
|
|
159
|
+
...PERFORMANCE_PRESETS.PRODUCTION.overrides,
|
|
160
|
+
// Reduce batch sizes slightly for development stability
|
|
161
|
+
geographic: {
|
|
162
|
+
cities: { batchSize: 15000, maxConcurrentBatches: 8 }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
case 'Medium':
|
|
167
|
+
return PERFORMANCE_PRESETS.DEVELOPMENT;
|
|
168
|
+
case 'Low':
|
|
169
|
+
default:
|
|
170
|
+
return {
|
|
171
|
+
...PERFORMANCE_PRESETS.CI_CD,
|
|
172
|
+
profile: 'stability'
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get configuration for a specific seeder
|
|
179
|
+
*
|
|
180
|
+
* @param {string} seederName - Name of the seeder
|
|
181
|
+
* @param {Object} performanceConfig - Performance configuration instance
|
|
182
|
+
* @returns {Object} Configuration for the seeder
|
|
183
|
+
*/
|
|
184
|
+
export function getSeederConfig(seederName, performanceConfig) {
|
|
185
|
+
// Clean seeder name (remove .seed.js suffix if present)
|
|
186
|
+
const cleanName = seederName.replace(/\.seed\.js$/, '');
|
|
187
|
+
|
|
188
|
+
// Check if seeder is mapped
|
|
189
|
+
const mapping = SEEDER_MAPPING[cleanName];
|
|
190
|
+
|
|
191
|
+
if (mapping) {
|
|
192
|
+
// Get config from performance config
|
|
193
|
+
const config = performanceConfig.getConfig(mapping.category, mapping.configKey);
|
|
194
|
+
if (config) {
|
|
195
|
+
return {
|
|
196
|
+
...config,
|
|
197
|
+
category: mapping.category,
|
|
198
|
+
seederName: cleanName
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Return fallback config for unmapped seeders
|
|
204
|
+
return {
|
|
205
|
+
...FALLBACK_CONFIG,
|
|
206
|
+
category: 'unknown',
|
|
207
|
+
seederName: cleanName,
|
|
208
|
+
fallback: true
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get all seeders by category
|
|
214
|
+
*
|
|
215
|
+
* @param {string} category - Category name
|
|
216
|
+
* @returns {Array} Array of seeder names in the category
|
|
217
|
+
*/
|
|
218
|
+
export function getSeedersByCategory(category) {
|
|
219
|
+
return Object.entries(SEEDER_MAPPING)
|
|
220
|
+
.filter(([_, mapping]) => mapping.category === category)
|
|
221
|
+
.map(([seederName]) => seederName);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Create a configured seeder manager
|
|
226
|
+
*
|
|
227
|
+
* @param {Object} options - Configuration options
|
|
228
|
+
* @returns {Object} Seeder manager with configuration methods
|
|
229
|
+
*/
|
|
230
|
+
export function createSeederManager(options = {}) {
|
|
231
|
+
const {
|
|
232
|
+
environment = process.env.NODE_ENV || 'development',
|
|
233
|
+
countryFilter = [],
|
|
234
|
+
expectedRecords = 0,
|
|
235
|
+
availableMemory = process.memoryUsage().free
|
|
236
|
+
} = options;
|
|
237
|
+
|
|
238
|
+
// Determine data volume
|
|
239
|
+
const dataVolume = determineDataVolume({
|
|
240
|
+
expectedRecords,
|
|
241
|
+
availableMemory,
|
|
242
|
+
countryFilter,
|
|
243
|
+
seederType: 'mixed'
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Select appropriate preset
|
|
247
|
+
const preset = selectConfigPreset(dataVolume, environment);
|
|
248
|
+
|
|
249
|
+
// Create performance configuration
|
|
250
|
+
const performanceConfig = createPerformanceConfig(preset);
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
dataVolume,
|
|
254
|
+
preset,
|
|
255
|
+
performanceConfig,
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Get configuration for a specific seeder
|
|
259
|
+
*/
|
|
260
|
+
getConfig(seederName) {
|
|
261
|
+
return getSeederConfig(seederName, performanceConfig);
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Get all seeders by category
|
|
266
|
+
*/
|
|
267
|
+
getSeedersByCategory(category) {
|
|
268
|
+
return getSeedersByCategory(category);
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get category for a seeder
|
|
273
|
+
*/
|
|
274
|
+
getSeederCategory(seederName) {
|
|
275
|
+
const cleanName = seederName.replace(/\.seed\.js$/, '');
|
|
276
|
+
const mapping = SEEDER_MAPPING[cleanName];
|
|
277
|
+
return mapping ? mapping.category : 'unknown';
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Check if seeder is mapped
|
|
282
|
+
*/
|
|
283
|
+
isSeederMapped(seederName) {
|
|
284
|
+
const cleanName = seederName.replace(/\.seed\.js$/, '');
|
|
285
|
+
return SEEDER_MAPPING.hasOwnProperty(cleanName);
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Log configuration summary
|
|
290
|
+
*/
|
|
291
|
+
logConfigSummary() {
|
|
292
|
+
console.log('\n=== Seeder Configuration Summary ===');
|
|
293
|
+
console.log(`Environment: ${environment}`);
|
|
294
|
+
console.log(`Data Volume: ${dataVolume}`);
|
|
295
|
+
console.log(`Preset: ${preset.profile || 'custom'}`);
|
|
296
|
+
console.log(`Country Filter: ${countryFilter.length > 0 ? countryFilter.join(', ') : 'None'}`);
|
|
297
|
+
|
|
298
|
+
console.log('\nCategory Mappings:');
|
|
299
|
+
Object.values(SEEDER_CATEGORIES).forEach(category => {
|
|
300
|
+
const seeders = getSeedersByCategory(category);
|
|
301
|
+
console.log(` ${category.toUpperCase()}: ${seeders.length} seeders`);
|
|
302
|
+
seeders.forEach(seeder => {
|
|
303
|
+
const config = this.getConfig(seeder);
|
|
304
|
+
console.log(` - ${seeder}: batch=${config.batchSize}, concurrent=${config.maxConcurrentBatches}`);
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
console.log('\n====================================\n');
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Export category constants for easy access
|
|
315
|
+
*/
|
|
316
|
+
export { SEEDER_CATEGORIES as CATEGORIES };
|