@webiny/api-file-manager-aco 0.0.0-unstable.606fc9c866 → 0.0.0-unstable.7c9e8fbfd6

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/README.md CHANGED
@@ -15,19 +15,4 @@ Or if you prefer yarn:
15
15
 
16
16
  ```
17
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
18
  ```
package/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- import { ContextPlugin } from "@webiny/api";
2
- import { FmAcoContext } from "./types";
3
- export declare const createAcoFileManagerContext: () => ContextPlugin<FmAcoContext>;
1
+ export * from "./plugins";
package/index.js CHANGED
@@ -3,12 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
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);
6
+ var _plugins = require("./plugins");
7
+ Object.keys(_plugins).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _plugins[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _plugins[key];
14
+ }
12
15
  });
13
- };
14
- exports.createAcoFileManagerContext = createAcoFileManagerContext;
16
+ });
17
+
18
+ //# 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":["_plugins","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./plugins\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager-aco",
3
- "version": "0.0.0-unstable.606fc9c866",
3
+ "version": "0.0.0-unstable.7c9e8fbfd6",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "api-file-manager-aco:base"
@@ -14,42 +14,33 @@
14
14
  "author": "Webiny Ltd.",
15
15
  "license": "MIT",
16
16
  "scripts": {
17
- "build": "yarn webiny run build",
18
- "watch": "yarn webiny run watch"
17
+ "build": "node ../cli/bin.js run build",
18
+ "watch": "node ../cli/bin.js run watch"
19
19
  },
20
20
  "publishConfig": {
21
21
  "access": "public",
22
22
  "directory": "dist"
23
23
  },
24
- "devDependencies": {
25
- "@babel/cli": "^7.19.3",
26
- "@babel/core": "^7.19.3",
27
- "@babel/preset-env": "^7.19.4",
28
- "@babel/preset-typescript": "^7.18.6",
29
- "@babel/runtime": "^7.19.0",
30
- "@webiny/api-file-manager-ddb": "^0.0.0-unstable.606fc9c866",
31
- "@webiny/api-headless-cms": "^0.0.0-unstable.606fc9c866",
32
- "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.606fc9c866",
33
- "@webiny/api-i18n": "^0.0.0-unstable.606fc9c866",
34
- "@webiny/api-i18n-ddb": "^0.0.0-unstable.606fc9c866",
35
- "@webiny/api-security": "^0.0.0-unstable.606fc9c866",
36
- "@webiny/api-security-so-ddb": "^0.0.0-unstable.606fc9c866",
37
- "@webiny/api-tenancy": "^0.0.0-unstable.606fc9c866",
38
- "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.606fc9c866",
39
- "@webiny/cli": "^0.0.0-unstable.606fc9c866",
40
- "@webiny/handler-aws": "^0.0.0-unstable.606fc9c866",
41
- "@webiny/handler-graphql": "^0.0.0-unstable.606fc9c866",
42
- "@webiny/plugins": "^0.0.0-unstable.606fc9c866",
43
- "@webiny/project-utils": "^0.0.0-unstable.606fc9c866",
44
- "ttypescript": "^1.5.13",
45
- "typescript": "^4.7.4"
46
- },
47
24
  "dependencies": {
48
- "@webiny/api": "0.0.0-unstable.606fc9c866",
49
- "@webiny/api-aco": "0.0.0-unstable.606fc9c866",
50
- "@webiny/api-file-manager": "0.0.0-unstable.606fc9c866",
51
- "@webiny/error": "0.0.0-unstable.606fc9c866",
52
- "@webiny/handler": "0.0.0-unstable.606fc9c866"
25
+ "@webiny/api-aco": "0.0.0-unstable.7c9e8fbfd6"
26
+ },
27
+ "devDependencies": {
28
+ "@webiny/api": "0.0.0-unstable.7c9e8fbfd6",
29
+ "@webiny/api-admin-users": "0.0.0-unstable.7c9e8fbfd6",
30
+ "@webiny/api-headless-cms": "0.0.0-unstable.7c9e8fbfd6",
31
+ "@webiny/api-i18n": "0.0.0-unstable.7c9e8fbfd6",
32
+ "@webiny/api-security": "0.0.0-unstable.7c9e8fbfd6",
33
+ "@webiny/api-tenancy": "0.0.0-unstable.7c9e8fbfd6",
34
+ "@webiny/api-wcp": "0.0.0-unstable.7c9e8fbfd6",
35
+ "@webiny/handler": "0.0.0-unstable.7c9e8fbfd6",
36
+ "@webiny/handler-aws": "0.0.0-unstable.7c9e8fbfd6",
37
+ "@webiny/handler-graphql": "0.0.0-unstable.7c9e8fbfd6",
38
+ "@webiny/plugins": "0.0.0-unstable.7c9e8fbfd6",
39
+ "@webiny/project-utils": "0.0.0-unstable.7c9e8fbfd6",
40
+ "@webiny/wcp": "0.0.0-unstable.7c9e8fbfd6",
41
+ "graphql": "15.9.0",
42
+ "ttypescript": "1.5.15",
43
+ "typescript": "5.3.3"
53
44
  },
