@airdraft/plugin-media 0.2.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [0.2.1](https://github.com/aevrHQ/airdraft/compare/plugin-media@v0.2.0...plugin-media@v0.2.1) (2026-05-22)
6
+
7
+
8
+ ### Features
9
+
10
+ * add Next.js app detection and prompt for app directory in init commands ([2ed1afd](https://github.com/aevrHQ/airdraft/commit/2ed1afdd1ba3142fd50a9bfd4133f01c2ad22ae9))
11
+ * add schema editor plugin and GitHub schema adapter for managing airdraft.schema.json ([46fd7f2](https://github.com/aevrHQ/airdraft/commit/46fd7f271afe8bc562d5f2fe72b94390cb257161))
12
+ * add versioning and changelog support for all packages ([d6c85df](https://github.com/aevrHQ/airdraft/commit/d6c85dfed37f11c42151c93b49a80ede90699616))
13
+ * **cli,core,docs:** implement local filesystem mode with enhanced initialization and error handling ([1848408](https://github.com/aevrHQ/airdraft/commit/1848408738ee3d2bfa0ef532e6dec7a3beef0fb1))
14
+ * **cli:** add CMS client template and optional blog scaffolding to initialization ([cf7bda8](https://github.com/aevrHQ/airdraft/commit/cf7bda8137777aa319acd8edf55fb2cd718a9cd1))
15
+ * **cli:** enhance project initialization templates with schema path support ([a3b20c9](https://github.com/aevrHQ/airdraft/commit/a3b20c9d0dbf0e23594079f1685be8d688e7779b))
16
+ * **client:** add convenience methods for listing and retrieving entries ([c48e3f6](https://github.com/aevrHQ/airdraft/commit/c48e3f6848772bf1ed860785e1e3f9eadffb5ddc))
17
+ * **content:** update content package with new field components and type changes ([e1bd5fa](https://github.com/aevrHQ/airdraft/commit/e1bd5fa8af9b2903024c39a0fa945e49f87754d3))
18
+ * enhance media input components and add scoped media adapter for project isolation ([e599cf2](https://github.com/aevrHQ/airdraft/commit/e599cf2c488cf73164d1cb7b1ce479d6005cf923))
19
+ * implement terminal UI helpers for improved user interaction ([0e0dca4](https://github.com/aevrHQ/airdraft/commit/0e0dca4a4e06196abea22e99c9a350fdd202a948))
20
+ * **react-ui:** add CMSAdmin component and update related files for new admin functionality ([50f1459](https://github.com/aevrHQ/airdraft/commit/50f14598c268823615f61428ee1e0e399c610630))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * improve error handling for missing schema file in buildProjectHandler ([4c3d318](https://github.com/aevrHQ/airdraft/commit/4c3d3184c9c454062fd2d9b33fb0593d5e91b71c))
26
+ * update cloud package version to 0.1.4 and enhance audit log persistence logic ([e1fb0e5](https://github.com/aevrHQ/airdraft/commit/e1fb0e5509c7f95c4e659495bcdbd1339da20cea))
27
+ * update package versions and enhance schema cache handling ([7f4f395](https://github.com/aevrHQ/airdraft/commit/7f4f39572168b4e75dd6f1d756ebd5ef2d7ddbe1))
28
+ * update schema URL from airdraft.dev to airdraft.space ([dbace6e](https://github.com/aevrHQ/airdraft/commit/dbace6e13334f915feace70661810d5dc919f69b))
29
+
30
+
31
+ ### Documentation
32
+
33
+ * add Releasing & Publishing section to README ([132193b](https://github.com/aevrHQ/airdraft/commit/132193bebff585ad3223ccb82176c30615f21443))
34
+
35
+ # Changelog
36
+
3
37
  All notable changes to `@airdraft/plugin-media` will be documented here.
4
38
 
5
39
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export { withMedia } from './withMedia.js';
2
2
  export type { WithMediaOptions, MediaUploadResult } from './withMedia.js';
3
+ export { withAutoMedia } from './withAutoMedia.js';
4
+ export type { WithAutoMediaOptions } from './withAutoMedia.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { withMedia } from './withMedia.js';
2
+ export { withAutoMedia } from './withAutoMedia.js';
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,38 @@
1
+ import type { Plugin, StorageAdapter } from '@airdraft/core';
2
+ export interface WithAutoMediaOptions {
3
+ /**
4
+ * Pass the content StorageAdapter to enable the full media library (sidecar
5
+ * metadata at `_media/{key}.json`). Omit for upload-only mode.
6
+ */
7
+ storageAdapter?: StorageAdapter;
8
+ /** Key prefix. Default: `'uploads'` */
9
+ prefix?: string;
10
+ /** MIME allowlist. Default: common image types. */
11
+ allowedTypes?: string[];
12
+ /** Max upload size in bytes. Default: 5 MB. */
13
+ maxSize?: number;
14
+ /**
15
+ * Root directory for local uploads (when `AWS_S3_BUCKET_NAME` is not set).
16
+ * Default: `{cwd}/public` — Next.js serves these files at `/{key}`.
17
+ */
18
+ localRoot?: string;
19
+ }
20
+ /**
21
+ * Builds a media plugin automatically from environment variables.
22
+ *
23
+ * - `AWS_S3_BUCKET_NAME` set → S3-compatible storage via `files-sdk` +
24
+ * `@airdraft/media-adapter-files-sdk` (must be installed separately).
25
+ * - Otherwise → `@airdraft/media-adapter-local` writing to `{localRoot}/public`.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { withAutoMedia } from '@airdraft/plugin-media'
30
+ *
31
+ * const adapter = new LocalAdapter({ root: './content' })
32
+ * const media = await withAutoMedia({ storageAdapter: adapter })
33
+ *
34
+ * export default defineConfig({ adapter, plugins: [media] })
35
+ * ```
36
+ */
37
+ export declare function withAutoMedia(options?: WithAutoMediaOptions): Promise<Plugin>;
38
+ //# sourceMappingURL=withAutoMedia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withAutoMedia.d.ts","sourceRoot":"","sources":["../src/withAutoMedia.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG5D,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BvF"}
@@ -0,0 +1,43 @@
1
+ import { withMedia } from './withMedia.js';
2
+ /**
3
+ * Builds a media plugin automatically from environment variables.
4
+ *
5
+ * - `AWS_S3_BUCKET_NAME` set → S3-compatible storage via `files-sdk` +
6
+ * `@airdraft/media-adapter-files-sdk` (must be installed separately).
7
+ * - Otherwise → `@airdraft/media-adapter-local` writing to `{localRoot}/public`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { withAutoMedia } from '@airdraft/plugin-media'
12
+ *
13
+ * const adapter = new LocalAdapter({ root: './content' })
14
+ * const media = await withAutoMedia({ storageAdapter: adapter })
15
+ *
16
+ * export default defineConfig({ adapter, plugins: [media] })
17
+ * ```
18
+ */
19
+ export async function withAutoMedia(options = {}) {
20
+ const { storageAdapter, prefix = 'uploads', allowedTypes = ['image/jpeg', 'image/png', 'image/webp', 'image/gif', 'image/svg+xml'], maxSize = 5 * 1024 * 1024, localRoot = process.cwd() + '/public', } = options;
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ let adapter;
23
+ if (process.env.AWS_S3_BUCKET_NAME) {
24
+ // Dynamic — requires files-sdk + @airdraft/media-adapter-files-sdk to be installed.
25
+ const { Files } = await import('files-sdk');
26
+ const { s3 } = await import('files-sdk/s3');
27
+ const { FilesSdkMediaAdapter } = await import('@airdraft/media-adapter-files-sdk');
28
+ const files = new Files({
29
+ adapter: s3({
30
+ bucket: process.env.AWS_S3_BUCKET_NAME,
31
+ region: process.env.AWS_REGION ?? 'us-east-1',
32
+ // Credentials auto-loaded from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
33
+ }),
34
+ });
35
+ adapter = new FilesSdkMediaAdapter({ files });
36
+ }
37
+ else {
38
+ const { LocalMediaAdapter } = await import('@airdraft/media-adapter-local');
39
+ adapter = new LocalMediaAdapter({ root: localRoot });
40
+ }
41
+ return withMedia({ adapter, storageAdapter, prefix, allowedTypes, maxSize });
42
+ }
43
+ //# sourceMappingURL=withAutoMedia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withAutoMedia.js","sourceRoot":"","sources":["../src/withAutoMedia.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAqB1C;;;;;;;;;;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AAE,OAAO,EAAE,CAAC,CAAA;AAC9E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airdraft/plugin-media",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Airdraft media plugin — image upload, optimisation, CDN",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,11 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
- "files": ["dist", "README.md", "CHANGELOG.md"],
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "CHANGELOG.md"
18
+ ],
15
19
  "scripts": {
16
20
  "build": "tsc",
17
21
  "dev": "tsc --watch",
@@ -25,7 +29,9 @@
25
29
  "release:minor": "standard-version --release-as minor",
26
30
  "release:major": "standard-version --release-as major"
27
31
  },
28
- "publishConfig": { "access": "public" },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
29
35
  "license": "MIT",
30
36
  "devDependencies": {
31
37
  "@types/node": "^20.0.0",
@@ -37,5 +43,7 @@
37
43
  "dependencies": {
38
44
  "@airdraft/core": "*"
39
45
  },
40
- "engines": { "node": ">=18.0.0" }
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ }
41
49
  }