@antelopejs/dms-media 0.0.5 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-media",
3
- "version": "0.0.5",
3
+ "version": "0.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
+ "!dist/.tsbuildinfo",
11
12
  "frontend-vue",
12
13
  "src",
13
14
  "tsconfig.json"
@@ -27,13 +28,13 @@
27
28
  "registry": "https://registry.npmjs.org/"
28
29
  },
29
30
  "scripts": {
30
- "build": "rimraf dist && tsc -p tsconfig.build.json",
31
+ "build": "rimraf dist && tsc",
31
32
  "dev:frontend": "pnpm frontend:dev",
32
33
  "frontend:dev": "cd playground && pnpm frontend:dev",
33
34
  "dev": "ajs project run -w -p playground",
34
35
  "lint:fix": "oxlint --fix --max-warnings=1000000 && oxfmt . && pnpm --dir frontend-vue lint:fix",
35
36
  "lint": "oxlint && oxfmt --check . && pnpm --dir frontend-vue lint",
36
- "typecheck": "tsc -p tsconfig.json",
37
+ "typecheck": "tsc --noEmit",
37
38
  "format": "oxfmt . && pnpm --dir frontend-vue format",
38
39
  "test": "pnpm run build && ajs module test .",
39
40
  "test:unit": "pnpm run build && DMS_MEDIA_TEST_DIR=dist/test/unit ajs module test .",
@@ -46,17 +47,17 @@
46
47
  "dependencies": {
47
48
  "@antelopejs/interface-api": ">=0.0.13 <1.0.0",
48
49
  "@antelopejs/interface-api-util": ">=0.1.2 <1.0.0",
49
- "@antelopejs/interface-core": ">=0.0.13 <1.0.0",
50
+ "@antelopejs/interface-core": ">=0.1.1 <1.0.0",
50
51
  "@antelopejs/interface-database": ">=0.1.7 <1.0.0",
51
52
  "@antelopejs/interface-database-decorators": ">=0.1.6 <1.0.0",
52
- "@antelopejs/interface-dms": ">=0.0.1 <1.0.0",
53
+ "@antelopejs/interface-dms": ">=0.2.0 <1.0.0",
53
54
  "@antelopejs/interface-file-storage": ">=0.1.3 <1.0.0",
54
55
  "node-cron": "^4.2.1",
55
56
  "sharp": "^0.34.4",
56
57
  "zod": "~3.24.2"
57
58
  },
58
59
  "devDependencies": {
59
- "@antelopejs/core": ">=1.8.0 <2",
60
+ "@antelopejs/core": ">=1.9.1 <2",
60
61
  "@antelopejs/tooling-configs": ">=0.0.6 <1.0.0",
61
62
  "@types/chai": "^4.3.20",
62
63
  "@types/mocha": "^10",
@@ -72,7 +73,7 @@
72
73
  "release-it": "^19.2.4",
73
74
  "release-it-changelogen": "^0.1.0",
74
75
  "rimraf": "^6.1.3",
75
- "typescript": "^5.9.3"
76
+ "typescript": "^6.0.3"
76
77
  },
77
78
  "packageManager": "pnpm@10.2.0",
78
79
  "pnpm": {
@@ -1,13 +1,13 @@
1
1
  import {
2
- MEDIA_ACCESS_PERMISSION,
3
2
  MEDIA_FOLDERS_MANAGE_PERMISSION,
4
3
  MEDIA_UPLOAD_PERMISSION,
5
4
  } from "../constants";
5
+ import { MEDIA_PAGE_PERMISSION } from "../pages/media";
6
6
  import type { AclEntry } from "../types";
7
7
 
8
8
  export const DEFAULT_ROOT_ACL: AclEntry[] = [
9
9
  {
10
- subject: { kind: "permission", id: MEDIA_ACCESS_PERMISSION },
10
+ subject: { kind: "permission", id: MEDIA_PAGE_PERMISSION },
11
11
  rights: ["read"],
12
12
  },
13
13
  {
package/src/constants.ts CHANGED
@@ -1,4 +1,3 @@
1
- export const MEDIA_ACCESS_PERMISSION = "media.access";
2
1
  export const MEDIA_UPLOAD_PERMISSION = "media.upload";
3
2
  export const MEDIA_FOLDERS_MANAGE_PERMISSION = "media.folders.manage";
4
3
  export const MEDIA_PERMISSIONS_MANAGE_PERMISSION = "media.permissions.manage";
@@ -1,28 +1,26 @@
1
1
  import {
2
2
  Category,
3
+ GetPermissionId,
3
4
  PageController,
4
5
  RegisterPage,
5
6
  settingsCategory,
6
7
  } from "@antelopejs/interface-dms/page";
7
8
  import { DefaultLayout } from "@antelopejs/interface-dms/base";
8
9
  import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
9
- import { MEDIA_ACCESS_PERMISSION } from "../constants";
10
10
 
11
11
  const MEDIA_LIBRARY_COMPONENT = "dms-media-library";
12
12
 
13
13
  // Media section of the settings area, mirroring the built-in "User settings"
14
- // group. `authOnly` keeps the section itself grant-free: pages inside carry
15
- // the real permissions, and the settings index only shows the group when at
16
- // least one page in it is accessible.
14
+ // group. Pages inside carry their own default permissions, and the settings
15
+ // index only shows the group when at least one page in it is accessible.
17
16
  export const mediaSettingsCategory = Category("media", {
18
17
  category: settingsCategory,
19
18
  displayName: "Media",
20
19
  icon: "i-ph-images",
21
20
  order: 2,
22
- authOnly: true,
23
21
  });
24
22
 
25
- // Single entry point to the media library, gated by the media permission.
23
+ // Single entry point to the media library, gated by its default page permission.
26
24
  @RegisterPage()
27
25
  export class SettingsAssetsPage extends PageController(
28
26
  "assets",
@@ -31,9 +29,19 @@ export class SettingsAssetsPage extends PageController(
31
29
  icon: "i-ph-images",
32
30
  category: mediaSettingsCategory,
33
31
  description: "Browse and manage the media library",
34
- permission: { id: MEDIA_ACCESS_PERMISSION },
35
32
  },
36
33
  DefaultLayout({ fullWidth: true }),
37
34
  ) {
38
35
  static content = CustomComponent(MEDIA_LIBRARY_COMPONENT);
39
36
  }
37
+
38
+ function requirePagePermissionId(page: typeof SettingsAssetsPage): string {
39
+ const permissionId = GetPermissionId(page);
40
+ if (!permissionId) {
41
+ throw new Error(`Page ${page.name} has no registered permission`);
42
+ }
43
+ return permissionId;
44
+ }
45
+
46
+ export const MEDIA_PAGE_PERMISSION =
47
+ requirePagePermissionId(SettingsAssetsPage);
@@ -3,39 +3,33 @@ import {
3
3
  RegisterPermission,
4
4
  } from "@antelopejs/interface-dms/permissions";
5
5
  import {
6
- MEDIA_ACCESS_PERMISSION,
7
6
  MEDIA_FOLDERS_MANAGE_PERMISSION,
8
7
  MEDIA_PERMISSIONS_MANAGE_PERMISSION,
9
8
  MEDIA_UPLOAD_PERMISSION,
10
9
  } from "./constants";
10
+ import { MEDIA_PAGE_PERMISSION } from "./pages/media";
11
11
 
12
12
  const MEDIA_PERMISSIONS: Permission[] = [
13
- {
14
- id: MEDIA_ACCESS_PERMISSION,
15
- title: "Access media library",
16
- icon: "i-ph-images",
17
- description: "See the media library and browse readable folders",
18
- },
19
13
  {
20
14
  id: MEDIA_UPLOAD_PERMISSION,
21
15
  title: "Upload media",
22
16
  icon: "i-ph-upload-simple",
23
17
  description: "Upload files into writable folders",
24
- dependencies: [MEDIA_ACCESS_PERMISSION],
18
+ dependencies: [MEDIA_PAGE_PERMISSION],
25
19
  },
26
20
  {
27
21
  id: MEDIA_FOLDERS_MANAGE_PERMISSION,
28
22
  title: "Manage media folders",
29
23
  icon: "i-ph-folder-plus",
30
24
  description: "Create, rename, move and delete media folders",
31
- dependencies: [MEDIA_ACCESS_PERMISSION],
25
+ dependencies: [MEDIA_PAGE_PERMISSION],
32
26
  },
33
27
  {
34
28
  id: MEDIA_PERMISSIONS_MANAGE_PERMISSION,
35
29
  title: "Manage media permissions",
36
30
  icon: "i-ph-lock-key",
37
31
  description: "Edit folder access rules of the media library",
38
- dependencies: [MEDIA_ACCESS_PERMISSION],
32
+ dependencies: [MEDIA_PAGE_PERMISSION],
39
33
  },
40
34
  ];
41
35
 
@@ -108,7 +108,7 @@ export default defineConfig({
108
108
  source: {
109
109
  type: "package",
110
110
  package: "@antelopejs/dms",
111
- version: ">=0.0.1 <1.0.0",
111
+ version: ">=0.4.0 <1.0.0",
112
112
  },
113
113
  config: {
114
114
  auth: {
@@ -120,7 +120,7 @@ export default defineConfig({
120
120
  source: {
121
121
  type: "package",
122
122
  package: "@antelopejs/mongodb",
123
- version: "1.3.0",
123
+ version: "1.3.1",
124
124
  },
125
125
  },
126
126
  "auth-jwt": {
@@ -137,24 +137,25 @@ export default defineConfig({
137
137
  source: {
138
138
  type: "package",
139
139
  package: "@antelopejs/api",
140
- version: "1.2.5",
140
+ version: "1.3.0",
141
141
  },
142
142
  config: {
143
143
  servers: [{ protocol: "http", host: "127.0.0.1", port: API_PORT }],
144
+ publicBaseUrl: `http://127.0.0.1:${API_PORT}`,
144
145
  },
145
146
  },
146
147
  "file-storage-local": {
147
148
  source: {
148
149
  type: "package",
149
150
  package: "@antelopejs/file-storage-local",
150
- version: "0.1.4",
151
+ version: "0.1.5",
151
152
  },
152
153
  },
153
154
  nodemailer: {
154
155
  source: {
155
156
  type: "package",
156
157
  package: "@antelopejs/nodemailer",
157
- version: "0.0.4",
158
+ version: "0.0.5",
158
159
  },
159
160
  config: {
160
161
  host: SMTP_HOST,
@@ -2,11 +2,11 @@ import type { AxiosInstance } from "axios";
2
2
  import { expect } from "chai";
3
3
  import { RegisterAssetBinding } from "../../asset-type/bindings";
4
4
  import {
5
- MEDIA_ACCESS_PERMISSION,
6
5
  MEDIA_FOLDERS_MANAGE_PERMISSION,
7
6
  MEDIA_PERMISSIONS_MANAGE_PERMISSION,
8
7
  MEDIA_UPLOAD_PERMISSION,
9
8
  } from "../../constants";
9
+ import { MEDIA_PAGE_PERMISSION } from "../../pages/media";
10
10
  import type { AclEntry } from "../../types";
11
11
  import {
12
12
  rawGet,
@@ -155,17 +155,17 @@ async function createWorldRoles(): Promise<WorldRoles> {
155
155
  secretTeam,
156
156
  latecomer,
157
157
  ] = await Promise.all([
158
- createRole("media-viewer", [MEDIA_ACCESS_PERMISSION]),
158
+ createRole("media-viewer", [MEDIA_PAGE_PERMISSION]),
159
159
  createRole("media-uploader", [
160
- MEDIA_ACCESS_PERMISSION,
160
+ MEDIA_PAGE_PERMISSION,
161
161
  MEDIA_UPLOAD_PERMISSION,
162
162
  ]),
163
163
  createRole("media-folder-manager", [
164
- MEDIA_ACCESS_PERMISSION,
164
+ MEDIA_PAGE_PERMISSION,
165
165
  MEDIA_FOLDERS_MANAGE_PERMISSION,
166
166
  ]),
167
167
  createRole("media-permissions-manager", [
168
- MEDIA_ACCESS_PERMISSION,
168
+ MEDIA_PAGE_PERMISSION,
169
169
  MEDIA_FOLDERS_MANAGE_PERMISSION,
170
170
  MEDIA_PERMISSIONS_MANAGE_PERMISSION,
171
171
  ]),
@@ -219,7 +219,7 @@ async function buildWorldFolders(
219
219
  await setFolderAcl(owner, vault, []);
220
220
  await setFolderAcl(owner, pocket, [roleEntry(secretTeamRoleId, ["read"])]);
221
221
  await setFolderAcl(owner, readOnlyCorner, [
222
- permissionEntry(MEDIA_ACCESS_PERMISSION, ["read"]),
222
+ permissionEntry(MEDIA_PAGE_PERMISSION, ["read"]),
223
223
  ]);
224
224
  const flip = await owner.post(`/api/media/folders/${publicZone}/visibility`, {
225
225
  visibility: "public",
@@ -302,7 +302,7 @@ describe("[integration] media permissions — multi-actor ACL enforcement", () =
302
302
  expect(tree.root).to.deep.equal({ write: false, manage: false });
303
303
  });
304
304
 
305
- it("shows only root-inherited folders to a media.access holder", async () => {
305
+ it("shows only root-inherited folders to a media page permission holder", async () => {
306
306
  const tree = await fetchTree(sessions.viewer.client);
307
307
  const library = findById(tree, folders.library);
308
308
  expect(library, "library").to.not.equal(undefined);
@@ -364,7 +364,9 @@ describe("[integration] media permissions — multi-actor ACL enforcement", () =
364
364
  it("unions permission and role subjects across multiple roles", async () => {
365
365
  const tree = await fetchTree(sessions.hybrid.client);
366
366
  const library = findById(tree, folders.library);
367
- expect(library, "library via media.access").to.not.equal(undefined);
367
+ expect(library, "library via the media page permission").to.not.equal(
368
+ undefined,
369
+ );
368
370
  expect((library as TreeFolderNode).rights.read).to.equal(true);
369
371
  const restricted = findById(tree, folders.restricted);
370
372
  expect(restricted, "restricted via secret-team").to.not.equal(undefined);
@@ -874,7 +876,7 @@ describe("[integration] media permissions — multi-actor ACL enforcement", () =
874
876
  it("grants access on the next request when the role gains a permission", async () => {
875
877
  const before = await fetchTree(sessions.latecomer.client);
876
878
  expect(before.folders).to.deep.equal([]);
877
- await setRolePermissions(roles.latecomer, [MEDIA_ACCESS_PERMISSION]);
879
+ await setRolePermissions(roles.latecomer, [MEDIA_PAGE_PERMISSION]);
878
880
  const after = await fetchTree(sessions.latecomer.client);
879
881
  expect(
880
882
  findById(after, folders.library),
@@ -5,6 +5,7 @@ import {
5
5
  import { expect } from "chai";
6
6
  import { filterGrantablePermissions } from "../../../acl/grantable";
7
7
  import { OWNER_WILDCARD_PERMISSION } from "../../../constants";
8
+ import { MEDIA_PAGE_PERMISSION } from "../../../pages/media";
8
9
 
9
10
  const MODULE_PAGE_PERMISSION = "classified.page";
10
11
  const MODULE_ACTION_PERMISSION = "classified.page.table.edit";
@@ -21,11 +22,11 @@ describe("[unit] acl/grantable — filterGrantablePermissions", () => {
21
22
 
22
23
  it("keeps regular permissions untouched", () => {
23
24
  const filtered = filterGrantablePermissions(
24
- new Set([REGULAR_PERMISSION, "media.access"]),
25
+ new Set([REGULAR_PERMISSION, MEDIA_PAGE_PERMISSION]),
25
26
  );
26
27
  expect([...filtered].sort()).to.deep.equal([
27
28
  REGULAR_PERMISSION,
28
- "media.access",
29
+ MEDIA_PAGE_PERMISSION,
29
30
  ]);
30
31
  });
31
32
 
@@ -7,10 +7,10 @@ import {
7
7
  resolveRootRights,
8
8
  } from "../../../acl/resolver";
9
9
  import {
10
- MEDIA_ACCESS_PERMISSION,
11
10
  MEDIA_FOLDERS_MANAGE_PERMISSION,
12
11
  MEDIA_UPLOAD_PERMISSION,
13
12
  } from "../../../constants";
13
+ import { MEDIA_PAGE_PERMISSION } from "../../../pages/media";
14
14
  import type { MediaFolder } from "../../../db/tables";
15
15
  import type { AclEntry } from "../../../types";
16
16
 
@@ -67,7 +67,7 @@ describe("[unit] acl/resolver — resolveFolderAccess", () => {
67
67
  const folders = [buildFolder({ id: "root" })];
68
68
  const reader = resolveFolderAccess(
69
69
  folders,
70
- buildActor([MEDIA_ACCESS_PERMISSION]),
70
+ buildActor([MEDIA_PAGE_PERMISSION]),
71
71
  DEFAULT_ROOT_ACL,
72
72
  );
73
73
  expect(reader.readable.has("root")).to.equal(true);
@@ -145,7 +145,7 @@ describe("[unit] acl/resolver — resolveFolderAccess", () => {
145
145
 
146
146
  const outsider = resolveFolderAccess(
147
147
  folders,
148
- buildActor([MEDIA_ACCESS_PERMISSION]),
148
+ buildActor([MEDIA_PAGE_PERMISSION]),
149
149
  [],
150
150
  );
151
151
  expect(outsider.readable.has("articles-assets")).to.equal(false);
@@ -175,7 +175,7 @@ describe("[unit] acl/resolver — resolveFolderAccess", () => {
175
175
  ];
176
176
  const actor = resolveFolderAccess(
177
177
  folders,
178
- buildActor([MEDIA_ACCESS_PERMISSION]),
178
+ buildActor([MEDIA_PAGE_PERMISSION]),
179
179
  [],
180
180
  );
181
181
  expect(actor.readable.size).to.equal(0);
@@ -188,7 +188,7 @@ describe("[unit] acl/resolver — resolveFolderAccess", () => {
188
188
  const folders = [buildFolder({ id: "orphan", parentId: "gone" })];
189
189
  const reader = resolveFolderAccess(
190
190
  folders,
191
- buildActor([MEDIA_ACCESS_PERMISSION]),
191
+ buildActor([MEDIA_PAGE_PERMISSION]),
192
192
  DEFAULT_ROOT_ACL,
193
193
  );
194
194
  expect(reader.readable.has("orphan")).to.equal(true);
@@ -273,7 +273,7 @@ describe("[unit] acl/resolver — resolveFolderAccess", () => {
273
273
  ];
274
274
  const reader = resolveFolderAccess(
275
275
  folders,
276
- buildActor([MEDIA_ACCESS_PERMISSION]),
276
+ buildActor([MEDIA_PAGE_PERMISSION]),
277
277
  DEFAULT_ROOT_ACL,
278
278
  );
279
279
  expect(reader.readable.has("sane")).to.equal(true);
package/tsconfig.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "noEmit": true,
4
3
  "moduleResolution": "bundler",
5
4
  "target": "esnext",
6
- "module": "preserve",
5
+ "module": "commonjs",
7
6
  "lib": ["esnext", "dom"],
8
7
  "allowJs": true,
9
8
  "outDir": "dist",
@@ -23,7 +22,10 @@
23
22
  "paths": {
24
23
  "@antelopejs/dms-media/*": ["./src/*"]
25
24
  },
26
- "rootDir": "src"
25
+ "rootDir": "src",
26
+ "types": ["node", "mocha"],
27
+ "incremental": true,
28
+ "tsBuildInfoFile": "dist/.tsbuildinfo"
27
29
  },
28
30
  "include": ["./src/**/*.ts"]
29
31
  }