54
- "gitHead": "606fc9c866aec436f24983abc9bdaf02af2b8746"
45
+ "gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
55
46
  }
@@ -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";
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,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFmFileFolderModelModifier = exports.FolderModelFieldsModifier = void 0;
7
+ var _apiAco = require("@webiny/api-aco");
8
+ class FolderModelFieldsModifier {
9
+ fields = [];
10
+ constructor(namespace) {
11
+ this.namespace = namespace;
12
+ }
13
+ setFields(fields) {
14
+ this.fields = fields;
15
+ }
16
+ addField(field) {
17
+ const {
18
+ tags,
19
+ ...rest
20
+ } = field;
21
+ this.fields.push({
22
+ ...rest,
23
+ id: `${this.namespace}_${field.id}`,
24
+ fieldId: `${this.namespace}_${field.fieldId}`,
25
+ storageId: `${field.type}@${this.namespace}_${field.id}`,
26
+ tags: (tags ?? []).concat([`$namespace:${this.namespace}`])
27
+ });
28
+ }
29
+ }
30
+ exports.FolderModelFieldsModifier = FolderModelFieldsModifier;
31
+ const createFmFileFolderModelModifier = callback => {
32
+ const modifier = new FolderModelFieldsModifier("fm_file");
33
+ return new _apiAco.FolderCmsModelModifierPlugin({
34
+ callback,
35
+ modifier
36
+ });
37
+ };
38
+ exports.createFmFileFolderModelModifier = createFmFileFolderModelModifier;
39
+
40
+ //# sourceMappingURL=createFmFileFolderModelModifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_apiAco","require","FolderModelFieldsModifier","fields","constructor","namespace","setFields","addField","field","tags","rest","push","id","fieldId","storageId","type","concat","exports","createFmFileFolderModelModifier","callback","modifier","FolderCmsModelModifierPlugin"],"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\";\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,IAAAA,OAAA,GAAAC,OAAA;AAQO,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;AAACY,OAAA,CAAAf,yBAAA,GAAAA,yBAAA;AAEM,MAAMgB,+BAA+B,GAAIC,QAAkC,IAAK;EACnF,MAAMC,QAAQ,GAAG,IAAIlB,yBAAyB,CAAC,SAAS,CAAC;EAEzD,OAAO,IAAImB,oCAA4B,CAAC;IACpCF,QAAQ;IACRC;EACJ,CAAC,CAAC;AACN,CAAC;AAACH,OAAA,CAAAC,+BAAA,GAAAA,+BAAA","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export * from "./createFmFileFolderModelModifier";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _createFmFileFolderModelModifier = require("./createFmFileFolderModelModifier");
7
+ Object.keys(_createFmFileFolderModelModifier).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _createFmFileFolderModelModifier[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _createFmFileFolderModelModifier[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_createFmFileFolderModelModifier","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./createFmFileFolderModelModifier\";\n"],"mappings":";;;;;AAAA,IAAAA,gCAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gCAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gCAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gCAAA,CAAAK,GAAA;IAAA;EAAA;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,34 +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
- const payload = (0, _createRecordPayload.createFileRecordPayload)(file, meta);
24
- await aco.search.create(payload);
25
- }
26
- } catch (error) {
27
- throw _error.default.from(error, {
28
- message: "Error while executing onFileAfterBatchCreateHook hook",
29
- code: "ACO_AFTER_FILE_BATCH_CREATE_HOOK"
30
- });
31
- }
32
- });
33
- };
34
- exports.onFileAfterBatchCreateHook = onFileAfterBatchCreateHook;
@@ -1 +0,0 @@
1
- {"version":3,"names":["onFileAfterBatchCreateHook","fileManager","aco","onFileAfterBatchCreate","subscribe","files","meta","file","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 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,MAAMG,OAAO,GAAG,IAAAC,4CAAuB,EAACF,IAAI,EAAED,IAAI,CAAC;QACnD,MAAMJ,GAAG,CAACQ,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,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.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
- const payload = (0, _createRecordPayload.createFileRecordPayload)(file, meta);
23
- await aco.search.create(payload);
24
- } catch (error) {
25
- throw _error.default.from(error, {
26
- message: "Error while executing onFileAfterCreateHook hook",
27
- code: "ACO_AFTER_FILE_CREATE_HOOK"
28
- });
29
- }
30
- });
31
- };
32
- exports.onFileAfterCreateHook = onFileAfterCreateHook;
@@ -1 +0,0 @@
1
- {"version":3,"names":["onFileAfterCreateHook","fileManager","aco","onFileAfterCreate","subscribe","file","meta","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 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,MAAMC,OAAO,GAAG,IAAAC,4CAAuB,EAACH,IAAI,EAAEC,IAAI,CAAC;MACnD,MAAMJ,GAAG,CAACO,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 page 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 page 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"}