@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.
Files changed (121) hide show
  1. package/lib/cjs/commands/attributes/index.d.ts +2 -0
  2. package/lib/cjs/commands/attributes/index.js +19 -0
  3. package/lib/cjs/commands/attributes/index.js.map +1 -0
  4. package/lib/cjs/commands/attributes/names.d.ts +4 -4
  5. package/lib/cjs/commands/attributes/names.js.map +1 -1
  6. package/lib/cjs/commands/attributes/values.d.ts +6 -3
  7. package/lib/cjs/commands/attributes/values.js.map +1 -1
  8. package/lib/cjs/commands/expressions/condition/comparisons.d.ts +22 -0
  9. package/lib/cjs/commands/expressions/condition/comparisons.js +204 -0
  10. package/lib/cjs/commands/expressions/condition/comparisons.js.map +1 -0
  11. package/lib/cjs/commands/expressions/condition/condition.d.ts +24 -0
  12. package/lib/cjs/commands/expressions/condition/condition.js +27 -0
  13. package/lib/cjs/commands/expressions/condition/condition.js.map +1 -0
  14. package/lib/cjs/commands/expressions/condition/expression.d.ts +19 -0
  15. package/lib/cjs/commands/expressions/condition/expression.js +28 -0
  16. package/lib/cjs/commands/expressions/condition/expression.js.map +1 -0
  17. package/lib/cjs/commands/expressions/condition/functions.d.ts +70 -0
  18. package/lib/cjs/commands/expressions/condition/functions.js +80 -0
  19. package/lib/cjs/commands/expressions/condition/functions.js.map +1 -0
  20. package/lib/cjs/commands/expressions/condition/index.d.ts +5 -0
  21. package/lib/cjs/commands/expressions/condition/index.js +21 -0
  22. package/lib/cjs/commands/expressions/condition/index.js.map +1 -0
  23. package/lib/cjs/commands/expressions/condition/logic.d.ts +34 -0
  24. package/lib/cjs/commands/expressions/condition/logic.js +68 -0
  25. package/lib/cjs/commands/expressions/condition/logic.js.map +1 -0
  26. package/lib/cjs/commands/expressions/condition/size.d.ts +37 -0
  27. package/lib/cjs/commands/expressions/condition/size.js +35 -0
  28. package/lib/cjs/commands/expressions/condition/size.js.map +1 -0
  29. package/lib/cjs/commands/expressions/expression.d.ts +4 -0
  30. package/lib/cjs/commands/expressions/index.d.ts +1 -1
  31. package/lib/cjs/commands/expressions/index.js +1 -1
  32. package/lib/cjs/commands/expressions/index.js.map +1 -1
  33. package/lib/cjs/commands/expressions/key-condition.d.ts +2 -2
  34. package/lib/cjs/commands/expressions/operands/index.d.ts +1 -1
  35. package/lib/cjs/commands/expressions/operands/index.js +1 -1
  36. package/lib/cjs/commands/expressions/operands/{name.js → path.js} +1 -1
  37. package/lib/cjs/commands/expressions/operands/{name.js.map → path.js.map} +1 -1
  38. package/lib/cjs/commands/expressions/operands/type.d.ts +1 -1
  39. package/lib/cjs/commands/expressions/operands/value.js +0 -1
  40. package/lib/cjs/commands/expressions/operands/value.js.map +1 -1
  41. package/lib/cjs/commands/expressions/update/add.d.ts +1 -1
  42. package/lib/cjs/commands/expressions/update/delete.d.ts +1 -1
  43. package/lib/cjs/commands/expressions/update/if-not-exists.d.ts +1 -1
  44. package/lib/cjs/commands/expressions/update/remove.d.ts +1 -1
  45. package/lib/cjs/commands/expressions/update/set.d.ts +1 -1
  46. package/lib/cjs/commands/put-item.d.ts +2 -2
  47. package/lib/cjs/commands/put-item.js +5 -1
  48. package/lib/cjs/commands/put-item.js.map +1 -1
  49. package/lib/cjs/commands/query.js +5 -1
  50. package/lib/cjs/commands/query.js.map +1 -1
  51. package/lib/cjs/commands/update-item.d.ts +2 -2
  52. package/lib/cjs/commands/update-item.js +5 -1
  53. package/lib/cjs/commands/update-item.js.map +1 -1
  54. package/lib/cjs/types.d.ts +3 -2
  55. package/lib/cjs/types.js +13 -0
  56. package/lib/cjs/types.js.map +1 -1
  57. package/lib/esm/commands/attributes/index.d.ts +2 -0
  58. package/lib/esm/commands/attributes/index.js +3 -0
  59. package/lib/esm/commands/attributes/index.js.map +1 -0
  60. package/lib/esm/commands/attributes/names.d.ts +4 -4
  61. package/lib/esm/commands/attributes/names.js.map +1 -1
  62. package/lib/esm/commands/attributes/values.d.ts +6 -3
  63. package/lib/esm/commands/attributes/values.js.map +1 -1
  64. package/lib/esm/commands/expressions/condition/comparisons.d.ts +22 -0
  65. package/lib/esm/commands/expressions/condition/comparisons.js +200 -0
  66. package/lib/esm/commands/expressions/condition/comparisons.js.map +1 -0
  67. package/lib/esm/commands/expressions/condition/condition.d.ts +24 -0
  68. package/lib/esm/commands/expressions/condition/condition.js +22 -0
  69. package/lib/esm/commands/expressions/condition/condition.js.map +1 -0
  70. package/lib/esm/commands/expressions/condition/expression.d.ts +19 -0
  71. package/lib/esm/commands/expressions/condition/expression.js +23 -0
  72. package/lib/esm/commands/expressions/condition/expression.js.map +1 -0
  73. package/lib/esm/commands/expressions/condition/functions.d.ts +70 -0
  74. package/lib/esm/commands/expressions/condition/functions.js +73 -0
  75. package/lib/esm/commands/expressions/condition/functions.js.map +1 -0
  76. package/lib/esm/commands/expressions/condition/index.d.ts +5 -0
  77. package/lib/esm/commands/expressions/condition/index.js +5 -0
  78. package/lib/esm/commands/expressions/condition/index.js.map +1 -0
  79. package/lib/esm/commands/expressions/condition/logic.d.ts +34 -0
  80. package/lib/esm/commands/expressions/condition/logic.js +63 -0
  81. package/lib/esm/commands/expressions/condition/logic.js.map +1 -0
  82. package/lib/esm/commands/expressions/condition/size.d.ts +37 -0
  83. package/lib/esm/commands/expressions/condition/size.js +30 -0
  84. package/lib/esm/commands/expressions/condition/size.js.map +1 -0
  85. package/lib/esm/commands/expressions/expression.d.ts +4 -0
  86. package/lib/esm/commands/expressions/index.d.ts +1 -1
  87. package/lib/esm/commands/expressions/index.js +1 -1
  88. package/lib/esm/commands/expressions/index.js.map +1 -1
  89. package/lib/esm/commands/expressions/key-condition.d.ts +2 -2
  90. package/lib/esm/commands/expressions/operands/index.d.ts +1 -1
  91. package/lib/esm/commands/expressions/operands/index.js +1 -1
  92. package/lib/esm/commands/expressions/operands/{name.js → path.js} +1 -1
  93. package/lib/esm/commands/expressions/operands/{name.js.map → path.js.map} +1 -1
  94. package/lib/esm/commands/expressions/operands/type.d.ts +1 -1
  95. package/lib/esm/commands/expressions/operands/value.js +0 -1
  96. package/lib/esm/commands/expressions/operands/value.js.map +1 -1
  97. package/lib/esm/commands/expressions/update/add.d.ts +1 -1
  98. package/lib/esm/commands/expressions/update/delete.d.ts +1 -1
  99. package/lib/esm/commands/expressions/update/if-not-exists.d.ts +1 -1
  100. package/lib/esm/commands/expressions/update/remove.d.ts +1 -1
  101. package/lib/esm/commands/expressions/update/set.d.ts +1 -1
  102. package/lib/esm/commands/put-item.d.ts +2 -2
  103. package/lib/esm/commands/put-item.js +5 -1
  104. package/lib/esm/commands/put-item.js.map +1 -1
  105. package/lib/esm/commands/query.js +5 -1
  106. package/lib/esm/commands/query.js.map +1 -1
  107. package/lib/esm/commands/update-item.d.ts +2 -2
  108. package/lib/esm/commands/update-item.js +5 -1
  109. package/lib/esm/commands/update-item.js.map +1 -1
  110. package/lib/esm/types.d.ts +3 -2
  111. package/lib/esm/types.js +12 -1
  112. package/lib/esm/types.js.map +1 -1
  113. package/package.json +2 -2
  114. package/lib/cjs/commands/expressions/condition.d.ts +0 -224
  115. package/lib/cjs/commands/expressions/condition.js +0 -360
  116. package/lib/cjs/commands/expressions/condition.js.map +0 -1
  117. package/lib/esm/commands/expressions/condition.d.ts +0 -224
  118. package/lib/esm/commands/expressions/condition.js +0 -350
  119. package/lib/esm/commands/expressions/condition.js.map +0 -1
  120. /package/lib/cjs/commands/expressions/operands/{name.d.ts → path.d.ts} +0 -0
  121. /package/lib/esm/commands/expressions/operands/{name.d.ts → path.d.ts} +0 -0
