@ossy/resources 1.12.0 → 1.12.2

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 (67) hide show
  1. package/package.json +10 -4
  2. package/src/AudioResource.jsx +4 -2
  3. package/src/CreateDirectory.jsx +4 -3
  4. package/src/CreateDocument.jsx +4 -3
  5. package/src/DocumentEdit.jsx +9 -6
  6. package/src/DocumentView.jsx +8 -4
  7. package/src/GenericResourceCard.jsx +4 -2
  8. package/src/GenericResourceDetail.jsx +9 -4
  9. package/src/GenericResourceForm.jsx +5 -2
  10. package/src/ImageResource.jsx +4 -2
  11. package/src/PDFResource.jsx +4 -2
  12. package/src/ResourceContentPage.jsx +4 -2
  13. package/src/ResourceDescription.jsx +4 -3
  14. package/src/ResourceDetails.jsx +9 -4
  15. package/src/ResourceDialogMove.jsx +4 -3
  16. package/src/ResourceFactory.jsx +6 -3
  17. package/src/ResourceGenericView.jsx +4 -2
  18. package/src/ResourceList.jsx +4 -2
  19. package/src/ResourcePanel.jsx +9 -12
  20. package/src/ResourceTags.jsx +4 -3
  21. package/src/ResourcesPage.jsx +4 -2
  22. package/src/UploadResources.jsx +4 -3
  23. package/src/VideoResource.jsx +4 -2
  24. package/src/create-page-view.action.js +1 -38
  25. package/src/create-page-view.task.js +38 -0
  26. package/src/create.action.js +1 -98
  27. package/src/create.task.js +100 -0
  28. package/src/delete.action.js +1 -31
  29. package/src/delete.task.js +31 -0
  30. package/src/en.translations.json +5 -5
  31. package/src/get-page-view-stats.action.js +1 -65
  32. package/src/get-page-view-stats.task.js +64 -0
  33. package/src/get.action.js +1 -14
  34. package/src/get.task.js +14 -0
  35. package/src/index.js +13 -4
  36. package/src/list.action.js +1 -19
  37. package/src/list.task.js +20 -0
  38. package/src/resource-create.page.jsx +4 -3
  39. package/src/resource.helpers.js +83 -0
  40. package/src/resources.action-media.js +18 -0
  41. package/src/resources.attach-media-urls.js +1 -1
  42. package/src/resources.events.js +1 -0
  43. package/src/resources.spec.js +54 -55
  44. package/src/search.action.js +1 -19
  45. package/src/search.task.js +20 -0
  46. package/src/server.js +4 -0
  47. package/src/sv.translations.json +5 -5
  48. package/src/update-access.action.js +1 -20
  49. package/src/update-access.task.js +22 -0
  50. package/src/update-content.action.js +1 -39
  51. package/src/update-content.task.js +41 -0
  52. package/src/update-location.action.js +1 -18
  53. package/src/update-location.task.js +20 -0
  54. package/src/update-name.action.js +1 -18
  55. package/src/update-name.task.js +20 -0
  56. package/src/upload-named-version.action.js +1 -42
  57. package/src/upload-named-version.task.js +46 -0
  58. package/src/item-access.api.js +0 -34
  59. package/src/item-content.api.js +0 -35
  60. package/src/item-location.api.js +0 -34
  61. package/src/item-name.api.js +0 -34
  62. package/src/item-version.api.js +0 -48
  63. package/src/item.api.js +0 -58
  64. package/src/list.api.js +0 -43
  65. package/src/page-views-stats.api.js +0 -23
  66. package/src/page-views.api.js +0 -23
  67. package/src/search.api.js +0 -27
