@webiny/api-file-manager-aco 0.0.0-unstable.aa00eecd97 β†’ 0.0.0-unstable.ac6ebf63c6

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.
Files changed (41) hide show
  1. package/README.md +6 -28
  2. package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.d.ts +13 -0
  3. package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js +52 -0
  4. package/features/EnsureFolderIsEmptyBeforeDelete/EnsureFolderIsEmptyBeforeDelete.js.map +1 -0
  5. package/features/EnsureFolderIsEmptyBeforeDelete/feature.d.ts +1 -0
  6. package/features/EnsureFolderIsEmptyBeforeDelete/feature.js +10 -0
  7. package/features/EnsureFolderIsEmptyBeforeDelete/feature.js.map +1 -0
  8. package/index.d.ts +2 -3
  9. package/index.js +8 -12
  10. package/index.js.map +1 -1
  11. package/package.json +23 -34
  12. package/plugins/createFmFileFolderModelModifier.d.ts +10 -0
  13. package/plugins/createFmFileFolderModelModifier.js +32 -0
  14. package/plugins/createFmFileFolderModelModifier.js.map +1 -0
  15. package/plugins/index.d.ts +1 -0
  16. package/plugins/index.js +3 -0
  17. package/plugins/index.js.map +1 -0
  18. package/contants.d.ts +0 -2
  19. package/contants.js +0 -10
  20. package/contants.js.map +0 -1
  21. package/file/hooks/index.d.ts +0 -2
  22. package/file/hooks/index.js +0 -17
  23. package/file/hooks/index.js.map +0 -1
  24. package/file/hooks/onFileAfterBatchCreate.hook.d.ts +0 -2
  25. package/file/hooks/onFileAfterBatchCreate.hook.js +0 -38
  26. package/file/hooks/onFileAfterBatchCreate.hook.js.map +0 -1
  27. package/file/hooks/onFileAfterCreate.hook.d.ts +0 -2
  28. package/file/hooks/onFileAfterCreate.hook.js +0 -36
  29. package/file/hooks/onFileAfterCreate.hook.js.map +0 -1
  30. package/file/hooks/onFileAfterDelete.hook.d.ts +0 -2
  31. package/file/hooks/onFileAfterDelete.hook.js +0 -32
  32. package/file/hooks/onFileAfterDelete.hook.js.map +0 -1
  33. package/file/hooks/onFileAfterUpdate.hook.d.ts +0 -2
  34. package/file/hooks/onFileAfterUpdate.hook.js +0 -31
  35. package/file/hooks/onFileAfterUpdate.hook.js.map +0 -1
  36. package/types.d.ts +0 -6
  37. package/types.js +0 -5
  38. package/types.js.map +0 -1
  39. package/utils/createRecordPayload.d.ts +0 -6
  40. package/utils/createRecordPayload.js +0 -76
  41. package/utils/createRecordPayload.js.map +0 -1
