monkeybrain-runtime 1.0.0__py3-none-any.whl
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.
- monkeybrain_runtime-1.0.0.dist-info/METADATA +76 -0
- monkeybrain_runtime-1.0.0.dist-info/RECORD +838 -0
- monkeybrain_runtime-1.0.0.dist-info/WHEEL +5 -0
- monkeybrain_runtime-1.0.0.dist-info/entry_points.txt +3 -0
- monkeybrain_runtime-1.0.0.dist-info/top_level.txt +2 -0
- services/__init__.py +8 -0
- services/agentos/__init__.py +0 -0
- services/agentos/main.py +1 -0
- services/assets/helpers/__init__.py +12 -0
- services/assets/helpers/device.py +59 -0
- services/assets/helpers/equipment.py +179 -0
- services/assets/helpers/instruments.py +72 -0
- services/assets/helpers/machines.py +183 -0
- services/assets/helpers/materials.py +76 -0
- services/assets/helpers/parts.py +116 -0
- services/assets/helpers/plc.py +134 -0
- services/assets/helpers/tags.py +108 -0
- services/assets/helpers/tools.py +101 -0
- services/assets/main.py +75 -0
- services/assets/models/__init__.py +12 -0
- services/assets/models/device.py +79 -0
- services/assets/models/equipment.py +222 -0
- services/assets/models/instruments.py +85 -0
- services/assets/models/machines.py +230 -0
- services/assets/models/material.py +266 -0
- services/assets/models/parts.py +96 -0
- services/assets/models/plc.py +264 -0
- services/assets/models/tags.py +76 -0
- services/assets/models/tools.py +179 -0
- services/assets/routers/__init__.py +12 -0
- services/assets/routers/classes.py +65 -0
- services/assets/routers/device.py +86 -0
- services/assets/routers/equipment.py +145 -0
- services/assets/routers/families.py +61 -0
- services/assets/routers/instruments.py +70 -0
- services/assets/routers/machines.py +136 -0
- services/assets/routers/materials.py +105 -0
- services/assets/routers/parts.py +130 -0
- services/assets/routers/plc.py +94 -0
- services/assets/routers/subclasses.py +68 -0
- services/assets/routers/tags.py +138 -0
- services/assets/routers/tools.py +113 -0
- services/auth/helpers/__init__.py +13 -0
- services/auth/helpers/approval_decisions.py +261 -0
- services/auth/helpers/audit_elasticsearch_sync.py +350 -0
- services/auth/helpers/departments.py +53 -0
- services/auth/helpers/graph_store.py +848 -0
- services/auth/helpers/influx_store.py +280 -0
- services/auth/helpers/me.py +33 -0
- services/auth/helpers/nats_consumer.py +618 -0
- services/auth/helpers/nats_store.py +242 -0
- services/auth/helpers/permissions.py +62 -0
- services/auth/helpers/roles.py +87 -0
- services/auth/helpers/store.py +54 -0
- services/auth/helpers/team_members.py +155 -0
- services/auth/helpers/teams.py +87 -0
- services/auth/helpers/tokens.py +71 -0
- services/auth/helpers/users.py +119 -0
- services/auth/helpers/websocket_broadcast.py +41 -0
- services/auth/main.py +88 -0
- services/auth/models/__init__.py +12 -0
- services/auth/models/departments.py +55 -0
- services/auth/models/login.py +20 -0
- services/auth/models/permissions.py +61 -0
- services/auth/models/roles.py +53 -0
- services/auth/models/session.py +26 -0
- services/auth/models/teamMembers.py +59 -0
- services/auth/models/teams.py +56 -0
- services/auth/models/users.py +77 -0
- services/auth/routers/__init__.py +14 -0
- services/auth/routers/auth.py +3839 -0
- services/auth/routers/departments.py +84 -0
- services/auth/routers/integration_config.py +703 -0
- services/auth/routers/me.py +28 -0
- services/auth/routers/permissions.py +96 -0
- services/auth/routers/roles.py +139 -0
- services/auth/routers/session.py +224 -0
- services/auth/routers/team_members.py +152 -0
- services/auth/routers/teams.py +112 -0
- services/auth/routers/users.py +131 -0
- services/auth/routers/websocket_events.py +247 -0
- services/batch_execution/__init__.py +19 -0
- services/batch_execution/pipeline_triggers/__init__.py +53 -0
- services/batch_execution/pipeline_triggers/pipeline_parameter_adjuster.py +440 -0
- services/batch_execution/pipeline_triggers/pipeline_trigger_engine.py +445 -0
- services/batch_execution/pipeline_triggers/re_evaluation_queue.py +341 -0
- services/batch_execution/pipeline_triggers/test_phase3_implementation.py +553 -0
- services/batch_execution/pipeline_triggers/workflow_reevaluator.py +367 -0
- services/batch_execution/smoke_test_e2e_feedback_loop.py +704 -0
- services/batch_execution/workflow_executor.py +478 -0
- services/changeover/helpers/__init__.py +11 -0
- services/changeover/helpers/changeover.py +87 -0
- services/changeover/helpers/changeover_common.py +55 -0
- services/changeover/helpers/changeover_events.py +66 -0
- services/changeover/helpers/changeover_kpis.py +33 -0
- services/changeover/helpers/changeover_matrix.py +60 -0
- services/changeover/helpers/changeover_procedures.py +164 -0
- services/changeover/helpers/changeover_windows.py +96 -0
- services/changeover/main.py +52 -0
- services/changeover/models/__init__.py +11 -0
- services/changeover/models/changeover.py +73 -0
- services/changeover/models/changeover_events.py +142 -0
- services/changeover/models/changeover_kpis.py +75 -0
- services/changeover/models/changeover_matrix.py +63 -0
- services/changeover/models/changeover_procedures.py +108 -0
- services/changeover/models/changeover_tasks.py +87 -0
- services/changeover/models/changeover_windows.py +72 -0
- services/changeover/routers/__init__.py +9 -0
- services/changeover/routers/changeover_events.py +127 -0
- services/changeover/routers/changeover_kpis.py +80 -0
- services/changeover/routers/changeover_matrix.py +80 -0
- services/changeover/routers/changeover_procedures.py +118 -0
- services/changeover/routers/changeover_windows.py +98 -0
- services/common/__init__.py +2 -0
- services/common/approval_chains.py +648 -0
- services/common/auth.py +56 -0
- services/common/cdc.py +52 -0
- services/common/compat.py +217 -0
- services/common/compliance.py +562 -0
- services/common/config.py +134 -0
- services/common/cors.py +17 -0
- services/common/data_transformation.py +195 -0
- services/common/db.py +577 -0
- services/common/embeddings.py +97 -0
- services/common/event_reducers.py +194 -0
- services/common/event_types.py +51 -0
- services/common/integration_ingestion.py +169 -0
- services/common/logging.py +204 -0
- services/common/models/__init__.py +2 -0
- services/common/models/databricks.py +25 -0
- services/common/models/enums.py +64 -0
- services/common/module_control.py +422 -0
- services/common/mongo_cdc_watcher.py +106 -0
- services/common/n8n_auth.py +22 -0
- services/common/neo4j_mirror.py +1087 -0
- services/common/ontology_registry.py +110 -0
- services/common/reasoning_traces.py +52 -0
- services/common/supply_chain_cdc.py +555 -0
- services/common/tracing.py +159 -0
- services/common/utils.py +30 -0
- services/customers/helpers/__init__.py +8 -0
- services/customers/helpers/customer_details.py +64 -0
- services/customers/helpers/customer_metadata.py +64 -0
- services/customers/helpers/customer_order_metrics.py +67 -0
- services/customers/helpers/customer_payment_data.py +67 -0
- services/customers/main.py +50 -0
- services/customers/models/__init__.py +8 -0
- services/customers/models/customer_details.py +42 -0
- services/customers/models/customer_metadata.py +97 -0
- services/customers/models/customer_order_metrics.py +86 -0
- services/customers/models/customer_payment_data.py +60 -0
- services/customers/routers/__init__.py +8 -0
- services/customers/routers/customer_details.py +88 -0
- services/customers/routers/customer_metadata.py +88 -0
- services/customers/routers/customer_order_metrics.py +88 -0
- services/customers/routers/customer_payment_data.py +88 -0
- services/documents/__init__.py +1 -0
- services/documents/helpers/__init__.py +6 -0
- services/documents/helpers/document_metadata.py +569 -0
- services/documents/helpers/document_workflows.py +215 -0
- services/documents/helpers/report_templates.py +113 -0
- services/documents/main.py +49 -0
- services/documents/models/__init__.py +6 -0
- services/documents/models/document_metadata.py +215 -0
- services/documents/models/document_workflows.py +136 -0
- services/documents/models/report_templates.py +132 -0
- services/documents/routers/__init__.py +6 -0
- services/documents/routers/document_metadata.py +654 -0
- services/documents/routers/document_workflows.py +146 -0
- services/documents/routers/report_templates.py +86 -0
- services/events/helpers/__init__.py +5 -0
- services/events/helpers/events.py +394 -0
- services/events/main.py +40 -0
- services/events/models/__init__.py +5 -0
- services/events/models/events.py +50 -0
- services/events/routers/__init__.py +6 -0
- services/events/routers/count_events.py +109 -0
- services/events/routers/events.py +75 -0
- services/events/seed_events.py +196 -0
- services/facilities/helpers/__init__.py +8 -0
- services/facilities/helpers/lines.py +74 -0
- services/facilities/helpers/locations.py +231 -0
- services/facilities/helpers/plants.py +59 -0
- services/facilities/helpers/stages.py +110 -0
- services/facilities/helpers/workstation.py +213 -0
- services/facilities/main.py +60 -0
- services/facilities/models/__init__.py +10 -0
- services/facilities/models/industrialLine.py +72 -0
- services/facilities/models/industrialPlant.py +164 -0
- services/facilities/models/locations.py +74 -0
- services/facilities/models/stages.py +92 -0
- services/facilities/models/worker.py +73 -0
- services/facilities/models/workstation.py +117 -0
- services/facilities/models/workstation_live_state.py +59 -0
- services/facilities/routers/__init__.py +8 -0
- services/facilities/routers/bays.py +81 -0
- services/facilities/routers/buildings.py +92 -0
- services/facilities/routers/floors.py +81 -0
- services/facilities/routers/lines.py +154 -0
- services/facilities/routers/locations.py +208 -0
- services/facilities/routers/plant.py +203 -0
- services/facilities/routers/rooms.py +81 -0
- services/facilities/routers/stages.py +152 -0
- services/facilities/routers/workstation.py +173 -0
- services/file/backup.py +71 -0
- services/file/main.py +45 -0
- services/file/recieve.py +54 -0
- services/file/send.py +55 -0
- services/file/src/core/config.py +90 -0
- services/file/src/core/keycloak.py +152 -0
- services/file/src/core/logging_config.py +9 -0
- services/file/src/core/security.py +33 -0
- services/file/src/helpers/cad_conversion.py +331 -0
- services/file/src/helpers/helpers.py +825 -0
- services/file/src/routes/cad_conversion.py +26 -0
- services/file/src/routes/files.py +136 -0
- services/file/src/routes/presigned.py +154 -0
- services/file/src/services/websocket.py +293 -0
- services/floor_layout/helpers/__init__.py +8 -0
- services/floor_layout/helpers/bays.py +92 -0
- services/floor_layout/helpers/buildings.py +54 -0
- services/floor_layout/helpers/floors.py +65 -0
- services/floor_layout/helpers/rooms.py +76 -0
- services/floor_layout/main.py +52 -0
- services/floor_layout/models/__init__.py +8 -0
- services/floor_layout/models/bays.py +65 -0
- services/floor_layout/models/buildings.py +52 -0
- services/floor_layout/models/floors.py +45 -0
- services/floor_layout/models/rooms.py +61 -0
- services/floor_layout/routers/__init__.py +9 -0
- services/floor_layout/routers/bays.py +143 -0
- services/floor_layout/routers/buildings.py +116 -0
- services/floor_layout/routers/floors.py +89 -0
- services/floor_layout/routers/locations.py +80 -0
- services/floor_layout/routers/rooms.py +134 -0
- services/inventory/helpers/__init__.py +13 -0
- services/inventory/helpers/cycle_counts.py +124 -0
- services/inventory/helpers/inventory_allocations.py +134 -0
- services/inventory/helpers/inventory_item_counts.py +114 -0
- services/inventory/helpers/inventory_item_quantities.py +114 -0
- services/inventory/helpers/inventory_items.py +103 -0
- services/inventory/helpers/inventory_stage_outputs.py +134 -0
- services/inventory/helpers/inventory_transactions.py +112 -0
- services/inventory/helpers/stock_adjustment_requests.py +101 -0
- services/inventory/helpers/warehouse_cycle_counts.py +133 -0
- services/inventory/helpers/warehouse_locations.py +213 -0
- services/inventory/helpers/warehouse_regulated_records.py +123 -0
- services/inventory/main.py +62 -0
- services/inventory/models/__init__.py +17 -0
- services/inventory/models/cycle_counts.py +99 -0
- services/inventory/models/inventory_allocations.py +121 -0
- services/inventory/models/inventory_common.py +65 -0
- services/inventory/models/inventory_enums.py +21 -0
- services/inventory/models/inventory_item_count.py +65 -0
- services/inventory/models/inventory_item_quantity.py +82 -0
- services/inventory/models/inventory_items.py +168 -0
- services/inventory/models/inventory_responses.py +44 -0
- services/inventory/models/inventory_stage_outputs.py +96 -0
- services/inventory/models/inventory_state.py +15 -0
- services/inventory/models/inventory_transactions.py +80 -0
- services/inventory/models/stock_adjustment_requests.py +109 -0
- services/inventory/models/warehouse_cycle_counts.py +119 -0
- services/inventory/models/warehouse_location_models.py +708 -0
- services/inventory/models/warehouse_regulated_records.py +358 -0
- services/inventory/routers/__init__.py +13 -0
- services/inventory/routers/cycle_counts.py +106 -0
- services/inventory/routers/inventory_allocations.py +125 -0
- services/inventory/routers/inventory_item_counts.py +105 -0
- services/inventory/routers/inventory_item_quantities.py +105 -0
- services/inventory/routers/inventory_items.py +109 -0
- services/inventory/routers/inventory_stage_outputs.py +122 -0
- services/inventory/routers/inventory_transactions.py +96 -0
- services/inventory/routers/stock_adjustment_requests.py +124 -0
- services/inventory/routers/warehouse_cycle_counts.py +124 -0
- services/inventory/routers/warehouse_locations.py +426 -0
- services/inventory/routers/warehouse_regulated_records.py +273 -0
- services/iot/helpers/__init__.py +8 -0
- services/iot/helpers/ble_device.py +87 -0
- services/iot/helpers/mqtt_bridge.py +115 -0
- services/iot/helpers/sensor_readings.py +63 -0
- services/iot/helpers/sensors.py +77 -0
- services/iot/helpers/servers.py +72 -0
- services/iot/helpers/uwb_device.py +95 -0
- services/iot/main.py +53 -0
- services/iot/models/__init__.py +8 -0
- services/iot/models/ble_device.py +118 -0
- services/iot/models/sensors.py +256 -0
- services/iot/models/servers.py +206 -0
- services/iot/models/uwb_device.py +106 -0
- services/iot/routers/__init__.py +8 -0
- services/iot/routers/ble_device.py +110 -0
- services/iot/routers/sensors.py +144 -0
- services/iot/routers/servers.py +141 -0
- services/iot/routers/uwb_device.py +148 -0
- services/module_control/__init__.py +1 -0
- services/module_control/helpers/__init__.py +1 -0
- services/module_control/helpers/integration_config.py +243 -0
- services/module_control/helpers/security.py +104 -0
- services/module_control/main.py +44 -0
- services/module_control/models/__init__.py +1 -0
- services/module_control/models/module_control.py +65 -0
- services/module_control/routers/__init__.py +1 -0
- services/module_control/routers/module_control.py +219 -0
- services/orders/helpers/__init__.py +11 -0
- services/orders/helpers/invoices.py +123 -0
- services/orders/helpers/order_customer_metrics.py +61 -0
- services/orders/helpers/order_details.py +71 -0
- services/orders/helpers/order_metadata.py +61 -0
- services/orders/helpers/order_payment_metadata.py +74 -0
- services/orders/helpers/orders.py +119 -0
- services/orders/helpers/sales_orders.py +136 -0
- services/orders/main.py +56 -0
- services/orders/models/__init__.py +11 -0
- services/orders/models/invoices.py +415 -0
- services/orders/models/order_customer_metrics.py +78 -0
- services/orders/models/order_details.py +46 -0
- services/orders/models/order_metadata.py +60 -0
- services/orders/models/order_payment_metadata.py +63 -0
- services/orders/models/orders.py +64 -0
- services/orders/models/sales_orders.py +130 -0
- services/orders/routers/__init__.py +11 -0
- services/orders/routers/invoices.py +111 -0
- services/orders/routers/order_customer_metrics.py +87 -0
- services/orders/routers/order_details.py +87 -0
- services/orders/routers/order_metadata.py +87 -0
- services/orders/routers/order_payment_metadata.py +87 -0
- services/orders/routers/orders.py +74 -0
- services/orders/routers/sales_orders.py +111 -0
- services/pm/helpers/__init__.py +14 -0
- services/pm/helpers/calendar_bookings.py +114 -0
- services/pm/helpers/calibration_point.py +110 -0
- services/pm/helpers/calibrations.py +196 -0
- services/pm/helpers/checklists.py +318 -0
- services/pm/helpers/cleaning.py +333 -0
- services/pm/helpers/downtime.py +376 -0
- services/pm/helpers/kanban_boards.py +186 -0
- services/pm/helpers/maintainance.py +177 -0
- services/pm/helpers/sop.py +1155 -0
- services/pm/helpers/sop_cdc.py +324 -0
- services/pm/helpers/weekly_schedules.py +79 -0
- services/pm/main.py +62 -0
- services/pm/models/__init__.py +14 -0
- services/pm/models/calendar_booking.py +82 -0
- services/pm/models/calibration_point.py +44 -0
- services/pm/models/calibrations.py +167 -0
- services/pm/models/checklists.py +117 -0
- services/pm/models/cleaning.py +203 -0
- services/pm/models/downtime.py +109 -0
- services/pm/models/kanban_board.py +178 -0
- services/pm/models/maintainanceLog.py +148 -0
- services/pm/models/sop.py +152 -0
- services/pm/models/weekly_schedule.py +91 -0
- services/pm/routers/__init__.py +14 -0
- services/pm/routers/calendar_bookings.py +143 -0
- services/pm/routers/calibration_point.py +94 -0
- services/pm/routers/calibrations.py +232 -0
- services/pm/routers/checklists.py +188 -0
- services/pm/routers/cleaning.py +127 -0
- services/pm/routers/downtime.py +143 -0
- services/pm/routers/kanban_boards.py +283 -0
- services/pm/routers/maintainance.py +241 -0
- services/pm/routers/sop.py +437 -0
- services/pm/routers/weekly_schedules.py +108 -0
- services/process_definitions/helpers/__init__.py +11 -0
- services/process_definitions/helpers/cpp_cqa_registry.py +120 -0
- services/process_definitions/helpers/mbmr_templates.py +107 -0
- services/process_definitions/helpers/packing_instructions.py +113 -0
- services/process_definitions/helpers/process_constraints.py +495 -0
- services/process_definitions/helpers/process_corrections.py +279 -0
- services/process_definitions/helpers/process_definition.py +996 -0
- services/process_definitions/helpers/process_node_catalog.py +786 -0
- services/process_definitions/helpers/process_post_checks.py +441 -0
- services/process_definitions/helpers/process_pre_checks.py +351 -0
- services/process_definitions/helpers/process_steps.py +220 -0
- services/process_definitions/main.py +71 -0
- services/process_definitions/models/__init__.py +13 -0
- services/process_definitions/models/cpp_cqa_registry.py +145 -0
- services/process_definitions/models/gxp_change_controls.py +38 -0
- services/process_definitions/models/gxp_risk_assessments.py +30 -0
- services/process_definitions/models/gxp_validation_evidence.py +33 -0
- services/process_definitions/models/mbmr_templates.py +173 -0
- services/process_definitions/models/packing_instructions.py +176 -0
- services/process_definitions/models/process_constraints.py +159 -0
- services/process_definitions/models/process_corrections.py +118 -0
- services/process_definitions/models/process_definition.py +685 -0
- services/process_definitions/models/process_definition_common.py +48 -0
- services/process_definitions/models/process_node_catalog.py +25 -0
- services/process_definitions/models/process_post_checks.py +171 -0
- services/process_definitions/models/process_pre_checks.py +168 -0
- services/process_definitions/models/process_steps.py +170 -0
- services/process_definitions/node_services/__init__.py +8 -0
- services/process_definitions/node_services/common.py +95 -0
- services/process_definitions/node_services/executor.py +499 -0
- services/process_definitions/node_services/flow_simulator.py +733 -0
- services/process_definitions/node_services/functions.py +193 -0
- services/process_definitions/node_services/messaging.py +44 -0
- services/process_definitions/node_services/models.py +221 -0
- services/process_definitions/node_services/network.py +161 -0
- services/process_definitions/node_services/parsers.py +87 -0
- services/process_definitions/node_services/sequence.py +95 -0
- services/process_definitions/node_services/storage.py +50 -0
- services/process_definitions/node_services/webhooks.py +52 -0
- services/process_definitions/routers/__init__.py +10 -0
- services/process_definitions/routers/cpp_cqa_registry.py +86 -0
- services/process_definitions/routers/mbmr_templates.py +84 -0
- services/process_definitions/routers/packing_instructions.py +84 -0
- services/process_definitions/routers/process_constraints.py +564 -0
- services/process_definitions/routers/process_corrections.py +343 -0
- services/process_definitions/routers/process_definition.py +992 -0
- services/process_definitions/routers/process_post_checks.py +529 -0
- services/process_definitions/routers/process_pre_checks.py +435 -0
- services/process_definitions/routers/process_steps.py +274 -0
- services/procurement/helpers/__init__.py +9 -0
- services/procurement/helpers/goods_receipts.py +240 -0
- services/procurement/helpers/purchase_order_shipping_information.py +85 -0
- services/procurement/helpers/purchase_orders.py +68 -0
- services/procurement/helpers/quality_control.py +235 -0
- services/procurement/helpers/sampling.py +404 -0
- services/procurement/main.py +52 -0
- services/procurement/models/__init__.py +9 -0
- services/procurement/models/goods_receipts.py +165 -0
- services/procurement/models/purchase_orders.py +54 -0
- services/procurement/models/quality_control.py +464 -0
- services/procurement/models/reinspection_records.py +28 -0
- services/procurement/models/sampling.py +262 -0
- services/procurement/models/shipping_information.py +51 -0
- services/procurement/routers/__init__.py +9 -0
- services/procurement/routers/goods_receipts.py +201 -0
- services/procurement/routers/purchase_orders.py +106 -0
- services/procurement/routers/quality_control.py +386 -0
- services/procurement/routers/sampling.py +296 -0
- services/procurement/routers/shipping_information.py +97 -0
- services/production/__init__.py +1 -0
- services/production/agents/__init__.py +5 -0
- services/production/agents/batch_planning_agent.py +815 -0
- services/production/models/__init__.py +25 -0
- services/production/models/batch.py +253 -0
- services/products/helpers/__init__.py +10 -0
- services/products/helpers/boms.py +100 -0
- services/products/helpers/drug_research.py +644 -0
- services/products/helpers/product_component.py +168 -0
- services/products/helpers/product_inventory.py +221 -0
- services/products/helpers/product_pricing.py +123 -0
- services/products/helpers/product_utils.py +32 -0
- services/products/helpers/products.py +81 -0
- services/products/main.py +59 -0
- services/products/models/__init__.py +9 -0
- services/products/models/drug_research.py +138 -0
- services/products/models/product_common.py +60 -0
- services/products/models/product_component.py +1028 -0
- services/products/models/product_inventory.py +118 -0
- services/products/models/product_pricing.py +73 -0
- services/products/models/products.py +151 -0
- services/products/routers/__init__.py +9 -0
- services/products/routers/boms.py +116 -0
- services/products/routers/drug_research.py +115 -0
- services/products/routers/product_components.py +123 -0
- services/products/routers/product_inventory.py +185 -0
- services/products/routers/product_pricing.py +136 -0
- services/products/routers/products.py +165 -0
- services/replenishment/__init__.py +1 -0
- services/replenishment/main.py +46 -0
- services/replenishment/routers/__init__.py +1 -0
- services/replenishment/routers/replenishment.py +20 -0
- services/shifts/helpers/__init__.py +7 -0
- services/shifts/helpers/shift_templates.py +124 -0
- services/shifts/helpers/shifts.py +79 -0
- services/shifts/helpers/timesheets.py +137 -0
- services/shifts/main.py +48 -0
- services/shifts/models/__init__.py +8 -0
- services/shifts/models/shift.py +62 -0
- services/shifts/models/shift_template.py +82 -0
- services/shifts/models/time_range.py +31 -0
- services/shifts/models/timesheet.py +196 -0
- services/shifts/routers/__init__.py +7 -0
- services/shifts/routers/shift_templates.py +97 -0
- services/shifts/routers/shifts.py +117 -0
- services/shifts/routers/timesheets.py +117 -0
- services/shipping/helpers/__init__.py +15 -0
- services/shipping/helpers/carrier.py +78 -0
- services/shipping/helpers/customs_declaration.py +104 -0
- services/shipping/helpers/delivery_note.py +99 -0
- services/shipping/helpers/package.py +95 -0
- services/shipping/helpers/pallet.py +85 -0
- services/shipping/helpers/route.py +93 -0
- services/shipping/helpers/shipping_information.py +82 -0
- services/shipping/helpers/shipping_provider_details.py +59 -0
- services/shipping/helpers/shipping_provider_metadata.py +59 -0
- services/shipping/helpers/vehicle.py +85 -0
- services/shipping/helpers/waybill.py +86 -0
- services/shipping/main.py +64 -0
- services/shipping/models/__init__.py +15 -0
- services/shipping/models/carrier.py +97 -0
- services/shipping/models/customs_declaration.py +138 -0
- services/shipping/models/delivery_note.py +163 -0
- services/shipping/models/package.py +152 -0
- services/shipping/models/pallet.py +137 -0
- services/shipping/models/route.py +120 -0
- services/shipping/models/shipping_information.py +55 -0
- services/shipping/models/shipping_provider_details.py +42 -0
- services/shipping/models/shipping_provider_metadata.py +54 -0
- services/shipping/models/vehicle.py +129 -0
- services/shipping/models/waybill.py +189 -0
- services/shipping/routers/__init__.py +15 -0
- services/shipping/routers/carrier.py +99 -0
- services/shipping/routers/customs_declaration.py +132 -0
- services/shipping/routers/delivery_note.py +150 -0
- services/shipping/routers/package.py +141 -0
- services/shipping/routers/pallet.py +108 -0
- services/shipping/routers/route.py +128 -0
- services/shipping/routers/shipping_information.py +97 -0
- services/shipping/routers/shipping_provider_details.py +80 -0
- services/shipping/routers/shipping_provider_metadata.py +80 -0
- services/shipping/routers/vehicle.py +117 -0
- services/shipping/routers/waybill.py +119 -0
- services/suppliers/helpers/__init__.py +13 -0
- services/suppliers/helpers/supplier_capabilities.py +58 -0
- services/suppliers/helpers/supplier_certifications.py +67 -0
- services/suppliers/helpers/supplier_details.py +58 -0
- services/suppliers/helpers/supplier_financials.py +58 -0
- services/suppliers/helpers/supplier_inventory.py +74 -0
- services/suppliers/helpers/supplier_locations.py +60 -0
- services/suppliers/helpers/supplier_pricing.py +69 -0
- services/suppliers/helpers/supplier_quality.py +69 -0
- services/suppliers/helpers/supplier_shipping.py +69 -0
- services/suppliers/main.py +60 -0
- services/suppliers/models/__init__.py +13 -0
- services/suppliers/models/supplier_capabilities.py +70 -0
- services/suppliers/models/supplier_certifications.py +64 -0
- services/suppliers/models/supplier_details.py +75 -0
- services/suppliers/models/supplier_financials.py +69 -0
- services/suppliers/models/supplier_inventory.py +76 -0
- services/suppliers/models/supplier_locations.py +70 -0
- services/suppliers/models/supplier_pricing.py +74 -0
- services/suppliers/models/supplier_quality.py +74 -0
- services/suppliers/models/supplier_shipping.py +76 -0
- services/suppliers/routers/__init__.py +13 -0
- services/suppliers/routers/supplier_capabilities.py +88 -0
- services/suppliers/routers/supplier_certifications.py +87 -0
- services/suppliers/routers/supplier_details.py +83 -0
- services/suppliers/routers/supplier_financials.py +83 -0
- services/suppliers/routers/supplier_inventory.py +105 -0
- services/suppliers/routers/supplier_locations.py +89 -0
- services/suppliers/routers/supplier_pricing.py +96 -0
- services/suppliers/routers/supplier_quality.py +96 -0
- services/suppliers/routers/supplier_shipping.py +96 -0
- services/supply_allocation/main.py +46 -0
- services/supply_allocation/routers/__init__.py +1 -0
- services/supply_allocation/routers/allocation.py +20 -0
- services/taxonomy/helpers/__init__.py +7 -0
- services/taxonomy/helpers/classes.py +48 -0
- services/taxonomy/helpers/family.py +53 -0
- services/taxonomy/helpers/subclass.py +58 -0
- services/taxonomy/main.py +48 -0
- services/taxonomy/models/__init__.py +7 -0
- services/taxonomy/models/classes.py +52 -0
- services/taxonomy/models/family.py +60 -0
- services/taxonomy/models/subclass.py +50 -0
- services/taxonomy/routers/__init__.py +7 -0
- services/taxonomy/routers/classes.py +78 -0
- services/taxonomy/routers/family.py +77 -0
- services/taxonomy/routers/subclass.py +82 -0
- services/warehouse_execution/__init__.py +1 -0
- services/warehouse_execution/main.py +46 -0
- services/warehouse_execution/routers/__init__.py +1 -0
- services/warehouse_execution/routers/execution.py +21 -0
- services/work_order_agent/__init__.py +17 -0
- services/work_order_agent/agent/__init__.py +17 -0
- services/work_order_agent/agent/work_order_agent.py +658 -0
- services/work_order_agent/tracking/__init__.py +101 -0
- services/work_order_agent/tracking/event_system.py +182 -0
- services/work_order_agent/tracking/state_machine.py +163 -0
- services/work_order_agent/tracking/state_machine_integrator.py +295 -0
- services/work_order_agent/tracking/test_phase2_implementation.py +302 -0
- services/work_order_agent/tracking/time_analysis.py +301 -0
- services/work_order_agent/tracking/tracked_work_order.py +255 -0
- services/work_order_agent/tracking/work_order_adapter.py +367 -0
- services/work_order_agent/tracking/work_order_batch_manager.py +406 -0
- services/work_order_agent/tracking/work_order_repository.py +431 -0
- services/workorders/helpers/__init__.py +5 -0
- services/workorders/helpers/area_room_usage_ledger.py +139 -0
- services/workorders/helpers/batch_execution_records.py +265 -0
- services/workorders/helpers/batch_release_workflows.py +158 -0
- services/workorders/helpers/batch_step_executions.py +145 -0
- services/workorders/helpers/equipment_usage_ledger.py +209 -0
- services/workorders/helpers/executed_bmr_records.py +170 -0
- services/workorders/helpers/executed_bpr_records.py +170 -0
- services/workorders/helpers/executed_instruction_evidence.py +155 -0
- services/workorders/helpers/ipc_result_records.py +134 -0
- services/workorders/helpers/production_batches.py +117 -0
- services/workorders/helpers/work_orders.py +367 -0
- services/workorders/helpers/yield_reconciliation_records.py +158 -0
- services/workorders/main.py +110 -0
- services/workorders/models/__init__.py +5 -0
- services/workorders/models/area_room_usage_ledger.py +154 -0
- services/workorders/models/batch_execution_records.py +575 -0
- services/workorders/models/batch_release_workflows.py +190 -0
- services/workorders/models/batch_step_executions.py +142 -0
- services/workorders/models/equipment_usage_ledger.py +144 -0
- services/workorders/models/executed_bmr_records.py +220 -0
- services/workorders/models/executed_bpr_records.py +220 -0
- services/workorders/models/executed_instruction_evidence.py +128 -0
- services/workorders/models/ipc_result_records.py +164 -0
- services/workorders/models/production_batches.py +181 -0
- services/workorders/models/work_orders.py +255 -0
- services/workorders/models/yield_reconciliation_records.py +175 -0
- services/workorders/routers/__init__.py +5 -0
- services/workorders/routers/area_room_usage_ledger.py +117 -0
- services/workorders/routers/batch_execution_records.py +103 -0
- services/workorders/routers/batch_release_workflows.py +86 -0
- services/workorders/routers/batch_step_executions.py +88 -0
- services/workorders/routers/equipment_usage_ledger.py +115 -0
- services/workorders/routers/executed_bmr_records.py +86 -0
- services/workorders/routers/executed_bpr_records.py +86 -0
- services/workorders/routers/executed_instruction_evidence.py +86 -0
- services/workorders/routers/ipc_result_records.py +86 -0
- services/workorders/routers/production_batches.py +86 -0
- services/workorders/routers/work_orders.py +257 -0
- services/workorders/routers/yield_reconciliation_records.py +86 -0
- src/broca/__init__.py +5 -0
- src/broca/agent.py +201 -0
- src/cerebellum/__init__.py +0 -0
- src/cerebellum/adapter.py +84 -0
- src/cerebellum/capabilities/__init__.py +0 -0
- src/cerebellum/capabilities/agent/__init__.py +0 -0
- src/cerebellum/capabilities/agent/agents.py +65 -0
- src/cerebellum/capabilities/ai/__init__.py +0 -0
- src/cerebellum/capabilities/ai/providers.py +106 -0
- src/cerebellum/capabilities/api/__init__.py +0 -0
- src/cerebellum/capabilities/api/graphql.py +35 -0
- src/cerebellum/capabilities/api/rest_api.py +45 -0
- src/cerebellum/capabilities/api/webhook.py +30 -0
- src/cerebellum/capabilities/browser/__init__.py +0 -0
- src/cerebellum/capabilities/browser/browsers.py +27 -0
- src/cerebellum/capabilities/cloud/__init__.py +0 -0
- src/cerebellum/capabilities/cloud/cloud.py +46 -0
- src/cerebellum/capabilities/communication/__init__.py +0 -0
- src/cerebellum/capabilities/communication/communication.py +62 -0
- src/cerebellum/capabilities/database/__init__.py +0 -0
- src/cerebellum/capabilities/database/elasticsearch.py +40 -0
- src/cerebellum/capabilities/database/influxdb.py +37 -0
- src/cerebellum/capabilities/database/mongodb.py +50 -0
- src/cerebellum/capabilities/database/neo4j.py +32 -0
- src/cerebellum/capabilities/database/redis.py +44 -0
- src/cerebellum/capabilities/enterprise/__init__.py +0 -0
- src/cerebellum/capabilities/enterprise/opensource.py +180 -0
- src/cerebellum/capabilities/enterprise/proprietary.py +313 -0
- src/cerebellum/capabilities/event_streaming/__init__.py +0 -0
- src/cerebellum/capabilities/event_streaming/streaming.py +38 -0
- src/cerebellum/capabilities/infrastructure/__init__.py +0 -0
- src/cerebellum/capabilities/infrastructure/infrastructure.py +30 -0
- src/cerebellum/capabilities/productivity/__init__.py +0 -0
- src/cerebellum/capabilities/productivity/productivity.py +158 -0
- src/cerebellum/capabilities/robotics/__init__.py +0 -0
- src/cerebellum/capabilities/robotics/robotics.py +124 -0
- src/cerebellum/capabilities/runtime/__init__.py +0 -0
- src/cerebellum/capabilities/runtime/runtimes.py +92 -0
- src/cerebellum/capabilities/search/__init__.py +0 -0
- src/cerebellum/capabilities/search/search.py +63 -0
- src/cerebellum/capabilities/source_control/__init__.py +0 -0
- src/cerebellum/capabilities/source_control/source_control.py +113 -0
- src/cerebellum/capabilities/storage/__init__.py +0 -0
- src/cerebellum/capabilities/storage/storage.py +94 -0
- src/cerebellum/capabilities/workflow/__init__.py +0 -0
- src/cerebellum/capabilities/workflow/workflows.py +49 -0
- src/cerebellum/capability.py +108 -0
- src/cerebellum/config.py +157 -0
- src/cerebellum/fallback.py +147 -0
- src/cerebellum/fallback_engine.py +121 -0
- src/cerebellum/key_manager.py +129 -0
- src/cerebellum/keystore.py +179 -0
- src/cerebellum/lifecycle.py +54 -0
- src/cerebellum/metadata.py +61 -0
- src/cerebellum/operator/base.py +25 -0
- src/cerebellum/peripheral.py +92 -0
- src/cerebellum/registry.py +98 -0
- src/cerebellum/resolve_entity_capability.py +259 -0
- src/cingulate/benchmark/__init__.py +23 -0
- src/cingulate/benchmark/reporter.py +102 -0
- src/cingulate/benchmark/runner.py +159 -0
- src/cingulate/benchmark/scenario_runner.py +150 -0
- src/cingulate/benchmark/validator.py +102 -0
- src/cingulate/governance/__init__.py +21 -0
- src/cingulate/governance/architecture_validator.py +194 -0
- src/cingulate/governance/compliance.py +104 -0
- src/cingulate/governance/governance.py +77 -0
- src/cingulate/governance/policy_registry.py +91 -0
- src/cortex/__init__.py +33 -0
- src/cortex/cost.py +71 -0
- src/cortex/counterfactual.py +162 -0
- src/cortex/digital_twin.py +90 -0
- src/cortex/experience.py +83 -0
- src/cortex/feedback.py +144 -0
- src/cortex/loss.py +116 -0
- src/cortex/prediction.py +142 -0
- src/cortex/replay.py +130 -0
- src/cortex/reward.py +113 -0
- src/cortex/simulator.py +102 -0
- src/cortex/world_model.py +180 -0
- src/cortex/world_model_simulation.py +1591 -0
- src/cortex/world_state.py +121 -0
- src/cortex/xavier.py +250 -0
- src/deepdive/__init__.py +29 -0
- src/deepdive/aggregation.py +113 -0
- src/deepdive/digital_twin_aggregator.py +128 -0
- src/deepdive/elasticsearch_adapter.py +110 -0
- src/deepdive/fleet_analytics.py +131 -0
- src/deepdive/knowledge_aggregator.py +130 -0
- src/homeostasis/__init__.py +19 -0
- src/homeostasis/control_plane.py +159 -0
- src/introspection/__init__.py +38 -0
- src/introspection/alerting.py +142 -0
- src/introspection/health.py +101 -0
- src/introspection/lemon.py +243 -0
- src/introspection/logging.py +147 -0
- src/introspection/metrics.py +106 -0
- src/introspection/tracing.py +162 -0
- src/monkey_brain/__init__.py +1 -0
- src/monkey_brain/api/main.py +148 -0
- src/monkey_brain/api/models.py +81 -0
- src/monkey_brain/api/routes/routes/keys.py +106 -0
- src/monkey_brain/api/routes/routes/run.py +169 -0
- src/monkey_brain/api/routes/routes/simulate.py +485 -0
- src/monkey_brain/dlm/__init__.py +44 -0
- src/monkey_brain/dlm/dlm.py +139 -0
- src/monkey_brain/dlm/gc.py +115 -0
- src/monkey_brain/dlm/lifecycle.py +149 -0
- src/monkey_brain/dlm/orphans.py +99 -0
- src/monkey_brain/dlm/storage.py +149 -0
- src/monkey_brain/dlm/ttl.py +140 -0
- src/monkey_brain/documents/__init__.py +0 -0
- src/monkey_brain/documents/document_ocr.py +6 -0
- src/monkey_brain/kernel/__init__.py +53 -0
- src/monkey_brain/kernel/capability_interface.py +144 -0
- src/monkey_brain/kernel/classifier/__init__.py +1 -0
- src/monkey_brain/kernel/classifier/embed_classifier.py +125 -0
- src/monkey_brain/kernel/classifier/intent_examples.py +106 -0
- src/monkey_brain/kernel/dag.py +23 -0
- src/monkey_brain/kernel/execution_state.py +257 -0
- src/monkey_brain/kernel/goal_planner.py +85 -0
- src/monkey_brain/kernel/goal_router.py +20 -0
- src/monkey_brain/kernel/goals/__init__.py +1 -0
- src/monkey_brain/kernel/goals/goal.py +130 -0
- src/monkey_brain/kernel/goals/goal_bootstrap.py +38 -0
- src/monkey_brain/kernel/goals/goal_classifier.py +132 -0
- src/monkey_brain/kernel/goals/goal_registry.py +75 -0
- src/monkey_brain/kernel/intents/__init__.py +1 -0
- src/monkey_brain/kernel/intents/event_adapter.py +246 -0
- src/monkey_brain/kernel/intents/helpers.py +13 -0
- src/monkey_brain/kernel/intents/intent_registry.py +705 -0
- src/monkey_brain/kernel/intents/intent_router.py +102 -0
- src/monkey_brain/kernel/intents/predicates/approval_create.py +9 -0
- src/monkey_brain/kernel/intents/predicates/approval_decision.py +9 -0
- src/monkey_brain/kernel/intents/predicates/approval_hold.py +9 -0
- src/monkey_brain/kernel/intents/predicates/approval_query.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_close.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_creation.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_delete.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_hold.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_record.py +9 -0
- src/monkey_brain/kernel/intents/predicates/batch_update.py +9 -0
- src/monkey_brain/kernel/intents/predicates/change_control.py +49 -0
- src/monkey_brain/kernel/intents/predicates/compliance_audit.py +14 -0
- src/monkey_brain/kernel/intents/predicates/decision_intelligence.py +9 -0
- src/monkey_brain/kernel/intents/predicates/drug_research.py +9 -0
- src/monkey_brain/kernel/intents/predicates/fuzzy_match.py +19 -0
- src/monkey_brain/kernel/intents/predicates/production_kpi.py +9 -0
- src/monkey_brain/kernel/intents/predicates/sop_create.py +9 -0
- src/monkey_brain/kernel/intents/predicates/sop_query.py +9 -0
- src/monkey_brain/kernel/intents/predicates/sop_update.py +9 -0
- src/monkey_brain/kernel/intents/predicates/warehouse_shipping.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_create.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_delete.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_hold.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_query.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_status.py +9 -0
- src/monkey_brain/kernel/intents/predicates/work_order_update.py +9 -0
- src/monkey_brain/kernel/intents/predicates/worker.py +9 -0
- src/monkey_brain/kernel/intents/telemetry_adapter.py +274 -0
- src/monkey_brain/kernel/intents/utils.py +68 -0
- src/monkey_brain/kernel/learning.py +98 -0
- src/monkey_brain/kernel/llm_explorer.py +188 -0
- src/monkey_brain/kernel/loss.py +81 -0
- src/monkey_brain/kernel/nlp/__init__.py +1 -0
- src/monkey_brain/kernel/nlp/compat.py +23 -0
- src/monkey_brain/kernel/nlp/models.py +10 -0
- src/monkey_brain/kernel/nlp/question_analyzer.py +203 -0
- src/monkey_brain/kernel/nlp/spacy_parser.py +53 -0
- src/monkey_brain/kernel/observer.py +97 -0
- src/monkey_brain/kernel/parser/__init__.py +3 -0
- src/monkey_brain/kernel/parser/ast.py +28 -0
- src/monkey_brain/kernel/parser/extractors/__init__.py +11 -0
- src/monkey_brain/kernel/parser/extractors/entities.py +21 -0
- src/monkey_brain/kernel/parser/extractors/filters.py +16 -0
- src/monkey_brain/kernel/parser/extractors/projections.py +36 -0
- src/monkey_brain/kernel/parser/extractors/verbs.py +31 -0
- src/monkey_brain/kernel/parser/parser.py +57 -0
- src/monkey_brain/kernel/parser/rules.py +75 -0
- src/monkey_brain/kernel/pipeline.py +44 -0
- src/monkey_brain/kernel/planner.py +57 -0
- src/monkey_brain/kernel/rl/__init__.py +33 -0
- src/monkey_brain/kernel/rl/learner.py +98 -0
- src/monkey_brain/kernel/rl/policy.py +254 -0
- src/monkey_brain/kernel/rl/reward.py +117 -0
- src/monkey_brain/kernel/rl/transition.py +112 -0
- src/monkey_brain/persistence/__init__.py +47 -0
- src/monkey_brain/persistence/adapters.py +49 -0
- src/monkey_brain/persistence/events.py +105 -0
- src/monkey_brain/persistence/manager.py +124 -0
- src/monkey_brain/persistence/mongodb_adapter.py +91 -0
- src/monkey_brain/persistence/redis_adapter.py +93 -0
- src/monkey_brain/persistence/reducer.py +111 -0
- src/monkey_brain/runtime/__init__.py +49 -0
- src/monkey_brain/runtime/depedencies.py +8 -0
- src/monkey_brain/runtime/engine.py +183 -0
- src/monkey_brain/runtime/message_bus.py +82 -0
- src/monkey_brain/runtime/process.py +144 -0
- src/monkey_brain/runtime/resource_manager.py +100 -0
- src/monkey_brain/runtime/routers.py +8 -0
- src/monkey_brain/runtime/runtime.py +199 -0
- src/monkey_brain/runtime/scheduler.py +165 -0
- src/monkey_brain/runtime/supervisor.py +133 -0
- src/monkey_brain/runtime/worker_pool.py +111 -0
- src/plasticity/seed/__init__.py +30 -0
- src/plasticity/seed/benchmark_generator.py +105 -0
- src/plasticity/seed/event_generator.py +122 -0
- src/plasticity/seed/scenario_builder.py +134 -0
- src/plasticity/seed/seed_data.py +206 -0
- src/plasticity/seed/seeder.py +122 -0
- src/plasticity/testing/__init__.py +28 -0
- src/plasticity/testing/performance.py +131 -0
- src/plasticity/testing/profiler.py +255 -0
- src/plasticity/testing/reporter.py +84 -0
- src/plasticity/testing/runner.py +209 -0
- src/sync/__init__.py +12 -0
- src/sync/cloud_aggregator.py +63 -0
- src/sync/edge_node.py +51 -0
- src/sync/sync_manager.py +74 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
from uuid import uuid4
|
|
5
|
+
|
|
6
|
+
from fastapi.encoders import jsonable_encoder
|
|
7
|
+
|
|
8
|
+
from services.common.compliance import document_record_id, utc_now
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
SUPPLY_CHAIN_COLLECTIONS = {
|
|
12
|
+
"sales_orders",
|
|
13
|
+
"purchase_orders",
|
|
14
|
+
"goods_receipts",
|
|
15
|
+
"inventory_allocations",
|
|
16
|
+
"inventory_transactions",
|
|
17
|
+
"inventory_item_quantities",
|
|
18
|
+
"product_inventory",
|
|
19
|
+
"supplier_inventory",
|
|
20
|
+
"work_orders",
|
|
21
|
+
"material_inward_logs",
|
|
22
|
+
"warehouse_dispensing_records",
|
|
23
|
+
"inventory_disposition_records",
|
|
24
|
+
"warehouse_cycle_counts",
|
|
25
|
+
"stock_adjustment_requests",
|
|
26
|
+
"shipping_information",
|
|
27
|
+
"delivery_notes",
|
|
28
|
+
"packages",
|
|
29
|
+
"pallets",
|
|
30
|
+
"routes",
|
|
31
|
+
"waybills",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
STATUS_EVENT_PREFIX = {
|
|
36
|
+
"sales_orders": "sales_order",
|
|
37
|
+
"purchase_orders": "purchase_order",
|
|
38
|
+
"goods_receipts": "goods_receipt",
|
|
39
|
+
"inventory_allocations": "inventory",
|
|
40
|
+
"work_orders": "work_order",
|
|
41
|
+
"material_inward_logs": "material_inward",
|
|
42
|
+
"warehouse_dispensing_records": "warehouse_dispensing",
|
|
43
|
+
"inventory_disposition_records": "inventory_disposition",
|
|
44
|
+
"warehouse_cycle_counts": "warehouse_cycle_count",
|
|
45
|
+
"stock_adjustment_requests": "stock_adjustment",
|
|
46
|
+
"shipping_information": "shipping",
|
|
47
|
+
"delivery_notes": "delivery_note",
|
|
48
|
+
"packages": "package",
|
|
49
|
+
"pallets": "pallet",
|
|
50
|
+
"routes": "route",
|
|
51
|
+
"waybills": "waybill",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
STATUS_FIELD_BY_COLLECTION = {
|
|
56
|
+
"shipping_information": "shipment_status",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
STATUS_EVENT_ALIASES = {
|
|
61
|
+
("inventory_allocations", "allocated"): "inventory_allocated",
|
|
62
|
+
("inventory_allocations", "picked"): "inventory_picked",
|
|
63
|
+
("inventory_allocations", "delivered"): "inventory_delivered",
|
|
64
|
+
("goods_receipts", "released"): "goods_receipt_released",
|
|
65
|
+
("goods_receipts", "qc-hold"): "goods_receipt_qc_hold",
|
|
66
|
+
("goods_receipts", "rejected"): "goods_receipt_rejected",
|
|
67
|
+
("sales_orders", "confirmed"): "sales_order_confirmed",
|
|
68
|
+
("sales_orders", "allocated"): "sales_order_allocated",
|
|
69
|
+
("sales_orders", "shipped"): "sales_order_shipped",
|
|
70
|
+
("work_orders", "completed"): "work_order_completed",
|
|
71
|
+
("work_orders", "done"): "work_order_completed",
|
|
72
|
+
("delivery_notes", "dispatched"): "dispatch_confirmed",
|
|
73
|
+
("shipping_information", "dispatched"): "dispatch_confirmed",
|
|
74
|
+
("shipping_information", "shipped"): "dispatch_confirmed",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
INTERESTING_STATUS_VALUES = {
|
|
79
|
+
"approved",
|
|
80
|
+
"allocated",
|
|
81
|
+
"cancelled",
|
|
82
|
+
"closed",
|
|
83
|
+
"completed",
|
|
84
|
+
"confirmed",
|
|
85
|
+
"delivered",
|
|
86
|
+
"dispatched",
|
|
87
|
+
"done",
|
|
88
|
+
"in-progress",
|
|
89
|
+
"in-transit",
|
|
90
|
+
"issued",
|
|
91
|
+
"open",
|
|
92
|
+
"partial",
|
|
93
|
+
"partially-delivered",
|
|
94
|
+
"picked",
|
|
95
|
+
"qc-hold",
|
|
96
|
+
"ready-for-next-stage",
|
|
97
|
+
"received",
|
|
98
|
+
"rejected",
|
|
99
|
+
"released",
|
|
100
|
+
"reserved",
|
|
101
|
+
"shipped",
|
|
102
|
+
"submitted",
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
INVENTORY_TRANSACTION_EVENT_ALIASES = {
|
|
107
|
+
"receipt": "inventory_receipt_recorded",
|
|
108
|
+
"shipment": "inventory_shipment_recorded",
|
|
109
|
+
"reservation": "inventory_reserved",
|
|
110
|
+
"release": "inventory_released",
|
|
111
|
+
"transfer-in": "inventory_transfer_recorded",
|
|
112
|
+
"transfer-out": "inventory_transfer_recorded",
|
|
113
|
+
"adjustment": "inventory_adjustment_recorded",
|
|
114
|
+
"cycle-count": "inventory_cycle_count_recorded",
|
|
115
|
+
"return": "inventory_return_recorded",
|
|
116
|
+
"write-off": "inventory_write_off_recorded",
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
WAREHOUSE_WORKFLOW_ACTIONS = {
|
|
121
|
+
"sales_order_confirmed": "warehouse task",
|
|
122
|
+
"sales_order_allocated": "pick pack",
|
|
123
|
+
"goods_receipt_released": "quarantine release rejection",
|
|
124
|
+
"goods_receipt_qc_hold": "quarantine release rejection",
|
|
125
|
+
"goods_receipt_rejected": "quarantine release rejection",
|
|
126
|
+
"inventory_allocated": "pick pack",
|
|
127
|
+
"inventory_picked": "dispatch handoff",
|
|
128
|
+
"inventory_reserved": "inventory allocation",
|
|
129
|
+
"inventory_released": "dispensing record",
|
|
130
|
+
"inventory_receipt_recorded": "receiving",
|
|
131
|
+
"inventory_shipment_recorded": "dispatch handoff",
|
|
132
|
+
"inventory_transfer_recorded": "inventory transaction",
|
|
133
|
+
"inventory_adjustment_recorded": "stock adjustment",
|
|
134
|
+
"inventory_cycle_count_recorded": "cycle count",
|
|
135
|
+
"inventory_transaction_recorded": "inventory transaction",
|
|
136
|
+
"inventory_transaction_posted": "inventory transaction",
|
|
137
|
+
"material_inward_received": "material inward log",
|
|
138
|
+
"warehouse_dispensing_released": "dispensing record",
|
|
139
|
+
"inventory_disposition_release": "quarantine release rejection",
|
|
140
|
+
"inventory_disposition_rejection": "quarantine release rejection",
|
|
141
|
+
"warehouse_cycle_count_completed": "cycle count",
|
|
142
|
+
"stock_adjustment_approved": "stock adjustment",
|
|
143
|
+
"work_order_completed": "warehouse task",
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
WAREHOUSE_ACTION_NODES = {
|
|
148
|
+
"warehouse task": ("wh-task", "Warehouse Task Intake"),
|
|
149
|
+
"receiving": ("wh-receiving", "Receiving"),
|
|
150
|
+
"material inward log": ("wh-inward", "Material Inward Logs"),
|
|
151
|
+
"quarantine release rejection": ("wh-disposition", "Quarantine Release Rejection"),
|
|
152
|
+
"dispensing record": ("wh-dispensing", "Dispensing Records"),
|
|
153
|
+
"inventory allocation": ("wh-allocation", "Inventory Allocation"),
|
|
154
|
+
"inventory transaction": ("wh-allocation", "Inventory Allocation"),
|
|
155
|
+
"pick pack": ("wh-pick-pack", "Pick Pack Execute"),
|
|
156
|
+
"cycle count": ("wh-cycle-count", "Cycle Count Check"),
|
|
157
|
+
"stock adjustment": ("wh-adjust", "Stock Adjustment"),
|
|
158
|
+
"dispatch handoff": ("wh-dispatch", "Dispatch Handoff"),
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
WAREHOUSE_NODE_CONFIGS = {
|
|
163
|
+
"wh-queue": {
|
|
164
|
+
"source": "external_nats_queue",
|
|
165
|
+
"subject": "indus.warehouse.queue",
|
|
166
|
+
"queue": "indus-warehouse-websocket",
|
|
167
|
+
"exception_subject": "indus.warehouse.exceptions",
|
|
168
|
+
"exception_queue": "indus-warehouse-exceptions",
|
|
169
|
+
"websocket_path": "/api/v1/ws/events",
|
|
170
|
+
"target_node": "Warehouse Task Intake",
|
|
171
|
+
},
|
|
172
|
+
"wh-task": {
|
|
173
|
+
"source": "warehouse_operations",
|
|
174
|
+
"collections": ["goods_receipts", "inventory_items", "sales_orders", "work_orders"],
|
|
175
|
+
"output": "warehouse_task",
|
|
176
|
+
},
|
|
177
|
+
"wh-products": {"endpoint": "/api/v1/products", "output": "product_context"},
|
|
178
|
+
"wh-bom": {"endpoint": "/api/v1/boms", "output": "bom_context"},
|
|
179
|
+
"wh-components": {"endpoint": "/api/v1/products/components", "output": "component_context"},
|
|
180
|
+
"wh-storage-req": {
|
|
181
|
+
"endpoint": "/api/v1/warehouse/special-storage-requirements",
|
|
182
|
+
"temperature_control_check": True,
|
|
183
|
+
"segregation_check": True,
|
|
184
|
+
"output": "storage_requirements",
|
|
185
|
+
},
|
|
186
|
+
"wh-documents": {"endpoint": "/api/v1/documents", "output": "warehouse_documents"},
|
|
187
|
+
"wh-assets": {
|
|
188
|
+
"machine_endpoint": "/api/v1/machines",
|
|
189
|
+
"robot_filter": {"machine_type": "Industrial Robot"},
|
|
190
|
+
"output": "warehouse_machines_robots",
|
|
191
|
+
},
|
|
192
|
+
"wh-equipment": {"equipment_endpoint": "/api/v1/equipment", "output": "warehouse_equipment"},
|
|
193
|
+
"wh-receiving": {"endpoint": "/api/v1/goods-receipts", "dock_check": True, "output": "receiving_event"},
|
|
194
|
+
"wh-grn": {"endpoint": "/api/v1/goods-receipts", "record_type": "GRN", "output": "grn_record"},
|
|
195
|
+
"wh-inward": {"endpoint": "/api/v1/warehouse/material-inward-logs", "output": "material_inward_log"},
|
|
196
|
+
"wh-labels": {
|
|
197
|
+
"endpoint": "/api/v1/warehouse/status-labels",
|
|
198
|
+
"labels": ["Quarantine", "Release", "Rejection"],
|
|
199
|
+
"print_required": True,
|
|
200
|
+
"output": "status_label",
|
|
201
|
+
},
|
|
202
|
+
"wh-disposition": {
|
|
203
|
+
"endpoint": "/api/v1/warehouse/quarantine-release-rejection-records",
|
|
204
|
+
"signature_required": True,
|
|
205
|
+
"qa_review_required": True,
|
|
206
|
+
"output": "material_disposition",
|
|
207
|
+
},
|
|
208
|
+
"wh-dispensing": {
|
|
209
|
+
"endpoint": "/api/v1/warehouse/dispensing-records",
|
|
210
|
+
"signature_required": True,
|
|
211
|
+
"scale_required": True,
|
|
212
|
+
"output": "dispensing_record",
|
|
213
|
+
},
|
|
214
|
+
"wh-allocation": {
|
|
215
|
+
"endpoint": "/api/v1/inventory-allocations",
|
|
216
|
+
"output": "allocated_inventory",
|
|
217
|
+
"reservation_required": True,
|
|
218
|
+
},
|
|
219
|
+
"wh-location": {
|
|
220
|
+
"endpoint": "/api/v1/warehouse-locations",
|
|
221
|
+
"location_hierarchy": ["zone", "area", "aisle", "rack", "bin"],
|
|
222
|
+
"temperature_control_check": True,
|
|
223
|
+
},
|
|
224
|
+
"wh-pick-pack": {"scan_required": True, "device_type": "Warehouse Scanner", "output": "picked_inventory"},
|
|
225
|
+
"wh-cycle-count": {
|
|
226
|
+
"endpoint": "/api/v1/warehouse-cycle-counts",
|
|
227
|
+
"variance_check": True,
|
|
228
|
+
"output": "cycle_count_result",
|
|
229
|
+
},
|
|
230
|
+
"wh-adjust": {
|
|
231
|
+
"endpoint": "/api/v1/stock-adjustment-requests",
|
|
232
|
+
"approval_required": True,
|
|
233
|
+
"output": "stock_adjustment_request",
|
|
234
|
+
},
|
|
235
|
+
"wh-dispatch": {"endpoint": "/api/v1/shipping-information", "handoff_to": "shipping", "output": "dispatch_ready"},
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
WAREHOUSE_MAIN_PATH = [
|
|
240
|
+
"Warehouse Queue",
|
|
241
|
+
"Warehouse Task Intake",
|
|
242
|
+
"Products",
|
|
243
|
+
"BOM",
|
|
244
|
+
"Components",
|
|
245
|
+
"Special Storage Requirements",
|
|
246
|
+
"Receiving",
|
|
247
|
+
"GRN Records",
|
|
248
|
+
"Material Inward Logs",
|
|
249
|
+
"Status Labels",
|
|
250
|
+
"Quarantine Release Rejection",
|
|
251
|
+
"Dispensing Records",
|
|
252
|
+
"Inventory Allocation",
|
|
253
|
+
"Location Assignment",
|
|
254
|
+
"Pick Pack Execute",
|
|
255
|
+
"Cycle Count Check",
|
|
256
|
+
]
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
WAREHOUSE_CANVAS_PATHS = {
|
|
260
|
+
"warehouse task": ["Warehouse Queue", "Warehouse Task Intake"],
|
|
261
|
+
"receiving": WAREHOUSE_MAIN_PATH[:7],
|
|
262
|
+
"material inward log": WAREHOUSE_MAIN_PATH[:9],
|
|
263
|
+
"quarantine release rejection": WAREHOUSE_MAIN_PATH[:11],
|
|
264
|
+
"dispensing record": WAREHOUSE_MAIN_PATH[:12],
|
|
265
|
+
"inventory allocation": WAREHOUSE_MAIN_PATH[:13],
|
|
266
|
+
"inventory transaction": WAREHOUSE_MAIN_PATH[:13],
|
|
267
|
+
"pick pack": WAREHOUSE_MAIN_PATH[:15],
|
|
268
|
+
"cycle count": WAREHOUSE_MAIN_PATH[:16],
|
|
269
|
+
"stock adjustment": [*WAREHOUSE_MAIN_PATH[:16], "Stock Adjustment"],
|
|
270
|
+
"dispatch handoff": [*WAREHOUSE_MAIN_PATH[:16], "Dispatch Handoff"],
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
WAREHOUSE_SUPPORTING_NODES = {
|
|
275
|
+
"receiving": ["Warehouse Documents"],
|
|
276
|
+
"material inward log": ["Warehouse Documents"],
|
|
277
|
+
"quarantine release rejection": ["Warehouse Documents"],
|
|
278
|
+
"dispensing record": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
279
|
+
"inventory allocation": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
280
|
+
"inventory transaction": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
281
|
+
"pick pack": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
282
|
+
"cycle count": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
283
|
+
"stock adjustment": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
284
|
+
"dispatch handoff": ["Warehouse Documents", "Machines Robots", "Equipment"],
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
SHIPPING_WORKFLOW_ACTIONS = {
|
|
289
|
+
"dispatch_confirmed": "dispatch confirmation",
|
|
290
|
+
"delivery_note_dispatched": "delivery note",
|
|
291
|
+
"delivery_note_delivered": "dispatch confirmation",
|
|
292
|
+
"package_dispatched": "package",
|
|
293
|
+
"package_delivered": "package",
|
|
294
|
+
"pallet_dispatched": "pallet",
|
|
295
|
+
"route_completed": "shipping route",
|
|
296
|
+
"waybill_issued": "waybill",
|
|
297
|
+
"waybill_in_transit": "waybill",
|
|
298
|
+
"waybill_delivered": "dispatch confirmation",
|
|
299
|
+
"shipping_dispatched": "dispatch confirmation",
|
|
300
|
+
"shipping_shipped": "dispatch confirmation",
|
|
301
|
+
"shipping_in_transit": "shipping information",
|
|
302
|
+
"shipping_delivered": "dispatch confirmation",
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
SHIPPING_ACTION_NODES = {
|
|
307
|
+
"shipping information": ("ship-info", "Shipping Information"),
|
|
308
|
+
"pallet": ("ship-pallet", "Pallet"),
|
|
309
|
+
"package": ("ship-package", "Package"),
|
|
310
|
+
"delivery note": ("ship-delivery-note", "Delivery Note"),
|
|
311
|
+
"shipping route": ("ship-route", "Shipping Route"),
|
|
312
|
+
"waybill": ("ship-waybill", "Waybill"),
|
|
313
|
+
"dispatch confirmation": ("ship-confirm", "Dispatch Confirmation"),
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
SHIPPING_CANVAS_PATHS = {
|
|
318
|
+
"shipping information": ["Shipping Queue", "Shipping Intake", "Shipping Information"],
|
|
319
|
+
"pallet": ["Shipping Queue", "Shipping Intake", "Shipping Information", "Pallet"],
|
|
320
|
+
"package": ["Shipping Queue", "Shipping Intake", "Shipping Information", "Pallet", "Package"],
|
|
321
|
+
"delivery note": ["Shipping Queue", "Shipping Intake", "Shipping Information", "Pallet", "Package", "Delivery Note"],
|
|
322
|
+
"shipping route": [
|
|
323
|
+
"Shipping Queue",
|
|
324
|
+
"Shipping Intake",
|
|
325
|
+
"Shipping Information",
|
|
326
|
+
"Pallet",
|
|
327
|
+
"Package",
|
|
328
|
+
"Delivery Note",
|
|
329
|
+
"Shipping Route",
|
|
330
|
+
],
|
|
331
|
+
"waybill": [
|
|
332
|
+
"Shipping Queue",
|
|
333
|
+
"Shipping Intake",
|
|
334
|
+
"Shipping Information",
|
|
335
|
+
"Delivery Note",
|
|
336
|
+
"Shipping Route",
|
|
337
|
+
"Customs Declaration",
|
|
338
|
+
"Waybill",
|
|
339
|
+
],
|
|
340
|
+
"dispatch confirmation": [
|
|
341
|
+
"Shipping Queue",
|
|
342
|
+
"Shipping Intake",
|
|
343
|
+
"Shipping Information",
|
|
344
|
+
"Delivery Note",
|
|
345
|
+
"Shipping Route",
|
|
346
|
+
"Waybill",
|
|
347
|
+
"Dispatch Confirmation",
|
|
348
|
+
],
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def _normalize_token(value: Any) -> str:
|
|
353
|
+
return str(value or "").strip().lower().replace("_", "-").replace(" ", "-")
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _document(event: dict[str, Any], key: str) -> dict[str, Any]:
|
|
357
|
+
value = event.get(key)
|
|
358
|
+
return value if isinstance(value, dict) else {}
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def _record_id(collection: str, document: dict[str, Any], event: dict[str, Any]) -> str | None:
|
|
362
|
+
return (
|
|
363
|
+
str(event.get("record_id"))
|
|
364
|
+
if event.get("record_id")
|
|
365
|
+
else document_record_id(document)
|
|
366
|
+
or str(document.get("id") or "")
|
|
367
|
+
or None
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def _workflow_route(event_type: str) -> dict[str, Any]:
|
|
372
|
+
warehouse_action = WAREHOUSE_WORKFLOW_ACTIONS.get(event_type)
|
|
373
|
+
if warehouse_action:
|
|
374
|
+
action_node_id, action_node = WAREHOUSE_ACTION_NODES.get(warehouse_action, ("wh-task", "Warehouse Task Intake"))
|
|
375
|
+
return {
|
|
376
|
+
"domain": "warehouse",
|
|
377
|
+
"layout_id": "process_definition-warehouse-management-canvas",
|
|
378
|
+
"process_definition_id": "process_definition-warehouse-management",
|
|
379
|
+
"subject": "indus.warehouse.queue",
|
|
380
|
+
"target_node": "Warehouse Task Intake",
|
|
381
|
+
"entry_node": "Warehouse Task Intake",
|
|
382
|
+
"action_node_id": f"process_definition-warehouse-management:{action_node_id}",
|
|
383
|
+
"action_node": action_node,
|
|
384
|
+
"action_node_config": WAREHOUSE_NODE_CONFIGS.get(action_node_id, {}),
|
|
385
|
+
"warehouse_action": warehouse_action,
|
|
386
|
+
"workflow_path": WAREHOUSE_CANVAS_PATHS.get(warehouse_action, ["Warehouse Queue", "Warehouse Task Intake", action_node]),
|
|
387
|
+
"supporting_nodes": WAREHOUSE_SUPPORTING_NODES.get(warehouse_action, []),
|
|
388
|
+
"audit_node": "Warehouse Audit Log",
|
|
389
|
+
"exception_node": "Warehouse Exception Queue",
|
|
390
|
+
}
|
|
391
|
+
shipping_action = SHIPPING_WORKFLOW_ACTIONS.get(event_type)
|
|
392
|
+
if shipping_action:
|
|
393
|
+
action_node_id, action_node = SHIPPING_ACTION_NODES.get(shipping_action, ("ship-intake", "Shipping Intake"))
|
|
394
|
+
return {
|
|
395
|
+
"domain": "shipping",
|
|
396
|
+
"layout_id": "process_definition-shipping-management-canvas",
|
|
397
|
+
"process_definition_id": "process_definition-shipping-management",
|
|
398
|
+
"subject": "indus.shipping.queue",
|
|
399
|
+
"target_node": "Shipping Intake",
|
|
400
|
+
"entry_node": "Shipping Intake",
|
|
401
|
+
"action_node_id": f"process_definition-shipping-management:{action_node_id}",
|
|
402
|
+
"action_node": action_node,
|
|
403
|
+
"shipping_action": shipping_action,
|
|
404
|
+
"workflow_path": SHIPPING_CANVAS_PATHS.get(shipping_action, ["Shipping Queue", "Shipping Intake", action_node]),
|
|
405
|
+
"audit_node": "Shipping Audit Log",
|
|
406
|
+
"exception_node": "Shipping Exception Queue",
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
"domain": "supply_chain",
|
|
410
|
+
"subject": f"indus.events.{event_type.replace('_', '-')}",
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def _changed_by_update_payload(event: dict[str, Any], field: str) -> bool:
|
|
415
|
+
update = event.get("update")
|
|
416
|
+
if not isinstance(update, dict):
|
|
417
|
+
return False
|
|
418
|
+
updated_fields = update.get("updatedFields")
|
|
419
|
+
if isinstance(updated_fields, dict) and field in updated_fields:
|
|
420
|
+
return True
|
|
421
|
+
set_fields = update.get("$set")
|
|
422
|
+
if isinstance(set_fields, dict) and field in set_fields:
|
|
423
|
+
return True
|
|
424
|
+
return field in update
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def _status_changed(event: dict[str, Any], before: dict[str, Any], after: dict[str, Any], field: str) -> bool:
|
|
428
|
+
if before:
|
|
429
|
+
return _normalize_token(before.get(field)) != _normalize_token(after.get(field))
|
|
430
|
+
operation = _normalize_token(event.get("operation"))
|
|
431
|
+
if "insert" in operation:
|
|
432
|
+
return bool(after.get(field))
|
|
433
|
+
return _changed_by_update_payload(event, field)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
def _domain_event(
|
|
437
|
+
*,
|
|
438
|
+
cdc_event: dict[str, Any],
|
|
439
|
+
event_type: str,
|
|
440
|
+
collection: str,
|
|
441
|
+
record: dict[str, Any],
|
|
442
|
+
action: str,
|
|
443
|
+
details: dict[str, Any] | None = None,
|
|
444
|
+
) -> dict[str, Any]:
|
|
445
|
+
workflow = _workflow_route(event_type)
|
|
446
|
+
payload = {
|
|
447
|
+
"collection": collection,
|
|
448
|
+
"record_id": _record_id(collection, record, cdc_event),
|
|
449
|
+
"action": action,
|
|
450
|
+
"document": record,
|
|
451
|
+
"workflow": workflow,
|
|
452
|
+
**(details or {}),
|
|
453
|
+
}
|
|
454
|
+
event = {
|
|
455
|
+
"event_id": f"supply-chain-{uuid4().hex}",
|
|
456
|
+
"event_type": event_type,
|
|
457
|
+
"source": "cdc-domain-mapper",
|
|
458
|
+
"domain": "supply_chain",
|
|
459
|
+
"subject": workflow["subject"],
|
|
460
|
+
"payload_type": "json",
|
|
461
|
+
"payload": payload,
|
|
462
|
+
"workflow": workflow,
|
|
463
|
+
"source_cdc_event_id": cdc_event.get("event_id"),
|
|
464
|
+
"source_collection": collection,
|
|
465
|
+
"source_operation": cdc_event.get("operation"),
|
|
466
|
+
"record_id": payload["record_id"],
|
|
467
|
+
"occurred_at": utc_now(),
|
|
468
|
+
}
|
|
469
|
+
if workflow.get("target_node"):
|
|
470
|
+
event["target_node"] = workflow["target_node"]
|
|
471
|
+
if workflow.get("warehouse_action"):
|
|
472
|
+
event["warehouse_action"] = workflow["warehouse_action"]
|
|
473
|
+
if workflow.get("shipping_action"):
|
|
474
|
+
event["shipping_action"] = workflow["shipping_action"]
|
|
475
|
+
return jsonable_encoder(event)
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def _derive_status_event(cdc_event: dict[str, Any], collection: str, before: dict[str, Any], after: dict[str, Any]) -> dict[str, Any] | None:
|
|
479
|
+
field = STATUS_FIELD_BY_COLLECTION.get(collection, "status")
|
|
480
|
+
if not after or not _status_changed(cdc_event, before, after, field):
|
|
481
|
+
return None
|
|
482
|
+
status = _normalize_token(after.get(field))
|
|
483
|
+
if not status or status not in INTERESTING_STATUS_VALUES:
|
|
484
|
+
return None
|
|
485
|
+
|
|
486
|
+
event_type = STATUS_EVENT_ALIASES.get((collection, status))
|
|
487
|
+
if not event_type:
|
|
488
|
+
prefix = STATUS_EVENT_PREFIX.get(collection)
|
|
489
|
+
if not prefix:
|
|
490
|
+
return None
|
|
491
|
+
event_type = f"{prefix}_{status.replace('-', '_')}"
|
|
492
|
+
|
|
493
|
+
return _domain_event(
|
|
494
|
+
cdc_event=cdc_event,
|
|
495
|
+
event_type=event_type,
|
|
496
|
+
collection=collection,
|
|
497
|
+
record=after,
|
|
498
|
+
action=status,
|
|
499
|
+
details={
|
|
500
|
+
"field": field,
|
|
501
|
+
"before_status": before.get(field) if before else None,
|
|
502
|
+
"after_status": after.get(field),
|
|
503
|
+
},
|
|
504
|
+
)
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
def _derive_inventory_transaction_event(cdc_event: dict[str, Any], after: dict[str, Any]) -> dict[str, Any] | None:
|
|
508
|
+
if not after:
|
|
509
|
+
return None
|
|
510
|
+
operation = _normalize_token(cdc_event.get("operation"))
|
|
511
|
+
if "insert" not in operation and not _changed_by_update_payload(cdc_event, "posted"):
|
|
512
|
+
return None
|
|
513
|
+
|
|
514
|
+
transaction_type = _normalize_token(after.get("transaction_type"))
|
|
515
|
+
event_type = "inventory_transaction_recorded"
|
|
516
|
+
if after.get("posted") is True:
|
|
517
|
+
event_type = "inventory_transaction_posted"
|
|
518
|
+
elif transaction_type:
|
|
519
|
+
event_type = INVENTORY_TRANSACTION_EVENT_ALIASES.get(transaction_type, event_type)
|
|
520
|
+
|
|
521
|
+
return _domain_event(
|
|
522
|
+
cdc_event=cdc_event,
|
|
523
|
+
event_type=event_type,
|
|
524
|
+
collection="inventory_transactions",
|
|
525
|
+
record=after,
|
|
526
|
+
action=transaction_type or "transaction",
|
|
527
|
+
details={
|
|
528
|
+
"transaction_type": after.get("transaction_type"),
|
|
529
|
+
"direction": after.get("direction"),
|
|
530
|
+
"quantity": after.get("quantity"),
|
|
531
|
+
"reference_type": after.get("reference_type"),
|
|
532
|
+
"reference_id": after.get("reference_id"),
|
|
533
|
+
"posted": after.get("posted"),
|
|
534
|
+
},
|
|
535
|
+
)
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
def derive_supply_chain_domain_events(cdc_event: dict[str, Any]) -> list[dict[str, Any]]:
|
|
539
|
+
collection = str(cdc_event.get("collection") or "").strip()
|
|
540
|
+
if collection not in SUPPLY_CHAIN_COLLECTIONS:
|
|
541
|
+
return []
|
|
542
|
+
|
|
543
|
+
before = _document(cdc_event, "before")
|
|
544
|
+
after = _document(cdc_event, "after")
|
|
545
|
+
if not after:
|
|
546
|
+
return []
|
|
547
|
+
|
|
548
|
+
events: list[dict[str, Any]] = []
|
|
549
|
+
if collection == "inventory_transactions":
|
|
550
|
+
event = _derive_inventory_transaction_event(cdc_event, after)
|
|
551
|
+
else:
|
|
552
|
+
event = _derive_status_event(cdc_event, collection, before, after)
|
|
553
|
+
if event:
|
|
554
|
+
events.append(event)
|
|
555
|
+
return events
|