@webiny/api-file-manager-ddb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7f63ea0744
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/definitions/filesEntity.js +0 -6
- package/definitions/filesEntity.js.map +1 -1
- package/definitions/settingsEntity.js +0 -6
- package/definitions/settingsEntity.js.map +1 -1
- package/definitions/systemEntity.js +0 -6
- package/definitions/systemEntity.js.map +1 -1
- package/definitions/table.js +0 -4
- package/definitions/table.js.map +1 -1
- package/index.js +0 -5
- package/index.js.map +1 -1
- package/operations/files/FilesStorageOperations.js +2 -52
- package/operations/files/FilesStorageOperations.js.map +1 -1
- package/operations/files/fields.js +0 -3
- package/operations/files/fields.js.map +1 -1
- package/operations/files/index.js +0 -9
- package/operations/files/index.js.map +1 -1
- package/operations/settings/SettingsStorageOperations.js +0 -21
- package/operations/settings/SettingsStorageOperations.js.map +1 -1
- package/operations/settings/index.js +0 -8
- package/operations/settings/index.js.map +1 -1
- package/operations/system/SystemStorageOperations.js +0 -22
- package/operations/system/SystemStorageOperations.js.map +1 -1
- package/operations/system/index.js +0 -8
- package/operations/system/index.js.map +1 -1
- package/operations/utils.js +0 -10
- package/operations/utils.js.map +1 -1
- package/package.json +9 -9
- package/plugins/FileAttributePlugin.js +0 -6
- package/plugins/FileAttributePlugin.js.map +1 -1
- package/plugins/FileDynamoDbFieldPlugin.js +0 -5
- package/plugins/FileDynamoDbFieldPlugin.js.map +1 -1
- package/plugins/SettingsAttributePlugin.js +0 -6
- package/plugins/SettingsAttributePlugin.js.map +1 -1
- package/plugins/SystemAttributePlugin.js +0 -6
- package/plugins/SystemAttributePlugin.js.map +1 -1
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
|
-
|
|
14
10
|
var _attributes = require("@webiny/db-dynamodb/utils/attributes");
|
|
15
|
-
|
|
16
11
|
var _default = params => {
|
|
17
12
|
const {
|
|
18
13
|
context,
|
|
@@ -72,5 +67,4 @@ var _default = params => {
|
|
|
72
67
|
}, attributes)
|
|
73
68
|
});
|
|
74
69
|
};
|
|
75
|
-
|
|
76
70
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","id","key","size","meta","tags","createdOn","createdBy","tenant","locale","webinyVersion"],"sources":["filesEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface FilesEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: FilesEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"Files\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n size: {\n type: \"number\"\n },\n type: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n meta: {\n type: \"map\"\n },\n tags: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","id","key","size","meta","tags","createdOn","createdBy","tenant","locale","webinyVersion"],"sources":["filesEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface FilesEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: FilesEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"Files\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n size: {\n type: \"number\"\n },\n type: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n meta: {\n type: \"map\"\n },\n tags: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AAA0E,eAM1DA,MAAyB,IAAkB;EACvD,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGF,MAAM;EACjC,MAAMG,UAAU,GAAG,OAAO;EAC1B,MAAMC,UAAU,GAAG,IAAAC,8BAAkB,EAACJ,OAAO,EAAEE,UAAU,CAAC;EAC1D,OAAO,IAAIG,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBD,KAAK;IACLE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,EAAE,EAAE;QACAD,IAAI,EAAE;MACV,CAAC;MACDE,GAAG,EAAE;QACDF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV,CAAC;MACDA,IAAI,EAAE;QACFA,IAAI,EAAE;MACV,CAAC;MACDN,IAAI,EAAE;QACFM,IAAI,EAAE;MACV,CAAC;MACDI,IAAI,EAAE;QACFJ,IAAI,EAAE;MACV,CAAC;MACDK,IAAI,EAAE;QACFL,IAAI,EAAE;MACV,CAAC;MACDM,SAAS,EAAE;QACPN,IAAI,EAAE;MACV,CAAC;MACDO,SAAS,EAAE;QACPP,IAAI,EAAE;MACV,CAAC;MACDQ,MAAM,EAAE;QACJR,IAAI,EAAE;MACV,CAAC;MACDS,MAAM,EAAE;QACJT,IAAI,EAAE;MACV,CAAC;MACDU,aAAa,EAAE;QACXV,IAAI,EAAE;MACV;IAAC,GACET,UAAU;EAErB,CAAC,CAAC;AACN,CAAC;AAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
|
-
|
|
14
10
|
var _attributes = require("@webiny/db-dynamodb/utils/attributes");
|
|
15
|
-
|
|
16
11
|
var _default = params => {
|
|
17
12
|
const {
|
|
18
13
|
context,
|
|
@@ -48,5 +43,4 @@ var _default = params => {
|
|
|
48
43
|
}, attributes)
|
|
49
44
|
});
|
|
50
45
|
};
|
|
51
|
-
|
|
52
46
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","key","uploadMinFileSize","uploadMaxFileSize","srcPrefix"],"sources":["settingsEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface SettingsEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: SettingsEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"Settings\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n uploadMinFileSize: {\n type: \"number\"\n },\n uploadMaxFileSize: {\n type: \"number\"\n },\n srcPrefix: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","key","uploadMinFileSize","uploadMaxFileSize","srcPrefix"],"sources":["settingsEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface SettingsEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: SettingsEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"Settings\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n uploadMinFileSize: {\n type: \"number\"\n },\n uploadMaxFileSize: {\n type: \"number\"\n },\n srcPrefix: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AAA0E,eAM1DA,MAA4B,IAAkB;EAC1D,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGF,MAAM;EACjC,MAAMG,UAAU,GAAG,UAAU;EAC7B,MAAMC,UAAU,GAAG,IAAAC,8BAAkB,EAACJ,OAAO,EAAEE,UAAU,CAAC;EAC1D,OAAO,IAAIG,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBD,KAAK;IACLE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,GAAG,EAAE;QACDD,IAAI,EAAE;MACV,CAAC;MACDE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MACV,CAAC;MACDG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MACV,CAAC;MACDI,SAAS,EAAE;QACPJ,IAAI,EAAE;MACV;IAAC,GACET,UAAU;EAErB,CAAC,CAAC;AACN,CAAC;AAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
|
-
|
|
14
10
|
var _attributes = require("@webiny/db-dynamodb/utils/attributes");
|
|
15
|
-
|
|
16
11
|
var _default = params => {
|
|
17
12
|
const {
|
|
18
13
|
context,
|
|
@@ -39,5 +34,4 @@ var _default = params => {
|
|
|
39
34
|
}, attributes)
|
|
40
35
|
});
|
|
41
36
|
};
|
|
42
|
-
|
|
43
37
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant"],"sources":["systemEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface SystemEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: SystemEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"System\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant"],"sources":["systemEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface SystemEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: SystemEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"System\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AAA0E,eAM1DA,MAA0B,IAAkB;EACxD,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGF,MAAM;EACjC,MAAMG,UAAU,GAAG,QAAQ;EAC3B,MAAMC,UAAU,GAAG,IAAAC,8BAAkB,EAACJ,OAAO,EAAEE,UAAU,CAAC;EAC1D,OAAO,IAAIG,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBD,KAAK;IACLE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV;IAAC,GACET,UAAU;EAErB,CAAC,CAAC;AACN,CAAC;AAAA"}
|
package/definitions/table.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
9
|
-
|
|
10
8
|
var _utils = require("../operations/utils");
|
|
11
|
-
|
|
12
9
|
var _default = params => {
|
|
13
10
|
const {
|
|
14
11
|
context
|
|
@@ -20,5 +17,4 @@ var _default = params => {
|
|
|
20
17
|
DocumentClient: (0, _utils.getDocumentClient)(context)
|
|
21
18
|
});
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
exports.default = _default;
|
package/definitions/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["params","context","Table","name","process","env","DB_TABLE_FILE_MANGER","DB_TABLE","getTable","partitionKey","sortKey","DocumentClient","getDocumentClient"],"sources":["table.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { getDocumentClient, getTable } from \"~/operations/utils\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\n\nexport interface TableParams {\n context: FileManagerContext;\n}\nexport default (params: TableParams): Table => {\n const { context } = params;\n return new Table({\n name: process.env.DB_TABLE_FILE_MANGER || process.env.DB_TABLE || getTable(context),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: getDocumentClient(context)\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["params","context","Table","name","process","env","DB_TABLE_FILE_MANGER","DB_TABLE","getTable","partitionKey","sortKey","DocumentClient","getDocumentClient"],"sources":["table.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { getDocumentClient, getTable } from \"~/operations/utils\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\n\nexport interface TableParams {\n context: FileManagerContext;\n}\nexport default (params: TableParams): Table => {\n const { context } = params;\n return new Table({\n name: process.env.DB_TABLE_FILE_MANGER || process.env.DB_TABLE || getTable(context),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: getDocumentClient(context)\n });\n};\n"],"mappings":";;;;;;AAAA;AACA;AAAiE,eAMjDA,MAAmB,IAAY;EAC3C,MAAM;IAAEC;EAAQ,CAAC,GAAGD,MAAM;EAC1B,OAAO,IAAIE,sBAAK,CAAC;IACbC,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,oBAAoB,IAAIF,OAAO,CAACC,GAAG,CAACE,QAAQ,IAAI,IAAAC,eAAQ,EAACP,OAAO,CAAC;IACnFQ,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAE,IAAAC,wBAAiB,EAACX,OAAO;EAC7C,CAAC,CAAC;AACN,CAAC;AAAA"}
|
package/index.js
CHANGED
|
@@ -4,13 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _files = require("./operations/files");
|
|
9
|
-
|
|
10
8
|
var _settings = require("./operations/settings");
|
|
11
|
-
|
|
12
9
|
var _system = require("./operations/system");
|
|
13
|
-
|
|
14
10
|
var _default = () => [new _files.FilesStorageOperationsProviderDdb(), new _settings.SettingsStorageOperationsProviderDdbPlugin(), new _system.SystemStorageOperationsProviderDdbPlugin()];
|
|
15
|
-
|
|
16
11
|
exports.default = _default;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FilesStorageOperationsProviderDdb","SettingsStorageOperationsProviderDdbPlugin","SystemStorageOperationsProviderDdbPlugin"],"sources":["index.ts"],"sourcesContent":["import { FilesStorageOperationsProviderDdb } from \"./operations/files\";\nimport { SettingsStorageOperationsProviderDdbPlugin } from \"./operations/settings\";\nimport { SystemStorageOperationsProviderDdbPlugin } from \"./operations/system\";\n\nexport default () => [\n new FilesStorageOperationsProviderDdb(),\n new SettingsStorageOperationsProviderDdbPlugin(),\n new SystemStorageOperationsProviderDdbPlugin()\n];\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["FilesStorageOperationsProviderDdb","SettingsStorageOperationsProviderDdbPlugin","SystemStorageOperationsProviderDdbPlugin"],"sources":["index.ts"],"sourcesContent":["import { FilesStorageOperationsProviderDdb } from \"./operations/files\";\nimport { SettingsStorageOperationsProviderDdbPlugin } from \"./operations/settings\";\nimport { SystemStorageOperationsProviderDdbPlugin } from \"./operations/system\";\n\nexport default () => [\n new FilesStorageOperationsProviderDdb(),\n new SettingsStorageOperationsProviderDdbPlugin(),\n new SystemStorageOperationsProviderDdbPlugin()\n];\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAA+E,eAEhE,MAAM,CACjB,IAAIA,wCAAiC,EAAE,EACvC,IAAIC,oDAA0C,EAAE,EAChD,IAAIC,gDAAwC,EAAE,CACjD;AAAA"}
|
|
@@ -1,43 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.FilesStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _table = _interopRequireDefault(require("../../definitions/table"));
|
|
17
|
-
|
|
18
12
|
var _filesEntity = _interopRequireDefault(require("../../definitions/filesEntity"));
|
|
19
|
-
|
|
20
13
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
21
|
-
|
|
22
14
|
var _cursor = require("@webiny/db-dynamodb/utils/cursor");
|
|
23
|
-
|
|
24
15
|
var _filter = require("@webiny/db-dynamodb/utils/filter");
|
|
25
|
-
|
|
26
16
|
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
27
|
-
|
|
28
17
|
var _FileDynamoDbFieldPlugin = require("../../plugins/FileDynamoDbFieldPlugin");
|
|
29
|
-
|
|
30
18
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
31
|
-
|
|
32
19
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
33
|
-
|
|
34
20
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
35
|
-
|
|
36
21
|
class FilesStorageOperations {
|
|
37
22
|
get context() {
|
|
38
23
|
return this._context;
|
|
39
24
|
}
|
|
40
|
-
|
|
41
25
|
constructor({
|
|
42
26
|
context
|
|
43
27
|
}) {
|
|
@@ -53,7 +37,6 @@ class FilesStorageOperations {
|
|
|
53
37
|
table: this.table
|
|
54
38
|
});
|
|
55
39
|
}
|
|
56
|
-
|
|
57
40
|
async get(params) {
|
|
58
41
|
const {
|
|
59
42
|
where
|
|
@@ -62,7 +45,6 @@ class FilesStorageOperations {
|
|
|
62
45
|
PK: this.createPartitionKey(where),
|
|
63
46
|
SK: this.createSortKey(where)
|
|
64
47
|
};
|
|
65
|
-
|
|
66
48
|
try {
|
|
67
49
|
const file = await (0, _get.get)({
|
|
68
50
|
entity: this.entity,
|
|
@@ -76,7 +58,6 @@ class FilesStorageOperations {
|
|
|
76
58
|
});
|
|
77
59
|
}
|
|
78
60
|
}
|
|
79
|
-
|
|
80
61
|
async create(params) {
|
|
81
62
|
const {
|
|
82
63
|
file
|
|
@@ -88,7 +69,6 @@ class FilesStorageOperations {
|
|
|
88
69
|
const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
|
|
89
70
|
TYPE: "fm.file"
|
|
90
71
|
});
|
|
91
|
-
|
|
92
72
|
try {
|
|
93
73
|
await this.entity.put(item);
|
|
94
74
|
} catch (ex) {
|
|
@@ -97,10 +77,8 @@ class FilesStorageOperations {
|
|
|
97
77
|
item
|
|
98
78
|
});
|
|
99
79
|
}
|
|
100
|
-
|
|
101
80
|
return file;
|
|
102
81
|
}
|
|
103
|
-
|
|
104
82
|
async update(params) {
|
|
105
83
|
const {
|
|
106
84
|
file
|
|
@@ -112,7 +90,6 @@ class FilesStorageOperations {
|
|
|
112
90
|
const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
|
|
113
91
|
TYPE: "fm.file"
|
|
114
92
|
});
|
|
115
|
-
|
|
116
93
|
try {
|
|
117
94
|
await this.entity.put(item);
|
|
118
95
|
} catch (ex) {
|
|
@@ -121,10 +98,8 @@ class FilesStorageOperations {
|
|
|
121
98
|
item
|
|
122
99
|
});
|
|
123
100
|
}
|
|
124
|
-
|
|
125
101
|
return file;
|
|
126
102
|
}
|
|
127
|
-
|
|
128
103
|
async delete(params) {
|
|
129
104
|
const {
|
|
130
105
|
file
|
|
@@ -133,7 +108,6 @@ class FilesStorageOperations {
|
|
|
133
108
|
PK: this.createPartitionKey(file),
|
|
134
109
|
SK: this.createSortKey(file)
|
|
135
110
|
};
|
|
136
|
-
|
|
137
111
|
try {
|
|
138
112
|
await this.entity.delete(keys);
|
|
139
113
|
} catch (ex) {
|
|
@@ -144,7 +118,6 @@ class FilesStorageOperations {
|
|
|
144
118
|
});
|
|
145
119
|
}
|
|
146
120
|
}
|
|
147
|
-
|
|
148
121
|
async createBatch(params) {
|
|
149
122
|
const {
|
|
150
123
|
files
|
|
@@ -156,7 +129,6 @@ class FilesStorageOperations {
|
|
|
156
129
|
TYPE: "fm.file"
|
|
157
130
|
}));
|
|
158
131
|
});
|
|
159
|
-
|
|
160
132
|
try {
|
|
161
133
|
await (0, _batchWrite.batchWriteAll)({
|
|
162
134
|
table: this.entity.table,
|
|
@@ -168,10 +140,8 @@ class FilesStorageOperations {
|
|
|
168
140
|
files
|
|
169
141
|
});
|
|
170
142
|
}
|
|
171
|
-
|
|
172
143
|
return files;
|
|
173
144
|
}
|
|
174
|
-
|
|
175
145
|
async list(params) {
|
|
176
146
|
const {
|
|
177
147
|
where: initialWhere,
|
|
@@ -188,7 +158,6 @@ class FilesStorageOperations {
|
|
|
188
158
|
options
|
|
189
159
|
};
|
|
190
160
|
let items = [];
|
|
191
|
-
|
|
192
161
|
try {
|
|
193
162
|
items = await (0, _query.queryAll)(queryAllParams);
|
|
194
163
|
} catch (ex) {
|
|
@@ -206,16 +175,13 @@ class FilesStorageOperations {
|
|
|
206
175
|
}
|
|
207
176
|
});
|
|
208
177
|
}
|
|
209
|
-
|
|
210
178
|
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
211
|
-
|
|
212
179
|
if (where.search) {
|
|
213
180
|
where.contains = {
|
|
214
181
|
fields: ["name", "tags"],
|
|
215
182
|
value: where.search
|
|
216
183
|
};
|
|
217
184
|
}
|
|
218
|
-
|
|
219
185
|
delete where["tenant"];
|
|
220
186
|
delete where["locale"];
|
|
221
187
|
delete where["search"];
|
|
@@ -224,7 +190,6 @@ class FilesStorageOperations {
|
|
|
224
190
|
* Filter the read items via the code.
|
|
225
191
|
* It will build the filters out of the where input and transform the values it is using.
|
|
226
192
|
*/
|
|
227
|
-
|
|
228
193
|
const filteredFiles = (0, _filter.filterItems)({
|
|
229
194
|
plugins: this.context.plugins,
|
|
230
195
|
items,
|
|
@@ -236,7 +201,6 @@ class FilesStorageOperations {
|
|
|
236
201
|
* Sorting is also done via the code.
|
|
237
202
|
* It takes the sort input and sorts by it via the lodash sortBy method.
|
|
238
203
|
*/
|
|
239
|
-
|
|
240
204
|
const sortedFiles = (0, _sort.sortItems)({
|
|
241
205
|
items: filteredFiles,
|
|
242
206
|
sort,
|
|
@@ -250,7 +214,6 @@ class FilesStorageOperations {
|
|
|
250
214
|
* Although we do not need a cursor here, we will use it as such to keep it standardized.
|
|
251
215
|
* Number is simply encoded.
|
|
252
216
|
*/
|
|
253
|
-
|
|
254
217
|
const cursor = files.length > 0 ? (0, _cursor.encodeCursor)(start + limit) : null;
|
|
255
218
|
const meta = {
|
|
256
219
|
hasMoreItems,
|
|
@@ -259,7 +222,6 @@ class FilesStorageOperations {
|
|
|
259
222
|
};
|
|
260
223
|
return [files, meta];
|
|
261
224
|
}
|
|
262
|
-
|
|
263
225
|
async tags(params) {
|
|
264
226
|
const {
|
|
265
227
|
where: initialWhere
|
|
@@ -273,7 +235,6 @@ class FilesStorageOperations {
|
|
|
273
235
|
}
|
|
274
236
|
};
|
|
275
237
|
let results = [];
|
|
276
|
-
|
|
277
238
|
try {
|
|
278
239
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
279
240
|
} catch (ex) {
|
|
@@ -282,37 +243,33 @@ class FilesStorageOperations {
|
|
|
282
243
|
query: queryAllParams
|
|
283
244
|
});
|
|
284
245
|
}
|
|
285
|
-
|
|
286
246
|
const fields = this.context.plugins.byType(_FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin.type);
|
|
287
247
|
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
288
248
|
delete where["tenant"];
|
|
289
249
|
delete where["locale"];
|
|
250
|
+
|
|
290
251
|
/**
|
|
291
252
|
* Filter the read items via the code.
|
|
292
253
|
* It will build the filters out of the where input and transform the values it is using.
|
|
293
254
|
*/
|
|
294
|
-
|
|
295
255
|
const filteredItems = (0, _filter.filterItems)({
|
|
296
256
|
plugins: this.context.plugins,
|
|
297
257
|
items: results,
|
|
298
258
|
where,
|
|
299
259
|
fields
|
|
300
260
|
});
|
|
261
|
+
|
|
301
262
|
/**
|
|
302
263
|
* Aggregate all the tags from all the filtered items.
|
|
303
264
|
*/
|
|
304
|
-
|
|
305
265
|
const tagsObject = filteredItems.reduce((collection, item) => {
|
|
306
266
|
const tags = Array.isArray(item.tags) ? item.tags : [];
|
|
307
|
-
|
|
308
267
|
for (const tag of tags) {
|
|
309
268
|
if (!collection[tag]) {
|
|
310
269
|
collection[tag] = [];
|
|
311
270
|
}
|
|
312
|
-
|
|
313
271
|
collection[tag].push(item.id);
|
|
314
272
|
}
|
|
315
|
-
|
|
316
273
|
return collection;
|
|
317
274
|
}, {});
|
|
318
275
|
const tags = Object.keys(tagsObject);
|
|
@@ -325,19 +282,15 @@ class FilesStorageOperations {
|
|
|
325
282
|
};
|
|
326
283
|
return [tags, meta];
|
|
327
284
|
}
|
|
328
|
-
|
|
329
285
|
createQueryAllOptions({
|
|
330
286
|
where
|
|
331
287
|
}) {
|
|
332
288
|
const options = {};
|
|
333
|
-
|
|
334
289
|
if (where.id) {
|
|
335
290
|
options.eq = where.id;
|
|
336
291
|
}
|
|
337
|
-
|
|
338
292
|
return options;
|
|
339
293
|
}
|
|
340
|
-
|
|
341
294
|
createPartitionKey(params) {
|
|
342
295
|
const {
|
|
343
296
|
tenant,
|
|
@@ -345,14 +298,11 @@ class FilesStorageOperations {
|
|
|
345
298
|
} = params;
|
|
346
299
|
return `T#${tenant}#L#${locale}#FM#F`;
|
|
347
300
|
}
|
|
348
|
-
|
|
349
301
|
createSortKey(params) {
|
|
350
302
|
const {
|
|
351
303
|
id
|
|
352
304
|
} = params;
|
|
353
305
|
return id;
|
|
354
306
|
}
|
|
355
|
-
|
|
356
307
|
}
|
|
357
|
-
|
|
358
308
|
exports.FilesStorageOperations = FilesStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FilesStorageOperations","context","_context","constructor","table","defineTable","entity","defineFilesEntity","get","params","where","keys","PK","createPartitionKey","SK","createSortKey","file","getEntityItem","cleanupItem","ex","WebinyError","message","code","error","create","item","TYPE","put","update","delete","createBatch","files","items","map","putBatch","batchWriteAll","list","initialWhere","limit","after","sort","options","createQueryAllOptions","queryAllParams","partitionKey","queryAll","queryParams","name","search","contains","fields","value","plugins","byType","FileDynamoDbFieldPlugin","type","filteredFiles","filterItems","totalCount","length","sortedFiles","sortItems","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","tags","gte","reverse","results","query","filteredItems","tagsObject","reduce","collection","Array","isArray","tag","push","id","Object","eq","tenant","locale"],"sources":["FilesStorageOperations.ts"],"sourcesContent":["import {\n File,\n FileManagerContext,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsCreateBatchParams,\n FileManagerFilesStorageOperationsCreateParams,\n FileManagerFilesStorageOperationsDeleteParams,\n FileManagerFilesStorageOperationsGetParams,\n FileManagerFilesStorageOperationsListParams,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsListResponseMeta,\n FileManagerFilesStorageOperationsTagsParams,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FileManagerFilesStorageOperationsTagsResponse,\n FileManagerFilesStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineTable from \"~/definitions/table\";\nimport defineFilesEntity from \"~/definitions/filesEntity\";\nimport { queryOptions as DynamoDBToolboxQueryOptions } from \"dynamodb-toolbox/dist/classes/Table\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { FileDynamoDbFieldPlugin } from \"~/plugins/FileDynamoDbFieldPlugin\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { get as getEntityItem } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface FileItem extends File {\n PK: string;\n SK: string;\n TYPE: string;\n}\n\ninterface ConstructorParams {\n context: FileManagerContext;\n}\n\ninterface QueryAllOptionsParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n}\n\ninterface CreatePartitionKeyParams {\n locale: string;\n tenant: string;\n}\n\ninterface CreateSortKeyParams {\n id: string;\n}\n\nexport class FilesStorageOperations implements FileManagerFilesStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly table: Table;\n private readonly entity: Entity<any>;\n\n private get context(): FileManagerContext {\n return this._context;\n }\n\n public constructor({ context }: ConstructorParams) {\n this._context = context;\n this.table = defineTable({\n context\n });\n\n this.entity = defineFilesEntity({\n context,\n table: this.table\n });\n }\n\n public async get(params: FileManagerFilesStorageOperationsGetParams): Promise<File | null> {\n const { where } = params;\n const keys = {\n PK: this.createPartitionKey(where),\n SK: this.createSortKey(where)\n };\n try {\n const file = await getEntityItem<File>({\n entity: this.entity,\n keys\n });\n return cleanupItem<File>(this.entity, file);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch requested file.\",\n ex.code || \"GET_FILE_ERROR\",\n {\n error: ex,\n where\n }\n );\n }\n }\n\n public async create(params: FileManagerFilesStorageOperationsCreateParams): Promise<File> {\n const { file } = params;\n\n const keys = {\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file)\n };\n const item: FileItem = {\n ...file,\n ...keys,\n TYPE: \"fm.file\"\n };\n try {\n await this.entity.put(item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a new file in the DynamoDB.\",\n ex.code || \"CREATE_FILE_ERROR\",\n {\n error: ex,\n item\n }\n );\n }\n\n return file;\n }\n\n public async update(params: FileManagerFilesStorageOperationsUpdateParams): Promise<File> {\n const { file } = params;\n const keys = {\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file)\n };\n\n const item: FileItem = {\n ...file,\n ...keys,\n TYPE: \"fm.file\"\n };\n try {\n await this.entity.put(item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update a file in the DynamoDB.\",\n ex.code || \"UPDATE_FILE_ERROR\",\n {\n error: ex,\n item\n }\n );\n }\n return file;\n }\n\n public async delete(params: FileManagerFilesStorageOperationsDeleteParams): Promise<void> {\n const { file } = params;\n const keys = {\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file)\n };\n\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete file from the DynamoDB.\",\n ex.code || \"DELETE_FILE_ERROR\",\n {\n error: ex,\n file,\n keys\n }\n );\n }\n }\n\n public async createBatch(\n params: FileManagerFilesStorageOperationsCreateBatchParams\n ): Promise<File[]> {\n const { files } = params;\n\n const items = files.map(file => {\n return this.entity.putBatch({\n ...file,\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file),\n TYPE: \"fm.file\"\n });\n });\n\n try {\n await batchWriteAll({\n table: this.entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch insert a list of files.\",\n ex.code || \"BATCH_CREATE_FILES_ERROR\",\n {\n error: ex,\n files\n }\n );\n }\n return files;\n }\n\n public async list(\n params: FileManagerFilesStorageOperationsListParams\n ): Promise<FileManagerFilesStorageOperationsListResponse> {\n const { where: initialWhere, limit, after, sort } = params;\n\n const options = this.createQueryAllOptions({\n where: initialWhere\n });\n const queryAllParams = {\n entity: this.entity,\n partitionKey: this.createPartitionKey(initialWhere),\n options\n };\n let items = [];\n try {\n items = await queryAll<File>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query for the files.\",\n ex.code || \"FILE_LIST_ERROR\",\n {\n error: ex,\n where: initialWhere,\n limit,\n after,\n sort,\n queryParams: {\n options,\n partitionKey: queryAllParams.partitionKey,\n entity: queryAllParams.entity.name,\n table: queryAllParams.entity.table.name\n }\n }\n );\n }\n\n const where: Partial<FileManagerFilesStorageOperationsListParamsWhere> & {\n contains?: { fields: string[]; value: string };\n } = {\n ...initialWhere\n };\n if (where.search) {\n where.contains = {\n fields: [\"name\", \"tags\"],\n value: where.search\n };\n }\n delete where[\"tenant\"];\n delete where[\"locale\"];\n delete where[\"search\"];\n\n const fields = this.context.plugins.byType<FileDynamoDbFieldPlugin>(\n FileDynamoDbFieldPlugin.type\n );\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredFiles = filterItems({\n plugins: this.context.plugins,\n items,\n where,\n fields\n });\n\n const totalCount = filteredFiles.length;\n /**\n * Sorting is also done via the code.\n * It takes the sort input and sorts by it via the lodash sortBy method.\n */\n const sortedFiles = sortItems({\n items: filteredFiles,\n sort,\n fields\n });\n\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const files = sortedFiles.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = files.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount: totalCount,\n cursor\n };\n\n return [files, meta];\n }\n\n public async tags(\n params: FileManagerFilesStorageOperationsTagsParams\n ): Promise<FileManagerFilesStorageOperationsTagsResponse> {\n const { where: initialWhere } = params;\n\n const queryAllParams = {\n entity: this.entity,\n partitionKey: this.createPartitionKey(initialWhere),\n options: {\n gte: \" \",\n reverse: false\n }\n };\n let results = [];\n try {\n results = await queryAll<File>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Error in the DynamoDB query.\",\n ex.code || \"DYNAMODB_ERROR\",\n {\n error: ex,\n query: queryAllParams\n }\n );\n }\n\n const fields = this.context.plugins.byType<FileDynamoDbFieldPlugin>(\n FileDynamoDbFieldPlugin.type\n );\n\n const where: Partial<FileManagerFilesStorageOperationsTagsParamsWhere> = {\n ...initialWhere\n };\n\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredItems = filterItems({\n plugins: this.context.plugins,\n items: results,\n where,\n fields\n });\n\n /**\n * Aggregate all the tags from all the filtered items.\n */\n const tagsObject = filteredItems.reduce((collection, item) => {\n const tags = Array.isArray(item.tags) ? item.tags : [];\n for (const tag of tags) {\n if (!collection[tag]) {\n collection[tag] = [];\n }\n collection[tag].push(item.id);\n }\n return collection;\n }, {} as Record<string, string[]>);\n\n const tags: string[] = Object.keys(tagsObject);\n\n const hasMoreItems = false;\n const totalCount = tags.length;\n\n const meta: FileManagerFilesStorageOperationsListResponseMeta = {\n hasMoreItems,\n totalCount,\n cursor: null\n };\n\n return [tags, meta];\n }\n\n private createQueryAllOptions({ where }: QueryAllOptionsParams): DynamoDBToolboxQueryOptions {\n const options: DynamoDBToolboxQueryOptions = {};\n if (where.id) {\n options.eq = where.id;\n }\n return options;\n }\n\n private createPartitionKey(params: CreatePartitionKeyParams): string {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#FM#F`;\n }\n\n private createSortKey(params: CreateSortKeyParams) {\n const { id } = params;\n\n return id;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAyBO,MAAMA,sBAAN,CAA0E;EAK1D,IAAPC,OAAO,GAAuB;IACtC,OAAO,KAAKC,QAAZ;EACH;;EAEMC,WAAW,CAAC;IAAEF;EAAF,CAAD,EAAiC;IAAA;IAAA;IAAA;IAC/C,KAAKC,QAAL,GAAgBD,OAAhB;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AO,CAACG,IAAD,EAAOD,IAAP,CAAP;EACH;;EAEO7B,qBAAqB,CAAC;IAAEhC;EAAF,CAAD,EAAgE;IACzF,MAAM+B,OAAoC,GAAG,EAA7C;;IACA,IAAI/B,KAAK,CAAC2E,EAAV,EAAc;MACV5C,OAAO,CAAC8C,EAAR,GAAa7E,KAAK,CAAC2E,EAAnB;IACH;;IACD,OAAO5C,OAAP;EACH;;EAEO5B,kBAAkB,CAACJ,MAAD,EAA2C;IACjE,MAAM;MAAE+E,MAAF;MAAUC;IAAV,IAAqBhF,MAA3B;IACA,OAAQ,KAAI+E,MAAO,MAAKC,MAAO,OAA/B;EACH;;EAEO1E,aAAa,CAACN,MAAD,EAA8B;IAC/C,MAAM;MAAE4E;IAAF,IAAS5E,MAAf;IAEA,OAAO4E,EAAP;EACH;;AAvV4E"}
|
|
1
|
+
{"version":3,"names":["FilesStorageOperations","context","_context","constructor","table","defineTable","entity","defineFilesEntity","get","params","where","keys","PK","createPartitionKey","SK","createSortKey","file","getEntityItem","cleanupItem","ex","WebinyError","message","code","error","create","item","TYPE","put","update","delete","createBatch","files","items","map","putBatch","batchWriteAll","list","initialWhere","limit","after","sort","options","createQueryAllOptions","queryAllParams","partitionKey","queryAll","queryParams","name","search","contains","fields","value","plugins","byType","FileDynamoDbFieldPlugin","type","filteredFiles","filterItems","totalCount","length","sortedFiles","sortItems","start","parseInt","decodeCursor","hasMoreItems","end","undefined","slice","cursor","encodeCursor","meta","tags","gte","reverse","results","query","filteredItems","tagsObject","reduce","collection","Array","isArray","tag","push","id","Object","eq","tenant","locale"],"sources":["FilesStorageOperations.ts"],"sourcesContent":["import {\n File,\n FileManagerContext,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsCreateBatchParams,\n FileManagerFilesStorageOperationsCreateParams,\n FileManagerFilesStorageOperationsDeleteParams,\n FileManagerFilesStorageOperationsGetParams,\n FileManagerFilesStorageOperationsListParams,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsListResponseMeta,\n FileManagerFilesStorageOperationsTagsParams,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FileManagerFilesStorageOperationsTagsResponse,\n FileManagerFilesStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineTable from \"~/definitions/table\";\nimport defineFilesEntity from \"~/definitions/filesEntity\";\nimport { queryOptions as DynamoDBToolboxQueryOptions } from \"dynamodb-toolbox/dist/classes/Table\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { decodeCursor, encodeCursor } from \"@webiny/db-dynamodb/utils/cursor\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { FileDynamoDbFieldPlugin } from \"~/plugins/FileDynamoDbFieldPlugin\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { get as getEntityItem } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface FileItem extends File {\n PK: string;\n SK: string;\n TYPE: string;\n}\n\ninterface ConstructorParams {\n context: FileManagerContext;\n}\n\ninterface QueryAllOptionsParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n}\n\ninterface CreatePartitionKeyParams {\n locale: string;\n tenant: string;\n}\n\ninterface CreateSortKeyParams {\n id: string;\n}\n\nexport class FilesStorageOperations implements FileManagerFilesStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly table: Table;\n private readonly entity: Entity<any>;\n\n private get context(): FileManagerContext {\n return this._context;\n }\n\n public constructor({ context }: ConstructorParams) {\n this._context = context;\n this.table = defineTable({\n context\n });\n\n this.entity = defineFilesEntity({\n context,\n table: this.table\n });\n }\n\n public async get(params: FileManagerFilesStorageOperationsGetParams): Promise<File | null> {\n const { where } = params;\n const keys = {\n PK: this.createPartitionKey(where),\n SK: this.createSortKey(where)\n };\n try {\n const file = await getEntityItem<File>({\n entity: this.entity,\n keys\n });\n return cleanupItem<File>(this.entity, file);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch requested file.\",\n ex.code || \"GET_FILE_ERROR\",\n {\n error: ex,\n where\n }\n );\n }\n }\n\n public async create(params: FileManagerFilesStorageOperationsCreateParams): Promise<File> {\n const { file } = params;\n\n const keys = {\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file)\n };\n const item: FileItem = {\n ...file,\n ...keys,\n TYPE: \"fm.file\"\n };\n try {\n await this.entity.put(item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a new file in the DynamoDB.\",\n ex.code || \"CREATE_FILE_ERROR\",\n {\n error: ex,\n item\n }\n );\n }\n\n return file;\n }\n\n public async update(params: FileManagerFilesStorageOperationsUpdateParams): Promise<File> {\n const { file } = params;\n const keys = {\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file)\n };\n\n const item: FileItem = {\n ...file,\n ...keys,\n TYPE: \"fm.file\"\n };\n try {\n await this.entity.put(item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update a file in the DynamoDB.\",\n ex.code || \"UPDATE_FILE_ERROR\",\n {\n error: ex,\n item\n }\n );\n }\n return file;\n }\n\n public async delete(params: FileManagerFilesStorageOperationsDeleteParams): Promise<void> {\n const { file } = params;\n const keys = {\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file)\n };\n\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete file from the DynamoDB.\",\n ex.code || \"DELETE_FILE_ERROR\",\n {\n error: ex,\n file,\n keys\n }\n );\n }\n }\n\n public async createBatch(\n params: FileManagerFilesStorageOperationsCreateBatchParams\n ): Promise<File[]> {\n const { files } = params;\n\n const items = files.map(file => {\n return this.entity.putBatch({\n ...file,\n PK: this.createPartitionKey(file),\n SK: this.createSortKey(file),\n TYPE: \"fm.file\"\n });\n });\n\n try {\n await batchWriteAll({\n table: this.entity.table,\n items\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch insert a list of files.\",\n ex.code || \"BATCH_CREATE_FILES_ERROR\",\n {\n error: ex,\n files\n }\n );\n }\n return files;\n }\n\n public async list(\n params: FileManagerFilesStorageOperationsListParams\n ): Promise<FileManagerFilesStorageOperationsListResponse> {\n const { where: initialWhere, limit, after, sort } = params;\n\n const options = this.createQueryAllOptions({\n where: initialWhere\n });\n const queryAllParams = {\n entity: this.entity,\n partitionKey: this.createPartitionKey(initialWhere),\n options\n };\n let items = [];\n try {\n items = await queryAll<File>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not query for the files.\",\n ex.code || \"FILE_LIST_ERROR\",\n {\n error: ex,\n where: initialWhere,\n limit,\n after,\n sort,\n queryParams: {\n options,\n partitionKey: queryAllParams.partitionKey,\n entity: queryAllParams.entity.name,\n table: queryAllParams.entity.table.name\n }\n }\n );\n }\n\n const where: Partial<FileManagerFilesStorageOperationsListParamsWhere> & {\n contains?: { fields: string[]; value: string };\n } = {\n ...initialWhere\n };\n if (where.search) {\n where.contains = {\n fields: [\"name\", \"tags\"],\n value: where.search\n };\n }\n delete where[\"tenant\"];\n delete where[\"locale\"];\n delete where[\"search\"];\n\n const fields = this.context.plugins.byType<FileDynamoDbFieldPlugin>(\n FileDynamoDbFieldPlugin.type\n );\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredFiles = filterItems({\n plugins: this.context.plugins,\n items,\n where,\n fields\n });\n\n const totalCount = filteredFiles.length;\n /**\n * Sorting is also done via the code.\n * It takes the sort input and sorts by it via the lodash sortBy method.\n */\n const sortedFiles = sortItems({\n items: filteredFiles,\n sort,\n fields\n });\n\n const start = parseInt(decodeCursor(after) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const end = limit > totalCount + start + limit ? undefined : start + limit;\n const files = sortedFiles.slice(start, end);\n /**\n * Although we do not need a cursor here, we will use it as such to keep it standardized.\n * Number is simply encoded.\n */\n const cursor = files.length > 0 ? encodeCursor(start + limit) : null;\n\n const meta = {\n hasMoreItems,\n totalCount: totalCount,\n cursor\n };\n\n return [files, meta];\n }\n\n public async tags(\n params: FileManagerFilesStorageOperationsTagsParams\n ): Promise<FileManagerFilesStorageOperationsTagsResponse> {\n const { where: initialWhere } = params;\n\n const queryAllParams = {\n entity: this.entity,\n partitionKey: this.createPartitionKey(initialWhere),\n options: {\n gte: \" \",\n reverse: false\n }\n };\n let results = [];\n try {\n results = await queryAll<File>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Error in the DynamoDB query.\",\n ex.code || \"DYNAMODB_ERROR\",\n {\n error: ex,\n query: queryAllParams\n }\n );\n }\n\n const fields = this.context.plugins.byType<FileDynamoDbFieldPlugin>(\n FileDynamoDbFieldPlugin.type\n );\n\n const where: Partial<FileManagerFilesStorageOperationsTagsParamsWhere> = {\n ...initialWhere\n };\n\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n /**\n * Filter the read items via the code.\n * It will build the filters out of the where input and transform the values it is using.\n */\n const filteredItems = filterItems({\n plugins: this.context.plugins,\n items: results,\n where,\n fields\n });\n\n /**\n * Aggregate all the tags from all the filtered items.\n */\n const tagsObject = filteredItems.reduce((collection, item) => {\n const tags = Array.isArray(item.tags) ? item.tags : [];\n for (const tag of tags) {\n if (!collection[tag]) {\n collection[tag] = [];\n }\n collection[tag].push(item.id);\n }\n return collection;\n }, {} as Record<string, string[]>);\n\n const tags: string[] = Object.keys(tagsObject);\n\n const hasMoreItems = false;\n const totalCount = tags.length;\n\n const meta: FileManagerFilesStorageOperationsListResponseMeta = {\n hasMoreItems,\n totalCount,\n cursor: null\n };\n\n return [tags, meta];\n }\n\n private createQueryAllOptions({ where }: QueryAllOptionsParams): DynamoDBToolboxQueryOptions {\n const options: DynamoDBToolboxQueryOptions = {};\n if (where.id) {\n options.eq = where.id;\n }\n return options;\n }\n\n private createPartitionKey(params: CreatePartitionKeyParams): string {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#FM#F`;\n }\n\n private createSortKey(params: CreateSortKeyParams) {\n const { id } = params;\n\n return id;\n }\n}\n"],"mappings":";;;;;;;;;AAkBA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAyBO,MAAMA,sBAAsB,CAA8C;EAK7E,IAAYC,OAAO,GAAuB;IACtC,OAAO,IAAI,CAACC,QAAQ;EACxB;EAEOC,WAAW,CAAC;IAAEF;EAA2B,CAAC,EAAE;IAAA;IAAA;IAAA;IAC/C,IAAI,CAACC,QAAQ,GAAGD,OAAO;IACvB,IAAI,CAACG,KAAK,GAAG,IAAAC,cAAW,EAAC;MACrBJ;IACJ,CAAC,CAAC;IAEF,IAAI,CAACK,MAAM,GAAG,IAAAC,oBAAiB,EAAC;MAC5BN,OAAO;MACPG,KAAK,EAAE,IAAI,CAACA;IAChB,CAAC,CAAC;EACN;EAEA,MAAaI,GAAG,CAACC,MAAkD,EAAwB;IACvF,MAAM;MAAEC;IAAM,CAAC,GAAGD,MAAM;IACxB,MAAME,IAAI,GAAG;MACTC,EAAE,EAAE,IAAI,CAACC,kBAAkB,CAACH,KAAK,CAAC;MAClCI,EAAE,EAAE,IAAI,CAACC,aAAa,CAACL,KAAK;IAChC,CAAC;IACD,IAAI;MACA,MAAMM,IAAI,GAAG,MAAM,IAAAC,QAAa,EAAO;QACnCX,MAAM,EAAE,IAAI,CAACA,MAAM;QACnBK;MACJ,CAAC,CAAC;MACF,OAAO,IAAAO,oBAAW,EAAO,IAAI,CAACZ,MAAM,EAAEU,IAAI,CAAC;IAC/C,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,iCAAiC,EAC/CF,EAAE,CAACG,IAAI,IAAI,gBAAgB,EAC3B;QACIC,KAAK,EAAEJ,EAA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pB,IAAI,CAACQ,UAAU,CAACG,GAAG,CAAC,EAAE;UAClBH,UAAU,CAACG,GAAG,CAAC,GAAG,EAAE;QACxB;QACAH,UAAU,CAACG,GAAG,CAAC,CAACC,IAAI,CAAC3D,IAAI,CAAC4D,EAAE,CAAC;MACjC;MACA,OAAOL,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC,CAA6B;IAElC,MAAMR,IAAc,GAAGc,MAAM,CAAC3E,IAAI,CAACmE,UAAU,CAAC;IAE9C,MAAMb,YAAY,GAAG,KAAK;IAC1B,MAAMP,UAAU,GAAGc,IAAI,CAACb,MAAM;IAE9B,MAAMY,IAAuD,GAAG;MAC5DN,YAAY;MACZP,UAAU;MACVW,MAAM,EAAE;IACZ,CAAC;IAED,OAAO,CAACG,IAAI,EAAED,IAAI,CAAC;EACvB;EAEQ7B,qBAAqB,CAAC;IAAEhC;EAA6B,CAAC,EAA+B;IACzF,MAAM+B,OAAoC,GAAG,CAAC,CAAC;IAC/C,IAAI/B,KAAK,CAAC2E,EAAE,EAAE;MACV5C,OAAO,CAAC8C,EAAE,GAAG7E,KAAK,CAAC2E,EAAE;IACzB;IACA,OAAO5C,OAAO;EAClB;EAEQ5B,kBAAkB,CAACJ,MAAgC,EAAU;IACjE,MAAM;MAAE+E,MAAM;MAAEC;IAAO,CAAC,GAAGhF,MAAM;IACjC,OAAQ,KAAI+E,MAAO,MAAKC,MAAO,OAAM;EACzC;EAEQ1E,aAAa,CAACN,MAA2B,EAAE;IAC/C,MAAM;MAAE4E;IAAG,CAAC,GAAG5E,MAAM;IAErB,OAAO4E,EAAE;EACb;AACJ;AAAC"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _FileDynamoDbFieldPlugin = require("../../plugins/FileDynamoDbFieldPlugin");
|
|
9
|
-
|
|
10
8
|
var _default = () => [new _FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin({
|
|
11
9
|
field: "id"
|
|
12
10
|
}),
|
|
@@ -38,5 +36,4 @@ new _FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin({
|
|
|
38
36
|
field: "createdOn",
|
|
39
37
|
type: "date"
|
|
40
38
|
})];
|
|
41
|
-
|
|
42
39
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FileDynamoDbFieldPlugin","field","path","type"],"sources":["fields.ts"],"sourcesContent":["import { FileDynamoDbFieldPlugin } from \"~/plugins/FileDynamoDbFieldPlugin\";\n\nexport default () => [\n new FileDynamoDbFieldPlugin({\n field: \"id\"\n }),\n /**\n * Path plugin for the field that are ddb map type and the value filtered by is the id property in the object.\n */\n new FileDynamoDbFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n }),\n /**\n * Path plugin for meta field properties.\n */\n new FileDynamoDbFieldPlugin({\n field: \"private\",\n path: \"meta.private\"\n }),\n /**\n * Path plugin for tag field.\n */\n new FileDynamoDbFieldPlugin({\n field: \"tag\",\n path: \"tags\"\n }),\n /**\n * Value transformation for the dateTime field.\n */\n new FileDynamoDbFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n })\n];\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["FileDynamoDbFieldPlugin","field","path","type"],"sources":["fields.ts"],"sourcesContent":["import { FileDynamoDbFieldPlugin } from \"~/plugins/FileDynamoDbFieldPlugin\";\n\nexport default () => [\n new FileDynamoDbFieldPlugin({\n field: \"id\"\n }),\n /**\n * Path plugin for the field that are ddb map type and the value filtered by is the id property in the object.\n */\n new FileDynamoDbFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n }),\n /**\n * Path plugin for meta field properties.\n */\n new FileDynamoDbFieldPlugin({\n field: \"private\",\n path: \"meta.private\"\n }),\n /**\n * Path plugin for tag field.\n */\n new FileDynamoDbFieldPlugin({\n field: \"tag\",\n path: \"tags\"\n }),\n /**\n * Value transformation for the dateTime field.\n */\n new FileDynamoDbFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n })\n];\n"],"mappings":";;;;;;AAAA;AAA4E,eAE7D,MAAM,CACjB,IAAIA,gDAAuB,CAAC;EACxBC,KAAK,EAAE;AACX,CAAC,CAAC;AACF;AACJ;AACA;AACI,IAAID,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC,CAAC;AACF;AACJ;AACA;AACI,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC;AACF;AACJ;AACA;AACI,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,KAAK;EACZC,IAAI,EAAE;AACV,CAAC,CAAC;AACF;AACJ;AACA;AACI,IAAIF,gDAAuB,CAAC;EACxBC,KAAK,EAAE,WAAW;EAClBE,IAAI,EAAE;AACV,CAAC,CAAC,CACL;AAAA"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.FilesStorageOperationsProviderDdb = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _FilesStorageOperationsProviderPlugin = require("@webiny/api-file-manager/plugins/definitions/FilesStorageOperationsProviderPlugin");
|
|
13
|
-
|
|
14
10
|
var _FilesStorageOperations = require("./FilesStorageOperations");
|
|
15
|
-
|
|
16
11
|
var _fields = _interopRequireDefault(require("./fields"));
|
|
17
|
-
|
|
18
12
|
class FilesStorageOperationsProviderDdb extends _FilesStorageOperationsProviderPlugin.FilesStorageOperationsProviderPlugin {
|
|
19
13
|
constructor(...args) {
|
|
20
14
|
super(...args);
|
|
21
15
|
(0, _defineProperty2.default)(this, "name", "fm.storageOperationsProvider.files.ddb");
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
async provide({
|
|
25
18
|
context
|
|
26
19
|
}) {
|
|
@@ -29,7 +22,5 @@ class FilesStorageOperationsProviderDdb extends _FilesStorageOperationsProviderP
|
|
|
29
22
|
context
|
|
30
23
|
});
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
exports.FilesStorageOperationsProviderDdb = FilesStorageOperationsProviderDdb;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FilesStorageOperationsProviderDdb","FilesStorageOperationsProviderPlugin","provide","context","plugins","register","fields","FilesStorageOperations"],"sources":["index.ts"],"sourcesContent":["import {\n FilesStorageOperationsProviderPlugin,\n FilesStorageOperationsProviderPluginParams\n} from \"@webiny/api-file-manager/plugins/definitions/FilesStorageOperationsProviderPlugin\";\nimport { FilesStorageOperations } from \"./FilesStorageOperations\";\nimport fields from \"./fields\";\n\nexport class FilesStorageOperationsProviderDdb extends FilesStorageOperationsProviderPlugin {\n public override name = \"fm.storageOperationsProvider.files.ddb\";\n async provide({ context }: FilesStorageOperationsProviderPluginParams) {\n context.plugins.register(fields());\n return new FilesStorageOperations({\n context\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["FilesStorageOperationsProviderDdb","FilesStorageOperationsProviderPlugin","provide","context","plugins","register","fields","FilesStorageOperations"],"sources":["index.ts"],"sourcesContent":["import {\n FilesStorageOperationsProviderPlugin,\n FilesStorageOperationsProviderPluginParams\n} from \"@webiny/api-file-manager/plugins/definitions/FilesStorageOperationsProviderPlugin\";\nimport { FilesStorageOperations } from \"./FilesStorageOperations\";\nimport fields from \"./fields\";\n\nexport class FilesStorageOperationsProviderDdb extends FilesStorageOperationsProviderPlugin {\n public override name = \"fm.storageOperationsProvider.files.ddb\";\n async provide({ context }: FilesStorageOperationsProviderPluginParams) {\n context.plugins.register(fields());\n return new FilesStorageOperations({\n context\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAIA;AACA;AAEO,MAAMA,iCAAiC,SAASC,0EAAoC,CAAC;EAAA;IAAA;IAAA,4CACjE,wCAAwC;EAAA;EAC/D,MAAMC,OAAO,CAAC;IAAEC;EAAoD,CAAC,EAAE;IACnEA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,IAAAC,eAAM,GAAE,CAAC;IAClC,OAAO,IAAIC,8CAAsB,CAAC;MAC9BJ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SettingsStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _table = _interopRequireDefault(require("../../definitions/table"));
|
|
17
|
-
|
|
18
12
|
var _settingsEntity = _interopRequireDefault(require("../../definitions/settingsEntity"));
|
|
19
|
-
|
|
20
13
|
const SORT_KEY = "default";
|
|
21
|
-
|
|
22
14
|
class SettingsStorageOperations {
|
|
23
15
|
get partitionKey() {
|
|
24
16
|
const tenant = this._context.tenancy.getCurrentTenant();
|
|
25
|
-
|
|
26
17
|
if (!tenant) {
|
|
27
18
|
throw new _error.default("Tenant missing.", "TENANT_NOT_FOUND");
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
return `T#${tenant.id}#FM#SETTINGS`;
|
|
31
21
|
}
|
|
32
|
-
|
|
33
22
|
constructor({
|
|
34
23
|
context
|
|
35
24
|
}) {
|
|
@@ -44,24 +33,20 @@ class SettingsStorageOperations {
|
|
|
44
33
|
table
|
|
45
34
|
});
|
|
46
35
|
}
|
|
47
|
-
|
|
48
36
|
async get() {
|
|
49
37
|
try {
|
|
50
38
|
const settings = await this._entity.get({
|
|
51
39
|
PK: this.partitionKey,
|
|
52
40
|
SK: SORT_KEY
|
|
53
41
|
});
|
|
54
|
-
|
|
55
42
|
if (!settings || !settings.Item) {
|
|
56
43
|
return null;
|
|
57
44
|
}
|
|
58
|
-
|
|
59
45
|
return settings.Item;
|
|
60
46
|
} catch (ex) {
|
|
61
47
|
throw new _error.default(ex.message || "Could not fetch the FileManager settings.", ex.code || "GET_SETTINGS_ERROR");
|
|
62
48
|
}
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
async create({
|
|
66
51
|
data
|
|
67
52
|
}) {
|
|
@@ -69,14 +54,12 @@ class SettingsStorageOperations {
|
|
|
69
54
|
/**
|
|
70
55
|
* TODO: check if need to throw an error on existing settings
|
|
71
56
|
*/
|
|
72
|
-
|
|
73
57
|
if (original) {
|
|
74
58
|
return await this.update({
|
|
75
59
|
original,
|
|
76
60
|
data
|
|
77
61
|
});
|
|
78
62
|
}
|
|
79
|
-
|
|
80
63
|
try {
|
|
81
64
|
await this._entity.put((0, _objectSpread2.default)({
|
|
82
65
|
PK: this.partitionKey,
|
|
@@ -89,7 +72,6 @@ class SettingsStorageOperations {
|
|
|
89
72
|
});
|
|
90
73
|
}
|
|
91
74
|
}
|
|
92
|
-
|
|
93
75
|
async update({
|
|
94
76
|
data
|
|
95
77
|
}) {
|
|
@@ -105,14 +87,11 @@ class SettingsStorageOperations {
|
|
|
105
87
|
});
|
|
106
88
|
}
|
|
107
89
|
}
|
|
108
|
-
|
|
109
90
|
async delete() {
|
|
110
91
|
return this._entity.delete({
|
|
111
92
|
PK: this.partitionKey,
|
|
112
93
|
SK: SORT_KEY
|
|
113
94
|
});
|
|
114
95
|
}
|
|
115
|
-
|
|
116
96
|
}
|
|
117
|
-
|
|
118
97
|
exports.SettingsStorageOperations = SettingsStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SORT_KEY","SettingsStorageOperations","partitionKey","tenant","_context","tenancy","getCurrentTenant","WebinyError","id","constructor","context","table","defineTable","_entity","defineSettingsEntity","get","settings","PK","SK","Item","ex","message","code","create","data","original","update","put","delete"],"sources":["SettingsStorageOperations.ts"],"sourcesContent":["import {\n FileManagerContext,\n FileManagerSettings,\n FileManagerSettingsStorageOperations,\n FileManagerSettingsStorageOperationsCreateParams,\n FileManagerSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineTable from \"~/definitions/table\";\nimport defineSettingsEntity from \"~/definitions/settingsEntity\";\n\ninterface SettingsStorageOperationsConstructorParams {\n context: FileManagerContext;\n}\n\nconst SORT_KEY = \"default\";\n\nexport class SettingsStorageOperations implements FileManagerSettingsStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly _entity: Entity<any>;\n\n private get partitionKey(): string {\n const tenant = this._context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Tenant missing.\", \"TENANT_NOT_FOUND\");\n }\n return `T#${tenant.id}#FM#SETTINGS`;\n }\n\n public constructor({ context }: SettingsStorageOperationsConstructorParams) {\n this._context = context;\n const table = defineTable({\n context\n });\n\n this._entity = defineSettingsEntity({\n context,\n table\n });\n }\n\n public async get(): Promise<FileManagerSettings | null> {\n try {\n const settings = await this._entity.get({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n if (!settings || !settings.Item) {\n return null;\n }\n return settings.Item;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager settings.\",\n ex.code || \"GET_SETTINGS_ERROR\"\n );\n }\n }\n\n public async create({\n data\n }: FileManagerSettingsStorageOperationsCreateParams): Promise<FileManagerSettings> {\n const original = await this.get();\n /**\n * TODO: check if need to throw an error on existing settings\n */\n if (original) {\n return await this.update({ original, data });\n }\n\n try {\n await this._entity.put({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot create FileManager settings.\",\n ex.code || \"CREATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async update({\n data\n }: FileManagerSettingsStorageOperationsUpdateParams): Promise<FileManagerSettings> {\n try {\n await this._entity.update({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot update FileManager settings.\",\n ex.code || \"UPDATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async delete(): Promise<void> {\n return this._entity.delete({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SORT_KEY","SettingsStorageOperations","partitionKey","tenant","_context","tenancy","getCurrentTenant","WebinyError","id","constructor","context","table","defineTable","_entity","defineSettingsEntity","get","settings","PK","SK","Item","ex","message","code","create","data","original","update","put","delete"],"sources":["SettingsStorageOperations.ts"],"sourcesContent":["import {\n FileManagerContext,\n FileManagerSettings,\n FileManagerSettingsStorageOperations,\n FileManagerSettingsStorageOperationsCreateParams,\n FileManagerSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineTable from \"~/definitions/table\";\nimport defineSettingsEntity from \"~/definitions/settingsEntity\";\n\ninterface SettingsStorageOperationsConstructorParams {\n context: FileManagerContext;\n}\n\nconst SORT_KEY = \"default\";\n\nexport class SettingsStorageOperations implements FileManagerSettingsStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly _entity: Entity<any>;\n\n private get partitionKey(): string {\n const tenant = this._context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Tenant missing.\", \"TENANT_NOT_FOUND\");\n }\n return `T#${tenant.id}#FM#SETTINGS`;\n }\n\n public constructor({ context }: SettingsStorageOperationsConstructorParams) {\n this._context = context;\n const table = defineTable({\n context\n });\n\n this._entity = defineSettingsEntity({\n context,\n table\n });\n }\n\n public async get(): Promise<FileManagerSettings | null> {\n try {\n const settings = await this._entity.get({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n if (!settings || !settings.Item) {\n return null;\n }\n return settings.Item;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager settings.\",\n ex.code || \"GET_SETTINGS_ERROR\"\n );\n }\n }\n\n public async create({\n data\n }: FileManagerSettingsStorageOperationsCreateParams): Promise<FileManagerSettings> {\n const original = await this.get();\n /**\n * TODO: check if need to throw an error on existing settings\n */\n if (original) {\n return await this.update({ original, data });\n }\n\n try {\n await this._entity.put({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot create FileManager settings.\",\n ex.code || \"CREATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async update({\n data\n }: FileManagerSettingsStorageOperationsUpdateParams): Promise<FileManagerSettings> {\n try {\n await this._entity.update({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot update FileManager settings.\",\n ex.code || \"UPDATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async delete(): Promise<void> {\n return this._entity.delete({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n }\n}\n"],"mappings":";;;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,QAAQ,GAAG,SAAS;AAEnB,MAAMC,yBAAyB,CAAiD;EAInF,IAAYC,YAAY,GAAW;IAC/B,MAAMC,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AE,IAAI,CAACf,YAAY;QACrBgB,EAAE,EAAElB;MAAQ,GACTwB,IAAI,EACT;MACF,OAAOA,IAAI;IACf,CAAC,CAAC,OAAOJ,EAAE,EAAE;MACT,MAAM,IAAIb,cAAW,CACjBa,EAAE,CAACC,OAAO,IAAI,qCAAqC,EACnDD,EAAE,CAACE,IAAI,IAAI,0BAA0B,EACrC;QACIE;MACJ,CAAC,CACJ;IACL;EACJ;EAEA,MAAaE,MAAM,CAAC;IAChBF;EAC8C,CAAC,EAAgC;IAC/E,IAAI;MACA,MAAM,IAAI,CAACX,OAAO,CAACa,MAAM;QACrBT,EAAE,EAAE,IAAI,CAACf,YAAY;QACrBgB,EAAE,EAAElB;MAAQ,GACTwB,IAAI,EACT;MACF,OAAOA,IAAI;IACf,CAAC,CAAC,OAAOJ,EAAE,EAAE;MACT,MAAM,IAAIb,cAAW,CACjBa,EAAE,CAACC,OAAO,IAAI,qCAAqC,EACnDD,EAAE,CAACE,IAAI,IAAI,0BAA0B,EACrC;QACIE;MACJ,CAAC,CACJ;IACL;EACJ;EAEA,MAAaI,MAAM,GAAkB;IACjC,OAAO,IAAI,CAACf,OAAO,CAACe,MAAM,CAAC;MACvBX,EAAE,EAAE,IAAI,CAACf,YAAY;MACrBgB,EAAE,EAAElB;IACR,CAAC,CAAC;EACN;AACJ;AAAC"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SettingsStorageOperationsProviderDdbPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _SettingsStorageOperations = require("./SettingsStorageOperations");
|
|
13
|
-
|
|
14
10
|
var _SettingsStorageOperationsProviderPlugin = require("@webiny/api-file-manager/plugins/definitions/SettingsStorageOperationsProviderPlugin");
|
|
15
|
-
|
|
16
11
|
class SettingsStorageOperationsProviderDdbPlugin extends _SettingsStorageOperationsProviderPlugin.SettingsStorageOperationsProviderPlugin {
|
|
17
12
|
constructor(...args) {
|
|
18
13
|
super(...args);
|
|
19
14
|
(0, _defineProperty2.default)(this, "name", "fm.storageOperationsProvider.settings.ddb");
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
async provide({
|
|
23
17
|
context
|
|
24
18
|
}) {
|
|
@@ -26,7 +20,5 @@ class SettingsStorageOperationsProviderDdbPlugin extends _SettingsStorageOperati
|
|
|
26
20
|
context
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
exports.SettingsStorageOperationsProviderDdbPlugin = SettingsStorageOperationsProviderDdbPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SettingsStorageOperationsProviderDdbPlugin","SettingsStorageOperationsProviderPlugin","provide","context","SettingsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import { SettingsStorageOperations } from \"./SettingsStorageOperations\";\nimport {\n SettingsStorageOperationsProviderPlugin,\n SettingsStorageOperationsProviderPluginParams\n} from \"@webiny/api-file-manager/plugins/definitions/SettingsStorageOperationsProviderPlugin\";\n\nexport class SettingsStorageOperationsProviderDdbPlugin extends SettingsStorageOperationsProviderPlugin {\n public override name = \"fm.storageOperationsProvider.settings.ddb\";\n\n public async provide({ context }: SettingsStorageOperationsProviderPluginParams) {\n return new SettingsStorageOperations({\n context\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SettingsStorageOperationsProviderDdbPlugin","SettingsStorageOperationsProviderPlugin","provide","context","SettingsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import { SettingsStorageOperations } from \"./SettingsStorageOperations\";\nimport {\n SettingsStorageOperationsProviderPlugin,\n SettingsStorageOperationsProviderPluginParams\n} from \"@webiny/api-file-manager/plugins/definitions/SettingsStorageOperationsProviderPlugin\";\n\nexport class SettingsStorageOperationsProviderDdbPlugin extends SettingsStorageOperationsProviderPlugin {\n public override name = \"fm.storageOperationsProvider.settings.ddb\";\n\n public async provide({ context }: SettingsStorageOperationsProviderPluginParams) {\n return new SettingsStorageOperations({\n context\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAKO,MAAMA,0CAA0C,SAASC,gFAAuC,CAAC;EAAA;IAAA;IAAA,4CAC7E,2CAA2C;EAAA;EAElE,MAAaC,OAAO,CAAC;IAAEC;EAAuD,CAAC,EAAE;IAC7E,OAAO,IAAIC,oDAAyB,CAAC;MACjCD;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SystemStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _systemEntity = _interopRequireDefault(require("../../definitions/systemEntity"));
|
|
17
|
-
|
|
18
12
|
var _table = _interopRequireDefault(require("../../definitions/table"));
|
|
19
|
-
|
|
20
13
|
const SORT_KEY = "FM";
|
|
21
|
-
|
|
22
14
|
class SystemStorageOperations {
|
|
23
15
|
get partitionKey() {
|
|
24
16
|
const tenant = this._context.tenancy.getCurrentTenant();
|
|
25
|
-
|
|
26
17
|
if (!tenant) {
|
|
27
18
|
throw new _error.default("Tenant missing.", "TENANT_NOT_FOUND");
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
return `T#${tenant.id}#SYSTEM`;
|
|
31
21
|
}
|
|
32
|
-
|
|
33
22
|
constructor({
|
|
34
23
|
context
|
|
35
24
|
}) {
|
|
@@ -44,29 +33,24 @@ class SystemStorageOperations {
|
|
|
44
33
|
table
|
|
45
34
|
});
|
|
46
35
|
}
|
|
47
|
-
|
|
48
36
|
async get() {
|
|
49
37
|
try {
|
|
50
38
|
const system = await this._entity.get({
|
|
51
39
|
PK: this.partitionKey,
|
|
52
40
|
SK: SORT_KEY
|
|
53
41
|
});
|
|
54
|
-
|
|
55
42
|
if (!system || !system.Item) {
|
|
56
43
|
return null;
|
|
57
44
|
}
|
|
58
|
-
|
|
59
45
|
return system.Item;
|
|
60
46
|
} catch (ex) {
|
|
61
47
|
throw new _error.default(ex.message || "Could not fetch the FileManager system.", ex.code || "GET_SYSTEM_ERROR");
|
|
62
48
|
}
|
|
63
49
|
}
|
|
64
|
-
|
|
65
50
|
async create(params) {
|
|
66
51
|
const {
|
|
67
52
|
data
|
|
68
53
|
} = params;
|
|
69
|
-
|
|
70
54
|
try {
|
|
71
55
|
await this._entity.put((0, _objectSpread2.default)({
|
|
72
56
|
PK: this.partitionKey,
|
|
@@ -77,16 +61,13 @@ class SystemStorageOperations {
|
|
|
77
61
|
data
|
|
78
62
|
});
|
|
79
63
|
}
|
|
80
|
-
|
|
81
64
|
return data;
|
|
82
65
|
}
|
|
83
|
-
|
|
84
66
|
async update(params) {
|
|
85
67
|
const {
|
|
86
68
|
original,
|
|
87
69
|
data
|
|
88
70
|
} = params;
|
|
89
|
-
|
|
90
71
|
try {
|
|
91
72
|
await this._entity.update((0, _objectSpread2.default)({
|
|
92
73
|
PK: this.partitionKey,
|
|
@@ -97,10 +78,7 @@ class SystemStorageOperations {
|
|
|
97
78
|
data
|
|
98
79
|
});
|
|
99
80
|
}
|
|
100
|
-
|
|
101
81
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
|
|
102
82
|
}
|
|
103
|
-
|
|
104
83
|
}
|
|
105
|
-
|
|
106
84
|
exports.SystemStorageOperations = SystemStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SORT_KEY","SystemStorageOperations","partitionKey","tenant","_context","tenancy","getCurrentTenant","WebinyError","id","constructor","context","table","defineTable","_entity","defineSystemEntity","get","system","PK","SK","Item","ex","message","code","create","params","data","put","update","original"],"sources":["SystemStorageOperations.ts"],"sourcesContent":["import {\n FileManagerContext,\n FileManagerSystem,\n FileManagerSystemStorageOperations,\n FileManagerSystemStorageOperationsCreateParams,\n FileManagerSystemStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineSystemEntity from \"~/definitions/systemEntity\";\nimport defineTable from \"~/definitions/table\";\n\ninterface SystemStorageOperationsConstructorParams {\n context: FileManagerContext;\n}\n\nconst SORT_KEY = \"FM\";\n\nexport class SystemStorageOperations implements FileManagerSystemStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly _entity: Entity<any>;\n\n private get partitionKey(): string {\n const tenant = this._context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Tenant missing.\", \"TENANT_NOT_FOUND\");\n }\n return `T#${tenant.id}#SYSTEM`;\n }\n\n public constructor({ context }: SystemStorageOperationsConstructorParams) {\n this._context = context;\n const table = defineTable({\n context\n });\n\n this._entity = defineSystemEntity({\n context,\n table\n });\n }\n\n public async get(): Promise<FileManagerSystem | null> {\n try {\n const system = await this._entity.get({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n if (!system || !system.Item) {\n return null;\n }\n return system.Item;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager system.\",\n ex.code || \"GET_SYSTEM_ERROR\"\n );\n }\n }\n\n public async create(\n params: FileManagerSystemStorageOperationsCreateParams\n ): Promise<FileManagerSystem> {\n const { data } = params;\n try {\n await this._entity.put({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not insert new system data into DynamoDB\",\n \"CREATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return data;\n }\n\n public async update(\n params: FileManagerSystemStorageOperationsUpdateParams\n ): Promise<FileManagerSystem> {\n const { original, data } = params;\n\n try {\n await this._entity.update({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not update system data in the DynamoDB.\",\n \"UPDATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return {\n ...original,\n ...data\n };\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SORT_KEY","SystemStorageOperations","partitionKey","tenant","_context","tenancy","getCurrentTenant","WebinyError","id","constructor","context","table","defineTable","_entity","defineSystemEntity","get","system","PK","SK","Item","ex","message","code","create","params","data","put","update","original"],"sources":["SystemStorageOperations.ts"],"sourcesContent":["import {\n FileManagerContext,\n FileManagerSystem,\n FileManagerSystemStorageOperations,\n FileManagerSystemStorageOperationsCreateParams,\n FileManagerSystemStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineSystemEntity from \"~/definitions/systemEntity\";\nimport defineTable from \"~/definitions/table\";\n\ninterface SystemStorageOperationsConstructorParams {\n context: FileManagerContext;\n}\n\nconst SORT_KEY = \"FM\";\n\nexport class SystemStorageOperations implements FileManagerSystemStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly _entity: Entity<any>;\n\n private get partitionKey(): string {\n const tenant = this._context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Tenant missing.\", \"TENANT_NOT_FOUND\");\n }\n return `T#${tenant.id}#SYSTEM`;\n }\n\n public constructor({ context }: SystemStorageOperationsConstructorParams) {\n this._context = context;\n const table = defineTable({\n context\n });\n\n this._entity = defineSystemEntity({\n context,\n table\n });\n }\n\n public async get(): Promise<FileManagerSystem | null> {\n try {\n const system = await this._entity.get({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n if (!system || !system.Item) {\n return null;\n }\n return system.Item;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager system.\",\n ex.code || \"GET_SYSTEM_ERROR\"\n );\n }\n }\n\n public async create(\n params: FileManagerSystemStorageOperationsCreateParams\n ): Promise<FileManagerSystem> {\n const { data } = params;\n try {\n await this._entity.put({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not insert new system data into DynamoDB\",\n \"CREATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return data;\n }\n\n public async update(\n params: FileManagerSystemStorageOperationsUpdateParams\n ): Promise<FileManagerSystem> {\n const { original, data } = params;\n\n try {\n await this._entity.update({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not update system data in the DynamoDB.\",\n \"UPDATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return {\n ...original,\n ...data\n };\n }\n}\n"],"mappings":";;;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,QAAQ,GAAG,IAAI;AAEd,MAAMC,uBAAuB,CAA+C;EAI/E,IAAYC,YAAY,GAAW;IAC/B,MAAMC,MAAM,GAAG,IAAI,CAACC,QAAQ,CAACC,OAAO,CAACC,gBAAgB,EAAE;IACvD,IAAI,CAACH,MAAM,EAAE;MACT,MAAM,IAAII,cAAW,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;IAChE;IACA,OAAQ,KAAIJ,MAAM,CAACK,EAAG,SAAQ;EAClC;EAEOC,WAAW,CAAC;IAAEC;EAAkD,CAAC,EAAE;IAAA;IAAA;IACtE,IAAI,CAACN,QAAQ,GAAGM,OAAO;IACvB,MAAMC,KAAK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EAAE,EAAE;MACT,MAAM,IAAIb,cAAW,CACjB,+CAA+C,EAC/C,qBAAqB,EACrB;QACIkB;MACJ,CAAC,CACJ;IACL;IACA,mEACOG,QAAQ,GACRH,IAAI;EAEf;AACJ;AAAC"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SystemStorageOperationsProviderDdbPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _SystemStorageOperations = require("./SystemStorageOperations");
|
|
13
|
-
|
|
14
10
|
var _SystemStorageOperationsProviderPlugin = require("@webiny/api-file-manager/plugins/definitions/SystemStorageOperationsProviderPlugin");
|
|
15
|
-
|
|
16
11
|
class SystemStorageOperationsProviderDdbPlugin extends _SystemStorageOperationsProviderPlugin.SystemStorageOperationsProviderPlugin {
|
|
17
12
|
constructor(...args) {
|
|
18
13
|
super(...args);
|
|
19
14
|
(0, _defineProperty2.default)(this, "name", "fm.storageOperationsProvider.system.ddb");
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
async provide({
|
|
23
17
|
context
|
|
24
18
|
}) {
|
|
@@ -26,7 +20,5 @@ class SystemStorageOperationsProviderDdbPlugin extends _SystemStorageOperationsP
|
|
|
26
20
|
context
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
exports.SystemStorageOperationsProviderDdbPlugin = SystemStorageOperationsProviderDdbPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SystemStorageOperationsProviderDdbPlugin","SystemStorageOperationsProviderPlugin","provide","context","SystemStorageOperations"],"sources":["index.ts"],"sourcesContent":["import { SystemStorageOperations } from \"./SystemStorageOperations\";\nimport {\n SystemStorageOperationsProviderPlugin,\n SystemStorageOperationsProviderPluginParams\n} from \"@webiny/api-file-manager/plugins/definitions/SystemStorageOperationsProviderPlugin\";\n\nexport class SystemStorageOperationsProviderDdbPlugin extends SystemStorageOperationsProviderPlugin {\n public override name = \"fm.storageOperationsProvider.system.ddb\";\n public async provide({ context }: SystemStorageOperationsProviderPluginParams) {\n return new SystemStorageOperations({\n context\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SystemStorageOperationsProviderDdbPlugin","SystemStorageOperationsProviderPlugin","provide","context","SystemStorageOperations"],"sources":["index.ts"],"sourcesContent":["import { SystemStorageOperations } from \"./SystemStorageOperations\";\nimport {\n SystemStorageOperationsProviderPlugin,\n SystemStorageOperationsProviderPluginParams\n} from \"@webiny/api-file-manager/plugins/definitions/SystemStorageOperationsProviderPlugin\";\n\nexport class SystemStorageOperationsProviderDdbPlugin extends SystemStorageOperationsProviderPlugin {\n public override name = \"fm.storageOperationsProvider.system.ddb\";\n public async provide({ context }: SystemStorageOperationsProviderPluginParams) {\n return new SystemStorageOperations({\n context\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAKO,MAAMA,wCAAwC,SAASC,4EAAqC,CAAC;EAAA;IAAA;IAAA,4CACzE,yCAAyC;EAAA;EAChE,MAAaC,OAAO,CAAC;IAAEC;EAAqD,CAAC,EAAE;IAC3E,OAAO,IAAIC,gDAAuB,CAAC;MAC/BD;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
|
package/operations/utils.js
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getTable = exports.getDocumentClient = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
const getDocumentClient = context => {
|
|
13
10
|
const driver = context.db.driver;
|
|
14
|
-
|
|
15
11
|
if (!driver || !driver.documentClient) {
|
|
16
12
|
throw new _error.default(`Missing documentDriver on the context db.driver property.`, "DOCUMENT_CLIENT_ERROR");
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
return driver.documentClient;
|
|
20
15
|
};
|
|
21
|
-
|
|
22
16
|
exports.getDocumentClient = getDocumentClient;
|
|
23
|
-
|
|
24
17
|
const getTable = context => {
|
|
25
18
|
const db = context.db;
|
|
26
|
-
|
|
27
19
|
if (!db) {
|
|
28
20
|
throw new _error.default("Missing db on context.", "DB_ERROR");
|
|
29
21
|
} else if (!db.table) {
|
|
30
22
|
throw new _error.default("Missing table on context.db.", "TABLE_ERROR");
|
|
31
23
|
}
|
|
32
|
-
|
|
33
24
|
return db.table;
|
|
34
25
|
};
|
|
35
|
-
|
|
36
26
|
exports.getTable = getTable;
|
package/operations/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getDocumentClient","context","driver","db","documentClient","WebinyError","getTable","table"],"sources":["utils.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\n\nexport const getDocumentClient = (context: FileManagerContext): DocumentClient => {\n const driver = context.db.driver as any;\n if (!driver || !driver.documentClient) {\n throw new WebinyError(\n `Missing documentDriver on the context db.driver property.`,\n \"DOCUMENT_CLIENT_ERROR\"\n );\n }\n return driver.documentClient;\n};\n\nexport const getTable = (context: FileManagerContext): string => {\n const db = context.db as any;\n if (!db) {\n throw new WebinyError(\"Missing db on context.\", \"DB_ERROR\");\n } else if (!db.table) {\n throw new WebinyError(\"Missing table on context.db.\", \"TABLE_ERROR\");\n }\n return db.table;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["getDocumentClient","context","driver","db","documentClient","WebinyError","getTable","table"],"sources":["utils.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\n\nexport const getDocumentClient = (context: FileManagerContext): DocumentClient => {\n const driver = context.db.driver as any;\n if (!driver || !driver.documentClient) {\n throw new WebinyError(\n `Missing documentDriver on the context db.driver property.`,\n \"DOCUMENT_CLIENT_ERROR\"\n );\n }\n return driver.documentClient;\n};\n\nexport const getTable = (context: FileManagerContext): string => {\n const db = context.db as any;\n if (!db) {\n throw new WebinyError(\"Missing db on context.\", \"DB_ERROR\");\n } else if (!db.table) {\n throw new WebinyError(\"Missing table on context.db.\", \"TABLE_ERROR\");\n }\n return db.table;\n};\n"],"mappings":";;;;;;;AAAA;AAIO,MAAMA,iBAAiB,GAAIC,OAA2B,IAAqB;EAC9E,MAAMC,MAAM,GAAGD,OAAO,CAACE,EAAE,CAACD,MAAa;EACvC,IAAI,CAACA,MAAM,IAAI,CAACA,MAAM,CAACE,cAAc,EAAE;IACnC,MAAM,IAAIC,cAAW,CAChB,2DAA0D,EAC3D,uBAAuB,CAC1B;EACL;EACA,OAAOH,MAAM,CAACE,cAAc;AAChC,CAAC;AAAC;AAEK,MAAME,QAAQ,GAAIL,OAA2B,IAAa;EAC7D,MAAME,EAAE,GAAGF,OAAO,CAACE,EAAS;EAC5B,IAAI,CAACA,EAAE,EAAE;IACL,MAAM,IAAIE,cAAW,CAAC,wBAAwB,EAAE,UAAU,CAAC;EAC/D,CAAC,MAAM,IAAI,CAACF,EAAE,CAACI,KAAK,EAAE;IAClB,MAAM,IAAIF,cAAW,CAAC,8BAA8B,EAAE,aAAa,CAAC;EACxE;EACA,OAAOF,EAAE,CAACI,KAAK;AACnB,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager-ddb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7f63ea0744",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-file-manager",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
25
|
-
"@webiny/api-file-manager": "0.0.0-unstable.
|
|
26
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
27
|
-
"@webiny/error": "0.0.0-unstable.
|
|
28
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
29
|
-
"aws-sdk": "2.
|
|
24
|
+
"@babel/runtime": "7.20.13",
|
|
25
|
+
"@webiny/api-file-manager": "0.0.0-unstable.7f63ea0744",
|
|
26
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.7f63ea0744",
|
|
27
|
+
"@webiny/error": "0.0.0-unstable.7f63ea0744",
|
|
28
|
+
"@webiny/project-utils": "0.0.0-unstable.7f63ea0744",
|
|
29
|
+
"aws-sdk": "2.1310.0",
|
|
30
30
|
"dynamodb-toolbox": "0.3.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
37
37
|
"@babel/preset-env": "^7.19.4",
|
|
38
38
|
"@babel/preset-typescript": "^7.18.6",
|
|
39
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
39
|
+
"@webiny/cli": "^0.0.0-unstable.7f63ea0744",
|
|
40
40
|
"jest": "^28.1.0",
|
|
41
41
|
"jest-dynalite": "^3.2.0",
|
|
42
42
|
"jsonpack": "^1.1.5",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
]
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "7f63ea0744c9e31977e5dabb95538d22b4db585c"
|
|
67
67
|
}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.FileAttributePlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
|
|
13
|
-
|
|
14
10
|
class FileAttributePlugin extends _AttributePlugin.AttributePlugin {
|
|
15
11
|
constructor(params) {
|
|
16
12
|
super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
17
13
|
entity: "Files"
|
|
18
14
|
}));
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
exports.FileAttributePlugin = FileAttributePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FileAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["FileAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class FileAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"Files\"\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["FileAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["FileAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class FileAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"Files\"\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAKO,MAAMA,mBAAmB,SAASC,gCAAe,CAAC;EAC9CC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,6DACEA,MAAM;MACTC,MAAM,EAAE;IAAO,GACjB;EACN;AACJ;AAAC"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.FileDynamoDbFieldPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _FieldPlugin = require("@webiny/db-dynamodb/plugins/definitions/FieldPlugin");
|
|
13
|
-
|
|
14
10
|
class FileDynamoDbFieldPlugin extends _FieldPlugin.FieldPlugin {}
|
|
15
|
-
|
|
16
11
|
exports.FileDynamoDbFieldPlugin = FileDynamoDbFieldPlugin;
|
|
17
12
|
(0, _defineProperty2.default)(FileDynamoDbFieldPlugin, "type", "fileManager.dynamodb.field.file");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FileDynamoDbFieldPlugin","FieldPlugin"],"sources":["FileDynamoDbFieldPlugin.ts"],"sourcesContent":["import { FieldPlugin } from \"@webiny/db-dynamodb/plugins/definitions/FieldPlugin\";\n\nexport class FileDynamoDbFieldPlugin extends FieldPlugin {\n public static override readonly type: string = \"fileManager.dynamodb.field.file\";\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["FileDynamoDbFieldPlugin","FieldPlugin"],"sources":["FileDynamoDbFieldPlugin.ts"],"sourcesContent":["import { FieldPlugin } from \"@webiny/db-dynamodb/plugins/definitions/FieldPlugin\";\n\nexport class FileDynamoDbFieldPlugin extends FieldPlugin {\n public static override readonly type: string = \"fileManager.dynamodb.field.file\";\n}\n"],"mappings":";;;;;;;;AAAA;AAEO,MAAMA,uBAAuB,SAASC,wBAAW,CAAC;AAExD;AAAA,8BAFYD,uBAAuB,UACe,iCAAiC"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SettingsAttributePlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
|
|
13
|
-
|
|
14
10
|
class SettingsAttributePlugin extends _AttributePlugin.AttributePlugin {
|
|
15
11
|
constructor(params) {
|
|
16
12
|
super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
17
13
|
entity: "Settings"
|
|
18
14
|
}));
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
exports.SettingsAttributePlugin = SettingsAttributePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SettingsAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["SettingsAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SettingsAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"Settings\"\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SettingsAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["SettingsAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SettingsAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"Settings\"\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAKO,MAAMA,uBAAuB,SAASC,gCAAe,CAAC;EAClDC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,6DACEA,MAAM;MACTC,MAAM,EAAE;IAAU,GACpB;EACN;AACJ;AAAC"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.SystemAttributePlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
|
|
13
|
-
|
|
14
10
|
class SystemAttributePlugin extends _AttributePlugin.AttributePlugin {
|
|
15
11
|
constructor(params) {
|
|
16
12
|
super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
17
13
|
entity: "System"
|
|
18
14
|
}));
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
exports.SystemAttributePlugin = SystemAttributePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SystemAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["SystemAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SystemAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"System\"\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["SystemAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["SystemAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SystemAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"System\"\n });\n }\n}\n"],"mappings":";;;;;;;;AAAA;AAKO,MAAMA,qBAAqB,SAASC,gCAAe,CAAC;EAChDC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,6DACEA,MAAM;MACTC,MAAM,EAAE;IAAQ,GAClB;EACN;AACJ;AAAC"}
|