@open-mercato/core 0.6.6-develop.6551.1.1511bfa890 → 0.6.6
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 +2 -2
- package/dist/generated/entities.ids.generated.js +0 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +0 -12
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/api_keys/api/keys/route.js +13 -30
- package/dist/modules/api_keys/api/keys/route.js.map +2 -2
- package/dist/modules/api_keys/cli.js +1 -2
- package/dist/modules/api_keys/cli.js.map +2 -2
- package/dist/modules/attachments/api/file/[id]/route.js +7 -9
- package/dist/modules/attachments/api/file/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js +7 -9
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +17 -21
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentContentPreview.js +35 -6
- package/dist/modules/attachments/components/AttachmentContentPreview.js.map +2 -2
- package/dist/modules/audit_logs/backend/audit-logs/page.js +24 -14
- package/dist/modules/audit_logs/backend/audit-logs/page.js.map +2 -2
- package/dist/modules/auth/api/users/route.js +2 -6
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/cli.js +2 -3
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/configs/lib/upgrade-actions.js +0 -22
- package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/roles/[id]/acl.js +0 -1
- package/dist/modules/customer_accounts/api/admin/roles/[id]/acl.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/roles/[id].js +3 -17
- package/dist/modules/customer_accounts/api/admin/roles/[id].js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js +1 -6
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/users-invite.js +1 -6
- package/dist/modules/customer_accounts/api/portal/users-invite.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerInvitationService.js +0 -1
- package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerRbacService.js +1 -6
- package/dist/modules/customer_accounts/services/customerRbacService.js.map +2 -2
- package/dist/modules/customer_accounts/widgets/injection-table.js +2 -0
- package/dist/modules/customer_accounts/widgets/injection-table.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +1 -7
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/ViewTabsRow.js +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/ViewTabsRow.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyDetailTabs.js +43 -37
- package/dist/modules/customers/components/detail/CompanyDetailTabs.js.map +2 -2
- package/dist/modules/customers/components/detail/DealDetailTabs.js +35 -23
- package/dist/modules/customers/components/detail/DealDetailTabs.js.map +2 -2
- package/dist/modules/customers/components/detail/DetailTabsLayout.js +21 -6
- package/dist/modules/customers/components/detail/DetailTabsLayout.js.map +2 -2
- package/dist/modules/customers/components/detail/MobilePersonDetail.js +32 -26
- package/dist/modules/customers/components/detail/MobilePersonDetail.js.map +2 -2
- package/dist/modules/customers/components/detail/PersonDetailTabs.js +39 -29
- package/dist/modules/customers/components/detail/PersonDetailTabs.js.map +2 -2
- package/dist/modules/dashboards/api/roles/widgets/route.js +3 -22
- package/dist/modules/dashboards/api/roles/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/api/users/widgets/route.js +3 -22
- package/dist/modules/dashboards/api/users/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/cli.js +3 -4
- package/dist/modules/dashboards/cli.js.map +2 -2
- package/dist/modules/dashboards/lib/widgetAssignmentScope.js +1 -9
- package/dist/modules/dashboards/lib/widgetAssignmentScope.js.map +2 -2
- package/dist/modules/dictionaries/commands/entries.js +14 -7
- package/dist/modules/dictionaries/commands/entries.js.map +2 -2
- package/dist/modules/dictionaries/commands/entry-operations.js +16 -7
- package/dist/modules/dictionaries/commands/entry-operations.js.map +2 -2
- package/dist/modules/dictionaries/commands/factory.js +3 -9
- package/dist/modules/dictionaries/commands/factory.js.map +2 -2
- package/dist/modules/dictionaries/fields/dictionary.js +41 -56
- package/dist/modules/dictionaries/fields/dictionary.js.map +2 -2
- package/dist/modules/directory/utils/organizationScope.js +3 -10
- package/dist/modules/directory/utils/organizationScope.js.map +2 -2
- package/dist/modules/entities/api/records.js +4 -5
- package/dist/modules/entities/api/records.js.map +2 -2
- package/dist/modules/entities/backend/entities/system/[entityId]/page.meta.js +0 -1
- package/dist/modules/entities/backend/entities/system/[entityId]/page.meta.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js +49 -49
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/page.meta.js +0 -1
- package/dist/modules/entities/backend/entities/user/[entityId]/page.meta.js.map +2 -2
- package/dist/modules/entities/cli.js +1 -2
- package/dist/modules/entities/cli.js.map +2 -2
- package/dist/modules/feature_toggles/api/check/boolean/route.js +14 -0
- package/dist/modules/feature_toggles/api/check/boolean/route.js.map +2 -2
- package/dist/modules/feature_toggles/defaults.json +0 -8
- package/dist/modules/integrations/backend/integrations/[id]/page.js +80 -9
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
- package/dist/modules/payment_gateways/data/entities.js +0 -45
- package/dist/modules/payment_gateways/data/entities.js.map +2 -2
- package/dist/modules/payment_gateways/lib/gateway-service.js +38 -173
- package/dist/modules/payment_gateways/lib/gateway-service.js.map +3 -3
- package/dist/modules/planner/backend/planner/availability-rulesets/[id]/page.js +14 -16
- package/dist/modules/planner/backend/planner/availability-rulesets/[id]/page.js.map +2 -2
- package/dist/modules/planner/components/AvailabilityRulesEditor.js +30 -18
- package/dist/modules/planner/components/AvailabilityRulesEditor.js.map +2 -2
- package/dist/modules/query_index/api/status.js +8 -2
- package/dist/modules/query_index/api/status.js.map +2 -2
- package/dist/modules/resources/backend/resources/resources/[id]/page.js +24 -24
- package/dist/modules/resources/backend/resources/resources/[id]/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/create/page.js +0 -6
- package/dist/modules/sales/backend/sales/channels/create/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/create/page.meta.js +0 -2
- package/dist/modules/sales/backend/sales/channels/create/page.meta.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.js +0 -6
- package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.meta.js +0 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.meta.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.js +0 -6
- package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.meta.js +0 -2
- package/dist/modules/sales/backend/sales/channels/page.meta.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +4 -6
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +0 -44
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/returns.js +27 -2
- package/dist/modules/sales/commands/returns.js.map +2 -2
- package/dist/modules/sales/components/documents/AddressesSection.js +2 -6
- package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
- package/dist/modules/sales/components/documents/ItemsSection.js +0 -1
- package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/LineItemDialog.js +0 -9
- package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentForm.js +3 -51
- package/dist/modules/sales/components/documents/SalesDocumentForm.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js +8 -10
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js +38 -59
- package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
- package/dist/modules/sales/lib/shipments/snapshots.js +1 -27
- package/dist/modules/sales/lib/shipments/snapshots.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js +25 -22
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +14 -12
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js +29 -10
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js.map +2 -2
- package/dist/modules/sync_excel/lib/adapters/customers.js +20 -19
- package/dist/modules/sync_excel/lib/adapters/customers.js.map +2 -2
- package/dist/modules/sync_excel/lib/parser.js +0 -185
- package/dist/modules/sync_excel/lib/parser.js.map +2 -2
- package/dist/modules/sync_excel/lib/upload-storage.js +1 -20
- package/dist/modules/sync_excel/lib/upload-storage.js.map +2 -2
- package/dist/modules/workflows/frontend/checkout-demo/page.js +8 -1
- package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +1 -1
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/find-definition.js +18 -2
- package/dist/modules/workflows/lib/find-definition.js.map +2 -2
- package/dist/modules/workflows/lib/signal-handler.js +3 -2
- package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
- package/dist/modules/workflows/lib/step-handler.js +4 -8
- package/dist/modules/workflows/lib/step-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-handler.js +3 -5
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/timer-handler.js +2 -1
- package/dist/modules/workflows/lib/timer-handler.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +5 -13
- package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/workflow-executor.js +11 -9
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/dist/modules/workflows/migrations/Migration20260715120000.js +68 -0
- package/dist/modules/workflows/migrations/Migration20260715120000.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260716120000.js +24 -0
- package/dist/modules/workflows/migrations/Migration20260716120000.js.map +7 -0
- package/dist/modules/workflows/workflows.js +2 -0
- package/dist/modules/workflows/workflows.js.map +2 -2
- package/generated/entities.ids.generated.ts +0 -1
- package/generated/entity-fields-registry.ts +0 -12
- package/package.json +8 -9
- package/src/modules/api_keys/api/keys/route.ts +13 -36
- package/src/modules/api_keys/cli.ts +3 -2
- package/src/modules/attachments/api/file/[id]/route.ts +7 -11
- package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +7 -11
- package/src/modules/attachments/api/route.ts +21 -26
- package/src/modules/attachments/components/AttachmentContentPreview.tsx +44 -9
- package/src/modules/audit_logs/backend/audit-logs/page.tsx +22 -12
- package/src/modules/auth/api/users/route.ts +2 -11
- package/src/modules/auth/cli.ts +2 -3
- package/src/modules/configs/i18n/de.json +1 -5
- package/src/modules/configs/i18n/en.json +1 -5
- package/src/modules/configs/i18n/es.json +1 -5
- package/src/modules/configs/i18n/pl.json +1 -5
- package/src/modules/configs/lib/upgrade-actions.ts +0 -24
- package/src/modules/customer_accounts/AGENTS.md +6 -8
- package/src/modules/customer_accounts/api/admin/roles/[id]/acl.ts +0 -1
- package/src/modules/customer_accounts/api/admin/roles/[id].ts +3 -17
- package/src/modules/customer_accounts/api/portal/users/[id]/roles.ts +1 -6
- package/src/modules/customer_accounts/api/portal/users-invite.ts +1 -6
- package/src/modules/customer_accounts/services/customerInvitationService.ts +0 -1
- package/src/modules/customer_accounts/services/customerRbacService.ts +2 -9
- package/src/modules/customer_accounts/widgets/injection-table.ts +2 -0
- package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +1 -11
- package/src/modules/customers/backend/customers/deals/pipeline/components/ViewTabsRow.tsx +2 -6
- package/src/modules/customers/components/detail/CompanyDetailTabs.tsx +55 -39
- package/src/modules/customers/components/detail/DealDetailTabs.tsx +49 -24
- package/src/modules/customers/components/detail/DetailTabsLayout.tsx +24 -13
- package/src/modules/customers/components/detail/MobilePersonDetail.tsx +31 -25
- package/src/modules/customers/components/detail/PersonDetailTabs.tsx +50 -29
- package/src/modules/dashboards/api/roles/widgets/route.ts +3 -22
- package/src/modules/dashboards/api/users/widgets/route.ts +3 -22
- package/src/modules/dashboards/cli.ts +9 -4
- package/src/modules/dashboards/lib/widgetAssignmentScope.ts +0 -18
- package/src/modules/dictionaries/commands/entries.ts +16 -7
- package/src/modules/dictionaries/commands/entry-operations.ts +18 -8
- package/src/modules/dictionaries/commands/factory.ts +2 -8
- package/src/modules/dictionaries/fields/dictionary.tsx +32 -55
- package/src/modules/dictionaries/i18n/de.json +0 -2
- package/src/modules/dictionaries/i18n/en.json +0 -2
- package/src/modules/dictionaries/i18n/es.json +0 -2
- package/src/modules/dictionaries/i18n/pl.json +0 -2
- package/src/modules/directory/utils/organizationScope.ts +2 -36
- package/src/modules/entities/api/records.ts +7 -5
- package/src/modules/entities/backend/entities/system/[entityId]/page.meta.ts +0 -1
- package/src/modules/entities/backend/entities/user/[entityId]/page.meta.ts +0 -1
- package/src/modules/entities/backend/entities/user/[entityId]/page.tsx +49 -51
- package/src/modules/entities/cli.ts +1 -2
- package/src/modules/entities/i18n/de.json +0 -34
- package/src/modules/entities/i18n/en.json +0 -34
- package/src/modules/entities/i18n/es.json +0 -34
- package/src/modules/entities/i18n/pl.json +0 -34
- package/src/modules/feature_toggles/api/check/boolean/route.ts +15 -0
- package/src/modules/feature_toggles/defaults.json +0 -8
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +59 -16
- package/src/modules/payment_gateways/data/entities.ts +0 -39
- package/src/modules/payment_gateways/lib/gateway-service.ts +40 -211
- package/src/modules/payment_gateways/migrations/.snapshot-open-mercato.json +0 -236
- package/src/modules/planner/backend/planner/availability-rulesets/[id]/page.tsx +20 -14
- package/src/modules/planner/components/AvailabilityRulesEditor.tsx +34 -16
- package/src/modules/query_index/api/status.ts +8 -2
- package/src/modules/resources/backend/resources/resources/[id]/page.tsx +37 -27
- package/src/modules/sales/backend/sales/channels/create/page.meta.ts +0 -3
- package/src/modules/sales/backend/sales/channels/create/page.tsx +0 -7
- package/src/modules/sales/backend/sales/channels/offers/page.meta.ts +0 -3
- package/src/modules/sales/backend/sales/channels/offers/page.tsx +0 -7
- package/src/modules/sales/backend/sales/channels/page.meta.ts +0 -4
- package/src/modules/sales/backend/sales/channels/page.tsx +0 -7
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +5 -7
- package/src/modules/sales/commands/documents.ts +0 -65
- package/src/modules/sales/commands/returns.ts +32 -2
- package/src/modules/sales/components/documents/AddressesSection.tsx +2 -6
- package/src/modules/sales/components/documents/ItemsSection.tsx +0 -5
- package/src/modules/sales/components/documents/LineItemDialog.tsx +0 -10
- package/src/modules/sales/components/documents/SalesDocumentForm.tsx +3 -53
- package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +8 -10
- package/src/modules/sales/components/documents/ShipmentDialog.tsx +40 -65
- package/src/modules/sales/i18n/de.json +0 -5
- package/src/modules/sales/i18n/en.json +0 -5
- package/src/modules/sales/i18n/es.json +0 -5
- package/src/modules/sales/i18n/pl.json +0 -5
- package/src/modules/sales/lib/shipments/snapshots.ts +0 -30
- package/src/modules/staff/backend/staff/team-members/[id]/page.tsx +34 -25
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +17 -11
- package/src/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.tsx +28 -11
- package/src/modules/sync_excel/lib/adapters/customers.ts +22 -20
- package/src/modules/sync_excel/lib/parser.ts +0 -245
- package/src/modules/sync_excel/lib/upload-storage.ts +1 -23
- package/src/modules/workflows/frontend/checkout-demo/page.tsx +12 -1
- package/src/modules/workflows/lib/activity-executor.ts +22 -2
- package/src/modules/workflows/lib/find-definition.ts +53 -1
- package/src/modules/workflows/lib/signal-handler.ts +5 -4
- package/src/modules/workflows/lib/step-handler.ts +4 -8
- package/src/modules/workflows/lib/task-handler.ts +2 -4
- package/src/modules/workflows/lib/timer-handler.ts +3 -2
- package/src/modules/workflows/lib/transition-handler.ts +5 -13
- package/src/modules/workflows/lib/workflow-executor.ts +11 -8
- package/src/modules/workflows/migrations/Migration20260715120000.ts +114 -0
- package/src/modules/workflows/migrations/Migration20260716120000.ts +57 -0
- package/src/modules/workflows/workflows.ts +2 -0
- package/dist/generated/entities/gateway_session_initialization/index.js +0 -23
- package/dist/generated/entities/gateway_session_initialization/index.js.map +0 -7
- package/dist/modules/attachments/lib/reconcileOrganization.js +0 -110
- package/dist/modules/attachments/lib/reconcileOrganization.js.map +0 -7
- package/dist/modules/attachments/lib/requestScope.js +0 -10
- package/dist/modules/attachments/lib/requestScope.js.map +0 -7
- package/dist/modules/auth/api/autologin.js +0 -85
- package/dist/modules/auth/api/autologin.js.map +0 -7
- package/dist/modules/auth/lib/autologin.js +0 -19
- package/dist/modules/auth/lib/autologin.js.map +0 -7
- package/dist/modules/customers/components/detail/useDealsAccess.js +0 -16
- package/dist/modules/customers/components/detail/useDealsAccess.js.map +0 -7
- package/dist/modules/payment_gateways/lib/session-idempotency.js +0 -104
- package/dist/modules/payment_gateways/lib/session-idempotency.js.map +0 -7
- package/dist/modules/payment_gateways/migrations/Migration20260709220938_payment_gateways.js +0 -11
- package/dist/modules/payment_gateways/migrations/Migration20260709220938_payment_gateways.js.map +0 -7
- package/dist/modules/sales/components/SalesChannelsDisabledNotice.js +0 -15
- package/dist/modules/sales/components/SalesChannelsDisabledNotice.js.map +0 -7
- package/dist/modules/sales/components/useSalesChannelsEnabled.js +0 -44
- package/dist/modules/sales/components/useSalesChannelsEnabled.js.map +0 -7
- package/dist/modules/sales/lib/salesChannelsToggle.js +0 -18
- package/dist/modules/sales/lib/salesChannelsToggle.js.map +0 -7
- package/dist/modules/sales/lib/salesChannelsToggleId.js +0 -5
- package/dist/modules/sales/lib/salesChannelsToggleId.js.map +0 -7
- package/generated/entities/gateway_session_initialization/index.ts +0 -10
- package/src/modules/attachments/lib/reconcileOrganization.ts +0 -188
- package/src/modules/attachments/lib/requestScope.ts +0 -27
- package/src/modules/auth/api/autologin.ts +0 -100
- package/src/modules/auth/lib/autologin.ts +0 -36
- package/src/modules/customers/components/detail/useDealsAccess.ts +0 -19
- package/src/modules/payment_gateways/lib/session-idempotency.ts +0 -142
- package/src/modules/payment_gateways/migrations/Migration20260709220938_payment_gateways.ts +0 -10
- package/src/modules/sales/components/SalesChannelsDisabledNotice.tsx +0 -21
- package/src/modules/sales/components/useSalesChannelsEnabled.ts +0 -59
- package/src/modules/sales/lib/salesChannelsToggle.ts +0 -26
- package/src/modules/sales/lib/salesChannelsToggleId.ts +0 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { TextDecoder } from 'util'
|
|
2
|
-
|
|
3
1
|
export type CsvPreviewRow = Record<string, string | null>
|
|
4
2
|
|
|
5
3
|
export type CsvPreview = {
|
|
@@ -18,36 +16,10 @@ export type CsvDocument = {
|
|
|
18
16
|
encoding: 'utf-8'
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
export type CsvStreamMetadata = {
|
|
22
|
-
headers: string[]
|
|
23
|
-
totalRows: number
|
|
24
|
-
delimiter: ',' | ';'
|
|
25
|
-
encoding: 'utf-8'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type CsvDocumentBatch = {
|
|
29
|
-
headers: string[]
|
|
30
|
-
rows: CsvPreviewRow[]
|
|
31
|
-
rowStart: number
|
|
32
|
-
nextOffset: number
|
|
33
|
-
delimiter: ',' | ';'
|
|
34
|
-
encoding: 'utf-8'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
19
|
type ParseCsvPreviewOptions = {
|
|
38
20
|
maxRows?: number
|
|
39
21
|
}
|
|
40
22
|
|
|
41
|
-
type ParseCsvBatchOptions = {
|
|
42
|
-
batchSize: number
|
|
43
|
-
startOffset?: number
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type CsvInputChunk = Buffer | Uint8Array | string
|
|
47
|
-
|
|
48
|
-
const CSV_DELIMITER_PROBE_ROWS = 5
|
|
49
|
-
const CSV_DELIMITER_PROBE_MAX_CHARS = 64 * 1024
|
|
50
|
-
|
|
51
23
|
function stripUtf8Bom(value: string): string {
|
|
52
24
|
return value.charCodeAt(0) === 0xfeff ? value.slice(1) : value
|
|
53
25
|
}
|
|
@@ -159,223 +131,6 @@ function rowsToObjects(headers: string[], rows: string[][], maxRows: number): Cs
|
|
|
159
131
|
})
|
|
160
132
|
}
|
|
161
133
|
|
|
162
|
-
async function createCsvRowStream(input: AsyncIterable<CsvInputChunk>): Promise<{
|
|
163
|
-
delimiter: ',' | ';'
|
|
164
|
-
rows: AsyncIterable<string[]>
|
|
165
|
-
}> {
|
|
166
|
-
const iterator = input[Symbol.asyncIterator]()
|
|
167
|
-
const decoder = new TextDecoder('utf-8')
|
|
168
|
-
const prefixTexts: string[] = []
|
|
169
|
-
let probeText = ''
|
|
170
|
-
|
|
171
|
-
while (probeText.length < CSV_DELIMITER_PROBE_MAX_CHARS) {
|
|
172
|
-
const next = await iterator.next()
|
|
173
|
-
if (next.done) break
|
|
174
|
-
|
|
175
|
-
const text = typeof next.value === 'string' ? next.value : decoder.decode(next.value, { stream: true })
|
|
176
|
-
prefixTexts.push(text)
|
|
177
|
-
probeText += text
|
|
178
|
-
|
|
179
|
-
if (parseCsvText(probeText, ',').length >= CSV_DELIMITER_PROBE_ROWS) {
|
|
180
|
-
break
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const delimiter = detectCsvDelimiter(probeText)
|
|
185
|
-
|
|
186
|
-
async function* decodedChunks(): AsyncIterable<string> {
|
|
187
|
-
for (const text of prefixTexts) {
|
|
188
|
-
yield text
|
|
189
|
-
}
|
|
190
|
-
while (true) {
|
|
191
|
-
const next = await iterator.next()
|
|
192
|
-
if (next.done) break
|
|
193
|
-
yield typeof next.value === 'string' ? next.value : decoder.decode(next.value, { stream: true })
|
|
194
|
-
}
|
|
195
|
-
const finalChunk = decoder.decode()
|
|
196
|
-
if (finalChunk.length > 0) {
|
|
197
|
-
yield finalChunk
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return {
|
|
202
|
-
delimiter,
|
|
203
|
-
rows: parseCsvRowsFromTextChunks(decodedChunks(), delimiter),
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
async function* parseCsvRowsFromTextChunks(
|
|
208
|
-
chunks: AsyncIterable<string>,
|
|
209
|
-
delimiter: ',' | ';',
|
|
210
|
-
): AsyncIterable<string[]> {
|
|
211
|
-
let currentRow: string[] = []
|
|
212
|
-
let currentValue = ''
|
|
213
|
-
let inQuotes = false
|
|
214
|
-
let isFirstChunk = true
|
|
215
|
-
let previousWasCarriageReturn = false
|
|
216
|
-
let pendingQuote = false
|
|
217
|
-
let pendingQuoteWasInQuotes = false
|
|
218
|
-
|
|
219
|
-
const completeRow = (): string[] | null => {
|
|
220
|
-
currentRow.push(currentValue)
|
|
221
|
-
const completedRow = currentRow
|
|
222
|
-
currentRow = []
|
|
223
|
-
currentValue = ''
|
|
224
|
-
return completedRow.some((value) => value.trim().length > 0) ? completedRow : null
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
for await (const chunk of chunks) {
|
|
228
|
-
const text = isFirstChunk ? stripUtf8Bom(chunk) : chunk
|
|
229
|
-
isFirstChunk = false
|
|
230
|
-
|
|
231
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
232
|
-
const character = text[index]
|
|
233
|
-
|
|
234
|
-
if (pendingQuote) {
|
|
235
|
-
pendingQuote = false
|
|
236
|
-
if (pendingQuoteWasInQuotes && character === '"') {
|
|
237
|
-
currentValue += '"'
|
|
238
|
-
continue
|
|
239
|
-
}
|
|
240
|
-
inQuotes = !pendingQuoteWasInQuotes
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (previousWasCarriageReturn) {
|
|
244
|
-
previousWasCarriageReturn = false
|
|
245
|
-
if (character === '\n') {
|
|
246
|
-
continue
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (character === '"') {
|
|
251
|
-
if (index + 1 >= text.length) {
|
|
252
|
-
pendingQuote = true
|
|
253
|
-
pendingQuoteWasInQuotes = inQuotes
|
|
254
|
-
continue
|
|
255
|
-
}
|
|
256
|
-
if (inQuotes && text[index + 1] === '"') {
|
|
257
|
-
currentValue += '"'
|
|
258
|
-
index += 1
|
|
259
|
-
continue
|
|
260
|
-
}
|
|
261
|
-
inQuotes = !inQuotes
|
|
262
|
-
continue
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (!inQuotes && character === delimiter) {
|
|
266
|
-
currentRow.push(currentValue)
|
|
267
|
-
currentValue = ''
|
|
268
|
-
continue
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
if (character === '\r') {
|
|
272
|
-
previousWasCarriageReturn = true
|
|
273
|
-
if (inQuotes) {
|
|
274
|
-
currentValue += '\n'
|
|
275
|
-
} else {
|
|
276
|
-
const row = completeRow()
|
|
277
|
-
if (row) yield row
|
|
278
|
-
}
|
|
279
|
-
continue
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (character === '\n') {
|
|
283
|
-
if (inQuotes) {
|
|
284
|
-
currentValue += '\n'
|
|
285
|
-
} else {
|
|
286
|
-
const row = completeRow()
|
|
287
|
-
if (row) yield row
|
|
288
|
-
}
|
|
289
|
-
continue
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
currentValue += character
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (currentValue.length > 0 || currentRow.length > 0) {
|
|
297
|
-
const row = completeRow()
|
|
298
|
-
if (row) yield row
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export async function parseCsvStreamMetadata(input: AsyncIterable<CsvInputChunk>): Promise<CsvStreamMetadata> {
|
|
303
|
-
const stream = await createCsvRowStream(input)
|
|
304
|
-
let headers: string[] = []
|
|
305
|
-
let hasHeaders = false
|
|
306
|
-
let totalRows = 0
|
|
307
|
-
|
|
308
|
-
for await (const row of stream.rows) {
|
|
309
|
-
if (!hasHeaders) {
|
|
310
|
-
headers = normalizeHeaders(row)
|
|
311
|
-
hasHeaders = true
|
|
312
|
-
continue
|
|
313
|
-
}
|
|
314
|
-
totalRows += 1
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return {
|
|
318
|
-
headers,
|
|
319
|
-
totalRows,
|
|
320
|
-
delimiter: stream.delimiter,
|
|
321
|
-
encoding: 'utf-8',
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export async function* parseCsvDocumentBatches(
|
|
326
|
-
input: AsyncIterable<CsvInputChunk>,
|
|
327
|
-
options: ParseCsvBatchOptions,
|
|
328
|
-
): AsyncIterable<CsvDocumentBatch> {
|
|
329
|
-
const stream = await createCsvRowStream(input)
|
|
330
|
-
const batchSize = Math.max(1, Math.floor(options.batchSize))
|
|
331
|
-
const startOffset = Math.max(0, Math.floor(options.startOffset ?? 0))
|
|
332
|
-
let headers: string[] | null = null
|
|
333
|
-
let rowOffset = 0
|
|
334
|
-
let batchRows: string[][] = []
|
|
335
|
-
let batchStart = startOffset
|
|
336
|
-
|
|
337
|
-
for await (const row of stream.rows) {
|
|
338
|
-
if (!headers) {
|
|
339
|
-
headers = normalizeHeaders(row)
|
|
340
|
-
continue
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (rowOffset < startOffset) {
|
|
344
|
-
rowOffset += 1
|
|
345
|
-
continue
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (batchRows.length === 0) {
|
|
349
|
-
batchStart = rowOffset
|
|
350
|
-
}
|
|
351
|
-
batchRows.push(row)
|
|
352
|
-
rowOffset += 1
|
|
353
|
-
|
|
354
|
-
if (batchRows.length >= batchSize) {
|
|
355
|
-
yield {
|
|
356
|
-
headers,
|
|
357
|
-
rows: rowsToObjects(headers, batchRows, batchRows.length),
|
|
358
|
-
rowStart: batchStart,
|
|
359
|
-
nextOffset: rowOffset,
|
|
360
|
-
delimiter: stream.delimiter,
|
|
361
|
-
encoding: 'utf-8',
|
|
362
|
-
}
|
|
363
|
-
batchRows = []
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (headers && batchRows.length > 0) {
|
|
368
|
-
yield {
|
|
369
|
-
headers,
|
|
370
|
-
rows: rowsToObjects(headers, batchRows, batchRows.length),
|
|
371
|
-
rowStart: batchStart,
|
|
372
|
-
nextOffset: rowOffset,
|
|
373
|
-
delimiter: stream.delimiter,
|
|
374
|
-
encoding: 'utf-8',
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
134
|
export function parseCsvPreview(buffer: Buffer, options: ParseCsvPreviewOptions = {}): CsvPreview {
|
|
380
135
|
const text = buffer.toString('utf-8')
|
|
381
136
|
const delimiter = detectCsvDelimiter(text)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Readable } from 'stream'
|
|
1
|
+
import { promises as fs } from 'fs'
|
|
3
2
|
import { randomUUID } from 'crypto'
|
|
4
3
|
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
5
4
|
import { Attachment, AttachmentPartition } from '../../attachments/data/entities'
|
|
@@ -80,24 +79,3 @@ export async function readSyncExcelUploadBuffer(
|
|
|
80
79
|
throw error
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
export async function createSyncExcelUploadReadStream(
|
|
85
|
-
attachment: Pick<Attachment, 'partitionCode' | 'storagePath' | 'storageDriver' | 'storageMetadata'>,
|
|
86
|
-
): Promise<Readable> {
|
|
87
|
-
const inlineCsvBase64 = attachment.storageMetadata?.inlineCsvBase64
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
const absolutePath = resolveAttachmentAbsolutePath(
|
|
91
|
-
attachment.partitionCode,
|
|
92
|
-
attachment.storagePath,
|
|
93
|
-
attachment.storageDriver,
|
|
94
|
-
)
|
|
95
|
-
await fs.access(absolutePath)
|
|
96
|
-
return createReadStream(absolutePath)
|
|
97
|
-
} catch (error) {
|
|
98
|
-
if (typeof inlineCsvBase64 === 'string' && inlineCsvBase64.length > 0) {
|
|
99
|
-
return Readable.from([Buffer.from(inlineCsvBase64, 'base64')])
|
|
100
|
-
}
|
|
101
|
-
throw error
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -389,9 +389,20 @@ export default function CheckoutDemoPage() {
|
|
|
389
389
|
currencyCode: selectedCurrency || 'USD', // Ensure currency is always set
|
|
390
390
|
kind: 'product' as const,
|
|
391
391
|
productId: item.id,
|
|
392
|
-
|
|
392
|
+
name: item.name,
|
|
393
393
|
unitPriceGross: item.price,
|
|
394
394
|
})),
|
|
395
|
+
// Fold the demo's shipping and tax into order-level adjustments so the
|
|
396
|
+
// created order's grand total matches the cart total shown to the user
|
|
397
|
+
// (line items alone only cover the product subtotal).
|
|
398
|
+
orderAdjustments: [
|
|
399
|
+
...(shipping > 0
|
|
400
|
+
? [{ kind: 'shipping' as const, label: 'Shipping', currencyCode: selectedCurrency || 'USD', amountGross: shipping }]
|
|
401
|
+
: []),
|
|
402
|
+
...(tax > 0
|
|
403
|
+
? [{ kind: 'tax' as const, label: 'Tax', currencyCode: selectedCurrency || 'USD', amountGross: tax }]
|
|
404
|
+
: []),
|
|
405
|
+
],
|
|
395
406
|
itemCount: demoCart.reduce((sum, item) => sum + item.quantity, 0),
|
|
396
407
|
subtotal: subtotal,
|
|
397
408
|
tax: tax,
|
|
@@ -929,8 +929,28 @@ export async function executeCallApi(
|
|
|
929
929
|
// 3. Import the one-time API key helper
|
|
930
930
|
const { withOnetimeApiKey } = await import('../../api_keys/services/apiKeyService')
|
|
931
931
|
|
|
932
|
-
// 4.
|
|
933
|
-
|
|
932
|
+
// 4. Create the one-time API key on an EntityManager that is fully detached
|
|
933
|
+
// from the surrounding request/transaction context.
|
|
934
|
+
//
|
|
935
|
+
// CALL_API runs inside `workflowExecutor.executeWorkflow()`, which wraps
|
|
936
|
+
// the whole execution in `em.transactional(...)`. The request EM is forked
|
|
937
|
+
// with `useContext: true`, so while that transaction is open, EVERY
|
|
938
|
+
// operation on the container's `em` — including this API key's
|
|
939
|
+
// persist/flush — is transparently redirected to the uncommitted
|
|
940
|
+
// transaction fork (MikroORM `getContext()` → `TransactionContext`). The
|
|
941
|
+
// key would therefore stay invisible until the transaction commits, but
|
|
942
|
+
// the commit cannot happen until this activity returns. The outbound
|
|
943
|
+
// self-authenticated `fetch` below opens a SEPARATE DB connection that
|
|
944
|
+
// cannot see the uncommitted row, so the internal API responds `401` and
|
|
945
|
+
// the activity fails (issue #4202).
|
|
946
|
+
//
|
|
947
|
+
// Forking with `useContext: false` (matching the query_index/webhooks
|
|
948
|
+
// isolated-EM convention) gives the key its own pooled connection with
|
|
949
|
+
// autocommit, so it is committed and visible to the internal request
|
|
950
|
+
// immediately.
|
|
951
|
+
const apiKeyEm = container
|
|
952
|
+
.resolve<PostgreSqlEntityManager>('em')
|
|
953
|
+
.fork({ clear: true, freshEventManager: true, useContext: false }) as PostgreSqlEntityManager
|
|
934
954
|
|
|
935
955
|
// 5. Resolve the roles that the one-time API key will inherit.
|
|
936
956
|
//
|
|
@@ -80,9 +80,17 @@ export async function findWorkflowDefinition(
|
|
|
80
80
|
// so disabled code workflows aren't silently executable.
|
|
81
81
|
if (version === undefined && !codeDef.enabled) return null
|
|
82
82
|
|
|
83
|
+
return buildVirtualCodeDefinition(codeDef, tenantId, organizationId)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function buildVirtualCodeDefinition(
|
|
87
|
+
codeDef: NonNullable<ReturnType<typeof getCodeWorkflow>>,
|
|
88
|
+
tenantId: string,
|
|
89
|
+
organizationId: string,
|
|
90
|
+
): WorkflowDefinition {
|
|
83
91
|
// Construct a virtual WorkflowDefinition object (not persisted)
|
|
84
92
|
const virtual = new WorkflowDefinition()
|
|
85
|
-
virtual.id = codeWorkflowUuid(workflowId)
|
|
93
|
+
virtual.id = codeWorkflowUuid(codeDef.workflowId)
|
|
86
94
|
virtual.workflowId = codeDef.workflowId
|
|
87
95
|
virtual.workflowName = codeDef.workflowName
|
|
88
96
|
virtual.description = codeDef.description ?? null
|
|
@@ -98,3 +106,47 @@ export async function findWorkflowDefinition(
|
|
|
98
106
|
|
|
99
107
|
return virtual
|
|
100
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Resolve a virtual code definition for an already-started instance whose
|
|
112
|
+
* `definitionId` does not exist in the database.
|
|
113
|
+
*
|
|
114
|
+
* Instances started from a virtual code definition persist the deterministic
|
|
115
|
+
* `codeWorkflowUuid(workflowId)` as their `definitionId`. Runtime handlers
|
|
116
|
+
* (step/transition/signal/timer/task) load definitions by that id, so without
|
|
117
|
+
* this fallback an unpersisted code workflow starts but can never advance.
|
|
118
|
+
*
|
|
119
|
+
* The UUID equality gate ensures the fallback never substitutes the code
|
|
120
|
+
* definition for a hard-deleted persisted row: those rows have their own
|
|
121
|
+
* random UUIDs that can never match the deterministic code UUID.
|
|
122
|
+
*/
|
|
123
|
+
export function resolveCodeDefinitionForInstance(instance: {
|
|
124
|
+
definitionId: string
|
|
125
|
+
workflowId: string
|
|
126
|
+
tenantId: string
|
|
127
|
+
organizationId: string
|
|
128
|
+
}): WorkflowDefinition | null {
|
|
129
|
+
const codeDef = getCodeWorkflow(instance.workflowId)
|
|
130
|
+
if (!codeDef) return null
|
|
131
|
+
if (codeWorkflowUuid(instance.workflowId) !== instance.definitionId) return null
|
|
132
|
+
return buildVirtualCodeDefinition(codeDef, instance.tenantId, instance.organizationId)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Find the definition backing a workflow instance: database row by id first,
|
|
137
|
+
* falling back to the in-memory code registry for instances started from an
|
|
138
|
+
* unpersisted code definition.
|
|
139
|
+
*/
|
|
140
|
+
export async function findDefinitionForInstance(
|
|
141
|
+
em: EntityManager,
|
|
142
|
+
instance: {
|
|
143
|
+
definitionId: string
|
|
144
|
+
workflowId: string
|
|
145
|
+
tenantId: string
|
|
146
|
+
organizationId: string
|
|
147
|
+
},
|
|
148
|
+
): Promise<WorkflowDefinition | null> {
|
|
149
|
+
const dbDef = await em.findOne(WorkflowDefinition, { id: instance.definitionId })
|
|
150
|
+
if (dbDef) return dbDef
|
|
151
|
+
return resolveCodeDefinitionForInstance(instance)
|
|
152
|
+
}
|
|
@@ -13,6 +13,7 @@ import type * as eventLoggerModule from './event-logger'
|
|
|
13
13
|
import type * as stepHandlerModule from './step-handler'
|
|
14
14
|
import type * as transitionHandlerModule from './transition-handler'
|
|
15
15
|
import type * as workflowExecutorModule from './workflow-executor'
|
|
16
|
+
import { resolveCodeDefinitionForInstance } from './find-definition'
|
|
16
17
|
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
17
18
|
|
|
18
19
|
const logger = createLogger('workflows')
|
|
@@ -95,13 +96,13 @@ export async function sendSignal(
|
|
|
95
96
|
// Branch-scoped signal: a FORKED instance routes the signal to the branch
|
|
96
97
|
// paused at a matching WAIT_FOR_SIGNAL step.
|
|
97
98
|
if (instance.status === 'FORKED') {
|
|
98
|
-
const branchDefinition = await findOneWithDecryption(
|
|
99
|
+
const branchDefinition = (await findOneWithDecryption(
|
|
99
100
|
em as PostgreSqlEntityManager,
|
|
100
101
|
WorkflowDefinition,
|
|
101
102
|
{ id: instance.definitionId, tenantId: instance.tenantId, organizationId: instance.organizationId, deletedAt: null },
|
|
102
103
|
undefined,
|
|
103
104
|
{ tenantId: instance.tenantId, organizationId: instance.organizationId },
|
|
104
|
-
)
|
|
105
|
+
)) ?? resolveCodeDefinitionForInstance(instance)
|
|
105
106
|
if (!branchDefinition) {
|
|
106
107
|
throw new SignalError('Workflow definition not found', 'DEFINITION_NOT_FOUND', { definitionId: instance.definitionId })
|
|
107
108
|
}
|
|
@@ -173,7 +174,7 @@ export async function sendSignal(
|
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
// Load workflow definition with tenant/org scope to check current step
|
|
176
|
-
const definition = await findOneWithDecryption(
|
|
177
|
+
const definition = (await findOneWithDecryption(
|
|
177
178
|
em as PostgreSqlEntityManager,
|
|
178
179
|
WorkflowDefinition,
|
|
179
180
|
{
|
|
@@ -184,7 +185,7 @@ export async function sendSignal(
|
|
|
184
185
|
},
|
|
185
186
|
undefined,
|
|
186
187
|
{ tenantId: instance.tenantId, organizationId: instance.organizationId },
|
|
187
|
-
)
|
|
188
|
+
)) ?? resolveCodeDefinitionForInstance(instance)
|
|
188
189
|
if (!definition) {
|
|
189
190
|
throw new SignalError(
|
|
190
191
|
'Workflow definition not found',
|
|
@@ -13,7 +13,6 @@ import { EntityManager } from '@mikro-orm/core'
|
|
|
13
13
|
import {
|
|
14
14
|
WorkflowInstance,
|
|
15
15
|
WorkflowBranchInstance,
|
|
16
|
-
WorkflowDefinition,
|
|
17
16
|
StepInstance,
|
|
18
17
|
UserTask,
|
|
19
18
|
WorkflowEvent,
|
|
@@ -22,6 +21,7 @@ import {
|
|
|
22
21
|
} from '../data/entities'
|
|
23
22
|
import { parseDuration } from './duration'
|
|
24
23
|
import { logWorkflowEvent } from './event-logger'
|
|
24
|
+
import { findDefinitionForInstance } from './find-definition'
|
|
25
25
|
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
26
26
|
|
|
27
27
|
const logger = createLogger('workflows')
|
|
@@ -76,9 +76,7 @@ export async function enterStep(
|
|
|
76
76
|
branch?: WorkflowBranchInstance | null
|
|
77
77
|
): Promise<StepInstance> {
|
|
78
78
|
// Load workflow definition to get step details
|
|
79
|
-
const definition = await em
|
|
80
|
-
id: instance.definitionId,
|
|
81
|
-
})
|
|
79
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
82
80
|
|
|
83
81
|
if (!definition) {
|
|
84
82
|
throw new StepExecutionError(
|
|
@@ -213,9 +211,7 @@ export async function executeStep(
|
|
|
213
211
|
const stepInstance = await enterStep(em, instance, stepId, context, branch)
|
|
214
212
|
|
|
215
213
|
// Load workflow definition to get step configuration
|
|
216
|
-
const definition = await em
|
|
217
|
-
id: instance.definitionId,
|
|
218
|
-
})
|
|
214
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
219
215
|
|
|
220
216
|
if (!definition) {
|
|
221
217
|
throw new StepExecutionError(
|
|
@@ -359,7 +355,7 @@ async function executeStepByType(
|
|
|
359
355
|
{ stepType, stepId: stepDef.stepId }
|
|
360
356
|
)
|
|
361
357
|
}
|
|
362
|
-
const definition = await em
|
|
358
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
363
359
|
if (!definition) {
|
|
364
360
|
throw new StepExecutionError(
|
|
365
361
|
`Workflow definition not found: ${instance.definitionId}`,
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
WorkflowInstance,
|
|
18
18
|
WorkflowEvent,
|
|
19
19
|
StepInstance,
|
|
20
|
-
WorkflowDefinition,
|
|
21
20
|
} from '../data/entities'
|
|
22
21
|
import { executeWorkflow } from './workflow-executor'
|
|
22
|
+
import { findDefinitionForInstance } from './find-definition'
|
|
23
23
|
import * as stepHandler from './step-handler'
|
|
24
24
|
import * as transitionHandler from './transition-handler'
|
|
25
25
|
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
@@ -191,9 +191,7 @@ export async function completeUserTask(
|
|
|
191
191
|
const currentStepId = instance.currentStepId
|
|
192
192
|
|
|
193
193
|
// Load workflow definition to find transitions
|
|
194
|
-
const definition = await em
|
|
195
|
-
id: instance.definitionId,
|
|
196
|
-
})
|
|
194
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
197
195
|
|
|
198
196
|
if (!definition) {
|
|
199
197
|
throw new UserTaskError(
|
|
@@ -14,6 +14,7 @@ import type * as eventLoggerModule from './event-logger'
|
|
|
14
14
|
import type * as stepHandlerModule from './step-handler'
|
|
15
15
|
import type * as transitionHandlerModule from './transition-handler'
|
|
16
16
|
import type * as workflowExecutorModule from './workflow-executor'
|
|
17
|
+
import { resolveCodeDefinitionForInstance } from './find-definition'
|
|
17
18
|
|
|
18
19
|
export interface FireTimerOptions {
|
|
19
20
|
instanceId: string
|
|
@@ -110,7 +111,7 @@ export async function fireTimer(
|
|
|
110
111
|
)
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
const definition = await findOneWithDecryption(
|
|
114
|
+
const definition = (await findOneWithDecryption(
|
|
114
115
|
em as PostgreSqlEntityManager,
|
|
115
116
|
WorkflowDefinition,
|
|
116
117
|
{
|
|
@@ -121,7 +122,7 @@ export async function fireTimer(
|
|
|
121
122
|
},
|
|
122
123
|
undefined,
|
|
123
124
|
{ tenantId: instance.tenantId, organizationId: instance.organizationId },
|
|
124
|
-
)
|
|
125
|
+
)) ?? resolveCodeDefinitionForInstance(instance)
|
|
125
126
|
if (!definition) {
|
|
126
127
|
throw new TimerError(
|
|
127
128
|
'Workflow definition not found',
|
|
@@ -15,7 +15,6 @@ import type { AwilixContainer } from 'awilix'
|
|
|
15
15
|
import type { EventBus } from '@open-mercato/events'
|
|
16
16
|
import {
|
|
17
17
|
WorkflowInstance,
|
|
18
|
-
WorkflowDefinition,
|
|
19
18
|
WorkflowEvent,
|
|
20
19
|
} from '../data/entities'
|
|
21
20
|
import * as ruleEvaluator from '../../business_rules/lib/rule-evaluator'
|
|
@@ -23,6 +22,7 @@ import * as ruleEngine from '../../business_rules/lib/rule-engine'
|
|
|
23
22
|
import * as activityExecutor from './activity-executor'
|
|
24
23
|
import type { ActivityDefinition } from './activity-executor'
|
|
25
24
|
import * as stepHandler from './step-handler'
|
|
25
|
+
import { findDefinitionForInstance } from './find-definition'
|
|
26
26
|
import {
|
|
27
27
|
type ExecutionToken,
|
|
28
28
|
rootToken,
|
|
@@ -116,9 +116,7 @@ export async function evaluateTransition(
|
|
|
116
116
|
|
|
117
117
|
try {
|
|
118
118
|
// Load workflow definition
|
|
119
|
-
const definition = await em
|
|
120
|
-
id: instance.definitionId,
|
|
121
|
-
})
|
|
119
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
122
120
|
|
|
123
121
|
if (!definition) {
|
|
124
122
|
return {
|
|
@@ -227,9 +225,7 @@ export async function findValidTransitions(
|
|
|
227
225
|
): Promise<TransitionEvaluationResult[]> {
|
|
228
226
|
try {
|
|
229
227
|
// Load workflow definition
|
|
230
|
-
const definition = await em
|
|
231
|
-
id: instance.definitionId,
|
|
232
|
-
})
|
|
228
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
233
229
|
|
|
234
230
|
if (!definition) {
|
|
235
231
|
return []
|
|
@@ -752,9 +748,7 @@ async function evaluatePreConditions(
|
|
|
752
748
|
): Promise<ruleEngine.RuleEngineResult> {
|
|
753
749
|
try {
|
|
754
750
|
// Load workflow definition to get workflow ID
|
|
755
|
-
const definition = await em
|
|
756
|
-
id: instance.definitionId,
|
|
757
|
-
})
|
|
751
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
758
752
|
|
|
759
753
|
if (!definition) {
|
|
760
754
|
return {
|
|
@@ -881,9 +875,7 @@ async function evaluatePostConditions(
|
|
|
881
875
|
): Promise<ruleEngine.RuleEngineResult> {
|
|
882
876
|
try {
|
|
883
877
|
// Load workflow definition to get workflow ID
|
|
884
|
-
const definition = await em
|
|
885
|
-
id: instance.definitionId,
|
|
886
|
-
})
|
|
878
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
887
879
|
|
|
888
880
|
if (!definition) {
|
|
889
881
|
return {
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
type WorkflowInstanceStatus,
|
|
20
20
|
} from '../data/entities'
|
|
21
21
|
import { compensateWorkflow } from './compensation-handler'
|
|
22
|
-
import { findWorkflowDefinition } from './find-definition'
|
|
22
|
+
import { findWorkflowDefinition, findDefinitionForInstance } from './find-definition'
|
|
23
23
|
import { createLogger } from '@open-mercato/shared/lib/logger'
|
|
24
24
|
|
|
25
25
|
const logger = createLogger('workflows')
|
|
@@ -278,9 +278,7 @@ export async function executeWorkflow(
|
|
|
278
278
|
)
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
const definition = await trx
|
|
282
|
-
id: instance.definitionId,
|
|
283
|
-
})
|
|
281
|
+
const definition = await findDefinitionForInstance(trx, instance)
|
|
284
282
|
|
|
285
283
|
if (!definition) {
|
|
286
284
|
throw new WorkflowExecutionError(
|
|
@@ -614,7 +612,7 @@ export async function completeWorkflow(
|
|
|
614
612
|
|
|
615
613
|
// Trigger compensation if workflow failed and has compensatable activities (Phase 8.2)
|
|
616
614
|
if (status === 'FAILED') {
|
|
617
|
-
const definition = await em
|
|
615
|
+
const definition = await findDefinitionForInstance(em, instance)
|
|
618
616
|
|
|
619
617
|
if (definition && checkIfCompensationNeeded(definition)) {
|
|
620
618
|
try {
|
|
@@ -836,9 +834,14 @@ export async function resumeWorkflowAfterActivities(
|
|
|
836
834
|
fromStepId: instance.currentStepId,
|
|
837
835
|
})
|
|
838
836
|
|
|
839
|
-
const definition = await trx
|
|
840
|
-
|
|
841
|
-
|
|
837
|
+
const definition = await findDefinitionForInstance(trx, instance)
|
|
838
|
+
if (!definition) {
|
|
839
|
+
throw new WorkflowExecutionError(
|
|
840
|
+
`Workflow definition not found: ${instance.definitionId}`,
|
|
841
|
+
'DEFINITION_NOT_FOUND',
|
|
842
|
+
{ definitionId: instance.definitionId }
|
|
843
|
+
)
|
|
844
|
+
}
|
|
842
845
|
|
|
843
846
|
const step = definition.definition.steps.find(s => s.stepId === pendingTransition.toStepId)
|
|
844
847
|
|