@webiny/api-file-manager-ddb 0.0.0-mt-3 → 0.0.0-unstable.1e66d121db

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 (48) hide show
  1. package/definitions/filesEntity.d.ts +3 -2
  2. package/definitions/filesEntity.js +3 -7
  3. package/definitions/filesEntity.js.map +1 -0
  4. package/definitions/settingsEntity.d.ts +3 -2
  5. package/definitions/settingsEntity.js +3 -7
  6. package/definitions/settingsEntity.js.map +1 -0
  7. package/definitions/systemEntity.d.ts +3 -2
  8. package/definitions/systemEntity.js +6 -7
  9. package/definitions/systemEntity.js.map +1 -0
  10. package/definitions/table.d.ts +3 -2
  11. package/definitions/table.js +1 -5
  12. package/definitions/table.js.map +1 -0
  13. package/index.js.map +1 -0
  14. package/operations/files/FilesStorageOperations.js +30 -17
  15. package/operations/files/FilesStorageOperations.js.map +1 -0
  16. package/operations/files/fields.js.map +1 -0
  17. package/operations/files/index.d.ts +2 -2
  18. package/operations/files/index.js +1 -1
  19. package/operations/files/index.js.map +1 -0
  20. package/operations/settings/SettingsStorageOperations.d.ts +3 -3
  21. package/operations/settings/SettingsStorageOperations.js +5 -7
  22. package/operations/settings/SettingsStorageOperations.js.map +1 -0
  23. package/operations/settings/index.d.ts +2 -4
  24. package/operations/settings/index.js +1 -1
  25. package/operations/settings/index.js.map +1 -0
  26. package/operations/system/SystemStorageOperations.d.ts +2 -2
  27. package/operations/system/SystemStorageOperations.js +6 -8
  28. package/operations/system/SystemStorageOperations.js.map +1 -0
  29. package/operations/system/index.d.ts +2 -4
  30. package/operations/system/index.js +1 -1
  31. package/operations/system/index.js.map +1 -0
  32. package/operations/utils.js +1 -1
  33. package/operations/utils.js.map +1 -0
  34. package/package.json +18 -18
  35. package/plugins/FileAttributePlugin.d.ts +2 -2
  36. package/plugins/FileAttributePlugin.js +3 -7
  37. package/plugins/FileAttributePlugin.js.map +1 -0
  38. package/plugins/FileDynamoDbFieldPlugin.js +1 -1
  39. package/plugins/FileDynamoDbFieldPlugin.js.map +1 -0
  40. package/plugins/SettingsAttributePlugin.d.ts +2 -2
  41. package/plugins/SettingsAttributePlugin.js +3 -7
  42. package/plugins/SettingsAttributePlugin.js.map +1 -0
  43. package/plugins/SystemAttributePlugin.d.ts +2 -2
  44. package/plugins/SystemAttributePlugin.js +3 -7
  45. package/plugins/SystemAttributePlugin.js.map +1 -0
  46. package/types.js.map +1 -0
  47. package/operations/configurations.d.ts +0 -14
  48. package/operations/configurations.js +0 -22
@@ -1,7 +1,8 @@
1
1
  import { Entity, Table } from "dynamodb-toolbox";
2
2
  import { FileManagerContext } from "@webiny/api-file-manager/types";
3
- declare const _default: (params: {
3
+ export interface FilesEntityParams {
4
4
  context: FileManagerContext;
5
5
  table: Table;
6
- }) => Entity<any>;
6
+ }
7
+ declare const _default: (params: FilesEntityParams) => Entity<any>;
7
8
  export default _default;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
13
 
