@open-mercato/core 0.4.6-develop-a88276bc52 → 0.4.6-develop-806a2ed6b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +10 -0
- package/dist/generated/entities/integration_credentials/index.js +19 -0
- package/dist/generated/entities/integration_credentials/index.js.map +7 -0
- package/dist/generated/entities/integration_log/index.js +27 -0
- package/dist/generated/entities/integration_log/index.js.map +7 -0
- package/dist/generated/entities/integration_state/index.js +27 -0
- package/dist/generated/entities/integration_state/index.js.map +7 -0
- package/dist/generated/entities/sync_cursor/index.js +19 -0
- package/dist/generated/entities/sync_cursor/index.js.map +7 -0
- package/dist/generated/entities/sync_external_id_mapping/index.js +27 -0
- package/dist/generated/entities/sync_external_id_mapping/index.js.map +7 -0
- package/dist/generated/entities/sync_mapping/index.js +19 -0
- package/dist/generated/entities/sync_mapping/index.js.map +7 -0
- package/dist/generated/entities/sync_run/index.js +45 -0
- package/dist/generated/entities/sync_run/index.js.map +7 -0
- package/dist/generated/entities/sync_schedule/index.js +35 -0
- package/dist/generated/entities/sync_schedule/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +14 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +16 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/data_sync/acl.js +11 -0
- package/dist/modules/data_sync/acl.js.map +7 -0
- package/dist/modules/data_sync/api/mappings/[id]/route.js +137 -0
- package/dist/modules/data_sync/api/mappings/[id]/route.js.map +7 -0
- package/dist/modules/data_sync/api/mappings/route.js +132 -0
- package/dist/modules/data_sync/api/mappings/route.js.map +7 -0
- package/dist/modules/data_sync/api/run.js +87 -0
- package/dist/modules/data_sync/api/run.js.map +7 -0
- package/dist/modules/data_sync/api/runs/[id]/cancel.js +49 -0
- package/dist/modules/data_sync/api/runs/[id]/cancel.js.map +7 -0
- package/dist/modules/data_sync/api/runs/[id]/retry.js +93 -0
- package/dist/modules/data_sync/api/runs/[id]/retry.js.map +7 -0
- package/dist/modules/data_sync/api/runs/[id]/route.js +69 -0
- package/dist/modules/data_sync/api/runs/[id]/route.js.map +7 -0
- package/dist/modules/data_sync/api/runs.js +66 -0
- package/dist/modules/data_sync/api/runs.js.map +7 -0
- package/dist/modules/data_sync/api/validate.js +66 -0
- package/dist/modules/data_sync/api/validate.js.map +7 -0
- package/dist/modules/data_sync/backend/data-sync/page.js +216 -0
- package/dist/modules/data_sync/backend/data-sync/page.js.map +7 -0
- package/dist/modules/data_sync/backend/data-sync/page.meta.js +25 -0
- package/dist/modules/data_sync/backend/data-sync/page.meta.js.map +7 -0
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js +178 -0
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.js.map +7 -0
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.meta.js +14 -0
- package/dist/modules/data_sync/backend/data-sync/runs/[id]/page.meta.js.map +7 -0
- package/dist/modules/data_sync/data/entities.js +228 -0
- package/dist/modules/data_sync/data/entities.js.map +7 -0
- package/dist/modules/data_sync/data/validators.js +32 -0
- package/dist/modules/data_sync/data/validators.js.map +7 -0
- package/dist/modules/data_sync/di.js +26 -0
- package/dist/modules/data_sync/di.js.map +7 -0
- package/dist/modules/data_sync/events.js +16 -0
- package/dist/modules/data_sync/events.js.map +7 -0
- package/dist/modules/data_sync/index.js +9 -0
- package/dist/modules/data_sync/index.js.map +7 -0
- package/dist/modules/data_sync/lib/adapter-registry.js +16 -0
- package/dist/modules/data_sync/lib/adapter-registry.js.map +7 -0
- package/dist/modules/data_sync/lib/adapter.js +1 -0
- package/dist/modules/data_sync/lib/adapter.js.map +7 -0
- package/dist/modules/data_sync/lib/id-mapping.js +79 -0
- package/dist/modules/data_sync/lib/id-mapping.js.map +7 -0
- package/dist/modules/data_sync/lib/queue.js +17 -0
- package/dist/modules/data_sync/lib/queue.js.map +7 -0
- package/dist/modules/data_sync/lib/sync-engine.js +309 -0
- package/dist/modules/data_sync/lib/sync-engine.js.map +7 -0
- package/dist/modules/data_sync/lib/sync-run-service.js +148 -0
- package/dist/modules/data_sync/lib/sync-run-service.js.map +7 -0
- package/dist/modules/data_sync/migrations/Migration20260304113737.js +17 -0
- package/dist/modules/data_sync/migrations/Migration20260304113737.js.map +7 -0
- package/dist/modules/data_sync/setup.js +13 -0
- package/dist/modules/data_sync/setup.js.map +7 -0
- package/dist/modules/data_sync/workers/sync-export.js +14 -0
- package/dist/modules/data_sync/workers/sync-export.js.map +7 -0
- package/dist/modules/data_sync/workers/sync-import.js +14 -0
- package/dist/modules/data_sync/workers/sync-import.js.map +7 -0
- package/dist/modules/data_sync/workers/sync-scheduled.js +63 -0
- package/dist/modules/data_sync/workers/sync-scheduled.js.map +7 -0
- package/dist/modules/entities/lib/encryptionDefaults.js +4 -0
- package/dist/modules/entities/lib/encryptionDefaults.js.map +2 -2
- package/dist/modules/integrations/acl.js +4 -1
- package/dist/modules/integrations/acl.js.map +2 -2
- package/dist/modules/integrations/api/[id]/credentials/route.js +127 -0
- package/dist/modules/integrations/api/[id]/credentials/route.js.map +7 -0
- package/dist/modules/integrations/api/[id]/health/route.js +46 -0
- package/dist/modules/integrations/api/[id]/health/route.js.map +7 -0
- package/dist/modules/integrations/api/[id]/route.js +65 -0
- package/dist/modules/integrations/api/[id]/route.js.map +7 -0
- package/dist/modules/integrations/api/[id]/state/route.js +109 -0
- package/dist/modules/integrations/api/[id]/state/route.js.map +7 -0
- package/dist/modules/integrations/api/[id]/version/route.js +117 -0
- package/dist/modules/integrations/api/[id]/version/route.js.map +7 -0
- package/dist/modules/integrations/api/guards.js +31 -0
- package/dist/modules/integrations/api/guards.js.map +7 -0
- package/dist/modules/integrations/api/logs/route.js +60 -0
- package/dist/modules/integrations/api/logs/route.js.map +7 -0
- package/dist/modules/integrations/api/openapi.js +25 -0
- package/dist/modules/integrations/api/openapi.js.map +7 -0
- package/dist/modules/integrations/api/route.js +68 -0
- package/dist/modules/integrations/api/route.js.map +7 -0
- package/dist/modules/integrations/backend/integrations/[id]/page.js +313 -0
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +7 -0
- package/dist/modules/integrations/backend/integrations/[id]/page.meta.js +15 -0
- package/dist/modules/integrations/backend/integrations/[id]/page.meta.js.map +7 -0
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js +189 -0
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.js.map +7 -0
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.meta.js +15 -0
- package/dist/modules/integrations/backend/integrations/bundle/[id]/page.meta.js.map +7 -0
- package/dist/modules/integrations/backend/integrations/page.js +212 -0
- package/dist/modules/integrations/backend/integrations/page.js.map +7 -0
- package/dist/modules/integrations/backend/integrations/page.meta.js +22 -0
- package/dist/modules/integrations/backend/integrations/page.meta.js.map +7 -0
- package/dist/modules/integrations/data/enrichers.js +27 -12
- package/dist/modules/integrations/data/enrichers.js.map +2 -2
- package/dist/modules/integrations/data/entities.js +136 -1
- package/dist/modules/integrations/data/entities.js.map +2 -2
- package/dist/modules/integrations/data/validators.js +36 -0
- package/dist/modules/integrations/data/validators.js.map +7 -0
- package/dist/modules/integrations/di.js +24 -0
- package/dist/modules/integrations/di.js.map +7 -0
- package/dist/modules/integrations/events.js +19 -0
- package/dist/modules/integrations/events.js.map +7 -0
- package/dist/modules/integrations/lib/credentials-service.js +159 -0
- package/dist/modules/integrations/lib/credentials-service.js.map +7 -0
- package/dist/modules/integrations/lib/health-service.js +37 -0
- package/dist/modules/integrations/lib/health-service.js.map +7 -0
- package/dist/modules/integrations/lib/log-service.js +66 -0
- package/dist/modules/integrations/lib/log-service.js.map +7 -0
- package/dist/modules/integrations/lib/registry-service.js +33 -0
- package/dist/modules/integrations/lib/registry-service.js.map +7 -0
- package/dist/modules/integrations/lib/state-service.js +55 -0
- package/dist/modules/integrations/lib/state-service.js.map +7 -0
- package/dist/modules/integrations/lib/types.js +1 -0
- package/dist/modules/integrations/lib/types.js.map +7 -0
- package/dist/modules/integrations/migrations/Migration20260304113737.js +19 -0
- package/dist/modules/integrations/migrations/Migration20260304113737.js.map +7 -0
- package/dist/modules/integrations/setup.js +2 -2
- package/dist/modules/integrations/setup.js.map +2 -2
- package/dist/modules/integrations/widgets/injection-table.js.map +1 -1
- package/dist/modules/integrations/workers/log-pruner.js +18 -0
- package/dist/modules/integrations/workers/log-pruner.js.map +7 -0
- package/generated/entities/integration_credentials/index.ts +8 -0
- package/generated/entities/integration_log/index.ts +12 -0
- package/generated/entities/integration_state/index.ts +12 -0
- package/generated/entities/sync_cursor/index.ts +8 -0
- package/generated/entities/sync_external_id_mapping/index.ts +12 -0
- package/generated/entities/sync_mapping/index.ts +8 -0
- package/generated/entities/sync_run/index.ts +21 -0
- package/generated/entities/sync_schedule/index.ts +16 -0
- package/generated/entities.ids.generated.ts +14 -0
- package/generated/entity-fields-registry.ts +16 -0
- package/package.json +2 -2
- package/src/modules/data_sync/AGENTS.md +157 -0
- package/src/modules/data_sync/acl.ts +7 -0
- package/src/modules/data_sync/api/mappings/[id]/route.ts +158 -0
- package/src/modules/data_sync/api/mappings/route.ts +144 -0
- package/src/modules/data_sync/api/run.ts +97 -0
- package/src/modules/data_sync/api/runs/[id]/cancel.ts +57 -0
- package/src/modules/data_sync/api/runs/[id]/retry.ts +108 -0
- package/src/modules/data_sync/api/runs/[id]/route.ts +81 -0
- package/src/modules/data_sync/api/runs.ts +69 -0
- package/src/modules/data_sync/api/validate.ts +73 -0
- package/src/modules/data_sync/backend/data-sync/page.meta.ts +21 -0
- package/src/modules/data_sync/backend/data-sync/page.tsx +244 -0
- package/src/modules/data_sync/backend/data-sync/runs/[id]/page.meta.ts +10 -0
- package/src/modules/data_sync/backend/data-sync/runs/[id]/page.tsx +278 -0
- package/src/modules/data_sync/data/entities.ts +180 -0
- package/src/modules/data_sync/data/validators.ts +35 -0
- package/src/modules/data_sync/di.ts +38 -0
- package/src/modules/data_sync/events.ts +12 -0
- package/src/modules/data_sync/i18n/de.json +48 -0
- package/src/modules/data_sync/i18n/en.json +48 -0
- package/src/modules/data_sync/i18n/es.json +48 -0
- package/src/modules/data_sync/i18n/pl.json +48 -0
- package/src/modules/data_sync/index.ts +5 -0
- package/src/modules/data_sync/lib/adapter-registry.ts +15 -0
- package/src/modules/data_sync/lib/adapter.ts +90 -0
- package/src/modules/data_sync/lib/id-mapping.ts +95 -0
- package/src/modules/data_sync/lib/queue.ts +19 -0
- package/src/modules/data_sync/lib/sync-engine.ts +375 -0
- package/src/modules/data_sync/lib/sync-run-service.ts +187 -0
- package/src/modules/data_sync/migrations/.snapshot-open-mercato.json +653 -0
- package/src/modules/data_sync/migrations/Migration20260304113737.ts +19 -0
- package/src/modules/data_sync/setup.ts +11 -0
- package/src/modules/data_sync/workers/sync-export.ts +27 -0
- package/src/modules/data_sync/workers/sync-import.ts +27 -0
- package/src/modules/data_sync/workers/sync-scheduled.ts +84 -0
- package/src/modules/entities/lib/encryptionDefaults.ts +4 -0
- package/src/modules/integrations/AGENTS.md +160 -0
- package/src/modules/integrations/acl.ts +3 -0
- package/src/modules/integrations/api/[id]/credentials/route.ts +142 -0
- package/src/modules/integrations/api/[id]/health/route.ts +53 -0
- package/src/modules/integrations/api/[id]/route.ts +76 -0
- package/src/modules/integrations/api/[id]/state/route.ts +121 -0
- package/src/modules/integrations/api/[id]/version/route.ts +132 -0
- package/src/modules/integrations/api/guards.ts +59 -0
- package/src/modules/integrations/api/logs/route.ts +63 -0
- package/src/modules/integrations/api/openapi.ts +22 -0
- package/src/modules/integrations/api/route.ts +73 -0
- package/src/modules/integrations/backend/integrations/[id]/page.meta.ts +11 -0
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +424 -0
- package/src/modules/integrations/backend/integrations/bundle/[id]/page.meta.ts +11 -0
- package/src/modules/integrations/backend/integrations/bundle/[id]/page.tsx +249 -0
- package/src/modules/integrations/backend/integrations/page.meta.ts +18 -0
- package/src/modules/integrations/backend/integrations/page.tsx +296 -0
- package/src/modules/integrations/data/enrichers.ts +35 -18
- package/src/modules/integrations/data/entities.ts +114 -5
- package/src/modules/integrations/data/validators.ts +41 -0
- package/src/modules/integrations/di.ts +31 -0
- package/src/modules/integrations/events.ts +17 -0
- package/src/modules/integrations/i18n/de.json +70 -0
- package/src/modules/integrations/i18n/en.json +70 -0
- package/src/modules/integrations/i18n/es.json +70 -0
- package/src/modules/integrations/i18n/pl.json +70 -0
- package/src/modules/integrations/lib/credentials-service.ts +204 -0
- package/src/modules/integrations/lib/health-service.ts +59 -0
- package/src/modules/integrations/lib/log-service.ts +84 -0
- package/src/modules/integrations/lib/registry-service.ts +42 -0
- package/src/modules/integrations/lib/state-service.ts +64 -0
- package/src/modules/integrations/lib/types.ts +4 -0
- package/src/modules/integrations/migrations/.snapshot-open-mercato.json +582 -0
- package/src/modules/integrations/migrations/Migration20260304113737.ts +21 -0
- package/src/modules/integrations/setup.ts +2 -2
- package/src/modules/integrations/widgets/injection-table.ts +1 -1
- package/src/modules/integrations/workers/log-pruner.ts +30 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/integrations/backend/integrations/bundle/%5Bid%5D/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { useParams } from 'next/navigation'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { Card, CardHeader, CardTitle, CardContent } from '@open-mercato/ui/primitives/card'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { IntegrationCredentialField } from '@open-mercato/shared/modules/integrations/types'\nimport { LoadingMessage } from '@open-mercato/ui/backend/detail'\nimport { ErrorMessage } from '@open-mercato/ui/backend/detail'\n\ntype CredentialField = IntegrationCredentialField\n\ntype BundleIntegration = {\n id: string\n title: string\n description?: string\n category?: string\n isEnabled: boolean\n}\n\ntype BundleDetail = {\n integration: {\n id: string\n title: string\n description?: string\n bundleId?: string\n }\n bundle?: {\n id: string\n title: string\n description?: string\n credentials?: { fields: CredentialField[] }\n }\n bundleIntegrations: BundleIntegration[]\n state: { isEnabled: boolean }\n hasCredentials: boolean\n}\n\nexport default function BundleConfigPage() {\n const params = useParams<{ id: string }>()\n const bundleId = params.id\n const t = useT()\n\n const [detail, setDetail] = React.useState<BundleDetail | null>(null)\n const [isLoading, setIsLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n const [credValues, setCredValues] = React.useState<Record<string, unknown>>({})\n const [isSavingCreds, setIsSavingCreds] = React.useState(false)\n const [togglingIds, setTogglingIds] = React.useState<Set<string>>(new Set())\n\n const load = React.useCallback(async () => {\n setIsLoading(true)\n setError(null)\n const call = await apiCall<BundleDetail>(\n `/api/integrations/${encodeURIComponent(bundleId)}`,\n undefined,\n { fallback: null },\n )\n if (!call.ok || !call.result) {\n setError(t('integrations.detail.loadError'))\n setIsLoading(false)\n return\n }\n setDetail(call.result)\n\n const credCall = await apiCall<{ credentials: Record<string, unknown> }>(\n `/api/integrations/${encodeURIComponent(bundleId)}/credentials`,\n undefined,\n { fallback: null },\n )\n if (credCall.ok && credCall.result?.credentials) {\n setCredValues(credCall.result.credentials)\n }\n setIsLoading(false)\n }, [bundleId, t])\n\n React.useEffect(() => { void load() }, [load])\n\n const handleSaveCredentials = React.useCallback(async () => {\n setIsSavingCreds(true)\n const call = await apiCall(`/api/integrations/${encodeURIComponent(bundleId)}/credentials`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ credentials: credValues }),\n }, { fallback: null })\n if (call.ok) {\n flash(t('integrations.detail.credentials.saved'), 'success')\n } else {\n flash(t('integrations.detail.credentials.saveError'), 'error')\n }\n setIsSavingCreds(false)\n }, [bundleId, credValues, t])\n\n const handleToggle = React.useCallback(async (integrationId: string, enabled: boolean) => {\n setTogglingIds((prev) => new Set(prev).add(integrationId))\n const call = await apiCall(`/api/integrations/${encodeURIComponent(integrationId)}/state`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ isEnabled: enabled }),\n }, { fallback: null })\n if (call.ok) {\n setDetail((prev) => {\n if (!prev) return prev\n return {\n ...prev,\n bundleIntegrations: prev.bundleIntegrations.map((item) =>\n item.id === integrationId ? { ...item, isEnabled: enabled } : item,\n ),\n }\n })\n } else {\n flash(t('integrations.detail.stateError'), 'error')\n }\n setTogglingIds((prev) => { const next = new Set(prev); next.delete(integrationId); return next })\n }, [t])\n\n const handleBulkToggle = React.useCallback(async (enabled: boolean) => {\n if (!detail) return\n const targets = detail.bundleIntegrations.filter((item) => item.isEnabled !== enabled)\n await Promise.all(targets.map((item) => handleToggle(item.id, enabled)))\n }, [detail, handleToggle])\n\n if (isLoading) return <Page><PageBody><LoadingMessage label={t('integrations.bundle.title')} /></PageBody></Page>\n if (error || !detail?.bundle) return <Page><PageBody><ErrorMessage label={error ?? t('integrations.detail.loadError')} /></PageBody></Page>\n\n const credFields = detail.bundle.credentials?.fields ?? []\n\n return (\n <Page>\n <PageBody className=\"space-y-6\">\n <div>\n <Link href=\"/backend/integrations\" className=\"text-sm text-muted-foreground hover:underline\">\n {t('integrations.detail.back')}\n </Link>\n </div>\n\n <div>\n <h1 className=\"text-2xl font-semibold\">{detail.bundle.title}</h1>\n {detail.bundle.description && (\n <p className=\"text-muted-foreground mt-1\">{detail.bundle.description}</p>\n )}\n </div>\n\n {credFields.length > 0 && (\n <Card>\n <CardHeader>\n <CardTitle>{t('integrations.bundle.sharedCredentials')}</CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {credFields.map((field) => (\n <div key={field.key} className=\"space-y-1.5\">\n <label className=\"text-sm font-medium\">\n {field.label}{field.required && <span className=\"text-red-500 ml-0.5\">*</span>}\n </label>\n {field.type === 'select' && field.options ? (\n <select\n className=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm\"\n value={(credValues[field.key] as string) ?? ''}\n onChange={(e) => setCredValues((prev) => ({ ...prev, [field.key]: e.target.value }))}\n >\n <option value=\"\">\u2014</option>\n {field.options.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n ) : field.type === 'boolean' ? (\n <Switch\n checked={Boolean(credValues[field.key])}\n onCheckedChange={(checked) => setCredValues((prev) => ({ ...prev, [field.key]: checked }))}\n />\n ) : (\n <Input\n type={field.type === 'secret' ? 'password' : 'text'}\n placeholder={field.placeholder}\n value={(credValues[field.key] as string) ?? ''}\n onChange={(e) => setCredValues((prev) => ({ ...prev, [field.key]: e.target.value }))}\n />\n )}\n </div>\n ))}\n <Button type=\"button\" onClick={() => void handleSaveCredentials()} disabled={isSavingCreds}>\n {isSavingCreds ? <Spinner className=\"mr-2 h-4 w-4\" /> : null}\n {t('integrations.detail.credentials.save')}\n </Button>\n </CardContent>\n </Card>\n )}\n\n <Card>\n <CardHeader>\n <div className=\"flex items-center justify-between\">\n <CardTitle>{t('integrations.bundle.integrationToggles')}</CardTitle>\n <div className=\"flex gap-2\">\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => void handleBulkToggle(true)}>\n {t('integrations.marketplace.enableAll')}\n </Button>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => void handleBulkToggle(false)}>\n {t('integrations.marketplace.disableAll')}\n </Button>\n </div>\n </div>\n </CardHeader>\n <CardContent>\n <div className=\"space-y-3\">\n {detail.bundleIntegrations.map((item) => (\n <div key={item.id} className=\"flex items-center justify-between rounded-lg border p-3\">\n <div>\n <Link\n href={`/backend/integrations/${encodeURIComponent(item.id)}`}\n className=\"text-sm font-medium hover:underline\"\n >\n {item.title}\n </Link>\n {item.category && (\n <Badge variant=\"secondary\" className=\"ml-2 text-xs\">{item.category}</Badge>\n )}\n {item.description && (\n <p className=\"text-xs text-muted-foreground mt-0.5\">{item.description}</p>\n )}\n </div>\n <div className=\"flex items-center gap-3\">\n <Button asChild variant=\"ghost\" size=\"sm\">\n <Link href={`/backend/integrations/${encodeURIComponent(item.id)}`}>\n {t('integrations.bundle.configureIntegration')}\n </Link>\n </Button>\n <Switch\n checked={item.isEnabled}\n disabled={togglingIds.has(item.id)}\n onCheckedChange={(checked) => void handleToggle(item.id, checked)}\n />\n </div>\n </div>\n ))}\n </div>\n </CardContent>\n </Card>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAkIwC,cAchC,YAdgC;AAjIxC,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,MAAM,YAAY,WAAW,mBAAmB;AACzD,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,YAAY;AAErB,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AA8Bd,SAAR,mBAAoC;AACzC,QAAM,SAAS,UAA0B;AACzC,QAAM,WAAW,OAAO;AACxB,QAAM,IAAI,KAAK;AAEf,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAA8B,IAAI;AACpE,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,IAAI;AACrD,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAwB,IAAI;AAC5D,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAkC,CAAC,CAAC;AAC9E,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,KAAK;AAC9D,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SA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C1D,WAAU;AAAA,cAET,eAAK;AAAA;AAAA,UACR;AAAA,UACC,KAAK,YACJ,oBAAC,SAAM,SAAQ,aAAY,WAAU,gBAAgB,eAAK,UAAS;AAAA,UAEpE,KAAK,eACJ,oBAAC,OAAE,WAAU,wCAAwC,eAAK,aAAY;AAAA,WAE1E;AAAA,QACA,qBAAC,SAAI,WAAU,2BACb;AAAA,8BAAC,UAAO,SAAO,MAAC,SAAQ,SAAQ,MAAK,MACnC,8BAAC,QAAK,MAAM,yBAAyB,mBAAmB,KAAK,EAAE,CAAC,IAC7D,YAAE,0CAA0C,GAC/C,GACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,SAAS,KAAK;AAAA,cACd,UAAU,YAAY,IAAI,KAAK,EAAE;AAAA,cACjC,iBAAiB,CAAC,YAAY,KAAK,aAAa,KAAK,IAAI,OAAO;AAAA;AAAA,UAClE;AAAA,WACF;AAAA,WA1BQ,KAAK,EA2Bf,CACD,GACH,GACF;AAAA,OACF;AAAA,KACF,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const metadata = {
|
|
2
|
+
requireAuth: true,
|
|
3
|
+
requireFeatures: ["integrations.view"],
|
|
4
|
+
pageContext: "settings",
|
|
5
|
+
pageTitle: "Bundle Configuration",
|
|
6
|
+
pageTitleKey: "integrations.bundle.title",
|
|
7
|
+
navHidden: true,
|
|
8
|
+
breadcrumb: [
|
|
9
|
+
{ label: "Integrations", labelKey: "integrations.nav.title", href: "/backend/integrations" }
|
|
10
|
+
]
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
metadata
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/integrations/backend/integrations/bundle/%5Bid%5D/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["export const metadata = {\n requireAuth: true,\n requireFeatures: ['integrations.view'],\n pageContext: 'settings' as const,\n pageTitle: 'Bundle Configuration',\n pageTitleKey: 'integrations.bundle.title',\n navHidden: true,\n breadcrumb: [\n { label: 'Integrations', labelKey: 'integrations.nav.title', href: '/backend/integrations' },\n ],\n}\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,mBAAmB;AAAA,EACrC,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,YAAY;AAAA,IACV,EAAE,OAAO,gBAAgB,UAAU,0BAA0B,MAAM,wBAAwB;AAAA,EAC7F;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
6
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@open-mercato/ui/primitives/card";
|
|
7
|
+
import { Badge } from "@open-mercato/ui/primitives/badge";
|
|
8
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
9
|
+
import { Switch } from "@open-mercato/ui/primitives/switch";
|
|
10
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
11
|
+
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
12
|
+
import { apiCall } from "@open-mercato/ui/backend/utils/apiCall";
|
|
13
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
14
|
+
import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
15
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
16
|
+
import {
|
|
17
|
+
LayoutGrid,
|
|
18
|
+
CreditCard,
|
|
19
|
+
Truck,
|
|
20
|
+
RefreshCw,
|
|
21
|
+
MessageSquare,
|
|
22
|
+
Bell,
|
|
23
|
+
HardDrive,
|
|
24
|
+
Webhook
|
|
25
|
+
} from "lucide-react";
|
|
26
|
+
const CATEGORY_ICONS = {
|
|
27
|
+
all: LayoutGrid,
|
|
28
|
+
payment: CreditCard,
|
|
29
|
+
shipping: Truck,
|
|
30
|
+
data_sync: RefreshCw,
|
|
31
|
+
communication: MessageSquare,
|
|
32
|
+
notification: Bell,
|
|
33
|
+
storage: HardDrive,
|
|
34
|
+
webhook: Webhook
|
|
35
|
+
};
|
|
36
|
+
const CATEGORIES = ["all", "payment", "shipping", "data_sync", "communication", "notification", "storage", "webhook"];
|
|
37
|
+
function categoryBadgeVariant(category) {
|
|
38
|
+
if (!category) return "outline";
|
|
39
|
+
return "secondary";
|
|
40
|
+
}
|
|
41
|
+
function IntegrationsMarketplacePage() {
|
|
42
|
+
const [data, setData] = React.useState(null);
|
|
43
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
44
|
+
const [search, setSearch] = React.useState("");
|
|
45
|
+
const [category, setCategory] = React.useState("all");
|
|
46
|
+
const [togglingIds, setTogglingIds] = React.useState(/* @__PURE__ */ new Set());
|
|
47
|
+
const scopeVersion = useOrganizationScopeVersion();
|
|
48
|
+
const t = useT();
|
|
49
|
+
const load = React.useCallback(async () => {
|
|
50
|
+
setIsLoading(true);
|
|
51
|
+
const fallback = { items: [], bundles: [] };
|
|
52
|
+
const call = await apiCall("/api/integrations", void 0, { fallback });
|
|
53
|
+
if (!call.ok) {
|
|
54
|
+
flash(t("integrations.marketplace.loadError"), "error");
|
|
55
|
+
setIsLoading(false);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
setData(call.result ?? fallback);
|
|
59
|
+
setIsLoading(false);
|
|
60
|
+
}, [t]);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
void load();
|
|
63
|
+
}, [load, scopeVersion]);
|
|
64
|
+
const handleToggle = React.useCallback(async (integrationId, enabled) => {
|
|
65
|
+
setTogglingIds((prev) => new Set(prev).add(integrationId));
|
|
66
|
+
const call = await apiCall(`/api/integrations/${encodeURIComponent(integrationId)}/state`, {
|
|
67
|
+
method: "PUT",
|
|
68
|
+
headers: { "Content-Type": "application/json" },
|
|
69
|
+
body: JSON.stringify({ isEnabled: enabled })
|
|
70
|
+
}, { fallback: null });
|
|
71
|
+
if (!call.ok) {
|
|
72
|
+
flash(t("integrations.detail.stateError"), "error");
|
|
73
|
+
} else {
|
|
74
|
+
setData((prev) => {
|
|
75
|
+
if (!prev) return prev;
|
|
76
|
+
return {
|
|
77
|
+
...prev,
|
|
78
|
+
items: prev.items.map(
|
|
79
|
+
(item) => item.id === integrationId ? { ...item, isEnabled: enabled } : item
|
|
80
|
+
)
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
setTogglingIds((prev) => {
|
|
85
|
+
const next = new Set(prev);
|
|
86
|
+
next.delete(integrationId);
|
|
87
|
+
return next;
|
|
88
|
+
});
|
|
89
|
+
}, [t]);
|
|
90
|
+
const filteredItems = React.useMemo(() => {
|
|
91
|
+
if (!data) return { bundles: [], standalone: [] };
|
|
92
|
+
let items = data.items;
|
|
93
|
+
if (search) {
|
|
94
|
+
const q = search.toLowerCase();
|
|
95
|
+
items = items.filter((item) => item.title.toLowerCase().includes(q) || item.description?.toLowerCase().includes(q));
|
|
96
|
+
}
|
|
97
|
+
if (category !== "all") {
|
|
98
|
+
items = items.filter((item) => item.category === category);
|
|
99
|
+
}
|
|
100
|
+
const bundled = /* @__PURE__ */ new Map();
|
|
101
|
+
const standalone = [];
|
|
102
|
+
for (const item of items) {
|
|
103
|
+
if (item.bundleId) {
|
|
104
|
+
const list = bundled.get(item.bundleId) ?? [];
|
|
105
|
+
list.push(item);
|
|
106
|
+
bundled.set(item.bundleId, list);
|
|
107
|
+
} else {
|
|
108
|
+
standalone.push(item);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const bundles = (data.bundles ?? []).filter((b) => bundled.has(b.id)).map((b) => ({ ...b, integrations: bundled.get(b.id) ?? [] }));
|
|
112
|
+
return { bundles, standalone };
|
|
113
|
+
}, [data, search, category]);
|
|
114
|
+
if (isLoading) {
|
|
115
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-16", children: /* @__PURE__ */ jsx(Spinner, {}) }) }) });
|
|
116
|
+
}
|
|
117
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { className: "space-y-6", children: /* @__PURE__ */ jsxs("section", { className: "space-y-6 rounded-lg border bg-background p-6", children: [
|
|
118
|
+
/* @__PURE__ */ jsx("header", { className: "flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
119
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: t("integrations.marketplace.title") }),
|
|
120
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("integrations.marketplace.description") })
|
|
121
|
+
] }) }),
|
|
122
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-center", children: [
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
Input,
|
|
125
|
+
{
|
|
126
|
+
placeholder: t("integrations.marketplace.search"),
|
|
127
|
+
value: search,
|
|
128
|
+
onChange: (e) => setSearch(e.target.value),
|
|
129
|
+
className: "max-w-sm"
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: CATEGORIES.map((cat) => {
|
|
133
|
+
const Icon = CATEGORY_ICONS[cat];
|
|
134
|
+
return /* @__PURE__ */ jsxs(
|
|
135
|
+
Button,
|
|
136
|
+
{
|
|
137
|
+
type: "button",
|
|
138
|
+
variant: category === cat ? "default" : "outline",
|
|
139
|
+
size: "sm",
|
|
140
|
+
onClick: () => setCategory(cat),
|
|
141
|
+
children: [
|
|
142
|
+
Icon ? /* @__PURE__ */ jsx(Icon, { className: "mr-1.5 h-3.5 w-3.5" }) : null,
|
|
143
|
+
t(`integrations.marketplace.categories.${cat}`)
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
cat
|
|
147
|
+
);
|
|
148
|
+
}) })
|
|
149
|
+
] }),
|
|
150
|
+
filteredItems.bundles.map((bundle) => /* @__PURE__ */ jsxs(Card, { children: [
|
|
151
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
152
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
153
|
+
/* @__PURE__ */ jsx(CardTitle, { children: bundle.title }),
|
|
154
|
+
bundle.description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm mt-1", children: bundle.description }),
|
|
155
|
+
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs mt-1", children: t("integrations.marketplace.integrations", { count: bundle.integrations.length }) })
|
|
156
|
+
] }),
|
|
157
|
+
/* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", size: "sm", children: /* @__PURE__ */ jsx(Link, { href: `/backend/integrations/bundle/${encodeURIComponent(bundle.id)}`, children: t("integrations.marketplace.configure") }) })
|
|
158
|
+
] }) }),
|
|
159
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3", children: bundle.integrations.map((item) => /* @__PURE__ */ jsxs(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
className: "flex items-center justify-between rounded-lg border p-3",
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
Link,
|
|
167
|
+
{
|
|
168
|
+
href: `/backend/integrations/${encodeURIComponent(item.id)}`,
|
|
169
|
+
className: "text-sm font-medium hover:underline",
|
|
170
|
+
children: item.title
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
item.category && /* @__PURE__ */ jsx(Badge, { variant: categoryBadgeVariant(item.category), className: "ml-2 text-xs", children: item.category })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
Switch,
|
|
177
|
+
{
|
|
178
|
+
checked: item.isEnabled,
|
|
179
|
+
disabled: togglingIds.has(item.id),
|
|
180
|
+
onCheckedChange: (checked) => void handleToggle(item.id, checked)
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
item.id
|
|
186
|
+
)) }) })
|
|
187
|
+
] }, bundle.id)),
|
|
188
|
+
filteredItems.standalone.length > 0 && /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: filteredItems.standalone.map((item) => /* @__PURE__ */ jsxs(Card, { className: "flex flex-col", children: [
|
|
189
|
+
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
190
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
191
|
+
/* @__PURE__ */ jsx(CardTitle, { className: "text-base", children: item.title }),
|
|
192
|
+
/* @__PURE__ */ jsx(
|
|
193
|
+
Switch,
|
|
194
|
+
{
|
|
195
|
+
checked: item.isEnabled,
|
|
196
|
+
disabled: togglingIds.has(item.id),
|
|
197
|
+
onCheckedChange: (checked) => void handleToggle(item.id, checked)
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
] }),
|
|
201
|
+
item.category && /* @__PURE__ */ jsx(Badge, { variant: categoryBadgeVariant(item.category), className: "w-fit text-xs", children: item.category })
|
|
202
|
+
] }),
|
|
203
|
+
/* @__PURE__ */ jsx(CardContent, { className: "flex-1", children: item.description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: item.description }) }),
|
|
204
|
+
/* @__PURE__ */ jsx("div", { className: "px-6 pb-4", children: /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "w-full", children: /* @__PURE__ */ jsx(Link, { href: `/backend/integrations/${encodeURIComponent(item.id)}`, children: t("integrations.marketplace.configure") }) }) })
|
|
205
|
+
] }, item.id)) }),
|
|
206
|
+
filteredItems.bundles.length === 0 && filteredItems.standalone.length === 0 && /* @__PURE__ */ jsx("div", { className: "text-center py-12 text-muted-foreground", children: t("integrations.marketplace.noResults") })
|
|
207
|
+
] }) }) });
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
IntegrationsMarketplacePage as default
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/integrations/backend/integrations/page.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport Link from 'next/link'\nimport { Page, PageBody } from '@open-mercato/ui/backend/Page'\nimport { Card, CardHeader, CardTitle, CardContent } from '@open-mercato/ui/primitives/card'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Switch } from '@open-mercato/ui/primitives/switch'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n LayoutGrid,\n CreditCard,\n Truck,\n RefreshCw,\n MessageSquare,\n Bell,\n HardDrive,\n Webhook,\n} from 'lucide-react'\n\ntype IntegrationItem = {\n id: string\n title: string\n description?: string\n category?: string\n icon?: string\n bundleId?: string\n isEnabled: boolean\n hasCredentials: boolean\n}\n\ntype BundleItem = {\n id: string\n title: string\n description?: string\n icon?: string\n integrationCount: number\n enabledCount: number\n}\n\ntype ListResponse = {\n items: IntegrationItem[]\n bundles: BundleItem[]\n}\n\nconst CATEGORY_ICONS: Record<string, React.ElementType> = {\n all: LayoutGrid,\n payment: CreditCard,\n shipping: Truck,\n data_sync: RefreshCw,\n communication: MessageSquare,\n notification: Bell,\n storage: HardDrive,\n webhook: Webhook,\n}\n\nconst CATEGORIES = ['all', 'payment', 'shipping', 'data_sync', 'communication', 'notification', 'storage', 'webhook'] as const\n\nfunction categoryBadgeVariant(category: string | undefined): 'default' | 'secondary' | 'outline' {\n if (!category) return 'outline'\n return 'secondary'\n}\n\nexport default function IntegrationsMarketplacePage() {\n const [data, setData] = React.useState<ListResponse | null>(null)\n const [isLoading, setIsLoading] = React.useState(true)\n const [search, setSearch] = React.useState('')\n const [category, setCategory] = React.useState<string>('all')\n const [togglingIds, setTogglingIds] = React.useState<Set<string>>(new Set())\n const scopeVersion = useOrganizationScopeVersion()\n const t = useT()\n\n const load = React.useCallback(async () => {\n setIsLoading(true)\n const fallback: ListResponse = { items: [], bundles: [] }\n const call = await apiCall<ListResponse>('/api/integrations', undefined, { fallback })\n if (!call.ok) {\n flash(t('integrations.marketplace.loadError'), 'error')\n setIsLoading(false)\n return\n }\n setData(call.result ?? fallback)\n setIsLoading(false)\n }, [t])\n\n React.useEffect(() => { void load() }, [load, scopeVersion])\n\n const handleToggle = React.useCallback(async (integrationId: string, enabled: boolean) => {\n setTogglingIds((prev) => new Set(prev).add(integrationId))\n const call = await apiCall(`/api/integrations/${encodeURIComponent(integrationId)}/state`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ isEnabled: enabled }),\n }, { fallback: null })\n\n if (!call.ok) {\n flash(t('integrations.detail.stateError'), 'error')\n } else {\n setData((prev) => {\n if (!prev) return prev\n return {\n ...prev,\n items: prev.items.map((item) =>\n item.id === integrationId ? { ...item, isEnabled: enabled } : item,\n ),\n }\n })\n }\n setTogglingIds((prev) => { const next = new Set(prev); next.delete(integrationId); return next })\n }, [t])\n\n const filteredItems = React.useMemo(() => {\n if (!data) return { bundles: [], standalone: [] }\n\n let items = data.items\n if (search) {\n const q = search.toLowerCase()\n items = items.filter((item) => item.title.toLowerCase().includes(q) || item.description?.toLowerCase().includes(q))\n }\n if (category !== 'all') {\n items = items.filter((item) => item.category === category)\n }\n\n const bundled = new Map<string, IntegrationItem[]>()\n const standalone: IntegrationItem[] = []\n for (const item of items) {\n if (item.bundleId) {\n const list = bundled.get(item.bundleId) ?? []\n list.push(item)\n bundled.set(item.bundleId, list)\n } else {\n standalone.push(item)\n }\n }\n\n const bundles = (data.bundles ?? [])\n .filter((b) => bundled.has(b.id))\n .map((b) => ({ ...b, integrations: bundled.get(b.id) ?? [] }))\n\n return { bundles, standalone }\n }, [data, search, category])\n\n if (isLoading) {\n return (\n <Page>\n <PageBody>\n <div className=\"flex items-center justify-center py-16\">\n <Spinner />\n </div>\n </PageBody>\n </Page>\n )\n }\n\n return (\n <Page>\n <PageBody className=\"space-y-6\">\n <section className=\"space-y-6 rounded-lg border bg-background p-6\">\n <header className=\"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between\">\n <div className=\"space-y-1\">\n <h2 className=\"text-lg font-semibold\">{t('integrations.marketplace.title')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('integrations.marketplace.description')}\n </p>\n </div>\n </header>\n\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center\">\n <Input\n placeholder={t('integrations.marketplace.search')}\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n className=\"max-w-sm\"\n />\n <div className=\"flex flex-wrap gap-1.5\">\n {CATEGORIES.map((cat) => {\n const Icon = CATEGORY_ICONS[cat]\n return (\n <Button\n key={cat}\n type=\"button\"\n variant={category === cat ? 'default' : 'outline'}\n size=\"sm\"\n onClick={() => setCategory(cat)}\n >\n {Icon ? <Icon className=\"mr-1.5 h-3.5 w-3.5\" /> : null}\n {t(`integrations.marketplace.categories.${cat}`)}\n </Button>\n )\n })}\n </div>\n </div>\n\n {filteredItems.bundles.map((bundle) => (\n <Card key={bundle.id}>\n <CardHeader>\n <div className=\"flex items-center justify-between\">\n <div>\n <CardTitle>{bundle.title}</CardTitle>\n {bundle.description && (\n <p className=\"text-muted-foreground text-sm mt-1\">{bundle.description}</p>\n )}\n <p className=\"text-muted-foreground text-xs mt-1\">\n {t('integrations.marketplace.integrations', { count: bundle.integrations.length })}\n </p>\n </div>\n <Button asChild variant=\"outline\" size=\"sm\">\n <Link href={`/backend/integrations/bundle/${encodeURIComponent(bundle.id)}`}>\n {t('integrations.marketplace.configure')}\n </Link>\n </Button>\n </div>\n </CardHeader>\n <CardContent>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3\">\n {bundle.integrations.map((item) => (\n <div\n key={item.id}\n className=\"flex items-center justify-between rounded-lg border p-3\"\n >\n <div className=\"min-w-0\">\n <Link\n href={`/backend/integrations/${encodeURIComponent(item.id)}`}\n className=\"text-sm font-medium hover:underline\"\n >\n {item.title}\n </Link>\n {item.category && (\n <Badge variant={categoryBadgeVariant(item.category)} className=\"ml-2 text-xs\">\n {item.category}\n </Badge>\n )}\n </div>\n <Switch\n checked={item.isEnabled}\n disabled={togglingIds.has(item.id)}\n onCheckedChange={(checked) => void handleToggle(item.id, checked)}\n />\n </div>\n ))}\n </div>\n </CardContent>\n </Card>\n ))}\n\n {filteredItems.standalone.length > 0 && (\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n {filteredItems.standalone.map((item) => (\n <Card key={item.id} className=\"flex flex-col\">\n <CardHeader>\n <div className=\"flex items-center justify-between\">\n <CardTitle className=\"text-base\">{item.title}</CardTitle>\n <Switch\n checked={item.isEnabled}\n disabled={togglingIds.has(item.id)}\n onCheckedChange={(checked) => void handleToggle(item.id, checked)}\n />\n </div>\n {item.category && (\n <Badge variant={categoryBadgeVariant(item.category)} className=\"w-fit text-xs\">\n {item.category}\n </Badge>\n )}\n </CardHeader>\n <CardContent className=\"flex-1\">\n {item.description && (\n <p className=\"text-muted-foreground text-sm\">{item.description}</p>\n )}\n </CardContent>\n <div className=\"px-6 pb-4\">\n <Button asChild variant=\"outline\" size=\"sm\" className=\"w-full\">\n <Link href={`/backend/integrations/${encodeURIComponent(item.id)}`}>\n {t('integrations.marketplace.configure')}\n </Link>\n </Button>\n </div>\n </Card>\n ))}\n </div>\n )}\n\n {filteredItems.bundles.length === 0 && filteredItems.standalone.length === 0 && (\n <div className=\"text-center py-12 text-muted-foreground\">\n {t('integrations.marketplace.noResults')}\n </div>\n )}\n </section>\n </PageBody>\n </Page>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAwJY,cAYA,YAZA;AAvJZ,YAAY,WAAW;AACvB,OAAO,UAAU;AACjB,SAAS,MAAM,gBAAgB;AAC/B,SAAS,MAAM,YAAY,WAAW,mBAAmB;AACzD,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,mCAAmC;AAC5C,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA2BP,MAAM,iBAAoD;AAAA,EACxD,KAAK;AAAA,EACL,SAAS;AAAA,EACT,UAAU;AAAA,EACV,WAAW;AAAA,EACX,eAAe;AAAA,EACf,cAAc;AAAA,EACd,SAAS;AAAA,EACT,SAAS;AACX;AAEA,MAAM,aAAa,CAAC,OAAO,WAAW,YAAY,aAAa,iBAAiB,gBAAgB,WAAW,SAAS;AAEpH,SAAS,qBAAqB,UAAmE;AAC/F,MAAI,CAAC,SAAU,QAAO;AACtB,SAAO;AACT;AAEe,SAA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8BAAC,aAAU,WAAU,aAAa,eAAK,OAAM;AAAA,UAC7C;AAAA,YAAC;AAAA;AAAA,cACC,SAAS,KAAK;AAAA,cACd,UAAU,YAAY,IAAI,KAAK,EAAE;AAAA,cACjC,iBAAiB,CAAC,YAAY,KAAK,aAAa,KAAK,IAAI,OAAO;AAAA;AAAA,UAClE;AAAA,WACF;AAAA,QACC,KAAK,YACJ,oBAAC,SAAM,SAAS,qBAAqB,KAAK,QAAQ,GAAG,WAAU,iBAC5D,eAAK,UACR;AAAA,SAEJ;AAAA,MACA,oBAAC,eAAY,WAAU,UACpB,eAAK,eACJ,oBAAC,OAAE,WAAU,iCAAiC,eAAK,aAAY,GAEnE;AAAA,MACA,oBAAC,SAAI,WAAU,aACb,8BAAC,UAAO,SAAO,MAAC,SAAQ,WAAU,MAAK,MAAK,WAAU,UACpD,8BAAC,QAAK,MAAM,yBAAyB,mBAAmB,KAAK,EAAE,CAAC,IAC7D,YAAE,oCAAoC,GACzC,GACF,GACF;AAAA,SA3BS,KAAK,EA4BhB,CACD,GACH;AAAA,IAGD,cAAc,QAAQ,WAAW,KAAK,cAAc,WAAW,WAAW,KACzE,oBAAC,SAAI,WAAU,2CACZ,YAAE,oCAAoC,GACzC;AAAA,KAEJ,GACF,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
const puzzleIcon = React.createElement(
|
|
3
|
+
"svg",
|
|
4
|
+
{ width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2 },
|
|
5
|
+
React.createElement("path", { d: "M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z" })
|
|
6
|
+
);
|
|
7
|
+
const metadata = {
|
|
8
|
+
requireAuth: true,
|
|
9
|
+
requireFeatures: ["integrations.view"],
|
|
10
|
+
pageTitle: "Integrations",
|
|
11
|
+
pageTitleKey: "integrations.nav.title",
|
|
12
|
+
pageGroup: "Settings",
|
|
13
|
+
pageGroupKey: "settings.sections.general",
|
|
14
|
+
pageOrder: 50,
|
|
15
|
+
icon: puzzleIcon,
|
|
16
|
+
pageContext: "settings",
|
|
17
|
+
breadcrumb: [{ label: "Integrations", labelKey: "integrations.nav.title" }]
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
metadata
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/integrations/backend/integrations/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["import React from 'react'\n\nconst puzzleIcon = React.createElement('svg', { width: 16, height: 16, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2 },\n React.createElement('path', { d: 'M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z' }),\n)\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['integrations.view'],\n pageTitle: 'Integrations',\n pageTitleKey: 'integrations.nav.title',\n pageGroup: 'Settings',\n pageGroupKey: 'settings.sections.general',\n pageOrder: 50,\n icon: puzzleIcon,\n pageContext: 'settings' as const,\n breadcrumb: [{ label: 'Integrations', labelKey: 'integrations.nav.title' }],\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB,MAAM,aAAa,MAAM;AAAA,EAAc;AAAA,EAAO,EAAE,OAAO,IAAI,QAAQ,IAAI,SAAS,aAAa,MAAM,QAAQ,QAAQ,gBAAgB,aAAa,EAAE;AAAA,EAChJ,MAAM,cAAc,QAAQ,EAAE,GAAG,s1BAAs1B,CAAC;AAC13B;AAEO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,mBAAmB;AAAA,EACrC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY,CAAC,EAAE,OAAO,gBAAgB,UAAU,yBAAyB,CAAC;AAC5E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
1
2
|
import { getIntegration } from "@open-mercato/shared/modules/integrations/types";
|
|
2
3
|
import { SyncExternalIdMapping } from "./entities.js";
|
|
3
4
|
function buildIntegrationData(mappings) {
|
|
@@ -25,12 +26,19 @@ const externalIdMappingEnricher = {
|
|
|
25
26
|
const em = context.em.fork();
|
|
26
27
|
const targetEntity = context.targetEntity;
|
|
27
28
|
if (!targetEntity) return { ...record, _integrations: {} };
|
|
28
|
-
const mappings = await
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const mappings = await findWithDecryption(
|
|
30
|
+
em,
|
|
31
|
+
SyncExternalIdMapping,
|
|
32
|
+
{
|
|
33
|
+
internalEntityType: targetEntity,
|
|
34
|
+
internalEntityId: record.id,
|
|
35
|
+
organizationId: context.organizationId,
|
|
36
|
+
tenantId: context.tenantId,
|
|
37
|
+
deletedAt: null
|
|
38
|
+
},
|
|
39
|
+
void 0,
|
|
40
|
+
{ organizationId: context.organizationId, tenantId: context.tenantId }
|
|
41
|
+
);
|
|
34
42
|
if (mappings.length === 0) return { ...record, _integrations: {} };
|
|
35
43
|
return {
|
|
36
44
|
...record,
|
|
@@ -42,12 +50,19 @@ const externalIdMappingEnricher = {
|
|
|
42
50
|
const targetEntity = context.targetEntity;
|
|
43
51
|
if (!targetEntity || records.length === 0) return records.map((r) => ({ ...r, _integrations: {} }));
|
|
44
52
|
const recordIds = records.map((r) => r.id);
|
|
45
|
-
const allMappings = await
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const allMappings = await findWithDecryption(
|
|
54
|
+
em,
|
|
55
|
+
SyncExternalIdMapping,
|
|
56
|
+
{
|
|
57
|
+
internalEntityType: targetEntity,
|
|
58
|
+
internalEntityId: { $in: recordIds },
|
|
59
|
+
organizationId: context.organizationId,
|
|
60
|
+
tenantId: context.tenantId,
|
|
61
|
+
deletedAt: null
|
|
62
|
+
},
|
|
63
|
+
void 0,
|
|
64
|
+
{ organizationId: context.organizationId, tenantId: context.tenantId }
|
|
65
|
+
);
|
|
51
66
|
if (allMappings.length === 0) return records.map((r) => ({ ...r, _integrations: {} }));
|
|
52
67
|
const mappingsByRecord = /* @__PURE__ */ new Map();
|
|
53
68
|
for (const mapping of allMappings) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/integrations/data/enrichers.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External ID Mapping Enricher\n *\n * Enriches any entity's API response with external integration ID mappings.\n * Adds `_integrations` namespace containing all external IDs for the record.\n *\n * Uses batch queries via `enrichMany` to prevent N+1.\n */\n\nimport type { ResponseEnricher, EnricherContext } from '@open-mercato/shared/lib/crud/response-enricher'\nimport type { ExternalIdEnrichment } from '@open-mercato/shared/modules/integrations/types'\nimport { getIntegration } from '@open-mercato/shared/modules/integrations/types'\nimport { SyncExternalIdMapping } from './entities'\n\ntype EntityRecord = Record<string, unknown> & { id: string }\n\nfunction buildIntegrationData(\n mappings: SyncExternalIdMapping[],\n): ExternalIdEnrichment['_integrations'] {\n const data: ExternalIdEnrichment['_integrations'] = {}\n\n for (const mapping of mappings) {\n const definition = getIntegration(mapping.integrationId)\n data[mapping.integrationId] = {\n externalId: mapping.externalId,\n externalUrl: definition?.buildExternalUrl?.(mapping.externalId),\n lastSyncedAt: mapping.lastSyncedAt?.toISOString(),\n syncStatus: mapping.syncStatus,\n }\n }\n\n return data\n}\n\nconst externalIdMappingEnricher: ResponseEnricher<EntityRecord, ExternalIdEnrichment> = {\n id: 'integrations.external-id-mapping',\n targetEntity: '*',\n features: ['integrations.view'],\n priority: 10,\n timeout: 500,\n critical: false,\n fallback: {},\n\n async enrichOne(record, context:
|
|
5
|
-
"mappings": "AAWA,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;
|
|
4
|
+
"sourcesContent": ["/**\n * External ID Mapping Enricher\n *\n * Enriches any entity's API response with external integration ID mappings.\n * Adds `_integrations` namespace containing all external IDs for the record.\n *\n * Uses batch queries via `enrichMany` to prevent N+1.\n */\n\nimport type { ResponseEnricher, EnricherContext } from '@open-mercato/shared/lib/crud/response-enricher'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport type { ExternalIdEnrichment } from '@open-mercato/shared/modules/integrations/types'\nimport { getIntegration } from '@open-mercato/shared/modules/integrations/types'\nimport { SyncExternalIdMapping } from './entities'\n\ntype EntityRecord = Record<string, unknown> & { id: string }\ntype EnricherScope = EnricherContext & { targetEntity?: string; em: EntityManager }\n\nfunction buildIntegrationData(\n mappings: SyncExternalIdMapping[],\n): ExternalIdEnrichment['_integrations'] {\n const data: ExternalIdEnrichment['_integrations'] = {}\n\n for (const mapping of mappings) {\n const definition = getIntegration(mapping.integrationId)\n data[mapping.integrationId] = {\n externalId: mapping.externalId,\n externalUrl: definition?.buildExternalUrl?.(mapping.externalId),\n lastSyncedAt: mapping.lastSyncedAt?.toISOString(),\n syncStatus: mapping.syncStatus,\n }\n }\n\n return data\n}\n\nconst externalIdMappingEnricher: ResponseEnricher<EntityRecord, ExternalIdEnrichment> = {\n id: 'integrations.external-id-mapping',\n targetEntity: '*',\n features: ['integrations.view'],\n priority: 10,\n timeout: 500,\n critical: false,\n fallback: {},\n\n async enrichOne(record, context: EnricherScope) {\n const em = context.em.fork()\n const targetEntity = context.targetEntity\n if (!targetEntity) return { ...record, _integrations: {} }\n\n const mappings = await findWithDecryption(\n em,\n SyncExternalIdMapping,\n {\n internalEntityType: targetEntity,\n internalEntityId: record.id,\n organizationId: context.organizationId,\n tenantId: context.tenantId,\n deletedAt: null,\n },\n undefined,\n { organizationId: context.organizationId, tenantId: context.tenantId },\n )\n\n if (mappings.length === 0) return { ...record, _integrations: {} }\n\n return {\n ...record,\n _integrations: buildIntegrationData(mappings),\n }\n },\n\n async enrichMany(records, context: EnricherScope) {\n const em = context.em.fork()\n const targetEntity = context.targetEntity\n if (!targetEntity || records.length === 0) return records.map((r) => ({ ...r, _integrations: {} }))\n\n const recordIds = records.map((r) => r.id)\n const allMappings = await findWithDecryption(\n em,\n SyncExternalIdMapping,\n {\n internalEntityType: targetEntity,\n internalEntityId: { $in: recordIds },\n organizationId: context.organizationId,\n tenantId: context.tenantId,\n deletedAt: null,\n },\n undefined,\n { organizationId: context.organizationId, tenantId: context.tenantId },\n )\n\n if (allMappings.length === 0) return records.map((r) => ({ ...r, _integrations: {} }))\n\n const mappingsByRecord = new Map<string, SyncExternalIdMapping[]>()\n for (const mapping of allMappings) {\n const list = mappingsByRecord.get(mapping.internalEntityId) ?? []\n list.push(mapping)\n mappingsByRecord.set(mapping.internalEntityId, list)\n }\n\n return records.map((record) => {\n const mappings = mappingsByRecord.get(record.id)\n if (!mappings || mappings.length === 0) return { ...record, _integrations: {} }\n\n return {\n ...record,\n _integrations: buildIntegrationData(mappings),\n }\n })\n },\n}\n\nexport const enrichers: ResponseEnricher[] = [externalIdMappingEnricher]\n"],
|
|
5
|
+
"mappings": "AAWA,SAAS,0BAA0B;AAEnC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAKtC,SAAS,qBACP,UACuC;AACvC,QAAM,OAA8C,CAAC;AAErD,aAAW,WAAW,UAAU;AAC9B,UAAM,aAAa,eAAe,QAAQ,aAAa;AACvD,SAAK,QAAQ,aAAa,IAAI;AAAA,MAC5B,YAAY,QAAQ;AAAA,MACpB,aAAa,YAAY,mBAAmB,QAAQ,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A,QACpB,kBAAkB,EAAE,KAAK,UAAU;AAAA,QACnC,gBAAgB,QAAQ;AAAA,QACxB,UAAU,QAAQ;AAAA,QAClB,WAAW;AAAA,MACb;AAAA,MACA;AAAA,MACA,EAAE,gBAAgB,QAAQ,gBAAgB,UAAU,QAAQ,SAAS;AAAA,IACvE;AAEA,QAAI,YAAY,WAAW,EAAG,QAAO,QAAQ,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,eAAe,CAAC,EAAE,EAAE;AAErF,UAAM,mBAAmB,oBAAI,IAAqC;AAClE,eAAW,WAAW,aAAa;AACjC,YAAM,OAAO,iBAAiB,IAAI,QAAQ,gBAAgB,KAAK,CAAC;AAChE,WAAK,KAAK,OAAO;AACjB,uBAAiB,IAAI,QAAQ,kBAAkB,IAAI;AAAA,IACrD;AAEA,WAAO,QAAQ,IAAI,CAAC,WAAW;AAC7B,YAAM,WAAW,iBAAiB,IAAI,OAAO,EAAE;AAC/C,UAAI,CAAC,YAAY,SAAS,WAAW,EAAG,QAAO,EAAE,GAAG,QAAQ,eAAe,CAAC,EAAE;AAE9E,aAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe,qBAAqB,QAAQ;AAAA,MAC9C;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,YAAgC,CAAC,yBAAyB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,8 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
8
8
|
if (kind && result) __defProp(target, key, result);
|
|
9
9
|
return result;
|
|
10
10
|
};
|
|
11
|
-
import { Entity, PrimaryKey, Property, Index } from "@mikro-orm/core";
|
|
11
|
+
import { Entity, PrimaryKey, Property, Index, OptionalProps } from "@mikro-orm/core";
|
|
12
|
+
OptionalProps;
|
|
12
13
|
let SyncExternalIdMapping = class {
|
|
13
14
|
constructor() {
|
|
14
15
|
this.syncStatus = "not_synced";
|
|
@@ -57,7 +58,141 @@ SyncExternalIdMapping = __decorateClass([
|
|
|
57
58
|
Index({ properties: ["internalEntityType", "internalEntityId", "organizationId"] }),
|
|
58
59
|
Index({ properties: ["integrationId", "externalId", "organizationId"] })
|
|
59
60
|
], SyncExternalIdMapping);
|
|
61
|
+
OptionalProps;
|
|
62
|
+
let IntegrationCredentials = class {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
65
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
__decorateClass([
|
|
69
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
70
|
+
], IntegrationCredentials.prototype, "id", 2);
|
|
71
|
+
__decorateClass([
|
|
72
|
+
Property({ name: "integration_id", type: "text" })
|
|
73
|
+
], IntegrationCredentials.prototype, "integrationId", 2);
|
|
74
|
+
__decorateClass([
|
|
75
|
+
Property({ name: "credentials", type: "json" })
|
|
76
|
+
], IntegrationCredentials.prototype, "credentials", 2);
|
|
77
|
+
__decorateClass([
|
|
78
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
79
|
+
], IntegrationCredentials.prototype, "organizationId", 2);
|
|
80
|
+
__decorateClass([
|
|
81
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
82
|
+
], IntegrationCredentials.prototype, "tenantId", 2);
|
|
83
|
+
__decorateClass([
|
|
84
|
+
Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
|
|
85
|
+
], IntegrationCredentials.prototype, "createdAt", 2);
|
|
86
|
+
__decorateClass([
|
|
87
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
88
|
+
], IntegrationCredentials.prototype, "updatedAt", 2);
|
|
89
|
+
__decorateClass([
|
|
90
|
+
Property({ name: "deleted_at", type: Date, nullable: true })
|
|
91
|
+
], IntegrationCredentials.prototype, "deletedAt", 2);
|
|
92
|
+
IntegrationCredentials = __decorateClass([
|
|
93
|
+
Entity({ tableName: "integration_credentials" }),
|
|
94
|
+
Index({ properties: ["integrationId", "organizationId", "tenantId"] })
|
|
95
|
+
], IntegrationCredentials);
|
|
96
|
+
OptionalProps;
|
|
97
|
+
let IntegrationState = class {
|
|
98
|
+
constructor() {
|
|
99
|
+
this.isEnabled = true;
|
|
100
|
+
this.reauthRequired = false;
|
|
101
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
102
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
__decorateClass([
|
|
106
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
107
|
+
], IntegrationState.prototype, "id", 2);
|
|
108
|
+
__decorateClass([
|
|
109
|
+
Property({ name: "integration_id", type: "text" })
|
|
110
|
+
], IntegrationState.prototype, "integrationId", 2);
|
|
111
|
+
__decorateClass([
|
|
112
|
+
Property({ name: "is_enabled", type: "boolean", default: true })
|
|
113
|
+
], IntegrationState.prototype, "isEnabled", 2);
|
|
114
|
+
__decorateClass([
|
|
115
|
+
Property({ name: "api_version", type: "text", nullable: true })
|
|
116
|
+
], IntegrationState.prototype, "apiVersion", 2);
|
|
117
|
+
__decorateClass([
|
|
118
|
+
Property({ name: "reauth_required", type: "boolean", default: false })
|
|
119
|
+
], IntegrationState.prototype, "reauthRequired", 2);
|
|
120
|
+
__decorateClass([
|
|
121
|
+
Property({ name: "last_health_status", type: "text", nullable: true })
|
|
122
|
+
], IntegrationState.prototype, "lastHealthStatus", 2);
|
|
123
|
+
__decorateClass([
|
|
124
|
+
Property({ name: "last_health_checked_at", type: Date, nullable: true })
|
|
125
|
+
], IntegrationState.prototype, "lastHealthCheckedAt", 2);
|
|
126
|
+
__decorateClass([
|
|
127
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
128
|
+
], IntegrationState.prototype, "organizationId", 2);
|
|
129
|
+
__decorateClass([
|
|
130
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
131
|
+
], IntegrationState.prototype, "tenantId", 2);
|
|
132
|
+
__decorateClass([
|
|
133
|
+
Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
|
|
134
|
+
], IntegrationState.prototype, "createdAt", 2);
|
|
135
|
+
__decorateClass([
|
|
136
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
137
|
+
], IntegrationState.prototype, "updatedAt", 2);
|
|
138
|
+
__decorateClass([
|
|
139
|
+
Property({ name: "deleted_at", type: Date, nullable: true })
|
|
140
|
+
], IntegrationState.prototype, "deletedAt", 2);
|
|
141
|
+
IntegrationState = __decorateClass([
|
|
142
|
+
Entity({ tableName: "integration_states" }),
|
|
143
|
+
Index({ properties: ["integrationId", "organizationId", "tenantId"] })
|
|
144
|
+
], IntegrationState);
|
|
145
|
+
OptionalProps;
|
|
146
|
+
let IntegrationLog = class {
|
|
147
|
+
constructor() {
|
|
148
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
__decorateClass([
|
|
152
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
153
|
+
], IntegrationLog.prototype, "id", 2);
|
|
154
|
+
__decorateClass([
|
|
155
|
+
Property({ name: "integration_id", type: "text" })
|
|
156
|
+
], IntegrationLog.prototype, "integrationId", 2);
|
|
157
|
+
__decorateClass([
|
|
158
|
+
Property({ name: "run_id", type: "uuid", nullable: true })
|
|
159
|
+
], IntegrationLog.prototype, "runId", 2);
|
|
160
|
+
__decorateClass([
|
|
161
|
+
Property({ name: "scope_entity_type", type: "text", nullable: true })
|
|
162
|
+
], IntegrationLog.prototype, "scopeEntityType", 2);
|
|
163
|
+
__decorateClass([
|
|
164
|
+
Property({ name: "scope_entity_id", type: "uuid", nullable: true })
|
|
165
|
+
], IntegrationLog.prototype, "scopeEntityId", 2);
|
|
166
|
+
__decorateClass([
|
|
167
|
+
Property({ name: "level", type: "text" })
|
|
168
|
+
], IntegrationLog.prototype, "level", 2);
|
|
169
|
+
__decorateClass([
|
|
170
|
+
Property({ name: "message", type: "text" })
|
|
171
|
+
], IntegrationLog.prototype, "message", 2);
|
|
172
|
+
__decorateClass([
|
|
173
|
+
Property({ name: "code", type: "text", nullable: true })
|
|
174
|
+
], IntegrationLog.prototype, "code", 2);
|
|
175
|
+
__decorateClass([
|
|
176
|
+
Property({ name: "payload", type: "json", nullable: true })
|
|
177
|
+
], IntegrationLog.prototype, "payload", 2);
|
|
178
|
+
__decorateClass([
|
|
179
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
180
|
+
], IntegrationLog.prototype, "organizationId", 2);
|
|
181
|
+
__decorateClass([
|
|
182
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
183
|
+
], IntegrationLog.prototype, "tenantId", 2);
|
|
184
|
+
__decorateClass([
|
|
185
|
+
Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
|
|
186
|
+
], IntegrationLog.prototype, "createdAt", 2);
|
|
187
|
+
IntegrationLog = __decorateClass([
|
|
188
|
+
Entity({ tableName: "integration_logs" }),
|
|
189
|
+
Index({ properties: ["integrationId", "organizationId", "tenantId", "createdAt"] }),
|
|
190
|
+
Index({ properties: ["level", "organizationId", "tenantId", "createdAt"] })
|
|
191
|
+
], IntegrationLog);
|
|
60
192
|
export {
|
|
193
|
+
IntegrationCredentials,
|
|
194
|
+
IntegrationLog,
|
|
195
|
+
IntegrationState,
|
|
61
196
|
SyncExternalIdMapping
|
|
62
197
|
};
|
|
63
198
|
//# sourceMappingURL=entities.js.map
|