@webiny/db-dynamodb 0.0.0-unstable.990c3ab1b6 → 0.0.0-unstable.aa00eecd97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BatchProcess.d.ts +1 -1
- package/index.d.ts +2 -0
- package/index.js +24 -1
- package/index.js.map +1 -1
- package/package.json +17 -17
- package/plugins/filters/andIn.d.ts +2 -2
- package/plugins/filters/andIn.js +3 -1
- package/plugins/filters/andIn.js.map +1 -1
- package/plugins/filters/between.d.ts +2 -2
- package/plugins/filters/between.js +3 -1
- package/plugins/filters/between.js.map +1 -1
- package/plugins/filters/contains.d.ts +2 -2
- package/plugins/filters/contains.js +3 -1
- package/plugins/filters/contains.js.map +1 -1
- package/plugins/filters/eq.d.ts +2 -2
- package/plugins/filters/eq.js +3 -1
- package/plugins/filters/eq.js.map +1 -1
- package/plugins/filters/fuzzy.d.ts +2 -2
- package/plugins/filters/fuzzy.js +3 -1
- package/plugins/filters/fuzzy.js.map +1 -1
- package/plugins/filters/gt.d.ts +2 -2
- package/plugins/filters/gt.js +3 -1
- package/plugins/filters/gt.js.map +1 -1
- package/plugins/filters/gte.d.ts +2 -2
- package/plugins/filters/gte.js +3 -1
- package/plugins/filters/gte.js.map +1 -1
- package/plugins/filters/in.d.ts +2 -2
- package/plugins/filters/in.js +3 -1
- package/plugins/filters/in.js.map +1 -1
- package/plugins/filters/lt.d.ts +2 -2
- package/plugins/filters/lt.js +3 -1
- package/plugins/filters/lt.js.map +1 -1
- package/plugins/filters/lte.d.ts +2 -2
- package/plugins/filters/lte.js +3 -1
- package/plugins/filters/lte.js.map +1 -1
- package/plugins/filters/startsWith.d.ts +2 -2
- package/plugins/filters/startsWith.js +3 -1
- package/plugins/filters/startsWith.js.map +1 -1
- package/types.d.ts +8 -0
- package/types.js.map +1 -1
- package/utils/createStandardEntity.d.ts +2 -0
- package/utils/createStandardEntity.js +34 -0
- package/utils/createStandardEntity.js.map +1 -0
- package/utils/index.d.ts +11 -0
- package/utils/index.js +126 -0
- package/utils/index.js.map +1 -0
- package/utils/query.d.ts +6 -1
- package/utils/query.js +22 -3
- package/utils/query.js.map +1 -1
package/BatchProcess.d.ts
CHANGED
|
@@ -42,6 +42,6 @@ declare class BatchProcess {
|
|
|
42
42
|
addBatchDelete(args: AddBatchOperationArgs): AddBatchOperationResponse;
|
|
43
43
|
addBatchGet(args: AddBatchOperationArgs): AddBatchOperationResponse;
|
|
44
44
|
allOperationsAdded(): boolean;
|
|
45
|
-
startExecution(): import("aws-sdk/lib/request").Request<DocumentClient.
|
|
45
|
+
startExecution(): import("aws-sdk/lib/request").Request<DocumentClient.BatchGetItemOutput, import("aws-sdk/lib/error").AWSError> | import("aws-sdk/lib/request").Request<DocumentClient.BatchWriteItemOutput, import("aws-sdk/lib/error").AWSError>;
|
|
46
46
|
}
|
|
47
47
|
export default BatchProcess;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -4,10 +4,33 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
var _exportNames = {
|
|
8
|
+
DynamoDbDriver: true,
|
|
9
|
+
DbItem: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "DbItem", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _types.DbItem;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
7
17
|
Object.defineProperty(exports, "DynamoDbDriver", {
|
|
8
18
|
enumerable: true,
|
|
9
19
|
get: function () {
|
|
10
20
|
return _DynamoDbDriver.default;
|
|
11
21
|
}
|
|
12
22
|
});
|
|
13
|
-
var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
|
|
23
|
+
var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
|
|
24
|
+
var _utils = require("./utils");
|
|
25
|
+
Object.keys(_utils).forEach(function (key) {
|
|
26
|
+
if (key === "default" || key === "__esModule") return;
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
29
|
+
Object.defineProperty(exports, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () {
|
|
32
|
+
return _utils[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
var _types = require("./types");
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\n\nexport { DynamoDbDriver };\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\nexport * from \"./utils\";\nexport { DbItem } from \"./types\";\n\nexport { DynamoDbDriver };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/db-dynamodb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.aa00eecd97",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"author": "Webiny Ltd",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/api": "0.0.0-unstable.
|
|
14
|
-
"@webiny/db": "0.0.0-unstable.
|
|
15
|
-
"@webiny/error": "0.0.0-unstable.
|
|
16
|
-
"@webiny/handler-db": "0.0.0-unstable.
|
|
17
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
13
|
+
"@webiny/api": "0.0.0-unstable.aa00eecd97",
|
|
14
|
+
"@webiny/db": "0.0.0-unstable.aa00eecd97",
|
|
15
|
+
"@webiny/error": "0.0.0-unstable.aa00eecd97",
|
|
16
|
+
"@webiny/handler-db": "0.0.0-unstable.aa00eecd97",
|
|
17
|
+
"@webiny/plugins": "0.0.0-unstable.aa00eecd97",
|
|
18
18
|
"date-fns": "2.29.3",
|
|
19
19
|
"dot-prop": "6.0.1",
|
|
20
20
|
"fuse.js": "6.6.2",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"lodash": "4.17.21"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "
|
|
26
|
-
"@babel/core": "
|
|
27
|
-
"@types/is-number": "
|
|
28
|
-
"@webiny/cli": "
|
|
29
|
-
"@webiny/project-utils": "
|
|
30
|
-
"dynamodb-toolbox": "
|
|
31
|
-
"jest": "
|
|
32
|
-
"jest-dynalite": "
|
|
33
|
-
"rimraf": "
|
|
34
|
-
"ttypescript": "
|
|
25
|
+
"@babel/cli": "7.20.7",
|
|
26
|
+
"@babel/core": "7.20.12",
|
|
27
|
+
"@types/is-number": "7.0.3",
|
|
28
|
+
"@webiny/cli": "0.0.0-unstable.aa00eecd97",
|
|
29
|
+
"@webiny/project-utils": "0.0.0-unstable.aa00eecd97",
|
|
30
|
+
"dynamodb-toolbox": "0.3.5",
|
|
31
|
+
"jest": "28.1.3",
|
|
32
|
+
"jest-dynalite": "3.6.1",
|
|
33
|
+
"rimraf": "3.0.2",
|
|
34
|
+
"ttypescript": "1.5.15",
|
|
35
35
|
"typescript": "4.7.4"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"build": "yarn webiny run build",
|
|
43
43
|
"watch": "yarn webiny run watch"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "aa00eecd97d16da9bdb0581f33d491487ce43ce9"
|
|
46
46
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/andIn.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
|
|
10
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
11
11
|
operation: "and_in",
|
|
12
12
|
matches: ({
|
|
13
13
|
value,
|
|
@@ -25,4 +25,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
25
25
|
return compareValue.includes(value);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
+
plugin.name = "dynamodb.value.filter.and_in";
|
|
29
|
+
var _default = plugin;
|
|
28
30
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","WebinyError","every","c","includes"],"sources":["andIn.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface MatchesParams {\n value: any[];\n compareValue?: any[];\n}\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","WebinyError","every","c","includes","name"],"sources":["andIn.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface MatchesParams {\n value: any[];\n compareValue?: any[];\n}\n\nconst plugin = new ValueFilterPlugin({\n operation: \"and_in\",\n matches: ({ value, compareValue }: MatchesParams) => {\n if (!compareValue || Array.isArray(compareValue) === false) {\n throw new WebinyError(\n `The value given as \"compareValue\" must be an array!`,\n \"COMPARE_VALUE_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n if (Array.isArray(value) === true) {\n return compareValue.every(c => value.includes(c));\n }\n return compareValue.includes(value);\n }\n});\n\nplugin.name = \"dynamodb.value.filter.and_in\";\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;AACA;AAOA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,QAAQ;EACnBC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAA4B,CAAC,KAAK;IACjD,IAAI,CAACA,YAAY,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,KAAK,KAAK,EAAE;MACxD,MAAM,IAAIG,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,EACrB;QACIJ,KAAK;QACLC;MACJ,CAAC,CACJ;IACL;IACA,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAOC,YAAY,CAACI,KAAK,CAACC,CAAC,IAAIN,KAAK,CAACO,QAAQ,CAACD,CAAC,CAAC,CAAC;IACrD;IACA,OAAOL,YAAY,CAACM,QAAQ,CAACP,KAAK,CAAC;EACvC;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACY,IAAI,GAAG,8BAA8B;AAAC,eAE9BZ,MAAM;AAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
9
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
10
|
-
|
|
10
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
11
11
|
operation: "between",
|
|
12
12
|
matches: ({
|
|
13
13
|
value,
|
|
@@ -26,4 +26,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
26
26
|
return value >= compareValue && value <= compareValue;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
+
plugin.name = "dynamodb.value.filter.between";
|
|
30
|
+
var _default = plugin;
|
|
29
31
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","length","WebinyError","from","to"],"sources":["between.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","length","WebinyError","from","to","name"],"sources":["between.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"between\",\n matches: ({ value, compareValue }) => {\n if (Array.isArray(compareValue)) {\n if (compareValue.length !== 2) {\n throw new WebinyError(\n \"When comparing between and you give an array, there must be two items in it.\",\n \"FILTER_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n const [from, to] = compareValue;\n return value >= from && value <= to;\n }\n return value >= compareValue && value <= compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.between\";\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;AACA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,SAAS;EACpBC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;MAC7B,IAAIA,YAAY,CAACG,MAAM,KAAK,CAAC,EAAE;QAC3B,MAAM,IAAIC,cAAW,CACjB,8EAA8E,EAC9E,cAAc,EACd;UACIL,KAAK;UACLC;QACJ,CAAC,CACJ;MACL;MACA,MAAM,CAACK,IAAI,EAAEC,EAAE,CAAC,GAAGN,YAAY;MAC/B,OAAOD,KAAK,IAAIM,IAAI,IAAIN,KAAK,IAAIO,EAAE;IACvC;IACA,OAAOP,KAAK,IAAIC,YAAY,IAAID,KAAK,IAAIC,YAAY;EACzD;AACJ,CAAC,CAAC;AAEFL,MAAM,CAACY,IAAI,GAAG,+BAA+B;AAAC,eAE/BZ,MAAM;AAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "contains",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -24,4 +24,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
24
24
|
return value.match(re) !== null;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
plugin.name = "dynamodb.value.filter.contains";
|
|
28
|
+
var _default = plugin;
|
|
27
29
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","re","RegExp","some","v","match"],"sources":["contains.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","re","RegExp","some","v","match","name"],"sources":["contains.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"contains\",\n matches: ({ value, compareValue }) => {\n if (typeof value !== \"string\") {\n if (Array.isArray(value) === true) {\n const re = new RegExp(compareValue, \"i\");\n return value.some((v: string) => {\n return v.match(re) !== null;\n });\n }\n return false;\n }\n const re = new RegExp(compareValue, \"i\");\n return value.match(re) !== null;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.contains\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,UAAU;EACrBC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC3B,IAAIE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;QAC/B,MAAMI,EAAE,GAAG,IAAIC,MAAM,CAACJ,YAAY,EAAE,GAAG,CAAC;QACxC,OAAOD,KAAK,CAACM,IAAI,CAAEC,CAAS,IAAK;UAC7B,OAAOA,CAAC,CAACC,KAAK,CAACJ,EAAE,CAAC,KAAK,IAAI;QAC/B,CAAC,CAAC;MACN;MACA,OAAO,KAAK;IAChB;IACA,MAAMA,EAAE,GAAG,IAAIC,MAAM,CAACJ,YAAY,EAAE,GAAG,CAAC;IACxC,OAAOD,KAAK,CAACQ,KAAK,CAACJ,EAAE,CAAC,KAAK,IAAI;EACnC;AACJ,CAAC,CAAC;AAEFR,MAAM,CAACa,IAAI,GAAG,gCAAgC;AAAC,eAEhCb,MAAM;AAAA"}
|
package/plugins/filters/eq.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/eq.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "eq",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -26,4 +26,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
26
26
|
return value === compareValue;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
+
plugin.name = "dynamodb.value.filter.eq";
|
|
30
|
+
var _default = plugin;
|
|
29
31
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","some","v","includes","every"],"sources":["eq.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","some","v","includes","every","name"],"sources":["eq.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"eq\",\n matches: ({ value, compareValue }) => {\n /**\n * Possibility that either input value or one from the system is array.\n */\n if (Array.isArray(value) === true) {\n return value.some((v: string) => {\n return Array.isArray(compareValue) ? compareValue.includes(v) : compareValue === v;\n });\n } else if (Array.isArray(compareValue) === true) {\n return compareValue.every((v: string) => {\n return value === v;\n });\n }\n return value === compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.eq\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC;AACR;AACA;IACQ,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAOA,KAAK,CAACI,IAAI,CAAEC,CAAS,IAAK;QAC7B,OAAOH,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,GAAGA,YAAY,CAACK,QAAQ,CAACD,CAAC,CAAC,GAAGJ,YAAY,KAAKI,CAAC;MACtF,CAAC,CAAC;IACN,CAAC,MAAM,IAAIH,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,KAAK,IAAI,EAAE;MAC7C,OAAOA,YAAY,CAACM,KAAK,CAAEF,CAAS,IAAK;QACrC,OAAOL,KAAK,KAAKK,CAAC;MACtB,CAAC,CAAC;IACN;IACA,OAAOL,KAAK,KAAKC,YAAY;EACjC;AACJ,CAAC,CAAC;AAEFL,MAAM,CAACY,IAAI,GAAG,0BAA0B;AAAC,eAE1BZ,MAAM;AAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/fuzzy.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _fuse = _interopRequireDefault(require("fuse.js"));
|
|
9
9
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
10
|
-
|
|
10
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
11
11
|
operation: "fuzzy",
|
|
12
12
|
matches: ({
|
|
13
13
|
value,
|
|
@@ -21,4 +21,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
21
21
|
return result.length > 0;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
plugin.name = "dynamodb.value.filter.fuzzy";
|
|
25
|
+
var _default = plugin;
|
|
24
26
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","f","Fuse","result","search","length"],"sources":["fuzzy.ts"],"sourcesContent":["import Fuse from \"fuse.js\";\nimport {\n ValueFilterPluginParamsMatchesParams,\n ValueFilterPlugin\n} from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","f","Fuse","result","search","length","name"],"sources":["fuzzy.ts"],"sourcesContent":["import Fuse from \"fuse.js\";\nimport {\n ValueFilterPluginParamsMatchesParams,\n ValueFilterPlugin\n} from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"fuzzy\",\n matches: ({\n value,\n compareValue\n }: ValueFilterPluginParamsMatchesParams<string | null, string>) => {\n if (typeof value !== \"string\") {\n return false;\n }\n const f = new Fuse([value], {});\n const result = f.search(compareValue);\n\n return result.length > 0;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.fuzzy\";\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;AACA;AAKA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,OAAO;EAClBC,OAAO,EAAE,CAAC;IACNC,KAAK;IACLC;EACyD,CAAC,KAAK;IAC/D,IAAI,OAAOD,KAAK,KAAK,QAAQ,EAAE;MAC3B,OAAO,KAAK;IAChB;IACA,MAAME,CAAC,GAAG,IAAIC,aAAI,CAAC,CAACH,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,MAAMI,MAAM,GAAGF,CAAC,CAACG,MAAM,CAACJ,YAAY,CAAC;IAErC,OAAOG,MAAM,CAACE,MAAM,GAAG,CAAC;EAC5B;AACJ,CAAC,CAAC;AAEFV,MAAM,CAACW,IAAI,GAAG,6BAA6B;AAAC,eAE7BX,MAAM;AAAA"}
|
package/plugins/filters/gt.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/gt.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "gt",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -14,4 +14,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
14
14
|
return value > compareValue;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
+
plugin.name = "dynamodb.value.filter.gt";
|
|
18
|
+
var _default = plugin;
|
|
17
19
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue"],"sources":["gt.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","name"],"sources":["gt.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"gt\",\n matches: ({ value, compareValue }) => {\n return value > compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.gt\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,GAAGC,YAAY;EAC/B;AACJ,CAAC,CAAC;AAEFL,MAAM,CAACM,IAAI,GAAG,0BAA0B;AAAC,eAE1BN,MAAM;AAAA"}
|
package/plugins/filters/gte.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/gte.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "gte",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -14,4 +14,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
14
14
|
return value >= compareValue;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
+
plugin.name = "dynamodb.value.filter.gte";
|
|
18
|
+
var _default = plugin;
|
|
17
19
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue"],"sources":["gte.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","name"],"sources":["gte.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"gte\",\n matches: ({ value, compareValue }) => {\n return value >= compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.gte\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,KAAK;EAChBC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,IAAIC,YAAY;EAChC;AACJ,CAAC,CAAC;AAEFL,MAAM,CAACM,IAAI,GAAG,2BAA2B;AAAC,eAE3BN,MAAM;AAAA"}
|
package/plugins/filters/in.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/in.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
|
|
10
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
11
11
|
operation: "in",
|
|
12
12
|
matches: ({
|
|
13
13
|
value,
|
|
@@ -25,4 +25,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
25
25
|
return compareValue.includes(value);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
+
plugin.name = "dynamodb.value.filter.in";
|
|
29
|
+
var _default = plugin;
|
|
28
30
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","WebinyError","some","c","includes"],"sources":["in.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface MatchesParams {\n value: any[];\n compareValue?: any[];\n}\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","Array","isArray","WebinyError","some","c","includes","name"],"sources":["in.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface MatchesParams {\n value: any[];\n compareValue?: any[];\n}\n\nconst plugin = new ValueFilterPlugin({\n operation: \"in\",\n matches: ({ value, compareValue }: MatchesParams) => {\n if (!compareValue || Array.isArray(compareValue) === false) {\n throw new WebinyError(\n `The value given as \"compareValue\" must be an array!`,\n \"COMPARE_VALUE_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n if (Array.isArray(value) === true) {\n return compareValue.some(c => value.includes(c));\n }\n return compareValue.includes(value);\n }\n});\n\nplugin.name = \"dynamodb.value.filter.in\";\n\nexport default plugin;\n"],"mappings":";;;;;;;AAAA;AACA;AAOA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAA4B,CAAC,KAAK;IACjD,IAAI,CAACA,YAAY,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,KAAK,KAAK,EAAE;MACxD,MAAM,IAAIG,cAAW,CAChB,qDAAoD,EACrD,qBAAqB,EACrB;QACIJ,KAAK;QACLC;MACJ,CAAC,CACJ;IACL;IACA,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAOC,YAAY,CAACI,IAAI,CAACC,CAAC,IAAIN,KAAK,CAACO,QAAQ,CAACD,CAAC,CAAC,CAAC;IACpD;IACA,OAAOL,YAAY,CAACM,QAAQ,CAACP,KAAK,CAAC;EACvC;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACY,IAAI,GAAG,0BAA0B;AAAC,eAE1BZ,MAAM;AAAA"}
|
package/plugins/filters/lt.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/lt.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "lt",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -14,4 +14,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
14
14
|
return value < compareValue;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
+
plugin.name = "dynamodb.value.filter.lt";
|
|
18
|
+
var _default = plugin;
|
|
17
19
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue"],"sources":["lt.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","name"],"sources":["lt.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"lt\",\n matches: ({ value, compareValue }) => {\n return value < compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.lt\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,GAAGC,YAAY;EAC/B;AACJ,CAAC,CAAC;AAEFL,MAAM,CAACM,IAAI,GAAG,0BAA0B;AAAC,eAE1BN,MAAM;AAAA"}
|
package/plugins/filters/lte.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
package/plugins/filters/lte.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "lte",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -14,4 +14,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
14
14
|
return value <= compareValue;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
+
plugin.name = "dynamodb.value.filter.lte";
|
|
18
|
+
var _default = plugin;
|
|
17
19
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue"],"sources":["lte.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","name"],"sources":["lte.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"lte\",\n matches: ({ value, compareValue }) => {\n return value <= compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.lte\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,KAAK;EAChBC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,IAAIC,YAAY;EAChC;AACJ,CAAC,CAAC;AAEFL,MAAM,CAACM,IAAI,GAAG,2BAA2B;AAAC,eAE3BN,MAAM;AAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const plugin: ValueFilterPlugin;
|
|
3
|
+
export default plugin;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _ValueFilterPlugin = require("../definitions/ValueFilterPlugin");
|
|
8
|
-
|
|
8
|
+
const plugin = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
9
9
|
operation: "startsWith",
|
|
10
10
|
matches: ({
|
|
11
11
|
value,
|
|
@@ -24,4 +24,6 @@ var _default = new _ValueFilterPlugin.ValueFilterPlugin({
|
|
|
24
24
|
return value.toLowerCase().startsWith(compareValueInLowerCase);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
plugin.name = "dynamodb.value.filter.startsWith";
|
|
28
|
+
var _default = plugin;
|
|
27
29
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ValueFilterPlugin","operation","matches","value","compareValue","compareValueInLowerCase","toLowerCase","Array","isArray","some","v","startsWith"],"sources":["startsWith.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\
|
|
1
|
+
{"version":3,"names":["plugin","ValueFilterPlugin","operation","matches","value","compareValue","compareValueInLowerCase","toLowerCase","Array","isArray","some","v","startsWith","name"],"sources":["startsWith.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"startsWith\",\n matches: ({ value, compareValue }) => {\n /**\n * We do \"case-insensitive\" comparison.\n */\n const compareValueInLowerCase = compareValue.toLowerCase();\n\n if (typeof value !== \"string\") {\n if (Array.isArray(value) === true) {\n return value.some((v: string) =>\n v.toLowerCase().startsWith(compareValueInLowerCase)\n );\n }\n return false;\n }\n\n return value.toLowerCase().startsWith(compareValueInLowerCase);\n }\n});\n\nplugin.name = \"dynamodb.value.filter.startsWith\";\n\nexport default plugin;\n"],"mappings":";;;;;;AAAA;AAEA,MAAMA,MAAM,GAAG,IAAIC,oCAAiB,CAAC;EACjCC,SAAS,EAAE,YAAY;EACvBC,OAAO,EAAE,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC;AACR;AACA;IACQ,MAAMC,uBAAuB,GAAGD,YAAY,CAACE,WAAW,EAAE;IAE1D,IAAI,OAAOH,KAAK,KAAK,QAAQ,EAAE;MAC3B,IAAII,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;QAC/B,OAAOA,KAAK,CAACM,IAAI,CAAEC,CAAS,IACxBA,CAAC,CAACJ,WAAW,EAAE,CAACK,UAAU,CAACN,uBAAuB,CAAC,CACtD;MACL;MACA,OAAO,KAAK;IAChB;IAEA,OAAOF,KAAK,CAACG,WAAW,EAAE,CAACK,UAAU,CAACN,uBAAuB,CAAC;EAClE;AACJ,CAAC,CAAC;AAEFN,MAAM,CAACa,IAAI,GAAG,kCAAkC;AAAC,eAElCb,MAAM;AAAA"}
|
package/types.d.ts
CHANGED
|
@@ -55,4 +55,12 @@ export interface QueryKey {
|
|
|
55
55
|
}
|
|
56
56
|
export declare type QueryKeys = QueryKey[];
|
|
57
57
|
export declare type QuerySort = Record<string, -1 | 1>;
|
|
58
|
+
export declare type DbItem<TData extends Record<string, any> = Record<string, any>> = {
|
|
59
|
+
PK: string;
|
|
60
|
+
SK: string;
|
|
61
|
+
GSI1_PK: string;
|
|
62
|
+
GSI1_SK: string;
|
|
63
|
+
TYPE: string;
|
|
64
|
+
data: TData;
|
|
65
|
+
};
|
|
58
66
|
export {};
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface OperatorArgs {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\n\ninterface CanProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n}\n\ninterface ProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n processStatement: any;\n}\n\nexport interface Operator {\n canProcess: ({ key }: CanProcessArgs) => boolean;\n process: ({ key, value, args }: ProcessArgs) => void;\n}\n\n/**\n * We use this definition to search for a value in any given field that was passed.\n * It works as an \"OR\" condition.\n */\nexport interface DynamoDbContainsFilter {\n fields: string[];\n value: string;\n}\n\nexport interface ProcessStatementArgsParam {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\nexport interface ProcessStatementQueryParam {\n [key: string]: any;\n}\nexport interface ProcessStatementParams {\n args: ProcessStatementArgsParam;\n query: ProcessStatementQueryParam;\n}\n\nexport interface ProcessStatementCallable {\n (params: ProcessStatementParams): void;\n}\n\nexport interface Query {\n [key: string]: string;\n}\nexport interface QueryKeyField {\n name: string;\n}\nexport interface QueryKey {\n fields: QueryKeyField[];\n primary?: boolean;\n unique?: boolean;\n name: string;\n}\nexport type QueryKeys = QueryKey[];\n\nexport type QuerySort = Record<string, -1 | 1>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface OperatorArgs {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\n\ninterface CanProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n}\n\ninterface ProcessArgs {\n key: string;\n value: any;\n args: OperatorArgs;\n processStatement: any;\n}\n\nexport interface Operator {\n canProcess: ({ key }: CanProcessArgs) => boolean;\n process: ({ key, value, args }: ProcessArgs) => void;\n}\n\n/**\n * We use this definition to search for a value in any given field that was passed.\n * It works as an \"OR\" condition.\n */\nexport interface DynamoDbContainsFilter {\n fields: string[];\n value: string;\n}\n\nexport interface ProcessStatementArgsParam {\n expression: string;\n attributeNames: Record<string, any>;\n attributeValues: Record<string, any>;\n}\nexport interface ProcessStatementQueryParam {\n [key: string]: any;\n}\nexport interface ProcessStatementParams {\n args: ProcessStatementArgsParam;\n query: ProcessStatementQueryParam;\n}\n\nexport interface ProcessStatementCallable {\n (params: ProcessStatementParams): void;\n}\n\nexport interface Query {\n [key: string]: string;\n}\nexport interface QueryKeyField {\n name: string;\n}\nexport interface QueryKey {\n fields: QueryKeyField[];\n primary?: boolean;\n unique?: boolean;\n name: string;\n}\nexport type QueryKeys = QueryKey[];\n\nexport type QuerySort = Record<string, -1 | 1>;\n\nexport type DbItem<TData extends Record<string, any> = Record<string, any>> = {\n PK: string;\n SK: string;\n GSI1_PK: string;\n GSI1_SK: string;\n TYPE: string;\n data: TData;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createStandardEntity = void 0;
|
|
7
|
+
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
8
|
+
const createStandardEntity = (table, name) => {
|
|
9
|
+
return new _dynamodbToolbox.Entity({
|
|
10
|
+
name,
|
|
11
|
+
table,
|
|
12
|
+
attributes: {
|
|
13
|
+
PK: {
|
|
14
|
+
partitionKey: true
|
|
15
|
+
},
|
|
16
|
+
SK: {
|
|
17
|
+
sortKey: true
|
|
18
|
+
},
|
|
19
|
+
GSI1_PK: {
|
|
20
|
+
type: "string"
|
|
21
|
+
},
|
|
22
|
+
GSI1_SK: {
|
|
23
|
+
type: "string"
|
|
24
|
+
},
|
|
25
|
+
TYPE: {
|
|
26
|
+
type: "string"
|
|
27
|
+
},
|
|
28
|
+
data: {
|
|
29
|
+
type: "map"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
exports.createStandardEntity = createStandardEntity;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStandardEntity","table","name","Entity","attributes","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data"],"sources":["createStandardEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\n\nexport const createStandardEntity = (table: Table, name: string): Entity<any> => {\n return new Entity({\n name,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AAAA;AAEO,MAAMA,oBAAoB,GAAG,CAACC,KAAY,EAAEC,IAAY,KAAkB;EAC7E,OAAO,IAAIC,uBAAM,CAAC;IACdD,IAAI;IACJD,KAAK;IACLG,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./batchRead";
|
|
2
|
+
export * from "./batchWrite";
|
|
3
|
+
export * from "./cleanup";
|
|
4
|
+
export * from "./createStandardEntity";
|
|
5
|
+
export * from "./cursor";
|
|
6
|
+
export * from "./filter";
|
|
7
|
+
export * from "./get";
|
|
8
|
+
export * from "./listResponse";
|
|
9
|
+
export * from "./query";
|
|
10
|
+
export * from "./sort";
|
|
11
|
+
export * from "./table";
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _batchRead = require("./batchRead");
|
|
7
|
+
Object.keys(_batchRead).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _batchRead[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _batchRead[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _batchWrite = require("./batchWrite");
|
|
18
|
+
Object.keys(_batchWrite).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _batchWrite[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _batchWrite[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _cleanup = require("./cleanup");
|
|
29
|
+
Object.keys(_cleanup).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _cleanup[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _cleanup[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _createStandardEntity = require("./createStandardEntity");
|
|
40
|
+
Object.keys(_createStandardEntity).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _createStandardEntity[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _createStandardEntity[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _cursor = require("./cursor");
|
|
51
|
+
Object.keys(_cursor).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _cursor[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _cursor[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _filter = require("./filter");
|
|
62
|
+
Object.keys(_filter).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _filter[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _filter[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _get = require("./get");
|
|
73
|
+
Object.keys(_get).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _get[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _get[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _listResponse = require("./listResponse");
|
|
84
|
+
Object.keys(_listResponse).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _listResponse[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _listResponse[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _query = require("./query");
|
|
95
|
+
Object.keys(_query).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _query[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _query[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _sort = require("./sort");
|
|
106
|
+
Object.keys(_sort).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _sort[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _sort[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _table = require("./table");
|
|
117
|
+
Object.keys(_table).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _table[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _table[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./batchRead\";\nexport * from \"./batchWrite\";\nexport * from \"./cleanup\";\nexport * from \"./createStandardEntity\";\nexport * from \"./cursor\";\nexport * from \"./filter\";\nexport * from \"./get\";\nexport * from \"./listResponse\";\nexport * from \"./query\";\nexport * from \"./sort\";\nexport * from \"./table\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/utils/query.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export declare type DbItem<T> = T & {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const queryOne: <T>(params: QueryOneParams) => Promise<DbItem<T> | null>;
|
|
29
29
|
/**
|
|
30
|
-
* Will run the query to fetch the results no matter how
|
|
30
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
31
31
|
*/
|
|
32
32
|
export declare const queryAll: <T>(params: QueryAllParams) => Promise<DbItem<T>[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
35
|
+
* Results of each iteration will be passed to the provided callback
|
|
36
|
+
*/
|
|
37
|
+
export declare const queryAllWithCallback: <T>(params: QueryAllParams, callback: (items: DbItem<T>[]) => Promise<void>) => Promise<void>;
|
package/utils/query.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.queryOne = exports.queryAll = void 0;
|
|
7
|
+
exports.queryOne = exports.queryAllWithCallback = exports.queryAll = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
10
|
/**
|
|
@@ -79,7 +79,7 @@ const queryOne = async params => {
|
|
|
79
79
|
return item ? item : null;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* Will run the query to fetch the results no matter how
|
|
82
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
83
83
|
*/
|
|
84
84
|
exports.queryOne = queryOne;
|
|
85
85
|
const queryAll = async params => {
|
|
@@ -97,4 +97,23 @@ const queryAll = async params => {
|
|
|
97
97
|
}
|
|
98
98
|
return items;
|
|
99
99
|
};
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Will run the query to fetch the results no matter how many iterations it needs to go through.
|
|
103
|
+
* Results of each iteration will be passed to the provided callback
|
|
104
|
+
*/
|
|
105
|
+
exports.queryAll = queryAll;
|
|
106
|
+
const queryAllWithCallback = async (params, callback) => {
|
|
107
|
+
let results;
|
|
108
|
+
let previousResult = undefined;
|
|
109
|
+
while (results = await query((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
110
|
+
previous: previousResult
|
|
111
|
+
}))) {
|
|
112
|
+
if (!results.result) {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
await callback(results.items);
|
|
116
|
+
previousResult = results.result;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
exports.queryAllWithCallback = queryAllWithCallback;
|
package/utils/query.js.map
CHANGED
|
@@ -1 +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
|
|
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","queryAllWithCallback","callback"],"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 many 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\n/**\n * Will run the query to fetch the results no matter how many iterations it needs to go through.\n * Results of each iteration will be passed to the provided callback\n */\nexport const queryAllWithCallback = async <T>(\n params: QueryAllParams,\n callback: (items: DbItem<T>[]) => Promise<void>\n): Promise<void> => {\n let results: QueryResult<DbItem<T>>;\n let previousResult: any = undefined;\n while ((results = await query({ ...params, previous: previousResult }))) {\n if (!results.result) {\n break;\n }\n await callback(results.items);\n previousResult = results.result;\n }\n};\n"],"mappings":";;;;;;;;AACA;AA8BA;AACA;AACA;AACA;AACA;AACA,MAAMA,KAAK,GAAG,MAAUC,MAAmB,IAA8B;EACrE,MAAM;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAC1D,IAAIK,MAAM;EACV;AACJ;AACA;AACA;EACI,IAAI,CAACH,QAAQ,EAAE;IACXG,MAAM,GAAG,MAAMJ,MAAM,CAACF,KAAK,CAACI,YAAY,EAAEC,OAAO,CAAC;EACtD,CAAC,MAAM,IAAI,OAAOF,QAAQ,CAACI,IAAI,KAAK,UAAU,EAAE;IAC5C;AACR;AACA;AACA;AACA;IACQD,MAAM,GAAG,MAAMH,QAAQ,CAACI,IAAI,EAAE;IAC9B,IAAID,MAAM,KAAK,KAAK,EAAE;MAClB,OAAO;QACHA,MAAM,EAAE,IAAI;QACZE,KAAK,EAAE;MACX,CAAC;IACL;EACJ,CAAC,MAAM;IACH;AACR;AACA;AACA;AACA;IACQ,OAAO;MACHF,MAAM,EAAE,IAAI;MACZE,KAAK,EAAE;IACX,CAAC;EACL;EACA;AACJ;AACA;EACI,IAAI,CAACF,MAAM,IAAI,CAACA,MAAM,CAACG,KAAK,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,MAAM,CAACG,KAAK,CAAC,EAAE;IAC1D,MAAM,IAAIG,cAAW,CACjB,sDAAsD,EACtD,aAAa,EACb;MACIR,YAAY;MACZC;IACJ,CAAC,CACJ;EACL;EACA,OAAO;IACHC,MAAM;IACNE,KAAK,EAAEF,MAAM,CAACG;EAClB,CAAC;AACL,CAAC;AACD;AACA;AACA;AACO,MAAMI,QAAQ,GAAG,MAAUZ,MAAsB,IAAgC;EACpF,MAAM;IAAEO;EAAM,CAAC,GAAG,MAAMR,KAAK,6DACtBC,MAAM;IACTI,OAAO,8DACCJ,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MACxBS,KAAK,EAAE;IAAC;EACX,GACH;EACF,MAAMC,IAAI,GAAGP,KAAK,CAACQ,KAAK,EAAE;EAC1B,OAAOD,IAAI,GAAGA,IAAI,GAAG,IAAI;AAC7B,CAAC;AACD;AACA;AACA;AAFA;AAGO,MAAME,QAAQ,GAAG,MAAUhB,MAAsB,IAA2B;EAC/E,MAAMO,KAAkB,GAAG,EAAE;EAC7B,IAAIU,OAA+B;EACnC,IAAIC,cAAmB,GAAGC,SAAS;EACnC,OAAQF,OAAO,GAAG,MAAMlB,KAAK,6DAAMC,MAAM;IAAEE,QAAQ,EAAEgB;EAAc,GAAG,EAAG;IACrEX,KAAK,CAACa,IAAI,CAAC,GAAGH,OAAO,CAACV,KAAK,CAAC;IAC5B,IAAI,CAACU,OAAO,CAACZ,MAAM,EAAE;MACjB,OAAOE,KAAK;IAChB;IACAW,cAAc,GAAGD,OAAO,CAACZ,MAAM;EACnC;EACA,OAAOE,KAAK;AAChB,CAAC;;AAED;AACA;AACA;AACA;AAHA;AAIO,MAAMc,oBAAoB,GAAG,OAChCrB,MAAsB,EACtBsB,QAA+C,KAC/B;EAChB,IAAIL,OAA+B;EACnC,IAAIC,cAAmB,GAAGC,SAAS;EACnC,OAAQF,OAAO,GAAG,MAAMlB,KAAK,6DAAMC,MAAM;IAAEE,QAAQ,EAAEgB;EAAc,GAAG,EAAG;IACrE,IAAI,CAACD,OAAO,CAACZ,MAAM,EAAE;MACjB;IACJ;IACA,MAAMiB,QAAQ,CAACL,OAAO,CAACV,KAAK,CAAC;IAC7BW,cAAc,GAAGD,OAAO,CAACZ,MAAM;EACnC;AACJ,CAAC;AAAC"}
|