@webiny/db-dynamodb 0.0.0-mt-2 → 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 (110) hide show
  1. package/BatchProcess.d.ts +26 -10
  2. package/BatchProcess.js +9 -7
  3. package/BatchProcess.js.map +1 -0
  4. package/DynamoDbDriver.d.ts +19 -11
  5. package/DynamoDbDriver.js +10 -8
  6. package/DynamoDbDriver.js.map +1 -0
  7. package/QueryGenerator.d.ts +15 -13
  8. package/QueryGenerator.js +16 -17
  9. package/QueryGenerator.js.map +1 -0
  10. package/index.js +1 -1
  11. package/index.js.map +1 -0
  12. package/operators/comparison/beginsWith.js.map +1 -0
  13. package/operators/comparison/between.js.map +1 -0
  14. package/operators/comparison/eq.js.map +1 -0
  15. package/operators/comparison/gt.js.map +1 -0
  16. package/operators/comparison/gte.js.map +1 -0
  17. package/operators/comparison/lt.js.map +1 -0
  18. package/operators/comparison/lte.js.map +1 -0
  19. package/operators/index.js +1 -1
  20. package/operators/index.js.map +1 -0
  21. package/operators/logical/and.js.map +1 -0
  22. package/operators/logical/or.js.map +1 -0
  23. package/package.json +17 -16
  24. package/plugins/definitions/AttributePlugin.d.ts +3 -3
  25. package/plugins/definitions/AttributePlugin.js +1 -1
  26. package/plugins/definitions/AttributePlugin.js.map +1 -0
  27. package/plugins/definitions/DateTimeTransformPlugin.d.ts +2 -2
  28. package/plugins/definitions/DateTimeTransformPlugin.js +7 -7
  29. package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -0
  30. package/plugins/definitions/FieldPathPlugin.d.ts +3 -3
  31. package/plugins/definitions/FieldPathPlugin.js +4 -6
  32. package/plugins/definitions/FieldPathPlugin.js.map +1 -0
  33. package/plugins/definitions/FieldPlugin.d.ts +3 -3
  34. package/plugins/definitions/FieldPlugin.js +1 -1
  35. package/plugins/definitions/FieldPlugin.js.map +1 -0
  36. package/plugins/definitions/NumberTransformPlugin.d.ts +2 -2
  37. package/plugins/definitions/NumberTransformPlugin.js +3 -7
  38. package/plugins/definitions/NumberTransformPlugin.js.map +1 -0
  39. package/plugins/definitions/TimeTransformPlugin.d.ts +2 -2
  40. package/plugins/definitions/TimeTransformPlugin.js +3 -7
  41. package/plugins/definitions/TimeTransformPlugin.js.map +1 -0
  42. package/plugins/definitions/ValueFilterPlugin.d.ts +10 -10
  43. package/plugins/definitions/ValueFilterPlugin.js +1 -1
  44. package/plugins/definitions/ValueFilterPlugin.js.map +1 -0
  45. package/plugins/definitions/ValueTransformPlugin.d.ts +8 -8
  46. package/plugins/definitions/ValueTransformPlugin.js +4 -6
  47. package/plugins/definitions/ValueTransformPlugin.js.map +1 -0
  48. package/plugins/definitions/assignFields.js +1 -1
  49. package/plugins/definitions/assignFields.js.map +1 -0
  50. package/plugins/filters/andIn.js +1 -1
  51. package/plugins/filters/andIn.js.map +1 -0
  52. package/plugins/filters/between.js +1 -1
  53. package/plugins/filters/between.js.map +1 -0
  54. package/plugins/filters/contains.js.map +1 -0
  55. package/plugins/filters/eq.js +13 -0
  56. package/plugins/filters/eq.js.map +1 -0
  57. package/plugins/filters/fuzzy.js +1 -1
  58. package/plugins/filters/fuzzy.js.map +1 -0
  59. package/plugins/filters/gt.js.map +1 -0
  60. package/plugins/filters/gte.js.map +1 -0
  61. package/plugins/filters/in.js +1 -1
  62. package/plugins/filters/in.js.map +1 -0
  63. package/plugins/filters/index.js +4 -2
  64. package/plugins/filters/index.js.map +1 -0
  65. package/plugins/filters/lt.js.map +1 -0
  66. package/plugins/filters/lte.js.map +1 -0
  67. package/plugins/filters/startsWith.d.ts +3 -0
  68. package/plugins/filters/startsWith.js +33 -0
  69. package/plugins/filters/startsWith.js.map +1 -0
  70. package/plugins/index.js +1 -1
  71. package/plugins/index.js.map +1 -0
  72. package/statements/createKeyConditionExpressionArgs.d.ts +12 -9
  73. package/statements/createKeyConditionExpressionArgs.js +5 -1
  74. package/statements/createKeyConditionExpressionArgs.js.map +1 -0
  75. package/statements/processStatement.d.ts +3 -4
  76. package/statements/processStatement.js +8 -5
  77. package/statements/processStatement.js.map +1 -0
  78. package/types.d.ts +37 -8
  79. package/types.js.map +1 -0
  80. package/utils/attributes.d.ts +2 -2
  81. package/utils/attributes.js +3 -7
  82. package/utils/attributes.js.map +1 -0
  83. package/utils/batchRead.d.ts +1 -1
  84. package/utils/batchRead.js +56 -25
  85. package/utils/batchRead.js.map +1 -0
  86. package/utils/batchWrite.js +1 -1
  87. package/utils/batchWrite.js.map +1 -0
  88. package/utils/cleanup.d.ts +2 -2
  89. package/utils/cleanup.js +9 -17
  90. package/utils/cleanup.js.map +1 -0
  91. package/utils/cursor.d.ts +2 -2
  92. package/utils/cursor.js.map +1 -0
  93. package/utils/filter.d.ts +2 -2
  94. package/utils/filter.js +7 -6
  95. package/utils/filter.js.map +1 -0
  96. package/utils/get.d.ts +2 -2
  97. package/utils/get.js.map +1 -0
  98. package/utils/listResponse.d.ts +1 -1
  99. package/utils/listResponse.js +9 -6
  100. package/utils/listResponse.js.map +1 -0
  101. package/utils/query.d.ts +2 -3
  102. package/utils/query.js +7 -15
  103. package/utils/query.js.map +1 -0
  104. package/utils/sort.d.ts +2 -2
  105. package/utils/sort.js +4 -6
  106. package/utils/sort.js.map +1 -0
  107. package/utils/table.js +1 -1
  108. package/utils/table.js.map +1 -0
  109. package/utils/documentClient.d.ts +0 -8
  110. package/utils/documentClient.js +0 -33
