@open-mercato/core 0.6.8-develop.6992.1.00c90fecff → 0.6.8-develop.6998.1.d2bc46c56c
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/generated/entities/sync_run/index.js +2 -0
- package/dist/generated/entities/sync_run/index.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +1 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/auth/api/sidebar/preferences/route.js +2 -2
- package/dist/modules/auth/api/sidebar/preferences/route.js.map +1 -1
- package/dist/modules/auth/lib/backendChrome.js +3 -3
- package/dist/modules/auth/lib/backendChrome.js.map +1 -1
- package/dist/modules/auth/services/sidebarPreferencesService.js +7 -2
- package/dist/modules/auth/services/sidebarPreferencesService.js.map +2 -2
- package/dist/modules/data_sync/api/options.js +1 -0
- package/dist/modules/data_sync/api/options.js.map +2 -2
- package/dist/modules/data_sync/api/run.js +15 -1
- package/dist/modules/data_sync/api/run.js.map +2 -2
- package/dist/modules/data_sync/api/runs/[id]/retry.js +23 -1
- package/dist/modules/data_sync/api/runs/[id]/retry.js.map +2 -2
- package/dist/modules/data_sync/api/runs/[id]/route.js +1 -0
- package/dist/modules/data_sync/api/runs/[id]/route.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/page.js +60 -17
- package/dist/modules/data_sync/backend/data-sync/page.js.map +2 -2
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +34 -2
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +2 -2
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js +21 -15
- package/dist/modules/data_sync/components/IntegrationScheduleTab.js.map +2 -2
- package/dist/modules/data_sync/components/RunParameterFields.js +135 -0
- package/dist/modules/data_sync/components/RunParameterFields.js.map +7 -0
- package/dist/modules/data_sync/data/entities.js +3 -0
- package/dist/modules/data_sync/data/entities.js.map +2 -2
- package/dist/modules/data_sync/data/validators.js +4 -1
- package/dist/modules/data_sync/data/validators.js.map +2 -2
- package/dist/modules/data_sync/lib/run-parameters.js +108 -0
- package/dist/modules/data_sync/lib/run-parameters.js.map +7 -0
- package/dist/modules/data_sync/lib/start-run.js +1 -0
- package/dist/modules/data_sync/lib/start-run.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-engine.js +4 -2
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-run-service.js +1 -0
- package/dist/modules/data_sync/lib/sync-run-service.js.map +2 -2
- package/dist/modules/data_sync/migrations/Migration20260810120000.js +13 -0
- package/dist/modules/data_sync/migrations/Migration20260810120000.js.map +7 -0
- package/dist/modules/data_sync/workers/sync-scheduled.js +23 -2
- package/dist/modules/data_sync/workers/sync-scheduled.js.map +2 -2
- package/dist/modules/query_index/di.js +125 -48
- package/dist/modules/query_index/di.js.map +2 -2
- package/dist/modules/sales/api/documents/factory.js +39 -1
- package/dist/modules/sales/api/documents/factory.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +26 -5
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/generated/entities/sync_run/index.ts +1 -0
- package/generated/entity-fields-registry.ts +1 -0
- package/package.json +7 -7
- package/src/modules/auth/api/sidebar/preferences/route.ts +2 -2
- package/src/modules/auth/lib/backendChrome.tsx +2 -2
- package/src/modules/auth/services/sidebarPreferencesService.ts +22 -3
- package/src/modules/data_sync/AGENTS.md +83 -8
- package/src/modules/data_sync/api/options.ts +1 -0
- package/src/modules/data_sync/api/run.ts +17 -0
- package/src/modules/data_sync/api/runs/[id]/retry.ts +32 -1
- package/src/modules/data_sync/api/runs/[id]/route.ts +1 -0
- package/src/modules/data_sync/backend/data-sync/page.tsx +73 -17
- package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +62 -2
- package/src/modules/data_sync/components/IntegrationScheduleTab.tsx +28 -15
- package/src/modules/data_sync/components/RunParameterFields.tsx +229 -0
- package/src/modules/data_sync/data/entities.ts +4 -1
- package/src/modules/data_sync/data/validators.ts +3 -0
- package/src/modules/data_sync/i18n/de.json +10 -0
- package/src/modules/data_sync/i18n/en.json +10 -0
- package/src/modules/data_sync/i18n/es.json +10 -0
- package/src/modules/data_sync/i18n/ko.json +10 -0
- package/src/modules/data_sync/i18n/pl.json +10 -0
- package/src/modules/data_sync/lib/adapter.ts +88 -0
- package/src/modules/data_sync/lib/run-parameters.ts +196 -0
- package/src/modules/data_sync/lib/start-run.ts +2 -0
- package/src/modules/data_sync/lib/sync-engine.ts +5 -1
- package/src/modules/data_sync/lib/sync-run-service.ts +2 -0
- package/src/modules/data_sync/migrations/.snapshot-open-mercato.json +17 -1
- package/src/modules/data_sync/migrations/Migration20260810120000.ts +13 -0
- package/src/modules/data_sync/workers/sync-scheduled.ts +32 -1
- package/src/modules/query_index/di.ts +153 -56
- package/src/modules/sales/api/documents/factory.ts +62 -1
- package/src/modules/sales/commands/documents.ts +40 -4
- package/src/modules/sales/i18n/de.json +1 -0
- package/src/modules/sales/i18n/en.json +1 -0
- package/src/modules/sales/i18n/es.json +1 -0
- package/src/modules/sales/i18n/ko.json +1 -0
- package/src/modules/sales/i18n/pl.json +1 -0
|
@@ -23,6 +23,11 @@ import { Switch } from "@open-mercato/ui/primitives/switch";
|
|
|
23
23
|
import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
24
24
|
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
25
25
|
import { getSyncSummaryVariant } from "../lib/syncRunStatus.js";
|
|
26
|
+
import { getApplicableRunParameters } from "../lib/run-parameters.js";
|
|
27
|
+
import {
|
|
28
|
+
buildDefaultRunParameterValues,
|
|
29
|
+
hasRequiredRunParameterWithoutDefault
|
|
30
|
+
} from "./RunParameterFields.js";
|
|
26
31
|
import {
|
|
27
32
|
CalendarClock,
|
|
28
33
|
Play,
|
|
@@ -147,29 +152,30 @@ function IntegrationScheduleTab(props) {
|
|
|
147
152
|
flash(t("data_sync.integrationTab.providerManaged", "Start this integration from its provider-specific setup flow."), "error");
|
|
148
153
|
return;
|
|
149
154
|
}
|
|
155
|
+
const runParameters = getApplicableRunParameters(option?.runParameters, direction, entityType);
|
|
156
|
+
if (hasRequiredRunParameterWithoutDefault(runParameters)) {
|
|
157
|
+
flash(t("data_sync.integrationTab.parametersRequired", "This run needs parameters. Start it from the Data Sync dashboard."), "error");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
150
160
|
setRunningKey(scheduleKey);
|
|
151
161
|
try {
|
|
152
162
|
const scheduleState = schedules[scheduleKey] ?? buildDefaultScheduleState(entityType);
|
|
163
|
+
const requestBody = {
|
|
164
|
+
integrationId: props.integrationId,
|
|
165
|
+
entityType,
|
|
166
|
+
direction,
|
|
167
|
+
fullSync: scheduleState.fullSync,
|
|
168
|
+
batchSize: 100
|
|
169
|
+
};
|
|
170
|
+
if (runParameters.length > 0) requestBody.parameters = buildDefaultRunParameterValues(runParameters);
|
|
153
171
|
const call = await runMutation({
|
|
154
172
|
// optimistic-lock-exempt: starts a new sync run (create), not a concurrent record edit
|
|
155
173
|
operation: () => apiCall("/api/data_sync/run", {
|
|
156
174
|
method: "POST",
|
|
157
175
|
headers: { "content-type": "application/json" },
|
|
158
|
-
body: JSON.stringify(
|
|
159
|
-
integrationId: props.integrationId,
|
|
160
|
-
entityType,
|
|
161
|
-
direction,
|
|
162
|
-
fullSync: scheduleState.fullSync,
|
|
163
|
-
batchSize: 100
|
|
164
|
-
})
|
|
176
|
+
body: JSON.stringify(requestBody)
|
|
165
177
|
}, { fallback: null }),
|
|
166
|
-
mutationPayload:
|
|
167
|
-
integrationId: props.integrationId,
|
|
168
|
-
entityType,
|
|
169
|
-
direction,
|
|
170
|
-
fullSync: scheduleState.fullSync,
|
|
171
|
-
batchSize: 100
|
|
172
|
-
},
|
|
178
|
+
mutationPayload: requestBody,
|
|
173
179
|
context: {
|
|
174
180
|
operation: "create",
|
|
175
181
|
actionId: "start-sync-run",
|
|
@@ -186,7 +192,7 @@ function IntegrationScheduleTab(props) {
|
|
|
186
192
|
} finally {
|
|
187
193
|
setRunningKey(null);
|
|
188
194
|
}
|
|
189
|
-
}, [option?.canStartRun, props.hasCredentials, props.integrationId, props.isEnabled, runMutation, schedules, t]);
|
|
195
|
+
}, [option?.canStartRun, option?.runParameters, props.hasCredentials, props.integrationId, props.isEnabled, runMutation, schedules, t]);
|
|
190
196
|
const handleSaveSchedule = React.useCallback(async (entityType, direction, scheduleKey) => {
|
|
191
197
|
const scheduleState = schedules[scheduleKey] ?? buildDefaultScheduleState(entityType);
|
|
192
198
|
setSavingKey(scheduleKey);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/data_sync/components/IntegrationScheduleTab.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\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 { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { getSyncSummaryVariant } from '../lib/syncRunStatus'\nimport {\n CalendarClock,\n Play,\n RefreshCw,\n Save,\n ShieldAlert,\n ShieldCheck,\n Trash2,\n} from 'lucide-react'\n\ntype SyncOption = {\n integrationId: string\n title: string\n direction: 'import' | 'export' | 'bidirectional'\n runMode?: 'generic' | 'provider'\n canStartRun?: boolean\n supportedEntities: string[]\n hasCredentials: boolean\n isEnabled: boolean\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\ntype IntegrationScheduleTabProps = {\n integrationId: string\n hasCredentials: boolean\n isEnabled: boolean\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\nfunction getSupportedDirections(direction: SyncOption['direction'] | null | undefined): Array<'import' | 'export'> {\n if (direction === 'export') return ['export']\n if (direction === 'bidirectional') return ['import', 'export']\n return ['import']\n}\n\nfunction buildScheduleKey(entityType: string, direction: 'import' | 'export'): string {\n return `${entityType}:${direction}`\n}\n\nfunction buildScheduleEditors(\n entityTypes: string[],\n directions: Array<'import' | 'export'>,\n records: SyncScheduleRecord[],\n): Record<string, SyncScheduleEditorState> {\n const nextEntries: Array<[string, SyncScheduleEditorState]> = []\n for (const entityType of entityTypes) {\n for (const direction of directions) {\n const record = records.find((item) => item.entityType === entityType && item.direction === direction)\n nextEntries.push([\n buildScheduleKey(entityType, direction),\n record\n ? {\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 : buildDefaultScheduleState(entityType),\n ])\n }\n }\n return Object.fromEntries(nextEntries)\n}\n\nexport function IntegrationScheduleTab(props: IntegrationScheduleTabProps) {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const { runMutation } = useGuardedMutation<Record<string, unknown>>({\n contextId: 'data_sync.integrationTab',\n })\n const [option, setOption] = React.useState<SyncOption | null>(null)\n const [schedules, setSchedules] = React.useState<Record<string, SyncScheduleEditorState>>({})\n const [isLoading, setIsLoading] = React.useState(true)\n const [runningKey, setRunningKey] = React.useState<string | null>(null)\n const [savingKey, setSavingKey] = React.useState<string | null>(null)\n const [deletingKey, setDeletingKey] = React.useState<string | null>(null)\n\n const load = React.useCallback(async () => {\n setIsLoading(true)\n try {\n const [optionsCall, schedulesCall] = await Promise.all([\n apiCall<SyncOptionsResponse>('/api/data_sync/options', undefined, { fallback: { items: [] } }),\n apiCall<SyncSchedulesResponse>(`/api/data_sync/schedules?integrationId=${encodeURIComponent(props.integrationId)}&page=1&pageSize=100`, undefined, { fallback: { items: [] } }),\n ])\n\n const resolvedOption = (optionsCall.result?.items ?? []).find((item) => item.integrationId === props.integrationId) ?? null\n setOption(resolvedOption)\n\n const supportedEntities = resolvedOption?.supportedEntities ?? []\n const supportedDirections = getSupportedDirections(resolvedOption?.direction)\n setSchedules(buildScheduleEditors(supportedEntities, supportedDirections, schedulesCall.result?.items ?? []))\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.integrationTab.loadError', 'Failed to load sync schedules.')\n flash(message, 'error')\n } finally {\n setIsLoading(false)\n }\n }, [props.integrationId, t])\n\n React.useEffect(() => {\n void load()\n }, [load, scopeVersion])\n\n const supportedDirections = React.useMemo(\n () => getSupportedDirections(option?.direction),\n [option?.direction],\n )\n\n const rows = React.useMemo(\n () => (option?.supportedEntities ?? []).flatMap((entityType) => (\n supportedDirections.map((direction) => ({\n entityType,\n direction,\n key: buildScheduleKey(entityType, direction),\n }))\n )),\n [option?.supportedEntities, supportedDirections],\n )\n\n const updateScheduleEditor = React.useCallback((key: string, patch: Partial<SyncScheduleEditorState>, entityType: string) => {\n setSchedules((current) => ({\n ...current,\n [key]: {\n ...(current[key] ?? buildDefaultScheduleState(entityType)),\n ...patch,\n },\n }))\n }, [])\n\n const handleStartSync = React.useCallback(async (entityType: string, direction: 'import' | 'export', scheduleKey: string) => {\n if (!props.isEnabled) {\n flash(t('data_sync.integrationTab.integrationDisabled', 'Enable the integration before starting a sync.'), 'error')\n return\n }\n if (!props.hasCredentials) {\n flash(t('data_sync.integrationTab.credentialsMissing', 'Configure credentials before starting a sync.'), 'error')\n return\n }\n if (option?.canStartRun === false) {\n flash(t('data_sync.integrationTab.providerManaged', 'Start this integration from its provider-specific setup flow.'), 'error')\n return\n }\n\n setRunningKey(scheduleKey)\n try {\n const scheduleState = schedules[scheduleKey] ?? buildDefaultScheduleState(entityType)\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({\n integrationId: props.integrationId,\n entityType,\n direction,\n fullSync: scheduleState.fullSync,\n batchSize: 100,\n }),\n }, { fallback: null }),\n mutationPayload: {\n integrationId: props.integrationId,\n entityType,\n direction,\n fullSync: scheduleState.fullSync,\n batchSize: 100,\n },\n context: {\n operation: 'create',\n actionId: 'start-sync-run',\n integrationId: props.integrationId,\n },\n })\n\n if (!call.ok) {\n throw new Error((call.result as { error?: string } | null)?.error ?? 'Failed to start sync')\n }\n\n flash(t('data_sync.integrationTab.runStarted', 'Sync run started.'), 'success')\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.integrationTab.runError', 'Failed to start sync.')\n flash(message, 'error')\n } finally {\n setRunningKey(null)\n }\n }, [option?.canStartRun, props.hasCredentials, props.integrationId, props.isEnabled, runMutation, schedules, t])\n\n const handleSaveSchedule = React.useCallback(async (entityType: string, direction: 'import' | 'export', scheduleKey: string) => {\n const scheduleState = schedules[scheduleKey] ?? buildDefaultScheduleState(entityType)\n setSavingKey(scheduleKey)\n try {\n // Keyed upsert (POST). When the server resolves an existing row the save\n // version-checks against this schedule's loaded `updatedAt`; for a brand\n // new row the header is empty so the create path is unaffected.\n const call = await runMutation({\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleState.updatedAt),\n () => apiCall<SyncScheduleRecord>('/api/data_sync/schedules', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n integrationId: props.integrationId,\n entityType,\n direction,\n scheduleType: scheduleState.scheduleType,\n scheduleValue: scheduleState.scheduleValue,\n timezone: scheduleState.timezone,\n fullSync: scheduleState.fullSync,\n isEnabled: scheduleState.isEnabled,\n }),\n }, { fallback: null }),\n ),\n mutationPayload: {\n integrationId: props.integrationId,\n entityType,\n direction,\n scheduleType: scheduleState.scheduleType,\n scheduleValue: scheduleState.scheduleValue,\n timezone: scheduleState.timezone,\n fullSync: scheduleState.fullSync,\n isEnabled: scheduleState.isEnabled,\n },\n context: {\n operation: 'update',\n actionId: 'save-sync-schedule',\n integrationId: props.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 ?? 'Failed to save 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 throw conflictError\n }\n\n updateScheduleEditor(scheduleKey, {\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 }, entityType)\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 setSavingKey(null)\n }\n }, [props.integrationId, runMutation, schedules, t, updateScheduleEditor])\n\n const handleDeleteSchedule = React.useCallback(async (entityType: string, scheduleKey: string) => {\n const scheduleState = schedules[scheduleKey]\n if (!scheduleState?.id) {\n updateScheduleEditor(scheduleKey, buildDefaultScheduleState(entityType), entityType)\n return\n }\n\n setDeletingKey(scheduleKey)\n try {\n const call = await runMutation({\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleState.updatedAt),\n () => apiCall(`/api/data_sync/schedules/${encodeURIComponent(scheduleState.id as string)}`, {\n method: 'DELETE',\n }, { fallback: null }),\n ),\n mutationPayload: {\n scheduleId: scheduleState.id,\n },\n context: {\n operation: 'delete',\n actionId: 'delete-sync-schedule',\n },\n })\n\n if (!call.ok) {\n throw new Error((call.result as { error?: string } | null)?.error ?? 'Failed to delete schedule')\n }\n\n setSchedules((current) => ({\n ...current,\n [scheduleKey]: buildDefaultScheduleState(entityType),\n }))\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 setDeletingKey(null)\n }\n }, [runMutation, schedules, t, updateScheduleEditor])\n\n if (isLoading) {\n return (\n <div className=\"flex min-h-40 items-center justify-center rounded-lg border bg-card\">\n <Spinner />\n </div>\n )\n }\n\n if (!option) {\n return (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('data_sync.integrationTab.notAvailable', 'This integration is not registered as a data sync provider.')}\n </AlertDescription>\n </Alert>\n )\n }\n\n return (\n <section className=\"space-y-4 rounded-lg border bg-card p-6\">\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <Badge variant={getSyncSummaryVariant(props.isEnabled ? 'enabled' : 'disabled')}>\n {props.isEnabled ? <ShieldCheck className=\"mr-2 h-3.5 w-3.5\" /> : <ShieldAlert className=\"mr-2 h-3.5 w-3.5\" />}\n {props.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={getSyncSummaryVariant(props.hasCredentials ? 'ready' : 'missing')}>\n <CalendarClock className=\"mr-2 h-3.5 w-3.5\" />\n {props.hasCredentials\n ? t('data_sync.dashboard.start.status.credentialsReady', 'Credentials ready')\n : t('data_sync.dashboard.start.status.credentialsMissing', 'Credentials missing')}\n </Badge>\n </div>\n <div>\n <h3 className=\"text-base font-semibold\">{t('data_sync.integrationTab.title', 'Sync schedules')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('data_sync.integrationTab.description', 'Run one-off syncs or save recurring schedules for every supported entity directly from the integration detail page.')}\n </p>\n </div>\n </div>\n <Button type=\"button\" variant=\"outline\" onClick={() => void load()} disabled={isLoading}>\n <RefreshCw className=\"mr-2 h-4 w-4\" />\n {t('data_sync.integrationTab.refresh', 'Refresh')}\n </Button>\n </div>\n\n {!props.isEnabled ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('data_sync.integrationTab.integrationDisabledNotice', 'The integration is disabled. You can save schedules now, but runs will stay blocked until the integration is enabled.')}\n </AlertDescription>\n </Alert>\n ) : null}\n\n {!props.hasCredentials ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('data_sync.integrationTab.credentialsMissingNotice', 'Credentials are still missing. Save schedules first if you want, but manual and scheduled runs will fail until credentials are configured.')}\n </AlertDescription>\n </Alert>\n ) : null}\n\n {option.canStartRun === false ? (\n <Alert status=\"information\">\n <AlertDescription>\n {t('data_sync.integrationTab.providerManagedNotice', 'This provider needs its own setup flow before a run can start. Use the provider tab on this page instead of generic schedules.')}\n </AlertDescription>\n </Alert>\n ) : null}\n\n {rows.length === 0 ? (\n <Alert status=\"information\">\n <AlertDescription>\n {t('data_sync.integrationTab.empty', 'This provider does not expose any schedulable sync entities yet.')}\n </AlertDescription>\n </Alert>\n ) : (\n <div className=\"overflow-x-auto rounded-lg border\">\n <table className=\"w-full min-w-[1080px] text-sm\">\n <thead className=\"bg-muted/50 text-left\">\n <tr>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.columns.entityType', 'Entity Type')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.columns.direction', 'Direction')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.schedule.type', 'Schedule type')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.integrationTab.columns.value', 'Value')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.schedule.timezone', 'Timezone')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.start.fullSync', 'Run as full sync')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.schedule.enabled', 'Schedule enabled')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.integrationTab.columns.lastRun', 'Last run')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.integrationTab.columns.actions', 'Actions')}</th>\n </tr>\n </thead>\n <tbody>\n {rows.map((row) => {\n const scheduleState = schedules[row.key] ?? buildDefaultScheduleState(row.entityType)\n const isRunning = runningKey === row.key\n const isSaving = savingKey === row.key\n const isDeleting = deletingKey === row.key\n const controlsDisabled = isRunning || isSaving || isDeleting\n return (\n <tr key={row.key} className=\"border-t align-top\">\n <td className=\"px-3 py-3 font-medium\">{formatEntityTypeLabel(row.entityType)}</td>\n <td className=\"px-3 py-3\">{t(`data_sync.dashboard.direction.${row.direction}`, row.direction === 'import' ? 'Import' : 'Export')}</td>\n <td className=\"px-3 py-3\">\n <Select\n value={scheduleState.scheduleType}\n onValueChange={(value) => updateScheduleEditor(row.key, {\n scheduleType: value === 'cron' ? 'cron' : 'interval',\n }, row.entityType)}\n disabled={controlsDisabled}\n >\n <SelectTrigger size=\"lg\" className=\"min-w-32\">\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 </td>\n <td className=\"px-3 py-3\">\n <Input\n value={scheduleState.scheduleValue}\n onChange={(event) => updateScheduleEditor(row.key, { scheduleValue: event.target.value }, row.entityType)}\n disabled={controlsDisabled}\n placeholder={scheduleState.scheduleType === 'cron' ? '0 * * * *' : '1h'}\n />\n </td>\n <td className=\"px-3 py-3\">\n <Input\n value={scheduleState.timezone}\n onChange={(event) => updateScheduleEditor(row.key, { timezone: event.target.value }, row.entityType)}\n disabled={controlsDisabled}\n />\n </td>\n <td className=\"px-3 py-3\">\n <label className=\"flex min-h-10 items-center gap-2 text-sm\">\n <Switch\n checked={scheduleState.fullSync}\n onCheckedChange={(checked) => updateScheduleEditor(row.key, { fullSync: checked }, row.entityType)}\n disabled={controlsDisabled}\n aria-label={t('data_sync.dashboard.start.fullSync', 'Run as full sync')}\n />\n <span>{t('data_sync.integrationTab.fullSyncShort', 'Full')}</span>\n </label>\n </td>\n <td className=\"px-3 py-3\">\n <label className=\"flex min-h-10 items-center gap-2 text-sm\">\n <Switch\n checked={scheduleState.isEnabled}\n onCheckedChange={(checked) => updateScheduleEditor(row.key, { isEnabled: checked }, row.entityType)}\n disabled={controlsDisabled}\n aria-label={t('data_sync.dashboard.schedule.enabled', 'Schedule enabled')}\n />\n <span>{scheduleState.isEnabled ? t('data_sync.dashboard.schedule.status.shortEnabled', 'Scheduled') : t('data_sync.dashboard.schedule.status.shortDisabled', 'Paused')}</span>\n </label>\n </td>\n <td className=\"px-3 py-3 text-muted-foreground\">\n {scheduleState.lastRunAt\n ? new Date(scheduleState.lastRunAt).toLocaleString()\n : scheduleState.id\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 </td>\n <td className=\"px-3 py-3\">\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => void handleStartSync(row.entityType, row.direction, row.key)}\n disabled={controlsDisabled || !props.isEnabled || !props.hasCredentials || option.canStartRun === false}\n >\n {isRunning ? <Spinner className=\"mr-2 h-4 w-4\" /> : <Play className=\"mr-2 h-4 w-4\" />}\n {isRunning\n ? t('data_sync.integrationTab.starting', 'Starting...')\n : t('data_sync.integrationTab.start', 'Run now')}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => void handleSaveSchedule(row.entityType, row.direction, row.key)}\n disabled={controlsDisabled || option.canStartRun === false}\n >\n {isSaving ? <Spinner className=\"mr-2 h-4 w-4\" /> : <Save className=\"mr-2 h-4 w-4\" />}\n {isSaving\n ? t('data_sync.dashboard.schedule.saving', 'Saving...')\n : t('data_sync.dashboard.schedule.save', 'Save recurring schedule')}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => void handleDeleteSchedule(row.entityType, row.key)}\n disabled={controlsDisabled || !scheduleState.id}\n >\n {isDeleting ? <Spinner className=\"mr-2 h-4 w-4\" /> : <Trash2 className=\"mr-2 h-4 w-4\" />}\n {isDeleting\n ? t('data_sync.dashboard.schedule.deleting', 'Removing...')\n : t('data_sync.dashboard.schedule.delete', 'Remove schedule')}\n </Button>\n </div>\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </div>\n )}\n\n <div className=\"grid gap-3 rounded-lg border border-dashed p-4 text-sm text-muted-foreground md:grid-cols-3\">\n <div className=\"space-y-1\">\n <Label>{t('data_sync.dashboard.schedule.interval', 'Interval')}</Label>\n <p>{t('data_sync.dashboard.schedule.intervalHelp', 'Example: `1h`, `6h`, or `24h` for repeating intervals.')}</p>\n </div>\n <div className=\"space-y-1\">\n <Label>{t('data_sync.dashboard.schedule.cron', 'Cron')}</Label>\n <p>{t('data_sync.dashboard.schedule.cronHelp', 'Example: `0 * * * *` runs at the start of every hour.')}</p>\n </div>\n <div className=\"space-y-1\">\n <Label>{t('data_sync.integrationTab.runNowTitle', 'Manual runs')}</Label>\n <p>{t('data_sync.integrationTab.runNowHelp', 'Run now uses the full-sync checkbox from the same row and starts progress tracking immediately in Data Sync.')}</p>\n </div>\n </div>\n </section>\n )\n}\n\nexport default IntegrationScheduleTab\n"],
|
|
5
|
-
"mappings": ";AAoYQ,cAoBI,YApBJ;AAlYR,YAAY,WAAW;AACvB,SAAS,SAAS,mCAAmC;AACrD,SAAS,iCAAiC;AAC1C,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,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,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AE;AAAA,SAC/G;AAAA,MACA,qBAAC,SAAI,WAAU,aACb;AAAA,4BAAC,SAAO,YAAE,qCAAqC,MAAM,GAAE;AAAA,QACvD,oBAAC,OAAG,YAAE,yCAAyC,uDAAuD,GAAE;AAAA,SAC1G;AAAA,MACA,qBAAC,SAAI,WAAU,aACb;AAAA,4BAAC,SAAO,YAAE,wCAAwC,aAAa,GAAE;AAAA,QACjE,oBAAC,OAAG,YAAE,uCAAuC,8GAA8G,GAAE;AAAA,SAC/J;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,iCAAQ;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { apiCall, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\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 { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { getSyncSummaryVariant } from '../lib/syncRunStatus'\nimport type { RunParameter } from '../lib/adapter'\nimport { getApplicableRunParameters } from '../lib/run-parameters'\nimport {\n buildDefaultRunParameterValues,\n hasRequiredRunParameterWithoutDefault,\n} from './RunParameterFields'\nimport {\n CalendarClock,\n Play,\n RefreshCw,\n Save,\n ShieldAlert,\n ShieldCheck,\n Trash2,\n} from 'lucide-react'\n\ntype SyncOption = {\n integrationId: string\n title: string\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}\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\ntype IntegrationScheduleTabProps = {\n integrationId: string\n hasCredentials: boolean\n isEnabled: boolean\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\nfunction getSupportedDirections(direction: SyncOption['direction'] | null | undefined): Array<'import' | 'export'> {\n if (direction === 'export') return ['export']\n if (direction === 'bidirectional') return ['import', 'export']\n return ['import']\n}\n\nfunction buildScheduleKey(entityType: string, direction: 'import' | 'export'): string {\n return `${entityType}:${direction}`\n}\n\nfunction buildScheduleEditors(\n entityTypes: string[],\n directions: Array<'import' | 'export'>,\n records: SyncScheduleRecord[],\n): Record<string, SyncScheduleEditorState> {\n const nextEntries: Array<[string, SyncScheduleEditorState]> = []\n for (const entityType of entityTypes) {\n for (const direction of directions) {\n const record = records.find((item) => item.entityType === entityType && item.direction === direction)\n nextEntries.push([\n buildScheduleKey(entityType, direction),\n record\n ? {\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 : buildDefaultScheduleState(entityType),\n ])\n }\n }\n return Object.fromEntries(nextEntries)\n}\n\nexport function IntegrationScheduleTab(props: IntegrationScheduleTabProps) {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const { runMutation } = useGuardedMutation<Record<string, unknown>>({\n contextId: 'data_sync.integrationTab',\n })\n const [option, setOption] = React.useState<SyncOption | null>(null)\n const [schedules, setSchedules] = React.useState<Record<string, SyncScheduleEditorState>>({})\n const [isLoading, setIsLoading] = React.useState(true)\n const [runningKey, setRunningKey] = React.useState<string | null>(null)\n const [savingKey, setSavingKey] = React.useState<string | null>(null)\n const [deletingKey, setDeletingKey] = React.useState<string | null>(null)\n\n const load = React.useCallback(async () => {\n setIsLoading(true)\n try {\n const [optionsCall, schedulesCall] = await Promise.all([\n apiCall<SyncOptionsResponse>('/api/data_sync/options', undefined, { fallback: { items: [] } }),\n apiCall<SyncSchedulesResponse>(`/api/data_sync/schedules?integrationId=${encodeURIComponent(props.integrationId)}&page=1&pageSize=100`, undefined, { fallback: { items: [] } }),\n ])\n\n const resolvedOption = (optionsCall.result?.items ?? []).find((item) => item.integrationId === props.integrationId) ?? null\n setOption(resolvedOption)\n\n const supportedEntities = resolvedOption?.supportedEntities ?? []\n const supportedDirections = getSupportedDirections(resolvedOption?.direction)\n setSchedules(buildScheduleEditors(supportedEntities, supportedDirections, schedulesCall.result?.items ?? []))\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.integrationTab.loadError', 'Failed to load sync schedules.')\n flash(message, 'error')\n } finally {\n setIsLoading(false)\n }\n }, [props.integrationId, t])\n\n React.useEffect(() => {\n void load()\n }, [load, scopeVersion])\n\n const supportedDirections = React.useMemo(\n () => getSupportedDirections(option?.direction),\n [option?.direction],\n )\n\n const rows = React.useMemo(\n () => (option?.supportedEntities ?? []).flatMap((entityType) => (\n supportedDirections.map((direction) => ({\n entityType,\n direction,\n key: buildScheduleKey(entityType, direction),\n }))\n )),\n [option?.supportedEntities, supportedDirections],\n )\n\n const updateScheduleEditor = React.useCallback((key: string, patch: Partial<SyncScheduleEditorState>, entityType: string) => {\n setSchedules((current) => ({\n ...current,\n [key]: {\n ...(current[key] ?? buildDefaultScheduleState(entityType)),\n ...patch,\n },\n }))\n }, [])\n\n const handleStartSync = React.useCallback(async (entityType: string, direction: 'import' | 'export', scheduleKey: string) => {\n if (!props.isEnabled) {\n flash(t('data_sync.integrationTab.integrationDisabled', 'Enable the integration before starting a sync.'), 'error')\n return\n }\n if (!props.hasCredentials) {\n flash(t('data_sync.integrationTab.credentialsMissing', 'Configure credentials before starting a sync.'), 'error')\n return\n }\n if (option?.canStartRun === false) {\n flash(t('data_sync.integrationTab.providerManaged', 'Start this integration from its provider-specific setup flow.'), 'error')\n return\n }\n\n // This table has no room for a parameter form, so a row run submits the\n // adapter's declared defaults. A parameter the operator must fill in has no\n // default to send, so route them to the Data Sync dashboard instead of\n // letting the run API reject the request.\n const runParameters = getApplicableRunParameters(option?.runParameters, direction, entityType)\n if (hasRequiredRunParameterWithoutDefault(runParameters)) {\n flash(t('data_sync.integrationTab.parametersRequired', 'This run needs parameters. Start it from the Data Sync dashboard.'), 'error')\n return\n }\n\n setRunningKey(scheduleKey)\n try {\n const scheduleState = schedules[scheduleKey] ?? buildDefaultScheduleState(entityType)\n const requestBody: Record<string, unknown> = {\n integrationId: props.integrationId,\n entityType,\n direction,\n fullSync: scheduleState.fullSync,\n batchSize: 100,\n }\n if (runParameters.length > 0) requestBody.parameters = buildDefaultRunParameterValues(runParameters)\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: props.integrationId,\n },\n })\n\n if (!call.ok) {\n throw new Error((call.result as { error?: string } | null)?.error ?? 'Failed to start sync')\n }\n\n flash(t('data_sync.integrationTab.runStarted', 'Sync run started.'), 'success')\n } catch (error) {\n const message = error instanceof Error ? error.message : t('data_sync.integrationTab.runError', 'Failed to start sync.')\n flash(message, 'error')\n } finally {\n setRunningKey(null)\n }\n }, [option?.canStartRun, option?.runParameters, props.hasCredentials, props.integrationId, props.isEnabled, runMutation, schedules, t])\n\n const handleSaveSchedule = React.useCallback(async (entityType: string, direction: 'import' | 'export', scheduleKey: string) => {\n const scheduleState = schedules[scheduleKey] ?? buildDefaultScheduleState(entityType)\n setSavingKey(scheduleKey)\n try {\n // Keyed upsert (POST). When the server resolves an existing row the save\n // version-checks against this schedule's loaded `updatedAt`; for a brand\n // new row the header is empty so the create path is unaffected.\n const call = await runMutation({\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleState.updatedAt),\n () => apiCall<SyncScheduleRecord>('/api/data_sync/schedules', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n integrationId: props.integrationId,\n entityType,\n direction,\n scheduleType: scheduleState.scheduleType,\n scheduleValue: scheduleState.scheduleValue,\n timezone: scheduleState.timezone,\n fullSync: scheduleState.fullSync,\n isEnabled: scheduleState.isEnabled,\n }),\n }, { fallback: null }),\n ),\n mutationPayload: {\n integrationId: props.integrationId,\n entityType,\n direction,\n scheduleType: scheduleState.scheduleType,\n scheduleValue: scheduleState.scheduleValue,\n timezone: scheduleState.timezone,\n fullSync: scheduleState.fullSync,\n isEnabled: scheduleState.isEnabled,\n },\n context: {\n operation: 'update',\n actionId: 'save-sync-schedule',\n integrationId: props.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 ?? 'Failed to save 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 throw conflictError\n }\n\n updateScheduleEditor(scheduleKey, {\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 }, entityType)\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 setSavingKey(null)\n }\n }, [props.integrationId, runMutation, schedules, t, updateScheduleEditor])\n\n const handleDeleteSchedule = React.useCallback(async (entityType: string, scheduleKey: string) => {\n const scheduleState = schedules[scheduleKey]\n if (!scheduleState?.id) {\n updateScheduleEditor(scheduleKey, buildDefaultScheduleState(entityType), entityType)\n return\n }\n\n setDeletingKey(scheduleKey)\n try {\n const call = await runMutation({\n operation: () => withScopedApiRequestHeaders(\n buildOptimisticLockHeader(scheduleState.updatedAt),\n () => apiCall(`/api/data_sync/schedules/${encodeURIComponent(scheduleState.id as string)}`, {\n method: 'DELETE',\n }, { fallback: null }),\n ),\n mutationPayload: {\n scheduleId: scheduleState.id,\n },\n context: {\n operation: 'delete',\n actionId: 'delete-sync-schedule',\n },\n })\n\n if (!call.ok) {\n throw new Error((call.result as { error?: string } | null)?.error ?? 'Failed to delete schedule')\n }\n\n setSchedules((current) => ({\n ...current,\n [scheduleKey]: buildDefaultScheduleState(entityType),\n }))\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 setDeletingKey(null)\n }\n }, [runMutation, schedules, t, updateScheduleEditor])\n\n if (isLoading) {\n return (\n <div className=\"flex min-h-40 items-center justify-center rounded-lg border bg-card\">\n <Spinner />\n </div>\n )\n }\n\n if (!option) {\n return (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('data_sync.integrationTab.notAvailable', 'This integration is not registered as a data sync provider.')}\n </AlertDescription>\n </Alert>\n )\n }\n\n return (\n <section className=\"space-y-4 rounded-lg border bg-card p-6\">\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <Badge variant={getSyncSummaryVariant(props.isEnabled ? 'enabled' : 'disabled')}>\n {props.isEnabled ? <ShieldCheck className=\"mr-2 h-3.5 w-3.5\" /> : <ShieldAlert className=\"mr-2 h-3.5 w-3.5\" />}\n {props.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={getSyncSummaryVariant(props.hasCredentials ? 'ready' : 'missing')}>\n <CalendarClock className=\"mr-2 h-3.5 w-3.5\" />\n {props.hasCredentials\n ? t('data_sync.dashboard.start.status.credentialsReady', 'Credentials ready')\n : t('data_sync.dashboard.start.status.credentialsMissing', 'Credentials missing')}\n </Badge>\n </div>\n <div>\n <h3 className=\"text-base font-semibold\">{t('data_sync.integrationTab.title', 'Sync schedules')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('data_sync.integrationTab.description', 'Run one-off syncs or save recurring schedules for every supported entity directly from the integration detail page.')}\n </p>\n </div>\n </div>\n <Button type=\"button\" variant=\"outline\" onClick={() => void load()} disabled={isLoading}>\n <RefreshCw className=\"mr-2 h-4 w-4\" />\n {t('data_sync.integrationTab.refresh', 'Refresh')}\n </Button>\n </div>\n\n {!props.isEnabled ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('data_sync.integrationTab.integrationDisabledNotice', 'The integration is disabled. You can save schedules now, but runs will stay blocked until the integration is enabled.')}\n </AlertDescription>\n </Alert>\n ) : null}\n\n {!props.hasCredentials ? (\n <Alert status=\"warning\">\n <AlertDescription>\n {t('data_sync.integrationTab.credentialsMissingNotice', 'Credentials are still missing. Save schedules first if you want, but manual and scheduled runs will fail until credentials are configured.')}\n </AlertDescription>\n </Alert>\n ) : null}\n\n {option.canStartRun === false ? (\n <Alert status=\"information\">\n <AlertDescription>\n {t('data_sync.integrationTab.providerManagedNotice', 'This provider needs its own setup flow before a run can start. Use the provider tab on this page instead of generic schedules.')}\n </AlertDescription>\n </Alert>\n ) : null}\n\n {rows.length === 0 ? (\n <Alert status=\"information\">\n <AlertDescription>\n {t('data_sync.integrationTab.empty', 'This provider does not expose any schedulable sync entities yet.')}\n </AlertDescription>\n </Alert>\n ) : (\n <div className=\"overflow-x-auto rounded-lg border\">\n <table className=\"w-full min-w-[1080px] text-sm\">\n <thead className=\"bg-muted/50 text-left\">\n <tr>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.columns.entityType', 'Entity Type')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.columns.direction', 'Direction')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.schedule.type', 'Schedule type')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.integrationTab.columns.value', 'Value')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.schedule.timezone', 'Timezone')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.start.fullSync', 'Run as full sync')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.dashboard.schedule.enabled', 'Schedule enabled')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.integrationTab.columns.lastRun', 'Last run')}</th>\n <th className=\"px-3 py-2 font-medium\">{t('data_sync.integrationTab.columns.actions', 'Actions')}</th>\n </tr>\n </thead>\n <tbody>\n {rows.map((row) => {\n const scheduleState = schedules[row.key] ?? buildDefaultScheduleState(row.entityType)\n const isRunning = runningKey === row.key\n const isSaving = savingKey === row.key\n const isDeleting = deletingKey === row.key\n const controlsDisabled = isRunning || isSaving || isDeleting\n return (\n <tr key={row.key} className=\"border-t align-top\">\n <td className=\"px-3 py-3 font-medium\">{formatEntityTypeLabel(row.entityType)}</td>\n <td className=\"px-3 py-3\">{t(`data_sync.dashboard.direction.${row.direction}`, row.direction === 'import' ? 'Import' : 'Export')}</td>\n <td className=\"px-3 py-3\">\n <Select\n value={scheduleState.scheduleType}\n onValueChange={(value) => updateScheduleEditor(row.key, {\n scheduleType: value === 'cron' ? 'cron' : 'interval',\n }, row.entityType)}\n disabled={controlsDisabled}\n >\n <SelectTrigger size=\"lg\" className=\"min-w-32\">\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 </td>\n <td className=\"px-3 py-3\">\n <Input\n value={scheduleState.scheduleValue}\n onChange={(event) => updateScheduleEditor(row.key, { scheduleValue: event.target.value }, row.entityType)}\n disabled={controlsDisabled}\n placeholder={scheduleState.scheduleType === 'cron' ? '0 * * * *' : '1h'}\n />\n </td>\n <td className=\"px-3 py-3\">\n <Input\n value={scheduleState.timezone}\n onChange={(event) => updateScheduleEditor(row.key, { timezone: event.target.value }, row.entityType)}\n disabled={controlsDisabled}\n />\n </td>\n <td className=\"px-3 py-3\">\n <label className=\"flex min-h-10 items-center gap-2 text-sm\">\n <Switch\n checked={scheduleState.fullSync}\n onCheckedChange={(checked) => updateScheduleEditor(row.key, { fullSync: checked }, row.entityType)}\n disabled={controlsDisabled}\n aria-label={t('data_sync.dashboard.start.fullSync', 'Run as full sync')}\n />\n <span>{t('data_sync.integrationTab.fullSyncShort', 'Full')}</span>\n </label>\n </td>\n <td className=\"px-3 py-3\">\n <label className=\"flex min-h-10 items-center gap-2 text-sm\">\n <Switch\n checked={scheduleState.isEnabled}\n onCheckedChange={(checked) => updateScheduleEditor(row.key, { isEnabled: checked }, row.entityType)}\n disabled={controlsDisabled}\n aria-label={t('data_sync.dashboard.schedule.enabled', 'Schedule enabled')}\n />\n <span>{scheduleState.isEnabled ? t('data_sync.dashboard.schedule.status.shortEnabled', 'Scheduled') : t('data_sync.dashboard.schedule.status.shortDisabled', 'Paused')}</span>\n </label>\n </td>\n <td className=\"px-3 py-3 text-muted-foreground\">\n {scheduleState.lastRunAt\n ? new Date(scheduleState.lastRunAt).toLocaleString()\n : scheduleState.id\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 </td>\n <td className=\"px-3 py-3\">\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={() => void handleStartSync(row.entityType, row.direction, row.key)}\n disabled={controlsDisabled || !props.isEnabled || !props.hasCredentials || option.canStartRun === false}\n >\n {isRunning ? <Spinner className=\"mr-2 h-4 w-4\" /> : <Play className=\"mr-2 h-4 w-4\" />}\n {isRunning\n ? t('data_sync.integrationTab.starting', 'Starting...')\n : t('data_sync.integrationTab.start', 'Run now')}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => void handleSaveSchedule(row.entityType, row.direction, row.key)}\n disabled={controlsDisabled || option.canStartRun === false}\n >\n {isSaving ? <Spinner className=\"mr-2 h-4 w-4\" /> : <Save className=\"mr-2 h-4 w-4\" />}\n {isSaving\n ? t('data_sync.dashboard.schedule.saving', 'Saving...')\n : t('data_sync.dashboard.schedule.save', 'Save recurring schedule')}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => void handleDeleteSchedule(row.entityType, row.key)}\n disabled={controlsDisabled || !scheduleState.id}\n >\n {isDeleting ? <Spinner className=\"mr-2 h-4 w-4\" /> : <Trash2 className=\"mr-2 h-4 w-4\" />}\n {isDeleting\n ? t('data_sync.dashboard.schedule.deleting', 'Removing...')\n : t('data_sync.dashboard.schedule.delete', 'Remove schedule')}\n </Button>\n </div>\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </div>\n )}\n\n <div className=\"grid gap-3 rounded-lg border border-dashed p-4 text-sm text-muted-foreground md:grid-cols-3\">\n <div className=\"space-y-1\">\n <Label>{t('data_sync.dashboard.schedule.interval', 'Interval')}</Label>\n <p>{t('data_sync.dashboard.schedule.intervalHelp', 'Example: `1h`, `6h`, or `24h` for repeating intervals.')}</p>\n </div>\n <div className=\"space-y-1\">\n <Label>{t('data_sync.dashboard.schedule.cron', 'Cron')}</Label>\n <p>{t('data_sync.dashboard.schedule.cronHelp', 'Example: `0 * * * *` runs at the start of every hour.')}</p>\n </div>\n <div className=\"space-y-1\">\n <Label>{t('data_sync.integrationTab.runNowTitle', 'Manual runs')}</Label>\n <p>{t('data_sync.integrationTab.runNowHelp', 'Run now uses the full-sync checkbox from the same row and starts progress tracking immediately in Data Sync.')}</p>\n </div>\n </div>\n </section>\n )\n}\n\nexport default IntegrationScheduleTab\n"],
|
|
5
|
+
"mappings": ";AAiZQ,cAoBI,YApBJ;AA/YR,YAAY,WAAW;AACvB,SAAS,SAAS,mCAAmC;AACrD,SAAS,iCAAiC;AAC1C,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,aAAa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AAI,YAAY,IAAI,GAAG;AAAA,gBAChE,UAAU,oBAAoB,CAAC,cAAc;AAAA,gBAE5C;AAAA,+BAAa,oBAAC,WAAQ,WAAU,gBAAe,IAAK,oBAAC,UAAO,WAAU,gBAAe;AAAA,kBACrF,aACG,EAAE,yCAAyC,aAAa,IACxD,EAAE,uCAAuC,iBAAiB;AAAA;AAAA;AAAA,YAChE;AAAA,aACF,GACF;AAAA,aAtGO,IAAI,GAuGb;AAAA,MAEJ,CAAC,GACH;AAAA,OACF,GACF;AAAA,IAGF,qBAAC,SAAI,WAAU,+FACb;AAAA,2BAAC,SAAI,WAAU,aACb;AAAA,4BAAC,SAAO,YAAE,yCAAyC,UAAU,GAAE;AAAA,QAC/D,oBAAC,OAAG,YAAE,6CAA6C,wDAAwD,GAAE;AAAA,SAC/G;AAAA,MACA,qBAAC,SAAI,WAAU,aACb;AAAA,4BAAC,SAAO,YAAE,qCAAqC,MAAM,GAAE;AAAA,QACvD,oBAAC,OAAG,YAAE,yCAAyC,uDAAuD,GAAE;AAAA,SAC1G;AAAA,MACA,qBAAC,SAAI,WAAU,aACb;AAAA,4BAAC,SAAO,YAAE,wCAAwC,aAAa,GAAE;AAAA,QACjE,oBAAC,OAAG,YAAE,uCAAuC,8GAA8G,GAAE;AAAA,SAC/J;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,iCAAQ;",
|
|
6
6
|
"names": ["supportedDirections"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
4
|
+
import { Label } from "@open-mercato/ui/primitives/label";
|
|
5
|
+
import {
|
|
6
|
+
Select,
|
|
7
|
+
SelectContent,
|
|
8
|
+
SelectItem,
|
|
9
|
+
SelectTrigger,
|
|
10
|
+
SelectValue
|
|
11
|
+
} from "@open-mercato/ui/primitives/select";
|
|
12
|
+
import { Switch } from "@open-mercato/ui/primitives/switch";
|
|
13
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
14
|
+
function buildDefaultRunParameterValues(params) {
|
|
15
|
+
const values = {};
|
|
16
|
+
for (const param of params) {
|
|
17
|
+
if (param.type === "boolean") {
|
|
18
|
+
values[param.key] = param.defaultValue === true;
|
|
19
|
+
} else {
|
|
20
|
+
values[param.key] = param.defaultValue !== void 0 && param.defaultValue !== null ? String(param.defaultValue) : "";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return values;
|
|
24
|
+
}
|
|
25
|
+
function buildRunParametersPayload(params, values) {
|
|
26
|
+
const payload = {};
|
|
27
|
+
for (const param of params) {
|
|
28
|
+
if (param.key in values) payload[param.key] = values[param.key];
|
|
29
|
+
}
|
|
30
|
+
return payload;
|
|
31
|
+
}
|
|
32
|
+
function hasRequiredRunParameterWithoutDefault(params) {
|
|
33
|
+
return params.some((param) => param.type !== "boolean" && param.required && param.defaultValue === void 0);
|
|
34
|
+
}
|
|
35
|
+
function resolveRunParameterText(t, key, literal) {
|
|
36
|
+
if (key) {
|
|
37
|
+
const translated = t(key, literal ?? key);
|
|
38
|
+
if (translated && translated !== key) return translated;
|
|
39
|
+
}
|
|
40
|
+
return literal;
|
|
41
|
+
}
|
|
42
|
+
const ERROR_FALLBACKS = {
|
|
43
|
+
required: "{label} is required.",
|
|
44
|
+
type: "{label} must be a {type}.",
|
|
45
|
+
min: "{label} must be at least {min}.",
|
|
46
|
+
max: "{label} must be at most {max}.",
|
|
47
|
+
select: "{label} must be one of: {options}."
|
|
48
|
+
};
|
|
49
|
+
function buildRunFailureMessage(failure, fallback, t) {
|
|
50
|
+
const rendered = (failure?.details?.parameters ?? []).map((entry) => {
|
|
51
|
+
if (t && entry?.code && ERROR_FALLBACKS[entry.code]) {
|
|
52
|
+
return t(`data_sync.runParameters.errors.${entry.code}`, ERROR_FALLBACKS[entry.code], {
|
|
53
|
+
...entry.params ?? {}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return entry?.message;
|
|
57
|
+
}).filter((message) => typeof message === "string" && message.trim().length > 0);
|
|
58
|
+
if (rendered.length > 0) return rendered.join(" ");
|
|
59
|
+
return failure?.error ?? fallback;
|
|
60
|
+
}
|
|
61
|
+
function buildRetryFailureMessage(failure, t) {
|
|
62
|
+
if (failure?.code === "parametersStale") {
|
|
63
|
+
return t(
|
|
64
|
+
"data_sync.runs.detail.retryParametersStale",
|
|
65
|
+
"The stored run parameters are no longer valid for this integration. Start a new run from the Data Sync dashboard."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return t("data_sync.runs.detail.retryError", "Failed to retry sync run");
|
|
69
|
+
}
|
|
70
|
+
function RunParameterFields({ params, values, onChange }) {
|
|
71
|
+
const t = useT();
|
|
72
|
+
return /* @__PURE__ */ jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: params.map((param) => {
|
|
73
|
+
const value = values[param.key];
|
|
74
|
+
const fieldId = `run-param-${param.key}`;
|
|
75
|
+
const describedById = `${fieldId}-description`;
|
|
76
|
+
const label = resolveRunParameterText(t, param.labelKey, param.label) ?? param.key;
|
|
77
|
+
const description = resolveRunParameterText(t, param.descriptionKey, param.description);
|
|
78
|
+
const placeholder = resolveRunParameterText(t, param.placeholderKey, param.placeholder);
|
|
79
|
+
if (param.type === "boolean") {
|
|
80
|
+
return /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-3 sm:col-span-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
81
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
82
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: "text-sm font-medium", children: label }),
|
|
83
|
+
description ? /* @__PURE__ */ jsx("p", { id: describedById, className: "text-xs text-muted-foreground", children: description }) : null
|
|
84
|
+
] }),
|
|
85
|
+
/* @__PURE__ */ jsx(
|
|
86
|
+
Switch,
|
|
87
|
+
{
|
|
88
|
+
id: fieldId,
|
|
89
|
+
"aria-describedby": description ? describedById : void 0,
|
|
90
|
+
checked: value === true,
|
|
91
|
+
onCheckedChange: (checked) => onChange(param.key, checked)
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] }) }, param.key);
|
|
95
|
+
}
|
|
96
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
97
|
+
/* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: "text-sm font-medium", children: [
|
|
98
|
+
label,
|
|
99
|
+
param.required ? /* @__PURE__ */ jsx("span", { className: "text-status-error-text", children: " *" }) : null
|
|
100
|
+
] }),
|
|
101
|
+
param.type === "select" ? /* @__PURE__ */ jsxs(
|
|
102
|
+
Select,
|
|
103
|
+
{
|
|
104
|
+
value: typeof value === "string" && value.length > 0 ? value : void 0,
|
|
105
|
+
onValueChange: (next) => onChange(param.key, next ?? ""),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(SelectTrigger, { id: fieldId, "aria-describedby": description ? describedById : void 0, children: /* @__PURE__ */ jsx(SelectValue, { placeholder: placeholder ?? void 0 }) }),
|
|
108
|
+
/* @__PURE__ */ jsx(SelectContent, { children: (param.options ?? []).map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label ?? option.value }, option.value)) })
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
) : /* @__PURE__ */ jsx(
|
|
112
|
+
Input,
|
|
113
|
+
{
|
|
114
|
+
id: fieldId,
|
|
115
|
+
"aria-describedby": description ? describedById : void 0,
|
|
116
|
+
value: typeof value === "string" ? value : "",
|
|
117
|
+
onChange: (event) => onChange(param.key, event.target.value),
|
|
118
|
+
placeholder: placeholder ?? void 0,
|
|
119
|
+
inputMode: param.type === "number" ? "numeric" : void 0
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
description ? /* @__PURE__ */ jsx("p", { id: describedById, className: "text-xs text-muted-foreground", children: description }) : null
|
|
123
|
+
] }, param.key);
|
|
124
|
+
}) });
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
RunParameterFields,
|
|
128
|
+
buildDefaultRunParameterValues,
|
|
129
|
+
buildRetryFailureMessage,
|
|
130
|
+
buildRunFailureMessage,
|
|
131
|
+
buildRunParametersPayload,
|
|
132
|
+
hasRequiredRunParameterWithoutDefault,
|
|
133
|
+
resolveRunParameterText
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=RunParameterFields.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/data_sync/components/RunParameterFields.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Label } from '@open-mercato/ui/primitives/label'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { useT, type TranslateFn } from '@open-mercato/shared/lib/i18n/context'\nimport type { RunParameter } from '../lib/adapter'\n\n/**\n * Form-state representation of a run parameter value. Numbers are held as\n * strings while the operator types; the run API coerces them to the declared\n * type via `normalizeRunParameters`.\n */\nexport type RunParameterFormValue = string | boolean\n\nexport function buildDefaultRunParameterValues(\n params: RunParameter[],\n): Record<string, RunParameterFormValue> {\n const values: Record<string, RunParameterFormValue> = {}\n for (const param of params) {\n if (param.type === 'boolean') {\n values[param.key] = param.defaultValue === true\n } else {\n values[param.key] = param.defaultValue !== undefined && param.defaultValue !== null\n ? String(param.defaultValue)\n : ''\n }\n }\n return values\n}\n\nexport function buildRunParametersPayload(\n params: RunParameter[],\n values: Record<string, RunParameterFormValue>,\n): Record<string, RunParameterFormValue> {\n const payload: Record<string, RunParameterFormValue> = {}\n for (const param of params) {\n if (param.key in values) payload[param.key] = values[param.key]\n }\n return payload\n}\n\n/**\n * True when a run cannot be started without operator input \u2014 a required\n * parameter with no default to fall back on. Surfaces that cannot render the\n * full parameter form (the integration schedule table) use this to point the\n * operator at the Data Sync dashboard instead of failing with a 422.\n *\n * Booleans are excluded: a switch always submits `true` or `false`, so their\n * `required` can never fail (see `RunParameter.required`). Counting them would\n * send the operator away from a button that would in fact have worked.\n */\nexport function hasRequiredRunParameterWithoutDefault(params: RunParameter[]): boolean {\n return params.some((param) => param.type !== 'boolean' && param.required && param.defaultValue === undefined)\n}\n\nexport type RunParameterErrorEntry = {\n key?: string\n code?: string\n params?: { label?: string; type?: string; min?: number; max?: number; options?: string }\n message?: string\n}\n\nexport type RunFailureBody = {\n error?: string\n details?: { parameters?: RunParameterErrorEntry[] }\n}\n\ntype Translate = TranslateFn\n\n/** Resolves an optional i18n key, falling back to the adapter's literal. */\nexport function resolveRunParameterText(\n t: Translate,\n key: string | undefined,\n literal: string | undefined,\n): string | undefined {\n if (key) {\n const translated = t(key, literal ?? key)\n if (translated && translated !== key) return translated\n }\n return literal\n}\n\nconst ERROR_FALLBACKS: Record<string, string> = {\n required: '{label} is required.',\n type: '{label} must be a {type}.',\n min: '{label} must be at least {min}.',\n max: '{label} must be at most {max}.',\n select: '{label} must be one of: {options}.',\n}\n\n/**\n * Picks the most specific message out of a failed run response and renders it\n * in the operator's language. The run API reports invalid parameters per key\n * under `details.parameters` with a machine-readable `code`; surfacing only the\n * top-level `error` would say \"Invalid run parameters\" without saying which one\n * or why, and using the server's pre-rendered `message` would put an English\n * sentence next to a translated dashboard.\n */\nexport function buildRunFailureMessage(\n failure: RunFailureBody | null | undefined,\n fallback: string,\n t?: Translate,\n): string {\n const rendered = (failure?.details?.parameters ?? [])\n .map((entry) => {\n if (t && entry?.code && ERROR_FALLBACKS[entry.code]) {\n return t(`data_sync.runParameters.errors.${entry.code}`, ERROR_FALLBACKS[entry.code], {\n ...(entry.params ?? {}),\n })\n }\n return entry?.message\n })\n .filter((message): message is string => typeof message === 'string' && message.trim().length > 0)\n if (rendered.length > 0) return rendered.join(' ')\n return failure?.error ?? fallback\n}\n\nexport type RetryFailureBody = {\n code?: string\n}\n\n/**\n * Retry failures are otherwise indistinguishable to the operator, so both retry\n * buttons flash one generic sentence. The stale-parameter refusal is the one\n * whose remedy is not obvious from context \u2014 it is reported with a machine\n * -readable `code` so the UI can name the way out instead of dead-ending.\n */\nexport function buildRetryFailureMessage(\n failure: RetryFailureBody | null | undefined,\n t: Translate,\n): string {\n if (failure?.code === 'parametersStale') {\n return t(\n 'data_sync.runs.detail.retryParametersStale',\n 'The stored run parameters are no longer valid for this integration. Start a new run from the Data Sync dashboard.',\n )\n }\n return t('data_sync.runs.detail.retryError', 'Failed to retry sync run')\n}\n\nexport type RunParameterFieldsProps = {\n params: RunParameter[]\n values: Record<string, RunParameterFormValue>\n onChange: (key: string, value: RunParameterFormValue) => void\n}\n\nexport function RunParameterFields({ params, values, onChange }: RunParameterFieldsProps) {\n const t = useT()\n return (\n <div className=\"grid gap-3 sm:grid-cols-2\">\n {params.map((param) => {\n const value = values[param.key]\n const fieldId = `run-param-${param.key}`\n const describedById = `${fieldId}-description`\n const label = resolveRunParameterText(t, param.labelKey, param.label) ?? param.key\n const description = resolveRunParameterText(t, param.descriptionKey, param.description)\n const placeholder = resolveRunParameterText(t, param.placeholderKey, param.placeholder)\n // No required marker on booleans: a switch always submits true/false,\n // so `required` can never fail for them (see RunParameter.required).\n if (param.type === 'boolean') {\n return (\n <div key={param.key} className=\"rounded-lg border bg-card p-3 sm:col-span-2\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"space-y-1\">\n <Label htmlFor={fieldId} className=\"text-sm font-medium\">{label}</Label>\n {description ? (\n <p id={describedById} className=\"text-xs text-muted-foreground\">{description}</p>\n ) : null}\n </div>\n <Switch\n id={fieldId}\n aria-describedby={description ? describedById : undefined}\n checked={value === true}\n onCheckedChange={(checked) => onChange(param.key, checked)}\n />\n </div>\n </div>\n )\n }\n return (\n <div key={param.key} className=\"space-y-2\">\n <Label htmlFor={fieldId} className=\"text-sm font-medium\">\n {label}\n {param.required ? <span className=\"text-status-error-text\"> *</span> : null}\n </Label>\n {param.type === 'select' ? (\n <Select\n value={typeof value === 'string' && value.length > 0 ? value : undefined}\n onValueChange={(next) => onChange(param.key, next ?? '')}\n >\n <SelectTrigger id={fieldId} aria-describedby={description ? describedById : undefined}>\n <SelectValue placeholder={placeholder ?? undefined} />\n </SelectTrigger>\n <SelectContent>\n {(param.options ?? []).map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label ?? option.value}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : (\n <Input\n id={fieldId}\n aria-describedby={description ? describedById : undefined}\n value={typeof value === 'string' ? value : ''}\n onChange={(event) => onChange(param.key, event.target.value)}\n placeholder={placeholder ?? undefined}\n inputMode={param.type === 'number' ? 'numeric' : undefined}\n />\n )}\n {description ? (\n <p id={describedById} className=\"text-xs text-muted-foreground\">{description}</p>\n ) : null}\n </div>\n )\n })}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA4KgB,SACE,KADF;AAzKhB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,YAA8B;AAUhC,SAAS,+BACd,QACuC;AACvC,QAAM,SAAgD,CAAC;AACvD,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,SAAS,WAAW;AAC5B,aAAO,MAAM,GAAG,IAAI,MAAM,iBAAiB;AAAA,IAC7C,OAAO;AACL,aAAO,MAAM,GAAG,IAAI,MAAM,iBAAiB,UAAa,MAAM,iBAAiB,OAC3E,OAAO,MAAM,YAAY,IACzB;AAAA,IACN;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,0BACd,QACA,QACuC;AACvC,QAAM,UAAiD,CAAC;AACxD,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,OAAO,OAAQ,SAAQ,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;AAAA,YACA,oBAAC,iBACG,iBAAM,WAAW,CAAC,GAAG,IAAI,CAAC,WAC1B,oBAAC,cAA8B,OAAO,OAAO,OAC1C,iBAAO,SAAS,OAAO,SADT,OAAO,KAExB,CACD,GACH;AAAA;AAAA;AAAA,MACF,IAEA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,oBAAkB,cAAc,gBAAgB;AAAA,UAChD,OAAO,OAAO,UAAU,WAAW,QAAQ;AAAA,UAC3C,UAAU,CAAC,UAAU,SAAS,MAAM,KAAK,MAAM,OAAO,KAAK;AAAA,UAC3D,aAAa,eAAe;AAAA,UAC5B,WAAW,MAAM,SAAS,WAAW,YAAY;AAAA;AAAA,MACnD;AAAA,MAED,cACC,oBAAC,OAAE,IAAI,eAAe,WAAU,iCAAiC,uBAAY,IAC3E;AAAA,SAjCI,MAAM,GAkChB;AAAA,EAEJ,CAAC,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -70,6 +70,9 @@ __decorateClass([
|
|
|
70
70
|
__decorateClass([
|
|
71
71
|
Property({ name: "triggered_by", type: "text", nullable: true })
|
|
72
72
|
], SyncRun.prototype, "triggeredBy", 2);
|
|
73
|
+
__decorateClass([
|
|
74
|
+
Property({ name: "parameters", type: "json", nullable: true })
|
|
75
|
+
], SyncRun.prototype, "parameters", 2);
|
|
73
76
|
__decorateClass([
|
|
74
77
|
Property({ name: "organization_id", type: "uuid" })
|
|
75
78
|
], SyncRun.prototype, "organizationId", 2);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/data_sync/data/entities.ts"],
|
|
4
|
-
"sourcesContent": ["import { OptionalProps } from '@mikro-orm/core'\nimport { Entity, Index, PrimaryKey, Property } from '@mikro-orm/decorators/legacy'\n\n@Entity({ tableName: 'sync_runs' })\n@Index({ properties: ['integrationId', 'entityType', 'status', 'organizationId', 'tenantId'] })\nexport class SyncRun {\n [OptionalProps]?: 'status' | 'cursor' | 'initialCursor' | 'createdCount' | 'updatedCount' | 'skippedCount' | 'failedCount' | 'batchesCompleted' | 'lastError' | 'progressJobId' | 'jobId' | 'triggeredBy' | 'createdAt' | 'updatedAt' | 'deletedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'import' | 'export'\n\n @Property({ name: 'status', type: 'text' })\n status!: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused'\n\n @Property({ name: 'cursor', type: 'text', nullable: true })\n cursor?: string | null\n\n @Property({ name: 'initial_cursor', type: 'text', nullable: true })\n initialCursor?: string | null\n\n @Property({ name: 'created_count', type: 'int', default: 0 })\n createdCount: number = 0\n\n @Property({ name: 'updated_count', type: 'int', default: 0 })\n updatedCount: number = 0\n\n @Property({ name: 'skipped_count', type: 'int', default: 0 })\n skippedCount: number = 0\n\n @Property({ name: 'failed_count', type: 'int', default: 0 })\n failedCount: number = 0\n\n @Property({ name: 'batches_completed', type: 'int', default: 0 })\n batchesCompleted: number = 0\n\n @Property({ name: 'last_error', type: 'text', nullable: true })\n lastError?: string | null\n\n @Property({ name: 'progress_job_id', type: 'uuid', nullable: true })\n progressJobId?: string | null\n\n @Property({ name: 'job_id', type: 'text', nullable: true })\n jobId?: string | null\n\n @Property({ name: 'triggered_by', type: 'text', nullable: true })\n triggeredBy?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'sync_cursors' })\n@Index({ properties: ['integrationId', 'entityType', 'direction', 'organizationId', 'tenantId'], options: { unique: true } })\nexport class SyncCursor {\n [OptionalProps]?: 'cursor' | 'updatedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'import' | 'export'\n\n @Property({ name: 'cursor', type: 'text', nullable: true })\n cursor?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'updated_at', type: Date, onCreate: () => new Date(), onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'sync_mappings' })\n@Index({ properties: ['integrationId', 'entityType', 'organizationId', 'tenantId'], options: { unique: true } })\nexport class SyncMapping {\n [OptionalProps]?: 'createdAt' | 'updatedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'mapping', type: 'json' })\n mapping!: Record<string, unknown>\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'sync_schedules' })\n@Index({ properties: ['integrationId', 'entityType', 'direction', 'organizationId', 'tenantId'] })\nexport class SyncSchedule {\n [OptionalProps]?: 'timezone' | 'fullSync' | 'isEnabled' | 'scheduledJobId' | 'lastRunAt' | 'createdAt' | 'updatedAt' | 'deletedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'import' | 'export'\n\n @Property({ name: 'schedule_type', type: 'text' })\n scheduleType!: 'cron' | 'interval'\n\n @Property({ name: 'schedule_value', type: 'text' })\n scheduleValue!: string\n\n @Property({ name: 'timezone', type: 'text', default: 'UTC' })\n timezone: string = 'UTC'\n\n @Property({ name: 'full_sync', type: 'boolean', default: false })\n fullSync: boolean = false\n\n @Property({ name: 'is_enabled', type: 'boolean', default: true })\n isEnabled: boolean = true\n\n @Property({ name: 'scheduled_job_id', type: 'uuid', nullable: true })\n scheduledJobId?: string | null\n\n @Property({ name: 'last_run_at', type: Date, nullable: true })\n lastRunAt?: Date | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,gBAAgB;AAKjD;AADI,IAAM,UAAN,MAAc;AAAA,EAAd;AAwBL,wBAAuB;AAGvB,wBAAuB;AAGvB,wBAAuB;AAGvB,uBAAsB;AAGtB,4BAA2B;
|
|
4
|
+
"sourcesContent": ["import { OptionalProps } from '@mikro-orm/core'\nimport { Entity, Index, PrimaryKey, Property } from '@mikro-orm/decorators/legacy'\n\n@Entity({ tableName: 'sync_runs' })\n@Index({ properties: ['integrationId', 'entityType', 'status', 'organizationId', 'tenantId'] })\nexport class SyncRun {\n [OptionalProps]?: 'status' | 'cursor' | 'initialCursor' | 'createdCount' | 'updatedCount' | 'skippedCount' | 'failedCount' | 'batchesCompleted' | 'lastError' | 'progressJobId' | 'jobId' | 'triggeredBy' | 'parameters' | 'createdAt' | 'updatedAt' | 'deletedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'import' | 'export'\n\n @Property({ name: 'status', type: 'text' })\n status!: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'paused'\n\n @Property({ name: 'cursor', type: 'text', nullable: true })\n cursor?: string | null\n\n @Property({ name: 'initial_cursor', type: 'text', nullable: true })\n initialCursor?: string | null\n\n @Property({ name: 'created_count', type: 'int', default: 0 })\n createdCount: number = 0\n\n @Property({ name: 'updated_count', type: 'int', default: 0 })\n updatedCount: number = 0\n\n @Property({ name: 'skipped_count', type: 'int', default: 0 })\n skippedCount: number = 0\n\n @Property({ name: 'failed_count', type: 'int', default: 0 })\n failedCount: number = 0\n\n @Property({ name: 'batches_completed', type: 'int', default: 0 })\n batchesCompleted: number = 0\n\n @Property({ name: 'last_error', type: 'text', nullable: true })\n lastError?: string | null\n\n @Property({ name: 'progress_job_id', type: 'uuid', nullable: true })\n progressJobId?: string | null\n\n @Property({ name: 'job_id', type: 'text', nullable: true })\n jobId?: string | null\n\n @Property({ name: 'triggered_by', type: 'text', nullable: true })\n triggeredBy?: string | null\n\n @Property({ name: 'parameters', type: 'json', nullable: true })\n parameters?: Record<string, unknown> | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'sync_cursors' })\n@Index({ properties: ['integrationId', 'entityType', 'direction', 'organizationId', 'tenantId'], options: { unique: true } })\nexport class SyncCursor {\n [OptionalProps]?: 'cursor' | 'updatedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'import' | 'export'\n\n @Property({ name: 'cursor', type: 'text', nullable: true })\n cursor?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'updated_at', type: Date, onCreate: () => new Date(), onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'sync_mappings' })\n@Index({ properties: ['integrationId', 'entityType', 'organizationId', 'tenantId'], options: { unique: true } })\nexport class SyncMapping {\n [OptionalProps]?: 'createdAt' | 'updatedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'mapping', type: 'json' })\n mapping!: Record<string, unknown>\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'sync_schedules' })\n@Index({ properties: ['integrationId', 'entityType', 'direction', 'organizationId', 'tenantId'] })\nexport class SyncSchedule {\n [OptionalProps]?: 'timezone' | 'fullSync' | 'isEnabled' | 'scheduledJobId' | 'lastRunAt' | 'createdAt' | 'updatedAt' | 'deletedAt'\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'integration_id', type: 'text' })\n integrationId!: string\n\n @Property({ name: 'entity_type', type: 'text' })\n entityType!: string\n\n @Property({ name: 'direction', type: 'text' })\n direction!: 'import' | 'export'\n\n @Property({ name: 'schedule_type', type: 'text' })\n scheduleType!: 'cron' | 'interval'\n\n @Property({ name: 'schedule_value', type: 'text' })\n scheduleValue!: string\n\n @Property({ name: 'timezone', type: 'text', default: 'UTC' })\n timezone: string = 'UTC'\n\n @Property({ name: 'full_sync', type: 'boolean', default: false })\n fullSync: boolean = false\n\n @Property({ name: 'is_enabled', type: 'boolean', default: true })\n isEnabled: boolean = true\n\n @Property({ name: 'scheduled_job_id', type: 'uuid', nullable: true })\n scheduledJobId?: string | null\n\n @Property({ name: 'last_run_at', type: Date, nullable: true })\n lastRunAt?: Date | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,OAAO,YAAY,gBAAgB;AAKjD;AADI,IAAM,UAAN,MAAc;AAAA,EAAd;AAwBL,wBAAuB;AAGvB,wBAAuB;AAGvB,wBAAuB;AAGvB,uBAAsB;AAGtB,4BAA2B;AAwB3B,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;A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M,WAAW,SAAS,MAAM,CAAC;AAAA,GAvBrD,aAwBX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,WAAW,SAAS,KAAK,CAAC;AAAA,GA1BrD,aA2BX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,oBAAoB,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GA7BzD,aA8BX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GAhClD,aAiCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,mBAAmB,MAAM,OAAO,CAAC;AAAA,GAnCxC,aAoCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,aAAa,MAAM,OAAO,CAAC;AAAA,GAtClC,aAuCX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GAzC7D,aA0CX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,MAAM,oBAAI,KAAK,EAAE,CAAC;AAAA,GA5C7D,aA6CX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,cAAc,MAAM,MAAM,UAAU,KAAK,CAAC;AAAA,GA/CjD,aAgDX;AAhDW,eAAN;AAAA,EAFN,OAAO,EAAE,WAAW,iBAAiB,CAAC;AAAA,EACtC,MAAM,EAAE,YAAY,CAAC,iBAAiB,cAAc,aAAa,kBAAkB,UAAU,EAAE,CAAC;AAAA,GACpF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,10 @@ const runSyncSchema = z.object({
|
|
|
5
5
|
direction: z.enum(["import", "export"]),
|
|
6
6
|
fullSync: z.boolean().default(false),
|
|
7
7
|
batchSize: z.number().int().min(1).max(1e3).default(100),
|
|
8
|
-
triggeredBy: z.string().optional()
|
|
8
|
+
triggeredBy: z.string().optional(),
|
|
9
|
+
// Adapter-declared run parameters. Validated/coerced against the adapter's
|
|
10
|
+
// `runParameters` declaration in the run route; here we only accept a record.
|
|
11
|
+
parameters: z.record(z.string(), z.unknown()).optional()
|
|
9
12
|
});
|
|
10
13
|
const retrySyncSchema = z.object({
|
|
11
14
|
fromBeginning: z.boolean().default(false)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/data_sync/data/validators.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod'\n\nexport const runSyncSchema = z.object({\n integrationId: z.string().min(1),\n entityType: z.string().min(1),\n direction: z.enum(['import', 'export']),\n fullSync: z.boolean().default(false),\n batchSize: z.number().int().min(1).max(1000).default(100),\n triggeredBy: z.string().optional(),\n})\n\nexport type RunSyncInput = z.infer<typeof runSyncSchema>\n\nexport const retrySyncSchema = z.object({\n fromBeginning: z.boolean().default(false),\n})\n\nexport type RetrySyncInput = z.infer<typeof retrySyncSchema>\n\nexport const validateConnectionSchema = z.object({\n integrationId: z.string().min(1),\n entityType: z.string().min(1),\n direction: z.enum(['import', 'export']),\n})\n\nexport const listSyncRunsQuerySchema = z.object({\n integrationId: z.string().optional(),\n entityType: z.string().optional(),\n direction: z.enum(['import', 'export']).optional(),\n status: z.enum(['pending', 'running', 'completed', 'failed', 'cancelled', 'paused']).optional(),\n search: z.string().trim().min(1).max(200).optional(),\n page: z.coerce.number().int().min(1).default(1),\n pageSize: z.coerce.number().int().min(1).max(100).default(20),\n})\n\nexport type ListSyncRunsQuery = z.infer<typeof listSyncRunsQuerySchema>\n\nexport const listSyncSchedulesQuerySchema = z.object({\n integrationId: z.string().optional(),\n entityType: z.string().optional(),\n direction: z.enum(['import', 'export']).optional(),\n page: z.coerce.number().int().min(1).default(1),\n pageSize: z.coerce.number().int().min(1).max(100).default(20),\n})\n\nexport const createSyncScheduleSchema = z.object({\n integrationId: z.string().min(1),\n entityType: z.string().min(1),\n direction: z.enum(['import', 'export']),\n scheduleType: z.enum(['cron', 'interval']),\n scheduleValue: z.string().min(1),\n timezone: z.string().min(1).default('UTC'),\n fullSync: z.boolean().default(false),\n isEnabled: z.boolean().default(true),\n})\n\nexport const updateSyncScheduleSchema = z.object({\n integrationId: z.string().min(1).optional(),\n entityType: z.string().min(1).optional(),\n direction: z.enum(['import', 'export']).optional(),\n scheduleType: z.enum(['cron', 'interval']).optional(),\n scheduleValue: z.string().min(1).optional(),\n timezone: z.string().min(1).optional(),\n fullSync: z.boolean().optional(),\n isEnabled: z.boolean().optional(),\n}).refine((value) => Object.keys(value).length > 0, {\n message: 'At least one field must be updated',\n})\n\nexport type CreateSyncScheduleInput = z.infer<typeof createSyncScheduleSchema>\nexport type UpdateSyncScheduleInput = z.infer<typeof updateSyncScheduleSchema>\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS;AAEX,MAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC/B,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC5B,WAAW,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC;AAAA,EACtC,UAAU,EAAE,QAAQ,EAAE,QAAQ,KAAK;AAAA,EACnC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAI,EAAE,QAAQ,GAAG;AAAA,EACxD,aAAa,EAAE,OAAO,EAAE,SAAS;
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\n\nexport const runSyncSchema = z.object({\n integrationId: z.string().min(1),\n entityType: z.string().min(1),\n direction: z.enum(['import', 'export']),\n fullSync: z.boolean().default(false),\n batchSize: z.number().int().min(1).max(1000).default(100),\n triggeredBy: z.string().optional(),\n // Adapter-declared run parameters. Validated/coerced against the adapter's\n // `runParameters` declaration in the run route; here we only accept a record.\n parameters: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport type RunSyncInput = z.infer<typeof runSyncSchema>\n\nexport const retrySyncSchema = z.object({\n fromBeginning: z.boolean().default(false),\n})\n\nexport type RetrySyncInput = z.infer<typeof retrySyncSchema>\n\nexport const validateConnectionSchema = z.object({\n integrationId: z.string().min(1),\n entityType: z.string().min(1),\n direction: z.enum(['import', 'export']),\n})\n\nexport const listSyncRunsQuerySchema = z.object({\n integrationId: z.string().optional(),\n entityType: z.string().optional(),\n direction: z.enum(['import', 'export']).optional(),\n status: z.enum(['pending', 'running', 'completed', 'failed', 'cancelled', 'paused']).optional(),\n search: z.string().trim().min(1).max(200).optional(),\n page: z.coerce.number().int().min(1).default(1),\n pageSize: z.coerce.number().int().min(1).max(100).default(20),\n})\n\nexport type ListSyncRunsQuery = z.infer<typeof listSyncRunsQuerySchema>\n\nexport const listSyncSchedulesQuerySchema = z.object({\n integrationId: z.string().optional(),\n entityType: z.string().optional(),\n direction: z.enum(['import', 'export']).optional(),\n page: z.coerce.number().int().min(1).default(1),\n pageSize: z.coerce.number().int().min(1).max(100).default(20),\n})\n\nexport const createSyncScheduleSchema = z.object({\n integrationId: z.string().min(1),\n entityType: z.string().min(1),\n direction: z.enum(['import', 'export']),\n scheduleType: z.enum(['cron', 'interval']),\n scheduleValue: z.string().min(1),\n timezone: z.string().min(1).default('UTC'),\n fullSync: z.boolean().default(false),\n isEnabled: z.boolean().default(true),\n})\n\nexport const updateSyncScheduleSchema = z.object({\n integrationId: z.string().min(1).optional(),\n entityType: z.string().min(1).optional(),\n direction: z.enum(['import', 'export']).optional(),\n scheduleType: z.enum(['cron', 'interval']).optional(),\n scheduleValue: z.string().min(1).optional(),\n timezone: z.string().min(1).optional(),\n fullSync: z.boolean().optional(),\n isEnabled: z.boolean().optional(),\n}).refine((value) => Object.keys(value).length > 0, {\n message: 'At least one field must be updated',\n})\n\nexport type CreateSyncScheduleInput = z.infer<typeof createSyncScheduleSchema>\nexport type UpdateSyncScheduleInput = z.infer<typeof updateSyncScheduleSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAEX,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