@webiny/api-file-manager-aco 0.0.0-unstable.606fc9c866
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/contants.d.ts +2 -0
- package/contants.js +10 -0
- package/contants.js.map +1 -0
- package/file/hooks/index.d.ts +2 -0
- package/file/hooks/index.js +17 -0
- package/file/hooks/index.js.map +1 -0
- package/file/hooks/onFileAfterBatchCreate.hook.d.ts +2 -0
- package/file/hooks/onFileAfterBatchCreate.hook.js +34 -0
- package/file/hooks/onFileAfterBatchCreate.hook.js.map +1 -0
- package/file/hooks/onFileAfterCreate.hook.d.ts +2 -0
- package/file/hooks/onFileAfterCreate.hook.js +32 -0
- package/file/hooks/onFileAfterCreate.hook.js.map +1 -0
- package/file/hooks/onFileAfterDelete.hook.d.ts +2 -0
- package/file/hooks/onFileAfterDelete.hook.js +32 -0
- package/file/hooks/onFileAfterDelete.hook.js.map +1 -0
- package/file/hooks/onFileAfterUpdate.hook.d.ts +2 -0
- package/file/hooks/onFileAfterUpdate.hook.js +31 -0
- package/file/hooks/onFileAfterUpdate.hook.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +14 -0
- package/index.js.map +1 -0
- package/package.json +55 -0
- package/types.d.ts +6 -0
- package/types.js +5 -0
- package/types.js.map +1 -0
- package/utils/createRecordPayload.d.ts +6 -0
- package/utils/createRecordPayload.js +76 -0
- package/utils/createRecordPayload.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @webiny/api-file-manager-aco
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/api-file-manager-aco)
|
|
4
|
+
[](https://www.npmjs.com/package/@webiny/api-file-manager-aco)
|
|
5
|
+
[](https://github.com/prettier/prettier)
|
|
6
|
+
[](http://makeapullrequest.com)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npm install --save @webiny/api-file-manager-aco
|
|
12
|
+
```
|
|
13
|
+
|
|
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
|
+
```
|
package/contants.d.ts
ADDED
package/contants.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.createAcoFileManagerContext = createAcoFileManagerContext;
|
package/index.js.map
ADDED
|
@@ -0,0 +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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-file-manager-aco",
|
|
3
|
+
"version": "0.0.0-unstable.606fc9c866",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api-file-manager-aco:base"
|
|
7
|
+
],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
11
|
+
"directory": "packages/api-file-manager-aco"
|
|
12
|
+
},
|
|
13
|
+
"description": "Connect File Manager to ACO",
|
|
14
|
+
"author": "Webiny Ltd.",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "yarn webiny run build",
|
|
18
|
+
"watch": "yarn webiny run watch"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"directory": "dist"
|
|
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
|
+
"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"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "606fc9c866aec436f24983abc9bdaf02af2b8746"
|
|
55
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
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>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|