@open-mercato/core 0.4.6-develop-e321a4e2a1 → 0.4.6-main-24e64eef39
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 +0 -22
- package/dist/modules/api_docs/frontend/docs/api/page.js +1 -1
- package/dist/modules/api_docs/frontend/docs/api/page.js.map +2 -2
- package/dist/modules/attachments/api/library/[id]/route.js +1 -0
- package/dist/modules/attachments/api/library/[id]/route.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentLibrary.js +1 -1
- package/dist/modules/attachments/components/AttachmentLibrary.js.map +2 -2
- package/dist/modules/attachments/lib/partitionEnv.js +1 -1
- package/dist/modules/attachments/lib/partitionEnv.js.map +2 -2
- package/dist/modules/auth/backend/users/page.js +1 -1
- package/dist/modules/auth/backend/users/page.js.map +2 -2
- package/dist/modules/auth/cli.js +1 -1
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/commands/users.js +1 -1
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/business_rules/components/utils/formHelpers.js +1 -1
- package/dist/modules/business_rules/components/utils/formHelpers.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +1 -1
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +1 -1
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/shared.js +1 -1
- package/dist/modules/catalog/commands/shared.js.map +2 -2
- package/dist/modules/catalog/components/PriceKindSettings.js +1 -1
- package/dist/modules/catalog/components/PriceKindSettings.js.map +2 -2
- package/dist/modules/catalog/components/products/productForm.js +1 -1
- package/dist/modules/catalog/components/products/productForm.js.map +2 -2
- package/dist/modules/configs/lib/upgrade-actions.js.map +1 -1
- package/dist/modules/currencies/services/providers/raiffeisen.js +1 -1
- package/dist/modules/currencies/services/providers/raiffeisen.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies/page.js +3 -3
- package/dist/modules/customers/backend/customers/companies/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/page.js +3 -3
- package/dist/modules/customers/backend/customers/deals/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people/page.js +3 -3
- package/dist/modules/customers/backend/customers/people/page.js.map +2 -2
- package/dist/modules/customers/cli.js +2 -2
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/lib/detailHelpers.js +1 -1
- package/dist/modules/customers/lib/detailHelpers.js.map +2 -2
- package/dist/modules/entities/cli.js +1 -1
- package/dist/modules/entities/cli.js.map +2 -2
- package/dist/modules/entities/lib/field-definitions.js +1 -1
- package/dist/modules/entities/lib/field-definitions.js.map +2 -2
- package/dist/modules/entities/lib/install-from-ce.js +1 -1
- package/dist/modules/entities/lib/install-from-ce.js.map +2 -2
- package/dist/modules/inbox_ops/lib/emailParser.js +1 -1
- package/dist/modules/inbox_ops/lib/emailParser.js.map +2 -2
- package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js +0 -8
- package/dist/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.js.map +2 -2
- package/dist/modules/perspectives/services/perspectiveService.js +1 -1
- package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js +3 -3
- package/dist/modules/planner/backend/planner/availability-rulesets/page.js.map +2 -2
- package/dist/modules/query_index/components/QueryIndexesTable.js +7 -7
- package/dist/modules/query_index/components/QueryIndexesTable.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +1 -1
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js +2 -2
- package/dist/modules/resources/backend/resources/resource-types/page.js.map +2 -2
- package/dist/modules/resources/backend/resources/resources/page.js +3 -3
- package/dist/modules/resources/backend/resources/resources/page.js.map +2 -2
- package/dist/modules/resources/commands/resources.js +1 -1
- package/dist/modules/resources/commands/resources.js.map +2 -2
- package/dist/modules/resources/lib/seeds.js +1 -1
- package/dist/modules/resources/lib/seeds.js.map +2 -2
- package/dist/modules/sales/api/dashboard/widgets/new-orders/route.js +1 -1
- package/dist/modules/sales/api/dashboard/widgets/new-orders/route.js.map +2 -2
- package/dist/modules/sales/api/dashboard/widgets/new-quotes/route.js +1 -1
- package/dist/modules/sales/api/dashboard/widgets/new-quotes/route.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.js +3 -3
- package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +2 -2
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/components/channels/offerTableUtils.js +2 -3
- package/dist/modules/sales/components/channels/offerTableUtils.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js +4 -4
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js +1 -1
- package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
- package/dist/modules/sales/lib/shipments/snapshots.js.map +1 -1
- package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js +0 -8
- package/dist/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.js.map +2 -2
- package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js +0 -8
- package/dist/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.js.map +2 -2
- package/dist/modules/staff/backend/staff/leave-requests/page.js +3 -3
- package/dist/modules/staff/backend/staff/leave-requests/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/my-leave-requests/page.js +3 -3
- package/dist/modules/staff/backend/staff/my-leave-requests/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/page.js +3 -3
- package/dist/modules/staff/backend/staff/team-members/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js +2 -2
- package/dist/modules/staff/backend/staff/team-roles/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +3 -3
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/page.js +2 -2
- package/dist/modules/staff/backend/staff/teams/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/page.js +2 -2
- package/dist/modules/workflows/backend/instances/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/page.js +1 -1
- package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js +1 -1
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +2 -2
- package/dist/modules/workflows/lib/graph-utils.js +1 -1
- package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
- package/package.json +2 -2
- package/src/modules/api_docs/frontend/docs/api/page.tsx +1 -1
- package/src/modules/attachments/api/library/[id]/route.ts +1 -0
- package/src/modules/attachments/components/AttachmentLibrary.tsx +1 -1
- package/src/modules/attachments/lib/partitionEnv.ts +1 -1
- package/src/modules/auth/backend/users/page.tsx +1 -1
- package/src/modules/auth/cli.ts +1 -1
- package/src/modules/auth/commands/users.ts +1 -1
- package/src/modules/business_rules/components/utils/formHelpers.ts +1 -1
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +1 -1
- package/src/modules/catalog/commands/products.ts +1 -1
- package/src/modules/catalog/commands/shared.ts +1 -1
- package/src/modules/catalog/components/PriceKindSettings.tsx +1 -1
- package/src/modules/catalog/components/products/productForm.ts +1 -1
- package/src/modules/configs/lib/upgrade-actions.ts +1 -1
- package/src/modules/currencies/services/providers/raiffeisen.ts +1 -1
- package/src/modules/customers/backend/customers/companies/page.tsx +3 -3
- package/src/modules/customers/backend/customers/deals/page.tsx +3 -3
- package/src/modules/customers/backend/customers/people/page.tsx +3 -3
- package/src/modules/customers/cli.ts +2 -2
- package/src/modules/customers/lib/detailHelpers.ts +1 -1
- package/src/modules/entities/cli.ts +1 -1
- package/src/modules/entities/lib/field-definitions.ts +1 -1
- package/src/modules/entities/lib/install-from-ce.ts +1 -1
- package/src/modules/inbox_ops/lib/emailParser.ts +1 -1
- package/src/modules/inbox_ops/widgets/notifications/ProposalCreatedRenderer.tsx +0 -8
- package/src/modules/perspectives/services/perspectiveService.ts +1 -1
- package/src/modules/planner/backend/planner/availability-rulesets/page.tsx +4 -3
- package/src/modules/query_index/components/QueryIndexesTable.tsx +7 -7
- package/src/modules/query_index/lib/engine.ts +1 -1
- package/src/modules/resources/backend/resources/resource-types/page.tsx +3 -2
- package/src/modules/resources/backend/resources/resources/page.tsx +3 -3
- package/src/modules/resources/commands/resources.ts +1 -1
- package/src/modules/resources/lib/seeds.ts +1 -1
- package/src/modules/sales/api/dashboard/widgets/new-orders/route.ts +1 -1
- package/src/modules/sales/api/dashboard/widgets/new-quotes/route.ts +1 -1
- package/src/modules/sales/backend/sales/channels/page.tsx +3 -3
- package/src/modules/sales/commands/documents.ts +2 -2
- package/src/modules/sales/components/channels/offerTableUtils.tsx +2 -3
- package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +4 -4
- package/src/modules/sales/components/documents/ShipmentDialog.tsx +1 -1
- package/src/modules/sales/lib/shipments/snapshots.ts +1 -1
- package/src/modules/sales/widgets/notifications/SalesOrderCreatedRenderer.tsx +0 -8
- package/src/modules/sales/widgets/notifications/SalesQuoteCreatedRenderer.tsx +0 -8
- package/src/modules/staff/backend/staff/leave-requests/page.tsx +3 -3
- package/src/modules/staff/backend/staff/my-leave-requests/page.tsx +3 -3
- package/src/modules/staff/backend/staff/team-members/page.tsx +3 -3
- package/src/modules/staff/backend/staff/team-roles/page.tsx +2 -2
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +4 -3
- package/src/modules/staff/backend/staff/teams/page.tsx +3 -2
- package/src/modules/workflows/backend/instances/page.tsx +2 -2
- package/src/modules/workflows/backend/tasks/page.tsx +1 -1
- package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +1 -1
- package/src/modules/workflows/lib/graph-utils.ts +1 -1
- package/dist/modules/integrations/acl.js +0 -8
- package/dist/modules/integrations/acl.js.map +0 -7
- package/dist/modules/integrations/data/enrichers.js +0 -72
- package/dist/modules/integrations/data/enrichers.js.map +0 -7
- package/dist/modules/integrations/data/entities.js +0 -63
- package/dist/modules/integrations/data/entities.js.map +0 -7
- package/dist/modules/integrations/index.js +0 -9
- package/dist/modules/integrations/index.js.map +0 -7
- package/dist/modules/integrations/setup.js +0 -13
- package/dist/modules/integrations/setup.js.map +0 -7
- package/dist/modules/integrations/widgets/injection/external-ids/widget.client.js +0 -69
- package/dist/modules/integrations/widgets/injection/external-ids/widget.client.js.map +0 -7
- package/dist/modules/integrations/widgets/injection-table.js +0 -13
- package/dist/modules/integrations/widgets/injection-table.js.map +0 -7
- package/src/modules/integrations/acl.ts +0 -4
- package/src/modules/integrations/data/enrichers.ts +0 -98
- package/src/modules/integrations/data/entities.ts +0 -46
- package/src/modules/integrations/index.ts +0 -5
- package/src/modules/integrations/setup.ts +0 -11
- package/src/modules/integrations/widgets/injection/external-ids/widget.client.tsx +0 -94
- package/src/modules/integrations/widgets/injection-table.ts +0 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/resources/backend/resources/resource-types/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport Link from 'next/link'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\nimport type { PluggableList } from 'unified'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable, withDataTableNamespaces } from '@open-mercato/ui/backend/DataTable'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { renderDictionaryColor, renderDictionaryIcon } from '@open-mercato/core/modules/dictionaries/components/dictionaryAppearance'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { Package } from 'lucide-react'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { formatDateTime } from '@open-mercato/shared/lib/time'\n\nconst PAGE_SIZE = 50\nconst MARKDOWN_PLUGINS: PluggableList = [remarkGfm]\nconst MARKDOWN_DESCRIPTION_CLASSNAME =\n 'text-sm text-foreground [&>p]:m-0 [&_ul]:ml-4 [&_ul]:list-disc [&_ol]:ml-4 [&_ol]:list-decimal [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5'\nconst MARKDOWN_SUBTEXT_CLASSNAME =\n 'text-xs text-muted-foreground [&>p]:m-0 [&_ul]:ml-4 [&_ul]:list-disc [&_ol]:ml-4 [&_ol]:list-decimal [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5'\n\ntype ResourceTypeRow = {\n id: string\n name: string\n description: string | null\n appearanceIcon: string | null\n appearanceColor: string | null\n updatedAt: string | null\n resourceCount: number\n}\n\ntype ResourceTypesResponse = {\n items?: Array<Record<string, unknown>>\n total?: number\n totalPages?: number\n}\n\nexport default function ResourcesResourceTypesPage() {\n const translate = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const router = useRouter()\n const scopeVersion = useOrganizationScopeVersion()\n const [rows, setRows] = React.useState<ResourceTypeRow[]>([])\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: 'name', desc: false }])\n const [search, setSearch] = React.useState('')\n const [isLoading, setIsLoading] = React.useState(true)\n const [reloadToken, setReloadToken] = React.useState(0)\n\n const translations = React.useMemo(() => ({\n title: translate('resources.resourceTypes.page.title', 'Resource types'),\n description: translate('resources.resourceTypes.page.description', 'Organize shared resources by category.'),\n table: {\n name: translate('resources.resourceTypes.table.name', 'Name'),\n description: translate('resources.resourceTypes.table.description', 'Description'),\n appearance: translate('resources.resourceTypes.table.appearance', 'Appearance'),\n resources: translate('resources.resourceTypes.table.resources', 'Resources'),\n updatedAt: translate('resources.resourceTypes.table.updatedAt', 'Updated'),\n empty: translate('resources.resourceTypes.table.empty', 'No resource types yet.'),\n search: translate('resources.resourceTypes.table.search', 'Search resource types\u2026'),\n },\n actions: {\n add: translate('resources.resourceTypes.actions.add', 'Add resource type'),\n edit: translate('resources.resourceTypes.actions.edit', 'Edit'),\n delete: translate('resources.resourceTypes.actions.delete', 'Delete'),\n deleteConfirm: translate('resources.resourceTypes.actions.deleteConfirm', 'Delete resource type \"{{name}}\"?'),\n showResources: translate('resources.resourceTypes.actions.showResources', 'Show resources ({{count}})'),\n refresh: translate('resources.resourceTypes.actions.refresh', 'Refresh'),\n },\n form: {\n createTitle: translate('resources.resourceTypes.form.createTitle', 'Add resource type'),\n editTitle: translate('resources.resourceTypes.form.editTitle', 'Edit resource type'),\n name: translate('resources.resourceTypes.form.name', 'Name'),\n description: translate('resources.resourceTypes.form.description', 'Description'),\n save: translate('resources.resourceTypes.form.save', 'Save'),\n cancel: translate('resources.resourceTypes.form.cancel', 'Cancel'),\n },\n messages: {\n saved: translate('resources.resourceTypes.messages.saved', 'Resource type saved.'),\n deleted: translate('resources.resourceTypes.messages.deleted', 'Resource type deleted.'),\n },\n errors: {\n load: translate('resources.resourceTypes.errors.load', 'Failed to load resource types.'),\n save: translate('resources.resourceTypes.errors.save', 'Failed to save resource type.'),\n delete: translate('resources.resourceTypes.errors.delete', 'Failed to delete resource type.'),\n deleteAssigned: translate('resources.resourceTypes.errors.deleteAssigned', 'Resource type has assigned resources.'),\n },\n }), [translate])\n\n const columns = React.useMemo<ColumnDef<ResourceTypeRow>[]>(() => [\n {\n accessorKey: 'name',\n header: translations.table.name,\n meta: { priority: 1, sticky: true },\n cell: ({ row }) => (\n <div className=\"flex flex-col\">\n <span className=\"font-medium\">{row.original.name}</span>\n {row.original.description ? (\n <ReactMarkdown remarkPlugins={MARKDOWN_PLUGINS} className={MARKDOWN_SUBTEXT_CLASSNAME}>\n {row.original.description}\n </ReactMarkdown>\n ) : null}\n </div>\n ),\n },\n {\n accessorKey: 'appearance',\n header: translations.table.appearance,\n meta: { priority: 2 },\n cell: ({ row }) => {\n const icon = row.original.appearanceIcon\n const color = row.original.appearanceColor\n if (!icon && !color) {\n return <span className=\"text-xs text-muted-foreground\">\u2014</span>\n }\n return (\n <div className=\"flex items-center gap-2\">\n {color ? renderDictionaryColor(color) : null}\n {icon ? renderDictionaryIcon(icon) : null}\n </div>\n )\n },\n },\n {\n accessorKey: 'resourceCount',\n header: translations.table.resources,\n meta: { priority: 3 },\n cell: ({ row }) => (\n <Link\n className=\"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground\"\n href={`/backend/resources/resources?resourceTypeId=${encodeURIComponent(row.original.id)}`}\n onClick={(event) => event.stopPropagation()}\n >\n <Package className=\"h-4 w-4\" aria-hidden />\n {translations.actions.showResources.replace('{{count}}', String(row.original.resourceCount))}\n </Link>\n ),\n },\n {\n accessorKey: 'description',\n header: translations.table.description,\n meta: { priority: 5 },\n cell: ({ row }) => row.original.description ? (\n <ReactMarkdown remarkPlugins={MARKDOWN_PLUGINS} className={MARKDOWN_DESCRIPTION_CLASSNAME}>\n {row.original.description}\n </ReactMarkdown>\n ) : (\n <span className=\"text-xs text-muted-foreground\">\u2014</span>\n ),\n },\n {\n accessorKey: 'updatedAt',\n header: translations.table.updatedAt,\n meta: { priority: 4 },\n cell: ({ row }) => row.original.updatedAt\n ? <span className=\"text-xs text-muted-foreground\">{formatDateTime(row.original.updatedAt)}</span>\n : <span className=\"text-xs text-muted-foreground\">\u2014</span>,\n },\n ], [\n translations.actions.showResources,\n translations.table.appearance,\n translations.table.description,\n translations.table.name,\n translations.table.resources,\n translations.table.updatedAt,\n ])\n\n const loadResourceTypes = React.useCallback(async () => {\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(PAGE_SIZE),\n })\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 if (search.trim()) {\n params.set('search', search.trim())\n }\n const payload = await readApiResultOrThrow<ResourceTypesResponse>(\n `/api/resources/resource-types?${params.toString()}`,\n undefined,\n { errorMessage: translations.errors.load, fallback: { items: [], total: 0, totalPages: 1 } },\n )\n const items = Array.isArray(payload.items) ? payload.items : []\n setRows(items.map(mapApiResourceType))\n setTotal(typeof payload.total === 'number' ? payload.total : items.length)\n setTotalPages(typeof payload.totalPages === 'number' ? payload.totalPages : Math.max(1, Math.ceil(items.length / PAGE_SIZE)))\n } catch (error) {\n console.error('resources.resource-types.list', error)\n flash(translations.errors.load, 'error')\n } finally {\n setIsLoading(false)\n }\n }, [page, search, sorting, translations.errors.load])\n\n React.useEffect(() => {\n void loadResourceTypes()\n }, [loadResourceTypes, scopeVersion, reloadToken])\n\n const handleSearchChange = React.useCallback((value: string) => {\n setSearch(value)\n setPage(1)\n }, [])\n\n const handleRefresh = React.useCallback(() => {\n setReloadToken((token) => token + 1)\n }, [])\n\n const handleDelete = React.useCallback(async (entry: ResourceTypeRow) => {\n if (entry.resourceCount > 0) {\n flash(translations.errors.deleteAssigned, 'error')\n return\n }\n const message = translations.actions.deleteConfirm.replace('{{name}}', entry.name)\n const confirmed = await confirm({\n title: message,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n await deleteCrud('resources/resource-types', entry.id, { errorMessage: translations.errors.delete })\n flash(translations.messages.deleted, 'success')\n handleRefresh()\n } catch (error) {\n console.error('resources.resource-types.delete', error)\n flash(translations.errors.delete, 'error')\n }\n }, [confirm, handleRefresh, translations.actions.deleteConfirm, translations.errors.delete, translations.errors.deleteAssigned, translations.messages.deleted])\n\n return (\n <Page>\n <PageBody>\n <DataTable<ResourceTypeRow>\n title={translations.title}\n data={rows}\n columns={columns}\n isLoading={isLoading}\n searchValue={search}\n onSearchChange={handleSearchChange}\n searchPlaceholder={translations.table.search}\n emptyState={<p className=\"py-8 text-center text-sm text-muted-foreground\">{translations.table.empty}</p>}\n actions={(\n <Button asChild size=\"sm\">\n <Link href=\"/backend/resources/resource-types/create\">\n {translations.actions.add}\n </Link>\n </Button>\n )}\n refreshButton={{\n label: translations.actions.refresh,\n onRefresh: handleRefresh,\n isRefreshing: isLoading,\n }}\n sortable\n sorting={sorting}\n onSortingChange={setSorting}\n pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, onPageChange: setPage }}\n rowActions={(row) => (\n <RowActions\n items={[\n { id: 'edit', label: translations.actions.edit, href: `/backend/resources/resource-types/${row.id}/edit` },\n ...(row.resourceCount > 0\n ? []\n : [{ id: 'delete', label: translations.actions.delete, destructive: true, onSelect: () => handleDelete(row) }]),\n ]}\n />\n )}\n onRowClick={(row) => router.push(`/backend/resources/resource-types/${row.id}/edit`)}\n perspective={{ tableId: 'resources.resource-types.list' }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n\nfunction mapApiResourceType(item: Record<string, unknown>): ResourceTypeRow {\n const id = typeof item.id === 'string' ? item.id : ''\n const name = typeof item.name === 'string' && item.name.length ? item.name : id\n const description = typeof item.description === 'string' && item.description.length\n ? item.description\n : typeof item.description === 'string'\n ? item.description\n : null\n const appearanceIcon = typeof item.appearanceIcon === 'string'\n ? item.appearanceIcon\n : typeof item.appearance_icon === 'string'\n ? item.appearance_icon\n : null\n const appearanceColor = typeof item.appearanceColor === 'string'\n ? item.appearanceColor\n : typeof item.appearance_color === 'string'\n ? item.appearance_color\n : null\n const updatedAt = typeof item.updatedAt === 'string'\n ? item.updatedAt\n : typeof item.updated_at === 'string'\n ? item.updated_at\n : null\n const resourceCount = typeof item.resourceCount === 'number'\n ? item.resourceCount\n : typeof item.resource_count === 'number'\n ? item.resource_count\n : 0\n return withDataTableNamespaces({ id, name, description, appearanceIcon, appearanceColor, updatedAt, resourceCount }, item)\n}\n\n"],
|
|
5
|
-
"mappings": ";AA0GQ,SACE,KADF;AAxGR,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,OAAO,UAAU;AAGjB,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useRouter } from 'next/navigation'\nimport Link from 'next/link'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\nimport type { PluggableList } from 'unified'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { renderDictionaryColor, renderDictionaryIcon } from '@open-mercato/core/modules/dictionaries/components/dictionaryAppearance'\nimport { useConfirmDialog } from '@open-mercato/ui/backend/confirm-dialog'\nimport { Package } from 'lucide-react'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { formatDateTime } from '@open-mercato/shared/lib/time'\n\nconst PAGE_SIZE = 50\nconst MARKDOWN_PLUGINS: PluggableList = [remarkGfm]\nconst MARKDOWN_DESCRIPTION_CLASSNAME =\n 'text-sm text-foreground [&>p]:m-0 [&_ul]:ml-4 [&_ul]:list-disc [&_ol]:ml-4 [&_ol]:list-decimal [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5'\nconst MARKDOWN_SUBTEXT_CLASSNAME =\n 'text-xs text-muted-foreground [&>p]:m-0 [&_ul]:ml-4 [&_ul]:list-disc [&_ol]:ml-4 [&_ol]:list-decimal [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5'\n\ntype ResourceTypeRow = {\n id: string\n name: string\n description: string | null\n appearanceIcon: string | null\n appearanceColor: string | null\n updatedAt: string | null\n resourceCount: number\n}\n\ntype ResourceTypesResponse = {\n items?: Array<Record<string, unknown>>\n total?: number\n totalPages?: number\n}\n\nexport default function ResourcesResourceTypesPage() {\n const translate = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const router = useRouter()\n const scopeVersion = useOrganizationScopeVersion()\n const [rows, setRows] = React.useState<ResourceTypeRow[]>([])\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: 'name', desc: false }])\n const [search, setSearch] = React.useState('')\n const [isLoading, setIsLoading] = React.useState(true)\n const [reloadToken, setReloadToken] = React.useState(0)\n\n const translations = React.useMemo(() => ({\n title: translate('resources.resourceTypes.page.title', 'Resource types'),\n description: translate('resources.resourceTypes.page.description', 'Organize shared resources by category.'),\n table: {\n name: translate('resources.resourceTypes.table.name', 'Name'),\n description: translate('resources.resourceTypes.table.description', 'Description'),\n appearance: translate('resources.resourceTypes.table.appearance', 'Appearance'),\n resources: translate('resources.resourceTypes.table.resources', 'Resources'),\n updatedAt: translate('resources.resourceTypes.table.updatedAt', 'Updated'),\n empty: translate('resources.resourceTypes.table.empty', 'No resource types yet.'),\n search: translate('resources.resourceTypes.table.search', 'Search resource types\u2026'),\n },\n actions: {\n add: translate('resources.resourceTypes.actions.add', 'Add resource type'),\n edit: translate('resources.resourceTypes.actions.edit', 'Edit'),\n delete: translate('resources.resourceTypes.actions.delete', 'Delete'),\n deleteConfirm: translate('resources.resourceTypes.actions.deleteConfirm', 'Delete resource type \"{{name}}\"?'),\n showResources: translate('resources.resourceTypes.actions.showResources', 'Show resources ({{count}})'),\n refresh: translate('resources.resourceTypes.actions.refresh', 'Refresh'),\n },\n form: {\n createTitle: translate('resources.resourceTypes.form.createTitle', 'Add resource type'),\n editTitle: translate('resources.resourceTypes.form.editTitle', 'Edit resource type'),\n name: translate('resources.resourceTypes.form.name', 'Name'),\n description: translate('resources.resourceTypes.form.description', 'Description'),\n save: translate('resources.resourceTypes.form.save', 'Save'),\n cancel: translate('resources.resourceTypes.form.cancel', 'Cancel'),\n },\n messages: {\n saved: translate('resources.resourceTypes.messages.saved', 'Resource type saved.'),\n deleted: translate('resources.resourceTypes.messages.deleted', 'Resource type deleted.'),\n },\n errors: {\n load: translate('resources.resourceTypes.errors.load', 'Failed to load resource types.'),\n save: translate('resources.resourceTypes.errors.save', 'Failed to save resource type.'),\n delete: translate('resources.resourceTypes.errors.delete', 'Failed to delete resource type.'),\n deleteAssigned: translate('resources.resourceTypes.errors.deleteAssigned', 'Resource type has assigned resources.'),\n },\n }), [translate])\n\n const columns = React.useMemo<ColumnDef<ResourceTypeRow>[]>(() => [\n {\n accessorKey: 'name',\n header: translations.table.name,\n meta: { priority: 1, sticky: true },\n cell: ({ row }) => (\n <div className=\"flex flex-col\">\n <span className=\"font-medium\">{row.original.name}</span>\n {row.original.description ? (\n <ReactMarkdown remarkPlugins={MARKDOWN_PLUGINS} className={MARKDOWN_SUBTEXT_CLASSNAME}>\n {row.original.description}\n </ReactMarkdown>\n ) : null}\n </div>\n ),\n },\n {\n accessorKey: 'appearance',\n header: translations.table.appearance,\n meta: { priority: 2 },\n cell: ({ row }) => {\n const icon = row.original.appearanceIcon\n const color = row.original.appearanceColor\n if (!icon && !color) {\n return <span className=\"text-xs text-muted-foreground\">\u2014</span>\n }\n return (\n <div className=\"flex items-center gap-2\">\n {color ? renderDictionaryColor(color) : null}\n {icon ? renderDictionaryIcon(icon) : null}\n </div>\n )\n },\n },\n {\n accessorKey: 'resourceCount',\n header: translations.table.resources,\n meta: { priority: 3 },\n cell: ({ row }) => (\n <Link\n className=\"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground\"\n href={`/backend/resources/resources?resourceTypeId=${encodeURIComponent(row.original.id)}`}\n onClick={(event) => event.stopPropagation()}\n >\n <Package className=\"h-4 w-4\" aria-hidden />\n {translations.actions.showResources.replace('{{count}}', String(row.original.resourceCount))}\n </Link>\n ),\n },\n {\n accessorKey: 'description',\n header: translations.table.description,\n meta: { priority: 5 },\n cell: ({ row }) => row.original.description ? (\n <ReactMarkdown remarkPlugins={MARKDOWN_PLUGINS} className={MARKDOWN_DESCRIPTION_CLASSNAME}>\n {row.original.description}\n </ReactMarkdown>\n ) : (\n <span className=\"text-xs text-muted-foreground\">\u2014</span>\n ),\n },\n {\n accessorKey: 'updatedAt',\n header: translations.table.updatedAt,\n meta: { priority: 4 },\n cell: ({ row }) => row.original.updatedAt\n ? <span className=\"text-xs text-muted-foreground\">{formatDateTime(row.original.updatedAt)}</span>\n : <span className=\"text-xs text-muted-foreground\">\u2014</span>,\n },\n ], [\n translations.actions.showResources,\n translations.table.appearance,\n translations.table.description,\n translations.table.name,\n translations.table.resources,\n translations.table.updatedAt,\n ])\n\n const loadResourceTypes = React.useCallback(async () => {\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(PAGE_SIZE),\n })\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 if (search.trim()) {\n params.set('search', search.trim())\n }\n const payload = await readApiResultOrThrow<ResourceTypesResponse>(\n `/api/resources/resource-types?${params.toString()}`,\n undefined,\n { errorMessage: translations.errors.load, fallback: { items: [], total: 0, totalPages: 1 } },\n )\n const items = Array.isArray(payload.items) ? payload.items : []\n setRows(items.map(mapApiResourceType))\n setTotal(typeof payload.total === 'number' ? payload.total : items.length)\n setTotalPages(typeof payload.totalPages === 'number' ? payload.totalPages : Math.max(1, Math.ceil(items.length / PAGE_SIZE)))\n } catch (error) {\n console.error('resources.resource-types.list', error)\n flash(translations.errors.load, 'error')\n } finally {\n setIsLoading(false)\n }\n }, [page, search, sorting, translations.errors.load])\n\n React.useEffect(() => {\n void loadResourceTypes()\n }, [loadResourceTypes, scopeVersion, reloadToken])\n\n const handleSearchChange = React.useCallback((value: string) => {\n setSearch(value)\n setPage(1)\n }, [])\n\n const handleRefresh = React.useCallback(() => {\n setReloadToken((token) => token + 1)\n }, [])\n\n const handleDelete = React.useCallback(async (entry: ResourceTypeRow) => {\n if (entry.resourceCount > 0) {\n flash(translations.errors.deleteAssigned, 'error')\n return\n }\n const message = translations.actions.deleteConfirm.replace('{{name}}', entry.name)\n const confirmed = await confirm({\n title: message,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n await deleteCrud('resources/resource-types', entry.id, { errorMessage: translations.errors.delete })\n flash(translations.messages.deleted, 'success')\n handleRefresh()\n } catch (error) {\n console.error('resources.resource-types.delete', error)\n flash(translations.errors.delete, 'error')\n }\n }, [confirm, handleRefresh, translations.actions.deleteConfirm, translations.errors.delete, translations.errors.deleteAssigned, translations.messages.deleted])\n\n return (\n <Page>\n <PageBody>\n <DataTable<ResourceTypeRow>\n title={translations.title}\n data={rows}\n columns={columns}\n isLoading={isLoading}\n searchValue={search}\n onSearchChange={handleSearchChange}\n searchPlaceholder={translations.table.search}\n emptyState={<p className=\"py-8 text-center text-sm text-muted-foreground\">{translations.table.empty}</p>}\n actions={(\n <Button asChild size=\"sm\">\n <Link href=\"/backend/resources/resource-types/create\">\n {translations.actions.add}\n </Link>\n </Button>\n )}\n refreshButton={{\n label: translations.actions.refresh,\n onRefresh: handleRefresh,\n isRefreshing: isLoading,\n }}\n sortable\n sorting={sorting}\n onSortingChange={setSorting}\n pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, onPageChange: setPage }}\n rowActions={(row) => (\n <RowActions\n items={[\n { id: 'edit', label: translations.actions.edit, href: `/backend/resources/resource-types/${row.id}/edit` },\n ...(row.resourceCount > 0\n ? []\n : [{ id: 'delete', label: translations.actions.delete, destructive: true, onSelect: () => handleDelete(row) }]),\n ]}\n />\n )}\n onRowClick={(row) => router.push(`/backend/resources/resource-types/${row.id}/edit`)}\n perspective={{ tableId: 'resources.resource-types.list' }}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n\nfunction mapApiResourceType(item: Record<string, unknown>): ResourceTypeRow {\n const id = typeof item.id === 'string' ? item.id : ''\n const name = typeof item.name === 'string' && item.name.length ? item.name : id\n const description = typeof item.description === 'string' && item.description.length\n ? item.description\n : typeof item.description === 'string'\n ? item.description\n : null\n const appearanceIcon = typeof item.appearanceIcon === 'string'\n ? item.appearanceIcon\n : typeof item.appearance_icon === 'string'\n ? item.appearance_icon\n : null\n const appearanceColor = typeof item.appearanceColor === 'string'\n ? item.appearanceColor\n : typeof item.appearance_color === 'string'\n ? item.appearance_color\n : null\n const updatedAt = typeof item.updatedAt === 'string'\n ? item.updatedAt\n : typeof item.updated_at === 'string'\n ? item.updated_at\n : null\n const resourceCount = typeof item.resourceCount === 'number'\n ? item.resourceCount\n : typeof item.resource_count === 'number'\n ? item.resource_count\n : 0\n return { id, name, description, appearanceIcon, appearanceColor, updatedAt, resourceCount }\n}\n\n\n"],
|
|
5
|
+
"mappings": ";AA0GQ,SACE,KADF;AAxGR,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,OAAO,UAAU;AAGjB,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB,4BAA4B;AAC5D,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,sBAAsB;AAE/B,MAAM,YAAY;AAClB,MAAM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AAK,cACL;AACN,QAAM,iBAAiB,OAAO,KAAK,mBAAmB,WAClD,KAAK,iBACL,OAAO,KAAK,oBAAoB,WAC9B,KAAK,kBACL;AACN,QAAM,kBAAkB,OAAO,KAAK,oBAAoB,WACpD,KAAK,kBACL,OAAO,KAAK,qBAAqB,WAC/B,KAAK,mBACL;AACN,QAAM,YAAY,OAAO,KAAK,cAAc,WACxC,KAAK,YACL,OAAO,KAAK,eAAe,WACzB,KAAK,aACL;AACN,QAAM,gBAAgB,OAAO,KAAK,kBAAkB,WAChD,KAAK,gBACL,OAAO,KAAK,mBAAmB,WAC7B,KAAK,iBACL;AACN,SAAO,EAAE,IAAI,MAAM,aAAa,gBAAgB,iBAAiB,WAAW,cAAc;AAC5F;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import Link from "next/link";
|
|
5
5
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
6
6
|
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
7
|
-
import { DataTable
|
|
7
|
+
import { DataTable } from "@open-mercato/ui/backend/DataTable";
|
|
8
8
|
import { RowActions } from "@open-mercato/ui/backend/RowActions";
|
|
9
9
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
10
10
|
import { BooleanIcon } from "@open-mercato/ui/backend/ValueIcons";
|
|
@@ -411,7 +411,7 @@ function mapApiResource(item) {
|
|
|
411
411
|
const appearanceIcon = typeof item.appearanceIcon === "string" ? item.appearanceIcon : typeof item.appearance_icon === "string" ? item.appearance_icon : null;
|
|
412
412
|
const appearanceColor = typeof item.appearanceColor === "string" ? item.appearanceColor : typeof item.appearance_color === "string" ? item.appearance_color : null;
|
|
413
413
|
const tags = Array.isArray(item.tags) ? item.tags : [];
|
|
414
|
-
return
|
|
414
|
+
return {
|
|
415
415
|
id,
|
|
416
416
|
name,
|
|
417
417
|
resourceTypeId,
|
|
@@ -420,7 +420,7 @@ function mapApiResource(item) {
|
|
|
420
420
|
isActive,
|
|
421
421
|
appearanceIcon,
|
|
422
422
|
appearanceColor
|
|
423
|
-
}
|
|
423
|
+
};
|
|
424
424
|
}
|
|
425
425
|
export {
|
|
426
426
|
ResourcesResourcesPage as default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/modules/resources/backend/resources/resources/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { usePathname, useRouter, useSearchParams } from 'next/navigation'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable, withDataTableNamespaces } from '@open-mercato/ui/backend/DataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport type { FilterDef, FilterOption, FilterValues } from '@open-mercato/ui/backend/FilterOverlay'\nimport type { TagOption } from '@open-mercato/ui/backend/detail'\nimport { renderDictionaryColor, renderDictionaryIcon } from '@open-mercato/core/modules/dictionaries/components/dictionaryAppearance'\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 { Pencil } from 'lucide-react'\n\nconst PAGE_SIZE = 20\n\ntype ResourceRow = {\n id: string\n name: string\n resourceTypeId: string | null\n capacity: number | null\n tags?: TagOption[] | null\n isActive: boolean\n appearanceIcon?: string | null\n appearanceColor?: string | null\n}\n\ntype ResourceTypeRow = {\n id: string\n name: string\n appearanceIcon: string | null\n appearanceColor: string | null\n}\n\ntype ResourceGroupRow = {\n id: string\n name: string\n resourceTypeId: string | null\n appearanceIcon: string | null\n appearanceColor: string | null\n rowKind: 'group'\n depth: number\n}\n\ntype ResourceTableRow = (ResourceRow & { rowKind: 'resource'; depth: number }) | ResourceGroupRow\n\ntype ResourcesResponse = {\n items: Array<Record<string, unknown>>\n total: number\n page: number\n totalPages: number\n}\n\ntype ResourceTypesResponse = {\n items: Array<Record<string, unknown>>\n}\n\nexport default function ResourcesResourcesPage() {\n const [rows, setRows] = React.useState<ResourceRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n const [isLoading, setIsLoading] = React.useState(true)\n const [resourceTypes, setResourceTypes] = React.useState<Map<string, ResourceTypeRow>>(new Map())\n const [canManage, setCanManage] = React.useState(false)\n const [tagOptions, setTagOptions] = React.useState<FilterOption[]>([])\n const scopeVersion = useOrganizationScopeVersion()\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const router = useRouter()\n const pathname = usePathname()\n const searchParams = useSearchParams()\n const resourceTypeFilter = searchParams.get('resourceTypeId')\n const selectedResourceTypeId = typeof filterValues.resourceTypeId === 'string'\n ? filterValues.resourceTypeId\n : resourceTypeFilter\n\n React.useEffect(() => {\n setPage(1)\n }, [resourceTypeFilter])\n\n React.useEffect(() => {\n if (!resourceTypeFilter) return\n setFilterValues((prev) => {\n if (prev.resourceTypeId === resourceTypeFilter) return prev\n if (typeof prev.resourceTypeId === 'string' && prev.resourceTypeId.length > 0) return prev\n return { ...prev, resourceTypeId: resourceTypeFilter }\n })\n }, [resourceTypeFilter])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadPermissions() {\n try {\n const call = await apiCall<{ granted?: string[]; ok?: boolean }>('/api/auth/feature-check', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ features: ['resources.manage_resources'] }),\n })\n if (!cancelled) {\n const granted = Array.isArray(call.result?.granted) ? call.result?.granted : []\n setCanManage(call.result?.ok === true || granted.includes('resources.manage_resources'))\n }\n } catch {\n if (!cancelled) setCanManage(false)\n }\n }\n loadPermissions()\n return () => { cancelled = true }\n }, [])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadResourceTypes() {\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100' })\n const call = await apiCall<ResourceTypesResponse>(`/api/resources/resource-types?${params.toString()}`)\n const items = Array.isArray(call.result?.items) ? call.result.items : []\n const map = new Map<string, ResourceTypeRow>()\n for (const item of items) {\n const raw = item as Record<string, unknown>\n const id = typeof raw.id === 'string' ? raw.id : ''\n const name = typeof raw.name === 'string' ? raw.name : id\n const appearanceIcon = typeof raw.appearanceIcon === 'string'\n ? raw.appearanceIcon\n : typeof raw.appearance_icon === 'string'\n ? raw.appearance_icon\n : null\n const appearanceColor = typeof raw.appearanceColor === 'string'\n ? raw.appearanceColor\n : typeof raw.appearance_color === 'string'\n ? raw.appearance_color\n : null\n map.set(id, {\n id,\n name,\n appearanceIcon,\n appearanceColor,\n })\n }\n if (!cancelled) setResourceTypes(map)\n } catch {\n if (!cancelled) setResourceTypes(new Map())\n }\n }\n loadResourceTypes()\n return () => { cancelled = true }\n }, [scopeVersion])\n\n const loadTagOptions = React.useCallback(\n async (query?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '100' })\n if (query && query.trim().length) params.set('search', query.trim())\n const call = await apiCall<{ items?: Array<{ id?: string; label?: string; slug?: string }> }>(`/api/resources/tags?${params.toString()}`)\n const items = Array.isArray(call.result?.items) ? call.result.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\n ? entry.label.trim()\n : typeof entry.slug === 'string' && entry.slug.trim().length\n ? entry.slug.trim()\n : value\n return { value, label }\n })\n .filter((option): option is FilterOption => option !== null)\n if (options.length > 0) {\n setTagOptions((prev) => {\n const map = new Map(prev.map((opt) => [opt.value, opt]))\n options.forEach((opt) => map.set(opt.value, opt))\n return Array.from(map.values())\n })\n }\n return options\n } catch {\n return []\n }\n },\n [],\n )\n\n const resourceTypeOptions = React.useMemo<FilterOption[]>(() => {\n const entries = Array.from(resourceTypes.values())\n entries.sort((a, b) => a.name.localeCompare(b.name))\n return entries.map((entry) => ({ value: entry.id, label: entry.name }))\n }, [resourceTypes])\n\n const filters = React.useMemo<FilterDef[]>(() => [\n {\n id: 'resourceTypeId',\n label: t('resources.resources.list.filters.resourceType', 'Resource type'),\n type: 'select',\n options: resourceTypeOptions,\n },\n {\n id: 'tagIds',\n label: t('resources.resources.list.filters.tags', 'Tags'),\n type: 'tags',\n loadOptions: loadTagOptions,\n options: tagOptions,\n },\n ], [loadTagOptions, resourceTypeOptions, tagOptions, t])\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n setFilterValues(values)\n setPage(1)\n\n const params = new URLSearchParams(searchParams?.toString())\n const hasResourceType = typeof values.resourceTypeId === 'string' && values.resourceTypeId.length > 0\n if (!hasResourceType && params.has('resourceTypeId')) {\n params.delete('resourceTypeId')\n const query = params.toString()\n router.replace(query ? `${pathname}?${query}` : pathname)\n }\n }, [pathname, router, searchParams])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n\n const params = new URLSearchParams(searchParams?.toString())\n if (params.has('resourceTypeId')) {\n params.delete('resourceTypeId')\n const query = params.toString()\n router.replace(query ? `${pathname}?${query}` : pathname)\n }\n }, [pathname, router, searchParams])\n\n const groupedRows = React.useMemo(() => {\n const grouped: ResourceTableRow[] = []\n if (!rows.length) return grouped\n const byType = new Map<string, ResourceRow[]>()\n const unassigned: ResourceRow[] = []\n rows.forEach((row) => {\n if (!row.resourceTypeId) {\n unassigned.push(row)\n return\n }\n const list = byType.get(row.resourceTypeId) ?? []\n list.push(row)\n byType.set(row.resourceTypeId, list)\n })\n const typeEntries = Array.from(byType.entries())\n .map(([typeId, list]) => ({\n typeId,\n list,\n type: resourceTypes.get(typeId),\n }))\n .sort((a, b) => {\n const nameA = a.type?.name ?? ''\n const nameB = b.type?.name ?? ''\n return nameA.localeCompare(nameB)\n })\n for (const entry of typeEntries) {\n const label = entry.type?.name ?? t('resources.resources.list.group.unknown', 'Unknown type')\n grouped.push({\n id: `group:${entry.typeId}`,\n name: label,\n resourceTypeId: entry.typeId,\n appearanceIcon: entry.type?.appearanceIcon ?? null,\n appearanceColor: entry.type?.appearanceColor ?? null,\n rowKind: 'group',\n depth: 0,\n })\n entry.list.forEach((resource) => {\n grouped.push({ ...resource, rowKind: 'resource', depth: 1 })\n })\n }\n if (unassigned.length) {\n grouped.push({\n id: 'group:unassigned',\n name: t('resources.resources.list.group.unassigned', 'Unassigned'),\n resourceTypeId: null,\n appearanceIcon: null,\n appearanceColor: null,\n rowKind: 'group',\n depth: 0,\n })\n unassigned.forEach((resource) => {\n grouped.push({ ...resource, rowKind: 'resource', depth: 1 })\n })\n }\n return grouped\n }, [resourceTypes, rows, t])\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(PAGE_SIZE),\n })\n if (search) params.set('search', search)\n if (selectedResourceTypeId) params.set('resourceTypeId', selectedResourceTypeId)\n const tagIds = Array.isArray(filterValues.tagIds)\n ? filterValues.tagIds\n .map((value) => (typeof value === 'string' ? value.trim() : String(value || '').trim()))\n .filter((value) => value.length > 0)\n : []\n if (tagIds.length > 0) params.set('tagIds', tagIds.join(','))\n const fallback: ResourcesResponse = { items: [], total: 0, page, totalPages: 1 }\n const call = await apiCall<ResourcesResponse>(`/api/resources/resources?${params.toString()}`, undefined, { fallback })\n if (!call.ok) {\n flash(t('resources.resources.list.error.load', 'Failed to load resources.'), 'error')\n return\n }\n const payload = call.result ?? fallback\n if (!cancelled) {\n const items = Array.isArray(payload.items) ? payload.items : []\n const mapped = items.map(mapApiResource)\n setRows(mapped)\n setTotal(payload.total || 0)\n setTotalPages(payload.totalPages || 1)\n }\n } catch (error) {\n if (!cancelled) {\n const message = error instanceof Error ? error.message : t('resources.resources.list.error.load', 'Failed to load resources.')\n flash(message, 'error')\n }\n } finally {\n if (!cancelled) setIsLoading(false)\n }\n }\n load()\n return () => { cancelled = true }\n }, [filterValues, page, search, scopeVersion, selectedResourceTypeId, t])\n\n const handleDelete = React.useCallback(async (row: ResourceTableRow) => {\n if (row.rowKind !== 'resource') return\n const confirmLabel = t('resources.resources.list.confirmDelete', 'Delete resource \"{name}\"?', { name: row.name })\n const confirmed = await confirm({\n title: confirmLabel,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n await deleteCrud('resources/resources', row.id, {\n errorMessage: t('resources.resources.list.error.delete', 'Failed to delete resource.'),\n })\n flash(t('resources.resources.list.flash.deleted', 'Resource deleted.'), 'success')\n setPage(1)\n router.refresh()\n } catch (error) {\n const message = error instanceof Error ? error.message : t('resources.resources.list.error.delete', 'Failed to delete resource.')\n flash(message, 'error')\n }\n }, [confirm, router, t])\n\n const columns = React.useMemo<ColumnDef<ResourceTableRow>[]>(() => [\n {\n accessorKey: 'name',\n header: t('resources.resources.list.columns.name', 'Resource'),\n meta: { priority: 1 },\n cell: ({ row }) => {\n const depth = row.original.depth ?? 0\n const indent = depth > 0 ? 18 : 0\n const isGroup = row.original.rowKind === 'group'\n const showEdit = isGroup && canManage && row.original.resourceTypeId\n return (\n <div className={isGroup ? 'flex items-center justify-between gap-3' : 'flex items-center gap-2'}>\n <span style={{ marginLeft: indent }} className={isGroup ? 'text-sm font-semibold text-foreground' : 'text-sm font-medium text-foreground'}>\n {row.original.name}\n </span>\n {showEdit ? (\n <Button\n asChild\n size=\"icon\"\n variant=\"ghost\"\n className=\"h-7 w-7\"\n title={t('resources.resourceTypes.actions.edit', 'Edit')}\n aria-label={t('resources.resourceTypes.actions.edit', 'Edit')}\n >\n <Link href={`/backend/resources/resource-types/${encodeURIComponent(row.original.resourceTypeId ?? '')}/edit`}>\n <Pencil className=\"h-4 w-4\" />\n </Link>\n </Button>\n ) : null}\n </div>\n )\n },\n },\n {\n accessorKey: 'appearance',\n header: t('resources.resources.list.columns.appearance', 'Appearance'),\n meta: { priority: 2 },\n cell: ({ row }) => {\n const isGroup = row.original.rowKind === 'group'\n const typeId = row.original.resourceTypeId ?? ''\n const type = resourceTypes.get(typeId) ?? null\n const icon = isGroup\n ? row.original.appearanceIcon\n : row.original.appearanceIcon ?? type?.appearanceIcon\n const color = isGroup\n ? row.original.appearanceColor\n : row.original.appearanceColor ?? type?.appearanceColor\n if (!icon && !color) {\n return <span className=\"text-xs text-muted-foreground\">\u2014</span>\n }\n return (\n <div className=\"flex items-center gap-2\">\n {color ? renderDictionaryColor(color) : null}\n {icon ? renderDictionaryIcon(icon) : null}\n </div>\n )\n },\n },\n {\n accessorKey: 'resourceTypeId',\n header: t('resources.resources.list.columns.type', 'Type'),\n meta: { priority: 3 },\n cell: ({ row }) => {\n if (row.original.rowKind === 'group') return null\n return resourceTypes.get(row.original.resourceTypeId ?? '')?.name || t('resources.resources.list.columns.type.empty', 'Unassigned')\n },\n },\n {\n accessorKey: 'capacity',\n header: t('resources.resources.list.columns.capacity', 'Capacity'),\n meta: { priority: 4 },\n cell: ({ row }) => row.original.rowKind === 'group'\n ? null\n : row.original.capacity ?? t('resources.resources.list.columns.capacity.empty', '-'),\n },\n {\n accessorKey: 'tags',\n header: t('resources.resources.list.columns.tags', 'Tags'),\n meta: { priority: 5 },\n cell: ({ row }) => {\n if (row.original.rowKind === 'group') {\n return null\n }\n const tags = row.original.tags ?? []\n if (!tags.length) return <span className=\"text-xs text-muted-foreground\">{t('resources.resources.list.columns.tags.empty', '-')}</span>\n return (\n <div className=\"flex flex-wrap gap-1\">\n {tags.map((tag) => (\n <span key={tag.id} className=\"rounded-full border px-2 py-0.5 text-xs font-medium\">\n {tag.label}\n </span>\n ))}\n </div>\n )\n },\n },\n {\n accessorKey: 'isActive',\n header: t('resources.resources.list.columns.active', 'Active'),\n meta: { priority: 6 },\n cell: ({ row }) => row.original.rowKind === 'group' ? null : <BooleanIcon value={row.original.isActive} />,\n },\n ], [canManage, resourceTypes, t])\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('resources.resources.page.title', 'Resources')}\n actions={canManage ? (\n <Button asChild>\n <Link href=\"/backend/resources/resources/create\">{t('resources.resources.list.actions.create', 'New resource')}</Link>\n </Button>\n ) : null}\n columns={columns}\n data={groupedRows}\n searchValue={search}\n onSearchChange={(value) => { setSearch(value); setPage(1) }}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n perspective={{ tableId: 'resources.resources.list' }}\n rowActions={(row) => {\n if (!canManage || row.rowKind !== 'resource') return null\n return (\n <RowActions items={[\n { id: 'edit', label: t('common.edit', 'Edit'), href: `/backend/resources/resources/${encodeURIComponent(row.id)}` },\n { id: 'delete', label: t('common.delete', 'Delete'), destructive: true, onSelect: () => { void handleDelete(row) } },\n ]} />\n )\n }}\n onRowClick={canManage ? (row) => {\n if (row.rowKind !== 'resource') return\n router.push(`/backend/resources/resources/${encodeURIComponent(row.id)}`)\n } : undefined}\n pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, onPageChange: setPage }}\n isLoading={isLoading}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n\nfunction mapApiResource(item: Record<string, unknown>): ResourceRow {\n const id = typeof item.id === 'string' ? item.id : ''\n const name = typeof item.name === 'string' ? item.name : id\n const resourceTypeId = typeof item.resourceTypeId === 'string'\n ? item.resourceTypeId\n : typeof item.resource_type_id === 'string'\n ? item.resource_type_id\n : null\n const capacity = typeof item.capacity === 'number'\n ? item.capacity\n : typeof item.capacity === 'string'\n ? Number(item.capacity)\n : null\n const isActive = typeof item.isActive === 'boolean'\n ? item.isActive\n : typeof item.is_active === 'boolean'\n ? item.is_active\n : false\n const appearanceIcon = typeof item.appearanceIcon === 'string'\n ? item.appearanceIcon\n : typeof item.appearance_icon === 'string'\n ? item.appearance_icon\n : null\n const appearanceColor = typeof item.appearanceColor === 'string'\n ? item.appearanceColor\n : typeof item.appearance_color === 'string'\n ? item.appearance_color\n : null\n const tags = Array.isArray(item.tags) ? item.tags as TagOption[] : []\n return withDataTableNamespaces({\n id,\n name,\n resourceTypeId,\n capacity: Number.isFinite(capacity as number) ? capacity as number : null,\n tags,\n isActive,\n appearanceIcon,\n appearanceColor,\n }, item)\n}\n"],
|
|
5
|
-
"mappings": ";AAqXU,SACE,KADF;AAnXV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,aAAa,WAAW,uBAAuB;AAExD,SAAS,MAAM,gBAAgB;AAC/B,SAAS,WAAW,+BAA+B;AACnD,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AAGtB,SAAS,uBAAuB,4BAA4B;AAC5D,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,wBAAwB;AACjC,SAAS,cAAc;AAEvB,MAAM,YAAY;AA2CH,SAAR,yBAA0C;AAC/C,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAwB,CAAC,CAAC;AACxD,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,CAAC;AACxC,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;AAC1C,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,CAAC;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,EAAE;AAC7C,QAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAuB,CAAC,CAAC;AACvE,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,IAAI;AACrD,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAuC,oBAAI,IAAI,CAAC;AACh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AAU,WAAW,OAAO,YAAY,cAAc,QAAQ;AAAA,QAClF;AAAA;AAAA,IACF,GACF;AAAA,IACC;AAAA,KACH;AAEJ;AAEA,SAAS,eAAe,MAA4C;AAClE,QAAM,KAAK,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK;AACnD,QAAM,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACzD,QAAM,iBAAiB,OAAO,KAAK,mBAAmB,WAClD,KAAK,iBACL,OAAO,KAAK,qBAAqB,WAC/B,KAAK,mBACL;AACN,QAAM,WAAW,OAAO,KAAK,aAAa,WACtC,KAAK,WACL,OAAO,KAAK,aAAa,WACvB,OAAO,KAAK,QAAQ,IACpB;AACN,QAAM,WAAW,OAAO,KAAK,aAAa,YACtC,KAAK,WACL,OAAO,KAAK,cAAc,YACxB,KAAK,YACL;AACN,QAAM,iBAAiB,OAAO,KAAK,mBAAmB,WAClD,KAAK,iBACL,OAAO,KAAK,oBAAoB,WAC9B,KAAK,kBACL;AACN,QAAM,kBAAkB,OAAO,KAAK,oBAAoB,WACpD,KAAK,kBACL,OAAO,KAAK,qBAAqB,WAC/B,KAAK,mBACL;AACN,QAAM,OAAO,MAAM,QAAQ,KAAK,IAAI,IAAI,KAAK,OAAsB,CAAC;AACpE,SAAO,wBAAwB;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,OAAO,SAAS,QAAkB,IAAI,WAAqB;AAAA,IACrE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAG,IAAI;AACT;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { usePathname, useRouter, useSearchParams } from 'next/navigation'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { BooleanIcon } from '@open-mercato/ui/backend/ValueIcons'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { deleteCrud } from '@open-mercato/ui/backend/utils/crud'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport type { FilterDef, FilterOption, FilterValues } from '@open-mercato/ui/backend/FilterOverlay'\nimport type { TagOption } from '@open-mercato/ui/backend/detail'\nimport { renderDictionaryColor, renderDictionaryIcon } from '@open-mercato/core/modules/dictionaries/components/dictionaryAppearance'\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 { Pencil } from 'lucide-react'\n\nconst PAGE_SIZE = 20\n\ntype ResourceRow = {\n id: string\n name: string\n resourceTypeId: string | null\n capacity: number | null\n tags?: TagOption[] | null\n isActive: boolean\n appearanceIcon?: string | null\n appearanceColor?: string | null\n}\n\ntype ResourceTypeRow = {\n id: string\n name: string\n appearanceIcon: string | null\n appearanceColor: string | null\n}\n\ntype ResourceGroupRow = {\n id: string\n name: string\n resourceTypeId: string | null\n appearanceIcon: string | null\n appearanceColor: string | null\n rowKind: 'group'\n depth: number\n}\n\ntype ResourceTableRow = (ResourceRow & { rowKind: 'resource'; depth: number }) | ResourceGroupRow\n\ntype ResourcesResponse = {\n items: Array<Record<string, unknown>>\n total: number\n page: number\n totalPages: number\n}\n\ntype ResourceTypesResponse = {\n items: Array<Record<string, unknown>>\n}\n\nexport default function ResourcesResourcesPage() {\n const [rows, setRows] = React.useState<ResourceRow[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n const [isLoading, setIsLoading] = React.useState(true)\n const [resourceTypes, setResourceTypes] = React.useState<Map<string, ResourceTypeRow>>(new Map())\n const [canManage, setCanManage] = React.useState(false)\n const [tagOptions, setTagOptions] = React.useState<FilterOption[]>([])\n const scopeVersion = useOrganizationScopeVersion()\n const t = useT()\n const { confirm, ConfirmDialogElement } = useConfirmDialog()\n const router = useRouter()\n const pathname = usePathname()\n const searchParams = useSearchParams()\n const resourceTypeFilter = searchParams.get('resourceTypeId')\n const selectedResourceTypeId = typeof filterValues.resourceTypeId === 'string'\n ? filterValues.resourceTypeId\n : resourceTypeFilter\n\n React.useEffect(() => {\n setPage(1)\n }, [resourceTypeFilter])\n\n React.useEffect(() => {\n if (!resourceTypeFilter) return\n setFilterValues((prev) => {\n if (prev.resourceTypeId === resourceTypeFilter) return prev\n if (typeof prev.resourceTypeId === 'string' && prev.resourceTypeId.length > 0) return prev\n return { ...prev, resourceTypeId: resourceTypeFilter }\n })\n }, [resourceTypeFilter])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadPermissions() {\n try {\n const call = await apiCall<{ granted?: string[]; ok?: boolean }>('/api/auth/feature-check', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ features: ['resources.manage_resources'] }),\n })\n if (!cancelled) {\n const granted = Array.isArray(call.result?.granted) ? call.result?.granted : []\n setCanManage(call.result?.ok === true || granted.includes('resources.manage_resources'))\n }\n } catch {\n if (!cancelled) setCanManage(false)\n }\n }\n loadPermissions()\n return () => { cancelled = true }\n }, [])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadResourceTypes() {\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100' })\n const call = await apiCall<ResourceTypesResponse>(`/api/resources/resource-types?${params.toString()}`)\n const items = Array.isArray(call.result?.items) ? call.result.items : []\n const map = new Map<string, ResourceTypeRow>()\n for (const item of items) {\n const raw = item as Record<string, unknown>\n const id = typeof raw.id === 'string' ? raw.id : ''\n const name = typeof raw.name === 'string' ? raw.name : id\n const appearanceIcon = typeof raw.appearanceIcon === 'string'\n ? raw.appearanceIcon\n : typeof raw.appearance_icon === 'string'\n ? raw.appearance_icon\n : null\n const appearanceColor = typeof raw.appearanceColor === 'string'\n ? raw.appearanceColor\n : typeof raw.appearance_color === 'string'\n ? raw.appearance_color\n : null\n map.set(id, {\n id,\n name,\n appearanceIcon,\n appearanceColor,\n })\n }\n if (!cancelled) setResourceTypes(map)\n } catch {\n if (!cancelled) setResourceTypes(new Map())\n }\n }\n loadResourceTypes()\n return () => { cancelled = true }\n }, [scopeVersion])\n\n const loadTagOptions = React.useCallback(\n async (query?: string): Promise<FilterOption[]> => {\n try {\n const params = new URLSearchParams({ pageSize: '100' })\n if (query && query.trim().length) params.set('search', query.trim())\n const call = await apiCall<{ items?: Array<{ id?: string; label?: string; slug?: string }> }>(`/api/resources/tags?${params.toString()}`)\n const items = Array.isArray(call.result?.items) ? call.result.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\n ? entry.label.trim()\n : typeof entry.slug === 'string' && entry.slug.trim().length\n ? entry.slug.trim()\n : value\n return { value, label }\n })\n .filter((option): option is FilterOption => option !== null)\n if (options.length > 0) {\n setTagOptions((prev) => {\n const map = new Map(prev.map((opt) => [opt.value, opt]))\n options.forEach((opt) => map.set(opt.value, opt))\n return Array.from(map.values())\n })\n }\n return options\n } catch {\n return []\n }\n },\n [],\n )\n\n const resourceTypeOptions = React.useMemo<FilterOption[]>(() => {\n const entries = Array.from(resourceTypes.values())\n entries.sort((a, b) => a.name.localeCompare(b.name))\n return entries.map((entry) => ({ value: entry.id, label: entry.name }))\n }, [resourceTypes])\n\n const filters = React.useMemo<FilterDef[]>(() => [\n {\n id: 'resourceTypeId',\n label: t('resources.resources.list.filters.resourceType', 'Resource type'),\n type: 'select',\n options: resourceTypeOptions,\n },\n {\n id: 'tagIds',\n label: t('resources.resources.list.filters.tags', 'Tags'),\n type: 'tags',\n loadOptions: loadTagOptions,\n options: tagOptions,\n },\n ], [loadTagOptions, resourceTypeOptions, tagOptions, t])\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n setFilterValues(values)\n setPage(1)\n\n const params = new URLSearchParams(searchParams?.toString())\n const hasResourceType = typeof values.resourceTypeId === 'string' && values.resourceTypeId.length > 0\n if (!hasResourceType && params.has('resourceTypeId')) {\n params.delete('resourceTypeId')\n const query = params.toString()\n router.replace(query ? `${pathname}?${query}` : pathname)\n }\n }, [pathname, router, searchParams])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n\n const params = new URLSearchParams(searchParams?.toString())\n if (params.has('resourceTypeId')) {\n params.delete('resourceTypeId')\n const query = params.toString()\n router.replace(query ? `${pathname}?${query}` : pathname)\n }\n }, [pathname, router, searchParams])\n\n const groupedRows = React.useMemo(() => {\n const grouped: ResourceTableRow[] = []\n if (!rows.length) return grouped\n const byType = new Map<string, ResourceRow[]>()\n const unassigned: ResourceRow[] = []\n rows.forEach((row) => {\n if (!row.resourceTypeId) {\n unassigned.push(row)\n return\n }\n const list = byType.get(row.resourceTypeId) ?? []\n list.push(row)\n byType.set(row.resourceTypeId, list)\n })\n const typeEntries = Array.from(byType.entries())\n .map(([typeId, list]) => ({\n typeId,\n list,\n type: resourceTypes.get(typeId),\n }))\n .sort((a, b) => {\n const nameA = a.type?.name ?? ''\n const nameB = b.type?.name ?? ''\n return nameA.localeCompare(nameB)\n })\n for (const entry of typeEntries) {\n const label = entry.type?.name ?? t('resources.resources.list.group.unknown', 'Unknown type')\n grouped.push({\n id: `group:${entry.typeId}`,\n name: label,\n resourceTypeId: entry.typeId,\n appearanceIcon: entry.type?.appearanceIcon ?? null,\n appearanceColor: entry.type?.appearanceColor ?? null,\n rowKind: 'group',\n depth: 0,\n })\n entry.list.forEach((resource) => {\n grouped.push({ ...resource, rowKind: 'resource', depth: 1 })\n })\n }\n if (unassigned.length) {\n grouped.push({\n id: 'group:unassigned',\n name: t('resources.resources.list.group.unassigned', 'Unassigned'),\n resourceTypeId: null,\n appearanceIcon: null,\n appearanceColor: null,\n rowKind: 'group',\n depth: 0,\n })\n unassigned.forEach((resource) => {\n grouped.push({ ...resource, rowKind: 'resource', depth: 1 })\n })\n }\n return grouped\n }, [resourceTypes, rows, t])\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n setIsLoading(true)\n try {\n const params = new URLSearchParams({\n page: String(page),\n pageSize: String(PAGE_SIZE),\n })\n if (search) params.set('search', search)\n if (selectedResourceTypeId) params.set('resourceTypeId', selectedResourceTypeId)\n const tagIds = Array.isArray(filterValues.tagIds)\n ? filterValues.tagIds\n .map((value) => (typeof value === 'string' ? value.trim() : String(value || '').trim()))\n .filter((value) => value.length > 0)\n : []\n if (tagIds.length > 0) params.set('tagIds', tagIds.join(','))\n const fallback: ResourcesResponse = { items: [], total: 0, page, totalPages: 1 }\n const call = await apiCall<ResourcesResponse>(`/api/resources/resources?${params.toString()}`, undefined, { fallback })\n if (!call.ok) {\n flash(t('resources.resources.list.error.load', 'Failed to load resources.'), 'error')\n return\n }\n const payload = call.result ?? fallback\n if (!cancelled) {\n const items = Array.isArray(payload.items) ? payload.items : []\n const mapped = items.map(mapApiResource)\n setRows(mapped)\n setTotal(payload.total || 0)\n setTotalPages(payload.totalPages || 1)\n }\n } catch (error) {\n if (!cancelled) {\n const message = error instanceof Error ? error.message : t('resources.resources.list.error.load', 'Failed to load resources.')\n flash(message, 'error')\n }\n } finally {\n if (!cancelled) setIsLoading(false)\n }\n }\n load()\n return () => { cancelled = true }\n }, [filterValues, page, search, scopeVersion, selectedResourceTypeId, t])\n\n const handleDelete = React.useCallback(async (row: ResourceTableRow) => {\n if (row.rowKind !== 'resource') return\n const confirmLabel = t('resources.resources.list.confirmDelete', 'Delete resource \"{name}\"?', { name: row.name })\n const confirmed = await confirm({\n title: confirmLabel,\n variant: 'destructive',\n })\n if (!confirmed) return\n try {\n await deleteCrud('resources/resources', row.id, {\n errorMessage: t('resources.resources.list.error.delete', 'Failed to delete resource.'),\n })\n flash(t('resources.resources.list.flash.deleted', 'Resource deleted.'), 'success')\n setPage(1)\n router.refresh()\n } catch (error) {\n const message = error instanceof Error ? error.message : t('resources.resources.list.error.delete', 'Failed to delete resource.')\n flash(message, 'error')\n }\n }, [confirm, router, t])\n\n const columns = React.useMemo<ColumnDef<ResourceTableRow>[]>(() => [\n {\n accessorKey: 'name',\n header: t('resources.resources.list.columns.name', 'Resource'),\n meta: { priority: 1 },\n cell: ({ row }) => {\n const depth = row.original.depth ?? 0\n const indent = depth > 0 ? 18 : 0\n const isGroup = row.original.rowKind === 'group'\n const showEdit = isGroup && canManage && row.original.resourceTypeId\n return (\n <div className={isGroup ? 'flex items-center justify-between gap-3' : 'flex items-center gap-2'}>\n <span style={{ marginLeft: indent }} className={isGroup ? 'text-sm font-semibold text-foreground' : 'text-sm font-medium text-foreground'}>\n {row.original.name}\n </span>\n {showEdit ? (\n <Button\n asChild\n size=\"icon\"\n variant=\"ghost\"\n className=\"h-7 w-7\"\n title={t('resources.resourceTypes.actions.edit', 'Edit')}\n aria-label={t('resources.resourceTypes.actions.edit', 'Edit')}\n >\n <Link href={`/backend/resources/resource-types/${encodeURIComponent(row.original.resourceTypeId ?? '')}/edit`}>\n <Pencil className=\"h-4 w-4\" />\n </Link>\n </Button>\n ) : null}\n </div>\n )\n },\n },\n {\n accessorKey: 'appearance',\n header: t('resources.resources.list.columns.appearance', 'Appearance'),\n meta: { priority: 2 },\n cell: ({ row }) => {\n const isGroup = row.original.rowKind === 'group'\n const typeId = row.original.resourceTypeId ?? ''\n const type = resourceTypes.get(typeId) ?? null\n const icon = isGroup\n ? row.original.appearanceIcon\n : row.original.appearanceIcon ?? type?.appearanceIcon\n const color = isGroup\n ? row.original.appearanceColor\n : row.original.appearanceColor ?? type?.appearanceColor\n if (!icon && !color) {\n return <span className=\"text-xs text-muted-foreground\">\u2014</span>\n }\n return (\n <div className=\"flex items-center gap-2\">\n {color ? renderDictionaryColor(color) : null}\n {icon ? renderDictionaryIcon(icon) : null}\n </div>\n )\n },\n },\n {\n accessorKey: 'resourceTypeId',\n header: t('resources.resources.list.columns.type', 'Type'),\n meta: { priority: 3 },\n cell: ({ row }) => {\n if (row.original.rowKind === 'group') return null\n return resourceTypes.get(row.original.resourceTypeId ?? '')?.name || t('resources.resources.list.columns.type.empty', 'Unassigned')\n },\n },\n {\n accessorKey: 'capacity',\n header: t('resources.resources.list.columns.capacity', 'Capacity'),\n meta: { priority: 4 },\n cell: ({ row }) => row.original.rowKind === 'group'\n ? null\n : row.original.capacity ?? t('resources.resources.list.columns.capacity.empty', '-'),\n },\n {\n accessorKey: 'tags',\n header: t('resources.resources.list.columns.tags', 'Tags'),\n meta: { priority: 5 },\n cell: ({ row }) => {\n if (row.original.rowKind === 'group') {\n return null\n }\n const tags = row.original.tags ?? []\n if (!tags.length) return <span className=\"text-xs text-muted-foreground\">{t('resources.resources.list.columns.tags.empty', '-')}</span>\n return (\n <div className=\"flex flex-wrap gap-1\">\n {tags.map((tag) => (\n <span key={tag.id} className=\"rounded-full border px-2 py-0.5 text-xs font-medium\">\n {tag.label}\n </span>\n ))}\n </div>\n )\n },\n },\n {\n accessorKey: 'isActive',\n header: t('resources.resources.list.columns.active', 'Active'),\n meta: { priority: 6 },\n cell: ({ row }) => row.original.rowKind === 'group' ? null : <BooleanIcon value={row.original.isActive} />,\n },\n ], [canManage, resourceTypes, t])\n\n return (\n <Page>\n <PageBody>\n <DataTable\n title={t('resources.resources.page.title', 'Resources')}\n actions={canManage ? (\n <Button asChild>\n <Link href=\"/backend/resources/resources/create\">{t('resources.resources.list.actions.create', 'New resource')}</Link>\n </Button>\n ) : null}\n columns={columns}\n data={groupedRows}\n searchValue={search}\n onSearchChange={(value) => { setSearch(value); setPage(1) }}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n perspective={{ tableId: 'resources.resources.list' }}\n rowActions={(row) => {\n if (!canManage || row.rowKind !== 'resource') return null\n return (\n <RowActions items={[\n { id: 'edit', label: t('common.edit', 'Edit'), href: `/backend/resources/resources/${encodeURIComponent(row.id)}` },\n { id: 'delete', label: t('common.delete', 'Delete'), destructive: true, onSelect: () => { void handleDelete(row) } },\n ]} />\n )\n }}\n onRowClick={canManage ? (row) => {\n if (row.rowKind !== 'resource') return\n router.push(`/backend/resources/resources/${encodeURIComponent(row.id)}`)\n } : undefined}\n pagination={{ page, pageSize: PAGE_SIZE, total, totalPages, onPageChange: setPage }}\n isLoading={isLoading}\n />\n </PageBody>\n {ConfirmDialogElement}\n </Page>\n )\n}\n\nfunction mapApiResource(item: Record<string, unknown>): ResourceRow {\n const id = typeof item.id === 'string' ? item.id : ''\n const name = typeof item.name === 'string' ? item.name : id\n const resourceTypeId = typeof item.resourceTypeId === 'string'\n ? item.resourceTypeId\n : typeof item.resource_type_id === 'string'\n ? item.resource_type_id\n : null\n const capacity = typeof item.capacity === 'number'\n ? item.capacity\n : typeof item.capacity === 'string'\n ? Number(item.capacity)\n : null\n const isActive = typeof item.isActive === 'boolean'\n ? item.isActive\n : typeof item.is_active === 'boolean'\n ? item.is_active\n : false\n const appearanceIcon = typeof item.appearanceIcon === 'string'\n ? item.appearanceIcon\n : typeof item.appearance_icon === 'string'\n ? item.appearance_icon\n : null\n const appearanceColor = typeof item.appearanceColor === 'string'\n ? item.appearanceColor\n : typeof item.appearance_color === 'string'\n ? item.appearance_color\n : null\n const tags = Array.isArray(item.tags) ? item.tags as TagOption[] : []\n return {\n id,\n name,\n resourceTypeId,\n capacity: Number.isFinite(capacity as number) ? capacity as number : null,\n tags,\n isActive,\n appearanceIcon,\n appearanceColor,\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAqXU,SACE,KADF;AAnXV,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,aAAa,WAAW,uBAAuB;AAExD,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,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O,KAAK,oBAAoB,WAC9B,KAAK,kBACL;AACN,QAAM,kBAAkB,OAAO,KAAK,oBAAoB,WACpD,KAAK,kBACL,OAAO,KAAK,qBAAqB,WAC/B,KAAK,mBACL;AACN,QAAM,OAAO,MAAM,QAAQ,KAAK,IAAI,IAAI,KAAK,OAAsB,CAAC;AACpE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,OAAO,SAAS,QAAkB,IAAI,WAAqB;AAAA,IACrE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -82,7 +82,7 @@ async function loadResourceSnapshot(em, id) {
|
|
|
82
82
|
{ resource: resource.id },
|
|
83
83
|
{ populate: ["tag"] }
|
|
84
84
|
);
|
|
85
|
-
const tags = assignments.map((assignment) => assignment.tag?.id ?? null).filter((tagId) => typeof tagId === "string" && tagId.length > 0).sort(
|
|
85
|
+
const tags = assignments.map((assignment) => assignment.tag?.id ?? null).filter((tagId) => typeof tagId === "string" && tagId.length > 0).sort();
|
|
86
86
|
return {
|
|
87
87
|
id: resource.id,
|
|
88
88
|
tenantId: resource.tenantId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/resources/commands/resources.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CommandHandler } from '@open-mercato/shared/lib/commands'\nimport { registerCommand } from '@open-mercato/shared/lib/commands'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { buildChanges, emitCrudSideEffects, emitCrudUndoSideEffects, parseWithCustomFields, setCustomFieldsIfAny } from '@open-mercato/shared/lib/commands/helpers'\nimport { buildCustomFieldResetMap, diffCustomFieldChanges, loadCustomFieldSnapshot, type CustomFieldSnapshot } from '@open-mercato/shared/lib/commands/customFieldSnapshots'\nimport type { DataEngine } from '@open-mercato/shared/lib/data/engine'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport type { CrudIndexerConfig } from '@open-mercato/shared/lib/crud/types'\nimport { Dictionary, DictionaryEntry } from '@open-mercato/core/modules/dictionaries/data/entities'\nimport { ResourcesResource, ResourcesResourceTag, ResourcesResourceTagAssignment } from '../data/entities'\nimport {\n resourcesResourceCreateSchema,\n resourcesResourceUpdateSchema,\n type ResourcesResourceCreateInput,\n type ResourcesResourceUpdateInput,\n} from '../data/validators'\nimport { ensureOrganizationScope, ensureTenantScope, extractUndoPayload } from './shared'\nimport { RESOURCES_CAPACITY_UNIT_DICTIONARY_KEY } from '../lib/capacityUnits'\nimport { E } from '#generated/entities.ids.generated'\n\nconst resourceCrudIndexer: CrudIndexerConfig<ResourcesResource> = {\n entityType: E.resources.resources_resource,\n}\n\ntype CapacityUnitSnapshot = {\n value: string\n name: string\n color: string | null\n icon: string | null\n}\n\ntype ResourceSnapshot = {\n id: string\n tenantId: string\n organizationId: string\n name: string\n description: string | null\n resourceTypeId: string | null\n capacity: number | null\n capacityUnitValue: string | null\n capacityUnitName: string | null\n capacityUnitColor: string | null\n capacityUnitIcon: string | null\n appearanceIcon: string | null\n appearanceColor: string | null\n isActive: boolean\n availabilityRuleSetId: string | null\n tags: string[]\n deletedAt: string | null\n customFields?: CustomFieldSnapshot | null\n}\n\ntype ResourceUndoPayload = {\n before?: ResourceSnapshot | null\n after?: ResourceSnapshot | null\n customBefore?: CustomFieldSnapshot | null\n customAfter?: CustomFieldSnapshot | null\n}\n\nasync function resolveCapacityUnit(\n em: EntityManager,\n scope: { tenantId: string; organizationId: string },\n rawValue: string,\n): Promise<CapacityUnitSnapshot> {\n const trimmed = rawValue.trim()\n if (!trimmed) {\n throw new CrudHttpError(400, { error: 'Capacity unit is required.' })\n }\n const dictionary = await findOneWithDecryption(\n em,\n Dictionary,\n {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n key: RESOURCES_CAPACITY_UNIT_DICTIONARY_KEY,\n deletedAt: null,\n isActive: true,\n },\n undefined,\n scope,\n )\n if (!dictionary) {\n throw new CrudHttpError(400, { error: 'Capacity unit dictionary is not configured.' })\n }\n const normalizedValue = trimmed.toLowerCase()\n const entry = await findOneWithDecryption(\n em,\n DictionaryEntry,\n {\n dictionary,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n normalizedValue,\n },\n { populate: ['dictionary'] },\n scope,\n )\n if (!entry) {\n throw new CrudHttpError(400, { error: 'Capacity unit not found.' })\n }\n return {\n value: entry.value,\n name: entry.label?.trim().length ? entry.label : entry.value,\n color: entry.color ?? null,\n icon: entry.icon ?? null,\n }\n}\n\nfunction normalizeTagIds(tags?: Array<string | null | undefined>): string[] {\n if (!Array.isArray(tags)) return []\n const set = new Set<string>()\n tags.forEach((id) => {\n if (typeof id === 'string' && id.trim().length > 0) set.add(id.trim())\n })\n return Array.from(set)\n}\n\nasync function loadResourceSnapshot(em: EntityManager, id: string): Promise<ResourceSnapshot | null> {\n const resource = await findOneWithDecryption(\n em,\n ResourcesResource,\n { id },\n undefined,\n { tenantId: null, organizationId: null },\n )\n if (!resource) return null\n const assignments = await em.find(\n ResourcesResourceTagAssignment,\n { resource: resource.id },\n { populate: ['tag'] },\n )\n const tags = assignments\n .map((assignment) => (assignment.tag as ResourcesResourceTag | undefined)?.id ?? null)\n .filter((tagId): tagId is string => typeof tagId === 'string' && tagId.length > 0)\n .sort((a, b) => a.localeCompare(b))\n return {\n id: resource.id,\n tenantId: resource.tenantId,\n organizationId: resource.organizationId,\n name: resource.name,\n description: resource.description ?? null,\n resourceTypeId: resource.resourceTypeId ?? null,\n capacity: resource.capacity ?? null,\n capacityUnitValue: resource.capacityUnitValue ?? null,\n capacityUnitName: resource.capacityUnitName ?? null,\n capacityUnitColor: resource.capacityUnitColor ?? null,\n capacityUnitIcon: resource.capacityUnitIcon ?? null,\n appearanceIcon: resource.appearanceIcon ?? null,\n appearanceColor: resource.appearanceColor ?? null,\n isActive: resource.isActive,\n availabilityRuleSetId: resource.availabilityRuleSetId ?? null,\n tags,\n deletedAt: resource.deletedAt ? resource.deletedAt.toISOString() : null,\n }\n}\n\nasync function loadResourceCustomSnapshot(em: EntityManager, snapshot: ResourceSnapshot): Promise<CustomFieldSnapshot> {\n return loadCustomFieldSnapshot(em, {\n entityId: E.resources.resources_resource,\n recordId: snapshot.id,\n tenantId: snapshot.tenantId,\n organizationId: snapshot.organizationId,\n })\n}\n\nasync function syncResourcesResourceTags(em: EntityManager, params: {\n resourceId: string\n organizationId: string\n tenantId: string\n tagIds?: Array<string | null | undefined> | null\n}) {\n if (params.tagIds === undefined) return\n const tagIds = normalizeTagIds(params.tagIds ?? [])\n if (tagIds.length === 0) {\n await em.nativeDelete(ResourcesResourceTagAssignment, { resource: params.resourceId })\n return\n }\n const tagsInScope = await em.find(ResourcesResourceTag, {\n id: { $in: tagIds },\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n })\n if (tagsInScope.length !== tagIds.length) {\n throw new CrudHttpError(400, { error: 'One or more tags not found for this scope' })\n }\n const byId = new Map(tagsInScope.map((tag) => [tag.id, tag]))\n await em.nativeDelete(ResourcesResourceTagAssignment, { resource: params.resourceId })\n const resource = em.getReference(ResourcesResource, params.resourceId)\n for (const tagId of tagIds) {\n const tag = byId.get(tagId)\n if (!tag) continue\n const assignment = em.create(ResourcesResourceTagAssignment, {\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n resource,\n tag,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n em.persist(assignment)\n }\n}\n\nconst createResourceCommand: CommandHandler<ResourcesResourceCreateInput, { resourceId: string }> = {\n id: 'resources.resources.create',\n async execute(rawInput, ctx) {\n const { parsed, custom } = parseWithCustomFields(resourcesResourceCreateSchema, rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const now = new Date()\n const unitValue =\n typeof parsed.capacityUnitValue === 'string' ? parsed.capacityUnitValue.trim() : ''\n const unitSnapshot = unitValue\n ? await resolveCapacityUnit(em, { tenantId: parsed.tenantId, organizationId: parsed.organizationId }, unitValue)\n : null\n const record = em.create(ResourcesResource, {\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n name: parsed.name,\n description: parsed.description ?? null,\n resourceTypeId: parsed.resourceTypeId ?? null,\n capacity: parsed.capacity ?? null,\n capacityUnitValue: unitSnapshot?.value ?? null,\n capacityUnitName: unitSnapshot?.name ?? null,\n capacityUnitColor: unitSnapshot?.color ?? null,\n capacityUnitIcon: unitSnapshot?.icon ?? null,\n appearanceIcon: parsed.appearanceIcon ?? null,\n appearanceColor: parsed.appearanceColor ?? null,\n isActive: parsed.isActive ?? true,\n availabilityRuleSetId: parsed.availabilityRuleSetId ?? null,\n createdAt: now,\n updatedAt: now,\n })\n em.persist(record)\n await em.flush()\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: custom,\n })\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: parsed.tags,\n })\n await em.flush()\n await emitCrudSideEffects({\n dataEngine,\n action: 'created',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n return { resourceId: record.id }\n },\n captureAfter: async (_input, result, ctx) => {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const snapshot = await loadResourceSnapshot(em, result.resourceId)\n if (!snapshot) return null\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n return { snapshot, custom }\n },\n buildLog: async ({ result, ctx }) => {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const snapshot = await loadResourceSnapshot(em, result?.resourceId ?? '')\n if (!snapshot) return null\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n const snapshotWithCustom: ResourceSnapshot = custom\n ? { ...snapshot, customFields: custom }\n : snapshot\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('resources.audit.resources.create', 'Create resource'),\n resourceKind: 'resources.resource',\n resourceId: snapshotWithCustom.id,\n tenantId: snapshotWithCustom.tenantId,\n organizationId: snapshotWithCustom.organizationId,\n snapshotAfter: snapshotWithCustom,\n payload: {\n undo: {\n after: snapshotWithCustom,\n customAfter: custom,\n } satisfies ResourceUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<ResourceUndoPayload>(logEntry)\n const after = payload?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await em.findOne(ResourcesResource, { id: after.id })\n if (record) {\n record.deletedAt = new Date()\n record.updatedAt = new Date()\n await em.flush()\n\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine,\n action: 'deleted',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n }\n },\n}\n\nconst updateResourceCommand: CommandHandler<ResourcesResourceUpdateInput, { resourceId: string }> = {\n id: 'resources.resources.update',\n async prepare(rawInput, ctx) {\n const { parsed } = parseWithCustomFields(resourcesResourceUpdateSchema, rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadResourceSnapshot(em, parsed.id)\n if (!snapshot) return {}\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n return { before: snapshot, customBefore: custom }\n },\n async execute(rawInput, ctx) {\n const { parsed, custom } = parseWithCustomFields(resourcesResourceUpdateSchema, rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await findOneWithDecryption(\n em,\n ResourcesResource,\n { id: parsed.id, deletedAt: null },\n undefined,\n { tenantId: ctx.auth?.tenantId ?? null, organizationId: ctx.auth?.orgId ?? null },\n )\n if (!record) throw new CrudHttpError(404, { error: 'Resources resource not found.' })\n ensureTenantScope(ctx, record.tenantId)\n ensureOrganizationScope(ctx, record.organizationId)\n\n if (parsed.capacityUnitValue !== undefined) {\n const unitValue =\n typeof parsed.capacityUnitValue === 'string' ? parsed.capacityUnitValue.trim() : ''\n if (!unitValue) {\n record.capacityUnitValue = null\n record.capacityUnitName = null\n record.capacityUnitColor = null\n record.capacityUnitIcon = null\n } else {\n const unitSnapshot = await resolveCapacityUnit(\n em,\n { tenantId: record.tenantId, organizationId: record.organizationId },\n unitValue,\n )\n record.capacityUnitValue = unitSnapshot.value\n record.capacityUnitName = unitSnapshot.name\n record.capacityUnitColor = unitSnapshot.color\n record.capacityUnitIcon = unitSnapshot.icon\n }\n }\n if (parsed.name !== undefined) record.name = parsed.name\n if (parsed.description !== undefined) record.description = parsed.description ?? null\n if (parsed.resourceTypeId !== undefined) record.resourceTypeId = parsed.resourceTypeId ?? null\n if (parsed.capacity !== undefined) record.capacity = parsed.capacity ?? null\n if (parsed.appearanceIcon !== undefined) record.appearanceIcon = parsed.appearanceIcon ?? null\n if (parsed.appearanceColor !== undefined) record.appearanceColor = parsed.appearanceColor ?? null\n if (parsed.availabilityRuleSetId !== undefined) record.availabilityRuleSetId = parsed.availabilityRuleSetId ?? null\n record.updatedAt = new Date()\n if (parsed.isActive !== undefined) record.isActive = parsed.isActive\n await em.flush()\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: parsed.tags,\n })\n await em.flush()\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: custom,\n })\n await emitCrudSideEffects({\n dataEngine,\n action: 'updated',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n return { resourceId: record.id }\n },\n buildLog: async ({ snapshots, ctx }) => {\n const before = snapshots.before as ResourceSnapshot | undefined\n if (!before) return null\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const after = await loadResourceSnapshot(em, before.id)\n if (!after) return null\n const customBefore = (snapshots as { customBefore?: CustomFieldSnapshot | null }).customBefore ?? undefined\n const customAfter = await loadResourceCustomSnapshot(em, after)\n const beforeWithCustom: ResourceSnapshot = customBefore\n ? { ...before, customFields: customBefore }\n : before\n const afterWithCustom: ResourceSnapshot = customAfter\n ? { ...after, customFields: customAfter }\n : after\n const changes = buildChanges(before as unknown as Record<string, unknown>, after as unknown as Record<string, unknown>, [\n 'name',\n 'description',\n 'resourceTypeId',\n 'capacity',\n 'capacityUnitValue',\n 'capacityUnitName',\n 'capacityUnitColor',\n 'capacityUnitIcon',\n 'appearanceIcon',\n 'appearanceColor',\n 'isActive',\n 'availabilityRuleSetId',\n 'deletedAt',\n ])\n if (before.tags.join(',') !== after.tags.join(',')) {\n changes.tags = { from: before.tags, to: after.tags }\n }\n const customChanges = diffCustomFieldChanges(customBefore, customAfter)\n if (Object.keys(customChanges).length) {\n changes.customFields = { from: customBefore ?? null, to: customAfter ?? null }\n }\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('resources.audit.resources.update', 'Update resource'),\n resourceKind: 'resources.resource',\n resourceId: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n snapshotBefore: beforeWithCustom,\n snapshotAfter: afterWithCustom,\n changes,\n payload: {\n undo: {\n before: beforeWithCustom,\n after: afterWithCustom,\n customBefore: customBefore ?? null,\n customAfter,\n } satisfies ResourceUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<ResourceUndoPayload>(logEntry)\n const before = payload?.before\n if (!before) return\n const fallbackCustomBefore = (before as ResourceSnapshot).customFields ?? null\n const fallbackCustomAfter = (payload?.after as ResourceSnapshot | null | undefined)?.customFields ?? null\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await em.findOne(ResourcesResource, { id: before.id })\n if (!record) return\n record.name = before.name\n record.description = before.description ?? null\n record.resourceTypeId = before.resourceTypeId ?? null\n record.capacity = before.capacity ?? null\n record.capacityUnitValue = before.capacityUnitValue ?? null\n record.capacityUnitName = before.capacityUnitName ?? null\n record.capacityUnitColor = before.capacityUnitColor ?? null\n record.capacityUnitIcon = before.capacityUnitIcon ?? null\n record.appearanceIcon = before.appearanceIcon ?? null\n record.appearanceColor = before.appearanceColor ?? null\n record.isActive = before.isActive\n record.availabilityRuleSetId = before.availabilityRuleSetId ?? null\n record.deletedAt = before.deletedAt ? new Date(before.deletedAt) : null\n record.updatedAt = new Date()\n await em.flush()\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: before.tags,\n })\n await em.flush()\n\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n const customBefore = payload.customBefore ?? fallbackCustomBefore ?? undefined\n const customAfter = payload.customAfter ?? fallbackCustomAfter ?? undefined\n if (customBefore || customAfter) {\n const reset = buildCustomFieldResetMap(customBefore, customAfter)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: reset,\n })\n }\n\n await emitCrudUndoSideEffects({\n dataEngine,\n action: 'updated',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n },\n}\n\nconst deleteResourceCommand: CommandHandler<{ id?: string }, { resourceId: string }> = {\n id: 'resources.resources.delete',\n async prepare(input, ctx) {\n const id = input?.id\n if (!id) throw new CrudHttpError(400, { error: 'Resource id is required.' })\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadResourceSnapshot(em, id)\n if (!snapshot) return {}\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n return { before: snapshot, customBefore: custom }\n },\n async execute(input, ctx) {\n const id = input?.id\n if (!id) throw new CrudHttpError(400, { error: 'Resource id is required.' })\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await findOneWithDecryption(\n em,\n ResourcesResource,\n { id, deletedAt: null },\n undefined,\n { tenantId: ctx.auth?.tenantId ?? null, organizationId: ctx.auth?.orgId ?? null },\n )\n if (!record) throw new CrudHttpError(404, { error: 'Resources resource not found.' })\n ensureTenantScope(ctx, record.tenantId)\n ensureOrganizationScope(ctx, record.organizationId)\n record.deletedAt = new Date()\n record.updatedAt = new Date()\n await em.flush()\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine,\n action: 'deleted',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n return { resourceId: record.id }\n },\n buildLog: async ({ snapshots }) => {\n const before = snapshots.before as ResourceSnapshot | undefined\n if (!before) return null\n const customBefore = (snapshots as { customBefore?: CustomFieldSnapshot | null }).customBefore ?? undefined\n const beforeWithCustom: ResourceSnapshot = customBefore\n ? { ...before, customFields: customBefore }\n : before\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('resources.audit.resources.delete', 'Delete resource'),\n resourceKind: 'resources.resource',\n resourceId: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n snapshotBefore: beforeWithCustom,\n payload: {\n undo: {\n before: beforeWithCustom,\n customBefore: customBefore ?? null,\n } satisfies ResourceUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<ResourceUndoPayload>(logEntry)\n const before = payload?.before\n if (!before) return\n const fallbackCustomBefore = (before as ResourceSnapshot).customFields ?? null\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n let record = await em.findOne(ResourcesResource, { id: before.id })\n if (!record) {\n record = em.create(ResourcesResource, {\n id: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n name: before.name,\n description: before.description ?? null,\n resourceTypeId: before.resourceTypeId ?? null,\n capacity: before.capacity ?? null,\n capacityUnitValue: before.capacityUnitValue ?? null,\n capacityUnitName: before.capacityUnitName ?? null,\n capacityUnitColor: before.capacityUnitColor ?? null,\n capacityUnitIcon: before.capacityUnitIcon ?? null,\n appearanceIcon: before.appearanceIcon ?? null,\n appearanceColor: before.appearanceColor ?? null,\n isActive: before.isActive,\n availabilityRuleSetId: before.availabilityRuleSetId ?? null,\n deletedAt: null,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n em.persist(record)\n } else {\n record.name = before.name\n record.description = before.description ?? null\n record.resourceTypeId = before.resourceTypeId ?? null\n record.capacity = before.capacity ?? null\n record.capacityUnitValue = before.capacityUnitValue ?? null\n record.capacityUnitName = before.capacityUnitName ?? null\n record.capacityUnitColor = before.capacityUnitColor ?? null\n record.capacityUnitIcon = before.capacityUnitIcon ?? null\n record.appearanceIcon = before.appearanceIcon ?? null\n record.appearanceColor = before.appearanceColor ?? null\n record.isActive = before.isActive\n record.availabilityRuleSetId = before.availabilityRuleSetId ?? null\n record.deletedAt = null\n record.updatedAt = new Date()\n }\n await em.flush()\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: before.tags,\n })\n await em.flush()\n\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n const customBefore = payload.customBefore ?? fallbackCustomBefore ?? undefined\n if (customBefore) {\n const reset = buildCustomFieldResetMap(customBefore, undefined)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: reset,\n })\n }\n\n await emitCrudUndoSideEffects({\n dataEngine,\n action: 'created',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n },\n}\n\nregisterCommand(createResourceCommand)\nregisterCommand(updateResourceCommand)\nregisterCommand(deleteResourceCommand)\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,uBAAuB;AAEhC,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AACtC,SAAS,cAAc,qBAAqB,yBAAyB,uBAAuB,4BAA4B;AACxH,SAAS,0BAA0B,wBAAwB,+BAAyD;AAEpH,SAAS,2BAA2B;AAEpC,SAAS,YAAY,uBAAuB;AAC5C,SAAS,mBAAmB,sBAAsB,sCAAsC;AACxF;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,yBAAyB,mBAAmB,0BAA0B;AAC/E,SAAS,8CAA8C;AACvD,SAAS,SAAS;AAElB,MAAM,sBAA4D;AAAA,EAChE,YAAY,EAAE,UAAU;AAC1B;AAqCA,eAAe,oBACb,IACA,OACA,UAC+B;AAC/B,QAAM,UAAU,SAAS,KAAK;AAC9B,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,cAAc,KAAK,EAAE,OAAO,6BAA6B,CAAC;AAAA,EACtE;AACA,QAAM,aAAa,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,MACE,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,MACtB,KAAK;AAAA,MACL,WAAW;AAAA,MACX,UAAU;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,cAAc,KAAK,EAAE,OAAO,8CAA8C,CAAC;AAAA,EACvF;AACA,QAAM,kBAAkB,QAAQ,YAAY;AAC5C,QAAM,QAAQ,MAAM;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,MACE;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,MACtB;AAAA,IACF;AAAA,IACA,EAAE,UAAU,CAAC,YAAY,EAAE;AAAA,IAC3B;AAAA,EACF;AACA,MAAI,CAAC,O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,MAClC,YAAY,OAAO;AAAA,MACnB,gBAAgB,OAAO;AAAA,MACvB,UAAU,OAAO;AAAA,MACjB,QAAQ,OAAO;AAAA,IACjB,CAAC;AACD,UAAM,GAAG,MAAM;AAEf,UAAM,aAAc,IAAI,UAAU,QAAQ,YAAY;AACtD,UAAM,eAAe,QAAQ,gBAAgB,wBAAwB;AACrE,QAAI,cAAc;AAChB,YAAM,QAAQ,yBAAyB,cAAc,MAAS;AAC9D,YAAM,qBAAqB;AAAA,QACzB;AAAA,QACA,UAAU,EAAE,UAAU;AAAA,QACtB,UAAU,OAAO;AAAA,QACjB,UAAU,OAAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,QACvB,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAEA,UAAM,wBAAwB;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,QACX,IAAI,OAAO;AAAA,QACX,gBAAgB,OAAO;AAAA,QACvB,UAAU,OAAO;AAAA,MACnB;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAEA,gBAAgB,qBAAqB;AACrC,gBAAgB,qBAAqB;AACrC,gBAAgB,qBAAqB;",
|
|
4
|
+
"sourcesContent": ["import type { CommandHandler } from '@open-mercato/shared/lib/commands'\nimport { registerCommand } from '@open-mercato/shared/lib/commands'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { buildChanges, emitCrudSideEffects, emitCrudUndoSideEffects, parseWithCustomFields, setCustomFieldsIfAny } from '@open-mercato/shared/lib/commands/helpers'\nimport { buildCustomFieldResetMap, diffCustomFieldChanges, loadCustomFieldSnapshot, type CustomFieldSnapshot } from '@open-mercato/shared/lib/commands/customFieldSnapshots'\nimport type { DataEngine } from '@open-mercato/shared/lib/data/engine'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport type { CrudIndexerConfig } from '@open-mercato/shared/lib/crud/types'\nimport { Dictionary, DictionaryEntry } from '@open-mercato/core/modules/dictionaries/data/entities'\nimport { ResourcesResource, ResourcesResourceTag, ResourcesResourceTagAssignment } from '../data/entities'\nimport {\n resourcesResourceCreateSchema,\n resourcesResourceUpdateSchema,\n type ResourcesResourceCreateInput,\n type ResourcesResourceUpdateInput,\n} from '../data/validators'\nimport { ensureOrganizationScope, ensureTenantScope, extractUndoPayload } from './shared'\nimport { RESOURCES_CAPACITY_UNIT_DICTIONARY_KEY } from '../lib/capacityUnits'\nimport { E } from '#generated/entities.ids.generated'\n\nconst resourceCrudIndexer: CrudIndexerConfig<ResourcesResource> = {\n entityType: E.resources.resources_resource,\n}\n\ntype CapacityUnitSnapshot = {\n value: string\n name: string\n color: string | null\n icon: string | null\n}\n\ntype ResourceSnapshot = {\n id: string\n tenantId: string\n organizationId: string\n name: string\n description: string | null\n resourceTypeId: string | null\n capacity: number | null\n capacityUnitValue: string | null\n capacityUnitName: string | null\n capacityUnitColor: string | null\n capacityUnitIcon: string | null\n appearanceIcon: string | null\n appearanceColor: string | null\n isActive: boolean\n availabilityRuleSetId: string | null\n tags: string[]\n deletedAt: string | null\n customFields?: CustomFieldSnapshot | null\n}\n\ntype ResourceUndoPayload = {\n before?: ResourceSnapshot | null\n after?: ResourceSnapshot | null\n customBefore?: CustomFieldSnapshot | null\n customAfter?: CustomFieldSnapshot | null\n}\n\nasync function resolveCapacityUnit(\n em: EntityManager,\n scope: { tenantId: string; organizationId: string },\n rawValue: string,\n): Promise<CapacityUnitSnapshot> {\n const trimmed = rawValue.trim()\n if (!trimmed) {\n throw new CrudHttpError(400, { error: 'Capacity unit is required.' })\n }\n const dictionary = await findOneWithDecryption(\n em,\n Dictionary,\n {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n key: RESOURCES_CAPACITY_UNIT_DICTIONARY_KEY,\n deletedAt: null,\n isActive: true,\n },\n undefined,\n scope,\n )\n if (!dictionary) {\n throw new CrudHttpError(400, { error: 'Capacity unit dictionary is not configured.' })\n }\n const normalizedValue = trimmed.toLowerCase()\n const entry = await findOneWithDecryption(\n em,\n DictionaryEntry,\n {\n dictionary,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n normalizedValue,\n },\n { populate: ['dictionary'] },\n scope,\n )\n if (!entry) {\n throw new CrudHttpError(400, { error: 'Capacity unit not found.' })\n }\n return {\n value: entry.value,\n name: entry.label?.trim().length ? entry.label : entry.value,\n color: entry.color ?? null,\n icon: entry.icon ?? null,\n }\n}\n\nfunction normalizeTagIds(tags?: Array<string | null | undefined>): string[] {\n if (!Array.isArray(tags)) return []\n const set = new Set<string>()\n tags.forEach((id) => {\n if (typeof id === 'string' && id.trim().length > 0) set.add(id.trim())\n })\n return Array.from(set)\n}\n\nasync function loadResourceSnapshot(em: EntityManager, id: string): Promise<ResourceSnapshot | null> {\n const resource = await findOneWithDecryption(\n em,\n ResourcesResource,\n { id },\n undefined,\n { tenantId: null, organizationId: null },\n )\n if (!resource) return null\n const assignments = await em.find(\n ResourcesResourceTagAssignment,\n { resource: resource.id },\n { populate: ['tag'] },\n )\n const tags = assignments\n .map((assignment) => (assignment.tag as ResourcesResourceTag | undefined)?.id ?? null)\n .filter((tagId): tagId is string => typeof tagId === 'string' && tagId.length > 0)\n .sort()\n return {\n id: resource.id,\n tenantId: resource.tenantId,\n organizationId: resource.organizationId,\n name: resource.name,\n description: resource.description ?? null,\n resourceTypeId: resource.resourceTypeId ?? null,\n capacity: resource.capacity ?? null,\n capacityUnitValue: resource.capacityUnitValue ?? null,\n capacityUnitName: resource.capacityUnitName ?? null,\n capacityUnitColor: resource.capacityUnitColor ?? null,\n capacityUnitIcon: resource.capacityUnitIcon ?? null,\n appearanceIcon: resource.appearanceIcon ?? null,\n appearanceColor: resource.appearanceColor ?? null,\n isActive: resource.isActive,\n availabilityRuleSetId: resource.availabilityRuleSetId ?? null,\n tags,\n deletedAt: resource.deletedAt ? resource.deletedAt.toISOString() : null,\n }\n}\n\nasync function loadResourceCustomSnapshot(em: EntityManager, snapshot: ResourceSnapshot): Promise<CustomFieldSnapshot> {\n return loadCustomFieldSnapshot(em, {\n entityId: E.resources.resources_resource,\n recordId: snapshot.id,\n tenantId: snapshot.tenantId,\n organizationId: snapshot.organizationId,\n })\n}\n\nasync function syncResourcesResourceTags(em: EntityManager, params: {\n resourceId: string\n organizationId: string\n tenantId: string\n tagIds?: Array<string | null | undefined> | null\n}) {\n if (params.tagIds === undefined) return\n const tagIds = normalizeTagIds(params.tagIds ?? [])\n if (tagIds.length === 0) {\n await em.nativeDelete(ResourcesResourceTagAssignment, { resource: params.resourceId })\n return\n }\n const tagsInScope = await em.find(ResourcesResourceTag, {\n id: { $in: tagIds },\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n })\n if (tagsInScope.length !== tagIds.length) {\n throw new CrudHttpError(400, { error: 'One or more tags not found for this scope' })\n }\n const byId = new Map(tagsInScope.map((tag) => [tag.id, tag]))\n await em.nativeDelete(ResourcesResourceTagAssignment, { resource: params.resourceId })\n const resource = em.getReference(ResourcesResource, params.resourceId)\n for (const tagId of tagIds) {\n const tag = byId.get(tagId)\n if (!tag) continue\n const assignment = em.create(ResourcesResourceTagAssignment, {\n organizationId: params.organizationId,\n tenantId: params.tenantId,\n resource,\n tag,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n em.persist(assignment)\n }\n}\n\nconst createResourceCommand: CommandHandler<ResourcesResourceCreateInput, { resourceId: string }> = {\n id: 'resources.resources.create',\n async execute(rawInput, ctx) {\n const { parsed, custom } = parseWithCustomFields(resourcesResourceCreateSchema, rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const now = new Date()\n const unitValue =\n typeof parsed.capacityUnitValue === 'string' ? parsed.capacityUnitValue.trim() : ''\n const unitSnapshot = unitValue\n ? await resolveCapacityUnit(em, { tenantId: parsed.tenantId, organizationId: parsed.organizationId }, unitValue)\n : null\n const record = em.create(ResourcesResource, {\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n name: parsed.name,\n description: parsed.description ?? null,\n resourceTypeId: parsed.resourceTypeId ?? null,\n capacity: parsed.capacity ?? null,\n capacityUnitValue: unitSnapshot?.value ?? null,\n capacityUnitName: unitSnapshot?.name ?? null,\n capacityUnitColor: unitSnapshot?.color ?? null,\n capacityUnitIcon: unitSnapshot?.icon ?? null,\n appearanceIcon: parsed.appearanceIcon ?? null,\n appearanceColor: parsed.appearanceColor ?? null,\n isActive: parsed.isActive ?? true,\n availabilityRuleSetId: parsed.availabilityRuleSetId ?? null,\n createdAt: now,\n updatedAt: now,\n })\n em.persist(record)\n await em.flush()\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: custom,\n })\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: parsed.tags,\n })\n await em.flush()\n await emitCrudSideEffects({\n dataEngine,\n action: 'created',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n return { resourceId: record.id }\n },\n captureAfter: async (_input, result, ctx) => {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const snapshot = await loadResourceSnapshot(em, result.resourceId)\n if (!snapshot) return null\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n return { snapshot, custom }\n },\n buildLog: async ({ result, ctx }) => {\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const snapshot = await loadResourceSnapshot(em, result?.resourceId ?? '')\n if (!snapshot) return null\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n const snapshotWithCustom: ResourceSnapshot = custom\n ? { ...snapshot, customFields: custom }\n : snapshot\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('resources.audit.resources.create', 'Create resource'),\n resourceKind: 'resources.resource',\n resourceId: snapshotWithCustom.id,\n tenantId: snapshotWithCustom.tenantId,\n organizationId: snapshotWithCustom.organizationId,\n snapshotAfter: snapshotWithCustom,\n payload: {\n undo: {\n after: snapshotWithCustom,\n customAfter: custom,\n } satisfies ResourceUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<ResourceUndoPayload>(logEntry)\n const after = payload?.after\n if (!after) return\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await em.findOne(ResourcesResource, { id: after.id })\n if (record) {\n record.deletedAt = new Date()\n record.updatedAt = new Date()\n await em.flush()\n\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudUndoSideEffects({\n dataEngine,\n action: 'deleted',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n }\n },\n}\n\nconst updateResourceCommand: CommandHandler<ResourcesResourceUpdateInput, { resourceId: string }> = {\n id: 'resources.resources.update',\n async prepare(rawInput, ctx) {\n const { parsed } = parseWithCustomFields(resourcesResourceUpdateSchema, rawInput)\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadResourceSnapshot(em, parsed.id)\n if (!snapshot) return {}\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n return { before: snapshot, customBefore: custom }\n },\n async execute(rawInput, ctx) {\n const { parsed, custom } = parseWithCustomFields(resourcesResourceUpdateSchema, rawInput)\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await findOneWithDecryption(\n em,\n ResourcesResource,\n { id: parsed.id, deletedAt: null },\n undefined,\n { tenantId: ctx.auth?.tenantId ?? null, organizationId: ctx.auth?.orgId ?? null },\n )\n if (!record) throw new CrudHttpError(404, { error: 'Resources resource not found.' })\n ensureTenantScope(ctx, record.tenantId)\n ensureOrganizationScope(ctx, record.organizationId)\n\n if (parsed.capacityUnitValue !== undefined) {\n const unitValue =\n typeof parsed.capacityUnitValue === 'string' ? parsed.capacityUnitValue.trim() : ''\n if (!unitValue) {\n record.capacityUnitValue = null\n record.capacityUnitName = null\n record.capacityUnitColor = null\n record.capacityUnitIcon = null\n } else {\n const unitSnapshot = await resolveCapacityUnit(\n em,\n { tenantId: record.tenantId, organizationId: record.organizationId },\n unitValue,\n )\n record.capacityUnitValue = unitSnapshot.value\n record.capacityUnitName = unitSnapshot.name\n record.capacityUnitColor = unitSnapshot.color\n record.capacityUnitIcon = unitSnapshot.icon\n }\n }\n if (parsed.name !== undefined) record.name = parsed.name\n if (parsed.description !== undefined) record.description = parsed.description ?? null\n if (parsed.resourceTypeId !== undefined) record.resourceTypeId = parsed.resourceTypeId ?? null\n if (parsed.capacity !== undefined) record.capacity = parsed.capacity ?? null\n if (parsed.appearanceIcon !== undefined) record.appearanceIcon = parsed.appearanceIcon ?? null\n if (parsed.appearanceColor !== undefined) record.appearanceColor = parsed.appearanceColor ?? null\n if (parsed.availabilityRuleSetId !== undefined) record.availabilityRuleSetId = parsed.availabilityRuleSetId ?? null\n record.updatedAt = new Date()\n if (parsed.isActive !== undefined) record.isActive = parsed.isActive\n await em.flush()\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: parsed.tags,\n })\n await em.flush()\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: custom,\n })\n await emitCrudSideEffects({\n dataEngine,\n action: 'updated',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n return { resourceId: record.id }\n },\n buildLog: async ({ snapshots, ctx }) => {\n const before = snapshots.before as ResourceSnapshot | undefined\n if (!before) return null\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const after = await loadResourceSnapshot(em, before.id)\n if (!after) return null\n const customBefore = (snapshots as { customBefore?: CustomFieldSnapshot | null }).customBefore ?? undefined\n const customAfter = await loadResourceCustomSnapshot(em, after)\n const beforeWithCustom: ResourceSnapshot = customBefore\n ? { ...before, customFields: customBefore }\n : before\n const afterWithCustom: ResourceSnapshot = customAfter\n ? { ...after, customFields: customAfter }\n : after\n const changes = buildChanges(before as unknown as Record<string, unknown>, after as unknown as Record<string, unknown>, [\n 'name',\n 'description',\n 'resourceTypeId',\n 'capacity',\n 'capacityUnitValue',\n 'capacityUnitName',\n 'capacityUnitColor',\n 'capacityUnitIcon',\n 'appearanceIcon',\n 'appearanceColor',\n 'isActive',\n 'availabilityRuleSetId',\n 'deletedAt',\n ])\n if (before.tags.join(',') !== after.tags.join(',')) {\n changes.tags = { from: before.tags, to: after.tags }\n }\n const customChanges = diffCustomFieldChanges(customBefore, customAfter)\n if (Object.keys(customChanges).length) {\n changes.customFields = { from: customBefore ?? null, to: customAfter ?? null }\n }\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('resources.audit.resources.update', 'Update resource'),\n resourceKind: 'resources.resource',\n resourceId: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n snapshotBefore: beforeWithCustom,\n snapshotAfter: afterWithCustom,\n changes,\n payload: {\n undo: {\n before: beforeWithCustom,\n after: afterWithCustom,\n customBefore: customBefore ?? null,\n customAfter,\n } satisfies ResourceUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<ResourceUndoPayload>(logEntry)\n const before = payload?.before\n if (!before) return\n const fallbackCustomBefore = (before as ResourceSnapshot).customFields ?? null\n const fallbackCustomAfter = (payload?.after as ResourceSnapshot | null | undefined)?.customFields ?? null\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await em.findOne(ResourcesResource, { id: before.id })\n if (!record) return\n record.name = before.name\n record.description = before.description ?? null\n record.resourceTypeId = before.resourceTypeId ?? null\n record.capacity = before.capacity ?? null\n record.capacityUnitValue = before.capacityUnitValue ?? null\n record.capacityUnitName = before.capacityUnitName ?? null\n record.capacityUnitColor = before.capacityUnitColor ?? null\n record.capacityUnitIcon = before.capacityUnitIcon ?? null\n record.appearanceIcon = before.appearanceIcon ?? null\n record.appearanceColor = before.appearanceColor ?? null\n record.isActive = before.isActive\n record.availabilityRuleSetId = before.availabilityRuleSetId ?? null\n record.deletedAt = before.deletedAt ? new Date(before.deletedAt) : null\n record.updatedAt = new Date()\n await em.flush()\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: before.tags,\n })\n await em.flush()\n\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n const customBefore = payload.customBefore ?? fallbackCustomBefore ?? undefined\n const customAfter = payload.customAfter ?? fallbackCustomAfter ?? undefined\n if (customBefore || customAfter) {\n const reset = buildCustomFieldResetMap(customBefore, customAfter)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: reset,\n })\n }\n\n await emitCrudUndoSideEffects({\n dataEngine,\n action: 'updated',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n },\n}\n\nconst deleteResourceCommand: CommandHandler<{ id?: string }, { resourceId: string }> = {\n id: 'resources.resources.delete',\n async prepare(input, ctx) {\n const id = input?.id\n if (!id) throw new CrudHttpError(400, { error: 'Resource id is required.' })\n const em = (ctx.container.resolve('em') as EntityManager)\n const snapshot = await loadResourceSnapshot(em, id)\n if (!snapshot) return {}\n const custom = await loadResourceCustomSnapshot(em, snapshot)\n return { before: snapshot, customBefore: custom }\n },\n async execute(input, ctx) {\n const id = input?.id\n if (!id) throw new CrudHttpError(400, { error: 'Resource id is required.' })\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n const record = await findOneWithDecryption(\n em,\n ResourcesResource,\n { id, deletedAt: null },\n undefined,\n { tenantId: ctx.auth?.tenantId ?? null, organizationId: ctx.auth?.orgId ?? null },\n )\n if (!record) throw new CrudHttpError(404, { error: 'Resources resource not found.' })\n ensureTenantScope(ctx, record.tenantId)\n ensureOrganizationScope(ctx, record.organizationId)\n record.deletedAt = new Date()\n record.updatedAt = new Date()\n await em.flush()\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n await emitCrudSideEffects({\n dataEngine,\n action: 'deleted',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n return { resourceId: record.id }\n },\n buildLog: async ({ snapshots }) => {\n const before = snapshots.before as ResourceSnapshot | undefined\n if (!before) return null\n const customBefore = (snapshots as { customBefore?: CustomFieldSnapshot | null }).customBefore ?? undefined\n const beforeWithCustom: ResourceSnapshot = customBefore\n ? { ...before, customFields: customBefore }\n : before\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('resources.audit.resources.delete', 'Delete resource'),\n resourceKind: 'resources.resource',\n resourceId: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n snapshotBefore: beforeWithCustom,\n payload: {\n undo: {\n before: beforeWithCustom,\n customBefore: customBefore ?? null,\n } satisfies ResourceUndoPayload,\n },\n }\n },\n undo: async ({ logEntry, ctx }) => {\n const payload = extractUndoPayload<ResourceUndoPayload>(logEntry)\n const before = payload?.before\n if (!before) return\n const fallbackCustomBefore = (before as ResourceSnapshot).customFields ?? null\n const em = (ctx.container.resolve('em') as EntityManager).fork()\n let record = await em.findOne(ResourcesResource, { id: before.id })\n if (!record) {\n record = em.create(ResourcesResource, {\n id: before.id,\n tenantId: before.tenantId,\n organizationId: before.organizationId,\n name: before.name,\n description: before.description ?? null,\n resourceTypeId: before.resourceTypeId ?? null,\n capacity: before.capacity ?? null,\n capacityUnitValue: before.capacityUnitValue ?? null,\n capacityUnitName: before.capacityUnitName ?? null,\n capacityUnitColor: before.capacityUnitColor ?? null,\n capacityUnitIcon: before.capacityUnitIcon ?? null,\n appearanceIcon: before.appearanceIcon ?? null,\n appearanceColor: before.appearanceColor ?? null,\n isActive: before.isActive,\n availabilityRuleSetId: before.availabilityRuleSetId ?? null,\n deletedAt: null,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n em.persist(record)\n } else {\n record.name = before.name\n record.description = before.description ?? null\n record.resourceTypeId = before.resourceTypeId ?? null\n record.capacity = before.capacity ?? null\n record.capacityUnitValue = before.capacityUnitValue ?? null\n record.capacityUnitName = before.capacityUnitName ?? null\n record.capacityUnitColor = before.capacityUnitColor ?? null\n record.capacityUnitIcon = before.capacityUnitIcon ?? null\n record.appearanceIcon = before.appearanceIcon ?? null\n record.appearanceColor = before.appearanceColor ?? null\n record.isActive = before.isActive\n record.availabilityRuleSetId = before.availabilityRuleSetId ?? null\n record.deletedAt = null\n record.updatedAt = new Date()\n }\n await em.flush()\n await syncResourcesResourceTags(em, {\n resourceId: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n tagIds: before.tags,\n })\n await em.flush()\n\n const dataEngine = (ctx.container.resolve('dataEngine') as DataEngine)\n const customBefore = payload.customBefore ?? fallbackCustomBefore ?? undefined\n if (customBefore) {\n const reset = buildCustomFieldResetMap(customBefore, undefined)\n await setCustomFieldsIfAny({\n dataEngine,\n entityId: E.resources.resources_resource,\n recordId: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n values: reset,\n })\n }\n\n await emitCrudUndoSideEffects({\n dataEngine,\n action: 'created',\n entity: record,\n identifiers: {\n id: record.id,\n organizationId: record.organizationId,\n tenantId: record.tenantId,\n },\n indexer: resourceCrudIndexer,\n })\n },\n}\n\nregisterCommand(createResourceCommand)\nregisterCommand(updateResourceCommand)\nregisterCommand(deleteResourceCommand)\n"],
|
|
5
|
+
"mappings": "AACA,SAA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,UAAU,QAAQ,YAAY;AACtD,UAAM,eAAe,QAAQ,gBAAgB,wBAAwB;AACrE,QAAI,cAAc;AAChB,YAAM,QAAQ,yBAAyB,cAAc,MAAS;AAC9D,YAAM,qBAAqB;AAAA,QACzB;AAAA,QACA,UAAU,EAAE,UAAU;AAAA,QACtB,UAAU,OAAO;AAAA,QACjB,UAAU,OAAO;AAAA,QACjB,gBAAgB,OAAO;AAAA,QACvB,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAEA,UAAM,wBAAwB;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,aAAa;AAAA,QACX,IAAI,OAAO;AAAA,QACX,gBAAgB,OAAO;AAAA,QACvB,UAAU,OAAO;AAAA,MACnB;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF;AAEA,gBAAgB,qBAAqB;AACrC,gBAAgB,qBAAqB;AACrC,gBAAgB,qBAAqB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -248,7 +248,7 @@ function normalizeAssetTag(value) {
|
|
|
248
248
|
const trimmed = value.trim();
|
|
249
249
|
if (!trimmed) return "RESOURCE";
|
|
250
250
|
const upper = trimmed.toUpperCase();
|
|
251
|
-
const normalized = upper.replace(/[^A-Z0-9]+/g, "-").replace(
|
|
251
|
+
const normalized = upper.replace(/[^A-Z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
252
252
|
return normalized || "RESOURCE";
|
|
253
253
|
}
|
|
254
254
|
function buildBaseResourceCustomValues(resourceName, seedKey) {
|