electrodb 2.10.1 → 2.10.2
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/package.json +11 -8
- package/src/clauses.js +26 -8
- package/src/entity.js +18 -8
- package/tsconfig.json +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electrodb",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
4
4
|
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build:browser": "browserify playground/browser.js -o playground/bundle.js",
|
|
9
9
|
"test": "./test.sh",
|
|
10
10
|
"test:ci": "npm install && npm test",
|
|
11
|
-
"test:run": "npm run test:
|
|
11
|
+
"test:run": "npm run test:types && npm run test:init && npm run test:unit",
|
|
12
12
|
"test:init": "node ./test/init.js",
|
|
13
13
|
"test:unit": "mocha -r ts-node/register ./test/**.spec.*",
|
|
14
14
|
"test:types": "tsd",
|
|
@@ -16,15 +16,16 @@
|
|
|
16
16
|
"coverage": "npm run test:init && nyc npm run test:unit && nyc report --reporter=text-lcov | coveralls",
|
|
17
17
|
"coverage:local:coveralls": "npm run test:init && nyc npm run test:unit && nyc report --reporter=text-lcov | coveralls",
|
|
18
18
|
"coverage:local:html": "npm run test:init && nyc npm run test:unit && nyc report --reporter=html",
|
|
19
|
-
"ddb:start": "docker compose up -d",
|
|
19
|
+
"ddb:start": "docker compose up -d dynamodb",
|
|
20
20
|
"ddb:load": "docker compose exec electro npm run test:init",
|
|
21
21
|
"ddb:stop": "docker compose stop",
|
|
22
22
|
"examples:load:library": "npm run ddb:start && npm run local:init && ts-node ./examples/library/load.ts",
|
|
23
23
|
"examples:query:library": "npm run ddb:start && npm run local:init && ts-node ./examples/library/query.ts",
|
|
24
|
-
"examples:load:taskmanager": "npm run ddb:start && npm run local:init && ts-node ./examples/
|
|
25
|
-
"examples:query:taskmanager": "npm run ddb:start && npm run local:init && ts-node ./examples/
|
|
26
|
-
"examples:load:versioncontrol": "npm run ddb:start && npm run local:init && ts-node ./examples/
|
|
27
|
-
"examples:query:versioncontrol": "npm run ddb:start && npm run local:init && ts-node ./examples/
|
|
24
|
+
"examples:load:taskmanager": "npm run ddb:start && npm run local:init && ts-node ./examples/taskManager/load.ts",
|
|
25
|
+
"examples:query:taskmanager": "npm run ddb:start && npm run local:init && ts-node ./examples/taskManager/query.ts",
|
|
26
|
+
"examples:load:versioncontrol": "npm run ddb:start && npm run local:init && ts-node ./examples/versionControl/load.ts",
|
|
27
|
+
"examples:query:versioncontrol": "npm run ddb:start && npm run local:init && ts-node ./examples/versionControl/query.ts",
|
|
28
|
+
"examples:provisiontable": "npm run ddb:start && npm run local:init && ts-node ./examples/provisionTable",
|
|
28
29
|
"examples:locks": "npm run ddb:start && npm run local:init && ts-node ./examples/locks",
|
|
29
30
|
"local:init": "LOCAL_DYNAMO_ENDPOINT='http://localhost:8000' npm run test:init",
|
|
30
31
|
"local:start": "npm run ddb:start && npm run local:init",
|
|
@@ -64,10 +65,12 @@
|
|
|
64
65
|
"prettier": "^3.0.3",
|
|
65
66
|
"prettier-plugin-astro": "^0.12.0",
|
|
66
67
|
"source-map-support": "^0.5.19",
|
|
68
|
+
"sst": "^2.28.0",
|
|
67
69
|
"ts-node": "^10.9.1",
|
|
68
70
|
"tsd": "^0.28.1",
|
|
69
71
|
"typescript": "^5.2.2",
|
|
70
|
-
"uuid": "7.0.1"
|
|
72
|
+
"uuid": "7.0.1",
|
|
73
|
+
"aws-cdk-lib": "^2.100.0"
|
|
71
74
|
},
|
|
72
75
|
"keywords": [
|
|
73
76
|
"electrodb",
|
package/src/clauses.js
CHANGED
|
@@ -973,12 +973,21 @@ let clauses = {
|
|
|
973
973
|
sk,
|
|
974
974
|
pk,
|
|
975
975
|
);
|
|
976
|
+
|
|
977
|
+
const accessPattern =
|
|
978
|
+
entity.model.translations.indexes.fromIndexToAccessPattern[
|
|
979
|
+
state.query.index
|
|
980
|
+
];
|
|
981
|
+
|
|
982
|
+
if (!entity.model.indexes[accessPattern].sk.isFieldRef) {
|
|
983
|
+
state.filterProperties(FilterOperationNames.lte, endingSk.composites);
|
|
984
|
+
}
|
|
985
|
+
|
|
976
986
|
return state
|
|
977
987
|
.setType(QueryTypes.and)
|
|
978
988
|
.setSK(endingSk.composites)
|
|
979
989
|
.setType(QueryTypes.between)
|
|
980
|
-
.setSK(startingSk.composites)
|
|
981
|
-
.filterProperties(FilterOperationNames.lte, endingSk.composites);
|
|
990
|
+
.setSK(startingSk.composites);
|
|
982
991
|
} catch (err) {
|
|
983
992
|
state.setError(err);
|
|
984
993
|
return state;
|
|
@@ -1019,9 +1028,14 @@ let clauses = {
|
|
|
1019
1028
|
pk,
|
|
1020
1029
|
);
|
|
1021
1030
|
state.setSK(composites);
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1031
|
+
const accessPattern =
|
|
1032
|
+
entity.model.translations.indexes.fromIndexToAccessPattern[
|
|
1033
|
+
state.query.index
|
|
1034
|
+
];
|
|
1035
|
+
|
|
1036
|
+
if (!entity.model.indexes[accessPattern].sk.isFieldRef) {
|
|
1037
|
+
state.filterProperties(FilterOperationNames.gt, composites);
|
|
1038
|
+
}
|
|
1025
1039
|
});
|
|
1026
1040
|
} catch (err) {
|
|
1027
1041
|
state.setError(err);
|
|
@@ -1086,9 +1100,13 @@ let clauses = {
|
|
|
1086
1100
|
pk,
|
|
1087
1101
|
);
|
|
1088
1102
|
state.setSK(composites);
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1103
|
+
const accessPattern =
|
|
1104
|
+
entity.model.translations.indexes.fromIndexToAccessPattern[
|
|
1105
|
+
state.query.index
|
|
1106
|
+
];
|
|
1107
|
+
if (!entity.model.indexes[accessPattern].sk.isFieldRef) {
|
|
1108
|
+
state.filterProperties(FilterOperationNames.lte, composites);
|
|
1109
|
+
}
|
|
1092
1110
|
});
|
|
1093
1111
|
} catch (err) {
|
|
1094
1112
|
state.setError(err);
|
package/src/entity.js
CHANGED
|
@@ -2724,8 +2724,9 @@ class Entity {
|
|
|
2724
2724
|
|
|
2725
2725
|
if (
|
|
2726
2726
|
this.model.lookup.indexHasSortKeys[index] &&
|
|
2727
|
-
typeof keyExpressions.ExpressionAttributeValues[":sk1"] === "
|
|
2728
|
-
|
|
2727
|
+
(typeof keyExpressions.ExpressionAttributeValues[":sk1"] === "number" ||
|
|
2728
|
+
(typeof keyExpressions.ExpressionAttributeValues[":sk1"] === "string" &&
|
|
2729
|
+
keyExpressions.ExpressionAttributeValues[":sk1"].length > 0))
|
|
2729
2730
|
) {
|
|
2730
2731
|
if (type === QueryTypes.is) {
|
|
2731
2732
|
KeyConditionExpression = `${KeyConditionExpression} and #sk1 = :sk1`;
|
|
@@ -2834,17 +2835,18 @@ class Entity {
|
|
|
2834
2835
|
filter = {},
|
|
2835
2836
|
indexKeys = {},
|
|
2836
2837
|
) {
|
|
2837
|
-
const { pk
|
|
2838
|
+
const { pk } = indexKeys;
|
|
2838
2839
|
const sk = indexKeys.sk[0];
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2840
|
+
|
|
2841
|
+
let operator =
|
|
2842
|
+
typeof sk === "number"
|
|
2843
|
+
? Comparisons[comparison]
|
|
2844
|
+
: PartialComparisons[comparison];
|
|
2843
2845
|
|
|
2844
2846
|
if (!operator) {
|
|
2845
2847
|
throw new Error(
|
|
2846
2848
|
`Unexpected comparison operator "${comparison}", expected ${u.commaSeparatedString(
|
|
2847
|
-
Object.values(
|
|
2849
|
+
Object.values(PartialComparisons),
|
|
2848
2850
|
)}`,
|
|
2849
2851
|
);
|
|
2850
2852
|
}
|
|
@@ -2853,6 +2855,7 @@ class Entity {
|
|
|
2853
2855
|
pk,
|
|
2854
2856
|
sk,
|
|
2855
2857
|
);
|
|
2858
|
+
|
|
2856
2859
|
let params = {
|
|
2857
2860
|
TableName: this.getTableName(),
|
|
2858
2861
|
ExpressionAttributeNames: this._mergeExpressionsAttributes(
|
|
@@ -4409,6 +4412,7 @@ class Entity {
|
|
|
4409
4412
|
getClient: () => this.client,
|
|
4410
4413
|
isRoot: true,
|
|
4411
4414
|
});
|
|
4415
|
+
|
|
4412
4416
|
let filters = this._normalizeFilters(model.filters);
|
|
4413
4417
|
// todo: consider a rename
|
|
4414
4418
|
let prefixes = this._normalizeKeyFixings({
|
|
@@ -4445,6 +4449,12 @@ class Entity {
|
|
|
4445
4449
|
labels,
|
|
4446
4450
|
attributes,
|
|
4447
4451
|
);
|
|
4452
|
+
for (let attributeName in schema.attributes) {
|
|
4453
|
+
const { field } = schema.attributes[attributeName];
|
|
4454
|
+
if (indexes[accessPattern][keyType].field === field) {
|
|
4455
|
+
indexes[accessPattern][keyType].isFieldRef = true;
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4448
4458
|
}
|
|
4449
4459
|
}
|
|
4450
4460
|
|
package/tsconfig.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
|
8
8
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
9
9
|
"lib": ["ESNext"], /* Specify library files to be included in the compilation. */
|
|
10
|
+
"resolveJsonModule": true,
|
|
10
11
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
12
|
// "checkJs": true, /* Report errors in .js files. */
|
|
12
13
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|