@webiny/db-dynamodb 0.0.0-ee-vpcs.549378cf03
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 +47 -0
- package/BatchProcess.js +198 -0
- package/BatchProcess.js.map +1 -0
- package/DynamoDbDriver.d.ts +35 -0
- package/DynamoDbDriver.js +274 -0
- package/DynamoDbDriver.js.map +1 -0
- package/LICENSE +21 -0
- package/QueryGenerator.d.ts +21 -0
- package/QueryGenerator.js +78 -0
- package/QueryGenerator.js.map +1 -0
- package/README.md +67 -0
- package/index.d.ts +2 -0
- package/index.js +15 -0
- package/index.js.map +1 -0
- package/operators/comparison/beginsWith.d.ts +3 -0
- package/operators/comparison/beginsWith.js +24 -0
- package/operators/comparison/beginsWith.js.map +1 -0
- package/operators/comparison/between.d.ts +3 -0
- package/operators/comparison/between.js +30 -0
- package/operators/comparison/between.js.map +1 -0
- package/operators/comparison/eq.d.ts +3 -0
- package/operators/comparison/eq.js +34 -0
- package/operators/comparison/eq.js.map +1 -0
- package/operators/comparison/gt.d.ts +3 -0
- package/operators/comparison/gt.js +24 -0
- package/operators/comparison/gt.js.map +1 -0
- package/operators/comparison/gte.d.ts +3 -0
- package/operators/comparison/gte.js +24 -0
- package/operators/comparison/gte.js.map +1 -0
- package/operators/comparison/lt.d.ts +3 -0
- package/operators/comparison/lt.js +24 -0
- package/operators/comparison/lt.js.map +1 -0
- package/operators/comparison/lte.d.ts +3 -0
- package/operators/comparison/lte.js +24 -0
- package/operators/comparison/lte.js.map +1 -0
- package/operators/index.d.ts +12 -0
- package/operators/index.js +39 -0
- package/operators/index.js.map +1 -0
- package/operators/logical/and.d.ts +3 -0
- package/operators/logical/and.js +63 -0
- package/operators/logical/and.js.map +1 -0
- package/operators/logical/or.d.ts +3 -0
- package/operators/logical/or.js +63 -0
- package/operators/logical/or.js.map +1 -0
- package/package.json +46 -0
- package/plugins/definitions/AttributePlugin.d.ts +20 -0
- package/plugins/definitions/AttributePlugin.js +61 -0
- package/plugins/definitions/AttributePlugin.js.map +1 -0
- package/plugins/definitions/DateTimeTransformPlugin.d.ts +4 -0
- package/plugins/definitions/DateTimeTransformPlugin.js +54 -0
- package/plugins/definitions/DateTimeTransformPlugin.js.map +1 -0
- package/plugins/definitions/FieldPathPlugin.d.ts +22 -0
- package/plugins/definitions/FieldPathPlugin.js +46 -0
- package/plugins/definitions/FieldPathPlugin.js.map +1 -0
- package/plugins/definitions/FieldPlugin.d.ts +34 -0
- package/plugins/definitions/FieldPlugin.js +73 -0
- package/plugins/definitions/FieldPlugin.js.map +1 -0
- package/plugins/definitions/NumberTransformPlugin.d.ts +4 -0
- package/plugins/definitions/NumberTransformPlugin.js +45 -0
- package/plugins/definitions/NumberTransformPlugin.js.map +1 -0
- package/plugins/definitions/TimeTransformPlugin.d.ts +4 -0
- package/plugins/definitions/TimeTransformPlugin.js +61 -0
- package/plugins/definitions/TimeTransformPlugin.js.map +1 -0
- package/plugins/definitions/ValueFilterPlugin.d.ts +20 -0
- package/plugins/definitions/ValueFilterPlugin.js +49 -0
- package/plugins/definitions/ValueFilterPlugin.js.map +1 -0
- package/plugins/definitions/ValueTransformPlugin.d.ts +22 -0
- package/plugins/definitions/ValueTransformPlugin.js +50 -0
- package/plugins/definitions/ValueTransformPlugin.js.map +1 -0
- package/plugins/definitions/assignFields.d.ts +1 -0
- package/plugins/definitions/assignFields.js +37 -0
- package/plugins/definitions/assignFields.js.map +1 -0
- package/plugins/filters/andIn.d.ts +3 -0
- package/plugins/filters/andIn.js +36 -0
- package/plugins/filters/andIn.js.map +1 -0
- package/plugins/filters/between.d.ts +3 -0
- package/plugins/filters/between.js +37 -0
- package/plugins/filters/between.js.map +1 -0
- package/plugins/filters/contains.d.ts +3 -0
- package/plugins/filters/contains.js +33 -0
- package/plugins/filters/contains.js.map +1 -0
- package/plugins/filters/eq.d.ts +3 -0
- package/plugins/filters/eq.js +34 -0
- package/plugins/filters/eq.js.map +1 -0
- package/plugins/filters/fuzzy.d.ts +3 -0
- package/plugins/filters/fuzzy.js +31 -0
- package/plugins/filters/fuzzy.js.map +1 -0
- package/plugins/filters/gt.d.ts +3 -0
- package/plugins/filters/gt.js +21 -0
- package/plugins/filters/gt.js.map +1 -0
- package/plugins/filters/gte.d.ts +3 -0
- package/plugins/filters/gte.js +21 -0
- package/plugins/filters/gte.js.map +1 -0
- package/plugins/filters/in.d.ts +3 -0
- package/plugins/filters/in.js +36 -0
- package/plugins/filters/in.js.map +1 -0
- package/plugins/filters/index.d.ts +2 -0
- package/plugins/filters/index.js +34 -0
- package/plugins/filters/index.js.map +1 -0
- package/plugins/filters/lt.d.ts +3 -0
- package/plugins/filters/lt.js +21 -0
- package/plugins/filters/lt.js.map +1 -0
- package/plugins/filters/lte.d.ts +3 -0
- package/plugins/filters/lte.js +21 -0
- package/plugins/filters/lte.js.map +1 -0
- package/plugins/filters/startsWith.d.ts +3 -0
- package/plugins/filters/startsWith.js +34 -0
- package/plugins/filters/startsWith.js.map +1 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +19 -0
- package/plugins/index.js.map +1 -0
- package/statements/createKeyConditionExpressionArgs.d.ts +15 -0
- package/statements/createKeyConditionExpressionArgs.js +52 -0
- package/statements/createKeyConditionExpressionArgs.js.map +1 -0
- package/statements/processStatement.d.ts +3 -0
- package/statements/processStatement.js +42 -0
- package/statements/processStatement.js.map +1 -0
- package/types.d.ts +58 -0
- package/types.js +5 -0
- package/types.js.map +1 -0
- package/utils/attributes.d.ts +10 -0
- package/utils/attributes.js +31 -0
- package/utils/attributes.js.map +1 -0
- package/utils/batchRead.d.ts +15 -0
- package/utils/batchRead.js +89 -0
- package/utils/batchRead.js.map +1 -0
- package/utils/batchWrite.d.ts +17 -0
- package/utils/batchWrite.js +30 -0
- package/utils/batchWrite.js.map +1 -0
- package/utils/cleanup.d.ts +3 -0
- package/utils/cleanup.js +45 -0
- package/utils/cleanup.js.map +1 -0
- package/utils/cursor.d.ts +2 -0
- package/utils/cursor.js +26 -0
- package/utils/cursor.js.map +1 -0
- package/utils/filter.d.ts +12 -0
- package/utils/filter.js +213 -0
- package/utils/filter.js.map +1 -0
- package/utils/get.d.ts +17 -0
- package/utils/get.js +30 -0
- package/utils/get.js.map +1 -0
- package/utils/listResponse.d.ts +13 -0
- package/utils/listResponse.js +33 -0
- package/utils/listResponse.js.map +1 -0
- package/utils/query.d.ts +32 -0
- package/utils/query.js +119 -0
- package/utils/query.js.map +1 -0
- package/utils/sort.d.ts +17 -0
- package/utils/sort.js +91 -0
- package/utils/sort.js.map +1 -0
- package/utils/table.d.ts +7 -0
- package/utils/table.js +27 -0
- package/utils/table.js.map +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _createKeyConditionExpressionArgs = _interopRequireDefault(require("./statements/createKeyConditionExpressionArgs"));
|
|
13
|
+
|
|
14
|
+
class QueryGenerator {
|
|
15
|
+
generate(params) {
|
|
16
|
+
const {
|
|
17
|
+
query,
|
|
18
|
+
keys,
|
|
19
|
+
sort,
|
|
20
|
+
limit,
|
|
21
|
+
tableName
|
|
22
|
+
} = params; // 1. Which key can we use in this query operation?
|
|
23
|
+
|
|
24
|
+
const key = this.findQueryKey(query, keys);
|
|
25
|
+
|
|
26
|
+
if (!key) {
|
|
27
|
+
throw new Error("Cannot perform query - key not found.");
|
|
28
|
+
} // 2. Now that we know the key, let's separate the key attributes from the rest.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const keyAttributesValues = {};
|
|
32
|
+
const nonKeyAttributesValues = {};
|
|
33
|
+
|
|
34
|
+
for (const queryKey in query) {
|
|
35
|
+
if (key.fields.find(item => item.name === queryKey)) {
|
|
36
|
+
keyAttributesValues[queryKey] = query[queryKey];
|
|
37
|
+
} else {
|
|
38
|
+
nonKeyAttributesValues[queryKey] = query[queryKey];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const keyConditionExpression = (0, _createKeyConditionExpressionArgs.default)({
|
|
43
|
+
query: keyAttributesValues,
|
|
44
|
+
sort,
|
|
45
|
+
key
|
|
46
|
+
});
|
|
47
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, keyConditionExpression), {}, {
|
|
48
|
+
TableName: tableName,
|
|
49
|
+
Limit: limit
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
findQueryKey(query = {}, keys = []) {
|
|
54
|
+
for (let i = 0; i < keys.length; i++) {
|
|
55
|
+
const key = keys[i];
|
|
56
|
+
let hasAllFields = true;
|
|
57
|
+
|
|
58
|
+
for (let j = 0; j < key.fields.length; j++) {
|
|
59
|
+
const field = key.fields[j];
|
|
60
|
+
|
|
61
|
+
if (!query[field.name]) {
|
|
62
|
+
hasAllFields = false;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (hasAllFields) {
|
|
68
|
+
return key;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var _default = QueryGenerator;
|
|
78
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["QueryGenerator","generate","params","query","keys","sort","limit","tableName","key","findQueryKey","Error","keyAttributesValues","nonKeyAttributesValues","queryKey","fields","find","item","name","keyConditionExpression","createKeyConditionExpressionArgs","TableName","Limit","i","length","hasAllFields","j","field"],"sources":["QueryGenerator.ts"],"sourcesContent":["import createKeyConditionExpressionArgs from \"./statements/createKeyConditionExpressionArgs\";\nimport { Query, QueryKey, QueryKeyField, QueryKeys, QuerySort } from \"~/types\";\n\ninterface GenerateParams {\n query: Query;\n keys: QueryKeys;\n sort: QuerySort;\n limit: number;\n tableName: string;\n}\nclass QueryGenerator {\n generate(params: GenerateParams) {\n const { query, keys, sort, limit, tableName } = params;\n // 1. Which key can we use in this query operation?\n const key = this.findQueryKey(query, keys);\n\n if (!key) {\n throw new Error(\"Cannot perform query - key not found.\");\n }\n\n // 2. Now that we know the key, let's separate the key attributes from the rest.\n const keyAttributesValues: Record<string, string> = {};\n const nonKeyAttributesValues: Record<string, string> = {};\n for (const queryKey in query) {\n if (key.fields.find((item: QueryKeyField) => item.name === queryKey)) {\n keyAttributesValues[queryKey] = query[queryKey];\n } else {\n nonKeyAttributesValues[queryKey] = query[queryKey];\n }\n }\n\n const keyConditionExpression = createKeyConditionExpressionArgs({\n query: keyAttributesValues,\n sort,\n key\n });\n\n return { ...keyConditionExpression, TableName: tableName, Limit: limit };\n }\n\n findQueryKey(query: Query = {}, keys: QueryKeys = []): QueryKey | null {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n let hasAllFields = true;\n for (let j = 0; j < key.fields.length; j++) {\n const field = key.fields[j];\n if (!query[field.name]) {\n hasAllFields = false;\n break;\n }\n }\n\n if (hasAllFields) {\n return key;\n }\n }\n return null;\n }\n}\n\nexport default QueryGenerator;\n"],"mappings":";;;;;;;;;;;AAAA;;AAUA,MAAMA,cAAN,CAAqB;EACjBC,QAAQ,CAACC,MAAD,EAAyB;IAC7B,MAAM;MAAEC,KAAF;MAASC,IAAT;MAAeC,IAAf;MAAqBC,KAArB;MAA4BC;IAA5B,IAA0CL,MAAhD,CAD6B,CAE7B;;IACA,MAAMM,GAAG,GAAG,KAAKC,YAAL,CAAkBN,KAAlB,EAAyBC,IAAzB,CAAZ;;IAEA,IAAI,CAACI,GAAL,EAAU;MACN,MAAM,IAAIE,KAAJ,CAAU,uCAAV,CAAN;IACH,CAP4B,CAS7B;;;IACA,MAAMC,mBAA2C,GAAG,EAApD;IACA,MAAMC,sBAA8C,GAAG,EAAvD;;IACA,KAAK,MAAMC,QAAX,IAAuBV,KAAvB,EAA8B;MAC1B,IAAIK,GAAG,CAACM,MAAJ,CAAWC,IAAX,CAAiBC,IAAD,IAAyBA,IAAI,CAACC,IAAL,KAAcJ,QAAvD,CAAJ,EAAsE;QAClEF,mBAAmB,CAACE,QAAD,CAAnB,GAAgCV,KAAK,CAACU,QAAD,CAArC;MACH,CAFD,MAEO;QACHD,sBAAsB,CAACC,QAAD,CAAtB,GAAmCV,KAAK,CAACU,QAAD,CAAxC;MACH;IACJ;;IAED,MAAMK,sBAAsB,GAAG,IAAAC,yCAAA,EAAiC;MAC5DhB,KAAK,EAAEQ,mBADqD;MAE5DN,IAF4D;MAG5DG;IAH4D,CAAjC,CAA/B;IAMA,mEAAYU,sBAAZ;MAAoCE,SAAS,EAAEb,SAA/C;MAA0Dc,KAAK,EAAEf;IAAjE;EACH;;EAEDG,YAAY,CAACN,KAAY,GAAG,EAAhB,EAAoBC,IAAe,GAAG,EAAtC,EAA2D;IACnE,KAAK,IAAIkB,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGlB,IAAI,CAACmB,MAAzB,EAAiCD,CAAC,EAAlC,EAAsC;MAClC,MAAMd,GAAG,GAAGJ,IAAI,CAACkB,CAAD,CAAhB;MACA,IAAIE,YAAY,GAAG,IAAnB;;MACA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGjB,GAAG,CAACM,MAAJ,CAAWS,MAA/B,EAAuCE,CAAC,EAAxC,EAA4C;QACxC,MAAMC,KAAK,GAAGlB,GAAG,CAACM,MAAJ,CAAWW,CAAX,CAAd;;QACA,IAAI,CAACtB,KAAK,CAACuB,KAAK,CAACT,IAAP,CAAV,EAAwB;UACpBO,YAAY,GAAG,KAAf;UACA;QACH;MACJ;;MAED,IAAIA,YAAJ,EAAkB;QACd,OAAOhB,GAAP;MACH;IACJ;;IACD,OAAO,IAAP;EACH;;AA/CgB;;eAkDNR,c"}
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @webiny/db-dynamodb
|
|
2
|
+
[](https://www.npmjs.com/package/webiny-data-dynamodb)
|
|
3
|
+
[](https://www.npmjs.com/package/webiny-data-dynamodb)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
A set of frequently used data-dynamodb higher order functions.
|
|
8
|
+
|
|
9
|
+
For more information, please visit
|
|
10
|
+
[the official docs](https://github.com/doitadrian/data-dynamodb).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
```
|
|
14
|
+
yarn add @webiny/db-dynamodb
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Helper functions
|
|
19
|
+
We have a number [helper](./src/utils) functions that ease the use of either dynamodb-toolbox, filtering, sorting or just creating proper response.
|
|
20
|
+
|
|
21
|
+
#### [batchRead](./src/utils/batchRead.ts)
|
|
22
|
+
Read a batch of records from the DynamoDB table.
|
|
23
|
+
|
|
24
|
+
This function accepts [table](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Table.ts) and items, an array of objects created by [Entity.getBatch()](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Entity.ts#L313).
|
|
25
|
+
|
|
26
|
+
Internally it reads records until there are no more to read and returns a list of read records.
|
|
27
|
+
|
|
28
|
+
#### [batchWrite](./src/utils/batchWrite.ts)
|
|
29
|
+
Write a batch of records to the DynamoDB table.
|
|
30
|
+
|
|
31
|
+
This function accepts [table](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Table.ts) and items, an array of objects created by [Entity.putBatch()](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Entity.ts#L989).
|
|
32
|
+
It also accepts a number which defines a number of items to be written in one request. DO NOT put that number over the official DynamoDB maximum.
|
|
33
|
+
|
|
34
|
+
Internally it loops through the items received (in chunks of `maxChunks` parameter) and does not return anything.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#### [cleanupItem and cleanupItems](./src/utils/cleanup.ts)
|
|
38
|
+
Clean up records received from the DynamoDB table.
|
|
39
|
+
|
|
40
|
+
This function accepts [entity](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Entity.ts) and item to be cleaned up, in case of the cleanupItem.
|
|
41
|
+
In case of `cleanupItems` it accepts an array of items to clean up.
|
|
42
|
+
|
|
43
|
+
We use this to remove the properties that dynamodb-toolbox puts on the record automatically.
|
|
44
|
+
|
|
45
|
+
#### [get](./src/utils/get.ts)
|
|
46
|
+
Get a single record from the DynamoDB table with given keys.
|
|
47
|
+
|
|
48
|
+
This function accepts [entity](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Entity.ts) and keys to fetch the record by.
|
|
49
|
+
|
|
50
|
+
It returns either record or null. By default, [entity.get()](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Entity.ts#L281) returns a object with some meta data and `Item` property, which contains the record (or null if no record).
|
|
51
|
+
|
|
52
|
+
#### [queryOne and queryAll](./src/utils/query.ts)
|
|
53
|
+
Query the DynamoDB table for record(s) by given partition key and query options.
|
|
54
|
+
|
|
55
|
+
This function accepts [entity](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Entity.ts) to perform the query on, `partitionKey` to query by and [options](https://github.com/jeremydaly/dynamodb-toolbox/blob/main/src/classes/Table.ts#L65) to define the query parameters with.
|
|
56
|
+
|
|
57
|
+
The `queryAll` method accepts `limit`, a number with which you can load only a certain amount of records. The `queryOne` method does not have that property.
|
|
58
|
+
|
|
59
|
+
#### [filter](./src/utils/filter.ts)
|
|
60
|
+
Filter the DynamoDB records by given where condition.
|
|
61
|
+
|
|
62
|
+
This function accepts items (records) to be filtered, a definition of fields to filter by (not required by default if no field modification is required), where conditions (eg. `{published: true, date_gte: "2021-01-01"}`) and filtering plugins.
|
|
63
|
+
|
|
64
|
+
#### [sort](./src/utils/sort.ts)
|
|
65
|
+
Sort the DynamoDB records by given sort condition.
|
|
66
|
+
|
|
67
|
+
This function accepts items (records) to be sorted, sort options (eg. createdBy_ASC, id_DESC, etc.) and a definitions of fields to sort by (not required by default if no field modification is required).
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "DynamoDbDriver", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _DynamoDbDriver.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _DynamoDbDriver = _interopRequireDefault(require("./DynamoDbDriver"));
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { default as DynamoDbDriver } from \"./DynamoDbDriver\";\n\nexport { DynamoDbDriver };\n"],"mappings":";;;;;;;;;;;;;;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const beginsWith = {
|
|
8
|
+
canProcess: ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
return value && typeof value["$beginsWith"] !== "undefined";
|
|
12
|
+
},
|
|
13
|
+
process: ({
|
|
14
|
+
key,
|
|
15
|
+
value,
|
|
16
|
+
args
|
|
17
|
+
}) => {
|
|
18
|
+
args.expression += `begins_with (#${key}, :${key})`;
|
|
19
|
+
args.attributeNames[`#${key}`] = key;
|
|
20
|
+
args.attributeValues[`:${key}`] = value["$beginsWith"];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var _default = beginsWith;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["beginsWith","canProcess","value","process","key","args","expression","attributeNames","attributeValues"],"sources":["beginsWith.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst beginsWith: Operator = {\n canProcess: ({ value }) => {\n return value && typeof value[\"$beginsWith\"] !== \"undefined\";\n },\n process: ({ key, value, args }) => {\n args.expression += `begins_with (#${key}, :${key})`;\n args.attributeNames[`#${key}`] = key;\n args.attributeValues[`:${key}`] = value[\"$beginsWith\"];\n }\n};\n\nexport default beginsWith;\n"],"mappings":";;;;;;AAEA,MAAMA,UAAoB,GAAG;EACzBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAe;IACvB,OAAOA,KAAK,IAAI,OAAOA,KAAK,CAAC,aAAD,CAAZ,KAAgC,WAAhD;EACH,CAHwB;EAIzBC,OAAO,EAAE,CAAC;IAAEC,GAAF;IAAOF,KAAP;IAAcG;EAAd,CAAD,KAA0B;IAC/BA,IAAI,CAACC,UAAL,IAAoB,iBAAgBF,GAAI,MAAKA,GAAI,GAAjD;IACAC,IAAI,CAACE,cAAL,CAAqB,IAAGH,GAAI,EAA5B,IAAiCA,GAAjC;IACAC,IAAI,CAACG,eAAL,CAAsB,IAAGJ,GAAI,EAA7B,IAAkCF,KAAK,CAAC,aAAD,CAAvC;EACH;AARwB,CAA7B;eAWeF,U"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const between = {
|
|
8
|
+
canProcess: ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
return value && typeof value["$between"] !== "undefined";
|
|
12
|
+
},
|
|
13
|
+
process: ({
|
|
14
|
+
key,
|
|
15
|
+
value
|
|
16
|
+
}) => {
|
|
17
|
+
return {
|
|
18
|
+
statement: `#${key} BETWEEN :${key}Gte AND :${key}Lte`,
|
|
19
|
+
attributeNames: {
|
|
20
|
+
[`#${key}`]: key
|
|
21
|
+
},
|
|
22
|
+
attributeValues: {
|
|
23
|
+
[`:${key}Gte`]: value[0],
|
|
24
|
+
[`:${key}Lte`]: value[1]
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var _default = between;
|
|
30
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["between","canProcess","value","process","key","statement","attributeNames","attributeValues"],"sources":["between.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst between: Operator = {\n canProcess: ({ value }) => {\n return value && typeof value[\"$between\"] !== \"undefined\";\n },\n process: ({ key, value }) => {\n return {\n statement: `#${key} BETWEEN :${key}Gte AND :${key}Lte`,\n attributeNames: {\n [`#${key}`]: key\n },\n attributeValues: {\n [`:${key}Gte`]: value[0],\n [`:${key}Lte`]: value[1]\n }\n };\n }\n};\n\nexport default between;\n"],"mappings":";;;;;;AAEA,MAAMA,OAAiB,GAAG;EACtBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAe;IACvB,OAAOA,KAAK,IAAI,OAAOA,KAAK,CAAC,UAAD,CAAZ,KAA6B,WAA7C;EACH,CAHqB;EAItBC,OAAO,EAAE,CAAC;IAAEC,GAAF;IAAOF;EAAP,CAAD,KAAoB;IACzB,OAAO;MACHG,SAAS,EAAG,IAAGD,GAAI,aAAYA,GAAI,YAAWA,GAAI,KAD/C;MAEHE,cAAc,EAAE;QACZ,CAAE,IAAGF,GAAI,EAAT,GAAaA;MADD,CAFb;MAKHG,eAAe,EAAE;QACb,CAAE,IAAGH,GAAI,KAAT,GAAgBF,KAAK,CAAC,CAAD,CADR;QAEb,CAAE,IAAGE,GAAI,KAAT,GAAgBF,KAAK,CAAC,CAAD;MAFR;IALd,CAAP;EAUH;AAfqB,CAA1B;eAkBeF,O"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const validTypes = ["string", "boolean", "number"];
|
|
8
|
+
const eq = {
|
|
9
|
+
canProcess: ({
|
|
10
|
+
key,
|
|
11
|
+
value
|
|
12
|
+
}) => {
|
|
13
|
+
if (key && key.charAt(0) === "$") {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (value && typeof value["$eq"] !== "undefined") {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return validTypes.includes(typeof value);
|
|
22
|
+
},
|
|
23
|
+
process: ({
|
|
24
|
+
key,
|
|
25
|
+
value,
|
|
26
|
+
args
|
|
27
|
+
}) => {
|
|
28
|
+
args.expression += `#${key} = :${key}`;
|
|
29
|
+
args.attributeNames[`#${key}`] = key;
|
|
30
|
+
args.attributeValues[`:${key}`] = value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var _default = eq;
|
|
34
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["validTypes","eq","canProcess","key","value","charAt","includes","process","args","expression","attributeNames","attributeValues"],"sources":["eq.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst validTypes = [\"string\", \"boolean\", \"number\"];\n\nconst eq: Operator = {\n canProcess: ({ key, value }) => {\n if (key && key.charAt(0) === \"$\") {\n return false;\n }\n\n if (value && typeof value[\"$eq\"] !== \"undefined\") {\n return true;\n }\n\n return validTypes.includes(typeof value);\n },\n process: ({ key, value, args }) => {\n args.expression += `#${key} = :${key}`;\n args.attributeNames[`#${key}`] = key;\n args.attributeValues[`:${key}`] = value;\n }\n};\n\nexport default eq;\n"],"mappings":";;;;;;AAEA,MAAMA,UAAU,GAAG,CAAC,QAAD,EAAW,SAAX,EAAsB,QAAtB,CAAnB;AAEA,MAAMC,EAAY,GAAG;EACjBC,UAAU,EAAE,CAAC;IAAEC,GAAF;IAAOC;EAAP,CAAD,KAAoB;IAC5B,IAAID,GAAG,IAAIA,GAAG,CAACE,MAAJ,CAAW,CAAX,MAAkB,GAA7B,EAAkC;MAC9B,OAAO,KAAP;IACH;;IAED,IAAID,KAAK,IAAI,OAAOA,KAAK,CAAC,KAAD,CAAZ,KAAwB,WAArC,EAAkD;MAC9C,OAAO,IAAP;IACH;;IAED,OAAOJ,UAAU,CAACM,QAAX,CAAoB,OAAOF,KAA3B,CAAP;EACH,CAXgB;EAYjBG,OAAO,EAAE,CAAC;IAAEJ,GAAF;IAAOC,KAAP;IAAcI;EAAd,CAAD,KAA0B;IAC/BA,IAAI,CAACC,UAAL,IAAoB,IAAGN,GAAI,OAAMA,GAAI,EAArC;IACAK,IAAI,CAACE,cAAL,CAAqB,IAAGP,GAAI,EAA5B,IAAiCA,GAAjC;IACAK,IAAI,CAACG,eAAL,CAAsB,IAAGR,GAAI,EAA7B,IAAkCC,KAAlC;EACH;AAhBgB,CAArB;eAmBeH,E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const gt = {
|
|
8
|
+
canProcess: ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
return value && typeof value["$gt"] !== "undefined";
|
|
12
|
+
},
|
|
13
|
+
process: ({
|
|
14
|
+
key,
|
|
15
|
+
value,
|
|
16
|
+
args
|
|
17
|
+
}) => {
|
|
18
|
+
args.expression += `#${key} > :${key}`;
|
|
19
|
+
args.attributeNames[`#${key}`] = key;
|
|
20
|
+
args.attributeValues[`:${key}`] = value["$gt"];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var _default = gt;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["gt","canProcess","value","process","key","args","expression","attributeNames","attributeValues"],"sources":["gt.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst gt: Operator = {\n canProcess: ({ value }) => {\n return value && typeof value[\"$gt\"] !== \"undefined\";\n },\n process: ({ key, value, args }) => {\n args.expression += `#${key} > :${key}`;\n args.attributeNames[`#${key}`] = key;\n args.attributeValues[`:${key}`] = value[\"$gt\"];\n }\n};\n\nexport default gt;\n"],"mappings":";;;;;;AAEA,MAAMA,EAAY,GAAG;EACjBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAe;IACvB,OAAOA,KAAK,IAAI,OAAOA,KAAK,CAAC,KAAD,CAAZ,KAAwB,WAAxC;EACH,CAHgB;EAIjBC,OAAO,EAAE,CAAC;IAAEC,GAAF;IAAOF,KAAP;IAAcG;EAAd,CAAD,KAA0B;IAC/BA,IAAI,CAACC,UAAL,IAAoB,IAAGF,GAAI,OAAMA,GAAI,EAArC;IACAC,IAAI,CAACE,cAAL,CAAqB,IAAGH,GAAI,EAA5B,IAAiCA,GAAjC;IACAC,IAAI,CAACG,eAAL,CAAsB,IAAGJ,GAAI,EAA7B,IAAkCF,KAAK,CAAC,KAAD,CAAvC;EACH;AARgB,CAArB;eAWeF,E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const gte = {
|
|
8
|
+
canProcess: ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
return value && typeof value["$gte"] !== "undefined";
|
|
12
|
+
},
|
|
13
|
+
process: ({
|
|
14
|
+
key,
|
|
15
|
+
value,
|
|
16
|
+
args
|
|
17
|
+
}) => {
|
|
18
|
+
args.expression += `#${key} >= :${key}`;
|
|
19
|
+
args.attributeNames[`#${key}`] = key;
|
|
20
|
+
args.attributeValues[`:${key}`] = value["$gte"];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var _default = gte;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["gte","canProcess","value","process","key","args","expression","attributeNames","attributeValues"],"sources":["gte.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst gte: Operator = {\n canProcess: ({ value }) => {\n return value && typeof value[\"$gte\"] !== \"undefined\";\n },\n process: ({ key, value, args }) => {\n args.expression += `#${key} >= :${key}`;\n args.attributeNames[`#${key}`] = key;\n args.attributeValues[`:${key}`] = value[\"$gte\"];\n }\n};\n\nexport default gte;\n"],"mappings":";;;;;;AAEA,MAAMA,GAAa,GAAG;EAClBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAe;IACvB,OAAOA,KAAK,IAAI,OAAOA,KAAK,CAAC,MAAD,CAAZ,KAAyB,WAAzC;EACH,CAHiB;EAIlBC,OAAO,EAAE,CAAC;IAAEC,GAAF;IAAOF,KAAP;IAAcG;EAAd,CAAD,KAA0B;IAC/BA,IAAI,CAACC,UAAL,IAAoB,IAAGF,GAAI,QAAOA,GAAI,EAAtC;IACAC,IAAI,CAACE,cAAL,CAAqB,IAAGH,GAAI,EAA5B,IAAiCA,GAAjC;IACAC,IAAI,CAACG,eAAL,CAAsB,IAAGJ,GAAI,EAA7B,IAAkCF,KAAK,CAAC,MAAD,CAAvC;EACH;AARiB,CAAtB;eAWeF,G"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const lt = {
|
|
8
|
+
canProcess: ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
return value && typeof value["$lt"] !== "undefined";
|
|
12
|
+
},
|
|
13
|
+
process: ({
|
|
14
|
+
key,
|
|
15
|
+
value,
|
|
16
|
+
args
|
|
17
|
+
}) => {
|
|
18
|
+
args.expression += `#${key} < :${key}`;
|
|
19
|
+
args.attributeNames[`#${key}`] = key;
|
|
20
|
+
args.attributeValues[`:${key}`] = value["$lt"];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var _default = lt;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["lt","canProcess","value","process","key","args","expression","attributeNames","attributeValues"],"sources":["lt.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst lt: Operator = {\n canProcess: ({ value }) => {\n return value && typeof value[\"$lt\"] !== \"undefined\";\n },\n process: ({ key, value, args }) => {\n args.expression += `#${key} < :${key}`;\n args.attributeNames[`#${key}`] = key;\n args.attributeValues[`:${key}`] = value[\"$lt\"];\n }\n};\n\nexport default lt;\n"],"mappings":";;;;;;AAEA,MAAMA,EAAY,GAAG;EACjBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAe;IACvB,OAAOA,KAAK,IAAI,OAAOA,KAAK,CAAC,KAAD,CAAZ,KAAwB,WAAxC;EACH,CAHgB;EAIjBC,OAAO,EAAE,CAAC;IAAEC,GAAF;IAAOF,KAAP;IAAcG;EAAd,CAAD,KAA0B;IAC/BA,IAAI,CAACC,UAAL,IAAoB,IAAGF,GAAI,OAAMA,GAAI,EAArC;IACAC,IAAI,CAACE,cAAL,CAAqB,IAAGH,GAAI,EAA5B,IAAiCA,GAAjC;IACAC,IAAI,CAACG,eAAL,CAAsB,IAAGJ,GAAI,EAA7B,IAAkCF,KAAK,CAAC,KAAD,CAAvC;EACH;AARgB,CAArB;eAWeF,E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const lte = {
|
|
8
|
+
canProcess: ({
|
|
9
|
+
value
|
|
10
|
+
}) => {
|
|
11
|
+
return value && typeof value["$lte"] !== "undefined";
|
|
12
|
+
},
|
|
13
|
+
process: ({
|
|
14
|
+
key,
|
|
15
|
+
value,
|
|
16
|
+
args
|
|
17
|
+
}) => {
|
|
18
|
+
args.expression += `#${key} <= :${key}`;
|
|
19
|
+
args.attributeNames[`#${key}`] = key;
|
|
20
|
+
args.attributeValues[`:${key}`] = value["$lte"];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var _default = lte;
|
|
24
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["lte","canProcess","value","process","key","args","expression","attributeNames","attributeValues"],"sources":["lte.ts"],"sourcesContent":["import { Operator } from \"~/types\";\n\nconst lte: Operator = {\n canProcess: ({ value }) => {\n return value && typeof value[\"$lte\"] !== \"undefined\";\n },\n process: ({ key, value, args }) => {\n args.expression += `#${key} <= :${key}`;\n args.attributeNames[`#${key}`] = key;\n args.attributeValues[`:${key}`] = value[\"$lte\"];\n }\n};\n\nexport default lte;\n"],"mappings":";;;;;;AAEA,MAAMA,GAAa,GAAG;EAClBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAe;IACvB,OAAOA,KAAK,IAAI,OAAOA,KAAK,CAAC,MAAD,CAAZ,KAAyB,WAAzC;EACH,CAHiB;EAIlBC,OAAO,EAAE,CAAC;IAAEC,GAAF;IAAOF,KAAP;IAAcG;EAAd,CAAD,KAA0B;IAC/BA,IAAI,CAACC,UAAL,IAAoB,IAAGF,GAAI,QAAOA,GAAI,EAAtC;IACAC,IAAI,CAACE,cAAL,CAAqB,IAAGH,GAAI,EAA5B,IAAiCA,GAAjC;IACAC,IAAI,CAACG,eAAL,CAAsB,IAAGJ,GAAI,EAA7B,IAAkCF,KAAK,CAAC,MAAD,CAAvC;EACH;AARiB,CAAtB;eAWeF,G"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
$and: import("../types").Operator;
|
|
3
|
+
$or: import("../types").Operator;
|
|
4
|
+
$beginsWith: import("../types").Operator;
|
|
5
|
+
$between: import("../types").Operator;
|
|
6
|
+
$eq: import("../types").Operator;
|
|
7
|
+
$gt: import("../types").Operator;
|
|
8
|
+
$gte: import("../types").Operator;
|
|
9
|
+
$lt: import("../types").Operator;
|
|
10
|
+
$lte: import("../types").Operator;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _and = _interopRequireDefault(require("./logical/and"));
|
|
11
|
+
|
|
12
|
+
var _or = _interopRequireDefault(require("./logical/or"));
|
|
13
|
+
|
|
14
|
+
var _beginsWith = _interopRequireDefault(require("./comparison/beginsWith"));
|
|
15
|
+
|
|
16
|
+
var _between = _interopRequireDefault(require("./comparison/between"));
|
|
17
|
+
|
|
18
|
+
var _gt = _interopRequireDefault(require("./comparison/gt"));
|
|
19
|
+
|
|
20
|
+
var _gte = _interopRequireDefault(require("./comparison/gte"));
|
|
21
|
+
|
|
22
|
+
var _lt = _interopRequireDefault(require("./comparison/lt"));
|
|
23
|
+
|
|
24
|
+
var _lte = _interopRequireDefault(require("./comparison/lte"));
|
|
25
|
+
|
|
26
|
+
var _eq = _interopRequireDefault(require("./comparison/eq"));
|
|
27
|
+
|
|
28
|
+
var _default = {
|
|
29
|
+
$and: _and.default,
|
|
30
|
+
$or: _or.default,
|
|
31
|
+
$beginsWith: _beginsWith.default,
|
|
32
|
+
$between: _between.default,
|
|
33
|
+
$eq: _eq.default,
|
|
34
|
+
$gt: _gt.default,
|
|
35
|
+
$gte: _gte.default,
|
|
36
|
+
$lt: _lt.default,
|
|
37
|
+
$lte: _lte.default
|
|
38
|
+
};
|
|
39
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["$and","$or","$beginsWith","$between","$eq","$gt","$gte","$lt","$lte"],"sources":["index.ts"],"sourcesContent":["import $and from \"./logical/and\";\nimport $or from \"./logical/or\";\nimport $beginsWith from \"./comparison/beginsWith\";\nimport $between from \"./comparison/between\";\nimport $gt from \"./comparison/gt\";\nimport $gte from \"./comparison/gte\";\nimport $lt from \"./comparison/lt\";\nimport $lte from \"./comparison/lte\";\nimport $eq from \"./comparison/eq\";\n\nexport default {\n $and,\n $or,\n $beginsWith,\n $between,\n $eq,\n $gt,\n $gte,\n $lt,\n $lte\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;eAEe;EACXA,IAAI,EAAJA,YADW;EAEXC,GAAG,EAAHA,WAFW;EAGXC,WAAW,EAAXA,mBAHW;EAIXC,QAAQ,EAARA,gBAJW;EAKXC,GAAG,EAAHA,WALW;EAMXC,GAAG,EAAHA,WANW;EAOXC,IAAI,EAAJA,YAPW;EAQXC,GAAG,EAAHA,WARW;EASXC,IAAI,EAAJA;AATW,C"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
const processQuery = (query, andArgs, processStatement) => {
|
|
9
|
+
const args = {
|
|
10
|
+
expression: "",
|
|
11
|
+
attributeNames: {},
|
|
12
|
+
attributeValues: {}
|
|
13
|
+
};
|
|
14
|
+
processStatement({
|
|
15
|
+
args,
|
|
16
|
+
query
|
|
17
|
+
});
|
|
18
|
+
Object.assign(andArgs.attributeNames, args.attributeNames);
|
|
19
|
+
Object.assign(andArgs.attributeValues, args.attributeValues);
|
|
20
|
+
|
|
21
|
+
if (andArgs.expression === "") {
|
|
22
|
+
andArgs.expression = args.expression;
|
|
23
|
+
} else {
|
|
24
|
+
andArgs.expression += " and " + args.expression;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const and = {
|
|
29
|
+
canProcess: ({
|
|
30
|
+
key
|
|
31
|
+
}) => {
|
|
32
|
+
return key === "$and";
|
|
33
|
+
},
|
|
34
|
+
process: ({
|
|
35
|
+
value,
|
|
36
|
+
args,
|
|
37
|
+
processStatement
|
|
38
|
+
}) => {
|
|
39
|
+
const andArgs = {
|
|
40
|
+
expression: "",
|
|
41
|
+
attributeNames: {},
|
|
42
|
+
attributeValues: {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
for (let i = 0; i < value.length; i++) {
|
|
47
|
+
processQuery(value[i], andArgs, processStatement);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
for (const [andKey, andValue] of Object.entries(value)) {
|
|
51
|
+
processQuery({
|
|
52
|
+
[andKey]: andValue
|
|
53
|
+
}, andArgs, processStatement);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
args.expression += "(" + andArgs.expression + ")";
|
|
58
|
+
Object.assign(args.attributeNames, andArgs.attributeNames);
|
|
59
|
+
Object.assign(args.attributeValues, andArgs.attributeValues);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var _default = and;
|
|
63
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["processQuery","query","andArgs","processStatement","args","expression","attributeNames","attributeValues","Object","assign","and","canProcess","key","process","value","Array","isArray","i","length","andKey","andValue","entries"],"sources":["and.ts"],"sourcesContent":["import {\n Operator,\n ProcessStatementArgsParam,\n ProcessStatementCallable,\n ProcessStatementQueryParam\n} from \"~/types\";\n\nconst processQuery = (\n query: ProcessStatementQueryParam,\n andArgs: ProcessStatementArgsParam,\n processStatement: ProcessStatementCallable\n) => {\n const args: ProcessStatementArgsParam = {\n expression: \"\",\n attributeNames: {},\n attributeValues: {}\n };\n\n processStatement({ args, query });\n\n Object.assign(andArgs.attributeNames, args.attributeNames);\n Object.assign(andArgs.attributeValues, args.attributeValues);\n\n if (andArgs.expression === \"\") {\n andArgs.expression = args.expression;\n } else {\n andArgs.expression += \" and \" + args.expression;\n }\n};\n\nconst and: Operator = {\n canProcess: ({ key }) => {\n return key === \"$and\";\n },\n process: ({ value, args, processStatement }) => {\n const andArgs = {\n expression: \"\",\n attributeNames: {},\n attributeValues: {}\n };\n\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n processQuery(value[i], andArgs, processStatement);\n }\n } else {\n for (const [andKey, andValue] of Object.entries(value)) {\n processQuery({ [andKey]: andValue }, andArgs, processStatement);\n }\n }\n\n args.expression += \"(\" + andArgs.expression + \")\";\n Object.assign(args.attributeNames, andArgs.attributeNames);\n Object.assign(args.attributeValues, andArgs.attributeValues);\n }\n};\n\nexport default and;\n"],"mappings":";;;;;;;AAOA,MAAMA,YAAY,GAAG,CACjBC,KADiB,EAEjBC,OAFiB,EAGjBC,gBAHiB,KAIhB;EACD,MAAMC,IAA+B,GAAG;IACpCC,UAAU,EAAE,EADwB;IAEpCC,cAAc,EAAE,EAFoB;IAGpCC,eAAe,EAAE;EAHmB,CAAxC;EAMAJ,gBAAgB,CAAC;IAAEC,IAAF;IAAQH;EAAR,CAAD,CAAhB;EAEAO,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACI,cAAtB,EAAsCF,IAAI,CAACE,cAA3C;EACAE,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACK,eAAtB,EAAuCH,IAAI,CAACG,eAA5C;;EAEA,IAAIL,OAAO,CAACG,UAAR,KAAuB,EAA3B,EAA+B;IAC3BH,OAAO,CAACG,UAAR,GAAqBD,IAAI,CAACC,UAA1B;EACH,CAFD,MAEO;IACHH,OAAO,CAACG,UAAR,IAAsB,UAAUD,IAAI,CAACC,UAArC;EACH;AACJ,CArBD;;AAuBA,MAAMK,GAAa,GAAG;EAClBC,UAAU,EAAE,CAAC;IAAEC;EAAF,CAAD,KAAa;IACrB,OAAOA,GAAG,KAAK,MAAf;EACH,CAHiB;EAIlBC,OAAO,EAAE,CAAC;IAAEC,KAAF;IAASV,IAAT;IAAeD;EAAf,CAAD,KAAuC;IAC5C,MAAMD,OAAO,GAAG;MACZG,UAAU,EAAE,EADA;MAEZC,cAAc,EAAE,EAFJ;MAGZC,eAAe,EAAE;IAHL,CAAhB;;IAMA,IAAIQ,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAJ,EAA0B;MACtB,KAAK,IAAIG,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,KAAK,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAuC;QACnCjB,YAAY,CAACc,KAAK,CAACG,CAAD,CAAN,EAAWf,OAAX,EAAoBC,gBAApB,CAAZ;MACH;IACJ,CAJD,MAIO;MACH,KAAK,MAAM,CAACgB,MAAD,EAASC,QAAT,CAAX,IAAiCZ,MAAM,CAACa,OAAP,CAAeP,KAAf,CAAjC,EAAwD;QACpDd,YAAY,CAAC;UAAE,CAACmB,MAAD,GAAUC;QAAZ,CAAD,EAAyBlB,OAAzB,EAAkCC,gBAAlC,CAAZ;MACH;IACJ;;IAEDC,IAAI,CAACC,UAAL,IAAmB,MAAMH,OAAO,CAACG,UAAd,GAA2B,GAA9C;IACAG,MAAM,CAACC,MAAP,CAAcL,IAAI,CAACE,cAAnB,EAAmCJ,OAAO,CAACI,cAA3C;IACAE,MAAM,CAACC,MAAP,CAAcL,IAAI,CAACG,eAAnB,EAAoCL,OAAO,CAACK,eAA5C;EACH;AAxBiB,CAAtB;eA2BeG,G"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
const processQuery = (query, orArgs, processStatement) => {
|
|
9
|
+
const args = {
|
|
10
|
+
expression: "",
|
|
11
|
+
attributeNames: {},
|
|
12
|
+
attributeValues: {}
|
|
13
|
+
};
|
|
14
|
+
processStatement({
|
|
15
|
+
args,
|
|
16
|
+
query
|
|
17
|
+
});
|
|
18
|
+
Object.assign(orArgs.attributeNames, args.attributeNames);
|
|
19
|
+
Object.assign(orArgs.attributeValues, args.attributeValues);
|
|
20
|
+
|
|
21
|
+
if (orArgs.expression === "") {
|
|
22
|
+
orArgs.expression = args.expression;
|
|
23
|
+
} else {
|
|
24
|
+
orArgs.expression += " or " + args.expression;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const or = {
|
|
29
|
+
canProcess: ({
|
|
30
|
+
key
|
|
31
|
+
}) => {
|
|
32
|
+
return key === "$or";
|
|
33
|
+
},
|
|
34
|
+
process: ({
|
|
35
|
+
value,
|
|
36
|
+
args,
|
|
37
|
+
processStatement
|
|
38
|
+
}) => {
|
|
39
|
+
const orArgs = {
|
|
40
|
+
expression: "",
|
|
41
|
+
attributeNames: {},
|
|
42
|
+
attributeValues: {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
for (let i = 0; i < value.length; i++) {
|
|
47
|
+
processQuery(value[i], orArgs, processStatement);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
for (const [orKey, orValue] of Object.entries(value)) {
|
|
51
|
+
processQuery({
|
|
52
|
+
[orKey]: orValue
|
|
53
|
+
}, orArgs, processStatement);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
args.expression += "(" + orArgs.expression + ")";
|
|
58
|
+
Object.assign(args.attributeNames, orArgs.attributeNames);
|
|
59
|
+
Object.assign(args.attributeValues, orArgs.attributeValues);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var _default = or;
|
|
63
|
+
exports.default = _default;
|