@infuro/cms-core 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ export class ChatAndKnowledgeBase1772178563555 implements MigrationInterface {
4
+ name = 'ChatAndKnowledgeBase1772178563555';
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `CREATE TABLE "knowledge_base_documents" ("id" SERIAL NOT NULL, "name" character varying NOT NULL, "sourceUrl" character varying, "content" text NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_knowledge_base_documents" PRIMARY KEY ("id"))`
9
+ );
10
+ await queryRunner.query(
11
+ `CREATE TABLE "knowledge_base_chunks" ("id" SERIAL NOT NULL, "documentId" integer NOT NULL, "content" text NOT NULL, "chunkIndex" integer NOT NULL DEFAULT 0, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_knowledge_base_chunks" PRIMARY KEY ("id"))`
12
+ );
13
+ await queryRunner.query(
14
+ `CREATE TABLE "chat_conversations" ("id" SERIAL NOT NULL, "contactId" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_chat_conversations" PRIMARY KEY ("id"))`
15
+ );
16
+ await queryRunner.query(
17
+ `CREATE TABLE "chat_messages" ("id" SERIAL NOT NULL, "conversationId" integer NOT NULL, "role" character varying NOT NULL, "content" text NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_chat_messages" PRIMARY KEY ("id"))`
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "knowledge_base_chunks" ADD CONSTRAINT "FK_knowledge_base_chunks_document" FOREIGN KEY ("documentId") REFERENCES "knowledge_base_documents"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "chat_conversations" ADD CONSTRAINT "FK_chat_conversations_contact" FOREIGN KEY ("contactId") REFERENCES "contacts"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "chat_messages" ADD CONSTRAINT "FK_chat_messages_conversation" FOREIGN KEY ("conversationId") REFERENCES "chat_conversations"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
27
+ );
28
+ }
29
+
30
+ public async down(queryRunner: QueryRunner): Promise<void> {
31
+ await queryRunner.query(`ALTER TABLE "chat_messages" DROP CONSTRAINT "FK_chat_messages_conversation"`);
32
+ await queryRunner.query(`ALTER TABLE "chat_conversations" DROP CONSTRAINT "FK_chat_conversations_contact"`);
33
+ await queryRunner.query(`ALTER TABLE "knowledge_base_chunks" DROP CONSTRAINT "FK_knowledge_base_chunks_document"`);
34
+ await queryRunner.query(`DROP TABLE "chat_messages"`);
35
+ await queryRunner.query(`DROP TABLE "chat_conversations"`);
36
+ await queryRunner.query(`DROP TABLE "knowledge_base_chunks"`);
37
+ await queryRunner.query(`DROP TABLE "knowledge_base_documents"`);
38
+ }
39
+ }
@@ -0,0 +1,16 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+
3
+ /** Requires pgvector: run as DB superuser first: CREATE EXTENSION IF NOT EXISTS vector; */
4
+ export class KnowledgeBaseVector1772178563556 implements MigrationInterface {
5
+ name = 'KnowledgeBaseVector1772178563556';
6
+
7
+ public async up(queryRunner: QueryRunner): Promise<void> {
8
+ await queryRunner.query(
9
+ `ALTER TABLE "knowledge_base_chunks" ADD COLUMN IF NOT EXISTS "embedding" vector(1536)`
10
+ );
11
+ }
12
+
13
+ public async down(queryRunner: QueryRunner): Promise<void> {
14
+ await queryRunner.query(`ALTER TABLE "knowledge_base_chunks" DROP COLUMN IF EXISTS "embedding"`);
15
+ }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infuro/cms-core",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",