@infra-blocks/aws-dynamodb 0.15.0 → 0.16.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/commands/expressions/condition.d.ts +213 -2
- package/lib/cjs/commands/expressions/condition.js +349 -0
- package/lib/cjs/commands/expressions/condition.js.map +1 -1
- package/lib/cjs/commands/expressions/index.d.ts +2 -1
- package/lib/cjs/commands/expressions/index.js +2 -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.d.ts +28 -0
- package/lib/cjs/commands/expressions/operands.js +34 -0
- package/lib/cjs/commands/expressions/operands.js.map +1 -0
- package/lib/cjs/commands/put-item.d.ts +2 -2
- package/lib/cjs/commands/put-item.js.map +1 -1
- package/lib/esm/commands/expressions/condition.d.ts +213 -2
- package/lib/esm/commands/expressions/condition.js +341 -1
- package/lib/esm/commands/expressions/condition.js.map +1 -1
- package/lib/esm/commands/expressions/index.d.ts +2 -1
- package/lib/esm/commands/expressions/index.js +2 -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.d.ts +28 -0
- package/lib/esm/commands/expressions/operands.js +27 -0
- package/lib/esm/commands/expressions/operands.js.map +1 -0
- package/lib/esm/commands/put-item.d.ts +2 -2
- package/lib/esm/commands/put-item.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/commands/expressions/expression.d.ts +0 -185
- package/lib/cjs/commands/expressions/expression.js +0 -326
- package/lib/cjs/commands/expressions/expression.js.map +0 -1
- package/lib/esm/commands/expressions/expression.d.ts +0 -185
- package/lib/esm/commands/expressions/expression.js +0 -315
- package/lib/esm/commands/expressions/expression.js.map +0 -1
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import type { AttributePath, AttributeType, AttributeValue } from "../../types.js";
|
|
2
|
-
import type { AttributeNames } from "../attributes/names.js";
|
|
3
|
-
import type { AttributeValues } from "../attributes/values.js";
|
|
4
|
-
export type Stringifier = (params: {
|
|
5
|
-
names: AttributeNames;
|
|
6
|
-
values: AttributeValues;
|
|
7
|
-
}) => string;
|
|
8
|
-
export interface ExpressionParams {
|
|
9
|
-
stringify: Stringifier;
|
|
10
|
-
}
|
|
11
|
-
export declare class Expression {
|
|
12
|
-
private readonly stringifier;
|
|
13
|
-
constructor(params: ExpressionParams);
|
|
14
|
-
/**
|
|
15
|
-
* Returns an expression that combines this one with the provided expression using the `AND` operator.
|
|
16
|
-
*
|
|
17
|
-
* @param other - The other expression to combine with this one.
|
|
18
|
-
* @returns An {@link Expression} that is true only if both expressions are true.
|
|
19
|
-
*/
|
|
20
|
-
and(other: Expression): Expression;
|
|
21
|
-
/**
|
|
22
|
-
* Returns an expression that combines this one with the provided expression using the `OR` operator.
|
|
23
|
-
*
|
|
24
|
-
* @param other - The other expression to combine with this one.
|
|
25
|
-
* @returns An {@link Expression} that is true if any of the expressions is true.
|
|
26
|
-
*/
|
|
27
|
-
or(other: Expression): Expression;
|
|
28
|
-
stringify(params: {
|
|
29
|
-
names: AttributeNames;
|
|
30
|
-
values: AttributeValues;
|
|
31
|
-
}): string;
|
|
32
|
-
}
|
|
33
|
-
export declare function expression(params: ExpressionParams): Expression;
|
|
34
|
-
/**
|
|
35
|
-
* Negates the provided expression using the `NOT` operator.
|
|
36
|
-
*
|
|
37
|
-
* @param expression - The expression to negate.
|
|
38
|
-
* @returns An {@link Expression} that corresponds to the negation the provided expression.
|
|
39
|
-
*/
|
|
40
|
-
export declare function not(expression: Expression): Expression;
|
|
41
|
-
export declare abstract class Operand {
|
|
42
|
-
protected constructor();
|
|
43
|
-
beginsWith(rhs: Operand): Expression;
|
|
44
|
-
/**
|
|
45
|
-
* Returns an expression that checks if this operand is between the two provided ones using the `BETWEEN` operator.
|
|
46
|
-
*
|
|
47
|
-
* Both bounds are inclusive, meaning that the returned expression corresponds to `lower <= this <= upper`.
|
|
48
|
-
*
|
|
49
|
-
* @param lower - The lower inclusive bound of the range.
|
|
50
|
-
* @param upper - The upper inclusive bound of the range.
|
|
51
|
-
*
|
|
52
|
-
* @returns An {@link Expression} that is true if this operand is between the two provided bounds.
|
|
53
|
-
*/
|
|
54
|
-
between(lower: Operand, upper: Operand): Expression;
|
|
55
|
-
contains(rhs: Operand): Expression;
|
|
56
|
-
/**
|
|
57
|
-
* Tests that two operands are equals.
|
|
58
|
-
*
|
|
59
|
-
* This uses the `=` operator.
|
|
60
|
-
*
|
|
61
|
-
* @param rhs - The right hand side operand.
|
|
62
|
-
*
|
|
63
|
-
* @returns The corresponding {@link Expression}.
|
|
64
|
-
*/
|
|
65
|
-
equals(rhs: Operand): Expression;
|
|
66
|
-
/**
|
|
67
|
-
* An alias for {@link equals}.
|
|
68
|
-
*/
|
|
69
|
-
eq: (rhs: Operand) => Expression;
|
|
70
|
-
/**
|
|
71
|
-
* Tests that this operand is greater than the right operand.
|
|
72
|
-
*
|
|
73
|
-
* This uses the `>` operator.
|
|
74
|
-
*
|
|
75
|
-
* @param rhs - The right hand side operand.
|
|
76
|
-
*
|
|
77
|
-
* @returns The corresponding {@link Expression}.
|
|
78
|
-
*/
|
|
79
|
-
greaterThan(rhs: Operand): Expression;
|
|
80
|
-
/**
|
|
81
|
-
* Tests that this operand is greater than or equals to the right operand.
|
|
82
|
-
*
|
|
83
|
-
* This uses the `>=` operator.
|
|
84
|
-
*
|
|
85
|
-
* @param rhs - The right hand side operand.
|
|
86
|
-
*
|
|
87
|
-
* @returns The corresponding {@link Expression}.
|
|
88
|
-
*/
|
|
89
|
-
greaterThanOrEquals(rhs: Operand): Expression;
|
|
90
|
-
/**
|
|
91
|
-
* An alias for {@link greaterThan}.
|
|
92
|
-
*/
|
|
93
|
-
gt: (rhs: Operand) => Expression;
|
|
94
|
-
/**
|
|
95
|
-
* An alias for {@link greaterThanOrEquals}
|
|
96
|
-
*/
|
|
97
|
-
gte: (rhs: Operand) => Expression;
|
|
98
|
-
/**
|
|
99
|
-
* Tests that this operand is contained within the provided list.
|
|
100
|
-
*
|
|
101
|
-
* This uses the `IN` operator.
|
|
102
|
-
*
|
|
103
|
-
* @param operands - The list of operands to check against. This function throws if the list is
|
|
104
|
-
* empty or contains more than 100 operands.
|
|
105
|
-
*
|
|
106
|
-
* @returns The corresponding {@link Expression} that is true if this operand is contained within the provided list.
|
|
107
|
-
*/
|
|
108
|
-
in(...operands: Operand[]): Expression;
|
|
109
|
-
/**
|
|
110
|
-
* Tests that this operand is lower than the right operand.
|
|
111
|
-
*
|
|
112
|
-
* This uses the `<` operator.
|
|
113
|
-
*
|
|
114
|
-
* @param rhs - The right hand side operand.
|
|
115
|
-
*
|
|
116
|
-
* @returns The corresponding {@link Expression}.
|
|
117
|
-
*/
|
|
118
|
-
lowerThan(rhs: Operand): Expression;
|
|
119
|
-
/**
|
|
120
|
-
* Tests that this operand is lower than or equals to the right operand.
|
|
121
|
-
*
|
|
122
|
-
* This uses the `<=` operator.
|
|
123
|
-
*
|
|
124
|
-
* @param rhs - The right hand side operand.
|
|
125
|
-
*
|
|
126
|
-
* @returns The corresponding {@link Expression}.
|
|
127
|
-
*/
|
|
128
|
-
lowerThanOrEquals(rhs: Operand): Expression;
|
|
129
|
-
/**
|
|
130
|
-
* An alias for {@link lowerThan}.
|
|
131
|
-
*/
|
|
132
|
-
lt: (rhs: Operand) => Expression;
|
|
133
|
-
/**
|
|
134
|
-
* An alias for {@link lowerThanOrEquals}
|
|
135
|
-
*/
|
|
136
|
-
lte: (rhs: Operand) => Expression;
|
|
137
|
-
/**
|
|
138
|
-
* Tests that two operands are not equals.
|
|
139
|
-
*
|
|
140
|
-
* This is the opposite of {@link equals} and it uses the `<>` operator.
|
|
141
|
-
*
|
|
142
|
-
* @param rhs - The right hand side operand.
|
|
143
|
-
*
|
|
144
|
-
* @returns The corresponding {@link Expression}.
|
|
145
|
-
*/
|
|
146
|
-
notEquals(rhs: Operand): Expression;
|
|
147
|
-
/**
|
|
148
|
-
* An alias for {@link notEquals}.
|
|
149
|
-
*/
|
|
150
|
-
ne: (rhs: Operand) => Expression;
|
|
151
|
-
size(): Operand;
|
|
152
|
-
abstract substitute(params: {
|
|
153
|
-
names: AttributeNames;
|
|
154
|
-
values: AttributeValues;
|
|
155
|
-
}): string;
|
|
156
|
-
}
|
|
157
|
-
export declare class ExpressionAttribute extends Operand {
|
|
158
|
-
private readonly path;
|
|
159
|
-
constructor(path: AttributePath);
|
|
160
|
-
/**
|
|
161
|
-
* @returns An {@link Expression} that returns true if the provided attribute path exists.
|
|
162
|
-
*/
|
|
163
|
-
exists(): Expression;
|
|
164
|
-
/**
|
|
165
|
-
* @param type - The type to check against.
|
|
166
|
-
* @returns An {@link Expression} that returns true if there exists an attribute at
|
|
167
|
-
* the provided path of the given type.
|
|
168
|
-
*/
|
|
169
|
-
isType(type: ExpressionValue<AttributeType>): Expression;
|
|
170
|
-
notExists(): Expression;
|
|
171
|
-
substitute(params: {
|
|
172
|
-
names: AttributeNames;
|
|
173
|
-
values: AttributeValues;
|
|
174
|
-
}): string;
|
|
175
|
-
}
|
|
176
|
-
export declare function attribute(path: AttributePath): ExpressionAttribute;
|
|
177
|
-
export declare class ExpressionValue<T extends AttributeValue> extends Operand {
|
|
178
|
-
private readonly value;
|
|
179
|
-
constructor(value: T);
|
|
180
|
-
substitute(params: {
|
|
181
|
-
names: AttributeNames;
|
|
182
|
-
values: AttributeValues;
|
|
183
|
-
}): string;
|
|
184
|
-
}
|
|
185
|
-
export declare function value<T extends AttributeValue = AttributeValue>(value: AttributeValue): ExpressionValue<T>;
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
// TODO: once we have a working structure, retype everything so that it's type safe for condition expression vs key condition expression vs update expression.
|
|
2
|
-
export class Expression {
|
|
3
|
-
stringifier;
|
|
4
|
-
constructor(params) {
|
|
5
|
-
const { stringify } = params;
|
|
6
|
-
this.stringifier = stringify;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Returns an expression that combines this one with the provided expression using the `AND` operator.
|
|
10
|
-
*
|
|
11
|
-
* @param other - The other expression to combine with this one.
|
|
12
|
-
* @returns An {@link Expression} that is true only if both expressions are true.
|
|
13
|
-
*/
|
|
14
|
-
and(other) {
|
|
15
|
-
return new Expression({
|
|
16
|
-
stringify: ({ names, values }) => {
|
|
17
|
-
const left = this.stringify({ names, values });
|
|
18
|
-
const right = other.stringify({ names, values });
|
|
19
|
-
return `(${left} AND ${right})`;
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Returns an expression that combines this one with the provided expression using the `OR` operator.
|
|
25
|
-
*
|
|
26
|
-
* @param other - The other expression to combine with this one.
|
|
27
|
-
* @returns An {@link Expression} that is true if any of the expressions is true.
|
|
28
|
-
*/
|
|
29
|
-
or(other) {
|
|
30
|
-
return new Expression({
|
|
31
|
-
stringify: ({ names, values }) => {
|
|
32
|
-
const left = this.stringify({ names, values });
|
|
33
|
-
const right = other.stringify({ names, values });
|
|
34
|
-
return `(${left} OR ${right})`;
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
stringify(params) {
|
|
39
|
-
return this.stringifier(params);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function expression(params) {
|
|
43
|
-
return new Expression(params);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Negates the provided expression using the `NOT` operator.
|
|
47
|
-
*
|
|
48
|
-
* @param expression - The expression to negate.
|
|
49
|
-
* @returns An {@link Expression} that corresponds to the negation the provided expression.
|
|
50
|
-
*/
|
|
51
|
-
export function not(expression) {
|
|
52
|
-
return new Expression({
|
|
53
|
-
stringify: ({ names, values }) => {
|
|
54
|
-
return `NOT (${expression.stringify({ names, values })})`;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export class Operand {
|
|
59
|
-
constructor() { }
|
|
60
|
-
// NOTE: both sides of this expression can either be attribute names or attribute values.
|
|
61
|
-
beginsWith(rhs) {
|
|
62
|
-
return expression({
|
|
63
|
-
stringify: ({ names, values }) => {
|
|
64
|
-
return `begins_with(${this.substitute({ names, values })}, ${rhs.substitute({ names, values })})`;
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Returns an expression that checks if this operand is between the two provided ones using the `BETWEEN` operator.
|
|
70
|
-
*
|
|
71
|
-
* Both bounds are inclusive, meaning that the returned expression corresponds to `lower <= this <= upper`.
|
|
72
|
-
*
|
|
73
|
-
* @param lower - The lower inclusive bound of the range.
|
|
74
|
-
* @param upper - The upper inclusive bound of the range.
|
|
75
|
-
*
|
|
76
|
-
* @returns An {@link Expression} that is true if this operand is between the two provided bounds.
|
|
77
|
-
*/
|
|
78
|
-
between(lower, upper) {
|
|
79
|
-
return expression({
|
|
80
|
-
stringify: ({ names, values }) => {
|
|
81
|
-
return `${this.substitute({ names, values })} BETWEEN ${lower.substitute({ names, values })} AND ${upper.substitute({ names, values })}`;
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// NOTE: both sides of this expression can either be attribute names or attribute values.
|
|
86
|
-
contains(rhs) {
|
|
87
|
-
return expression({
|
|
88
|
-
stringify: ({ names, values }) => {
|
|
89
|
-
return `contains(${this.substitute({ names, values })}, ${rhs.substitute({ names, values })})`;
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Tests that two operands are equals.
|
|
95
|
-
*
|
|
96
|
-
* This uses the `=` operator.
|
|
97
|
-
*
|
|
98
|
-
* @param rhs - The right hand side operand.
|
|
99
|
-
*
|
|
100
|
-
* @returns The corresponding {@link Expression}.
|
|
101
|
-
*/
|
|
102
|
-
equals(rhs) {
|
|
103
|
-
return expression({
|
|
104
|
-
stringify: ({ names, values }) => {
|
|
105
|
-
return `${this.substitute({ names, values })} = ${rhs.substitute({ names, values })}`;
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* An alias for {@link equals}.
|
|
111
|
-
*/
|
|
112
|
-
eq = this.equals.bind(this);
|
|
113
|
-
/**
|
|
114
|
-
* Tests that this operand is greater than the right operand.
|
|
115
|
-
*
|
|
116
|
-
* This uses the `>` operator.
|
|
117
|
-
*
|
|
118
|
-
* @param rhs - The right hand side operand.
|
|
119
|
-
*
|
|
120
|
-
* @returns The corresponding {@link Expression}.
|
|
121
|
-
*/
|
|
122
|
-
greaterThan(rhs) {
|
|
123
|
-
return expression({
|
|
124
|
-
stringify: ({ names, values }) => {
|
|
125
|
-
return `${this.substitute({ names, values })} > ${rhs.substitute({ names, values })}`;
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Tests that this operand is greater than or equals to the right operand.
|
|
131
|
-
*
|
|
132
|
-
* This uses the `>=` operator.
|
|
133
|
-
*
|
|
134
|
-
* @param rhs - The right hand side operand.
|
|
135
|
-
*
|
|
136
|
-
* @returns The corresponding {@link Expression}.
|
|
137
|
-
*/
|
|
138
|
-
greaterThanOrEquals(rhs) {
|
|
139
|
-
return expression({
|
|
140
|
-
stringify: ({ names, values }) => {
|
|
141
|
-
return `${this.substitute({ names, values })} >= ${rhs.substitute({ names, values })}`;
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* An alias for {@link greaterThan}.
|
|
147
|
-
*/
|
|
148
|
-
gt = this.greaterThan.bind(this);
|
|
149
|
-
/**
|
|
150
|
-
* An alias for {@link greaterThanOrEquals}
|
|
151
|
-
*/
|
|
152
|
-
gte = this.greaterThanOrEquals.bind(this);
|
|
153
|
-
/**
|
|
154
|
-
* Tests that this operand is contained within the provided list.
|
|
155
|
-
*
|
|
156
|
-
* This uses the `IN` operator.
|
|
157
|
-
*
|
|
158
|
-
* @param operands - The list of operands to check against. This function throws if the list is
|
|
159
|
-
* empty or contains more than 100 operands.
|
|
160
|
-
*
|
|
161
|
-
* @returns The corresponding {@link Expression} that is true if this operand is contained within the provided list.
|
|
162
|
-
*/
|
|
163
|
-
in(...operands) {
|
|
164
|
-
if (operands.length === 0) {
|
|
165
|
-
throw new Error("the IN operator requires at least one operand.");
|
|
166
|
-
}
|
|
167
|
-
if (operands.length > 100) {
|
|
168
|
-
throw new Error(`up to 100 operands are support for the IN operator, got ${operands.length}`);
|
|
169
|
-
}
|
|
170
|
-
return expression({
|
|
171
|
-
stringify: ({ names, values }) => {
|
|
172
|
-
const operandsString = operands
|
|
173
|
-
.map((operand) => operand.substitute({ names, values }))
|
|
174
|
-
.join(",");
|
|
175
|
-
return `${this.substitute({ names, values })} IN (${operandsString})`;
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Tests that this operand is lower than the right operand.
|
|
181
|
-
*
|
|
182
|
-
* This uses the `<` operator.
|
|
183
|
-
*
|
|
184
|
-
* @param rhs - The right hand side operand.
|
|
185
|
-
*
|
|
186
|
-
* @returns The corresponding {@link Expression}.
|
|
187
|
-
*/
|
|
188
|
-
lowerThan(rhs) {
|
|
189
|
-
return expression({
|
|
190
|
-
stringify: ({ names, values }) => {
|
|
191
|
-
return `${this.substitute({ names, values })} < ${rhs.substitute({ names, values })}`;
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Tests that this operand is lower than or equals to the right operand.
|
|
197
|
-
*
|
|
198
|
-
* This uses the `<=` operator.
|
|
199
|
-
*
|
|
200
|
-
* @param rhs - The right hand side operand.
|
|
201
|
-
*
|
|
202
|
-
* @returns The corresponding {@link Expression}.
|
|
203
|
-
*/
|
|
204
|
-
lowerThanOrEquals(rhs) {
|
|
205
|
-
return expression({
|
|
206
|
-
stringify: ({ names, values }) => {
|
|
207
|
-
return `${this.substitute({ names, values })} <= ${rhs.substitute({ names, values })}`;
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* An alias for {@link lowerThan}.
|
|
213
|
-
*/
|
|
214
|
-
lt = this.lowerThan.bind(this);
|
|
215
|
-
/**
|
|
216
|
-
* An alias for {@link lowerThanOrEquals}
|
|
217
|
-
*/
|
|
218
|
-
lte = this.lowerThanOrEquals.bind(this);
|
|
219
|
-
/**
|
|
220
|
-
* Tests that two operands are not equals.
|
|
221
|
-
*
|
|
222
|
-
* This is the opposite of {@link equals} and it uses the `<>` operator.
|
|
223
|
-
*
|
|
224
|
-
* @param rhs - The right hand side operand.
|
|
225
|
-
*
|
|
226
|
-
* @returns The corresponding {@link Expression}.
|
|
227
|
-
*/
|
|
228
|
-
notEquals(rhs) {
|
|
229
|
-
return expression({
|
|
230
|
-
stringify: ({ names, values }) => {
|
|
231
|
-
return `${this.substitute({ names, values })} <> ${rhs.substitute({ names, values })}`;
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* An alias for {@link notEquals}.
|
|
237
|
-
*/
|
|
238
|
-
ne = this.notEquals.bind(this);
|
|
239
|
-
// TODO: make a function? size(attribute("toto")) is more readable than attribute("toto").size()
|
|
240
|
-
size() {
|
|
241
|
-
return new SizeOperand(this);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
export class ExpressionAttribute extends Operand {
|
|
245
|
-
path;
|
|
246
|
-
constructor(path) {
|
|
247
|
-
super();
|
|
248
|
-
this.path = path;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* @returns An {@link Expression} that returns true if the provided attribute path exists.
|
|
252
|
-
*/
|
|
253
|
-
// NOTE: the left hand side of this expression can only be a literal value (tested)
|
|
254
|
-
exists() {
|
|
255
|
-
return expression({
|
|
256
|
-
stringify: ({ names, values }) => {
|
|
257
|
-
return `attribute_exists(${this.substitute({ names, values })})`;
|
|
258
|
-
},
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* @param type - The type to check against.
|
|
263
|
-
* @returns An {@link Expression} that returns true if there exists an attribute at
|
|
264
|
-
* the provided path of the given type.
|
|
265
|
-
*/
|
|
266
|
-
// NOTE: the left hand side of this expression *can be* an attribute value pointing to a valid path.
|
|
267
|
-
// NOTE: the right hand side of this expression *must be* an expression attribute (not a literal).
|
|
268
|
-
isType(type) {
|
|
269
|
-
return expression({
|
|
270
|
-
stringify: ({ names, values }) => {
|
|
271
|
-
return `attribute_type(${this.substitute({ names, values })}, ${type.substitute({ names, values })})`;
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
// NOTE: the left hand side of this expression can only be a literal value (tested)
|
|
276
|
-
notExists() {
|
|
277
|
-
return expression({
|
|
278
|
-
stringify: ({ names, values }) => {
|
|
279
|
-
return `attribute_not_exists(${this.substitute({ names, values })})`;
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
substitute(params) {
|
|
284
|
-
const { names } = params;
|
|
285
|
-
return names.substitute(this.path);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
export function attribute(path) {
|
|
289
|
-
return new ExpressionAttribute(path);
|
|
290
|
-
}
|
|
291
|
-
export class ExpressionValue extends Operand {
|
|
292
|
-
value;
|
|
293
|
-
constructor(value) {
|
|
294
|
-
super();
|
|
295
|
-
this.value = value;
|
|
296
|
-
}
|
|
297
|
-
substitute(params) {
|
|
298
|
-
const { values } = params;
|
|
299
|
-
return values.reference(this.value).toString();
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
export function value(value) {
|
|
303
|
-
return new ExpressionValue(value);
|
|
304
|
-
}
|
|
305
|
-
class SizeOperand extends Operand {
|
|
306
|
-
inner;
|
|
307
|
-
constructor(operand) {
|
|
308
|
-
super();
|
|
309
|
-
this.inner = operand;
|
|
310
|
-
}
|
|
311
|
-
substitute(params) {
|
|
312
|
-
return `size(${this.inner.substitute(params)})`;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
//# sourceMappingURL=expression.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../../src/commands/expressions/expression.ts"],"names":[],"mappings":"AAuBA,8JAA8J;AAC9J,MAAM,OAAO,UAAU;IACJ,WAAW,CAAc;IAE1C,YAAY,MAAwB;QAClC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,KAAiB;QACnB,OAAO,IAAI,UAAU,CAAC;YACpB,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBACjD,OAAO,IAAI,IAAI,QAAQ,KAAK,GAAG,CAAC;YAClC,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,EAAE,CAAC,KAAiB;QAClB,OAAO,IAAI,UAAU,CAAC;YACpB,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBACjD,OAAO,IAAI,IAAI,OAAO,KAAK,GAAG,CAAC;YACjC,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CAAC,MAGT;Q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