@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
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { PathOperand, } from "./operands/index.js";
|
|
2
|
-
export class Condition {
|
|
3
|
-
stringifier;
|
|
4
|
-
constructor(params) {
|
|
5
|
-
const { stringify } = params;
|
|
6
|
-
this.stringifier = stringify;
|
|
7
|
-
}
|
|
8
|
-
// TODO: exclude from exported type definitions if possible.
|
|
9
|
-
stringify(params) {
|
|
10
|
-
return this.stringifier(params);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns a condition that combines this one with the provided condition using the `AND` operator.
|
|
14
|
-
*
|
|
15
|
-
* @param other - The other condition to combine with this one.
|
|
16
|
-
*
|
|
17
|
-
* @returns A {@link Condition} that evaluates to true only if both conditions evaluate to true.
|
|
18
|
-
*
|
|
19
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
|
|
20
|
-
*/
|
|
21
|
-
and(other) {
|
|
22
|
-
return Condition.from({
|
|
23
|
-
stringify: ({ names, values }) => {
|
|
24
|
-
const left = this.stringify({ names, values });
|
|
25
|
-
const right = other.stringify({ names, values });
|
|
26
|
-
return `(${left} AND ${right})`;
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Returns a condition that combines this one with the provided condition using the `OR` operator.
|
|
32
|
-
*
|
|
33
|
-
* @param other - The other condition to combine with this one.
|
|
34
|
-
*
|
|
35
|
-
* @returns A {@link Condition} that evaluates to true if any conditions evaluate to true.
|
|
36
|
-
*
|
|
37
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
|
|
38
|
-
*/
|
|
39
|
-
or(other) {
|
|
40
|
-
return Condition.from({
|
|
41
|
-
stringify: ({ names, values }) => {
|
|
42
|
-
const left = this.stringify({ names, values });
|
|
43
|
-
const right = other.stringify({ names, values });
|
|
44
|
-
return `(${left} OR ${right})`;
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Factory method to create a new {@link Condition} instance.
|
|
50
|
-
*
|
|
51
|
-
* This is not meant to be called outside this package.
|
|
52
|
-
*
|
|
53
|
-
* @param params - The parameters to create the condition.
|
|
54
|
-
*
|
|
55
|
-
* @returns A new {@link Condition} instance.
|
|
56
|
-
*/
|
|
57
|
-
static from(params) {
|
|
58
|
-
return new Condition(params);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Negates the provided condition using the `NOT` operator.
|
|
63
|
-
*
|
|
64
|
-
* @param inner - The condition to negate.
|
|
65
|
-
*
|
|
66
|
-
* @returns A {@link Condition} that evaluates to the opposite of what the provided condition evaluates to.
|
|
67
|
-
*
|
|
68
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.LogicalEvaluations
|
|
69
|
-
*/
|
|
70
|
-
export function not(inner) {
|
|
71
|
-
return Condition.from({
|
|
72
|
-
stringify: ({ names, values }) => {
|
|
73
|
-
return `NOT (${inner.stringify({ names, values })})`;
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
// NOTE: methods here means that both sides of the conditions can either be attribute names or attribute values.
|
|
78
|
-
export class OperandConditionBuilder {
|
|
79
|
-
operand;
|
|
80
|
-
constructor(operand) {
|
|
81
|
-
this.operand = operand;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Returns a condition that uses the `begins_with` function.
|
|
85
|
-
*
|
|
86
|
-
* @param rhs - The right hand side operand.
|
|
87
|
-
*
|
|
88
|
-
* @returns A {@link Condition} that evaluates to true if this operand begins with the provided one.
|
|
89
|
-
*
|
|
90
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
91
|
-
*/
|
|
92
|
-
beginsWith(rhs) {
|
|
93
|
-
return Condition.from({
|
|
94
|
-
stringify: ({ names, values }) => {
|
|
95
|
-
return `begins_with(${this.substitute({ names, values })}, ${rhs.substitute({ names, values })})`;
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Returns a condition that uses the `BETWEEN` operator.
|
|
101
|
-
*
|
|
102
|
-
* Both bounds are inclusive, meaning that the returned condition corresponds to `lower <= this <= upper`.
|
|
103
|
-
*
|
|
104
|
-
* @param lower - The lower inclusive bound of the range.
|
|
105
|
-
* @param upper - The upper inclusive bound of the range.
|
|
106
|
-
*
|
|
107
|
-
* @returns A {@link Condition} that evaluates to true if this operand is within the provided bounds.
|
|
108
|
-
*
|
|
109
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
110
|
-
*/
|
|
111
|
-
// TODO: test with size operands.
|
|
112
|
-
between(lower, upper) {
|
|
113
|
-
return Condition.from({
|
|
114
|
-
stringify: ({ names, values }) => {
|
|
115
|
-
return `${this.substitute({ names, values })} BETWEEN ${lower.substitute({ names, values })} AND ${upper.substitute({ names, values })}`;
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Returns a condition that uses the `contains` function.
|
|
121
|
-
*
|
|
122
|
-
* @param rhs - The right hand side operand.
|
|
123
|
-
*
|
|
124
|
-
* @returns A {@link Condition} that evaluates to true if this operand contains the provided one.
|
|
125
|
-
*
|
|
126
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
127
|
-
*/
|
|
128
|
-
// TODO: test with size operands.
|
|
129
|
-
contains(rhs) {
|
|
130
|
-
return Condition.from({
|
|
131
|
-
stringify: ({ names, values }) => {
|
|
132
|
-
return `contains(${this.substitute({ names, values })}, ${rhs.substitute({ names, values })})`;
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Returns a condition that uses the `=` operator.
|
|
138
|
-
*
|
|
139
|
-
* @param rhs - The right hand side operand.
|
|
140
|
-
*
|
|
141
|
-
* @returns A {@link Condition} that evaluates to true if this operand is equal to the provided one.
|
|
142
|
-
*
|
|
143
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
144
|
-
*/
|
|
145
|
-
// TODO: this should be typed better once moved out. It accepts the interface only to make the tests compile.
|
|
146
|
-
equals(rhs) {
|
|
147
|
-
return Condition.from({
|
|
148
|
-
stringify: ({ names, values }) => {
|
|
149
|
-
return `${this.substitute({ names, values })} = ${rhs.substitute({ names, values })}`;
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* An alias for {@link equals}.
|
|
155
|
-
*/
|
|
156
|
-
eq = this.equals.bind(this);
|
|
157
|
-
/**
|
|
158
|
-
* Returns a condition that uses the `>` operator.
|
|
159
|
-
*
|
|
160
|
-
* @param rhs - The right hand side operand.
|
|
161
|
-
*
|
|
162
|
-
* @returns A {@link Condition} that evaluates to true if this operand is greater than the provided one.
|
|
163
|
-
*
|
|
164
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
165
|
-
*/
|
|
166
|
-
// TODO: test that both sides can be size manually, then add the unit tests if it makes sense.
|
|
167
|
-
greaterThan(rhs) {
|
|
168
|
-
return Condition.from({
|
|
169
|
-
stringify: ({ names, values }) => {
|
|
170
|
-
return `${this.substitute({ names, values })} > ${rhs.substitute({ names, values })}`;
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* An alias for {@link greaterThan}.
|
|
176
|
-
*/
|
|
177
|
-
gt = this.greaterThan.bind(this);
|
|
178
|
-
/**
|
|
179
|
-
* Returns a condition that uses the `>=` operator.
|
|
180
|
-
*
|
|
181
|
-
* @param rhs - The right hand side operand.
|
|
182
|
-
*
|
|
183
|
-
* @returns A {@link Condition} that evaluates to true if this operand is greater than or equal to the provided one.
|
|
184
|
-
*
|
|
185
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
186
|
-
*/
|
|
187
|
-
// TODO: test that both sides can be size manually, then add the unit tests if it makes sense.
|
|
188
|
-
greaterThanOrEquals(rhs) {
|
|
189
|
-
return Condition.from({
|
|
190
|
-
stringify: ({ names, values }) => {
|
|
191
|
-
return `${this.substitute({ names, values })} >= ${rhs.substitute({ names, values })}`;
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* An alias for {@link greaterThanOrEquals}
|
|
197
|
-
*/
|
|
198
|
-
gte = this.greaterThanOrEquals.bind(this);
|
|
199
|
-
/**
|
|
200
|
-
* Returns a condition that uses the `IN` operator.
|
|
201
|
-
*
|
|
202
|
-
* @param operands - The list of operands to check against. This function throws if the list is
|
|
203
|
-
* empty or contains more than 100 operands.
|
|
204
|
-
*
|
|
205
|
-
* @returns A {@link Condition} that evaluates to true if this operand is equal to any of the provided ones.
|
|
206
|
-
*
|
|
207
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
208
|
-
*/
|
|
209
|
-
// TODO: test that both sides can be size manually, then add the unit tests if it makes sense.
|
|
210
|
-
in(...operands) {
|
|
211
|
-
if (operands.length === 0) {
|
|
212
|
-
throw new Error("the IN operator requires at least one operand.");
|
|
213
|
-
}
|
|
214
|
-
if (operands.length > 100) {
|
|
215
|
-
throw new Error(`up to 100 operands are support for the IN operator, got ${operands.length}`);
|
|
216
|
-
}
|
|
217
|
-
return Condition.from({
|
|
218
|
-
stringify: ({ names, values }) => {
|
|
219
|
-
const operandsString = operands
|
|
220
|
-
.map((operand) => operand.substitute({ names, values }))
|
|
221
|
-
.join(",");
|
|
222
|
-
return `${this.substitute({ names, values })} IN (${operandsString})`;
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Returns a condition that uses the `<` operator
|
|
228
|
-
*
|
|
229
|
-
* @param rhs - The right hand side operand.
|
|
230
|
-
*
|
|
231
|
-
* @returns A {@link Condition} that evaluates to true if this operand is lower than the provided one.
|
|
232
|
-
*
|
|
233
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
234
|
-
*/
|
|
235
|
-
// TODO: test that both sides can be size manually, then add the unit tests if it makes sense.
|
|
236
|
-
lowerThan(rhs) {
|
|
237
|
-
return Condition.from({
|
|
238
|
-
stringify: ({ names, values }) => {
|
|
239
|
-
return `${this.substitute({ names, values })} < ${rhs.substitute({ names, values })}`;
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* An alias for {@link lowerThan}.
|
|
245
|
-
*/
|
|
246
|
-
lt = this.lowerThan.bind(this);
|
|
247
|
-
/**
|
|
248
|
-
* Returns a condition that uses the `<=` operator.
|
|
249
|
-
*
|
|
250
|
-
* @param rhs - The right hand side operand.
|
|
251
|
-
*
|
|
252
|
-
* @returns A {@link Condition} that evaluates to true if this operand is lower than or equal to the provided one.
|
|
253
|
-
*
|
|
254
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
255
|
-
*/
|
|
256
|
-
//TODO: test that both sides can be size manually, then add the unit tests if it makes sense.
|
|
257
|
-
lowerThanOrEquals(rhs) {
|
|
258
|
-
return Condition.from({
|
|
259
|
-
stringify: ({ names, values }) => {
|
|
260
|
-
return `${this.substitute({ names, values })} <= ${rhs.substitute({ names, values })}`;
|
|
261
|
-
},
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* An alias for {@link lowerThanOrEquals}
|
|
266
|
-
*/
|
|
267
|
-
lte = this.lowerThanOrEquals.bind(this);
|
|
268
|
-
/**
|
|
269
|
-
* Returns a condition that uses the `<>` operator.
|
|
270
|
-
*
|
|
271
|
-
* @param rhs - The right hand side operand.
|
|
272
|
-
*
|
|
273
|
-
* @returns A {@link Condition} that evaluates to true if this operand is not equal to the provided one.
|
|
274
|
-
*
|
|
275
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
276
|
-
*/
|
|
277
|
-
notEquals(rhs) {
|
|
278
|
-
return Condition.from({
|
|
279
|
-
stringify: ({ names, values }) => {
|
|
280
|
-
return `${this.substitute({ names, values })} <> ${rhs.substitute({ names, values })}`;
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* An alias for {@link notEquals}.
|
|
286
|
-
*/
|
|
287
|
-
ne = this.notEquals.bind(this);
|
|
288
|
-
substitute(params) {
|
|
289
|
-
return this.operand.substitute(params);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
// A specialized class with more capabilities.
|
|
293
|
-
export class AttributeConditionBuilder extends OperandConditionBuilder {
|
|
294
|
-
/**
|
|
295
|
-
* @returns A {@link Condition} that evaluates to true if the provided attribute path exists.
|
|
296
|
-
*/
|
|
297
|
-
// NOTE: the left hand side of this condition can only be a literal value (tested)
|
|
298
|
-
exists() {
|
|
299
|
-
return Condition.from({
|
|
300
|
-
stringify: ({ names, values }) => {
|
|
301
|
-
return `attribute_exists(${this.substitute({ names, values })})`;
|
|
302
|
-
},
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* @returns A {@link Condition} that evaluates to true if the provided attribute path does not exist.
|
|
307
|
-
*/
|
|
308
|
-
// NOTE: the left hand side of this condition can only be a literal value (tested)
|
|
309
|
-
notExists() {
|
|
310
|
-
return Condition.from({
|
|
311
|
-
stringify: ({ names, values }) => {
|
|
312
|
-
return `attribute_not_exists(${this.substitute({ names, values })})`;
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* @param type - The type to check against.
|
|
318
|
-
* @returns A {@link Condition} that evaluates to true if there exists an attribute at
|
|
319
|
-
* the provided path of the given type.
|
|
320
|
-
*/
|
|
321
|
-
// NOTE: the left hand side of this condition *can be* an attribute value pointing to a valid path.
|
|
322
|
-
// NOTE: the right hand side of this condition *must be* an condition attribute (not a literal).
|
|
323
|
-
isType(type) {
|
|
324
|
-
return Condition.from({
|
|
325
|
-
stringify: ({ names, values }) => {
|
|
326
|
-
return `attribute_type(${this.substitute({ names, values })}, ${type.substitute({ values })})`;
|
|
327
|
-
},
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
export function where(operand) {
|
|
332
|
-
if (operand instanceof PathOperand) {
|
|
333
|
-
return new AttributeConditionBuilder(operand);
|
|
334
|
-
}
|
|
335
|
-
return new OperandConditionBuilder(operand);
|
|
336
|
-
}
|
|
337
|
-
// TODO: type this as a "value operand" of type number if possiburu or useful?
|
|
338
|
-
export class SizeOperand {
|
|
339
|
-
inner;
|
|
340
|
-
constructor(operand) {
|
|
341
|
-
this.inner = operand;
|
|
342
|
-
}
|
|
343
|
-
substitute(params) {
|
|
344
|
-
return `size(${this.inner.substitute(params)})`;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
export function size(operand) {
|
|
348
|
-
return new SizeOperand(operand);
|
|
349
|
-
}
|
|
350
|
-
//# sourceMappingURL=condition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,WAAW,GAEZ,MAAM,qBAAqB,CAAC;AAmB7B,MAAM,OAAO,SAAS;IACH,WAAW,CAAc;IAE1C,YAAoB,MAAuB;QACzC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,4DAA4D;IAC5D,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,KAAgB;QAClB,OAAO,SAAS,CAAC,IAAI,CAAC;YACpB,SAAS,EAAE,CA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