@allbluecn/database 0.4.14 → 0.4.16
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/generated/browser.ts +10 -0
- package/generated/client.ts +10 -0
- package/generated/commonInputTypes.ts +34 -0
- package/generated/enums.ts +2 -2
- package/generated/internal/class.ts +24 -4
- package/generated/internal/prismaNamespace.ts +191 -1
- package/generated/internal/prismaNamespaceBrowser.ts +26 -0
- package/generated/models/KnowledgeBase.ts +138 -0
- package/generated/models/Project.ts +158 -0
- package/generated/models/ProjectKnowledgeBase.ts +1430 -0
- package/generated/models/Story.ts +270 -0
- package/generated/models/StoryAttachment.ts +110 -1
- package/generated/models/StoryExternalLink.ts +1352 -0
- package/generated/models.ts +2 -0
- package/generated-sqlite/browser.ts +5 -10
- package/generated-sqlite/client.ts +5 -10
- package/generated-sqlite/internal/class.ts +14 -24
- package/generated-sqlite/internal/prismaNamespace.ts +88 -180
- package/generated-sqlite/internal/prismaNamespaceBrowser.ts +12 -29
- package/generated-sqlite/models/KnowledgeBase.ts +138 -0
- package/generated-sqlite/models/Project.ts +150 -0
- package/generated-sqlite/models/ProjectKnowledgeBase.ts +1426 -0
- package/generated-sqlite/models/User.ts +101 -1067
- package/generated-sqlite/models.ts +1 -2
- package/migrations/20260830000000_story_dependency_plane_align/migration.sql +37 -0
- package/migrations/20260831063744_project_knowledge_base/migration.sql +24 -0
- package/migrations/20260831123150_story_external_link/migration.sql +19 -0
- package/migrations/20260831151740_story_attachment_bytes/migration.sql +2 -0
- package/migrations/20260901010000_story_attachment_description/migration.sql +2 -0
- package/package.json +2 -2
- package/schema.prisma +53 -15
- package/schema.sqlite.prisma +25 -7
- package/generated-sqlite/models/Notification.ts +0 -1482
- package/generated-sqlite/models/NotificationPreference.ts +0 -1287
|
@@ -27,6 +27,7 @@ export type * from './models/InvitationCode'
|
|
|
27
27
|
export type * from './models/InvitationUse'
|
|
28
28
|
export type * from './models/PasswordResetToken'
|
|
29
29
|
export type * from './models/KnowledgeBase'
|
|
30
|
+
export type * from './models/ProjectKnowledgeBase'
|
|
30
31
|
export type * from './models/KnowledgeDocument'
|
|
31
32
|
export type * from './models/PRD'
|
|
32
33
|
export type * from './models/AgentConversation'
|
|
@@ -86,6 +87,4 @@ export type * from './models/ComplianceExport'
|
|
|
86
87
|
export type * from './models/UserAgent'
|
|
87
88
|
export type * from './models/UserSkill'
|
|
88
89
|
export type * from './models/DeveloperLog'
|
|
89
|
-
export type * from './models/Notification'
|
|
90
|
-
export type * from './models/NotificationPreference'
|
|
91
90
|
export type * from './commonInputTypes'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- 依赖关系存储规范化(对齐 Plane):
|
|
2
|
+
-- 旧模型 4 值(BLOCKS / BLOCKED_BY / RELATES_TO)→ 新模型 3 正向值
|
|
3
|
+
-- (BLOCKS / STARTS_BEFORE / FINISHES_BEFORE),语义统一为「source 领先于 target」。
|
|
4
|
+
-- 本迁移需先清理数据再重建 enum,否则 USING cast 会因残留旧值失败。
|
|
5
|
+
|
|
6
|
+
-- 1. 删除 RELATES_TO(Plane 中属于 Relation,不属于依赖)
|
|
7
|
+
DELETE FROM "story_dependencies" WHERE "type" = 'RELATES_TO';
|
|
8
|
+
|
|
9
|
+
-- 2. 删除翻转后与现存 BLOCKS 重复的 BLOCKED_BY 行
|
|
10
|
+
DELETE FROM "story_dependencies" d
|
|
11
|
+
WHERE d."type" = 'BLOCKED_BY'
|
|
12
|
+
AND EXISTS (
|
|
13
|
+
SELECT 1 FROM "story_dependencies" b
|
|
14
|
+
WHERE b."type" = 'BLOCKS'
|
|
15
|
+
AND b."sourceId" = d."targetId"
|
|
16
|
+
AND b."targetId" = d."sourceId"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
-- 3. BLOCKED_BY 翻转(X BLOCKED_BY Y ≡ Y BLOCKS X;PG UPDATE 右侧均取旧值,可直接交换)
|
|
20
|
+
UPDATE "story_dependencies"
|
|
21
|
+
SET "sourceId" = "targetId", "targetId" = "sourceId", "type" = 'BLOCKS'
|
|
22
|
+
WHERE "type" = 'BLOCKED_BY';
|
|
23
|
+
|
|
24
|
+
-- 4. enum 重建为 3 正向值
|
|
25
|
+
DO $$
|
|
26
|
+
BEGIN
|
|
27
|
+
IF EXISTS (SELECT 1 FROM pg_type WHERE typname = 'DependencyType_old') THEN
|
|
28
|
+
EXECUTE 'DROP TYPE "DependencyType_old"';
|
|
29
|
+
END IF;
|
|
30
|
+
END $$;
|
|
31
|
+
|
|
32
|
+
ALTER TYPE "DependencyType" RENAME TO "DependencyType_old";
|
|
33
|
+
CREATE TYPE "DependencyType" AS ENUM ('BLOCKS', 'STARTS_BEFORE', 'FINISHES_BEFORE');
|
|
34
|
+
ALTER TABLE "story_dependencies"
|
|
35
|
+
ALTER COLUMN "type" TYPE "DependencyType"
|
|
36
|
+
USING ("type"::text::"DependencyType");
|
|
37
|
+
DROP TYPE "DependencyType_old";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "project_knowledge_bases" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"projectId" TEXT NOT NULL,
|
|
5
|
+
"kbId" TEXT NOT NULL,
|
|
6
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
7
|
+
|
|
8
|
+
CONSTRAINT "project_knowledge_bases_pkey" PRIMARY KEY ("id")
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
-- CreateIndex
|
|
12
|
+
CREATE INDEX "project_knowledge_bases_projectId_idx" ON "project_knowledge_bases"("projectId");
|
|
13
|
+
|
|
14
|
+
-- CreateIndex
|
|
15
|
+
CREATE INDEX "project_knowledge_bases_kbId_idx" ON "project_knowledge_bases"("kbId");
|
|
16
|
+
|
|
17
|
+
-- CreateIndex
|
|
18
|
+
CREATE UNIQUE INDEX "project_knowledge_bases_projectId_kbId_key" ON "project_knowledge_bases"("projectId", "kbId");
|
|
19
|
+
|
|
20
|
+
-- AddForeignKey
|
|
21
|
+
ALTER TABLE "project_knowledge_bases" ADD CONSTRAINT "project_knowledge_bases_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
22
|
+
|
|
23
|
+
-- AddForeignKey
|
|
24
|
+
ALTER TABLE "project_knowledge_bases" ADD CONSTRAINT "project_knowledge_bases_kbId_fkey" FOREIGN KEY ("kbId") REFERENCES "knowledge_bases"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "story_external_links" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"storyId" TEXT NOT NULL,
|
|
5
|
+
"group" TEXT NOT NULL,
|
|
6
|
+
"externalId" TEXT NOT NULL,
|
|
7
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
8
|
+
|
|
9
|
+
CONSTRAINT "story_external_links_pkey" PRIMARY KEY ("id")
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
-- CreateIndex
|
|
13
|
+
CREATE INDEX "story_external_links_storyId_idx" ON "story_external_links"("storyId");
|
|
14
|
+
|
|
15
|
+
-- CreateIndex
|
|
16
|
+
CREATE UNIQUE INDEX "story_external_links_storyId_group_externalId_key" ON "story_external_links"("storyId", "group", "externalId");
|
|
17
|
+
|
|
18
|
+
-- AddForeignKey
|
|
19
|
+
ALTER TABLE "story_external_links" ADD CONSTRAINT "story_external_links_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "stories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allbluecn/database",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.16",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pg": "^8.22.0",
|
|
16
16
|
"sqlite-vec": "^0.1.9",
|
|
17
17
|
"bcryptjs": "^3.0.2",
|
|
18
|
-
"@allbluecn/shared": "0.4.
|
|
18
|
+
"@allbluecn/shared": "0.4.17"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/better-sqlite3": "^7.6.13",
|
package/schema.prisma
CHANGED
|
@@ -152,8 +152,9 @@ model Project {
|
|
|
152
152
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
153
153
|
members ProjectMember[]
|
|
154
154
|
activities ProjectActivity[]
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
stories Story[]
|
|
156
|
+
knowledgeBases ProjectKnowledgeBase[]
|
|
157
|
+
createdAt DateTime @default(now())
|
|
157
158
|
updatedAt DateTime @updatedAt
|
|
158
159
|
|
|
159
160
|
@@unique([ownerId, displayId])
|
|
@@ -479,11 +480,12 @@ model KnowledgeBase {
|
|
|
479
480
|
createdAt DateTime @default(now())
|
|
480
481
|
updatedAt DateTime @updatedAt
|
|
481
482
|
|
|
482
|
-
|
|
483
|
-
|
|
483
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
484
|
+
documents KnowledgeDocument[]
|
|
485
|
+
projectLinks ProjectKnowledgeBase[]
|
|
484
486
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
+
@@index([userId])
|
|
488
|
+
@@map("knowledge_bases")
|
|
487
489
|
}
|
|
488
490
|
|
|
489
491
|
model KnowledgeDocument {
|
|
@@ -1413,6 +1415,7 @@ model Story {
|
|
|
1413
1415
|
attachments StoryAttachment[]
|
|
1414
1416
|
linkedPrds StoryPrdLink[] @relation("StoryPrdLinks")
|
|
1415
1417
|
linkedDocs StoryDocLink[] @relation("StoryDocLinks")
|
|
1418
|
+
linkedExternalDocs StoryExternalLink[] @relation("StoryExternalLinks")
|
|
1416
1419
|
|
|
1417
1420
|
@@unique([identifier])
|
|
1418
1421
|
@@index([projectId, sequenceId])
|
|
@@ -1538,6 +1541,22 @@ model StoryDependency {
|
|
|
1538
1541
|
@@map("story_dependencies")
|
|
1539
1542
|
}
|
|
1540
1543
|
|
|
1544
|
+
// 项目关联知识库(join 表;关联时仅允许 visibility=team,general 全局可见无需关联,private 跨用户不可读)
|
|
1545
|
+
model ProjectKnowledgeBase {
|
|
1546
|
+
id String @id @default(cuid())
|
|
1547
|
+
projectId String
|
|
1548
|
+
kbId String
|
|
1549
|
+
createdAt DateTime @default(now())
|
|
1550
|
+
|
|
1551
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
1552
|
+
kb KnowledgeBase @relation(fields: [kbId], references: [id], onDelete: Cascade)
|
|
1553
|
+
|
|
1554
|
+
@@unique([projectId, kbId])
|
|
1555
|
+
@@index([projectId])
|
|
1556
|
+
@@index([kbId])
|
|
1557
|
+
@@map("project_knowledge_bases")
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1541
1560
|
model StoryLink {
|
|
1542
1561
|
id String @id @default(cuid())
|
|
1543
1562
|
storyId String
|
|
@@ -1554,17 +1573,21 @@ model StoryLink {
|
|
|
1554
1573
|
}
|
|
1555
1574
|
|
|
1556
1575
|
model StoryAttachment {
|
|
1557
|
-
id
|
|
1558
|
-
storyId
|
|
1559
|
-
fileName
|
|
1560
|
-
fileSize
|
|
1561
|
-
mimeType
|
|
1562
|
-
|
|
1563
|
-
|
|
1576
|
+
id String @id @default(cuid())
|
|
1577
|
+
storyId String
|
|
1578
|
+
fileName String
|
|
1579
|
+
fileSize BigInt
|
|
1580
|
+
mimeType String
|
|
1581
|
+
description String?
|
|
1582
|
+
storageUrl String
|
|
1583
|
+
bytes Bytes?
|
|
1584
|
+
fileHash String? @db.Text
|
|
1585
|
+
createdAt DateTime @default(now())
|
|
1564
1586
|
|
|
1565
1587
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1566
1588
|
|
|
1567
1589
|
@@index([storyId])
|
|
1590
|
+
@@index([fileHash])
|
|
1568
1591
|
@@map("story_attachments")
|
|
1569
1592
|
}
|
|
1570
1593
|
|
|
@@ -1598,10 +1621,25 @@ model StoryDocLink {
|
|
|
1598
1621
|
@@map("story_doc_links")
|
|
1599
1622
|
}
|
|
1600
1623
|
|
|
1624
|
+
// 通用知识库条目(法律法规/行业合规/词典词条/网站收藏)与需求的关联
|
|
1625
|
+
model StoryExternalLink {
|
|
1626
|
+
id String @id @default(cuid())
|
|
1627
|
+
storyId String
|
|
1628
|
+
group String
|
|
1629
|
+
externalId String
|
|
1630
|
+
createdAt DateTime @default(now())
|
|
1631
|
+
|
|
1632
|
+
story Story @relation("StoryExternalLinks", fields: [storyId], references: [id], onDelete: Cascade)
|
|
1633
|
+
|
|
1634
|
+
@@unique([storyId, group, externalId])
|
|
1635
|
+
@@index([storyId])
|
|
1636
|
+
@@map("story_external_links")
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1601
1639
|
enum DependencyType {
|
|
1602
1640
|
BLOCKS
|
|
1603
|
-
|
|
1604
|
-
|
|
1641
|
+
STARTS_BEFORE
|
|
1642
|
+
FINISHES_BEFORE
|
|
1605
1643
|
}
|
|
1606
1644
|
|
|
1607
1645
|
// 需求模块保存视图(per-user 私有)
|
package/schema.sqlite.prisma
CHANGED
|
@@ -114,9 +114,10 @@ model Project {
|
|
|
114
114
|
owner User @relation("projectOwner", fields: [ownerId], references: [id])
|
|
115
115
|
workspaceId String?
|
|
116
116
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
members ProjectMember[]
|
|
118
|
+
activities ProjectActivity[]
|
|
119
|
+
knowledgeBases ProjectKnowledgeBase[]
|
|
120
|
+
createdAt DateTime @default(now())
|
|
120
121
|
updatedAt DateTime @updatedAt
|
|
121
122
|
|
|
122
123
|
@@unique([ownerId, displayId])
|
|
@@ -398,11 +399,28 @@ model KnowledgeBase {
|
|
|
398
399
|
createdAt DateTime @default(now())
|
|
399
400
|
updatedAt DateTime @updatedAt
|
|
400
401
|
|
|
401
|
-
|
|
402
|
-
|
|
402
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
403
|
+
documents KnowledgeDocument[]
|
|
404
|
+
projectLinks ProjectKnowledgeBase[]
|
|
403
405
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
+
@@index([userId])
|
|
407
|
+
@@map("knowledge_bases")
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// 项目关联知识库(join 表;关联时仅允许 visibility=team,general 全局可见无需关联,private 跨用户不可读)
|
|
411
|
+
model ProjectKnowledgeBase {
|
|
412
|
+
id String @id @default(cuid())
|
|
413
|
+
projectId String
|
|
414
|
+
kbId String
|
|
415
|
+
createdAt DateTime @default(now())
|
|
416
|
+
|
|
417
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
418
|
+
kb KnowledgeBase @relation(fields: [kbId], references: [id], onDelete: Cascade)
|
|
419
|
+
|
|
420
|
+
@@unique([projectId, kbId])
|
|
421
|
+
@@index([projectId])
|
|
422
|
+
@@index([kbId])
|
|
423
|
+
@@map("project_knowledge_bases")
|
|
406
424
|
}
|
|
407
425
|
|
|
408
426
|
model KnowledgeDocument {
|