Integrations now have a setupStatus and can be missing fields
This commit is contained in:
@@ -36,6 +36,7 @@ export class IntegrationsPresenter {
|
||||
title: true,
|
||||
slug: true,
|
||||
description: true,
|
||||
setupStatus: true,
|
||||
authMethod: {
|
||||
select: {
|
||||
type: true,
|
||||
@@ -123,13 +124,16 @@ export class IntegrationsPresenter {
|
||||
name: c.authMethod?.name ?? "Local Only",
|
||||
},
|
||||
authSource: c.authSource,
|
||||
setupStatus: c.setupStatus,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
//filter out the ones that have no connections
|
||||
const clientsWithConnections = enrichedClients.filter(
|
||||
(c) => c.authSource === "LOCAL" || c.connectionsCount > 0
|
||||
const setupClients = enrichedClients.filter(
|
||||
(c) => c.setupStatus === "COMPLETE"
|
||||
);
|
||||
const clientMissingFields = enrichedClients.filter(
|
||||
(c) => c.setupStatus === "MISSING_FIELDS"
|
||||
);
|
||||
|
||||
const integrations = Object.values(
|
||||
@@ -160,9 +164,10 @@ export class IntegrationsPresenter {
|
||||
);
|
||||
|
||||
return {
|
||||
clients: clientsWithConnections,
|
||||
clients: setupClients,
|
||||
clientMissingFields,
|
||||
options,
|
||||
callbackUrl: `${env.APP_ORIGIN}/oauth2/callback`
|
||||
callbackUrl: `${env.APP_ORIGIN}/oauth2/callback`,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +118,32 @@ export class RegisterJobService {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// TODO: find a better way to handle and message the user about this issue
|
||||
throw new Error(
|
||||
`Could not find Integration with id ${jobIntegration.id}`
|
||||
);
|
||||
integration = await this.#prismaClient.integration.create({
|
||||
data: {
|
||||
slug: jobIntegration.id,
|
||||
title: jobIntegration.metadata.name,
|
||||
authSource: "HOSTED",
|
||||
setupStatus: "MISSING_FIELDS",
|
||||
connectionType: "DEVELOPER",
|
||||
organization: {
|
||||
connect: {
|
||||
id: environment.organizationId,
|
||||
},
|
||||
},
|
||||
definition: {
|
||||
connectOrCreate: {
|
||||
where: {
|
||||
id: jobIntegration.metadata.id,
|
||||
},
|
||||
create: {
|
||||
id: jobIntegration.metadata.id,
|
||||
name: jobIntegration.metadata.name,
|
||||
instructions: jobIntegration.metadata.instructions,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "IntegrationSetupStatus" AS ENUM ('MISSING_FIELDS', 'COMPLETE');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Integration" ADD COLUMN "setupStatus" "IntegrationSetupStatus" NOT NULL DEFAULT 'COMPLETE';
|
||||
@@ -132,6 +132,7 @@ model Integration {
|
||||
title String?
|
||||
description String?
|
||||
|
||||
setupStatus IntegrationSetupStatus @default(COMPLETE)
|
||||
authSource IntegrationAuthSource @default(HOSTED)
|
||||
|
||||
definition IntegrationDefinition @relation(fields: [definitionId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
||||
@@ -168,6 +169,11 @@ enum IntegrationAuthSource {
|
||||
LOCAL
|
||||
}
|
||||
|
||||
enum IntegrationSetupStatus {
|
||||
MISSING_FIELDS
|
||||
COMPLETE
|
||||
}
|
||||
|
||||
model IntegrationConnection {
|
||||
id String @id @default(cuid())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user