@infra-blocks/aws-dynamodb 0.9.0 → 0.10.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.
@@ -10,12 +10,39 @@ export type Substitution = `#${string}`;
10
10
  * - To access an attribute whose name conflicts with a DynamoDB reserved word.
11
11
  * - To create a placeholder for repeating occurrences of an attribute name in an expression.
12
12
  * - To prevent special characters in an attribute name from being misinterpreted in an expression.
13
+ *
14
+ * This class provides an automated way to generate attribute substitution variables
15
+ * so that every attribute path in an expression can be treated the same: systematically replaced
16
+ * with an automatically generated variable.
17
+ *
18
+ * The class keeps track of the variables generated for each attribute path, such that when
19
+ * the user requests a substitution for a known value, that substitution is returned.
20
+ *
21
+ * When the user requests a substitution for an unknown attribute name, then one is generated and
22
+ * stored for future use.
13
23
  */
14
24
  export declare class AttributeNames {
15
25
  private readonly names;
16
26
  private constructor();
17
- add(...attributes: AttributePath[]): void;
18
- getSubstitute(attribute: AttributePath): Substitution;
27
+ /**
28
+ * Returns a substitution variable for the given attribute path.
29
+ *
30
+ * If the attribute path is seen for the first time by this object, a new substitution is generated,
31
+ * assigned to the attribute path, and returned.
32
+ *
33
+ * If the attribute path was previously seen, then the associated substitution is returned.
34
+ *
35
+ * @param attribute - The path of the attribute to substitute.
36
+ *
37
+ * @returns The substitution associated with the attribute path.
38
+ */
39
+ substitute(attribute: AttributePath): Substitution;
40
+ /**
41
+ * Returns a record where the keys are the substitutions generated by this object
42
+ * and the values are the corresponding attribute paths they where generated for.
43
+ *
44
+ * @returns A mapping of substitutions generated by this object, undefined if none were.
45
+ */
19
46
  getSubstitutions(): Record<Substitution, AttributePath> | undefined;
20
47
  private generateSubstitute;
21
48
  static create(): AttributeNames;
@@ -8,28 +8,51 @@ exports.AttributeNames = void 0;
8
8
  * - To access an attribute whose name conflicts with a DynamoDB reserved word.
9
9
  * - To create a placeholder for repeating occurrences of an attribute name in an expression.
10
10
  * - To prevent special characters in an attribute name from being misinterpreted in an expression.
11
+ *
12
+ * This class provides an automated way to generate attribute substitution variables
13
+ * so that every attribute path in an expression can be treated the same: systematically replaced
14
+ * with an automatically generated variable.
15
+ *
16
+ * The class keeps track of the variables generated for each attribute path, such that when
17
+ * the user requests a substitution for a known value, that substitution is returned.
18
+ *
19
+ * When the user requests a substitution for an unknown attribute name, then one is generated and
20
+ * stored for future use.
11
21
  */
12
22
  class AttributeNames {
13
23
  names;
14
24
  constructor() {
15
25
  this.names = new Map();
16
26
  }
17
- add(...attributes) {
18
- for (const attribute of attributes) {
19
- if (this.names.has(attribute)) {
20
- continue;
21
- }
22
- const substitute = this.generateSubstitute(attribute);
23
- this.names.set(attribute, substitute);
24
- }
25
- }
26
- getSubstitute(attribute) {
27
- const substitute = this.names.get(attribute);
28
- if (substitute == null) {
29
- throw new Error(`no substitution found for attribute: ${attribute}`);
27
+ /**
28
+ * Returns a substitution variable for the given attribute path.
29
+ *
30
+ * If the attribute path is seen for the first time by this object, a new substitution is generated,
31
+ * assigned to the attribute path, and returned.
32
+ *
33
+ * If the attribute path was previously seen, then the associated substitution is returned.
34
+ *
35
+ * @param attribute - The path of the attribute to substitute.
36
+ *
37
+ * @returns The substitution associated with the attribute path.
38
+ */
39
+ substitute(attribute) {
40
+ const current = this.names.get(attribute);
41
+ if (current != null) {
42
+ // If the attribute is already known, we return its current substitution.
43
+ return current;
30
44
  }
45
+ // Otherwise, we generate a new substitution for the attribute.
46
+ const substitute = this.generateSubstitute(attribute);
47
+ this.names.set(attribute, substitute);
31
48
  return substitute;
32
49
  }
50
+ /**
51
+ * Returns a record where the keys are the substitutions generated by this object
52
+ * and the values are the corresponding attribute paths they where generated for.
53
+ *
54
+ * @returns A mapping of substitutions generated by this object, undefined if none were.
55
+ */
33
56
  getSubstitutions() {
34
57
  if (this.names.size === 0) {
35
58
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/commands/attributes/names.ts"],"names":[],"mappings":";;;AAOA;;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}
1
+ {"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/commands/attributes/names.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,cAAc;IACR,KAAK,CAAmC;IAEzD;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,SAAwB;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,yEAAyE;YACzE,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,+DAA+D;QAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,gBAAgB;QACd,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,MAAM,GAAwC,EAAE,CAAC;QACvD,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3D,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;QACjC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,kBAAkB,CAAC,SAAwB;QACjD,OAAO,IAAI,SAAS,EAAkB,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;CACF;AAxDD,wCAwDC"}
@@ -1,11 +1,35 @@
1
1
  import type { AttributeValue } from "../../types.js";
2
2
  export type ValueReference = `:${string}`;
3
+ /**
4
+ * Represents a set of attribute values used in an expression.
5
+ *
6
+ * This class provides an automated way to generate value reference variables
7
+ * so that every value in an expression can be treated the same: systematically replaced
8
+ * with an automatically generated variable.
9
+ *
10
+ * The class keeps track of the references generated for each value, such that when
11
+ * the user requests a reference for a known value, that reference is returned.
12
+ *
13
+ * When the user requests a reference for an unknown value, then one is generated and
14
+ * stored for future use.
15
+ */
3
16
  export declare class AttributeValues {
4
17
  private readonly values;
5
18
  private counter;
6
19
  private constructor();
7
- add(...values: AttributeValue[]): void;
8
- getReference(value: AttributeValue): ValueReference;
20
+ /**
21
+ * Returns a reference variable for the given attribute value.
22
+ *
23
+ * If the attribute value is seen for the first time by this object, a new reference is generated,
24
+ * assigned to the attribute value, and returned.
25
+ *
26
+ * If the value was previously seen, then the associated reference is returned.
27
+ *
28
+ * @param value - The attribute value to generate a reference for.
29
+ *
30
+ * @returns The reference associated with the attribute value.
31
+ */
32
+ reference(value: AttributeValue): ValueReference;
9
33
  getReferences(): Record<ValueReference, AttributeValue> | undefined;
10
34
  private nextReference;
11
35
  static create(): AttributeValues;
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AttributeValues = void 0;
4
+ /**
5
+ * Represents a set of attribute values used in an expression.
6
+ *
7
+ * This class provides an automated way to generate value reference variables
8
+ * so that every value in an expression can be treated the same: systematically replaced
9
+ * with an automatically generated variable.
10
+ *
11
+ * The class keeps track of the references generated for each value, such that when
12
+ * the user requests a reference for a known value, that reference is returned.
13
+ *
14
+ * When the user requests a reference for an unknown value, then one is generated and
15
+ * stored for future use.
16
+ */
4
17
  class AttributeValues {
5
18
  values;
6
19
  counter;
@@ -8,18 +21,22 @@ class AttributeValues {
8
21
  this.values = new Map();
9
22
  this.counter = 0;
10
23
  }
11
- add(...values) {
12
- for (const value of values) {
13
- if (this.values.has(value)) {
14
- continue;
15
- }
16
- const reference = this.nextReference();
17
- this.values.set(value, reference);
18
- }
19
- }
20
- getReference(value) {
24
+ /**
25
+ * Returns a reference variable for the given attribute value.
26
+ *
27
+ * If the attribute value is seen for the first time by this object, a new reference is generated,
28
+ * assigned to the attribute value, and returned.
29
+ *
30
+ * If the value was previously seen, then the associated reference is returned.
31
+ *
32
+ * @param value - The attribute value to generate a reference for.
33
+ *
34
+ * @returns The reference associated with the attribute value.
35
+ */
36
+ reference(value) {
21
37
  const existing = this.values.get(value);
22
38
  if (existing != null) {
39
+ // If the value is already known, we do not need to generate a new reference.
23
40
  return existing;
24
41
  }
25
42
  const reference = this.nextReference();
@@ -1 +1 @@
1
- {"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/commands/attributes/values.ts"],"names":[],"mappings":";;;AAIA,MAAa,eAAe;IACT,MAAM,CAAsC;IACrD,OAAO,CAAS;IAExB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,GAAG,CAAC,GAAG,MAAwB;QAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACX,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,YAAY,CAAC,KAAqB;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EA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,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,aAAa;QACX,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,aAAa;QACnB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,EAAoB,CAAC;QACvD,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,eAAe,EAAE,CAAC;IAC/B,CAAC;CACF;AAtDD,0CAsDC"}
@@ -21,4 +21,5 @@ export declare class ConditionExpression implements Expression {
21
21
  export declare function attributeNotExists(attribute: AttributePath): ConditionExpression;
22
22
  export declare function attributeExists(attribute: AttributePath): ConditionExpression;
23
23
  export declare function attributeType(attribute: AttributePath, type: AttributeType): ConditionExpression;
24
+ export declare function beginsWith(attribute: AttributePath, value: string): ConditionExpression;
24
25
  export declare function not(condition: ConditionExpression): ConditionExpression;
@@ -4,6 +4,7 @@ exports.ConditionExpression = void 0;
4
4
  exports.attributeNotExists = attributeNotExists;
5
5
  exports.attributeExists = attributeExists;
6
6
  exports.attributeType = attributeType;
7
+ exports.beginsWith = beginsWith;
7
8
  exports.not = not;
8
9
  /**
9
10
  *
@@ -46,8 +47,7 @@ function attributeNotExists(attribute) {
46
47
  return new ConditionExpression({
47
48
  inner: {
48
49
  stringify: ({ attributeNames }) => {
49
- attributeNames.add(attribute);
50
- return `attribute_not_exists(${attributeNames.getSubstitute(attribute)})`;
50
+ return `attribute_not_exists(${attributeNames.substitute(attribute)})`;
51
51
  },
52
52
  },
53
53
  });
@@ -56,8 +56,7 @@ function attributeExists(attribute) {
56
56
  return new ConditionExpression({
57
57
  inner: {
58
58
  stringify: ({ attributeNames }) => {
59
- attributeNames.add(attribute);
60
- return `attribute_exists(${attributeNames.getSubstitute(attribute)})`;
59
+ return `attribute_exists(${attributeNames.substitute(attribute)})`;
61
60
  },
62
61
  },
63
62
  });
@@ -66,9 +65,16 @@ function attributeType(attribute, type) {
66
65
  return new ConditionExpression({
67
66
  inner: {
68
67
  stringify: ({ attributeNames, attributeValues }) => {
69
- attributeNames.add(attribute);
70
- attributeValues.add(type);
71
- return `attribute_type(${attributeNames.getSubstitute(attribute)}, ${attributeValues.getReference(type)})`;
68
+ return `attribute_type(${attributeNames.substitute(attribute)}, ${attributeValues.reference(type)})`;
69
+ },
70
+ },
71
+ });
72
+ }
73
+ function beginsWith(attribute, value) {
74
+ return new ConditionExpression({
75
+ inner: {
76
+ stringify: ({ attributeNames, attributeValues }) => {
77
+ return `begins_with(${attributeNames.substitute(attribute)}, ${attributeValues.reference(value)})`;
72
78
  },
73
79
  },
74
80
  });
@@ -1 +1 @@
1
- {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":";;;AAiDA,gDAWC;AAED,0CASC;AAED,sCAaC;AAED,kBASC;AA5FD;;;GAGG;AACH,MAAa,mBAAmB;IACb,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,EAAE,CAAC,KAA0B;QAC3B,OAAO,IAAI,mBAAmB,CAAC;YAC7B,KA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AAE;gBAChC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC9B,OAAO,oBAAoB,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC;YACxE,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,aAAa,CAC3B,SAAwB,EACxB,IAAmB;IAEnB,OAAO,IAAI,mBAAmB,CAAC;QAC7B,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC9B,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC1B,OAAO,kBAAkB,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;YAC7G,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,GAAG,CAAC,SAA8B;IAChD,OAAO,IAAI,mBAAmB,CAAC;QAC7B,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC,CAAC;gBACvE,OAAO,QAAQ,KAAK,GAAG,CAAC;YAC1B,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":";;;AAiDA,gDAUC;AAED,0CAQC;AAED,sCAWC;AAED,gCAWC;AAED,kBASC;AArGD;;;GAGG;AACH,MAAa,mBAAmB;IACb,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;I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new KeyConditionExpression({
18
18
  inner: {
19
19
  stringify: ({ attributeNames, attributeValues }) => {
20
- attributeNames.add(name);
21
- attributeValues.add(value);
22
- const substitute = attributeNames.getSubstitute(name);
23
- const reference = attributeValues.getReference(value);
20
+ const substitute = attributeNames.substitute(name);
21
+ const reference = attributeValues.reference(value);
24
22
  return `${substitute} = ${reference}`;
25
23
  },
26
24
  },
@@ -1 +1 @@
1
- {"version":3,"file":"key-condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/key-condition.ts"],"names":[],"mappings":";;;AAqBA,wBAeC;AA/BD,MAAa,sBAAsB;IAChB,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AAdD,wDAcC;AAED,SAAgB,MAAM,CACpB,IAAmB,EACnB,KAAqB;IAErB,OAAO,IAAI,sBAAsB,CAAC;QAChC,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACzB,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC3B,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACtD,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBACtD,OAAO,GAAG,UAAU,MAAM,SAAS,EAAE,CAAC;YACxC,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"key-condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/key-condition.ts"],"names":[],"mappings":";;;AAqBA,wBAaC;AA7BD,MAAa,sBAAsB;IAChB,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AAdD,wDAcC;AAED,SAAgB,MAAM,CACpB,IAAmB,EACnB,KAAqB;IAErB,OAAO,IAAI,sBAAsB,CAAC;QAChC,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACnD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACnD,OAAO,GAAG,UAAU,MAAM,SAAS,EAAE,CAAC;YACxC,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -10,12 +10,39 @@ export type Substitution = `#${string}`;
10
10
  * - To access an attribute whose name conflicts with a DynamoDB reserved word.
11
11
  * - To create a placeholder for repeating occurrences of an attribute name in an expression.
12
12
  * - To prevent special characters in an attribute name from being misinterpreted in an expression.
13
+ *
14
+ * This class provides an automated way to generate attribute substitution variables
15
+ * so that every attribute path in an expression can be treated the same: systematically replaced
16
+ * with an automatically generated variable.
17
+ *
18
+ * The class keeps track of the variables generated for each attribute path, such that when
19
+ * the user requests a substitution for a known value, that substitution is returned.
20
+ *
21
+ * When the user requests a substitution for an unknown attribute name, then one is generated and
22
+ * stored for future use.
13
23
  */
14
24
  export declare class AttributeNames {
15
25
  private readonly names;
16
26
  private constructor();
17
- add(...attributes: AttributePath[]): void;
18
- getSubstitute(attribute: AttributePath): Substitution;
27
+ /**
28
+ * Returns a substitution variable for the given attribute path.
29
+ *
30
+ * If the attribute path is seen for the first time by this object, a new substitution is generated,
31
+ * assigned to the attribute path, and returned.
32
+ *
33
+ * If the attribute path was previously seen, then the associated substitution is returned.
34
+ *
35
+ * @param attribute - The path of the attribute to substitute.
36
+ *
37
+ * @returns The substitution associated with the attribute path.
38
+ */
39
+ substitute(attribute: AttributePath): Substitution;
40
+ /**
41
+ * Returns a record where the keys are the substitutions generated by this object
42
+ * and the values are the corresponding attribute paths they where generated for.
43
+ *
44
+ * @returns A mapping of substitutions generated by this object, undefined if none were.
45
+ */
19
46
  getSubstitutions(): Record<Substitution, AttributePath> | undefined;
20
47
  private generateSubstitute;
21
48
  static create(): AttributeNames;
@@ -5,28 +5,51 @@
5
5
  * - To access an attribute whose name conflicts with a DynamoDB reserved word.
6
6
  * - To create a placeholder for repeating occurrences of an attribute name in an expression.
7
7
  * - To prevent special characters in an attribute name from being misinterpreted in an expression.
8
+ *
9
+ * This class provides an automated way to generate attribute substitution variables
10
+ * so that every attribute path in an expression can be treated the same: systematically replaced
11
+ * with an automatically generated variable.
12
+ *
13
+ * The class keeps track of the variables generated for each attribute path, such that when
14
+ * the user requests a substitution for a known value, that substitution is returned.
15
+ *
16
+ * When the user requests a substitution for an unknown attribute name, then one is generated and
17
+ * stored for future use.
8
18
  */
9
19
  export class AttributeNames {
10
20
  names;
11
21
  constructor() {
12
22
  this.names = new Map();
13
23
  }
14
- add(...attributes) {
15
- for (const attribute of attributes) {
16
- if (this.names.has(attribute)) {
17
- continue;
18
- }
19
- const substitute = this.generateSubstitute(attribute);
20
- this.names.set(attribute, substitute);
21
- }
22
- }
23
- getSubstitute(attribute) {
24
- const substitute = this.names.get(attribute);
25
- if (substitute == null) {
26
- throw new Error(`no substitution found for attribute: ${attribute}`);
24
+ /**
25
+ * Returns a substitution variable for the given attribute path.
26
+ *
27
+ * If the attribute path is seen for the first time by this object, a new substitution is generated,
28
+ * assigned to the attribute path, and returned.
29
+ *
30
+ * If the attribute path was previously seen, then the associated substitution is returned.
31
+ *
32
+ * @param attribute - The path of the attribute to substitute.
33
+ *
34
+ * @returns The substitution associated with the attribute path.
35
+ */
36
+ substitute(attribute) {
37
+ const current = this.names.get(attribute);
38
+ if (current != null) {
39
+ // If the attribute is already known, we return its current substitution.
40
+ return current;
27
41
  }
42
+ // Otherwise, we generate a new substitution for the attribute.
43
+ const substitute = this.generateSubstitute(attribute);
44
+ this.names.set(attribute, substitute);
28
45
  return substitute;
29
46
  }
47
+ /**
48
+ * Returns a record where the keys are the substitutions generated by this object
49
+ * and the values are the corresponding attribute paths they where generated for.
50
+ *
51
+ * @returns A mapping of substitutions generated by this object, undefined if none were.
52
+ */
30
53
  getSubstitutions() {
31
54
  if (this.names.size === 0) {
32
55
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"names.js","sourceRoot":"","sources":["../../../../src/commands/attributes/names.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACR,KAAK,CAAmC;IAEzD;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IACtD,CAAC;IAED,GAAG,CAAC,GAAG,UAA2B;QAChC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9B,SAAS;YACX,CAAC;YACD,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;YACtD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,aAAa,CAAC,SAAwB;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,wCAAwC,SAAS,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;I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1B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,MAAM,GAAwC,EAAE,CAAC;QACvD,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3D,MAAM,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;QACjC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,kBAAkB,CAAC,SAAwB;QACjD,OAAO,IAAI,SAAS,EAAkB,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,cAAc,EAAE,CAAC;IAC9B,CAAC;CACF"}
@@ -1,11 +1,35 @@
1
1
  import type { AttributeValue } from "../../types.js";
2
2
  export type ValueReference = `:${string}`;
3
+ /**
4
+ * Represents a set of attribute values used in an expression.
5
+ *
6
+ * This class provides an automated way to generate value reference variables
7
+ * so that every value in an expression can be treated the same: systematically replaced
8
+ * with an automatically generated variable.
9
+ *
10
+ * The class keeps track of the references generated for each value, such that when
11
+ * the user requests a reference for a known value, that reference is returned.
12
+ *
13
+ * When the user requests a reference for an unknown value, then one is generated and
14
+ * stored for future use.
15
+ */
3
16
  export declare class AttributeValues {
4
17
  private readonly values;
5
18
  private counter;
6
19
  private constructor();
7
- add(...values: AttributeValue[]): void;
8
- getReference(value: AttributeValue): ValueReference;
20
+ /**
21
+ * Returns a reference variable for the given attribute value.
22
+ *
23
+ * If the attribute value is seen for the first time by this object, a new reference is generated,
24
+ * assigned to the attribute value, and returned.
25
+ *
26
+ * If the value was previously seen, then the associated reference is returned.
27
+ *
28
+ * @param value - The attribute value to generate a reference for.
29
+ *
30
+ * @returns The reference associated with the attribute value.
31
+ */
32
+ reference(value: AttributeValue): ValueReference;
9
33
  getReferences(): Record<ValueReference, AttributeValue> | undefined;
10
34
  private nextReference;
11
35
  static create(): AttributeValues;
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Represents a set of attribute values used in an expression.
3
+ *
4
+ * This class provides an automated way to generate value reference variables
5
+ * so that every value in an expression can be treated the same: systematically replaced
6
+ * with an automatically generated variable.
7
+ *
8
+ * The class keeps track of the references generated for each value, such that when
9
+ * the user requests a reference for a known value, that reference is returned.
10
+ *
11
+ * When the user requests a reference for an unknown value, then one is generated and
12
+ * stored for future use.
13
+ */
1
14
  export class AttributeValues {
2
15
  values;
3
16
  counter;
@@ -5,18 +18,22 @@ export class AttributeValues {
5
18
  this.values = new Map();
6
19
  this.counter = 0;
7
20
  }
8
- add(...values) {
9
- for (const value of values) {
10
- if (this.values.has(value)) {
11
- continue;
12
- }
13
- const reference = this.nextReference();
14
- this.values.set(value, reference);
15
- }
16
- }
17
- getReference(value) {
21
+ /**
22
+ * Returns a reference variable for the given attribute value.
23
+ *
24
+ * If the attribute value is seen for the first time by this object, a new reference is generated,
25
+ * assigned to the attribute value, and returned.
26
+ *
27
+ * If the value was previously seen, then the associated reference is returned.
28
+ *
29
+ * @param value - The attribute value to generate a reference for.
30
+ *
31
+ * @returns The reference associated with the attribute value.
32
+ */
33
+ reference(value) {
18
34
  const existing = this.values.get(value);
19
35
  if (existing != null) {
36
+ // If the value is already known, we do not need to generate a new reference.
20
37
  return existing;
21
38
  }
22
39
  const reference = this.nextReference();
@@ -1 +1 @@
1
- {"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../src/commands/attributes/values.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,eAAe;IACT,MAAM,CAAsC;IACrD,OAAO,CAAS;IAExB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,GAAG,CAAC,GAAG,MAAwB;QAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,SAAS;YACX,CAAC;YACD,MAAM,S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I,CAAC,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;QACxD,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,KAAqB;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,6EAA6E;YAC7E,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,aAAa;QACX,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,aAAa;QACnB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,EAAoB,CAAC;QACvD,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,eAAe,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -21,4 +21,5 @@ export declare class ConditionExpression implements Expression {
21
21
  export declare function attributeNotExists(attribute: AttributePath): ConditionExpression;
22
22
  export declare function attributeExists(attribute: AttributePath): ConditionExpression;
23
23
  export declare function attributeType(attribute: AttributePath, type: AttributeType): ConditionExpression;
24
+ export declare function beginsWith(attribute: AttributePath, value: string): ConditionExpression;
24
25
  export declare function not(condition: ConditionExpression): ConditionExpression;
@@ -38,8 +38,7 @@ export function attributeNotExists(attribute) {
38
38
  return new ConditionExpression({
39
39
  inner: {
40
40
  stringify: ({ attributeNames }) => {
41
- attributeNames.add(attribute);
42
- return `attribute_not_exists(${attributeNames.getSubstitute(attribute)})`;
41
+ return `attribute_not_exists(${attributeNames.substitute(attribute)})`;
43
42
  },
44
43
  },
45
44
  });
@@ -48,8 +47,7 @@ export function attributeExists(attribute) {
48
47
  return new ConditionExpression({
49
48
  inner: {
50
49
  stringify: ({ attributeNames }) => {
51
- attributeNames.add(attribute);
52
- return `attribute_exists(${attributeNames.getSubstitute(attribute)})`;
50
+ return `attribute_exists(${attributeNames.substitute(attribute)})`;
53
51
  },
54
52
  },
55
53
  });
@@ -58,9 +56,16 @@ export function attributeType(attribute, type) {
58
56
  return new ConditionExpression({
59
57
  inner: {
60
58
  stringify: ({ attributeNames, attributeValues }) => {
61
- attributeNames.add(attribute);
62
- attributeValues.add(type);
63
- return `attribute_type(${attributeNames.getSubstitute(attribute)}, ${attributeValues.getReference(type)})`;
59
+ return `attribute_type(${attributeNames.substitute(attribute)}, ${attributeValues.reference(type)})`;
60
+ },
61
+ },
62
+ });
63
+ }
64
+ export function beginsWith(attribute, value) {
65
+ return new ConditionExpression({
66
+ inner: {
67
+ stringify: ({ attributeNames, attributeValues }) => {
68
+ return `begins_with(${attributeNames.substitute(attribute)}, ${attributeValues.reference(value)})`;
64
69
  },
65
70
  },
66
71
  });
@@ -1 +1 @@
1
- {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IACb,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC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CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAwB;IACtD,OAAO,IAAI,mBAAmB,CAAC;QAC7B,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE;gBAChC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC9B,OAAO,oBAAoB,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC;YACxE,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,SAAwB,EACxB,IAAmB;IAEnB,OAAO,IAAI,mBAAmB,CAAC;QAC7B,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC9B,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC1B,OAAO,kBAAkB,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;YAC7G,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,SAA8B;IAChD,OAAO,IAAI,mBAAmB,CAAC;QAC7B,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC,CAAC;gBACvE,OAAO,QAAQ,KAAK,GAAG,CAAC;YAC1B,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/condition.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IACb,KAAK,CAA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AC,CAAC;gBACvE,OAAO,QAAQ,KAAK,GAAG,CAAC;YAC1B,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -12,10 +12,8 @@ export function equals(name, value) {
12
12
  return new KeyConditionExpression({
13
13
  inner: {
14
14
  stringify: ({ attributeNames, attributeValues }) => {
15
- attributeNames.add(name);
16
- attributeValues.add(value);
17
- const substitute = attributeNames.getSubstitute(name);
18
- const reference = attributeValues.getReference(value);
15
+ const substitute = attributeNames.substitute(name);
16
+ const reference = attributeValues.reference(value);
19
17
  return `${substitute} = ${reference}`;
20
18
  },
21
19
  },
@@ -1 +1 @@
1
- {"version":3,"file":"key-condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/key-condition.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,sBAAsB;IAChB,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AAED,MAAM,UAAU,MAAM,CACpB,IAAmB,EACnB,KAAqB;IAErB,OAAO,IAAI,sBAAsB,CAAC;QAChC,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACzB,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC3B,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACtD,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;gBACtD,OAAO,GAAG,UAAU,MAAM,SAAS,EAAE,CAAC;YACxC,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"key-condition.js","sourceRoot":"","sources":["../../../../src/commands/expressions/key-condition.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,sBAAsB;IAChB,KAAK,CAAa;IAEnC,YAAY,MAA6B;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,MAGT;QACC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AAED,MAAM,UAAU,MAAM,CACpB,IAAmB,EACnB,KAAqB;IAErB,OAAO,IAAI,sBAAsB,CAAC;QAChC,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE;gBACjD,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACnD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACnD,OAAO,GAAG,UAAU,MAAM,SAAS,EAAE,CAAC;YACxC,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/aws-dynamodb",
3
- "version": "0.9.0",
3
+ "version": "0.10.0-alpha.0",
4
4
  "description": "A convenience wrapper over @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb.",
5
5
  "keywords": [
6
6
  "aws",