package/utils/query.js CHANGED
@@ -1,20 +1,16 @@
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.queryOne = exports.queryAll = 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 _error = _interopRequireDefault(require("@webiny/error"));
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
  /**
19
15
  * Will run query only once. Pass the previous to run the query again to fetch new data.
20
16
  * It returns the result and the items it found.
@@ -85,17 +81,13 @@ const query = async params => {
85
81
  const queryOne = async params => {
86
82
  const {
87
83
  items
88
- } = await query(_objectSpread(_objectSpread({}, params), {}, {
89
- options: _objectSpread(_objectSpread({}, params.options || {}), {}, {
84
+ } = await query((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
85
+ options: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params.options || {}), {}, {
90
86
  limit: 1
91
87
  })
92
88
  }));
93
-
94
- if (items.length === 0) {
95
- return null;
96
- }
97
-
98
- return items.shift();
89
+ const item = items.shift();
90
+ return item ? item : null;
99
91
  };
100
92
  /**
101
93
  * Will run the query to fetch the results no matter how much iterations it needs to go through.
@@ -109,7 +101,7 @@ const queryAll = async params => {
109
101
  let results;
110
102
  let previousResult = undefined;
111
103
 
112
- while (results = await query(_objectSpread(_objectSpread({}, params), {}, {
104
+ while (results = await query((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
113
105
  previous: previousResult
114
106
  }))) {
115
107
  items.push(...results.items);
@@ -0,0 +1 @@
1
+ {"version":3,"names":["query","params","entity","previous","partitionKey","options","result","next","items","Items","Array","isArray","WebinyError","queryOne","limit","item","shift","queryAll","results","previousResult","undefined","push"],"sources":["query.ts"],"sourcesContent":["import { queryOptions as DynamoDBToolboxQueryOptions } from \"dynamodb-toolbox/dist/classes/Table\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\n\nexport interface QueryAllParams {\n entity: Entity<any>;\n partitionKey: string;\n options?: DynamoDBToolboxQueryOptions;\n}\n\nexport interface QueryOneParams extends QueryAllParams {\n options?: Omit<DynamoDBToolboxQueryOptions, \"limit\">;\n}\n\nexport interface QueryParams extends QueryAllParams {\n previous?: any;\n}\n\nexport interface QueryResult<T> {\n result: any | null;\n items: T[];\n}\n\nexport type DbItem<T> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n GSI1_PK?: string;\n GSI1_SK?: string;\n};\n\n/**\n * Will run query only once. Pass the previous to run the query again to fetch new data.\n * It returns the result and the items it found.\n * Result is required to fetch the items that were not fetched in the previous run.\n */\nconst query = async <T>(params: QueryParams): Promise<QueryResult<T>> => {\n const { entity, previous, partitionKey, options } = params;\n let result;\n /**\n * In case there is no previous result we must make a new query.\n * This is the first query on the given partition key.\n */\n if (!previous) {\n result = await entity.query(partitionKey, options);\n } else if (typeof previous.next === \"function\") {\n /**\n * In case we have a previous result and it has a next method, we run it.\n * In case result of the next method is false, it means it has nothing else to read\n * and we return a null to keep the query from repeating.\n */\n result = await previous.next();\n if (result === false) {\n return {\n result: null,\n items: []\n };\n }\n } else {\n /**\n * This could probably never happen but keep it here just in case to break the query loop.\n * Basically, either previous does not exist or it exists and it does not have the next method\n * and at that point a result returned will be null and loop should not start again.\n */\n return {\n result: null,\n items: []\n };\n }\n /**\n * We expect the result to contain an Items array and if not, something went wrong, very wrong.\n */\n if (!result || !result.Items || !Array.isArray(result.Items)) {\n throw new WebinyError(\n \"Error when querying for content entries - no result.\",\n \"QUERY_ERROR\",\n {\n partitionKey,\n options\n }\n );\n }\n return {\n result,\n items: result.Items\n };\n};\n/**\n * Will run the query to fetch the first possible item from the database.\n */\nexport const queryOne = async <T>(params: QueryOneParams): Promise<DbItem<T> | null> => {\n const { items } = await query<DbItem<T>>({\n ...params,\n options: {\n ...(params.options || {}),\n limit: 1\n }\n });\n const item = items.shift();\n return item ? item : null;\n};\n/**\n * Will run the query to fetch the results no matter how much iterations it needs to go through.\n */\nexport const queryAll = async <T>(params: QueryAllParams): Promise<DbItem<T>[]> => {\n const items: DbItem<T>[] = [];\n let results: QueryResult<DbItem<T>>;\n let previousResult: any = undefined;\n while ((results = await query({ ...params, previous: previousResult }))) {\n items.push(...results.items);\n if (!results.result) {\n return items;\n }\n previousResult = results.result;\n }\n return items;\n};\n"],"mappings":";;;;;;;;;;;AACA;;AA8BA;AACA;AACA;AACA;AACA;AACA,MAAMA,KAAK,GAAG,MAAUC,MAAV,IAA2D;EACrE,MAAM;IAAEC,MAAF;IAAUC,QAAV;IAAoBC,YAApB;IAAkCC;EAAlC,IAA8CJ,MAApD;EACA,IAAIK,MAAJ;EACA;AACJ;AACA;AACA;;EACI,IAAI,CAACH,QAAL,EAAe;IACXG,MAAM,GAAG,MAAMJ,MAAM,CAACF,KAAP,CAAaI,YAAb,EAA2BC,OAA3B,CAAf;EACH,CAFD,MAEO,IAAI,OAAOF,QAAQ,CAACI,IAAhB,KAAyB,UAA7B,EAAyC;IAC5C;AACR;AACA;AACA;AACA;IACQD,MAAM,GAAG,MAAMH,QAAQ,CAACI,IAAT,EAAf;;IACA,IAAID,MAAM,KAAK,KAAf,EAAsB;MAClB,OAAO;QACHA,MAAM,EAAE,IADL;QAEHE,KAAK,EAAE;MAFJ,CAAP;IAIH;EACJ,CAbM,MAaA;IACH;AACR;AACA;AACA;AACA;IACQ,OAAO;MACHF,MAAM,EAAE,IADL;MAEHE,KAAK,EAAE;IAFJ,CAAP;EAIH;EACD;AACJ;AACA;;;EACI,IAAI,CAACF,MAAD,IAAW,CAACA,MAAM,CAACG,KAAnB,IAA4B,CAACC,KAAK,CAACC,OAAN,CAAcL,MAAM,CAACG,KAArB,CAAjC,EAA8D;IAC1D,MAAM,IAAIG,cAAJ,CACF,sDADE,EAEF,aAFE,EAGF;MACIR,YADJ;MAEIC;IAFJ,CAHE,CAAN;EAQH;;EACD,OAAO;IACHC,MADG;IAEHE,KAAK,EAAEF,MAAM,CAACG;EAFX,CAAP;AAIH,CAlDD;AAmDA;AACA;AACA;;;AACO,MAAMI,QAAQ,GAAG,MAAUZ,MAAV,IAAgE;EACpF,MAAM;IAAEO;EAAF,IAAY,MAAMR,KAAK,6DACtBC,MADsB;IAEzBI,OAAO,8DACCJ,MAAM,CAACI,OAAP,IAAkB,EADnB;MAEHS,KAAK,EAAE;IAFJ;EAFkB,GAA7B;EAOA,MAAMC,IAAI,GAAGP,KAAK,CAACQ,KAAN,EAAb;EACA,OAAOD,IAAI,GAAGA,IAAH,GAAU,IAArB;AACH,CAVM;AAWP;AACA;AACA;;;;;AACO,MAAME,QAAQ,GAAG,MAAUhB,MAAV,IAA2D;EAC/E,MAAMO,KAAkB,GAAG,EAA3B;EACA,IAAIU,OAAJ;EACA,IAAIC,cAAmB,GAAGC,SAA1B;;EACA,OAAQF,OAAO,GAAG,MAAMlB,KAAK,6DAAMC,MAAN;IAAcE,QAAQ,EAAEgB;EAAxB,GAA7B,EAAyE;IACrEX,KAAK,CAACa,IAAN,CAAW,GAAGH,OAAO,CAACV,KAAtB;;IACA,IAAI,CAACU,OAAO,CAACZ,MAAb,EAAqB;MACjB,OAAOE,KAAP;IACH;;IACDW,cAAc,GAAGD,OAAO,CAACZ,MAAzB;EACH;;EACD,OAAOE,KAAP;AACH,CAZM"}
package/utils/sort.d.ts CHANGED
@@ -7,11 +7,11 @@ interface Params<T> {
7
7
  /**
8
8
  * Sort options. For example: ["id_ASC"]
9
9
  */
10
- sort: string[];
10
+ sort?: string[];
11
11
  /**
12
12
  * Fields we can sort by.
13
13
  */
14
14
  fields?: FieldPlugin[];
15
15
  }
