@open-mercato/core 0.6.6-develop.6453.1.6cbc2d5d47 → 0.6.6-develop.6456.1.d4b0c54321

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.
@@ -1,4 +1,4 @@
1
- [build:core] found 3457 entry points
1
+ [build:core] found 3458 entry points
2
2
  [build:core] built successfully
3
3
  [build:core:generated] found 186 entry points
4
4
  [build:core:generated] built successfully
@@ -3,7 +3,7 @@ const widget = {
3
3
  metadata: {
4
4
  id: "customer_accounts.injection.account-status",
5
5
  title: "Customer Account Status",
6
- description: "Shows customer portal account status on CRM person detail",
6
+ description: "customer_accounts.widgets.accountStatus.description",
7
7
  features: ["customer_accounts.view"],
8
8
  priority: 100,
9
9
  enabled: true
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/modules/customer_accounts/widgets/injection/account-status/widget.ts"],
4
- "sourcesContent": ["import type { InjectionWidgetModule } from '@open-mercato/shared/modules/widgets/injection'\nimport AccountStatusWidget from './widget.client'\n\nconst widget: InjectionWidgetModule<Record<string, unknown>, Record<string, unknown>> = {\n metadata: {\n id: 'customer_accounts.injection.account-status',\n title: 'Customer Account Status',\n description: 'Shows customer portal account status on CRM person detail',\n features: ['customer_accounts.view'],\n priority: 100,\n enabled: true,\n },\n Widget: AccountStatusWidget,\n}\n\nexport default widget\n"],
4
+ "sourcesContent": ["import type { InjectionWidgetModule } from '@open-mercato/shared/modules/widgets/injection'\nimport AccountStatusWidget from './widget.client'\n\nconst widget: InjectionWidgetModule<Record<string, unknown>, Record<string, unknown>> = {\n metadata: {\n id: 'customer_accounts.injection.account-status',\n title: 'Customer Account Status',\n description: 'customer_accounts.widgets.accountStatus.description',\n features: ['customer_accounts.view'],\n priority: 100,\n enabled: true,\n },\n Widget: AccountStatusWidget,\n}\n\nexport default widget\n"],
5
5
  "mappings": "AACA,OAAO,yBAAyB;AAEhC,MAAM,SAAkF;AAAA,EACtF,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU,CAAC,wBAAwB;AAAA,IACnC,UAAU;AAAA,IACV,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AACV;AAEA,IAAO,iBAAQ;",
6
6
  "names": []
7
7
  }
@@ -7,23 +7,13 @@ import { RowActions } from "@open-mercato/ui/backend/RowActions";
7
7
  import { Button } from "@open-mercato/ui/primitives/button";
8
8
  import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
9
9
  import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
10
+ import { buildEntitiesCsv } from "../lib/entitiesCsvExport.js";
10
11
  const columns = [
11
12
  { accessorKey: "entityId", header: "Entity", meta: { priority: 1 }, cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-mono", children: String(getValue()) }) },
12
13
  { accessorKey: "label", header: "Label", meta: { priority: 2 } },
13
14
  { accessorKey: "source", header: "Source", meta: { priority: 3 } },
14
15
  { accessorKey: "count", header: "Fields", meta: { priority: 4 } }
15
16
  ];
16
- function toCsv(rows) {
17
- const header = ["entityId", "label", "source", "count"];
18
- const esc = (s) => {
19
- const str = String(s ?? "");
20
- if (/[",\n]/.test(str)) return '"' + str.replace(/"/g, '""') + '"';
21
- return str;
22
- };
23
- const lines = [header.join(",")];
24
- for (const r of rows) lines.push([r.entityId, r.label, r.source, r.count].map(esc).join(","));
25
- return lines.join("\n");
26
- }
27
17
  function SystemEntitiesTable() {
28
18
  const [sorting, setSorting] = React.useState([{ id: "entityId", desc: false }]);
29
19
  const [page, setPage] = React.useState(1);
@@ -49,7 +39,7 @@ function SystemEntitiesTable() {
49
39
  {
50
40
  title: "System Entities",
51
41
  actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => {
52
- const csv = toCsv(rows);
42
+ const csv = buildEntitiesCsv(rows);
53
43
  const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
54
44
  const url = URL.createObjectURL(blob);
55
45
  const a = document.createElement("a");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/entities/components/SystemEntitiesTable.tsx"],
4
- "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useQuery } from '@tanstack/react-query'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\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 { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\n\ntype EntityRow = {\n entityId: string\n label: string\n source: 'code' | 'custom'\n count: number\n}\n\ntype EntitiesResponse = { items: EntityRow[] }\n\nconst columns: ColumnDef<EntityRow>[] = [\n { accessorKey: 'entityId', header: 'Entity', meta: { priority: 1 }, cell: ({ getValue }) => <span className=\"font-mono\">{String(getValue())}</span> },\n { accessorKey: 'label', header: 'Label', meta: { priority: 2 } },\n { accessorKey: 'source', header: 'Source', meta: { priority: 3 } },\n { accessorKey: 'count', header: 'Fields', meta: { priority: 4 } },\n]\n\nfunction toCsv(rows: EntityRow[]) {\n const header = ['entityId','label','source','count']\n const esc = (s: string | number) => {\n const str = String(s ?? '')\n if (/[\",\\n]/.test(str)) return '\"' + str.replace(/\"/g, '\"\"') + '\"'\n return str\n }\n const lines = [header.join(',')]\n for (const r of rows) lines.push([r.entityId, r.label, r.source, r.count].map(esc).join(','))\n return lines.join('\\n')\n}\n\nexport default function SystemEntitiesTable() {\n const [sorting, setSorting] = React.useState<SortingState>([{ id: 'entityId', desc: false }])\n const [page, setPage] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const scopeVersion = useOrganizationScopeVersion()\n\n const { data, isLoading } = useQuery<EntitiesResponse>({\n queryKey: ['custom-entities', scopeVersion],\n queryFn: async () => {\n return readApiResultOrThrow<EntitiesResponse>('/api/entities/entities', undefined, {\n errorMessage: 'Failed to load entities',\n })\n },\n })\n\n const rowsAll = data?.items || []\n // Filter to only show system entities (source: 'code')\n const systemRows = rowsAll.filter(row => row.source === 'code')\n const rows = React.useMemo(() => {\n if (!search) return systemRows\n const q = search.toLowerCase()\n return systemRows.filter(r => r.entityId.toLowerCase().includes(q) || r.label.toLowerCase().includes(q))\n }, [systemRows, search])\n\n return (\n <DataTable\n title=\"System Entities\"\n actions={(\n <>\n <Button variant=\"outline\" onClick={() => {\n const csv = toCsv(rows)\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = 'entities-system.csv'\n a.click()\n URL.revokeObjectURL(url)\n }}>Export</Button>\n </>\n )}\n columns={columns}\n data={rows}\n searchValue={search}\n onSearchChange={(v) => { setSearch(v); setPage(1) }}\n sortable\n sorting={sorting}\n onSortingChange={setSorting}\n perspective={{ tableId: 'entities.system.list' }}\n rowActions={(row) => (\n <RowActions\n items={[\n { id: 'edit', label: 'Edit', href: `/backend/entities/system/${encodeURIComponent(row.entityId)}` },\n ]}\n />\n )}\n pagination={{ page, pageSize: 50, total: rows.length, totalPages: 1, onPageChange: setPage }}\n isLoading={isLoading}\n />\n )\n}\n"],
5
- "mappings": ";AAoB8F,SA8CtF,UA9CsF;AAnB9F,YAAY,WAAW;AACvB,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAW5C,MAAM,UAAkC;AAAA,EACtC,EAAE,aAAa,YAAY,QAAQ,UAAU,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,SAAS,MAAM,oBAAC,UAAK,WAAU,aAAa,iBAAO,SAAS,CAAC,GAAE,EAAQ;AAAA,EACpJ,EAAE,aAAa,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ack/react-query'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\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 { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { buildEntitiesCsv } from '../lib/entitiesCsvExport'\n\ntype EntityRow = {\n entityId: string\n label: string\n source: 'code' | 'custom'\n count: number\n}\n\ntype EntitiesResponse = { items: EntityRow[] }\n\nconst columns: ColumnDef<EntityRow>[] = [\n { accessorKey: 'entityId', header: 'Entity', meta: { priority: 1 }, cell: ({ getValue }) => <span className=\"font-mono\">{String(getValue())}</span> },\n { accessorKey: 'label', header: 'Label', meta: { priority: 2 } },\n { accessorKey: 'source', header: 'Source', meta: { priority: 3 } },\n { accessorKey: 'count', header: 'Fields', meta: { priority: 4 } },\n]\n\nexport default function SystemEntitiesTable() {\n const [sorting, setSorting] = React.useState<SortingState>([{ id: 'entityId', desc: false }])\n const [page, setPage] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const scopeVersion = useOrganizationScopeVersion()\n\n const { data, isLoading } = useQuery<EntitiesResponse>({\n queryKey: ['custom-entities', scopeVersion],\n queryFn: async () => {\n return readApiResultOrThrow<EntitiesResponse>('/api/entities/entities', undefined, {\n errorMessage: 'Failed to load entities',\n })\n },\n })\n\n const rowsAll = data?.items || []\n // Filter to only show system entities (source: 'code')\n const systemRows = rowsAll.filter(row => row.source === 'code')\n const rows = React.useMemo(() => {\n if (!search) return systemRows\n const q = search.toLowerCase()\n return systemRows.filter(r => r.entityId.toLowerCase().includes(q) || r.label.toLowerCase().includes(q))\n }, [systemRows, search])\n\n return (\n <DataTable\n title=\"System Entities\"\n actions={(\n <>\n <Button variant=\"outline\" onClick={() => {\n const csv = buildEntitiesCsv(rows)\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = 'entities-system.csv'\n a.click()\n URL.revokeObjectURL(url)\n }}>Export</Button>\n </>\n )}\n columns={columns}\n data={rows}\n searchValue={search}\n onSearchChange={(v) => { setSearch(v); setPage(1) }}\n sortable\n sorting={sorting}\n onSortingChange={setSorting}\n perspective={{ tableId: 'entities.system.list' }}\n rowActions={(row) => (\n <RowActions\n items={[\n { id: 'edit', label: 'Edit', href: `/backend/entities/system/${encodeURIComponent(row.entityId)}` },\n ]}\n />\n )}\n pagination={{ page, pageSize: 50, total: rows.length, totalPages: 1, onPageChange: setPage }}\n isLoading={isLoading}\n />\n )\n}\n"],
5
+ "mappings": ";AAqB8F,SAkCtF,UAlCsF;AApB9F,YAAY,WAAW;AACvB,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AAWjC,MAAM,UAAkC;AAAA,EACtC,EAAE,aAAa,YAAY,QAAQ,UAAU,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,SAAS,MAAM,oBAAC,UAAK,WAAU,aAAa,iBAAO,SAAS,CAAC,GAAE,EAAQ;AAAA,EACpJ,EAAE,aAAa,SAAS,QAAQ,SAAS,MAAM,EAAE,UAAU,EAAE,EAAE;AAAA,EAC/D,EAAE,aAAa,UAAU,QAAQ,UAAU,MAAM,EAAE,UAAU,EAAE,EAAE;AAAA,EACjE,EAAE,aAAa,SAAS,QAAQ,UAAU,MAAM,EAAE,UAAU,EAAE,EAAE;AAClE;AAEe,SAAR,sBAAuC;AAC5C,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAuB,CAAC,EAAE,IAAI,YAAY,MAAM,MAAM,CAAC,CAAC;AAC5F,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,CAAC;AACxC,QA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AS,uBAAuB;AAAA,MAC/C,YAAY,CAAC,QACX;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,EAAE,IAAI,QAAQ,OAAO,QAAQ,MAAM,4BAA4B,mBAAmB,IAAI,QAAQ,CAAC,GAAG;AAAA,UACpG;AAAA;AAAA,MACF;AAAA,MAEF,YAAY,EAAE,MAAM,UAAU,IAAI,OAAO,KAAK,QAAQ,YAAY,GAAG,cAAc,QAAQ;AAAA,MAC3F;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -8,6 +8,7 @@ import { ListEmptyState } from "@open-mercato/ui/backend/filters/ListEmptyState"
8
8
  import { readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
9
9
  import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
10
10
  import { useT } from "@open-mercato/shared/lib/i18n/context";
11
+ import { buildEntitiesCsv } from "../lib/entitiesCsvExport.js";
11
12
  function buildColumns(t) {
12
13
  return [
13
14
  { accessorKey: "entityId", header: t("entities.user.table.column.entity", "Entity"), meta: { priority: 1 }, cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-mono", children: String(getValue()) }) },
@@ -22,17 +23,6 @@ function buildColumns(t) {
22
23
  }
23
24
  ];
24
25
  }
25
- function toCsv(rows) {
26
- const header = ["entityId", "label", "source", "count", "showInSidebar"];
27
- const esc = (s) => {
28
- const str = String(s ?? "");
29
- if (/[",\n]/.test(str)) return '"' + str.replace(/"/g, '""') + '"';
30
- return str;
31
- };
32
- const lines = [header.join(",")];
33
- for (const r of rows) lines.push([r.entityId, r.label, r.source, r.count, r.showInSidebar || false].map(esc).join(","));
34
- return lines.join("\n");
35
- }
36
26
  function UserEntitiesTable() {
37
27
  const t = useT();
38
28
  const [sorting, setSorting] = React.useState([{ id: "entityId", desc: false }]);
@@ -61,7 +51,7 @@ function UserEntitiesTable() {
61
51
  title: t("entities.user.table.title", "User Entities"),
62
52
  actions: /* @__PURE__ */ jsxs(Fragment, { children: [
63
53
  /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => {
64
- const csv = toCsv(rows);
54
+ const csv = buildEntitiesCsv(rows, { includeSidebar: true });
65
55
  const blob = new Blob([csv], { type: "text/csv;charset=utf-8;" });
66
56
  const url = URL.createObjectURL(blob);
67
57
  const a = document.createElement("a");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/entities/components/UserEntitiesTable.tsx"],
4
- "sourcesContent": ["\n\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useQuery } from '@tanstack/react-query'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\nimport { DataTable, RowActions, Button } from '@open-mercato/ui'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\ntype EntityRow = {\n entityId: string\n label: string\n source: 'code' | 'custom'\n count: number\n showInSidebar?: boolean\n}\n\ntype EntitiesResponse = { items: EntityRow[] }\n\nfunction buildColumns(t: (key: string, fallback: string) => string): ColumnDef<EntityRow>[] {\n return [\n { accessorKey: 'entityId', header: t('entities.user.table.column.entity', 'Entity'), meta: { priority: 1 }, cell: ({ getValue }) => <span className=\"font-mono\">{String(getValue())}</span> },\n { accessorKey: 'label', header: t('entities.user.table.column.label', 'Label'), meta: { priority: 2 } },\n { accessorKey: 'source', header: t('entities.user.table.column.source', 'Source'), meta: { priority: 3 } },\n { accessorKey: 'count', header: t('entities.user.table.column.fields', 'Fields'), meta: { priority: 4 } },\n { \n accessorKey: 'showInSidebar', \n header: t('entities.user.table.column.inSidebar', 'In Sidebar'), \n meta: { priority: 5 },\n cell: ({ getValue }) => (\n <span className={`px-2 py-1 rounded text-xs ${\n getValue() ? 'bg-status-success-bg text-status-success-text' : 'bg-muted text-muted-foreground'\n }`}>\n {getValue() ? t('common.yes', 'Yes') : t('common.no', 'No')}\n </span>\n )\n },\n ]\n}\n\nfunction toCsv(rows: EntityRow[]) {\n const header = ['entityId','label','source','count','showInSidebar']\n const esc = (s: string | number | boolean) => {\n const str = String(s ?? '')\n if (/[\",\\n]/.test(str)) return '\"' + str.replace(/\"/g, '\"\"') + '\"'\n return str\n }\n const lines = [header.join(',')]\n for (const r of rows) lines.push([r.entityId, r.label, r.source, r.count, r.showInSidebar || false].map(esc).join(','))\n return lines.join('\\n')\n}\n\nexport default function UserEntitiesTable() {\n const t = useT()\n const [sorting, setSorting] = React.useState<SortingState>([{ id: 'entityId', desc: false }])\n const [page, setPage] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const scopeVersion = useOrganizationScopeVersion()\n \n const columns = React.useMemo(() => buildColumns(t), [t])\n\n const { data, isLoading } = useQuery<EntitiesResponse>({\n queryKey: ['custom-entities', scopeVersion],\n queryFn: async () => {\n return readApiResultOrThrow<EntitiesResponse>('/api/entities/entities', undefined, {\n errorMessage: 'Failed to load entities',\n })\n },\n })\n\n const rowsAll = data?.items || []\n // Filter to only show user entities (source: 'custom')\n const userRows = rowsAll.filter(row => row.source === 'custom')\n const rows = React.useMemo(() => {\n if (!search) return userRows\n const q = search.toLowerCase()\n return userRows.filter(r => r.entityId.toLowerCase().includes(q) || r.label.toLowerCase().includes(q))\n }, [userRows, search])\n\n return (\n <DataTable\n title={t('entities.user.table.title', 'User Entities')}\n actions={(\n <>\n <Button variant=\"outline\" onClick={() => {\n const csv = toCsv(rows)\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = 'entities-user.csv'\n a.click()\n URL.revokeObjectURL(url)\n }}>{t('common.export', 'Export')}</Button>\n <Button asChild>\n <Link href=\"/backend/entities/user/create\">{t('common.create', 'Create')}</Link>\n </Button>\n </>\n )}\n columns={columns}\n data={rows}\n searchValue={search}\n onSearchChange={(v) => { setSearch(v); setPage(1) }}\n sortable\n sorting={sorting}\n onSortingChange={setSorting}\n perspective={{ tableId: 'entities.user.list' }}\n emptyState={(\n <ListEmptyState\n entityName={t('entities.user.table.title', 'User Entities')}\n createHref=\"/backend/entities/user/create\"\n createLabel={t('common.create', 'Create')}\n />\n )}\n rowActions={(row) => (\n <RowActions\n items={[\n { id: 'edit', label: t('common.edit', 'Edit'), href: `/backend/entities/user/${encodeURIComponent(row.entityId)}` },\n { id: 'show-records', label: t('entities.user.table.actions.showRecords', 'Show records'), href: `/backend/entities/user/${encodeURIComponent(row.entityId)}/records` },\n ]}\n />\n )}\n pagination={{ page, pageSize: 50, total: rows.length, totalPages: 1, onPageChange: setPage }}\n isLoading={isLoading}\n />\n )\n}\n"],
5
- "mappings": ";AAwBwI,SA8DhI,UA9DgI,KA8DhI,YA9DgI;AAtBxI,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,gBAAgB;AAEzB,SAAS,WAAW,YAAY,cAAc;AAC9C,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AAYrB,SAAS,aAAa,GAAsE;AAC1F,SAAO;AAAA,IACL,EAAE,aAAa,YAAY,QAAQ,EAAE,qCAAqC,QAAQ,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,SAAS,MAAM,oBAAC,UAAK,WAAU,aAAa,iBAAO,SAAS,CAAC,GAAE,EAAQ;AAAA,IAC5L,EAAE,aAAa,SAAS,QAAQ,EAAE,oCAAoC,OAAO,GAAG,MAAM,EAAE,UAAU,EAAE,EAAE;AAAA,IACtG,EAAE,aAAa,UAAU,QAAQ,EAAE,qCAAqC,QAAQ,GAAG,MAAM,EAAE,UAAU,EAAE,EAAE;AAAA,IACzG,EAAE,aAAa,SAAS,QAAQ,EAAE,qCAAqC,QAAQ,GAAG,MAAM,EAAE,UAAU,E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,SAAS,qBAAqB;AAAA,MAC7C,YACE;AAAA,QAAC;AAAA;AAAA,UACC,YAAY,EAAE,6BAA6B,eAAe;AAAA,UAC1D,YAAW;AAAA,UACX,aAAa,EAAE,iBAAiB,QAAQ;AAAA;AAAA,MAC1C;AAAA,MAEF,YAAY,CAAC,QACX;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,EAAE,IAAI,QAAQ,OAAO,EAAE,eAAe,MAAM,GAAG,MAAM,0BAA0B,mBAAmB,IAAI,QAAQ,CAAC,GAAG;AAAA,YAClH,EAAE,IAAI,gBAAgB,OAAO,EAAE,2CAA2C,cAAc,GAAG,MAAM,0BAA0B,mBAAmB,IAAI,QAAQ,CAAC,WAAW;AAAA,UACxK;AAAA;AAAA,MACF;AAAA,MAEF,YAAY,EAAE,MAAM,UAAU,IAAI,OAAO,KAAK,QAAQ,YAAY,GAAG,cAAc,QAAQ;AAAA,MAC3F;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["\n\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useQuery } from '@tanstack/react-query'\nimport type { ColumnDef, SortingState } from '@tanstack/react-table'\nimport { DataTable, RowActions, Button } from '@open-mercato/ui'\nimport { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { buildEntitiesCsv } from '../lib/entitiesCsvExport'\n\ntype EntityRow = {\n entityId: string\n label: string\n source: 'code' | 'custom'\n count: number\n showInSidebar?: boolean\n}\n\ntype EntitiesResponse = { items: EntityRow[] }\n\nfunction buildColumns(t: (key: string, fallback: string) => string): ColumnDef<EntityRow>[] {\n return [\n { accessorKey: 'entityId', header: t('entities.user.table.column.entity', 'Entity'), meta: { priority: 1 }, cell: ({ getValue }) => <span className=\"font-mono\">{String(getValue())}</span> },\n { accessorKey: 'label', header: t('entities.user.table.column.label', 'Label'), meta: { priority: 2 } },\n { accessorKey: 'source', header: t('entities.user.table.column.source', 'Source'), meta: { priority: 3 } },\n { accessorKey: 'count', header: t('entities.user.table.column.fields', 'Fields'), meta: { priority: 4 } },\n { \n accessorKey: 'showInSidebar', \n header: t('entities.user.table.column.inSidebar', 'In Sidebar'), \n meta: { priority: 5 },\n cell: ({ getValue }) => (\n <span className={`px-2 py-1 rounded text-xs ${\n getValue() ? 'bg-status-success-bg text-status-success-text' : 'bg-muted text-muted-foreground'\n }`}>\n {getValue() ? t('common.yes', 'Yes') : t('common.no', 'No')}\n </span>\n )\n },\n ]\n}\n\nexport default function UserEntitiesTable() {\n const t = useT()\n const [sorting, setSorting] = React.useState<SortingState>([{ id: 'entityId', desc: false }])\n const [page, setPage] = React.useState(1)\n const [search, setSearch] = React.useState('')\n const scopeVersion = useOrganizationScopeVersion()\n \n const columns = React.useMemo(() => buildColumns(t), [t])\n\n const { data, isLoading } = useQuery<EntitiesResponse>({\n queryKey: ['custom-entities', scopeVersion],\n queryFn: async () => {\n return readApiResultOrThrow<EntitiesResponse>('/api/entities/entities', undefined, {\n errorMessage: 'Failed to load entities',\n })\n },\n })\n\n const rowsAll = data?.items || []\n // Filter to only show user entities (source: 'custom')\n const userRows = rowsAll.filter(row => row.source === 'custom')\n const rows = React.useMemo(() => {\n if (!search) return userRows\n const q = search.toLowerCase()\n return userRows.filter(r => r.entityId.toLowerCase().includes(q) || r.label.toLowerCase().includes(q))\n }, [userRows, search])\n\n return (\n <DataTable\n title={t('entities.user.table.title', 'User Entities')}\n actions={(\n <>\n <Button variant=\"outline\" onClick={() => {\n const csv = buildEntitiesCsv(rows, { includeSidebar: true })\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = 'entities-user.csv'\n a.click()\n URL.revokeObjectURL(url)\n }}>{t('common.export', 'Export')}</Button>\n <Button asChild>\n <Link href=\"/backend/entities/user/create\">{t('common.create', 'Create')}</Link>\n </Button>\n </>\n )}\n columns={columns}\n data={rows}\n searchValue={search}\n onSearchChange={(v) => { setSearch(v); setPage(1) }}\n sortable\n sorting={sorting}\n onSortingChange={setSorting}\n perspective={{ tableId: 'entities.user.list' }}\n emptyState={(\n <ListEmptyState\n entityName={t('entities.user.table.title', 'User Entities')}\n createHref=\"/backend/entities/user/create\"\n createLabel={t('common.create', 'Create')}\n />\n )}\n rowActions={(row) => (\n <RowActions\n items={[\n { id: 'edit', label: t('common.edit', 'Edit'), href: `/backend/entities/user/${encodeURIComponent(row.entityId)}` },\n { id: 'show-records', label: t('entities.user.table.actions.showRecords', 'Show records'), href: `/backend/entities/user/${encodeURIComponent(row.entityId)}/records` },\n ]}\n />\n )}\n pagination={{ page, pageSize: 50, total: rows.length, totalPages: 1, onPageChange: setPage }}\n isLoading={isLoading}\n />\n )\n}\n"],
5
+ "mappings": ";AAyBwI,SAkDhI,UAlDgI,KAkDhI,YAlDgI;AAvBxI,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,gBAAgB;AAEzB,SAAS,WAAW,YAAY,cAAc;AAC9C,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,wBAAwB;AAYjC,SAAS,aAAa,GAAsE;AAC1F,SAAO;AAAA,IACL,EAAE,aAAa,YAAY,QAAQ,EAAE,qCAAqC,QAAQ,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,EAAE,SAAS,MAAM,oBAAC,UAAK,WAAU,aAAa,iBAAO,SAAS,CAAC,GAAE,EAAQ;AAAA,IAC5L,EAAE,aAAa,SAAS,QAAQ,EAAE,oCAAoC,OAAO,GAAG,MAAM,EAAE,UAAU,EAAE,EAAE;AAAA,IACtG,EAAE,aAAa,UAAU,QAAQ,EAAE,qCAAqC,QAAQ,GAAG,MA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AE,IAAI,gBAAgB,OAAO,EAAE,2CAA2C,cAAc,GAAG,MAAM,0BAA0B,mBAAmB,IAAI,QAAQ,CAAC,WAAW;AAAA,UACxK;AAAA;AAAA,MACF;AAAA,MAEF,YAAY,EAAE,MAAM,UAAU,IAAI,OAAO,KAAK,QAAQ,YAAY,GAAG,cAAc,QAAQ;AAAA,MAC3F;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,26 @@
1
+ import { serializeExport } from "@open-mercato/shared/lib/crud/exporters";
2
+ function buildEntitiesCsv(rows, options) {
3
+ const includeSidebar = options?.includeSidebar ?? false;
4
+ const columns = [
5
+ { field: "entityId", header: "entityId" },
6
+ { field: "label", header: "label" },
7
+ { field: "source", header: "source" },
8
+ { field: "count", header: "count" }
9
+ ];
10
+ if (includeSidebar) columns.push({ field: "showInSidebar", header: "showInSidebar" });
11
+ const prepared = {
12
+ columns,
13
+ rows: rows.map((row) => ({
14
+ entityId: row.entityId,
15
+ label: row.label,
16
+ source: row.source,
17
+ count: row.count,
18
+ ...includeSidebar ? { showInSidebar: row.showInSidebar || false } : {}
19
+ }))
20
+ };
21
+ return serializeExport(prepared, "csv").body;
22
+ }
23
+ export {
24
+ buildEntitiesCsv
25
+ };
26
+ //# sourceMappingURL=entitiesCsvExport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/entities/lib/entitiesCsvExport.ts"],
4
+ "sourcesContent": ["import { serializeExport, type CrudExportColumn, type PreparedExport } from '@open-mercato/shared/lib/crud/exporters'\n\nexport type EntitiesExportRow = {\n entityId: string\n label: string\n source: 'code' | 'custom'\n count: number\n showInSidebar?: boolean\n}\n\nexport function buildEntitiesCsv(rows: EntitiesExportRow[], options?: { includeSidebar?: boolean }): string {\n const includeSidebar = options?.includeSidebar ?? false\n const columns: CrudExportColumn[] = [\n { field: 'entityId', header: 'entityId' },\n { field: 'label', header: 'label' },\n { field: 'source', header: 'source' },\n { field: 'count', header: 'count' },\n ]\n if (includeSidebar) columns.push({ field: 'showInSidebar', header: 'showInSidebar' })\n const prepared: PreparedExport = {\n columns,\n rows: rows.map((row) => ({\n entityId: row.entityId,\n label: row.label,\n source: row.source,\n count: row.count,\n ...(includeSidebar ? { showInSidebar: row.showInSidebar || false } : {}),\n })),\n }\n return serializeExport(prepared, 'csv').body\n}\n"],
5
+ "mappings": "AAAA,SAAS,uBAAmE;AAUrE,SAAS,iBAAiB,MAA2B,SAAgD;AAC1G,QAAM,iBAAiB,SAAS,kBAAkB;AAClD,QAAM,UAA8B;AAAA,IAClC,EAAE,OAAO,YAAY,QAAQ,WAAW;AAAA,IACxC,EAAE,OAAO,SAAS,QAAQ,QAAQ;AAAA,IAClC,EAAE,OAAO,UAAU,QAAQ,SAAS;AAAA,IACpC,EAAE,OAAO,SAAS,QAAQ,QAAQ;AAAA,EACpC;AACA,MAAI,eAAgB,SAAQ,KAAK,EAAE,OAAO,iBAAiB,QAAQ,gBAAgB,CAAC;AACpF,QAAM,WAA2B;AAAA,IAC/B;AAAA,IACA,MAAM,KAAK,IAAI,CAAC,SAAS;AAAA,MACvB,UAAU,IAAI;AAAA,MACd,OAAO,IAAI;AAAA,MACX,QAAQ,IAAI;AAAA,MACZ,OAAO,IAAI;AAAA,MACX,GAAI,iBAAiB,EAAE,eAAe,IAAI,iBAAiB,MAAM,IAAI,CAAC;AAAA,IACxE,EAAE;AAAA,EACJ;AACA,SAAO,gBAAgB,UAAU,KAAK,EAAE;AAC1C;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/staff/commands/shared.ts"],
4
- "sourcesContent": ["import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { ensureOrganizationScope, ensureTenantScope } from '@open-mercato/shared/lib/commands/scope'\nimport { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'\nimport type { EntityManager, FilterQuery } from '@mikro-orm/postgresql'\nimport { StaffTeamMember } from '../data/entities'\n\nexport { ensureOrganizationScope, ensureTenantScope, extractUndoPayload }\n\nexport type StaffCommandScope = {\n tenantId: string | null\n organizationId: string | null\n requireTenant: boolean\n requireOrganization: boolean\n}\n\nexport function commandActorScope(ctx: CommandRuntimeContext): StaffCommandScope {\n const isPrivilegedActor = ctx.auth?.isSuperAdmin === true || ctx.systemActor === true\n const tenantId = isPrivilegedActor ? null : (ctx.auth?.tenantId ?? ctx.organizationScope?.tenantId ?? null)\n const organizationId = isPrivilegedActor ? null : (ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null)\n const organizationUnrestricted =\n isPrivilegedActor || (organizationId === null && tenantId !== null && ctx.organizationScope?.allowedIds === null)\n return {\n tenantId,\n organizationId: organizationUnrestricted ? null : organizationId,\n requireTenant: !isPrivilegedActor,\n requireOrganization: !organizationUnrestricted,\n }\n}\n\nexport function explicitStaffCommandScope(tenantId: string | null, organizationId: string | null): StaffCommandScope {\n return {\n tenantId,\n organizationId,\n requireTenant: true,\n requireOrganization: true,\n }\n}\n\nexport function commandInputScope(ctx: CommandRuntimeContext, tenantId: string, organizationId: string): StaffCommandScope {\n if (ctx.auth?.isSuperAdmin === true || ctx.systemActor === true) {\n return explicitStaffCommandScope(tenantId, organizationId)\n }\n\n ensureTenantScope(ctx, tenantId)\n ensureOrganizationScope(ctx, organizationId)\n\n const actorTenantId = ctx.auth?.tenantId ?? ctx.organizationScope?.tenantId ?? null\n if (!actorTenantId || actorTenantId !== tenantId) {\n throw new CrudHttpError(403, { error: 'Forbidden' })\n }\n\n if (!ctx.organizationScope) {\n const currentOrganizationId = ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null\n if (!currentOrganizationId || currentOrganizationId !== organizationId) {\n throw new CrudHttpError(403, { error: 'Forbidden' })\n }\n }\n\n return explicitStaffCommandScope(tenantId, organizationId)\n}\n\nexport function applyScopeToWhere<TEntity extends object>(\n where: FilterQuery<TEntity>,\n scope: StaffCommandScope,\n): FilterQuery<TEntity> {\n const scoped = { ...(where as Record<string, unknown>) }\n if (scope.requireTenant || scope.tenantId !== null) scoped.tenantId = scope.tenantId\n if (scope.requireOrganization || scope.organizationId !== null) scoped.organizationId = scope.organizationId\n return scoped as FilterQuery<TEntity>\n}\n\nexport function scopeForDecryption(scope: StaffCommandScope): { tenantId: string | null; organizationId: string | null } {\n return { tenantId: scope.tenantId, organizationId: scope.organizationId }\n}\n\nexport async function requireTeamMember(\n em: EntityManager,\n memberId: string,\n scope: StaffCommandScope,\n message = 'Team member not found',\n): Promise<StaffTeamMember> {\n const member = await em.findOne(\n StaffTeamMember,\n applyScopeToWhere<StaffTeamMember>({ id: memberId, deletedAt: null }, scope),\n )\n if (!member) throw new CrudHttpError(404, { error: message })\n return member\n}\n"],
5
- "mappings": "AACA,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB,yBAAyB;AAC3D,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAWzB,SAAS,kBAAkB,KAA+C;AAC/E,QAAM,oBAAoB,IAAI,MAAM,iBAAiB,QAAQ,IAAI,gBAAgB;AACjF,QAAM,WAAW,oBAAoB,OAAQ,IAAI,MAAM,YAAY,IAAI,mBAAmB,YAAY;AACtG,QAAM,iBAAiB,oBAAoB,OAAQ,IAAI,0BAA0B,IAAI,MAAM,SAAS;AACpG,QAAM,2BACJ,qBAAsB,mBAAmB,QAAQ,aAAa,QAAQ,IAAI,mBAAmB,eAAe;AAC9G,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB,2BAA2B,OAAO;AAAA,IAClD,eAAe,CAAC;AAAA,IAChB,qBAAqB,CAAC;AAAA,EACxB;AACF;AAEO,SAAS,0BAA0B,UAAyB,gBAAkD;AACnH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,qBAAqB;AAAA,EACvB;AACF;AAEO,SAAS,kBAAkB,KAA4B,UAAkB,gBAA2C;AACzH,MAAI,IAAI,MAAM,iBAAiB,QAAQ,IAAI,gBAAgB,MAAM;AAC/D,WAAO,0BAA0B,UAAU,cAAc;AAAA,EAC3D;AAEA,oBAAkB,KAAK,QAAQ;AAC/B,0BAAwB,KAAK,cAAc;AAE3C,QAAM,gBAAgB,IAAI,MAAM,YAAY,IAAI,mBAAmB,YAAY;AAC/E,MAAI,CAAC,iBAAiB,kBAAkB,UAAU;AAChD,UAAM,IAAI,cAAc,KAAK,EAAE,OAAO,YAAY,CAAC;AAAA,EACrD;AAEA,MAAI,CAAC,IAAI,mBAAmB;AAC1B,UAAM,wBAAwB,IAAI,0BAA0B,IAAI,MAAM,SAAS;AAC/E,QAAI,CAAC,yBAAyB,0BAA0B,gBAAgB;AACtE,YAAM,IAAI,cAAc,KAAK,EAAE,OAAO,YAAY,CAAC;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,0BAA0B,UAAU,cAAc;AAC3D;AAEO,SAAS,kBACd,OACA,OACsB;AACtB,QAAM,SAAS,EAAE,GAAI,MAAkC;AACvD,MAAI,MAAM,iBAAiB,MAAM,aAAa,KAAM,QAAO,WAAW,MAAM;AAC5E,MAAI,MAAM,uBAAuB,MAAM,mBAAmB,KAAM,QAAO,iBAAiB,MAAM;AAC9F,SAAO;AACT;AAEO,SAAS,mBAAmB,OAAsF;AACvH,SAAO,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAC1E;AAEA,eAAsB,kBACpB,IACA,UACA,OACA,UAAU,yBACgB;AAC1B,QAAM,SAAS,MAAM,GAAG;AAAA,IACtB;AAAA,IACA,kBAAmC,EAAE,IAAI,UAAU,WAAW,KAAK,GAAG,KAAK;AAAA,EAC7E;AACA,MAAI,CAAC,OAAQ,OAAM,IAAI,cAAc,KAAK,EAAE,OAAO,QAAQ,CAAC;AAC5D,SAAO;AACT;",
4
+ "sourcesContent": ["import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'\nimport { ensureOrganizationScope, ensureTenantScope } from '@open-mercato/shared/lib/commands/scope'\nimport { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'\nimport type { EntityManager, FilterQuery } from '@mikro-orm/postgresql'\nimport { StaffTeamMember } from '../data/entities'\n\nexport { ensureOrganizationScope, ensureTenantScope, extractUndoPayload }\n\nexport type StaffCommandScope = {\n tenantId: string | null\n organizationId: string | null\n requireTenant: boolean\n requireOrganization: boolean\n}\n\nexport function commandActorScope(ctx: CommandRuntimeContext): StaffCommandScope {\n const isPrivilegedActor = ctx.auth?.isSuperAdmin === true || ctx.systemActor === true\n const tenantId = isPrivilegedActor ? null : (ctx.auth?.tenantId ?? ctx.organizationScope?.tenantId ?? null)\n const organizationId = isPrivilegedActor ? null : (ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null)\n const organizationUnrestricted =\n isPrivilegedActor || (organizationId === null && tenantId !== null && ctx.organizationScope?.allowedIds === null)\n return {\n tenantId,\n organizationId: organizationUnrestricted ? null : organizationId,\n requireTenant: !isPrivilegedActor,\n requireOrganization: !organizationUnrestricted,\n }\n}\n\nexport function explicitStaffCommandScope(tenantId: string | null, organizationId: string | null): StaffCommandScope {\n return {\n tenantId,\n organizationId,\n requireTenant: true,\n requireOrganization: true,\n }\n}\n\nexport function commandInputScope(ctx: CommandRuntimeContext, tenantId: string, organizationId: string): StaffCommandScope {\n if (ctx.auth?.isSuperAdmin === true || ctx.systemActor === true) {\n return explicitStaffCommandScope(tenantId, organizationId)\n }\n\n ensureTenantScope(ctx, tenantId)\n ensureOrganizationScope(ctx, organizationId)\n\n const actorTenantId = ctx.auth?.tenantId ?? ctx.organizationScope?.tenantId ?? null\n if (!actorTenantId || actorTenantId !== tenantId) {\n throw new CrudHttpError(403, { error: 'Forbidden' })\n }\n\n if (!ctx.organizationScope) {\n const currentOrganizationId = ctx.selectedOrganizationId ?? ctx.auth?.orgId ?? null\n if (!currentOrganizationId || currentOrganizationId !== organizationId) {\n throw new CrudHttpError(403, { error: 'Forbidden' })\n }\n }\n\n return explicitStaffCommandScope(tenantId, organizationId)\n}\n\nexport function applyScopeToWhere<TEntity extends object>(\n where: FilterQuery<TEntity>,\n scope: StaffCommandScope,\n): FilterQuery<TEntity> {\n const scoped = { ...(where as Record<string, unknown>) }\n if (scope.requireTenant || scope.tenantId !== null) scoped.tenantId = scope.tenantId\n if (scope.requireOrganization || scope.organizationId !== null) scoped.organizationId = scope.organizationId\n return scoped as FilterQuery<TEntity>\n}\n\nexport function scopeForDecryption(scope: StaffCommandScope): { tenantId: string | null; organizationId: string | null } {\n return { tenantId: scope.tenantId, organizationId: scope.organizationId }\n}\n\nexport async function requireTeamMember(\n em: EntityManager,\n memberId: string,\n scope: StaffCommandScope,\n message = 'Team member not found',\n): Promise<StaffTeamMember> {\n const member = await em.findOne(\n StaffTeamMember,\n applyScopeToWhere<StaffTeamMember>({ id: memberId, deletedAt: null }, scope),\n )\n if (!member) throw new CrudHttpError(404, { error: message })\n return member\n}\n"],
5
+ "mappings": "AACA,SAAS,qBAAqB;AAE9B,SAAS,yBAAyB,yBAAyB;AAC3D,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAWzB,SAAS,kBAAkB,KAA+C;AAC/E,QAAM,oBAAoB,IAAI,MAAM,iBAAiB,QAAQ,IAAI,gBAAgB;AACjF,QAAM,WAAW,oBAAoB,OAAQ,IAAI,MAAM,YAAY,IAAI,mBAAmB,YAAY;AACtG,QAAM,iBAAiB,oBAAoB,OAAQ,IAAI,0BAA0B,IAAI,MAAM,SAAS;AACpG,QAAM,2BACJ,qBAAsB,mBAAmB,QAAQ,aAAa,QAAQ,IAAI,mBAAmB,eAAe;AAC9G,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB,2BAA2B,OAAO;AAAA,IAClD,eAAe,CAAC;AAAA,IAChB,qBAAqB,CAAC;AAAA,EACxB;AACF;AAEO,SAAS,0BAA0B,UAAyB,gB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AK,EAAE,OAAO,QAAQ,CAAC;AAC5D,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/core",
3
- "version": "0.6.6-develop.6453.1.6cbc2d5d47",
3
+ "version": "0.6.6-develop.6456.1.d4b0c54321",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -253,16 +253,16 @@
253
253
  "zod": "^4.4.3"
254
254
  },
255
255
  "peerDependencies": {
256
- "@open-mercato/ai-assistant": "0.6.6-develop.6453.1.6cbc2d5d47",
257
- "@open-mercato/shared": "0.6.6-develop.6453.1.6cbc2d5d47",
258
- "@open-mercato/ui": "0.6.6-develop.6453.1.6cbc2d5d47",
256
+ "@open-mercato/ai-assistant": "0.6.6-develop.6456.1.d4b0c54321",
257
+ "@open-mercato/shared": "0.6.6-develop.6456.1.d4b0c54321",
258
+ "@open-mercato/ui": "0.6.6-develop.6456.1.d4b0c54321",
259
259
  "react": "^19.0.0",
260
260
  "react-dom": "^19.0.0"
261
261
  },
262
262
  "devDependencies": {
263
- "@open-mercato/ai-assistant": "0.6.6-develop.6453.1.6cbc2d5d47",
264
- "@open-mercato/shared": "0.6.6-develop.6453.1.6cbc2d5d47",
265
- "@open-mercato/ui": "0.6.6-develop.6453.1.6cbc2d5d47",
263
+ "@open-mercato/ai-assistant": "0.6.6-develop.6456.1.d4b0c54321",
264
+ "@open-mercato/shared": "0.6.6-develop.6456.1.d4b0c54321",
265
+ "@open-mercato/ui": "0.6.6-develop.6456.1.d4b0c54321",
266
266
  "@testing-library/dom": "^10.4.1",
267
267
  "@testing-library/jest-dom": "^6.9.1",
268
268
  "@testing-library/react": "^16.3.1",
@@ -317,16 +317,17 @@
317
317
  "customer_accounts.signup.existing.subject": "You already have a portal account",
318
318
  "customer_accounts.signup.existing.title": "You already have a portal account",
319
319
  "customer_accounts.widgets.accountStatus": "Kontostatus",
320
+ "customer_accounts.widgets.accountStatus.description": "Zeigt den Status des Kundenportal-Kontos in der CRM-Personendetailansicht",
320
321
  "customer_accounts.widgets.emailVerified": "E-Mail verifiziert",
321
- "customer_accounts.widgets.invite.button": "Invite to Portal",
322
- "customer_accounts.widgets.invite.displayName": "Display Name",
323
- "customer_accounts.widgets.invite.error.emailRequired": "Email is required",
324
- "customer_accounts.widgets.invite.error.failed": "Failed to send invitation",
325
- "customer_accounts.widgets.invite.error.roleRequired": "At least one role must be selected",
326
- "customer_accounts.widgets.invite.noRoles": "No roles available",
327
- "customer_accounts.widgets.invite.roles": "Roles",
328
- "customer_accounts.widgets.invite.submit": "Send Invitation",
329
- "customer_accounts.widgets.invite.success": "Invitation sent successfully",
322
+ "customer_accounts.widgets.invite.button": "Zum Portal einladen",
323
+ "customer_accounts.widgets.invite.displayName": "Anzeigename",
324
+ "customer_accounts.widgets.invite.error.emailRequired": "E-Mail-Adresse ist erforderlich",
325
+ "customer_accounts.widgets.invite.error.failed": "Einladung konnte nicht gesendet werden",
326
+ "customer_accounts.widgets.invite.error.roleRequired": "Mindestens eine Rolle muss ausgewählt werden",
327
+ "customer_accounts.widgets.invite.noRoles": "Keine Rollen verfügbar",
328
+ "customer_accounts.widgets.invite.roles": "Rollen",
329
+ "customer_accounts.widgets.invite.submit": "Einladung senden",
330
+ "customer_accounts.widgets.invite.success": "Einladung erfolgreich gesendet",
330
331
  "customer_accounts.widgets.lastLogin": "Letzte Anmeldung",
331
332
  "customer_accounts.widgets.noAccount": "Kein verknüpftes Konto",
332
333
  "customer_accounts.widgets.noUsers": "Keine verknüpften Benutzer",
@@ -317,6 +317,7 @@
317
317
  "customer_accounts.signup.existing.subject": "You already have a portal account",
318
318
  "customer_accounts.signup.existing.title": "You already have a portal account",
319
319
  "customer_accounts.widgets.accountStatus": "Account status",
320
+ "customer_accounts.widgets.accountStatus.description": "Shows customer portal account status on CRM person detail",
320
321
  "customer_accounts.widgets.emailVerified": "Email verified",
321
322
  "customer_accounts.widgets.invite.button": "Invite to Portal",
322
323
  "customer_accounts.widgets.invite.displayName": "Display Name",
@@ -317,16 +317,17 @@
317
317
  "customer_accounts.signup.existing.subject": "You already have a portal account",
318
318
  "customer_accounts.signup.existing.title": "You already have a portal account",
319
319
  "customer_accounts.widgets.accountStatus": "Estado de la cuenta",
320
+ "customer_accounts.widgets.accountStatus.description": "Muestra el estado de la cuenta del portal del cliente en el detalle de la persona del CRM",
320
321
  "customer_accounts.widgets.emailVerified": "Correo verificado",
321
- "customer_accounts.widgets.invite.button": "Invite to Portal",
322
- "customer_accounts.widgets.invite.displayName": "Display Name",
323
- "customer_accounts.widgets.invite.error.emailRequired": "Email is required",
324
- "customer_accounts.widgets.invite.error.failed": "Failed to send invitation",
325
- "customer_accounts.widgets.invite.error.roleRequired": "At least one role must be selected",
326
- "customer_accounts.widgets.invite.noRoles": "No roles available",
322
+ "customer_accounts.widgets.invite.button": "Invitar al portal",
323
+ "customer_accounts.widgets.invite.displayName": "Nombre visible",
324
+ "customer_accounts.widgets.invite.error.emailRequired": "El correo electrónico es obligatorio",
325
+ "customer_accounts.widgets.invite.error.failed": "No se pudo enviar la invitación",
326
+ "customer_accounts.widgets.invite.error.roleRequired": "Debe seleccionar al menos un rol",
327
+ "customer_accounts.widgets.invite.noRoles": "No hay roles disponibles",
327
328
  "customer_accounts.widgets.invite.roles": "Roles",
328
- "customer_accounts.widgets.invite.submit": "Send Invitation",
329
- "customer_accounts.widgets.invite.success": "Invitation sent successfully",
329
+ "customer_accounts.widgets.invite.submit": "Enviar invitación",
330
+ "customer_accounts.widgets.invite.success": "Invitación enviada correctamente",
330
331
  "customer_accounts.widgets.lastLogin": "Último acceso",
331
332
  "customer_accounts.widgets.noAccount": "No hay cuenta vinculada",
332
333
  "customer_accounts.widgets.noUsers": "No hay usuarios vinculados",
@@ -317,16 +317,17 @@
317
317
  "customer_accounts.signup.existing.subject": "You already have a portal account",
318
318
  "customer_accounts.signup.existing.title": "You already have a portal account",
319
319
  "customer_accounts.widgets.accountStatus": "Status konta",
320
+ "customer_accounts.widgets.accountStatus.description": "Pokazuje status konta w portalu klienta na szczegółach osoby CRM",
320
321
  "customer_accounts.widgets.emailVerified": "E-mail zweryfikowany",
321
- "customer_accounts.widgets.invite.button": "Invite to Portal",
322
- "customer_accounts.widgets.invite.displayName": "Display Name",
323
- "customer_accounts.widgets.invite.error.emailRequired": "Email is required",
324
- "customer_accounts.widgets.invite.error.failed": "Failed to send invitation",
325
- "customer_accounts.widgets.invite.error.roleRequired": "At least one role must be selected",
326
- "customer_accounts.widgets.invite.noRoles": "No roles available",
327
- "customer_accounts.widgets.invite.roles": "Roles",
328
- "customer_accounts.widgets.invite.submit": "Send Invitation",
329
- "customer_accounts.widgets.invite.success": "Invitation sent successfully",
322
+ "customer_accounts.widgets.invite.button": "Zaproś do portalu",
323
+ "customer_accounts.widgets.invite.displayName": "Nazwa wyświetlana",
324
+ "customer_accounts.widgets.invite.error.emailRequired": "Adres e-mail jest wymagany",
325
+ "customer_accounts.widgets.invite.error.failed": "Nie udało się wysłać zaproszenia",
326
+ "customer_accounts.widgets.invite.error.roleRequired": "Musisz wybrać co najmniej jedną rolę",
327
+ "customer_accounts.widgets.invite.noRoles": "Brak dostępnych ról",
328
+ "customer_accounts.widgets.invite.roles": "Role",
329
+ "customer_accounts.widgets.invite.submit": "Wyślij zaproszenie",
330
+ "customer_accounts.widgets.invite.success": "Zaproszenie zostało wysłane",
330
331
  "customer_accounts.widgets.lastLogin": "Ostatnie logowanie",
331
332
  "customer_accounts.widgets.noAccount": "Brak powiązanego konta",
332
333
  "customer_accounts.widgets.noUsers": "Brak powiązanych użytkowników",
@@ -5,7 +5,7 @@ const widget: InjectionWidgetModule<Record<string, unknown>, Record<string, unkn
5
5
  metadata: {
6
6
  id: 'customer_accounts.injection.account-status',
7
7
  title: 'Customer Account Status',
8
- description: 'Shows customer portal account status on CRM person detail',
8
+ description: 'customer_accounts.widgets.accountStatus.description',
9
9
  features: ['customer_accounts.view'],
10
10
  priority: 100,
11
11
  enabled: true,
@@ -7,6 +7,7 @@ import { RowActions } from '@open-mercato/ui/backend/RowActions'
7
7
  import { Button } from '@open-mercato/ui/primitives/button'
8
8
  import { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'
9
9
  import { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'
10
+ import { buildEntitiesCsv } from '../lib/entitiesCsvExport'
10
11
 
11
12
  type EntityRow = {
12
13
  entityId: string
@@ -24,18 +25,6 @@ const columns: ColumnDef<EntityRow>[] = [
24
25
  { accessorKey: 'count', header: 'Fields', meta: { priority: 4 } },
25
26
  ]
26
27
 
27
- function toCsv(rows: EntityRow[]) {
28
- const header = ['entityId','label','source','count']
29
- const esc = (s: string | number) => {
30
- const str = String(s ?? '')
31
- if (/[",\n]/.test(str)) return '"' + str.replace(/"/g, '""') + '"'
32
- return str
33
- }
34
- const lines = [header.join(',')]
35
- for (const r of rows) lines.push([r.entityId, r.label, r.source, r.count].map(esc).join(','))
36
- return lines.join('\n')
37
- }
38
-
39
28
  export default function SystemEntitiesTable() {
40
29
  const [sorting, setSorting] = React.useState<SortingState>([{ id: 'entityId', desc: false }])
41
30
  const [page, setPage] = React.useState(1)
@@ -66,7 +55,7 @@ export default function SystemEntitiesTable() {
66
55
  actions={(
67
56
  <>
68
57
  <Button variant="outline" onClick={() => {
69
- const csv = toCsv(rows)
58
+ const csv = buildEntitiesCsv(rows)
70
59
  const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })
71
60
  const url = URL.createObjectURL(blob)
72
61
  const a = document.createElement('a')
@@ -9,6 +9,7 @@ import { ListEmptyState } from '@open-mercato/ui/backend/filters/ListEmptyState'
9
9
  import { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'
10
10
  import { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'
11
11
  import { useT } from '@open-mercato/shared/lib/i18n/context'
12
+ import { buildEntitiesCsv } from '../lib/entitiesCsvExport'
12
13
 
13
14
  type EntityRow = {
14
15
  entityId: string
@@ -41,18 +42,6 @@ function buildColumns(t: (key: string, fallback: string) => string): ColumnDef<E
41
42
  ]
42
43
  }
43
44
 
44
- function toCsv(rows: EntityRow[]) {
45
- const header = ['entityId','label','source','count','showInSidebar']
46
- const esc = (s: string | number | boolean) => {
47
- const str = String(s ?? '')
48
- if (/[",\n]/.test(str)) return '"' + str.replace(/"/g, '""') + '"'
49
- return str
50
- }
51
- const lines = [header.join(',')]
52
- for (const r of rows) lines.push([r.entityId, r.label, r.source, r.count, r.showInSidebar || false].map(esc).join(','))
53
- return lines.join('\n')
54
- }
55
-
56
45
  export default function UserEntitiesTable() {
57
46
  const t = useT()
58
47
  const [sorting, setSorting] = React.useState<SortingState>([{ id: 'entityId', desc: false }])
@@ -86,7 +75,7 @@ export default function UserEntitiesTable() {
86
75
  actions={(
87
76
  <>
88
77
  <Button variant="outline" onClick={() => {
89
- const csv = toCsv(rows)
78
+ const csv = buildEntitiesCsv(rows, { includeSidebar: true })
90
79
  const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })
91
80
  const url = URL.createObjectURL(blob)
92
81
  const a = document.createElement('a')
@@ -0,0 +1,31 @@
1
+ import { serializeExport, type CrudExportColumn, type PreparedExport } from '@open-mercato/shared/lib/crud/exporters'
2
+
3
+ export type EntitiesExportRow = {
4
+ entityId: string
5
+ label: string
6
+ source: 'code' | 'custom'
7
+ count: number
8
+ showInSidebar?: boolean
9
+ }
10
+
11
+ export function buildEntitiesCsv(rows: EntitiesExportRow[], options?: { includeSidebar?: boolean }): string {
12
+ const includeSidebar = options?.includeSidebar ?? false
13
+ const columns: CrudExportColumn[] = [
14
+ { field: 'entityId', header: 'entityId' },
15
+ { field: 'label', header: 'label' },
16
+ { field: 'source', header: 'source' },
17
+ { field: 'count', header: 'count' },
18
+ ]
19
+ if (includeSidebar) columns.push({ field: 'showInSidebar', header: 'showInSidebar' })
20
+ const prepared: PreparedExport = {
21
+ columns,
22
+ rows: rows.map((row) => ({
23
+ entityId: row.entityId,
24
+ label: row.label,
25
+ source: row.source,
26
+ count: row.count,
27
+ ...(includeSidebar ? { showInSidebar: row.showInSidebar || false } : {}),
28
+ })),
29
+ }
30
+ return serializeExport(prepared, 'csv').body
31
+ }
@@ -1,5 +1,6 @@
1
1
  import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
2
2
  import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
3
+ import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
3
4
  import { ensureOrganizationScope, ensureTenantScope } from '@open-mercato/shared/lib/commands/scope'
4
5
  import { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'
5
6
  import type { EntityManager, FilterQuery } from '@mikro-orm/postgresql'