@ossy/workspaces 1.16.7 → 1.17.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.
Files changed (53) hide show
  1. package/README.md +1 -0
  2. package/package.json +5 -4
  3. package/src/AuthenticationGuard.jsx +23 -10
  4. package/src/CreateWorkspacePage.jsx +18 -12
  5. package/src/Definition.js +1 -17
  6. package/src/GeneralSettings.jsx +27 -70
  7. package/src/Invitations.jsx +11 -19
  8. package/src/Invite.jsx +17 -14
  9. package/src/SelectWorkspacePage.jsx +17 -22
  10. package/src/Users.jsx +10 -15
  11. package/src/accept-invitation.action.js +1 -85
  12. package/src/accept-invitation.task.js +84 -0
  13. package/src/create-api-token.action.js +1 -17
  14. package/src/create-api-token.task.js +16 -0
  15. package/src/create.action.js +1 -30
  16. package/src/create.task.js +29 -0
  17. package/src/disable-service.action.js +1 -28
  18. package/src/disable-service.task.js +27 -0
  19. package/src/en.translations.json +72 -0
  20. package/src/enable-service.action.js +1 -28
  21. package/src/enable-service.task.js +27 -0
  22. package/src/get-api-tokens.action.js +1 -11
  23. package/src/get-api-tokens.task.js +10 -0
  24. package/src/get-invitations.action.js +1 -11
  25. package/src/get-invitations.task.js +10 -0
  26. package/src/get-resource-templates.action.js +1 -19
  27. package/src/get-resource-templates.task.js +18 -0
  28. package/src/get-users.action.js +1 -14
  29. package/src/get-users.task.js +13 -0
  30. package/src/get.action.js +1 -14
  31. package/src/get.task.js +13 -0
  32. package/src/import-resource-templates.action.js +1 -27
  33. package/src/import-resource-templates.task.js +26 -0
  34. package/src/index.js +14 -2
  35. package/src/invite-user.action.js +1 -85
  36. package/src/invite-user.task.js +84 -0
  37. package/src/list.action.js +1 -9
  38. package/src/list.task.js +8 -0
  39. package/src/remove-member.action.js +1 -17
  40. package/src/remove-member.task.js +16 -0
  41. package/src/server.js +3 -0
  42. package/src/sv.translations.json +72 -0
  43. package/src/sync-workspace-membership.task.js +4 -3
  44. package/src/workspaces.spec.js +71 -80
  45. package/src/current.api.js +0 -30
  46. package/src/invitations.api.js +0 -46
  47. package/src/item.api.js +0 -32
  48. package/src/list.api.js +0 -35
  49. package/src/members.api.js +0 -42
  50. package/src/resource-templates.api.js +0 -35
  51. package/src/services-disable.api.js +0 -23
  52. package/src/services-enable.api.js +0 -23
  53. package/src/tokens.api.js +0 -35
