feat: new importer (#214)

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-05 09:49:36 +01:00
committed by GitHub
parent b51bc8f3f6
commit 212254d31a
80 changed files with 4884 additions and 842 deletions

View File

@@ -435,3 +435,54 @@ export const zEditOrganization = z.object({
name: z.string().min(2),
timezone: z.string().min(1),
});
const zProjectMapper = z.object({
from: z.string().min(1),
to: z.string().min(1),
});
const createFileImportConfig = <T extends string>(provider: T) =>
z.object({
provider: z.literal(provider),
type: z.literal('file'),
fileUrl: z.string().url(),
});
// Import configs
export const zUmamiImportConfig = createFileImportConfig('umami').extend({
projectMapper: z.array(zProjectMapper),
});
export type IUmamiImportConfig = z.infer<typeof zUmamiImportConfig>;
export const zPlausibleImportConfig = createFileImportConfig('plausible');
export type IPlausibleImportConfig = z.infer<typeof zPlausibleImportConfig>;
export const zMixpanelImportConfig = z.object({
provider: z.literal('mixpanel'),
type: z.literal('api'),
serviceAccount: z.string().min(1),
serviceSecret: z.string().min(1),
projectId: z.string().min(1),
from: z.string().min(1),
to: z.string().min(1),
mapScreenViewProperty: z.string().optional(),
});
export type IMixpanelImportConfig = z.infer<typeof zMixpanelImportConfig>;
export type IImportConfig =
| IUmamiImportConfig
| IPlausibleImportConfig
| IMixpanelImportConfig;
export const zCreateImport = z.object({
projectId: z.string().min(1),
provider: z.enum(['umami', 'plausible', 'mixpanel']),
config: z.union([
zUmamiImportConfig,
zPlausibleImportConfig,
zMixpanelImportConfig,
]),
});
export type ICreateImport = z.infer<typeof zCreateImport>;