nuxt-media-library 0.0.54 → 0.0.55

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/README.md CHANGED
@@ -52,6 +52,9 @@ export default defineNuxtConfig({
52
52
  baseURL: 'http://media-library.internal/v1',
53
53
  // Only for direct browser uploads (proxyUploads: false): a public address.
54
54
  // publicBaseURL: 'https://media.example.com/v1',
55
+ // false when your own server/api/media-library/[...].ts serves /manage
56
+ // (media grants, below). Default true: the module's /manage proxies.
57
+ // manageProxy: false,
55
58
  // Uploads always go through Nuxt server (/api/media-library/uploads/*)
56
59
  routes: {
57
60
  createSession: '/uploads/sessions',
@@ -103,6 +106,18 @@ request is checked by your rules and sent upstream with a short-lived
103
106
  endpoints, and no long-lived credential reaches the media library from the
104
107
  browser.
105
108
 
109
+ Turn off the module's built-in `/manage` proxies so your handler gets the
110
+ requests. Their routes (`/api/media-library/manage/assets/**`…) are more
111
+ specific than a catch-all file and would otherwise answer first, without
112
+ `authorize` (the module warns at startup when it sees a shadowed catch-all):
113
+
114
+ ```ts
115
+ // nuxt.config.ts
116
+ export default defineNuxtConfig({
117
+ mediaLibrary: { manageProxy: false },
118
+ })
119
+ ```
120
+
106
121
  ```ts
107
122
  // server/api/media-library/[...].ts
108
123
  import { createMLCatchAllProxy, specFromNeed } from '@fritill-team/nuxt-media-library/server'
@@ -139,6 +154,9 @@ export default createMLCatchAllProxy({
139
154
  before they expire; an upload's parts, finalize and abort reuse the grant
140
155
  that created the session.
141
156
  - `/delivery` and the processing metadata routes are not affected.
157
+ - With `manageProxy: false` the module still serves `/api/media-library/delivery/**`
158
+ and, when `serviceUploads.proxy` is on, the service-upload pass-through.
159
+ Your catch-all handles everything else under `/api/media-library`.
142
160
 
143
161
  ### Showing assets of several services: read grants
144
162
 
package/dist/module.d.mts CHANGED
@@ -52,6 +52,16 @@ interface ModuleOptions {
52
52
  baseURL?: string;
53
53
  backends?: Record<string, ServiceUploadBackend>;
54
54
  };
55
+ /**
56
+ * The built-in `/api/media-library/manage/**` proxies (default `true`).
57
+ * Set `false` when the app serves `/manage` itself, e.g. with
58
+ * `createMLCatchAllProxy({ authorize })` in
59
+ * `server/api/media-library/[...].ts`: the built-in routes are more
60
+ * specific than an app's catch-all and would otherwise answer first, so
61
+ * `authorize` would never run. `/delivery/**` and the service-upload
62
+ * pass-through are still registered.
63
+ */
64
+ manageProxy?: boolean;
55
65
  }
56
66
  declare const SERVICE_UPLOADS_ROUTE = "/api/media-library/service-uploads";
57
67
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.d.ts CHANGED
@@ -52,6 +52,16 @@ interface ModuleOptions {
52
52
  baseURL?: string;
53
53
  backends?: Record<string, ServiceUploadBackend>;
54
54
  };
55
+ /**
56
+ * The built-in `/api/media-library/manage/**` proxies (default `true`).
57
+ * Set `false` when the app serves `/manage` itself, e.g. with
58
+ * `createMLCatchAllProxy({ authorize })` in
59
+ * `server/api/media-library/[...].ts`: the built-in routes are more
60
+ * specific than an app's catch-all and would otherwise answer first, so
61
+ * `authorize` would never run. `/delivery/**` and the service-upload
62
+ * pass-through are still registered.
63
+ */
64
+ manageProxy?: boolean;
55
65
  }
56
66
  declare const SERVICE_UPLOADS_ROUTE = "/api/media-library/service-uploads";
57
67
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "media-library",
3
3
  "configKey": "mediaLibrary",
4
- "version": "0.0.54",
4
+ "version": "0.0.55",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { existsSync, readdirSync } from 'node:fs';
2
+ import { join } from 'node:path';
1
3
  import { defineNuxtModule, createResolver, addImportsDir, addComponentsDir, addServerHandler, useLogger, addPlugin } from '@nuxt/kit';
2
4
  export * from '../dist/runtime/types/resourcePolicy.js';
3
5
  export * from '../dist/runtime/types/uploader.js';
@@ -37,6 +39,20 @@ function serviceBackends(backends, logger) {
37
39
  }
38
40
  return out;
39
41
  }