14
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
16
  var _default = params => {
21
17
  const {
22
18
  context,
@@ -27,7 +23,7 @@ var _default = params => {
27
23
  return new _dynamodbToolbox.Entity({
28
24
  name: entityName,
29
25
  table,
30
- attributes: _objectSpread({
26
+ attributes: (0, _objectSpread2.default)({
31
27
  PK: {
32
28
  partitionKey: true
33
29
  },
@@ -0,0 +1 @@
1
+ {"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","id","key","size","meta","tags","createdOn","createdBy","tenant","locale","webinyVersion"],"sources":["filesEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface FilesEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: FilesEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"Files\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n size: {\n type: \"number\"\n },\n type: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n meta: {\n type: \"map\"\n },\n tags: {\n type: \"list\"\n },\n createdOn: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;eAMgBA,MAAD,IAA4C;EACvD,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,OAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,EAAE,EAAE;QACAD,IAAI,EAAE;MADN,CAVE;MAaNE,GAAG,EAAE;QACDF,IAAI,EAAE;MADL,CAbC;MAgBNG,IAAI,EAAE;QACFH,IAAI,EAAE;MADJ,CAhBA;MAmBNA,IAAI,EAAE;QACFA,IAAI,EAAE;MADJ,CAnBA;MAsBNN,IAAI,EAAE;QACFM,IAAI,EAAE;MADJ,CAtBA;MAyBNI,IAAI,EAAE;QACFJ,IAAI,EAAE;MADJ,CAzBA;MA4BNK,IAAI,EAAE;QACFL,IAAI,EAAE;MADJ,CA5BA;MA+BNM,SAAS,EAAE;QACPN,IAAI,EAAE;MADC,CA/BL;MAkCNO,SAAS,EAAE;QACPP,IAAI,EAAE;MADC,CAlCL;MAqCNQ,MAAM,EAAE;QACJR,IAAI,EAAE;MADF,CArCF;MAwCNS,MAAM,EAAE;QACJT,IAAI,EAAE;MADF,CAxCF;MA2CNU,aAAa,EAAE;QACXV,IAAI,EAAE;MADK;IA3CT,GA8CHT,UA9CG;EAHI,CAAX,CAAP;AAoDH,C"}
@@ -1,7 +1,8 @@
1
1
  import { Entity, Table } from "dynamodb-toolbox";
2
2
  import { FileManagerContext } from "@webiny/api-file-manager/types";
3
- declare const _default: (params: {
3
+ export interface SettingsEntityParams {
4
4
  context: FileManagerContext;
5
5
  table: Table;
6
- }) => Entity<any>;
6
+ }
7
+ declare const _default: (params: SettingsEntityParams) => Entity<any>;
7
8
  export default _default;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
13
 
14
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
16
  var _default = params => {
21
17
  const {
22
18
  context,
@@ -27,7 +23,7 @@ var _default = params => {
27
23
  return new _dynamodbToolbox.Entity({
28
24
  name: entityName,
29
25
  table,
30
- attributes: _objectSpread({
26
+ attributes: (0, _objectSpread2.default)({
31
27
  PK: {
32
28
  partitionKey: true
33
29
  },
@@ -0,0 +1 @@
1
+ {"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","key","uploadMinFileSize","uploadMaxFileSize","srcPrefix"],"sources":["settingsEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface SettingsEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: SettingsEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"Settings\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n uploadMinFileSize: {\n type: \"number\"\n },\n uploadMaxFileSize: {\n type: \"number\"\n },\n srcPrefix: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;eAMgBA,MAAD,IAA+C;EAC1D,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,UAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE;MADJ,CAPA;MAUNC,GAAG,EAAE;QACDD,IAAI,EAAE;MADL,CAVC;MAaNE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MADS,CAbb;MAgBNG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MADS,CAhBb;MAmBNI,SAAS,EAAE;QACPJ,IAAI,EAAE;MADC;IAnBL,GAsBHT,UAtBG;EAHI,CAAX,CAAP;AA4BH,C"}
@@ -1,7 +1,8 @@
1
1
  import { Entity, Table } from "dynamodb-toolbox";
2
2
  import { FileManagerContext } from "@webiny/api-file-manager/types";
3
- declare const _default: (params: {
3
+ export interface SystemEntityParams {
4
4
  context: FileManagerContext;
5
5
  table: Table;
6
- }) => Entity<any>;
6
+ }
7
+ declare const _default: (params: SystemEntityParams) => Entity<any>;
7
8
  export default _default;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dynamodbToolbox = require("dynamodb-toolbox");
13
13
 
14
14
  var _attributes = require("@webiny/db-dynamodb/utils/attributes");
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
-
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
-
20
16
  var _default = params => {
21
17
  const {
22
18
  context,
@@ -27,7 +23,7 @@ var _default = params => {
27
23
  return new _dynamodbToolbox.Entity({
28
24
  name: entityName,
29
25
  table,
30
- attributes: _objectSpread({
26
+ attributes: (0, _objectSpread2.default)({
31
27
  PK: {
32
28
  partitionKey: true
33
29
  },
@@ -36,6 +32,9 @@ var _default = params => {
36
32
  },
37
33
  version: {
38
34
  type: "string"
35
+ },
36
+ tenant: {
37
+ type: "string"
39
38
  }
40
39
  }, attributes)
41
40
  });
@@ -0,0 +1 @@
1
+ {"version":3,"names":["params","context","table","entityName","attributes","getExtraAttributes","Entity","name","PK","partitionKey","SK","sortKey","version","type","tenant"],"sources":["systemEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { getExtraAttributes } from \"@webiny/db-dynamodb/utils/attributes\";\n\nexport interface SystemEntityParams {\n context: FileManagerContext;\n table: Table;\n}\nexport default (params: SystemEntityParams): Entity<any> => {\n const { context, table } = params;\n const entityName = \"System\";\n const attributes = getExtraAttributes(context, entityName);\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;eAMgBA,MAAD,IAA6C;EACxD,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAqBF,MAA3B;EACA,MAAMG,UAAU,GAAG,QAAnB;EACA,MAAMC,UAAU,GAAG,IAAAC,8BAAA,EAAmBJ,OAAnB,EAA4BE,UAA5B,CAAnB;EACA,OAAO,IAAIG,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdD,KAFc;IAGdE,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD,CAPH;MAUNC,MAAM,EAAE;QACJD,IAAI,EAAE;MADF;IAVF,GAaHT,UAbG;EAHI,CAAX,CAAP;AAmBH,C"}
@@ -1,6 +1,7 @@
1
1
  import { Table } from "dynamodb-toolbox";
2
2
  import { FileManagerContext } from "@webiny/api-file-manager/types";
3
- declare const _default: (params: {
3
+ export interface TableParams {
4
4
  context: FileManagerContext;
5
- }) => Table;
5
+ }
6
+ declare const _default: (params: TableParams) => Table;
6
7
  export default _default;
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -9,8 +7,6 @@ exports.default = void 0;
9
7
 
10
8
  var _dynamodbToolbox = require("dynamodb-toolbox");
11
9
 
12
- var _configurations = _interopRequireDefault(require("../operations/configurations"));
13
-
14
10
  var _utils = require("../operations/utils");
15
11
 
16
12
  var _default = params => {
@@ -18,7 +14,7 @@ var _default = params => {
18
14
  context
19
15
  } = params;
20
16
  return new _dynamodbToolbox.Table({
21
- name: _configurations.default.db().table || (0, _utils.getTable)(context),
17
+ name: process.env.DB_TABLE_FILE_MANGER || process.env.DB_TABLE || (0, _utils.getTable)(context),
22
18
  partitionKey: "PK",
23
19
  sortKey: "SK",
24
20
  DocumentClient: (0, _utils.getDocumentClient)(context)
@@ -0,0 +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;;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.map ADDED
@@ -0,0 +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;;eAEe,MAAM,CACjB,IAAIA,wCAAJ,EADiB,EAEjB,IAAIC,oDAAJ,EAFiB,EAGjB,IAAIC,gDAAJ,EAHiB,C"}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.FilesStorageOperations = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _error = _interopRequireDefault(require("@webiny/error"));
@@ -31,10 +33,6 @@ var _get = require("@webiny/db-dynamodb/utils/get");
31
33
 
32
34
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
33
35
 
34
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
35
-
36
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
37
-
38
36
  class FilesStorageOperations {
39
37
  get context() {
40
38
  return this._context;
@@ -87,8 +85,7 @@ class FilesStorageOperations {
87
85
  PK: this.createPartitionKey(file),
88
86
  SK: this.createSortKey(file)
89
87
  };
90
-
91
- const item = _objectSpread(_objectSpread(_objectSpread({}, file), keys), {}, {
88
+ const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
92
89
  TYPE: "fm.file"
93
90
  });
94
91
 
@@ -112,8 +109,7 @@ class FilesStorageOperations {
112
109
  PK: this.createPartitionKey(file),
113
110
  SK: this.createSortKey(file)
114
111
  };
115
-
116
- const item = _objectSpread(_objectSpread(_objectSpread({}, file), keys), {}, {
112
+ const item = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), keys), {}, {
117
113
  TYPE: "fm.file"
118
114
  });
119
115
 
@@ -154,7 +150,7 @@ class FilesStorageOperations {
154
150
  files
155
151
  } = params;
156
152
  const items = files.map(file => {
157
- return this.entity.putBatch(_objectSpread(_objectSpread({}, file), {}, {
153
+ return this.entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, file), {}, {
158
154
  PK: this.createPartitionKey(file),
159
155
  SK: this.createSortKey(file),
160
156
  TYPE: "fm.file"
@@ -211,7 +207,7 @@ class FilesStorageOperations {
211
207
  });
212
208
  }
213
209
 
214
- const where = _objectSpread({}, initialWhere);
210
+ const where = (0, _objectSpread2.default)({}, initialWhere);
215
211
 
216
212
  if (where.search) {
217
213
  where.contains = {
@@ -246,7 +242,7 @@ class FilesStorageOperations {
246
242
  sort,
247
243
  fields
248
244
  });
249
- const start = (0, _cursor.decodeCursor)(after) || 0;
245
+ const start = parseInt((0, _cursor.decodeCursor)(after) || "0") || 0;
250
246
  const hasMoreItems = totalCount > start + limit;
251
247
  const end = limit > totalCount + start + limit ? undefined : start + limit;
252
248
  const files = sortedFiles.slice(start, end);
@@ -266,11 +262,11 @@ class FilesStorageOperations {
266
262
 
267
263
  async tags(params) {
268
264
  const {
269
- where
265
+ where: initialWhere
270
266
  } = params;
271
267
  const queryAllParams = {
272
268
  entity: this.entity,
273
- partitionKey: this.createPartitionKey(where),
269
+ partitionKey: this.createPartitionKey(initialWhere),
274
270
  options: {
275
271
  gte: " ",
276
272
  reverse: false
@@ -286,13 +282,30 @@ class FilesStorageOperations {
286
282
  query: queryAllParams
287
283
  });
288
284
  }
285
+
286
+ const fields = this.context.plugins.byType(_FileDynamoDbFieldPlugin.FileDynamoDbFieldPlugin.type);
287
+ const where = (0, _objectSpread2.default)({}, initialWhere);
288
+ delete where["tenant"];
289
+ delete where["locale"];
290
+ /**
291
+ * Filter the read items via the code.
292
+ * It will build the filters out of the where input and transform the values it is using.
293
+ */
294
+
295
+ const filteredItems = (0, _filter.filterItems)({
296
+ plugins: this.context.plugins,
297
+ items: results,
298
+ where,
299
+ fields
300
+ });
289
301
  /**
290
- * Aggregate all the tags from all the items in the database.
302
+ * Aggregate all the tags from all the filtered items.
291
303
  */
292
304
 
305
+ const tagsObject = filteredItems.reduce((collection, item) => {
306
+ const tags = Array.isArray(item.tags) ? item.tags : [];
293
307
 
294
- const tagsObject = results.reduce((collection, item) => {
295
- for (const tag of item.tags) {
308
+ for (const tag of tags) {
296
309
  if (!collection[tag]) {
297
310
  collection[tag] = [];
298
311
  }
@@ -0,0 +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":";;;;;;;;;;;;;AAk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,CAAnB;IAWA,MAAMR,IAAc,GAAGc,MAAM,CAAC3E,IAAP,CAAYmE,UAAZ,CAAvB;IAEA,MAAMb,YAAY,GAAG,KAArB;IACA,MAAMP,UAAU,GAAGc,IAAI,CAACb,MAAxB;IAEA,MAAMY,IAAuD,GAAG;MAC5DN,YAD4D;MAE5DP,UAF4D;MAG5DW,MAAM,EAAE;IAHoD,CAAhE;IAMA,OAAO,CAACG,IAAD,EAAOD,IAAP,CAAP;EACH;;EAEO7B,qBAAqB,CAAC;IAAEhC;EAAF,CAAD,EAAgE;IACzF,MAAM+B,OAAoC,GAAG,EAA7C;;IACA,IAAI/B,KAAK,CAAC2E,EAAV,EAAc;MACV5C,OAAO,CAAC8C,EAAR,GAAa7E,KAAK,CAAC2E,EAAnB;IACH;;IACD,OAAO5C,OAAP;EACH;;EAEO5B,kBAAkB,CAACJ,MAAD,EAA2C;IACjE,MAAM;MAAE+E,MAAF;MAAUC;IAAV,IAAqBhF,MAA3B;IACA,OAAQ,KAAI+E,MAAO,MAAKC,MAAO,OAA/B;EACH;;EAEO1E,aAAa,CAACN,MAAD,EAA8B;IAC/C,MAAM;MAAE4E;IAAF,IAAS5E,MAAf;IAEA,OAAO4E,EAAP;EACH;;AAvV4E"}
@@ -0,0 +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;;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,6 +1,6 @@
1
- import { FilesStorageOperationsProviderPlugin, Params } from "@webiny/api-file-manager/plugins/definitions/FilesStorageOperationsProviderPlugin";
1
+ import { FilesStorageOperationsProviderPlugin, FilesStorageOperationsProviderPluginParams } from "@webiny/api-file-manager/plugins/definitions/FilesStorageOperationsProviderPlugin";
2
2
  import { FilesStorageOperations } from "./FilesStorageOperations";
3
3
  export declare class FilesStorageOperationsProviderDdb extends FilesStorageOperationsProviderPlugin {
4
4
  name: string;
5
- provide({ context }: Params): Promise<FilesStorageOperations>;
5
+ provide({ context }: FilesStorageOperationsProviderPluginParams): Promise<FilesStorageOperations>;
6
6
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +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,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,13 +1,13 @@
1
1
  import { FileManagerContext, FileManagerSettings, FileManagerSettingsStorageOperations, FileManagerSettingsStorageOperationsCreateParams, FileManagerSettingsStorageOperationsUpdateParams } from "@webiny/api-file-manager/types";
2
- interface ConstructorParams {
2
+ interface SettingsStorageOperationsConstructorParams {
3
3
  context: FileManagerContext;
4
4
  }
5
5
  export declare class SettingsStorageOperations implements FileManagerSettingsStorageOperations {
6
6
  private readonly _context;
7
7
  private readonly _entity;
8
8
  private get partitionKey();
9
- constructor({ context }: ConstructorParams);
10
- get(): Promise<FileManagerSettings>;
9
+ constructor({ context }: SettingsStorageOperationsConstructorParams);
10
+ get(): Promise<FileManagerSettings | null>;
11
11
  create({ data }: FileManagerSettingsStorageOperationsCreateParams): Promise<FileManagerSettings>;
12
12
  update({ data }: FileManagerSettingsStorageOperationsUpdateParams): Promise<FileManagerSettings>;
13
13
  delete(): Promise<void>;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SettingsStorageOperations = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _error = _interopRequireDefault(require("@webiny/error"));
@@ -15,10 +17,6 @@ var _table = _interopRequireDefault(require("../../definitions/table"));
15
17
 
16
18
  var _settingsEntity = _interopRequireDefault(require("../../definitions/settingsEntity"));
17
19
 
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
-
22
20
  const SORT_KEY = "default";
23
21
 
24
22
  class SettingsStorageOperations {
@@ -80,7 +78,7 @@ class SettingsStorageOperations {
80
78
  }
81
79
 
82
80
  try {
83
- await this._entity.put(_objectSpread({
81
+ await this._entity.put((0, _objectSpread2.default)({
84
82
  PK: this.partitionKey,
85
83
  SK: SORT_KEY
86
84
  }, data));
@@ -96,7 +94,7 @@ class SettingsStorageOperations {
96
94
  data
97
95
  }) {
98
96
  try {
99
- await this._entity.update(_objectSpread({
97
+ await this._entity.update((0, _objectSpread2.default)({
100
98
  PK: this.partitionKey,
101
99
  SK: SORT_KEY
102
100
  }, data));
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SORT_KEY","SettingsStorageOperations","partitionKey","tenant","_context","tenancy","getCurrentTenant","WebinyError","id","constructor","context","table","defineTable","_entity","defineSettingsEntity","get","settings","PK","SK","Item","ex","message","code","create","data","original","update","put","delete"],"sources":["SettingsStorageOperations.ts"],"sourcesContent":["import {\n FileManagerContext,\n FileManagerSettings,\n FileManagerSettingsStorageOperations,\n FileManagerSettingsStorageOperationsCreateParams,\n FileManagerSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineTable from \"~/definitions/table\";\nimport defineSettingsEntity from \"~/definitions/settingsEntity\";\n\ninterface SettingsStorageOperationsConstructorParams {\n context: FileManagerContext;\n}\n\nconst SORT_KEY = \"default\";\n\nexport class SettingsStorageOperations implements FileManagerSettingsStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly _entity: Entity<any>;\n\n private get partitionKey(): string {\n const tenant = this._context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Tenant missing.\", \"TENANT_NOT_FOUND\");\n }\n return `T#${tenant.id}#FM#SETTINGS`;\n }\n\n public constructor({ context }: SettingsStorageOperationsConstructorParams) {\n this._context = context;\n const table = defineTable({\n context\n });\n\n this._entity = defineSettingsEntity({\n context,\n table\n });\n }\n\n public async get(): Promise<FileManagerSettings | null> {\n try {\n const settings = await this._entity.get({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n if (!settings || !settings.Item) {\n return null;\n }\n return settings.Item;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager settings.\",\n ex.code || \"GET_SETTINGS_ERROR\"\n );\n }\n }\n\n public async create({\n data\n }: FileManagerSettingsStorageOperationsCreateParams): Promise<FileManagerSettings> {\n const original = await this.get();\n /**\n * TODO: check if need to throw an error on existing settings\n */\n if (original) {\n return await this.update({ original, data });\n }\n\n try {\n await this._entity.put({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot create FileManager settings.\",\n ex.code || \"CREATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async update({\n data\n }: FileManagerSettingsStorageOperationsUpdateParams): Promise<FileManagerSettings> {\n try {\n await this._entity.update({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n return data;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Cannot update FileManager settings.\",\n ex.code || \"UPDATE_FM_SETTINGS_ERROR\",\n {\n data\n }\n );\n }\n }\n\n public async delete(): Promise<void> {\n return this._entity.delete({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAMA,MAAMA,QAAQ,GAAG,SAAjB;;AAEO,MAAMC,yBAAN,CAAgF;EAI3D,IAAZC,YAAY,GAAW;IAC/B,MAAMC,MAAM,GAAG,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,gBAAtB,EAAf;;IACA,IAAI,CAACH,MAAL,EAAa;MACT,MAAM,IAAII,cAAJ,CAAgB,iBAAhB,EAAmC,kBAAnC,CAAN;IACH;;IACD,OAAQ,KAAIJ,MAAM,CAACK,EAAG,cAAtB;EACH;;EAEMC,WAAW,CAAC;IAAEC;EAAF,CAAD,EAA0D;IAAA;IAAA;IACxE,KAAKN,QAAL,GAAgBM,OAAhB;IACA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAY;MACtBF;IADsB,CAAZ,CAA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E,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,8 +1,6 @@
1
1
  import { SettingsStorageOperations } from "./SettingsStorageOperations";
2
- import { SettingsStorageOperationsProviderPlugin } from "@webiny/api-file-manager/plugins/definitions/SettingsStorageOperationsProviderPlugin";
2
+ import { SettingsStorageOperationsProviderPlugin, SettingsStorageOperationsProviderPluginParams } from "@webiny/api-file-manager/plugins/definitions/SettingsStorageOperationsProviderPlugin";
3
3
  export declare class SettingsStorageOperationsProviderDdbPlugin extends SettingsStorageOperationsProviderPlugin {
4
4
  name: string;
5
- provide({ context }: {
6
- context: any;
7
- }): Promise<SettingsStorageOperations>;
5
+ provide({ context }: SettingsStorageOperationsProviderPluginParams): Promise<SettingsStorageOperations>;
8
6
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +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,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,12 +1,12 @@
1
1
  import { FileManagerContext, FileManagerSystem, FileManagerSystemStorageOperations, FileManagerSystemStorageOperationsCreateParams, FileManagerSystemStorageOperationsUpdateParams } from "@webiny/api-file-manager/types";
2
- interface ConstructorParams {
2
+ interface SystemStorageOperationsConstructorParams {
3
3
  context: FileManagerContext;
4
4
  }
5
5
  export declare class SystemStorageOperations implements FileManagerSystemStorageOperations {
6
6
  private readonly _context;
7
7
  private readonly _entity;
8
8
  private get partitionKey();
9
- constructor({ context }: ConstructorParams);
9
+ constructor({ context }: SystemStorageOperationsConstructorParams);
10
10
  get(): Promise<FileManagerSystem | null>;
11
11
  create(params: FileManagerSystemStorageOperationsCreateParams): Promise<FileManagerSystem>;
12
12
  update(params: FileManagerSystemStorageOperationsUpdateParams): Promise<FileManagerSystem>;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SystemStorageOperations = void 0;
9
9
 
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _error = _interopRequireDefault(require("@webiny/error"));
@@ -15,10 +17,6 @@ var _systemEntity = _interopRequireDefault(require("../../definitions/systemEnti
15
17
 
16
18
  var _table = _interopRequireDefault(require("../../definitions/table"));
17
19
 
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
19
-
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
-
22
20
  const SORT_KEY = "FM";
23
21
 
24
22
  class SystemStorageOperations {
@@ -70,7 +68,7 @@ class SystemStorageOperations {
70
68
  } = params;
71
69
 
72
70
  try {
73
- await this._entity.put(_objectSpread({
71
+ await this._entity.put((0, _objectSpread2.default)({
74
72
  PK: this.partitionKey,
75
73
  SK: SORT_KEY
76
74
  }, data));
@@ -90,7 +88,7 @@ class SystemStorageOperations {
90
88
  } = params;
91
89
 
92
90
  try {
93
- await this._entity.update(_objectSpread({
91
+ await this._entity.update((0, _objectSpread2.default)({
94
92
  PK: this.partitionKey,
95
93
  SK: SORT_KEY
96
94
  }, data));
@@ -100,7 +98,7 @@ class SystemStorageOperations {
100
98
  });
101
99
  }
102
100
 
103
- return _objectSpread(_objectSpread({}, original), data);
101
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), data);
104
102
  }
105
103
 
106
104
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SORT_KEY","SystemStorageOperations","partitionKey","tenant","_context","tenancy","getCurrentTenant","WebinyError","id","constructor","context","table","defineTable","_entity","defineSystemEntity","get","system","PK","SK","Item","ex","message","code","create","params","data","put","update","original"],"sources":["SystemStorageOperations.ts"],"sourcesContent":["import {\n FileManagerContext,\n FileManagerSystem,\n FileManagerSystemStorageOperations,\n FileManagerSystemStorageOperationsCreateParams,\n FileManagerSystemStorageOperationsUpdateParams\n} from \"@webiny/api-file-manager/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport defineSystemEntity from \"~/definitions/systemEntity\";\nimport defineTable from \"~/definitions/table\";\n\ninterface SystemStorageOperationsConstructorParams {\n context: FileManagerContext;\n}\n\nconst SORT_KEY = \"FM\";\n\nexport class SystemStorageOperations implements FileManagerSystemStorageOperations {\n private readonly _context: FileManagerContext;\n private readonly _entity: Entity<any>;\n\n private get partitionKey(): string {\n const tenant = this._context.tenancy.getCurrentTenant();\n if (!tenant) {\n throw new WebinyError(\"Tenant missing.\", \"TENANT_NOT_FOUND\");\n }\n return `T#${tenant.id}#SYSTEM`;\n }\n\n public constructor({ context }: SystemStorageOperationsConstructorParams) {\n this._context = context;\n const table = defineTable({\n context\n });\n\n this._entity = defineSystemEntity({\n context,\n table\n });\n }\n\n public async get(): Promise<FileManagerSystem | null> {\n try {\n const system = await this._entity.get({\n PK: this.partitionKey,\n SK: SORT_KEY\n });\n if (!system || !system.Item) {\n return null;\n }\n return system.Item;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not fetch the FileManager system.\",\n ex.code || \"GET_SYSTEM_ERROR\"\n );\n }\n }\n\n public async create(\n params: FileManagerSystemStorageOperationsCreateParams\n ): Promise<FileManagerSystem> {\n const { data } = params;\n try {\n await this._entity.put({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not insert new system data into DynamoDB\",\n \"CREATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return data;\n }\n\n public async update(\n params: FileManagerSystemStorageOperationsUpdateParams\n ): Promise<FileManagerSystem> {\n const { original, data } = params;\n\n try {\n await this._entity.update({\n PK: this.partitionKey,\n SK: SORT_KEY,\n ...data\n });\n } catch (ex) {\n throw new WebinyError(\n \"Could not update system data in the DynamoDB.\",\n \"UPDATE_SYSTEM_ERROR\",\n {\n data\n }\n );\n }\n return {\n ...original,\n ...data\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAMA,MAAMA,QAAQ,GAAG,IAAjB;;AAEO,MAAMC,uBAAN,CAA4E;EAIvD,IAAZC,YAAY,GAAW;IAC/B,MAAMC,MAAM,GAAG,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,gBAAtB,EAAf;;IACA,IAAI,CAACH,MAAL,EAAa;MACT,MAAM,IAAII,cAAJ,CAAgB,iBAAhB,EAAmC,kBAAnC,CAAN;IACH;;IACD,OAAQ,KAAIJ,MAAM,CAACK,EAAG,SAAtB;EACH;;EAEMC,WAAW,CAAC;IAAEC;EAAF,CAAD,EAAwD;IAAA;IAAA;IACtE,KAAKN,QAAL,GAAgBM,OAAhB;IACA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAY;MACtBF;IADsB,CAAZ,CAAd;IAIA,KAAKG,OAAL,GAAe,IAAAC,qBAAA,EAAmB;MAC9BJ,OAD8B;MAE9BC;IAF8B,CAAnB,CAAf;EAIH;;EAEe,MAAHI,GAAG,GAAsC;IAClD,IAAI;MACA,MAAMC,MAAM,GAAG,MAAM,KAAKH,OAAL,CAAaE,GAAb,CAAiB;QAClCE,EAAE,EAAE,KAAKf,YADyB;QAElCgB,EAAE,EAAElB;MAF8B,CAAjB,CAArB;;MAIA,IAAI,CAACgB,MAAD,IAAW,CAACA,MAAM,CAACG,IAAvB,EAA6B;QACzB,OAAO,IAAP;MACH;;MACD,OAAOH,MAAM,CAACG,IAAd;IACH,CATD,CASE,OAAOC,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACFa,EAAE,CAACC,OAAH,IAAc,yCADZ,EAEFD,EAAE,CAACE,IAAH,IAAW,kBAFT,CAAN;IAIH;EACJ;;EAEkB,MAANC,MAAM,CACfC,MADe,EAEW;IAC1B,MAAM;MAAEC;IAAF,IAAWD,MAAjB;;IACA,IAAI;MACA,MAAM,KAAKX,OAAL,CAAaa,GAAb;QACFT,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCyB,IAHD,EAAN;IAKH,CAND,CAME,OAAOL,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACF,gDADE,EAEF,qBAFE,EAGF;QACIkB;MADJ,CAHE,CAAN;IAOH;;IACD,OAAOA,IAAP;EACH;;EAEkB,MAANE,MAAM,CACfH,MADe,EAEW;IAC1B,MAAM;MAAEI,QAAF;MAAYH;IAAZ,IAAqBD,MAA3B;;IAEA,IAAI;MACA,MAAM,KAAKX,OAAL,CAAac,MAAb;QACFV,EAAE,EAAE,KAAKf,YADP;QAEFgB,EAAE,EAAElB;MAFF,GAGCyB,IAHD,EAAN;IAKH,CAND,CAME,OAAOL,EAAP,EAAW;MACT,MAAM,IAAIb,cAAJ,CACF,+CADE,EAEF,qBAFE,EAGF;QACIkB;MADJ,CAHE,CAAN;IAOH;;IACD,mEACOG,QADP,GAEOH,IAFP;EAIH;;AAxF8E"}
@@ -1,8 +1,6 @@
1
1
  import { SystemStorageOperations } from "./SystemStorageOperations";
2
- import { SystemStorageOperationsProviderPlugin } from "@webiny/api-file-manager/plugins/definitions/SystemStorageOperationsProviderPlugin";
2
+ import { SystemStorageOperationsProviderPlugin, SystemStorageOperationsProviderPluginParams } from "@webiny/api-file-manager/plugins/definitions/SystemStorageOperationsProviderPlugin";
3
3
  export declare class SystemStorageOperationsProviderDdbPlugin extends SystemStorageOperationsProviderPlugin {
4
4
  name: string;
5
- provide({ context }: {
6
- context: any;
7
- }): Promise<SystemStorageOperations>;
5
+ provide({ context }: SystemStorageOperationsProviderPluginParams): Promise<SystemStorageOperations>;
8
6
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +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,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,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +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,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-mt-3",
3
+ "version": "0.0.0-unstable.1e66d121db",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-file-manager",
@@ -21,28 +21,28 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@babel/runtime": "7.15.4",
25
- "@webiny/api-file-manager": "0.0.0-mt-3",
26
- "@webiny/db-dynamodb": "0.0.0-mt-3",
27
- "@webiny/error": "0.0.0-mt-3",
28
- "@webiny/project-utils": "0.0.0-mt-3",
29
- "aws-sdk": "2.1026.0",
30
- "dynamodb-toolbox": "0.3.4"
24
+ "@babel/runtime": "7.19.0",
25
+ "@webiny/api-file-manager": "0.0.0-unstable.1e66d121db",
26
+ "@webiny/db-dynamodb": "0.0.0-unstable.1e66d121db",
27
+ "@webiny/error": "0.0.0-unstable.1e66d121db",
28
+ "@webiny/project-utils": "0.0.0-unstable.1e66d121db",
29
+ "aws-sdk": "2.1230.0",
30
+ "dynamodb-toolbox": "0.3.5"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/cli": "^7.5.5",
34
- "@babel/core": "^7.5.5",
35
- "@babel/plugin-proposal-object-rest-spread": "^7.5.5",
36
- "@babel/plugin-transform-runtime": "^7.5.5",
37
- "@babel/preset-env": "^7.5.5",
38
- "@babel/preset-typescript": "^7.0.0",
39
- "@webiny/cli": "^0.0.0-mt-3",
40
- "jest": "^26.6.3",
33
+ "@babel/cli": "^7.19.3",
34
+ "@babel/core": "^7.19.3",
35
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
36
+ "@babel/plugin-transform-runtime": "^7.16.4",
37
+ "@babel/preset-env": "^7.19.4",
38
+ "@babel/preset-typescript": "^7.18.6",
39
+ "@webiny/cli": "^0.0.0-unstable.1e66d121db",
40
+ "jest": "^28.1.0",
41
41
  "jest-dynalite": "^3.2.0",
42
42
  "jsonpack": "^1.1.5",
43
43
  "rimraf": "^3.0.2",
44
44
  "ttypescript": "^1.5.12",
45
- "typescript": "^4.1.3"
45
+ "typescript": "4.7.4"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",
@@ -63,5 +63,5 @@
63
63
  ]
64
64
  }
65
65
  },
66
- "gitHead": "ebea815be2be99404591cba465cc1fe88355bd48"
66
+ "gitHead": "b670bf27c5039de1a2b0be764a09ba4cb94ad5e2"
67
67
  }
@@ -1,4 +1,4 @@
1
- import { AttributePlugin, Params } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
1
+ import { AttributePlugin, AttributePluginParams } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
2
2
  export declare class FileAttributePlugin extends AttributePlugin {
3
- constructor(params: Omit<Params, "entity">);
3
+ constructor(params: Omit<AttributePluginParams, "entity">);
4
4
  }
@@ -1,23 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.FileAttributePlugin = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
14
  class FileAttributePlugin extends _AttributePlugin.AttributePlugin {
19
15
  constructor(params) {
20
- super(_objectSpread(_objectSpread({}, params), {}, {
16
+ super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
21
17
  entity: "Files"
22
18
  }));
23
19
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FileAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["FileAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class FileAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"Files\"\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAKO,MAAMA,mBAAN,SAAkCC,gCAAlC,CAAkD;EAC9CC,WAAW,CAACC,MAAD,EAAgD;IAC9D,kEACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANoD"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -0,0 +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,uBAAN,SAAsCC,wBAAtC,CAAkD;;;8BAA5CD,uB,UACsC,iC"}
@@ -1,4 +1,4 @@
1
- import { AttributePlugin, Params } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
1
+ import { AttributePlugin, AttributePluginParams } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
2
2
  export declare class SettingsAttributePlugin extends AttributePlugin {
3
- constructor(params: Omit<Params, "entity">);
3
+ constructor(params: Omit<AttributePluginParams, "entity">);
4
4
  }
@@ -1,23 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SettingsAttributePlugin = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
14
  class SettingsAttributePlugin extends _AttributePlugin.AttributePlugin {
19
15
  constructor(params) {
20
- super(_objectSpread(_objectSpread({}, params), {}, {
16
+ super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
21
17
  entity: "Settings"
22
18
  }));
23
19
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SettingsAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["SettingsAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SettingsAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"Settings\"\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAKO,MAAMA,uBAAN,SAAsCC,gCAAtC,CAAsD;EAClDC,WAAW,CAACC,MAAD,EAAgD;IAC9D,kEACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANwD"}
@@ -1,4 +1,4 @@
1
- import { AttributePlugin, Params } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
1
+ import { AttributePlugin, AttributePluginParams } from "@webiny/db-dynamodb/plugins/definitions/AttributePlugin";
2
2
  export declare class SystemAttributePlugin extends AttributePlugin {
3
- constructor(params: Omit<Params, "entity">);
3
+ constructor(params: Omit<AttributePluginParams, "entity">);
4
4
  }
@@ -1,23 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.SystemAttributePlugin = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _AttributePlugin = require("@webiny/db-dynamodb/plugins/definitions/AttributePlugin");
13
13
 
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
17
-
18
14
  class SystemAttributePlugin extends _AttributePlugin.AttributePlugin {
19
15
  constructor(params) {
20
- super(_objectSpread(_objectSpread({}, params), {}, {
16
+ super((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
21
17
  entity: "System"
22
18
  }));
23
19
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SystemAttributePlugin","AttributePlugin","constructor","params","entity"],"sources":["SystemAttributePlugin.ts"],"sourcesContent":["import {\n AttributePlugin,\n AttributePluginParams\n} from \"@webiny/db-dynamodb/plugins/definitions/AttributePlugin\";\n\nexport class SystemAttributePlugin extends AttributePlugin {\n public constructor(params: Omit<AttributePluginParams, \"entity\">) {\n super({\n ...params,\n entity: \"System\"\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAKO,MAAMA,qBAAN,SAAoCC,gCAApC,CAAoD;EAChDC,WAAW,CAACC,MAAD,EAAgD;IAC9D,kEACOA,MADP;MAEIC,MAAM,EAAE;IAFZ;EAIH;;AANsD"}
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":[""],"mappings":""}
@@ -1,14 +0,0 @@
1
- declare const _default: {
2
- db: () => {
3
- table: string;
4
- keys: {
5
- primary: boolean;
6
- unique: boolean;
7
- name: string;
8
- fields: {
9
- name: string;
10
- }[];
11
- }[];
12
- };
13
- };
14
- export default _default;
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = {
8
- db: () => ({
9
- table: process.env.DB_TABLE_FILE_MANGER || process.env.DB_TABLE,
10
- keys: [{
11
- primary: true,
12
- unique: true,
13
- name: "primary",
14
- fields: [{
15
- name: "PK"
16
- }, {
17
- name: "SK"
18
- }]
19
- }]
20
- })
21
- };
22
- exports.default = _default;