@@ -0,0 +1,200 @@
1
+ import { unreachable } from "@infra-blocks/types";
2
+ import { ConditionExpression } from "./expression.js";
3
+ // TODO: don't export publicly through index.
4
+ export function comparison(params) {
5
+ if (isBetween(params)) {
6
+ return between(params);
7
+ }
8
+ if (isEquals(params)) {
9
+ return equals(params);
10
+ }
11
+ if (isGreaterThan(params)) {
12
+ return greaterThan(params);
13
+ }
14
+ if (isGreaterThanOrEquals(params)) {
15
+ return greaterThanOrEquals(params);
16
+ }
17
+ if (isIn(params)) {
18
+ return inComparison(params);
19
+ }
20
+ if (isLowerThan(params)) {
21
+ return lowerThan(params);
22
+ }
23
+ if (isLowerThanOrEquals(params)) {
24
+ return lowerThanOrEquals(params);
25
+ }
26
+ if (isNotEquals(params)) {
27
+ return notEquals(params);
28
+ }
29
+ unreachable(params);
30
+ }
31
+ export function isComparison(params) {
32
+ const casted = params;
33
+ return (isBetween(casted) ||
34
+ isEquals(casted) ||
35
+ isGreaterThan(casted) ||
36
+ isGreaterThanOrEquals(casted) ||
37
+ isIn(casted) ||
38
+ isLowerThan(casted) ||
39
+ isLowerThanOrEquals(casted) ||
40
+ isNotEquals(casted));
41
+ }
42
+ /**
43
+ * Returns a condition that uses the `BETWEEN` operator.
44
+ *
45
+ * Both bounds are inclusive, meaning that the returned condition corresponds to `lower <= lhs <= upper`.
46
+ *
47
+ * @param params - The parameters of the `BETWEEN` comparison. The first element contains the left-hand side operand,
48
+ * the third element contains the lower inclusive bound, and the fifth element contains the upper inclusive bound.
49
+ *
50
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is within the provided bounds.
51
+ *
52
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
53
+ */
54
+ function between(params) {
55
+ return ConditionExpression.from({
56
+ stringify: ({ names, values }) => {
57
+ return `${params[0].substitute({ names, values })} BETWEEN ${params[2].substitute({ names, values })} AND ${params[4].substitute({ names, values })}`;
58
+ },
59
+ });
60
+ }
61
+ function isBetween(value) {
62
+ return value[1] === "BETWEEN" && value[3] === "AND";
63
+ }
64
+ /**
65
+ * Returns a condition that uses the `=` operator.
66
+ *
67
+ * @param params - The parameters of the `=` comparison. The first element contains the left-hand side operand,
68
+ * and the third element contains the right-hand side operand.
69
+ *
70
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is equal to the provided one.
71
+ *
72
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
73
+ */
74
+ function equals(params) {
75
+ return binaryOperation(params);
76
+ }
77
+ function isEquals(value) {
78
+ return value[1] === "=";
79
+ }
80
+ /**
81
+ * Returns a condition that uses the `>` operator.
82
+ *
83
+ * @param params - The parameters of the `>` comparison. The first element contains the left-hand side operand,
84
+ * the third element contains the right-hand side operand.
85
+ *
86
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is greater than the provided one.
87
+ *
88
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
89
+ */
90
+ function greaterThan(params) {
91
+ return binaryOperation(params);
92
+ }
93
+ function isGreaterThan(value) {
94
+ return value[1] === ">";
95
+ }
96
+ /**
97
+ * Returns a condition that uses the `>=` operator.
98
+ *
99
+ * @param params - The parameters of the `>=` comparison. The first element contains the left-hand side operand,
100
+ * the third element contains the right-hand side operand.
101
+ *
102
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is greater than or equal to the provided one.
103
+ *
104
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
105
+ */
106
+ function greaterThanOrEquals(params) {
107
+ return binaryOperation(params);
108
+ }
109
+ function isGreaterThanOrEquals(value) {
110
+ return value[1] === ">=";
111
+ }
112
+ /**
113
+ * Returns a condition that uses the `IN` operator.
114
+ *
115
+ * This function throws if the list of elements to compared against is empty or exceeds 100 elements.
116
+ *
117
+ * @param params - The parameters of the `IN` comparison. The first element contains the left-hand side operand,
118
+ * the third element contains the list of elements to compare against.
119
+ *
120
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is equal to any of the provided ones.
121
+ *
122
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
123
+ */
124
+ function inComparison(params) {
125
+ const containerElements = params[2];
126
+ // TODO: unit test those limits
127
+ if (containerElements.length === 0) {
128
+ throw new Error("the IN operator requires at least one operand.");
129
+ }
130
+ if (containerElements.length > 100) {
131
+ throw new Error(`up to 100 operands are support for the IN operator, got ${containerElements.length}`);
132
+ }
133
+ return ConditionExpression.from({
134
+ stringify: ({ names, values }) => {
135
+ const operands = containerElements
136
+ .map((operand) => operand.substitute({ names, values }))
137
+ .join(",");
138
+ return `${params[0].substitute({ names, values })} IN (${operands})`;
139
+ },
140
+ });
141
+ }
142
+ function isIn(value) {
143
+ return value[1] === "IN";
144
+ }
145
+ /**
146
+ * Returns a condition that uses the `<` operator
147
+ *
148
+ * @param params - The parameters of the `<` comparison. The first element contains the left-hand side operand,
149
+ * the third element contains the right-hand side operand.
150
+ *
151
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is lower than the provided one.
152
+ *
153
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
154
+ */
155
+ function lowerThan(params) {
156
+ return binaryOperation(params);
157
+ }
158
+ function isLowerThan(value) {
159
+ return value[1] === "<";
160
+ }
161
+ /**
162
+ * Returns a condition that uses the `<=` operator.
163
+ *
164
+ * @param params - The parameters of the `<=` comparison. The first element contains the left-hand side operand,
165
+ * the third element contains the right-hand side operand.
166
+ *
167
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is lower than or equal to the provided one.
168
+ *
169
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
170
+ */
171
+ function lowerThanOrEquals(params) {
172
+ return binaryOperation(params);
173
+ }
174
+ function isLowerThanOrEquals(value) {
175
+ return value[1] === "<=";
176
+ }
177
+ /**
178
+ * Returns a condition that uses the `<>` operator.
179
+ *
180
+ * @param params - The parameters of the `<>` comparison. The first element contains the left-hand side operand,
181
+ * the third element contains the right-hand side operand.
182
+ *
183
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand is not equal to the provided one.
184
+ *
185
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
186
+ */
187
+ function notEquals(params) {
188
+ return binaryOperation(params);
189
+ }
190
+ function isNotEquals(value) {
191
+ return value[1] === "<>";
192
+ }
193
+ function binaryOperation(params) {
194
+ return ConditionExpression.from({
195
+ stringify: ({ names, values }) => {
196
+ return `${params[0].substitute({ names, values })} ${params[1]} ${params[2].substitute({ names, values })}`;
197
+ },
198
+ });
199
+ }
200
+ //# sourceMappingURL=comparisons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparisons.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/comparisons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQlD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAgCtD,6CAA6C;AAC7C,MAAM,UAAU,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,CAAC;QAClC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,I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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,22 @@
1
+ import { conditionExpression } from "./expression.js";
2
+ // TODO: remove/rename?
3
+ export class Condition {
4
+ inner;
5
+ constructor(params) {
6
+ this.inner = params;
7
+ }
8
+ stringify(params) {
9
+ return this.inner.stringify(params);
10
+ }
11
+ /**
12
+ * @private
13
+ */
14
+ static from(params) {
15
+ return new Condition(conditionExpression(params));
16
+ }
17
+ }
18
+ // TODO: not meant to be exported publicly.
19
+ export function condition(params) {
20
+ return Condition.from(params);
21
+ }
22
+ //# sourceMappingURL=condition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/condition.ts"],"names":[],"mappings":"AAOA,OAAO,EAA4B,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAahF,uBAAuB;AACvB,MAAM,OAAO,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,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;CACF;AAED,2CAA2C;AAC3C,MAAM,UAAU,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,23 @@
1
+ import { comparison, isComparison } from "./comparisons.js";
2
+ export class ConditionExpression {
3
+ stringifier;
4
+ constructor(stringifier) {
5
+ this.stringifier = stringifier;
6
+ }
7
+ stringify(params) {
8
+ const { names, values } = params;
9
+ return this.stringifier({ names, values });
10
+ }
11
+ /**
12
+ * @private
13
+ */
14
+ static from(params) {
15
+ const { stringify } = params;
16
+ return new ConditionExpression(stringify);
17
+ }
18
+ }
19
+ // TODO: module visibility.
20
+ export function conditionExpression(params) {
21
+ return isComparison(params) ? comparison(params) : params;
22
+ }
23
+ //# sourceMappingURL=expression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/expression.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAG5D,MAAM,OAAO,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;AAED,2BAA2B;AAC3B,MAAM,UAAU,mBAAmB,CACjC,MAAuB;IAEvB,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,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,73 @@
1
+ import { ConditionExpression } from "./expression.js";
2
+ /**
3
+ * Returns a condition that uses the `attribute_exists` function.
4
+ *
5
+ * @param attribute - The attribute path to check for existence.
6
+ * @returns A {@link ConditionExpression} that evaluates to true if the provided attribute path exists.
7
+ *
8
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
9
+ */
10
+ export function attributeExists(attribute) {
11
+ return ConditionExpression.from({
12
+ stringify: ({ names }) => `attribute_exists(${attribute.substitute({ names })})`,
13
+ });
14
+ }
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 function attributeNotExists(attribute) {
24
+ return ConditionExpression.from({
25
+ stringify: ({ names }) => `attribute_not_exists(${attribute.substitute({ names })})`,
26
+ });
27
+ }
28
+ /**
29
+ * Returns a condition that uses the `attribute_type` function.
30
+ *
31
+ * @param attribute - The attribute path to check.
32
+ * @param type - The expected type of the attribute.
33
+ *
34
+ * @returns A {@link ConditionExpression} that evaluates to true if the attribute is of the expected type.
35
+ *
36
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
37
+ */
38
+ export function attributeType(attribute, type) {
39
+ return ConditionExpression.from({
40
+ stringify: ({ names, values }) => `attribute_type(${attribute.substitute({ names })}, ${type.substitute({ values })})`,
41
+ });
42
+ }
43
+ /**
44
+ * Returns a condition that uses the `begins_with` function.
45
+ *
46
+ * @param first - The first function operand, which is the attribute or value to check.
47
+ * @param second - The second function operand, which is the prefix to validate against.
48
+ *
49
+ * @returns A {@link ConditionExpression} that evaluates to true if the first operand begins with the second.
50
+ *
51
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
52
+ */
53
+ export function beginsWith(first, second) {
54
+ return ConditionExpression.from({
55
+ stringify: ({ names, values }) => `begins_with(${first.substitute({ names, values })}, ${second.substitute({ names, values })})`,
56
+ });
57
+ }
58
+ /**
59
+ * Returns a condition that uses the `contains` function.
60
+ *
61
+ * @param first - The first function operand, which is the attribute or value to check.
62
+ * @param second - The second function operand, which is the value to check for containment.
63
+ *
64
+ * @returns A {@link ConditionExpression} that evaluates to true if this operand contains the provided one.
65
+ *
66
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
67
+ */
68
+ export function contains(first, second) {
69
+ return ConditionExpression.from({
70
+ stringify: ({ names, values }) => `contains(${first.substitute({ names, values })}, ${second.substitute({ names, values })})`,
71
+ });
72
+ }
73
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/functions.ts"],"names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AACL,CAAC;AAWD;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,KAA2B,EAC3B,MAA6B;IAE7B,OAAO,mBAAmB,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,5 @@
1
+ export * from "./condition.js";
2
+ export * from "./functions.js";
3
+ export * from "./logic.js";
4
+ export * from "./size.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ConditionParams } from "./condition.js";
2
+ import { ConditionExpression } from "./expression.js";
3
+ /**
4
+ * Negates the provided condition using the `NOT` operator.
5
+ *
6
+ * @param condition - The condition to negate.
7
+ *
8
+ * @returns A {@link ConditionExpression} that evaluates to the opposite of what the provided condition evaluates to.
9
+ *
10
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
11
+ */
12
+ export declare function not(condition: ConditionParams): ConditionExpression;
13
+ /**
14
+ * Returns a condition that combines the provided ones using the `AND` operator.
15
+ *
16
+ * @param lhs - The first condition to combine.
17
+ * @param rhs - The second condition to combine.
18
+ *
19
+ * @returns A {@link ConditionExpression} that evaluates to true only if both conditions evaluate to true.
20
+ *
21
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
22
+ */
23
+ export declare function and(lhs: ConditionParams, rhs: ConditionParams): ConditionExpression;
24
+ /**
25
+ * Returns a condition that combines the provided ones using the `OR` operator.
26
+ *
27
+ * @param lhs - The first condition to combine.
28
+ * @param rhs - The second condition to combine.
29
+ *
30
+ * @returns A {@link ConditionExpression} that evaluates to true if any conditions evaluate to true.
31
+ *
32
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
33
+ */
34
+ export declare function or(lhs: ConditionParams, rhs: ConditionParams): ConditionExpression;
@@ -0,0 +1,63 @@
1
+ import { ConditionExpression, conditionExpression } from "./expression.js";
2
+ /**
3
+ * Negates the provided condition using the `NOT` operator.
4
+ *
5
+ * @param condition - The condition to negate.
6
+ *
7
+ * @returns A {@link ConditionExpression} that evaluates to the opposite of what the provided condition evaluates to.
8
+ *
9
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
10
+ */
11
+ export function not(condition) {
12
+ const expression = conditionExpression(condition);
13
+ return ConditionExpression.from({
14
+ stringify: ({ names, values }) => {
15
+ return `(NOT ${expression.stringify({ names, values })})`;
16
+ },
17
+ });
18
+ }
19
+ /**
20
+ * Returns a condition that combines the provided ones using the `AND` operator.
21
+ *
22
+ * @param lhs - The first condition to combine.
23
+ * @param rhs - The second condition to combine.
24
+ *
25
+ * @returns A {@link ConditionExpression} that evaluates to true only if both conditions evaluate to true.
26
+ *
27
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
28
+ */
29
+ export function and(lhs, rhs) {
30
+ const left = conditionExpression(lhs);
31
+ const right = conditionExpression(rhs);
32
+ return ConditionExpression.from({
33
+ stringify: ({ names, values }) => {
34
+ return `(${left.stringify({ names, values })} AND ${right.stringify({
35
+ names,
36
+ values,
37
+ })})`;
38
+ },
39
+ });
40
+ }
41
+ /**
42
+ * Returns a condition that combines the provided ones using the `OR` operator.
43
+ *
44
+ * @param lhs - The first condition to combine.
45
+ * @param rhs - The second condition to combine.
46
+ *
47
+ * @returns A {@link ConditionExpression} that evaluates to true if any conditions evaluate to true.
48
+ *
49
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
50
+ */
51
+ export function or(lhs, rhs) {
52
+ const left = conditionExpression(lhs);
53
+ const right = conditionExpression(rhs);
54
+ return ConditionExpression.from({
55
+ stringify: ({ names, values }) => {
56
+ return `(${left.stringify({ names, values })} OR ${right.stringify({
57
+ names,
58
+ values,
59
+ })})`;
60
+ },
61
+ });
62
+ }
63
+ //# sourceMappingURL=logic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/logic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,CAAC,SAA0B;IAC5C,MAAM,UAAU,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAClD,OAAO,mBAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/B,OAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,GAAG,CACjB,GAAoB,EACpB,GAAoB;IAEpB,MAAM,IAAI,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,mBAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/B,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,QAAQ,KAAK,CAAC,SAAS,CAAC;gBAClE,KAAK;gBACL,MAAM;aACP,CAAC,GAAG,CAAC;QACR,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,EAAE,CAChB,GAAoB,EACpB,GAAoB;IAEpB,MAAM,IAAI,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,mBAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/B,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,OAAO,KAAK,CAAC,SAAS,CAAC;gBACjE,KAAK;gBACL,MAAM;aACP,CAAC,GAAG,CAAC;QACR,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { NativeBinary, NativeList, NativeMap, NativeSet, NativeString } from "../../../types.js";
2
+ import type { AttributeNames, AttributeValues } from "../../attributes/index.js";
3
+ import type { PathOperand } from "../operands/path.js";
4
+ import type { IOperand } from "../operands/type.js";
5
+ import type { ValueOperand } from "../operands/value.js";
6
+ /**
7
+ * This type aggregates the types of operands that can be used with the {@link size} function.
8
+ *
9
+ * @see size
10
+ * @see PathOperand
11
+ * @see ValueOperand
12
+ */
13
+ export type SizeOperand = PathOperand | ValueOperand<NativeBinary | NativeList | NativeMap | NativeSet | NativeString>;
14
+ /**
15
+ * A type representing the result of the {@link size} function as an operand to be used in expressions.
16
+ */
17
+ export declare class Size implements IOperand {
18
+ private readonly inner;
19
+ constructor(operand: SizeOperand);
20
+ substitute(params: {
21
+ names: AttributeNames;
22
+ values: AttributeValues;
23
+ }): string;
24
+ /**
25
+ * @private
26
+ */
27
+ static from(operand: SizeOperand): Size;
28
+ }
29
+ /**
30
+ * Creates a new {@link Size} operand to be nested in expressions.
31
+ *
32
+ * @param operand - The operand to calculate the size of.
33
+ * @returns A new {@link Size} operand.
34
+ *
35
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
36
+ */
37
+ export declare function size(operand: SizeOperand): Size;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A type representing the result of the {@link size} function as an operand to be used in expressions.
3
+ */
4
+ export class Size {
5
+ inner;
6
+ constructor(operand) {
7
+ this.inner = operand;
8
+ }
9
+ substitute(params) {
10
+ return `size(${this.inner.substitute(params)})`;
11
+ }
12
+ /**
13
+ * @private
14
+ */
15
+ static from(operand) {
16
+ return new Size(operand);
17
+ }
18
+ }
19
+ /**
20
+ * Creates a new {@link Size} operand to be nested in expressions.
21
+ *
22
+ * @param operand - The operand to calculate the size of.
23
+ * @returns A new {@link Size} operand.
24
+ *
25
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
26
+ */
27
+ export function size(operand) {
28
+ return Size.from(operand);
29
+ }
30
+ //# sourceMappingURL=size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/size.ts"],"names":[],"mappings":"AA4BA;;GAEG;AACH,MAAM,OAAO,IAAI;IACE,KAAK,CAAc;IAEpC,YAAY,OAAoB;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IACvB,CAAC;IAED,UAAU,CAAC,MAGV;QACC,OAAO,QAAQ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,OAAoB;QAC9B,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,OAAoB;IACvC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC"}