@antelopejs/dms-media 0.1.4 → 0.2.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/README.md +21 -5
- package/dist/bindings.d.ts +9 -0
- package/dist/{asset-type/bindings.js → bindings.js} +10 -5
- package/dist/bindings.js.map +1 -0
- package/dist/implementations/interface-dms-media/index.d.ts +7 -0
- package/dist/implementations/interface-dms-media/index.js +16 -0
- package/dist/implementations/interface-dms-media/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/public.d.ts +2 -0
- package/dist/public.js +10 -0
- package/dist/public.js.map +1 -0
- package/dist/routes/media/context.js +1 -1
- package/dist/routes/media/context.js.map +1 -1
- package/dist/routes/media/folders.d.ts +1 -1
- package/dist/test/antelope.test.js +1 -1
- package/dist/test/integration/media-bindings.test.js +4 -4
- package/dist/test/integration/media-bindings.test.js.map +1 -1
- package/dist/test/integration/media-permissions.test.js +3 -3
- package/dist/test/integration/media-permissions.test.js.map +1 -1
- package/dist/test/unit/{asset-type/bindings.test.js → bindings.test.js} +2 -2
- package/dist/test/unit/bindings.test.js.map +1 -0
- package/dist/types.d.ts +1 -10
- package/dist/validation/media.schema.d.ts +19 -19
- package/frontend-vue/app/components/finder/components/FilterMenu.vue +3 -3
- package/frontend-vue/app/components/finder/layout/navigation/Breadcrumbs.vue +4 -3
- package/frontend-vue/app/components/finder/layout/panel/Shortcuts.vue +1 -1
- package/frontend-vue/app/components/finder/layout/view/List.vue +1 -1
- package/frontend-vue/app/components/picker/PickerColumnsView.vue +1 -1
- package/frontend-vue/app/components/picker/PickerGridView.vue +1 -1
- package/frontend-vue/app/components/picker/PickerListView.vue +1 -1
- package/package.json +14 -16
- package/src/{asset-type/bindings.ts → bindings.ts} +12 -27
- package/src/implementations/interface-dms-media/index.ts +13 -0
- package/src/index.ts +6 -1
- package/src/public.ts +43 -0
- package/src/routes/media/context.ts +1 -1
- package/src/test/antelope.test.ts +1 -1
- package/src/test/integration/media-bindings.test.ts +1 -1
- package/src/test/integration/media-permissions.test.ts +1 -1
- package/src/test/unit/{asset-type/bindings.test.ts → bindings.test.ts} +3 -3
- package/src/types.ts +6 -13
- package/dist/asset-type/asset-type.d.ts +0 -24
- package/dist/asset-type/asset-type.js +0 -54
- package/dist/asset-type/asset-type.js.map +0 -1
- package/dist/asset-type/bindings.d.ts +0 -19
- package/dist/asset-type/bindings.js.map +0 -1
- package/dist/asset-type/index.d.ts +0 -2
- package/dist/asset-type/index.js +0 -19
- package/dist/asset-type/index.js.map +0 -1
- package/dist/test/unit/asset-type/bindings.test.js.map +0 -1
- package/src/asset-type/asset-type.ts +0 -61
- package/src/asset-type/index.ts +0 -2
- package/tsconfig.json +0 -31
- /package/dist/test/unit/{asset-type/bindings.test.d.ts → bindings.test.d.ts} +0 -0
|
@@ -12,17 +12,17 @@ export declare const aclEntrySchema: z.ZodObject<{
|
|
|
12
12
|
}>;
|
|
13
13
|
rights: z.ZodArray<z.ZodEnum<["read", "write", "manage"]>, "many">;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
rights: ("read" | "write" | "manage")[];
|
|
15
16
|
subject: {
|
|
16
17
|
kind: "permission" | "role";
|
|
17
18
|
id: string;
|
|
18
19
|
};
|
|
19
|
-
rights: ("read" | "write" | "manage")[];
|
|
20
20
|
}, {
|
|
21
|
+
rights: ("read" | "write" | "manage")[];
|
|
21
22
|
subject: {
|
|
22
23
|
kind: "permission" | "role";
|
|
23
24
|
id: string;
|
|
24
25
|
};
|
|
25
|
-
rights: ("read" | "write" | "manage")[];
|
|
26
26
|
}>;
|
|
27
27
|
export declare const createFolderSchema: z.ZodObject<{
|
|
28
28
|
name: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -69,33 +69,33 @@ export declare const folderAclSchema: z.ZodObject<{
|
|
|
69
69
|
}>;
|
|
70
70
|
rights: z.ZodArray<z.ZodEnum<["read", "write", "manage"]>, "many">;
|
|
71
71
|
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
rights: ("read" | "write" | "manage")[];
|
|
72
73
|
subject: {
|
|
73
74
|
kind: "permission" | "role";
|
|
74
75
|
id: string;
|
|
75
76
|
};
|
|
76
|
-
rights: ("read" | "write" | "manage")[];
|
|
77
77
|
}, {
|
|
78
|
+
rights: ("read" | "write" | "manage")[];
|
|
78
79
|
subject: {
|
|
79
80
|
kind: "permission" | "role";
|
|
80
81
|
id: string;
|
|
81
82
|
};
|
|
82
|
-
rights: ("read" | "write" | "manage")[];
|
|
83
83
|
}>, "many">>;
|
|
84
84
|
}, "strip", z.ZodTypeAny, {
|
|
85
85
|
entries: {
|
|
86
|
+
rights: ("read" | "write" | "manage")[];
|
|
86
87
|
subject: {
|
|
87
88
|
kind: "permission" | "role";
|
|
88
89
|
id: string;
|
|
89
90
|
};
|
|
90
|
-
rights: ("read" | "write" | "manage")[];
|
|
91
91
|
}[] | null;
|
|
92
92
|
}, {
|
|
93
93
|
entries: {
|
|
94
|
+
rights: ("read" | "write" | "manage")[];
|
|
94
95
|
subject: {
|
|
95
96
|
kind: "permission" | "role";
|
|
96
97
|
id: string;
|
|
97
98
|
};
|
|
98
|
-
rights: ("read" | "write" | "manage")[];
|
|
99
99
|
}[] | null;
|
|
100
100
|
}>;
|
|
101
101
|
export declare const presignSchema: z.ZodObject<{
|
|
@@ -104,27 +104,27 @@ export declare const presignSchema: z.ZodObject<{
|
|
|
104
104
|
size: z.ZodNumber;
|
|
105
105
|
mimetype: z.ZodString;
|
|
106
106
|
}, "strip", z.ZodTypeAny, {
|
|
107
|
-
folderId: string;
|
|
108
|
-
mimetype: string;
|
|
109
107
|
size: number;
|
|
110
108
|
filename: string;
|
|
111
|
-
}, {
|
|
112
109
|
folderId: string;
|
|
113
110
|
mimetype: string;
|
|
111
|
+
}, {
|
|
114
112
|
size: number;
|
|
115
113
|
filename: string;
|
|
114
|
+
folderId: string;
|
|
115
|
+
mimetype: string;
|
|
116
116
|
}>;
|
|
117
117
|
export declare const confirmUploadSchema: z.ZodObject<{
|
|
118
118
|
folderId: z.ZodString;
|
|
119
119
|
resourceKey: z.ZodString;
|
|
120
120
|
filename: z.ZodEffects<z.ZodString, string, string>;
|
|
121
121
|
}, "strip", z.ZodTypeAny, {
|
|
122
|
-
folderId: string;
|
|
123
122
|
filename: string;
|
|
123
|
+
folderId: string;
|
|
124
124
|
resourceKey: string;
|
|
125
125
|
}, {
|
|
126
|
-
folderId: string;
|
|
127
126
|
filename: string;
|
|
127
|
+
folderId: string;
|
|
128
128
|
resourceKey: string;
|
|
129
129
|
}>;
|
|
130
130
|
export declare const updateAssetSchema: z.ZodObject<{
|
|
@@ -165,55 +165,55 @@ export declare const transformSchema: z.ZodEffects<z.ZodObject<{
|
|
|
165
165
|
width: z.ZodEffects<z.ZodNumber, number, number>;
|
|
166
166
|
height: z.ZodEffects<z.ZodNumber, number, number>;
|
|
167
167
|
}, "strip", z.ZodTypeAny, {
|
|
168
|
-
width: number;
|
|
169
168
|
height: number;
|
|
169
|
+
width: number;
|
|
170
170
|
x: number;
|
|
171
171
|
y: number;
|
|
172
172
|
}, {
|
|
173
|
-
width: number;
|
|
174
173
|
height: number;
|
|
174
|
+
width: number;
|
|
175
175
|
x: number;
|
|
176
176
|
y: number;
|
|
177
177
|
}>, {
|
|
178
|
-
width: number;
|
|
179
178
|
height: number;
|
|
179
|
+
width: number;
|
|
180
180
|
x: number;
|
|
181
181
|
y: number;
|
|
182
182
|
}, {
|
|
183
|
-
width: number;
|
|
184
183
|
height: number;
|
|
184
|
+
width: number;
|
|
185
185
|
x: number;
|
|
186
186
|
y: number;
|
|
187
187
|
}>>;
|
|
188
188
|
rotate: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, number>>;
|
|
189
189
|
}, "strip", z.ZodTypeAny, {
|
|
190
190
|
crop?: {
|
|
191
|
-
width: number;
|
|
192
191
|
height: number;
|
|
192
|
+
width: number;
|
|
193
193
|
x: number;
|
|
194
194
|
y: number;
|
|
195
195
|
} | undefined;
|
|
196
196
|
rotate?: number | undefined;
|
|
197
197
|
}, {
|
|
198
198
|
crop?: {
|
|
199
|
-
width: number;
|
|
200
199
|
height: number;
|
|
200
|
+
width: number;
|
|
201
201
|
x: number;
|
|
202
202
|
y: number;
|
|
203
203
|
} | undefined;
|
|
204
204
|
rotate?: number | undefined;
|
|
205
205
|
}>, {
|
|
206
206
|
crop?: {
|
|
207
|
-
width: number;
|
|
208
207
|
height: number;
|
|
208
|
+
width: number;
|
|
209
209
|
x: number;
|
|
210
210
|
y: number;
|
|
211
211
|
} | undefined;
|
|
212
212
|
rotate?: number | undefined;
|
|
213
213
|
}, {
|
|
214
214
|
crop?: {
|
|
215
|
-
width: number;
|
|
216
215
|
height: number;
|
|
216
|
+
width: number;
|
|
217
217
|
x: number;
|
|
218
218
|
y: number;
|
|
219
219
|
} | undefined;
|
|
@@ -53,10 +53,10 @@ const isFilterChecked = (type: FilterType) => {
|
|
|
53
53
|
return current.includes(type);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
const filterItems = computed<DropdownMenuItem[]>(() => [
|
|
56
|
+
const filterItems = computed<DropdownMenuItem[][]>(() => [
|
|
57
57
|
[{ label: t("dms.finder.filter.title"), type: "label" }],
|
|
58
58
|
[
|
|
59
|
-
...FILTER_TYPES.map((type) => ({
|
|
59
|
+
...FILTER_TYPES.map((type): DropdownMenuItem => ({
|
|
60
60
|
label: t(FILTER_LABELS[type]),
|
|
61
61
|
icon: FILTER_ICONS[type],
|
|
62
62
|
type: "checkbox",
|
|
@@ -67,7 +67,7 @@ const filterItems = computed<DropdownMenuItem[]>(() => [
|
|
|
67
67
|
],
|
|
68
68
|
[{ label: t("dms.finder.filter.sort_by"), type: "label" }],
|
|
69
69
|
[
|
|
70
|
-
...SORT_OPTIONS.map((option) => ({
|
|
70
|
+
...SORT_OPTIONS.map((option): DropdownMenuItem => ({
|
|
71
71
|
label: t(SORT_LABELS[option]),
|
|
72
72
|
icon: SORT_ICONS[option],
|
|
73
73
|
type: "checkbox",
|
|
@@ -24,7 +24,7 @@ const breadcrumbs = computed<BreadcrumbItemWithClick[]>(() => {
|
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const items = folders
|
|
28
28
|
.map((id, index, arr): BreadcrumbItemWithClick | undefined => {
|
|
29
29
|
const folder = map.value.folders.get(id);
|
|
30
30
|
if (!folder) return;
|
|
@@ -40,8 +40,9 @@ const breadcrumbs = computed<BreadcrumbItemWithClick[]>(() => {
|
|
|
40
40
|
: undefined,
|
|
41
41
|
};
|
|
42
42
|
})
|
|
43
|
-
.filter((f): f is BreadcrumbItemWithClick => f !== undefined)
|
|
44
|
-
|
|
43
|
+
.filter((f): f is BreadcrumbItemWithClick => f !== undefined);
|
|
44
|
+
|
|
45
|
+
return [root, ...items];
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
const hiddenItems = computed<DropdownMenuItem[]>(() => {
|
|
@@ -205,7 +205,7 @@ watch([currentFile, selectedItems], updateSelectedRow, {
|
|
|
205
205
|
:ghost-ref="getGhostRef(row.original.id)"
|
|
206
206
|
>
|
|
207
207
|
<FinderLayoutViewCardGhost
|
|
208
|
-
:ref="(el) => setRowGhostRef(row.original.id, el)"
|
|
208
|
+
:ref="(el: unknown) => setRowGhostRef(row.original.id, el)"
|
|
209
209
|
:icon="getItemIcon(row.original)"
|
|
210
210
|
:preview="getItemPreview(row.original)"
|
|
211
211
|
/>
|
|
@@ -141,7 +141,7 @@ function rowClass(item: MockItemPublic): string {
|
|
|
141
141
|
<DmsMediaPickerNameEdit
|
|
142
142
|
v-if="renamingId === item.id"
|
|
143
143
|
:name="item.name"
|
|
144
|
-
@commit="(name) => commitRename(item, name)"
|
|
144
|
+
@commit="(name: string) => commitRename(item, name)"
|
|
145
145
|
@cancel="cancelRename"
|
|
146
146
|
/>
|
|
147
147
|
<template v-else>{{ item.name }}</template>
|
|
@@ -119,7 +119,7 @@ function itemTitle(item: MockItemPublic): string | undefined {
|
|
|
119
119
|
<DmsMediaPickerNameEdit
|
|
120
120
|
v-if="renamingId === item.id"
|
|
121
121
|
:name="item.name"
|
|
122
|
-
@commit="(name) => commitRename(item, name)"
|
|
122
|
+
@commit="(name: string) => commitRename(item, name)"
|
|
123
123
|
@cancel="cancelRename"
|
|
124
124
|
/>
|
|
125
125
|
<div
|
|
@@ -142,7 +142,7 @@ function modifiedLabel(item: MockItemPublic): string {
|
|
|
142
142
|
<DmsMediaPickerNameEdit
|
|
143
143
|
v-if="renamingId === item.id"
|
|
144
144
|
:name="item.name"
|
|
145
|
-
@commit="(name) => commitRename(item, name)"
|
|
145
|
+
@commit="(name: string) => commitRename(item, name)"
|
|
146
146
|
@cancel="cancelRename"
|
|
147
147
|
/>
|
|
148
148
|
<span
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms-media",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/AntelopeJS/dms-media.git"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
+
"LICENSE",
|
|
10
11
|
"dist",
|
|
11
12
|
"!dist/.tsbuildinfo",
|
|
12
13
|
"frontend-vue",
|
|
13
|
-
"src"
|
|
14
|
-
"tsconfig.json"
|
|
14
|
+
"src"
|
|
15
15
|
],
|
|
16
16
|
"main": "dist/index.js",
|
|
17
|
-
"types": "dist/
|
|
17
|
+
"types": "dist/public.d.ts",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"types": "./dist/
|
|
21
|
-
"default": "./dist/
|
|
20
|
+
"types": "./dist/public.d.ts",
|
|
21
|
+
"default": "./dist/public.js"
|
|
22
22
|
},
|
|
23
23
|
"./package.json": "./package.json"
|
|
24
24
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"registry": "https://registry.npmjs.org/"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "rimraf dist && tsc",
|
|
31
|
+
"build": "pnpm --filter @antelopejs/interface-dms-media build && rimraf dist && tsc",
|
|
32
32
|
"dev:frontend": "pnpm frontend:dev",
|
|
33
33
|
"frontend:dev": "cd playground && pnpm frontend:dev",
|
|
34
34
|
"dev": "ajs project run -w -p playground",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"test": "pnpm run build && ajs module test .",
|
|
40
40
|
"test:unit": "pnpm run build && DMS_MEDIA_TEST_DIR=dist/test/unit ajs module test .",
|
|
41
41
|
"test:integration": "pnpm run build && DMS_MEDIA_TEST_DIR=dist/test/integration ajs module test .",
|
|
42
|
-
"
|
|
42
|
+
"test:reload": "pnpm run build && node --test --test-force-exit tests/hot-reload.test.mjs",
|
|
43
|
+
"test:frontend": "ajs dms verify-source --layer node_modules/@antelopejs/dms/frontend-vue --module frontend-vue",
|
|
44
|
+
"release": "pnpm --filter @antelopejs/interface-dms-media build && pnpm --dir frontend-vue install --frozen-lockfile && release-it",
|
|
43
45
|
"prepack": "pnpm run build",
|
|
44
46
|
"knip": "knip --dependencies",
|
|
45
47
|
"knip:all": "knip"
|
|
@@ -51,6 +53,7 @@
|
|
|
51
53
|
"@antelopejs/interface-database": ">=0.1.8 <1.0.0",
|
|
52
54
|
"@antelopejs/interface-database-decorators": ">=0.1.7 <1.0.0",
|
|
53
55
|
"@antelopejs/interface-dms": ">=0.2.8 <1.0.0",
|
|
56
|
+
"@antelopejs/interface-dms-media": ">=0.1.0 <0.2.0",
|
|
54
57
|
"@antelopejs/interface-file-storage": ">=0.1.3 <1.0.0",
|
|
55
58
|
"node-cron": "^4.2.1",
|
|
56
59
|
"sharp": "^0.34.4",
|
|
@@ -58,6 +61,8 @@
|
|
|
58
61
|
},
|
|
59
62
|
"devDependencies": {
|
|
60
63
|
"@antelopejs/core": ">=1.10.1 <2",
|
|
64
|
+
"@antelopejs/dms": ">=0.5.0 <1.0.0",
|
|
65
|
+
"@antelopejs/dms-frontend": ">=0.3.6 <0.4.0",
|
|
61
66
|
"@antelopejs/tooling-configs": ">=0.0.7 <1.0.0",
|
|
62
67
|
"@types/chai": "^4.3.20",
|
|
63
68
|
"@types/mocha": "^10",
|
|
@@ -76,17 +81,10 @@
|
|
|
76
81
|
"typescript": "^6.0.3"
|
|
77
82
|
},
|
|
78
83
|
"packageManager": "pnpm@10.2.0",
|
|
79
|
-
"pnpm": {
|
|
80
|
-
"onlyBuiltDependencies": [
|
|
81
|
-
"sharp",
|
|
82
|
-
"mongodb-memory-server-core",
|
|
83
|
-
"esbuild"
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
84
|
"antelopeJs": {
|
|
87
85
|
"baseUrl": "dist",
|
|
88
86
|
"implements": [
|
|
89
|
-
"@antelopejs/dms-media"
|
|
87
|
+
"@antelopejs/interface-dms-media"
|
|
90
88
|
],
|
|
91
89
|
"test": "src/test/antelope.test.ts"
|
|
92
90
|
}
|
|
@@ -1,33 +1,13 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import type { ControllerClass } from "@antelopejs/interface-api";
|
|
3
2
|
import { GetPermissionId } from "@antelopejs/interface-dms/page";
|
|
4
|
-
import {
|
|
3
|
+
import type { AssetBindingConfig } from "@antelopejs/interface-dms-media";
|
|
4
|
+
import { serializeAcl } from "./acl";
|
|
5
5
|
import {
|
|
6
6
|
MEDIA_FOLDERS_MANAGE_PERMISSION,
|
|
7
7
|
MEDIA_PERMISSIONS_MANAGE_PERMISSION,
|
|
8
|
-
} from "
|
|
9
|
-
import type { MediaFolder, MediaFolderModel } from "
|
|
10
|
-
import type { AclEntry } from "
|
|
11
|
-
|
|
12
|
-
export interface AssetPermissionMapping {
|
|
13
|
-
read?: string[];
|
|
14
|
-
write?: string[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface AssetBindingConfig {
|
|
18
|
-
id: string;
|
|
19
|
-
folderName?: string;
|
|
20
|
-
permissionMapping?: AssetPermissionMapping;
|
|
21
|
-
/**
|
|
22
|
-
* Page controller whose effective permission becomes the default read and
|
|
23
|
-
* write mapping of the linked folder. Resolved lazily at provisioning time,
|
|
24
|
-
* so the binding can reference the page class it is declared in. Explicit
|
|
25
|
-
* `permissionMapping` entries take precedence per right: an explicit empty
|
|
26
|
-
* array opts that right out of the page-derived fallback entirely.
|
|
27
|
-
*/
|
|
28
|
-
permissionsFromPage?: ControllerClass;
|
|
29
|
-
acl?: AclEntry[];
|
|
30
|
-
}
|
|
8
|
+
} from "./constants";
|
|
9
|
+
import type { MediaFolder, MediaFolderModel } from "./db";
|
|
10
|
+
import type { AclEntry } from "./types";
|
|
31
11
|
|
|
32
12
|
export const CONTENT_ROOT_BINDING = "dms-media.content-root";
|
|
33
13
|
const CONTENT_ROOT_NAME = "Content";
|
|
@@ -37,8 +17,13 @@ const registeredBindings = new Map<string, AssetBindingConfig>();
|
|
|
37
17
|
const provisionedTenants = new Map<string, string>();
|
|
38
18
|
const provisioningLocks = new Map<string, Promise<void>>();
|
|
39
19
|
|
|
40
|
-
export function
|
|
41
|
-
registeredBindings.set(
|
|
20
|
+
export function addAssetBinding(id: string, config: AssetBindingConfig): void {
|
|
21
|
+
registeredBindings.set(id, config);
|
|
22
|
+
provisionedTenants.clear();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function removeAssetBinding(id: string): void {
|
|
26
|
+
registeredBindings.delete(id);
|
|
42
27
|
provisionedTenants.clear();
|
|
43
28
|
}
|
|
44
29
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AssetBindingConfig } from "@antelopejs/interface-dms-media";
|
|
2
|
+
import { addAssetBinding, removeAssetBinding } from "../../bindings";
|
|
3
|
+
|
|
4
|
+
export namespace internal {
|
|
5
|
+
export const RegisterAssetBinding = {
|
|
6
|
+
register: (id: string, config: AssetBindingConfig): void => {
|
|
7
|
+
addAssetBinding(id, config);
|
|
8
|
+
},
|
|
9
|
+
unregister: (id: string): void => {
|
|
10
|
+
removeAssetBinding(id);
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { ImplementInterface } from "@antelopejs/interface-core";
|
|
2
3
|
import { AddFrontendModule } from "@antelopejs/interface-dms/page";
|
|
3
4
|
import { Logging } from "@antelopejs/interface-core/logging";
|
|
4
5
|
import "./db";
|
|
@@ -8,7 +9,7 @@ import { type DmsMediaConfig, configureMediaModule } from "./config";
|
|
|
8
9
|
import { registerMediaCrons } from "./crons";
|
|
9
10
|
|
|
10
11
|
export * from "./acl";
|
|
11
|
-
export * from "./
|
|
12
|
+
export * from "./bindings";
|
|
12
13
|
export * from "./config";
|
|
13
14
|
export * from "./constants";
|
|
14
15
|
export * from "./crons";
|
|
@@ -24,6 +25,10 @@ let cronTasks: ScheduledTask[] = [];
|
|
|
24
25
|
|
|
25
26
|
export async function construct(config: DmsMediaConfig = {}): Promise<void> {
|
|
26
27
|
configureMediaModule(config);
|
|
28
|
+
ImplementInterface(
|
|
29
|
+
await import("@antelopejs/interface-dms-media"),
|
|
30
|
+
await import("./implementations/interface-dms-media"),
|
|
31
|
+
);
|
|
27
32
|
const sourcePath = path.join(__dirname, "../frontend-vue");
|
|
28
33
|
|
|
29
34
|
await AddFrontendModule({
|
package/src/public.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `import ... from "@antelopejs/dms-media"` resolves to, through the
|
|
3
|
+
* package `exports` map. The AntelopeJS module entry is `main`
|
|
4
|
+
* (`dist/index.js`), which only the runtime loads.
|
|
5
|
+
*
|
|
6
|
+
* This file re-exports `@antelopejs/interface-dms-media` and nothing of the
|
|
7
|
+
* module itself, so a consumer importing it gets the shared interface and
|
|
8
|
+
* never evaluates the module's pages, permissions or routes under its own
|
|
9
|
+
* context. Each name is re-exported individually so editors flag it as
|
|
10
|
+
* deprecated at the import site.
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
export {
|
|
15
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
16
|
+
ASSET_DATA_TYPE_ID,
|
|
17
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
18
|
+
ASSET_PICKER_COMPONENT,
|
|
19
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
20
|
+
AssetType,
|
|
21
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
22
|
+
RegisterAssetBinding,
|
|
23
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
24
|
+
UnregisterAssetBinding,
|
|
25
|
+
} from "@antelopejs/interface-dms-media";
|
|
26
|
+
export type {
|
|
27
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
28
|
+
AclEntry,
|
|
29
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
30
|
+
AclRight,
|
|
31
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
32
|
+
AclSubject,
|
|
33
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
34
|
+
AclSubjectKind,
|
|
35
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
36
|
+
AssetBindingConfig,
|
|
37
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
38
|
+
AssetPermissionMapping,
|
|
39
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
40
|
+
AssetPickerComponentOptions,
|
|
41
|
+
/** @deprecated Import it from `@antelopejs/interface-dms-media`. */
|
|
42
|
+
AssetTypeOptions,
|
|
43
|
+
} from "@antelopejs/interface-dms-media";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
resolveFolderAccess,
|
|
18
18
|
resolveRootRights,
|
|
19
19
|
} from "../../acl";
|
|
20
|
-
import { ensureTenantBindings } from "../../
|
|
20
|
+
import { ensureTenantBindings } from "../../bindings";
|
|
21
21
|
import { getMediaConfig } from "../../config";
|
|
22
22
|
import { MEDIA_PERMISSIONS_MANAGE_PERMISSION } from "../../constants";
|
|
23
23
|
import type { MediaAssetModel, MediaFolder, MediaFolderModel } from "../../db";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
|
|
8
8
|
import type { AxiosInstance } from "axios";
|
|
9
9
|
import { expect } from "chai";
|
|
10
|
-
import { RegisterAssetBinding } from "
|
|
10
|
+
import { RegisterAssetBinding } from "@antelopejs/interface-dms-media";
|
|
11
11
|
import { authorizedClient } from "../helpers/http";
|
|
12
12
|
import { ensureOwnerSession } from "../helpers/owner";
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AxiosInstance } from "axios";
|
|
2
2
|
import { expect } from "chai";
|
|
3
|
-
import { RegisterAssetBinding } from "
|
|
3
|
+
import { RegisterAssetBinding } from "@antelopejs/interface-dms-media";
|
|
4
4
|
import {
|
|
5
5
|
MEDIA_FOLDERS_MANAGE_PERMISSION,
|
|
6
6
|
MEDIA_PERMISSIONS_MANAGE_PERMISSION,
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
} from "@antelopejs/interface-dms/page";
|
|
7
7
|
import { CustomComponent } from "@antelopejs/interface-dms/base/custom";
|
|
8
8
|
import { expect } from "chai";
|
|
9
|
-
import { buildBindingAcl } from "
|
|
9
|
+
import { buildBindingAcl } from "../../bindings";
|
|
10
10
|
import {
|
|
11
11
|
MEDIA_FOLDERS_MANAGE_PERMISSION,
|
|
12
12
|
MEDIA_PERMISSIONS_MANAGE_PERMISSION,
|
|
13
|
-
} from "
|
|
14
|
-
import type { AclEntry } from "
|
|
13
|
+
} from "../../constants";
|
|
14
|
+
import type { AclEntry } from "../../types";
|
|
15
15
|
|
|
16
16
|
@RegisterPage()
|
|
17
17
|
class BindingProbePage extends PageController("binding-probe", {
|
package/src/types.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
id: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface AclEntry {
|
|
11
|
-
subject: AclSubject;
|
|
12
|
-
rights: AclRight[];
|
|
13
|
-
}
|
|
1
|
+
export type {
|
|
2
|
+
AclEntry,
|
|
3
|
+
AclRight,
|
|
4
|
+
AclSubject,
|
|
5
|
+
AclSubjectKind,
|
|
6
|
+
} from "@antelopejs/interface-dms-media";
|
|
14
7
|
|
|
15
8
|
export type FolderVisibility = "private" | "public";
|
|
16
9
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type ComponentInfoSerialized } from "@antelopejs/interface-dms/component";
|
|
2
|
-
import { DataType } from "@antelopejs/interface-dms/base/data-types";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { type AssetBindingConfig } from "./bindings";
|
|
5
|
-
export declare const ASSET_DATA_TYPE_ID = "asset";
|
|
6
|
-
export declare const ASSET_PICKER_COMPONENT = "dms-media-asset-picker";
|
|
7
|
-
export interface AssetTypeOptions extends Record<string, unknown> {
|
|
8
|
-
multiple?: boolean;
|
|
9
|
-
max?: number;
|
|
10
|
-
mimetypes?: string[];
|
|
11
|
-
binding?: AssetBindingConfig;
|
|
12
|
-
}
|
|
13
|
-
export interface AssetPickerComponentOptions {
|
|
14
|
-
multiple?: boolean;
|
|
15
|
-
max?: number;
|
|
16
|
-
mimetypes?: string[];
|
|
17
|
-
bindingId?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare class AssetType extends DataType {
|
|
20
|
-
readonly options: AssetTypeOptions;
|
|
21
|
-
constructor(options?: AssetTypeOptions);
|
|
22
|
-
protected defaultInputComponent(): ComponentInfoSerialized;
|
|
23
|
-
getValidation(): z.ZodType;
|
|
24
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AssetType = exports.ASSET_PICKER_COMPONENT = exports.ASSET_DATA_TYPE_ID = void 0;
|
|
13
|
-
const component_1 = require("@antelopejs/interface-dms/component");
|
|
14
|
-
const data_types_1 = require("@antelopejs/interface-dms/base/data-types");
|
|
15
|
-
const zod_1 = require("zod");
|
|
16
|
-
const bindings_1 = require("./bindings");
|
|
17
|
-
exports.ASSET_DATA_TYPE_ID = "asset";
|
|
18
|
-
exports.ASSET_PICKER_COMPONENT = "dms-media-asset-picker";
|
|
19
|
-
let AssetType = class AssetType extends data_types_1.DataType {
|
|
20
|
-
options;
|
|
21
|
-
constructor(options = {}) {
|
|
22
|
-
super([], undefined, options);
|
|
23
|
-
this.options = options;
|
|
24
|
-
if (options.binding) {
|
|
25
|
-
(0, bindings_1.RegisterAssetBinding)(options.binding);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
defaultInputComponent() {
|
|
29
|
-
return new component_1.ComponentBuilder(exports.ASSET_PICKER_COMPONENT)
|
|
30
|
-
.options({
|
|
31
|
-
multiple: this.options.multiple,
|
|
32
|
-
max: this.options.max,
|
|
33
|
-
mimetypes: this.options.mimetypes,
|
|
34
|
-
bindingId: this.options.binding?.id,
|
|
35
|
-
})
|
|
36
|
-
.serializeSync();
|
|
37
|
-
}
|
|
38
|
-
getValidation() {
|
|
39
|
-
const idSchema = zod_1.z.string().min(1);
|
|
40
|
-
if (!this.options.multiple) {
|
|
41
|
-
return idSchema;
|
|
42
|
-
}
|
|
43
|
-
if (this.options.max !== undefined) {
|
|
44
|
-
return zod_1.z.array(idSchema).max(this.options.max);
|
|
45
|
-
}
|
|
46
|
-
return zod_1.z.array(idSchema);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.AssetType = AssetType;
|
|
50
|
-
exports.AssetType = AssetType = __decorate([
|
|
51
|
-
(0, data_types_1.RegisterDataType)(exports.ASSET_DATA_TYPE_ID),
|
|
52
|
-
__metadata("design:paramtypes", [Object])
|
|
53
|
-
], AssetType);
|
|
54
|
-
//# sourceMappingURL=asset-type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asset-type.js","sourceRoot":"","sources":["../../src/asset-type/asset-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAG6C;AAC7C,0EAGmD;AACnD,6BAAwB;AACxB,yCAA2E;AAE9D,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAC7B,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAiBxD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,qBAAQ;IACT;IAA5B,YAA4B,UAA4B,EAAE;QACxD,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QADJ,YAAO,GAAP,OAAO,CAAuB;QAExD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,IAAA,+BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAES,qBAAqB;QAC7B,OAAO,IAAI,4BAAgB,CACzB,8BAAsB,CACvB;aACE,OAAO,CAAC;YACP,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;YAC/B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;YACrB,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;YACjC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE;SACpC,CAAC;aACD,aAAa,EAAE,CAAC;IACrB,CAAC;IAED,aAAa;QACX,MAAM,QAAQ,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3B,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YACnC,OAAO,OAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,OAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF,CAAA;AA/BY,8BAAS;oBAAT,SAAS;IADrB,IAAA,6BAAgB,EAAC,0BAAkB,CAAC;;GACxB,SAAS,CA+BrB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ControllerClass } from "@antelopejs/interface-api";
|
|
2
|
-
import type { MediaFolderModel } from "../db";
|
|
3
|
-
import type { AclEntry } from "../types";
|
|
4
|
-
export interface AssetPermissionMapping {
|
|
5
|
-
read?: string[];
|
|
6
|
-
write?: string[];
|
|
7
|
-
}
|
|
8
|
-
export interface AssetBindingConfig {
|
|
9
|
-
id: string;
|
|
10
|
-
folderName?: string;
|
|
11
|
-
permissionMapping?: AssetPermissionMapping;
|
|
12
|
-
permissionsFromPage?: ControllerClass;
|
|
13
|
-
acl?: AclEntry[];
|
|
14
|
-
}
|
|
15
|
-
export declare const CONTENT_ROOT_BINDING = "dms-media.content-root";
|
|
16
|
-
export declare function RegisterAssetBinding(config: AssetBindingConfig): void;
|
|
17
|
-
export declare function getRegisteredBindings(): AssetBindingConfig[];
|
|
18
|
-
export declare function buildBindingAcl(config: AssetBindingConfig): AclEntry[];
|
|
19
|
-
export declare function ensureTenantBindings(tenantId: string, folderModel: MediaFolderModel): Promise<void>;
|