Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/integrations/src/catalog-seed.ts
T
2026-07-08 16:15:37 +02:00

40 lines
1.5 KiB
TypeScript

// R-P5 — pure builders for the App catalog seed (INTEGRATION_CATALOG -> global
// `App` definition table). No Prisma/node imports: the caller (db seed) runs the
// actual upserts, so this stays importable everywhere and unit-testable. The
// tenant runtime keeps reading the code catalog (DataConnection.appId = bare
// catalog key, AD-21 — no App FK); the table exists as the global definition/
// drift surface.
import { INTEGRATION_CATALOG, type AppCatalogEntry } from "./catalog.js";
/** Prisma-shaped payload for one `App` upsert (create/update identical). */
export interface AppUpsertData {
readonly key: string;
/** i18n key of the display name (App.title carries the key, M003). */
readonly title: string;
readonly category: AppCatalogEntry["category"];
readonly connectionType: AppCatalogEntry["connectionType"];
readonly connectionSchema: { readonly fields: AppCatalogEntry["connectionSchema"]["fields"] };
readonly phase: string | null;
readonly icon: string | null;
readonly isActive: boolean;
}
export function buildAppUpsertData(entry: AppCatalogEntry): AppUpsertData {
return {
key: entry.key,
title: entry.titleKey,
category: entry.category,
connectionType: entry.connectionType,
connectionSchema: { fields: entry.connectionSchema.fields },
phase: entry.phase ?? null,
icon: entry.icon ?? null,
isActive: true,
};
}
/** One upsert payload per catalog entry (idempotent by unique `key`). */
export function buildCatalogSeedPlan(): AppUpsertData[] {
return INTEGRATION_CATALOG.map(buildAppUpsertData);
}