@open-mercato/core 0.4.7-develop-78d7541539 → 0.4.7-develop-74069040de
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/AGENTS.md +1 -0
- package/dist/modules/catalog/api/bulk-delete/route.js +86 -0
- package/dist/modules/catalog/api/bulk-delete/route.js.map +7 -0
- package/dist/modules/catalog/api/prices/route.js +39 -6
- package/dist/modules/catalog/api/prices/route.js.map +2 -2
- package/dist/modules/catalog/api/products/route.js +6 -11
- package/dist/modules/catalog/api/products/route.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +2 -0
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductsDataTable.js +9 -1
- package/dist/modules/catalog/components/products/ProductsDataTable.js.map +2 -2
- package/dist/modules/catalog/lib/bulkDelete.js +70 -0
- package/dist/modules/catalog/lib/bulkDelete.js.map +7 -0
- package/dist/modules/catalog/widgets/injection/product-bulk-delete/widget.js +185 -0
- package/dist/modules/catalog/widgets/injection/product-bulk-delete/widget.js.map +7 -0
- package/dist/modules/catalog/widgets/injection-table.js +9 -1
- package/dist/modules/catalog/widgets/injection-table.js.map +2 -2
- package/dist/modules/catalog/workers/catalog-product-bulk-delete.js +40 -0
- package/dist/modules/catalog/workers/catalog-product-bulk-delete.js.map +7 -0
- package/dist/modules/data_sync/api/options.js +52 -0
- package/dist/modules/data_sync/api/options.js.map +7 -0
- package/dist/modules/data_sync/api/run.js +30 -35
- package/dist/modules/data_sync/api/run.js.map +2 -2
- package/dist/modules/data_sync/api/runs/[id]/cancel.js +2 -2
- package/dist/modules/data_sync/api/runs/[id]/cancel.js.map +2 -2
- package/dist/modules/data_sync/api/runs/[id]/retry.js +15 -30
- package/dist/modules/data_sync/api/runs/[id]/retry.js.map +2 -2
- package/dist/modules/data_sync/api/schedules/[id]/route.js +109 -0
- package/dist/modules/data_sync/api/schedules/[id]/route.js.map +7 -0
- package/dist/modules/data_sync/api/schedules/route.js +72 -0
- package/dist/modules/data_sync/api/schedules/route.js.map +7 -0
- package/dist/modules/data_sync/api/schedules/serialize.js +21 -0
- package/dist/modules/data_sync/api/schedules/serialize.js.map +7 -0
- package/dist/modules/data_sync/backend/data-sync/page.js +656 -47
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +116 -34
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +2 -2
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js +394 -0
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js.map +7 -0
- package/dist/modules/data_sync/data/validators.js +32 -0
- package/dist/modules/data_sync/data/validators.js.map +2 -2
- package/dist/modules/data_sync/di.js +2 -0
- package/dist/modules/data_sync/di.js.map +2 -2
- package/dist/modules/data_sync/lib/id-mapping.js +24 -2
- package/dist/modules/data_sync/lib/id-mapping.js.map +2 -2
- package/dist/modules/data_sync/lib/start-run.js +57 -0
- package/dist/modules/data_sync/lib/start-run.js.map +7 -0
- package/dist/modules/data_sync/lib/sync-engine.js +93 -4
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-run-service.js +5 -1
- package/dist/modules/data_sync/lib/sync-run-service.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-schedule-service.js +138 -0
- package/dist/modules/data_sync/lib/sync-schedule-service.js.map +7 -0
- package/dist/modules/data_sync/workers/sync-export.js +28 -2
- package/dist/modules/data_sync/workers/sync-export.js.map +2 -2
- package/dist/modules/data_sync/workers/sync-import.js +28 -2
- package/dist/modules/data_sync/workers/sync-import.js.map +2 -2
- package/dist/modules/data_sync/workers/sync-scheduled.js +5 -0
- package/dist/modules/data_sync/workers/sync-scheduled.js.map +2 -2
- package/dist/modules/entities/api/definitions.js +5 -2
- package/dist/modules/entities/api/definitions.js.map +2 -2
- package/dist/modules/entities/lib/field-definitions.js +3 -1
- package/dist/modules/entities/lib/field-definitions.js.map +2 -2
- package/dist/modules/integrations/api/[id]/route.js +14 -15
- package/dist/modules/integrations/api/[id]/route.js.map +2 -2
- package/dist/modules/integrations/api/route.js +3 -3
- package/dist/modules/integrations/api/route.js.map +2 -2
- package/dist/modules/integrations/backend/integrations/[id]/page.js +148 -33
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
- package/dist/modules/integrations/lib/state-service.js +15 -1
- package/dist/modules/integrations/lib/state-service.js.map +2 -2
- package/dist/modules/messages/api/[id]/route.js +24 -22
- package/dist/modules/messages/api/[id]/route.js.map +2 -2
- package/dist/modules/payment_gateways/api/webhook/[provider]/route.js.map +2 -2
- package/dist/modules/progress/api/active/route.js +3 -1
- package/dist/modules/progress/api/active/route.js.map +2 -2
- package/dist/modules/progress/api/jobs/[id]/route.js +1 -1
- package/dist/modules/progress/api/jobs/[id]/route.js.map +2 -2
- package/dist/modules/progress/api/jobs/route.js +1 -1
- package/dist/modules/progress/api/jobs/route.js.map +2 -2
- package/dist/modules/progress/lib/events.js.map +1 -1
- package/dist/modules/progress/lib/progressService.js.map +2 -2
- package/dist/modules/progress/lib/progressServiceImpl.js +42 -1
- package/dist/modules/progress/lib/progressServiceImpl.js.map +2 -2
- package/dist/modules/query_index/lib/document.js +35 -1
- package/dist/modules/query_index/lib/document.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +91 -4
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/query_index/lib/indexer.js +2 -0
- package/dist/modules/query_index/lib/indexer.js.map +2 -2
- package/dist/modules/sales/api/adjustment-kinds/route.js +3 -9
- package/dist/modules/sales/api/adjustment-kinds/route.js.map +2 -2
- package/dist/modules/sales/api/channels/route.js +3 -10
- package/dist/modules/sales/api/channels/route.js.map +2 -2
- package/dist/modules/sales/api/delivery-windows/route.js +3 -10
- package/dist/modules/sales/api/delivery-windows/route.js.map +2 -2
- package/dist/modules/sales/api/payment-methods/route.js +3 -11
- package/dist/modules/sales/api/payment-methods/route.js.map +2 -2
- package/dist/modules/sales/api/price-kinds/route.js +3 -5
- package/dist/modules/sales/api/price-kinds/route.js.map +2 -2
- package/dist/modules/sales/api/shipping-methods/route.js +3 -11
- package/dist/modules/sales/api/shipping-methods/route.js.map +2 -2
- package/dist/modules/sales/api/tags/route.js +3 -9
- package/dist/modules/sales/api/tags/route.js.map +2 -2
- package/dist/modules/sales/api/tax-rates/route.js +3 -13
- package/dist/modules/sales/api/tax-rates/route.js.map +2 -2
- package/dist/modules/sales/api/utils.js +9 -0
- package/dist/modules/sales/api/utils.js.map +2 -2
- package/dist/modules/sales/lib/makeStatusDictionaryRoute.js +3 -9
- package/dist/modules/sales/lib/makeStatusDictionaryRoute.js.map +2 -2
- package/dist/modules/workflows/api/definitions/[id]/route.js +3 -2
- package/dist/modules/workflows/api/definitions/[id]/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/route.js +4 -3
- package/dist/modules/workflows/api/definitions/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/serialize.js +25 -0
- package/dist/modules/workflows/api/definitions/serialize.js.map +7 -0
- package/package.json +3 -3
- package/src/modules/catalog/api/bulk-delete/route.ts +93 -0
- package/src/modules/catalog/api/prices/route.ts +53 -6
- package/src/modules/catalog/api/products/route.ts +6 -11
- package/src/modules/catalog/commands/products.ts +2 -0
- package/src/modules/catalog/components/products/ProductsDataTable.tsx +8 -0
- package/src/modules/catalog/i18n/de.json +10 -0
- package/src/modules/catalog/i18n/en.json +10 -0
- package/src/modules/catalog/i18n/es.json +10 -0
- package/src/modules/catalog/i18n/pl.json +10 -0
- package/src/modules/catalog/lib/bulkDelete.ts +106 -0
- package/src/modules/catalog/widgets/injection/product-bulk-delete/widget.ts +242 -0
- package/src/modules/catalog/widgets/injection-table.ts +8 -0
- package/src/modules/catalog/workers/catalog-product-bulk-delete.ts +48 -0
- package/src/modules/data_sync/AGENTS.md +11 -3
- package/src/modules/data_sync/api/options.ts +58 -0
- package/src/modules/data_sync/api/run.ts +34 -36
- package/src/modules/data_sync/api/runs/[id]/cancel.ts +2 -2
- package/src/modules/data_sync/api/runs/[id]/retry.ts +14 -31
- package/src/modules/data_sync/api/schedules/[id]/route.ts +130 -0
- package/src/modules/data_sync/api/schedules/route.ts +77 -0
- package/src/modules/data_sync/api/schedules/serialize.ts +31 -0
- package/src/modules/data_sync/backend/data-sync/page.tsx +756 -2
- package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +179 -53
- package/src/modules/data_sync/components/IntegrationScheduleTab.tsx +512 -0
- package/src/modules/data_sync/data/validators.ts +35 -0
- package/src/modules/data_sync/di.ts +6 -0
- package/src/modules/data_sync/i18n/de.json +72 -0
- package/src/modules/data_sync/i18n/en.json +72 -0
- package/src/modules/data_sync/i18n/es.json +72 -0
- package/src/modules/data_sync/i18n/pl.json +72 -0
- package/src/modules/data_sync/lib/adapter.ts +4 -1
- package/src/modules/data_sync/lib/id-mapping.ts +32 -2
- package/src/modules/data_sync/lib/start-run.ts +90 -0
- package/src/modules/data_sync/lib/sync-engine.ts +111 -4
- package/src/modules/data_sync/lib/sync-run-service.ts +5 -1
- package/src/modules/data_sync/lib/sync-schedule-service.ts +207 -0
- package/src/modules/data_sync/workers/sync-export.ts +33 -2
- package/src/modules/data_sync/workers/sync-import.ts +33 -2
- package/src/modules/data_sync/workers/sync-scheduled.ts +7 -0
- package/src/modules/entities/api/definitions.ts +12 -2
- package/src/modules/entities/lib/field-definitions.ts +2 -0
- package/src/modules/integrations/AGENTS.md +16 -3
- package/src/modules/integrations/api/[id]/route.ts +14 -15
- package/src/modules/integrations/api/route.ts +3 -3
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +176 -54
- package/src/modules/integrations/lib/state-service.ts +25 -1
- package/src/modules/messages/api/[id]/route.ts +25 -22
- package/src/modules/payment_gateways/api/webhook/[provider]/route.ts +3 -3
- package/src/modules/progress/api/active/route.ts +4 -1
- package/src/modules/progress/api/jobs/[id]/route.ts +1 -1
- package/src/modules/progress/api/jobs/route.ts +1 -1
- package/src/modules/progress/lib/events.ts +6 -0
- package/src/modules/progress/lib/progressService.ts +1 -0
- package/src/modules/progress/lib/progressServiceImpl.ts +47 -1
- package/src/modules/query_index/lib/document.ts +52 -1
- package/src/modules/query_index/lib/engine.ts +104 -4
- package/src/modules/query_index/lib/indexer.ts +2 -0
- package/src/modules/sales/api/adjustment-kinds/route.ts +3 -9
- package/src/modules/sales/api/channels/route.ts +3 -10
- package/src/modules/sales/api/delivery-windows/route.ts +3 -10
- package/src/modules/sales/api/payment-methods/route.ts +3 -11
- package/src/modules/sales/api/price-kinds/route.ts +3 -5
- package/src/modules/sales/api/shipping-methods/route.ts +3 -11
- package/src/modules/sales/api/tags/route.ts +3 -9
- package/src/modules/sales/api/tax-rates/route.ts +3 -13
- package/src/modules/sales/api/utils.ts +9 -0
- package/src/modules/sales/lib/makeStatusDictionaryRoute.ts +3 -9
- package/src/modules/workflows/api/definitions/[id]/route.ts +3 -2
- package/src/modules/workflows/api/definitions/route.ts +4 -3
- package/src/modules/workflows/api/definitions/serialize.ts +23 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/catalog/components/products/ProductsDataTable.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\nimport { DataTable, type DataTableExportFormat } from '@open-mercato/ui/backend/DataTable'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { deleteCrud, buildCrudExportUrl } from '@open-mercato/ui/backend/utils/crud'\nimport { useCustomFieldDefs } from '@open-mercato/ui/backend/utils/customFieldDefs'\nimport { applyCustomFieldVisibility } from '@open-mercato/ui/backend/utils/customFieldColumns'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport type { FilterOption } from '@open-mercato/ui/backend/FilterOverlay'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { E } from '#generated/entities.ids.generated'\nimport { ProductImageCell } from './ProductImageCell'\n\ntype PricingScope = {\n variant_id?: string | null\n offer_id?: string | null\n channel_id?: string | null\n user_id?: string | null\n user_group_id?: string | null\n customer_id?: string | null\n customer_group_id?: string | null\n}\n\ntype PricingInfo = {\n kind?: string | null\n price_kind_id?: string | null\n price_kind_code?: string | null\n currency_code?: string | null\n unit_price_net?: string | null\n unit_price_gross?: string | null\n min_quantity?: number | null\n max_quantity?: number | null\n tax_rate?: string | null\n scope?: PricingScope | null\n} | null\n\ntype OfferInfo = {\n id: string\n channelId: string\n channelName?: string | null\n channelCode?: string | null\n title: string\n description?: string | null\n isActive: boolean\n}\n\nexport type ProductRow = {\n id: string\n title: string\n subtitle?: string | null\n description?: string | null\n sku?: string | null\n handle?: string | null\n product_type?: string | null\n status_entry_id?: string | null\n primary_currency_code?: string | null\n default_unit?: string | null\n default_media_id?: string | null\n default_media_url?: string | null\n is_configurable?: boolean\n is_active?: boolean\n metadata?: Record<string, unknown> | null\n custom_fieldset_code?: string | null\n created_at?: string\n updated_at?: string\n offers?: OfferInfo[]\n pricing?: PricingInfo\n} & Record<string, unknown>\n\ntype ProductsResponse = {\n items?: ProductRow[]\n total?: number\n totalPages?: number\n}\n\nconst PAGE_SIZE = 25\nconst ENTITY_ID = E.catalog.catalog_product\n\nfunction formatDate(value?: string): string {\n if (!value) return '\u2014'\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return '\u2014'\n return date.toLocaleDateString()\n}\n\nfunction renderOffers(offers: OfferInfo[] | undefined): React.ReactNode {\n if (!offers || offers.length === 0) return <span className=\"text-xs text-muted-foreground\">\u2014</span>\n const visible = offers.slice(0, 3)\n return (\n <div className=\"flex flex-wrap gap-1\">\n {visible.map((offer) => {\n const label =\n typeof offer.channelName === 'string' && offer.channelName.trim().length\n ? offer.channelName.trim()\n : typeof offer.title === 'string' && offer.title.trim().length\n ? offer.title.trim()\n : offer.channelId\n const badgeTitle =\n typeof offer.channelCode === 'string' && offer.channelCode.trim().length ? offer.channelCode : undefined\n return (\n <span\n key={offer.id}\n className={`inline-flex items-center rounded-full border px-2 py-0.5 text-xs ${\n offer.isActive ? 'bg-secondary/80 text-secondary-foreground' : 'bg-muted text-muted-foreground'\n }`}\n title={badgeTitle}\n >\n {label}\n </span>\n )\n })}\n {offers.length > visible.length ? (\n <span className=\"text-xs text-muted-foreground\">+{offers.length - visible.length}</span>\n ) : null}\n </div>\n )\n}\n\nfunction renderPrice(pricing: PricingInfo | undefined, currency?: string | null, fallback = '\u2014'): React.ReactNode {\n if (!pricing) return <span className=\"text-xs text-muted-foreground\">{fallback}</span>\n const unit = pricing.unit_price_net ?? pricing.unit_price_gross\n if (unit == null) return <span className=\"text-xs text-muted-foreground\">{fallback}</span>\n const formatted = `${currency ?? pricing.currency_code ?? ''} ${unit}`\n const kind = pricing.kind ?? 'list'\n return (\n <div className=\"flex flex-col\">\n <span className=\"font-medium\">{formatted.trim()}</span>\n <span className=\"text-xs text-muted-foreground\">{kind}</span>\n </div>\n )\n}\n\nexport default function ProductsDataTable() {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const scopeVersion = useOrganizationScopeVersion()\n const [rows, setRows] = React.useState<ProductRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [sorting, setSorting] = React.useState<SortingState>([{ id: 'title', desc: false }])\n const [search, setSearch] = React.useState('')\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n const [isLoading, setIsLoading] = React.useState(false)\n const [reloadToken, setReloadToken] = React.useState(0)\n const [customFieldsetFilter, setCustomFieldsetFilter] = React.useState<string | null>(null)\n const { data: customFieldDefs = [] } = useCustomFieldDefs(ENTITY_ID, {\n keyExtras: [scopeVersion, reloadToken],\n })\n const [channelOptionsCache, setChannelOptionsCache] = React.useState<Record<string, FilterOption>>({})\n const [categoryOptionsCache, setCategoryOptionsCache] = React.useState<Record<string, FilterOption>>({})\n const [tagOptionsCache, setTagOptionsCache] = React.useState<Record<string, FilterOption>>({})\n\n const registerOptions = React.useCallback(\n (\n setter: React.Dispatch<React.SetStateAction<Record<string, FilterOption>>>,\n options: FilterOption[]\n ) => {\n setter((prev) => {\n const next = { ...prev }\n options.forEach((opt) => {\n if (opt.value) next[opt.value] = opt\n })\n return next\n })\n },\n []\n )\n\n const registerChannelOptions = React.useCallback(\n (options: FilterOption[]) => registerOptions(setChannelOptionsCache, options),\n [registerOptions]\n )\n const registerCategoryOptions = React.useCallback(\n (options: FilterOption[]) => registerOptions(setCategoryOptionsCache, options),\n [registerOptions]\n )\n const registerTagOptions = React.useCallback(\n (options: FilterOption[]) => registerOptions(setTagOptionsCache, options),\n [registerOptions]\n )\n\n const channelOptions = React.useMemo(() => Object.values(channelOptionsCache), [channelOptionsCache])\n const categoryOptions = React.useMemo(() => Object.values(categoryOptionsCache), [categoryOptionsCache])\n const tagOptions = React.useMemo(() => Object.values(tagOptionsCache), [tagOptionsCache])\n\n const loadChannelOptions = React.useCallback(\n async (term?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '100', isActive: 'true' })\n if (term && term.trim().length) params.set('search', term.trim())\n const payload = await readApiResultOrThrow<{ items?: Array<{ id?: string; name?: string; code?: string }> }>(\n `/api/sales/channels?${params.toString()}`,\n undefined,\n { errorMessage: t('catalog.products.filters.channelsLoadError', 'Failed to load channels') },\n )\n const items = Array.isArray(payload?.items) ? payload.items : []\n const options = items\n .map((entry) => {\n const value = typeof entry.id === 'string' ? entry.id : null\n if (!value) return null\n const label =\n typeof entry.name === 'string'\n ? entry.name\n : typeof entry.code === 'string'\n ? entry.code\n : value\n return { value, label, description: typeof entry.code === 'string' ? entry.code : undefined }\n })\n .filter((option) => !!option) as FilterOption[]\n registerChannelOptions(options)\n return options\n } catch {\n return []\n }\n },\n [registerChannelOptions, t],\n )\n\n const loadCategoryOptions = React.useCallback(\n async (term?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '200', view: 'manage' })\n if (term && term.trim().length) params.set('search', term.trim())\n const payload = await readApiResultOrThrow<{ items?: Array<{ id?: string; name?: string; parentName?: string | null }> }>(\n `/api/catalog/categories?${params.toString()}`,\n undefined,\n { errorMessage: t('catalog.products.filters.categoriesLoadError', 'Failed to load categories') },\n )\n const items = Array.isArray(payload?.items) ? payload.items : []\n const options = items\n .map((entry) => {\n const value = typeof entry.id === 'string' ? entry.id : null\n if (!value) return null\n const label = typeof entry.name === 'string' && entry.name.trim().length ? entry.name : value\n const description =\n typeof entry.parentName === 'string' && entry.parentName.trim().length ? entry.parentName : null\n return { value, label, description }\n })\n .filter((option) => !!option) as FilterOption[]\n registerCategoryOptions(options)\n return options\n } catch {\n return []\n }\n },\n [registerCategoryOptions, t],\n )\n\n const loadTagOptions = React.useCallback(\n async (term?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '100' })\n if (term && term.trim().length) params.set('search', term.trim())\n const payload = await readApiResultOrThrow<{ items?: Array<{ id?: string; label?: string }> }>(\n `/api/catalog/tags?${params.toString()}`,\n undefined,\n { errorMessage: t('catalog.products.filters.tagsLoadError', 'Failed to load tags') },\n )\n const items = Array.isArray(payload?.items) ? payload.items : []\n const options = items\n .map((entry) => {\n const value = typeof entry.id === 'string' ? entry.id : null\n if (!value) return null\n const label = typeof entry.label === 'string' && entry.label.trim().length ? entry.label : value\n return { value, label }\n })\n .filter((option) => !!option) as FilterOption[]\n registerTagOptions(options)\n return options\n } catch {\n return []\n }\n },\n [registerTagOptions, t],\n )\n\n const productTypeOptions = React.useMemo<FilterOption[]>(() => [\n { value: 'simple', label: t('catalog.products.types.simple', 'Simple') },\n { value: 'configurable', label: t('catalog.products.types.configurable', 'Configurable') },\n { value: 'virtual', label: t('catalog.products.types.virtual', 'Virtual') },\n { value: 'downloadable', label: t('catalog.products.types.downloadable', 'Downloadable') },\n {\n value: 'bundle',\n label: `${t('catalog.products.types.bundle', 'Bundle')} (${t('common.comingSoon', 'Coming soon')})`,\n },\n {\n value: 'grouped',\n label: `${t('catalog.products.types.grouped', 'Grouped')} (${t('common.comingSoon', 'Coming soon')})`,\n },\n ], [t])\n\n const productTypeLabelMap = React.useMemo(() => {\n const map = new Map<string, string>()\n productTypeOptions.forEach((opt) => map.set(opt.value, opt.label))\n return map\n }, [productTypeOptions])\n\n const filters = React.useMemo<FilterDef[]>(() => [\n { id: 'status', label: t('catalog.products.filters.status'), type: 'text' },\n { id: 'isActive', label: t('catalog.products.filters.active'), type: 'checkbox' },\n { id: 'configurable', label: t('catalog.products.filters.configurable'), type: 'checkbox' },\n { id: 'productType', label: t('catalog.products.filters.productType', 'Type'), type: 'select', options: productTypeOptions },\n {\n id: 'channelIds',\n label: t('catalog.products.filters.channels'),\n type: 'tags',\n loadOptions: loadChannelOptions,\n options: channelOptions,\n formatValue: (val) => channelOptionsCache[val]?.label ?? val,\n formatDescription: (val) => channelOptionsCache[val]?.description ?? null,\n },\n {\n id: 'categoryIds',\n label: t('catalog.products.filters.categories', 'Categories'),\n type: 'tags',\n loadOptions: loadCategoryOptions,\n options: categoryOptions,\n formatValue: (val) => categoryOptionsCache[val]?.label ?? val,\n formatDescription: (val) => categoryOptionsCache[val]?.description ?? null,\n },\n {\n id: 'tagIds',\n label: t('catalog.products.filters.tags', 'Tags'),\n type: 'tags',\n loadOptions: loadTagOptions,\n options: tagOptions,\n formatValue: (val) => tagOptionsCache[val]?.label ?? val,\n },\n ], [\n categoryOptions,\n categoryOptionsCache,\n channelOptions,\n channelOptionsCache,\n loadCategoryOptions,\n loadChannelOptions,\n loadTagOptions,\n productTypeOptions,\n tagOptions,\n tagOptionsCache,\n t,\n ])\n\n const columns = React.useMemo<ColumnDef<ProductRow>[]>(() => {\n const base: ColumnDef<ProductRow>[] = [\n {\n id: 'media',\n header: '',\n size: 80,\n cell: ({ row }) => (\n <ProductImageCell\n mediaId={row.original.default_media_id}\n mediaUrl={row.original.default_media_url}\n title={row.original.title}\n cropType=\"contain\"\n />\n ),\n meta: { sticky: true },\n },\n {\n accessorKey: 'title',\n header: t('catalog.products.table.title', 'Title'),\n cell: ({ row }) => (\n <div className=\"flex flex-col\">\n <span className=\"font-medium\">{row.original.title || '\u2014'}</span>\n {row.original.subtitle ? (\n <span className=\"text-xs text-muted-foreground\">{row.original.subtitle}</span>\n ) : null}\n {row.original.handle ? (\n <span className=\"text-xs text-muted-foreground\">/{row.original.handle}</span>\n ) : null}\n {row.original.description ? (\n <span className=\"text-xs text-muted-foreground\">{row.original.description}</span>\n ) : null}\n </div>\n ),\n meta: { sticky: true },\n },\n {\n accessorKey: 'sku',\n header: t('catalog.products.table.sku', 'SKU'),\n cell: ({ getValue }) => {\n const value = getValue()\n return value ? <span className=\"font-mono text-xs\">{String(value)}</span> : <span className=\"text-xs text-muted-foreground\">\u2014</span>\n },\n },\n {\n accessorKey: 'product_type',\n header: t('catalog.products.table.type'),\n cell: ({ row }) => {\n const type = typeof row.original.product_type === 'string' ? row.original.product_type : 'simple'\n const label = productTypeLabelMap.get(type) ?? type\n return <span className=\"text-xs text-muted-foreground\">{label}</span>\n },\n },\n {\n accessorKey: 'is_configurable',\n header: t('catalog.products.table.configurable'),\n cell: ({ row }) => <BooleanIcon value={!!row.original.is_configurable} />,\n },\n {\n accessorKey: 'is_active',\n header: t('catalog.products.table.active'),\n cell: ({ row }) => <BooleanIcon value={!!row.original.is_active} />,\n },\n {\n accessorKey: 'pricing',\n header: t('catalog.products.table.price'),\n cell: ({ row }) => renderPrice(row.original.pricing, row.original.primary_currency_code),\n },\n {\n accessorKey: 'offers',\n header: t('catalog.products.table.channels'),\n cell: ({ row }) => renderOffers(row.original.offers),\n },\n {\n accessorKey: 'updated_at',\n header: t('catalog.products.table.updatedAt'),\n cell: ({ row }) => <span className=\"text-xs text-muted-foreground\">{formatDate(row.original.updated_at)}</span>,\n },\n ]\n return applyCustomFieldVisibility(base, customFieldDefs)\n }, [customFieldDefs, productTypeLabelMap, t])\n\n const handleSearchChange = React.useCallback((value: string) => {\n setSearch(value)\n setPage(1)\n }, [])\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n setFilterValues(values)\n setPage(1)\n }, [])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [])\n\n const handleCustomFieldsetFilterChange = React.useCallback(\n (value: string | null) => {\n if (value === customFieldsetFilter) return\n setCustomFieldsetFilter(value)\n setFilterValues((prev) => {\n const entries = Object.entries(prev)\n if (!entries.some(([key]) => key.startsWith('cf_'))) return prev\n const next: FilterValues = {}\n entries.forEach(([key, val]) => {\n if (!key.startsWith('cf_')) next[key] = val\n })\n return next\n })\n setPage(1)\n },\n [customFieldsetFilter],\n )\n\n const handleRefresh = React.useCallback(() => {\n setReloadToken((token) => token + 1)\n }, [])\n\n const queryParams = React.useMemo(() => {\n const params = new URLSearchParams()\n params.set('page', String(page))\n params.set('pageSize', String(PAGE_SIZE))\n if (search.trim()) params.set('search', search.trim())\n const sort = sorting[0]\n if (sort?.id) {\n params.set('sortField', sort.id)\n params.set('sortDir', sort.desc ? 'desc' : 'asc')\n }\n const status = filterValues.status\n if (typeof status === 'string' && status.trim()) {\n params.set('status', status.trim())\n }\n if (filterValues.isActive === true) params.set('isActive', 'true')\n if (filterValues.isActive === false) params.set('isActive', 'false')\n if (filterValues.configurable === true) params.set('configurable', 'true')\n if (filterValues.configurable === false) params.set('configurable', 'false')\n if (typeof filterValues.productType === 'string' && filterValues.productType.trim()) {\n params.set('productType', filterValues.productType.trim())\n }\n if (Array.isArray(filterValues.channelIds) && filterValues.channelIds.length) {\n const values = filterValues.channelIds\n .map((value) => (typeof value === 'string' ? value : null))\n .filter((value): value is string => !!value)\n if (values.length) params.set('channelIds', values.join(','))\n }\n if (Array.isArray(filterValues.categoryIds) && filterValues.categoryIds.length) {\n const values = filterValues.categoryIds\n .map((value) => (typeof value === 'string' ? value : null))\n .filter((value): value is string => !!value)\n if (values.length) params.set('categoryIds', values.join(','))\n }\n if (Array.isArray(filterValues.tagIds) && filterValues.tagIds.length) {\n const values = filterValues.tagIds\n .map((value) => (typeof value === 'string' ? value : null))\n .filter((value): value is string => !!value)\n if (values.length) params.set('tagIds', values.join(','))\n }\n Object.entries(filterValues).forEach(([key, value]) => {\n if (!key.startsWith('cf_') || value == null) return\n if (Array.isArray(value)) {\n const entries = value\n .map((entry) => (typeof entry === 'string' ? entry.trim() : String(entry || '').trim()))\n .filter((entry) => entry.length > 0)\n if (entries.length) params.set(key, entries.join(','))\n } else if (typeof value === 'object' && value !== null && ('from' in (value as Record<string, unknown>) || 'to' in (value as Record<string, unknown>))) {\n const range = value as { from?: string; to?: string }\n if (typeof range.from === 'string' && range.from.trim().length) {\n params.set(`${key}:from`, range.from.trim())\n }\n if (typeof range.to === 'string' && range.to.trim().length) {\n params.set(`${key}:to`, range.to.trim())\n }\n } else if (typeof value === 'string' && value.trim()) {\n params.set(key, value.trim())\n }\n })\n if (typeof customFieldsetFilter === 'string' && customFieldsetFilter.trim().length > 0) {\n params.set('customFieldset', customFieldsetFilter.trim())\n }\n return params.toString()\n }, [customFieldsetFilter, filterValues, page, search, sorting])\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n setIsLoading(true)\n try {\n const fallback: ProductsResponse = { items: [], total: 0, totalPages: 1 }\n const call = await apiCall<ProductsResponse>(\n `/api/catalog/products?${queryParams}`,\n undefined,\n { fallback },\n )\n if (!call.ok) {\n const message = t('catalog.products.list.error.load', 'Failed to load products')\n flash(message, 'error')\n return\n }\n const payload = call.result ?? fallback\n if (cancelled) return\n const items = Array.isArray(payload.items) ? payload.items : []\n const normalized = items.filter((item): item is ProductRow => typeof item?.id === 'string')\n setRows(normalized)\n setTotal(typeof payload.total === 'number' ? payload.total : normalized.length)\n setTotalPages(typeof payload.totalPages === 'number' ? payload.totalPages : 1)\n } catch (error) {\n if (!cancelled) {\n const message =\n error instanceof Error\n ? error.message\n : t('catalog.products.list.error.load', 'Failed to load products')\n flash(message, 'error')\n }\n } finally {\n if (!cancelled) setIsLoading(false)\n }\n }\n load()\n return () => {\n cancelled = true\n }\n }, [queryParams, reloadToken, scopeVersion, t])\n\n const handleDelete = React.useCallback(async (row: ProductRow) => {\n const confirmed = await confirm({\n title: t('catalog.products.list.deleteConfirm', 'Delete this product?'),\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n await deleteCrud('catalog/products', row.id, {\n errorMessage: t('catalog.products.list.error.delete', 'Failed to delete product'),\n })\n flash(t('catalog.products.flash.deleted', 'Product deleted'), 'success')\n setReloadToken((token) => token + 1)\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : t('catalog.products.list.error.delete', 'Failed to delete product')\n flash(message, 'error')\n }\n }, [confirm, t])\n\n const currentParams = React.useMemo(() => Object.fromEntries(new URLSearchParams(queryParams)), [queryParams])\n\n const exportConfig = React.useMemo(() => ({\n view: {\n getUrl: (format: DataTableExportFormat) =>\n buildCrudExportUrl('catalog/products', { ...currentParams, exportScope: 'view' }, format),\n },\n full: {\n getUrl: (format: DataTableExportFormat) =>\n buildCrudExportUrl('catalog/products', { ...currentParams, exportScope: 'full', all: 'true' }, format),\n },\n }), [currentParams])\n\n return (\n <>\n <DataTable<ProductRow>\n title={t('catalog.products.page.title', 'Products & services')}\n entityId={ENTITY_ID}\n customFieldFilterKeyExtras={[scopeVersion, reloadToken]}\n refreshButton={{\n label: t('catalog.products.actions.refresh', 'Refresh'),\n onRefresh: handleRefresh,\n isRefreshing: isLoading,\n }}\n actions={(\n <Button asChild>\n <Link href=\"/backend/catalog/products/create\">\n {t('catalog.products.actions.create', 'Create')}\n </Link>\n </Button>\n )}\n columns={columns}\n data={rows}\n searchValue={search}\n onSearchChange={handleSearchChange}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n onCustomFieldFilterFieldsetChange={handleCustomFieldsetFilterChange}\n sorting={sorting}\n onSortingChange={setSorting}\n injectionSpotId=\"data-table:catalog.products\"\n injectionContext={{\n search,\n filters: filterValues,\n page,\n scopeVersion,\n }}\n pagination={{\n page,\n pageSize: PAGE_SIZE,\n total,\n totalPages,\n onPageChange: setPage,\n }}\n exporter={exportConfig}\n isLoading={isLoading}\n perspective={{ tableId: 'catalog.products.list' }}\n rowActions={(row) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('catalog.products.table.actions.edit', 'Edit'),\n href: `/backend/catalog/products/${row.id}`,\n },\n {\n id: 'delete',\n label: t('catalog.products.table.actions.delete', 'Delete'),\n destructive: true,\n onSelect: () => {\n void handleDelete(row)\n },\n },\n ]}\n />\n )}\n />\n {ConfirmDialogElement}\n </>\n )\n}\n"],
|
|
5
|
-
"mappings": ";AA+F6C,SAmgBzC,UAngByC,KA0BrC,YA1BqC;AA7F7C,YAAY,WAAW;AACvB,OAAO,UAAU;AAEjB,SAAS,iBAA6C;AACtD,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,4BAA4B;AAC9C,SAAS,aAAa;AACtB,SAAS,YAAY,0BAA0B;AAC/C,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAG3C,SAAS,mBAAmB;AAC5B,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,SAAS;AAClB,SAAS,wBAAwB;AAgEjC,MAAM,YAAY;AAClB,MAAM,YAAY,EAAE,QAAQ;AAE5B,SAAS,WAAW,OAAwB;AAC1C,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,MAAI,O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BAA+B,qBAAqB;AAAA,QAC7D,UAAU;AAAA,QACV,4BAA4B,CAAC,cAAc,WAAW;AAAA,QACtD,eAAe;AAAA,UACb,OAAO,EAAE,oCAAoC,SAAS;AAAA,UACtD,WAAW;AAAA,UACX,cAAc;AAAA,QAChB;AAAA,QACA,SACE,oBAAC,UAAO,SAAO,MACb,8BAAC,QAAK,MAAK,oCACR,YAAE,mCAAmC,QAAQ,GAChD,GACF;AAAA,QAEF;AAAA,QACA,MAAM;AAAA,QACN,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB,gBAAgB;AAAA,QAChB,mCAAmC;AAAA,QACnC;AAAA,QACA,iBAAiB;AAAA,QACjB,iBAAgB;AAAA,QAChB,kBAAkB;AAAA,UAChB;AAAA,UACA,SAAS;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,QACA,YAAY;AAAA,UACV;AAAA,UACA,UAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QAChB;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACA,aAAa,EAAE,SAAS,wBAAwB;AAAA,QAChD,YAAY,CAAC,QACX;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL;AAAA,gBACE,IAAI;AAAA,gBACJ,OAAO,EAAE,uCAAuC,MAAM;AAAA,gBACtD,MAAM,6BAA6B,IAAI,EAAE;AAAA,cAC3C;AAAA,cACA;AAAA,gBACE,IAAI;AAAA,gBACJ,OAAO,EAAE,yCAAyC,QAAQ;AAAA,gBAC1D,aAAa;AAAA,gBACb,UAAU,MAAM;AACd,uBAAK,aAAa,GAAG;AAAA,gBACvB;AAAA,cACF;AAAA,YACF;AAAA;AAAA,QACF;AAAA;AAAA,IAEJ;AAAA,IACC;AAAA,KACH;AAEJ;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\nimport { DataTable, type DataTableExportFormat } from '@open-mercato/ui/backend/DataTable'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { deleteCrud, buildCrudExportUrl } from '@open-mercato/ui/backend/utils/crud'\nimport { useCustomFieldDefs } from '@open-mercato/ui/backend/utils/customFieldDefs'\nimport { applyCustomFieldVisibility } from '@open-mercato/ui/backend/utils/customFieldColumns'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport type { FilterOption } from '@open-mercato/ui/backend/FilterOverlay'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { E } from '#generated/entities.ids.generated'\nimport { ProductImageCell } from './ProductImageCell'\n\ntype PricingScope = {\n variant_id?: string | null\n offer_id?: string | null\n channel_id?: string | null\n user_id?: string | null\n user_group_id?: string | null\n customer_id?: string | null\n customer_group_id?: string | null\n}\n\ntype PricingInfo = {\n kind?: string | null\n price_kind_id?: string | null\n price_kind_code?: string | null\n currency_code?: string | null\n unit_price_net?: string | null\n unit_price_gross?: string | null\n min_quantity?: number | null\n max_quantity?: number | null\n tax_rate?: string | null\n scope?: PricingScope | null\n} | null\n\ntype OfferInfo = {\n id: string\n channelId: string\n channelName?: string | null\n channelCode?: string | null\n title: string\n description?: string | null\n isActive: boolean\n}\n\nexport type ProductRow = {\n id: string\n title: string\n subtitle?: string | null\n description?: string | null\n sku?: string | null\n handle?: string | null\n product_type?: string | null\n status_entry_id?: string | null\n primary_currency_code?: string | null\n default_unit?: string | null\n default_media_id?: string | null\n default_media_url?: string | null\n is_configurable?: boolean\n is_active?: boolean\n metadata?: Record<string, unknown> | null\n custom_fieldset_code?: string | null\n created_at?: string\n updated_at?: string\n offers?: OfferInfo[]\n pricing?: PricingInfo\n} & Record<string, unknown>\n\ntype ProductsResponse = {\n items?: ProductRow[]\n total?: number\n totalPages?: number\n}\n\nconst PAGE_SIZE = 25\nconst ENTITY_ID = E.catalog.catalog_product\n\nfunction formatDate(value?: string): string {\n if (!value) return '\u2014'\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return '\u2014'\n return date.toLocaleDateString()\n}\n\nfunction renderOffers(offers: OfferInfo[] | undefined): React.ReactNode {\n if (!offers || offers.length === 0) return <span className=\"text-xs text-muted-foreground\">\u2014</span>\n const visible = offers.slice(0, 3)\n return (\n <div className=\"flex flex-wrap gap-1\">\n {visible.map((offer) => {\n const label =\n typeof offer.channelName === 'string' && offer.channelName.trim().length\n ? offer.channelName.trim()\n : typeof offer.title === 'string' && offer.title.trim().length\n ? offer.title.trim()\n : offer.channelId\n const badgeTitle =\n typeof offer.channelCode === 'string' && offer.channelCode.trim().length ? offer.channelCode : undefined\n return (\n <span\n key={offer.id}\n className={`inline-flex items-center rounded-full border px-2 py-0.5 text-xs ${\n offer.isActive ? 'bg-secondary/80 text-secondary-foreground' : 'bg-muted text-muted-foreground'\n }`}\n title={badgeTitle}\n >\n {label}\n </span>\n )\n })}\n {offers.length > visible.length ? (\n <span className=\"text-xs text-muted-foreground\">+{offers.length - visible.length}</span>\n ) : null}\n </div>\n )\n}\n\nfunction renderPrice(pricing: PricingInfo | undefined, currency?: string | null, fallback = '\u2014'): React.ReactNode {\n if (!pricing) return <span className=\"text-xs text-muted-foreground\">{fallback}</span>\n const unit = pricing.unit_price_net ?? pricing.unit_price_gross\n if (unit == null) return <span className=\"text-xs text-muted-foreground\">{fallback}</span>\n const formatted = `${currency ?? pricing.currency_code ?? ''} ${unit}`\n const kind = pricing.kind ?? 'list'\n return (\n <div className=\"flex flex-col\">\n <span className=\"font-medium\">{formatted.trim()}</span>\n <span className=\"text-xs text-muted-foreground\">{kind}</span>\n </div>\n )\n}\n\nexport default function ProductsDataTable() {\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const scopeVersion = useOrganizationScopeVersion()\n const [rows, setRows] = React.useState<ProductRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [cacheStatus, setCacheStatus] = React.useState<'hit' | 'miss' | null>(null)\n const [sorting, setSorting] = React.useState<SortingState>([{ id: 'title', desc: false }])\n const [search, setSearch] = React.useState('')\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n const [isLoading, setIsLoading] = React.useState(false)\n const [reloadToken, setReloadToken] = React.useState(0)\n const [customFieldsetFilter, setCustomFieldsetFilter] = React.useState<string | null>(null)\n const { data: customFieldDefs = [] } = useCustomFieldDefs(ENTITY_ID, {\n keyExtras: [scopeVersion, reloadToken],\n })\n const [channelOptionsCache, setChannelOptionsCache] = React.useState<Record<string, FilterOption>>({})\n const [categoryOptionsCache, setCategoryOptionsCache] = React.useState<Record<string, FilterOption>>({})\n const [tagOptionsCache, setTagOptionsCache] = React.useState<Record<string, FilterOption>>({})\n\n const registerOptions = React.useCallback(\n (\n setter: React.Dispatch<React.SetStateAction<Record<string, FilterOption>>>,\n options: FilterOption[]\n ) => {\n setter((prev) => {\n const next = { ...prev }\n options.forEach((opt) => {\n if (opt.value) next[opt.value] = opt\n })\n return next\n })\n },\n []\n )\n\n const registerChannelOptions = React.useCallback(\n (options: FilterOption[]) => registerOptions(setChannelOptionsCache, options),\n [registerOptions]\n )\n const registerCategoryOptions = React.useCallback(\n (options: FilterOption[]) => registerOptions(setCategoryOptionsCache, options),\n [registerOptions]\n )\n const registerTagOptions = React.useCallback(\n (options: FilterOption[]) => registerOptions(setTagOptionsCache, options),\n [registerOptions]\n )\n\n const channelOptions = React.useMemo(() => Object.values(channelOptionsCache), [channelOptionsCache])\n const categoryOptions = React.useMemo(() => Object.values(categoryOptionsCache), [categoryOptionsCache])\n const tagOptions = React.useMemo(() => Object.values(tagOptionsCache), [tagOptionsCache])\n\n const loadChannelOptions = React.useCallback(\n async (term?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '100', isActive: 'true' })\n if (term && term.trim().length) params.set('search', term.trim())\n const payload = await readApiResultOrThrow<{ items?: Array<{ id?: string; name?: string; code?: string }> }>(\n `/api/sales/channels?${params.toString()}`,\n undefined,\n { errorMessage: t('catalog.products.filters.channelsLoadError', 'Failed to load channels') },\n )\n const items = Array.isArray(payload?.items) ? payload.items : []\n const options = items\n .map((entry) => {\n const value = typeof entry.id === 'string' ? entry.id : null\n if (!value) return null\n const label =\n typeof entry.name === 'string'\n ? entry.name\n : typeof entry.code === 'string'\n ? entry.code\n : value\n return { value, label, description: typeof entry.code === 'string' ? entry.code : undefined }\n })\n .filter((option) => !!option) as FilterOption[]\n registerChannelOptions(options)\n return options\n } catch {\n return []\n }\n },\n [registerChannelOptions, t],\n )\n\n const loadCategoryOptions = React.useCallback(\n async (term?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '200', view: 'manage' })\n if (term && term.trim().length) params.set('search', term.trim())\n const payload = await readApiResultOrThrow<{ items?: Array<{ id?: string; name?: string; parentName?: string | null }> }>(\n `/api/catalog/categories?${params.toString()}`,\n undefined,\n { errorMessage: t('catalog.products.filters.categoriesLoadError', 'Failed to load categories') },\n )\n const items = Array.isArray(payload?.items) ? payload.items : []\n const options = items\n .map((entry) => {\n const value = typeof entry.id === 'string' ? entry.id : null\n if (!value) return null\n const label = typeof entry.name === 'string' && entry.name.trim().length ? entry.name : value\n const description =\n typeof entry.parentName === 'string' && entry.parentName.trim().length ? entry.parentName : null\n return { value, label, description }\n })\n .filter((option) => !!option) as FilterOption[]\n registerCategoryOptions(options)\n return options\n } catch {\n return []\n }\n },\n [registerCategoryOptions, t],\n )\n\n const loadTagOptions = React.useCallback(\n async (term?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '100' })\n if (term && term.trim().length) params.set('search', term.trim())\n const payload = await readApiResultOrThrow<{ items?: Array<{ id?: string; label?: string }> }>(\n `/api/catalog/tags?${params.toString()}`,\n undefined,\n { errorMessage: t('catalog.products.filters.tagsLoadError', 'Failed to load tags') },\n )\n const items = Array.isArray(payload?.items) ? payload.items : []\n const options = items\n .map((entry) => {\n const value = typeof entry.id === 'string' ? entry.id : null\n if (!value) return null\n const label = typeof entry.label === 'string' && entry.label.trim().length ? entry.label : value\n return { value, label }\n })\n .filter((option) => !!option) as FilterOption[]\n registerTagOptions(options)\n return options\n } catch {\n return []\n }\n },\n [registerTagOptions, t],\n )\n\n const productTypeOptions = React.useMemo<FilterOption[]>(() => [\n { value: 'simple', label: t('catalog.products.types.simple', 'Simple') },\n { value: 'configurable', label: t('catalog.products.types.configurable', 'Configurable') },\n { value: 'virtual', label: t('catalog.products.types.virtual', 'Virtual') },\n { value: 'downloadable', label: t('catalog.products.types.downloadable', 'Downloadable') },\n {\n value: 'bundle',\n label: `${t('catalog.products.types.bundle', 'Bundle')} (${t('common.comingSoon', 'Coming soon')})`,\n },\n {\n value: 'grouped',\n label: `${t('catalog.products.types.grouped', 'Grouped')} (${t('common.comingSoon', 'Coming soon')})`,\n },\n ], [t])\n\n const productTypeLabelMap = React.useMemo(() => {\n const map = new Map<string, string>()\n productTypeOptions.forEach((opt) => map.set(opt.value, opt.label))\n return map\n }, [productTypeOptions])\n\n const filters = React.useMemo<FilterDef[]>(() => [\n { id: 'status', label: t('catalog.products.filters.status'), type: 'text' },\n { id: 'isActive', label: t('catalog.products.filters.active'), type: 'checkbox' },\n { id: 'configurable', label: t('catalog.products.filters.configurable'), type: 'checkbox' },\n { id: 'productType', label: t('catalog.products.filters.productType', 'Type'), type: 'select', options: productTypeOptions },\n {\n id: 'channelIds',\n label: t('catalog.products.filters.channels'),\n type: 'tags',\n loadOptions: loadChannelOptions,\n options: channelOptions,\n formatValue: (val) => channelOptionsCache[val]?.label ?? val,\n formatDescription: (val) => channelOptionsCache[val]?.description ?? null,\n },\n {\n id: 'categoryIds',\n label: t('catalog.products.filters.categories', 'Categories'),\n type: 'tags',\n loadOptions: loadCategoryOptions,\n options: categoryOptions,\n formatValue: (val) => categoryOptionsCache[val]?.label ?? val,\n formatDescription: (val) => categoryOptionsCache[val]?.description ?? null,\n },\n {\n id: 'tagIds',\n label: t('catalog.products.filters.tags', 'Tags'),\n type: 'tags',\n loadOptions: loadTagOptions,\n options: tagOptions,\n formatValue: (val) => tagOptionsCache[val]?.label ?? val,\n },\n ], [\n categoryOptions,\n categoryOptionsCache,\n channelOptions,\n channelOptionsCache,\n loadCategoryOptions,\n loadChannelOptions,\n loadTagOptions,\n productTypeOptions,\n tagOptions,\n tagOptionsCache,\n t,\n ])\n\n const columns = React.useMemo<ColumnDef<ProductRow>[]>(() => {\n const base: ColumnDef<ProductRow>[] = [\n {\n id: 'media',\n header: '',\n size: 80,\n cell: ({ row }) => (\n <ProductImageCell\n mediaId={row.original.default_media_id}\n mediaUrl={row.original.default_media_url}\n title={row.original.title}\n cropType=\"contain\"\n />\n ),\n meta: { sticky: true },\n },\n {\n accessorKey: 'title',\n header: t('catalog.products.table.title', 'Title'),\n cell: ({ row }) => (\n <div className=\"flex flex-col\">\n <span className=\"font-medium\">{row.original.title || '\u2014'}</span>\n {row.original.subtitle ? (\n <span className=\"text-xs text-muted-foreground\">{row.original.subtitle}</span>\n ) : null}\n {row.original.handle ? (\n <span className=\"text-xs text-muted-foreground\">/{row.original.handle}</span>\n ) : null}\n {row.original.description ? (\n <span className=\"text-xs text-muted-foreground\">{row.original.description}</span>\n ) : null}\n </div>\n ),\n meta: { sticky: true },\n },\n {\n accessorKey: 'sku',\n header: t('catalog.products.table.sku', 'SKU'),\n cell: ({ getValue }) => {\n const value = getValue()\n return value ? <span className=\"font-mono text-xs\">{String(value)}</span> : <span className=\"text-xs text-muted-foreground\">\u2014</span>\n },\n },\n {\n accessorKey: 'product_type',\n header: t('catalog.products.table.type'),\n cell: ({ row }) => {\n const type = typeof row.original.product_type === 'string' ? row.original.product_type : 'simple'\n const label = productTypeLabelMap.get(type) ?? type\n return <span className=\"text-xs text-muted-foreground\">{label}</span>\n },\n },\n {\n accessorKey: 'is_configurable',\n header: t('catalog.products.table.configurable'),\n cell: ({ row }) => <BooleanIcon value={!!row.original.is_configurable} />,\n },\n {\n accessorKey: 'is_active',\n header: t('catalog.products.table.active'),\n cell: ({ row }) => <BooleanIcon value={!!row.original.is_active} />,\n },\n {\n accessorKey: 'pricing',\n header: t('catalog.products.table.price'),\n cell: ({ row }) => renderPrice(row.original.pricing, row.original.primary_currency_code),\n },\n {\n accessorKey: 'offers',\n header: t('catalog.products.table.channels'),\n cell: ({ row }) => renderOffers(row.original.offers),\n },\n {\n accessorKey: 'updated_at',\n header: t('catalog.products.table.updatedAt'),\n cell: ({ row }) => <span className=\"text-xs text-muted-foreground\">{formatDate(row.original.updated_at)}</span>,\n },\n ]\n return applyCustomFieldVisibility(base, customFieldDefs)\n }, [customFieldDefs, productTypeLabelMap, t])\n\n const handleSearchChange = React.useCallback((value: string) => {\n setSearch(value)\n setPage(1)\n }, [])\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n setFilterValues(values)\n setPage(1)\n }, [])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [])\n\n const handleCustomFieldsetFilterChange = React.useCallback(\n (value: string | null) => {\n if (value === customFieldsetFilter) return\n setCustomFieldsetFilter(value)\n setFilterValues((prev) => {\n const entries = Object.entries(prev)\n if (!entries.some(([key]) => key.startsWith('cf_'))) return prev\n const next: FilterValues = {}\n entries.forEach(([key, val]) => {\n if (!key.startsWith('cf_')) next[key] = val\n })\n return next\n })\n setPage(1)\n },\n [customFieldsetFilter],\n )\n\n const handleRefresh = React.useCallback(() => {\n setReloadToken((token) => token + 1)\n }, [])\n\n const queryParams = React.useMemo(() => {\n const params = new URLSearchParams()\n params.set('page', String(page))\n params.set('pageSize', String(PAGE_SIZE))\n if (search.trim()) params.set('search', search.trim())\n const sort = sorting[0]\n if (sort?.id) {\n params.set('sortField', sort.id)\n params.set('sortDir', sort.desc ? 'desc' : 'asc')\n }\n const status = filterValues.status\n if (typeof status === 'string' && status.trim()) {\n params.set('status', status.trim())\n }\n if (filterValues.isActive === true) params.set('isActive', 'true')\n if (filterValues.isActive === false) params.set('isActive', 'false')\n if (filterValues.configurable === true) params.set('configurable', 'true')\n if (filterValues.configurable === false) params.set('configurable', 'false')\n if (typeof filterValues.productType === 'string' && filterValues.productType.trim()) {\n params.set('productType', filterValues.productType.trim())\n }\n if (Array.isArray(filterValues.channelIds) && filterValues.channelIds.length) {\n const values = filterValues.channelIds\n .map((value) => (typeof value === 'string' ? value : null))\n .filter((value): value is string => !!value)\n if (values.length) params.set('channelIds', values.join(','))\n }\n if (Array.isArray(filterValues.categoryIds) && filterValues.categoryIds.length) {\n const values = filterValues.categoryIds\n .map((value) => (typeof value === 'string' ? value : null))\n .filter((value): value is string => !!value)\n if (values.length) params.set('categoryIds', values.join(','))\n }\n if (Array.isArray(filterValues.tagIds) && filterValues.tagIds.length) {\n const values = filterValues.tagIds\n .map((value) => (typeof value === 'string' ? value : null))\n .filter((value): value is string => !!value)\n if (values.length) params.set('tagIds', values.join(','))\n }\n Object.entries(filterValues).forEach(([key, value]) => {\n if (!key.startsWith('cf_') || value == null) return\n if (Array.isArray(value)) {\n const entries = value\n .map((entry) => (typeof entry === 'string' ? entry.trim() : String(entry || '').trim()))\n .filter((entry) => entry.length > 0)\n if (entries.length) params.set(key, entries.join(','))\n } else if (typeof value === 'object' && value !== null && ('from' in (value as Record<string, unknown>) || 'to' in (value as Record<string, unknown>))) {\n const range = value as { from?: string; to?: string }\n if (typeof range.from === 'string' && range.from.trim().length) {\n params.set(`${key}:from`, range.from.trim())\n }\n if (typeof range.to === 'string' && range.to.trim().length) {\n params.set(`${key}:to`, range.to.trim())\n }\n } else if (typeof value === 'string' && value.trim()) {\n params.set(key, value.trim())\n }\n })\n if (typeof customFieldsetFilter === 'string' && customFieldsetFilter.trim().length > 0) {\n params.set('customFieldset', customFieldsetFilter.trim())\n }\n return params.toString()\n }, [customFieldsetFilter, filterValues, page, search, sorting])\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n setIsLoading(true)\n setCacheStatus(null)\n try {\n const fallback: ProductsResponse = { items: [], total: 0, totalPages: 1 }\n const call = await apiCall<ProductsResponse>(\n `/api/catalog/products?${queryParams}`,\n undefined,\n { fallback },\n )\n if (!call.ok) {\n const message = t('catalog.products.list.error.load', 'Failed to load products')\n flash(message, 'error')\n if (!cancelled) setCacheStatus(null)\n return\n }\n const payload = call.result ?? fallback\n if (cancelled) return\n setCacheStatus(call.cacheStatus ?? null)\n const items = Array.isArray(payload.items) ? payload.items : []\n const normalized = items.filter((item): item is ProductRow => typeof item?.id === 'string')\n setRows(normalized)\n setTotal(typeof payload.total === 'number' ? payload.total : normalized.length)\n setTotalPages(typeof payload.totalPages === 'number' ? payload.totalPages : 1)\n } catch (error) {\n if (!cancelled) {\n setCacheStatus(null)\n const message =\n error instanceof Error\n ? error.message\n : t('catalog.products.list.error.load', 'Failed to load products')\n flash(message, 'error')\n }\n } finally {\n if (!cancelled) setIsLoading(false)\n }\n }\n load()\n return () => {\n cancelled = true\n }\n }, [queryParams, reloadToken, scopeVersion, t])\n\n const handleDelete = React.useCallback(async (row: ProductRow) => {\n const confirmed = await confirm({\n title: t('catalog.products.list.deleteConfirm', 'Delete this product?'),\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n await deleteCrud('catalog/products', row.id, {\n errorMessage: t('catalog.products.list.error.delete', 'Failed to delete product'),\n })\n flash(t('catalog.products.flash.deleted', 'Product deleted'), 'success')\n setReloadToken((token) => token + 1)\n } catch (error) {\n const message =\n error instanceof Error\n ? error.message\n : t('catalog.products.list.error.delete', 'Failed to delete product')\n flash(message, 'error')\n }\n }, [confirm, t])\n\n const currentParams = React.useMemo(() => Object.fromEntries(new URLSearchParams(queryParams)), [queryParams])\n\n const exportConfig = React.useMemo(() => ({\n view: {\n getUrl: (format: DataTableExportFormat) =>\n buildCrudExportUrl('catalog/products', { ...currentParams, exportScope: 'view' }, format),\n },\n full: {\n getUrl: (format: DataTableExportFormat) =>\n buildCrudExportUrl('catalog/products', { ...currentParams, exportScope: 'full', all: 'true' }, format),\n },\n }), [currentParams])\n\n return (\n <>\n <DataTable<ProductRow>\n title={t('catalog.products.page.title', 'Products & services')}\n entityId={ENTITY_ID}\n customFieldFilterKeyExtras={[scopeVersion, reloadToken]}\n refreshButton={{\n label: t('catalog.products.actions.refresh', 'Refresh'),\n onRefresh: handleRefresh,\n isRefreshing: isLoading,\n }}\n actions={(\n <Button asChild>\n <Link href=\"/backend/catalog/products/create\">\n {t('catalog.products.actions.create', 'Create')}\n </Link>\n </Button>\n )}\n columns={columns}\n data={rows}\n searchValue={search}\n onSearchChange={handleSearchChange}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n onCustomFieldFilterFieldsetChange={handleCustomFieldsetFilterChange}\n sorting={sorting}\n onSortingChange={setSorting}\n injectionSpotId=\"data-table:catalog.products\"\n injectionContext={{\n search,\n filters: filterValues,\n customFieldset: customFieldsetFilter,\n page,\n sorting,\n scopeVersion,\n }}\n pagination={{\n page,\n pageSize: PAGE_SIZE,\n total,\n totalPages,\n onPageChange: setPage,\n cacheStatus,\n }}\n exporter={exportConfig}\n isLoading={isLoading}\n perspective={{ tableId: 'catalog.products.list' }}\n rowActions={(row) => (\n <RowActions\n items={[\n {\n id: 'edit',\n label: t('catalog.products.table.actions.edit', 'Edit'),\n href: `/backend/catalog/products/${row.id}`,\n },\n {\n id: 'delete',\n label: t('catalog.products.table.actions.delete', 'Delete'),\n destructive: true,\n onSelect: () => {\n void handleDelete(row)\n },\n },\n ]}\n />\n )}\n />\n {ConfirmDialogElement}\n </>\n )\n}\n"],
|
|
5
|
+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AAAA,UACT,gBAAgB;AAAA,UAChB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACA,YAAY;AAAA,UACV;AAAA,UACA,UAAU;AAAA,UACV;AAAA,UACA;AAAA,UACA,cAAc;AAAA,UACd;AAAA,QACF;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACA,aAAa,EAAE,SAAS,wBAAwB;AAAA,QAChD,YAAY,CAAC,QACX;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL;AAAA,gBACE,IAAI;AAAA,gBACJ,OAAO,EAAE,uCAAuC,MAAM;AAAA,gBACtD,MAAM,6BAA6B,IAAI,EAAE;AAAA,cAC3C;AAAA,cACA;AAAA,gBACE,IAAI;AAAA,gBACJ,OAAO,EAAE,yCAAyC,QAAQ;AAAA,gBAC1D,aAAa;AAAA,gBACb,UAAU,MAAM;AACd,uBAAK,aAAa,GAAG;AAAA,gBACvB;AAAA,cACF;AAAA,YACF;AAAA;AAAA,QACF;AAAA;AAAA,IAEJ;AAAA,IACC;AAAA,KACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createQueue } from "@open-mercato/queue";
|
|
2
|
+
import { getRedisUrl } from "@open-mercato/shared/lib/redis/connection";
|
|
3
|
+
const CATALOG_PRODUCT_BULK_DELETE_QUEUE = "catalog-product-bulk-delete";
|
|
4
|
+
const queues = /* @__PURE__ */ new Map();
|
|
5
|
+
function getCatalogQueue(queueName) {
|
|
6
|
+
const existing = queues.get(queueName);
|
|
7
|
+
if (existing) return existing;
|
|
8
|
+
const created = process.env.QUEUE_STRATEGY === "async" ? createQueue(queueName, "async", {
|
|
9
|
+
connection: { url: getRedisUrl("QUEUE") },
|
|
10
|
+
concurrency: Math.max(1, Number.parseInt(process.env.CATALOG_QUEUE_CONCURRENCY ?? "3", 10) || 3)
|
|
11
|
+
}) : createQueue(queueName, "local");
|
|
12
|
+
queues.set(queueName, created);
|
|
13
|
+
return created;
|
|
14
|
+
}
|
|
15
|
+
function buildCommandContext(scope, container) {
|
|
16
|
+
return {
|
|
17
|
+
container,
|
|
18
|
+
auth: null,
|
|
19
|
+
organizationScope: {
|
|
20
|
+
selectedId: scope.organizationId,
|
|
21
|
+
filterIds: [scope.organizationId],
|
|
22
|
+
allowedIds: [scope.organizationId],
|
|
23
|
+
tenantId: scope.tenantId
|
|
24
|
+
},
|
|
25
|
+
selectedOrganizationId: scope.organizationId,
|
|
26
|
+
organizationIds: [scope.organizationId]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function deleteCatalogProductsWithProgress(params) {
|
|
30
|
+
const { container, progressJobId, ids, scope } = params;
|
|
31
|
+
const commandBus = container.resolve("commandBus");
|
|
32
|
+
const progressService = container.resolve("progressService");
|
|
33
|
+
const progressContext = {
|
|
34
|
+
tenantId: scope.tenantId,
|
|
35
|
+
organizationId: scope.organizationId,
|
|
36
|
+
userId: scope.userId
|
|
37
|
+
};
|
|
38
|
+
await progressService.startJob(progressJobId, progressContext);
|
|
39
|
+
await progressService.updateProgress(
|
|
40
|
+
progressJobId,
|
|
41
|
+
{ totalCount: ids.length, processedCount: 0 },
|
|
42
|
+
progressContext
|
|
43
|
+
);
|
|
44
|
+
const commandContext = buildCommandContext(scope, container);
|
|
45
|
+
let affectedCount = 0;
|
|
46
|
+
for (const [index, id] of ids.entries()) {
|
|
47
|
+
await commandBus.execute("catalog.products.delete", {
|
|
48
|
+
input: { body: { id } },
|
|
49
|
+
ctx: commandContext
|
|
50
|
+
});
|
|
51
|
+
affectedCount += 1;
|
|
52
|
+
await progressService.updateProgress(
|
|
53
|
+
progressJobId,
|
|
54
|
+
{
|
|
55
|
+
totalCount: ids.length,
|
|
56
|
+
processedCount: index + 1
|
|
57
|
+
},
|
|
58
|
+
progressContext
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const summary = { affectedCount };
|
|
62
|
+
await progressService.completeJob(progressJobId, { resultSummary: summary }, progressContext);
|
|
63
|
+
return summary;
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
CATALOG_PRODUCT_BULK_DELETE_QUEUE,
|
|
67
|
+
deleteCatalogProductsWithProgress,
|
|
68
|
+
getCatalogQueue
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=bulkDelete.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/catalog/lib/bulkDelete.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AwilixContainer } from 'awilix'\nimport type { CommandBus, CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { createQueue, type Queue } from '@open-mercato/queue'\nimport { getRedisUrl } from '@open-mercato/shared/lib/redis/connection'\nimport type { ProgressService, ProgressServiceContext } from '../../progress/lib/progressService'\n\nexport const CATALOG_PRODUCT_BULK_DELETE_QUEUE = 'catalog-product-bulk-delete'\n\nconst queues = new Map<string, Queue<Record<string, unknown>>>()\n\nexport type CatalogProductBulkDeleteScope = {\n organizationId: string\n tenantId: string\n userId?: string | null\n}\n\nexport type CatalogProductBulkDeleteJobPayload = {\n progressJobId: string\n ids: string[]\n scope: CatalogProductBulkDeleteScope\n}\n\nexport type CatalogProductBulkDeleteSummary = {\n affectedCount: number\n}\n\nexport function getCatalogQueue(queueName: string): Queue<Record<string, unknown>> {\n const existing = queues.get(queueName)\n if (existing) return existing\n\n const created = process.env.QUEUE_STRATEGY === 'async'\n ? createQueue<Record<string, unknown>>(queueName, 'async', {\n connection: { url: getRedisUrl('QUEUE') },\n concurrency: Math.max(1, Number.parseInt(process.env.CATALOG_QUEUE_CONCURRENCY ?? '3', 10) || 3),\n })\n : createQueue<Record<string, unknown>>(queueName, 'local')\n\n queues.set(queueName, created)\n return created\n}\n\nfunction buildCommandContext(\n scope: CatalogProductBulkDeleteScope,\n container: AwilixContainer,\n): CommandRuntimeContext {\n return {\n container,\n auth: null,\n organizationScope: {\n selectedId: scope.organizationId,\n filterIds: [scope.organizationId],\n allowedIds: [scope.organizationId],\n tenantId: scope.tenantId,\n },\n selectedOrganizationId: scope.organizationId,\n organizationIds: [scope.organizationId],\n }\n}\n\nexport async function deleteCatalogProductsWithProgress(params: {\n container: AwilixContainer\n progressJobId: string\n ids: string[]\n scope: CatalogProductBulkDeleteScope\n}): Promise<CatalogProductBulkDeleteSummary> {\n const { container, progressJobId, ids, scope } = params\n const commandBus = container.resolve('commandBus') as CommandBus\n const progressService = container.resolve('progressService') as ProgressService\n const progressContext: ProgressServiceContext = {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n userId: scope.userId,\n }\n\n await progressService.startJob(progressJobId, progressContext)\n await progressService.updateProgress(\n progressJobId,\n { totalCount: ids.length, processedCount: 0 },\n progressContext,\n )\n\n const commandContext = buildCommandContext(scope, container)\n let affectedCount = 0\n\n for (const [index, id] of ids.entries()) {\n await commandBus.execute<{ body?: Record<string, unknown> }, { productId: string }>('catalog.products.delete', {\n input: { body: { id } },\n ctx: commandContext,\n })\n affectedCount += 1\n\n await progressService.updateProgress(\n progressJobId,\n {\n totalCount: ids.length,\n processedCount: index + 1,\n },\n progressContext,\n )\n }\n\n const summary: CatalogProductBulkDeleteSummary = { affectedCount }\n await progressService.completeJob(progressJobId, { resultSummary: summary }, progressContext)\n\n return summary\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,mBAA+B;AACxC,SAAS,mBAAmB;AAGrB,MAAM,oCAAoC;AAEjD,MAAM,SAAS,oBAAI,IAA4C;AAkBxD,SAAS,gBAAgB,WAAmD;AACjF,QAAM,WAAW,OAAO,IAAI,SAAS;AACrC,MAAI,SAAU,QAAO;AAErB,QAAM,UAAU,QAAQ,IAAI,mBAAmB,UAC3C,YAAqC,WAAW,SAAS;AAAA,IACzD,YAAY,EAAE,KAAK,YAAY,OAAO,EAAE;AAAA,IACxC,aAAa,KAAK,IAAI,GAAG,OAAO,SAAS,QAAQ,IAAI,6BAA6B,KAAK,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2C,EAAE,cAAc;AACjE,QAAM,gBAAgB,YAAY,eAAe,EAAE,eAAe,QAAQ,GAAG,eAAe;AAE5F,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
2
|
+
import { fetchCrudList } from "@open-mercato/ui/backend/utils/crud";
|
|
3
|
+
function readRowId(row) {
|
|
4
|
+
if (!row || typeof row !== "object") return null;
|
|
5
|
+
const value = row.id;
|
|
6
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
7
|
+
}
|
|
8
|
+
function buildListParams(context) {
|
|
9
|
+
const params = { pageSize: "100" };
|
|
10
|
+
const injectionContext = context.injectionContext;
|
|
11
|
+
const search = typeof injectionContext?.search === "string" ? injectionContext.search.trim() : "";
|
|
12
|
+
if (search) params.search = search;
|
|
13
|
+
const sorting = Array.isArray(injectionContext?.sorting) ? injectionContext.sorting : [];
|
|
14
|
+
const sort = sorting[0];
|
|
15
|
+
if (sort?.id) {
|
|
16
|
+
params.sortField = sort.id;
|
|
17
|
+
params.sortDir = sort.desc ? "desc" : "asc";
|
|
18
|
+
}
|
|
19
|
+
const filters = injectionContext?.filters;
|
|
20
|
+
if (filters && typeof filters === "object") {
|
|
21
|
+
const status = typeof filters.status === "string" ? filters.status.trim() : "";
|
|
22
|
+
if (status) params.status = status;
|
|
23
|
+
if (filters.isActive === true) params.isActive = "true";
|
|
24
|
+
if (filters.isActive === false) params.isActive = "false";
|
|
25
|
+
if (filters.configurable === true) params.configurable = "true";
|
|
26
|
+
if (filters.configurable === false) params.configurable = "false";
|
|
27
|
+
const productType = typeof filters.productType === "string" ? filters.productType.trim() : "";
|
|
28
|
+
if (productType) params.productType = productType;
|
|
29
|
+
const listFilters = [
|
|
30
|
+
["channelIds", filters.channelIds],
|
|
31
|
+
["categoryIds", filters.categoryIds],
|
|
32
|
+
["tagIds", filters.tagIds]
|
|
33
|
+
];
|
|
34
|
+
for (const [key, value] of listFilters) {
|
|
35
|
+
if (!Array.isArray(value) || value.length === 0) continue;
|
|
36
|
+
const normalized = value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
37
|
+
if (normalized.length > 0) params[key] = normalized.join(",");
|
|
38
|
+
}
|
|
39
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
40
|
+
if (!key.startsWith("cf_") || value == null) continue;
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
const normalized = value.map((entry) => typeof entry === "string" ? entry.trim() : String(entry ?? "").trim()).filter((entry) => entry.length > 0);
|
|
43
|
+
if (normalized.length > 0) params[key] = normalized.join(",");
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (typeof value === "object" && value !== null && ("from" in value || "to" in value)) {
|
|
47
|
+
const range = value;
|
|
48
|
+
if (typeof range.from === "string" && range.from.trim().length > 0) {
|
|
49
|
+
params[`${key}:from`] = range.from.trim();
|
|
50
|
+
}
|
|
51
|
+
if (typeof range.to === "string" && range.to.trim().length > 0) {
|
|
52
|
+
params[`${key}:to`] = range.to.trim();
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
57
|
+
params[key] = value.trim();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const customFieldset = typeof injectionContext?.customFieldset === "string" ? injectionContext.customFieldset.trim() : "";
|
|
62
|
+
if (customFieldset) params.customFieldset = customFieldset;
|
|
63
|
+
return params;
|
|
64
|
+
}
|
|
65
|
+
async function fetchFilteredProductIds(context) {
|
|
66
|
+
const baseParams = buildListParams(context);
|
|
67
|
+
const productIds = /* @__PURE__ */ new Set();
|
|
68
|
+
let page = 1;
|
|
69
|
+
let totalPages = 1;
|
|
70
|
+
while (page <= totalPages) {
|
|
71
|
+
const payload = await fetchCrudList("catalog/products", {
|
|
72
|
+
...baseParams,
|
|
73
|
+
page
|
|
74
|
+
});
|
|
75
|
+
for (const item of payload.items) {
|
|
76
|
+
if (typeof item?.id === "string" && item.id.length > 0) {
|
|
77
|
+
productIds.add(item.id);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
totalPages = typeof payload.totalPages === "number" && payload.totalPages > 0 ? payload.totalPages : 1;
|
|
81
|
+
page += 1;
|
|
82
|
+
}
|
|
83
|
+
return Array.from(productIds);
|
|
84
|
+
}
|
|
85
|
+
async function startDeleteProductsJob(ids, scope, context) {
|
|
86
|
+
const translate = context.translate ?? ((_, fallback) => fallback);
|
|
87
|
+
const result = await apiCall(
|
|
88
|
+
"/api/catalog/bulk-delete",
|
|
89
|
+
{
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: { "content-type": "application/json" },
|
|
92
|
+
body: JSON.stringify({
|
|
93
|
+
confirm: true,
|
|
94
|
+
ids,
|
|
95
|
+
scope
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
if (!result.ok || !result.result?.progressJobId) {
|
|
100
|
+
throw new Error(translate("catalog.bulkDelete.error", "Failed to delete products."));
|
|
101
|
+
}
|
|
102
|
+
return result.result.progressJobId;
|
|
103
|
+
}
|
|
104
|
+
const widget = {
|
|
105
|
+
metadata: {
|
|
106
|
+
id: "catalog.injection.product-bulk-delete",
|
|
107
|
+
priority: 40
|
|
108
|
+
},
|
|
109
|
+
bulkActions: [
|
|
110
|
+
{
|
|
111
|
+
id: "catalog.products.bulk-delete-selected",
|
|
112
|
+
label: "catalog.bulkDelete.selected.label",
|
|
113
|
+
icon: "trash-2",
|
|
114
|
+
onExecute: async (selectedRows, rawContext) => {
|
|
115
|
+
const context = rawContext ?? {};
|
|
116
|
+
const translate = context.translate ?? ((_, fallback) => fallback);
|
|
117
|
+
const ids = selectedRows.map((row) => readRowId(row)).filter((id) => typeof id === "string" && id.length > 0);
|
|
118
|
+
if (ids.length === 0) {
|
|
119
|
+
return {
|
|
120
|
+
ok: false,
|
|
121
|
+
message: translate("catalog.bulkDelete.noneSelected", "Select at least one product to delete.")
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const confirmed = await context.confirm?.({
|
|
125
|
+
title: translate("catalog.bulkDelete.selected.confirmTitle", "Delete selected products?"),
|
|
126
|
+
text: translate(
|
|
127
|
+
"catalog.bulkDelete.selected.confirmText",
|
|
128
|
+
"Delete {count} selected products? This cannot be undone.",
|
|
129
|
+
{ count: ids.length }
|
|
130
|
+
),
|
|
131
|
+
confirmText: translate("catalog.bulkDelete.confirm", "Delete"),
|
|
132
|
+
cancelText: translate("common.cancel", "Cancel"),
|
|
133
|
+
variant: "destructive"
|
|
134
|
+
});
|
|
135
|
+
if (confirmed === false) {
|
|
136
|
+
return { ok: false, message: void 0 };
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
ok: true,
|
|
140
|
+
progressJobId: await startDeleteProductsJob(ids, "selected", context)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "catalog.products.bulk-delete-filtered",
|
|
146
|
+
label: "catalog.bulkDelete.filtered.label",
|
|
147
|
+
icon: "filter-x",
|
|
148
|
+
requiresSelection: false,
|
|
149
|
+
onExecute: async (_selectedRows, rawContext) => {
|
|
150
|
+
const context = rawContext ?? {};
|
|
151
|
+
const translate = context.translate ?? ((_, fallback) => fallback);
|
|
152
|
+
const ids = await fetchFilteredProductIds(context);
|
|
153
|
+
if (ids.length === 0) {
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
message: translate("catalog.bulkDelete.noneFiltered", "No products match the current filters.")
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const confirmed = await context.confirm?.({
|
|
160
|
+
title: translate("catalog.bulkDelete.filtered.confirmTitle", "Delete filtered products?"),
|
|
161
|
+
text: translate(
|
|
162
|
+
"catalog.bulkDelete.filtered.confirmText",
|
|
163
|
+
"Delete {count} products matching the current filters? This cannot be undone.",
|
|
164
|
+
{ count: ids.length }
|
|
165
|
+
),
|
|
166
|
+
confirmText: translate("catalog.bulkDelete.confirm", "Delete"),
|
|
167
|
+
cancelText: translate("common.cancel", "Cancel"),
|
|
168
|
+
variant: "destructive"
|
|
169
|
+
});
|
|
170
|
+
if (confirmed === false) {
|
|
171
|
+
return { ok: false, message: void 0 };
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
ok: true,
|
|
175
|
+
progressJobId: await startDeleteProductsJob(ids, "filtered", context)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
var widget_default = widget;
|
|
182
|
+
export {
|
|
183
|
+
widget_default as default
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=widget.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/catalog/widgets/injection/product-bulk-delete/widget.ts"],
|
|
4
|
+
"sourcesContent": ["import type { InjectionBulkActionWidget } from '@open-mercato/shared/modules/widgets/injection'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { fetchCrudList } from '@open-mercato/ui/backend/utils/crud'\nimport type { FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport type { SortingState } from '@tanstack/react-table'\n\ntype ProductRow = {\n id: string\n}\n\ntype BulkActionContext = {\n confirm?: (options?: {\n title?: string\n text?: string\n confirmText?: string | false\n cancelText?: string | false\n variant?: 'default' | 'destructive'\n }) => Promise<boolean>\n injectionContext?: {\n search?: string\n filters?: FilterValues\n customFieldset?: string | null\n sorting?: SortingState\n }\n translate?: (key: string, fallback: string, params?: Record<string, string | number>) => string\n}\n\nfunction readRowId(row: unknown): string | null {\n if (!row || typeof row !== 'object') return null\n const value = (row as Record<string, unknown>).id\n return typeof value === 'string' && value.length > 0 ? value : null\n}\n\nfunction buildListParams(context: BulkActionContext): Record<string, string> {\n const params: Record<string, string> = { pageSize: '100' }\n const injectionContext = context.injectionContext\n const search = typeof injectionContext?.search === 'string' ? injectionContext.search.trim() : ''\n if (search) params.search = search\n\n const sorting = Array.isArray(injectionContext?.sorting) ? injectionContext.sorting : []\n const sort = sorting[0]\n if (sort?.id) {\n params.sortField = sort.id\n params.sortDir = sort.desc ? 'desc' : 'asc'\n }\n\n const filters = injectionContext?.filters\n if (filters && typeof filters === 'object') {\n const status = typeof filters.status === 'string' ? filters.status.trim() : ''\n if (status) params.status = status\n\n if (filters.isActive === true) params.isActive = 'true'\n if (filters.isActive === false) params.isActive = 'false'\n if (filters.configurable === true) params.configurable = 'true'\n if (filters.configurable === false) params.configurable = 'false'\n\n const productType = typeof filters.productType === 'string' ? filters.productType.trim() : ''\n if (productType) params.productType = productType\n\n const listFilters: Array<[string, unknown]> = [\n ['channelIds', filters.channelIds],\n ['categoryIds', filters.categoryIds],\n ['tagIds', filters.tagIds],\n ]\n for (const [key, value] of listFilters) {\n if (!Array.isArray(value) || value.length === 0) continue\n const normalized = value\n .map((entry) => (typeof entry === 'string' ? entry.trim() : ''))\n .filter((entry): entry is string => entry.length > 0)\n if (normalized.length > 0) params[key] = normalized.join(',')\n }\n\n for (const [key, value] of Object.entries(filters)) {\n if (!key.startsWith('cf_') || value == null) continue\n if (Array.isArray(value)) {\n const normalized = value\n .map((entry) => (typeof entry === 'string' ? entry.trim() : String(entry ?? '').trim()))\n .filter((entry) => entry.length > 0)\n if (normalized.length > 0) params[key] = normalized.join(',')\n continue\n }\n if (typeof value === 'object' && value !== null && ('from' in value || 'to' in value)) {\n const range = value as { from?: string; to?: string }\n if (typeof range.from === 'string' && range.from.trim().length > 0) {\n params[`${key}:from`] = range.from.trim()\n }\n if (typeof range.to === 'string' && range.to.trim().length > 0) {\n params[`${key}:to`] = range.to.trim()\n }\n continue\n }\n if (typeof value === 'string' && value.trim().length > 0) {\n params[key] = value.trim()\n }\n }\n }\n\n const customFieldset =\n typeof injectionContext?.customFieldset === 'string' ? injectionContext.customFieldset.trim() : ''\n if (customFieldset) params.customFieldset = customFieldset\n\n return params\n}\n\nasync function fetchFilteredProductIds(context: BulkActionContext): Promise<string[]> {\n const baseParams = buildListParams(context)\n const productIds = new Set<string>()\n let page = 1\n let totalPages = 1\n\n while (page <= totalPages) {\n const payload = await fetchCrudList<ProductRow>('catalog/products', {\n ...baseParams,\n page,\n })\n for (const item of payload.items) {\n if (typeof item?.id === 'string' && item.id.length > 0) {\n productIds.add(item.id)\n }\n }\n totalPages = typeof payload.totalPages === 'number' && payload.totalPages > 0 ? payload.totalPages : 1\n page += 1\n }\n\n return Array.from(productIds)\n}\n\nasync function startDeleteProductsJob(\n ids: string[],\n scope: 'selected' | 'filtered',\n context: BulkActionContext,\n): Promise<string> {\n const translate = context.translate ?? ((_: string, fallback: string) => fallback)\n const result = await apiCall<{ ok: boolean; progressJobId: string | null }>(\n '/api/catalog/bulk-delete',\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n confirm: true,\n ids,\n scope,\n }),\n },\n )\n\n if (!result.ok || !result.result?.progressJobId) {\n throw new Error(translate('catalog.bulkDelete.error', 'Failed to delete products.'))\n }\n\n return result.result.progressJobId\n}\n\nconst widget: InjectionBulkActionWidget = {\n metadata: {\n id: 'catalog.injection.product-bulk-delete',\n priority: 40,\n },\n bulkActions: [\n {\n id: 'catalog.products.bulk-delete-selected',\n label: 'catalog.bulkDelete.selected.label',\n icon: 'trash-2',\n onExecute: async (selectedRows, rawContext) => {\n const context = (rawContext ?? {}) as BulkActionContext\n const translate = context.translate ?? ((_: string, fallback: string) => fallback)\n const ids = selectedRows\n .map((row) => readRowId(row))\n .filter((id): id is string => typeof id === 'string' && id.length > 0)\n\n if (ids.length === 0) {\n return {\n ok: false,\n message: translate('catalog.bulkDelete.noneSelected', 'Select at least one product to delete.'),\n }\n }\n\n const confirmed = await context.confirm?.({\n title: translate('catalog.bulkDelete.selected.confirmTitle', 'Delete selected products?'),\n text: translate(\n 'catalog.bulkDelete.selected.confirmText',\n 'Delete {count} selected products? This cannot be undone.',\n { count: ids.length },\n ),\n confirmText: translate('catalog.bulkDelete.confirm', 'Delete'),\n cancelText: translate('common.cancel', 'Cancel'),\n variant: 'destructive',\n })\n\n if (confirmed === false) {\n return { ok: false, message: undefined }\n }\n\n return {\n ok: true,\n progressJobId: await startDeleteProductsJob(ids, 'selected', context),\n }\n },\n },\n {\n id: 'catalog.products.bulk-delete-filtered',\n label: 'catalog.bulkDelete.filtered.label',\n icon: 'filter-x',\n requiresSelection: false,\n onExecute: async (_selectedRows, rawContext) => {\n const context = (rawContext ?? {}) as BulkActionContext\n const translate = context.translate ?? ((_: string, fallback: string) => fallback)\n const ids = await fetchFilteredProductIds(context)\n\n if (ids.length === 0) {\n return {\n ok: false,\n message: translate('catalog.bulkDelete.noneFiltered', 'No products match the current filters.'),\n }\n }\n\n const confirmed = await context.confirm?.({\n title: translate('catalog.bulkDelete.filtered.confirmTitle', 'Delete filtered products?'),\n text: translate(\n 'catalog.bulkDelete.filtered.confirmText',\n 'Delete {count} products matching the current filters? This cannot be undone.',\n { count: ids.length },\n ),\n confirmText: translate('catalog.bulkDelete.confirm', 'Delete'),\n cancelText: translate('common.cancel', 'Cancel'),\n variant: 'destructive',\n })\n\n if (confirmed === false) {\n return { ok: false, message: undefined }\n }\n\n return {\n ok: true,\n progressJobId: await startDeleteProductsJob(ids, 'filtered', context),\n }\n },\n },\n ],\n}\n\nexport default widget\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAyB9B,SAAS,UAAU,KAA6B;AAC9C,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,QAAM,QAAS,IAAgC;AAC/C,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAEA,SAAS,gBAAgB,SAAoD;AAC3E,QAAM,SAAiC,EAAE,UAAU,MAAM;AACzD,QAAM,mBAAmB,QA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A,QACzC;AAEA,eAAO;AAAA,UACL,IAAI;AAAA,UACJ,eAAe,MAAM,uBAAuB,KAAK,YAAY,OAAO;AAAA,QACtE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,iBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -11,7 +11,15 @@ const injectionTable = {
|
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
13
|
// Fallback alias when forms derive spot id from entity id
|
|
14
|
-
"crud-form:catalog.catalog_product": "catalog.injection.product-seo"
|
|
14
|
+
"crud-form:catalog.catalog_product": "catalog.injection.product-seo",
|
|
15
|
+
"data-table:catalog.products:bulk-actions": {
|
|
16
|
+
widgetId: "catalog.injection.product-bulk-delete",
|
|
17
|
+
priority: 40
|
|
18
|
+
},
|
|
19
|
+
"data-table:catalog.products.list:bulk-actions": {
|
|
20
|
+
widgetId: "catalog.injection.product-bulk-delete",
|
|
21
|
+
priority: 40
|
|
22
|
+
}
|
|
15
23
|
};
|
|
16
24
|
var injection_table_default = injectionTable;
|
|
17
25
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/catalog/widgets/injection-table.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ModuleInjectionTable } from '@open-mercato/shared/modules/widgets/injection'\n\n/**\n * Catalog module injection table\n * Maps injection spot IDs to widget IDs for automatic widget injection\n */\nexport const injectionTable: ModuleInjectionTable = {\n // Inject the SEO helper widget into the catalog product CRUD form\n 'crud-form:catalog.product': [\n {\n widgetId: 'catalog.injection.product-seo',\n kind: 'group',\n column: 2,\n groupLabel: 'catalog.widgets.productSeo.groupLabel',\n groupDescription: 'catalog.widgets.productSeo.groupDescription',\n priority: 50,\n },\n ],\n // Fallback alias when forms derive spot id from entity id\n 'crud-form:catalog.catalog_product': 'catalog.injection.product-seo',\n}\n\nexport default injectionTable\n"],
|
|
5
|
-
"mappings": "AAMO,MAAM,iBAAuC;AAAA;AAAA,EAElD,6BAA6B;AAAA,IAC3B;AAAA,MACE,UAAU;AAAA,MACV,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA;AAAA,EAEA,qCAAqC;
|
|
4
|
+
"sourcesContent": ["import type { ModuleInjectionTable } from '@open-mercato/shared/modules/widgets/injection'\n\n/**\n * Catalog module injection table\n * Maps injection spot IDs to widget IDs for automatic widget injection\n */\nexport const injectionTable: ModuleInjectionTable = {\n // Inject the SEO helper widget into the catalog product CRUD form\n 'crud-form:catalog.product': [\n {\n widgetId: 'catalog.injection.product-seo',\n kind: 'group',\n column: 2,\n groupLabel: 'catalog.widgets.productSeo.groupLabel',\n groupDescription: 'catalog.widgets.productSeo.groupDescription',\n priority: 50,\n },\n ],\n // Fallback alias when forms derive spot id from entity id\n 'crud-form:catalog.catalog_product': 'catalog.injection.product-seo',\n 'data-table:catalog.products:bulk-actions': {\n widgetId: 'catalog.injection.product-bulk-delete',\n priority: 40,\n },\n 'data-table:catalog.products.list:bulk-actions': {\n widgetId: 'catalog.injection.product-bulk-delete',\n priority: 40,\n },\n}\n\nexport default injectionTable\n"],
|
|
5
|
+
"mappings": "AAMO,MAAM,iBAAuC;AAAA;AAAA,EAElD,6BAA6B;AAAA,IAC3B;AAAA,MACE,UAAU;AAAA,MACV,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,kBAAkB;AAAA,MAClB,UAAU;AAAA,IACZ;AAAA,EACF;AAAA;AAAA,EAEA,qCAAqC;AAAA,EACrC,4CAA4C;AAAA,IAC1C,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA,iDAAiD;AAAA,IAC/C,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AACF;AAEA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
2
|
+
import {
|
|
3
|
+
CATALOG_PRODUCT_BULK_DELETE_QUEUE,
|
|
4
|
+
deleteCatalogProductsWithProgress
|
|
5
|
+
} from "../lib/bulkDelete.js";
|
|
6
|
+
const metadata = {
|
|
7
|
+
queue: CATALOG_PRODUCT_BULK_DELETE_QUEUE,
|
|
8
|
+
id: "catalog:product-bulk-delete",
|
|
9
|
+
concurrency: 1
|
|
10
|
+
};
|
|
11
|
+
async function handle(job, _ctx) {
|
|
12
|
+
const container = await createRequestContainer();
|
|
13
|
+
try {
|
|
14
|
+
await deleteCatalogProductsWithProgress({
|
|
15
|
+
container,
|
|
16
|
+
progressJobId: job.payload.progressJobId,
|
|
17
|
+
ids: job.payload.ids,
|
|
18
|
+
scope: job.payload.scope
|
|
19
|
+
});
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const progressService = container.resolve("progressService");
|
|
22
|
+
await progressService.failJob(
|
|
23
|
+
job.payload.progressJobId,
|
|
24
|
+
{
|
|
25
|
+
errorMessage: error instanceof Error ? error.message : "Bulk product deletion failed"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
tenantId: job.payload.scope.tenantId,
|
|
29
|
+
organizationId: job.payload.scope.organizationId,
|
|
30
|
+
userId: job.payload.scope.userId
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
handle as default,
|
|
38
|
+
metadata
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=catalog-product-bulk-delete.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/catalog/workers/catalog-product-bulk-delete.ts"],
|
|
4
|
+
"sourcesContent": ["import type { JobContext, QueuedJob, WorkerMeta } from '@open-mercato/queue'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { ProgressService } from '../../progress/lib/progressService'\nimport {\n CATALOG_PRODUCT_BULK_DELETE_QUEUE,\n deleteCatalogProductsWithProgress,\n type CatalogProductBulkDeleteJobPayload,\n} from '../lib/bulkDelete'\n\ntype HandlerContext = JobContext & {\n resolve: <T = unknown>(name: string) => T\n}\n\nexport const metadata: WorkerMeta = {\n queue: CATALOG_PRODUCT_BULK_DELETE_QUEUE,\n id: 'catalog:product-bulk-delete',\n concurrency: 1,\n}\n\nexport default async function handle(\n job: QueuedJob<CatalogProductBulkDeleteJobPayload>,\n _ctx: HandlerContext,\n): Promise<void> {\n const container = await createRequestContainer()\n\n try {\n await deleteCatalogProductsWithProgress({\n container,\n progressJobId: job.payload.progressJobId,\n ids: job.payload.ids,\n scope: job.payload.scope,\n })\n } catch (error) {\n const progressService = container.resolve('progressService') as ProgressService\n await progressService.failJob(\n job.payload.progressJobId,\n {\n errorMessage: error instanceof Error ? error.message : 'Bulk product deletion failed',\n },\n {\n tenantId: job.payload.scope.tenantId,\n organizationId: job.payload.scope.organizationId,\n userId: job.payload.scope.userId,\n },\n )\n throw error\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,8BAA8B;AAEvC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAMA,MAAM,WAAuB;AAAA,EAClC,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,aAAa;AACf;AAEA,eAAO,OACL,KACA,MACe;AACf,QAAM,YAAY,MAAM,uBAAuB;AAE/C,MAAI;AACF,UAAM,kCAAkC;AAAA,MACtC;AAAA,MACA,eAAe,IAAI,QAAQ;AAAA,MAC3B,KAAK,IAAI,QAAQ;AAAA,MACjB,OAAO,IAAI,QAAQ;AAAA,IACrB,CAAC;AAAA,EACH,SAAS,OAAO;AACd,UAAM,kBAAkB,UAAU,QAAQ,iBAAiB;AAC3D,UAAM,gBAAgB;AAAA,MACpB,IAAI,QAAQ;AAAA,MACZ;AAAA,QACE,cAAc,iBAAiB,QAAQ,MAAM,UAAU;AAAA,MACzD;AAAA,MACA;AAAA,QACE,UAAU,IAAI,QAAQ,MAAM;AAAA,QAC5B,gBAAgB,IAAI,QAAQ,MAAM;AAAA,QAClC,QAAQ,IAAI,QAAQ,MAAM;AAAA,MAC5B;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|