@adonis-agora/media 0.17.0 → 0.18.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # @adonis-agora/media
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#80](https://github.com/DavideCarvalho/adonis-agora-media/pull/80) [`e83f7d2`](https://github.com/DavideCarvalho/adonis-agora-media/commit/e83f7d2ca0d57ca2af770d7b9385b18fb96c60c2) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Breaking (0.x minor):** the dashboard's paginated listings now use the ecosystem's shared **cursor** pagination interface, the same one `@adonis-agora/filter` defines — `{ after, first }` in, `{ …items, nextCursor, prevCursor, hasNext, hasPrev }` out. Every `@adonis-agora/*` library is converging on that interface so a caller learns it once.
8
+
9
+ Filter defines two mechanisms — offset and cursor. This package adopts the **cursor** one (not offset), because its listings are backed by S3's `ListObjectsV2` continuation token and, for `/collections`, a `createdAt`/`id` keyset. Those are opaque, forward-only handles to *what comes next*: there is no way to compute an offset or seek to page 7, so cursor is the honest match rather than a workaround.
10
+
11
+ **Forward-only, deliberately.** Filter's `CursorParams` also carries `before` / `last`; this package does **not** accept them — better a compile error than a silently ignored parameter — and pins `prevCursor: null` / `hasPrev: false` in every response. Those two fields stay present so the page *is* the ecosystem's `CursorPage` shape rather than a near-miss of it. Walk forward and keep the pages you've seen (which is what the console SPA does).
12
+
13
+ What changed:
14
+
15
+ - `DashboardService.objects(disk, { prefix?, cursor?, limit? })` → `objects(disk, { prefix?, after?, first? })`. Its result `{ folders, files, cursor? }` → `{ folders, files, nextCursor, prevCursor, hasNext, hasPrev }`. `objects` keeps **two** payload arrays instead of a single `items`: a delimiter listing returns folders (common prefixes) *and* files in the same page, and merging them would lose that distinction — its type is `CursorPageInfo & { folders, files }`, i.e. filter's page envelope with a two-part payload.
16
+ - `DashboardService.collections({ …filters, cursor?, limit? })` → `collections({ …filters, after?, first? })`, returning `CursorPage<MediaEntry>` verbatim (`items` + the envelope) instead of `{ items, nextCursor }`.
17
+ - Routes: `GET /objects` and `GET /collections` now read `?after=&first=` instead of `?cursor=&limit=`.
18
+ - New exported types on both `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard/types`: `CursorParams`, `CursorPage<T>`, `CursorPageInfo`.
19
+ - Page sizes are unchanged — the SPA still asks for 50 per page, only the parameter name moved.
20
+
21
+ Not changed: `MediaStore.list` and the `ExtendedDisk.list` driver keep their `{ cursor, limit }` → `{ items, nextCursor }` / `{ folders, files, cursor }` vocabulary. Those are persistence/driver SPIs that custom stores and disks implement, not listing APIs a client calls; the dashboard maps `after` → `cursor` and `first` → `limit` at its boundary.
22
+
23
+ Migration — a hand-rolled route over `DashboardService`:
24
+
25
+ ```ts
26
+ // before
27
+ const page = await dashboard.objects('s3', {
28
+ prefix: request.input('prefix'),
29
+ cursor: request.input('cursor'),
30
+ limit: 100,
31
+ })
32
+ render(page.folders, page.files)
33
+ const more = page.cursor
34
+
35
+ // after
36
+ const page = await dashboard.objects('s3', {
37
+ prefix: request.input('prefix'),
38
+ after: request.input('after'),
39
+ first: 100,
40
+ })
41
+ render(page.folders, page.files)
42
+ const more = page.hasNext ? page.nextCursor : null // prevCursor is always null: forward-only
43
+ ```
44
+
45
+ And a browser client call:
46
+
47
+ ```ts
48
+ // before
49
+ await client.collections({ ownerType: 'Post', cursor: page.nextCursor ?? undefined, limit: 50 })
50
+ // after
51
+ await client.collections({ ownerType: 'Post', after: page.nextCursor ?? undefined, first: 50 })
52
+ ```
53
+
3
54
  ## 0.17.0
4
55
 
5
56
  ### Minor Changes