Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export class DynamicIntegrationsController {
? SyncDefinitionSchema.parse(rawSyncDef)
: undefined;

const rawDeviceSyncDef = body.deviceSyncDefinition;
const validatedDeviceSyncDef = rawDeviceSyncDef
? SyncDefinitionSchema.parse(rawDeviceSyncDef)
Comment thread
Marfuen marked this conversation as resolved.
: undefined;

// Upsert the integration
const integration = await this.dynamicIntegrationRepo.upsertBySlug({
slug: def.slug,
Expand All @@ -83,6 +88,11 @@ export class DynamicIntegrationsController {
JSON.stringify(validatedSyncDef),
) as Prisma.InputJsonValue)
: null,
deviceSyncDefinition: validatedDeviceSyncDef
? (JSON.parse(
JSON.stringify(validatedDeviceSyncDef),
) as Prisma.InputJsonValue)
: null,
services: (def.services as unknown as Prisma.InputJsonValue) ?? undefined,
});

Expand Down Expand Up @@ -167,6 +177,12 @@ export class DynamicIntegrationsController {
const validatedSyncDefCreate = rawSyncDefCreate
? SyncDefinitionSchema.parse(rawSyncDefCreate)
: undefined;

const rawDeviceSyncDefCreate = body.deviceSyncDefinition;
const validatedDeviceSyncDefCreate = rawDeviceSyncDefCreate
? SyncDefinitionSchema.parse(rawDeviceSyncDefCreate)
Comment thread
Marfuen marked this conversation as resolved.
: undefined;

const integration = await this.dynamicIntegrationRepo.create({
slug: def.slug,
name: def.name,
Expand All @@ -184,6 +200,11 @@ export class DynamicIntegrationsController {
JSON.stringify(validatedSyncDefCreate),
) as Prisma.InputJsonValue)
: undefined,
deviceSyncDefinition: validatedDeviceSyncDefCreate
? (JSON.parse(
JSON.stringify(validatedDeviceSyncDefCreate),
) as Prisma.InputJsonValue)
: undefined,
});

for (const [index, check] of def.checks.entries()) {
Expand Down
Loading
Loading