@arcote.tech/arc-workspace 0.7.30 → 0.7.31
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 +3 -3
- package/src/aggregates/workspace.ts +51 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-workspace",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.31",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Reusable workspace module for Arc framework — multi-workspace with dual token architecture",
|
|
7
7
|
"main": "./src/index.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"type-check": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@arcote.tech/arc": "^0.7.
|
|
14
|
-
"@arcote.tech/arc-auth": "^0.7.
|
|
13
|
+
"@arcote.tech/arc": "^0.7.31",
|
|
14
|
+
"@arcote.tech/arc-auth": "^0.7.31",
|
|
15
15
|
"typescript": "^5.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -19,7 +19,10 @@ export const createWorkspaceAggregate = <
|
|
|
19
19
|
return aggregate(`${data.name as Data["name"]}Workspaces`, workspaceId, {
|
|
20
20
|
name: string().minLength(1).maxLength(100),
|
|
21
21
|
type: string(),
|
|
22
|
-
|
|
22
|
+
// Opcjonalne — organizacje provisionowane serwerowo (np. z researchu) nie mają
|
|
23
|
+
// właściciela; dołączają do nich członkowie przez zaproszenie. Klasyczny
|
|
24
|
+
// `create` nadal ustawia ownerId (wstecznie zgodne).
|
|
25
|
+
ownerId: accountId.optional(),
|
|
23
26
|
isArchived: boolean(),
|
|
24
27
|
createdAt: date(),
|
|
25
28
|
})
|
|
@@ -44,6 +47,27 @@ export const createWorkspaceAggregate = <
|
|
|
44
47
|
},
|
|
45
48
|
)
|
|
46
49
|
|
|
50
|
+
// Provisioning bez właściciela — organizacja tworzona serwerowo (np. przez
|
|
51
|
+
// listener researchu). Projekcja tworzy wiersz bez ownerId; WorkspaceMember
|
|
52
|
+
// celowo NIE nasłuchuje tego eventu, więc nie powstaje owner-membership.
|
|
53
|
+
.publicEvent(
|
|
54
|
+
"workspaceProvisioned",
|
|
55
|
+
{
|
|
56
|
+
workspaceId,
|
|
57
|
+
name: string().minLength(1).maxLength(100),
|
|
58
|
+
type: string(),
|
|
59
|
+
},
|
|
60
|
+
async (ctx, event) => {
|
|
61
|
+
const { workspaceId: id, name, type } = event.payload;
|
|
62
|
+
await ctx.set(id, {
|
|
63
|
+
name,
|
|
64
|
+
type,
|
|
65
|
+
isArchived: false,
|
|
66
|
+
createdAt: event.createdAt,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
)
|
|
70
|
+
|
|
47
71
|
.publicEvent(
|
|
48
72
|
"workspaceRenamed",
|
|
49
73
|
{
|
|
@@ -92,6 +116,32 @@ export const createWorkspaceAggregate = <
|
|
|
92
116
|
),
|
|
93
117
|
)
|
|
94
118
|
|
|
119
|
+
// Server-only provisioning bez właściciela — dla listenerów (np. research
|
|
120
|
+
// budujący organizację z leada, zanim istnieje konto klienta). Nie wydaje
|
|
121
|
+
// tokenu; dostęp nadaje się później przez zaproszenie.
|
|
122
|
+
.mutateMethod(
|
|
123
|
+
"createForResearch",
|
|
124
|
+
(fn) =>
|
|
125
|
+
fn
|
|
126
|
+
.withParams({
|
|
127
|
+
name: string().minLength(1).maxLength(100),
|
|
128
|
+
type: string(),
|
|
129
|
+
})
|
|
130
|
+
.private()
|
|
131
|
+
.handle(
|
|
132
|
+
ONLY_SERVER &&
|
|
133
|
+
(async (ctx, params) => {
|
|
134
|
+
const id = workspaceId.generate();
|
|
135
|
+
await ctx.workspaceProvisioned.emit({
|
|
136
|
+
workspaceId: id,
|
|
137
|
+
name: params.name,
|
|
138
|
+
type: params.type,
|
|
139
|
+
});
|
|
140
|
+
return { workspaceId: id };
|
|
141
|
+
}),
|
|
142
|
+
),
|
|
143
|
+
)
|
|
144
|
+
|
|
95
145
|
.mutateMethod(
|
|
96
146
|
"rename",
|
|
97
147
|
(fn) =>
|