@webiny/api-file-manager-aco 0.0.0-unstable.c59b9cc5b9 → 0.0.0-unstable.d0f34a8194
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/FileManagerAcoFeature.d.ts +5 -0
- package/FileManagerAcoFeature.js +11 -0
- package/FileManagerAcoFeature.js.map +1 -0
- package/README.md +6 -28
- package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.d.ts +13 -0
- package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js +42 -0
- package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js.map +1 -0
- package/features/EnsureFolderIsEmptyBeforeDelete/feature.d.ts +4 -0
- package/features/EnsureFolderIsEmptyBeforeDelete/feature.js +11 -0
- package/features/EnsureFolderIsEmptyBeforeDelete/feature.js.map +1 -0
- package/index.d.ts +2 -4
- package/index.js +2 -20
- package/package.json +33 -38
- package/plugins/createFmFileFolderModelModifier.d.ts +10 -0
- package/plugins/createFmFileFolderModelModifier.js +32 -0
- package/plugins/createFmFileFolderModelModifier.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +1 -0
- package/contants.d.ts +0 -2
- package/contants.js +0 -10
- package/contants.js.map +0 -1
- package/file/hooks/index.d.ts +0 -3
- package/file/hooks/index.js +0 -22
- package/file/hooks/index.js.map +0 -1
- package/file/hooks/onFileAfterBatchCreate.hook.d.ts +0 -2
- package/file/hooks/onFileAfterBatchCreate.hook.js +0 -38
- package/file/hooks/onFileAfterBatchCreate.hook.js.map +0 -1
- package/file/hooks/onFileAfterCreate.hook.d.ts +0 -2
- package/file/hooks/onFileAfterCreate.hook.js +0 -36
- package/file/hooks/onFileAfterCreate.hook.js.map +0 -1
- package/file/hooks/onFileAfterDelete.hook.d.ts +0 -2
- package/file/hooks/onFileAfterDelete.hook.js +0 -32
- package/file/hooks/onFileAfterDelete.hook.js.map +0 -1
- package/file/hooks/onFileAfterUpdate.hook.d.ts +0 -2
- package/file/hooks/onFileAfterUpdate.hook.js +0 -31
- package/file/hooks/onFileAfterUpdate.hook.js.map +0 -1
- package/index.js.map +0 -1
- package/types.d.ts +0 -6
- package/types.js +0 -5
- package/types.js.map +0 -1
- package/utils/createRecordPayload.d.ts +0 -6
- package/utils/createRecordPayload.js +0 -76
- package/utils/createRecordPayload.js.map +0 -1
|
@@ -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/README.md
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
# @webiny/api-file-manager-aco
|
|
2
2
|
|
|
3
|
-
[!
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
[](http://makeapullrequest.com)
|
|
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.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
npm install --save @webiny/api-file-manager-aco
|
|
12
|
-
```
|
|
9
|
+
---
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
yarn add @webiny/api-file-manager-aco
|
|
18
|
-
```
|
|
19
|
-
## Testing
|
|
20
|
-
|
|
21
|
-
To run tests api-file-manager-aco tests with targeted storage operations loaded use:
|
|
22
|
-
|
|
23
|
-
### DynamoDB
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
yarn test packages/api-file-manager-aco/* --keyword=cms:ddb --keyword=aco:base --keyword=fm:ddb --keyword=fm:base --keyword=api-file-manager-aco:base
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### DynamoDB + ElasticSearch
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
yarn test packages/api-file-manager-aco/* --keyword=cms:ddb-es --keyword=aco:base --keyword=fm:ddb-es --keyword=fm:base --keyword=api-file-manager-aco:base
|
|
33
|
-
```
|
|
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,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
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const createAcoFileManagerContext: () => ContextPlugin<FmAcoContext>;
|
|
4
|
-
export declare const createAcoFileManagerImportExportContext: () => ContextPlugin<FmAcoContext>;
|
|
1
|
+
export * from "./plugins/index.js";
|
|
2
|
+
export { FileManagerAcoFeature } from "./FileManagerAcoFeature.js";
|
package/index.js
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createAcoFileManagerImportExportContext = exports.createAcoFileManagerContext = void 0;
|
|
7
|
-
var _api = require("@webiny/api");
|
|
8
|
-
var _hooks = require("./file/hooks");
|
|
9
|
-
const createAcoFileManagerContext = () => {
|
|
10
|
-
return new _api.ContextPlugin(context => {
|
|
11
|
-
(0, _hooks.createFileHooks)(context);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
exports.createAcoFileManagerContext = createAcoFileManagerContext;
|
|
15
|
-
const createAcoFileManagerImportExportContext = () => {
|
|
16
|
-
return new _api.ContextPlugin(context => {
|
|
17
|
-
(0, _hooks.createImportExportFileHooks)(context);
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
exports.createAcoFileManagerImportExportContext = createAcoFileManagerImportExportContext;
|
|
1
|
+
export * from "./plugins/index.js";
|
|
2
|
+
export { FileManagerAcoFeature } from "./FileManagerAcoFeature.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager-aco",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.d0f34a8194",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"keywords": [
|
|
6
10
|
"api-file-manager-aco:base"
|
|
7
11
|
],
|
|
@@ -13,44 +17,35 @@
|
|
|
13
17
|
"description": "Connect File Manager to ACO",
|
|
14
18
|
"author": "Webiny Ltd.",
|
|
15
19
|
"license": "MIT",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "yarn webiny run build",
|
|
18
|
-
"watch": "yarn webiny run watch"
|
|
19
|
-
},
|
|
20
20
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
"directory": "dist"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@babel/cli": "7.20.7",
|
|
26
|
-
"@babel/core": "7.20.12",
|
|
27
|
-
"@babel/preset-env": "7.20.2",
|
|
28
|
-
"@babel/preset-typescript": "7.18.6",
|
|
29
|
-
"@babel/runtime": "7.20.13",
|
|
30
|
-
"@webiny/api-file-manager-ddb": "0.0.0-unstable.c59b9cc5b9",
|
|
31
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.c59b9cc5b9",
|
|
32
|
-
"@webiny/api-headless-cms-ddb": "0.0.0-unstable.c59b9cc5b9",
|
|
33
|
-
"@webiny/api-i18n": "0.0.0-unstable.c59b9cc5b9",
|
|
34
|
-
"@webiny/api-i18n-ddb": "0.0.0-unstable.c59b9cc5b9",
|
|
35
|
-
"@webiny/api-security": "0.0.0-unstable.c59b9cc5b9",
|
|
36
|
-
"@webiny/api-security-so-ddb": "0.0.0-unstable.c59b9cc5b9",
|
|
37
|
-
"@webiny/api-tenancy": "0.0.0-unstable.c59b9cc5b9",
|
|
38
|
-
"@webiny/api-tenancy-so-ddb": "0.0.0-unstable.c59b9cc5b9",
|
|
39
|
-
"@webiny/cli": "0.0.0-unstable.c59b9cc5b9",
|
|
40
|
-
"@webiny/handler-aws": "0.0.0-unstable.c59b9cc5b9",
|
|
41
|
-
"@webiny/handler-graphql": "0.0.0-unstable.c59b9cc5b9",
|
|
42
|
-
"@webiny/plugins": "0.0.0-unstable.c59b9cc5b9",
|
|
43
|
-
"@webiny/project-utils": "0.0.0-unstable.c59b9cc5b9",
|
|
44
|
-
"mdbid": "1.0.0",
|
|
45
|
-
"ttypescript": "1.5.15",
|
|
46
|
-
"typescript": "4.7.4"
|
|
21
|
+
"access": "public"
|
|
47
22
|
},
|
|
48
23
|
"dependencies": {
|
|
49
|
-
"@webiny/api": "0.0.0-unstable.
|
|
50
|
-
"@webiny/api-
|
|
51
|
-
"@webiny/api-
|
|
52
|
-
"@webiny/error": "0.0.0-unstable.
|
|
53
|
-
"@webiny/
|
|
24
|
+
"@webiny/api-aco": "0.0.0-unstable.d0f34a8194",
|
|
25
|
+
"@webiny/api-file-manager": "0.0.0-unstable.d0f34a8194",
|
|
26
|
+
"@webiny/api-graphql": "0.0.0-unstable.d0f34a8194",
|
|
27
|
+
"@webiny/error": "0.0.0-unstable.d0f34a8194",
|
|
28
|
+
"@webiny/feature": "0.0.0-unstable.d0f34a8194"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@webiny/api": "0.0.0-unstable.d0f34a8194",
|
|
32
|
+
"@webiny/api-core": "0.0.0-unstable.d0f34a8194",
|
|
33
|
+
"@webiny/api-core-testing": "0.0.0-unstable.d0f34a8194",
|
|
34
|
+
"@webiny/api-graphql": "0.0.0-unstable.d0f34a8194",
|
|
35
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.d0f34a8194",
|
|
36
|
+
"@webiny/api-websockets": "0.0.0-unstable.d0f34a8194",
|
|
37
|
+
"@webiny/build-tools": "0.0.0-unstable.d0f34a8194",
|
|
38
|
+
"@webiny/di": "2.0.0",
|
|
39
|
+
"@webiny/event-handler-core": "0.0.0-unstable.d0f34a8194",
|
|
40
|
+
"@webiny/handler": "0.0.0-unstable.d0f34a8194",
|
|
41
|
+
"@webiny/plugins": "0.0.0-unstable.d0f34a8194",
|
|
42
|
+
"@webiny/utils": "0.0.0-unstable.d0f34a8194",
|
|
43
|
+
"@webiny/wcp": "0.0.0-unstable.d0f34a8194",
|
|
44
|
+
"graphql": "16.14.2",
|
|
45
|
+
"typescript": "7.0.2",
|
|
46
|
+
"vitest": "4.1.11"
|
|
54
47
|
},
|
|
55
|
-
"
|
|
48
|
+
"webiny": {
|
|
49
|
+
"publishFrom": "dist"
|
|
50
|
+
}
|
|
56
51
|
}
|
|
@@ -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";
|
package/plugins/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./createFmFileFolderModelModifier.js";
|
package/contants.d.ts
DELETED
package/contants.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ROOT_FOLDER = exports.FM_FILE_TYPE = void 0;
|
|
7
|
-
const ROOT_FOLDER = "ROOT";
|
|
8
|
-
exports.ROOT_FOLDER = ROOT_FOLDER;
|
|
9
|
-
const FM_FILE_TYPE = "FmFile";
|
|
10
|
-
exports.FM_FILE_TYPE = FM_FILE_TYPE;
|
package/contants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ROOT_FOLDER","FM_FILE_TYPE"],"sources":["contants.ts"],"sourcesContent":["export const ROOT_FOLDER = \"ROOT\";\nexport const FM_FILE_TYPE = \"FmFile\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAG,MAAM;AAAC;AAC3B,MAAMC,YAAY,GAAG,QAAQ;AAAC"}
|
package/file/hooks/index.d.ts
DELETED
package/file/hooks/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createImportExportFileHooks = exports.createFileHooks = void 0;
|
|
7
|
-
var _onFileAfterCreate = require("./onFileAfterCreate.hook");
|
|
8
|
-
var _onFileAfterBatchCreate = require("./onFileAfterBatchCreate.hook");
|
|
9
|
-
var _onFileAfterDelete = require("./onFileAfterDelete.hook");
|
|
10
|
-
var _onFileAfterUpdate = require("./onFileAfterUpdate.hook");
|
|
11
|
-
const createFileHooks = context => {
|
|
12
|
-
(0, _onFileAfterCreate.onFileAfterCreateHook)(context);
|
|
13
|
-
(0, _onFileAfterBatchCreate.onFileAfterBatchCreateHook)(context);
|
|
14
|
-
(0, _onFileAfterDelete.onFileAfterDeleteHook)(context);
|
|
15
|
-
(0, _onFileAfterUpdate.onFileAfterUpdateHook)(context);
|
|
16
|
-
};
|
|
17
|
-
exports.createFileHooks = createFileHooks;
|
|
18
|
-
const createImportExportFileHooks = context => {
|
|
19
|
-
(0, _onFileAfterCreate.onFileAfterCreateHook)(context);
|
|
20
|
-
(0, _onFileAfterBatchCreate.onFileAfterBatchCreateHook)(context);
|
|
21
|
-
};
|
|
22
|
-
exports.createImportExportFileHooks = createImportExportFileHooks;
|
package/file/hooks/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createFileHooks","context","onFileAfterCreateHook","onFileAfterBatchCreateHook","onFileAfterDeleteHook","onFileAfterUpdateHook","createImportExportFileHooks"],"sources":["index.ts"],"sourcesContent":["import { onFileAfterCreateHook } from \"~/file/hooks/onFileAfterCreate.hook\";\nimport { onFileAfterBatchCreateHook } from \"~/file/hooks/onFileAfterBatchCreate.hook\";\nimport { onFileAfterDeleteHook } from \"~/file/hooks/onFileAfterDelete.hook\";\nimport { onFileAfterUpdateHook } from \"~/file/hooks/onFileAfterUpdate.hook\";\n\nimport { FmAcoContext } from \"~/types\";\n\nexport const createFileHooks = (context: FmAcoContext) => {\n onFileAfterCreateHook(context);\n onFileAfterBatchCreateHook(context);\n onFileAfterDeleteHook(context);\n onFileAfterUpdateHook(context);\n};\n\nexport const createImportExportFileHooks = (context: FmAcoContext) => {\n onFileAfterCreateHook(context);\n onFileAfterBatchCreateHook(context);\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAIO,MAAMA,eAAe,GAAIC,OAAqB,IAAK;EACtD,IAAAC,wCAAqB,EAACD,OAAO,CAAC;EAC9B,IAAAE,kDAA0B,EAACF,OAAO,CAAC;EACnC,IAAAG,wCAAqB,EAACH,OAAO,CAAC;EAC9B,IAAAI,wCAAqB,EAACJ,OAAO,CAAC;AAClC,CAAC;AAAC;AAEK,MAAMK,2BAA2B,GAAIL,OAAqB,IAAK;EAClE,IAAAC,wCAAqB,EAACD,OAAO,CAAC;EAC9B,IAAAE,kDAA0B,EAACF,OAAO,CAAC;AACvC,CAAC;AAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.onFileAfterBatchCreateHook = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _createRecordPayload = require("../../utils/createRecordPayload");
|
|
10
|
-
const onFileAfterBatchCreateHook = ({
|
|
11
|
-
fileManager,
|
|
12
|
-
aco
|
|
13
|
-
}) => {
|
|
14
|
-
/**
|
|
15
|
-
* Intercept file batch creation and create a new search records.
|
|
16
|
-
*/
|
|
17
|
-
fileManager.onFileAfterBatchCreate.subscribe(async ({
|
|
18
|
-
files,
|
|
19
|
-
meta
|
|
20
|
-
}) => {
|
|
21
|
-
try {
|
|
22
|
-
for (const file of files) {
|
|
23
|
-
if (file.meta.private) {
|
|
24
|
-
// Skipping ACO search record creation while file is marked as private
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const payload = (0, _createRecordPayload.createFileRecordPayload)(file, meta);
|
|
28
|
-
await aco.search.create(payload);
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
throw _error.default.from(error, {
|
|
32
|
-
message: "Error while executing onFileAfterBatchCreateHook hook",
|
|
33
|
-
code: "ACO_AFTER_FILE_BATCH_CREATE_HOOK"
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
exports.onFileAfterBatchCreateHook = onFileAfterBatchCreateHook;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["onFileAfterBatchCreateHook","fileManager","aco","onFileAfterBatchCreate","subscribe","files","meta","file","private","payload","createFileRecordPayload","search","create","error","WebinyError","from","message","code"],"sources":["onFileAfterBatchCreate.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { createFileRecordPayload } from \"../../utils/createRecordPayload\";\n\nimport { FmAcoContext, FmFileRecordData } from \"~/types\";\n\nexport const onFileAfterBatchCreateHook = ({ fileManager, aco }: FmAcoContext) => {\n /**\n * Intercept file batch creation and create a new search records.\n */\n fileManager.onFileAfterBatchCreate.subscribe(async ({ files, meta }) => {\n try {\n for (const file of files) {\n if (file.meta.private) {\n // Skipping ACO search record creation while file is marked as private\n continue;\n }\n const payload = createFileRecordPayload(file, meta);\n await aco.search.create<FmFileRecordData>(payload);\n }\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterBatchCreateHook hook\",\n code: \"ACO_AFTER_FILE_BATCH_CREATE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAIO,MAAMA,0BAA0B,GAAG,CAAC;EAAEC,WAAW;EAAEC;AAAkB,CAAC,KAAK;EAC9E;AACJ;AACA;EACID,WAAW,CAACE,sBAAsB,CAACC,SAAS,CAAC,OAAO;IAAEC,KAAK;IAAEC;EAAK,CAAC,KAAK;IACpE,IAAI;MACA,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;QACtB,IAAIE,IAAI,CAACD,IAAI,CAACE,OAAO,EAAE;UACnB;UACA;QACJ;QACA,MAAMC,OAAO,GAAG,IAAAC,4CAAuB,EAACH,IAAI,EAAED,IAAI,CAAC;QACnD,MAAMJ,GAAG,CAACS,MAAM,CAACC,MAAM,CAAmBH,OAAO,CAAC;MACtD;IACJ,CAAC,CAAC,OAAOI,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,uDAAuD;QAChEC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.onFileAfterCreateHook = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _createRecordPayload = require("../../utils/createRecordPayload");
|
|
10
|
-
const onFileAfterCreateHook = ({
|
|
11
|
-
fileManager,
|
|
12
|
-
aco
|
|
13
|
-
}) => {
|
|
14
|
-
/**
|
|
15
|
-
* Intercept file creation and create a new search record.
|
|
16
|
-
*/
|
|
17
|
-
fileManager.onFileAfterCreate.subscribe(async ({
|
|
18
|
-
file,
|
|
19
|
-
meta
|
|
20
|
-
}) => {
|
|
21
|
-
try {
|
|
22
|
-
if (file.meta.private) {
|
|
23
|
-
// Skipping ACO search record creation while file is marked as private
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const payload = (0, _createRecordPayload.createFileRecordPayload)(file, meta);
|
|
27
|
-
await aco.search.create(payload);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
throw _error.default.from(error, {
|
|
30
|
-
message: "Error while executing onFileAfterCreateHook hook",
|
|
31
|
-
code: "ACO_AFTER_FILE_CREATE_HOOK"
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
exports.onFileAfterCreateHook = onFileAfterCreateHook;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["onFileAfterCreateHook","fileManager","aco","onFileAfterCreate","subscribe","file","meta","private","payload","createFileRecordPayload","search","create","error","WebinyError","from","message","code"],"sources":["onFileAfterCreate.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { createFileRecordPayload } from \"../../utils/createRecordPayload\";\n\nimport { FmAcoContext, FmFileRecordData } from \"~/types\";\n\nexport const onFileAfterCreateHook = ({ fileManager, aco }: FmAcoContext) => {\n /**\n * Intercept file creation and create a new search record.\n */\n fileManager.onFileAfterCreate.subscribe(async ({ file, meta }) => {\n try {\n if (file.meta.private) {\n // Skipping ACO search record creation while file is marked as private\n return;\n }\n const payload = createFileRecordPayload(file, meta);\n await aco.search.create<FmFileRecordData>(payload);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterCreateHook hook\",\n code: \"ACO_AFTER_FILE_CREATE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAIO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC,WAAW;EAAEC;AAAkB,CAAC,KAAK;EACzE;AACJ;AACA;EACID,WAAW,CAACE,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC,IAAI;IAAEC;EAAK,CAAC,KAAK;IAC9D,IAAI;MACA,IAAID,IAAI,CAACC,IAAI,CAACC,OAAO,EAAE;QACnB;QACA;MACJ;MACA,MAAMC,OAAO,GAAG,IAAAC,4CAAuB,EAACJ,IAAI,EAAEC,IAAI,CAAC;MACnD,MAAMJ,GAAG,CAACQ,MAAM,CAACC,MAAM,CAAmBH,OAAO,CAAC;IACtD,CAAC,CAAC,OAAOI,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.onFileAfterDeleteHook = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
const onFileAfterDeleteHook = ({
|
|
10
|
-
fileManager,
|
|
11
|
-
aco
|
|
12
|
-
}) => {
|
|
13
|
-
/**
|
|
14
|
-
* Intercept file deletion and delete the related search record.
|
|
15
|
-
*/
|
|
16
|
-
fileManager.onFileAfterDelete.subscribe(async ({
|
|
17
|
-
file
|
|
18
|
-
}) => {
|
|
19
|
-
try {
|
|
20
|
-
await aco.search.delete(file.id);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
if (error.code === "NOT_FOUND") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
throw _error.default.from(error, {
|
|
26
|
-
message: "Error while executing onFileAfterDeleteHook hook",
|
|
27
|
-
code: "ACO_AFTER_FILE_DELETE_HOOK"
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
exports.onFileAfterDeleteHook = onFileAfterDeleteHook;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["onFileAfterDeleteHook","fileManager","aco","onFileAfterDelete","subscribe","file","search","delete","id","error","code","WebinyError","from","message"],"sources":["onFileAfterDelete.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { FmAcoContext } from \"~/types\";\n\nexport const onFileAfterDeleteHook = ({ fileManager, aco }: FmAcoContext) => {\n /**\n * Intercept file deletion and delete the related search record.\n */\n fileManager.onFileAfterDelete.subscribe(async ({ file }) => {\n try {\n await aco.search.delete(file.id);\n } catch (error) {\n if (error.code === \"NOT_FOUND\") {\n return;\n }\n\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterDeleteHook hook\",\n code: \"ACO_AFTER_FILE_DELETE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAIO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC,WAAW;EAAEC;AAAkB,CAAC,KAAK;EACzE;AACJ;AACA;EACID,WAAW,CAACE,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IACxD,IAAI;MACA,MAAMH,GAAG,CAACI,MAAM,CAACC,MAAM,CAACF,IAAI,CAACG,EAAE,CAAC;IACpC,CAAC,CAAC,OAAOC,KAAK,EAAE;MACZ,IAAIA,KAAK,CAACC,IAAI,KAAK,WAAW,EAAE;QAC5B;MACJ;MAEA,MAAMC,cAAW,CAACC,IAAI,CAACH,KAAK,EAAE;QAC1BI,OAAO,EAAE,kDAAkD;QAC3DH,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.onFileAfterUpdateHook = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _createRecordPayload = require("../../utils/createRecordPayload");
|
|
10
|
-
const onFileAfterUpdateHook = ({
|
|
11
|
-
aco,
|
|
12
|
-
fileManager
|
|
13
|
-
}) => {
|
|
14
|
-
/**
|
|
15
|
-
* Intercept file update event and update the related search record.
|
|
16
|
-
*/
|
|
17
|
-
fileManager.onFileAfterUpdate.subscribe(async ({
|
|
18
|
-
file
|
|
19
|
-
}) => {
|
|
20
|
-
try {
|
|
21
|
-
const payload = await (0, _createRecordPayload.updatePageRecordPayload)(file);
|
|
22
|
-
await aco.search.update(file.id, payload);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
throw _error.default.from(error, {
|
|
25
|
-
message: "Error while executing onFileAfterUpdateHook hook",
|
|
26
|
-
code: "ACO_AFTER_FILE_UPDATE_HOOK"
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
exports.onFileAfterUpdateHook = onFileAfterUpdateHook;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["onFileAfterUpdateHook","aco","fileManager","onFileAfterUpdate","subscribe","file","payload","updatePageRecordPayload","search","update","id","error","WebinyError","from","message","code"],"sources":["onFileAfterUpdate.hook.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nimport { updatePageRecordPayload } from \"../../utils/createRecordPayload\";\n\nimport { FmAcoContext, FmFileRecordData } from \"~/types\";\n\nexport const onFileAfterUpdateHook = ({ aco, fileManager }: FmAcoContext) => {\n /**\n * Intercept file update event and update the related search record.\n */\n fileManager.onFileAfterUpdate.subscribe(async ({ file }) => {\n try {\n const payload = await updatePageRecordPayload(file);\n await aco.search.update<FmFileRecordData>(file.id, payload);\n } catch (error) {\n throw WebinyError.from(error, {\n message: \"Error while executing onFileAfterUpdateHook hook\",\n code: \"ACO_AFTER_FILE_UPDATE_HOOK\"\n });\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAIO,MAAMA,qBAAqB,GAAG,CAAC;EAAEC,GAAG;EAAEC;AAA0B,CAAC,KAAK;EACzE;AACJ;AACA;EACIA,WAAW,CAACC,iBAAiB,CAACC,SAAS,CAAC,OAAO;IAAEC;EAAK,CAAC,KAAK;IACxD,IAAI;MACA,MAAMC,OAAO,GAAG,MAAM,IAAAC,4CAAuB,EAACF,IAAI,CAAC;MACnD,MAAMJ,GAAG,CAACO,MAAM,CAACC,MAAM,CAAmBJ,IAAI,CAACK,EAAE,EAAEJ,OAAO,CAAC;IAC/D,CAAC,CAAC,OAAOK,KAAK,EAAE;MACZ,MAAMC,cAAW,CAACC,IAAI,CAACF,KAAK,EAAE;QAC1BG,OAAO,EAAE,kDAAkD;QAC3DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createAcoFileManagerContext","ContextPlugin","context","createFileHooks","createAcoFileManagerImportExportContext","createImportExportFileHooks"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\n\nimport { createImportExportFileHooks, createFileHooks } from \"~/file/hooks\";\n\nimport { FmAcoContext } from \"~/types\";\n\nexport const createAcoFileManagerContext = () => {\n return new ContextPlugin<FmAcoContext>(context => {\n createFileHooks(context);\n });\n};\n\nexport const createAcoFileManagerImportExportContext = () => {\n return new ContextPlugin<FmAcoContext>(context => {\n createImportExportFileHooks(context);\n });\n};\n"],"mappings":";;;;;;AAAA;AAEA;AAIO,MAAMA,2BAA2B,GAAG,MAAM;EAC7C,OAAO,IAAIC,kBAAa,CAAeC,OAAO,IAAI;IAC9C,IAAAC,sBAAe,EAACD,OAAO,CAAC;EAC5B,CAAC,CAAC;AACN,CAAC;AAAC;AAEK,MAAME,uCAAuC,GAAG,MAAM;EACzD,OAAO,IAAIH,kBAAa,CAAeC,OAAO,IAAI;IAC9C,IAAAG,kCAA2B,EAACH,OAAO,CAAC;EACxC,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/types.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AcoContext } from "@webiny/api-aco/types";
|
|
2
|
-
import { FileManagerContext, File } from "@webiny/api-file-manager/types";
|
|
3
|
-
import { Context as BaseContext } from "@webiny/handler/types";
|
|
4
|
-
export declare type FmFileRecordData = Pick<File, "id" | "key" | "size" | "type" | "name" | "meta" | "createdOn" | "createdBy" | "aliases">;
|
|
5
|
-
export interface FmAcoContext extends BaseContext, AcoContext, FileManagerContext {
|
|
6
|
-
}
|
package/types.js
DELETED
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { AcoContext } from \"@webiny/api-aco/types\";\nimport { FileManagerContext, File } from \"@webiny/api-file-manager/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\n\nexport type FmFileRecordData = Pick<\n File,\n \"id\" | \"key\" | \"size\" | \"type\" | \"name\" | \"meta\" | \"createdOn\" | \"createdBy\" | \"aliases\"\n>;\n\nexport interface FmAcoContext extends BaseContext, AcoContext, FileManagerContext {}\n"],"mappings":""}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CreateSearchRecordParams, UpdateSearchRecordParams } from "@webiny/api-aco/record/record.types";
|
|
2
|
-
import { File } from "@webiny/api-file-manager/types";
|
|
3
|
-
import { FmFileRecordData } from "../types";
|
|
4
|
-
export declare const addMimeTag: (tags: string[], mime: string) => string[];
|
|
5
|
-
export declare const createFileRecordPayload: (file: File, requestMeta?: Record<string, any>) => CreateSearchRecordParams<FmFileRecordData>;
|
|
6
|
-
export declare const updatePageRecordPayload: (file: File) => Promise<UpdateSearchRecordParams<FmFileRecordData>>;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.updatePageRecordPayload = exports.createFileRecordPayload = exports.addMimeTag = void 0;
|
|
7
|
-
var _contants = require("../contants");
|
|
8
|
-
const addMimeTag = (tags, mime) => [...tags, `mime:${mime}`];
|
|
9
|
-
exports.addMimeTag = addMimeTag;
|
|
10
|
-
const createFileRecordPayload = (file, requestMeta) => {
|
|
11
|
-
var _requestMeta$location;
|
|
12
|
-
const {
|
|
13
|
-
id,
|
|
14
|
-
key,
|
|
15
|
-
size,
|
|
16
|
-
type,
|
|
17
|
-
name,
|
|
18
|
-
meta,
|
|
19
|
-
createdOn,
|
|
20
|
-
createdBy,
|
|
21
|
-
tags,
|
|
22
|
-
aliases
|
|
23
|
-
} = file;
|
|
24
|
-
const location = {
|
|
25
|
-
folderId: (requestMeta === null || requestMeta === void 0 ? void 0 : (_requestMeta$location = requestMeta.location) === null || _requestMeta$location === void 0 ? void 0 : _requestMeta$location.folderId) || _contants.ROOT_FOLDER
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
id,
|
|
29
|
-
type: _contants.FM_FILE_TYPE,
|
|
30
|
-
title: name,
|
|
31
|
-
location,
|
|
32
|
-
tags: addMimeTag(tags, type),
|
|
33
|
-
data: {
|
|
34
|
-
id,
|
|
35
|
-
key,
|
|
36
|
-
size,
|
|
37
|
-
type,
|
|
38
|
-
name,
|
|
39
|
-
createdOn,
|
|
40
|
-
createdBy,
|
|
41
|
-
aliases,
|
|
42
|
-
meta
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
exports.createFileRecordPayload = createFileRecordPayload;
|
|
47
|
-
const updatePageRecordPayload = async file => {
|
|
48
|
-
const {
|
|
49
|
-
id,
|
|
50
|
-
key,
|
|
51
|
-
size,
|
|
52
|
-
type,
|
|
53
|
-
name,
|
|
54
|
-
meta,
|
|
55
|
-
createdOn,
|
|
56
|
-
createdBy,
|
|
57
|
-
tags,
|
|
58
|
-
aliases
|
|
59
|
-
} = file;
|
|
60
|
-
return {
|
|
61
|
-
title: name,
|
|
62
|
-
tags: addMimeTag(tags, type),
|
|
63
|
-
data: {
|
|
64
|
-
id,
|
|
65
|
-
key,
|
|
66
|
-
size,
|
|
67
|
-
type,
|
|
68
|
-
name,
|
|
69
|
-
createdOn,
|
|
70
|
-
createdBy,
|
|
71
|
-
aliases,
|
|
72
|
-
meta
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
exports.updatePageRecordPayload = updatePageRecordPayload;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["addMimeTag","tags","mime","createFileRecordPayload","file","requestMeta","id","key","size","type","name","meta","createdOn","createdBy","aliases","location","folderId","ROOT_FOLDER","FM_FILE_TYPE","title","data","updatePageRecordPayload"],"sources":["createRecordPayload.ts"],"sourcesContent":["import { FM_FILE_TYPE, ROOT_FOLDER } from \"~/contants\";\n\nimport {\n CreateSearchRecordParams,\n UpdateSearchRecordParams\n} from \"@webiny/api-aco/record/record.types\";\nimport { File } from \"@webiny/api-file-manager/types\";\nimport { FmFileRecordData } from \"~/types\";\n\nexport const addMimeTag = (tags: string[], mime: string): string[] => [...tags, `mime:${mime}`];\n\nexport const createFileRecordPayload = (\n file: File,\n requestMeta?: Record<string, any>\n): CreateSearchRecordParams<FmFileRecordData> => {\n const { id, key, size, type, name, meta, createdOn, createdBy, tags, aliases } = file;\n const location = {\n folderId: requestMeta?.location?.folderId || ROOT_FOLDER\n };\n\n return {\n id,\n type: FM_FILE_TYPE,\n title: name,\n location,\n tags: addMimeTag(tags, type),\n data: {\n id,\n key,\n size,\n type,\n name,\n createdOn,\n createdBy,\n aliases,\n meta\n }\n };\n};\n\nexport const updatePageRecordPayload = async (\n file: File\n): Promise<UpdateSearchRecordParams<FmFileRecordData>> => {\n const { id, key, size, type, name, meta, createdOn, createdBy, tags, aliases } = file;\n\n return {\n title: name,\n tags: addMimeTag(tags, type),\n data: {\n id,\n key,\n size,\n type,\n name,\n createdOn,\n createdBy,\n aliases,\n meta\n }\n };\n};\n"],"mappings":";;;;;;AAAA;AASO,MAAMA,UAAU,GAAG,CAACC,IAAc,EAAEC,IAAY,KAAe,CAAC,GAAGD,IAAI,EAAG,QAAOC,IAAK,EAAC,CAAC;AAAC;AAEzF,MAAMC,uBAAuB,GAAG,CACnCC,IAAU,EACVC,WAAiC,KACY;EAAA;EAC7C,MAAM;IAAEC,EAAE;IAAEC,GAAG;IAAEC,IAAI;IAAEC,IAAI;IAAEC,IAAI;IAAEC,IAAI;IAAEC,SAAS;IAAEC,SAAS;IAAEZ,IAAI;IAAEa;EAAQ,CAAC,GAAGV,IAAI;EACrF,MAAMW,QAAQ,GAAG;IACbC,QAAQ,EAAE,CAAAX,WAAW,aAAXA,WAAW,gDAAXA,WAAW,CAAEU,QAAQ,0DAArB,sBAAuBC,QAAQ,KAAIC;EACjD,CAAC;EAED,OAAO;IACHX,EAAE;IACFG,IAAI,EAAES,sBAAY;IAClBC,KAAK,EAAET,IAAI;IACXK,QAAQ;IACRd,IAAI,EAAED,UAAU,CAACC,IAAI,EAAEQ,IAAI,CAAC;IAC5BW,IAAI,EAAE;MACFd,EAAE;MACFC,GAAG;MACHC,IAAI;MACJC,IAAI;MACJC,IAAI;MACJE,SAAS;MACTC,SAAS;MACTC,OAAO;MACPH;IACJ;EACJ,CAAC;AACL,CAAC;AAAC;AAEK,MAAMU,uBAAuB,GAAG,MACnCjB,IAAU,IAC4C;EACtD,MAAM;IAAEE,EAAE;IAAEC,GAAG;IAAEC,IAAI;IAAEC,IAAI;IAAEC,IAAI;IAAEC,IAAI;IAAEC,SAAS;IAAEC,SAAS;IAAEZ,IAAI;IAAEa;EAAQ,CAAC,GAAGV,IAAI;EAErF,OAAO;IACHe,KAAK,EAAET,IAAI;IACXT,IAAI,EAAED,UAAU,CAACC,IAAI,EAAEQ,IAAI,CAAC;IAC5BW,IAAI,EAAE;MACFd,EAAE;MACFC,GAAG;MACHC,IAAI;MACJC,IAAI;MACJC,IAAI;MACJE,SAAS;MACTC,SAAS;MACTC,OAAO;MACPH;IACJ;EACJ,CAAC;AACL,CAAC;AAAC"}
|