@ossy/workspaces 3.0.1 → 3.0.3
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 +6 -3
- package/src/SelectWorkspacePage.jsx +1 -1
- package/src/accept-invitation.task.js +1 -1
- package/src/create.task.js +1 -1
- package/src/disable-service.task.js +3 -1
- package/src/enable-service.task.js +3 -1
- package/src/get-schemas.task.js +1 -1
- package/src/import-schemas.task.js +1 -1
- package/src/invite-user.task.js +1 -1
- package/src/accept-invitation.api.js +0 -46
- package/src/select-workspace.api.js +0 -50
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/workspaces",
|
|
3
3
|
"description": "Workspaces feature package - create, select, and manage workspaces, users, and invitations",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"module": "./src/index.js",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"ossy": {
|
|
23
23
|
"src": "./src"
|
|
24
24
|
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@ossy/config": "^3.0.3",
|
|
27
|
+
"@ossy/schema": "^3.0.3"
|
|
28
|
+
},
|
|
25
29
|
"peerDependencies": {
|
|
26
30
|
"@ossy/design-system": ">=1.0.0",
|
|
27
31
|
"@ossy/router-react": ">=1.0.0",
|
|
@@ -30,7 +34,6 @@
|
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
36
|
"@jest/globals": "^30.2.0",
|
|
33
|
-
"@ossy/platform": "^3.0.1",
|
|
34
37
|
"casual": "^1.6.2",
|
|
35
38
|
"jest": "^30.2.0"
|
|
36
39
|
},
|
|
@@ -42,5 +45,5 @@
|
|
|
42
45
|
"/src",
|
|
43
46
|
"README.md"
|
|
44
47
|
],
|
|
45
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8d098a04b595b2d1f54788c5c7ed7f310e9cd7e1"
|
|
46
49
|
}
|
|
@@ -4,7 +4,7 @@ import { UserSchema } from '@ossy/users/server'
|
|
|
4
4
|
import { Workspace, WorkspacesEvents } from '@ossy/workspaces/server'
|
|
5
5
|
import { User, UsersEvents } from '@ossy/users/server'
|
|
6
6
|
import { Token, TokenEvents } from '@ossy/tokens/server'
|
|
7
|
-
import { ConfigService } from '@ossy/
|
|
7
|
+
import { ConfigService } from '@ossy/config'
|
|
8
8
|
import { createLogger } from '@ossy/observability'
|
|
9
9
|
|
|
10
10
|
export const metadata = { id: '@ossy/workspaces/tasks/accept-invitation' }
|
package/src/create.task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Aggregate } from '@ossy/event-store'
|
|
2
2
|
import { Workspace, WorkspacesEvents } from '@ossy/workspaces/server'
|
|
3
|
-
import { ConfigService } from '@ossy/
|
|
3
|
+
import { ConfigService } from '@ossy/config'
|
|
4
4
|
|
|
5
5
|
export const metadata = { id: '@ossy/workspaces/tasks/create' }
|
|
6
6
|
|
|
@@ -10,6 +10,8 @@ export async function run({ payload, req }) {
|
|
|
10
10
|
const service = assertEnableableService(payload?.service)
|
|
11
11
|
|
|
12
12
|
const event = WorkspacesEvents.ServiceDisabled({ createdBy, service })
|
|
13
|
-
await Aggregate.Of(Workspace, workspaceId)
|
|
13
|
+
await Aggregate.Of(Workspace, workspaceId)
|
|
14
|
+
.then(Aggregate.Add(event))
|
|
15
|
+
.then(Aggregate.Save())
|
|
14
16
|
return null
|
|
15
17
|
}
|
|
@@ -10,6 +10,8 @@ export async function run({ payload, req }) {
|
|
|
10
10
|
const service = assertEnableableService(payload?.service ?? payload)
|
|
11
11
|
|
|
12
12
|
const event = WorkspacesEvents.ServiceEnabled({ createdBy, service })
|
|
13
|
-
await Aggregate.Of(Workspace, workspaceId)
|
|
13
|
+
await Aggregate.Of(Workspace, workspaceId)
|
|
14
|
+
.then(Aggregate.Add(event))
|
|
15
|
+
.then(Aggregate.Save())
|
|
14
16
|
return null
|
|
15
17
|
}
|
package/src/get-schemas.task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Aggregate } from '@ossy/event-store'
|
|
2
2
|
import { Workspace } from '@ossy/workspaces/server'
|
|
3
|
-
import { getSystemSchemas } from '@ossy/
|
|
3
|
+
import { getSystemSchemas } from '@ossy/schema'
|
|
4
4
|
import { mergeWorkspaceSchemas } from './merge-workspace-schemas.js'
|
|
5
5
|
|
|
6
6
|
export const metadata = { id: '@ossy/workspaces/tasks/get-schemas' }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Aggregate } from '@ossy/event-store'
|
|
2
2
|
import { Workspace, WorkspacesEvents } from '@ossy/workspaces/server'
|
|
3
|
-
import { validateSchemasForImport } from '@ossy/
|
|
3
|
+
import { validateSchemasForImport } from '@ossy/schema'
|
|
4
4
|
|
|
5
5
|
export const metadata = { id: '@ossy/workspaces/tasks/import-schemas' }
|
|
6
6
|
|
package/src/invite-user.task.js
CHANGED
|
@@ -4,7 +4,7 @@ import { UserSchema } from '@ossy/users/server'
|
|
|
4
4
|
import { Workspace, WorkspacesEvents } from '@ossy/workspaces/server'
|
|
5
5
|
import { Token, TokenEvents } from '@ossy/tokens/server'
|
|
6
6
|
import { EmailRenderer } from '@ossy/email'
|
|
7
|
-
import { ConfigService } from '@ossy/
|
|
7
|
+
import { ConfigService } from '@ossy/config'
|
|
8
8
|
import { createLogger } from '@ossy/observability'
|
|
9
9
|
import WorkspaceInvitationEmail, { subject as workspaceInvitationSubject } from './workspace-invitation.email.jsx'
|
|
10
10
|
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionService,
|
|
3
|
-
mergeUserAppSettingsCookie,
|
|
4
|
-
setAuthCookie,
|
|
5
|
-
} from '@ossy/platform'
|
|
6
|
-
|
|
7
|
-
export const metadata = {
|
|
8
|
-
id: 'users.accept-invitation',
|
|
9
|
-
path: '/api/v0/users/accept-invitation',
|
|
10
|
-
action: '@ossy/workspaces/actions/accept-invitation',
|
|
11
|
-
method: 'GET',
|
|
12
|
-
query: ['token', 'workspaceId', 'redirect'],
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default async function handle (req, res) {
|
|
16
|
-
if (req.method !== 'GET') {
|
|
17
|
-
res.setHeader('Allow', 'GET')
|
|
18
|
-
res.status(405).json({ error: 'Method Not Allowed' })
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const { authToken, workspaceId } = await ActionService.invoke('@ossy/workspaces/actions/accept-invitation', {
|
|
24
|
-
payload: {
|
|
25
|
-
token: req.query.token,
|
|
26
|
-
workspaceId: req.query.workspaceId,
|
|
27
|
-
},
|
|
28
|
-
req,
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
setAuthCookie(res, authToken)
|
|
32
|
-
if (workspaceId) {
|
|
33
|
-
mergeUserAppSettingsCookie(req, res, { workspaceId })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const redirect = req.query.redirect
|
|
37
|
-
if (redirect && typeof redirect === 'string') {
|
|
38
|
-
res.redirect(302, redirect)
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
res.status(200).json('')
|
|
43
|
-
} catch (err) {
|
|
44
|
-
res.status(err.status || 401).json('')
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionService,
|
|
3
|
-
mergeUserAppSettingsCookie,
|
|
4
|
-
} from '@ossy/platform'
|
|
5
|
-
|
|
6
|
-
export const metadata = {
|
|
7
|
-
id: 'users.select-workspace',
|
|
8
|
-
path: '/api/v0/users/select-workspace',
|
|
9
|
-
method: 'GET',
|
|
10
|
-
query: ['workspaceId', 'redirect'],
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default async function handle (req, res) {
|
|
14
|
-
if (req.method !== 'GET') {
|
|
15
|
-
res.setHeader('Allow', 'GET')
|
|
16
|
-
res.status(405).json({ error: 'Method Not Allowed' })
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!req.userId || req.userId === 'anonymous') {
|
|
21
|
-
res.status(401).json({ error: 'Unauthorized' })
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const workspaceId = req.query.workspaceId
|
|
26
|
-
if (!workspaceId || typeof workspaceId !== 'string') {
|
|
27
|
-
res.status(400).json({ message: 'No workspaceId provided' })
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const workspaces = await ActionService.invoke('@ossy/workspaces/actions/list', { req })
|
|
33
|
-
if (!workspaces.some((w) => w.id === workspaceId)) {
|
|
34
|
-
res.status(403).json({ message: 'Forbidden' })
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
mergeUserAppSettingsCookie(req, res, { workspaceId })
|
|
39
|
-
|
|
40
|
-
const redirect = req.query.redirect
|
|
41
|
-
if (redirect && typeof redirect === 'string') {
|
|
42
|
-
res.redirect(302, redirect)
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
res.status(200).json('')
|
|
47
|
-
} catch (err) {
|
|
48
|
-
res.status(err.status || 500).json({ message: err.message || 'Internal Server Error' })
|
|
49
|
-
}
|
|
50
|
-
}
|