@open-mercato/core 0.11.1-develop.8557.1.e615240a3e → 0.11.1-develop.8572.1.85986dc508
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/api_keys/di.js +6 -2
- package/dist/modules/api_keys/di.js.map +2 -2
- package/dist/modules/api_keys/services/oneTimeIssuerService.js +47 -0
- package/dist/modules/api_keys/services/oneTimeIssuerService.js.map +7 -0
- package/dist/modules/audit_logs/di.js +2 -1
- package/dist/modules/audit_logs/di.js.map +2 -2
- package/dist/modules/audit_logs/services/actionLogService.js +65 -1
- package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
- package/dist/modules/auth/cli.js +1 -0
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/commands/users.js +10 -2
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +19 -5
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/catalog/lib/productScopeReindex.js +1 -1
- package/dist/modules/catalog/lib/productScopeReindex.js.map +2 -2
- package/dist/modules/configs/cli.js +26 -29
- package/dist/modules/configs/cli.js.map +2 -2
- package/dist/modules/configs/di.js +3 -1
- package/dist/modules/configs/di.js.map +2 -2
- package/dist/modules/configs/lib/instance-config-initializer.js +44 -0
- package/dist/modules/configs/lib/instance-config-initializer.js.map +7 -0
- package/dist/modules/configs/lib/instance-defaults.js +204 -0
- package/dist/modules/configs/lib/instance-defaults.js.map +7 -0
- package/dist/modules/configs/lib/module-config-service.js +115 -1
- package/dist/modules/configs/lib/module-config-service.js.map +2 -2
- package/dist/modules/entities/api/definitions.batch.js +55 -25
- package/dist/modules/entities/api/definitions.batch.js.map +2 -2
- package/dist/modules/entities/api/definitions.js +35 -8
- package/dist/modules/entities/api/definitions.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js +14 -8
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js.map +2 -2
- package/dist/modules/notifications/lib/deliveryConfig.js +19 -12
- package/dist/modules/notifications/lib/deliveryConfig.js.map +2 -2
- package/dist/modules/notifications/setup.js +10 -0
- package/dist/modules/notifications/setup.js.map +2 -2
- package/dist/modules/payment_gateways/lib/gateway-service.js +1 -1
- package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
- package/dist/modules/query_index/api/purge.js +1 -1
- package/dist/modules/query_index/api/purge.js.map +2 -2
- package/dist/modules/query_index/api/reindex.js +1 -1
- package/dist/modules/query_index/api/reindex.js.map +2 -2
- package/dist/modules/query_index/cli.js +2 -2
- package/dist/modules/query_index/cli.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +5 -1
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/query_index/subscribers/purge.js +3 -3
- package/dist/modules/query_index/subscribers/purge.js.map +2 -2
- package/dist/modules/query_index/subscribers/reindex.js +11 -13
- package/dist/modules/query_index/subscribers/reindex.js.map +2 -2
- package/dist/modules/translations/components/TranslationManager.js +47 -10
- package/dist/modules/translations/components/TranslationManager.js.map +2 -2
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js +8 -1
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js.map +2 -2
- package/dist/modules/workflows/ai-tools/authoring-pack.js +1 -1
- package/dist/modules/workflows/ai-tools/authoring-pack.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/advance/route.js +1 -0
- package/dist/modules/workflows/api/instances/[id]/advance/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/route.js +1 -1
- package/dist/modules/workflows/api/instances/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/validate-start/route.js +3 -1
- package/dist/modules/workflows/api/instances/validate-start/route.js.map +2 -2
- package/dist/modules/workflows/components/fields/ActivityConfigFields.js +2 -0
- package/dist/modules/workflows/components/fields/ActivityConfigFields.js.map +2 -2
- package/dist/modules/workflows/di.js +3 -1
- package/dist/modules/workflows/di.js.map +2 -2
- package/dist/modules/workflows/events.js +13 -0
- package/dist/modules/workflows/events.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +48 -15
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/condition-handler.js +1 -1
- package/dist/modules/workflows/lib/condition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/error-handler.js +1 -1
- package/dist/modules/workflows/lib/error-handler.js.map +2 -2
- package/dist/modules/workflows/lib/event-trigger-service.js +1 -1
- package/dist/modules/workflows/lib/event-trigger-service.js.map +2 -2
- package/dist/modules/workflows/lib/example-definition-authoring.js +90 -0
- package/dist/modules/workflows/lib/example-definition-authoring.js.map +7 -0
- package/dist/modules/workflows/lib/named-rules.js +42 -0
- package/dist/modules/workflows/lib/named-rules.js.map +7 -0
- package/dist/modules/workflows/lib/owned-definition.js +2 -0
- package/dist/modules/workflows/lib/owned-definition.js.map +2 -2
- package/dist/modules/workflows/lib/parallel-handler.js +1 -1
- package/dist/modules/workflows/lib/parallel-handler.js.map +2 -2
- package/dist/modules/workflows/lib/signal-handler.js +1 -0
- package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
- package/dist/modules/workflows/lib/start-validator.js +87 -85
- package/dist/modules/workflows/lib/start-validator.js.map +2 -2
- package/dist/modules/workflows/lib/step-handler.js +1 -1
- package/dist/modules/workflows/lib/step-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-handler.js +1 -0
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/timer-handler.js +1 -0
- package/dist/modules/workflows/lib/timer-handler.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +48 -166
- package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
- package/dist/modules/workflows/lib/workflow-executor.js +3 -2
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/package.json +8 -8
- package/src/modules/api_keys/di.ts +7 -2
- package/src/modules/api_keys/services/oneTimeIssuerService.ts +61 -0
- package/src/modules/audit_logs/di.ts +1 -0
- package/src/modules/audit_logs/services/actionLogService.ts +132 -1
- package/src/modules/auth/cli.ts +1 -0
- package/src/modules/auth/commands/users.ts +10 -2
- package/src/modules/auth/i18n/de.json +2 -0
- package/src/modules/auth/i18n/en.json +2 -0
- package/src/modules/auth/i18n/es.json +2 -0
- package/src/modules/auth/i18n/ko.json +2 -0
- package/src/modules/auth/i18n/pl.json +2 -0
- package/src/modules/auth/lib/setup-app.ts +30 -7
- package/src/modules/catalog/lib/productScopeReindex.ts +1 -1
- package/src/modules/configs/cli.ts +39 -37
- package/src/modules/configs/di.ts +2 -0
- package/src/modules/configs/lib/instance-config-initializer.ts +56 -0
- package/src/modules/configs/lib/instance-defaults.ts +262 -0
- package/src/modules/configs/lib/module-config-service.ts +156 -0
- package/src/modules/entities/api/definitions.batch.ts +65 -27
- package/src/modules/entities/api/definitions.ts +40 -11
- package/src/modules/entities/backend/entities/user/[entityId]/page.tsx +14 -7
- package/src/modules/notifications/lib/deliveryConfig.ts +20 -11
- package/src/modules/notifications/setup.ts +11 -0
- package/src/modules/payment_gateways/lib/gateway-service.ts +2 -2
- package/src/modules/query_index/api/purge.ts +1 -1
- package/src/modules/query_index/api/reindex.ts +1 -1
- package/src/modules/query_index/cli.ts +2 -2
- package/src/modules/query_index/lib/engine.ts +5 -1
- package/src/modules/query_index/subscribers/purge.ts +5 -4
- package/src/modules/query_index/subscribers/reindex.ts +14 -15
- package/src/modules/translations/components/TranslationManager.tsx +49 -10
- package/src/modules/translations/i18n/de.json +1 -0
- package/src/modules/translations/i18n/en.json +1 -0
- package/src/modules/translations/i18n/es.json +1 -0
- package/src/modules/translations/i18n/ko.json +1 -0
- package/src/modules/translations/i18n/pl.json +1 -0
- package/src/modules/wms/components/backend/CompletePutawayTaskDialog.tsx +8 -1
- package/src/modules/wms/i18n/de.json +1 -0
- package/src/modules/wms/i18n/en.json +1 -0
- package/src/modules/wms/i18n/es.json +1 -0
- package/src/modules/wms/i18n/ko.json +1 -0
- package/src/modules/wms/i18n/pl.json +1 -0
- package/src/modules/workflows/ai-tools/authoring-pack.ts +3 -1
- package/src/modules/workflows/api/instances/[id]/advance/route.ts +1 -0
- package/src/modules/workflows/api/instances/route.ts +1 -1
- package/src/modules/workflows/api/instances/validate-start/route.ts +3 -1
- package/src/modules/workflows/components/fields/ActivityConfigFields.tsx +2 -0
- package/src/modules/workflows/di.ts +2 -0
- package/src/modules/workflows/events.ts +14 -0
- package/src/modules/workflows/lib/activity-executor.ts +64 -40
- package/src/modules/workflows/lib/condition-handler.ts +1 -1
- package/src/modules/workflows/lib/error-handler.ts +1 -1
- package/src/modules/workflows/lib/event-trigger-service.ts +1 -1
- package/src/modules/workflows/lib/example-definition-authoring.ts +114 -0
- package/src/modules/workflows/lib/named-rules.ts +54 -0
- package/src/modules/workflows/lib/owned-definition.ts +4 -1
- package/src/modules/workflows/lib/parallel-handler.ts +1 -1
- package/src/modules/workflows/lib/signal-handler.ts +1 -0
- package/src/modules/workflows/lib/start-validator.ts +96 -94
- package/src/modules/workflows/lib/step-handler.ts +1 -1
- package/src/modules/workflows/lib/task-handler.ts +1 -0
- package/src/modules/workflows/lib/timer-handler.ts +1 -0
- package/src/modules/workflows/lib/transition-handler.ts +74 -238
- package/src/modules/workflows/lib/workflow-executor.ts +7 -4
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { EntityManager } from '@mikro-orm/core'
|
|
10
|
-
import { WorkflowDefinition } from '../data/entities'
|
|
11
|
-
import * as ruleEngine from '../../business_rules/lib/rule-engine'
|
|
12
10
|
import { findWorkflowDefinition } from './find-definition'
|
|
13
|
-
import {
|
|
11
|
+
import { withNamedWorkflowRuleRunner, type WorkflowRuleContainer } from './named-rules'
|
|
14
12
|
import type { StartPreCondition } from '../data/validators'
|
|
15
13
|
import { defaultLocale } from '@open-mercato/shared/lib/i18n/config'
|
|
16
14
|
import { resolveLocaleFromCandidates } from '@open-mercato/shared/lib/i18n/locale'
|
|
@@ -64,7 +62,8 @@ export interface ValidateStartResult {
|
|
|
64
62
|
*/
|
|
65
63
|
export async function validateWorkflowStart(
|
|
66
64
|
em: EntityManager,
|
|
67
|
-
options: ValidateStartOptions
|
|
65
|
+
options: ValidateStartOptions,
|
|
66
|
+
runtime?: { container?: WorkflowRuleContainer | null; skipActions?: boolean },
|
|
68
67
|
): Promise<ValidateStartResult> {
|
|
69
68
|
const { workflowId, version, context, locale = 'en', tenantId, organizationId } = options
|
|
70
69
|
|
|
@@ -136,111 +135,114 @@ export async function validateWorkflowStart(
|
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
return withNamedWorkflowRuleRunner(runtime?.container, async (runner) => {
|
|
139
|
+
if (!runner) {
|
|
140
|
+
const required = preConditions.filter((condition) => condition.required)
|
|
141
|
+
if (required.length === 0) return { canStart: true, errors: [], validatedRules: [] }
|
|
142
|
+
const language = resolveLocaleFromCandidates([locale], getSupportedLocales()) ?? defaultLocale
|
|
143
|
+
const t = createTranslator(await loadDictionary(language))
|
|
144
|
+
return {
|
|
145
|
+
canStart: false,
|
|
146
|
+
errors: required.map((condition) => ({
|
|
147
|
+
ruleId: condition.ruleId,
|
|
148
|
+
message: getLocalizedMessage(
|
|
149
|
+
condition,
|
|
150
|
+
null,
|
|
151
|
+
locale,
|
|
152
|
+
t('workflows.errors.businessRulesModuleDisabled', 'Business rules module is disabled: {ruleId}', {
|
|
153
|
+
ruleId: condition.ruleId,
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
156
|
+
code: 'RULE_ENGINE_UNAVAILABLE',
|
|
157
|
+
})),
|
|
158
|
+
validatedRules: [],
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Evaluate each pre-condition using rule engine
|
|
163
|
+
const errors: ValidationError[] = []
|
|
164
|
+
const validatedRules: ValidatedRule[] = []
|
|
165
|
+
|
|
166
|
+
for (const condition of preConditions) {
|
|
167
|
+
// Execute rule directly by string rule_id
|
|
168
|
+
const result = await runner.executeRuleByRuleId(em, {
|
|
169
|
+
ruleId: condition.ruleId, // String identifier like "workflow_checkout_inventory_available"
|
|
170
|
+
data: {
|
|
171
|
+
workflowId,
|
|
172
|
+
workflowContext: context,
|
|
173
|
+
},
|
|
174
|
+
tenantId,
|
|
175
|
+
organizationId,
|
|
176
|
+
entityType: `workflow:${workflowId}:start`,
|
|
177
|
+
entityId: 'pre_start_validation',
|
|
178
|
+
eventType: 'validate_start',
|
|
179
|
+
dryRun: true, // Don't log execution during validation
|
|
180
|
+
...(runtime?.skipActions ? { skipActions: true } : {}),
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
validatedRules.push({
|
|
147
184
|
ruleId: condition.ruleId,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
185
|
+
passed: result.conditionResult,
|
|
186
|
+
executionTime: result.executionTime,
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
// Handle rule not found
|
|
190
|
+
if (result.error === 'Rule not found') {
|
|
191
|
+
if (condition.required) {
|
|
192
|
+
errors.push({
|
|
153
193
|
ruleId: condition.ruleId,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
194
|
+
message: getLocalizedMessage(condition, null, locale, `Business rule not found: ${condition.ruleId}`),
|
|
195
|
+
code: 'RULE_NOT_FOUND',
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
continue
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Handle disabled rule
|
|
202
|
+
if (result.error === 'Rule is disabled') {
|
|
203
|
+
if (condition.required) {
|
|
204
|
+
errors.push({
|
|
205
|
+
ruleId: condition.ruleId,
|
|
206
|
+
message: getLocalizedMessage(condition, null, locale, `Business rule is disabled: ${result.ruleName}`),
|
|
207
|
+
code: 'RULE_DISABLED',
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
continue
|
|
211
|
+
}
|
|
161
212
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const validatedRules: ValidatedRule[] = []
|
|
165
|
-
|
|
166
|
-
for (const condition of preConditions) {
|
|
167
|
-
// Execute rule directly by string rule_id
|
|
168
|
-
const result = await ruleEngine.executeRuleByRuleId(em, {
|
|
169
|
-
ruleId: condition.ruleId, // String identifier like "workflow_checkout_inventory_available"
|
|
170
|
-
data: {
|
|
171
|
-
workflowId,
|
|
172
|
-
workflowContext: context,
|
|
173
|
-
},
|
|
174
|
-
tenantId,
|
|
175
|
-
organizationId,
|
|
176
|
-
entityType: `workflow:${workflowId}:start`,
|
|
177
|
-
entityId: 'pre_start_validation',
|
|
178
|
-
eventType: 'validate_start',
|
|
179
|
-
dryRun: true, // Don't log execution during validation
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
validatedRules.push({
|
|
183
|
-
ruleId: condition.ruleId,
|
|
184
|
-
passed: result.conditionResult,
|
|
185
|
-
executionTime: result.executionTime,
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
// Handle rule not found
|
|
189
|
-
if (result.error === 'Rule not found') {
|
|
190
|
-
if (condition.required) {
|
|
213
|
+
// Handle other errors (not yet effective, expired, etc.)
|
|
214
|
+
if (result.error && condition.required) {
|
|
191
215
|
errors.push({
|
|
192
216
|
ruleId: condition.ruleId,
|
|
193
|
-
message: getLocalizedMessage(condition, null, locale, `
|
|
194
|
-
code: '
|
|
217
|
+
message: getLocalizedMessage(condition, null, locale, `Rule error: ${result.error}`),
|
|
218
|
+
code: 'RULE_ERROR',
|
|
195
219
|
})
|
|
220
|
+
continue
|
|
196
221
|
}
|
|
197
|
-
continue
|
|
198
|
-
}
|
|
199
222
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
223
|
+
// Handle condition failure
|
|
224
|
+
if (!result.conditionResult && condition.required) {
|
|
225
|
+
// Get localized message from condition or use default with rule name
|
|
226
|
+
const message = getLocalizedMessage(
|
|
227
|
+
condition,
|
|
228
|
+
null,
|
|
229
|
+
locale,
|
|
230
|
+
`Pre-condition '${result.ruleName || condition.ruleId}' failed`
|
|
231
|
+
)
|
|
203
232
|
errors.push({
|
|
204
233
|
ruleId: condition.ruleId,
|
|
205
|
-
message
|
|
206
|
-
code: '
|
|
234
|
+
message,
|
|
235
|
+
code: 'PRE_CONDITION_FAILED',
|
|
207
236
|
})
|
|
208
237
|
}
|
|
209
|
-
continue
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Handle other errors (not yet effective, expired, etc.)
|
|
213
|
-
if (result.error && condition.required) {
|
|
214
|
-
errors.push({
|
|
215
|
-
ruleId: condition.ruleId,
|
|
216
|
-
message: getLocalizedMessage(condition, null, locale, `Rule error: ${result.error}`),
|
|
217
|
-
code: 'RULE_ERROR',
|
|
218
|
-
})
|
|
219
|
-
continue
|
|
220
238
|
}
|
|
221
239
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
condition,
|
|
227
|
-
null,
|
|
228
|
-
locale,
|
|
229
|
-
`Pre-condition '${result.ruleName || condition.ruleId}' failed`
|
|
230
|
-
)
|
|
231
|
-
errors.push({
|
|
232
|
-
ruleId: condition.ruleId,
|
|
233
|
-
message,
|
|
234
|
-
code: 'PRE_CONDITION_FAILED',
|
|
235
|
-
})
|
|
240
|
+
return {
|
|
241
|
+
canStart: errors.length === 0,
|
|
242
|
+
errors,
|
|
243
|
+
validatedRules,
|
|
236
244
|
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
canStart: errors.length === 0,
|
|
241
|
-
errors,
|
|
242
|
-
validatedRules,
|
|
243
|
-
}
|
|
245
|
+
})
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
// ============================================================================
|