@webiny/api-file-manager-ddb 0.0.0-unstable.990c3ab1b6 → 0.0.0-unstable.d4f203fa97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/definitions/filesEntity.js +6 -0
  2. package/definitions/filesEntity.js.map +1 -1
  3. package/definitions/settingsEntity.js +6 -0
  4. package/definitions/settingsEntity.js.map +1 -1
  5. package/definitions/systemEntity.js +6 -0
  6. package/definitions/systemEntity.js.map +1 -1
  7. package/definitions/table.js +4 -0
  8. package/definitions/table.js.map +1 -1
  9. package/index.js +5 -0
  10. package/index.js.map +1 -1
  11. package/operations/files/FilesStorageOperations.js +52 -2
  12. package/operations/files/FilesStorageOperations.js.map +1 -1
  13. package/operations/files/fields.js +3 -0
  14. package/operations/files/fields.js.map +1 -1
  15. package/operations/files/index.js +9 -0
  16. package/operations/files/index.js.map +1 -1
  17. package/operations/settings/SettingsStorageOperations.js +21 -0
  18. package/operations/settings/SettingsStorageOperations.js.map +1 -1
  19. package/operations/settings/index.js +8 -0
  20. package/operations/settings/index.js.map +1 -1
  21. package/operations/system/SystemStorageOperations.js +22 -0
  22. package/operations/system/SystemStorageOperations.js.map +1 -1
  23. package/operations/system/index.js +8 -0
  24. package/operations/system/index.js.map +1 -1
  25. package/operations/utils.js +10 -0
  26. package/operations/utils.js.map +1 -1
  27. package/package.json +9 -9
  28. package/plugins/FileAttributePlugin.js +6 -0
  29. package/plugins/FileAttributePlugin.js.map +1 -1
  30. package/plugins/FileDynamoDbFieldPlugin.js +5 -0
  31. package/plugins/FileDynamoDbFieldPlugin.js.map +1 -1
  32. package/plugins/SettingsAttributePlugin.js +6 -0
  33. package/plugins/SettingsAttributePlugin.js.map +1 -1
  34. package/plugins/SystemAttributePlugin.js +6 -0
  35. package/plugins/SystemAttributePlugin.js.map +1 -1
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
10
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
+
11
16
  var _default = params => {
12
17
  const {
13
18
  context,
@@ -67,4 +72,5 @@ var _default = params => {
67
72
  }, attributes)
68
73
  });
69
74
  };
75
+
70
76
  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":";;;;;;;;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
+ {"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,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
10
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
+
11
16
  var _default = params => {
12
17
  const {
13
18
  context,
@@ -43,4 +48,5 @@ var _default = params => {
43
48
  }, attributes)
44
49
  });
45
50
  };
51
+
46
52
  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":";;;;;;;;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
+ {"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,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
10
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
+
11
16
  var _default = params => {
12
17
  const {
13
18
  context,
@@ -34,4 +39,5 @@ var _default = params => {
34
39
  }, attributes)
35
40
  });
36
41
  };
42
+
37
43
  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":";;;;;;;;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"}
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"}
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _dynamodbToolbox = require("dynamodb-toolbox");
9
+
8
10
  var _utils = require("../operations/utils");
11
+
9
12
  var _default = params => {
10
13
  const {
11
14
  context
@@ -17,4 +20,5 @@ var _default = params => {
17
20
  DocumentClient: (0, _utils.getDocumentClient)(context)
18
21
  });
19
22
  };
23
+
20
24
  exports.default = _default;
@@ -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":";;;;;;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"}
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;;eAMgBA,MAAD,IAAgC;EAC3C,MAAM;IAAEC;EAAF,IAAcD,MAApB;EACA,OAAO,IAAIE,sBAAJ,CAAU;IACbC,IAAI,EAAEC,OAAO,CAACC,GAAR,CAAYC,oBAAZ,IAAoCF,OAAO,CAACC,GAAR,CAAYE,QAAhD,IAA4D,IAAAC,eAAA,EAASP,OAAT,CADrD;IAEbQ,YAAY,EAAE,IAFD;IAGbC,OAAO,EAAE,IAHI;IAIbC,cAAc,EAAE,IAAAC,wBAAA,EAAkBX,OAAlB;EAJH,CAAV,CAAP;AAMH,C"}
package/index.js CHANGED
@@ -4,8 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _files = require("./operations/files");
9
+
8
10
  var _settings = require("./operations/settings");
