@webiny/api-file-manager-aco 0.0.0-unstable.0156a4c312

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.
@@ -0,0 +1,5 @@
1
+ import { type Container } from "@webiny/feature/api";
2
+ export declare const FileManagerAcoFeature: {
3
+ name: string;
4
+ register(container: Container): void;
5
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { EnsureFolderIsEmptyBeforeDeleteFeature } from "./features/EnsureFolderIsEmptyBeforeDelete/feature.js";
3
+ const FileManagerAcoFeature = createFeature({
4
+ name: "FileManagerAco",
5
+ register (container) {
6
+ EnsureFolderIsEmptyBeforeDeleteFeature.register(container);
7
+ }
8
+ });
9
+ export { FileManagerAcoFeature };
10
+
11
+ //# sourceMappingURL=FileManagerAcoFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileManagerAcoFeature.js","sources":["../src/FileManagerAcoFeature.ts"],"sourcesContent":["import { type Container, createFeature } from \"@webiny/feature/api\";\nimport { EnsureFolderIsEmptyBeforeDeleteFeature } from \"./features/EnsureFolderIsEmptyBeforeDelete/feature.js\";\n\nexport const FileManagerAcoFeature = createFeature({\n name: \"FileManagerAco\",\n register(container: Container) {\n // Pure DI registration — no legacy ContextPlugin bridge needed.\n EnsureFolderIsEmptyBeforeDeleteFeature.register(container);\n }\n});\n"],"names":["FileManagerAcoFeature","createFeature","container","EnsureFolderIsEmptyBeforeDeleteFeature"],"mappings":";;AAGO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAoB;QAEzBC,uCAAuC,QAAQ,CAACD;IACpD;AACJ"}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-file-manager-aco
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,13 @@
1
+ import { FolderBeforeDeleteEventHandler } from "@webiny/api-aco/features/folder/DeleteFolder/index.js";
2
+ import { ListFilesUseCase } from "@webiny/api-file-manager/features/file/ListFiles/index.js";
3
+ import { EnsureFolderIsEmpty } from "@webiny/api-aco/features/folder/EnsureFolderIsEmpty/index.js";
4
+ declare class EnsureFolderIsEmptyBeforeDeleteImpl implements FolderBeforeDeleteEventHandler.Interface {
5
+ private ensureFolderIsEmpty;
6
+ private listFiles;
7
+ constructor(ensureFolderIsEmpty: EnsureFolderIsEmpty.Interface, listFiles: ListFilesUseCase.Interface);
8
+ handle(event: FolderBeforeDeleteEventHandler.Event): Promise<void>;
9
+ }
10
+ export declare const EnsureFolderIsEmptyBeforeDelete: typeof EnsureFolderIsEmptyBeforeDeleteImpl & {
11
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/eventPublisher").IEventHandler<import("@webiny/api-core/features/eventPublisher").DomainEvent<import("@webiny/api-aco/features/folder/DeleteFolder/abstractions").FolderBeforeDeletePayload>>>;
12
+ };
13
+ export {};
@@ -0,0 +1,42 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ import { FolderBeforeDeleteEventHandler } from "@webiny/api-aco/features/folder/DeleteFolder/index.js";
3
+ import { ListFilesUseCase } from "@webiny/api-file-manager/features/file/ListFiles/index.js";
4
+ import { EnsureFolderIsEmpty } from "@webiny/api-aco/features/folder/EnsureFolderIsEmpty/index.js";
5
+ class EnsureFolderIsEmptyBeforeDeleteImpl {
6
+ constructor(ensureFolderIsEmpty, listFiles){
7
+ this.ensureFolderIsEmpty = ensureFolderIsEmpty;
8
+ this.listFiles = listFiles;
9
+ }
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
+ if (result.isFail()) throw result.error;
24
+ const { items } = result.value;
25
+ return items.length > 0;
26
+ });
27
+ if (result.isFail()) throw WebinyError.from(result.error, {
28
+ message: "Error while ensuring folder is empty before delete.",
29
+ code: "ACO_BEFORE_FOLDER_DELETE_FILE_HANDLER"
30
+ });
31
+ }
32
+ }
33
+ const EnsureFolderIsEmptyBeforeDelete = FolderBeforeDeleteEventHandler.createImplementation({
34
+ implementation: EnsureFolderIsEmptyBeforeDeleteImpl,
35
+ dependencies: [
36
+ EnsureFolderIsEmpty,
37
+ ListFilesUseCase
38
+ ]
39
+ });
40
+ export { EnsureFolderIsEmptyBeforeDelete };
41
+
42
+ //# sourceMappingURL=EnsureFolderIsEmptyBeforeDelete.js.map
@@ -0,0 +1 @@
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 if (result.isFail()) {\n throw result.error;\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,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;YAGtB,MAAM,EAAEC,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"}
@@ -0,0 +1,4 @@
1
+ export declare const EnsureFolderIsEmptyBeforeDeleteFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { EnsureFolderIsEmptyBeforeDelete } from "./EnsureFolderIsEmptyBeforeDelete.js";
3
+ const EnsureFolderIsEmptyBeforeDeleteFeature = createFeature({
4
+ name: "EnsureFolderIsEmptyBeforeDelete",
5
+ register (container) {
6
+ container.register(EnsureFolderIsEmptyBeforeDelete);
7
+ }
8
+ });
9
+ export { EnsureFolderIsEmptyBeforeDeleteFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
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.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./plugins/index.js";
2
+ export { FileManagerAcoFeature } from "./FileManagerAcoFeature.js";
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./plugins/index.js";
2
+ export { FileManagerAcoFeature } from "./FileManagerAcoFeature.js";
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@webiny/api-file-manager-aco",
3
+ "version": "0.0.0-unstable.0156a4c312",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
9
+ "keywords": [
10
+ "api-file-manager-aco:base"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/webiny/webiny-js.git",
15
+ "directory": "packages/api-file-manager-aco"
16
+ },
17
+ "description": "Connect File Manager to ACO",
18
+ "author": "Webiny Ltd.",
19
+ "license": "MIT",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "dependencies": {
24
+ "@webiny/api-aco": "0.0.0-unstable.0156a4c312",
25
+ "@webiny/api-file-manager": "0.0.0-unstable.0156a4c312",
26
+ "@webiny/api-graphql": "0.0.0-unstable.0156a4c312",
27
+ "@webiny/error": "0.0.0-unstable.0156a4c312",
28
+ "@webiny/feature": "0.0.0-unstable.0156a4c312"
29
+ },
30
+ "devDependencies": {
31
+ "@webiny/api": "0.0.0-unstable.0156a4c312",
32
+ "@webiny/api-core": "0.0.0-unstable.0156a4c312",
33
+ "@webiny/api-core-testing": "0.0.0-unstable.0156a4c312",
34
+ "@webiny/api-graphql": "0.0.0-unstable.0156a4c312",
35
+ "@webiny/api-headless-cms": "0.0.0-unstable.0156a4c312",
36
+ "@webiny/api-websockets": "0.0.0-unstable.0156a4c312",
37
+ "@webiny/build-tools": "0.0.0-unstable.0156a4c312",
38
+ "@webiny/di": "2.0.0",
39
+ "@webiny/event-handler-core": "0.0.0-unstable.0156a4c312",
40
+ "@webiny/handler": "0.0.0-unstable.0156a4c312",
41
+ "@webiny/logger": "0.0.0-unstable.0156a4c312",
42
+ "@webiny/plugins": "0.0.0-unstable.0156a4c312",
43
+ "@webiny/utils": "0.0.0-unstable.0156a4c312",
44
+ "@webiny/wcp": "0.0.0-unstable.0156a4c312",
45
+ "graphql": "16.14.2",
46
+ "typescript": "7.0.2",
47
+ "vitest": "5.0.5"
48
+ },
49
+ "webiny": {
50
+ "publishFrom": "dist"
51
+ }
52
+ }
@@ -0,0 +1,10 @@
1
+ import { type CmsModelField, type CmsModelModifierCallable, FolderCmsModelModifierPlugin, type IFolderModelFieldsModifier } from "@webiny/api-aco";
2
+ import type { CmsModelField as BaseModelField } from "@webiny/api-headless-cms/types/index.js";
3
+ export declare class FolderModelFieldsModifier implements IFolderModelFieldsModifier {
4
+ private fields;
5
+ private readonly namespace;
6
+ constructor(namespace: string);
7
+ setFields(fields: BaseModelField[]): void;
8
+ addField(field: CmsModelField): void;
9
+ }
10
+ export declare const createFmFileFolderModelModifier: (callback: CmsModelModifierCallable) => FolderCmsModelModifierPlugin;
@@ -0,0 +1,32 @@
1
+ import { FolderCmsModelModifierPlugin } from "@webiny/api-aco";
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
+ }
22
+ }
23
+ const createFmFileFolderModelModifier = (callback)=>{
24
+ const modifier = new FolderModelFieldsModifier("fm_file");
25
+ return new FolderCmsModelModifierPlugin({
26
+ callback,
27
+ modifier
28
+ });
29
+ };
30
+ export { FolderModelFieldsModifier, createFmFileFolderModelModifier };
31
+
32
+ //# sourceMappingURL=createFmFileFolderModelModifier.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1 @@
1
+ export * from "./createFmFileFolderModelModifier.js";
@@ -0,0 +1 @@
1
+ export * from "./createFmFileFolderModelModifier.js";