@open-mercato/core 0.7.1-develop.7179.1.e8c03264b6 → 0.7.1-develop.7181.1.702cedc42c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/modules/data_sync/api/options.js +2 -0
- package/dist/modules/data_sync/api/options.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +39 -17
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/lib/start-controls.js +42 -0
- package/dist/modules/data_sync/lib/start-controls.js.map +7 -0
- package/package.json +7 -7
- package/src/modules/data_sync/AGENTS.md +34 -0
- package/src/modules/data_sync/api/options.ts +2 -0
- package/src/modules/data_sync/backend/data-sync/page.tsx +82 -33
- package/src/modules/data_sync/i18n/de.json +1 -0
- package/src/modules/data_sync/i18n/en.json +1 -0
- package/src/modules/data_sync/i18n/es.json +1 -0
- package/src/modules/data_sync/i18n/ko.json +1 -0
- package/src/modules/data_sync/i18n/pl.json +1 -0
- package/src/modules/data_sync/lib/adapter.ts +45 -0
- package/src/modules/data_sync/lib/start-controls.ts +89 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,6 +4,7 @@ import { organizationScopeRequiredResponse, resolveActiveOrganizationId } from "
|
|
|
4
4
|
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
|
|
5
5
|
import { getAllIntegrations } from "@open-mercato/shared/modules/integrations/types";
|
|
6
6
|
import { getDataSyncAdapter } from "../lib/adapter-registry.js";
|
|
7
|
+
import { resolveStartControlMap } from "../lib/start-controls.js";
|
|
7
8
|
const metadata = {
|
|
8
9
|
GET: { requireAuth: true, requireFeatures: ["data_sync.view"] }
|
|
9
10
|
};
|
|
@@ -42,6 +43,7 @@ async function GET(req) {
|
|
|
42
43
|
canStartRun: adapter.runMode !== "provider",
|
|
43
44
|
supportedEntities: adapter.supportedEntities,
|
|
44
45
|
runParameters: adapter.runParameters ?? [],
|
|
46
|
+
startControls: resolveStartControlMap(adapter),
|
|
45
47
|
hasCredentials: Boolean(credentials),
|
|
46
48
|
isEnabled,
|
|
47
49
|
settingsPath: `/backend/integrations/${encodeURIComponent(integration.id)}`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/data_sync/api/options.ts"],
|
|
4
|
-
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { organizationScopeRequiredResponse, resolveActiveOrganizationId } from '@open-mercato/shared/lib/auth/organizationScope'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAllIntegrations } from '@open-mercato/shared/modules/integrations/types'\nimport type { CredentialsService } from '../../integrations/lib/credentials-service'\nimport type { IntegrationStateService } from '../../integrations/lib/state-service'\nimport { getDataSyncAdapter } from '../lib/adapter-registry'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['data_sync.view'] },\n}\n\nexport const openApi = {\n tags: ['DataSync'],\n summary: 'List data sync integration options',\n}\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.tenantId) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n const organizationId = resolveActiveOrganizationId(auth)\n if (!organizationId) {\n return organizationScopeRequiredResponse()\n }\n\n const container = await createRequestContainer()\n const credentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const stateService = container.resolve('integrationStateService') as IntegrationStateService\n const scope = { organizationId, tenantId: auth.tenantId }\n\n const items = await Promise.all(\n getAllIntegrations()\n .filter((integration) => integration.hub === 'data_sync' && integration.providerKey)\n .map(async (integration) => {\n const adapter = getDataSyncAdapter(integration.providerKey as string)\n if (!adapter) return null\n\n const [credentials, isEnabled] = await Promise.all([\n credentialsService.resolve(integration.id, scope).catch(() => null),\n stateService\n .resolveState(integration.id, scope)\n .then((state) => state.isEnabled)\n .catch(() => false),\n ])\n\n return {\n integrationId: integration.id,\n title: integration.title,\n description: integration.description ?? null,\n providerKey: integration.providerKey ?? null,\n direction: adapter.direction,\n runMode: adapter.runMode ?? 'generic',\n canStartRun: adapter.runMode !== 'provider',\n supportedEntities: adapter.supportedEntities,\n runParameters: adapter.runParameters ?? [],\n hasCredentials: Boolean(credentials),\n isEnabled,\n settingsPath: `/backend/integrations/${encodeURIComponent(integration.id)}`,\n }\n }),\n )\n\n return NextResponse.json({\n items: items.filter((item): item is NonNullable<typeof item> => Boolean(item)),\n })\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,mCAAmC,mCAAmC;AAC/E,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAGnC,SAAS,0BAA0B;
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { getAuthFromRequest } from '@open-mercato/shared/lib/auth/server'\nimport { organizationScopeRequiredResponse, resolveActiveOrganizationId } from '@open-mercato/shared/lib/auth/organizationScope'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport { getAllIntegrations } from '@open-mercato/shared/modules/integrations/types'\nimport type { CredentialsService } from '../../integrations/lib/credentials-service'\nimport type { IntegrationStateService } from '../../integrations/lib/state-service'\nimport { getDataSyncAdapter } from '../lib/adapter-registry'\nimport { resolveStartControlMap } from '../lib/start-controls'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['data_sync.view'] },\n}\n\nexport const openApi = {\n tags: ['DataSync'],\n summary: 'List data sync integration options',\n}\n\nexport async function GET(req: Request) {\n const auth = await getAuthFromRequest(req)\n if (!auth?.tenantId) {\n return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n }\n const organizationId = resolveActiveOrganizationId(auth)\n if (!organizationId) {\n return organizationScopeRequiredResponse()\n }\n\n const container = await createRequestContainer()\n const credentialsService = container.resolve('integrationCredentialsService') as CredentialsService\n const stateService = container.resolve('integrationStateService') as IntegrationStateService\n const scope = { organizationId, tenantId: auth.tenantId }\n\n const items = await Promise.all(\n getAllIntegrations()\n .filter((integration) => integration.hub === 'data_sync' && integration.providerKey)\n .map(async (integration) => {\n const adapter = getDataSyncAdapter(integration.providerKey as string)\n if (!adapter) return null\n\n const [credentials, isEnabled] = await Promise.all([\n credentialsService.resolve(integration.id, scope).catch(() => null),\n stateService\n .resolveState(integration.id, scope)\n .then((state) => state.isEnabled)\n .catch(() => false),\n ])\n\n return {\n integrationId: integration.id,\n title: integration.title,\n description: integration.description ?? null,\n providerKey: integration.providerKey ?? null,\n direction: adapter.direction,\n runMode: adapter.runMode ?? 'generic',\n canStartRun: adapter.runMode !== 'provider',\n supportedEntities: adapter.supportedEntities,\n runParameters: adapter.runParameters ?? [],\n startControls: resolveStartControlMap(adapter),\n hasCredentials: Boolean(credentials),\n isEnabled,\n settingsPath: `/backend/integrations/${encodeURIComponent(integration.id)}`,\n }\n }),\n )\n\n return NextResponse.json({\n items: items.filter((item): item is NonNullable<typeof item> => Boolean(item)),\n })\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,mCAAmC,mCAAmC;AAC/E,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAGnC,SAAS,0BAA0B;AACnC,SAAS,8BAA8B;AAEhC,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,gBAAgB,EAAE;AAChE;AAEO,MAAM,UAAU;AAAA,EACrB,MAAM,CAAC,UAAU;AAAA,EACjB,SAAS;AACX;AAEA,eAAsB,IAAI,KAAc;AACtC,QAAM,OAAO,MAAM,mBAAmB,GAAG;AACzC,MAAI,CAAC,MAAM,UAAU;AACnB,WAAO,aAAa,KAAK,EAAE,OAAO,eAAe,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACrE;AACA,QAAM,iBAAiB,4BAA4B,IAAI;AACvD,MAAI,CAAC,gBAAgB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"names": []
|
|
7
7
|
}
|
|
@@ -30,6 +30,7 @@ import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
|
|
|
30
30
|
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
31
31
|
import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
32
32
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
33
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
33
34
|
import {
|
|
34
35
|
ArrowRightLeft,
|
|
35
36
|
Boxes,
|
|
@@ -44,6 +45,9 @@ import {
|
|
|
44
45
|
} from "lucide-react";
|
|
45
46
|
import { getSyncRunStatusVariant, getSyncSummaryVariant } from "../../lib/syncRunStatus.js";
|
|
46
47
|
import { getApplicableRunParameters } from "../../lib/run-parameters.js";
|
|
48
|
+
import {
|
|
49
|
+
applicableStartControls
|
|
50
|
+
} from "../../lib/start-controls.js";
|
|
47
51
|
import {
|
|
48
52
|
RunParameterFields,
|
|
49
53
|
buildDefaultRunParameterValues,
|
|
@@ -52,6 +56,12 @@ import {
|
|
|
52
56
|
buildRunParametersPayload
|
|
53
57
|
} from "../../components/RunParameterFields.js";
|
|
54
58
|
const DEFAULT_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
59
|
+
const DEFAULT_BATCH_SIZE = "100";
|
|
60
|
+
function startControlsGridClass(controls) {
|
|
61
|
+
if (controls.batchSize && controls.fullSync) return "sm:grid-cols-[minmax(0,180px)_1fr]";
|
|
62
|
+
if (controls.batchSize) return "sm:grid-cols-[minmax(0,180px)]";
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
55
65
|
function formatEntityTypeLabel(entityType) {
|
|
56
66
|
return entityType.replace(/[_-]+/g, " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
57
67
|
}
|
|
@@ -83,7 +93,7 @@ function SyncRunsDashboardPage() {
|
|
|
83
93
|
const [selectedIntegrationId, setSelectedIntegrationId] = React.useState("");
|
|
84
94
|
const [selectedEntityType, setSelectedEntityType] = React.useState("");
|
|
85
95
|
const [selectedDirection, setSelectedDirection] = React.useState("import");
|
|
86
|
-
const [batchSize, setBatchSize] = React.useState(
|
|
96
|
+
const [batchSize, setBatchSize] = React.useState(DEFAULT_BATCH_SIZE);
|
|
87
97
|
const [fullSync, setFullSync] = React.useState(false);
|
|
88
98
|
const [paramValues, setParamValues] = React.useState({});
|
|
89
99
|
const [scheduleEditor, setScheduleEditor] = React.useState(() => buildDefaultScheduleState(""));
|
|
@@ -178,9 +188,19 @@ function SyncRunsDashboardPage() {
|
|
|
178
188
|
),
|
|
179
189
|
[selectedIntegration, selectedDirection, selectedEntityType]
|
|
180
190
|
);
|
|
191
|
+
const startControls = React.useMemo(
|
|
192
|
+
() => applicableStartControls(selectedIntegration?.startControls, selectedEntityType),
|
|
193
|
+
[selectedIntegration, selectedEntityType]
|
|
194
|
+
);
|
|
181
195
|
React.useEffect(() => {
|
|
182
196
|
setParamValues(buildDefaultRunParameterValues(runParameters));
|
|
183
197
|
}, [runParameters]);
|
|
198
|
+
React.useEffect(() => {
|
|
199
|
+
if (!startControls.fullSync) setFullSync(false);
|
|
200
|
+
}, [startControls.fullSync]);
|
|
201
|
+
React.useEffect(() => {
|
|
202
|
+
if (!startControls.batchSize) setBatchSize(DEFAULT_BATCH_SIZE);
|
|
203
|
+
}, [startControls.batchSize]);
|
|
184
204
|
const updateParamValue = React.useCallback((key, value) => {
|
|
185
205
|
setParamValues((current) => ({ ...current, [key]: value }));
|
|
186
206
|
}, []);
|
|
@@ -281,19 +301,21 @@ function SyncRunsDashboardPage() {
|
|
|
281
301
|
}, []);
|
|
282
302
|
const handleStartSync = React.useCallback(async () => {
|
|
283
303
|
if (!selectedIntegration || !selectedEntityType) return;
|
|
284
|
-
const parsedBatchSize = Number.parseInt(batchSize, 10);
|
|
285
|
-
if (!Number.isFinite(parsedBatchSize) || parsedBatchSize < 1 || parsedBatchSize > 1e3) {
|
|
286
|
-
flash(t("data_sync.dashboard.start.invalidBatchSize", "Batch size must be between 1 and 1000."), "error");
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
304
|
const parameters = buildRunParametersPayload(runParameters, paramValues);
|
|
290
305
|
const requestBody = {
|
|
291
306
|
integrationId: selectedIntegration.integrationId,
|
|
292
307
|
entityType: selectedEntityType,
|
|
293
|
-
direction: selectedDirection
|
|
294
|
-
batchSize: parsedBatchSize,
|
|
295
|
-
fullSync
|
|
308
|
+
direction: selectedDirection
|
|
296
309
|
};
|
|
310
|
+
if (startControls.batchSize) {
|
|
311
|
+
const parsedBatchSize = Number.parseInt(batchSize, 10);
|
|
312
|
+
if (!Number.isFinite(parsedBatchSize) || parsedBatchSize < 1 || parsedBatchSize > 1e3) {
|
|
313
|
+
flash(t("data_sync.dashboard.start.invalidBatchSize", "Batch size must be between 1 and 1000."), "error");
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
requestBody.batchSize = parsedBatchSize;
|
|
317
|
+
}
|
|
318
|
+
if (startControls.fullSync) requestBody.fullSync = fullSync;
|
|
297
319
|
if (runParameters.length > 0) requestBody.parameters = parameters;
|
|
298
320
|
try {
|
|
299
321
|
const call = await runMutation({
|
|
@@ -325,7 +347,7 @@ function SyncRunsDashboardPage() {
|
|
|
325
347
|
const message = error instanceof Error ? error.message : t("data_sync.dashboard.start.error", "Failed to start sync run");
|
|
326
348
|
flash(message, "error");
|
|
327
349
|
}
|
|
328
|
-
}, [batchSize, fullSync, paramValues, router, runMutation, runParameters, selectedDirection, selectedEntityType, selectedIntegration, t]);
|
|
350
|
+
}, [batchSize, fullSync, paramValues, router, runMutation, runParameters, selectedDirection, selectedEntityType, selectedIntegration, startControls, t]);
|
|
329
351
|
const handleSaveSchedule = React.useCallback(async () => {
|
|
330
352
|
if (!selectedIntegration || !selectedEntityType) return;
|
|
331
353
|
if (scheduleEditor.scheduleValue.trim().length === 0) {
|
|
@@ -625,13 +647,13 @@ function SyncRunsDashboardPage() {
|
|
|
625
647
|
/* @__PURE__ */ jsx(Play, { className: "size-4 text-primary" }),
|
|
626
648
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: t("data_sync.dashboard.start.runNowTitle", "Run once now") })
|
|
627
649
|
] }),
|
|
628
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("data_sync.dashboard.start.runNowDescription", "Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.") })
|
|
650
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: startControls.batchSize && startControls.fullSync ? t("data_sync.dashboard.start.runNowDescription", "Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.") : t("data_sync.dashboard.start.runNowDescriptionScoped", "Use this for the next immediate sync. Anything set here applies only to this manual run.") })
|
|
629
651
|
] }),
|
|
630
652
|
/* @__PURE__ */ jsx(Badge, { variant: "outline", children: selectedEntityLabel })
|
|
631
653
|
] }),
|
|
632
654
|
/* @__PURE__ */ jsx(Separator, { className: "my-4" }),
|
|
633
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-4
|
|
634
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
655
|
+
startControls.batchSize || startControls.fullSync ? /* @__PURE__ */ jsxs("div", { className: cn("grid gap-4", startControlsGridClass(startControls)), children: [
|
|
656
|
+
startControls.batchSize ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
635
657
|
/* @__PURE__ */ jsxs(Label, { className: "flex items-center gap-2 text-sm font-medium", children: [
|
|
636
658
|
/* @__PURE__ */ jsx(Gauge, { className: "size-4 text-muted-foreground" }),
|
|
637
659
|
/* @__PURE__ */ jsx("span", { children: t("data_sync.dashboard.start.batchSize", "Batch size") })
|
|
@@ -644,15 +666,15 @@ function SyncRunsDashboardPage() {
|
|
|
644
666
|
inputMode: "numeric"
|
|
645
667
|
}
|
|
646
668
|
)
|
|
647
|
-
] }),
|
|
648
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-background p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
669
|
+
] }) : null,
|
|
670
|
+
startControls.fullSync ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-background p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
649
671
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
650
672
|
/* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: t("data_sync.dashboard.start.fullSync", "Run as full sync") }),
|
|
651
673
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("data_sync.dashboard.start.fullSyncHelp", "Ignore the saved cursor and process the entire source again for this run.") })
|
|
652
674
|
] }),
|
|
653
675
|
/* @__PURE__ */ jsx(Switch, { checked: fullSync, onCheckedChange: setFullSync })
|
|
654
|
-
] }) })
|
|
655
|
-
] }),
|
|
676
|
+
] }) }) : null
|
|
677
|
+
] }) : null,
|
|
656
678
|
runParameters.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-3", children: [
|
|
657
679
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
658
680
|
/* @__PURE__ */ jsx(Settings2, { className: "size-4 text-muted-foreground" }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/data_sync/backend/data-sync/page.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/data_sync/extension-points'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { StatusBadge } from '@open-mercato/ui/primitives/status-badge'\nimport { Card, CardContent, CardHeader, CardTitle } from '@open-mercato/ui/primitives/card'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Separator } from '@open-mercato/ui/primitives/separator'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n ArrowRightLeft,\n Boxes,\n CalendarClock,\n Clock3,\n Gauge,\n Play,\n PlugZap,\n Repeat,\n Settings2,\n ShieldCheck,\n} from 'lucide-react'\nimport { getSyncRunStatusVariant, getSyncSummaryVariant } from '../../lib/syncRunStatus'\nimport type { RunParameter } from '../../lib/adapter'\nimport { getApplicableRunParameters } from '../../lib/run-parameters'\nimport {\n RunParameterFields,\n buildDefaultRunParameterValues,\n buildRetryFailureMessage,\n buildRunFailureMessage,\n buildRunParametersPayload,\n type RetryFailureBody,\n type RunFailureBody,\n type RunParameterFormValue,\n} from '../../components/RunParameterFields'\n\ntype SyncRunRow = {\n id: string\n integrationId: string\n entityType: string\n direction: 'import' | 'export'\n status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused'\n createdCount: number\n updatedCount: number\n failedCount: number\n createdAt: string\n}\n\ntype ResponsePayload = {\n items: SyncRunRow[]\n total: number\n page: number\n totalPages: number\n totalIsCapped?: boolean\n}\n\ntype SyncOption = {\n integrationId: string\n title: string\n description?: string | null\n providerKey?: string | null\n direction: 'import' | 'export' | 'bidirectional'\n runMode?: 'generic' | 'provider'\n canStartRun?: boolean\n supportedEntities: string[]\n runParameters?: RunParameter[]\n hasCredentials: boolean\n isEnabled: boolean\n settingsPath: string\n}\n\ntype SyncOptionsResponse = {\n items: SyncOption[]\n}\n\ntype SyncScheduleRecord = {\n id: string\n integrationId: string\n entityType: string\n direction: 'import' | 'export'\n scheduleType: 'cron' | 'interval'\n scheduleValue: string\n timezone: string\n fullSync: boolean\n isEnabled: boolean\n lastRunAt: string | null\n updatedAt?: string | null\n}\n\ntype SyncSchedulesResponse = {\n items?: SyncScheduleRecord[]\n}\n\ntype SyncScheduleEditorState = {\n id?: string\n scheduleType: 'cron' | 'interval'\n scheduleValue: string\n timezone: string\n fullSync: boolean\n isEnabled: boolean\n lastRunAt: string | null\n updatedAt?: string | null\n}\n\nconst DEFAULT_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'\n\nfunction formatEntityTypeLabel(entityType: string): string {\n return entityType\n .replace(/[_-]+/g, ' ')\n .replace(/\\b\\w/g, (letter) => letter.toUpperCase())\n}\n\nfunction buildDefaultScheduleState(entityType: string): SyncScheduleEditorState {\n const normalized = entityType.trim().toLowerCase()\n const longerInterval = normalized === 'categories' || normalized === 'attributes'\n return {\n scheduleType: 'interval',\n scheduleValue: longerInterval ? '6h' : '1h',\n timezone: DEFAULT_TIMEZONE,\n fullSync: normalized !== 'products',\n isEnabled: true,\n lastRunAt: null,\n updatedAt: null,\n }\n}\n\nexport default function SyncRunsDashboardPage() {\n const router = useRouter()\n const [rows, setRows] = React.useState<SyncRunRow[]>([])\n const [options, setOptions] = React.useState<SyncOption[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [totalIsCapped, setTotalIsCapped] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n const [isLoading, setIsLoading] = React.useState(true)\n const [isLoadingOptions, setIsLoadingOptions] = React.useState(true)\n const [selectedIntegrationId, setSelectedIntegrationId] = React.useState('')\n const [selectedEntityType, setSelectedEntityType] = React.useState('')\n const [selectedDirection, setSelectedDirection] = React.useState<'import' | 'export'>('import')\n const [batchSize, setBatchSize] = React.useState('100')\n const [fullSync, setFullSync] = React.useState(false)\n const [paramValues, setParamValues] = React.useState<Record<string, RunParameterFormValue>>({})\n const [scheduleEditor, setScheduleEditor] = React.useState<SyncScheduleEditorState>(() => buildDefaultScheduleState(''))\n const [isLoadingSchedule, setIsLoadingSchedule] = React.useState(false)\n const [isSavingSchedule, setIsSavingSchedule] = React.useState(false)\n const [isDeletingSchedule, setIsDeletingSchedule] = React.useState(false)\n const [reloadToken, setReloadToken] = React.useState(0)\n const scopeVersion = useOrganizationScopeVersion()\n const t = useT()\n const { runMutation } = useGuardedMutation<Record<string, unknown>>({\n contextId: 'data_sync.dashboard',\n })\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n setIsLoading(true)\n const params = new URLSearchParams()\n params.set('page', String(page))\n params.set('pageSize', '20')\n if (filterValues.status) params.set('status', filterValues.status as string)\n if (filterValues.direction) params.set('direction', filterValues.direction as string)\n if (search.trim()) params.set('search', search.trim())\n const fallback: ResponsePayload = { items: [], total: 0, page, totalPages: 1 }\n const call = await apiCall<ResponsePayload>(\n `/api/data_sync/runs?${params.toString()}`,\n undefined,\n { fallback },\n )\n if (!call.ok) {\n flash(t('data_sync.dashboard.loadError'), 'error')\n if (!cancelled) setIsLoading(false)\n return\n }\n const payload = call.result ?? fallback\n if (!cancelled) {\n setRows(Array.isArray(payload.items) ? payload.items : [])\n setTotal(payload.total || 0)\n setTotalPages(payload.totalPages || 1)\n setTotalIsCapped(payload?.totalIsCapped === true)\n setIsLoading(false)\n }\n }\n load()\n return () => { cancelled = true }\n }, [page, filterValues, search, reloadToken, scopeVersion, t])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadOptions() {\n setIsLoadingOptions(true)\n const fallback: SyncOptionsResponse = { items: [] }\n const call = await apiCall<SyncOptionsResponse>('/api/data_sync/options', undefined, { fallback })\n if (!cancelled) {\n if (!call.ok) {\n flash(t('data_sync.dashboard.loadError'), 'error')\n setOptions([])\n setIsLoadingOptions(false)\n return\n }\n\n const nextItems = Array.isArray(call.result?.items) ? call.result.items : []\n setOptions(nextItems)\n setSelectedIntegrationId((current) => {\n if (current && nextItems.some((item) => item.integrationId === current)) return current\n return nextItems[0]?.integrationId ?? ''\n })\n setIsLoadingOptions(false)\n }\n }\n\n void loadOptions()\n return () => { cancelled = true }\n }, [scopeVersion, t])\n\n const selectedIntegration = React.useMemo(\n () => options.find((item) => item.integrationId === selectedIntegrationId) ?? null,\n [options, selectedIntegrationId],\n )\n\n const entityOptions = React.useMemo(\n () => selectedIntegration?.supportedEntities ?? [],\n [selectedIntegration],\n )\n\n const runParameters = React.useMemo(\n () => getApplicableRunParameters(\n selectedIntegration?.runParameters,\n selectedDirection,\n // Pass the state through as-is. Before an entity is chosen it is '',\n // which matches no `entityType` and so hides scoped parameters \u2014 the\n // wanted outcome. Mapping '' to `undefined` would mean \"skip entity\n // scoping\" and show every scoped parameter instead.\n selectedEntityType,\n ),\n [selectedIntegration, selectedDirection, selectedEntityType],\n )\n\n React.useEffect(() => {\n setParamValues(buildDefaultRunParameterValues(runParameters))\n }, [runParameters])\n\n const updateParamValue = React.useCallback((key: string, value: RunParameterFormValue) => {\n setParamValues((current) => ({ ...current, [key]: value }))\n }, [])\n\n React.useEffect(() => {\n if (!selectedIntegration) {\n setSelectedEntityType('')\n return\n }\n setSelectedEntityType((current) => (\n current && selectedIntegration.supportedEntities.includes(current)\n ? current\n : (selectedIntegration.supportedEntities[0] ?? '')\n ))\n setSelectedDirection(selectedIntegration.direction === 'export' ? 'export' : 'import')\n }, [selectedIntegration])\n\n React.useEffect(() => {\n if (!selectedIntegration || !selectedEntityType) {\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n return\n }\n\n const currentIntegration = selectedIntegration\n let cancelled = false\n async function loadSchedule() {\n setIsLoadingSchedule(true)\n const integrationId = currentIntegration.integrationId\n const params = new URLSearchParams({\n integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n page: '1',\n pageSize: '1',\n })\n const fallback: SyncSchedulesResponse = { items: [] }\n const call = await apiCall<SyncSchedulesResponse>(`/api/data_sync/schedules?${params.toString()}`, undefined, { fallback })\n\n if (cancelled) return\n\n if (!call.ok) {\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n setIsLoadingSchedule(false)\n return\n }\n\n const record = Array.isArray(call.result?.items) ? call.result?.items[0] : undefined\n if (!record) {\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n setIsLoadingSchedule(false)\n return\n }\n\n setScheduleEditor({\n id: record.id,\n scheduleType: record.scheduleType,\n scheduleValue: record.scheduleValue,\n timezone: record.timezone,\n fullSync: record.fullSync,\n isEnabled: record.isEnabled,\n lastRunAt: record.lastRunAt,\n updatedAt: record.updatedAt ?? null,\n })\n setIsLoadingSchedule(false)\n }\n\n void loadSchedule()\n return () => { cancelled = true }\n }, [selectedDirection, selectedEntityType, selectedIntegration, scopeVersion])\n\n const updateScheduleEditor = React.useCallback((changes: Partial<SyncScheduleEditorState>) => {\n setScheduleEditor((current) => ({ ...current, ...changes }))\n }, [])\n\n const handleCancel = React.useCallback(async (row: SyncRunRow) => {\n // optimistic-lock-exempt: run lifecycle action endpoint (cancel), not a concurrent record edit\n const call = await apiCall(`/api/data_sync/runs/${encodeURIComponent(row.id)}/cancel`, {\n method: 'POST',\n }, { fallback: null })\n if (call.ok) {\n flash(t('data_sync.runs.detail.cancelSuccess'), 'success')\n setReloadToken((token) => token + 1)\n } else {\n flash(t('data_sync.runs.detail.cancelError'), 'error')\n }\n }, [t])\n\n const handleRetry = React.useCallback(async (row: SyncRunRow) => {\n // optimistic-lock-exempt: run lifecycle action endpoint (retry), not a concurrent record edit\n const call = await apiCall(`/api/data_sync/runs/${encodeURIComponent(row.id)}/retry`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ fromBeginning: false }),\n }, { fallback: null })\n if (call.ok) {\n flash(t('data_sync.runs.detail.retrySuccess'), 'success')\n setReloadToken((token) => token + 1)\n } else {\n flash(buildRetryFailureMessage(call.result as RetryFailureBody | null, t), 'error')\n }\n }, [t])\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined && value !== '') next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [])\n\n const handleStartSync = React.useCallback(async () => {\n if (!selectedIntegration || !selectedEntityType) return\n\n const parsedBatchSize = Number.parseInt(batchSize, 10)\n if (!Number.isFinite(parsedBatchSize) || parsedBatchSize < 1 || parsedBatchSize > 1000) {\n flash(t('data_sync.dashboard.start.invalidBatchSize', 'Batch size must be between 1 and 1000.'), 'error')\n return\n }\n\n const parameters = buildRunParametersPayload(runParameters, paramValues)\n const requestBody: Record<string, unknown> = {\n integrationId: selectedIntegration.integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n batchSize: parsedBatchSize,\n fullSync,\n }\n if (runParameters.length > 0) requestBody.parameters = parameters\n\n try {\n const call = await runMutation({\n // optimistic-lock-exempt: starts a new sync run (create), not a concurrent record edit\n operation: () => apiCall<{ id: string }>('/api/data_sync/run', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(requestBody),\n }, { fallback: null }),\n mutationPayload: requestBody,\n context: {\n operation: 'create',\n actionId: 'start-sync-run',\n integrationId: selectedIntegration.integrationId,\n },\n })\n\n if (!call.ok || !call.result?.id) {\n flash(buildRunFailureMessage(\n call.result as RunFailureBody | null,\n t('data_sync.dashboard.start.error', 'Failed to start sync run'),\n t,\n ), 'error')\n return\n }\n\n flash(t('data_sync.dashboard.start.success', 'Sync run started'), 'success')\n setReloadToken((token) => token + 1)\n router.push(`/backend/data-sync/runs/${encodeURIComponent(call.result.id)}`)\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.dashboard.start.error', 'Failed to start sync run')\n flash(message, 'error')\n }\n }, [batchSize, fullSync, paramValues, router, runMutation, runParameters, selectedDirection, selectedEntityType, selectedIntegration, t])\n\n const handleSaveSchedule = React.useCallback(async () => {\n if (!selectedIntegration || !selectedEntityType) return\n if (scheduleEditor.scheduleValue.trim().length === 0) {\n flash(t('data_sync.dashboard.schedule.invalidValue', 'Provide a schedule value before saving.'), 'error')\n return\n }\n\n setIsSavingSchedule(true)\n try {\n const call = await runMutation({\n // Keyed upsert (POST). When the editor holds an existing schedule's\n // `updatedAt`, the lock header version-checks the resolved row on the\n // server; a brand-new schedule has a null `updatedAt`, so the header is\n // empty and the create path stays unaffected.\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleEditor.updatedAt),\n () => apiCall<SyncScheduleRecord>('/api/data_sync/schedules', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n integrationId: selectedIntegration.integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n scheduleType: scheduleEditor.scheduleType,\n scheduleValue: scheduleEditor.scheduleValue.trim(),\n timezone: scheduleEditor.timezone.trim() || DEFAULT_TIMEZONE,\n fullSync: scheduleEditor.fullSync,\n isEnabled: scheduleEditor.isEnabled,\n }),\n }, { fallback: null }),\n ),\n mutationPayload: {\n integrationId: selectedIntegration.integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n scheduleType: scheduleEditor.scheduleType,\n scheduleValue: scheduleEditor.scheduleValue.trim(),\n timezone: scheduleEditor.timezone.trim() || DEFAULT_TIMEZONE,\n fullSync: scheduleEditor.fullSync,\n isEnabled: scheduleEditor.isEnabled,\n },\n context: {\n operation: 'update',\n actionId: 'save-sync-schedule',\n integrationId: selectedIntegration.integrationId,\n },\n })\n\n if (!call.ok || !call.result) {\n const conflictError = Object.assign(\n new Error((call.result as { error?: string } | null)?.error ?? t('data_sync.dashboard.schedule.error', 'Failed to save recurring schedule')),\n {\n status: call.status,\n ...(call.result && typeof call.result === 'object' ? call.result : {}),\n },\n )\n if (surfaceRecordConflict(conflictError, t)) {\n return\n }\n flash((call.result as { error?: string } | null)?.error ?? t('data_sync.dashboard.schedule.error', 'Failed to save recurring schedule'), 'error')\n return\n }\n\n setScheduleEditor({\n id: call.result.id,\n scheduleType: call.result.scheduleType,\n scheduleValue: call.result.scheduleValue,\n timezone: call.result.timezone,\n fullSync: call.result.fullSync,\n isEnabled: call.result.isEnabled,\n lastRunAt: call.result.lastRunAt,\n updatedAt: call.result.updatedAt ?? null,\n })\n flash(t('data_sync.dashboard.schedule.success', 'Recurring schedule saved'), 'success')\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.dashboard.schedule.error', 'Failed to save recurring schedule')\n flash(message, 'error')\n } finally {\n setIsSavingSchedule(false)\n }\n }, [runMutation, scheduleEditor, selectedDirection, selectedEntityType, selectedIntegration, t])\n\n const handleDeleteSchedule = React.useCallback(async () => {\n if (!scheduleEditor.id) return\n\n setIsDeletingSchedule(true)\n try {\n const call = await runMutation({\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleEditor.updatedAt),\n () => apiCall(`/api/data_sync/schedules/${encodeURIComponent(scheduleEditor.id as string)}`, {\n method: 'DELETE',\n }, { fallback: null }),\n ),\n mutationPayload: {\n scheduleId: scheduleEditor.id,\n },\n context: {\n operation: 'delete',\n actionId: 'delete-sync-schedule',\n },\n })\n\n if (!call.ok) {\n flash((call.result as { error?: string } | null)?.error ?? t('data_sync.dashboard.schedule.deleteError', 'Failed to remove recurring schedule'), 'error')\n return\n }\n\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n flash(t('data_sync.dashboard.schedule.deleteSuccess', 'Recurring schedule removed'), 'success')\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.dashboard.schedule.deleteError', 'Failed to remove recurring schedule')\n flash(message, 'error')\n } finally {\n setIsDeletingSchedule(false)\n }\n }, [runMutation, scheduleEditor.id, scheduleEditor.updatedAt, selectedEntityType, t])\n\n const filters: FilterDef[] = [\n {\n id: 'status',\n type: 'select',\n label: t('data_sync.dashboard.filters.status'),\n options: [\n { label: t('data_sync.dashboard.filters.allStatuses'), value: '' },\n { label: t('data_sync.dashboard.status.pending'), value: 'pending' },\n { label: t('data_sync.dashboard.status.running'), value: 'running' },\n { label: t('data_sync.dashboard.status.completed'), value: 'completed' },\n { label: t('data_sync.dashboard.status.failed'), value: 'failed' },\n { label: t('data_sync.dashboard.status.cancelled'), value: 'cancelled' },\n ],\n },\n {\n id: 'direction',\n type: 'select',\n label: t('data_sync.dashboard.columns.direction'),\n options: [\n { label: t('data_sync.dashboard.filters.allDirections'), value: '' },\n { label: t('data_sync.dashboard.direction.import'), value: 'import' },\n { label: t('data_sync.dashboard.direction.export'), value: 'export' },\n ],\n },\n ]\n\n const columns = React.useMemo<ColumnDef<SyncRunRow>[]>(() => [\n {\n accessorKey: 'integrationId',\n header: t('data_sync.dashboard.columns.integration'),\n cell: ({ row }) => <span className=\"font-medium text-sm\">{row.original.integrationId}</span>,\n },\n {\n accessorKey: 'entityType',\n header: t('data_sync.dashboard.columns.entityType'),\n },\n {\n accessorKey: 'direction',\n header: t('data_sync.dashboard.columns.direction'),\n cell: ({ row }) => (\n <Badge variant=\"outline\">\n {t(`data_sync.dashboard.direction.${row.original.direction}`)}\n </Badge>\n ),\n },\n {\n accessorKey: 'status',\n header: t('data_sync.dashboard.columns.status'),\n cell: ({ row }) => (\n <StatusBadge variant={getSyncRunStatusVariant(row.original.status)}>\n {t(`data_sync.dashboard.status.${row.original.status}`)}\n </StatusBadge>\n ),\n },\n {\n accessorKey: 'createdCount',\n header: t('data_sync.dashboard.columns.created'),\n },\n {\n accessorKey: 'updatedCount',\n header: t('data_sync.dashboard.columns.updated'),\n },\n {\n accessorKey: 'failedCount',\n header: t('data_sync.dashboard.columns.failed'),\n },\n {\n accessorKey: 'createdAt',\n header: t('data_sync.dashboard.columns.createdAt'),\n cell: ({ row }) => new Date(row.original.createdAt).toLocaleString(),\n },\n ], [t])\n\n const canStartSelectedIntegration = Boolean(\n selectedIntegration\n && selectedEntityType\n && selectedIntegration.isEnabled\n && selectedIntegration.canStartRun !== false\n && selectedIntegration.hasCredentials,\n )\n const hasSavedSchedule = Boolean(scheduleEditor.id)\n const selectedEntityLabel = selectedEntityType ? formatEntityTypeLabel(selectedEntityType) : t('data_sync.dashboard.columns.entityType')\n const integrationStateVariant = getSyncSummaryVariant(selectedIntegration?.isEnabled ? 'enabled' : 'disabled')\n const credentialsVariant = getSyncSummaryVariant(selectedIntegration?.hasCredentials ? 'ready' : 'missing')\n const scheduleVariant = getSyncSummaryVariant(\n hasSavedSchedule\n ? (scheduleEditor.isEnabled ? 'scheduled' : 'paused')\n : 'none',\n )\n\n return (\n <Page>\n <PageBody className=\"space-y-6\">\n <Card>\n <CardHeader className=\"space-y-4\">\n <div className=\"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2 text-xs font-medium uppercase tracking-widest text-muted-foreground\">\n <Repeat className=\"size-4\" />\n <span>{t('data_sync.dashboard.start.eyebrow', 'Run once or keep it recurring')}</span>\n </div>\n <div className=\"space-y-1\">\n <CardTitle>{t('data_sync.dashboard.start.title', 'Start or schedule a sync')}</CardTitle>\n <p className=\"max-w-3xl text-sm text-muted-foreground\">\n {t('data_sync.dashboard.start.description', 'Pick a sync target, launch an ad-hoc run, or save a recurring schedule for the same entity and direction from this page.')}\n </p>\n </div>\n </div>\n {selectedIntegration ? (\n <Button asChild variant=\"outline\">\n <Link href={selectedIntegration.settingsPath}>\n <Settings2 className=\"mr-2 size-4\" />\n {t('integrations.marketplace.configure')}\n </Link>\n </Button>\n ) : null}\n </div>\n\n {selectedIntegration ? (\n <div className=\"flex flex-wrap gap-2\">\n <Badge variant=\"outline\" className=\"gap-1.5\">\n <PlugZap className=\"size-3.5\" />\n {selectedIntegration.title}\n </Badge>\n <Badge variant=\"outline\" className=\"gap-1.5\">\n <ArrowRightLeft className=\"size-3.5\" />\n {t(`data_sync.dashboard.direction.${selectedDirection}`)}\n </Badge>\n <Badge variant={integrationStateVariant} className=\"gap-1.5\">\n <ShieldCheck className=\"size-3.5\" />\n {selectedIntegration.isEnabled\n ? t('data_sync.dashboard.start.status.enabled', 'Integration enabled')\n : t('data_sync.dashboard.start.status.disabled', 'Integration disabled')}\n </Badge>\n <Badge variant={credentialsVariant} className=\"gap-1.5\">\n <PlugZap className=\"size-3.5\" />\n {selectedIntegration.hasCredentials\n ? t('data_sync.dashboard.start.status.credentialsReady', 'Credentials ready')\n : t('data_sync.dashboard.start.status.credentialsMissing', 'Credentials missing')}\n </Badge>\n <Badge variant={scheduleVariant} className=\"gap-1.5\">\n <CalendarClock className=\"size-3.5\" />\n {hasSavedSchedule\n ? (scheduleEditor.isEnabled\n ? t('data_sync.dashboard.schedule.status.enabled', 'Recurring schedule active')\n : t('data_sync.dashboard.schedule.status.disabled', 'Recurring schedule paused'))\n : t('data_sync.dashboard.schedule.status.none', 'No recurring schedule')}\n </Badge>\n </div>\n ) : null}\n </CardHeader>\n <CardContent className=\"space-y-6\">\n <div className=\"grid gap-4 xl:grid-cols-3\">\n <div className=\"space-y-2 xl:col-span-1\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <PlugZap className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.columns.integration')}</span>\n </Label>\n <Select\n value={selectedIntegrationId || undefined}\n onValueChange={(value) => setSelectedIntegrationId(value ?? '')}\n disabled={isLoadingOptions || options.length === 0}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue\n placeholder={\n options.length === 0\n ? t('integrations.marketplace.noResults', 'No integrations found')\n : undefined\n }\n />\n </SelectTrigger>\n <SelectContent>\n {options.map((item) => (\n <SelectItem key={item.integrationId} value={item.integrationId}>\n {item.title}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Boxes className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.columns.entityType')}</span>\n </Label>\n <Select\n value={selectedEntityType || undefined}\n onValueChange={(value) => setSelectedEntityType(value ?? '')}\n disabled={entityOptions.length === 0}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {entityOptions.map((entityType) => (\n <SelectItem key={entityType} value={entityType}>\n {formatEntityTypeLabel(entityType)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <ArrowRightLeft className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.columns.direction')}</span>\n </Label>\n <Select\n value={selectedDirection}\n onValueChange={(value) => setSelectedDirection(value === 'export' ? 'export' : 'import')}\n disabled={selectedIntegration?.direction !== 'bidirectional'}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"import\">{t('data_sync.dashboard.direction.import')}</SelectItem>\n {(selectedIntegration?.direction === 'bidirectional' || selectedIntegration?.direction === 'export') ? (\n <SelectItem value=\"export\">{t('data_sync.dashboard.direction.export')}</SelectItem>\n ) : null}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n {selectedIntegration?.description ? (\n <p className=\"text-sm text-muted-foreground\">{selectedIntegration.description}</p>\n ) : null}\n\n <div className=\"grid gap-4 xl:grid-cols-2\">\n <div className=\"rounded-xl border bg-muted/30 p-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <Play className=\"size-4 text-primary\" />\n <h3 className=\"text-sm font-semibold\">{t('data_sync.dashboard.start.runNowTitle', 'Run once now')}</h3>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t('data_sync.dashboard.start.runNowDescription', 'Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.')}\n </p>\n </div>\n <Badge variant=\"outline\">{selectedEntityLabel}</Badge>\n </div>\n\n <Separator className=\"my-4\" />\n\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,180px)_1fr]\">\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Gauge className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.start.batchSize', 'Batch size')}</span>\n </Label>\n <Input\n value={batchSize}\n onChange={(event) => setBatchSize(event.target.value)}\n inputMode=\"numeric\"\n />\n </div>\n <div className=\"rounded-lg border bg-background p-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label className=\"text-sm font-medium\">{t('data_sync.dashboard.start.fullSync', 'Run as full sync')}</Label>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.start.fullSyncHelp', 'Ignore the saved cursor and process the entire source again for this run.')}\n </p>\n </div>\n <Switch checked={fullSync} onCheckedChange={setFullSync} />\n </div>\n </div>\n </div>\n\n {runParameters.length > 0 ? (\n <div className=\"mt-4 space-y-3\">\n <div className=\"flex items-center gap-2\">\n <Settings2 className=\"size-4 text-muted-foreground\" />\n <h4 className=\"text-sm font-semibold\">\n {t('data_sync.dashboard.start.parameters', 'Run parameters')}\n </h4>\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.start.parametersHelp', 'Optional values this integration accepts for the manual run.')}\n </p>\n <RunParameterFields\n params={runParameters}\n values={paramValues}\n onChange={updateParamValue}\n />\n </div>\n ) : null}\n\n <div className=\"mt-4 flex flex-wrap items-center justify-between gap-3\">\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.start.runNowFootnote', 'Manual runs show progress immediately and land on the run detail page after launch.')}\n </p>\n <Button\n type=\"button\"\n onClick={() => void handleStartSync()}\n disabled={!canStartSelectedIntegration}\n >\n <Play className=\"mr-2 size-4\" />\n {t('data_sync.dashboard.start.submit', 'Start sync')}\n </Button>\n </div>\n </div>\n\n <div className=\"rounded-xl border bg-muted/30 p-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <CalendarClock className=\"size-4 text-primary\" />\n <h3 className=\"text-sm font-semibold\">{t('data_sync.dashboard.schedule.title', 'Recurring schedule')}</h3>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t('data_sync.dashboard.schedule.description', 'Save a repeating schedule for the selected integration, entity, and direction without leaving this dashboard.')}\n </p>\n </div>\n <Badge variant=\"outline\">\n {hasSavedSchedule\n ? (scheduleEditor.isEnabled\n ? t('data_sync.dashboard.schedule.status.shortEnabled', 'Scheduled')\n : t('data_sync.dashboard.schedule.status.shortDisabled', 'Paused'))\n : t('data_sync.dashboard.schedule.status.shortNone', 'One-time only')}\n </Badge>\n </div>\n\n <Separator className=\"my-4\" />\n\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Clock3 className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.schedule.type', 'Schedule type')}</span>\n </Label>\n <Select\n value={scheduleEditor.scheduleType}\n onValueChange={(value) => updateScheduleEditor({\n scheduleType: value === 'cron' ? 'cron' : 'interval',\n })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"interval\">{t('data_sync.dashboard.schedule.interval', 'Interval')}</SelectItem>\n <SelectItem value=\"cron\">{t('data_sync.dashboard.schedule.cron', 'Cron')}</SelectItem>\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <CalendarClock className=\"size-4 text-muted-foreground\" />\n <span>\n {scheduleEditor.scheduleType === 'cron'\n ? t('data_sync.dashboard.schedule.cronValue', 'Cron expression')\n : t('data_sync.dashboard.schedule.intervalValue', 'Interval')}\n </span>\n </Label>\n <Input\n value={scheduleEditor.scheduleValue}\n onChange={(event) => updateScheduleEditor({ scheduleValue: event.target.value })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n placeholder={scheduleEditor.scheduleType === 'cron' ? '0 * * * *' : '1h'}\n />\n <p className=\"text-xs text-muted-foreground\">\n {scheduleEditor.scheduleType === 'cron'\n ? t('data_sync.dashboard.schedule.cronHelp', 'Example: `0 * * * *` runs at the start of every hour.')\n : t('data_sync.dashboard.schedule.intervalHelp', 'Example: `1h`, `6h`, or `24h` for repeating intervals.')}\n </p>\n </div>\n <div className=\"space-y-2 sm:col-span-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Clock3 className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.schedule.timezone', 'Timezone')}</span>\n </Label>\n <Input\n value={scheduleEditor.timezone}\n onChange={(event) => updateScheduleEditor({ timezone: event.target.value })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n />\n </div>\n </div>\n\n <div className=\"mt-4 grid gap-3\">\n <div className=\"rounded-lg border bg-background p-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label className=\"text-sm font-medium\">{t('data_sync.dashboard.schedule.fullSync', 'Run scheduled jobs as full sync')}</Label>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.schedule.fullSyncHelp', 'When enabled, every recurring run starts from the beginning instead of the saved cursor.')}\n </p>\n </div>\n <Switch\n checked={scheduleEditor.fullSync}\n onCheckedChange={(checked) => updateScheduleEditor({ fullSync: checked })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n />\n </div>\n </div>\n <div className=\"rounded-lg border bg-background p-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label className=\"text-sm font-medium\">{t('data_sync.dashboard.schedule.enabled', 'Schedule enabled')}</Label>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.schedule.enabledHelp', 'Pause the recurring job without deleting the schedule definition.')}\n </p>\n </div>\n <Switch\n checked={scheduleEditor.isEnabled}\n onCheckedChange={(checked) => updateScheduleEditor({ isEnabled: checked })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n />\n </div>\n </div>\n </div>\n\n <div className=\"mt-4 flex flex-wrap items-center justify-between gap-3\">\n <div className=\"space-y-1 text-xs text-muted-foreground\">\n <div>\n {hasSavedSchedule\n ? (scheduleEditor.lastRunAt\n ? t('data_sync.dashboard.schedule.lastRun', 'Last scheduled run: {value}', {\n value: new Date(scheduleEditor.lastRunAt).toLocaleString(),\n })\n : t('data_sync.dashboard.schedule.neverRun', 'Saved, but no scheduled execution has completed yet.'))\n : t('data_sync.dashboard.schedule.none', 'No recurring schedule saved for this target yet.')}\n </div>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void handleDeleteSchedule()}\n disabled={!hasSavedSchedule || isDeletingSchedule}\n >\n {isDeletingSchedule\n ? t('data_sync.dashboard.schedule.deleting', 'Removing...')\n : t('data_sync.dashboard.schedule.delete', 'Remove schedule')}\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void handleSaveSchedule()}\n disabled={isSavingSchedule || !selectedIntegration || !selectedEntityType}\n >\n <CalendarClock className=\"mr-2 size-4\" />\n {isSavingSchedule\n ? t('data_sync.dashboard.schedule.saving', 'Saving...')\n : t('data_sync.dashboard.schedule.save', 'Save recurring schedule')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n\n {selectedIntegration && !selectedIntegration.isEnabled ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('integrations.detail.state.disabled', 'This integration is disabled. Enable it on the integration settings page before starting a sync.')}\n </AlertDescription>\n </Alert>\n ) : null}\n {selectedIntegration && !selectedIntegration.hasCredentials ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('integrations.detail.credentials.notConfigured', 'Credentials are not configured yet. Save the integration credentials before starting a sync.')}\n </AlertDescription>\n </Alert>\n ) : null}\n {selectedIntegration && selectedIntegration.canStartRun === false ? (\n <Alert status=\"information\">\n <AlertDescription>\n {t('data_sync.dashboard.start.providerManaged', 'This integration starts sync runs from its own setup flow. Open the integration settings page to continue.')}\n </AlertDescription>\n </Alert>\n ) : null}\n </CardContent>\n </Card>\n\n <DataTable\n stickyActionsColumn\n title={t('data_sync.dashboard.title')}\n titleHeadingLevel={1}\n columns={columns}\n data={rows}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n searchValue={search}\n onSearchChange={(value) => { setSearch(value); setPage(1) }}\n searchPlaceholder={t('data_sync.dashboard.searchPlaceholder')}\n perspective={{ tableId: extensionPoints.hosts.runsTable.tableId }}\n onRowClick={(row) => {\n router.push(`/backend/data-sync/runs/${encodeURIComponent(row.id)}`)\n }}\n rowActions={(row) => (\n <RowActions items={[\n {\n id: 'view',\n label: t('data_sync.dashboard.actions.view'),\n onSelect: () => { router.push(`/backend/data-sync/runs/${encodeURIComponent(row.id)}`) },\n },\n ...(row.status === 'running' ? [{\n id: 'cancel',\n label: t('data_sync.runs.detail.cancel'),\n destructive: true,\n onSelect: () => { void handleCancel(row) },\n }] : []),\n ...(row.status === 'failed' ? [{\n id: 'retry',\n label: t('data_sync.runs.detail.retry'),\n onSelect: () => { void handleRetry(row) },\n }] : []),\n ]} />\n )}\n pagination={{ page, pageSize: 20, total, totalPages, totalIsCapped, onPageChange: setPage }}\n isLoading={isLoading}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
-
"mappings": ";AAwkByB,cAmET,YAnES;AAvkBzB,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAG1B,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,MAAM,aAAa,YAAY,iBAAiB;AACzD,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,OAAO,wBAAwB;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,mCAAmC;AACrD,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB,6BAA6B;AAE/D,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAsEP,MAAM,mBAAmB,KAAK,eAAe,EAAE,gBAAgB,EAAE,YAAY;AAE7E,SAAS,sBAAsB,YAA4B;AACzD,SAAO,WACJ,QAAQ,UAAU,GAAG,EACrB,QAAQ,SAAS,CAAC,WAAW,OAAO,YAAY,CAAC;AACtD;AAEA,SAAS,0BAA0B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,QACnB;AAAA,QACA,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB,gBAAgB;AAAA,QAChB,aAAa;AAAA,QACb,gBAAgB,CAAC,UAAU;AAAE,oBAAU,KAAK;AAAG,kBAAQ,CAAC;AAAA,QAAE;AAAA,QAC1D,mBAAmB,EAAE,uCAAuC;AAAA,QAC5D,aAAa,EAAE,SAAS,gBAAgB,MAAM,UAAU,QAAQ;AAAA,QAChE,YAAY,CAAC,QAAQ;AACnB,iBAAO,KAAK,2BAA2B,mBAAmB,IAAI,EAAE,CAAC,EAAE;AAAA,QACrE;AAAA,QACA,YAAY,CAAC,QACX,oBAAC,cAAW,OAAO;AAAA,UACjB;AAAA,YACE,IAAI;AAAA,YACJ,OAAO,EAAE,kCAAkC;AAAA,YAC3C,UAAU,MAAM;AAAE,qBAAO,KAAK,2BAA2B,mBAAmB,IAAI,EAAE,CAAC,EAAE;AAAA,YAAE;AAAA,UACzF;AAAA,UACA,GAAI,IAAI,WAAW,YAAY,CAAC;AAAA,YAC9B,IAAI;AAAA,YACJ,OAAO,EAAE,8BAA8B;AAAA,YACvC,aAAa;AAAA,YACb,UAAU,MAAM;AAAE,mBAAK,aAAa,GAAG;AAAA,YAAE;AAAA,UAC3C,CAAC,IAAI,CAAC;AAAA,UACN,GAAI,IAAI,WAAW,WAAW,CAAC;AAAA,YAC7B,IAAI;AAAA,YACJ,OAAO,EAAE,6BAA6B;AAAA,YACtC,UAAU,MAAM;AAAE,mBAAK,YAAY,GAAG;AAAA,YAAE;AAAA,UAC1C,CAAC,IAAI,CAAC;AAAA,QACR,GAAG;AAAA,QAEL,YAAY,EAAE,MAAM,UAAU,IAAI,OAAO,YAAY,eAAe,cAAc,QAAQ;AAAA,QAC1F;AAAA;AAAA,IACF;AAAA,KACF,GACF;AAEJ;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { extensionPoints } from '@open-mercato/core/modules/data_sync/extension-points'\nimport Link from 'next/link'\nimport { useRouter } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { DataTable } from '@open-mercato/ui/backend/DataTable'\nimport type { LegacyColumnDef as ColumnDef } from '@tanstack/react-table/legacy'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { StatusBadge } from '@open-mercato/ui/primitives/status-badge'\nimport { Card, CardContent, CardHeader, CardTitle } from '@open-mercato/ui/primitives/card'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Separator } from '@open-mercato/ui/primitives/separator'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { RowActions } from '@open-mercato/ui/backend/RowActions'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport {\n ArrowRightLeft,\n Boxes,\n CalendarClock,\n Clock3,\n Gauge,\n Play,\n PlugZap,\n Repeat,\n Settings2,\n ShieldCheck,\n} from 'lucide-react'\nimport { getSyncRunStatusVariant, getSyncSummaryVariant } from '../../lib/syncRunStatus'\nimport type { RunParameter } from '../../lib/adapter'\nimport { getApplicableRunParameters } from '../../lib/run-parameters'\nimport {\n applicableStartControls,\n type StartControlApplicability,\n type StartControlMap,\n} from '../../lib/start-controls'\nimport {\n RunParameterFields,\n buildDefaultRunParameterValues,\n buildRetryFailureMessage,\n buildRunFailureMessage,\n buildRunParametersPayload,\n type RetryFailureBody,\n type RunFailureBody,\n type RunParameterFormValue,\n} from '../../components/RunParameterFields'\n\ntype SyncRunRow = {\n id: string\n integrationId: string\n entityType: string\n direction: 'import' | 'export'\n status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused'\n createdCount: number\n updatedCount: number\n failedCount: number\n createdAt: string\n}\n\ntype ResponsePayload = {\n items: SyncRunRow[]\n total: number\n page: number\n totalPages: number\n totalIsCapped?: boolean\n}\n\ntype SyncOption = {\n integrationId: string\n title: string\n description?: string | null\n providerKey?: string | null\n direction: 'import' | 'export' | 'bidirectional'\n runMode?: 'generic' | 'provider'\n canStartRun?: boolean\n supportedEntities: string[]\n runParameters?: RunParameter[]\n startControls?: StartControlMap\n hasCredentials: boolean\n isEnabled: boolean\n settingsPath: string\n}\n\ntype SyncOptionsResponse = {\n items: SyncOption[]\n}\n\ntype SyncScheduleRecord = {\n id: string\n integrationId: string\n entityType: string\n direction: 'import' | 'export'\n scheduleType: 'cron' | 'interval'\n scheduleValue: string\n timezone: string\n fullSync: boolean\n isEnabled: boolean\n lastRunAt: string | null\n updatedAt?: string | null\n}\n\ntype SyncSchedulesResponse = {\n items?: SyncScheduleRecord[]\n}\n\ntype SyncScheduleEditorState = {\n id?: string\n scheduleType: 'cron' | 'interval'\n scheduleValue: string\n timezone: string\n fullSync: boolean\n isEnabled: boolean\n lastRunAt: string | null\n updatedAt?: string | null\n}\n\nconst DEFAULT_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'\n\n/** Matches `runSyncSchema`'s own default, so omitting the field submits this value. */\nconst DEFAULT_BATCH_SIZE = '100'\n\n/**\n * Keeps the batch size input at its own narrow width without leaving a phantom\n * track: the second column exists only when the full sync card fills it. With\n * only that card the row falls back to one full-width column.\n */\nfunction startControlsGridClass(controls: StartControlApplicability): string | undefined {\n if (controls.batchSize && controls.fullSync) return 'sm:grid-cols-[minmax(0,180px)_1fr]'\n if (controls.batchSize) return 'sm:grid-cols-[minmax(0,180px)]'\n return undefined\n}\n\nfunction formatEntityTypeLabel(entityType: string): string {\n return entityType\n .replace(/[_-]+/g, ' ')\n .replace(/\\b\\w/g, (letter) => letter.toUpperCase())\n}\n\nfunction buildDefaultScheduleState(entityType: string): SyncScheduleEditorState {\n const normalized = entityType.trim().toLowerCase()\n const longerInterval = normalized === 'categories' || normalized === 'attributes'\n return {\n scheduleType: 'interval',\n scheduleValue: longerInterval ? '6h' : '1h',\n timezone: DEFAULT_TIMEZONE,\n fullSync: normalized !== 'products',\n isEnabled: true,\n lastRunAt: null,\n updatedAt: null,\n }\n}\n\nexport default function SyncRunsDashboardPage() {\n const router = useRouter()\n const [rows, setRows] = React.useState<SyncRunRow[]>([])\n const [options, setOptions] = React.useState<SyncOption[]>([])\n const [page, setPage] = React.useState(1)\n const [total, setTotal] = React.useState(0)\n const [totalPages, setTotalPages] = React.useState(1)\n const [totalIsCapped, setTotalIsCapped] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [filterValues, setFilterValues] = React.useState<FilterValues>({})\n const [isLoading, setIsLoading] = React.useState(true)\n const [isLoadingOptions, setIsLoadingOptions] = React.useState(true)\n const [selectedIntegrationId, setSelectedIntegrationId] = React.useState('')\n const [selectedEntityType, setSelectedEntityType] = React.useState('')\n const [selectedDirection, setSelectedDirection] = React.useState<'import' | 'export'>('import')\n const [batchSize, setBatchSize] = React.useState(DEFAULT_BATCH_SIZE)\n const [fullSync, setFullSync] = React.useState(false)\n const [paramValues, setParamValues] = React.useState<Record<string, RunParameterFormValue>>({})\n const [scheduleEditor, setScheduleEditor] = React.useState<SyncScheduleEditorState>(() => buildDefaultScheduleState(''))\n const [isLoadingSchedule, setIsLoadingSchedule] = React.useState(false)\n const [isSavingSchedule, setIsSavingSchedule] = React.useState(false)\n const [isDeletingSchedule, setIsDeletingSchedule] = React.useState(false)\n const [reloadToken, setReloadToken] = React.useState(0)\n const scopeVersion = useOrganizationScopeVersion()\n const t = useT()\n const { runMutation } = useGuardedMutation<Record<string, unknown>>({\n contextId: 'data_sync.dashboard',\n })\n\n React.useEffect(() => {\n let cancelled = false\n async function load() {\n setIsLoading(true)\n const params = new URLSearchParams()\n params.set('page', String(page))\n params.set('pageSize', '20')\n if (filterValues.status) params.set('status', filterValues.status as string)\n if (filterValues.direction) params.set('direction', filterValues.direction as string)\n if (search.trim()) params.set('search', search.trim())\n const fallback: ResponsePayload = { items: [], total: 0, page, totalPages: 1 }\n const call = await apiCall<ResponsePayload>(\n `/api/data_sync/runs?${params.toString()}`,\n undefined,\n { fallback },\n )\n if (!call.ok) {\n flash(t('data_sync.dashboard.loadError'), 'error')\n if (!cancelled) setIsLoading(false)\n return\n }\n const payload = call.result ?? fallback\n if (!cancelled) {\n setRows(Array.isArray(payload.items) ? payload.items : [])\n setTotal(payload.total || 0)\n setTotalPages(payload.totalPages || 1)\n setTotalIsCapped(payload?.totalIsCapped === true)\n setIsLoading(false)\n }\n }\n load()\n return () => { cancelled = true }\n }, [page, filterValues, search, reloadToken, scopeVersion, t])\n\n React.useEffect(() => {\n let cancelled = false\n async function loadOptions() {\n setIsLoadingOptions(true)\n const fallback: SyncOptionsResponse = { items: [] }\n const call = await apiCall<SyncOptionsResponse>('/api/data_sync/options', undefined, { fallback })\n if (!cancelled) {\n if (!call.ok) {\n flash(t('data_sync.dashboard.loadError'), 'error')\n setOptions([])\n setIsLoadingOptions(false)\n return\n }\n\n const nextItems = Array.isArray(call.result?.items) ? call.result.items : []\n setOptions(nextItems)\n setSelectedIntegrationId((current) => {\n if (current && nextItems.some((item) => item.integrationId === current)) return current\n return nextItems[0]?.integrationId ?? ''\n })\n setIsLoadingOptions(false)\n }\n }\n\n void loadOptions()\n return () => { cancelled = true }\n }, [scopeVersion, t])\n\n const selectedIntegration = React.useMemo(\n () => options.find((item) => item.integrationId === selectedIntegrationId) ?? null,\n [options, selectedIntegrationId],\n )\n\n const entityOptions = React.useMemo(\n () => selectedIntegration?.supportedEntities ?? [],\n [selectedIntegration],\n )\n\n const runParameters = React.useMemo(\n () => getApplicableRunParameters(\n selectedIntegration?.runParameters,\n selectedDirection,\n // Pass the state through as-is. Before an entity is chosen it is '',\n // which matches no `entityType` and so hides scoped parameters \u2014 the\n // wanted outcome. Mapping '' to `undefined` would mean \"skip entity\n // scoping\" and show every scoped parameter instead.\n selectedEntityType,\n ),\n [selectedIntegration, selectedDirection, selectedEntityType],\n )\n\n // Before an entity is chosen the state is '', which matches no declaration and\n // so renders both controls \u2014 the unselected form as it is today.\n const startControls = React.useMemo(\n () => applicableStartControls(selectedIntegration?.startControls, selectedEntityType),\n [selectedIntegration, selectedEntityType],\n )\n\n React.useEffect(() => {\n setParamValues(buildDefaultRunParameterValues(runParameters))\n }, [runParameters])\n\n // A control the form stopped showing must not keep submitting the value the\n // operator last set for another entity type.\n React.useEffect(() => {\n if (!startControls.fullSync) setFullSync(false)\n }, [startControls.fullSync])\n\n React.useEffect(() => {\n if (!startControls.batchSize) setBatchSize(DEFAULT_BATCH_SIZE)\n }, [startControls.batchSize])\n\n const updateParamValue = React.useCallback((key: string, value: RunParameterFormValue) => {\n setParamValues((current) => ({ ...current, [key]: value }))\n }, [])\n\n React.useEffect(() => {\n if (!selectedIntegration) {\n setSelectedEntityType('')\n return\n }\n setSelectedEntityType((current) => (\n current && selectedIntegration.supportedEntities.includes(current)\n ? current\n : (selectedIntegration.supportedEntities[0] ?? '')\n ))\n setSelectedDirection(selectedIntegration.direction === 'export' ? 'export' : 'import')\n }, [selectedIntegration])\n\n React.useEffect(() => {\n if (!selectedIntegration || !selectedEntityType) {\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n return\n }\n\n const currentIntegration = selectedIntegration\n let cancelled = false\n async function loadSchedule() {\n setIsLoadingSchedule(true)\n const integrationId = currentIntegration.integrationId\n const params = new URLSearchParams({\n integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n page: '1',\n pageSize: '1',\n })\n const fallback: SyncSchedulesResponse = { items: [] }\n const call = await apiCall<SyncSchedulesResponse>(`/api/data_sync/schedules?${params.toString()}`, undefined, { fallback })\n\n if (cancelled) return\n\n if (!call.ok) {\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n setIsLoadingSchedule(false)\n return\n }\n\n const record = Array.isArray(call.result?.items) ? call.result?.items[0] : undefined\n if (!record) {\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n setIsLoadingSchedule(false)\n return\n }\n\n setScheduleEditor({\n id: record.id,\n scheduleType: record.scheduleType,\n scheduleValue: record.scheduleValue,\n timezone: record.timezone,\n fullSync: record.fullSync,\n isEnabled: record.isEnabled,\n lastRunAt: record.lastRunAt,\n updatedAt: record.updatedAt ?? null,\n })\n setIsLoadingSchedule(false)\n }\n\n void loadSchedule()\n return () => { cancelled = true }\n }, [selectedDirection, selectedEntityType, selectedIntegration, scopeVersion])\n\n const updateScheduleEditor = React.useCallback((changes: Partial<SyncScheduleEditorState>) => {\n setScheduleEditor((current) => ({ ...current, ...changes }))\n }, [])\n\n const handleCancel = React.useCallback(async (row: SyncRunRow) => {\n // optimistic-lock-exempt: run lifecycle action endpoint (cancel), not a concurrent record edit\n const call = await apiCall(`/api/data_sync/runs/${encodeURIComponent(row.id)}/cancel`, {\n method: 'POST',\n }, { fallback: null })\n if (call.ok) {\n flash(t('data_sync.runs.detail.cancelSuccess'), 'success')\n setReloadToken((token) => token + 1)\n } else {\n flash(t('data_sync.runs.detail.cancelError'), 'error')\n }\n }, [t])\n\n const handleRetry = React.useCallback(async (row: SyncRunRow) => {\n // optimistic-lock-exempt: run lifecycle action endpoint (retry), not a concurrent record edit\n const call = await apiCall(`/api/data_sync/runs/${encodeURIComponent(row.id)}/retry`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ fromBeginning: false }),\n }, { fallback: null })\n if (call.ok) {\n flash(t('data_sync.runs.detail.retrySuccess'), 'success')\n setReloadToken((token) => token + 1)\n } else {\n flash(buildRetryFailureMessage(call.result as RetryFailureBody | null, t), 'error')\n }\n }, [t])\n\n const handleFiltersApply = React.useCallback((values: FilterValues) => {\n const next: FilterValues = {}\n Object.entries(values).forEach(([key, value]) => {\n if (value !== undefined && value !== '') next[key] = value\n })\n setFilterValues(next)\n setPage(1)\n }, [])\n\n const handleFiltersClear = React.useCallback(() => {\n setFilterValues({})\n setPage(1)\n }, [])\n\n const handleStartSync = React.useCallback(async () => {\n if (!selectedIntegration || !selectedEntityType) return\n\n const parameters = buildRunParametersPayload(runParameters, paramValues)\n // A control the adapter declared inapplicable is left out entirely, so\n // `runSyncSchema`'s defaults supply exactly what the rendered form sends.\n const requestBody: Record<string, unknown> = {\n integrationId: selectedIntegration.integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n }\n if (startControls.batchSize) {\n const parsedBatchSize = Number.parseInt(batchSize, 10)\n if (!Number.isFinite(parsedBatchSize) || parsedBatchSize < 1 || parsedBatchSize > 1000) {\n flash(t('data_sync.dashboard.start.invalidBatchSize', 'Batch size must be between 1 and 1000.'), 'error')\n return\n }\n requestBody.batchSize = parsedBatchSize\n }\n if (startControls.fullSync) requestBody.fullSync = fullSync\n if (runParameters.length > 0) requestBody.parameters = parameters\n\n try {\n const call = await runMutation({\n // optimistic-lock-exempt: starts a new sync run (create), not a concurrent record edit\n operation: () => apiCall<{ id: string }>('/api/data_sync/run', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(requestBody),\n }, { fallback: null }),\n mutationPayload: requestBody,\n context: {\n operation: 'create',\n actionId: 'start-sync-run',\n integrationId: selectedIntegration.integrationId,\n },\n })\n\n if (!call.ok || !call.result?.id) {\n flash(buildRunFailureMessage(\n call.result as RunFailureBody | null,\n t('data_sync.dashboard.start.error', 'Failed to start sync run'),\n t,\n ), 'error')\n return\n }\n\n flash(t('data_sync.dashboard.start.success', 'Sync run started'), 'success')\n setReloadToken((token) => token + 1)\n router.push(`/backend/data-sync/runs/${encodeURIComponent(call.result.id)}`)\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.dashboard.start.error', 'Failed to start sync run')\n flash(message, 'error')\n }\n }, [batchSize, fullSync, paramValues, router, runMutation, runParameters, selectedDirection, selectedEntityType, selectedIntegration, startControls, t])\n\n const handleSaveSchedule = React.useCallback(async () => {\n if (!selectedIntegration || !selectedEntityType) return\n if (scheduleEditor.scheduleValue.trim().length === 0) {\n flash(t('data_sync.dashboard.schedule.invalidValue', 'Provide a schedule value before saving.'), 'error')\n return\n }\n\n setIsSavingSchedule(true)\n try {\n const call = await runMutation({\n // Keyed upsert (POST). When the editor holds an existing schedule's\n // `updatedAt`, the lock header version-checks the resolved row on the\n // server; a brand-new schedule has a null `updatedAt`, so the header is\n // empty and the create path stays unaffected.\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleEditor.updatedAt),\n () => apiCall<SyncScheduleRecord>('/api/data_sync/schedules', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n integrationId: selectedIntegration.integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n scheduleType: scheduleEditor.scheduleType,\n scheduleValue: scheduleEditor.scheduleValue.trim(),\n timezone: scheduleEditor.timezone.trim() || DEFAULT_TIMEZONE,\n fullSync: scheduleEditor.fullSync,\n isEnabled: scheduleEditor.isEnabled,\n }),\n }, { fallback: null }),\n ),\n mutationPayload: {\n integrationId: selectedIntegration.integrationId,\n entityType: selectedEntityType,\n direction: selectedDirection,\n scheduleType: scheduleEditor.scheduleType,\n scheduleValue: scheduleEditor.scheduleValue.trim(),\n timezone: scheduleEditor.timezone.trim() || DEFAULT_TIMEZONE,\n fullSync: scheduleEditor.fullSync,\n isEnabled: scheduleEditor.isEnabled,\n },\n context: {\n operation: 'update',\n actionId: 'save-sync-schedule',\n integrationId: selectedIntegration.integrationId,\n },\n })\n\n if (!call.ok || !call.result) {\n const conflictError = Object.assign(\n new Error((call.result as { error?: string } | null)?.error ?? t('data_sync.dashboard.schedule.error', 'Failed to save recurring schedule')),\n {\n status: call.status,\n ...(call.result && typeof call.result === 'object' ? call.result : {}),\n },\n )\n if (surfaceRecordConflict(conflictError, t)) {\n return\n }\n flash((call.result as { error?: string } | null)?.error ?? t('data_sync.dashboard.schedule.error', 'Failed to save recurring schedule'), 'error')\n return\n }\n\n setScheduleEditor({\n id: call.result.id,\n scheduleType: call.result.scheduleType,\n scheduleValue: call.result.scheduleValue,\n timezone: call.result.timezone,\n fullSync: call.result.fullSync,\n isEnabled: call.result.isEnabled,\n lastRunAt: call.result.lastRunAt,\n updatedAt: call.result.updatedAt ?? null,\n })\n flash(t('data_sync.dashboard.schedule.success', 'Recurring schedule saved'), 'success')\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.dashboard.schedule.error', 'Failed to save recurring schedule')\n flash(message, 'error')\n } finally {\n setIsSavingSchedule(false)\n }\n }, [runMutation, scheduleEditor, selectedDirection, selectedEntityType, selectedIntegration, t])\n\n const handleDeleteSchedule = React.useCallback(async () => {\n if (!scheduleEditor.id) return\n\n setIsDeletingSchedule(true)\n try {\n const call = await runMutation({\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleEditor.updatedAt),\n () => apiCall(`/api/data_sync/schedules/${encodeURIComponent(scheduleEditor.id as string)}`, {\n method: 'DELETE',\n }, { fallback: null }),\n ),\n mutationPayload: {\n scheduleId: scheduleEditor.id,\n },\n context: {\n operation: 'delete',\n actionId: 'delete-sync-schedule',\n },\n })\n\n if (!call.ok) {\n flash((call.result as { error?: string } | null)?.error ?? t('data_sync.dashboard.schedule.deleteError', 'Failed to remove recurring schedule'), 'error')\n return\n }\n\n setScheduleEditor(buildDefaultScheduleState(selectedEntityType))\n flash(t('data_sync.dashboard.schedule.deleteSuccess', 'Recurring schedule removed'), 'success')\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.dashboard.schedule.deleteError', 'Failed to remove recurring schedule')\n flash(message, 'error')\n } finally {\n setIsDeletingSchedule(false)\n }\n }, [runMutation, scheduleEditor.id, scheduleEditor.updatedAt, selectedEntityType, t])\n\n const filters: FilterDef[] = [\n {\n id: 'status',\n type: 'select',\n label: t('data_sync.dashboard.filters.status'),\n options: [\n { label: t('data_sync.dashboard.filters.allStatuses'), value: '' },\n { label: t('data_sync.dashboard.status.pending'), value: 'pending' },\n { label: t('data_sync.dashboard.status.running'), value: 'running' },\n { label: t('data_sync.dashboard.status.completed'), value: 'completed' },\n { label: t('data_sync.dashboard.status.failed'), value: 'failed' },\n { label: t('data_sync.dashboard.status.cancelled'), value: 'cancelled' },\n ],\n },\n {\n id: 'direction',\n type: 'select',\n label: t('data_sync.dashboard.columns.direction'),\n options: [\n { label: t('data_sync.dashboard.filters.allDirections'), value: '' },\n { label: t('data_sync.dashboard.direction.import'), value: 'import' },\n { label: t('data_sync.dashboard.direction.export'), value: 'export' },\n ],\n },\n ]\n\n const columns = React.useMemo<ColumnDef<SyncRunRow>[]>(() => [\n {\n accessorKey: 'integrationId',\n header: t('data_sync.dashboard.columns.integration'),\n cell: ({ row }) => <span className=\"font-medium text-sm\">{row.original.integrationId}</span>,\n },\n {\n accessorKey: 'entityType',\n header: t('data_sync.dashboard.columns.entityType'),\n },\n {\n accessorKey: 'direction',\n header: t('data_sync.dashboard.columns.direction'),\n cell: ({ row }) => (\n <Badge variant=\"outline\">\n {t(`data_sync.dashboard.direction.${row.original.direction}`)}\n </Badge>\n ),\n },\n {\n accessorKey: 'status',\n header: t('data_sync.dashboard.columns.status'),\n cell: ({ row }) => (\n <StatusBadge variant={getSyncRunStatusVariant(row.original.status)}>\n {t(`data_sync.dashboard.status.${row.original.status}`)}\n </StatusBadge>\n ),\n },\n {\n accessorKey: 'createdCount',\n header: t('data_sync.dashboard.columns.created'),\n },\n {\n accessorKey: 'updatedCount',\n header: t('data_sync.dashboard.columns.updated'),\n },\n {\n accessorKey: 'failedCount',\n header: t('data_sync.dashboard.columns.failed'),\n },\n {\n accessorKey: 'createdAt',\n header: t('data_sync.dashboard.columns.createdAt'),\n cell: ({ row }) => new Date(row.original.createdAt).toLocaleString(),\n },\n ], [t])\n\n const canStartSelectedIntegration = Boolean(\n selectedIntegration\n && selectedEntityType\n && selectedIntegration.isEnabled\n && selectedIntegration.canStartRun !== false\n && selectedIntegration.hasCredentials,\n )\n const hasSavedSchedule = Boolean(scheduleEditor.id)\n const selectedEntityLabel = selectedEntityType ? formatEntityTypeLabel(selectedEntityType) : t('data_sync.dashboard.columns.entityType')\n const integrationStateVariant = getSyncSummaryVariant(selectedIntegration?.isEnabled ? 'enabled' : 'disabled')\n const credentialsVariant = getSyncSummaryVariant(selectedIntegration?.hasCredentials ? 'ready' : 'missing')\n const scheduleVariant = getSyncSummaryVariant(\n hasSavedSchedule\n ? (scheduleEditor.isEnabled ? 'scheduled' : 'paused')\n : 'none',\n )\n\n return (\n <Page>\n <PageBody className=\"space-y-6\">\n <Card>\n <CardHeader className=\"space-y-4\">\n <div className=\"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2 text-xs font-medium uppercase tracking-widest text-muted-foreground\">\n <Repeat className=\"size-4\" />\n <span>{t('data_sync.dashboard.start.eyebrow', 'Run once or keep it recurring')}</span>\n </div>\n <div className=\"space-y-1\">\n <CardTitle>{t('data_sync.dashboard.start.title', 'Start or schedule a sync')}</CardTitle>\n <p className=\"max-w-3xl text-sm text-muted-foreground\">\n {t('data_sync.dashboard.start.description', 'Pick a sync target, launch an ad-hoc run, or save a recurring schedule for the same entity and direction from this page.')}\n </p>\n </div>\n </div>\n {selectedIntegration ? (\n <Button asChild variant=\"outline\">\n <Link href={selectedIntegration.settingsPath}>\n <Settings2 className=\"mr-2 size-4\" />\n {t('integrations.marketplace.configure')}\n </Link>\n </Button>\n ) : null}\n </div>\n\n {selectedIntegration ? (\n <div className=\"flex flex-wrap gap-2\">\n <Badge variant=\"outline\" className=\"gap-1.5\">\n <PlugZap className=\"size-3.5\" />\n {selectedIntegration.title}\n </Badge>\n <Badge variant=\"outline\" className=\"gap-1.5\">\n <ArrowRightLeft className=\"size-3.5\" />\n {t(`data_sync.dashboard.direction.${selectedDirection}`)}\n </Badge>\n <Badge variant={integrationStateVariant} className=\"gap-1.5\">\n <ShieldCheck className=\"size-3.5\" />\n {selectedIntegration.isEnabled\n ? t('data_sync.dashboard.start.status.enabled', 'Integration enabled')\n : t('data_sync.dashboard.start.status.disabled', 'Integration disabled')}\n </Badge>\n <Badge variant={credentialsVariant} className=\"gap-1.5\">\n <PlugZap className=\"size-3.5\" />\n {selectedIntegration.hasCredentials\n ? t('data_sync.dashboard.start.status.credentialsReady', 'Credentials ready')\n : t('data_sync.dashboard.start.status.credentialsMissing', 'Credentials missing')}\n </Badge>\n <Badge variant={scheduleVariant} className=\"gap-1.5\">\n <CalendarClock className=\"size-3.5\" />\n {hasSavedSchedule\n ? (scheduleEditor.isEnabled\n ? t('data_sync.dashboard.schedule.status.enabled', 'Recurring schedule active')\n : t('data_sync.dashboard.schedule.status.disabled', 'Recurring schedule paused'))\n : t('data_sync.dashboard.schedule.status.none', 'No recurring schedule')}\n </Badge>\n </div>\n ) : null}\n </CardHeader>\n <CardContent className=\"space-y-6\">\n <div className=\"grid gap-4 xl:grid-cols-3\">\n <div className=\"space-y-2 xl:col-span-1\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <PlugZap className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.columns.integration')}</span>\n </Label>\n <Select\n value={selectedIntegrationId || undefined}\n onValueChange={(value) => setSelectedIntegrationId(value ?? '')}\n disabled={isLoadingOptions || options.length === 0}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue\n placeholder={\n options.length === 0\n ? t('integrations.marketplace.noResults', 'No integrations found')\n : undefined\n }\n />\n </SelectTrigger>\n <SelectContent>\n {options.map((item) => (\n <SelectItem key={item.integrationId} value={item.integrationId}>\n {item.title}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Boxes className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.columns.entityType')}</span>\n </Label>\n <Select\n value={selectedEntityType || undefined}\n onValueChange={(value) => setSelectedEntityType(value ?? '')}\n disabled={entityOptions.length === 0}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {entityOptions.map((entityType) => (\n <SelectItem key={entityType} value={entityType}>\n {formatEntityTypeLabel(entityType)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <ArrowRightLeft className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.columns.direction')}</span>\n </Label>\n <Select\n value={selectedDirection}\n onValueChange={(value) => setSelectedDirection(value === 'export' ? 'export' : 'import')}\n disabled={selectedIntegration?.direction !== 'bidirectional'}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"import\">{t('data_sync.dashboard.direction.import')}</SelectItem>\n {(selectedIntegration?.direction === 'bidirectional' || selectedIntegration?.direction === 'export') ? (\n <SelectItem value=\"export\">{t('data_sync.dashboard.direction.export')}</SelectItem>\n ) : null}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n {selectedIntegration?.description ? (\n <p className=\"text-sm text-muted-foreground\">{selectedIntegration.description}</p>\n ) : null}\n\n <div className=\"grid gap-4 xl:grid-cols-2\">\n <div className=\"rounded-xl border bg-muted/30 p-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <Play className=\"size-4 text-primary\" />\n <h3 className=\"text-sm font-semibold\">{t('data_sync.dashboard.start.runNowTitle', 'Run once now')}</h3>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {startControls.batchSize && startControls.fullSync\n ? t('data_sync.dashboard.start.runNowDescription', 'Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.')\n : t('data_sync.dashboard.start.runNowDescriptionScoped', 'Use this for the next immediate sync. Anything set here applies only to this manual run.')}\n </p>\n </div>\n <Badge variant=\"outline\">{selectedEntityLabel}</Badge>\n </div>\n\n <Separator className=\"my-4\" />\n\n {startControls.batchSize || startControls.fullSync ? (\n <div className={cn('grid gap-4', startControlsGridClass(startControls))}>\n {startControls.batchSize ? (\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Gauge className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.start.batchSize', 'Batch size')}</span>\n </Label>\n <Input\n value={batchSize}\n onChange={(event) => setBatchSize(event.target.value)}\n inputMode=\"numeric\"\n />\n </div>\n ) : null}\n {startControls.fullSync ? (\n <div className=\"rounded-lg border bg-background p-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label className=\"text-sm font-medium\">{t('data_sync.dashboard.start.fullSync', 'Run as full sync')}</Label>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.start.fullSyncHelp', 'Ignore the saved cursor and process the entire source again for this run.')}\n </p>\n </div>\n <Switch checked={fullSync} onCheckedChange={setFullSync} />\n </div>\n </div>\n ) : null}\n </div>\n ) : null}\n\n {runParameters.length > 0 ? (\n <div className=\"mt-4 space-y-3\">\n <div className=\"flex items-center gap-2\">\n <Settings2 className=\"size-4 text-muted-foreground\" />\n <h4 className=\"text-sm font-semibold\">\n {t('data_sync.dashboard.start.parameters', 'Run parameters')}\n </h4>\n </div>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.start.parametersHelp', 'Optional values this integration accepts for the manual run.')}\n </p>\n <RunParameterFields\n params={runParameters}\n values={paramValues}\n onChange={updateParamValue}\n />\n </div>\n ) : null}\n\n <div className=\"mt-4 flex flex-wrap items-center justify-between gap-3\">\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.start.runNowFootnote', 'Manual runs show progress immediately and land on the run detail page after launch.')}\n </p>\n <Button\n type=\"button\"\n onClick={() => void handleStartSync()}\n disabled={!canStartSelectedIntegration}\n >\n <Play className=\"mr-2 size-4\" />\n {t('data_sync.dashboard.start.submit', 'Start sync')}\n </Button>\n </div>\n </div>\n\n <div className=\"rounded-xl border bg-muted/30 p-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <CalendarClock className=\"size-4 text-primary\" />\n <h3 className=\"text-sm font-semibold\">{t('data_sync.dashboard.schedule.title', 'Recurring schedule')}</h3>\n </div>\n <p className=\"text-sm text-muted-foreground\">\n {t('data_sync.dashboard.schedule.description', 'Save a repeating schedule for the selected integration, entity, and direction without leaving this dashboard.')}\n </p>\n </div>\n <Badge variant=\"outline\">\n {hasSavedSchedule\n ? (scheduleEditor.isEnabled\n ? t('data_sync.dashboard.schedule.status.shortEnabled', 'Scheduled')\n : t('data_sync.dashboard.schedule.status.shortDisabled', 'Paused'))\n : t('data_sync.dashboard.schedule.status.shortNone', 'One-time only')}\n </Badge>\n </div>\n\n <Separator className=\"my-4\" />\n\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Clock3 className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.schedule.type', 'Schedule type')}</span>\n </Label>\n <Select\n value={scheduleEditor.scheduleType}\n onValueChange={(value) => updateScheduleEditor({\n scheduleType: value === 'cron' ? 'cron' : 'interval',\n })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n >\n <SelectTrigger size=\"lg\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"interval\">{t('data_sync.dashboard.schedule.interval', 'Interval')}</SelectItem>\n <SelectItem value=\"cron\">{t('data_sync.dashboard.schedule.cron', 'Cron')}</SelectItem>\n </SelectContent>\n </Select>\n </div>\n <div className=\"space-y-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <CalendarClock className=\"size-4 text-muted-foreground\" />\n <span>\n {scheduleEditor.scheduleType === 'cron'\n ? t('data_sync.dashboard.schedule.cronValue', 'Cron expression')\n : t('data_sync.dashboard.schedule.intervalValue', 'Interval')}\n </span>\n </Label>\n <Input\n value={scheduleEditor.scheduleValue}\n onChange={(event) => updateScheduleEditor({ scheduleValue: event.target.value })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n placeholder={scheduleEditor.scheduleType === 'cron' ? '0 * * * *' : '1h'}\n />\n <p className=\"text-xs text-muted-foreground\">\n {scheduleEditor.scheduleType === 'cron'\n ? t('data_sync.dashboard.schedule.cronHelp', 'Example: `0 * * * *` runs at the start of every hour.')\n : t('data_sync.dashboard.schedule.intervalHelp', 'Example: `1h`, `6h`, or `24h` for repeating intervals.')}\n </p>\n </div>\n <div className=\"space-y-2 sm:col-span-2\">\n <Label className=\"flex items-center gap-2 text-sm font-medium\">\n <Clock3 className=\"size-4 text-muted-foreground\" />\n <span>{t('data_sync.dashboard.schedule.timezone', 'Timezone')}</span>\n </Label>\n <Input\n value={scheduleEditor.timezone}\n onChange={(event) => updateScheduleEditor({ timezone: event.target.value })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n />\n </div>\n </div>\n\n <div className=\"mt-4 grid gap-3\">\n <div className=\"rounded-lg border bg-background p-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label className=\"text-sm font-medium\">{t('data_sync.dashboard.schedule.fullSync', 'Run scheduled jobs as full sync')}</Label>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.schedule.fullSyncHelp', 'When enabled, every recurring run starts from the beginning instead of the saved cursor.')}\n </p>\n </div>\n <Switch\n checked={scheduleEditor.fullSync}\n onCheckedChange={(checked) => updateScheduleEditor({ fullSync: checked })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n />\n </div>\n </div>\n <div className=\"rounded-lg border bg-background p-3\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label className=\"text-sm font-medium\">{t('data_sync.dashboard.schedule.enabled', 'Schedule enabled')}</Label>\n <p className=\"text-xs text-muted-foreground\">\n {t('data_sync.dashboard.schedule.enabledHelp', 'Pause the recurring job without deleting the schedule definition.')}\n </p>\n </div>\n <Switch\n checked={scheduleEditor.isEnabled}\n onCheckedChange={(checked) => updateScheduleEditor({ isEnabled: checked })}\n disabled={isLoadingSchedule || isSavingSchedule || isDeletingSchedule || !selectedIntegration || !selectedEntityType}\n />\n </div>\n </div>\n </div>\n\n <div className=\"mt-4 flex flex-wrap items-center justify-between gap-3\">\n <div className=\"space-y-1 text-xs text-muted-foreground\">\n <div>\n {hasSavedSchedule\n ? (scheduleEditor.lastRunAt\n ? t('data_sync.dashboard.schedule.lastRun', 'Last scheduled run: {value}', {\n value: new Date(scheduleEditor.lastRunAt).toLocaleString(),\n })\n : t('data_sync.dashboard.schedule.neverRun', 'Saved, but no scheduled execution has completed yet.'))\n : t('data_sync.dashboard.schedule.none', 'No recurring schedule saved for this target yet.')}\n </div>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void handleDeleteSchedule()}\n disabled={!hasSavedSchedule || isDeletingSchedule}\n >\n {isDeletingSchedule\n ? t('data_sync.dashboard.schedule.deleting', 'Removing...')\n : t('data_sync.dashboard.schedule.delete', 'Remove schedule')}\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void handleSaveSchedule()}\n disabled={isSavingSchedule || !selectedIntegration || !selectedEntityType}\n >\n <CalendarClock className=\"mr-2 size-4\" />\n {isSavingSchedule\n ? t('data_sync.dashboard.schedule.saving', 'Saving...')\n : t('data_sync.dashboard.schedule.save', 'Save recurring schedule')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n\n {selectedIntegration && !selectedIntegration.isEnabled ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('integrations.detail.state.disabled', 'This integration is disabled. Enable it on the integration settings page before starting a sync.')}\n </AlertDescription>\n </Alert>\n ) : null}\n {selectedIntegration && !selectedIntegration.hasCredentials ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('integrations.detail.credentials.notConfigured', 'Credentials are not configured yet. Save the integration credentials before starting a sync.')}\n </AlertDescription>\n </Alert>\n ) : null}\n {selectedIntegration && selectedIntegration.canStartRun === false ? (\n <Alert status=\"information\">\n <AlertDescription>\n {t('data_sync.dashboard.start.providerManaged', 'This integration starts sync runs from its own setup flow. Open the integration settings page to continue.')}\n </AlertDescription>\n </Alert>\n ) : null}\n </CardContent>\n </Card>\n\n <DataTable\n stickyActionsColumn\n title={t('data_sync.dashboard.title')}\n titleHeadingLevel={1}\n columns={columns}\n data={rows}\n filters={filters}\n filterValues={filterValues}\n onFiltersApply={handleFiltersApply}\n onFiltersClear={handleFiltersClear}\n searchValue={search}\n onSearchChange={(value) => { setSearch(value); setPage(1) }}\n searchPlaceholder={t('data_sync.dashboard.searchPlaceholder')}\n perspective={{ tableId: extensionPoints.hosts.runsTable.tableId }}\n onRowClick={(row) => {\n router.push(`/backend/data-sync/runs/${encodeURIComponent(row.id)}`)\n }}\n rowActions={(row) => (\n <RowActions items={[\n {\n id: 'view',\n label: t('data_sync.dashboard.actions.view'),\n onSelect: () => { router.push(`/backend/data-sync/runs/${encodeURIComponent(row.id)}`) },\n },\n ...(row.status === 'running' ? [{\n id: 'cancel',\n label: t('data_sync.runs.detail.cancel'),\n destructive: true,\n onSelect: () => { void handleCancel(row) },\n }] : []),\n ...(row.status === 'failed' ? [{\n id: 'retry',\n label: t('data_sync.runs.detail.retry'),\n onSelect: () => { void handleRetry(row) },\n }] : []),\n ]} />\n )}\n pagination={{ page, pageSize: 20, total, totalPages, totalIsCapped, onPageChange: setPage }}\n isLoading={isLoading}\n />\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAinByB,cAmET,YAnES;AAhnBzB,YAAY,WAAW;AACvB,SAAS,uBAAuB;AAChC,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,iBAAiB;AAG1B,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,MAAM,aAAa,YAAY,iBAAiB;AACzD,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,OAAO,wBAAwB;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,SAAS,mCAAmC;AACrD,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB,6BAA6B;AAE/D,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAuEP,MAAM,mBAAmB,KAAK,eAAe,EAAE,gBAAgB,EAAE,YAAY;AAG7E,MAAM,qBAAqB;AAO3B,SAAS,uBAAuB,UAAyD;AACvF,MAAI,SAAS,aAA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,YACE,IAAI;AAAA,YACJ,OAAO,EAAE,kCAAkC;AAAA,YAC3C,UAAU,MAAM;AAAE,qBAAO,KAAK,2BAA2B,mBAAmB,IAAI,EAAE,CAAC,EAAE;AAAA,YAAE;AAAA,UACzF;AAAA,UACA,GAAI,IAAI,WAAW,YAAY,CAAC;AAAA,YAC9B,IAAI;AAAA,YACJ,OAAO,EAAE,8BAA8B;AAAA,YACvC,aAAa;AAAA,YACb,UAAU,MAAM;AAAE,mBAAK,aAAa,GAAG;AAAA,YAAE;AAAA,UAC3C,CAAC,IAAI,CAAC;AAAA,UACN,GAAI,IAAI,WAAW,WAAW,CAAC;AAAA,YAC7B,IAAI;AAAA,YACJ,OAAO,EAAE,6BAA6B;AAAA,YACtC,UAAU,MAAM;AAAE,mBAAK,YAAY,GAAG;AAAA,YAAE;AAAA,UAC1C,CAAC,IAAI,CAAC;AAAA,QACR,GAAG;AAAA,QAEL,YAAY,EAAE,MAAM,UAAU,IAAI,OAAO,YAAY,eAAe,cAAc,QAAQ;AAAA,QAC1F;AAAA;AAAA,IACF;AAAA,KACF,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const START_CONTROL_KEYS = { fullSync: true, batchSize: true };
|
|
2
|
+
const DATA_SYNC_START_CONTROLS = Object.keys(START_CONTROL_KEYS);
|
|
3
|
+
function allApplicable() {
|
|
4
|
+
return { fullSync: true, batchSize: true };
|
|
5
|
+
}
|
|
6
|
+
function isApplicable(adapter, control, entityType) {
|
|
7
|
+
try {
|
|
8
|
+
return adapter.supportsStartControl?.(control, entityType) !== false;
|
|
9
|
+
} catch {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function resolveStartControlMap(adapter) {
|
|
14
|
+
if (!adapter || typeof adapter.supportsStartControl !== "function") return {};
|
|
15
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
16
|
+
for (const entityType of adapter.supportedEntities ?? []) {
|
|
17
|
+
const applicability = allApplicable();
|
|
18
|
+
let restricted = false;
|
|
19
|
+
for (const control of DATA_SYNC_START_CONTROLS) {
|
|
20
|
+
if (isApplicable(adapter, control, entityType)) continue;
|
|
21
|
+
applicability[control] = false;
|
|
22
|
+
restricted = true;
|
|
23
|
+
}
|
|
24
|
+
if (restricted) map[entityType] = applicability;
|
|
25
|
+
}
|
|
26
|
+
return map;
|
|
27
|
+
}
|
|
28
|
+
function applicableStartControls(map, entityType) {
|
|
29
|
+
if (!map || !Object.prototype.hasOwnProperty.call(map, entityType)) return allApplicable();
|
|
30
|
+
const declared = map[entityType];
|
|
31
|
+
const applicability = allApplicable();
|
|
32
|
+
for (const control of DATA_SYNC_START_CONTROLS) {
|
|
33
|
+
if (declared?.[control] === false) applicability[control] = false;
|
|
34
|
+
}
|
|
35
|
+
return applicability;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
DATA_SYNC_START_CONTROLS,
|
|
39
|
+
applicableStartControls,
|
|
40
|
+
resolveStartControlMap
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=start-controls.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/data_sync/lib/start-controls.ts"],
|
|
4
|
+
"sourcesContent": ["import type { DataSyncAdapter, DataSyncStartControl } from './adapter'\n\n/**\n * Keyed by the union rather than listed, so adding a control to\n * {@link DataSyncStartControl} fails to compile here instead of silently\n * dropping out of the resolution loop and the client-side read.\n */\nconst START_CONTROL_KEYS: Record<DataSyncStartControl, true> = { fullSync: true, batchSize: true }\n\nexport const DATA_SYNC_START_CONTROLS = Object.keys(START_CONTROL_KEYS) as readonly DataSyncStartControl[]\n\nexport type StartControlApplicability = Record<DataSyncStartControl, boolean>\n\n/**\n * Which manual-start controls apply, per entity type, as resolved by\n * `api/options.ts` and read by the dashboard.\n *\n * The map is sparse: an entity type whose controls all apply is omitted, so an\n * adapter that declares nothing serializes to `{}` and adds nothing to the\n * wire. \"Not declared\" and \"nothing restricted\" therefore share one default.\n */\nexport type StartControlMap = Record<string, StartControlApplicability>\n\nfunction allApplicable(): StartControlApplicability {\n return { fullSync: true, batchSize: true }\n}\n\n/**\n * A predicate that throws is treated as \"applies\". `api/options.ts` evaluates\n * every registered adapter in one response, so an adapter with a broken\n * predicate would otherwise take the options list \u2014 and with it the whole\n * dashboard \u2014 down for every other integration.\n */\nfunction isApplicable(\n adapter: DataSyncAdapter,\n control: DataSyncStartControl,\n entityType: string,\n): boolean {\n try {\n return adapter.supportsStartControl?.(control, entityType) !== false\n } catch {\n return true\n }\n}\n\n/**\n * Evaluates an adapter's declaration across the entity types it supports.\n *\n * The accumulator has a null prototype: assigning `__proto__` on a plain object\n * literal sets that object's prototype instead of creating an own property, so\n * an entity type under that name would serialize away and silently lose the\n * restriction the adapter declared.\n */\nexport function resolveStartControlMap(adapter: DataSyncAdapter | null | undefined): StartControlMap {\n if (!adapter || typeof adapter.supportsStartControl !== 'function') return {}\n const map: StartControlMap = Object.create(null)\n for (const entityType of adapter.supportedEntities ?? []) {\n const applicability = allApplicable()\n let restricted = false\n for (const control of DATA_SYNC_START_CONTROLS) {\n if (isApplicable(adapter, control, entityType)) continue\n applicability[control] = false\n restricted = true\n }\n if (restricted) map[entityType] = applicability\n }\n return map\n}\n\n/**\n * Reads the resolved map for the selected entity type, defaulting to \"every\n * control applies\" for an entity type the map does not restrict.\n *\n * The lookup is own-property only: an entity type named after something on\n * `Object.prototype` would otherwise read back an inherited value whose\n * `fullSync` is `undefined`, hiding a control the adapter never restricted.\n */\nexport function applicableStartControls(\n map: StartControlMap | null | undefined,\n entityType: string,\n): StartControlApplicability {\n if (!map || !Object.prototype.hasOwnProperty.call(map, entityType)) return allApplicable()\n const declared = map[entityType]\n const applicability = allApplicable()\n for (const control of DATA_SYNC_START_CONTROLS) {\n if (declared?.[control] === false) applicability[control] = false\n }\n return applicability\n}\n"],
|
|
5
|
+
"mappings": "AAOA,MAAM,qBAAyD,EAAE,UAAU,MAAM,WAAW,KAAK;AAE1F,MAAM,2BAA2B,OAAO,KAAK,kBAAkB;AActE,SAAS,gBAA2C;AAClD,SAAO,EAAE,UAAU,MAAM,WAAW,KAAK;AAC3C;AAQA,SAAS,aACP,SACA,SACA,YACS;AACT,MAAI;AACF,WAAO,QAAQ,uBAAuB,SAAS,UAAU,MAAM;AAAA,EACjE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAUO,SAAS,uBAAuB,SAA8D;AACnG,MAAI,CAAC,WAAW,OAAO,QAAQ,yBAAyB,WAAY,QAAO,CAAC;AAC5E,QAAM,MAAuB,uBAAO,OAAO,IAAI;AAC/C,aAAW,cAAc,QAAQ,qBAAqB,CAAC,GAAG;AACxD,UAAM,gBAAgB,cAAc;AACpC,QAAI,aAAa;AACjB,eAAW,WAAW,0BAA0B;AAC9C,UAAI,aAAa,SAAS,SAAS,UAAU,EAAG;AAChD,oBAAc,OAAO,IAAI;AACzB,mBAAa;AAAA,IACf;AACA,QAAI,WAAY,KAAI,UAAU,IAAI;AAAA,EACpC;AACA,SAAO;AACT;AAUO,SAAS,wBACd,KACA,YAC2B;AAC3B,MAAI,CAAC,OAAO,CAAC,OAAO,UAAU,eAAe,KAAK,KAAK,UAAU,EAAG,QAAO,cAAc;AACzF,QAAM,WAAW,IAAI,UAAU;AAC/B,QAAM,gBAAgB,cAAc;AACpC,aAAW,WAAW,0BAA0B;AAC9C,QAAI,WAAW,OAAO,MAAM,MAAO,eAAc,OAAO,IAAI;AAAA,EAC9D;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.7.1-develop.
|
|
3
|
+
"version": "0.7.1-develop.7181.1.702cedc42c",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -252,16 +252,16 @@
|
|
|
252
252
|
"zod": "^4.4.3"
|
|
253
253
|
},
|
|
254
254
|
"peerDependencies": {
|
|
255
|
-
"@open-mercato/ai-assistant": "0.7.1-develop.
|
|
256
|
-
"@open-mercato/shared": "0.7.1-develop.
|
|
257
|
-
"@open-mercato/ui": "0.7.1-develop.
|
|
255
|
+
"@open-mercato/ai-assistant": "0.7.1-develop.7181.1.702cedc42c",
|
|
256
|
+
"@open-mercato/shared": "0.7.1-develop.7181.1.702cedc42c",
|
|
257
|
+
"@open-mercato/ui": "0.7.1-develop.7181.1.702cedc42c",
|
|
258
258
|
"react": "^19.0.0",
|
|
259
259
|
"react-dom": "^19.0.0"
|
|
260
260
|
},
|
|
261
261
|
"devDependencies": {
|
|
262
|
-
"@open-mercato/ai-assistant": "0.7.1-develop.
|
|
263
|
-
"@open-mercato/shared": "0.7.1-develop.
|
|
264
|
-
"@open-mercato/ui": "0.7.1-develop.
|
|
262
|
+
"@open-mercato/ai-assistant": "0.7.1-develop.7181.1.702cedc42c",
|
|
263
|
+
"@open-mercato/shared": "0.7.1-develop.7181.1.702cedc42c",
|
|
264
|
+
"@open-mercato/ui": "0.7.1-develop.7181.1.702cedc42c",
|
|
265
265
|
"@testing-library/dom": "^10.4.1",
|
|
266
266
|
"@testing-library/jest-dom": "^7.0.1",
|
|
267
267
|
"@testing-library/react": "^16.3.3",
|
|
@@ -111,6 +111,7 @@ interface DataSyncAdapter {
|
|
|
111
111
|
getInitialCursor?(input: { entityType: string; scope: TenantScope }): Promise<string | null>
|
|
112
112
|
getMapping(input: { entityType: string; scope: TenantScope }): Promise<DataMapping>
|
|
113
113
|
persistsSharedCursor?(entityType: string): boolean
|
|
114
|
+
supportsStartControl?(control: 'fullSync' | 'batchSize', entityType: string): boolean
|
|
114
115
|
validateConnection?(input: {
|
|
115
116
|
entityType: string
|
|
116
117
|
credentials: Record<string, unknown>
|
|
@@ -190,6 +191,39 @@ against the defaults, not against `undefined`. A default that violates its own
|
|
|
190
191
|
declaration skips the scheduled run with a logged error instead of starting it
|
|
191
192
|
with a half-applied set.
|
|
192
193
|
|
|
194
|
+
### Start controls
|
|
195
|
+
|
|
196
|
+
The dashboard's "Run once now" card also renders two controls the framework owns
|
|
197
|
+
— **Run as full sync** and **Batch size**. Whether either is meaningful for an
|
|
198
|
+
entity type is adapter knowledge, so an adapter may declare it per entity type:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
supportsStartControl: (control, entityType) =>
|
|
202
|
+
!(control === 'fullSync' && entityType.endsWith('.backfill')),
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Only an explicit `false` removes a control; an adapter that declares nothing —
|
|
206
|
+
or returns nothing — keeps today's form exactly. Return `false` where the
|
|
207
|
+
operator's choice reaches the adapter and changes nothing observable: an entity
|
|
208
|
+
type whose cursor carries identity, so an inherited cursor is discarded and the
|
|
209
|
+
run starts from the top whichever way `fullSync` is set; or one whose paging the
|
|
210
|
+
source fixes, so `batchSize` is read and ignored.
|
|
211
|
+
|
|
212
|
+
`api/options.ts` evaluates the predicate across `supportedEntities` and ships the
|
|
213
|
+
result as `startControls` — a **sparse** map, so an entity type with no
|
|
214
|
+
restriction is omitted and an adapter that declares nothing serializes to `{}`.
|
|
215
|
+
`lib/start-controls.ts` owns both halves (`resolveStartControlMap` server-side,
|
|
216
|
+
`applicableStartControls` in the dashboard); a predicate that throws is treated
|
|
217
|
+
as *applies*, because the options route resolves every registered adapter in one
|
|
218
|
+
response.
|
|
219
|
+
|
|
220
|
+
**This governs what the dashboard offers, never what the API accepts.**
|
|
221
|
+
`POST /api/data_sync/run` keeps honouring both fields, so a client posting
|
|
222
|
+
`fullSync: true` still gets a `null` start cursor whatever the adapter declares.
|
|
223
|
+
Do not derive applicability from `persistsSharedCursor` — where a cursor is
|
|
224
|
+
stored and whether restarting from scratch is meaningful are independent facts,
|
|
225
|
+
and both belong to the adapter to state.
|
|
226
|
+
|
|
193
227
|
If the sync provider needs bootstrap credentials, mappings, locales, channels, or other default sync settings after a fresh install, implement a provider-owned env preset flow:
|
|
194
228
|
|
|
195
229
|
- read env vars in the provider package
|
|
@@ -6,6 +6,7 @@ import { getAllIntegrations } from '@open-mercato/shared/modules/integrations/ty
|
|
|
6
6
|
import type { CredentialsService } from '../../integrations/lib/credentials-service'
|
|
7
7
|
import type { IntegrationStateService } from '../../integrations/lib/state-service'
|
|
8
8
|
import { getDataSyncAdapter } from '../lib/adapter-registry'
|
|
9
|
+
import { resolveStartControlMap } from '../lib/start-controls'
|
|
9
10
|
|
|
10
11
|
export const metadata = {
|
|
11
12
|
GET: { requireAuth: true, requireFeatures: ['data_sync.view'] },
|
|
@@ -56,6 +57,7 @@ export async function GET(req: Request) {
|
|
|
56
57
|
canStartRun: adapter.runMode !== 'provider',
|
|
57
58
|
supportedEntities: adapter.supportedEntities,
|
|
58
59
|
runParameters: adapter.runParameters ?? [],
|
|
60
|
+
startControls: resolveStartControlMap(adapter),
|
|
59
61
|
hasCredentials: Boolean(credentials),
|
|
60
62
|
isEnabled,
|
|
61
63
|
settingsPath: `/backend/integrations/${encodeURIComponent(integration.id)}`,
|
|
@@ -31,6 +31,7 @@ import { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'
|
|
|
31
31
|
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
32
32
|
import { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'
|
|
33
33
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
34
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
34
35
|
import {
|
|
35
36
|
ArrowRightLeft,
|
|
36
37
|
Boxes,
|
|
@@ -46,6 +47,11 @@ import {
|
|
|
46
47
|
import { getSyncRunStatusVariant, getSyncSummaryVariant } from '../../lib/syncRunStatus'
|
|
47
48
|
import type { RunParameter } from '../../lib/adapter'
|
|
48
49
|
import { getApplicableRunParameters } from '../../lib/run-parameters'
|
|
50
|
+
import {
|
|
51
|
+
applicableStartControls,
|
|
52
|
+
type StartControlApplicability,
|
|
53
|
+
type StartControlMap,
|
|
54
|
+
} from '../../lib/start-controls'
|
|
49
55
|
import {
|
|
50
56
|
RunParameterFields,
|
|
51
57
|
buildDefaultRunParameterValues,
|
|
@@ -87,6 +93,7 @@ type SyncOption = {
|
|
|
87
93
|
canStartRun?: boolean
|
|
88
94
|
supportedEntities: string[]
|
|
89
95
|
runParameters?: RunParameter[]
|
|
96
|
+
startControls?: StartControlMap
|
|
90
97
|
hasCredentials: boolean
|
|
91
98
|
isEnabled: boolean
|
|
92
99
|
settingsPath: string
|
|
@@ -127,6 +134,20 @@ type SyncScheduleEditorState = {
|
|
|
127
134
|
|
|
128
135
|
const DEFAULT_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'
|
|
129
136
|
|
|
137
|
+
/** Matches `runSyncSchema`'s own default, so omitting the field submits this value. */
|
|
138
|
+
const DEFAULT_BATCH_SIZE = '100'
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Keeps the batch size input at its own narrow width without leaving a phantom
|
|
142
|
+
* track: the second column exists only when the full sync card fills it. With
|
|
143
|
+
* only that card the row falls back to one full-width column.
|
|
144
|
+
*/
|
|
145
|
+
function startControlsGridClass(controls: StartControlApplicability): string | undefined {
|
|
146
|
+
if (controls.batchSize && controls.fullSync) return 'sm:grid-cols-[minmax(0,180px)_1fr]'
|
|
147
|
+
if (controls.batchSize) return 'sm:grid-cols-[minmax(0,180px)]'
|
|
148
|
+
return undefined
|
|
149
|
+
}
|
|
150
|
+
|
|
130
151
|
function formatEntityTypeLabel(entityType: string): string {
|
|
131
152
|
return entityType
|
|
132
153
|
.replace(/[_-]+/g, ' ')
|
|
@@ -162,7 +183,7 @@ export default function SyncRunsDashboardPage() {
|
|
|
162
183
|
const [selectedIntegrationId, setSelectedIntegrationId] = React.useState('')
|
|
163
184
|
const [selectedEntityType, setSelectedEntityType] = React.useState('')
|
|
164
185
|
const [selectedDirection, setSelectedDirection] = React.useState<'import' | 'export'>('import')
|
|
165
|
-
const [batchSize, setBatchSize] = React.useState(
|
|
186
|
+
const [batchSize, setBatchSize] = React.useState(DEFAULT_BATCH_SIZE)
|
|
166
187
|
const [fullSync, setFullSync] = React.useState(false)
|
|
167
188
|
const [paramValues, setParamValues] = React.useState<Record<string, RunParameterFormValue>>({})
|
|
168
189
|
const [scheduleEditor, setScheduleEditor] = React.useState<SyncScheduleEditorState>(() => buildDefaultScheduleState(''))
|
|
@@ -261,10 +282,27 @@ export default function SyncRunsDashboardPage() {
|
|
|
261
282
|
[selectedIntegration, selectedDirection, selectedEntityType],
|
|
262
283
|
)
|
|
263
284
|
|
|
285
|
+
// Before an entity is chosen the state is '', which matches no declaration and
|
|
286
|
+
// so renders both controls — the unselected form as it is today.
|
|
287
|
+
const startControls = React.useMemo(
|
|
288
|
+
() => applicableStartControls(selectedIntegration?.startControls, selectedEntityType),
|
|
289
|
+
[selectedIntegration, selectedEntityType],
|
|
290
|
+
)
|
|
291
|
+
|
|
264
292
|
React.useEffect(() => {
|
|
265
293
|
setParamValues(buildDefaultRunParameterValues(runParameters))
|
|
266
294
|
}, [runParameters])
|
|
267
295
|
|
|
296
|
+
// A control the form stopped showing must not keep submitting the value the
|
|
297
|
+
// operator last set for another entity type.
|
|
298
|
+
React.useEffect(() => {
|
|
299
|
+
if (!startControls.fullSync) setFullSync(false)
|
|
300
|
+
}, [startControls.fullSync])
|
|
301
|
+
|
|
302
|
+
React.useEffect(() => {
|
|
303
|
+
if (!startControls.batchSize) setBatchSize(DEFAULT_BATCH_SIZE)
|
|
304
|
+
}, [startControls.batchSize])
|
|
305
|
+
|
|
268
306
|
const updateParamValue = React.useCallback((key: string, value: RunParameterFormValue) => {
|
|
269
307
|
setParamValues((current) => ({ ...current, [key]: value }))
|
|
270
308
|
}, [])
|
|
@@ -384,20 +422,23 @@ export default function SyncRunsDashboardPage() {
|
|
|
384
422
|
const handleStartSync = React.useCallback(async () => {
|
|
385
423
|
if (!selectedIntegration || !selectedEntityType) return
|
|
386
424
|
|
|
387
|
-
const parsedBatchSize = Number.parseInt(batchSize, 10)
|
|
388
|
-
if (!Number.isFinite(parsedBatchSize) || parsedBatchSize < 1 || parsedBatchSize > 1000) {
|
|
389
|
-
flash(t('data_sync.dashboard.start.invalidBatchSize', 'Batch size must be between 1 and 1000.'), 'error')
|
|
390
|
-
return
|
|
391
|
-
}
|
|
392
|
-
|
|
393
425
|
const parameters = buildRunParametersPayload(runParameters, paramValues)
|
|
426
|
+
// A control the adapter declared inapplicable is left out entirely, so
|
|
427
|
+
// `runSyncSchema`'s defaults supply exactly what the rendered form sends.
|
|
394
428
|
const requestBody: Record<string, unknown> = {
|
|
395
429
|
integrationId: selectedIntegration.integrationId,
|
|
396
430
|
entityType: selectedEntityType,
|
|
397
431
|
direction: selectedDirection,
|
|
398
|
-
batchSize: parsedBatchSize,
|
|
399
|
-
fullSync,
|
|
400
432
|
}
|
|
433
|
+
if (startControls.batchSize) {
|
|
434
|
+
const parsedBatchSize = Number.parseInt(batchSize, 10)
|
|
435
|
+
if (!Number.isFinite(parsedBatchSize) || parsedBatchSize < 1 || parsedBatchSize > 1000) {
|
|
436
|
+
flash(t('data_sync.dashboard.start.invalidBatchSize', 'Batch size must be between 1 and 1000.'), 'error')
|
|
437
|
+
return
|
|
438
|
+
}
|
|
439
|
+
requestBody.batchSize = parsedBatchSize
|
|
440
|
+
}
|
|
441
|
+
if (startControls.fullSync) requestBody.fullSync = fullSync
|
|
401
442
|
if (runParameters.length > 0) requestBody.parameters = parameters
|
|
402
443
|
|
|
403
444
|
try {
|
|
@@ -432,7 +473,7 @@ export default function SyncRunsDashboardPage() {
|
|
|
432
473
|
const message = error instanceof Error ? error.message : t('data_sync.dashboard.start.error', 'Failed to start sync run')
|
|
433
474
|
flash(message, 'error')
|
|
434
475
|
}
|
|
435
|
-
}, [batchSize, fullSync, paramValues, router, runMutation, runParameters, selectedDirection, selectedEntityType, selectedIntegration, t])
|
|
476
|
+
}, [batchSize, fullSync, paramValues, router, runMutation, runParameters, selectedDirection, selectedEntityType, selectedIntegration, startControls, t])
|
|
436
477
|
|
|
437
478
|
const handleSaveSchedule = React.useCallback(async () => {
|
|
438
479
|
if (!selectedIntegration || !selectedEntityType) return
|
|
@@ -791,7 +832,9 @@ export default function SyncRunsDashboardPage() {
|
|
|
791
832
|
<h3 className="text-sm font-semibold">{t('data_sync.dashboard.start.runNowTitle', 'Run once now')}</h3>
|
|
792
833
|
</div>
|
|
793
834
|
<p className="text-sm text-muted-foreground">
|
|
794
|
-
{
|
|
835
|
+
{startControls.batchSize && startControls.fullSync
|
|
836
|
+
? t('data_sync.dashboard.start.runNowDescription', 'Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.')
|
|
837
|
+
: t('data_sync.dashboard.start.runNowDescriptionScoped', 'Use this for the next immediate sync. Anything set here applies only to this manual run.')}
|
|
795
838
|
</p>
|
|
796
839
|
</div>
|
|
797
840
|
<Badge variant="outline">{selectedEntityLabel}</Badge>
|
|
@@ -799,30 +842,36 @@ export default function SyncRunsDashboardPage() {
|
|
|
799
842
|
|
|
800
843
|
<Separator className="my-4" />
|
|
801
844
|
|
|
802
|
-
|
|
803
|
-
<div className=
|
|
804
|
-
|
|
805
|
-
<
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
<div className="flex items-center justify-between gap-3">
|
|
816
|
-
<div className="space-y-1">
|
|
817
|
-
<Label className="text-sm font-medium">{t('data_sync.dashboard.start.fullSync', 'Run as full sync')}</Label>
|
|
818
|
-
<p className="text-xs text-muted-foreground">
|
|
819
|
-
{t('data_sync.dashboard.start.fullSyncHelp', 'Ignore the saved cursor and process the entire source again for this run.')}
|
|
820
|
-
</p>
|
|
845
|
+
{startControls.batchSize || startControls.fullSync ? (
|
|
846
|
+
<div className={cn('grid gap-4', startControlsGridClass(startControls))}>
|
|
847
|
+
{startControls.batchSize ? (
|
|
848
|
+
<div className="space-y-2">
|
|
849
|
+
<Label className="flex items-center gap-2 text-sm font-medium">
|
|
850
|
+
<Gauge className="size-4 text-muted-foreground" />
|
|
851
|
+
<span>{t('data_sync.dashboard.start.batchSize', 'Batch size')}</span>
|
|
852
|
+
</Label>
|
|
853
|
+
<Input
|
|
854
|
+
value={batchSize}
|
|
855
|
+
onChange={(event) => setBatchSize(event.target.value)}
|
|
856
|
+
inputMode="numeric"
|
|
857
|
+
/>
|
|
821
858
|
</div>
|
|
822
|
-
|
|
823
|
-
|
|
859
|
+
) : null}
|
|
860
|
+
{startControls.fullSync ? (
|
|
861
|
+
<div className="rounded-lg border bg-background p-3">
|
|
862
|
+
<div className="flex items-center justify-between gap-3">
|
|
863
|
+
<div className="space-y-1">
|
|
864
|
+
<Label className="text-sm font-medium">{t('data_sync.dashboard.start.fullSync', 'Run as full sync')}</Label>
|
|
865
|
+
<p className="text-xs text-muted-foreground">
|
|
866
|
+
{t('data_sync.dashboard.start.fullSyncHelp', 'Ignore the saved cursor and process the entire source again for this run.')}
|
|
867
|
+
</p>
|
|
868
|
+
</div>
|
|
869
|
+
<Switch checked={fullSync} onCheckedChange={setFullSync} />
|
|
870
|
+
</div>
|
|
871
|
+
</div>
|
|
872
|
+
) : null}
|
|
824
873
|
</div>
|
|
825
|
-
|
|
874
|
+
) : null}
|
|
826
875
|
|
|
827
876
|
{runParameters.length > 0 ? (
|
|
828
877
|
<div className="mt-4 space-y-3">
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"data_sync.dashboard.start.parametersHelp": "Optionale Werte, die diese Integration für den manuellen Lauf akzeptiert.",
|
|
60
60
|
"data_sync.dashboard.start.providerManaged": "Diese Integration startet Synchronisierungsläufe über ihren eigenen Einrichtungsablauf. Öffne die Integrationseinstellungen, um fortzufahren.",
|
|
61
61
|
"data_sync.dashboard.start.runNowDescription": "Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.",
|
|
62
|
+
"data_sync.dashboard.start.runNowDescriptionScoped": "Use this for the next immediate sync. Anything set here applies only to this manual run.",
|
|
62
63
|
"data_sync.dashboard.start.runNowFootnote": "Manual runs show progress immediately and land on the run detail page after launch.",
|
|
63
64
|
"data_sync.dashboard.start.runNowTitle": "Run once now",
|
|
64
65
|
"data_sync.dashboard.start.status.credentialsMissing": "Credentials missing",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"data_sync.dashboard.start.parametersHelp": "Optional values this integration accepts for the manual run.",
|
|
60
60
|
"data_sync.dashboard.start.providerManaged": "This integration starts sync runs from its own setup flow. Open the integration settings page to continue.",
|
|
61
61
|
"data_sync.dashboard.start.runNowDescription": "Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.",
|
|
62
|
+
"data_sync.dashboard.start.runNowDescriptionScoped": "Use this for the next immediate sync. Anything set here applies only to this manual run.",
|
|
62
63
|
"data_sync.dashboard.start.runNowFootnote": "Manual runs show progress immediately and land on the run detail page after launch.",
|
|
63
64
|
"data_sync.dashboard.start.runNowTitle": "Run once now",
|
|
64
65
|
"data_sync.dashboard.start.status.credentialsMissing": "Credentials missing",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"data_sync.dashboard.start.parametersHelp": "Valores opcionales que esta integración acepta para la ejecución manual.",
|
|
60
60
|
"data_sync.dashboard.start.providerManaged": "Esta integración inicia las sincronizaciones desde su propio flujo de configuración. Abre la página de ajustes de la integración para continuar.",
|
|
61
61
|
"data_sync.dashboard.start.runNowDescription": "Use this for the next immediate sync. Batch size and full-sync mode apply only to this manual run.",
|
|
62
|
+
"data_sync.dashboard.start.runNowDescriptionScoped": "Use this for the next immediate sync. Anything set here applies only to this manual run.",
|
|
62
63
|
"data_sync.dashboard.start.runNowFootnote": "Manual runs show progress immediately and land on the run detail page after launch.",
|
|
63
64
|
"data_sync.dashboard.start.runNowTitle": "Run once now",
|
|
64
65
|
"data_sync.dashboard.start.status.credentialsMissing": "Credentials missing",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"data_sync.dashboard.start.parametersHelp": "이 통합이 수동 실행에 대해 허용하는 선택적 값입니다.",
|
|
60
60
|
"data_sync.dashboard.start.providerManaged": "이 통합은 자체 설정 흐름에서 동기화 실행을 시작합니다. 계속하려면 통합 설정 페이지를 여세요.",
|
|
61
61
|
"data_sync.dashboard.start.runNowDescription": "다음 즉시 동기화에 사용하세요. 배치 크기와 전체 동기화 모드는 이 수동 실행에만 적용됩니다.",
|
|
62
|
+
"data_sync.dashboard.start.runNowDescriptionScoped": "다음 즉시 동기화에 사용하세요. 여기에서 설정한 값은 이 수동 실행에만 적용됩니다.",
|
|
62
63
|
"data_sync.dashboard.start.runNowFootnote": "수동 실행은 즉시 진행 상황을 표시하며 시작 후 실행 상세 페이지로 이동합니다.",
|
|
63
64
|
"data_sync.dashboard.start.runNowTitle": "지금 한 번 실행",
|
|
64
65
|
"data_sync.dashboard.start.status.credentialsMissing": "자격 증명 누락",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"data_sync.dashboard.start.parametersHelp": "Opcjonalne wartości akceptowane przez tę integrację dla ręcznego uruchomienia.",
|
|
60
60
|
"data_sync.dashboard.start.providerManaged": "Ta integracja uruchamia synchronizacje z własnego przepływu konfiguracji. Otwórz ustawienia integracji, aby kontynuować.",
|
|
61
61
|
"data_sync.dashboard.start.runNowDescription": "Użyj tej opcji dla najbliższej natychmiastowej synchronizacji. Rozmiar partii i tryb pełnej synchronizacji dotyczą wyłącznie tego ręcznego przebiegu.",
|
|
62
|
+
"data_sync.dashboard.start.runNowDescriptionScoped": "Użyj tej opcji dla najbliższej natychmiastowej synchronizacji. Ustawienia wprowadzone tutaj dotyczą wyłącznie tego ręcznego przebiegu.",
|
|
62
63
|
"data_sync.dashboard.start.runNowFootnote": "Ręczne przebiegi od razu pokazują postęp, a po uruchomieniu przenoszą na stronę szczegółów przebiegu.",
|
|
63
64
|
"data_sync.dashboard.start.runNowTitle": "Uruchom teraz jednorazowo",
|
|
64
65
|
"data_sync.dashboard.start.status.credentialsMissing": "Brak poświadczeń",
|
|
@@ -207,6 +207,14 @@ export interface RunParameter {
|
|
|
207
207
|
entityType?: string | string[]
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* A control the `data_sync` dashboard renders on its "Run once now" card.
|
|
212
|
+
*
|
|
213
|
+
* - `fullSync` asks the run API for a `null` start cursor instead of a resolved one.
|
|
214
|
+
* - `batchSize` sets `StreamImportInput.batchSize` / `StreamExportInput.batchSize`.
|
|
215
|
+
*/
|
|
216
|
+
export type DataSyncStartControl = 'fullSync' | 'batchSize'
|
|
217
|
+
|
|
210
218
|
export interface DataSyncAdapter {
|
|
211
219
|
readonly providerKey: string
|
|
212
220
|
readonly direction: 'import' | 'export' | 'bidirectional'
|
|
@@ -266,6 +274,43 @@ export interface DataSyncAdapter {
|
|
|
266
274
|
* kinds — an incremental feed and a whole-table backfill.
|
|
267
275
|
*/
|
|
268
276
|
persistsSharedCursor?(entityType: string): boolean
|
|
277
|
+
/**
|
|
278
|
+
* Whether a control on the Data Sync dashboard's "Run once now" card is
|
|
279
|
+
* meaningful for this entity type. Only an explicit `false` removes a
|
|
280
|
+
* control, so an adapter that declares nothing — or returns nothing — keeps
|
|
281
|
+
* today's form exactly.
|
|
282
|
+
*
|
|
283
|
+
* Return `false` for an entity type where the operator's choice reaches the
|
|
284
|
+
* adapter and changes nothing observable: an entity type whose cursor carries
|
|
285
|
+
* identity, so an inherited cursor is discarded and the run starts from the
|
|
286
|
+
* top whichever way `fullSync` is set; or one whose paging the source fixes,
|
|
287
|
+
* so `batchSize` is read and ignored. That card then omits the control rather
|
|
288
|
+
* than offering a switch whose "no effect" an operator cannot tell apart from
|
|
289
|
+
* "it worked".
|
|
290
|
+
*
|
|
291
|
+
* Core cannot infer this — it does not know what an entity type does with the
|
|
292
|
+
* values it is handed. The adapter does, and this is the channel for saying
|
|
293
|
+
* so.
|
|
294
|
+
*
|
|
295
|
+
* SCOPE: the "Run once now" card only. It does NOT gate the recurring-schedule
|
|
296
|
+
* switch on the same page, nor the per-entity-type "Full" switch on the
|
|
297
|
+
* integration settings tab — whose row-level run posts that schedule's own
|
|
298
|
+
* `fullSync` to the same run API. An adapter that declares `fullSync`
|
|
299
|
+
* inapplicable still sees those, and `buildDefaultScheduleState` may pre-set
|
|
300
|
+
* them to `true`. Harmless by construction, since the adapter has said the
|
|
301
|
+
* value does not matter, but do not read this predicate as covering every
|
|
302
|
+
* place a run can be started.
|
|
303
|
+
*
|
|
304
|
+
* This governs what the dashboard OFFERS, not what the API accepts:
|
|
305
|
+
* `POST /api/data_sync/run` keeps honouring both fields, so a client that
|
|
306
|
+
* posts `fullSync: true` still gets a `null` cursor whatever this returns.
|
|
307
|
+
*
|
|
308
|
+
* The predicate is per entity type for the same reason
|
|
309
|
+
* {@link DataSyncAdapter.persistsSharedCursor} is — one adapter commonly
|
|
310
|
+
* serves both an incremental feed and a whole-table backfill, and only one of
|
|
311
|
+
* them has a beginning to restart from.
|
|
312
|
+
*/
|
|
313
|
+
supportsStartControl?(control: DataSyncStartControl, entityType: string): boolean
|
|
269
314
|
getInitialCursor?(input: { entityType: string; scope: TenantScope }): Promise<string | null>
|
|
270
315
|
getMapping(input: { entityType: string; scope: TenantScope }): Promise<DataMapping>
|
|
271
316
|
validateConnection?(input: {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { DataSyncAdapter, DataSyncStartControl } from './adapter'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keyed by the union rather than listed, so adding a control to
|
|
5
|
+
* {@link DataSyncStartControl} fails to compile here instead of silently
|
|
6
|
+
* dropping out of the resolution loop and the client-side read.
|
|
7
|
+
*/
|
|
8
|
+
const START_CONTROL_KEYS: Record<DataSyncStartControl, true> = { fullSync: true, batchSize: true }
|
|
9
|
+
|
|
10
|
+
export const DATA_SYNC_START_CONTROLS = Object.keys(START_CONTROL_KEYS) as readonly DataSyncStartControl[]
|
|
11
|
+
|
|
12
|
+
export type StartControlApplicability = Record<DataSyncStartControl, boolean>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Which manual-start controls apply, per entity type, as resolved by
|
|
16
|
+
* `api/options.ts` and read by the dashboard.
|
|
17
|
+
*
|
|
18
|
+
* The map is sparse: an entity type whose controls all apply is omitted, so an
|
|
19
|
+
* adapter that declares nothing serializes to `{}` and adds nothing to the
|
|
20
|
+
* wire. "Not declared" and "nothing restricted" therefore share one default.
|
|
21
|
+
*/
|
|
22
|
+
export type StartControlMap = Record<string, StartControlApplicability>
|
|
23
|
+
|
|
24
|
+
function allApplicable(): StartControlApplicability {
|
|
25
|
+
return { fullSync: true, batchSize: true }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A predicate that throws is treated as "applies". `api/options.ts` evaluates
|
|
30
|
+
* every registered adapter in one response, so an adapter with a broken
|
|
31
|
+
* predicate would otherwise take the options list — and with it the whole
|
|
32
|
+
* dashboard — down for every other integration.
|
|
33
|
+
*/
|
|
34
|
+
function isApplicable(
|
|
35
|
+
adapter: DataSyncAdapter,
|
|
36
|
+
control: DataSyncStartControl,
|
|
37
|
+
entityType: string,
|
|
38
|
+
): boolean {
|
|
39
|
+
try {
|
|
40
|
+
return adapter.supportsStartControl?.(control, entityType) !== false
|
|
41
|
+
} catch {
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Evaluates an adapter's declaration across the entity types it supports.
|
|
48
|
+
*
|
|
49
|
+
* The accumulator has a null prototype: assigning `__proto__` on a plain object
|
|
50
|
+
* literal sets that object's prototype instead of creating an own property, so
|
|
51
|
+
* an entity type under that name would serialize away and silently lose the
|
|
52
|
+
* restriction the adapter declared.
|
|
53
|
+
*/
|
|
54
|
+
export function resolveStartControlMap(adapter: DataSyncAdapter | null | undefined): StartControlMap {
|
|
55
|
+
if (!adapter || typeof adapter.supportsStartControl !== 'function') return {}
|
|
56
|
+
const map: StartControlMap = Object.create(null)
|
|
57
|
+
for (const entityType of adapter.supportedEntities ?? []) {
|
|
58
|
+
const applicability = allApplicable()
|
|
59
|
+
let restricted = false
|
|
60
|
+
for (const control of DATA_SYNC_START_CONTROLS) {
|
|
61
|
+
if (isApplicable(adapter, control, entityType)) continue
|
|
62
|
+
applicability[control] = false
|
|
63
|
+
restricted = true
|
|
64
|
+
}
|
|
65
|
+
if (restricted) map[entityType] = applicability
|
|
66
|
+
}
|
|
67
|
+
return map
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Reads the resolved map for the selected entity type, defaulting to "every
|
|
72
|
+
* control applies" for an entity type the map does not restrict.
|
|
73
|
+
*
|
|
74
|
+
* The lookup is own-property only: an entity type named after something on
|
|
75
|
+
* `Object.prototype` would otherwise read back an inherited value whose
|
|
76
|
+
* `fullSync` is `undefined`, hiding a control the adapter never restricted.
|
|
77
|
+
*/
|
|
78
|
+
export function applicableStartControls(
|
|
79
|
+
map: StartControlMap | null | undefined,
|
|
80
|
+
entityType: string,
|
|
81
|
+
): StartControlApplicability {
|
|
82
|
+
if (!map || !Object.prototype.hasOwnProperty.call(map, entityType)) return allApplicable()
|
|
83
|
+
const declared = map[entityType]
|
|
84
|
+
const applicability = allApplicable()
|
|
85
|
+
for (const control of DATA_SYNC_START_CONTROLS) {
|
|
86
|
+
if (declared?.[control] === false) applicability[control] = false
|
|
87
|
+
}
|
|
88
|
+
return applicability
|
|
89
|
+
}
|