package/README.md CHANGED
@@ -1,33 +1,11 @@
1
1
  # @webiny/api-file-manager-aco
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/api-file-manager-aco.svg)](https://www.npmjs.com/package/@webiny/api-file-manager-aco)
4
- [![](https://img.shields.io/npm/v/@webiny/api-file-manager-aco.svg)](https://www.npmjs.com/package/@webiny/api-file-manager-aco)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](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
- ## Install
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
- Or if you prefer yarn:
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 { 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: [EnsureFolderIsEmpty, ListFilesUseCase]\n});\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,yBAAyB,QAAQ,8CAA8C;AACxF,SAASC,gBAAgB,QAAQ,2DAA2D;AAC5F,SAASC,mBAAmB,QAAQ,qDAAqD;AAEzF,MAAMC,mCAAmC,CAAgD;EACrFC,WAAWA,CACCC,mBAAkD,EAClDC,SAAqC,EAC/C;IAAA,KAFUD,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,SAAqC,GAArCA,SAAqC;EAC9C;EAEH,MAAMC,MAAMA,CAACC,KAAsC,EAAiB;IAChE,MAAM;MAAEC;IAAO,CAAC,GAAGD,KAAK,CAACE,OAAO;IAEhC,MAAM;MAAEC,EAAE;MAAEC;IAAK,CAAC,GAAGH,MAAM;;IAE3B;AACR;AACA;IACQ,IAAIG,IAAI,KAAK,QAAQ,EAAE;MACnB;IACJ;IAEA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACR,mBAAmB,CAACS,OAAO,CAACF,IAAI,EAAED,EAAE,EAAE,YAAY;MACxE,MAAME,MAAM,GAAG,MAAM,IAAI,CAACP,SAAS,CAACQ,OAAO,CAAC;QACxCC,KAAK,EAAE;UACHC,QAAQ,EAAE;YACNC,QAAQ,EAAEN;UACd;QACJ,CAAC;QACDO,KAAK,EAAE;MACX,CAAC,CAAC;MAEF,MAAM;QAAEC;MAAM,CAAC,GAAGN,MAAM,CAACO,KAAK;MAE9B,OAAOD,KAAK,CAACE,MAAM,GAAG,CAAC;IAC3B,CAAC,CAAC;IAEF,IAAIR,MAAM,CAACS,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMvB,WAAW,CAACwB,IAAI,CAACV,MAAM,CAACW,KAAK,EAAE;QACjCC,OAAO,EAAE,qDAAqD;QAC9DC,IAAI,EAAE;MACV,CAAC,CAAC;IACN;EACJ;AACJ;AAEA,OAAO,MAAMC,+BAA+B,GAAG3B,yBAAyB,CAAC4B,oBAAoB,CAAC;EAC1FC,cAAc,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 CHANGED
@@ -1,3 +1,2 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { FmAcoContext } from "./types";
3
- export declare const createAcoFileManagerContext: () => ContextPlugin<FmAcoContext>;
1
+ export * from "./plugins/index.js";
2
+ export declare const createFileManagerAco: () => import("@webiny/api").ContextPlugin<import("@webiny/api/types.js").Context>;
package/index.js CHANGED
@@ -1,14 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- 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);
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);
12
7
  });
13
8
  };