16
- export declare const sortItems: <T extends unknown = any>(params: Params<T>) => T[];
16
+ export declare function sortItems<T = any>(params: Params<T>): T[];
17
17
  export {};
package/utils/sort.js CHANGED
@@ -1,11 +1,11 @@
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
- exports.sortItems = void 0;
8
+ exports.sortItems = sortItems;
9
9
 
10
10
  var _orderBy = _interopRequireDefault(require("lodash/orderBy"));
11
11
 
@@ -46,7 +46,7 @@ const extractSort = (sortBy, fields) => {
46
46
  };
47
47
  };
48
48
 
49
- const sortItems = params => {
49
+ function sortItems(params) {
50
50
  const {
51
51
  items,
52
52
  sort: initialSort = [],
@@ -88,6 +88,4 @@ const sortItems = params => {
88
88
  }
89
89
 
90
90
  return (0, _orderBy.default)(items, info.sorters, info.orders);
91
- };
92
-
93
- exports.sortItems = sortItems;
91
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["extractSort","sortBy","fields","result","split","length","WebinyError","field","order","fieldPlugin","find","f","getField","isSortable","reverse","toUpperCase","sortItems","params","items","sort","initialSort","Array","isArray","info","sorters","orders","path","getPath","push","lodashOrderBy"],"sources":["sort.ts"],"sourcesContent":["import lodashOrderBy from \"lodash/orderBy\";\nimport WebinyError from \"@webiny/error\";\nimport { FieldPlugin } from \"~/plugins/definitions/FieldPlugin\";\n\ninterface Info {\n sorters: string[];\n orders: (boolean | \"asc\" | \"desc\")[];\n}\n\ninterface Response {\n reverse: boolean;\n field: string;\n}\n\nconst extractSort = (sortBy: string, fields: FieldPlugin[]): Response => {\n const result = sortBy.split(\"_\");\n if (result.length !== 2) {\n throw new WebinyError(\n \"Problem in determining the sorting for the entry items.\",\n \"SORT_ERROR\",\n {\n sortBy\n }\n );\n }\n const [field, order] = result;\n\n if (!field) {\n throw new WebinyError(\"Sorting field does not exist.\", \"SORTING_FIELD_ERROR\", {\n field,\n order,\n fields\n });\n }\n const fieldPlugin = fields.find(f => f.getField() === field);\n const isSortable = fieldPlugin ? fieldPlugin.isSortable() : true;\n if (isSortable === false) {\n throw new WebinyError(`Cannot sort by given field: \"${field}\".`, \"UNSUPPORTED_SORT_ERROR\", {\n fields,\n field\n });\n }\n\n return {\n field,\n reverse: order.toUpperCase() === \"DESC\"\n };\n};\n\ninterface Params<T> {\n /**\n * The items we are sorting.\n */\n items: T[];\n /**\n * Sort options. For example: [\"id_ASC\"]\n */\n sort?: string[];\n /**\n * Fields we can sort by.\n */\n fields?: FieldPlugin[];\n}\n\nexport function sortItems<T = any>(params: Params<T>): T[] {\n const { items, sort: initialSort = [], fields = [] } = params;\n /**\n * Skip sorting if nothing was passed to sort by or nothing to sort.\n */\n if (items.length <= 1 || Array.isArray(initialSort) === false || initialSort.length === 0) {\n return items;\n }\n\n const info: Info = {\n sorters: [],\n orders: []\n };\n\n for (const sort of initialSort) {\n /**\n * Possibly empty array item was passed.\n */\n if (!sort) {\n continue;\n }\n const { field, reverse } = extractSort(sort, fields);\n const fieldPlugin = fields.find(f => f.getField() === field);\n const path = fieldPlugin ? fieldPlugin.getPath() : field;\n\n info.sorters.push(path);\n info.orders.push(reverse === true ? \"desc\" : \"asc\");\n }\n\n if (info.sorters.length === 0) {\n return items;\n }\n\n return lodashOrderBy(items, info.sorters, info.orders);\n}\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAaA,MAAMA,WAAW,GAAG,CAACC,MAAD,EAAiBC,MAAjB,KAAqD;EACrE,MAAMC,MAAM,GAAGF,MAAM,CAACG,KAAP,CAAa,GAAb,CAAf;;EACA,IAAID,MAAM,CAACE,MAAP,KAAkB,CAAtB,EAAyB;IACrB,MAAM,IAAIC,cAAJ,CACF,yDADE,EAEF,YAFE,EAGF;MACIL;IADJ,CAHE,CAAN;EAOH;;EACD,MAAM,CAACM,KAAD,EAAQC,KAAR,IAAiBL,MAAvB;;EAEA,IAAI,CAACI,KAAL,EAAY;IACR,MAAM,IAAID,cAAJ,CAAgB,+BAAhB,EAAiD,qBAAjD,EAAwE;MAC1EC,KAD0E;MAE1EC,KAF0E;MAG1EN;IAH0E,CAAxE,CAAN;EAKH;;EACD,MAAMO,WAAW,GAAGP,MAAM,CAACQ,IAAP,CAAYC,CAAC,IAAIA,CAAC,CAACC,QAAF,OAAiBL,KAAlC,CAApB;EACA,MAAMM,UAAU,GAAGJ,WAAW,GAAGA,WAAW,CAACI,UAAZ,EAAH,GAA8B,IAA5D;;EACA,IAAIA,UAAU,KAAK,KAAnB,EAA0B;IACtB,MAAM,IAAIP,cAAJ,CAAiB,gCAA+BC,KAAM,IAAtD,EAA2D,wBAA3D,EAAqF;MACvFL,MADuF;MAEvFK;IAFuF,CAArF,CAAN;EAIH;;EAED,OAAO;IACHA,KADG;IAEHO,OAAO,EAAEN,KAAK,CAACO,WAAN,OAAwB;EAF9B,CAAP;AAIH,CAjCD;;AAkDO,SAASC,SAAT,CAA4BC,MAA5B,EAAoD;EACvD,MAAM;IAAEC,KAAF;IAASC,IAAI,EAAEC,WAAW,GAAG,EAA7B;IAAiClB,MAAM,GAAG;EAA1C,IAAiDe,MAAvD;EACA;AACJ;AACA;;EACI,IAAIC,KAAK,CAACb,MAAN,IAAgB,CAAhB,IAAqBgB,KAAK,CAACC,OAAN,CAAcF,WAAd,MAA+B,KAApD,IAA6DA,WAAW,CAACf,MAAZ,KAAuB,CAAxF,EAA2F;IACvF,OAAOa,KAAP;EACH;;EAED,MAAMK,IAAU,GAAG;IACfC,OAAO,EAAE,EADM;IAEfC,MAAM,EAAE;EAFO,CAAnB;;EAKA,KAAK,MAAMN,IAAX,IAAmBC,WAAnB,EAAgC;IAC5B;AACR;AACA;IACQ,IAAI,CAACD,IAAL,EAAW;MACP;IACH;;IACD,MAAM;MAAEZ,KAAF;MAASO;IAAT,IAAqBd,WAAW,CAACmB,IAAD,EAAOjB,MAAP,CAAtC;IACA,MAAMO,WAAW,GAAGP,MAAM,CAACQ,IAAP,CAAYC,CAAC,IAAIA,CAAC,CAACC,QAAF,OAAiBL,KAAlC,CAApB;IACA,MAAMmB,IAAI,GAAGjB,WAAW,GAAGA,WAAW,CAACkB,OAAZ,EAAH,GAA2BpB,KAAnD;IAEAgB,IAAI,CAACC,OAAL,CAAaI,IAAb,CAAkBF,IAAlB;IACAH,IAAI,CAACE,MAAL,CAAYG,IAAZ,CAAiBd,OAAO,KAAK,IAAZ,GAAmB,MAAnB,GAA4B,KAA7C;EACH;;EAED,IAAIS,IAAI,CAACC,OAAL,CAAanB,MAAb,KAAwB,CAA5B,EAA+B;IAC3B,OAAOa,KAAP;EACH;;EAED,OAAO,IAAAW,gBAAA,EAAcX,KAAd,EAAqBK,IAAI,CAACC,OAA1B,EAAmCD,IAAI,CAACE,MAAxC,CAAP;AACH"}
package/utils/table.js CHANGED
@@ -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":["getTable","context","db","WebinyError","table"],"sources":["table.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { DbContext } from \"@webiny/handler-db/types\";\n\n/**\n * Will be removed in favor of passing the table name directly to the storage operations.\n *\n * @deprecated\n */\nexport const getTable = <T extends DbContext>(context: T): string => {\n if (!context.db) {\n throw new WebinyError(\"Missing db on context.\", \"DB_ERROR\");\n } else if (!context.db.table) {\n throw new WebinyError(\"Missing table on context.db.\", \"TABLE_ERROR\");\n }\n return context.db.table;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAyBC,OAAtB,IAA6C;EACjE,IAAI,CAACA,OAAO,CAACC,EAAb,EAAiB;IACb,MAAM,IAAIC,cAAJ,CAAgB,wBAAhB,EAA0C,UAA1C,CAAN;EACH,CAFD,MAEO,IAAI,CAACF,OAAO,CAACC,EAAR,CAAWE,KAAhB,EAAuB;IAC1B,MAAM,IAAID,cAAJ,CAAgB,8BAAhB,EAAgD,aAAhD,CAAN;EACH;;EACD,OAAOF,OAAO,CAACC,EAAR,CAAWE,KAAlB;AACH,CAPM"}
@@ -1,8 +0,0 @@
1
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
2
- import { DbContext } from "@webiny/handler-db/types";
3
- /**
4
- * Will be removed in favor of directly passing the documentClient to the storage operations.
5
- *
6
- * @deprecated
7
- */
8
- export declare const getDocumentClient: <T extends DbContext>(context: T) => DocumentClient;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.getDocumentClient = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- /**
13
- * Will be removed in favor of directly passing the documentClient to the storage operations.
14
- *
15
- * @deprecated
16
- */
17
- const getDocumentClient = context => {
18
- if (!context.db) {
19
- throw new _error.default("Missing db on context.", "DB_ERROR");
20
- } else if (!context.db.driver) {
21
- throw new _error.default(`Missing driver on the context.db property.`, "DRIVER_ERROR");
22
- }
23
-
24
- const driver = context.db.driver;
25
-
26
- if (!driver.documentClient) {
27
- throw new _error.default(`Missing documentClient on the context.db.driver property.`, "DOCUMENT_CLIENT_ERROR");
28
- }
29
-
30
- return driver.documentClient;
31
- };
32
-
33
- exports.getDocumentClient = getDocumentClient;