42
+ function appCatchAlls(layers) {
43
+ const found = [];
44
+ for (const { config } of layers) {
45
+ const serverDir = config.serverDir ?? join(config.rootDir, "server");
46
+ for (const sub of ["api/media-library", "api/media-library/manage"]) {
47
+ const dir = join(serverDir, sub);
48
+ if (!existsSync(dir)) continue;
49
+ for (const name of readdirSync(dir)) {
50
+ if (name.startsWith("[...")) found.push(join(dir, name));
51
+ }
52
+ }
53
+ }
54
+ return found;
55
+ }
40
56
  const module$1 = defineNuxtModule({
41
57
  meta: {
42
58
  name: "media-library",
@@ -56,7 +72,8 @@ const module$1 = defineNuxtModule({
56
72
  partSize: 8 * 1024 * 1024,
57
73
  concurrency: 3,
58
74
  checksum: { algorithm: "SHA-256", perPart: true, final: true },
59
- headers: {}
75
+ headers: {},
76
+ manageProxy: true
60
77
  },
61
78
  async setup(options, nuxt) {
62
79
  const resolver = createResolver(import.meta.url);
@@ -101,30 +118,37 @@ const module$1 = defineNuxtModule({
101
118
  route: "/api/media-library/delivery/**",
102
119
  handler: resolver.resolve("./runtime/server/delivery-proxy")
103
120
  });
104
- addServerHandler({
105
- route: "/api/media-library/manage/uploads/**",
106
- handler: resolver.resolve("./runtime/server/uploads-proxy")
107
- });
108
- addServerHandler({
109
- route: "/api/media-library/manage/resource-policies/**",
110
- handler: resolver.resolve("./runtime/server/resource-policy-proxy")
111
- });
112
- addServerHandler({
113
- route: "/api/media-library/manage/resource-policies",
114
- handler: resolver.resolve("./runtime/server/resource-policy-proxy")
115
- });
116
- addServerHandler({
117
- route: "/api/media-library/manage/assets/**",
118
- handler: resolver.resolve("./runtime/server/assets-proxy")
119
- });
120
- addServerHandler({
121
- route: "/api/media-library/manage/assets",
122
- handler: resolver.resolve("./runtime/server/assets-proxy")
123
- });
124
- addServerHandler({
125
- route: "/api/media-library/manage/processing/**",
126
- handler: resolver.resolve("./runtime/server/processing-proxy")
127
- });
121
+ const logger = useLogger("media-library");
122
+ if (options.manageProxy !== false) {
123
+ addServerHandler({
124
+ route: "/api/media-library/manage/uploads/**",
125
+ handler: resolver.resolve("./runtime/server/uploads-proxy")
126
+ });
127
+ addServerHandler({
128
+ route: "/api/media-library/manage/resource-policies/**",
129
+ handler: resolver.resolve("./runtime/server/resource-policy-proxy")
130
+ });
131
+ addServerHandler({
132
+ route: "/api/media-library/manage/resource-policies",
133
+ handler: resolver.resolve("./runtime/server/resource-policy-proxy")
134
+ });
135
+ addServerHandler({
136
+ route: "/api/media-library/manage/assets/**",
137
+ handler: resolver.resolve("./runtime/server/assets-proxy")
138
+ });
139
+ addServerHandler({
140
+ route: "/api/media-library/manage/assets",
141
+ handler: resolver.resolve("./runtime/server/assets-proxy")
142
+ });
143
+ addServerHandler({
144
+ route: "/api/media-library/manage/processing/**",
145
+ handler: resolver.resolve("./runtime/server/processing-proxy")
146
+ });
147
+ const shadowed = appCatchAlls(nuxt.options._layers);
148
+ if (shadowed.length) {
149
+ logger.warn(`${shadowed.join(", ")} will not receive /api/media-library/manage requests: the module's own /manage routes answer first. Set mediaLibrary.manageProxy: false to serve /manage from your handler (e.g. createMLCatchAllProxy({ authorize })).`);
150
+ }
151
+ }
128
152
  if (options.serviceUploads?.proxy) {
129
153
  addServerHandler({
130
154
  route: `${SERVICE_UPLOADS_ROUTE}/**`,
@@ -140,7 +164,6 @@ const module$1 = defineNuxtModule({
140
164
  // grants). Declared so NUXT_MEDIA_LIBRARY_SERVICE_TOKEN applies.
141
165
  serviceToken: existingPrivate.serviceToken ?? ""
142
166
  };
143
- const logger = useLogger("media-library");
144
167
  const publicHeaders = browserHeaders(existingPublic.headers ?? options.headers);
145
168
  if (publicHeaders.dropped.length) {
146
169
  logger.warn(`mediaLibrary.headers: ${publicHeaders.dropped.join(", ")} kept server-side, not sent to browsers.`);
@@ -39,11 +39,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
39
39
  onFiles?: ((files: File[]) => any) | undefined;
40
40
  onRejected?: ((files: RejectedFile[]) => any) | undefined;
41
41
  }>, {
42
+ title: string;
42
43
  variant: "area" | "overlay";
43
44
  compact: boolean;
44
45
  disabled: boolean;
45
46
  multiple: boolean;
46
- title: string;
47
47
  accept: string;
48
48
  maxSize: number | null;
49
49
  maxFiles: number | null;
@@ -39,11 +39,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
39
39
  onFiles?: ((files: File[]) => any) | undefined;
40
40
  onRejected?: ((files: RejectedFile[]) => any) | undefined;
41
41
  }>, {
42
+ title: string;
42
43
  variant: "area" | "overlay";
43
44
  compact: boolean;
44
45
  disabled: boolean;
45
46
  multiple: boolean;
46
- title: string;
47
47
  accept: string;
48
48
  maxSize: number | null;
49
49
  maxFiles: number | null;
@@ -51,10 +51,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
51
51
  "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
52
52
  "onUpdate:alt"?: ((value: string | undefined) => any) | undefined;
53
53
  }>, {
54
- disabled: boolean;
55
- visibility: "private" | "public" | "restricted";
54
+ visibility: "private" | "restricted" | "public";
56
55
  label: string;
57
- profile: string | null;
56
+ disabled: boolean;
58
57
  accept: readonly string[] | string;
59
58
  maxSize: number | null;
60
59
  required: boolean;
@@ -65,6 +64,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
65
64
  enableTranscription?: boolean;
66
65
  };
67
66
  collectionName: string | null;
67
+ profile: string | null;
68
68
  service: string | import("../../index.js").MediaServiceUpload | null;
69
69
  serviceBody: Record<string, unknown> | null;
70
70
  hint: string;
@@ -51,10 +51,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
51
51
  "onUpdate:modelValue"?: ((value: string | null) => any) | undefined;
52
52
  "onUpdate:alt"?: ((value: string | undefined) => any) | undefined;
53
53
  }>, {
54
- disabled: boolean;
55
- visibility: "private" | "public" | "restricted";
54
+ visibility: "private" | "restricted" | "public";
56
55
  label: string;
57
- profile: string | null;
56
+ disabled: boolean;
58
57
  accept: readonly string[] | string;
59
58
  maxSize: number | null;
60
59
  required: boolean;
@@ -65,6 +64,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
65
64
  enableTranscription?: boolean;
66
65
  };
67
66
  collectionName: string | null;
67
+ profile: string | null;
68
68
  service: string | import("../../index.js").MediaServiceUpload | null;
69
69
  serviceBody: Record<string, unknown> | null;
70
70
  hint: string;
@@ -59,10 +59,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
59
59
  "onUpdate:alt"?: ((value: Record<string, string> | undefined) => any) | undefined;
60
60
  "onUpdate:profiles"?: ((profiles: MediaGalleryProfiles) => any) | undefined;
61
61
  }>, {
62
- disabled: boolean;
62
+ visibility: "private" | "restricted" | "public";
63
63
  title: string;
64
- visibility: "private" | "public" | "restricted";
65
- profile: string | null;
64
+ disabled: boolean;
66
65
  accept: readonly string[] | string;
67
66
  max: number | null;
68
67
  maxSize: number | null;
@@ -72,6 +71,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
72
71
  enableTranscription?: boolean;
73
72
  };
74
73
  collectionName: string | null;
74
+ profile: string | null;
75
75
  service: string | import("../../index.js").MediaServiceUpload | null;
76
76
  serviceBody: Record<string, unknown> | null;
77
77
  hint: string;
@@ -59,10 +59,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
59
59
  "onUpdate:alt"?: ((value: Record<string, string> | undefined) => any) | undefined;
60
60
  "onUpdate:profiles"?: ((profiles: MediaGalleryProfiles) => any) | undefined;
61
61
  }>, {
62
- disabled: boolean;
62
+ visibility: "private" | "restricted" | "public";
63
63
  title: string;
64
- visibility: "private" | "public" | "restricted";
65
- profile: string | null;
64
+ disabled: boolean;
66
65
  accept: readonly string[] | string;
67
66
  max: number | null;
68
67
  maxSize: number | null;
@@ -72,6 +71,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
72
71
  enableTranscription?: boolean;
73
72
  };
74
73
  collectionName: string | null;
74
+ profile: string | null;
75
75
  service: string | import("../../index.js").MediaServiceUpload | null;
76
76
  serviceBody: Record<string, unknown> | null;
77
77
  hint: string;
@@ -70,11 +70,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
70
70
  "onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
71
71
  "onUpdate:alt"?: ((value: Record<string, string> | undefined) => any) | undefined;
72
72
  }>, {
73
+ visibility: "private" | "restricted" | "public";
74
+ title: string;
73
75
  disabled: boolean;
74
76
  highlight: ReadonlySet<string> | null;
75
- title: string;
76
- visibility: "private" | "public" | "restricted";
77
- profile: string | null;
78
77
  accept: readonly string[] | string;
79
78
  max: number | null;
80
79
  maxSize: number | null;
@@ -85,6 +84,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
85
84
  enableTranscription?: boolean;
86
85
  };
87
86
  collectionName: string | null;
87
+ profile: string | null;
88
88
  service: string | import("../../index.js").MediaServiceUpload | null;
89
89
  serviceBody: Record<string, unknown> | null;
90
90
  onAdd: (assetId: string, tag: string | undefined) => void;
@@ -70,11 +70,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
70
70
  "onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
71
71
  "onUpdate:alt"?: ((value: Record<string, string> | undefined) => any) | undefined;
72
72
  }>, {
73
+ visibility: "private" | "restricted" | "public";
74
+ title: string;
73
75
  disabled: boolean;
74
76
  highlight: ReadonlySet<string> | null;
75
- title: string;
76
- visibility: "private" | "public" | "restricted";
77
- profile: string | null;
78
77
  accept: readonly string[] | string;
79
78
  max: number | null;
80
79
  maxSize: number | null;
@@ -85,6 +84,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
85
84
  enableTranscription?: boolean;
86
85
  };
87
86
  collectionName: string | null;
87
+ profile: string | null;
88
88
  service: string | import("../../index.js").MediaServiceUpload | null;
89
89
  serviceBody: Record<string, unknown> | null;
90
90
  onAdd: (assetId: string, tag: string | undefined) => void;
@@ -40,11 +40,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
40
40
  asset: AssetDetail | DeliveryAsset | null;
41
41
  src: string | null;
42
42
  progress: number | null;
43
- disabled: boolean;
44
- kind: string | null;
45
43
  name: string;
46
- phase: ProgressVeilPhase | null;
44
+ kind: string | null;
45
+ disabled: boolean;
47
46
  selected: boolean;
47
+ phase: ProgressVeilPhase | null;
48
48
  missingAlt: boolean;
49
49
  onOpen: () => void;
50
50
  duration: number | null;
@@ -40,11 +40,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
40
40
  asset: AssetDetail | DeliveryAsset | null;
41
41
  src: string | null;
42
42
  progress: number | null;
43
- disabled: boolean;
44
- kind: string | null;
45
43
  name: string;
46
- phase: ProgressVeilPhase | null;
44
+ kind: string | null;
45
+ disabled: boolean;
47
46
  selected: boolean;
47
+ phase: ProgressVeilPhase | null;
48
48
  missingAlt: boolean;
49
49
  onOpen: () => void;
50
50
  duration: number | null;
@@ -24,9 +24,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
24
24
  }>, {
25
25
  asset: AssetDetail | DeliveryAsset | null;
26
26
  src: string | null;
27
- disabled: boolean;
28
- kind: string | null;
29
27
  name: string;
28
+ kind: string | null;
29
+ disabled: boolean;
30
30
  selected: boolean;
31
31
  meta: string;
32
32
  disabledReason: string;
@@ -24,9 +24,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
24
24
  }>, {
25
25
  asset: AssetDetail | DeliveryAsset | null;
26
26
  src: string | null;
27
- disabled: boolean;
28
- kind: string | null;
29
27
  name: string;
28
+ kind: string | null;
29
+ disabled: boolean;
30
30
  selected: boolean;
31
31
  meta: string;
32
32
  disabledReason: string;
@@ -20,9 +20,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
20
20
  size: string;
21
21
  asset: AssetDetail | DeliveryAsset | null;
22
22
  src: string | null;
23
- disabled: boolean;
24
- kind: string | null;
25
23
  name: string;
24
+ kind: string | null;
25
+ disabled: boolean;
26
26
  selected: boolean;
27
27
  date: string;
28
28
  disabledReason: string;
@@ -20,9 +20,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
20
20
  size: string;
21
21
  asset: AssetDetail | DeliveryAsset | null;
22
22
  src: string | null;
23
- disabled: boolean;
24
- kind: string | null;
25
23
  name: string;
24
+ kind: string | null;
25
+ disabled: boolean;
26
26
  selected: boolean;
27
27
  date: string;
28
28
  disabledReason: string;
@@ -15,8 +15,8 @@ type __VLS_Props = {
15
15
  };
16
16
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
17
17
  progress: number | null;
18
- compact: boolean;
19
18
  label: string;
19
+ compact: boolean;
20
20
  onCancel: () => void;
21
21
  onRetry: () => void;
22
22
  detail: string;
@@ -15,8 +15,8 @@ type __VLS_Props = {
15
15
  };
16
16
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
17
17
  progress: number | null;
18
- compact: boolean;
19
18
  label: string;
19
+ compact: boolean;
20
20
  onCancel: () => void;
21
21
  onRetry: () => void;
22
22
  detail: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-media-library",
3
- "version": "0.0.54",
3
+ "version": "0.0.55",
4
4
  "description": "Nuxt module for media library management — chunked uploads, asset previews, and resource policies",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,7 +41,7 @@
41
41
  "admin:dev": "yarn dev:prepare && yarn --cwd admin-playground dev",
42
42
  "prepack": "nuxt-module-build build",
43
43
  "lint": "eslint .",
44
- "test": "yarn dev:prepare && nuxi prepare test/fixtures/basic && vitest run"
44
+ "test": "yarn dev:prepare && nuxi prepare test/fixtures/basic && nuxi prepare test/fixtures/manage-grants && vitest run"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@nuxt/ui": "^4.0.0",