@open-mercato/core 0.4.2-canary-51881f6bf3 → 0.4.2-canary-5f415b8a44
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/dist/generated/entities/workflow_event_trigger/index.js +33 -0
- package/dist/generated/entities/workflow_event_trigger/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +59 -58
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +2 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/auth/events.js +30 -0
- package/dist/modules/auth/events.js.map +7 -0
- package/dist/modules/business_rules/api/execute/[ruleId]/route.js +145 -0
- package/dist/modules/business_rules/api/execute/[ruleId]/route.js.map +7 -0
- package/dist/modules/business_rules/data/validators.js +34 -0
- package/dist/modules/business_rules/data/validators.js.map +2 -2
- package/dist/modules/business_rules/index.js +21 -1
- package/dist/modules/business_rules/index.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-engine.js +182 -1
- package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
- package/dist/modules/catalog/events.js +34 -0
- package/dist/modules/catalog/events.js.map +7 -0
- package/dist/modules/customers/events.js +49 -0
- package/dist/modules/customers/events.js.map +7 -0
- package/dist/modules/directory/events.js +23 -0
- package/dist/modules/directory/events.js.map +7 -0
- package/dist/modules/sales/acl.js +1 -0
- package/dist/modules/sales/acl.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +12 -0
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +62 -0
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/events.js +63 -0
- package/dist/modules/sales/events.js.map +7 -0
- package/dist/modules/sales/lib/dictionaries.js +3 -0
- package/dist/modules/sales/lib/dictionaries.js.map +2 -2
- package/dist/modules/sales/lib/frontend/documentDataEvents.js +25 -0
- package/dist/modules/sales/lib/frontend/documentDataEvents.js.map +7 -0
- package/dist/modules/workflows/acl.js +2 -0
- package/dist/modules/workflows/acl.js.map +2 -2
- package/dist/modules/workflows/api/instances/route.js +18 -6
- package/dist/modules/workflows/api/instances/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/route.js +6 -1
- package/dist/modules/workflows/api/tasks/route.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/[id]/page.js +9 -1
- package/dist/modules/workflows/backend/definitions/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/[id]/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/create/page.js +24 -15
- package/dist/modules/workflows/backend/definitions/create/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/create/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/create/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +150 -132
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/visual-editor/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/events/[id]/page.js +1 -1
- package/dist/modules/workflows/backend/events/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/events/[id]/page.meta.js +2 -2
- package/dist/modules/workflows/backend/events/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.meta.js +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.js +1 -1
- package/dist/modules/workflows/backend/tasks/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.meta.js +2 -2
- package/dist/modules/workflows/backend/tasks/[id]/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/page.js +5 -6
- package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
- package/dist/modules/workflows/cli.js +81 -3
- package/dist/modules/workflows/cli.js.map +3 -3
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js +481 -0
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +7 -0
- package/dist/modules/workflows/components/EventTriggersEditor.js +553 -0
- package/dist/modules/workflows/components/EventTriggersEditor.js.map +7 -0
- package/dist/modules/workflows/data/entities.js +64 -1
- package/dist/modules/workflows/data/entities.js.map +2 -2
- package/dist/modules/workflows/data/validators.js +115 -0
- package/dist/modules/workflows/data/validators.js.map +2 -2
- package/dist/modules/workflows/events.js +38 -0
- package/dist/modules/workflows/events.js.map +7 -0
- package/dist/modules/workflows/examples/checkout-demo-definition.json +1 -5
- package/dist/modules/workflows/examples/order-approval-definition.json +257 -0
- package/dist/modules/workflows/examples/order-approval-guard-rules.json +32 -0
- package/dist/modules/workflows/lib/activity-executor.js +75 -13
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/event-trigger-service.js +308 -0
- package/dist/modules/workflows/lib/event-trigger-service.js.map +7 -0
- package/dist/modules/workflows/lib/graph-utils.js +71 -2
- package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
- package/dist/modules/workflows/lib/seeds.js +22 -5
- package/dist/modules/workflows/lib/seeds.js.map +2 -2
- package/dist/modules/workflows/lib/start-validator.js +33 -23
- package/dist/modules/workflows/lib/start-validator.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +157 -45
- package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
- package/dist/modules/workflows/migrations/Migration20260123143500.js +36 -0
- package/dist/modules/workflows/migrations/Migration20260123143500.js.map +7 -0
- package/dist/modules/workflows/subscribers/event-trigger.js +78 -0
- package/dist/modules/workflows/subscribers/event-trigger.js.map +7 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js +323 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.client.js.map +7 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.js +17 -0
- package/dist/modules/workflows/widgets/injection/order-approval/widget.js.map +7 -0
- package/dist/modules/workflows/widgets/injection-table.js +19 -0
- package/dist/modules/workflows/widgets/injection-table.js.map +7 -0
- package/generated/entities/workflow_event_trigger/index.ts +15 -0
- package/generated/entities.ids.generated.ts +59 -58
- package/generated/entity-fields-registry.ts +2 -0
- package/package.json +3 -5
- package/src/modules/auth/events.ts +39 -0
- package/src/modules/business_rules/api/execute/[ruleId]/route.ts +163 -0
- package/src/modules/business_rules/data/validators.ts +40 -0
- package/src/modules/business_rules/index.ts +25 -0
- package/src/modules/business_rules/lib/rule-engine.ts +281 -1
- package/src/modules/catalog/events.ts +45 -0
- package/src/modules/customers/events.ts +63 -0
- package/src/modules/directory/events.ts +31 -0
- package/src/modules/sales/acl.ts +1 -0
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +16 -0
- package/src/modules/sales/commands/documents.ts +74 -1
- package/src/modules/sales/events.ts +82 -0
- package/src/modules/sales/lib/dictionaries.ts +3 -0
- package/src/modules/sales/lib/frontend/documentDataEvents.ts +28 -0
- package/src/modules/workflows/acl.ts +2 -0
- package/src/modules/workflows/api/instances/route.ts +21 -7
- package/src/modules/workflows/api/tasks/route.ts +7 -1
- package/src/modules/workflows/backend/definitions/[id]/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/[id]/page.tsx +9 -0
- package/src/modules/workflows/backend/definitions/create/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/create/page.tsx +9 -0
- package/src/modules/workflows/backend/definitions/visual-editor/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +21 -3
- package/src/modules/workflows/backend/events/[id]/page.meta.ts +2 -2
- package/src/modules/workflows/backend/events/[id]/page.tsx +1 -1
- package/src/modules/workflows/backend/instances/[id]/page.meta.ts +2 -2
- package/src/modules/workflows/backend/tasks/[id]/page.meta.ts +2 -2
- package/src/modules/workflows/backend/tasks/[id]/page.tsx +1 -1
- package/src/modules/workflows/backend/tasks/page.tsx +5 -6
- package/src/modules/workflows/cli.ts +111 -0
- package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +581 -0
- package/src/modules/workflows/components/EventTriggersEditor.tsx +664 -0
- package/src/modules/workflows/data/entities.ts +124 -0
- package/src/modules/workflows/data/validators.ts +138 -0
- package/src/modules/workflows/events.ts +49 -0
- package/src/modules/workflows/examples/checkout-demo-definition.json +1 -5
- package/src/modules/workflows/examples/order-approval-definition.json +257 -0
- package/src/modules/workflows/examples/order-approval-guard-rules.json +32 -0
- package/src/modules/workflows/i18n/en.json +71 -0
- package/src/modules/workflows/lib/activity-executor.ts +129 -16
- package/src/modules/workflows/lib/event-trigger-service.ts +557 -0
- package/src/modules/workflows/lib/graph-utils.ts +117 -2
- package/src/modules/workflows/lib/seeds.ts +34 -8
- package/src/modules/workflows/lib/start-validator.ts +38 -28
- package/src/modules/workflows/lib/transition-handler.ts +208 -55
- package/src/modules/workflows/migrations/Migration20260123143500.ts +38 -0
- package/src/modules/workflows/subscribers/event-trigger.ts +109 -0
- package/src/modules/workflows/widgets/injection/order-approval/widget.client.tsx +446 -0
- package/src/modules/workflows/widgets/injection/order-approval/widget.ts +16 -0
- package/src/modules/workflows/widgets/injection-table.ts +21 -0
|
@@ -30,34 +30,34 @@ export const E = {
|
|
|
30
30
|
"dashboard_user_widgets": "dashboards:dashboard_user_widgets"
|
|
31
31
|
},
|
|
32
32
|
"auth": {
|
|
33
|
-
"
|
|
33
|
+
"password_reset": "auth:password_reset",
|
|
34
34
|
"role": "auth:role",
|
|
35
|
-
"
|
|
35
|
+
"role_acl": "auth:role_acl",
|
|
36
36
|
"role_sidebar_preference": "auth:role_sidebar_preference",
|
|
37
|
-
"user_role": "auth:user_role",
|
|
38
37
|
"session": "auth:session",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
38
|
+
"user": "auth:user",
|
|
39
|
+
"user_acl": "auth:user_acl",
|
|
40
|
+
"user_role": "auth:user_role",
|
|
41
|
+
"user_sidebar_preference": "auth:user_sidebar_preference"
|
|
42
42
|
},
|
|
43
43
|
"directory": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
44
|
+
"organization": "directory:organization",
|
|
45
|
+
"tenant": "directory:tenant"
|
|
46
46
|
},
|
|
47
47
|
"customers": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"customer_activity": "customers:customer_activity",
|
|
49
|
+
"customer_address": "customers:customer_address",
|
|
50
|
+
"customer_comment": "customers:customer_comment",
|
|
50
51
|
"customer_company_profile": "customers:customer_company_profile",
|
|
51
52
|
"customer_deal": "customers:customer_deal",
|
|
52
|
-
"customer_deal_person_link": "customers:customer_deal_person_link",
|
|
53
53
|
"customer_deal_company_link": "customers:customer_deal_company_link",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
54
|
+
"customer_deal_person_link": "customers:customer_deal_person_link",
|
|
55
|
+
"customer_dictionary_entry": "customers:customer_dictionary_entry",
|
|
56
|
+
"customer_entity": "customers:customer_entity",
|
|
57
|
+
"customer_person_profile": "customers:customer_person_profile",
|
|
57
58
|
"customer_settings": "customers:customer_settings",
|
|
58
59
|
"customer_tag": "customers:customer_tag",
|
|
59
60
|
"customer_tag_assignment": "customers:customer_tag_assignment",
|
|
60
|
-
"customer_dictionary_entry": "customers:customer_dictionary_entry",
|
|
61
61
|
"customer_todo_link": "customers:customer_todo_link"
|
|
62
62
|
},
|
|
63
63
|
"perspectives": {
|
|
@@ -65,10 +65,10 @@ export const E = {
|
|
|
65
65
|
"role_perspective": "perspectives:role_perspective"
|
|
66
66
|
},
|
|
67
67
|
"entities": {
|
|
68
|
-
"custom_field_def": "entities:custom_field_def",
|
|
69
|
-
"custom_field_entity_config": "entities:custom_field_entity_config",
|
|
70
68
|
"custom_entity": "entities:custom_entity",
|
|
71
69
|
"custom_entity_storage": "entities:custom_entity_storage",
|
|
70
|
+
"custom_field_def": "entities:custom_field_def",
|
|
71
|
+
"custom_field_entity_config": "entities:custom_field_entity_config",
|
|
72
72
|
"custom_field_value": "entities:custom_field_value",
|
|
73
73
|
"encryption_map": "entities:encryption_map"
|
|
74
74
|
},
|
|
@@ -77,60 +77,60 @@ export const E = {
|
|
|
77
77
|
"upgrade_action_run": "configs:upgrade_action_run"
|
|
78
78
|
},
|
|
79
79
|
"query_index": {
|
|
80
|
-
"entity_index_row": "query_index:entity_index_row",
|
|
81
|
-
"entity_index_job": "query_index:entity_index_job",
|
|
82
80
|
"entity_index_coverage": "query_index:entity_index_coverage",
|
|
81
|
+
"entity_index_job": "query_index:entity_index_job",
|
|
82
|
+
"entity_index_row": "query_index:entity_index_row",
|
|
83
83
|
"indexer_error_log": "query_index:indexer_error_log",
|
|
84
84
|
"indexer_status_log": "query_index:indexer_status_log",
|
|
85
85
|
"search_token": "query_index:search_token"
|
|
86
86
|
},
|
|
87
87
|
"audit_logs": {
|
|
88
|
-
"
|
|
89
|
-
"
|
|
88
|
+
"access_log": "audit_logs:access_log",
|
|
89
|
+
"action_log": "audit_logs:action_log"
|
|
90
90
|
},
|
|
91
91
|
"attachments": {
|
|
92
|
-
"
|
|
93
|
-
"
|
|
92
|
+
"attachment": "attachments:attachment",
|
|
93
|
+
"attachment_partition": "attachments:attachment_partition"
|
|
94
94
|
},
|
|
95
95
|
"catalog": {
|
|
96
|
+
"catalog_offer": "catalog:catalog_offer",
|
|
96
97
|
"catalog_option_schema_template": "catalog:catalog_option_schema_template",
|
|
98
|
+
"catalog_price_kind": "catalog:catalog_price_kind",
|
|
97
99
|
"catalog_product": "catalog:catalog_product",
|
|
98
100
|
"catalog_product_category": "catalog:catalog_product_category",
|
|
99
101
|
"catalog_product_category_assignment": "catalog:catalog_product_category_assignment",
|
|
102
|
+
"catalog_product_price": "catalog:catalog_product_price",
|
|
100
103
|
"catalog_product_tag": "catalog:catalog_product_tag",
|
|
101
104
|
"catalog_product_tag_assignment": "catalog:catalog_product_tag_assignment",
|
|
102
|
-
"catalog_offer": "catalog:catalog_offer",
|
|
103
105
|
"catalog_product_variant": "catalog:catalog_product_variant",
|
|
104
|
-
"catalog_product_variant_relation": "catalog:catalog_product_variant_relation"
|
|
105
|
-
"catalog_price_kind": "catalog:catalog_price_kind",
|
|
106
|
-
"catalog_product_price": "catalog:catalog_product_price"
|
|
106
|
+
"catalog_product_variant_relation": "catalog:catalog_product_variant_relation"
|
|
107
107
|
},
|
|
108
108
|
"sales": {
|
|
109
109
|
"sales_channel": "sales:sales_channel",
|
|
110
|
-
"
|
|
110
|
+
"sales_credit_memo": "sales:sales_credit_memo",
|
|
111
|
+
"sales_credit_memo_line": "sales:sales_credit_memo_line",
|
|
111
112
|
"sales_delivery_window": "sales:sales_delivery_window",
|
|
112
|
-
"
|
|
113
|
-
"
|
|
113
|
+
"sales_document_address": "sales:sales_document_address",
|
|
114
|
+
"sales_document_sequence": "sales:sales_document_sequence",
|
|
115
|
+
"sales_document_tag": "sales:sales_document_tag",
|
|
116
|
+
"sales_document_tag_assignment": "sales:sales_document_tag_assignment",
|
|
117
|
+
"sales_invoice": "sales:sales_invoice",
|
|
118
|
+
"sales_invoice_line": "sales:sales_invoice_line",
|
|
119
|
+
"sales_note": "sales:sales_note",
|
|
114
120
|
"sales_order": "sales:sales_order",
|
|
115
|
-
"sales_order_line": "sales:sales_order_line",
|
|
116
121
|
"sales_order_adjustment": "sales:sales_order_adjustment",
|
|
117
|
-
"
|
|
118
|
-
"
|
|
122
|
+
"sales_order_line": "sales:sales_order_line",
|
|
123
|
+
"sales_payment": "sales:sales_payment",
|
|
124
|
+
"sales_payment_allocation": "sales:sales_payment_allocation",
|
|
125
|
+
"sales_payment_method": "sales:sales_payment_method",
|
|
119
126
|
"sales_quote": "sales:sales_quote",
|
|
120
|
-
"sales_quote_line": "sales:sales_quote_line",
|
|
121
127
|
"sales_quote_adjustment": "sales:sales_quote_adjustment",
|
|
128
|
+
"sales_quote_line": "sales:sales_quote_line",
|
|
129
|
+
"sales_settings": "sales:sales_settings",
|
|
122
130
|
"sales_shipment": "sales:sales_shipment",
|
|
123
131
|
"sales_shipment_item": "sales:sales_shipment_item",
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"sales_credit_memo": "sales:sales_credit_memo",
|
|
127
|
-
"sales_credit_memo_line": "sales:sales_credit_memo_line",
|
|
128
|
-
"sales_payment": "sales:sales_payment",
|
|
129
|
-
"sales_payment_allocation": "sales:sales_payment_allocation",
|
|
130
|
-
"sales_note": "sales:sales_note",
|
|
131
|
-
"sales_document_address": "sales:sales_document_address",
|
|
132
|
-
"sales_document_tag": "sales:sales_document_tag",
|
|
133
|
-
"sales_document_tag_assignment": "sales:sales_document_tag_assignment"
|
|
132
|
+
"sales_shipping_method": "sales:sales_shipping_method",
|
|
133
|
+
"sales_tax_rate": "sales:sales_tax_rate"
|
|
134
134
|
},
|
|
135
135
|
"api_keys": {
|
|
136
136
|
"api_key": "api_keys:api_key"
|
|
@@ -150,38 +150,39 @@ export const E = {
|
|
|
150
150
|
"feature_toggle_override": "feature_toggles:feature_toggle_override"
|
|
151
151
|
},
|
|
152
152
|
"workflows": {
|
|
153
|
-
"workflow_definition": "workflows:workflow_definition",
|
|
154
|
-
"workflow_instance": "workflows:workflow_instance",
|
|
155
153
|
"step_instance": "workflows:step_instance",
|
|
156
154
|
"user_task": "workflows:user_task",
|
|
157
|
-
"
|
|
155
|
+
"workflow_definition": "workflows:workflow_definition",
|
|
156
|
+
"workflow_event": "workflows:workflow_event",
|
|
157
|
+
"workflow_event_trigger": "workflows:workflow_event_trigger",
|
|
158
|
+
"workflow_instance": "workflows:workflow_instance"
|
|
158
159
|
},
|
|
159
160
|
"currencies": {
|
|
160
161
|
"currency": "currencies:currency",
|
|
161
|
-
"
|
|
162
|
-
"
|
|
162
|
+
"currency_fetch_config": "currencies:currency_fetch_config",
|
|
163
|
+
"exchange_rate": "currencies:exchange_rate"
|
|
163
164
|
},
|
|
164
165
|
"planner": {
|
|
165
|
-
"
|
|
166
|
-
"
|
|
166
|
+
"planner_availability_rule": "planner:planner_availability_rule",
|
|
167
|
+
"planner_availability_rule_set": "planner:planner_availability_rule_set"
|
|
167
168
|
},
|
|
168
169
|
"resources": {
|
|
169
|
-
"resources_resource_type": "resources:resources_resource_type",
|
|
170
170
|
"resources_resource": "resources:resources_resource",
|
|
171
|
-
"resources_resource_comment": "resources:resources_resource_comment",
|
|
172
171
|
"resources_resource_activity": "resources:resources_resource_activity",
|
|
172
|
+
"resources_resource_comment": "resources:resources_resource_comment",
|
|
173
173
|
"resources_resource_tag": "resources:resources_resource_tag",
|
|
174
|
-
"resources_resource_tag_assignment": "resources:resources_resource_tag_assignment"
|
|
174
|
+
"resources_resource_tag_assignment": "resources:resources_resource_tag_assignment",
|
|
175
|
+
"resources_resource_type": "resources:resources_resource_type"
|
|
175
176
|
},
|
|
176
177
|
"staff": {
|
|
178
|
+
"staff_leave_request": "staff:staff_leave_request",
|
|
177
179
|
"staff_team": "staff:staff_team",
|
|
178
|
-
"staff_team_role": "staff:staff_team_role",
|
|
179
180
|
"staff_team_member": "staff:staff_team_member",
|
|
180
|
-
"staff_leave_request": "staff:staff_leave_request",
|
|
181
|
-
"staff_team_member_comment": "staff:staff_team_member_comment",
|
|
182
181
|
"staff_team_member_activity": "staff:staff_team_member_activity",
|
|
182
|
+
"staff_team_member_address": "staff:staff_team_member_address",
|
|
183
|
+
"staff_team_member_comment": "staff:staff_team_member_comment",
|
|
183
184
|
"staff_team_member_job_history": "staff:staff_team_member_job_history",
|
|
184
|
-
"
|
|
185
|
+
"staff_team_role": "staff:staff_team_role"
|
|
185
186
|
}
|
|
186
187
|
} as const
|
|
187
188
|
export type KnownModuleId = keyof typeof M
|
|
@@ -116,6 +116,7 @@ import * as user_sidebar_preference from './entities/user_sidebar_preference/ind
|
|
|
116
116
|
import * as user_task from './entities/user_task/index'
|
|
117
117
|
import * as workflow_definition from './entities/workflow_definition/index'
|
|
118
118
|
import * as workflow_event from './entities/workflow_event/index'
|
|
119
|
+
import * as workflow_event_trigger from './entities/workflow_event_trigger/index'
|
|
119
120
|
import * as workflow_instance from './entities/workflow_instance/index'
|
|
120
121
|
|
|
121
122
|
export const entityFieldsRegistry: Record<string, Record<string, string>> = {
|
|
@@ -235,6 +236,7 @@ export const entityFieldsRegistry: Record<string, Record<string, string>> = {
|
|
|
235
236
|
user_task,
|
|
236
237
|
workflow_definition,
|
|
237
238
|
workflow_event,
|
|
239
|
+
workflow_event_trigger,
|
|
238
240
|
workflow_instance
|
|
239
241
|
}
|
|
240
242
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.4.2-canary-
|
|
3
|
+
"version": "0.4.2-canary-5f415b8a44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -207,12 +207,10 @@
|
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
209
|
"dependencies": {
|
|
210
|
-
"@open-mercato/shared": "0.4.2-canary-
|
|
211
|
-
"@types/semver": "^7.5.8",
|
|
210
|
+
"@open-mercato/shared": "0.4.2-canary-5f415b8a44",
|
|
212
211
|
"@xyflow/react": "^12.6.0",
|
|
213
212
|
"date-fns": "^4.1.0",
|
|
214
|
-
"date-fns-tz": "^3.2.0"
|
|
215
|
-
"semver": "^7.6.3"
|
|
213
|
+
"date-fns-tz": "^3.2.0"
|
|
216
214
|
},
|
|
217
215
|
"devDependencies": {
|
|
218
216
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createModuleEvents } from '@open-mercato/shared/modules/events'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Auth Module Events
|
|
5
|
+
*
|
|
6
|
+
* Declares all events that can be emitted by the auth module.
|
|
7
|
+
*/
|
|
8
|
+
const events = [
|
|
9
|
+
// Users
|
|
10
|
+
{ id: 'auth.users.created', label: 'User Created', entity: 'users', category: 'crud' },
|
|
11
|
+
{ id: 'auth.users.updated', label: 'User Updated', entity: 'users', category: 'crud' },
|
|
12
|
+
{ id: 'auth.users.deleted', label: 'User Deleted', entity: 'users', category: 'crud' },
|
|
13
|
+
|
|
14
|
+
// Roles
|
|
15
|
+
{ id: 'auth.roles.created', label: 'Role Created', entity: 'roles', category: 'crud' },
|
|
16
|
+
{ id: 'auth.roles.updated', label: 'Role Updated', entity: 'roles', category: 'crud' },
|
|
17
|
+
{ id: 'auth.roles.deleted', label: 'Role Deleted', entity: 'roles', category: 'crud' },
|
|
18
|
+
|
|
19
|
+
// Authentication events
|
|
20
|
+
{ id: 'auth.login.success', label: 'Login Successful', category: 'lifecycle' },
|
|
21
|
+
{ id: 'auth.login.failed', label: 'Login Failed', category: 'lifecycle' },
|
|
22
|
+
{ id: 'auth.logout', label: 'User Logged Out', category: 'lifecycle' },
|
|
23
|
+
{ id: 'auth.password.changed', label: 'Password Changed', category: 'lifecycle' },
|
|
24
|
+
{ id: 'auth.password.reset.requested', label: 'Password Reset Requested', category: 'lifecycle' },
|
|
25
|
+
{ id: 'auth.password.reset.completed', label: 'Password Reset Completed', category: 'lifecycle' },
|
|
26
|
+
] as const
|
|
27
|
+
|
|
28
|
+
export const eventsConfig = createModuleEvents({
|
|
29
|
+
moduleId: 'auth',
|
|
30
|
+
events,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
/** Type-safe event emitter for auth module */
|
|
34
|
+
export const emitAuthEvent = eventsConfig.emit
|
|
35
|
+
|
|
36
|
+
/** Event IDs that can be emitted by the auth module */
|
|
37
|
+
export type AuthEventId = typeof events[number]['id']
|
|
38
|
+
|
|
39
|
+
export default eventsConfig
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'
|
|
4
|
+
import { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'
|
|
5
|
+
import { createRequestContainer } from '@open-mercato/shared/lib/di/container'
|
|
6
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
7
|
+
import * as ruleEngine from '../../../lib/rule-engine'
|
|
8
|
+
|
|
9
|
+
const executeByIdRequestSchema = z.object({
|
|
10
|
+
data: z.any(),
|
|
11
|
+
dryRun: z.boolean().optional().default(false),
|
|
12
|
+
entityType: z.string().optional(),
|
|
13
|
+
entityId: z.string().optional(),
|
|
14
|
+
eventType: z.string().optional(),
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const executeByIdResponseSchema = z.object({
|
|
18
|
+
success: z.boolean(),
|
|
19
|
+
ruleId: z.string(),
|
|
20
|
+
ruleName: z.string(),
|
|
21
|
+
conditionResult: z.boolean(),
|
|
22
|
+
actionsExecuted: z.object({
|
|
23
|
+
success: z.boolean(),
|
|
24
|
+
results: z.array(z.object({
|
|
25
|
+
type: z.string(),
|
|
26
|
+
success: z.boolean(),
|
|
27
|
+
error: z.string().optional(),
|
|
28
|
+
})),
|
|
29
|
+
}).nullable(),
|
|
30
|
+
executionTime: z.number(),
|
|
31
|
+
error: z.string().optional(),
|
|
32
|
+
logId: z.string().optional(),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const errorResponseSchema = z.object({
|
|
36
|
+
error: z.string(),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const routeMetadata = {
|
|
40
|
+
POST: { requireAuth: true, requireFeatures: ['business_rules.execute'] },
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const metadata = routeMetadata
|
|
44
|
+
|
|
45
|
+
interface RouteContext {
|
|
46
|
+
params: Promise<{ ruleId: string }>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function POST(req: Request, context: RouteContext) {
|
|
50
|
+
const auth = await getAuthFromRequest(req)
|
|
51
|
+
if (!auth) {
|
|
52
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const params = await context.params
|
|
56
|
+
const ruleId = params.ruleId
|
|
57
|
+
|
|
58
|
+
if (!ruleId || !z.uuid().safeParse(ruleId).success) {
|
|
59
|
+
return NextResponse.json({ error: 'Invalid rule ID' }, { status: 400 })
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const container = await createRequestContainer()
|
|
63
|
+
const em = container.resolve('em') as EntityManager
|
|
64
|
+
|
|
65
|
+
let body: any
|
|
66
|
+
try {
|
|
67
|
+
body = await req.json()
|
|
68
|
+
} catch {
|
|
69
|
+
return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const parsed = executeByIdRequestSchema.safeParse(body)
|
|
73
|
+
if (!parsed.success) {
|
|
74
|
+
const errors = parsed.error.issues.map(e => `${e.path.join('.')}: ${e.message}`)
|
|
75
|
+
return NextResponse.json({ error: `Validation failed: ${errors.join(', ')}` }, { status: 400 })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const { data, dryRun, entityType, entityId, eventType } = parsed.data
|
|
79
|
+
|
|
80
|
+
const execContext: ruleEngine.DirectRuleExecutionContext = {
|
|
81
|
+
ruleId,
|
|
82
|
+
data,
|
|
83
|
+
user: {
|
|
84
|
+
id: auth.sub,
|
|
85
|
+
email: auth.email,
|
|
86
|
+
role: (auth.role as string) ?? undefined,
|
|
87
|
+
},
|
|
88
|
+
tenantId: auth.tenantId ?? '',
|
|
89
|
+
organizationId: auth.orgId ?? '',
|
|
90
|
+
executedBy: auth.sub ?? auth.email ?? undefined,
|
|
91
|
+
dryRun,
|
|
92
|
+
entityType,
|
|
93
|
+
entityId,
|
|
94
|
+
eventType,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
const result = await ruleEngine.executeRuleById(em, execContext)
|
|
99
|
+
|
|
100
|
+
const response = {
|
|
101
|
+
success: result.success,
|
|
102
|
+
ruleId: result.ruleId,
|
|
103
|
+
ruleName: result.ruleName,
|
|
104
|
+
conditionResult: result.conditionResult,
|
|
105
|
+
actionsExecuted: result.actionsExecuted ? {
|
|
106
|
+
success: result.actionsExecuted.success,
|
|
107
|
+
results: result.actionsExecuted.results.map(ar => ({
|
|
108
|
+
type: ar.action.type,
|
|
109
|
+
success: ar.success,
|
|
110
|
+
error: ar.error,
|
|
111
|
+
})),
|
|
112
|
+
} : null,
|
|
113
|
+
executionTime: result.executionTime,
|
|
114
|
+
error: result.error,
|
|
115
|
+
logId: result.logId,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Return appropriate status based on result
|
|
119
|
+
const status = result.success ? 200 : (result.error === 'Rule not found' ? 404 : 200)
|
|
120
|
+
return NextResponse.json(response, { status })
|
|
121
|
+
} catch (error) {
|
|
122
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
123
|
+
return NextResponse.json(
|
|
124
|
+
{ error: `Rule execution failed: ${errorMessage}` },
|
|
125
|
+
{ status: 500 }
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const openApi: OpenApiRouteDoc = {
|
|
131
|
+
tag: 'Business Rules',
|
|
132
|
+
summary: 'Execute a specific business rule by ID',
|
|
133
|
+
methods: {
|
|
134
|
+
POST: {
|
|
135
|
+
summary: 'Execute a specific rule by its database UUID',
|
|
136
|
+
description: 'Directly executes a specific business rule identified by its UUID, bypassing the normal entityType/eventType discovery mechanism. Useful for workflows and targeted rule execution.',
|
|
137
|
+
pathParams: z.object({
|
|
138
|
+
ruleId: z.string().uuid().describe('The database UUID of the business rule to execute'),
|
|
139
|
+
}),
|
|
140
|
+
requestBody: {
|
|
141
|
+
contentType: 'application/json',
|
|
142
|
+
schema: executeByIdRequestSchema,
|
|
143
|
+
},
|
|
144
|
+
responses: [
|
|
145
|
+
{
|
|
146
|
+
status: 200,
|
|
147
|
+
description: 'Rule executed successfully',
|
|
148
|
+
schema: executeByIdResponseSchema,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
status: 404,
|
|
152
|
+
description: 'Rule not found',
|
|
153
|
+
schema: errorResponseSchema,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
errors: [
|
|
157
|
+
{ status: 400, description: 'Invalid request payload or rule ID', schema: errorResponseSchema },
|
|
158
|
+
{ status: 401, description: 'Unauthorized', schema: errorResponseSchema },
|
|
159
|
+
{ status: 500, description: 'Execution error', schema: errorResponseSchema },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
}
|
|
@@ -287,3 +287,43 @@ export const ruleDiscoveryOptionsSchema = z.object({
|
|
|
287
287
|
})
|
|
288
288
|
|
|
289
289
|
export type RuleDiscoveryOptionsInput = z.infer<typeof ruleDiscoveryOptionsSchema>
|
|
290
|
+
|
|
291
|
+
// Direct Rule Execution Context Schema (for executing a specific rule by ID)
|
|
292
|
+
export const directRuleExecutionContextSchema = z.object({
|
|
293
|
+
ruleId: z.uuid('ruleId must be a valid UUID'),
|
|
294
|
+
data: z.any(),
|
|
295
|
+
user: z.looseObject({
|
|
296
|
+
id: z.string().optional(),
|
|
297
|
+
email: z.string().optional(),
|
|
298
|
+
role: z.string().optional(),
|
|
299
|
+
}).optional(),
|
|
300
|
+
tenantId: z.uuid('tenantId must be a valid UUID'),
|
|
301
|
+
organizationId: z.uuid('organizationId must be a valid UUID'),
|
|
302
|
+
executedBy: z.string().optional(),
|
|
303
|
+
dryRun: z.boolean().optional(),
|
|
304
|
+
entityType: z.string().optional(),
|
|
305
|
+
entityId: z.string().optional(),
|
|
306
|
+
eventType: z.string().optional(),
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
export type DirectRuleExecutionContextInput = z.infer<typeof directRuleExecutionContextSchema>
|
|
310
|
+
|
|
311
|
+
// Rule ID Execution Context Schema (for executing a specific rule by its string rule_id identifier)
|
|
312
|
+
export const ruleIdExecutionContextSchema = z.object({
|
|
313
|
+
ruleId: z.string().min(1, 'ruleId must be a non-empty string').max(50),
|
|
314
|
+
data: z.any(),
|
|
315
|
+
user: z.looseObject({
|
|
316
|
+
id: z.string().optional(),
|
|
317
|
+
email: z.string().optional(),
|
|
318
|
+
role: z.string().optional(),
|
|
319
|
+
}).optional(),
|
|
320
|
+
tenantId: z.uuid('tenantId must be a valid UUID'),
|
|
321
|
+
organizationId: z.uuid('organizationId must be a valid UUID'),
|
|
322
|
+
executedBy: z.string().optional(),
|
|
323
|
+
dryRun: z.boolean().optional(),
|
|
324
|
+
entityType: z.string().optional(),
|
|
325
|
+
entityId: z.string().optional(),
|
|
326
|
+
eventType: z.string().optional(),
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
export type RuleIdExecutionContextInput = z.infer<typeof ruleIdExecutionContextSchema>
|
|
@@ -8,3 +8,28 @@ export const metadata: ModuleInfo = {
|
|
|
8
8
|
author: 'Patryk Lewczuk',
|
|
9
9
|
license: 'Proprietary',
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
// Export rule engine types and functions for programmatic usage
|
|
13
|
+
export {
|
|
14
|
+
executeRules,
|
|
15
|
+
executeRuleById,
|
|
16
|
+
executeRuleByRuleId,
|
|
17
|
+
executeSingleRule,
|
|
18
|
+
findApplicableRules,
|
|
19
|
+
logRuleExecution,
|
|
20
|
+
type RuleEngineContext,
|
|
21
|
+
type RuleEngineResult,
|
|
22
|
+
type RuleExecutionResult,
|
|
23
|
+
type RuleDiscoveryOptions,
|
|
24
|
+
type DirectRuleExecutionContext,
|
|
25
|
+
type DirectRuleExecutionResult,
|
|
26
|
+
type RuleIdExecutionContext,
|
|
27
|
+
} from './lib/rule-engine'
|
|
28
|
+
|
|
29
|
+
// Export validator schemas
|
|
30
|
+
export {
|
|
31
|
+
directRuleExecutionContextSchema,
|
|
32
|
+
ruleIdExecutionContextSchema,
|
|
33
|
+
type DirectRuleExecutionContextInput,
|
|
34
|
+
type RuleIdExecutionContextInput,
|
|
35
|
+
} from './data/validators'
|