11
+
9
12
  var _system = require("./operations/system");
13
+
10
14
  var _default = () => [new _files.FilesStorageOperationsProviderDdb(), new _settings.SettingsStorageOperationsProviderDdbPlugin(), new _system.SystemStorageOperationsProviderDdbPlugin()];
15
+
11
16
  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":";;;;;;AAAA;AACA;AACA;AAA+E,eAEhE,MAAM,CACjB,IAAIA,wCAAiC,EAAE,EACvC,IAAIC,oDAA0C,EAAE,EAChD,IAAIC,gDAAwC,EAAE,CACjD;AAAA"}
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;;eAEe,MAAM,CACjB,IAAIA,wCAAJ,EADiB,EAEjB,IAAIC,oDAAJ,EAFiB,EAGjB,IAAIC,gDAAJ,EAHiB,C"}
@@ -1,27 +1,43 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FilesStorageOperations = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
10
14
  var _error = _interopRequireDefault(require("@webiny/error"));
15
+
11
16
  var _table = _interopRequireDefault(require("../../definitions/table"));
17
+
12
18
  var _filesEntity = _interopRequireDefault(require("../../definitions/filesEntity"));
19
+
13
20
  var _query = require("@webiny/db-dynamodb/utils/query");
21
+
14
22
  var _cursor = require("@webiny/db-dynamodb/utils/cursor");
23
+
15
24
  var _filter = require("@webiny/db-dynamodb/utils/filter");
25
+
16
26
  var _sort = require("@webiny/db-dynamodb/utils/sort");
27
+
17
28
  var _FileDynamoDbFieldPlugin = require("../../plugins/FileDynamoDbFieldPlugin");
29
+
18
30
  var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
31
+
19
32
  var _get = require("@webiny/db-dynamodb/utils/get");
33
+
20
34
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
35
+
21
36
  class FilesStorageOperations {
22
37
  get context() {
23
38
  return this._context;
24
39
  }
40
+
25
41
  constructor({
26
42
  context
27
43
  }) {
@@ -37,6 +53,7 @@ class FilesStorageOperations {
37
53
  table: this.table
38
54
  });
39
55
  }
56
+
40
57
  async get(params) {
41
58
  const {
42
59
  where
@@ -45,6 +62,7 @@ class FilesStorageOperations {
45
62
  PK: this.createPartitionKey(where),
46
63
  SK: this.createSortKey(where)
47
64
  };
65
+
48
66
  try {
49
67
  const file = await (0, _get.get)({
50
68
  entity: this.entity,
@@ -58,6 +76,7 @@ class FilesStorageOperations {
58
76
  });
59
77
  }
60
78
  }
79
+
61
80
  async create(params) {
62
81
  const {
63
82
  file
@@ -69,6 +88,7 @@ class FilesStorageOperations {
69
88
  const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
70
89
  TYPE: "fm.file"
71
90
  });
91
+
72
92
  try {
73
93
  await this.entity.put(item);
74
94
  } catch (ex) {
@@ -77,8 +97,10 @@ class FilesStorageOperations {
77
97
  item
78
98
  });
79
99
  }
100
+
80
101
  return file;
81
102
  }
103
+
82
104
  async update(params) {
83
105
  const {
84
106
  file
@@ -90,6 +112,7 @@ class FilesStorageOperations {
90
112
  const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
91
113
  TYPE: "fm.file"
92
114
  });
115
+
93
116
  try {
94
117
  await this.entity.put(item);
95
118
  } catch (ex) {
@@ -98,8 +121,10 @@ class FilesStorageOperations {
98
121
  item
99
122
  });
100
123
  }
124
+
101
125
  return file;
102
126
  }
