@adonis-agora/media-dashboard 6.1.0 → 7.0.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +38 -5
  3. package/dist/index.d.ts +12 -8
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +12 -4
  6. package/dist/index.js.map +1 -1
  7. package/dist/provider/media_dashboard_provider.d.ts +15 -7
  8. package/dist/provider/media_dashboard_provider.d.ts.map +1 -1
  9. package/dist/provider/media_dashboard_provider.js +27 -492
  10. package/dist/provider/media_dashboard_provider.js.map +1 -1
  11. package/dist/spa/assets/{index-BtCClrPE.js → index-Dvw2uJpF.js} +12 -12
  12. package/dist/spa/assets/index-Dvw2uJpF.js.map +1 -0
  13. package/dist/spa/index.html +1 -1
  14. package/package.json +4 -5
  15. package/dist/define_config.d.ts +0 -49
  16. package/dist/define_config.d.ts.map +0 -1
  17. package/dist/define_config.js +0 -5
  18. package/dist/define_config.js.map +0 -1
  19. package/dist/provider/serve.d.ts +0 -23
  20. package/dist/provider/serve.d.ts.map +0 -1
  21. package/dist/provider/serve.js +0 -41
  22. package/dist/provider/serve.js.map +0 -1
  23. package/dist/server/auth.d.ts +0 -76
  24. package/dist/server/auth.d.ts.map +0 -1
  25. package/dist/server/auth.js +0 -134
  26. package/dist/server/auth.js.map +0 -1
  27. package/dist/server/cookie.d.ts +0 -20
  28. package/dist/server/cookie.d.ts.map +0 -1
  29. package/dist/server/cookie.js +0 -44
  30. package/dist/server/cookie.js.map +0 -1
  31. package/dist/server/object_insights.d.ts +0 -42
  32. package/dist/server/object_insights.d.ts.map +0 -1
  33. package/dist/server/object_insights.js +0 -42
  34. package/dist/server/object_insights.js.map +0 -1
  35. package/dist/server/service.d.ts +0 -212
  36. package/dist/server/service.d.ts.map +0 -1
  37. package/dist/server/service.js +0 -470
  38. package/dist/server/service.js.map +0 -1
  39. package/dist/spa/assets/index-BtCClrPE.js.map +0 -1
