@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,142 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from 'node:crypto'
|
|
2
|
-
import { UniqueConstraintViolationException } from '@mikro-orm/core'
|
|
3
|
-
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
4
|
-
import { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'
|
|
5
|
-
import { GatewaySessionInitialization } from '../data/entities'
|
|
6
|
-
|
|
7
|
-
type Scope = { organizationId: string; tenantId: string }
|
|
8
|
-
|
|
9
|
-
export type OwnedPaymentSessionInitialization = {
|
|
10
|
-
id: string
|
|
11
|
-
claimToken: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function buildPaymentSessionOperationKey(input: {
|
|
15
|
-
idempotencyKey: string
|
|
16
|
-
paymentId: string
|
|
17
|
-
providerKey: string
|
|
18
|
-
scope: Scope
|
|
19
|
-
}): string {
|
|
20
|
-
const digest = createHash('sha256')
|
|
21
|
-
.update(JSON.stringify([
|
|
22
|
-
input.scope.tenantId,
|
|
23
|
-
input.scope.organizationId,
|
|
24
|
-
input.providerKey,
|
|
25
|
-
input.paymentId,
|
|
26
|
-
input.idempotencyKey,
|
|
27
|
-
]))
|
|
28
|
-
.digest('hex')
|
|
29
|
-
return `om-payment-session:${digest}`
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function findPaymentSessionInitialization(
|
|
33
|
-
em: EntityManager,
|
|
34
|
-
operationKey: string,
|
|
35
|
-
providerKey: string,
|
|
36
|
-
scope: Scope,
|
|
37
|
-
): Promise<GatewaySessionInitialization | null> {
|
|
38
|
-
return findOneWithDecryption(
|
|
39
|
-
em.fork(),
|
|
40
|
-
GatewaySessionInitialization,
|
|
41
|
-
{
|
|
42
|
-
operationKey,
|
|
43
|
-
providerKey,
|
|
44
|
-
organizationId: scope.organizationId,
|
|
45
|
-
tenantId: scope.tenantId,
|
|
46
|
-
},
|
|
47
|
-
undefined,
|
|
48
|
-
scope,
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export async function claimPaymentSessionInitialization(
|
|
53
|
-
em: EntityManager,
|
|
54
|
-
operationKey: string,
|
|
55
|
-
providerKey: string,
|
|
56
|
-
scope: Scope,
|
|
57
|
-
claimedAt: Date,
|
|
58
|
-
): Promise<OwnedPaymentSessionInitialization | null> {
|
|
59
|
-
const claimEm = em.fork()
|
|
60
|
-
const claimToken = randomUUID()
|
|
61
|
-
const record = claimEm.create(GatewaySessionInitialization, {
|
|
62
|
-
operationKey,
|
|
63
|
-
providerKey,
|
|
64
|
-
claimToken,
|
|
65
|
-
claimedAt,
|
|
66
|
-
gatewayTransactionId: null,
|
|
67
|
-
organizationId: scope.organizationId,
|
|
68
|
-
tenantId: scope.tenantId,
|
|
69
|
-
})
|
|
70
|
-
try {
|
|
71
|
-
await claimEm.persist(record).flush()
|
|
72
|
-
return { id: record.id, claimToken }
|
|
73
|
-
} catch (error: unknown) {
|
|
74
|
-
if (error instanceof UniqueConstraintViolationException) return null
|
|
75
|
-
throw error
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function reclaimPaymentSessionInitialization(
|
|
80
|
-
em: EntityManager,
|
|
81
|
-
claim: GatewaySessionInitialization,
|
|
82
|
-
scope: Scope,
|
|
83
|
-
claimedAt: Date,
|
|
84
|
-
staleBefore: Date,
|
|
85
|
-
): Promise<OwnedPaymentSessionInitialization | null> {
|
|
86
|
-
const claimToken = randomUUID()
|
|
87
|
-
const claimedRows = await em.fork().nativeUpdate(
|
|
88
|
-
GatewaySessionInitialization,
|
|
89
|
-
{
|
|
90
|
-
id: claim.id,
|
|
91
|
-
operationKey: claim.operationKey,
|
|
92
|
-
providerKey: claim.providerKey,
|
|
93
|
-
organizationId: scope.organizationId,
|
|
94
|
-
tenantId: scope.tenantId,
|
|
95
|
-
gatewayTransactionId: null,
|
|
96
|
-
$or: [
|
|
97
|
-
{ claimToken: null },
|
|
98
|
-
{ claimedAt: { $lt: staleBefore } },
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
{ claimToken, claimedAt, updatedAt: claimedAt },
|
|
102
|
-
)
|
|
103
|
-
return claimedRows > 0 ? { id: claim.id, claimToken } : null
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export async function releasePaymentSessionInitialization(
|
|
107
|
-
em: EntityManager,
|
|
108
|
-
ownership: OwnedPaymentSessionInitialization,
|
|
109
|
-
scope: Scope,
|
|
110
|
-
): Promise<void> {
|
|
111
|
-
await em.fork().nativeUpdate(
|
|
112
|
-
GatewaySessionInitialization,
|
|
113
|
-
{
|
|
114
|
-
id: ownership.id,
|
|
115
|
-
claimToken: ownership.claimToken,
|
|
116
|
-
organizationId: scope.organizationId,
|
|
117
|
-
tenantId: scope.tenantId,
|
|
118
|
-
gatewayTransactionId: null,
|
|
119
|
-
},
|
|
120
|
-
{ claimToken: null, claimedAt: null, updatedAt: new Date() },
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export async function refreshPaymentSessionInitialization(
|
|
125
|
-
em: EntityManager,
|
|
126
|
-
ownership: OwnedPaymentSessionInitialization,
|
|
127
|
-
scope: Scope,
|
|
128
|
-
claimedAt: Date,
|
|
129
|
-
): Promise<boolean> {
|
|
130
|
-
const refreshedRows = await em.fork().nativeUpdate(
|
|
131
|
-
GatewaySessionInitialization,
|
|
132
|
-
{
|
|
133
|
-
id: ownership.id,
|
|
134
|
-
claimToken: ownership.claimToken,
|
|
135
|
-
organizationId: scope.organizationId,
|
|
136
|
-
tenantId: scope.tenantId,
|
|
137
|
-
gatewayTransactionId: null,
|
|
138
|
-
},
|
|
139
|
-
{ claimedAt, updatedAt: claimedAt },
|
|
140
|
-
)
|
|
141
|
-
return refreshedRows > 0
|
|
142
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
-
|
|
3
|
-
export class Migration20260709220938_payment_gateways extends Migration {
|
|
4
|
-
|
|
5
|
-
override up(): void | Promise<void> {
|
|
6
|
-
this.addSql(`create table "gateway_session_initializations" ("id" uuid not null default gen_random_uuid(), "operation_key" text not null, "provider_key" text not null, "claim_token" uuid null, "claimed_at" timestamptz null, "gateway_transaction_id" uuid null, "organization_id" uuid not null, "tenant_id" uuid not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, primary key ("id"));`);
|
|
7
|
-
this.addSql(`alter table "gateway_session_initializations" add constraint "gateway_session_initializations_scope_operation_unique" unique ("operation_key", "provider_key", "organization_id", "tenant_id");`);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { Page, PageBody } from '@open-mercato/ui/backend/Page'
|
|
5
|
-
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
|
-
|
|
7
|
-
export function SalesChannelsDisabledNotice() {
|
|
8
|
-
const t = useT()
|
|
9
|
-
return (
|
|
10
|
-
<Page>
|
|
11
|
-
<PageBody>
|
|
12
|
-
<div className="rounded-lg border bg-muted/50 p-6 text-sm text-muted-foreground">
|
|
13
|
-
{t(
|
|
14
|
-
'sales.channels.disabledNotice',
|
|
15
|
-
'Sales channels are disabled for this tenant. Enable the "Sales Channels" feature toggle to manage them.',
|
|
16
|
-
)}
|
|
17
|
-
</div>
|
|
18
|
-
</PageBody>
|
|
19
|
-
</Page>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
5
|
-
import { SALES_CHANNELS_TOGGLE_ID } from '../lib/salesChannelsToggleId'
|
|
6
|
-
|
|
7
|
-
export { SALES_CHANNELS_TOGGLE_ID }
|
|
8
|
-
|
|
9
|
-
const CACHE_TTL_MS = 60_000
|
|
10
|
-
|
|
11
|
-
type FeatureToggleCheckResponse = {
|
|
12
|
-
ok?: boolean
|
|
13
|
-
value?: unknown
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Fails open: channels stay visible unless the toggle explicitly resolves to
|
|
17
|
-
// false. A missing toggle definition (404) or an absent feature_toggles module
|
|
18
|
-
// must not hide sales channel UI.
|
|
19
|
-
async function fetchSalesChannelsEnabled(): Promise<boolean> {
|
|
20
|
-
try {
|
|
21
|
-
const call = await apiCall<FeatureToggleCheckResponse>(
|
|
22
|
-
`/api/feature_toggles/check/boolean?identifier=${SALES_CHANNELS_TOGGLE_ID}`,
|
|
23
|
-
)
|
|
24
|
-
if (!call.ok) return true
|
|
25
|
-
return !(call.result?.ok === true && call.result.value === false)
|
|
26
|
-
} catch {
|
|
27
|
-
return true
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let cache: { value: Promise<boolean>; at: number } | null = null
|
|
32
|
-
|
|
33
|
-
function getSalesChannelsEnabled(): Promise<boolean> {
|
|
34
|
-
const now = Date.now()
|
|
35
|
-
if (!cache || now - cache.at > CACHE_TTL_MS) {
|
|
36
|
-
cache = { value: fetchSalesChannelsEnabled(), at: now }
|
|
37
|
-
}
|
|
38
|
-
return cache.value
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function useSalesChannelsEnabled(): { enabled: boolean; isLoading: boolean } {
|
|
42
|
-
const [resolved, setResolved] = React.useState<boolean | null>(null)
|
|
43
|
-
|
|
44
|
-
React.useEffect(() => {
|
|
45
|
-
let active = true
|
|
46
|
-
getSalesChannelsEnabled()
|
|
47
|
-
.then((value) => {
|
|
48
|
-
if (active) setResolved(value)
|
|
49
|
-
})
|
|
50
|
-
.catch(() => {
|
|
51
|
-
if (active) setResolved(true)
|
|
52
|
-
})
|
|
53
|
-
return () => {
|
|
54
|
-
active = false
|
|
55
|
-
}
|
|
56
|
-
}, [])
|
|
57
|
-
|
|
58
|
-
return { enabled: resolved !== false, isLoading: resolved === null }
|
|
59
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SALES_CHANNELS_TOGGLE_ID } from './salesChannelsToggleId'
|
|
2
|
-
|
|
3
|
-
export { SALES_CHANNELS_TOGGLE_ID }
|
|
4
|
-
|
|
5
|
-
type BoolConfigResult = { ok: boolean; value?: unknown }
|
|
6
|
-
|
|
7
|
-
type FeatureTogglesServiceLike = {
|
|
8
|
-
getBoolConfig: (identifier: string, tenantId: string) => Promise<BoolConfigResult>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Server-side counterpart of useSalesChannelsEnabled with the same fail-open
|
|
12
|
-
// contract: channels stay enabled unless the toggle explicitly resolves to
|
|
13
|
-
// false. The DI container and feature_toggles service are optional peers, so
|
|
14
|
-
// they are loaded lazily and any failure keeps channels visible.
|
|
15
|
-
export async function isSalesChannelsEnabledForTenant(tenantId: string | null | undefined): Promise<boolean> {
|
|
16
|
-
if (!tenantId) return true
|
|
17
|
-
try {
|
|
18
|
-
const { createRequestContainer } = await import('@open-mercato/shared/lib/di/container')
|
|
19
|
-
const container = await createRequestContainer()
|
|
20
|
-
const service = container.resolve('featureTogglesService') as FeatureTogglesServiceLike
|
|
21
|
-
const result = await service.getBoolConfig(SALES_CHANNELS_TOGGLE_ID, tenantId)
|
|
22
|
-
return !(result.ok === true && result.value === false)
|
|
23
|
-
} catch {
|
|
24
|
-
return true
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SALES_CHANNELS_TOGGLE_ID = 'sales_channels_enabled'
|