diff --git a/__tests__/prompts.ts b/__tests__/prompts.ts deleted file mode 100644 index bf958ad801..0000000000 --- a/__tests__/prompts.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { DataSource } from 'typeorm'; -import createOrGetConnection from '../src/db'; -import { - disposeGraphQLTesting, - GraphQLTestClient, - GraphQLTestingState, - initializeGraphQLTesting, - MockContext, -} from './helpers'; -import { Prompt } from '../src/entity/Prompt'; - -let con: DataSource; -let state: GraphQLTestingState; -let client: GraphQLTestClient; -let loggedUser: string = null; - -beforeAll(async () => { - con = await createOrGetConnection(); - state = await initializeGraphQLTesting( - () => new MockContext(con, loggedUser), - ); - client = state.client; -}); - -afterAll(() => disposeGraphQLTesting(state)); - -beforeEach(async () => { - loggedUser = null; - - await con.getRepository(Prompt).save([ - { - id: 'prompt1', - order: 1, - label: 'label1', - description: 'description1', - prompt: 'prompt1', - flags: { icon: 'icon1', color: 'color1' }, - }, - { - id: 'prompt2', - order: 2, - label: 'label2', - description: 'description2', - prompt: 'prompt2', - flags: { icon: 'icon2', color: 'color2' }, - }, - { - id: 'prompt3', - order: 3, - label: 'label3', - description: 'description3', - prompt: 'prompt3', - flags: { icon: 'icon3', color: 'color3' }, - }, - ]); -}); - -describe('query prompts', () => { - const QUERY = `{ - prompts { - id - label - description - flags { - icon - color - } - } - }`; - - it('should return all prompts in order', async () => { - const res = await client.query(QUERY); - - expect(res.data.prompts).toEqual([ - { - id: 'prompt1', - label: 'label1', - description: 'description1', - flags: { icon: 'icon1', color: 'color1' }, - }, - { - id: 'prompt2', - label: 'label2', - description: 'description2', - flags: { icon: 'icon2', color: 'color2' }, - }, - { - id: 'prompt3', - label: 'label3', - description: 'description3', - flags: { icon: 'icon3', color: 'color3' }, - }, - ]); - }); -}); diff --git a/src/entity/Settings.ts b/src/entity/Settings.ts index d2848e8e38..11fc96cfca 100644 --- a/src/entity/Settings.ts +++ b/src/entity/Settings.ts @@ -37,7 +37,6 @@ export type SettingsFlags = Partial<{ browsingContextEnabled: boolean; prompt: object; timezoneMismatchIgnore: string; - lastPrompt: string; defaultWriteTab: DefaultWriteTab; }>; @@ -53,7 +52,6 @@ export type SettingsFlagsPublic = Pick< | 'browsingContextEnabled' | 'prompt' | 'timezoneMismatchIgnore' - | 'lastPrompt' | 'defaultWriteTab' >; diff --git a/src/graphorm/index.ts b/src/graphorm/index.ts index e5c540f3e7..b9032039c0 100644 --- a/src/graphorm/index.ts +++ b/src/graphorm/index.ts @@ -1483,13 +1483,6 @@ const obj = new GraphORM({ }, }, }, - Prompt: { - fields: { - flags: { - jsonType: true, - }, - }, - }, Product: { fields: { flags: { diff --git a/src/graphql.ts b/src/graphql.ts index be67ca61eb..6ef32f4a81 100644 --- a/src/graphql.ts +++ b/src/graphql.ts @@ -25,7 +25,6 @@ import * as urlDirective from './directive/url'; import * as leaderboard from './schema/leaderboard'; import * as integrations from './schema/integrations'; import * as contentPreference from './schema/contentPreference'; -import * as prompts from './schema/prompts'; import * as paddle from './schema/paddle'; import * as njord from './schema/njord'; import * as organizations from './schema/organizations'; @@ -87,7 +86,6 @@ export const schema = urlDirective.transformer( leaderboard.typeDefs, integrations.typeDefs, contentPreference.typeDefs, - prompts.typeDefs, paddle.typeDefs, njord.typeDefs, organizations.typeDefs, @@ -132,7 +130,6 @@ export const schema = urlDirective.transformer( leaderboard.resolvers, integrations.resolvers, contentPreference.resolvers, - prompts.resolvers, paddle.resolvers, njord.resolvers, organizations.resolvers, diff --git a/src/migration/1713268800000-DropPrompt.ts b/src/migration/1713268800000-DropPrompt.ts new file mode 100644 index 0000000000..69828d3fd7 --- /dev/null +++ b/src/migration/1713268800000-DropPrompt.ts @@ -0,0 +1,37 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class DropPrompt1713268800000 implements MigrationInterface { + name = 'DropPrompt1713268800000'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `DROP INDEX IF EXISTS "public"."IDX_d8e3aa07a95560a445ad50fb93"`, + ); + await queryRunner.query( + `DROP INDEX IF EXISTS "public"."IDX_prompt_order"`, + ); + await queryRunner.query(`DROP TABLE IF EXISTS "prompt"`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "prompt" ( + "id" text NOT NULL, + "order" integer NOT NULL, + "label" text NOT NULL, + "description" text, + "prompt" text NOT NULL, + "createdAt" TIMESTAMP NOT NULL DEFAULT now(), + "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), + "flags" jsonb NOT NULL DEFAULT '{}', + CONSTRAINT "PK_d8e3aa07a95560a445ad50fb931" PRIMARY KEY ("id") + )`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_d8e3aa07a95560a445ad50fb93" ON "prompt" ("id")`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_prompt_order" ON "prompt" ("order")`, + ); + } +} diff --git a/src/schema/settings.ts b/src/schema/settings.ts index 54b2da9dad..38a3a16cb3 100644 --- a/src/schema/settings.ts +++ b/src/schema/settings.ts @@ -75,7 +75,6 @@ export const typeDefs = /* GraphQL */ ` noAiFeedEnabled: Boolean browsingContextEnabled: Boolean timezoneMismatchIgnore: String - lastPrompt: String defaultWriteTab: DefaultWriteTab }