@infra-blocks/aws-dynamodb 0.68.0 → 0.69.0
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/lib/cjs/commands/expressions/filter/comparison.d.ts +24 -0
- package/lib/cjs/commands/expressions/filter/comparison.js +21 -0
- package/lib/cjs/commands/expressions/filter/comparison.js.map +1 -0
- package/lib/cjs/commands/expressions/filter/filter.d.ts +39 -0
- package/lib/cjs/commands/expressions/filter/filter.js +17 -0
- package/lib/cjs/commands/expressions/filter/filter.js.map +1 -0
- package/lib/cjs/commands/expressions/filter/index.d.ts +2 -0
- package/lib/cjs/commands/expressions/filter/index.js +21 -0
- package/lib/cjs/commands/expressions/filter/index.js.map +1 -0
- package/lib/cjs/commands/expressions/functions/contains.d.ts +2 -2
- package/lib/cjs/commands/expressions/functions/contains.js +2 -2
- package/lib/cjs/commands/expressions/functions/contains.js.map +1 -1
- package/lib/cjs/commands/expressions/index.d.ts +1 -0
- package/lib/cjs/commands/expressions/index.js +1 -0
- package/lib/cjs/commands/expressions/index.js.map +1 -1
- package/lib/cjs/commands/inputs/query.d.ts +2 -1
- package/lib/cjs/commands/inputs/query.js +3 -0
- package/lib/cjs/commands/inputs/query.js.map +1 -1
- package/lib/esm/commands/expressions/filter/comparison.d.ts +24 -0
- package/lib/esm/commands/expressions/filter/comparison.js +17 -0
- package/lib/esm/commands/expressions/filter/comparison.js.map +1 -0
- package/lib/esm/commands/expressions/filter/filter.d.ts +39 -0
- package/lib/esm/commands/expressions/filter/filter.js +14 -0
- package/lib/esm/commands/expressions/filter/filter.js.map +1 -0
- package/lib/esm/commands/expressions/filter/index.d.ts +2 -0
- package/lib/esm/commands/expressions/filter/index.js +3 -0
- package/lib/esm/commands/expressions/filter/index.js.map +1 -0
- package/lib/esm/commands/expressions/functions/contains.d.ts +2 -2
- package/lib/esm/commands/expressions/functions/contains.js +2 -2
- package/lib/esm/commands/expressions/functions/contains.js.map +1 -1
- package/lib/esm/commands/expressions/index.d.ts +1 -0
- package/lib/esm/commands/expressions/index.js +1 -0
- package/lib/esm/commands/expressions/index.js.map +1 -1
- package/lib/esm/commands/inputs/query.d.ts +2 -1
- package/lib/esm/commands/inputs/query.js +4 -1
- package/lib/esm/commands/inputs/query.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/commands/expressions/condition/operand.d.ts +0 -7
- package/lib/cjs/commands/expressions/condition/operand.js +0 -8
- package/lib/cjs/commands/expressions/condition/operand.js.map +0 -1
- package/lib/esm/commands/expressions/condition/operand.d.ts +0 -7
- package/lib/esm/commands/expressions/condition/operand.js +0 -5
- package/lib/esm/commands/expressions/condition/operand.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Comparison, type ComparisonInput } from "../comparisons/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A type aggregating all values that can be used to produce a {@link FilterComparison}.
|
|
4
|
+
*
|
|
5
|
+
* Those include all available comparison expression inputs.
|
|
6
|
+
*
|
|
7
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.FilterExpression.html
|
|
8
|
+
*/
|
|
9
|
+
export type FilterComparisonInput = ComparisonInput;
|
|
10
|
+
export declare function isFilterComparisonInput(input: unknown): input is FilterComparisonInput;
|
|
11
|
+
/**
|
|
12
|
+
* The {@link ExpressionFormatter} equivalents to their respective {@link FilterComparisonInput}.
|
|
13
|
+
*/
|
|
14
|
+
export type FilterComparison = Comparison;
|
|
15
|
+
export declare const FilterComparison: {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a {@link FilterComparison} from the provided input.
|
|
18
|
+
*
|
|
19
|
+
* @param input - The {@link FilterComparison}'s input.
|
|
20
|
+
*
|
|
21
|
+
* @returns The corresponding {@link FilterComparison}.
|
|
22
|
+
*/
|
|
23
|
+
from(input: FilterComparisonInput): FilterComparison;
|
|
24
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterComparison = void 0;
|
|
4
|
+
exports.isFilterComparisonInput = isFilterComparisonInput;
|
|
5
|
+
const index_js_1 = require("../comparisons/index.js");
|
|
6
|
+
function isFilterComparisonInput(input) {
|
|
7
|
+
return (0, index_js_1.isComparisonInput)(input);
|
|
8
|
+
}
|
|
9
|
+
exports.FilterComparison = {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a {@link FilterComparison} from the provided input.
|
|
12
|
+
*
|
|
13
|
+
* @param input - The {@link FilterComparison}'s input.
|
|
14
|
+
*
|
|
15
|
+
* @returns The corresponding {@link FilterComparison}.
|
|
16
|
+
*/
|
|
17
|
+
from(input) {
|
|
18
|
+
return index_js_1.Comparison.from(input);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=comparison.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/filter/comparison.ts"],"names":[],"mappings":";;;AAeA,0DAIC;AAnBD,sDAIiC;AAWjC,SAAgB,uBAAuB,CACrC,KAAc;IAEd,OAAO,IAAA,4BAAiB,EAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAOY,QAAA,gBAAgB,GAAG;IAC9B;;;;;;OAMG;IACH,IAAI,CAAC,KAA4B;QAC/B,OAAO,qBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FunctionExpression } from "../functions/index.js";
|
|
2
|
+
import type { Logic } from "../logic/index.js";
|
|
3
|
+
import type { FilterComparison, FilterComparisonInput } from "./comparison.js";
|
|
4
|
+
/**
|
|
5
|
+
* A type aggregating all usable inputs to produce a {@link Filter}.
|
|
6
|
+
*/
|
|
7
|
+
export type FilterInput = FilterComparisonInput | FilterFunction | FilterLogic;
|
|
8
|
+
/**
|
|
9
|
+
* A type aggregating all usable functions in {@link Filter}s.
|
|
10
|
+
*
|
|
11
|
+
* This is an alias for all available functions.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.FilterExpression.html
|
|
14
|
+
*/
|
|
15
|
+
export type FilterFunction = FunctionExpression;
|
|
16
|
+
/**
|
|
17
|
+
* A type aggregating all usable logic in {@link Filter}s.
|
|
18
|
+
*
|
|
19
|
+
* This is an alias for all available logic.
|
|
20
|
+
*
|
|
21
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.FilterExpression.html
|
|
22
|
+
*/
|
|
23
|
+
export type FilterLogic = Logic;
|
|
24
|
+
/**
|
|
25
|
+
* A type aggregating all valid {@link Filter}s.
|
|
26
|
+
*
|
|
27
|
+
* All variants are branded {@link ExpressionFormatter}s.
|
|
28
|
+
*/
|
|
29
|
+
export type Filter = FilterComparison | FilterFunction | FilterLogic;
|
|
30
|
+
export declare const Filter: {
|
|
31
|
+
/**
|
|
32
|
+
* Creates a {@link Filter} from the provided input.
|
|
33
|
+
*
|
|
34
|
+
* @param input - The {@link Filter}'s input.
|
|
35
|
+
*
|
|
36
|
+
* @returns The corresponding {@link Filter}.
|
|
37
|
+
*/
|
|
38
|
+
from(input: FilterInput): Filter;
|
|
39
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Filter = void 0;
|
|
4
|
+
const expression_js_1 = require("../expression.js");
|
|
5
|
+
exports.Filter = {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a {@link Filter} from the provided input.
|
|
8
|
+
*
|
|
9
|
+
* @param input - The {@link Filter}'s input.
|
|
10
|
+
*
|
|
11
|
+
* @returns The corresponding {@link Filter}.
|
|
12
|
+
*/
|
|
13
|
+
from(input) {
|
|
14
|
+
return expression_js_1.Expression.from(input);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/filter/filter.ts"],"names":[],"mappings":";;;AAAA,oDAA8C;AAmCjC,QAAA,MAAM,GAAG;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,KAAkB;QACrB,OAAO,0BAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FilterComparison = void 0;
|
|
18
|
+
var comparison_js_1 = require("./comparison.js");
|
|
19
|
+
Object.defineProperty(exports, "FilterComparison", { enumerable: true, get: function () { return comparison_js_1.FilterComparison; } });
|
|
20
|
+
__exportStar(require("./filter.js"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAGyB;AAFvB,iHAAA,gBAAgB,OAAA;AAGlB,8CAA4B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Brand } from "@infra-blocks/types";
|
|
2
2
|
import { ExpressionFormatter } from "../formatter.js";
|
|
3
|
+
import { type OperandInput } from "../operands/operand.js";
|
|
3
4
|
import { type PathOrValueInput } from "../operands/path-or-value.js";
|
|
4
|
-
import { type Size } from "../operands/size.js";
|
|
5
5
|
export type Contains = ExpressionFormatter & Brand<"Contains">;
|
|
6
6
|
/**
|
|
7
7
|
* Returns a condition that uses the `contains` function.
|
|
@@ -13,4 +13,4 @@ export type Contains = ExpressionFormatter & Brand<"Contains">;
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
15
15
|
*/
|
|
16
|
-
export declare function contains(first: PathOrValueInput, second:
|
|
16
|
+
export declare function contains(first: PathOrValueInput, second: OperandInput): Contains;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.contains = contains;
|
|
4
4
|
const types_1 = require("@infra-blocks/types");
|
|
5
5
|
const formatter_js_1 = require("../formatter.js");
|
|
6
|
+
const operand_js_1 = require("../operands/operand.js");
|
|
6
7
|
const path_or_value_js_1 = require("../operands/path-or-value.js");
|
|
7
|
-
const size_js_1 = require("../operands/size.js");
|
|
8
8
|
/**
|
|
9
9
|
* Returns a condition that uses the `contains` function.
|
|
10
10
|
*
|
|
@@ -17,7 +17,7 @@ const size_js_1 = require("../operands/size.js");
|
|
|
17
17
|
*/
|
|
18
18
|
function contains(first, second) {
|
|
19
19
|
const firstOperand = path_or_value_js_1.PathOrValue.normalize(first);
|
|
20
|
-
const secondOperand =
|
|
20
|
+
const secondOperand = operand_js_1.Operand.normalize(second);
|
|
21
21
|
return (0, types_1.trusted)(formatter_js_1.ExpressionFormatter.from(({ names, values }) => `contains(${firstOperand.format({ names, values })}, ${secondOperand.format({ names, values })})`));
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=contains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/functions/contains.ts"],"names":[],"mappings":";;AAoBA,4BAaC;AAjCD,+CAA0D;AAC1D,kDAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/functions/contains.ts"],"names":[],"mappings":";;AAoBA,4BAaC;AAjCD,+CAA0D;AAC1D,kDAAsD;AACtD,uDAAoE;AACpE,mEAGsC;AAItC;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CACtB,KAAuB,EACvB,MAAoB;IAEpB,MAAM,YAAY,GAAG,8BAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,oBAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEhD,OAAO,IAAA,eAAO,EACZ,kCAAmB,CAAC,IAAI,CACtB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CACpB,YAAY,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,CACpG,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { BetweenInput, ComparableOperandInput, ComparableValue, EqualsInput, GreaterThanInput, GreaterThanOrEqualsInput, InInput, LowerThanInput, LowerThanOrEqualsInput, NotEqualsInput, } from "./comparisons/index.js";
|
|
2
2
|
export * from "./condition/index.js";
|
|
3
|
+
export * from "./filter/index.js";
|
|
3
4
|
export * from "./functions/index.js";
|
|
4
5
|
export * from "./key-condition/index.js";
|
|
5
6
|
export * from "./logic/index.js";
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
// TODO: don't export the typeguards beyond here.
|
|
18
18
|
__exportStar(require("./condition/index.js"), exports);
|
|
19
|
+
__exportStar(require("./filter/index.js"), exports);
|
|
19
20
|
__exportStar(require("./functions/index.js"), exports);
|
|
20
21
|
__exportStar(require("./key-condition/index.js"), exports);
|
|
21
22
|
__exportStar(require("./logic/index.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/expressions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,iDAAiD;AACjD,uDAAqC;AACrC,uDAAqC;AACrC,2DAAyC;AACzC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,oDAAkC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/expressions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,iDAAiD;AACjD,uDAAqC;AACrC,oDAAkC;AAClC,uDAAqC;AACrC,2DAAyC;AACzC,mDAAiC;AACjC,sDAAoC;AACpC,kDAAgC;AAChC,oDAAkC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { QueryCommandInput } from "@aws-sdk/lib-dynamodb";
|
|
2
2
|
import type { KeyAttributes } from "../../types.js";
|
|
3
|
-
import { type KeyConditionInput, type ProjectionInput } from "../expressions/index.js";
|
|
3
|
+
import { type FilterInput, type KeyConditionInput, type ProjectionInput } from "../expressions/index.js";
|
|
4
4
|
export type QueryInput<K extends KeyAttributes = KeyAttributes> = {
|
|
5
5
|
table: string;
|
|
6
6
|
keyCondition: KeyConditionInput;
|
|
7
7
|
consistentRead?: boolean;
|
|
8
8
|
exclusiveStartKey?: K;
|
|
9
|
+
filter?: FilterInput;
|
|
9
10
|
index?: string;
|
|
10
11
|
limit?: number;
|
|
11
12
|
projection?: ProjectionInput;
|
|
@@ -17,6 +17,9 @@ function encode(input) {
|
|
|
17
17
|
Limit: input.limit,
|
|
18
18
|
ScanIndexForward: input.scanIndexForward,
|
|
19
19
|
};
|
|
20
|
+
if (input.filter != null) {
|
|
21
|
+
result.FilterExpression = formatter.format(index_js_1.Filter.from(input.filter));
|
|
22
|
+
}
|
|
20
23
|
if (input.projection != null) {
|
|
21
24
|
result.ProjectionExpression = formatter.format(index_js_1.Projection.from(input.projection));
|
|
22
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/inputs/query.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/inputs/query.ts"],"names":[],"mappings":";;;AAEA,sDAOiC;AACjC,qCAAgD;AAcnC,QAAA,UAAU,GAAG;IACxB,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,KAAoB;IAEpB,MAAM,SAAS,GAAG,6BAAoB,CAAC,MAAM,EAAE,CAAC;IAChD,MAAM,MAAM,GAAsB;QAChC,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,sBAAsB,EAAE,SAAS,CAAC,MAAM,CACtC,uBAAY,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CACtC;QACD,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;KACzC,CAAC;IAEF,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,CAAC,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,iBAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC,MAAM,CAC5C,qBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAClC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,wBAAwB,GAAG,SAAS,CAAC,2BAA2B,EAAE,CAAC;IAC1E,MAAM,CAAC,yBAAyB,GAAG,SAAS,CAAC,4BAA4B,EAAE,CAAC;IAE5E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Comparison, type ComparisonInput } from "../comparisons/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A type aggregating all values that can be used to produce a {@link FilterComparison}.
|
|
4
|
+
*
|
|
5
|
+
* Those include all available comparison expression inputs.
|
|
6
|
+
*
|
|
7
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.FilterExpression.html
|
|
8
|
+
*/
|
|
9
|
+
export type FilterComparisonInput = ComparisonInput;
|
|
10
|
+
export declare function isFilterComparisonInput(input: unknown): input is FilterComparisonInput;
|
|
11
|
+
/**
|
|
12
|
+
* The {@link ExpressionFormatter} equivalents to their respective {@link FilterComparisonInput}.
|
|
13
|
+
*/
|
|
14
|
+
export type FilterComparison = Comparison;
|
|
15
|
+
export declare const FilterComparison: {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a {@link FilterComparison} from the provided input.
|
|
18
|
+
*
|
|
19
|
+
* @param input - The {@link FilterComparison}'s input.
|
|
20
|
+
*
|
|
21
|
+
* @returns The corresponding {@link FilterComparison}.
|
|
22
|
+
*/
|
|
23
|
+
from(input: FilterComparisonInput): FilterComparison;
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Comparison, isComparisonInput, } from "../comparisons/index.js";
|
|
2
|
+
export function isFilterComparisonInput(input) {
|
|
3
|
+
return isComparisonInput(input);
|
|
4
|
+
}
|
|
5
|
+
export const FilterComparison = {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a {@link FilterComparison} from the provided input.
|
|
8
|
+
*
|
|
9
|
+
* @param input - The {@link FilterComparison}'s input.
|
|
10
|
+
*
|
|
11
|
+
* @returns The corresponding {@link FilterComparison}.
|
|
12
|
+
*/
|
|
13
|
+
from(input) {
|
|
14
|
+
return Comparison.from(input);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=comparison.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/filter/comparison.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAWjC,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAOD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;;;;;;OAMG;IACH,IAAI,CAAC,KAA4B;QAC/B,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FunctionExpression } from "../functions/index.js";
|
|
2
|
+
import type { Logic } from "../logic/index.js";
|
|
3
|
+
import type { FilterComparison, FilterComparisonInput } from "./comparison.js";
|
|
4
|
+
/**
|
|
5
|
+
* A type aggregating all usable inputs to produce a {@link Filter}.
|
|
6
|
+
*/
|
|
7
|
+
export type FilterInput = FilterComparisonInput | FilterFunction | FilterLogic;
|
|
8
|
+
/**
|
|
9
|
+
* A type aggregating all usable functions in {@link Filter}s.
|
|
10
|
+
*
|
|
11
|
+
* This is an alias for all available functions.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.FilterExpression.html
|
|
14
|
+
*/
|
|
15
|
+
export type FilterFunction = FunctionExpression;
|
|
16
|
+
/**
|
|
17
|
+
* A type aggregating all usable logic in {@link Filter}s.
|
|
18
|
+
*
|
|
19
|
+
* This is an alias for all available logic.
|
|
20
|
+
*
|
|
21
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.FilterExpression.html
|
|
22
|
+
*/
|
|
23
|
+
export type FilterLogic = Logic;
|
|
24
|
+
/**
|
|
25
|
+
* A type aggregating all valid {@link Filter}s.
|
|
26
|
+
*
|
|
27
|
+
* All variants are branded {@link ExpressionFormatter}s.
|
|
28
|
+
*/
|
|
29
|
+
export type Filter = FilterComparison | FilterFunction | FilterLogic;
|
|
30
|
+
export declare const Filter: {
|
|
31
|
+
/**
|
|
32
|
+
* Creates a {@link Filter} from the provided input.
|
|
33
|
+
*
|
|
34
|
+
* @param input - The {@link Filter}'s input.
|
|
35
|
+
*
|
|
36
|
+
* @returns The corresponding {@link Filter}.
|
|
37
|
+
*/
|
|
38
|
+
from(input: FilterInput): Filter;
|
|
39
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Expression } from "../expression.js";
|
|
2
|
+
export const Filter = {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a {@link Filter} from the provided input.
|
|
5
|
+
*
|
|
6
|
+
* @param input - The {@link Filter}'s input.
|
|
7
|
+
*
|
|
8
|
+
* @returns The corresponding {@link Filter}.
|
|
9
|
+
*/
|
|
10
|
+
from(input) {
|
|
11
|
+
return Expression.from(input);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/filter/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAmC9C,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,KAAkB;QACrB,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/filter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Brand } from "@infra-blocks/types";
|
|
2
2
|
import { ExpressionFormatter } from "../formatter.js";
|
|
3
|
+
import { type OperandInput } from "../operands/operand.js";
|
|
3
4
|
import { type PathOrValueInput } from "../operands/path-or-value.js";
|
|
4
|
-
import { type Size } from "../operands/size.js";
|
|
5
5
|
export type Contains = ExpressionFormatter & Brand<"Contains">;
|
|
6
6
|
/**
|
|
7
7
|
* Returns a condition that uses the `contains` function.
|
|
@@ -13,4 +13,4 @@ export type Contains = ExpressionFormatter & Brand<"Contains">;
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
15
15
|
*/
|
|
16
|
-
export declare function contains(first: PathOrValueInput, second:
|
|
16
|
+
export declare function contains(first: PathOrValueInput, second: OperandInput): Contains;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { trusted } from "@infra-blocks/types";
|
|
2
2
|
import { ExpressionFormatter } from "../formatter.js";
|
|
3
|
+
import { Operand } from "../operands/operand.js";
|
|
3
4
|
import { PathOrValue, } from "../operands/path-or-value.js";
|
|
4
|
-
import { isSize } from "../operands/size.js";
|
|
5
5
|
/**
|
|
6
6
|
* Returns a condition that uses the `contains` function.
|
|
7
7
|
*
|
|
@@ -14,7 +14,7 @@ import { isSize } from "../operands/size.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export function contains(first, second) {
|
|
16
16
|
const firstOperand = PathOrValue.normalize(first);
|
|
17
|
-
const secondOperand =
|
|
17
|
+
const secondOperand = Operand.normalize(second);
|
|
18
18
|
return trusted(ExpressionFormatter.from(({ names, values }) => `contains(${firstOperand.format({ names, values })}, ${secondOperand.format({ names, values })})`));
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=contains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/functions/contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"contains.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/functions/contains.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAqB,MAAM,wBAAwB,CAAC;AACpE,OAAO,EACL,WAAW,GAEZ,MAAM,8BAA8B,CAAC;AAItC;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAuB,EACvB,MAAoB;IAEpB,MAAM,YAAY,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEhD,OAAO,OAAO,CACZ,mBAAmB,CAAC,IAAI,CACtB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CACpB,YAAY,YAAY,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,CACpG,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type { BetweenInput, ComparableOperandInput, ComparableValue, EqualsInput, GreaterThanInput, GreaterThanOrEqualsInput, InInput, LowerThanInput, LowerThanOrEqualsInput, NotEqualsInput, } from "./comparisons/index.js";
|
|
2
2
|
export * from "./condition/index.js";
|
|
3
|
+
export * from "./filter/index.js";
|
|
3
4
|
export * from "./functions/index.js";
|
|
4
5
|
export * from "./key-condition/index.js";
|
|
5
6
|
export * from "./logic/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/expressions/index.ts"],"names":[],"mappings":"AAYA,iDAAiD;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/expressions/index.ts"],"names":[],"mappings":"AAYA,iDAAiD;AACjD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { QueryCommandInput } from "@aws-sdk/lib-dynamodb";
|
|
2
2
|
import type { KeyAttributes } from "../../types.js";
|
|
3
|
-
import { type KeyConditionInput, type ProjectionInput } from "../expressions/index.js";
|
|
3
|
+
import { type FilterInput, type KeyConditionInput, type ProjectionInput } from "../expressions/index.js";
|
|
4
4
|
export type QueryInput<K extends KeyAttributes = KeyAttributes> = {
|
|
5
5
|
table: string;
|
|
6
6
|
keyCondition: KeyConditionInput;
|
|
7
7
|
consistentRead?: boolean;
|
|
8
8
|
exclusiveStartKey?: K;
|
|
9
|
+
filter?: FilterInput;
|
|
9
10
|
index?: string;
|
|
10
11
|
limit?: number;
|
|
11
12
|
projection?: ProjectionInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyCondition, Projection, } from "../expressions/index.js";
|
|
1
|
+
import { Filter, KeyCondition, Projection, } from "../expressions/index.js";
|
|
2
2
|
import { ExpressionsFormatter } from "./lib.js";
|
|
3
3
|
export const QueryInput = {
|
|
4
4
|
encode,
|
|
@@ -14,6 +14,9 @@ function encode(input) {
|
|
|
14
14
|
Limit: input.limit,
|
|
15
15
|
ScanIndexForward: input.scanIndexForward,
|
|
16
16
|
};
|
|
17
|
+
if (input.filter != null) {
|
|
18
|
+
result.FilterExpression = formatter.format(Filter.from(input.filter));
|
|
19
|
+
}
|
|
17
20
|
if (input.projection != null) {
|
|
18
21
|
result.ProjectionExpression = formatter.format(Projection.from(input.projection));
|
|
19
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/inputs/query.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EAEZ,UAAU,GAEX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/inputs/query.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EAEN,YAAY,EAEZ,UAAU,GAEX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAchD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,KAAoB;IAEpB,MAAM,SAAS,GAAG,oBAAoB,CAAC,MAAM,EAAE,CAAC;IAChD,MAAM,MAAM,GAAsB;QAChC,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,sBAAsB,EAAE,SAAS,CAAC,MAAM,CACtC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CACtC;QACD,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;KACzC,CAAC;IAEF,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACzB,MAAM,CAAC,gBAAgB,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,CAAC,oBAAoB,GAAG,SAAS,CAAC,MAAM,CAC5C,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAClC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,wBAAwB,GAAG,SAAS,CAAC,2BAA2B,EAAE,CAAC;IAC1E,MAAM,CAAC,yBAAyB,GAAG,SAAS,CAAC,4BAA4B,EAAE,CAAC;IAE5E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AttributeValue } from "../../../types.js";
|
|
2
|
-
import { Operand, type OperandInput } from "../operands/index.js";
|
|
3
|
-
export type ConditionOperand<T extends AttributeValue = AttributeValue> = Operand<T>;
|
|
4
|
-
export type ConditionOperandInput<T extends AttributeValue = AttributeValue> = OperandInput<T>;
|
|
5
|
-
export declare const ConditionOperand: {
|
|
6
|
-
normalize: <T extends AttributeValue = AttributeValue>(input: OperandInput<T>) => Operand<T>;
|
|
7
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConditionOperand = void 0;
|
|
4
|
-
const index_js_1 = require("../operands/index.js");
|
|
5
|
-
exports.ConditionOperand = {
|
|
6
|
-
normalize: index_js_1.Operand.normalize,
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=operand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operand.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/operand.ts"],"names":[],"mappings":";;;AACA,mDAAkE;AAQrD,QAAA,gBAAgB,GAAG;IAC9B,SAAS,EAAE,kBAAO,CAAC,SAAS;CAC7B,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AttributeValue } from "../../../types.js";
|
|
2
|
-
import { Operand, type OperandInput } from "../operands/index.js";
|
|
3
|
-
export type ConditionOperand<T extends AttributeValue = AttributeValue> = Operand<T>;
|
|
4
|
-
export type ConditionOperandInput<T extends AttributeValue = AttributeValue> = OperandInput<T>;
|
|
5
|
-
export declare const ConditionOperand: {
|
|
6
|
-
normalize: <T extends AttributeValue = AttributeValue>(input: OperandInput<T>) => Operand<T>;
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operand.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/operand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAqB,MAAM,sBAAsB,CAAC;AAQlE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;CAC7B,CAAC"}
|