@webiny/api-file-manager-aco 0.0.0-unstable.c7dec08bb0 β†’ 0.0.0-unstable.dbdf5d6258

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/LICENSE CHANGED
@@ -1,11 +1,6 @@
1
- Copyright (c) Webiny Inc.
1
+ MIT License
2
2
 
3
- Portions of this software are licensed as follows:
4
-
5
- * All content that resides under the "enterprise/" directories of this repository, is licensed under the license defined in their respective "enterprise/LICENSE" file.
6
- * All content that resides under the "packages/" sub-directories of this repository, is licensed under the license defined in their respective "packages/*/LICENSE" file.
7
- * All third party components incorporated into the Webiny Software are licensed under the original license provided by the owner of the applicable component.
8
- * Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined below.
3
+ Copyright (c) Webiny
9
4
 
10
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
6
  of this software and associated documentation files (the "Software"), to deal
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 { FolderBeforeDeleteHandler } from "@webiny/api-aco/features/folder/DeleteFolder";
2
+ import { ListFilesUseCase } from "@webiny/api-file-manager/features/file/ListFiles/index.js";
3
+ import { EnsureFolderIsEmpty } from "@webiny/api-aco/features/folder/EnsureFolderIsEmpty";
4
+ declare class EnsureFolderIsEmptyBeforeDeleteImpl implements FolderBeforeDeleteHandler.Interface {
5
+ private ensureFolderIsEmpty;
6
+ private listFiles;
7
+ constructor(ensureFolderIsEmpty: EnsureFolderIsEmpty.Interface, listFiles: ListFilesUseCase.Interface);
8
+ handle(event: FolderBeforeDeleteHandler.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,52 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ import { FolderBeforeDeleteHandler } from "@webiny/api-aco/features/folder/DeleteFolder";
3
+ import { ListFilesUseCase } from "@webiny/api-file-manager/features/file/ListFiles/index.js";
4
+ import { EnsureFolderIsEmpty } from "@webiny/api-aco/features/folder/EnsureFolderIsEmpty";
5
+ class EnsureFolderIsEmptyBeforeDeleteImpl {
6
+ constructor(ensureFolderIsEmpty, listFiles) {
7
+ this.ensureFolderIsEmpty = ensureFolderIsEmpty;
8
+ this.listFiles = listFiles;
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;
24
+ }
25
+ const result = await this.ensureFolderIsEmpty.execute(type, id, async () => {
26
+ const result = await this.listFiles.execute({
27
+ where: {
28
+ location: {
29
+ folderId: id
30
+ }
31
+ },
32
+ limit: 1
33
+ });
34
+ const {
35
+ items
36
+ } = result.value;
37
+ return items.length > 0;
38
+ });
39
+ if (result.isFail()) {
40
+ throw WebinyError.from(result.error, {
41
+ message: "Error while ensuring folder is empty before delete.",
42
+ code: "ACO_BEFORE_FOLDER_DELETE_FILE_HANDLER"
43
+ });
44
+ }
45
+ }
46
+ }
47
+ export const EnsureFolderIsEmptyBeforeDelete = FolderBeforeDeleteHandler.createImplementation({
48
+ implementation: EnsureFolderIsEmptyBeforeDeleteImpl,
49
+ dependencies: [EnsureFolderIsEmpty, ListFilesUseCase]
50
+ });
51
+
52
+ //# sourceMappingURL=EnsureFolderIsEmptyBeforeDelete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WebinyError","FolderBeforeDeleteHandler","ListFilesUseCase","EnsureFolderIsEmpty","EnsureFolderIsEmptyBeforeDeleteImpl","constructor","ensureFolderIsEmpty","listFiles","handle","event","folder","payload","id","type","result","execute","where","location","folderId","limit","items","value","length","isFail","from","error","message","code","EnsureFolderIsEmptyBeforeDelete","createImplementation","implementation","dependencies"],"sources":["EnsureFolderIsEmptyBeforeDelete.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { FolderBeforeDeleteHandler } from \"@webiny/api-aco/features/folder/DeleteFolder\";\nimport { ListFilesUseCase } from \"@webiny/api-file-manager/features/file/ListFiles/index.js\";\nimport { EnsureFolderIsEmpty } from \"@webiny/api-aco/features/folder/EnsureFolderIsEmpty\";\n\nclass EnsureFolderIsEmptyBeforeDeleteImpl implements FolderBeforeDeleteHandler.Interface {\n constructor(\n private ensureFolderIsEmpty: EnsureFolderIsEmpty.Interface,\n private listFiles: ListFilesUseCase.Interface\n ) {}\n\n async handle(event: FolderBeforeDeleteHandler.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 = FolderBeforeDeleteHandler.createImplementation({\n implementation: EnsureFolderIsEmptyBeforeDeleteImpl,\n dependencies: [EnsureFolderIsEmp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,EAAE1B,mCAAmC;EACnD2B,YAAY,EAAE,CAAC5B,mBAAmB,EAAED,gBAAgB;AACxD,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const EnsureFolderIsEmptyBeforeDeleteFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
@@ -0,0 +1,10 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { EnsureFolderIsEmptyBeforeDelete } from "./EnsureFolderIsEmptyBeforeDelete.js";
3
+ export const EnsureFolderIsEmptyBeforeDeleteFeature = createFeature({
4
+ name: "EnsureFolderIsEmptyBeforeDelete",
5
+ register(container) {
6
+ container.register(EnsureFolderIsEmptyBeforeDelete);
7
+ }
8
+ });
9
+
10
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","EnsureFolderIsEmptyBeforeDelete","EnsureFolderIsEmptyBeforeDeleteFeature","name","register","container"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,+BAA+B;AAExC,OAAO,MAAMC,sCAAsC,GAAGF,aAAa,CAAC;EAChEG,IAAI,EAAE,iCAAiC;EACvCC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,+BAA+B,CAAC;EACvD;AACJ,CAAC,CAAC","ignoreList":[]}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./plugins/index.js";
2
+ export declare const createFileManagerAco: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types.js").Context>;
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { createContextPlugin } from "@webiny/api";
2
+ import { EnsureFolderIsEmptyBeforeDeleteFeature } from "./features/EnsureFolderIsEmptyBeforeDelete/feature.js";
3
+ export * from "./plugins/index.js";
4
+ export const createFileManagerAco = () => {
5
+ return createContextPlugin(context => {
6
+ EnsureFolderIsEmptyBeforeDeleteFeature.register(context.container);
7
+ });
8
+ };
9
+
10
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContextPlugin","EnsureFolderIsEmptyBeforeDeleteFeature","createFileManagerAco","context","register","container"],"sources":["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"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,aAAa;AACjD,SAASC,sCAAsC;AAE/C;AAEA,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACtC,OAAOF,mBAAmB,CAACG,OAAO,IAAI;IAClCF,sCAAsC,CAACG,QAAQ,CAACD,OAAO,CAACE,SAAS,CAAC;EACtE,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,17 +1,45 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager-aco",
3
- "version": "0.0.0-unstable.c7dec08bb0",
3
+ "version": "0.0.0-unstable.dbdf5d6258",
4
+ "type": "module",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "api-file-manager-aco:base"
8
+ ],
4
9
  "repository": {
5
10
  "type": "git",
6
11
  "url": "https://github.com/webiny/webiny-js.git",
7
12
  "directory": "packages/api-file-manager-aco"
8
13
  },
