@varaos/db 1.5.0 → 1.5.1

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.5.0",
3
+ "version": "1.5.1",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,37 @@
1
+ -- AlterTable: Add currentVersion to WorkflowTemplate
2
+ ALTER TABLE "WorkflowTemplate" ADD COLUMN "currentVersion" INTEGER NOT NULL DEFAULT 1;
3
+
4
+ -- CreateTable: WorkflowTemplateVersion
5
+ CREATE TABLE "WorkflowTemplateVersion" (
6
+ "id" TEXT NOT NULL,
7
+ "templateId" TEXT NOT NULL,
8
+ "version" INTEGER NOT NULL,
9
+ "name" TEXT NOT NULL,
10
+ "description" TEXT,
11
+ "category" TEXT,
12
+ "recommended" BOOLEAN NOT NULL DEFAULT false,
13
+ "iconUrl" TEXT,
14
+ "estimatedSetupTime" INTEGER,
15
+ "spec" JSONB,
16
+ "triggerType" "public"."TriggerType",
17
+ "triggerConfig" JSONB,
18
+ "requiredIntegrations" TEXT[] DEFAULT ARRAY[]::TEXT[],
19
+ "requiredInputs" JSONB,
20
+ "setupTokenCost" INTEGER NOT NULL DEFAULT 0,
21
+ "runTokenCost" INTEGER NOT NULL DEFAULT 10,
22
+ "steps" JSONB NOT NULL,
23
+ "changeNote" TEXT,
24
+ "createdBy" TEXT,
25
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
26
+
27
+ CONSTRAINT "WorkflowTemplateVersion_pkey" PRIMARY KEY ("id")
28
+ );
29
+
30
+ -- CreateIndex: unique constraint on (templateId, version)
31
+ CREATE UNIQUE INDEX "WorkflowTemplateVersion_templateId_version_key" ON "WorkflowTemplateVersion"("templateId", "version");
32
+
33
+ -- CreateIndex: index on templateId for fast lookups
34
+ CREATE INDEX "WorkflowTemplateVersion_templateId_idx" ON "WorkflowTemplateVersion"("templateId");
35
+
36
+ -- AddForeignKey: link to WorkflowTemplate with cascade delete
37
+ ALTER TABLE "WorkflowTemplateVersion" ADD CONSTRAINT "WorkflowTemplateVersion_templateId_fkey" FOREIGN KEY ("templateId") REFERENCES "WorkflowTemplate"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -1205,11 +1205,43 @@ model WorkflowTemplate {
1205
1205
  setupTokenCost Int @default(0) // Tokens deducted when copying template
1206
1206
  runTokenCost Int @default(10) // Expected tokens per run or per step
1207
1207
 
1208
+ /// Current version number (auto-incremented on each update)
1209
+ currentVersion Int @default(1)
1210
+
1208
1211
  createdAt DateTime @default(now())
1209
1212
  updatedAt DateTime @updatedAt
1210
1213
 
1211
- steps WorkflowStepTemplate[]
1214
+ steps WorkflowStepTemplate[]
1212
1215
  workflows Workflow[]
1216
+ versions WorkflowTemplateVersion[]
1217
+ }
1218
+
1219
+ model WorkflowTemplateVersion {
1220
+ id String @id @default(uuid())
1221
+ templateId String
1222
+ version Int
1223
+ name String
1224
+ description String?
1225
+ category String?
1226
+ recommended Boolean @default(false)
1227
+ iconUrl String?
1228
+ estimatedSetupTime Int?
1229
+ spec Json?
1230
+ triggerType TriggerType?
1231
+ triggerConfig Json?
1232
+ requiredIntegrations String[] @default([])
1233
+ requiredInputs Json?
1234
+ setupTokenCost Int @default(0)
1235
+ runTokenCost Int @default(10)
1236
+ steps Json // snapshot of WorkflowStepTemplate[] at this version
1237
+ changeNote String?
1238
+ createdBy String? // admin user email
1239
+ createdAt DateTime @default(now())
1240
+
1241
+ template WorkflowTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
1242
+
1243
+ @@unique([templateId, version])
1244
+ @@index([templateId])
1213
1245
  }
1214
1246
 
1215
1247
  model WorkflowStepTemplate {