127
+
103
128
  async delete(params) {
104
129
  const {
105
130
  file
@@ -108,6 +133,7 @@ class FilesStorageOperations {
108
133
  PK: this.createPartitionKey(file),
109
134
  SK: this.createSortKey(file)
110
135
  };
136
+
111
137
  try {
112
138
  await this.entity.delete(keys);
113
139
  } catch (ex) {
@@ -118,6 +144,7 @@ class FilesStorageOperations {
118
144
  });
119
145
  }
120
146
  }
147
+
121
148
  async createBatch(params) {
122
149
  const {
123
150
  files
@@ -129,6 +156,7 @@ class FilesStorageOperations {
129
156
  TYPE: "fm.file"
130
157
  }));
131
158
  });
159
+
132
160
  try {
133
161
  await (0, _batchWrite.batchWriteAll)({
134
162
  table: this.entity.table,
@@ -140,8 +168,10 @@ class FilesStorageOperations {
140
168
  files
141
169
  });
142
170
  }
171
+
143
172
  return files;
144
173
  }
174
+
145
175
  async list(params) {
146
176
  const {
147
177
  where: initialWhere,
@@ -158,6 +188,7 @@ class FilesStorageOperations {
158
188
  options
159
189
  };
160
190
  let items = [];
191
+
161
192
  try {
162
193
  items = await (0, _query.queryAll)(queryAllParams);
163
194
  } catch (ex) {
@@ -175,13 +206,16 @@ class FilesStorageOperations {
175
206
  }
176
207
  });
177
208
  }
209
+
178
210
  const where = (0, _objectSpread2.default)({}, initialWhere);
211
+
179
212
  if (where.search) {
180
213
  where.contains = {
181
214
  fields: ["name", "tags"],
182
215
  value: where.search
183
216
  };
184
217
  }
218
+
185
219
  delete where["tenant"];
186
220
  delete where["locale"];
187
221
  delete where["search"];