9
- "description": "This package is scheduled for deletion in the next version.",
14
+ "description": "Connect File Manager to ACO",
10
15
  "author": "Webiny Ltd.",
11
16
  "license": "MIT",
12
17
  "publishConfig": {
13
18
  "access": "public",
14
- "directory": "."
19
+ "directory": "dist"
15
20
  },
16
- "gitHead": "c7dec08bb095467cca6a61381bd399d66b7bb147"
21
+ "dependencies": {
22
+ "@webiny/api-aco": "0.0.0-unstable.dbdf5d6258",
23
+ "@webiny/api-file-manager": "0.0.0-unstable.dbdf5d6258",
24
+ "@webiny/error": "0.0.0-unstable.dbdf5d6258",
25
+ "@webiny/feature": "0.0.0-unstable.dbdf5d6258"
26
+ },
27
+ "devDependencies": {
28
+ "@webiny/api": "0.0.0-unstable.dbdf5d6258",
29
+ "@webiny/api-core": "0.0.0-unstable.dbdf5d6258",
30
+ "@webiny/api-headless-cms": "0.0.0-unstable.dbdf5d6258",
31
+ "@webiny/build-tools": "0.0.0-unstable.dbdf5d6258",
32
+ "@webiny/handler": "0.0.0-unstable.dbdf5d6258",
33
+ "@webiny/handler-aws": "0.0.0-unstable.dbdf5d6258",
34
+ "@webiny/handler-graphql": "0.0.0-unstable.dbdf5d6258",
35
+ "@webiny/plugins": "0.0.0-unstable.dbdf5d6258",
36
+ "@webiny/project-utils": "0.0.0-unstable.dbdf5d6258",
37
+ "@webiny/utils": "0.0.0-unstable.dbdf5d6258",
38
+ "@webiny/wcp": "0.0.0-unstable.dbdf5d6258",
39
+ "graphql": "16.13.0",
40
+ "ttypescript": "1.5.15",
41
+ "typescript": "5.9.3",
42
+ "vitest": "4.0.18"
43
+ },
44
+ "gitHead": "dbdf5d62587b971d52125a69ad6e69bae9ce8ee7"
17
45
  }