@@ -1,212 +0,0 @@
1
- import type { Readable } from 'node:stream';
2
- import type { Disk, MediaListOptions, MediaListPage, MediaRecord, MultipartPart, UploadSession } from '@adonis-agora/media';
3
- import type { CollectionFilter, CollectionListResponse, CollectionsSummaryResponse, DiskListResponse, MediaDetailResponse, ObjectDetailResponse, ObjectInsightsResponse, ObjectListResponse, Topology, UploadDetailResponse, UploadListResponse } from '../types.js';
4
- import type { ObjectInsightProvider } from './object_insights.js';
5
- /** TTL of the signed URLs handed to the browser for object preview/download. */
6
- export declare const URL_TTL_SECONDS = 300;
7
- /** Cap on the get→put streaming path used for cross-disk copy/move (drivers can't copy across disks). */
8
- export declare const MAX_TRANSFER_BYTES: number;
9
- /** Page size for the flat sweep that recursive folder delete/copy/move paginates over. */
10
- export declare const FOLDER_SWEEP_LIMIT = 1000;
11
- /** Page size for the client-side scan behind {@link DashboardService.collectionsSummary}. */
12
- export declare const COLLECTIONS_SUMMARY_PAGE_SIZE = 200;
13
- /** Hard cap on records scanned by {@link DashboardService.collectionsSummary} — beyond this the
14
- * rollup is partial rather than unbounded. */
15
- export declare const COLLECTIONS_SUMMARY_SCAN_LIMIT = 5000;
16
- /** Ceiling for a console (direct) upload — buffered in memory, so bounded to protect the process
17
- * heap. Larger files belong on the resumable (TUS) upload path, not this convenience upload. */
18
- export declare const MAX_UPLOAD_BYTES: number;
19
- /** The slice of `MediaManager` the dashboard depends on — kept structural so it's trivial to fake in tests. */
20
- export interface MediaManagerLike {
21
- readonly storage: {
22
- readonly defaultDisk: string;
23
- disk(name?: string): Disk;
24
- };
25
- readonly hasResumable: boolean;
26
- readonly resumable: {
27
- list(filter?: {
28
- disk?: string;
29
- keyPrefix?: string;
30
- }): Promise<UploadSession[]>;
31
- /** Discard an in-flight session (native multipart + buffered parts), then drop its record. */
32
- abort(id: string): Promise<void>;
33
- /** All recorded parts for a session (multipart-capable disks); empty for a buffered session. */
34
- listParts(id: string): Promise<MultipartPart[]>;
35
- };
36
- /** The persistence SPI — the console reads stored records via the cross-owner `list`, and a single
37
- * record (+ delete) for the record-detail drill-in. */
38
- readonly store: {
39
- list(options?: MediaListOptions): Promise<MediaListPage>;
40
- find(id: string): Promise<MediaRecord | null>;
41
- delete(id: string): Promise<void>;
42
- };
43
- }
44
- export interface DashboardServiceOptions {
45
- /** Disk names the console may browse/act on. The first entry (or the manager default) is the default. */
46
- diskNames: string[];
47
- /** Whether mutating actions (copy/move/delete) are permitted. */
48
- actions: boolean;
49
- }
50
- /** An error carrying an HTTP status for the provider to surface verbatim. */
51
- export declare class DashboardError extends Error {
52
- readonly status: number;
53
- constructor(message: string, status: number);
54
- }
55
- /**
56
- * All dashboard read/action logic, expressed over a structural {@link MediaManagerLike}. It reads the
57
- * *real* `@adonis-agora/media` surface — disk `list`/`stat`/`getSignedUrl`/`copy`/`move`/`deleteMany`
58
- * and the resumable `UploadSessionStore.list()` — and never invents its own persistence. The provider
59
- * is a thin HTTP shell around this; the logic is pure and unit-tested without booting AdonisJS.
60
- */
61
- export declare class DashboardService {
62
- private readonly manager;
63
- private readonly options;
64
- /** Host-registered {@link ObjectInsightProvider}s, from `config/media_dashboard.ts`'s `objectInsights`. */
65
- private readonly insightProviders;
66
- constructor(manager: MediaManagerLike, options: DashboardServiceOptions,
67
- /** Host-registered {@link ObjectInsightProvider}s, from `config/media_dashboard.ts`'s `objectInsights`. */
68
- insightProviders?: ObjectInsightProvider[]);
69
- /** Coarse capability topology for the SPA to enable/disable affordances. */
70
- topology(): Topology;
71
- /** Enumerate the exposed disks with their capabilities (non-extended disks report `list:false`). */
72
- disks(): DiskListResponse;
73
- /** List one page of a bucket under `prefix` (cursor-based, folders rolled up on the `/` delimiter). */
74
- objects(diskName: string, params?: {
75
- prefix?: string;
76
- cursor?: string;
77
- limit?: number;
78
- }): Promise<ObjectListResponse>;
79
- /** Object metadata + a short-lived signed URL for preview/download. */
80
- object(diskName: string, key: string): Promise<ObjectDetailResponse>;
81
- /**
82
- * The object's raw byte stream plus the metadata the provider needs to serve it inline. Backs the
83
- * console's same-origin preview proxy so text/PDF render in the browser instead of downloading
84
- * (and so a CORS-locked bucket is still previewable).
85
- */
86
- objectStream(diskName: string, key: string): Promise<{
87
- stream: Readable;
88
- contentType: string;
89
- size: number;
90
- }>;
91
- /**
92
- * What the HOST knows about this object, from every registered `objectInsights` provider (see
93
- * `config/media_dashboard.ts`). `{ insights: [] }` when none are registered. A provider that
94
- * throws is skipped and logged — annotation must never be able to stop an admin opening a file, and
95
- * providers run concurrently so one host lookup being slow doesn't serialize the others.
96
- */
97
- objectInsights(diskName: string, key: string): Promise<ObjectInsightsResponse>;
98
- /** In-progress resumable uploads, projected from the session store (empty when unconfigured). */
99
- uploads(filter?: {
100
- disk?: string;
101
- prefix?: string;
102
- }): Promise<UploadListResponse>;
103
- /** Full detail (+ recorded parts) of one resumable upload session. */
104
- uploadDetail(id: string): Promise<UploadDetailResponse>;
105
- /**
106
- * Cancels a resumable session: discards its native multipart upload (or buffered parts) and drops
107
- * its record, so it stops appearing as in-progress. Actions-gated.
108
- */
109
- abortUpload(id: string): Promise<void>;
110
- /**
111
- * One cursor-paginated page of stored media-library records across owners/collections, projected to
112
- * the SPA's {@link MediaEntry}. Delegates to the real {@link MediaStore.list} — no bespoke query.
113
- */
114
- collections(params?: CollectionFilter & {
115
- cursor?: string;
116
- limit?: number;
117
- }): Promise<CollectionListResponse>;
118
- /**
119
- * Per-collection rollup (record count + total bytes) for the console's collection chips.
120
- * `MediaStore` has no aggregate query, so this walks `list()` in batches and sums client-side —
121
- * bounded at {@link COLLECTIONS_SUMMARY_SCAN_LIMIT} records so a very large library degrades to a
122
- * partial (still useful) summary instead of an unbounded scan.
123
- */
124
- collectionsSummary(): Promise<CollectionsSummaryResponse>;
125
- /**
126
- * Full detail of one stored `MediaRecord`, plus signed URLs for its generated conversions. Only
127
- * conversions carrying a concrete `{disk, path}` artifact get a link — a metadata-only conversion
128
- * (probe results with no output file) has nothing to preview.
129
- */
130
- mediaRecord(id: string): Promise<MediaDetailResponse>;
131
- /** Deletes a stored `MediaRecord`. Actions-gated (does not touch its underlying disk object). */
132
- deleteMediaRecord(id: string): Promise<void>;
133
- /** Server-side copy (same disk) or streamed cross-disk copy. Original is kept. */
134
- copy(body: {
135
- disk: string;
136
- from: string;
137
- to: string;
138
- toDisk?: string;
139
- }): Promise<void>;
140
- /** Server-side move (same disk) or streamed cross-disk move. Source is deleted after transfer. */
141
- move(body: {
142
- disk: string;
143
- from: string;
144
- to: string;
145
- toDisk?: string;
146
- }): Promise<void>;
147
- /** Batched delete of many keys on one disk. */
148
- remove(body: {
149
- disk: string;
150
- keys: string[];
151
- }): Promise<void>;
152
- /**
153
- * Writes an object from a byte stream (a browser upload) — the console's convenience upload,
154
- * distinct from the resumable TUS path. The caller supplies the full key (prefix + filename).
155
- * Bounded at {@link MAX_UPLOAD_BYTES} so a runaway upload can't exhaust the process heap. Actions-gated.
156
- */
157
- putObject(diskName: string, key: string, body: AsyncIterable<Uint8Array>, contentType?: string): Promise<void>;
158
- /**
159
- * Create a "folder" — a zero-byte marker object at `<prefix>/`, which S3-style delimiter listing
160
- * surfaces as a navigable folder. Normalizes to exactly one trailing slash (so the key never
161
- * double-slashes); rejects an empty prefix. Actions-gated.
162
- */
163
- createFolder(body: {
164
- disk: string;
165
- prefix: string;
166
- }): Promise<void>;
167
- /**
168
- * Recursively delete a "folder": every object under `<prefix>/` (nested included) plus the
169
- * zero-byte marker itself. Sweeps with an EMPTY delimiter so the driver lists keys FLAT — the
170
- * default `/` delimiter would roll nested keys up into folder prefixes and the sweep would miss
171
- * them, deleting only direct children. Paginates until the disk reports no more, then deletes the
172
- * marker explicitly (its key equals the sweep prefix, which `list` filters out). Actions-gated.
173
- */
174
- deleteFolder(body: {
175
- disk: string;
176
- prefix: string;
177
- }): Promise<void>;
178
- /** Copy a whole "folder" (every object under `<from>/`, nested included) to `<to>/`, same or cross disk. */
179
- copyFolder(body: {
180
- disk: string;
181
- from: string;
182
- to: string;
183
- toDisk?: string;
184
- }): Promise<void>;
185
- /** Move a whole "folder" (every object under `<from>/`, nested included) to `<to>/`, same or cross disk. */
186
- moveFolder(body: {
187
- disk: string;
188
- from: string;
189
- to: string;
190
- toDisk?: string;
191
- }): Promise<void>;
192
- private transfer;
193
- /**
194
- * Relocate a single object, same disk or across disks. Same-disk uses the driver's native
195
- * `copy`/`move` (server-side, no bytes through the app). Cross-disk has no driver primitive, so the
196
- * object is streamed through the app (get→put, capped at {@link MAX_TRANSFER_BYTES}); a `move` then
197
- * deletes the source. Callers gate actions.
198
- */
199
- private transferKey;
200
- /**
201
- * Shared engine for {@link copyFolder}/{@link moveFolder}. Same flat-listing sweep as
202
- * {@link deleteFolder}; each key is relocated via {@link transferKey} (so cross-disk works
203
- * transparently), preserving its path relative to the source. On the SAME disk, rejects a
204
- * destination inside the source (which would recurse forever); across disks that can't happen. The
205
- * destination folder marker is written, and for a move the source marker removed, so both listings
206
- * stay consistent. Actions-gated.
207
- */
208
- private transferFolder;
209
- private extended;
210
- private assertActions;
211
- }
212
- //# sourceMappingURL=service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/server/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EACV,IAAI,EAGJ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,0BAA0B,EAE1B,gBAAgB,EAChB,mBAAmB,EAEnB,oBAAoB,EAIpB,sBAAsB,EACtB,kBAAkB,EAClB,QAAQ,EACR,oBAAoB,EAEpB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlE,gFAAgF;AAChF,eAAO,MAAM,eAAe,MAAM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