14
- exports.createAcoFileManagerContext = createAcoFileManagerContext;
9
+
10
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createAcoFileManagerContext","ContextPlugin","context","createFileHooks"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\n\nimport { 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"],"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"}
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,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager-aco",
3
- "version": "0.0.0-unstable.aa00eecd97",
3
+ "version": "0.0.0-unstable.ac6ebf63c6",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "keywords": [
6
7
  "api-file-manager-aco:base"
@@ -13,44 +14,32 @@
13
14
  "description": "Connect File Manager to ACO",
14
15
  "author": "Webiny Ltd.",
15
16
  "license": "MIT",
16
- "scripts": {
17
- "build": "yarn webiny run build",
18
- "watch": "yarn webiny run watch"
19
- },
20
17
  "publishConfig": {
21
18
  "access": "public",
22
19
  "directory": "dist"
23
20
  },
21
+ "dependencies": {
22
+ "@webiny/api-aco": "0.0.0-unstable.ac6ebf63c6",
23
+ "@webiny/api-file-manager": "0.0.0-unstable.ac6ebf63c6",
24
+ "@webiny/error": "0.0.0-unstable.ac6ebf63c6",
25
+ "@webiny/feature": "0.0.0-unstable.ac6ebf63c6"
26
+ },
24
27
  "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.aa00eecd97",
31
- "@webiny/api-headless-cms": "0.0.0-unstable.aa00eecd97",
32
- "@webiny/api-headless-cms-ddb": "0.0.0-unstable.aa00eecd97",
33
- "@webiny/api-i18n": "0.0.0-unstable.aa00eecd97",
34
- "@webiny/api-i18n-ddb": "0.0.0-unstable.aa00eecd97",
35
- "@webiny/api-security": "0.0.0-unstable.aa00eecd97",
36
- "@webiny/api-security-so-ddb": "0.0.0-unstable.aa00eecd97",
37
- "@webiny/api-tenancy": "0.0.0-unstable.aa00eecd97",
38
- "@webiny/api-tenancy-so-ddb": "0.0.0-unstable.aa00eecd97",
39
- "@webiny/cli": "0.0.0-unstable.aa00eecd97",
40
- "@webiny/handler-aws": "0.0.0-unstable.aa00eecd97",
41
- "@webiny/handler-graphql": "0.0.0-unstable.aa00eecd97",
42
- "@webiny/plugins": "0.0.0-unstable.aa00eecd97",
43
- "@webiny/project-utils": "0.0.0-unstable.aa00eecd97",
44
- "mdbid": "1.0.0",
28
+ "@webiny/api": "0.0.0-unstable.ac6ebf63c6",
29
+ "@webiny/api-core": "0.0.0-unstable.ac6ebf63c6",
30
+ "@webiny/api-headless-cms": "0.0.0-unstable.ac6ebf63c6",
31
+ "@webiny/build-tools": "0.0.0-unstable.ac6ebf63c6",
32
+ "@webiny/handler": "0.0.0-unstable.ac6ebf63c6",
33
+ "@webiny/handler-aws": "0.0.0-unstable.ac6ebf63c6",
34
+ "@webiny/handler-graphql": "0.0.0-unstable.ac6ebf63c6",
35
+ "@webiny/plugins": "0.0.0-unstable.ac6ebf63c6",
36
+ "@webiny/project-utils": "0.0.0-unstable.ac6ebf63c6",
37
+ "@webiny/utils": "0.0.0-unstable.ac6ebf63c6",
38
+ "@webiny/wcp": "0.0.0-unstable.ac6ebf63c6",
39
+ "graphql": "16.12.0",
45
40
  "ttypescript": "1.5.15",
46
- "typescript": "4.7.4"
47
- },
48
- "dependencies": {
49
- "@webiny/api": "0.0.0-unstable.aa00eecd97",
50
- "@webiny/api-aco": "0.0.0-unstable.aa00eecd97",
51
- "@webiny/api-file-manager": "0.0.0-unstable.aa00eecd97",
52
- "@webiny/error": "0.0.0-unstable.aa00eecd97",
53
- "@webiny/handler": "0.0.0-unstable.aa00eecd97"
41
+ "typescript": "5.9.3",
42
+ "vitest": "3.2.4"
54
43
  },
55
- "gitHead": "aa00eecd97d16da9bdb0581f33d491487ce43ce9"
44
+ "gitHead": "ac6ebf63c6de308703d41f2c1b375e03cd96b813"
56
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":[]}
package/contants.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const ROOT_FOLDER = "ROOT";
2
- export declare const FM_FILE_TYPE = "FmFile";
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"}
@@ -1,2 +0,0 @@
1
- import { FmAcoContext } from "../../types";
2
- export declare const createFileHooks: (context: FmAcoContext) => void;
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- 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;
@@ -1 +0,0 @@
1
- {"version":3,"names":["createFileHooks","context","onFileAfterCreateHook","onFileAfterBatchCreateHook","onFileAfterDeleteHook","onFileAfterUpdateHook"],"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"],"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"}
@@ -1,2 +0,0 @@
1
- import { FmAcoContext } from "../../types";
2
- export declare const onFileAfterBatchCreateHook: ({ fileManager, aco }: FmAcoContext) => void;
@@ -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,2 +0,0 @@
1
- import { FmAcoContext } from "../../types";
2
- export declare const onFileAfterCreateHook: ({ fileManager, aco }: FmAcoContext) => void;
@@ -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,2 +0,0 @@
1
- import { FmAcoContext } from "../../types";
2
- export declare const onFileAfterDeleteHook: ({ fileManager, aco }: FmAcoContext) => void;
@@ -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,2 +0,0 @@
1
- import { FmAcoContext } from "../../types";
2
- export declare const onFileAfterUpdateHook: ({ aco, fileManager }: FmAcoContext) => void;
@@ -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/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
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
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"}