@webiny/api-file-manager-aco 6.3.0 → 6.4.0-beta.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/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js +30 -41
- package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js.map +1 -1
- package/features/EnsureFolderIsEmptyBeforeDelete/feature.js +6 -5
- package/features/EnsureFolderIsEmptyBeforeDelete/feature.js.map +1 -1
- package/index.js +4 -5
- package/index.js.map +1 -1
- package/package.json +19 -19
- package/plugins/createFmFileFolderModelModifier.js +27 -27
- package/plugins/createFmFileFolderModelModifier.js.map +1 -1
- package/plugins/index.js +0 -2
- package/plugins/index.js.map +0 -1
|
@@ -3,50 +3,39 @@ import { FolderBeforeDeleteEventHandler } from "@webiny/api-aco/features/folder/
|
|
|
3
3
|
import { ListFilesUseCase } from "@webiny/api-file-manager/features/file/ListFiles/index.js";
|
|
4
4
|
import { EnsureFolderIsEmpty } from "@webiny/api-aco/features/folder/EnsureFolderIsEmpty/index.js";
|
|
5
5
|
class EnsureFolderIsEmptyBeforeDeleteImpl {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
async handle(event) {
|
|
11
|
-
const {
|
|
12
|
-
folder
|
|
13
|
-
} = event.payload;
|
|
14
|
-
const {
|
|
15
|
-
id,
|
|
16
|
-
type
|
|
17
|
-
} = folder;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Exit if the folder type is not related to File Manager
|
|
21
|
-
*/
|
|
22
|
-
if (type !== "FmFile") {
|
|
23
|
-
return;
|
|
6
|
+
constructor(ensureFolderIsEmpty, listFiles){
|
|
7
|
+
this.ensureFolderIsEmpty = ensureFolderIsEmpty;
|
|
8
|
+
this.listFiles = listFiles;
|
|
24
9
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
10
|
+
async handle(event) {
|
|
11
|
+
const { folder } = event.payload;
|
|
12
|
+
const { id, type } = folder;
|
|
13
|
+
if ("FmFile" !== type) return;
|
|
14
|
+
const result = await this.ensureFolderIsEmpty.execute(type, id, async ()=>{
|
|
15
|
+
const result = await this.listFiles.execute({
|
|
16
|
+
where: {
|
|
17
|
+
location: {
|
|
18
|
+
folderId: id
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
limit: 1
|
|
22
|
+
});
|
|
23
|
+
const { items } = result.value;
|
|
24
|
+
return items.length > 0;
|
|
25
|
+
});
|
|
26
|
+
if (result.isFail()) throw WebinyError.from(result.error, {
|
|
27
|
+
message: "Error while ensuring folder is empty before delete.",
|
|
28
|
+
code: "ACO_BEFORE_FOLDER_DELETE_FILE_HANDLER"
|
|
29
|
+
});
|
|
44
30
|
}
|
|
45
|
-
}
|
|
46
31
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
const EnsureFolderIsEmptyBeforeDelete = FolderBeforeDeleteEventHandler.createImplementation({
|
|
33
|
+
implementation: EnsureFolderIsEmptyBeforeDeleteImpl,
|
|
34
|
+
dependencies: [
|
|
35
|
+
EnsureFolderIsEmpty,
|
|
36
|
+
ListFilesUseCase
|
|
37
|
+
]
|
|
50
38
|
});
|
|
39
|
+
export { EnsureFolderIsEmptyBeforeDelete };
|
|
51
40
|
|
|
52
41
|
//# sourceMappingURL=EnsureFolderIsEmptyBeforeDelete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js","sources":["../../../src/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { FolderBeforeDeleteEventHandler } from \"@webiny/api-aco/features/folder/DeleteFolder/index.js\";\nimport { ListFilesUseCase } from \"@webiny/api-file-manager/features/file/ListFiles/index.js\";\nimport { EnsureFolderIsEmpty } from \"@webiny/api-aco/features/folder/EnsureFolderIsEmpty/index.js\";\n\nclass EnsureFolderIsEmptyBeforeDeleteImpl implements FolderBeforeDeleteEventHandler.Interface {\n constructor(\n private ensureFolderIsEmpty: EnsureFolderIsEmpty.Interface,\n private listFiles: ListFilesUseCase.Interface\n ) {}\n\n async handle(event: FolderBeforeDeleteEventHandler.Event): Promise<void> {\n const { folder } = event.payload;\n\n const { id, type } = folder;\n\n /**\n * Exit if the folder type is not related to File Manager\n */\n if (type !== \"FmFile\") {\n return;\n }\n\n const result = await this.ensureFolderIsEmpty.execute(type, id, async () => {\n const result = await this.listFiles.execute({\n where: {\n location: {\n folderId: id\n }\n },\n limit: 1\n });\n\n const { items } = result.value;\n\n return items.length > 0;\n });\n\n if (result.isFail()) {\n throw WebinyError.from(result.error, {\n message: \"Error while ensuring folder is empty before delete.\",\n code: \"ACO_BEFORE_FOLDER_DELETE_FILE_HANDLER\"\n });\n }\n }\n}\n\nexport const EnsureFolderIsEmptyBeforeDelete = FolderBeforeDeleteEventHandler.createImplementation({\n implementation: EnsureFolderIsEmptyBeforeDeleteImpl,\n dependencies: [EnsureFolderIsEmpty, ListFilesUseCase]\n});\n"],"names":["EnsureFolderIsEmptyBeforeDeleteImpl","ensureFolderIsEmpty","listFiles","event","folder","id","type","result","items","WebinyError","EnsureFolderIsEmptyBeforeDelete","FolderBeforeDeleteEventHandler","EnsureFolderIsEmpty","ListFilesUseCase"],"mappings":";;;;AAKA,MAAMA;IACF,YACYC,mBAAkD,EAClDC,SAAqC,CAC/C;aAFUD,mBAAmB,GAAnBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,OAAOC,KAA2C,EAAiB;QACrE,MAAM,EAAEC,MAAM,EAAE,GAAGD,MAAM,OAAO;QAEhC,MAAM,EAAEE,EAAE,EAAEC,IAAI,EAAE,GAAGF;QAKrB,IAAIE,AAAS,aAATA,MACA;QAGJ,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAACD,MAAMD,IAAI;YAC5D,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACxC,OAAO;oBACH,UAAU;wBACN,UAAUF;oBACd;gBACJ;gBACA,OAAO;YACX;YAEA,MAAM,EAAEG,KAAK,EAAE,GAAGD,OAAO,KAAK;YAE9B,OAAOC,MAAM,MAAM,GAAG;QAC1B;QAEA,IAAID,OAAO,MAAM,IACb,MAAME,YAAY,IAAI,CAACF,OAAO,KAAK,EAAE;YACjC,SAAS;YACT,MAAM;QACV;IAER;AACJ;AAEO,MAAMG,kCAAkCC,+BAA+B,oBAAoB,CAAC;IAC/F,gBAAgBX;IAChB,cAAc;QAACY;QAAqBC;KAAiB;AACzD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { EnsureFolderIsEmptyBeforeDelete } from "./EnsureFolderIsEmptyBeforeDelete.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const EnsureFolderIsEmptyBeforeDeleteFeature = createFeature({
|
|
4
|
+
name: "EnsureFolderIsEmptyBeforeDelete",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(EnsureFolderIsEmptyBeforeDelete);
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { EnsureFolderIsEmptyBeforeDeleteFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/EnsureFolderIsEmptyBeforeDelete/feature.js","sources":["../../../src/features/EnsureFolderIsEmptyBeforeDelete/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { EnsureFolderIsEmptyBeforeDelete } from \"./EnsureFolderIsEmptyBeforeDelete.js\";\n\nexport const EnsureFolderIsEmptyBeforeDeleteFeature = createFeature({\n name: \"EnsureFolderIsEmptyBeforeDelete\",\n register(container) {\n container.register(EnsureFolderIsEmptyBeforeDelete);\n }\n});\n"],"names":["EnsureFolderIsEmptyBeforeDeleteFeature","createFeature","container","EnsureFolderIsEmptyBeforeDelete"],"mappings":";;AAGO,MAAMA,yCAAyCC,cAAc;IAChE,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
package/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createContextPlugin } from "@webiny/api";
|
|
2
2
|
import { EnsureFolderIsEmptyBeforeDeleteFeature } from "./features/EnsureFolderIsEmptyBeforeDelete/feature.js";
|
|
3
3
|
export * from "./plugins/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
4
|
+
const createFileManagerAco = ()=>createContextPlugin((context)=>{
|
|
5
|
+
EnsureFolderIsEmptyBeforeDeleteFeature.register(context.container);
|
|
6
|
+
});
|
|
7
|
+
export { createFileManagerAco };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport { EnsureFolderIsEmptyBeforeDeleteFeature } from \"~/features/EnsureFolderIsEmptyBeforeDelete/feature.js\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createFileManagerAco = () => {\n return createContextPlugin(context => {\n EnsureFolderIsEmptyBeforeDeleteFeature.register(context.container);\n });\n};\n"],"names":["createFileManagerAco","createContextPlugin","context","EnsureFolderIsEmptyBeforeDeleteFeature"],"mappings":";;;AAKO,MAAMA,uBAAuB,IACzBC,oBAAoBC,CAAAA;QACvBC,uCAAuC,QAAQ,CAACD,QAAQ,SAAS;IACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager-aco",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -22,26 +22,26 @@
|
|
|
22
22
|
"directory": "dist"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@webiny/api-aco": "6.
|
|
26
|
-
"@webiny/api-file-manager": "6.
|
|
27
|
-
"@webiny/error": "6.
|
|
28
|
-
"@webiny/feature": "6.
|
|
25
|
+
"@webiny/api-aco": "6.4.0-beta.1",
|
|
26
|
+
"@webiny/api-file-manager": "6.4.0-beta.1",
|
|
27
|
+
"@webiny/error": "6.4.0-beta.1",
|
|
28
|
+
"@webiny/feature": "6.4.0-beta.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@webiny/api": "6.
|
|
32
|
-
"@webiny/api-core": "6.
|
|
33
|
-
"@webiny/api-headless-cms": "6.
|
|
34
|
-
"@webiny/build-tools": "6.
|
|
35
|
-
"@webiny/handler": "6.
|
|
36
|
-
"@webiny/handler-aws": "6.
|
|
37
|
-
"@webiny/handler-graphql": "6.
|
|
38
|
-
"@webiny/plugins": "6.
|
|
39
|
-
"@webiny/project-utils": "6.
|
|
40
|
-
"@webiny/utils": "6.
|
|
41
|
-
"@webiny/wcp": "6.
|
|
42
|
-
"graphql": "16.
|
|
31
|
+
"@webiny/api": "6.4.0-beta.1",
|
|
32
|
+
"@webiny/api-core": "6.4.0-beta.1",
|
|
33
|
+
"@webiny/api-headless-cms": "6.4.0-beta.1",
|
|
34
|
+
"@webiny/build-tools": "6.4.0-beta.1",
|
|
35
|
+
"@webiny/handler": "6.4.0-beta.1",
|
|
36
|
+
"@webiny/handler-aws": "6.4.0-beta.1",
|
|
37
|
+
"@webiny/handler-graphql": "6.4.0-beta.1",
|
|
38
|
+
"@webiny/plugins": "6.4.0-beta.1",
|
|
39
|
+
"@webiny/project-utils": "6.4.0-beta.1",
|
|
40
|
+
"@webiny/utils": "6.4.0-beta.1",
|
|
41
|
+
"@webiny/wcp": "6.4.0-beta.1",
|
|
42
|
+
"graphql": "16.14.0",
|
|
43
43
|
"typescript": "6.0.3",
|
|
44
|
-
"vitest": "4.1.
|
|
44
|
+
"vitest": "4.1.6"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
|
|
47
47
|
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { FolderCmsModelModifierPlugin } from "@webiny/api-aco";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
2
|
+
class FolderModelFieldsModifier {
|
|
3
|
+
constructor(namespace){
|
|
4
|
+
this.fields = [];
|
|
5
|
+
this.namespace = namespace;
|
|
6
|
+
}
|
|
7
|
+
setFields(fields) {
|
|
8
|
+
this.fields = fields;
|
|
9
|
+
}
|
|
10
|
+
addField(field) {
|
|
11
|
+
const { tags, ...rest } = field;
|
|
12
|
+
this.fields.push({
|
|
13
|
+
...rest,
|
|
14
|
+
id: `${this.namespace}_${field.id}`,
|
|
15
|
+
fieldId: `${this.namespace}_${field.fieldId}`,
|
|
16
|
+
storageId: `${field.type}@${this.namespace}_${field.id}`,
|
|
17
|
+
tags: (tags ?? []).concat([
|
|
18
|
+
`$namespace:${this.namespace}`
|
|
19
|
+
])
|
|
20
|
+
});
|
|
21
|
+
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
const createFmFileFolderModelModifier = (callback)=>{
|
|
24
|
+
const modifier = new FolderModelFieldsModifier("fm_file");
|
|
25
|
+
return new FolderCmsModelModifierPlugin({
|
|
26
|
+
callback,
|
|
27
|
+
modifier
|
|
28
|
+
});
|
|
30
29
|
};
|
|
30
|
+
export { FolderModelFieldsModifier, createFmFileFolderModelModifier };
|
|
31
31
|
|
|
32
32
|
//# sourceMappingURL=createFmFileFolderModelModifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/createFmFileFolderModelModifier.js","sources":["../../src/plugins/createFmFileFolderModelModifier.ts"],"sourcesContent":["import {\n type CmsModelField,\n type CmsModelModifierCallable,\n FolderCmsModelModifierPlugin,\n type IFolderModelFieldsModifier\n} from \"@webiny/api-aco\";\nimport type { CmsModelField as BaseModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport class FolderModelFieldsModifier implements IFolderModelFieldsModifier {\n private fields: BaseModelField[] = [];\n private readonly namespace: string;\n\n constructor(namespace: string) {\n this.namespace = namespace;\n }\n\n setFields(fields: BaseModelField[]) {\n this.fields = fields;\n }\n\n addField(field: CmsModelField) {\n const { tags, ...rest } = field;\n\n this.fields.push({\n ...rest,\n id: `${this.namespace}_${field.id}`,\n fieldId: `${this.namespace}_${field.fieldId}`,\n storageId: `${field.type}@${this.namespace}_${field.id}`,\n tags: (tags ?? []).concat([`$namespace:${this.namespace}`])\n });\n }\n}\n\nexport const createFmFileFolderModelModifier = (callback: CmsModelModifierCallable) => {\n const modifier = new FolderModelFieldsModifier(\"fm_file\");\n\n return new FolderCmsModelModifierPlugin({\n callback,\n modifier\n });\n};\n"],"names":["FolderModelFieldsModifier","namespace","fields","field","tags","rest","createFmFileFolderModelModifier","callback","modifier","FolderCmsModelModifierPlugin"],"mappings":";AAQO,MAAMA;IAIT,YAAYC,SAAiB,CAAE;aAHvB,MAAM,GAAqB,EAAE;QAIjC,IAAI,CAAC,SAAS,GAAGA;IACrB;IAEA,UAAUC,MAAwB,EAAE;QAChC,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,SAASC,KAAoB,EAAE;QAC3B,MAAM,EAAEC,IAAI,EAAE,GAAGC,MAAM,GAAGF;QAE1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACb,GAAGE,IAAI;YACP,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEF,MAAM,EAAE,EAAE;YACnC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEA,MAAM,OAAO,EAAE;YAC7C,WAAW,GAAGA,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAEA,MAAM,EAAE,EAAE;YACxD,MAAOC,AAAAA,CAAAA,QAAQ,EAAC,EAAG,MAAM,CAAC;gBAAC,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE;aAAC;QAC9D;IACJ;AACJ;AAEO,MAAME,kCAAkC,CAACC;IAC5C,MAAMC,WAAW,IAAIR,0BAA0B;IAE/C,OAAO,IAAIS,6BAA6B;QACpCF;QACAC;IACJ;AACJ"}
|
package/plugins/index.js
CHANGED
package/plugins/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createFmFileFolderModelModifier.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|