@@ -1,34 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
- import { attachResourceMediaUrls } from './resources.attach-media-urls.js'
3
-
4
- const pathRe = /^\/api\/v0\/resources\/([^/]+)\/location$/
5
-
6
- export const metadata = {
7
- id: 'resources.item.location',
8
- path: '/api/v0/resources/:resourceId/location',
9
- }
10
-
11
- export default async function handle(req, res) {
12
- if (req.method !== 'PUT') {
13
- res.setHeader('Allow', 'PUT')
14
- res.status(405).json({ error: 'Method Not Allowed' })
15
- return
16
- }
17
- const pathname = (req.path || new URL(req.originalUrl, 'http://localhost').pathname).replace(/\/+$/, '')
18
- const m = pathname.match(pathRe)
19
- if (!m) {
20
- res.status(404).json('')
21
- return
22
- }
23
- const resourceId = decodeURIComponent(m[1])
24
- try {
25
- const resource = await ActionService.invoke('resources/update-location', {
26
- payload: { resourceId, target: req.body?.target, userId: req.userId },
27
- req,
28
- })
29
- const withUrls = await attachResourceMediaUrls(resource, { userId: req.userId, workspaceId: req.workspaceId })
30
- res.json(withUrls)
31
- } catch (err) {
32
- res.status(err?.status ?? 500).json({ error: err?.message })
33
- }
34
- }
@@ -1,34 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
- import { attachResourceMediaUrls } from './resources.attach-media-urls.js'
3
-
4
- const pathRe = /^\/api\/v0\/resources\/([^/]+)\/name$/
5
-
6
- export const metadata = {
7
- id: 'resources.item.name',
8
- path: '/api/v0/resources/:resourceId/name',
9
- }
10
-
11
- export default async function handle(req, res) {
12
- if (req.method !== 'PUT') {
13
- res.setHeader('Allow', 'PUT')
14
- res.status(405).json({ error: 'Method Not Allowed' })
15
- return
16
- }
17
- const pathname = (req.path || new URL(req.originalUrl, 'http://localhost').pathname).replace(/\/+$/, '')
18
- const m = pathname.match(pathRe)
19
- if (!m) {
20
- res.status(404).json('')
21
- return
22
- }
23
- const resourceId = decodeURIComponent(m[1])
24
- try {
25
- const resource = await ActionService.invoke('resources/update-name', {
26
- payload: { resourceId, name: req.body?.name, userId: req.userId },
27
- req,
28
- })
29
- const withUrls = await attachResourceMediaUrls(resource, { userId: req.userId, workspaceId: req.workspaceId })
30
- res.json(withUrls)
31
- } catch (err) {
32
- res.status(err?.status ?? 500).json({ error: err?.message })
33
- }
34
- }
@@ -1,48 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
- import { attachResourceMediaUrls } from './resources.attach-media-urls.js'
3
-
4
- const pathRe = /^\/api\/v0\/resources\/([^/]+)\/([^/]+)$/
5
- const reservedSecond = new Set(['name', 'location', 'content', 'access'])
6
-
7
- export const metadata = {
8
- id: 'resources.item.version',
9
- path: '/api/v0/resources/:resourceId/:namedVersion',
10
- }
11
-
12
- export default async function handle(req, res) {
13
- if (req.method !== 'PUT') {
14
- res.setHeader('Allow', 'PUT')
15
- res.status(405).json({ error: 'Method Not Allowed' })
16
- return
17
- }
18
- const pathname = (req.path || new URL(req.originalUrl, 'http://localhost').pathname).replace(/\/+$/, '')
19
- const m = pathname.match(pathRe)
20
- if (!m) {
21
- res.status(404).json('')
22
- return
23
- }
24
- const namedVersion = decodeURIComponent(m[2])
25
- if (reservedSecond.has(namedVersion)) {
26
- res.status(404).json('')
27
- return
28
- }
29
- const resourceId = decodeURIComponent(m[1])
30
- try {
31
- const resource = await ActionService.invoke('resources/upload-named-version', {
32
- payload: {
33
- resourceId,
34
- namedVersion,
35
- type: req.body?.type,
36
- size: req.body?.size,
37
- userId: req.userId,
38
- workspaceId: req.workspaceId,
39
- },
40
- integrations: req.integrations,
41
- req,
42
- })
43
- const withUrls = await attachResourceMediaUrls(resource, { userId: req.userId, workspaceId: req.workspaceId })
44
- res.json(withUrls)
45
- } catch (err) {
46
- res.status(err?.status ?? 400).json({ error: err?.message })
47
- }
48
- }
package/src/item.api.js DELETED
@@ -1,58 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
- import { attachResourceMediaUrls } from './resources.attach-media-urls.js'
3
-
4
- const pathRe = /^\/api\/v0\/resources\/([^/]+)$/
5
-
6
- export const metadata = {
7
- id: 'resources.item',
8
- path: '/api/v0/resources/:resourceId',
9
- }
10
-
11
- function mediaContext(req) {
12
- return { userId: req.userId, workspaceId: req.workspaceId }
13
- }
14
-
15
- export default async function handle(req, res) {
16
- const pathname = (req.path || new URL(req.originalUrl, 'http://localhost').pathname).replace(/\/+$/, '')
17
- const m = pathname.match(pathRe)
18
- if (!m) {
19
- res.status(404).json('')
20
- return
21
- }
22
- const segment = decodeURIComponent(m[1])
23
- const reserved = new Set(['search', 'page-views'])
24
- if (reserved.has(segment)) {
25
- res.status(404).json('')
26
- return
27
- }
28
-
29
- req.params = { ...req.params, resourceId: segment }
30
-
31
- if (req.method === 'GET') {
32
- try {
33
- const resource = await ActionService.invoke('resources/get', {
34
- payload: { resourceId: segment },
35
- req,
36
- })
37
- const withUrls = await attachResourceMediaUrls(resource, mediaContext(req))
38
- res.json(withUrls)
39
- } catch (err) {
40
- res.status(err?.status ?? 500).json({ error: err?.message })
41
- }
42
- return
43
- }
44
- if (req.method === 'DELETE') {
45
- try {
46
- await ActionService.invoke('resources/delete', {
47
- payload: { resourceId: segment, userId: req.userId },
48
- req,
49
- })
50
- res.status(204).end()
51
- } catch (err) {
52
- res.status(err?.status ?? 500).json({ error: err?.message })
53
- }
54
- return
55
- }
56
- res.setHeader('Allow', 'GET, DELETE')
57
- res.status(405).json({ error: 'Method Not Allowed' })
58
- }
package/src/list.api.js DELETED
@@ -1,43 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
- import { attachResourceMediaUrls } from './resources.attach-media-urls.js'
3
-
4
- export const metadata = {
5
- id: 'resources.list',
6
- path: '/api/v0/resources',
7
- }
8
-
9
- function mediaContext(req) {
10
- return { userId: req.userId, workspaceId: req.workspaceId }
11
- }
12
-
13
- export default async function handle(req, res) {
14
- if (req.method === 'POST') {
15
- try {
16
- const resource = await ActionService.invoke('resources/create', {
17
- payload: { ...req.body, userId: req.userId, workspaceId: req.workspaceId },
18
- integrations: req.integrations,
19
- req,
20
- })
21
- const withUrls = await attachResourceMediaUrls(resource, mediaContext(req))
22
- res.json(withUrls)
23
- } catch (err) {
24
- res.status(err?.status ?? 500).json({ error: err?.message })
25
- }
26
- return
27
- }
28
- if (req.method === 'GET') {
29
- try {
30
- const resources = await ActionService.invoke('resources/list', {
31
- payload: { query: req.query, workspaceId: req.workspaceId, userId: req.userId, user: req.user },
32
- req,
33
- })
34
- const withUrls = await Promise.all(resources.map(r => attachResourceMediaUrls(r, mediaContext(req))))
35
- res.json(withUrls)
36
- } catch (err) {
37
- res.status(err?.status ?? 500).json({ error: err?.message })
38
- }
39
- return
40
- }
41
- res.setHeader('Allow', 'GET, POST')
42
- res.status(405).json({ error: 'Method Not Allowed' })
43
- }
@@ -1,23 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'resources.pageViews.stats',
5
- path: '/api/v0/resources/page-views/stats',
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
- try {
15
- const result = await ActionService.invoke('resources/get-page-view-stats', {
16
- payload: { workspaceId: req.workspaceId, from: req.query?.from, to: req.query?.to, limit: req.query?.limit },
17
- req,
18
- })
19
- res.json(result)
20
- } catch (err) {
21
- res.status(err?.status ?? 500).json({ error: err?.message })
22
- }
23
- }
@@ -1,23 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
-
3
- export const metadata = {
4
- id: 'resources.pageViews',
5
- path: '/api/v0/resources/page-views',
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
- const result = await ActionService.invoke('resources/create-page-view', {
16
- payload: { ...req.body, workspaceId: req.workspaceId, userId: req.userId },
17
- req,
18
- })
19
- res.status(201).json(result)
20
- } catch (err) {
21
- res.status(err?.status ?? 500).json({ error: err?.message })
22
- }
23
- }
package/src/search.api.js DELETED
@@ -1,27 +0,0 @@
1
- import { ActionService } from '@ossy/platform'
2
- import { attachResourceMediaUrls } from './resources.attach-media-urls.js'
3
-
4
- export const metadata = {
5
- id: 'resources.search',
6
- path: '/api/v0/resources/search',
7
- }
8
-
9
- export default async function handle(req, res) {
10
- if (req.method !== 'POST') {
11
- res.setHeader('Allow', 'POST')
12
- res.status(405).json({ error: 'Method Not Allowed' })
13
- return
14
- }
15
- try {
16
- const resources = await ActionService.invoke('resources/search', {
17
- payload: { ...req.body, workspaceId: req.workspaceId, user: req.user },
18
- req,
19
- })
20
- const withUrls = await Promise.all(
21
- resources.map(r => attachResourceMediaUrls(r, { userId: req.userId, workspaceId: req.workspaceId }))
22
- )
23
- res.json(withUrls)
24
- } catch (err) {
25
- res.status(err?.status ?? 500).json({ error: err?.message })
26
- }
27
- }