@infra-blocks/aws-dynamodb 0.19.0 → 0.20.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/values.d.ts +13 -5
- package/lib/cjs/commands/attributes/values.js +13 -5
- package/lib/cjs/commands/attributes/values.js.map +1 -1
- package/lib/cjs/commands/expressions/condition.d.ts +1 -1
- package/lib/cjs/commands/expressions/condition.js +2 -2
- package/lib/cjs/commands/expressions/condition.js.map +1 -1
- 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/operands/index.d.ts +3 -0
- package/lib/cjs/commands/expressions/operands/index.js +20 -0
- package/lib/cjs/commands/expressions/operands/index.js.map +1 -0
- package/lib/cjs/commands/expressions/operands/name.d.ts +27 -0
- package/lib/cjs/commands/expressions/operands/name.js +33 -0
- package/lib/cjs/commands/expressions/operands/name.js.map +1 -0
- package/lib/cjs/commands/expressions/operands/type.d.ts +12 -0
- package/lib/cjs/commands/expressions/operands/type.js +3 -0
- package/lib/cjs/commands/expressions/operands/type.js.map +1 -0
- package/lib/cjs/commands/expressions/operands/value.d.ts +27 -0
- package/lib/cjs/commands/expressions/operands/value.js +33 -0
- package/lib/cjs/commands/expressions/operands/value.js.map +1 -0
- package/lib/cjs/commands/expressions/update.d.ts +35 -13
- package/lib/cjs/commands/expressions/update.js +54 -16
- package/lib/cjs/commands/expressions/update.js.map +1 -1
- package/lib/cjs/types.d.ts +11 -1
- package/lib/esm/commands/attributes/values.d.ts +13 -5
- package/lib/esm/commands/attributes/values.js +13 -5
- package/lib/esm/commands/attributes/values.js.map +1 -1
- package/lib/esm/commands/expressions/condition.d.ts +1 -1
- package/lib/esm/commands/expressions/condition.js +1 -1
- package/lib/esm/commands/expressions/condition.js.map +1 -1
- 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/operands/index.d.ts +3 -0
- package/lib/esm/commands/expressions/operands/index.js +4 -0
- package/lib/esm/commands/expressions/operands/index.js.map +1 -0
- package/lib/esm/commands/expressions/operands/name.d.ts +27 -0
- package/lib/esm/commands/expressions/operands/name.js +28 -0
- package/lib/esm/commands/expressions/operands/name.js.map +1 -0
- package/lib/esm/commands/expressions/operands/type.d.ts +12 -0
- package/lib/esm/commands/expressions/operands/type.js +2 -0
- package/lib/esm/commands/expressions/operands/type.js.map +1 -0
- package/lib/esm/commands/expressions/operands/value.d.ts +27 -0
- package/lib/esm/commands/expressions/operands/value.js +28 -0
- package/lib/esm/commands/expressions/operands/value.js.map +1 -0
- package/lib/esm/commands/expressions/update.d.ts +35 -13
- package/lib/esm/commands/expressions/update.js +48 -12
- package/lib/esm/commands/expressions/update.js.map +1 -1
- package/lib/esm/types.d.ts +11 -1
- package/package.json +1 -1
- package/lib/cjs/commands/expressions/operands.d.ts +0 -28
- package/lib/cjs/commands/expressions/operands.js +0 -34
- package/lib/cjs/commands/expressions/operands.js.map +0 -1
- package/lib/esm/commands/expressions/operands.d.ts +0 -28
- package/lib/esm/commands/expressions/operands.js +0 -27
- package/lib/esm/commands/expressions/operands.js.map +0 -1
|
@@ -3,15 +3,23 @@ export type ValueReference = `:${string}`;
|
|
|
3
3
|
/**
|
|
4
4
|
* Represents a set of attribute values used in an expression.
|
|
5
5
|
*
|
|
6
|
-
* This class provides an automated way to generate value reference variables
|
|
7
|
-
* so that every value in an expression can be treated
|
|
8
|
-
* with an automatically generated variable.
|
|
6
|
+
* This class provides an automated way to generate value reference variables,
|
|
7
|
+
* or substitutions, so that every value in an expression can be treated
|
|
8
|
+
* the same: systematically replaced with an automatically generated variable.
|
|
9
9
|
*
|
|
10
|
-
* The class keeps track of the
|
|
11
|
-
* the user requests a
|
|
10
|
+
* The class keeps track of the substitutions generated for each value, such that when
|
|
11
|
+
* the user requests a substitute for a known value, that previous one is returned.
|
|
12
|
+
*
|
|
13
|
+
* Values are compared using the SameValueZero algorithm(it uses a Map internally).
|
|
14
|
+
* This means that:
|
|
15
|
+
* ```ts
|
|
16
|
+
* assert(values.substitute(new Set([1,2,3])) !== values.substitute(new Set([1,2,3])));
|
|
17
|
+
* ```
|
|
12
18
|
*
|
|
13
19
|
* When the user requests a reference for an unknown value, then one is generated and
|
|
14
20
|
* stored for future use.
|
|
21
|
+
*
|
|
22
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Equality_comparisons_and_sameness#same-value-zero_equality
|
|
15
23
|
*/
|
|
16
24
|
export declare class AttributeValues {
|
|
17
25
|
private readonly values;
|
|
@@ -4,15 +4,23 @@ exports.AttributeValues = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Represents a set of attribute values used in an expression.
|
|
6
6
|
*
|
|
7
|
-
* This class provides an automated way to generate value reference variables
|
|
8
|
-
* so that every value in an expression can be treated
|
|
9
|
-
* with an automatically generated variable.
|
|
7
|
+
* This class provides an automated way to generate value reference variables,
|
|
8
|
+
* or substitutions, so that every value in an expression can be treated
|
|
9
|
+
* the same: systematically replaced with an automatically generated variable.
|
|
10
10
|
*
|
|
11
|
-
* The class keeps track of the
|
|
12
|
-
* the user requests a
|
|
11
|
+
* The class keeps track of the substitutions generated for each value, such that when
|
|
12
|
+
* the user requests a substitute for a known value, that previous one is returned.
|
|
13
|
+
*
|
|
14
|
+
* Values are compared using the SameValueZero algorithm(it uses a Map internally).
|
|
15
|
+
* This means that:
|
|
16
|
+
* ```ts
|
|
17
|
+
* assert(values.substitute(new Set([1,2,3])) !== values.substitute(new Set([1,2,3])));
|
|
18
|
+
* ```
|
|
13
19
|
*
|
|
14
20
|
* When the user requests a reference for an unknown value, then one is generated and
|
|
15
21
|
* stored for future use.
|
|
22
|
+
*
|
|
23
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Equality_comparisons_and_sameness#same-value-zero_equality
|
|
16
24
|
*/
|
|
17
25
|
class AttributeValues {
|
|
18
26
|
values;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/commands/attributes/values.ts"],"names":[],"mappings":";;;AAIA
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/commands/attributes/values.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,eAAe;IACT,MAAM,CAAsC;IAE7D;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,KAAqB;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACH,gBAAgB;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,MAAM,GAA2C,EAAE,CAAC;QAC1D,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YACvD,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,4BAA4B,CAAC,KAAqB;QACxD,MAAM,SAAS,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,EAAoB,CAAC;QACpE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,eAAe,EAAE,CAAC;IAC/B,CAAC;CACF;AAlDD,0CAkDC"}
|
|
@@ -2,7 +2,7 @@ import type { AttributeType } from "../../types.js";
|
|
|
2
2
|
import type { AttributeNames } from "../attributes/names.js";
|
|
3
3
|
import type { AttributeValues } from "../attributes/values.js";
|
|
4
4
|
import type { IExpression } from "./expression.js";
|
|
5
|
-
import { AttributeOperand, type IOperand, type Operand, type ValueOperand } from "./operands.js";
|
|
5
|
+
import { AttributeOperand, type IOperand, type Operand, type ValueOperand } from "./operands/index.js";
|
|
6
6
|
export type ConditionOperand = Operand | SizeOperand;
|
|
7
7
|
export type Stringifier = (params: {
|
|
8
8
|
names: AttributeNames;
|
|
@@ -4,7 +4,7 @@ exports.SizeOperand = exports.AttributeConditionBuilder = exports.OperandConditi
|
|
|
4
4
|
exports.not = not;
|
|
5
5
|
exports.where = where;
|
|
6
6
|
exports.size = size;
|
|
7
|
-
const
|
|
7
|
+
const index_js_1 = require("./operands/index.js");
|
|
8
8
|
class Condition {
|
|
9
9
|
stringifier;
|
|
10
10
|
constructor(params) {
|
|
@@ -338,7 +338,7 @@ class AttributeConditionBuilder extends OperandConditionBuilder {
|
|
|
338
338
|
}
|
|
339
339
|
exports.AttributeConditionBuilder = AttributeConditionBuilder;
|
|
340
340
|
function where(operand) {
|
|
341
|
-
if (operand instanceof
|
|
341
|
+
if (operand instanceof index_js_1.AttributeOperand) {
|
|
342
342
|
return new AttributeConditionBuilder(operand);
|
|
343
343
|
}
|
|
344
344
|
return new OperandConditionBuilder(operand);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":";;;AAyGA,kBAMC;AAgSD,sBAKC;AAkBD,oBAEC;AApaD
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":";;;AAyGA,kBAMC;AAgSD,sBAKC;AAkBD,oBAEC;AApaD,kDAK6B;AAmB7B,MAAa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,EAAE,CAAC;QACxC,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,8EAA8E;AAC9E,MAAa,WAAW;IACL,KAAK,CAAU;IAEhC,YAAY,OAAgB;QAC1B,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;CACF;AAbD,kCAaC;AAED,SAAgB,IAAI,CAAC,OAAgB;IACnC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./condition.js"), exports);
|
|
18
18
|
__exportStar(require("./key-condition.js"), exports);
|
|
19
|
-
__exportStar(require("./operands.js"), exports);
|
|
19
|
+
__exportStar(require("./operands/index.js"), exports);
|
|
20
20
|
__exportStar(require("./update.js"), exports);
|
|
21
21
|
/*
|
|
22
22
|
TODO: In the expression interfaces, a slight QoL improvement would be to assume that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/expressions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,qDAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/expressions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,qDAAmC;AACnC,sDAAoC;AACpC,8CAA4B;AAE5B;;;;;GAKG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./name.js"), exports);
|
|
18
|
+
__exportStar(require("./type.js"), exports);
|
|
19
|
+
__exportStar(require("./value.js"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AttributePath } from "../../../types.js";
|
|
2
|
+
import type { AttributeNames } from "../../attributes/names.js";
|
|
3
|
+
import type { AttributeValues } from "../../attributes/values.js";
|
|
4
|
+
import type { IOperand } from "./type.js";
|
|
5
|
+
/**
|
|
6
|
+
* Represents an attribute by name operand in an expression.
|
|
7
|
+
*
|
|
8
|
+
* When this operand is stringified, it first registers the
|
|
9
|
+
* attribute name in the {@link AttributeNames} registry and substitutes
|
|
10
|
+
* it with the returned value.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AttributeOperand implements IOperand {
|
|
13
|
+
private readonly path;
|
|
14
|
+
constructor(path: AttributePath);
|
|
15
|
+
substitute(params: {
|
|
16
|
+
names: AttributeNames;
|
|
17
|
+
values: AttributeValues;
|
|
18
|
+
}): string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Factory function to create an `AttributeOperand` with fewer characters.
|
|
22
|
+
*
|
|
23
|
+
* @param path - The path of the attribute this operand represents.
|
|
24
|
+
*
|
|
25
|
+
* @returns A new {@link AttributeOperand} instance for the provided path.
|
|
26
|
+
*/
|
|
27
|
+
export declare function attribute(path: AttributePath): AttributeOperand;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttributeOperand = void 0;
|
|
4
|
+
exports.attribute = attribute;
|
|
5
|
+
/**
|
|
6
|
+
* Represents an attribute by name operand in an expression.
|
|
7
|
+
*
|
|
8
|
+
* When this operand is stringified, it first registers the
|
|
9
|
+
* attribute name in the {@link AttributeNames} registry and substitutes
|
|
10
|
+
* it with the returned value.
|
|
11
|
+
*/
|
|
12
|
+
class AttributeOperand {
|
|
13
|
+
path;
|
|
14
|
+
constructor(path) {
|
|
15
|
+
this.path = path;
|
|
16
|
+
}
|
|
17
|
+
substitute(params) {
|
|
18
|
+
const { names } = params;
|
|
19
|
+
return names.substitute(this.path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.AttributeOperand = AttributeOperand;
|
|
23
|
+
/**
|
|
24
|
+
* Factory function to create an `AttributeOperand` with fewer characters.
|
|
25
|
+
*
|
|
26
|
+
* @param path - The path of the attribute this operand represents.
|
|
27
|
+
*
|
|
28
|
+
* @returns A new {@link AttributeOperand} instance for the provided path.
|
|
29
|
+
*/
|
|
30
|
+
function attribute(path) {
|
|
31
|
+
return new AttributeOperand(path);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/name.ts"],"names":[],"mappings":";;;AAmCA,8BAEC;AAhCD;;;;;;GAMG;AACH,MAAa,gBAAgB;IACV,IAAI,CAAgB;IAErC,YAAY,IAAmB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,UAAU,CAAC,MAGV;QACC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACF;AAdD,4CAcC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,IAAmB;IAC3C,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 { AttributeOperand } from "./name.js";
|
|
5
|
+
import type { ValueOperand } from "./value.js";
|
|
6
|
+
export type Operand<T extends AttributeValue = AttributeValue> = AttributeOperand | ValueOperand<T>;
|
|
7
|
+
export interface IOperand {
|
|
8
|
+
substitute(params: {
|
|
9
|
+
names: AttributeNames;
|
|
10
|
+
values: AttributeValues;
|
|
11
|
+
}): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { IOperand } from "./type.js";
|
|
5
|
+
/**
|
|
6
|
+
* Represents a value operand in an expression.
|
|
7
|
+
*
|
|
8
|
+
* When this operand is stringified, it first registers the
|
|
9
|
+
* value in the {@link AttributeValues} registry and substitutes
|
|
10
|
+
* it with the returned value.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ValueOperand<T extends AttributeValue = AttributeValue> implements IOperand {
|
|
13
|
+
private readonly value;
|
|
14
|
+
constructor(value: T);
|
|
15
|
+
substitute(params: {
|
|
16
|
+
names: AttributeNames;
|
|
17
|
+
values: AttributeValues;
|
|
18
|
+
}): string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Factory function to create a `ValueOperand` with fewer characters.
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value this operand represents.
|
|
24
|
+
*
|
|
25
|
+
* @returns A new {@link ValueOperand} instance for the provided value.
|
|
26
|
+
*/
|
|
27
|
+
export declare function value<T extends AttributeValue = AttributeValue>(value: T): ValueOperand<T>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValueOperand = void 0;
|
|
4
|
+
exports.value = value;
|
|
5
|
+
/**
|
|
6
|
+
* Represents a value operand in an expression.
|
|
7
|
+
*
|
|
8
|
+
* When this operand is stringified, it first registers the
|
|
9
|
+
* value in the {@link AttributeValues} registry and substitutes
|
|
10
|
+
* it with the returned value.
|
|
11
|
+
*/
|
|
12
|
+
class ValueOperand {
|
|
13
|
+
value;
|
|
14
|
+
constructor(value) {
|
|
15
|
+
this.value = value;
|
|
16
|
+
}
|
|
17
|
+
substitute(params) {
|
|
18
|
+
const { values } = params;
|
|
19
|
+
return values.substitute(this.value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ValueOperand = ValueOperand;
|
|
23
|
+
/**
|
|
24
|
+
* Factory function to create a `ValueOperand` with fewer characters.
|
|
25
|
+
*
|
|
26
|
+
* @param value - The value this operand represents.
|
|
27
|
+
*
|
|
28
|
+
* @returns A new {@link ValueOperand} instance for the provided value.
|
|
29
|
+
*/
|
|
30
|
+
function value(value) {
|
|
31
|
+
return new ValueOperand(value);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../../../../src/commands/expressions/operands/value.ts"],"names":[],"mappings":";;;AAqCA,sBAIC;AApCD;;;;;;GAMG;AACH,MAAa,YAAY;IAGN,KAAK,CAAI;IAE1B,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,UAAU,CAAC,MAGV;QACC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAC1B,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF;AAhBD,oCAgBC;AAED;;;;;;GAMG;AACH,SAAgB,KAAK,CACnB,KAAQ;IAER,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import type { AttributeValueNumber, AttributeValueSet } from "../../types.js";
|
|
1
2
|
import type { AttributeNames } from "../attributes/names.js";
|
|
2
3
|
import type { AttributeValues } from "../attributes/values.js";
|
|
3
4
|
import type { IExpression } from "./expression.js";
|
|
4
|
-
import type { AttributeOperand
|
|
5
|
+
import type { AttributeOperand } from "./operands/name.js";
|
|
6
|
+
import type { IOperand, Operand } from "./operands/type.js";
|
|
7
|
+
import type { ValueOperand } from "./operands/value.js";
|
|
5
8
|
export type UpdateExpressionParams = ReadonlyArray<UpdateAction>;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html
|
|
12
|
+
*/
|
|
6
13
|
export declare class UpdateExpression implements IExpression {
|
|
7
14
|
private readonly clauses;
|
|
8
15
|
private constructor();
|
|
@@ -18,28 +25,28 @@ export interface IUpdateAction {
|
|
|
18
25
|
values: AttributeValues;
|
|
19
26
|
}): string;
|
|
20
27
|
}
|
|
21
|
-
export type UpdateAction = SetAction | RemoveAction;
|
|
22
|
-
export type SetAction =
|
|
28
|
+
export type UpdateAction = SetAction | RemoveAction | AddAction;
|
|
29
|
+
export type SetAction = SetTo | SetToPlus | SetToMinus;
|
|
23
30
|
export type SetOperand = Operand | IfNotExistsOperand;
|
|
24
|
-
declare class
|
|
31
|
+
declare class SetTo implements IUpdateAction {
|
|
25
32
|
private readonly path;
|
|
26
33
|
private readonly operand;
|
|
27
34
|
constructor(params: {
|
|
28
35
|
path: AttributeOperand;
|
|
29
36
|
operand: SetOperand;
|
|
30
37
|
});
|
|
31
|
-
plus(operand: SetOperand):
|
|
32
|
-
minus(operand: SetOperand):
|
|
38
|
+
plus(operand: SetOperand): SetToPlus;
|
|
39
|
+
minus(operand: SetOperand): SetToMinus;
|
|
33
40
|
stringify(params: {
|
|
34
41
|
names: AttributeNames;
|
|
35
42
|
values: AttributeValues;
|
|
36
43
|
}): string;
|
|
37
44
|
}
|
|
38
|
-
export declare class
|
|
45
|
+
export declare class SetToPlus implements IUpdateAction {
|
|
39
46
|
private readonly inner;
|
|
40
47
|
private readonly operand;
|
|
41
48
|
constructor(params: {
|
|
42
|
-
inner:
|
|
49
|
+
inner: SetTo;
|
|
43
50
|
operand: SetOperand;
|
|
44
51
|
});
|
|
45
52
|
stringify(params: {
|
|
@@ -47,11 +54,11 @@ export declare class PlusAssignment implements IUpdateAction {
|
|
|
47
54
|
values: AttributeValues;
|
|
48
55
|
}): string;
|
|
49
56
|
}
|
|
50
|
-
export declare class
|
|
57
|
+
export declare class SetToMinus implements IUpdateAction {
|
|
51
58
|
private readonly inner;
|
|
52
59
|
private readonly operand;
|
|
53
60
|
constructor(params: {
|
|
54
|
-
inner:
|
|
61
|
+
inner: SetTo;
|
|
55
62
|
operand: SetOperand;
|
|
56
63
|
});
|
|
57
64
|
stringify(params: {
|
|
@@ -59,12 +66,12 @@ export declare class MinusAssignment implements IUpdateAction {
|
|
|
59
66
|
values: AttributeValues;
|
|
60
67
|
}): string;
|
|
61
68
|
}
|
|
62
|
-
declare class
|
|
69
|
+
declare class SetToBuilder {
|
|
63
70
|
private readonly path;
|
|
64
71
|
constructor(path: AttributeOperand);
|
|
65
|
-
to(operand: SetOperand):
|
|
72
|
+
to(operand: SetOperand): SetTo;
|
|
66
73
|
}
|
|
67
|
-
export declare function
|
|
74
|
+
export declare function set(path: AttributeOperand): SetToBuilder;
|
|
68
75
|
export declare class RemoveAction implements IUpdateAction {
|
|
69
76
|
private readonly path;
|
|
70
77
|
private constructor();
|
|
@@ -82,6 +89,21 @@ export declare class RemoveAction implements IUpdateAction {
|
|
|
82
89
|
* @returns A {@link RemoveAction} corresponding to the path provided.
|
|
83
90
|
*/
|
|
84
91
|
export declare function remove(path: AttributeOperand): RemoveAction;
|
|
92
|
+
type NumberOrSet = AttributeValueNumber | AttributeValueSet;
|
|
93
|
+
export declare class AddAction implements IUpdateAction {
|
|
94
|
+
private readonly path;
|
|
95
|
+
private readonly value;
|
|
96
|
+
private constructor();
|
|
97
|
+
stringify(params: {
|
|
98
|
+
names: AttributeNames;
|
|
99
|
+
values: AttributeValues;
|
|
100
|
+
}): string;
|
|
101
|
+
static from(params: {
|
|
102
|
+
path: AttributeOperand;
|
|
103
|
+
value: ValueOperand<NumberOrSet>;
|
|
104
|
+
}): AddAction;
|
|
105
|
+
}
|
|
106
|
+
export declare function add(path: AttributeOperand, value: ValueOperand<NumberOrSet>): AddAction;
|
|
85
107
|
export declare class IfNotExistsOperand implements IOperand {
|
|
86
108
|
private readonly path;
|
|
87
109
|
private readonly defaultValue;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IfNotExistsOperand = exports.RemoveAction = exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.IfNotExistsOperand = exports.AddAction = exports.RemoveAction = exports.SetToMinus = exports.SetToPlus = exports.UpdateExpression = void 0;
|
|
4
|
+
exports.set = set;
|
|
5
5
|
exports.remove = remove;
|
|
6
|
+
exports.add = add;
|
|
6
7
|
exports.ifNotExists = ifNotExists;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html
|
|
11
|
+
*/
|
|
7
12
|
class UpdateExpression {
|
|
8
13
|
clauses;
|
|
9
14
|
constructor(clauses) {
|
|
@@ -22,14 +27,19 @@ class UpdateExpression {
|
|
|
22
27
|
.map((action) => action.stringify({ names, values }))
|
|
23
28
|
.join(",")}`);
|
|
24
29
|
}
|
|
30
|
+
if (this.clauses.add != null) {
|
|
31
|
+
parts.push(`ADD ${this.clauses.add
|
|
32
|
+
.map((action) => action.stringify({ names, values }))
|
|
33
|
+
.join(",")}`);
|
|
34
|
+
}
|
|
25
35
|
return parts.join("\n");
|
|
26
36
|
}
|
|
27
37
|
static from(params) {
|
|
28
38
|
const clauses = {};
|
|
29
39
|
for (const action of params) {
|
|
30
|
-
if (action instanceof
|
|
31
|
-
action instanceof
|
|
32
|
-
action instanceof
|
|
40
|
+
if (action instanceof SetTo ||
|
|
41
|
+
action instanceof SetToPlus ||
|
|
42
|
+
action instanceof SetToMinus) {
|
|
33
43
|
clauses.set ??= [];
|
|
34
44
|
clauses.set.push(action);
|
|
35
45
|
}
|
|
@@ -37,6 +47,10 @@ class UpdateExpression {
|
|
|
37
47
|
clauses.remove ??= [];
|
|
38
48
|
clauses.remove.push(action);
|
|
39
49
|
}
|
|
50
|
+
else if (action instanceof AddAction) {
|
|
51
|
+
clauses.add ??= [];
|
|
52
|
+
clauses.add.push(action);
|
|
53
|
+
}
|
|
40
54
|
else {
|
|
41
55
|
throw new Error("unknown action type in update expression");
|
|
42
56
|
}
|
|
@@ -45,7 +59,7 @@ class UpdateExpression {
|
|
|
45
59
|
}
|
|
46
60
|
}
|
|
47
61
|
exports.UpdateExpression = UpdateExpression;
|
|
48
|
-
class
|
|
62
|
+
class SetTo {
|
|
49
63
|
path;
|
|
50
64
|
operand;
|
|
51
65
|
constructor(params) {
|
|
@@ -54,10 +68,10 @@ class Assignment {
|
|
|
54
68
|
this.operand = operand;
|
|
55
69
|
}
|
|
56
70
|
plus(operand) {
|
|
57
|
-
return new
|
|
71
|
+
return new SetToPlus({ inner: this, operand });
|
|
58
72
|
}
|
|
59
73
|
minus(operand) {
|
|
60
|
-
return new
|
|
74
|
+
return new SetToMinus({ inner: this, operand });
|
|
61
75
|
}
|
|
62
76
|
stringify(params) {
|
|
63
77
|
const { names, values } = params;
|
|
@@ -67,7 +81,7 @@ class Assignment {
|
|
|
67
81
|
})}`;
|
|
68
82
|
}
|
|
69
83
|
}
|
|
70
|
-
class
|
|
84
|
+
class SetToPlus {
|
|
71
85
|
inner;
|
|
72
86
|
operand;
|
|
73
87
|
constructor(params) {
|
|
@@ -83,8 +97,8 @@ class PlusAssignment {
|
|
|
83
97
|
})}`;
|
|
84
98
|
}
|
|
85
99
|
}
|
|
86
|
-
exports.
|
|
87
|
-
class
|
|
100
|
+
exports.SetToPlus = SetToPlus;
|
|
101
|
+
class SetToMinus {
|
|
88
102
|
inner;
|
|
89
103
|
operand;
|
|
90
104
|
constructor(params) {
|
|
@@ -100,19 +114,21 @@ class MinusAssignment {
|
|
|
100
114
|
})}`;
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
|
-
exports.
|
|
104
|
-
class
|
|
117
|
+
exports.SetToMinus = SetToMinus;
|
|
118
|
+
class SetToBuilder {
|
|
105
119
|
path;
|
|
106
120
|
constructor(path) {
|
|
107
121
|
this.path = path;
|
|
108
122
|
}
|
|
109
123
|
to(operand) {
|
|
110
|
-
return new
|
|
124
|
+
return new SetTo({ path: this.path, operand });
|
|
111
125
|
}
|
|
112
126
|
}
|
|
113
127
|
// TODO: increment/decrement utilities built on top of the assignments.
|
|
114
|
-
|
|
115
|
-
|
|
128
|
+
// TODO: review API for something more streamlined.... Imagine something like:
|
|
129
|
+
// set(attribute(<name>), value(<value>)) or set(attribute(<name>), value(<first>), "+", value(<second>))
|
|
130
|
+
function set(path) {
|
|
131
|
+
return new SetToBuilder(path);
|
|
116
132
|
}
|
|
117
133
|
class RemoveAction {
|
|
118
134
|
path;
|
|
@@ -138,6 +154,28 @@ exports.RemoveAction = RemoveAction;
|
|
|
138
154
|
function remove(path) {
|
|
139
155
|
return RemoveAction.from(path);
|
|
140
156
|
}
|
|
157
|
+
// Note: the first operand *must* be an attribute name, and the second operand *must* be a value.
|
|
158
|
+
// This action only makes sense for sets and numbers.
|
|
159
|
+
class AddAction {
|
|
160
|
+
path;
|
|
161
|
+
value;
|
|
162
|
+
constructor(params) {
|
|
163
|
+
const { path, value } = params;
|
|
164
|
+
this.path = path;
|
|
165
|
+
this.value = value;
|
|
166
|
+
}
|
|
167
|
+
stringify(params) {
|
|
168
|
+
const { names, values } = params;
|
|
169
|
+
return `${this.path.substitute({ names, values })} ${this.value.substitute({ names, values })}`;
|
|
170
|
+
}
|
|
171
|
+
static from(params) {
|
|
172
|
+
return new AddAction(params);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.AddAction = AddAction;
|
|
176
|
+
function add(path, value) {
|
|
177
|
+
return AddAction.from({ path, value });
|
|
178
|
+
}
|
|
141
179
|
class IfNotExistsOperand {
|
|
142
180
|
path;
|
|
143
181
|
defaultValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/expressions/update.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/expressions/update.ts"],"names":[],"mappings":";;;AAuNA,kBAEC;AA6BD,wBAEC;AAmCD,kBAKC;AAqBD,kCAKC;AAnRD;;;GAGG;AACH,MAAa,gBAAgB;IACV,OAAO,CAA0B;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.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { ScalarAttributeType } from "@aws-sdk/client-dynamodb";
|
|
2
|
-
import type { NativeAttributeValue } from "@aws-sdk/lib-dynamodb";
|
|
2
|
+
import type { NativeAttributeBinary, NativeAttributeValue, NumberValue } from "@aws-sdk/lib-dynamodb";
|
|
3
3
|
export type AttributeName = string;
|
|
4
4
|
export type AttributeValue = NativeAttributeValue;
|
|
5
|
+
/**
|
|
6
|
+
* A type regrouping all javascript native types that correspond to a valid DynamoDB
|
|
7
|
+
* number attribute.
|
|
8
|
+
*/
|
|
9
|
+
export type AttributeValueNumber = number | NumberValue | bigint;
|
|
10
|
+
/**
|
|
11
|
+
* A type regrouping all javascript native types that corerspond to a valid DynamoDB
|
|
12
|
+
* set attribute.
|
|
13
|
+
*/
|
|
14
|
+
export type AttributeValueSet = Set<AttributeValueNumber | string | NativeAttributeBinary | undefined>;
|
|
5
15
|
export type AttributePath = AttributeName;
|
|
6
16
|
export type AttributeType = "S" | "N" | "B" | "BOOL" | "NULL" | "M" | "L" | "SS" | "NS" | "BS";
|
|
7
17
|
export interface Attribute {
|