@@ -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
+ export class FolderModelFieldsModifier {
3
+ fields = [];
4
+ constructor(namespace) {
5
+ this.namespace = namespace;
6
+ }
7
+ setFields(fields) {
8
+ this.fields = fields;
9
+ }
10
+ addField(field) {
11
+ const {
12
+ tags,
13
+ ...rest
14
+ } = field;
15
+ this.fields.push({
16
+ ...rest,
17
+ id: `${this.namespace}_${field.id}`,
18
+ fieldId: `${this.namespace}_${field.fieldId}`,
19
+ storageId: `${field.type}@${this.namespace}_${field.id}`,
20
+ tags: (tags ?? []).concat([`$namespace:${this.namespace}`])
21
+ });
22
+ }
23
+ }
24
+ export const createFmFileFolderModelModifier = callback => {
25
+ const modifier = new FolderModelFieldsModifier("fm_file");
26
+ return new FolderCmsModelModifierPlugin({
27
+ callback,
28
+ modifier
29
+ });
30
+ };
31
+
32
+ //# sourceMappingURL=createFmFileFolderModelModifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FolderCmsModelModifierPlugin","FolderModelFieldsModifier","fields","constructor","namespace","setFields","addField","field","tags","rest","push","id","fieldId","storageId","type","concat","createFmFileFolderModelModifier","callback","modifier"],"sources":["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"],"mappings":"AAAA,SAGIA,4BAA4B,QAEzB,iBAAiB;AAGxB,OAAO,MAAMC,yBAAyB,CAAuC;EACjEC,MAAM,GAAqB,EAAE;EAGrCC,WAAWA,CAACC,SAAiB,EAAE;IAC3B,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC9B;EAEAC,SAASA,CAACH,MAAwB,EAAE;IAChC,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEAI,QAAQA,CAACC,KAAoB,EAAE;IAC3B,MAAM;MAAEC,IAAI;MAAE,GAAGC;IAAK,CAAC,GAAGF,KAAK;IAE/B,IAAI,CAACL,MAAM,CAACQ,IAAI,CAAC;MACb,GAAGD,IAAI;MACPE,EAAE,EAAE,GAAG,IAAI,CAACP,SAAS,IAAIG,KAAK,CAACI,EAAE,EAAE;MACnCC,OAAO,EAAE,GAAG,IAAI,CAACR,SAAS,IAAIG,KAAK,CAACK,OAAO,EAAE;MAC7CC,SAAS,EAAE,GAAGN,KAAK,CAACO,IAAI,IAAI,IAAI,CAACV,SAAS,IAAIG,KAAK,CAACI,EAAE,EAAE;MACxDH,IAAI,EAAE,CAACA,IAAI,IAAI,EAAE,EAAEO,MAAM,CAAC,CAAC,cAAc,IAAI,CAACX,SAAS,EAAE,CAAC;IAC9D,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMY,+BAA+B,GAAIC,QAAkC,IAAK;EACnF,MAAMC,QAAQ,GAAG,IAAIjB,yBAAyB,CAAC,SAAS,CAAC;EAEzD,OAAO,IAAID,4BAA4B,CAAC;IACpCiB,QAAQ;IACRC;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export * from "./createFmFileFolderModelModifier.js";
@@ -0,0 +1,3 @@
1
+ export * from "./createFmFileFolderModelModifier.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createFmFileFolderModelModifier.js\";\n"],"mappings":"AAAA","ignoreList":[]}