@@ -1,30 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.current',
5
- path: '/api/v0/workspaces/current',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method !== 'GET') {
10
- res.setHeader('Allow', 'GET')
11
- res.status(405).json({ error: 'Method Not Allowed' })
12
- return
13
- }
14
-
15
- const workspaceId = req.workspaceId || req.user?.workspaces?.[0]
16
- if (!workspaceId) {
17
- res.status(404).json(null)
18
- return
19
- }
20
-
21
- try {
22
- const workspace = await ActionService.invoke('workspaces/get', {
23
- payload: { workspaceId },
24
- req: { ...req, workspaceId },
25
- })
26
- res.json(workspace)
27
- } catch (err) {
28
- res.status(err?.status ?? 500).json({ error: err?.message })
29
- }
30
- }
@@ -1,46 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'invitations.root',
5
- path: '/api/v0/invitations',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method === 'POST') {
10
- try {
11
- await ActionService.invoke('workspaces/invite-user', {
12
- payload: {
13
- email: req.body,
14
- workspaceId: req.workspaceId,
15
- userId: req.userId,
16
- inviterEmail: req.user?.email,
17
- },
18
- integrations: req.integrations,
19
- req,
20
- })
21
- res.json('')
22
- } catch (err) {
23
- res.status(err?.status ?? 400).json(err?.message ?? 'Could not invite user')
24
- }
25
- return
26
- }
27
- if (req.method === 'GET') {
28
- try {
29
- const result = await ActionService.invoke('workspaces/accept-invitation', {
30
- payload: { workspaceId: req.workspaceId, token: req.query?.token },
31
- req,
32
- })
33
- res.cookie('auth', result.authToken, {
34
- httpOnly: true,
35
- signed: true,
36
- expires: new Date(result.authExpiresAt),
37
- })
38
- res.json('')
39
- } catch (err) {
40
- res.status(err?.status ?? 401).json('')
41
- }
42
- return
43
- }
44
- res.setHeader('Allow', 'GET, POST')
45
- res.status(405).json({ error: 'Method Not Allowed' })
46
- }
package/src/item.api.js DELETED
@@ -1,32 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.item',
5
- path: '/api/v0/workspaces/:workspaceId',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method !== 'GET') {
10
- res.setHeader('Allow', 'GET')
11
- res.status(405).json({ error: 'Method Not Allowed' })
12
- return
13
- }
14
-
15
- const pathname = (req.path || new URL(req.originalUrl, 'http://localhost').pathname).replace(/\/+$/, '')
16
- const m = pathname.match(/^\/api\/v0\/workspaces\/([^/]+)$/)
17
- if (!m || m[1] === 'current') {
18
- res.status(404).json('')
19
- return
20
- }
21
-
22
- const workspaceId = decodeURIComponent(m[1])
23
- try {
24
- const workspace = await ActionService.invoke('workspaces/get', {
25
- payload: { workspaceId },
26
- req: { ...req, workspaceId },
27
- })
28
- res.json(workspace)
29
- } catch (err) {
30
- res.status(err?.status ?? 500).json({ error: err?.message })
31
- }
32
- }
package/src/list.api.js DELETED
@@ -1,35 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.list',
5
- path: '/api/v0/workspaces',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method === 'POST') {
10
- try {
11
- const workspace = await ActionService.invoke('workspaces/create', {
12
- payload: { name: req.body?.name, userId: req.userId },
13
- req,
14
- })
15
- res.json(workspace)
16
- } catch (err) {
17
- res.status(err?.status ?? 400).json({ error: err?.message })
18
- }
19
- return
20
- }
21
- if (req.method === 'GET') {
22
- try {
23
- const workspaces = await ActionService.invoke('workspaces/list', {
24
- payload: { userId: req.userId },
25
- req,
26
- })
27
- res.json(workspaces)
28
- } catch (err) {
29
- res.status(err?.status ?? 400).json({ error: err?.message })
30
- }
31
- return
32
- }
33
- res.setHeader('Allow', 'GET, POST')
34
- res.status(405).json({ error: 'Method Not Allowed' })
35
- }
@@ -1,42 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.members',
5
- path: '/api/v0/workspaces/:workspaceId/members/:userId',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method !== 'DELETE') {
10
- res.setHeader('Allow', 'DELETE')
11
- res.status(405).json({ error: 'Method Not Allowed' })
12
- return
13
- }
14
-
15
- const pathname = (req.path || new URL(req.originalUrl, 'http://localhost').pathname).replace(/\/+$/, '')
16
- const m = pathname.match(/^\/api\/v0\/workspaces\/([^/]+)\/members\/([^/]+)$/)
17
- if (!m) {
18
- res.status(404).json('')
19
- return
20
- }
21
-
22
- const workspaceId = decodeURIComponent(m[1])
23
- const memberId = decodeURIComponent(m[2])
24
-
25
- const isMember = Array.isArray(req.user?.workspaces) && req.user.workspaces.includes(workspaceId)
26
- const isSelf = req.user?.id === memberId
27
-
28
- if (!isMember && !isSelf) {
29
- res.status(403).json({ error: 'Forbidden' })
30
- return
31
- }
32
-
33
- try {
34
- await ActionService.invoke('workspaces/remove-member', {
35
- payload: { workspaceId, memberId, userId: req.userId },
36
- req,
37
- })
38
- res.json()
39
- } catch (err) {
40
- res.status(err?.status ?? 500).json({ error: err?.message })
41
- }
42
- }
@@ -1,35 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'resourceTemplates.root',
5
- path: '/api/v0/resource-templates',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method === 'POST') {
10
- try {
11
- const templates = await ActionService.invoke('workspaces/import-resource-templates', {
12
- payload: { templates: req.body, workspaceId: req.workspaceId, userId: req.userId },
13
- req,
14
- })
15
- res.json(templates)
16
- } catch (err) {
17
- res.status(err?.status ?? 500).json({ type: err?.type, message: err?.message })
18
- }
19
- return
20
- }
21
- if (req.method === 'GET') {
22
- try {
23
- const templates = await ActionService.invoke('workspaces/get-resource-templates', {
24
- payload: { workspaceId: req.workspaceId },
25
- req,
26
- })
27
- res.json(templates)
28
- } catch (err) {
29
- res.status(err?.status ?? 500).json()
30
- }
31
- return
32
- }
33
- res.setHeader('Allow', 'GET, POST')
34
- res.status(405).json({ error: 'Method Not Allowed' })
35
- }
@@ -1,23 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.services.disable',
5
- path: '/api/v0/services/disable',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method !== 'POST') {
10
- res.setHeader('Allow', 'POST')
11
- res.status(405).json({ error: 'Method Not Allowed' })
12
- return
13
- }
14
- try {
15
- await ActionService.invoke('workspaces/disable-service', {
16
- payload: { service: req.body?.service, workspaceId: req.workspaceId, userId: req.userId },
17
- req,
18
- })
19
- res.json()
20
- } catch (err) {
21
- res.status(err?.status ?? 400).json({ error: err?.message })
22
- }
23
- }
@@ -1,23 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.services.enable',
5
- path: '/api/v0/services/enable',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method !== 'POST') {
10
- res.setHeader('Allow', 'POST')
11
- res.status(405).json({ error: 'Method Not Allowed' })
12
- return
13
- }
14
- try {
15
- await ActionService.invoke('workspaces/enable-service', {
16
- payload: { service: req.body, workspaceId: req.workspaceId, userId: req.userId },
17
- req,
18
- })
19
- res.json()
20
- } catch (err) {
21
- res.status(err?.status ?? 400).json({ error: err?.message })
22
- }
23
- }
package/src/tokens.api.js DELETED
@@ -1,35 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'workspaces.tokens',
5
- path: '/api/v0/tokens',
6
- }
7
-
8
- export default async function handle(req, res) {
9
- if (req.method === 'GET') {
10
- try {
11
- const tokens = await ActionService.invoke('workspaces/get-api-tokens', {
12
- payload: { workspaceId: req.workspaceId },
13
- req,
14
- })
15
- res.json(tokens)
16
- } catch (err) {
17
- res.status(err?.status ?? 500).json({ error: err?.message })
18
- }
19
- return
20
- }
21
- if (req.method === 'POST') {
22
- try {
23
- const token = await ActionService.invoke('workspaces/create-api-token', {
24
- payload: { workspaceId: req.workspaceId, userId: req.userId, description: req.body?.description },
25
- req,
26
- })
27
- res.json(token)
28
- } catch (err) {
29
- res.status(err?.status ?? 500).json({ error: err?.message })
30
- }
31
- return
32
- }
33
- res.setHeader('Allow', 'GET, POST')
34
- res.status(405).json({ error: 'Method Not Allowed' })
35
- }