@infra-blocks/aws-dynamodb 0.31.0-alpha.0 → 0.32.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/comparisons.d.ts +4 -4
- package/lib/cjs/commands/expressions/condition/comparisons.js +15 -8
- package/lib/cjs/commands/expressions/condition/comparisons.js.map +1 -1
- package/lib/cjs/commands/expressions/condition/condition.d.ts +5 -4
- package/lib/cjs/commands/expressions/condition/condition.js +9 -0
- package/lib/cjs/commands/expressions/condition/condition.js.map +1 -1
- package/lib/cjs/commands/expressions/condition/functions.d.ts +9 -8
- package/lib/cjs/commands/expressions/condition/functions.js +10 -4
- package/lib/cjs/commands/expressions/condition/functions.js.map +1 -1
- package/lib/cjs/commands/expressions/condition/size.d.ts +7 -6
- package/lib/cjs/commands/expressions/condition/size.js +10 -3
- package/lib/cjs/commands/expressions/condition/size.js.map +1 -1
- package/lib/cjs/commands/expressions/operands/index.d.ts +3 -3
- package/lib/cjs/commands/expressions/operands/index.js +9 -17
- package/lib/cjs/commands/expressions/operands/index.js.map +1 -1
- package/lib/cjs/commands/expressions/operands/{type.d.ts → operand.d.ts} +5 -2
- package/lib/cjs/commands/expressions/operands/operand.js +19 -0
- package/lib/cjs/commands/expressions/operands/operand.js.map +1 -0
- package/lib/cjs/commands/expressions/operands/path.d.ts +10 -2
- package/lib/cjs/commands/expressions/operands/path.js +18 -0
- package/lib/cjs/commands/expressions/operands/path.js.map +1 -1
- package/lib/cjs/commands/expressions/operands/value.d.ts +10 -2
- package/lib/cjs/commands/expressions/operands/value.js +25 -0
- package/lib/cjs/commands/expressions/operands/value.js.map +1 -1
- package/lib/cjs/commands/expressions/update/if-not-exists.d.ts +1 -1
- package/lib/cjs/commands/expressions/update/if-not-exists.js.map +1 -1
- package/lib/cjs/commands/expressions/update/set.d.ts +1 -1
- package/lib/cjs/commands/expressions/update/set.js.map +1 -1
- package/lib/cjs/types.d.ts +8 -0
- package/lib/cjs/types.js +37 -0
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/commands/expressions/condition/comparisons.d.ts +4 -4
- package/lib/esm/commands/expressions/condition/comparisons.js +15 -8
- package/lib/esm/commands/expressions/condition/comparisons.js.map +1 -1
- package/lib/esm/commands/expressions/condition/condition.d.ts +5 -4
- package/lib/esm/commands/expressions/condition/condition.js +8 -1
- package/lib/esm/commands/expressions/condition/condition.js.map +1 -1
- package/lib/esm/commands/expressions/condition/functions.d.ts +9 -8
- package/lib/esm/commands/expressions/condition/functions.js +10 -4
- package/lib/esm/commands/expressions/condition/functions.js.map +1 -1
- package/lib/esm/commands/expressions/condition/size.d.ts +7 -6
- package/lib/esm/commands/expressions/condition/size.js +9 -3
- package/lib/esm/commands/expressions/condition/size.js.map +1 -1
- package/lib/esm/commands/expressions/operands/index.d.ts +3 -3
- package/lib/esm/commands/expressions/operands/index.js +3 -3
- package/lib/esm/commands/expressions/operands/index.js.map +1 -1
- package/lib/esm/commands/expressions/operands/{type.d.ts → operand.d.ts} +5 -2
- package/lib/esm/commands/expressions/operands/operand.js +13 -0
- package/lib/esm/commands/expressions/operands/operand.js.map +1 -0
- package/lib/esm/commands/expressions/operands/path.d.ts +10 -2
- package/lib/esm/commands/expressions/operands/path.js +17 -0
- package/lib/esm/commands/expressions/operands/path.js.map +1 -1
- package/lib/esm/commands/expressions/operands/value.d.ts +10 -2
- package/lib/esm/commands/expressions/operands/value.js +24 -0
- package/lib/esm/commands/expressions/operands/value.js.map +1 -1
- package/lib/esm/commands/expressions/update/if-not-exists.d.ts +1 -1
- package/lib/esm/commands/expressions/update/if-not-exists.js.map +1 -1
- package/lib/esm/commands/expressions/update/set.d.ts +1 -1
- package/lib/esm/commands/expressions/update/set.js.map +1 -1
- package/lib/esm/types.d.ts +8 -0
- package/lib/esm/types.js +29 -0
- package/lib/esm/types.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/commands/expressions/operands/type.js +0 -3
- package/lib/cjs/commands/expressions/operands/type.js.map +0 -1
- package/lib/esm/commands/expressions/operands/type.js +0 -2
- package/lib/esm/commands/expressions/operands/type.js.map +0 -1
package/lib/cjs/types.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NATIVE_TYPES = void 0;
|
|
4
|
+
exports.isNativeBinary = isNativeBinary;
|
|
5
|
+
exports.isNativeBoolean = isNativeBoolean;
|
|
6
|
+
exports.isNativeList = isNativeList;
|
|
7
|
+
exports.isNativeMap = isNativeMap;
|
|
8
|
+
exports.isNativeNull = isNativeNull;
|
|
9
|
+
exports.isNativeNumber = isNativeNumber;
|
|
10
|
+
exports.isNativeSet = isNativeSet;
|
|
11
|
+
exports.isNativeString = isNativeString;
|
|
12
|
+
const types_1 = require("node:util/types");
|
|
13
|
+
const types_2 = require("@infra-blocks/types");
|
|
4
14
|
exports.NATIVE_TYPES = [
|
|
5
15
|
"B",
|
|
6
16
|
"BS",
|
|
@@ -13,4 +23,31 @@ exports.NATIVE_TYPES = [
|
|
|
13
23
|
"S",
|
|
14
24
|
"SS",
|
|
15
25
|
];
|
|
26
|
+
// Native type guards.
|
|
27
|
+
function isNativeBinary(value) {
|
|
28
|
+
return Buffer.isBuffer(value);
|
|
29
|
+
}
|
|
30
|
+
function isNativeBoolean(value) {
|
|
31
|
+
return (0, types_2.isBoolean)(value);
|
|
32
|
+
}
|
|
33
|
+
// Note: the type of the elements is not checked.
|
|
34
|
+
function isNativeList(value) {
|
|
35
|
+
return Array.isArray(value);
|
|
36
|
+
}
|
|
37
|
+
// Note: the type of the elements is not checked.
|
|
38
|
+
function isNativeMap(value) {
|
|
39
|
+
return (0, types_2.isPlainObject)(value);
|
|
40
|
+
}
|
|
41
|
+
function isNativeNull(value) {
|
|
42
|
+
return (0, types_2.isNull)(value);
|
|
43
|
+
}
|
|
44
|
+
function isNativeNumber(value) {
|
|
45
|
+
return (0, types_2.isNumber)(value) || (0, types_2.isBigint)(value);
|
|
46
|
+
}
|
|
47
|
+
function isNativeSet(value) {
|
|
48
|
+
return (0, types_1.isSet)(value);
|
|
49
|
+
}
|
|
50
|
+
function isNativeString(value) {
|
|
51
|
+
return (0, types_2.isString)(value);
|
|
52
|
+
}
|
|
16
53
|
//# sourceMappingURL=types.js.map
|
package/lib/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAsDA,wCAEC;AAED,0CAEC;AAGD,oCAEC;AAGD,kCAEC;AAED,oCAEC;AAED,wCAEC;AAED,kCAEC;AAED,wCAEC;AAtFD,2CAAwC;AACxC,+CAO6B;AAchB,QAAA,YAAY,GAAG;IAC1B,GAAG;IACH,IAAI;IACJ,MAAM;IACN,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;IACJ,MAAM;IACN,GAAG;IACH,IAAI;CACI,CAAC;AAoBX,sBAAsB;AACtB,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAA,iBAAS,EAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,iDAAiD;AACjD,SAAgB,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,iDAAiD;AACjD,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,IAAA,qBAAa,EAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,YAAY,CAAC,KAAc;IACzC,OAAO,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,IAAA,aAAK,EAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { NativeBinary, NativeNumber, NativeString } from "../../../types.js";
|
|
2
|
-
import
|
|
2
|
+
import { type ConditionParams, type RawConditionOperand } from "./condition.js";
|
|
3
3
|
import { ConditionExpression } from "./expression.js";
|
|
4
4
|
export type ComparableValue = NativeBinary | NativeNumber | NativeString;
|
|
5
|
-
export type ComparableOperand =
|
|
5
|
+
export type ComparableOperand = RawConditionOperand<ComparableValue>;
|
|
6
6
|
export type ConditionComparisonParams = Between | Equals | GreaterThan | GreaterThanOrEquals | In | LowerThan | LowerThanOrEquals | NotEquals;
|
|
7
7
|
export type Between = [
|
|
8
8
|
ComparableOperand,
|
|
@@ -11,12 +11,12 @@ export type Between = [
|
|
|
11
11
|
"AND",
|
|
12
12
|
ComparableOperand
|
|
13
13
|
];
|
|
14
|
-
export type Equals = [
|
|
14
|
+
export type Equals = [RawConditionOperand, "=", RawConditionOperand];
|
|
15
15
|
export type GreaterThan = [ComparableOperand, ">", ComparableOperand];
|
|
16
16
|
export type GreaterThanOrEquals = [ComparableOperand, ">=", ComparableOperand];
|
|
17
17
|
export type In = [ComparableOperand, "IN", ComparableOperand[]];
|
|
18
18
|
export type LowerThan = [ComparableOperand, "<", ComparableOperand];
|
|
19
19
|
export type LowerThanOrEquals = [ComparableOperand, "<=", ComparableOperand];
|
|
20
|
-
export type NotEquals = [
|
|
20
|
+
export type NotEquals = [RawConditionOperand, "<>", RawConditionOperand];
|
|
21
21
|
export declare function comparison(params: ConditionComparisonParams): ConditionExpression;
|
|
22
22
|
export declare function isComparison(params: ConditionParams): params is ConditionComparisonParams;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { unreachable } from "@infra-blocks/types";
|
|
2
|
+
import { conditionOperand, } from "./condition.js";
|
|
2
3
|
import { ConditionExpression } from "./expression.js";
|
|
3
4
|
// TODO: don't export publicly through index.
|
|
4
5
|
export function comparison(params) {
|
|
@@ -52,9 +53,12 @@ export function isComparison(params) {
|
|
|
52
53
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
53
54
|
*/
|
|
54
55
|
function between(params) {
|
|
56
|
+
const lhs = conditionOperand(params[0]);
|
|
57
|
+
const lower = conditionOperand(params[2]);
|
|
58
|
+
const upper = conditionOperand(params[4]);
|
|
55
59
|
return ConditionExpression.from({
|
|
56
60
|
stringify: ({ names, values }) => {
|
|
57
|
-
return `${
|
|
61
|
+
return `${lhs.substitute({ names, values })} BETWEEN ${lower.substitute({ names, values })} AND ${upper.substitute({ names, values })}`;
|
|
58
62
|
},
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -122,20 +126,21 @@ function isGreaterThanOrEquals(value) {
|
|
|
122
126
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators
|
|
123
127
|
*/
|
|
124
128
|
function inComparison(params) {
|
|
125
|
-
const containerElements = params[2];
|
|
126
129
|
// TODO: unit test those limits
|
|
127
|
-
if (
|
|
130
|
+
if (params[2].length === 0) {
|
|
128
131
|
throw new Error("the IN operator requires at least one operand.");
|
|
129
132
|
}
|
|
130
|
-
if (
|
|
131
|
-
throw new Error(`up to 100 operands are support for the IN operator, got ${
|
|
133
|
+
if (params[2].length > 100) {
|
|
134
|
+
throw new Error(`up to 100 operands are support for the IN operator, got ${params[2].length}`);
|
|
132
135
|
}
|
|
136
|
+
const element = conditionOperand(params[0]);
|
|
137
|
+
const elements = params[2].map((conditionOperand));
|
|
133
138
|
return ConditionExpression.from({
|
|
134
139
|
stringify: ({ names, values }) => {
|
|
135
|
-
const
|
|
140
|
+
const elementsString = elements
|
|
136
141
|
.map((operand) => operand.substitute({ names, values }))
|
|
137
142
|
.join(",");
|
|
138
|
-
return `${
|
|
143
|
+
return `${element.substitute({ names, values })} IN (${elementsString})`;
|
|
139
144
|
},
|
|
140
145
|
});
|
|
141
146
|
}
|
|
@@ -191,9 +196,11 @@ function isNotEquals(value) {
|
|
|
191
196
|
return value[1] === "<>";
|
|
192
197
|
}
|
|
193
198
|
function binaryOperation(params) {
|
|
199
|
+
const lhs = conditionOperand(params[0]);
|
|
200
|
+
const rhs = conditionOperand(params[2]);
|
|
194
201
|
return ConditionExpression.from({
|
|
195
202
|
stringify: ({ names, values }) => {
|
|
196
|
-
return `${
|
|
203
|
+
return `${lhs.substitute({ names, values })} ${params[1]} ${rhs.substitute({ names, values })}`;
|
|
197
204
|
},
|
|
198
205
|
});
|
|
199
206
|
}
|
|
@@ -1 +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,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,WAAW,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,MAAuB;IAEvB,MAAM,MAAM,GAAG,MAAmC,CAAC;IACnD,OAAO,CACL,SAAS,CAAC,MAAM,CAAC;QACjB,QAAQ,CAAC,MAAM,CAAC;QAChB,aAAa,CAAC,MAAM,CAAC;QACrB,qBAAqB,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC;QACZ,WAAW,CAAC,MAAM,CAAC;QACnB,mBAAmB,CAAC,MAAM,CAAC;QAC3B,WAAW,CAAC,MAAM,CAAC,CACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,OAAO,CAAC,MAAe;IAC9B,OAAO,mBAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/B,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"comparisons.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/comparisons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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AC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAClG,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { AttributeValue } from "../../../types.js";
|
|
2
|
-
import type
|
|
3
|
-
import type { Value } from "../operands/value.js";
|
|
2
|
+
import { type Operand, type RawOperand } from "../operands/index.js";
|
|
4
3
|
import type { ConditionComparisonParams } from "./comparisons.js";
|
|
5
4
|
import type { ConditionExpression } from "./expression.js";
|
|
6
|
-
import type
|
|
5
|
+
import { type Size } from "./size.js";
|
|
7
6
|
export type ConditionParams = ConditionExpression | ConditionComparisonParams | ConditionExpression;
|
|
8
|
-
export type ConditionOperand<T extends AttributeValue = AttributeValue> =
|
|
7
|
+
export type ConditionOperand<T extends AttributeValue = AttributeValue> = Operand<T> | Size;
|
|
8
|
+
export type RawConditionOperand<T extends AttributeValue = AttributeValue> = RawOperand<T> | Size;
|
|
9
|
+
export declare function conditionOperand<T extends AttributeValue = AttributeValue>(raw: RawConditionOperand<T>): ConditionOperand<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/condition.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/condition.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,OAAO,EAAmB,MAAM,sBAAsB,CAAC;AAG9E,OAAO,EAAE,MAAM,EAAa,MAAM,WAAW,CAAC;AAe9C,MAAM,UAAU,gBAAgB,CAC9B,GAA2B;IAE3B,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAChB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,OAAO,CAAI,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { NativeBinary, NativeString, NativeType } from "../../../types.js";
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
2
|
+
import { type RawOperand } from "../operands/operand.js";
|
|
3
|
+
import { type RawPath } from "../operands/path.js";
|
|
4
|
+
import { type RawValue } from "../operands/value.js";
|
|
5
|
+
import { type RawConditionOperand } from "./condition.js";
|
|
4
6
|
import { ConditionExpression } from "./expression.js";
|
|
5
|
-
import type { Size } from "./size.js";
|
|
6
7
|
/**
|
|
7
8
|
* Returns a condition that uses the `attribute_exists` function.
|
|
8
9
|
*
|
|
@@ -37,11 +38,11 @@ export declare function attributeType(attribute: RawPath, rawType: RawValue<Nati
|
|
|
37
38
|
*
|
|
38
39
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
39
40
|
*/
|
|
40
|
-
export type BeginsWithOperand =
|
|
41
|
+
export type BeginsWithOperand = RawOperand<NativeString | NativeBinary>;
|
|
41
42
|
/**
|
|
42
43
|
* Returns a condition that uses the `begins_with` function.
|
|
43
44
|
*
|
|
44
|
-
* @param first - The first function operand, which is the
|
|
45
|
+
* @param first - The first function operand, which is the path or value to check.
|
|
45
46
|
* @param second - The second function operand, which is the prefix to validate against.
|
|
46
47
|
*
|
|
47
48
|
* @returns A {@link ConditionExpression} that evaluates to true if the first operand begins with the second.
|
|
@@ -52,15 +53,15 @@ export declare function beginsWith(first: BeginsWithOperand, second: BeginsWithO
|
|
|
52
53
|
/**
|
|
53
54
|
* This type aggregates the types of operands that can be used as the first operand of the {@link contains} function.
|
|
54
55
|
*/
|
|
55
|
-
export type ContainsFirstOperand =
|
|
56
|
+
export type ContainsFirstOperand = RawOperand;
|
|
56
57
|
/**
|
|
57
58
|
* This type aggregates the types of operands that can be used as the second operand of the {@link contains} function.
|
|
58
59
|
*/
|
|
59
|
-
export type ContainsSecondOperand =
|
|
60
|
+
export type ContainsSecondOperand = RawConditionOperand;
|
|
60
61
|
/**
|
|
61
62
|
* Returns a condition that uses the `contains` function.
|
|
62
63
|
*
|
|
63
|
-
* @param first - The first function operand, which is the
|
|
64
|
+
* @param first - The first function operand, which is the path or value to check.
|
|
64
65
|
* @param second - The second function operand, which is the value to check for containment.
|
|
65
66
|
*
|
|
66
67
|
* @returns A {@link ConditionExpression} that evaluates to true if this operand contains the provided one.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { operand } from "../operands/operand.js";
|
|
1
2
|
import { Path } from "../operands/path.js";
|
|
2
3
|
import { Value } from "../operands/value.js";
|
|
4
|
+
import { conditionOperand } from "./condition.js";
|
|
3
5
|
import { ConditionExpression } from "./expression.js";
|
|
4
6
|
/**
|
|
5
7
|
* Returns a condition that uses the `attribute_exists` function.
|
|
@@ -49,7 +51,7 @@ export function attributeType(attribute, rawType) {
|
|
|
49
51
|
/**
|
|
50
52
|
* Returns a condition that uses the `begins_with` function.
|
|
51
53
|
*
|
|
52
|
-
* @param first - The first function operand, which is the
|
|
54
|
+
* @param first - The first function operand, which is the path or value to check.
|
|
53
55
|
* @param second - The second function operand, which is the prefix to validate against.
|
|
54
56
|
*
|
|
55
57
|
* @returns A {@link ConditionExpression} that evaluates to true if the first operand begins with the second.
|
|
@@ -57,14 +59,16 @@ export function attributeType(attribute, rawType) {
|
|
|
57
59
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
58
60
|
*/
|
|
59
61
|
export function beginsWith(first, second) {
|
|
62
|
+
const firstOperand = operand(first);
|
|
63
|
+
const secondOperand = operand(second);
|
|
60
64
|
return ConditionExpression.from({
|
|
61
|
-
stringify: ({ names, values }) => `begins_with(${
|
|
65
|
+
stringify: ({ names, values }) => `begins_with(${firstOperand.substitute({ names, values })}, ${secondOperand.substitute({ names, values })})`,
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* Returns a condition that uses the `contains` function.
|
|
66
70
|
*
|
|
67
|
-
* @param first - The first function operand, which is the
|
|
71
|
+
* @param first - The first function operand, which is the path or value to check.
|
|
68
72
|
* @param second - The second function operand, which is the value to check for containment.
|
|
69
73
|
*
|
|
70
74
|
* @returns A {@link ConditionExpression} that evaluates to true if this operand contains the provided one.
|
|
@@ -72,8 +76,10 @@ export function beginsWith(first, second) {
|
|
|
72
76
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
73
77
|
*/
|
|
74
78
|
export function contains(first, second) {
|
|
79
|
+
const firstOperand = operand(first);
|
|
80
|
+
const secondOperand = conditionOperand(second);
|
|
75
81
|
return ConditionExpression.from({
|
|
76
|
-
stringify: ({ names, values }) => `contains(${
|
|
82
|
+
stringify: ({ names, values }) => `contains(${firstOperand.substitute({ names, values })}, ${secondOperand.substitute({ names, values })})`,
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
85
|
//# sourceMappingURL=functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/functions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAmB,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAgB,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAiB,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAA4B,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO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E,EAAE,EAAE,CAC/B,eAAe,YAAY,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,aAAa,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG;KAC/G,CAAC,CAAC;AACL,CAAC;AAWD;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CACtB,KAA2B,EAC3B,MAA6B;IAE7B,MAAM,YAAY,GAAG,OAAO,CAAiB,KAAK,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,gBAAgB,CAAiB,MAAM,CAAC,CAAC;IAE/D,OAAO,mBAAmB,CAAC,IAAI,CAAC;QAC9B,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAC/B,YAAY,YAAY,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,aAAa,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG;KAC5G,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { NativeBinary, NativeList, NativeMap, NativeSet, NativeString } from "../../../types.js";
|
|
2
2
|
import type { AttributeNames, AttributeValues } from "../../attributes/index.js";
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
import type { Value } from "../operands/value.js";
|
|
3
|
+
import { type IOperand, type Operand, type RawOperand } from "../operands/operand.js";
|
|
4
|
+
export type SizeOperandValue = NativeBinary | NativeList | NativeMap | NativeSet | NativeString;
|
|
6
5
|
/**
|
|
7
6
|
* This type aggregates the types of operands that can be used with the {@link size} function.
|
|
8
7
|
*
|
|
@@ -10,7 +9,8 @@ import type { Value } from "../operands/value.js";
|
|
|
10
9
|
* @see Path
|
|
11
10
|
* @see Value
|
|
12
11
|
*/
|
|
13
|
-
export type SizeOperand =
|
|
12
|
+
export type SizeOperand = Operand<SizeOperandValue>;
|
|
13
|
+
export type RawSizeOperand = RawOperand<SizeOperandValue>;
|
|
14
14
|
/**
|
|
15
15
|
* A type representing the result of the {@link size} function as an operand to be used in expressions.
|
|
16
16
|
*/
|
|
@@ -29,9 +29,10 @@ export declare class Size implements IOperand {
|
|
|
29
29
|
/**
|
|
30
30
|
* Creates a new {@link Size} operand to be nested in expressions.
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param raw - The operand to calculate the size of.
|
|
33
33
|
* @returns A new {@link Size} operand.
|
|
34
34
|
*
|
|
35
35
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
36
36
|
*/
|
|
37
|
-
export declare function size(
|
|
37
|
+
export declare function size(raw: RawSizeOperand): Size;
|
|
38
|
+
export declare function isSize(value: unknown): value is Size;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { operand, } from "../operands/operand.js";
|
|
1
2
|
/**
|
|
2
3
|
* A type representing the result of the {@link size} function as an operand to be used in expressions.
|
|
3
4
|
*/
|
|
@@ -19,12 +20,17 @@ export class Size {
|
|
|
19
20
|
/**
|
|
20
21
|
* Creates a new {@link Size} operand to be nested in expressions.
|
|
21
22
|
*
|
|
22
|
-
* @param
|
|
23
|
+
* @param raw - The operand to calculate the size of.
|
|
23
24
|
* @returns A new {@link Size} operand.
|
|
24
25
|
*
|
|
25
26
|
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions
|
|
26
27
|
*/
|
|
27
|
-
export function size(
|
|
28
|
-
|
|
28
|
+
export function size(raw) {
|
|
29
|
+
const effective = operand(raw);
|
|
30
|
+
return Size.from(effective);
|
|
31
|
+
}
|
|
32
|
+
// TODO: module visibility
|
|
33
|
+
export function isSize(value) {
|
|
34
|
+
return value instanceof Size;
|
|
29
35
|
}
|
|
30
36
|
//# sourceMappingURL=size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/size.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/condition/size.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,OAAO,GAER,MAAM,wBAAwB,CAAC;AAoBhC;;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,GAAmB;IACtC,MAAM,SAAS,GAAG,OAAO,CAAmB,GAAG,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9B,CAAC;AAED,0BAA0B;AAC1B,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,IAAI,CAAC;AAC/B,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { type ImplicitOperand, type Operand, operand, type RawOperand, } from "./operand.js";
|
|
2
|
+
export { type ImplicitPath, Path, path, type RawPath } from "./path.js";
|
|
3
|
+
export { type ImplicitValue, type RawValue, Value, value, } from "./value.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { operand, } from "./operand.js";
|
|
2
|
+
export { Path, path } from "./path.js";
|
|
3
|
+
export { Value, value, } from "./value.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,GAER,MAAM,cAAc,CAAC;AACtB,OAAO,EAAqB,IAAI,EAAE,IAAI,EAAgB,MAAM,WAAW,CAAC;AACxE,OAAO,EAGL,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { AttributeValue } from "../../../types.js";
|
|
2
2
|
import type { AttributeNames } from "../../attributes/names.js";
|
|
3
3
|
import type { AttributeValues } from "../../attributes/values.js";
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
4
|
+
import { type ImplicitPath, Path, type RawPath } from "./path.js";
|
|
5
|
+
import { type ImplicitValue, type RawValue, Value } from "./value.js";
|
|
6
|
+
export type ImplicitOperand = ImplicitPath | ImplicitValue;
|
|
7
|
+
export type RawOperand<T extends AttributeValue = AttributeValue> = RawPath | RawValue<T>;
|
|
6
8
|
export type Operand<T extends AttributeValue = AttributeValue> = Path | Value<T>;
|
|
7
9
|
export interface IOperand {
|
|
8
10
|
substitute(params: {
|
|
@@ -10,3 +12,4 @@ export interface IOperand {
|
|
|
10
12
|
values: AttributeValues;
|
|
11
13
|
}): string;
|
|
12
14
|
}
|
|
15
|
+
export declare function operand<T extends AttributeValue = AttributeValue>(raw: RawOperand<T>): Operand<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
import { isRawPath, Path } from "./path.js";
|
|
3
|
+
import { isRawValue, Value, } from "./value.js";
|
|
4
|
+
export function operand(raw) {
|
|
5
|
+
if (isRawPath(raw)) {
|
|
6
|
+
return Path.normalize(raw);
|
|
7
|
+
}
|
|
8
|
+
if (isRawValue(raw)) {
|
|
9
|
+
return Value.normalize(raw);
|
|
10
|
+
}
|
|
11
|
+
assert(false, `unexpected operand: ${raw}`);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=operand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operand.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/operand.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAIjC,OAAO,EAAqB,SAAS,EAAE,IAAI,EAAgB,MAAM,WAAW,CAAC;AAC7E,OAAO,EAEL,UAAU,EAEV,KAAK,GACN,MAAM,YAAY,CAAC;AAmBpB,MAAM,UAAU,OAAO,CACrB,GAAkB;IAElB,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,UAAU,CAAI,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,EAAE,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AttributePath } from "../../../types.js";
|
|
2
2
|
import type { AttributeNames } from "../../attributes/names.js";
|
|
3
|
-
import type { IOperand } from "./
|
|
3
|
+
import type { IOperand } from "./operand.js";
|
|
4
4
|
/**
|
|
5
5
|
* This type represents the types that can implicitly be used
|
|
6
6
|
* as path operands.
|
|
@@ -62,3 +62,11 @@ export declare class Path implements IOperand {
|
|
|
62
62
|
* @returns A new {@link Path} instance for the provided path.
|
|
63
63
|
*/
|
|
64
64
|
export declare function path(path: AttributePath): Path;
|
|
65
|
+
/**
|
|
66
|
+
* A type guard to assess if something is a {@link RawPath}.
|
|
67
|
+
*
|
|
68
|
+
* @param operand - The operand to test.
|
|
69
|
+
*
|
|
70
|
+
* @returns Whether the operand is a {@link RawPath}.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isRawPath(operand: unknown): operand is RawPath;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNativeString } from "../../../types.js";
|
|
1
2
|
/**
|
|
2
3
|
* Represents an attribute path operand in an expression.
|
|
3
4
|
*
|
|
@@ -50,4 +51,20 @@ export class Path {
|
|
|
50
51
|
export function path(path) {
|
|
51
52
|
return Path.from(path);
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A type guard to assess if something is a {@link RawPath}.
|
|
56
|
+
*
|
|
57
|
+
* @param operand - The operand to test.
|
|
58
|
+
*
|
|
59
|
+
* @returns Whether the operand is a {@link RawPath}.
|
|
60
|
+
*/
|
|
61
|
+
export function isRawPath(operand) {
|
|
62
|
+
return isImplicitPath(operand) || isPath(operand);
|
|
63
|
+
}
|
|
64
|
+
function isImplicitPath(operand) {
|
|
65
|
+
return isNativeString(operand);
|
|
66
|
+
}
|
|
67
|
+
function isPath(operand) {
|
|
68
|
+
return operand instanceof Path;
|
|
69
|
+
}
|
|
53
70
|
//# sourceMappingURL=path.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA2BvE;;;;;;GAMG;AACH,MAAM,OAAO,IAAI;IACE,IAAI,CAAgB;IAErC,YAAoB,IAAmB;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,UAAU,CAAC,MAAiC;QAC1C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,IAAmB;QAC7B,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,SAAS,CAAC,SAAkB;QACjC,IAAI,SAAS,YAAY,IAAI,EAAE,CAAC;YAC9B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,IAAmB;IACtC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,OAAgB;IACxC,OAAO,cAAc,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB;IAC9B,OAAO,OAAO,YAAY,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AttributePath, type AttributeValue } from "../../../types.js";
|
|
2
2
|
import type { AttributeValues } from "../../attributes/values.js";
|
|
3
|
-
import type { IOperand } from "./
|
|
3
|
+
import type { IOperand } from "./operand.js";
|
|
4
4
|
export type ImplicitValue = Exclude<AttributeValue, AttributePath>;
|
|
5
5
|
export type RawValue<T extends AttributeValue = AttributeValue> = T extends ImplicitValue ? T | Value<T> : Value<T>;
|
|
6
6
|
/**
|
|
@@ -35,3 +35,11 @@ export declare class Value<T extends AttributeValue = AttributeValue> implements
|
|
|
35
35
|
* @returns A new {@link Value} instance for the provided value.
|
|
36
36
|
*/
|
|
37
37
|
export declare function value<T extends AttributeValue = AttributeValue>(value: T): Value<T>;
|
|
38
|
+
/**
|
|
39
|
+
* A type guard to assess if something is a {@link RawValue}.
|
|
40
|
+
*
|
|
41
|
+
* @param operand - The operand to test.
|
|
42
|
+
*
|
|
43
|
+
* @returns Whether the operand is a {@link RawValue}.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isRawValue<T extends AttributeValue = AttributeValue>(operand: unknown): operand is RawValue<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNativeBinary, isNativeBoolean, isNativeList, isNativeMap, isNativeNull, isNativeNumber, isNativeSet, } from "../../../types.js";
|
|
1
2
|
/**
|
|
2
3
|
* Represents a value operand in an expression.
|
|
3
4
|
*
|
|
@@ -43,4 +44,27 @@ export class Value {
|
|
|
43
44
|
export function value(value) {
|
|
44
45
|
return Value.from(value);
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* A type guard to assess if something is a {@link RawValue}.
|
|
49
|
+
*
|
|
50
|
+
* @param operand - The operand to test.
|
|
51
|
+
*
|
|
52
|
+
* @returns Whether the operand is a {@link RawValue}.
|
|
53
|
+
*/
|
|
54
|
+
export function isRawValue(operand) {
|
|
55
|
+
return isImplicitValue(operand) || isValue(operand);
|
|
56
|
+
}
|
|
57
|
+
function isImplicitValue(value) {
|
|
58
|
+
// Any of the native types *but* NativeString.
|
|
59
|
+
return (isNativeBinary(value) ||
|
|
60
|
+
isNativeBoolean(value) ||
|
|
61
|
+
isNativeList(value) ||
|
|
62
|
+
isNativeMap(value) ||
|
|
63
|
+
isNativeNull(value) ||
|
|
64
|
+
isNativeNumber(value) ||
|
|
65
|
+
isNativeSet(value));
|
|
66
|
+
}
|
|
67
|
+
function isValue(operand) {
|
|
68
|
+
return operand instanceof Value;
|
|
69
|
+
}
|
|
46
70
|
//# sourceMappingURL=value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/value.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/value.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAS3B;;;;;;GAMG;AACH,MAAM,OAAO,KAAK;IAGC,KAAK,CAAI;IAE1B,YAAoB,KAAQ;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,UAAU,CAAC,MAAmC;QAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAC1B,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAA4C,KAAQ;QAC7D,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,aAAa;IACb;;;;OAIG;IACH,MAAM,CAAC,SAAS,CACd,KAAkB;QAElB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,KAAiB,CAAC;QAC3B,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAa,CAAC;IACvC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CACnB,KAAQ;IAER,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,OAAgB;IAEhB,OAAO,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,8CAA8C;IAC9C,OAAO,CACL,cAAc,CAAC,KAAK,CAAC;QACrB,eAAe,CAAC,KAAK,CAAC;QACtB,YAAY,CAAC,KAAK,CAAC;QACnB,WAAW,CAAC,KAAK,CAAC;QAClB,YAAY,CAAC,KAAK,CAAC;QACnB,cAAc,CAAC,KAAK,CAAC;QACrB,WAAW,CAAC,KAAK,CAAC,CACnB,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,OAAgB;IAC/B,OAAO,OAAO,YAAY,KAAK,CAAC;AAClC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AttributeValue } from "../../../types.js";
|
|
2
2
|
import type { AttributeNames } from "../../attributes/names.js";
|
|
3
3
|
import type { AttributeValues } from "../../attributes/values.js";
|
|
4
|
+
import type { IOperand, Operand } from "../operands/operand.js";
|
|
4
5
|
import { Path, type RawPath } from "../operands/path.js";
|
|
5
|
-
import type { IOperand, Operand } from "../operands/type.js";
|
|
6
6
|
export declare class IfNotExists<T extends AttributeValue = AttributeValue> implements IOperand {
|
|
7
7
|
private readonly path;
|
|
8
8
|
private readonly defaultValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"if-not-exists.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/update/if-not-exists.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"if-not-exists.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/update/if-not-exists.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAgB,MAAM,qBAAqB,CAAC;AAEzD,MAAM,OAAO,WAAW;IAGL,IAAI,CAAO;IACX,YAAY,CAAa;IAE1C,YAAY,MAAgD;QAC1D,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,MAGV;QACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QACjC,OAAO,iBAAiB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;IACjH,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CACzB,OAAgB,EAChB,YAAwB;IAExB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,IAAI,WAAW,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AttributeNames } from "../../attributes/names.js";
|
|
2
2
|
import type { AttributeValues } from "../../attributes/values.js";
|
|
3
|
+
import type { Operand } from "../operands/operand.js";
|
|
3
4
|
import { Path, type RawPath } from "../operands/path.js";
|
|
4
|
-
import type { Operand } from "../operands/type.js";
|
|
5
5
|
import type { IUpdateAction, UpdateAction } from "./action.js";
|
|
6
6
|
import type { UpdateExpressionClauses } from "./clauses.js";
|
|
7
7
|
import type { IfNotExists } from "./if-not-exists.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/update/set.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/update/set.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAgB,MAAM,qBAAqB,CAAC;AAqBzD,MAAM,OAAO,SAAS;IACH,MAAM,CAAkB;IAEzC,YAAoB,MAAuB;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,QAAQ,CAAC,OAAgC;QACvC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,MAGT;QACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QACjC,IAAI,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CACxF;YACE,KAAK;YACL,MAAM;SACP,CACF,EAAE,CAAC;QACJ,IAAI,UAAU,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC9D,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CACxE;gBACE,KAAK;gBACL,MAAM;aACP,CACF,EAAE,CAAC;QACN,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,MAAuB;QACjC,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;CACF;AAUD,MAAM,UAAU,GAAG,CACjB,OAAgB,EAChB,OAAmB,EACnB,QAAsB,EACtB,aAA0B;IAE1B,OAAO,SAAS,CAAC,IAAI,CAAC;QACpB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC7B,OAAO;QACP,QAAQ;QACR,aAAa;KACd,CAAC,CAAC;AACL,CAAC"}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -14,6 +14,14 @@ export type NativeScalar = NativeBinary | NativeBoolean | NativeNull | NativeNum
|
|
|
14
14
|
export type NativeSet = NativeNumberSet | NativeStringSet | NativeBinarySet;
|
|
15
15
|
export type NativeString = string;
|
|
16
16
|
export type NativeStringSet = Set<NativeString>;
|
|
17
|
+
export declare function isNativeBinary(value: unknown): value is NativeBinary;
|
|
18
|
+
export declare function isNativeBoolean(value: unknown): value is NativeBoolean;
|
|
19
|
+
export declare function isNativeList(value: unknown): value is NativeList;
|
|
20
|
+
export declare function isNativeMap(value: unknown): value is NativeMap;
|
|
21
|
+
export declare function isNativeNull(value: unknown): value is NativeNull;
|
|
22
|
+
export declare function isNativeNumber(value: unknown): value is NativeNumber;
|
|
23
|
+
export declare function isNativeSet(value: unknown): value is NativeSet;
|
|
24
|
+
export declare function isNativeString(value: unknown): value is NativeString;
|
|
17
25
|
/**
|
|
18
26
|
* The type of an attribute name in DynamoDB.
|
|
19
27
|
*
|