Skip to content

Commit d5f8562

Browse files
committed
added in workspace
1 parent 36753d8 commit d5f8562

File tree

5 files changed

+79
-8
lines changed

5 files changed

+79
-8
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `ownerId` to the `Specification` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Specification" ADD COLUMN "ownerId" INTEGER NOT NULL,
9+
ADD COLUMN "workspaceId" INTEGER;
10+
11+
-- CreateTable
12+
CREATE TABLE "Workspace" (
13+
"id" SERIAL NOT NULL,
14+
"uuid" TEXT NOT NULL,
15+
"name" TEXT NOT NULL,
16+
"ownerId" INTEGER NOT NULL,
17+
18+
CONSTRAINT "Workspace_pkey" PRIMARY KEY ("id")
19+
);
20+
21+
-- CreateTable
22+
CREATE TABLE "BridgeWorkspaceAndUser" (
23+
"id" SERIAL NOT NULL,
24+
"userId" INTEGER NOT NULL,
25+
"workspaceId" INTEGER NOT NULL,
26+
27+
CONSTRAINT "BridgeWorkspaceAndUser_pkey" PRIMARY KEY ("id")
28+
);
29+
30+
-- AddForeignKey
31+
ALTER TABLE "Workspace" ADD CONSTRAINT "Workspace_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
32+
33+
-- AddForeignKey
34+
ALTER TABLE "BridgeWorkspaceAndUser" ADD CONSTRAINT "BridgeWorkspaceAndUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
35+
36+
-- AddForeignKey
37+
ALTER TABLE "BridgeWorkspaceAndUser" ADD CONSTRAINT "BridgeWorkspaceAndUser_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "Workspace"("id") ON DELETE CASCADE ON UPDATE CASCADE;
38+
39+
-- AddForeignKey
40+
ALTER TABLE "Specification" ADD CONSTRAINT "Specification_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
41+
42+
-- AddForeignKey
43+
ALTER TABLE "Specification" ADD CONSTRAINT "Specification_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "Workspace"("id") ON DELETE CASCADE ON UPDATE CASCADE;

prisma/schema.prisma

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ model User {
2222
google_id String?
2323
bridgeUserAndSpecification BridgeUserAndSpecfication[]
2424
SpecificationSnapshot SpecificationSnapshot[]
25+
Workspaces BridgeWorkspaceAndUser[]
26+
Workspace Workspace[]
27+
Specification Specification[]
28+
}
29+
30+
model Workspace {
31+
id Int @id @default(autoincrement())
32+
uuid String
33+
name String
34+
ownerId Int
35+
owner User @relation(references: [id], fields: [ownerId], onDelete: Cascade)
36+
members BridgeWorkspaceAndUser[]
37+
specifications Specification[]
38+
}
39+
40+
model BridgeWorkspaceAndUser {
41+
id Int @id @default(autoincrement())
42+
userId Int
43+
user User @relation(references: [id], fields: [userId], onDelete: Cascade)
44+
workspaceId Int
45+
workspace Workspace @relation(references: [id], fields: [workspaceId], onDelete: Cascade)
2546
}
2647

2748
model Session {
@@ -45,7 +66,11 @@ model Specification {
4566
uuid String
4667
name String
4768
specSnapshots SpecificationSnapshot[]
69+
ownerId Int
70+
owner User @relation(references: [id], fields: [ownerId], onDelete: Cascade)
4871
bridgeUserAndSpecification BridgeUserAndSpecfication[]
72+
workspaceId Int?
73+
workspace Workspace? @relation(references: [id], fields: [workspaceId], onDelete: Cascade)
4974
}
5075

5176
model SpecificationSnapshot {
@@ -57,6 +82,6 @@ model SpecificationSnapshot {
5782
createdAt DateTime @default(now())
5883
versionNum Int
5984
content String
60-
creatorId Int
85+
creatorId Int
6186
createdBy User @relation(references: [id], fields: [creatorId], onDelete: Cascade)
6287
}

src/lib/components/ui/HighlightCode.svelte

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,3 @@
4242
</button>
4343
<Highlight {language} {code} />
4444
</div>
45-
46-
<style>
47-
code {
48-
width: 100%;
49-
}
50-
</style>

src/lib/server/services/data/dbService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export async function createSpec(
244244
data: {
245245
name: name,
246246
uuid: crypto.randomUUID(),
247+
ownerId: user.id,
247248
},
248249
});
249250
const uuid = crypto.randomUUID();

src/lib/yizySpec/generators/browser-object-oriented-typescript/templates.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,20 @@ export interface ClassTemplateInput {
9292
}
9393

9494
export const CLASS_TEMPLATE = `export class {{serviceName}} {
95-
configs: {{serviceName}}ApiClientConfigs;
95+
private configs: {{serviceName}}ApiClientConfigs;
9696
9797
constructor(configs: {{serviceName}}ApiClientConfigs) {
9898
this.configs = configs;
9999
}
100100
101+
getApiClientConfigs(): {{serviceName}}ApiClientConfigs {
102+
return this.configs;
103+
}
104+
105+
updateApiClientConfigs(configs: {{serviceName}}ApiClientConfigs) {
106+
this.configs = configs;
107+
}
108+
101109
{{#each methods}}
102110
async {{functionName}}({{#if argType}}req: {{argType}}, {{/if}}hooks?: Hooks): Promise<{{#if returnType}}{{returnType}}{{else}}void{{/if}}> {
103111
let opts = this.configs.requestConfigs;

0 commit comments

Comments
 (0)