@webiny/api-file-manager-ddb 5.33.5 → 5.34.0-beta.0

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.
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
13
 
14
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
-
20
16
  var _default = params => {
21
17
  const {
22
18
  context,
@@ -27,7 +23,7 @@ var _default = params => {
27
23
  return new _dynamodbToolbox.Entity({
28
24
  name: entityName,
29
25
  table,
30
- attributes: _objectSpread({
26
+ attributes: (0, _objectSpread2.default)({
31
27
  PK: {
32
28
  partitionKey: true
33
29
  },
@@ -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":";;;;;;;;;;;AAAA;;AAEA;;;;;;eAMgBA,MAAD,IAA4C;EACvD,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,OAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,EAAE,EAAE;QACAD,IAAI,EAAE;MADN,CAVE;MAaNE,GAAG,EAAE;QACDF,IAAI,EAAE;MADL,CAbC;MAgBNG,IAAI,EAAE;QACFH,IAAI,EAAE;MADJ,CAhBA;MAmBNA,IAAI,EAAE;QACFA,IAAI,EAAE;MADJ,CAnBA;MAsBNN,IAAI,EAAE;QACFM,IAAI,EAAE;MADJ,CAtBA;MAyBNI,IAAI,EAAE;QACFJ,IAAI,EAAE;MADJ,CAzBA;MA4BNK,IAAI,EAAE;QACFL,IAAI,EAAE;MADJ,CA5BA;MA+BNM,SAAS,EAAE;QACPN,IAAI,EAAE;MADC,CA/BL;MAkCNO,SAAS,EAAE;QACPP,IAAI,EAAE;MADC,CAlCL;MAqCNQ,MAAM,EAAE;QACJR,IAAI,EAAE;MADF,CArCF;MAwCNS,MAAM,EAAE;QACJT,IAAI,EAAE;MADF,CAxCF;MA2CNU,aAAa,EAAE;QACXV,IAAI,EAAE;MADK;IA3CT,GA8CHT,UA9CG;EAHI,CAAX,CAAP;AAoDH,C"}
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;;eAMgBA,MAAD,IAA4C;EACvD,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,OAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,EAAE,EAAE;QACAD,IAAI,EAAE;MADN,CAVE;MAaNE,GAAG,EAAE;QACDF,IAAI,EAAE;MADL,CAbC;MAgBNG,IAAI,EAAE;QACFH,IAAI,EAAE;MADJ,CAhBA;MAmBNA,IAAI,EAAE;QACFA,IAAI,EAAE;MADJ,CAnBA;MAsBNN,IAAI,EAAE;QACFM,IAAI,EAAE;MADJ,CAtBA;MAyBNI,IAAI,EAAE;QACFJ,IAAI,EAAE;MADJ,CAzBA;MA4BNK,IAAI,EAAE;QACFL,IAAI,EAAE;MADJ,CA5BA;MA+BNM,SAAS,EAAE;QACPN,IAAI,EAAE;MADC,CA/BL;MAkCNO,SAAS,EAAE;QACPP,IAAI,EAAE;MADC,CAlCL;MAqCNQ,MAAM,EAAE;QACJR,IAAI,EAAE;MADF,CArCF;MAwCNS,MAAM,EAAE;QACJT,IAAI,EAAE;MADF,CAxCF;MA2CNU,aAAa,EAAE;QACXV,IAAI,EAAE;MADK;IA3CT,GA8CHT,UA9CG;EAHI,CAAX,CAAP;AAoDH,C"}
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
13
 
14
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
-
20
16
  var _default = params => {
21
17
  const {
22
18
  context,
@@ -27,7 +23,7 @@ var _default = params => {
27
23
  return new _dynamodbToolbox.Entity({
28
24
  name: entityName,
29
25
  table,
30
- attributes: _objectSpread({
26
+ attributes: (0, _objectSpread2.default)({
31
27
  PK: {
32
28
  partitionKey: true
33
29
  },
@@ -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":";;;;;;;;;;;AAAA;;AAEA;;;;;;eAMgBA,MAAD,IAA+C;EAC1D,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,UAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,GAAG,EAAE;QACDD,IAAI,EAAE;MADL,CAVC;MAaNE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MADS,CAbb;MAgBNG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MADS,CAhBb;MAmBNI,SAAS,EAAE;QACPJ,IAAI,EAAE;MADC;IAnBL,GAsBHT,UAtBG;EAHI,CAAX,CAAP;AA4BH,C"}
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;;eAMgBA,MAAD,IAA+C;EAC1D,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,UAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,GAAG,EAAE;QACDD,IAAI,EAAE;MADL,CAVC;MAaNE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MADS,CAbb;MAgBNG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MADS,CAhBb;MAmBNI,SAAS,EAAE;QACPJ,IAAI,EAAE;MADC;IAnBL,GAsBHT,UAtBG;EAHI,CAAX,CAAP;AA4BH,C"}
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
13
 
14
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
-
20
16
  var _default = params => {
21
17
  const {
22
18
  context,
@@ -27,7 +23,7 @@ var _default = params => {
27
23
  return new _dynamodbToolbox.Entity({
28
24
  name: entityName,
29
25
  table,
30
- attributes: _objectSpread({
26
+ attributes: (0, _objectSpread2.default)({
31
27
  PK: {
32
28
  partitionKey: true
33
29
  },
@@ -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":";;;;;;;;;;;AAAA;;AAEA;;;;;;eAMgBA,MAAD,IAA6C;EACxD,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,QAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD,CAPH;MAUNC,MAAM,EAAE;QACJD,IAAI,EAAE;MADF;IAVF,GAaHT,UAbG;EAHI,CAAX,CAAP;AAmBH,C"}
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;;eAMgBA,MAAD,IAA6C;EACxD,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,QAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD,CAPH;MAUNC,MAAM,EAAE;QACJD,IAAI,EAAE;MADF;IAVF,GAaHT,UAbG;EAHI,CAAX,CAAP;AAmBH,C"}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.FilesStorageOperations = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _error = _interopRequireDefault(require("@webiny/error"));
@@ -31,10 +33,6 @@ var _get = require("@webiny/db-dynamodb/utils/get");
31
33
 
32
34
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
33
35
 
34
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
35
-
36
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
37
-
38
36
  class FilesStorageOperations {
39
37
  get context() {
40
38
  return this._context;
@@ -87,8 +85,7 @@ class FilesStorageOperations {
87
85
  PK: this.createPartitionKey(file),
88
86
  SK: this.createSortKey(file)
89
87
  };
90
-
91
- const item = _objectSpread(_objectSpread(_objectSpread({}, file), keys), {}, {
88
+ const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
92
89
  TYPE: "fm.file"
93
90
  });
94
91
 
@@ -112,8 +109,7 @@ class FilesStorageOperations {
112
109
  PK: this.createPartitionKey(file),
113
110
  SK: this.createSortKey(file)
114
111
  };
115
-
116
- const item = _objectSpread(_objectSpread(_objectSpread({}, file), keys), {}, {
112
+ const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
117
113
  TYPE: "fm.file"
118
114
  });
119
115
 
@@ -154,7 +150,7 @@ class FilesStorageOperations {
154
150
  files
155
151
  } = params;
156
152
  const items = files.map(file => {
157
- return this.entity.putBatch(_objectSpread(_objectSpread({}, file), {}, {
153
+ return this.entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), {}, {
158
154
  PK: this.createPartitionKey(file),
159
155
  SK: this.createSortKey(file),
160
156
  TYPE: "fm.file"
@@ -211,7 +207,7 @@ class FilesStorageOperations {
211
207
  });
212
208
  }
213
209
 
214
- const where = _objectSpread({}, initialWhere);
210
+ const where = (0, _objectSpread2.default)({}, initialWhere);
215
211
 
216
212
  if (where.search) {
217
213
  where.contains = {
@@ -288,9 +284,7 @@ class FilesStorageOperations {
288
284
  }
289
285
 
290
286
  const fields = this.context.plugins.byType(_FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin.type);
291
-
292
- const where = _objectSpread({}, initialWhere);
293
-
287
+ const where = (0, _objectSpread2.default)({}, initialWhere);
294
288
  delete where["tenant"];
295
289
  delete where["locale"];
296
290
  /**
@@ -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;IACA,KAAKG,KAAL,GAAa,IAAAC,cAAA,EAAY;MACrBJ;IADqB,CAAZ,CAAb;IAIA,KAAKK,MAAL,GAAc,IAAAC,oBAAA,EAAkB;MAC5BN,OAD4B;MAE5BG,KAAK,EAAE,KAAKA;IAFgB,CAAlB,CAAd;EAIH;;EAEe,MAAHI,GAAG,CAACC,MAAD,EAA2E;IACvF,MAAM;MAAEC;IAAF,IAAYD,MAAlB;IACA,MAAME,IAAI,GAAG;MACTC,EAAE,EAAE,KAAKC,kBAAL,CAAwBH,KAAxB,CADK;MAETI,EAAE,EAAE,KAAKC,aAAL,CAAmBL,KAAnB;IAFK,CAAb;;IAIA,IAAI;MACA,MAAMM,IAAI,GAAG,MAAM,IAAAC,QAAA,EAAoB;QACnCX,MAAM,EAAE,KAAKA,MADsB;QAEnCK;MAFmC,CAApB,CAAnB;MAIA,OAAO,IAAAO,oBAAA,EAAkB,KAAKZ,MAAvB,EAA+BU,IAA/B,CAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,iCADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,gBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIT;MA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,UAAU,CAACG,GAAD,CAAf,EAAsB;UAClBH,UAAU,CAACG,GAAD,CAAV,GAAkB,EAAlB;QACH;;QACDH,UAAU,CAACG,GAAD,CAAV,CAAgBC,IAAhB,CAAqB3D,IAAI,CAAC4D,EAA1B;MACH;;MACD,OAAOL,UAAP;IACH,CATkB,EAShB,EATgB,CAAnB;IAWA,MAAMR,IAAc,GAAGc,MAAM,CAAC3E,IAAP,CAAYmE,UAAZ,CAAvB;IAEA,MAAMb,YAAY,GAAG,KAArB;IACA,MAAMP,UAAU,GAAGc,IAAI,CAACb,MAAxB;IAEA,MAAMY,IAAuD,GAAG;MAC5DN,YAD4D;MAE5DP,UAF4D;MAG5DW,MAAM,EAAE;IAHoD,CAAhE;IAMA,OAAO,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,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;IACA,KAAKG,KAAL,GAAa,IAAAC,cAAA,EAAY;MACrBJ;IADqB,CAAZ,CAAb;IAIA,KAAKK,MAAL,GAAc,IAAAC,oBAAA,EAAkB;MAC5BN,OAD4B;MAE5BG,KAAK,EAAE,KAAKA;IAFgB,CAAlB,CAAd;EAIH;;EAEe,MAAHI,GAAG,CAACC,MAAD,EAA2E;IACvF,MAAM;MAAEC;IAAF,IAAYD,MAAlB;IACA,MAAME,IAAI,GAAG;MACTC,EAAE,EAAE,KAAKC,kBAAL,C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UC;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,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SettingsStorageOperations = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _error = _interopRequireDefault(require("@webiny/error"));
@@ -15,10 +17,6 @@ var _table = _interopRequireDefault(require("../../definitions/table"));
15
17
 
16
18
  var _settingsEntity = _interopRequireDefault(require("../../definitions/settingsEntity"));
17
19
 
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
-
22
20
  const SORT_KEY = "default";
23
21
 
24
22
  class SettingsStorageOperations {
@@ -80,7 +78,7 @@ class SettingsStorageOperations {
80
78
  }
81
79
 
82
80
  try {
83
- await this._entity.put(_objectSpread({
81
+ await this._entity.put((0, _objectSpread2.default)({
84
82
  PK: this.partitionKey,
85
83
  SK: SORT_KEY
86
84
  }, data));
@@ -96,7 +94,7 @@ class SettingsStorageOperations {
96
94
  data
97
95
  }) {
98
96
  try {
99
- await this._entity.update(_objectSpread({
97
+ await this._entity.update((0, _objectSpread2.default)({
100
98
  PK: this.partitionKey,
101
99
  SK: SORT_KEY
102
100
  }, data));
@@ -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":";;;;;;;;;;;AAQA;;AACA;;AACA;;;;;;AAMA,MAAMA,QAAQ,GAAG,SAAjB;;AAEO,MAAMC,yBAAN,CAAgF;EAI3D,IAAZC,YAAY,GAAW;IAC/B,MAAMC,MAAM,GAAG,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,gBAAtB,EAAf;;IACA,IAAI,CAACH,MAAL,EAAa;MACT,MAAM,IAAII,cAAJ,C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M,IAAIb,cAAJ,CACFa,EAAE,CAACC,OAAH,IAAc,qCADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,0BAFT,EAGF;QACIE;MADJ,CAHE,CAAN;IAOH;EACJ;;EAEkB,MAANE,MAAM,CAAC;IAChBF;EADgB,CAAD,EAEgE;IAC/E,IAAI;MACA,MAAM,KAAKX,OAAL,CAAaa,MAAb;QACFT,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCwB,IAHD,EAAN;MAKA,OAAOA,IAAP;IACH,CAPD,CAOE,OAAOJ,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACFa,EAAE,CAACC,OAAH,IAAc,qCADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,0BAFT,EAGF;QACIE;MADJ,CAHE,CAAN;IAOH;EACJ;;EAEkB,MAANI,MAAM,GAAkB;IACjC,OAAO,KAAKf,OAAL,CAAae,MAAb,CAAoB;MACvBX,EAAE,EAAE,KAAKf,YADc;MAEvBgB,EAAE,EAAElB;IAFmB,CAApB,CAAP;EAIH;;AAjGkF"}
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,SAAjB;;AAEO,MAAMC,yBAA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AAKX,OAAL,CAAac,GAAb;QACFV,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCwB,IAHD,EAAN;MAKA,OAAOA,IAAP;IACH,CAPD,CAOE,OAAOJ,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACFa,EAAE,CAACC,OAAH,IAAc,qCADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,0BAFT,EAGF;QACIE;MADJ,CAHE,CAAN;IAOH;EACJ;;EAEkB,MAANE,MAAM,CAAC;IAChBF;EADgB,CAAD,EAEgE;IAC/E,IAAI;MACA,MAAM,KAAKX,OAAL,CAAaa,MAAb;QACFT,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCwB,IAHD,EAAN;MAKA,OAAOA,IAAP;IACH,CAPD,CAOE,OAAOJ,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACFa,EAAE,CAACC,OAAH,IAAc,qCADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,0BAFT,EAGF;QACIE;MADJ,CAHE,CAAN;IAOH;EACJ;;EAEkB,MAANI,MAAM,GAAkB;IACjC,OAAO,KAAKf,OAAL,CAAae,MAAb,CAAoB;MACvBX,EAAE,EAAE,KAAKf,YADc;MAEvBgB,EAAE,EAAElB;IAFmB,CAApB,CAAP;EAIH;;AAjGkF"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SystemStorageOperations = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _error = _interopRequireDefault(require("@webiny/error"));
@@ -15,10 +17,6 @@ var _systemEntity = _interopRequireDefault(require("../../definitions/systemEnti
15
17
 
16
18
  var _table = _interopRequireDefault(require("../../definitions/table"));
17
19
 
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
-
22
20
  const SORT_KEY = "FM";
23
21
 
24
22
  class SystemStorageOperations {
@@ -70,7 +68,7 @@ class SystemStorageOperations {
70
68
  } = params;
71
69
 
72
70
  try {
73
- await this._entity.put(_objectSpread({
71
+ await this._entity.put((0, _objectSpread2.default)({
74
72
  PK: this.partitionKey,
75
73
  SK: SORT_KEY
76
74
  }, data));
@@ -90,7 +88,7 @@ class SystemStorageOperations {
90
88
  } = params;
91
89
 
92
90
  try {
93
- await this._entity.update(_objectSpread({
91
+ await this._entity.update((0, _objectSpread2.default)({
94
92
  PK: this.partitionKey,
95
93
  SK: SORT_KEY
96
94
  }, data));
@@ -100,7 +98,7 @@ class SystemStorageOperations {
100
98
  });
101
99
  }
102
100
 
103
- return _objectSpread(_objectSpread({}, original), data);
101
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
104
102
  }
105
103
 
106
104
  }
@@ -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":";;;;;;;;;;;AAQA;;AACA;;AACA;;;;;;AAMA,MAAMA,QAAQ,GAAG,IAAjB;;AAEO,MAAMC,uBAAN,CAA4E;EAIvD,IAAZC,YAAY,GAAW;IAC/B,MAAMC,MAAM,GAAG,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,gBAAtB,EAAf;;IACA,IAAI,CAACH,MAAL,EAAa;MACT,MAAM,IAAII,cAAJ,CAAgB,iBAAhB,EAAmC,kBAAnC,CAAN;IACH;;IACD,OAAQ,KAAIJ,MAAM,CAACK,EAAG,SAAtB;EACH;;EAEMC,WAAW,CAAC;IAAEC;EAAF,CAAD,EAAwD;IAAA;IAAA;IACtE,KAAKN,QAAL,GAAgBM,OAAhB;IACA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAY;MACtBF;IADsB,CAAZ,CAAd;IAIA,KAAKG,OAAL,GAAe,IAAAC,qBAAA,EAAmB;MAC9BJ,OAD8B;MAE9BC;IAF8B,CAAnB,CAAf;EAIH;;EAEe,MAAHI,GAAG,GAAsC;IAClD,IAAI;MACA,MAAMC,MAAM,GAAG,MAAM,KAAKH,OAAL,CAAaE,GAAb,CAAiB;QAClCE,EAAE,EAAE,KAAKf,YADyB;QAElCgB,EAAE,EAAElB;MAF8B,CAAjB,CAArB;;MAIA,IAAI,CAACgB,MAAD,IAAW,CAACA,MAAM,CAACG,IAAvB,EAA6B;QACzB,OAAO,IAAP;MACH;;MACD,OAAOH,MAAM,CAACG,IAAd;IACH,CATD,CASE,OAAOC,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACFa,EAAE,CAACC,OAAH,IAAc,yCADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,kBAFT,CAAN;IAIH;EACJ;;EAEkB,MAANC,MAAM,CACfC,MADe,EAEW;IAC1B,MAAM;MAAEC;IAAF,IAAWD,MAAjB;;IACA,IAAI;MACA,MAAM,KAAKX,OAAL,CAAaa,GAAb;QACFT,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCyB,IAHD,EAAN;IAKH,CAND,CAME,OAAOL,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACF,gDADE,EAEF,qBAFE,EAGF;QACIkB;MADJ,CAHE,CAAN;IAOH;;IACD,OAAOA,IAAP;EACH;;EAEkB,MAANE,MAAM,CACfH,MADe,EAEW;IAC1B,MAAM;MAAEI,QAAF;MAAYH;IAAZ,IAAqBD,MAA3B;;IAEA,IAAI;MACA,MAAM,KAAKX,OAAL,CAAac,MAAb;QACFV,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCyB,IAHD,EAAN;IAKH,CAND,CAME,OAAOL,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACF,+CADE,EAEF,qBAFE,EAGF;QACIkB;MADJ,CAHE,CAAN;IAOH;;IACD,uCACOG,QADP,GAEOH,IAFP;EAIH;;AAxF8E"}
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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QACFT,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCyB,IAHD,EAAN;IAKH,CAND,CAME,OAAOL,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACF,gDADE,EAEF,qBAFE,EAGF;QACIkB;MADJ,CAHE,CAAN;IAOH;;IACD,OAAOA,IAAP;EACH;;EAEkB,MAANE,MAAM,CACfH,MADe,EAEW;IAC1B,MAAM;MAAEI,QAAF;MAAYH;IAAZ,IAAqBD,MAA3B;;IAEA,IAAI;MACA,MAAM,KAAKX,OAAL,CAAac,MAAb;QACFV,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCyB,IAHD,EAAN;IAKH,CAND,CAME,OAAOL,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACF,+CADE,EAEF,qBAFE,EAGF;QACIkB;MADJ,CAHE,CAAN;IAOH;;IACD,mEACOG,QADP,GAEOH,IAFP;EAIH;;AAxF8E"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager-ddb",
3
- "version": "5.33.5",
3
+ "version": "5.34.0-beta.0",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-file-manager",
@@ -21,22 +21,22 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@babel/runtime": "7.18.9",
25
- "@webiny/api-file-manager": "5.33.5",
26
- "@webiny/db-dynamodb": "5.33.5",
27
- "@webiny/error": "5.33.5",
28
- "@webiny/project-utils": "5.33.5",
29
- "aws-sdk": "2.1188.0",
24
+ "@babel/runtime": "7.19.0",
25
+ "@webiny/api-file-manager": "5.34.0-beta.0",
26
+ "@webiny/db-dynamodb": "5.34.0-beta.0",
27
+ "@webiny/error": "5.34.0-beta.0",
28
+ "@webiny/project-utils": "5.34.0-beta.0",
29
+ "aws-sdk": "2.1230.0",
30
30
  "dynamodb-toolbox": "0.3.5"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/cli": "^7.16.0",
34
- "@babel/core": "^7.16.0",
33
+ "@babel/cli": "^7.19.3",
34
+ "@babel/core": "^7.19.3",
35
35
  "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
36
36
  "@babel/plugin-transform-runtime": "^7.16.4",
37
- "@babel/preset-env": "^7.16.4",
38
- "@babel/preset-typescript": "^7.16.0",
39
- "@webiny/cli": "^5.33.5",
37
+ "@babel/preset-env": "^7.19.4",
38
+ "@babel/preset-typescript": "^7.18.6",
39
+ "@webiny/cli": "^5.34.0-beta.0",
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": "5063045cd2abdcdb360f97262f9b90b8858ec1df"
66
+ "gitHead": "9648454619a1bfb35040eb00f27a64ed75194e61"
67
67
  }
@@ -1,23 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.FileAttributePlugin = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
14
  class FileAttributePlugin extends _AttributePlugin.AttributePlugin {
19
15
  constructor(params) {
20
- super(_objectSpread(_objectSpread({}, params), {}, {
16
+ super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
21
17
  entity: "Files"
22
18
  }));
23
19
  }
@@ -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":";;;;;;;;;;;AAAA;;;;;;AAKO,MAAMA,mBAAN,SAAkCC,gCAAlC,CAAkD;EAC9CC,WAAW,CAACC,MAAD,EAAgD;IAC9D,sCACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANoD"}
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,mBAAN,SAAkCC,gCAAlC,CAAkD;EAC9CC,WAAW,CAACC,MAAD,EAAgD;IAC9D,kEACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANoD"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -1,23 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SettingsAttributePlugin = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
14
  class SettingsAttributePlugin extends _AttributePlugin.AttributePlugin {
19
15
  constructor(params) {
20
- super(_objectSpread(_objectSpread({}, params), {}, {
16
+ super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
21
17
  entity: "Settings"
22
18
  }));
23
19
  }
@@ -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":";;;;;;;;;;;AAAA;;;;;;AAKO,MAAMA,uBAAN,SAAsCC,gCAAtC,CAAsD;EAClDC,WAAW,CAACC,MAAD,EAAgD;IAC9D,sCACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANwD"}
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,uBAAN,SAAsCC,gCAAtC,CAAsD;EAClDC,WAAW,CAACC,MAAD,EAAgD;IAC9D,kEACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANwD"}
@@ -1,23 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SystemAttributePlugin = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
14
  class SystemAttributePlugin extends _AttributePlugin.AttributePlugin {
19
15
  constructor(params) {
20
- super(_objectSpread(_objectSpread({}, params), {}, {
16
+ super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
21
17
  entity: "System"
22
18
  }));
23
19
  }
@@ -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":";;;;;;;;;;;AAAA;;;;;;AAKO,MAAMA,qBAAN,SAAoCC,gCAApC,CAAoD;EAChDC,WAAW,CAACC,MAAD,EAAgD;IAC9D,sCACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANsD"}
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,qBAAN,SAAoCC,gCAApC,CAAoD;EAChDC,WAAW,CAACC,MAAD,EAAgD;IAC9D,kEACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANsD"}