@@ -190,6 +224,7 @@ class FilesStorageOperations {
190
224
  * Filter the read items via the code.
191
225
  * It will build the filters out of the where input and transform the values it is using.
192
226
  */
227
+
193
228
  const filteredFiles = (0, _filter.filterItems)({
194
229
  plugins: this.context.plugins,
195
230
  items,
@@ -201,6 +236,7 @@ class FilesStorageOperations {
201
236
  * Sorting is also done via the code.
202
237
  * It takes the sort input and sorts by it via the lodash sortBy method.
203
238
  */
239
+
204
240
  const sortedFiles = (0, _sort.sortItems)({
205
241
  items: filteredFiles,
206
242
  sort,
@@ -214,6 +250,7 @@ class FilesStorageOperations {
214
250
  * Although we do not need a cursor here, we will use it as such to keep it standardized.
215
251
  * Number is simply encoded.
216
252
  */
253
+
217
254
  const cursor = files.length > 0 ? (0, _cursor.encodeCursor)(start + limit) : null;
218
255
  const meta = {
219
256
  hasMoreItems,
@@ -222,6 +259,7 @@ class FilesStorageOperations {
222
259
  };
223
260
  return [files, meta];
224
261
  }
262
+
225
263
  async tags(params) {
226
264
  const {
227
265
  where: initialWhere
@@ -235,6 +273,7 @@ class FilesStorageOperations {
235
273
  }
236
274
  };
237
275
  let results = [];
276
+
238
277
  try {
239
278
  results = await (0, _query.queryAll)(queryAllParams);
240
279
  } catch (ex) {
@@ -243,33 +282,37 @@ class FilesStorageOperations {
243
282
  query: queryAllParams
244
283
  });
245
284
  }
285
+
246
286
  const fields = this.context.plugins.byType(_FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin.type);
247
287
  const where = (0, _objectSpread2.default)({}, initialWhere);
248
288
  delete where["tenant"];
249
289
  delete where["locale"];
250
-
251
290
  /**
252
291
  * Filter the read items via the code.
253
292
  * It will build the filters out of the where input and transform the values it is using.
254
293
  */
294
+
255
295
  const filteredItems = (0, _filter.filterItems)({
256
296
  plugins: this.context.plugins,
257
297
  items: results,
258
298
  where,
259
299
  fields
260
300
  });
261
-
262
301
  /**
263
302
  * Aggregate all the tags from all the filtered items.
264
303
  */
304
+
265
305
  const tagsObject = filteredItems.reduce((collection, item) => {
266
306
  const tags = Array.isArray(item.tags) ? item.tags : [];
307
+
267
308
  for (const tag of tags) {
268
309
  if (!collection[tag]) {
269
310
  collection[tag] = [];
270
311
  }
312
+
271
313
  collection[tag].push(item.id);
272
314
  }
315
+
273
316
  return collection;
274
317
  }, {});
275
318
  const tags = Object.keys(tagsObject);
@@ -282,15 +325,19 @@ class FilesStorageOperations {
282
325
  };
283
326
  return [tags, meta];
284
327
  }
328
+
285
329
  createQueryAllOptions({
286
330
  where
287
331
  }) {
288
332
  const options = {};
333
+
289
334
  if (where.id) {
290
335
  options.eq = where.id;
291
336
  }
337
+
292
338
  return options;
293
339
  }
340
+
294
341
  createPartitionKey(params) {
295
342
  const {
296
343
  tenant,
@@ -298,11 +345,14 @@ class FilesStorageOperations {
298
345
  } = params;
299
346
  return `T#${tenant}#L#${locale}#FM#F`;
300
347
  }
348
+
301
349
  createSortKey(params) {
302
350
  const {
303
351
  id
304
352
  } = params;
305
353
  return id;
306
354
  }
355
+
307
356
  }
357
+
308
358
  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":";;;;;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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"}
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,E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AEA,OAAO4E,EAAP;EACH;;AAvV4E"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
7
8
  var _FileDynamoDbFieldPlugin = require("../../plugins/FileDynamoDbFieldPlugin");
9
+
8
10
  var _default = () => [new _FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin({
9
11
  field: "id"
10
12
  }),
@@ -36,4 +38,5 @@ new _FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin({
36
38
  field: "createdOn",
37
39
  type: "date"
38
40
  })];
41
+
39
42
  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":";;;;;;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
+ {"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;;eAEe,MAAM,CACjB,IAAIA,gDAAJ,CAA4B;EACxBC,KAAK,EAAE;AADiB,CAA5B,CADiB;AAIjB;AACJ;AACA;AACI,IAAID,gDAAJ,CAA4B;EACxBC,KAAK,EAAE,WADiB;EAExBC,IAAI,EAAE;AAFkB,CAA5B,CAPiB;AAWjB;AACJ;AACA;AACI,IAAIF,gDAAJ,CAA4B;EACxBC,KAAK,EAAE,SADiB;EAExBC,IAAI,EAAE;AAFkB,CAA5B,CAdiB;AAkBjB;AACJ;AACA;AACI,IAAIF,gDAAJ,CAA4B;EACxBC,KAAK,EAAE,KADiB;EAExBC,IAAI,EAAE;AAFkB,CAA5B,CArBiB;AAyBjB;AACJ;AACA;AACI,IAAIF,gDAAJ,CAA4B;EACxBC,KAAK,EAAE,WADiB;EAExBE,IAAI,EAAE;AAFkB,CAA5B,CA5BiB,C"}
@@ -1,19 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FilesStorageOperationsProviderDdb = void 0;
9
+
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
9
12
  var _FilesStorageOperationsProviderPlugin = require("@webiny/api-file-manager/plugins/definitions/FilesStorageOperationsProviderPlugin");
13
+
10
14
  var _FilesStorageOperations = require("./FilesStorageOperations");
15
+
11
16
  var _fields = _interopRequireDefault(require("./fields"));
17
+
12
18
  class FilesStorageOperationsProviderDdb extends _FilesStorageOperationsProviderPlugin.FilesStorageOperationsProviderPlugin {
13
19
  constructor(...args) {
14
20
  super(...args);
15
21
  (0, _defineProperty2.default)(this, "name", "fm.storageOperationsProvider.files.ddb");
16
22
  }
23
+
17
24
  async provide({
18
25
  context
19
26
  }) {
@@ -22,5 +29,7 @@ class FilesStorageOperationsProviderDdb extends _FilesStorageOperationsProviderP
22
29
  context
23
30
  });
24
31
  }
32
+
25
33
  }
34
+
26
35
  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":";;;;;;;;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
+ {"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,iCAAN,SAAgDC,0EAAhD,CAAqF;EAAA;IAAA;IAAA,4CACjE,wCADiE;EAAA;;EAE3E,MAAPC,OAAO,CAAC;IAAEC;EAAF,CAAD,EAA0D;IACnEA,OAAO,CAACC,OAAR,CAAgBC,QAAhB,CAAyB,IAAAC,eAAA,GAAzB;IACA,OAAO,IAAIC,8CAAJ,CAA2B;MAC9BJ;IAD8B,CAA3B,CAAP;EAGH;;AAPuF"}
@@ -1,24 +1,35 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SettingsStorageOperations = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
10
14
  var _error = _interopRequireDefault(require("@webiny/error"));
15
+
11
16
  var _table = _interopRequireDefault(require("../../definitions/table"));
17
+
12
18
  var _settingsEntity = _interopRequireDefault(require("../../definitions/settingsEntity"));
19
+
13
20
  const SORT_KEY = "default";
21
+
14
22
  class SettingsStorageOperations {
15
23
  get partitionKey() {
16
24
  const tenant = this._context.tenancy.getCurrentTenant();
25
+
17
26
  if (!tenant) {
18
27
  throw new _error.default("Tenant missing.", "TENANT_NOT_FOUND");
19
28
  }
29
+
20
30
  return `T#${tenant.id}#FM#SETTINGS`;
21
31
  }
32
+
22
33
  constructor({
23
34
  context
24
35
  }) {
@@ -33,20 +44,24 @@ class SettingsStorageOperations {
33
44
  table
34
45
  });
35
46
  }
47
+
36
48
  async get() {
37
49
  try {
38
50
  const settings = await this._entity.get({
39
51
  PK: this.partitionKey,
40
52
  SK: SORT_KEY
41
53
  });
54
+
42
55
  if (!settings || !settings.Item) {
43
56
  return null;
44
57
  }
58
+
45
59
  return settings.Item;
46
60
  } catch (ex) {
47
61
  throw new _error.default(ex.message || "Could not fetch the FileManager settings.", ex.code || "GET_SETTINGS_ERROR");
48
62
  }
49
63
  }
64
+
50
65
  async create({
51
66
  data
52
67
  }) {
@@ -54,12 +69,14 @@ class SettingsStorageOperations {
54
69
  /**
55
70
  * TODO: check if need to throw an error on existing settings
56
71
  */
72
+
57
73
  if (original) {
58
74
  return await this.update({
59
75
  original,
60
76
  data
61
77
  });
62
78
  }
79
+
63
80
  try {
64
81
  await this._entity.put((0, _objectSpread2.default)({
65
82
  PK: this.partitionKey,
@@ -72,6 +89,7 @@ class SettingsStorageOperations {
72
89
  });
73
90
  }
74
91
  }
92
+
75
93
  async update({
76
94
  data
77
95
  }) {
@@ -87,11 +105,14 @@ class SettingsStorageOperations {
87
105
  });
88
106
  }
89
107
  }
108
+
90
109
  async delete() {
91
110
  return this._entity.delete({
92
111
  PK: this.partitionKey,
93
112
  SK: SORT_KEY
94
113
  });
95
114
  }
115
+
96
116
  }
117
+
97
118
  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":";;;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,QAAQ,GAAG,SAAS;AAEnB,MAAMC,yBAAyB,CAAiD;EAInF,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,cAAa;EACvC;EAEOC,WAAW,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAAA;IAAA;IACxE,IAAI,CAACN,QAAQ,GAAGM,OAAO;IACvB,MAAMC,KAAK,GAAG,IAAAC,cAAW,EAAC;MACtBF;IACJ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O,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
+ {"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,CAAgB,iBAAhB,EAAmC,kBAAnC,CAAN;IACH;;IAC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c,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,18 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SettingsStorageOperationsProviderDdbPlugin = void 0;
9
+
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
9
12
  var _SettingsStorageOperations = require("./SettingsStorageOperations");
13
+
10
14
  var _SettingsStorageOperationsProviderPlugin = require("@webiny/api-file-manager/plugins/definitions/SettingsStorageOperationsProviderPlugin");
15
+
11
16
  class SettingsStorageOperationsProviderDdbPlugin extends _SettingsStorageOperationsProviderPlugin.SettingsStorageOperationsProviderPlugin {
12
17
  constructor(...args) {
13
18
  super(...args);
14
19
  (0, _defineProperty2.default)(this, "name", "fm.storageOperationsProvider.settings.ddb");
15
20
  }
21
+
16
22
  async provide({
17
23
  context
18
24
  }) {
@@ -20,5 +26,7 @@ class SettingsStorageOperationsProviderDdbPlugin extends _SettingsStorageOperati
20
26
  context
21
27
  });
22
28
  }
29
+
23
30
  }
31
+
24
32
  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":";;;;;;;;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
+ {"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,0CAAN,SAAyDC,gFAAzD,CAAiG;EAAA;IAAA;IAAA,4CAC7E,2CAD6E;EAAA;;EAGhF,MAAPC,OAAO,CAAC;IAAEC;EAAF,CAAD,EAA6D;IAC7E,OAAO,IAAIC,oDAAJ,CAA8B;MACjCD;IADiC,CAA9B,CAAP;EAGH;;AAPmG"}
@@ -1,24 +1,35 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SystemStorageOperations = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
10
14
  var _error = _interopRequireDefault(require("@webiny/error"));
15
+
11
16
  var _systemEntity = _interopRequireDefault(require("../../definitions/systemEntity"));
17
+
12
18
  var _table = _interopRequireDefault(require("../../definitions/table"));
19
+
13
20
  const SORT_KEY = "FM";
21
+
14
22
  class SystemStorageOperations {
15
23
  get partitionKey() {
16
24
  const tenant = this._context.tenancy.getCurrentTenant();
25
+
17
26
  if (!tenant) {
18
27
  throw new _error.default("Tenant missing.", "TENANT_NOT_FOUND");
19
28
  }
29
+
20
30
  return `T#${tenant.id}#SYSTEM`;
21
31
  }
32
+
22
33
  constructor({
23
34
  context
24
35
  }) {
@@ -33,24 +44,29 @@ class SystemStorageOperations {
33
44
  table
34
45
  });
35
46
  }
47
+
36
48
  async get() {
37
49
  try {
38
50
  const system = await this._entity.get({
39
51
  PK: this.partitionKey,
40
52
  SK: SORT_KEY
41
53
  });
54
+
42
55
  if (!system || !system.Item) {
43
56
  return null;
44
57
  }
58
+
45
59
  return system.Item;
46
60
  } catch (ex) {
47
61
  throw new _error.default(ex.message || "Could not fetch the FileManager system.", ex.code || "GET_SYSTEM_ERROR");
48
62
  }
49
63
  }
64
+
50
65
  async create(params) {
51
66
  const {
52
67
  data
53
68
  } = params;
69
+
54
70
  try {
55
71
  await this._entity.put((0, _objectSpread2.default)({
56
72
  PK: this.partitionKey,
@@ -61,13 +77,16 @@ class SystemStorageOperations {
61
77
  data
62
78
  });
63
79
  }
80
+
64
81
  return data;
65
82
  }
83
+
66
84
  async update(params) {
67
85
  const {
68
86
  original,
69
87
  data
70
88
  } = params;
89
+
71
90
  try {
72
91
  await this._entity.update((0, _objectSpread2.default)({
73
92
  PK: this.partitionKey,
@@ -78,7 +97,10 @@ class SystemStorageOperations {
78
97
  data
79
98
  });
80
99
  }
100
+
81
101
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
82
102
  }
103
+
83
104
  }
105
+
84
106
  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":";;;;;;;;;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;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CAACc,MAAM;QACrBV,EAAE,EAAE,IAAI,CAACf,YAAY;QACrBgB,EAAE,EAAElB;MAAQ,GACTyB,IAAI,EACT;IACN,CAAC,CAAC,OAAOL,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
+ {"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;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RequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SystemStorageOperationsProviderDdbPlugin = void 0;
9
+
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
9
12
  var _SystemStorageOperations = require("./SystemStorageOperations");
13
+
10
14
  var _SystemStorageOperationsProviderPlugin = require("@webiny/api-file-manager/plugins/definitions/SystemStorageOperationsProviderPlugin");
15
+
11
16
  class SystemStorageOperationsProviderDdbPlugin extends _SystemStorageOperationsProviderPlugin.SystemStorageOperationsProviderPlugin {
12
17
  constructor(...args) {
13
18
  super(...args);
14
19
  (0, _defineProperty2.default)(this, "name", "fm.storageOperationsProvider.system.ddb");
15
20
  }
21
+
16
22
  async provide({
17
23
  context
18
24
  }) {
@@ -20,5 +26,7 @@ class SystemStorageOperationsProviderDdbPlugin extends _SystemStorageOperationsP
20
26
  context
21
27
  });
22
28
  }
29
+
23
30
  }
31
+
24
32
  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":";;;;;;;;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"}
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,wCAAN,SAAuDC,4EAAvD,CAA6F;EAAA;IAAA;IAAA,4CACzE,yCADyE;EAAA;;EAE5E,MAAPC,OAAO,CAAC;IAAEC;EAAF,CAAD,EAA2D;IAC3E,OAAO,IAAIC,gDAAJ,CAA4B;MAC/BD;IAD+B,CAA5B,CAAP;EAGH;;AAN+F"}
@@ -1,26 +1,36 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.getTable = exports.getDocumentClient = void 0;
9
+
8
10
  var _error = _interopRequireDefault(require("@webiny/error"));
11
+
9
12
  const getDocumentClient = context => {
10
13
  const driver = context.db.driver;
14
+
11
15
  if (!driver || !driver.documentClient) {
12
16
  throw new _error.default(`Missing documentDriver on the context db.driver property.`, "DOCUMENT_CLIENT_ERROR");
13
17
  }
18
+
14
19
  return driver.documentClient;
15
20
  };
21
+
16
22
  exports.getDocumentClient = getDocumentClient;
23
+
17
24
  const getTable = context => {
18
25
  const db = context.db;
26
+
19
27
  if (!db) {
20
28
  throw new _error.default("Missing db on context.", "DB_ERROR");
21
29
  } else if (!db.table) {
22
30
  throw new _error.default("Missing table on context.db.", "TABLE_ERROR");
23
31
  }
32
+
24
33
  return db.table;
25
34
  };
35
+
26
36
  exports.getTable = getTable;
@@ -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":";;;;;;;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"}
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,OAAD,IAAiD;EAC9E,MAAMC,MAAM,GAAGD,OAAO,CAACE,EAAR,CAAWD,MAA1B;;EACA,IAAI,CAACA,MAAD,IAAW,CAACA,MAAM,CAACE,cAAvB,EAAuC;IACnC,MAAM,IAAIC,cAAJ,CACD,2DADC,EAEF,uBAFE,CAAN;EAIH;;EACD,OAAOH,MAAM,CAACE,cAAd;AACH,CATM;;;;AAWA,MAAME,QAAQ,GAAIL,OAAD,IAAyC;EAC7D,MAAME,EAAE,GAAGF,OAAO,CAACE,EAAnB;;EACA,IAAI,CAACA,EAAL,EAAS;IACL,MAAM,IAAIE,cAAJ,CAAgB,wBAAhB,EAA0C,UAA1C,CAAN;EACH,CAFD,MAEO,IAAI,CAACF,EAAE,CAACI,KAAR,EAAe;IAClB,MAAM,IAAIF,cAAJ,CAAgB,8BAAhB,EAAgD,aAAhD,CAAN;EACH;;EACD,OAAOF,EAAE,CAACI,KAAV;AACH,CARM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager-ddb",
3
- "version": "0.0.0-unstable.990c3ab1b6",
3
+ "version": "0.0.0-unstable.d4f203fa97",
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.20.1",
25
- "@webiny/api-file-manager": "0.0.0-unstable.990c3ab1b6",
26
- "@webiny/db-dynamodb": "0.0.0-unstable.990c3ab1b6",
27
- "@webiny/error": "0.0.0-unstable.990c3ab1b6",
28
- "@webiny/project-utils": "0.0.0-unstable.990c3ab1b6",
29
- "aws-sdk": "2.1261.0",
24
+ "@babel/runtime": "7.19.0",
25
+ "@webiny/api-file-manager": "0.0.0-unstable.d4f203fa97",
26
+ "@webiny/db-dynamodb": "0.0.0-unstable.d4f203fa97",
27
+ "@webiny/error": "0.0.0-unstable.d4f203fa97",
28
+ "@webiny/project-utils": "0.0.0-unstable.d4f203fa97",
29
+ "aws-sdk": "2.1230.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.990c3ab1b6",
39
+ "@webiny/cli": "^0.0.0-unstable.d4f203fa97",
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": "87e7b4d0a643f65b31d029d6bf2a81902fb940a8"
66
+ "gitHead": "d4f203fa97feba84cd90ccb002963fca40d9b677"
67
67
  }
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FileAttributePlugin = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
+
10
14
  class FileAttributePlugin extends _AttributePlugin.AttributePlugin {
11
15
  constructor(params) {
12
16
  super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
13
17
  entity: "Files"
14
18
  }));
15
19
  }
20
+
16
21
  }
22
+
17
23
  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":";;;;;;;;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
+ {"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,12 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FileDynamoDbFieldPlugin = void 0;
9
+
8
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
9
12
  var _FieldPlugin = require("@webiny/db-dynamodb/plugins/definitions/FieldPlugin");
13
+
10
14
  class FileDynamoDbFieldPlugin extends _FieldPlugin.FieldPlugin {}
15
+
11
16
  exports.FileDynamoDbFieldPlugin = FileDynamoDbFieldPlugin;
12
17
  (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":";;;;;;;;AAAA;AAEO,MAAMA,uBAAuB,SAASC,wBAAW,CAAC;AAExD;AAAA,8BAFYD,uBAAuB,UACe,iCAAiC"}
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,uBAAN,SAAsCC,wBAAtC,CAAkD;;;8BAA5CD,uB,UACsC,iC"}
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SettingsAttributePlugin = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
+
10
14
  class SettingsAttributePlugin extends _AttributePlugin.AttributePlugin {
11
15
  constructor(params) {
12
16
  super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
13
17
  entity: "Settings"
14
18
  }));
15
19
  }
20
+
16
21
  }
22
+
17
23
  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":";;;;;;;;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
+ {"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,17 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SystemAttributePlugin = void 0;
9
+
8
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
9
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
+
10
14
  class SystemAttributePlugin extends _AttributePlugin.AttributePlugin {
11
15
  constructor(params) {
12
16
  super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
13
17
  entity: "System"
14
18
  }));
15
19
  }
20
+
16
21
  }
22
+
17
23
  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":";;;;;;;;AAAA;AAKO,MAAMA,qBAAqB,SAASC,gCAAe,CAAC;EAChDC,WAAW,CAACC,MAA6C,EAAE;IAC9D,KAAK,6DACEA,MAAM;MACTC,MAAM,EAAE;IAAQ,GAClB;EACN;AACJ;AAAC"}
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"}