-
Notifications
You must be signed in to change notification settings - Fork 305
feat: device import from integrations #2802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b9e7188
31975ff
4602f99
8a87d91
7adc931
6c44c18
6b1456f
59c57df
7e1b680
601f70a
f4148b7
a632419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,11 @@ export class DynamicIntegrationsController { | |
| ? SyncDefinitionSchema.parse(rawSyncDef) | ||
| : undefined; | ||
|
|
||
| const rawDeviceSyncDef = body.deviceSyncDefinition; | ||
| const validatedDeviceSyncDef = rawDeviceSyncDef | ||
| ? SyncDefinitionSchema.parse(rawDeviceSyncDef) | ||
| : undefined; | ||
|
|
||
| // Upsert the integration | ||
| const integration = await this.dynamicIntegrationRepo.upsertBySlug({ | ||
| slug: def.slug, | ||
|
|
@@ -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, | ||
| }); | ||
|
|
||
|
|
@@ -167,6 +177,12 @@ export class DynamicIntegrationsController { | |
| const validatedSyncDefCreate = rawSyncDefCreate | ||
| ? SyncDefinitionSchema.parse(rawSyncDefCreate) | ||
| : undefined; | ||
|
|
||
| const rawDeviceSyncDefCreate = body.deviceSyncDefinition; | ||
| const validatedDeviceSyncDefCreate = rawDeviceSyncDefCreate | ||
| ? SyncDefinitionSchema.parse(rawDeviceSyncDefCreate) | ||
This comment was marked as resolved.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above — follows the existing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! I already have a similar learning that covers this, so I'm keeping the existing one. |
||
| : undefined; | ||
|
|
||
| const integration = await this.dynamicIntegrationRepo.create({ | ||
| slug: def.slug, | ||
| name: def.name, | ||
|
|
@@ -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()) { | ||
|
|
||
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally matches the existing
syncDefinitionvalidation pattern on the line above, which also usesparse. Changing only the device variant tosafeParsewould be inconsistent — both should be changed together in a separate cleanup.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I've saved this as a new learning to improve future reviews.