@infra-blocks/aws-dynamodb 0.26.0 → 0.27.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/attributes/index.d.ts +2 -0
- package/lib/cjs/commands/attributes/index.js +19 -0
- package/lib/cjs/commands/attributes/index.js.map +1 -0
- package/lib/cjs/commands/attributes/names.d.ts +4 -4
- package/lib/cjs/commands/attributes/names.js.map +1 -1
- package/lib/cjs/commands/attributes/values.d.ts +6 -3
- package/lib/cjs/commands/attributes/values.js.map +1 -1
- package/lib/cjs/commands/expressions/condition/comparisons.d.ts +22 -0
- package/lib/cjs/commands/expressions/condition/comparisons.js +204 -0
- package/lib/cjs/commands/expressions/condition/comparisons.js.map +1 -0
- package/lib/cjs/commands/expressions/condition/condition.d.ts +24 -0
- package/lib/cjs/commands/expressions/condition/condition.js +27 -0
- package/lib/cjs/commands/expressions/condition/condition.js.map +1 -0
- package/lib/cjs/commands/expressions/condition/expression.d.ts +19 -0
- package/lib/cjs/commands/expressions/condition/expression.js +28 -0
- package/lib/cjs/commands/expressions/condition/expression.js.map +1 -0
- package/lib/cjs/commands/expressions/condition/functions.d.ts +70 -0
- package/lib/cjs/commands/expressions/condition/functions.js +80 -0
- package/lib/cjs/commands/expressions/condition/functions.js.map +1 -0
- package/lib/cjs/commands/expressions/condition/index.d.ts +5 -0
- package/lib/cjs/commands/expressions/condition/index.js +21 -0
- package/lib/cjs/commands/expressions/condition/index.js.map +1 -0
- package/lib/cjs/commands/expressions/condition/logic.d.ts +34 -0
- package/lib/cjs/commands/expressions/condition/logic.js +68 -0
- package/lib/cjs/commands/expressions/condition/logic.js.map +1 -0
- package/lib/cjs/commands/expressions/condition/size.d.ts +37 -0
- package/lib/cjs/commands/expressions/condition/size.js +35 -0
- package/lib/cjs/commands/expressions/condition/size.js.map +1 -0
- package/lib/cjs/commands/expressions/expression.d.ts +4 -0
- package/lib/cjs/commands/expressions/index.d.ts +1 -1
- package/lib/cjs/commands/expressions/index.js +1 -1
- package/lib/cjs/commands/expressions/index.js.map +1 -1
- package/lib/cjs/commands/expressions/key-condition.d.ts +2 -2
- package/lib/cjs/commands/expressions/operands/index.d.ts +1 -1
- package/lib/cjs/commands/expressions/operands/index.js +1 -1
- package/lib/cjs/commands/expressions/operands/{name.js → path.js} +1 -1
- package/lib/cjs/commands/expressions/operands/{name.js.map → path.js.map} +1 -1
- package/lib/cjs/commands/expressions/operands/type.d.ts +1 -1
- package/lib/cjs/commands/expressions/operands/value.js +0 -1
- package/lib/cjs/commands/expressions/operands/value.js.map +1 -1
- package/lib/cjs/commands/expressions/update/add.d.ts +1 -1
- package/lib/cjs/commands/expressions/update/delete.d.ts +1 -1
- package/lib/cjs/commands/expressions/update/if-not-exists.d.ts +1 -1
- package/lib/cjs/commands/expressions/update/remove.d.ts +1 -1
- package/lib/cjs/commands/expressions/update/set.d.ts +1 -1
- package/lib/cjs/commands/put-item.d.ts +2 -2
- package/lib/cjs/commands/put-item.js +5 -1
- package/lib/cjs/commands/put-item.js.map +1 -1
- package/lib/cjs/commands/query.js +5 -1
- package/lib/cjs/commands/query.js.map +1 -1
- package/lib/cjs/commands/update-item.d.ts +2 -2
- package/lib/cjs/commands/update-item.js +5 -1
- package/lib/cjs/commands/update-item.js.map +1 -1
- package/lib/cjs/types.d.ts +3 -2
- package/lib/cjs/types.js +13 -0
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/commands/attributes/index.d.ts +2 -0
- package/lib/esm/commands/attributes/index.js +3 -0
- package/lib/esm/commands/attributes/index.js.map +1 -0
- package/lib/esm/commands/attributes/names.d.ts +4 -4
- package/lib/esm/commands/attributes/names.js.map +1 -1
- package/lib/esm/commands/attributes/values.d.ts +6 -3
- package/lib/esm/commands/attributes/values.js.map +1 -1
- package/lib/esm/commands/expressions/condition/comparisons.d.ts +22 -0
- package/lib/esm/commands/expressions/condition/comparisons.js +200 -0
- package/lib/esm/commands/expressions/condition/comparisons.js.map +1 -0
- package/lib/esm/commands/expressions/condition/condition.d.ts +24 -0
- package/lib/esm/commands/expressions/condition/condition.js +22 -0
- package/lib/esm/commands/expressions/condition/condition.js.map +1 -0
- package/lib/esm/commands/expressions/condition/expression.d.ts +19 -0
- package/lib/esm/commands/expressions/condition/expression.js +23 -0
- package/lib/esm/commands/expressions/condition/expression.js.map +1 -0
- package/lib/esm/commands/expressions/condition/functions.d.ts +70 -0
- package/lib/esm/commands/expressions/condition/functions.js +73 -0
- package/lib/esm/commands/expressions/condition/functions.js.map +1 -0
- package/lib/esm/commands/expressions/condition/index.d.ts +5 -0
- package/lib/esm/commands/expressions/condition/index.js +5 -0
- package/lib/esm/commands/expressions/condition/index.js.map +1 -0
- package/lib/esm/commands/expressions/condition/logic.d.ts +34 -0
- package/lib/esm/commands/expressions/condition/logic.js +63 -0
- package/lib/esm/commands/expressions/condition/logic.js.map +1 -0
- package/lib/esm/commands/expressions/condition/size.d.ts +37 -0
- package/lib/esm/commands/expressions/condition/size.js +30 -0
- package/lib/esm/commands/expressions/condition/size.js.map +1 -0
- package/lib/esm/commands/expressions/expression.d.ts +4 -0
- package/lib/esm/commands/expressions/index.d.ts +1 -1
- package/lib/esm/commands/expressions/index.js +1 -1
- package/lib/esm/commands/expressions/index.js.map +1 -1
- package/lib/esm/commands/expressions/key-condition.d.ts +2 -2
- package/lib/esm/commands/expressions/operands/index.d.ts +1 -1
- package/lib/esm/commands/expressions/operands/index.js +1 -1
- package/lib/esm/commands/expressions/operands/{name.js → path.js} +1 -1
- package/lib/esm/commands/expressions/operands/{name.js.map → path.js.map} +1 -1
- package/lib/esm/commands/expressions/operands/type.d.ts +1 -1
- package/lib/esm/commands/expressions/operands/value.js +0 -1
- package/lib/esm/commands/expressions/operands/value.js.map +1 -1
- package/lib/esm/commands/expressions/update/add.d.ts +1 -1
- package/lib/esm/commands/expressions/update/delete.d.ts +1 -1
- package/lib/esm/commands/expressions/update/if-not-exists.d.ts +1 -1
- package/lib/esm/commands/expressions/update/remove.d.ts +1 -1
- package/lib/esm/commands/expressions/update/set.d.ts +1 -1
- package/lib/esm/commands/put-item.d.ts +2 -2
- package/lib/esm/commands/put-item.js +5 -1
- package/lib/esm/commands/put-item.js.map +1 -1
- package/lib/esm/commands/query.js +5 -1
- package/lib/esm/commands/query.js.map +1 -1
- package/lib/esm/commands/update-item.d.ts +2 -2
- package/lib/esm/commands/update-item.js +5 -1
- package/lib/esm/commands/update-item.js.map +1 -1
- package/lib/esm/types.d.ts +3 -2
- package/lib/esm/types.js +12 -1
- package/lib/esm/types.js.map +1 -1
- package/package.json +2 -2
- package/lib/cjs/commands/expressions/condition.d.ts +0 -224
- package/lib/cjs/commands/expressions/condition.js +0 -360
- package/lib/cjs/commands/expressions/condition.js.map +0 -1
- package/lib/esm/commands/expressions/condition.d.ts +0 -224
- package/lib/esm/commands/expressions/condition.js +0 -350
- package/lib/esm/commands/expressions/condition.js.map +0 -1
- /package/lib/cjs/commands/expressions/operands/{name.d.ts → path.d.ts} +0 -0
- /package/lib/esm/commands/expressions/operands/{name.d.ts → path.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
__exportStar(require("./names.js"), exports);
|
|
18
|
+
__exportStar(require("./values.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/attributes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AttributePath } from "../../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* A substitution always starts with the `#` character.
|
|
3
|
+
* A path substitution always starts with the `#` character.
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type PathSubstitution = `#${string}`;
|
|
6
6
|
/**
|
|
7
7
|
* Represents a set of attribute names used in a condition expression.
|
|
8
8
|
*
|
|
@@ -36,14 +36,14 @@ export declare class AttributeNames {
|
|
|
36
36
|
*
|
|
37
37
|
* @returns The substitution associated with the attribute path.
|
|
38
38
|
*/
|
|
39
|
-
substitute(attribute: AttributePath):
|
|
39
|
+
substitute(attribute: AttributePath): PathSubstitution;
|
|
40
40
|
/**
|
|
41
41
|
* Returns a record where the keys are the substitutions generated by this object
|
|
42
42
|
* and the values are the corresponding attribute paths they where generated for.
|
|
43
43
|
*
|
|
44
44
|
* @returns A mapping of substitutions generated by this object, undefined if none were.
|
|
45
45
|
*/
|
|
46
|
-
getSubstitutions(): Record<
|
|
46
|
+
getSubstitutions(): Record<PathSubstitution, AttributePath> | undefined;
|
|
47
47
|
private getAndSetNextSubstituteFor;
|
|
48
48
|
static create(): AttributeNames;
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/commands/attributes/names.ts"],"names":[],"mappings":";;;AAOA,yJAAyJ;AACzJ,kEAAkE;AAClE;;;;;;;;;;;;;;;;;GAiBG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O,EAAE,EAAE,CAAC;YAC3D,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;QACjC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,0BAA0B,CAAC,IAAmB;QACpD,MAAM,cAAc,GAAG,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAsB,CAAC;QACzE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACrC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;CACF;AApED,wCAoEC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { AttributeValue } from "../../types.js";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A value substitution always starts with the `:` character.
|
|
4
|
+
*/
|
|
5
|
+
export type ValueSubstitution = `:${string}`;
|
|
3
6
|
/**
|
|
4
7
|
* Represents a set of attribute values used in an expression.
|
|
5
8
|
*
|
|
@@ -36,14 +39,14 @@ export declare class AttributeValues {
|
|
|
36
39
|
*
|
|
37
40
|
* @returns The reference associated with the attribute value.
|
|
38
41
|
*/
|
|
39
|
-
substitute(value: AttributeValue):
|
|
42
|
+
substitute(value: AttributeValue): ValueSubstitution;
|
|
40
43
|
/**
|
|
41
44
|
* Returns record of all substitutions made by this object where the keys are
|
|
42
45
|
* the value references and the values are the attribute values they correspond to.
|
|
43
46
|
*
|
|
44
47
|
* @returns A mapping of value references generated by this object, undefined if none were.
|
|
45
48
|
*/
|
|
46
|
-
getSubstitutions(): Record<
|
|
49
|
+
getSubstitutions(): Record<ValueSubstitution, AttributeValue> | undefined;
|
|
47
50
|
private getAndSetNextSubstitutionFor;
|
|
48
51
|
static create(): AttributeValues;
|
|
49
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/commands/attributes/values.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/commands/attributes/values.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,eAAe;IACT,MAAM,CAAyC;IAEhE;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAqC,CAAC;IAC7D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,KAAqB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,gBAAgB;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,MAAM,GAA8C,EAAE,CAAC;QAC7D,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YACvD,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,4BAA4B,CAClC,KAAqB;QAErB,MAAM,SAAS,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,EAAuB,CAAC;QACvE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,eAAe,EAAE,CAAC;IAC/B,CAAC;CACF;AApDD,0CAoDC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { NativeBinary, NativeNumber, NativeString } from "../../../types.js";
|
|
2
|
+
import type { ConditionOperand, ConditionParams } from "./condition.js";
|
|
3
|
+
import { ConditionExpression } from "./expression.js";
|
|
4
|
+
export type ComparableValue = NativeBinary | NativeNumber | NativeString;
|
|
5
|
+
export type ComparableOperand = ConditionOperand<ComparableValue>;
|
|
6
|
+
export type ConditionComparisonParams = Between | Equals | GreaterThan | GreaterThanOrEquals | In | LowerThan | LowerThanOrEquals | NotEquals;
|
|
7
|
+
export type Between = [
|
|
8
|
+
ComparableOperand,
|
|
9
|
+
"BETWEEN",
|
|
10
|
+
ComparableOperand,
|
|
11
|
+
"AND",
|
|
12
|
+
ComparableOperand
|
|
13
|
+
];
|
|
14
|
+
export type Equals = [ConditionOperand, "=", ConditionOperand];
|
|
15
|
+
export type GreaterThan = [ComparableOperand, ">", ComparableOperand];
|
|
16
|
+
export type GreaterThanOrEquals = [ComparableOperand, ">=", ComparableOperand];
|
|
17
|
+
export type In = [ComparableOperand, "IN", ComparableOperand[]];
|
|
18
|
+
export type LowerThan = [ComparableOperand, "<", ComparableOperand];
|
|
19
|
+
export type LowerThanOrEquals = [ComparableOperand, "<=", ComparableOperand];
|
|
20
|
+
export type NotEquals = [ConditionOperand, "<>", ConditionOperand];
|
|
21
|
+
export declare function comparison(params: ConditionComparisonParams): ConditionExpression;
|
|
22
|
+
export declare function isComparison(params: ConditionParams): params is ConditionComparisonParams;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.comparison = comparison;
|
|
4
|
+
exports.isComparison = isComparison;
|
|
5
|
+
const types_1 = require("@infra-blocks/types");
|
|
6
|
+
const expression_js_1 = require("./expression.js");
|
|
7
|
+
// TODO: don't export publicly through index.
|
|
8
|
+
function comparison(params) {
|
|
9
|
+
if (isBetween(params)) {
|
|
10
|
+
return between(params);
|
|
11
|
+
}
|
|
12
|
+
if (isEquals(params)) {
|
|
13
|
+
return equals(params);
|
|
14
|
+
}
|
|
15
|
+
if (isGreaterThan(params)) {
|
|
16
|
+
return greaterThan(params);
|
|
17
|
+
}
|
|
18
|
+
if (isGreaterThanOrEquals(params)) {
|
|
19
|
+
return greaterThanOrEquals(params);
|
|
20
|
+
}
|
|
21
|
+
if (isIn(params)) {
|
|
22
|
+
return inComparison(params);
|
|
23
|
+
}
|
|
24
|
+
if (isLowerThan(params)) {
|
|
25
|
+
return lowerThan(params);
|
|
26
|
+
}
|
|
27
|
+
if (isLowerThanOrEquals(params)) {
|
|
28
|
+
return lowerThanOrEquals(params);
|
|
29
|
+
}
|
|
30
|
+
if (isNotEquals(params)) {
|
|
31
|
+
return notEquals(params);
|
|
32
|
+
}
|
|
33
|
+
(0, types_1.unreachable)(params);
|
|
34
|
+
}
|
|
35
|
+
function isComparison(params) {
|
|
36
|
+
const casted = params;
|
|
37
|
+
return (isBetween(casted) ||
|
|
38
|
+
isEquals(casted) ||
|
|
39
|
+
isGreaterThan(casted) ||
|
|
40
|
+
isGreaterThanOrEquals(casted) ||
|
|
41
|
+
isIn(casted) ||
|
|
42
|
+
isLowerThan(casted) ||
|
|
43
|
+
isLowerThanOrEquals(casted) ||
|
|
44
|
+
isNotEquals(casted));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns a condition that uses the `BETWEEN` operator.
|
|
48
|
+
*
|
|
49
|
+
* Both bounds are inclusive, meaning that the returned condition corresponds to `lower <= lhs <= upper`.
|
|
50
|
+
*
|
|
51
|
+
* @param params - The parameters of the `BETWEEN` comparison. The first element contains the left-hand side operand,
|
|
52
|
+
* the third element contains the lower inclusive bound, and the fifth element contains the upper inclusive bound.
|
|
53
|
+
*
|
|
54
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is within the provided bounds.
|
|
55
|
+
*
|
|
56
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
57
|
+
*/
|
|
58
|
+
function between(params) {
|
|
59
|
+
return expression_js_1.ConditionExpression.from({
|
|
60
|
+
stringify: ({ names, values }) => {
|
|
61
|
+
return `${params[0].substitute({ names, values })} BETWEEN ${params[2].substitute({ names, values })} AND ${params[4].substitute({ names, values })}`;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function isBetween(value) {
|
|
66
|
+
return value[1] === "BETWEEN" && value[3] === "AND";
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns a condition that uses the `=` operator.
|
|
70
|
+
*
|
|
71
|
+
* @param params - The parameters of the `=` comparison. The first element contains the left-hand side operand,
|
|
72
|
+
* and the third element contains the right-hand side operand.
|
|
73
|
+
*
|
|
74
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is equal to the provided one.
|
|
75
|
+
*
|
|
76
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
77
|
+
*/
|
|
78
|
+
function equals(params) {
|
|
79
|
+
return binaryOperation(params);
|
|
80
|
+
}
|
|
81
|
+
function isEquals(value) {
|
|
82
|
+
return value[1] === "=";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns a condition that uses the `>` operator.
|
|
86
|
+
*
|
|
87
|
+
* @param params - The parameters of the `>` comparison. The first element contains the left-hand side operand,
|
|
88
|
+
* the third element contains the right-hand side operand.
|
|
89
|
+
*
|
|
90
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is greater than the provided one.
|
|
91
|
+
*
|
|
92
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
93
|
+
*/
|
|
94
|
+
function greaterThan(params) {
|
|
95
|
+
return binaryOperation(params);
|
|
96
|
+
}
|
|
97
|
+
function isGreaterThan(value) {
|
|
98
|
+
return value[1] === ">";
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns a condition that uses the `>=` operator.
|
|
102
|
+
*
|
|
103
|
+
* @param params - The parameters of the `>=` comparison. The first element contains the left-hand side operand,
|
|
104
|
+
* the third element contains the right-hand side operand.
|
|
105
|
+
*
|
|
106
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is greater than or equal to the provided one.
|
|
107
|
+
*
|
|
108
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
109
|
+
*/
|
|
110
|
+
function greaterThanOrEquals(params) {
|
|
111
|
+
return binaryOperation(params);
|
|
112
|
+
}
|
|
113
|
+
function isGreaterThanOrEquals(value) {
|
|
114
|
+
return value[1] === ">=";
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Returns a condition that uses the `IN` operator.
|
|
118
|
+
*
|
|
119
|
+
* This function throws if the list of elements to compared against is empty or exceeds 100 elements.
|
|
120
|
+
*
|
|
121
|
+
* @param params - The parameters of the `IN` comparison. The first element contains the left-hand side operand,
|
|
122
|
+
* the third element contains the list of elements to compare against.
|
|
123
|
+
*
|
|
124
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is equal to any of the provided ones.
|
|
125
|
+
*
|
|
126
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
127
|
+
*/
|
|
128
|
+
function inComparison(params) {
|
|
129
|
+
const containerElements = params[2];
|
|
130
|
+
// TODO: unit test those limits
|
|
131
|
+
if (containerElements.length === 0) {
|
|
132
|
+
throw new Error("the IN operator requires at least one operand.");
|
|
133
|
+
}
|
|
134
|
+
if (containerElements.length > 100) {
|
|
135
|
+
throw new Error(`up to 100 operands are support for the IN operator, got ${containerElements.length}`);
|
|
136
|
+
}
|
|
137
|
+
return expression_js_1.ConditionExpression.from({
|
|
138
|
+
stringify: ({ names, values }) => {
|
|
139
|
+
const operands = containerElements
|
|
140
|
+
.map((operand) => operand.substitute({ names, values }))
|
|
141
|
+
.join(",");
|
|
142
|
+
return `${params[0].substitute({ names, values })} IN (${operands})`;
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function isIn(value) {
|
|
147
|
+
return value[1] === "IN";
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Returns a condition that uses the `<` operator
|
|
151
|
+
*
|
|
152
|
+
* @param params - The parameters of the `<` comparison. The first element contains the left-hand side operand,
|
|
153
|
+
* the third element contains the right-hand side operand.
|
|
154
|
+
*
|
|
155
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is lower than the provided one.
|
|
156
|
+
*
|
|
157
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
158
|
+
*/
|
|
159
|
+
function lowerThan(params) {
|
|
160
|
+
return binaryOperation(params);
|
|
161
|
+
}
|
|
162
|
+
function isLowerThan(value) {
|
|
163
|
+
return value[1] === "<";
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns a condition that uses the `<=` operator.
|
|
167
|
+
*
|
|
168
|
+
* @param params - The parameters of the `<=` comparison. The first element contains the left-hand side operand,
|
|
169
|
+
* the third element contains the right-hand side operand.
|
|
170
|
+
*
|
|
171
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is lower than or equal to the provided one.
|
|
172
|
+
*
|
|
173
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
174
|
+
*/
|
|
175
|
+
function lowerThanOrEquals(params) {
|
|
176
|
+
return binaryOperation(params);
|
|
177
|
+
}
|
|
178
|
+
function isLowerThanOrEquals(value) {
|
|
179
|
+
return value[1] === "<=";
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Returns a condition that uses the `<>` operator.
|
|
183
|
+
*
|
|
184
|
+
* @param params - The parameters of the `<>` comparison. The first element contains the left-hand side operand,
|
|
185
|
+
* the third element contains the right-hand side operand.
|
|
186
|
+
*
|
|
187
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand is not equal to the provided one.
|
|
188
|
+
*
|
|
189
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
190
|
+
*/
|
|
191
|
+
function notEquals(params) {
|
|
192
|
+
return binaryOperation(params);
|
|
193
|
+
}
|
|
194
|
+
function isNotEquals(value) {
|
|
195
|
+
return value[1] === "<>";
|
|
196
|
+
}
|
|
197
|
+
function binaryOperation(params) {
|
|
198
|
+
return expression_js_1.ConditionExpression.from({
|
|
199
|
+
stringify: ({ names, values }) => {
|
|
200
|
+
return `${params[0].substitute({ names, values })} ${params[1]} ${params[2].substitute({ names, values })}`;
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=comparisons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparisons.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/comparisons.ts"],"names":[],"mappings":";;AAyCA,gCA4BC;AAED,oCAcC;AArFD,+CAAkD;AAQlD,mDAAsD;AAgCtD,6CAA6C;AAC7C,SAAgB,UAAU,CACxB,MAAiC;IAEjC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,qBAAqB,CAAC,MAAM,CAAC,EAAE,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AEpC,OAAO,mCAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/B,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC9G,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AttributeValue } from "../../../types.js";
|
|
2
|
+
import type { AttributeNames } from "../../attributes/names.js";
|
|
3
|
+
import type { AttributeValues } from "../../attributes/values.js";
|
|
4
|
+
import type { IExpression } from "../expression.js";
|
|
5
|
+
import type { PathOperand } from "../operands/path.js";
|
|
6
|
+
import type { ValueOperand } from "../operands/value.js";
|
|
7
|
+
import type { ConditionComparisonParams } from "./comparisons.js";
|
|
8
|
+
import { type ConditionExpression } from "./expression.js";
|
|
9
|
+
import type { Size } from "./size.js";
|
|
10
|
+
export type ConditionParams = ConditionExpression | ConditionComparisonParams | ConditionExpression;
|
|
11
|
+
export type ConditionOperand<T extends AttributeValue = AttributeValue> = PathOperand | ValueOperand<T> | Size;
|
|
12
|
+
export declare class Condition implements IExpression {
|
|
13
|
+
private readonly inner;
|
|
14
|
+
private constructor();
|
|
15
|
+
stringify(params: {
|
|
16
|
+
names: AttributeNames;
|
|
17
|
+
values: AttributeValues;
|
|
18
|
+
}): string;
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
static from(params: ConditionParams): Condition;
|
|
23
|
+
}
|
|
24
|
+
export declare function condition(params: ConditionParams): Condition;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Condition = void 0;
|
|
4
|
+
exports.condition = condition;
|
|
5
|
+
const expression_js_1 = require("./expression.js");
|
|
6
|
+
// TODO: remove/rename?
|
|
7
|
+
class Condition {
|
|
8
|
+
inner;
|
|
9
|
+
constructor(params) {
|
|
10
|
+
this.inner = params;
|
|
11
|
+
}
|
|
12
|
+
stringify(params) {
|
|
13
|
+
return this.inner.stringify(params);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
static from(params) {
|
|
19
|
+
return new Condition((0, expression_js_1.conditionExpression)(params));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Condition = Condition;
|
|
23
|
+
// TODO: not meant to be exported publicly.
|
|
24
|
+
function condition(params) {
|
|
25
|
+
return Condition.from(params);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/condition.ts"],"names":[],"mappings":";;;AA4CA,8BAEC;AAvCD,mDAAgF;AAahF,uBAAuB;AACvB,MAAa,SAAS;IACH,KAAK,CAAsB;IAE5C,YAAoB,MAA2B;QAC7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,MAAuB;QACjC,OAAO,IAAI,SAAS,CAAC,IAAA,mCAAmB,EAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;CACF;AApBD,8BAoBC;AAED,2CAA2C;AAC3C,SAAgB,SAAS,CAAC,MAAuB;IAC/C,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AttributeNames } from "../../attributes/names.js";
|
|
2
|
+
import type { AttributeValues } from "../../attributes/values.js";
|
|
3
|
+
import type { IExpression, Stringifier } from "../expression.js";
|
|
4
|
+
import type { ConditionParams } from "./condition.js";
|
|
5
|
+
export declare class ConditionExpression implements IExpression {
|
|
6
|
+
private readonly stringifier;
|
|
7
|
+
private constructor();
|
|
8
|
+
stringify(params: {
|
|
9
|
+
names: AttributeNames;
|
|
10
|
+
values: AttributeValues;
|
|
11
|
+
}): string;
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
static from(params: {
|
|
16
|
+
stringify: Stringifier;
|
|
17
|
+
}): ConditionExpression;
|
|
18
|
+
}
|
|
19
|
+
export declare function conditionExpression(params: ConditionParams): ConditionExpression;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConditionExpression = void 0;
|
|
4
|
+
exports.conditionExpression = conditionExpression;
|
|
5
|
+
const comparisons_js_1 = require("./comparisons.js");
|
|
6
|
+
class ConditionExpression {
|
|
7
|
+
stringifier;
|
|
8
|
+
constructor(stringifier) {
|
|
9
|
+
this.stringifier = stringifier;
|
|
10
|
+
}
|
|
11
|
+
stringify(params) {
|
|
12
|
+
const { names, values } = params;
|
|
13
|
+
return this.stringifier({ names, values });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
static from(params) {
|
|
19
|
+
const { stringify } = params;
|
|
20
|
+
return new ConditionExpression(stringify);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ConditionExpression = ConditionExpression;
|
|
24
|
+
// TODO: module visibility.
|
|
25
|
+
function conditionExpression(params) {
|
|
26
|
+
return (0, comparisons_js_1.isComparison)(params) ? (0, comparisons_js_1.comparison)(params) : params;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=expression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/expression.ts"],"names":[],"mappings":";;;AA+BA,kDAIC;AAhCD,qDAA4D;AAG5D,MAAa,mBAAmB;IACb,WAAW,CAAc;IAE1C,YAAoB,WAAwB;QAC1C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,SAAS,CAAC,MAGT;QACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QACjC,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,MAAkC;QAC5C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;CACF;AAtBD,kDAsBC;AAED,2BAA2B;AAC3B,SAAgB,mBAAmB,CACjC,MAAuB;IAEvB,OAAO,IAAA,6BAAY,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,2BAAU,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { NativeBinary, NativeString, NativeType } from "../../../types.js";
|
|
2
|
+
import type { PathOperand } from "../operands/path.js";
|
|
3
|
+
import type { ValueOperand } from "../operands/value.js";
|
|
4
|
+
import { ConditionExpression } from "./expression.js";
|
|
5
|
+
import type { Size } from "./size.js";
|
|
6
|
+
/**
|
|
7
|
+
* Returns a condition that uses the `attribute_exists` function.
|
|
8
|
+
*
|
|
9
|
+
* @param attribute - The attribute path to check for existence.
|
|
10
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the provided attribute path exists.
|
|
11
|
+
*
|
|
12
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
13
|
+
*/
|
|
14
|
+
export declare function attributeExists(attribute: PathOperand): ConditionExpression;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a condition that uses the `attribute_not_exists` function.
|
|
17
|
+
*
|
|
18
|
+
* @param attribute - The attribute path to check for non-existence.
|
|
19
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the provided attribute path does not exist.
|
|
20
|
+
*
|
|
21
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
22
|
+
*/
|
|
23
|
+
export declare function attributeNotExists(attribute: PathOperand): ConditionExpression;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a condition that uses the `attribute_type` function.
|
|
26
|
+
*
|
|
27
|
+
* @param attribute - The attribute path to check.
|
|
28
|
+
* @param type - The expected type of the attribute.
|
|
29
|
+
*
|
|
30
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the attribute is of the expected type.
|
|
31
|
+
*
|
|
32
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
33
|
+
*/
|
|
34
|
+
export declare function attributeType(attribute: PathOperand, type: ValueOperand<NativeType>): ConditionExpression;
|
|
35
|
+
/**
|
|
36
|
+
* This type aggregates the types of operands that can be used with the {@link beginsWith} function.
|
|
37
|
+
*
|
|
38
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
39
|
+
*/
|
|
40
|
+
export type BeginsWithOperand = PathOperand | ValueOperand<NativeString | NativeBinary>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a condition that uses the `begins_with` function.
|
|
43
|
+
*
|
|
44
|
+
* @param first - The first function operand, which is the attribute or value to check.
|
|
45
|
+
* @param second - The second function operand, which is the prefix to validate against.
|
|
46
|
+
*
|
|
47
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the first operand begins with the second.
|
|
48
|
+
*
|
|
49
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
50
|
+
*/
|
|
51
|
+
export declare function beginsWith(first: BeginsWithOperand, second: BeginsWithOperand): ConditionExpression;
|
|
52
|
+
/**
|
|
53
|
+
* This type aggregates the types of operands that can be used as the first operand of the {@link contains} function.
|
|
54
|
+
*/
|
|
55
|
+
export type ContainsFirstOperand = PathOperand | ValueOperand;
|
|
56
|
+
/**
|
|
57
|
+
* This type aggregates the types of operands that can be used as the second operand of the {@link contains} function.
|
|
58
|
+
*/
|
|
59
|
+
export type ContainsSecondOperand = PathOperand | ValueOperand | Size;
|
|
60
|
+
/**
|
|
61
|
+
* Returns a condition that uses the `contains` function.
|
|
62
|
+
*
|
|
63
|
+
* @param first - The first function operand, which is the attribute or value to check.
|
|
64
|
+
* @param second - The second function operand, which is the value to check for containment.
|
|
65
|
+
*
|
|
66
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand contains the provided one.
|
|
67
|
+
*
|
|
68
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
69
|
+
*/
|
|
70
|
+
export declare function contains(first: ContainsFirstOperand, second: ContainsSecondOperand): ConditionExpression;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.attributeExists = attributeExists;
|
|
4
|
+
exports.attributeNotExists = attributeNotExists;
|
|
5
|
+
exports.attributeType = attributeType;
|
|
6
|
+
exports.beginsWith = beginsWith;
|
|
7
|
+
exports.contains = contains;
|
|
8
|
+
const expression_js_1 = require("./expression.js");
|
|
9
|
+
/**
|
|
10
|
+
* Returns a condition that uses the `attribute_exists` function.
|
|
11
|
+
*
|
|
12
|
+
* @param attribute - The attribute path to check for existence.
|
|
13
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the provided attribute path exists.
|
|
14
|
+
*
|
|
15
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
16
|
+
*/
|
|
17
|
+
function attributeExists(attribute) {
|
|
18
|
+
return expression_js_1.ConditionExpression.from({
|
|
19
|
+
stringify: ({ names }) => `attribute_exists(${attribute.substitute({ names })})`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns a condition that uses the `attribute_not_exists` function.
|
|
24
|
+
*
|
|
25
|
+
* @param attribute - The attribute path to check for non-existence.
|
|
26
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the provided attribute path does not exist.
|
|
27
|
+
*
|
|
28
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
29
|
+
*/
|
|
30
|
+
function attributeNotExists(attribute) {
|
|
31
|
+
return expression_js_1.ConditionExpression.from({
|
|
32
|
+
stringify: ({ names }) => `attribute_not_exists(${attribute.substitute({ names })})`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns a condition that uses the `attribute_type` function.
|
|
37
|
+
*
|
|
38
|
+
* @param attribute - The attribute path to check.
|
|
39
|
+
* @param type - The expected type of the attribute.
|
|
40
|
+
*
|
|
41
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the attribute is of the expected type.
|
|
42
|
+
*
|
|
43
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
44
|
+
*/
|
|
45
|
+
function attributeType(attribute, type) {
|
|
46
|
+
return expression_js_1.ConditionExpression.from({
|
|
47
|
+
stringify: ({ names, values }) => `attribute_type(${attribute.substitute({ names })}, ${type.substitute({ values })})`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns a condition that uses the `begins_with` function.
|
|
52
|
+
*
|
|
53
|
+
* @param first - The first function operand, which is the attribute or value to check.
|
|
54
|
+
* @param second - The second function operand, which is the prefix to validate against.
|
|
55
|
+
*
|
|
56
|
+
* @returns A {@link ConditionExpression} that evaluates to true if the first operand begins with the second.
|
|
57
|
+
*
|
|
58
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
59
|
+
*/
|
|
60
|
+
function beginsWith(first, second) {
|
|
61
|
+
return expression_js_1.ConditionExpression.from({
|
|
62
|
+
stringify: ({ names, values }) => `begins_with(${first.substitute({ names, values })}, ${second.substitute({ names, values })})`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns a condition that uses the `contains` function.
|
|
67
|
+
*
|
|
68
|
+
* @param first - The first function operand, which is the attribute or value to check.
|
|
69
|
+
* @param second - The second function operand, which is the value to check for containment.
|
|
70
|
+
*
|
|
71
|
+
* @returns A {@link ConditionExpression} that evaluates to true if this operand contains the provided one.
|
|
72
|
+
*
|
|
73
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
74
|
+
*/
|
|
75
|
+
function contains(first, second) {
|
|
76
|
+
return expression_js_1.ConditionExpression.from({
|
|
77
|
+
stringify: ({ names, values }) => `contains(${first.substitute({ names, values })}, ${second.substitute({ names, values })})`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sour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AE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG;KACjG,CAAC,CAAC;AACL,CAAC;AAWD;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CACtB,KAA2B,EAC3B,MAA6B;IAE7B,OAAO,mCAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAC/B,YAAY,KAAK,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG;KAC9F,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { Between, ComparableOperand, ComparableValue, ConditionComparisonParams, Equals, GreaterThan, GreaterThanOrEquals, In, LowerThan, LowerThanOrEquals, NotEquals, } from "./comparisons.js";
|
|
2
|
+
export * from "./condition.js";
|
|
3
|
+
export * from "./functions.js";
|
|
4
|
+
export * from "./logic.js";
|
|
5
|
+
export * from "./size.js";
|
|
@@ -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
|
+
__exportStar(require("./condition.js"), exports);
|
|
18
|
+
__exportStar(require("./functions.js"), exports);
|
|
19
|
+
__exportStar(require("./logic.js"), exports);
|
|
20
|
+
__exportStar(require("./size.js"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAaA,iDAA+B;AAC/B,iDAA+B;AAC/B,6CAA2B;AAC3B,4CAA0B"}
|