@varaos/db 1.4.0 → 1.4.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varaos/db",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,15 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - The `status` column on the `integrations` table would be dropped and recreated. This will lead to data loss if there is data in the column.
5
+
6
+ */
7
+ -- CreateEnum
8
+ CREATE TYPE "public"."IntegrationStatus" AS ENUM ('active', 'disconnected', 'suspended', 'failed', 'expired', 'error');
9
+
10
+ -- AlterTable
11
+ ALTER TABLE "public"."integrations" DROP COLUMN "status",
12
+ ADD COLUMN "status" "public"."IntegrationStatus" NOT NULL DEFAULT 'active';
13
+
14
+ -- CreateIndex
15
+ CREATE INDEX "integrations_status_idx" ON "public"."integrations"("status");
@@ -0,0 +1,30 @@
1
+ -- AlterEnum
2
+ -- Not adding an enum since Prisma didn't complain about it, assuming 'TriggerType' already exists in DB.
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "DocumentChunk" ADD COLUMN "embedding" vector(768);
6
+
7
+ -- AlterTable
8
+ ALTER TABLE "Memory" ADD COLUMN "embedding" vector(768);
9
+
10
+ -- CreateIndex
11
+ CREATE INDEX IF NOT EXISTS "Memory_embedding_idx" ON "Memory" USING ivfflat ("embedding" vector_cosine_ops) WITH (lists = 100);
12
+
13
+ -- CreateIndex
14
+ CREATE INDEX IF NOT EXISTS "DocumentChunk_embedding_idx" ON "DocumentChunk" USING ivfflat ("embedding" vector_cosine_ops) WITH (lists = 100);
15
+
16
+ -- AlterTable
17
+ ALTER TABLE "Workflow" ADD COLUMN "templateId" TEXT;
18
+ ALTER TABLE "Workflow" ADD COLUMN "tokensPerRun" INTEGER NOT NULL DEFAULT 10;
19
+
20
+ -- AlterTable
21
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "requiredInputs" JSONB;
22
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "requiredIntegrations" TEXT[] DEFAULT ARRAY[]::TEXT[];
23
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "runTokenCost" INTEGER NOT NULL DEFAULT 10;
24
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "setupTokenCost" INTEGER NOT NULL DEFAULT 0;
25
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "spec" JSONB;
26
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "triggerConfig" JSONB;
27
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "triggerType" "TriggerType";
28
+
29
+ -- AddForeignKey
30
+ ALTER TABLE "Workflow" ADD CONSTRAINT "Workflow_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "WorkflowTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -46,6 +46,15 @@ enum AuthType {
46
46
  hybrid
47
47
  }
48
48
 
49
+ enum IntegrationStatus {
50
+ active // Connected and syncing
51
+ disconnected // User disconnected the integration
52
+ suspended // Temporarily disabled
53
+ failed // Sync or auth failed
54
+ expired
55
+ error
56
+ }
57
+
49
58
  enum MessageRole {
50
59
  user
51
60
  assistant
@@ -532,7 +541,7 @@ model Integration {
532
541
  expiresAt DateTime?
533
542
  scopes Json
534
543
  profile Json
535
- status Status @default(active)
544
+ status IntegrationStatus @default(active)
536
545
  metadata Json?
537
546
  deletedAt DateTime?
538
547
 
@@ -657,6 +666,13 @@ model Workflow {
657
666
  /// Includes: trigger, conditions, actions, etc.
658
667
  spec Json?
659
668
 
669
+ /// Link to the template this was instantiated from (if any)
670
+ templateId String?
671
+ template WorkflowTemplate? @relation(fields: [templateId], references: [id])
672
+
673
+ /// Track cost to execute
674
+ tokensPerRun Int @default(10) // Copied from template.runTokenCost
675
+
660
676
  /// How this workflow is triggered
661
677
  triggerType TriggerType?
662
678
 
@@ -858,6 +874,11 @@ model Memory {
858
874
  /// Soft delete
859
875
  active Boolean @default(true)
860
876
 
877
+ /// Gemini text-embedding-004 vector (768 dims) for semantic search
878
+ /// Apply via raw SQL: ALTER TABLE "Memory" ADD COLUMN embedding vector(768);
879
+ /// CREATE INDEX ON "Memory" USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
880
+ embedding Unsupported("vector(768)")?
881
+
861
882
  metadata Json?
862
883
 
863
884
  createdAt DateTime @default(now())
@@ -960,15 +981,17 @@ model DocumentChunk {
960
981
  sectionTitle String?
961
982
  pageNumber Int?
962
983
 
984
+ /// Gemini text-embedding-004 vector (768 dims) for semantic search
985
+ /// Apply via raw SQL: ALTER TABLE "DocumentChunk" ADD COLUMN embedding vector(768);
986
+ /// CREATE INDEX ON "DocumentChunk" USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
987
+ embedding Unsupported("vector(768)")?
988
+
963
989
  metadata Json?
964
990
 
965
991
  createdAt DateTime @default(now())
966
992
 
967
993
  document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
968
994
 
969
- /// Note: Vector index needs to be added via raw SQL:
970
- /// CREATE INDEX ON "DocumentChunk" USING ivfflat (embedding vector_cosine_ops)
971
-
972
995
  @@index([documentId, chunkIndex])
973
996
  }
974
997
 
@@ -1099,10 +1122,29 @@ model WorkflowTemplate {
1099
1122
  estimatedSetupTime Int?
1100
1123
  status Status @default(active)
1101
1124
 
1125
+ /// The blueprint workflow configuration in JSON format (maps to Workflow.spec)
1126
+ spec Json?
1127
+
1128
+ /// How this template is triggered
1129
+ triggerType TriggerType?
1130
+ triggerConfig Json?
1131
+
1132
+ /// Integrations required (e.g., ["gmail", "slack"])
1133
+ requiredIntegrations String[] @default([])
1134
+
1135
+ /// Inputs the UI needs to gather from the user before instantiation
1136
+ /// e.g. [{"key": "slack_channel", "type": "string", "label": "Slack Channel"}]
1137
+ requiredInputs Json?
1138
+
1139
+ /// Token costs shown in the UI
1140
+ setupTokenCost Int @default(0) // Tokens deducted when copying template
1141
+ runTokenCost Int @default(10) // Expected tokens per run or per step
1142
+
1102
1143
  createdAt DateTime @default(now())
1103
1144
  updatedAt DateTime @updatedAt
1104
1145
 
1105
1146
  steps WorkflowStepTemplate[]
1147
+ workflows Workflow[]
1106
1148
  }
1107
1149
 
1108
1150
  model WorkflowStepTemplate {