@infra-blocks/aws-dynamodb 0.69.0 → 0.70.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.
Files changed (55) hide show
  1. package/lib/cjs/commands/index.d.ts +2 -2
  2. package/lib/cjs/commands/index.js.map +1 -1
  3. package/lib/cjs/commands/inputs/get-item.d.ts +6 -0
  4. package/lib/cjs/commands/inputs/get-item.js +3 -0
  5. package/lib/cjs/commands/inputs/get-item.js.map +1 -1
  6. package/lib/cjs/commands/inputs/lib.d.ts +5 -0
  7. package/lib/cjs/commands/inputs/lib.js +2 -1
  8. package/lib/cjs/commands/inputs/lib.js.map +1 -1
  9. package/lib/cjs/commands/outputs/consumed-capacity.d.ts +26 -0
  10. package/lib/cjs/commands/outputs/consumed-capacity.js +27 -0
  11. package/lib/cjs/commands/outputs/consumed-capacity.js.map +1 -0
  12. package/lib/cjs/commands/outputs/delete-item.js +3 -1
  13. package/lib/cjs/commands/outputs/delete-item.js.map +1 -1
  14. package/lib/cjs/commands/outputs/get-item.d.ts +2 -0
  15. package/lib/cjs/commands/outputs/get-item.js +5 -1
  16. package/lib/cjs/commands/outputs/get-item.js.map +1 -1
  17. package/lib/cjs/commands/outputs/index.d.ts +1 -0
  18. package/lib/cjs/commands/outputs/index.js.map +1 -1
  19. package/lib/cjs/commands/outputs/lib.d.ts +23 -2
  20. package/lib/cjs/commands/outputs/lib.js +56 -5
  21. package/lib/cjs/commands/outputs/lib.js.map +1 -1
  22. package/lib/cjs/commands/outputs/put-item.js +3 -1
  23. package/lib/cjs/commands/outputs/put-item.js.map +1 -1
  24. package/lib/cjs/commands/outputs/query.js +7 -7
  25. package/lib/cjs/commands/outputs/query.js.map +1 -1
  26. package/lib/cjs/commands/outputs/update-item.js +3 -1
  27. package/lib/cjs/commands/outputs/update-item.js.map +1 -1
  28. package/lib/esm/commands/index.d.ts +2 -2
  29. package/lib/esm/commands/index.js.map +1 -1
  30. package/lib/esm/commands/inputs/get-item.d.ts +6 -0
  31. package/lib/esm/commands/inputs/get-item.js +4 -1
  32. package/lib/esm/commands/inputs/get-item.js.map +1 -1
  33. package/lib/esm/commands/inputs/lib.d.ts +5 -0
  34. package/lib/esm/commands/inputs/lib.js +1 -0
  35. package/lib/esm/commands/inputs/lib.js.map +1 -1
  36. package/lib/esm/commands/outputs/consumed-capacity.d.ts +26 -0
  37. package/lib/esm/commands/outputs/consumed-capacity.js +24 -0
  38. package/lib/esm/commands/outputs/consumed-capacity.js.map +1 -0
  39. package/lib/esm/commands/outputs/delete-item.js +4 -2
  40. package/lib/esm/commands/outputs/delete-item.js.map +1 -1
  41. package/lib/esm/commands/outputs/get-item.d.ts +2 -0
  42. package/lib/esm/commands/outputs/get-item.js +6 -2
  43. package/lib/esm/commands/outputs/get-item.js.map +1 -1
  44. package/lib/esm/commands/outputs/index.d.ts +1 -0
  45. package/lib/esm/commands/outputs/index.js.map +1 -1
  46. package/lib/esm/commands/outputs/lib.d.ts +23 -2
  47. package/lib/esm/commands/outputs/lib.js +52 -4
  48. package/lib/esm/commands/outputs/lib.js.map +1 -1
  49. package/lib/esm/commands/outputs/put-item.js +4 -2
  50. package/lib/esm/commands/outputs/put-item.js.map +1 -1
  51. package/lib/esm/commands/outputs/query.js +7 -7
  52. package/lib/esm/commands/outputs/query.js.map +1 -1
  53. package/lib/esm/commands/outputs/update-item.js +4 -2
  54. package/lib/esm/commands/outputs/update-item.js.map +1 -1
  55. package/package.json +4 -6
@@ -5,8 +5,8 @@ export { DeleteItem } from "./delete-item.js";
5
5
  export { DeleteTable } from "./delete-table.js";
6
6
  export { type And, type AttributeExists, type AttributeNotExists, add, and, attributeExists, attributeNotExists, attributeType, type BeginsWith, type BeginsWithOperand, type BetweenInput, beginsWith, type ComparableValue, type ConditionComparisonInput, type ConditionFunction, type ConditionInput, type ConditionLogic, type Contains, contains, deleteFrom, type EqualsInput, type GreaterThanInput, type GreaterThanOrEqualsInput, type InInput, type IsAttributeOfType, ifNotExists, type KeyConditionComparisonInput, type KeyConditionFunction, type KeyConditionInput, type KeyConditionLogic, type LowerThanInput, type LowerThanOrEqualsInput, literal, type Not, type NotEqualsInput, not, type Or, or, type PathInput, type PathOrValueInput, type ProjectionInput, path, remove, set, size, type UpdateAction, type UpdateInput, type ValueInput, value, } from "./expressions/index.js";
7
7
  export { GetItem } from "./get-item.js";
8
- export type { ConditionCheckInput, CreateTableInput, DeleteItemInput, DeleteItemReturnValue, DeleteTableInput, GetItemInput, PutItemInput, QueryInput, UpdateItemInput, UpdateTimeToLiveInput, WriteTransactionInput, WriteTransactionWrite, } from "./inputs/index.js";
9
- export type { CreateTableOutput, DeleteItemOutput, DeleteTableOutput, GetItemOutput, PutItemOutput, QueryOutput, UpdateItemOutput, UpdateTimeToLiveOutput, WriteTransactionOutput, } from "./outputs/index.js";
8
+ export type { ConditionCheckInput, CreateTableInput, DeleteItemInput, DeleteItemReturnValue, DeleteTableInput, GetItemConsumedCapacityReturnValue, GetItemInput, PutItemInput, QueryInput, UpdateItemInput, UpdateTimeToLiveInput, WriteTransactionInput, WriteTransactionWrite, } from "./inputs/index.js";
9
+ export type { CapacityUnits, ConsumedCapacity, CreateTableOutput, DeleteItemOutput, DeleteTableOutput, GetItemOutput, PutItemOutput, QueryOutput, UpdateItemOutput, UpdateTimeToLiveOutput, WriteTransactionOutput, } from "./outputs/index.js";
10
10
  export { PutItem } from "./put-item.js";
11
11
  export { Query } from "./query.js";
12
12
  export { UpdateItem } from "./update-item.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":";;;AAEA,qDAAgD;AAAvC,8GAAA,WAAW,OAAA;AACpB,mDAA8C;AAArC,4GAAA,UAAU,OAAA;AACnB,qDAAgD;AAAvC,8GAAA,WAAW,OAAA;AACpB,mDAkDgC;AA9C9B,+FAAA,GAAG,OAAA;AACH,+FAAA,GAAG,OAAA;AACH,2GAAA,eAAe,OAAA;AACf,8GAAA,kBAAkB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AAwC;AAA/B,sGAAA,OAAO,OAAA;AA6BhB,6CAAwC;AAA/B,sGAAA,OAAO,OAAA;AAChB,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AACd,mDAA8C;AAArC,4GAAA,UAAU,OAAA;AACnB,mEAA4D;AAAnD,0HAAA,gBAAgB,OAAA;AACzB,+DAA0D;AAAjD,wHAAA,gBAAgB,OAAA"}
@@ -1,6 +1,8 @@
1
1
  import type { GetCommandInput } from "@aws-sdk/lib-dynamodb";
2
2
  import type { KeyAttributes } from "../../types.js";
3
3
  import { type ProjectionInput } from "../expressions/projection.js";
4
+ import { type ConsumedCapacityReturnValue } from "./lib.js";
5
+ export type GetItemConsumedCapacityReturnValue = ConsumedCapacityReturnValue;
4
6
  /**
5
7
  * The input required to call the GetItem API.
6
8
  */
@@ -20,6 +22,10 @@ export interface GetItemInput<K extends KeyAttributes = KeyAttributes> {
20
22
  * The projection applied to the return item, if any.
21
23
  */
22
24
  projection?: ProjectionInput;
25
+ /**
26
+ * The requested consumed capacity metrics on return, if any.
27
+ */
28
+ returnConsumedCapacity?: GetItemConsumedCapacityReturnValue;
23
29
  }
24
30
  export declare const GetItemInput: {
25
31
  encode: typeof encode;
@@ -11,6 +11,9 @@ function encode(input) {
11
11
  TableName: input.table,
12
12
  Key: input.key,
13
13
  };
14
+ if (input.returnConsumedCapacity != null) {
15
+ result.ReturnConsumedCapacity = input.returnConsumedCapacity;
16
+ }
14
17
  if (input.projection == null) {
15
18
  return result;
16
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/inputs/get-item.ts"],"names":[],"mappings":";;;AAEA,gEAAgF;AAChF,qCAAgD;AAuBnC,QAAA,YAAY,GAAG;IAC1B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,KAAsB;IAEtB,MAAM,MAAM,GAAoB;QAC9B,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC;IAEF,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,SAAS,GAAG,6BAAoB,CAAC,MAAM,EAAE,CAAC;IAChD,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB,EAAE,SAAS,CAAC,MAAM,CAAC,0BAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzE,wBAAwB,EAAE,SAAS,CAAC,2BAA2B,EAAE;KAClE,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/inputs/get-item.ts"],"names":[],"mappings":";;;AAEA,gEAAgF;AAChF,qCAGkB;AA6BL,QAAA,YAAY,GAAG;IAC1B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,KAAsB;IAEtB,MAAM,MAAM,GAAoB;QAC9B,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC;IAEF,IAAI,KAAK,CAAC,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACzC,MAAM,CAAC,sBAAsB,GAAG,KAAK,CAAC,sBAAsB,CAAC;IAC/D,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,SAAS,GAAG,6BAAoB,CAAC,MAAM,EAAE,CAAC;IAChD,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB,EAAE,SAAS,CAAC,MAAM,CAAC,0BAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzE,wBAAwB,EAAE,SAAS,CAAC,2BAA2B,EAAE;KAClE,CAAC;AACJ,CAAC"}
@@ -2,6 +2,11 @@ import { AttributeNames } from "../attributes/names.js";
2
2
  import { AttributeValues } from "../attributes/values.js";
3
3
  import type { ExpressionFormatter } from "../expressions/formatter.js";
4
4
  export type ConditionCheckFailureReturnValue = "NONE" | "ALL_OLD";
5
+ /**
6
+ * A type regrouping all possible values for `returnConsumedCapacity` options.
7
+ */
8
+ export type ConsumedCapacityReturnValue = "NONE" | "INDEXES" | "TOTAL";
9
+ export declare const CONSUMED_CAPACITY_RETURN_VALUES: ReadonlyArray<ConsumedCapacityReturnValue>;
5
10
  export type ExpressionsFormatter = {
6
11
  format(formatter: ExpressionFormatter): string;
7
12
  getExpressionAttributeNames(): ReturnType<AttributeNames["getSubstitutions"]>;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExpressionsFormatter = void 0;
3
+ exports.ExpressionsFormatter = exports.CONSUMED_CAPACITY_RETURN_VALUES = void 0;
4
4
  const names_js_1 = require("../attributes/names.js");
5
5
  const values_js_1 = require("../attributes/values.js");
6
+ exports.CONSUMED_CAPACITY_RETURN_VALUES = ["NONE", "INDEXES", "TOTAL"];
6
7
  exports.ExpressionsFormatter = {
7
8
  create(params) {
8
9
  const { names = names_js_1.AttributeNames.create(), values = values_js_1.AttributeValues.create(), } = params ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/inputs/lib.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AACxD,uDAA0D;AAa7C,QAAA,oBAAoB,GAAG;IAClC,MAAM,CAAC,MAGN;QACC,MAAM,EACJ,KAAK,GAAG,yBAAc,CAAC,MAAM,EAAE,EAC/B,MAAM,GAAG,2BAAe,CAAC,MAAM,EAAE,GAClC,GAAG,MAAM,IAAI,EAAE,CAAC;QAEjB,OAAO;YACL,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAC1D,2BAA2B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC3D,4BAA4B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE;SAC9D,CAAC;IACJ,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/inputs/lib.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AACxD,uDAA0D;AAU7C,QAAA,+BAA+B,GAC1C,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAUlB,QAAA,oBAAoB,GAAG;IAClC,MAAM,CAAC,MAGN;QACC,MAAM,EACJ,KAAK,GAAG,yBAAc,CAAC,MAAM,EAAE,EAC/B,MAAM,GAAG,2BAAe,CAAC,MAAM,EAAE,GAClC,GAAG,MAAM,IAAI,EAAE,CAAC;QAEjB,OAAO;YACL,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAC1D,2BAA2B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC3D,4BAA4B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE;SAC9D,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type * as sdk from "@aws-sdk/client-dynamodb";
2
+ export type ConsumedCapacity = CapacityUnits & {
3
+ tableName: string;
4
+ table?: CapacityUnits;
5
+ globalSecondaryIndexes?: {
6
+ [key: string]: CapacityUnits;
7
+ };
8
+ localSecondaryIndexes?: {
9
+ [key: string]: CapacityUnits;
10
+ };
11
+ };
12
+ export declare const ConsumedCapacity: {
13
+ decode(output: sdk.ConsumedCapacity): ConsumedCapacity;
14
+ };
15
+ export type CapacityUnits = {
16
+ capacityUnits: number;
17
+ readCapacityUnits?: number;
18
+ writeCapacityUnits?: number;
19
+ };
20
+ export declare const CapacityUnits: {
21
+ decode(output: {
22
+ CapacityUnits?: number;
23
+ ReadCapacityUnits?: number;
24
+ WriteCapacityUnits?: number;
25
+ }): CapacityUnits;
26
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CapacityUnits = exports.ConsumedCapacity = void 0;
4
+ const lib_js_1 = require("./lib.js");
5
+ exports.ConsumedCapacity = {
6
+ decode(output) {
7
+ return {
8
+ ...exports.CapacityUnits.decode(output),
9
+ ...lib_js_1.ObjectBuilder.of()
10
+ .enforceNotNull("tableName", output.TableName)
11
+ .mapIfNotNull("table", output.Table, exports.CapacityUnits.decode)
12
+ .mapValuesIfNotNull("globalSecondaryIndexes", output.GlobalSecondaryIndexes, exports.CapacityUnits.decode)
13
+ .mapValuesIfNotNull("localSecondaryIndexes", output.LocalSecondaryIndexes, exports.CapacityUnits.decode)
14
+ .unwrap(),
15
+ };
16
+ },
17
+ };
18
+ exports.CapacityUnits = {
19
+ decode(output) {
20
+ return lib_js_1.ObjectBuilder.of()
21
+ .enforceNotNull("capacityUnits", output.CapacityUnits)
22
+ .setIfNotNull("readCapacityUnits", output.ReadCapacityUnits)
23
+ .setIfNotNull("writeCapacityUnits", output.WriteCapacityUnits)
24
+ .unwrap();
25
+ },
26
+ };
27
+ //# sourceMappingURL=consumed-capacity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumed-capacity.js","sourceRoot":"","sources":["../../../../src/commands/outputs/consumed-capacity.ts"],"names":[],"mappings":";;;AACA,qCAAyC;AAe5B,QAAA,gBAAgB,GAAG;IAC9B,MAAM,CAAC,MAA4B;QACjC,OAAO;YACL,GAAG,qBAAa,CAAC,MAAM,CAAC,MAAM,CAAC;YAC/B,GAAG,sBAAa,CAAC,EAAE,EAAoB;iBACpC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC;iBAC7C,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,qBAAa,CAAC,MAAM,CAAC;iBACzD,kBAAkB,CACjB,wBAAwB,EACxB,MAAM,CAAC,sBAAsB,EAC7B,qBAAa,CAAC,MAAM,CACrB;iBACA,kBAAkB,CACjB,uBAAuB,EACvB,MAAM,CAAC,qBAAqB,EAC5B,qBAAa,CAAC,MAAM,CACrB;iBACA,MAAM,EAAE;SACZ,CAAC;IACJ,CAAC;CACF,CAAC;AASW,QAAA,aAAa,GAAG;IAC3B,MAAM,CAAC,MAIN;QACC,OAAO,sBAAa,CAAC,EAAE,EAAiB;aACrC,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC;aACrD,YAAY,CAAC,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC;aAC3D,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,kBAAkB,CAAC;aAC7D,MAAM,EAAE,CAAC;IACd,CAAC;CACF,CAAC"}
@@ -6,6 +6,8 @@ exports.DeleteItemOutput = {
6
6
  decode,
7
7
  };
8
8
  function decode(output) {
9
- return (0, lib_js_1.maybeSet)({}, "item", output, "Attributes");
9
+ return lib_js_1.ObjectBuilder.of()
10
+ .setIfNotNull("item", output.Attributes)
11
+ .unwrap();
10
12
  }
11
13
  //# sourceMappingURL=delete-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/delete-item.ts"],"names":[],"mappings":";;;AAEA,qCAAoC;AAIvB,QAAA,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,IAAA,iBAAQ,EAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"delete-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/delete-item.ts"],"names":[],"mappings":";;;AAEA,qCAAyC;AAI5B,QAAA,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,sBAAa,CAAC,EAAE,EAAuB;SAC3C,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC;SACvC,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import type { GetCommandOutput } from "@aws-sdk/lib-dynamodb";
2
2
  import type { Attributes } from "../../types.js";
3
+ import { ConsumedCapacity } from "./consumed-capacity.js";
3
4
  export type GetItemOutput<T extends Attributes = Attributes> = {
4
5
  item?: T;
6
+ consumedCapacity?: ConsumedCapacity;
5
7
  };
6
8
  export declare const GetItemOutput: {
7
9
  decode: typeof decode;
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetItemOutput = void 0;
4
+ const consumed_capacity_js_1 = require("./consumed-capacity.js");
4
5
  const lib_js_1 = require("./lib.js");
5
6
  exports.GetItemOutput = {
6
7
  decode,
7
8
  };
8
9
  function decode(output) {
9
- return (0, lib_js_1.maybeSet)({}, "item", output, "Item");
10
+ return lib_js_1.ObjectBuilder.of()
11
+ .setIfNotNull("item", output.Item)
12
+ .mapIfNotNull("consumedCapacity", output.ConsumedCapacity, consumed_capacity_js_1.ConsumedCapacity.decode)
13
+ .unwrap();
10
14
  }
11
15
  //# sourceMappingURL=get-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/get-item.ts"],"names":[],"mappings":";;;AAEA,qCAAoC;AAIvB,QAAA,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,IAAA,iBAAQ,EAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/get-item.ts"],"names":[],"mappings":";;;AAEA,iEAA0D;AAC1D,qCAAyC;AAO5B,QAAA,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,sBAAa,CAAC,EAAE,EAAoB;SACxC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;SACjC,YAAY,CACX,kBAAkB,EAClB,MAAM,CAAC,gBAAgB,EACvB,uCAAgB,CAAC,MAAM,CACxB;SACA,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -1,3 +1,4 @@
1
+ export type { CapacityUnits, ConsumedCapacity } from "./consumed-capacity.js";
1
2
  export * from "./create-table.js";
2
3
  export * from "./delete-item.js";
3
4
  export * from "./delete-table.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/outputs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,oDAAkC;AAClC,gDAA8B;AAC9B,gDAA8B;AAC9B,6CAA2B;AAC3B,mDAAiC;AACjC,2DAAyC;AACzC,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/outputs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,oDAAkC;AAClC,mDAAiC;AACjC,oDAAkC;AAClC,gDAA8B;AAC9B,gDAA8B;AAC9B,6CAA2B;AAC3B,mDAAiC;AACjC,2DAAyC;AACzC,yDAAuC"}
@@ -1,3 +1,24 @@
1
- export declare function maybeSet<T, A extends Record<string, unknown>, AK extends string, S extends Record<string, unknown>, SK extends keyof S>(acc: A, accKey: AK, source: S, sourceKey: SK, transform?: (value: S[SK]) => T): A & {
2
- [k in AK]?: T;
1
+ import { type Nullable, type Transform } from "@infra-blocks/types";
2
+ export type ObjectBuilder<A extends Record<string, unknown>> = {
3
+ enforceNotNull<K extends keyof A, T>(key: K, value: T): ObjectBuilder<A & {
4
+ [key in K]: NonNullable<T>;
5
+ }>;
6
+ map<K extends keyof A, T, R>(key: K, value: T, transform: Transform<T, R>): ObjectBuilder<A & {
7
+ [key in K]: R;
8
+ }>;
9
+ mapValuesIfNotNull<K extends keyof A, T extends Record<string, unknown>, R>(key: K, value: Nullable<T>, transform: Transform<T[keyof T], R>): ObjectBuilder<A & {
10
+ [key in K]?: {
11
+ [subKey in keyof T]: R;
12
+ };
13
+ }>;
14
+ mapIfNotNull<K extends keyof A, T, R>(key: K, value: Nullable<T>, transform: Transform<T, R>): ObjectBuilder<A & {
15
+ [key in K]?: R;
16
+ }>;
17
+ setIfNotNull<K extends keyof A, T>(key: K, value: T): ObjectBuilder<A & {
18
+ [key in K]?: T;
19
+ }>;
20
+ unwrap(): A;
21
+ };
22
+ export declare const ObjectBuilder: {
23
+ of<A extends Record<string, unknown>>(): ObjectBuilder<Partial<A>>;
3
24
  };
@@ -1,12 +1,63 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.maybeSet = maybeSet;
6
+ exports.ObjectBuilder = void 0;
7
+ const node_assert_1 = __importDefault(require("node:assert"));
4
8
  const types_1 = require("@infra-blocks/types");
5
- function maybeSet(acc, accKey, source, sourceKey, transform) {
6
- if (source[sourceKey] != null) {
7
- const newValue = transform != null ? transform(source[sourceKey]) : source[sourceKey];
8
- acc[accKey] = (0, types_1.trusted)(newValue);
9
+ exports.ObjectBuilder = {
10
+ of() {
11
+ return wrap({});
12
+ },
13
+ };
14
+ function wrap(payload) {
15
+ return {
16
+ enforceNotNull(key, value) {
17
+ enforceNotNull(payload, key, value);
18
+ return (0, types_1.trusted)(this);
19
+ },
20
+ map(key, value, transform) {
21
+ map(payload, key, value, transform);
22
+ return (0, types_1.trusted)(this);
23
+ },
24
+ mapValuesIfNotNull(key, value, transform) {
25
+ mapValuesIfNotNull(payload, key, value, transform);
26
+ return (0, types_1.trusted)(this);
27
+ },
28
+ mapIfNotNull(key, value, transform) {
29
+ mapIfNotNull(payload, key, value, transform);
30
+ return (0, types_1.trusted)(this);
31
+ },
32
+ setIfNotNull(key, value) {
33
+ mapIfNotNull(payload, key, value, (v) => v);
34
+ return (0, types_1.trusted)(this);
35
+ },
36
+ unwrap: () => payload,
37
+ };
38
+ }
39
+ function mapValuesIfNotNull(acc, accKey, record, transform) {
40
+ if (record != null) {
41
+ acc[accKey] = {};
42
+ for (const [key, value] of Object.entries(record)) {
43
+ acc[accKey][key] = (0, types_1.trusted)(transform((0, types_1.trusted)(value)));
44
+ }
45
+ }
46
+ return (0, types_1.trusted)(acc);
47
+ }
48
+ function mapIfNotNull(acc, accKey, value, transform) {
49
+ if (value != null) {
50
+ acc[accKey] = (0, types_1.trusted)(transform(value));
9
51
  }
10
52
  return (0, types_1.trusted)(acc);
11
53
  }
54
+ function map(acc, accKey, value, transform) {
55
+ acc[accKey] = (0, types_1.trusted)(transform(value));
56
+ return (0, types_1.trusted)(acc);
57
+ }
58
+ function enforceNotNull(acc, accKey, value) {
59
+ (0, node_assert_1.default)(value != null, "unexpected null value");
60
+ acc[accKey] = (0, types_1.trusted)(value);
61
+ return (0, types_1.trusted)(acc);
62
+ }
12
63
  //# sourceMappingURL=lib.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/outputs/lib.ts"],"names":[],"mappings":";;AAEA,4BAmBC;AArBD,+CAA8C;AAE9C,SAAgB,QAAQ,CAOtB,GAAM,EACN,MAAU,EACV,MAAS,EACT,SAAa,EACb,SAA+B;IAE/B,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,QAAQ,GACZ,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAA,eAAO,EAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,IAAA,eAAO,EAAC,GAAG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tB,CAAC"}
@@ -6,6 +6,8 @@ exports.PutItemOutput = {
6
6
  decode,
7
7
  };
8
8
  function decode(output) {
9
- return (0, lib_js_1.maybeSet)({}, "item", output, "Attributes");
9
+ return lib_js_1.ObjectBuilder.of()
10
+ .setIfNotNull("item", output.Attributes)
11
+ .unwrap();
10
12
  }
11
13
  //# sourceMappingURL=put-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"put-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/put-item.ts"],"names":[],"mappings":";;;AAEA,qCAAoC;AAKvB,QAAA,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,IAAA,iBAAQ,EAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"put-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/put-item.ts"],"names":[],"mappings":";;;AAEA,qCAAyC;AAK5B,QAAA,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,sBAAa,CAAC,EAAE,EAAoB;SACxC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC;SACvC,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QueryOutput = void 0;
4
4
  const types_1 = require("@infra-blocks/types");
5
+ const lib_js_1 = require("./lib.js");
5
6
  exports.QueryOutput = {
6
7
  decode,
7
8
  };
8
9
  function decode(output) {
9
- const items = (output.Items ?? []);
10
- return (0, types_1.trusted)({
11
- items,
12
- lastEvaluatedKey: output.LastEvaluatedKey,
13
- count: output.Count,
14
- scannedCount: output.ScannedCount,
15
- });
10
+ return lib_js_1.ObjectBuilder.of()
11
+ .enforceNotNull("count", output.Count)
12
+ .enforceNotNull("scannedCount", output.ScannedCount)
13
+ .map("items", output.Items, (items) => (items ?? []))
14
+ .mapIfNotNull("lastEvaluatedKey", output.LastEvaluatedKey, (types_1.trusted))
15
+ .unwrap();
16
16
  }
17
17
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/outputs/query.ts"],"names":[],"mappings":";;;AACA,+CAA8C;AAajC,QAAA,WAAW,GAAG;IACzB,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CAGb,MAA0B;IAC1B,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAa,CAAC;IAC/C,OAAO,IAAA,eAAO,EAAC;QACb,KAAK;QACL,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/outputs/query.ts"],"names":[],"mappings":";;;AACA,+CAA8C;AAE9C,qCAAyC;AAY5B,QAAA,WAAW,GAAG;IACzB,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CAGb,MAA0B;IAC1B,OAAO,sBAAa,CAAC,EAAE,EAAe;SACnC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;SACrC,cAAc,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;SACnD,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAa,CAAC;SAChE,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAA,eAAU,CAAA,CAAC;SACrE,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -6,6 +6,8 @@ exports.UpdateItemOutput = {
6
6
  decode,
7
7
  };
8
8
  function decode(output) {
9
- return (0, lib_js_1.maybeSet)({}, "attributes", output, "Attributes");
9
+ return lib_js_1.ObjectBuilder.of()
10
+ .setIfNotNull("attributes", output.Attributes)
11
+ .unwrap();
10
12
  }
11
13
  //# sourceMappingURL=update-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/update-item.ts"],"names":[],"mappings":";;;AAEA,qCAAoC;AAMvB,QAAA,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,IAAA,iBAAQ,EAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"file":"update-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/update-item.ts"],"names":[],"mappings":";;;AAEA,qCAAyC;AAM5B,QAAA,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,sBAAa,CAAC,EAAE,EAAuB;SAC3C,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC;SAC7C,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -5,8 +5,8 @@ export { DeleteItem } from "./delete-item.js";
5
5
  export { DeleteTable } from "./delete-table.js";
6
6
  export { type And, type AttributeExists, type AttributeNotExists, add, and, attributeExists, attributeNotExists, attributeType, type BeginsWith, type BeginsWithOperand, type BetweenInput, beginsWith, type ComparableValue, type ConditionComparisonInput, type ConditionFunction, type ConditionInput, type ConditionLogic, type Contains, contains, deleteFrom, type EqualsInput, type GreaterThanInput, type GreaterThanOrEqualsInput, type InInput, type IsAttributeOfType, ifNotExists, type KeyConditionComparisonInput, type KeyConditionFunction, type KeyConditionInput, type KeyConditionLogic, type LowerThanInput, type LowerThanOrEqualsInput, literal, type Not, type NotEqualsInput, not, type Or, or, type PathInput, type PathOrValueInput, type ProjectionInput, path, remove, set, size, type UpdateAction, type UpdateInput, type ValueInput, value, } from "./expressions/index.js";
7
7
  export { GetItem } from "./get-item.js";
8
- export type { ConditionCheckInput, CreateTableInput, DeleteItemInput, DeleteItemReturnValue, DeleteTableInput, GetItemInput, PutItemInput, QueryInput, UpdateItemInput, UpdateTimeToLiveInput, WriteTransactionInput, WriteTransactionWrite, } from "./inputs/index.js";
9
- export type { CreateTableOutput, DeleteItemOutput, DeleteTableOutput, GetItemOutput, PutItemOutput, QueryOutput, UpdateItemOutput, UpdateTimeToLiveOutput, WriteTransactionOutput, } from "./outputs/index.js";
8
+ export type { ConditionCheckInput, CreateTableInput, DeleteItemInput, DeleteItemReturnValue, DeleteTableInput, GetItemConsumedCapacityReturnValue, GetItemInput, PutItemInput, QueryInput, UpdateItemInput, UpdateTimeToLiveInput, WriteTransactionInput, WriteTransactionWrite, } from "./inputs/index.js";
9
+ export type { CapacityUnits, ConsumedCapacity, CreateTableOutput, DeleteItemOutput, DeleteTableOutput, GetItemOutput, PutItemOutput, QueryOutput, UpdateItemOutput, UpdateTimeToLiveOutput, WriteTransactionOutput, } from "./outputs/index.js";
10
10
  export { PutItem } from "./put-item.js";
11
11
  export { Query } from "./query.js";
12
12
  export { UpdateItem } from "./update-item.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAIL,GAAG,EACH,GAAG,EACH,eAAe,EACf,kBAAkB,EAClB,aAAa,EAIb,UAAU,EAOV,QAAQ,EACR,UAAU,EAMV,WAAW,EAOX,OAAO,EAGP,GAAG,EAEH,EAAE,EAIF,IAAI,EACJ,MAAM,EACN,GAAG,EACH,IAAI,EAIJ,KAAK,GACN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA0BxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAIL,GAAG,EACH,GAAG,EACH,eAAe,EACf,kBAAkB,EAClB,aAAa,EAIb,UAAU,EAOV,QAAQ,EACR,UAAU,EAMV,WAAW,EAOX,OAAO,EAGP,GAAG,EAEH,EAAE,EAIF,IAAI,EACJ,MAAM,EACN,GAAG,EACH,IAAI,EAIJ,KAAK,GACN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA6BxC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import type { GetCommandInput } from "@aws-sdk/lib-dynamodb";
2
2
  import type { KeyAttributes } from "../../types.js";
3
3
  import { type ProjectionInput } from "../expressions/projection.js";
4
+ import { type ConsumedCapacityReturnValue } from "./lib.js";
5
+ export type GetItemConsumedCapacityReturnValue = ConsumedCapacityReturnValue;
4
6
  /**
5
7
  * The input required to call the GetItem API.
6
8
  */
@@ -20,6 +22,10 @@ export interface GetItemInput<K extends KeyAttributes = KeyAttributes> {
20
22
  * The projection applied to the return item, if any.
21
23
  */
22
24
  projection?: ProjectionInput;
25
+ /**
26
+ * The requested consumed capacity metrics on return, if any.
27
+ */
28
+ returnConsumedCapacity?: GetItemConsumedCapacityReturnValue;
23
29
  }
24
30
  export declare const GetItemInput: {
25
31
  encode: typeof encode;
@@ -1,5 +1,5 @@
1
1
  import { Projection } from "../expressions/projection.js";
2
- import { ExpressionsFormatter } from "./lib.js";
2
+ import { ExpressionsFormatter, } from "./lib.js";
3
3
  export const GetItemInput = {
4
4
  encode,
5
5
  };
@@ -8,6 +8,9 @@ function encode(input) {
8
8
  TableName: input.table,
9
9
  Key: input.key,
10
10
  };
11
+ if (input.returnConsumedCapacity != null) {
12
+ result.ReturnConsumedCapacity = input.returnConsumedCapacity;
13
+ }
11
14
  if (input.projection == null) {
12
15
  return result;
13
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/inputs/get-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAwB,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAuBhD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,KAAsB;IAEtB,MAAM,MAAM,GAAoB;QAC9B,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC;IAEF,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,SAAS,GAAG,oBAAoB,CAAC,MAAM,EAAE,CAAC;IAChD,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzE,wBAAwB,EAAE,SAAS,CAAC,2BAA2B,EAAE;KAClE,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/inputs/get-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAwB,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAEL,oBAAoB,GACrB,MAAM,UAAU,CAAC;AA6BlB,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,KAAsB;IAEtB,MAAM,MAAM,GAAoB;QAC9B,SAAS,EAAE,KAAK,CAAC,KAAK;QACtB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC;IAEF,IAAI,KAAK,CAAC,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACzC,MAAM,CAAC,sBAAsB,GAAG,KAAK,CAAC,sBAAsB,CAAC;IAC/D,CAAC;IAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,SAAS,GAAG,oBAAoB,CAAC,MAAM,EAAE,CAAC;IAChD,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzE,wBAAwB,EAAE,SAAS,CAAC,2BAA2B,EAAE;KAClE,CAAC;AACJ,CAAC"}
@@ -2,6 +2,11 @@ import { AttributeNames } from "../attributes/names.js";
2
2
  import { AttributeValues } from "../attributes/values.js";
3
3
  import type { ExpressionFormatter } from "../expressions/formatter.js";
4
4
  export type ConditionCheckFailureReturnValue = "NONE" | "ALL_OLD";
5
+ /**
6
+ * A type regrouping all possible values for `returnConsumedCapacity` options.
7
+ */
8
+ export type ConsumedCapacityReturnValue = "NONE" | "INDEXES" | "TOTAL";
9
+ export declare const CONSUMED_CAPACITY_RETURN_VALUES: ReadonlyArray<ConsumedCapacityReturnValue>;
5
10
  export type ExpressionsFormatter = {
6
11
  format(formatter: ExpressionFormatter): string;
7
12
  getExpressionAttributeNames(): ReturnType<AttributeNames["getSubstitutions"]>;
@@ -1,5 +1,6 @@
1
1
  import { AttributeNames } from "../attributes/names.js";
2
2
  import { AttributeValues } from "../attributes/values.js";
3
+ export const CONSUMED_CAPACITY_RETURN_VALUES = ["NONE", "INDEXES", "TOTAL"];
3
4
  export const ExpressionsFormatter = {
4
5
  create(params) {
5
6
  const { names = AttributeNames.create(), values = AttributeValues.create(), } = params ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/inputs/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAa1D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,CAAC,MAGN;QACC,MAAM,EACJ,KAAK,GAAG,cAAc,CAAC,MAAM,EAAE,EAC/B,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,GAClC,GAAG,MAAM,IAAI,EAAE,CAAC;QAEjB,OAAO;YACL,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAC1D,2BAA2B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC3D,4BAA4B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE;SAC9D,CAAC;IACJ,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/inputs/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAU1D,MAAM,CAAC,MAAM,+BAA+B,GAC1C,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAU/B,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM,CAAC,MAGN;QACC,MAAM,EACJ,KAAK,GAAG,cAAc,CAAC,MAAM,EAAE,EAC/B,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,GAClC,GAAG,MAAM,IAAI,EAAE,CAAC;QAEjB,OAAO;YACL,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAC1D,2BAA2B,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC3D,4BAA4B,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE;SAC9D,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type * as sdk from "@aws-sdk/client-dynamodb";
2
+ export type ConsumedCapacity = CapacityUnits & {
3
+ tableName: string;
4
+ table?: CapacityUnits;
5
+ globalSecondaryIndexes?: {
6
+ [key: string]: CapacityUnits;
7
+ };
8
+ localSecondaryIndexes?: {
9
+ [key: string]: CapacityUnits;
10
+ };
11
+ };
12
+ export declare const ConsumedCapacity: {
13
+ decode(output: sdk.ConsumedCapacity): ConsumedCapacity;
14
+ };
15
+ export type CapacityUnits = {
16
+ capacityUnits: number;
17
+ readCapacityUnits?: number;
18
+ writeCapacityUnits?: number;
19
+ };
20
+ export declare const CapacityUnits: {
21
+ decode(output: {
22
+ CapacityUnits?: number;
23
+ ReadCapacityUnits?: number;
24
+ WriteCapacityUnits?: number;
25
+ }): CapacityUnits;
26
+ };
@@ -0,0 +1,24 @@
1
+ import { ObjectBuilder } from "./lib.js";
2
+ export const ConsumedCapacity = {
3
+ decode(output) {
4
+ return {
5
+ ...CapacityUnits.decode(output),
6
+ ...ObjectBuilder.of()
7
+ .enforceNotNull("tableName", output.TableName)
8
+ .mapIfNotNull("table", output.Table, CapacityUnits.decode)
9
+ .mapValuesIfNotNull("globalSecondaryIndexes", output.GlobalSecondaryIndexes, CapacityUnits.decode)
10
+ .mapValuesIfNotNull("localSecondaryIndexes", output.LocalSecondaryIndexes, CapacityUnits.decode)
11
+ .unwrap(),
12
+ };
13
+ },
14
+ };
15
+ export const CapacityUnits = {
16
+ decode(output) {
17
+ return ObjectBuilder.of()
18
+ .enforceNotNull("capacityUnits", output.CapacityUnits)
19
+ .setIfNotNull("readCapacityUnits", output.ReadCapacityUnits)
20
+ .setIfNotNull("writeCapacityUnits", output.WriteCapacityUnits)
21
+ .unwrap();
22
+ },
23
+ };
24
+ //# sourceMappingURL=consumed-capacity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumed-capacity.js","sourceRoot":"","sources":["../../../../src/commands/outputs/consumed-capacity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAezC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,CAAC,MAA4B;QACjC,OAAO;YACL,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;YAC/B,GAAG,aAAa,CAAC,EAAE,EAAoB;iBACpC,cAAc,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC;iBAC7C,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC;iBACzD,kBAAkB,CACjB,wBAAwB,EACxB,MAAM,CAAC,sBAAsB,EAC7B,aAAa,CAAC,MAAM,CACrB;iBACA,kBAAkB,CACjB,uBAAuB,EACvB,MAAM,CAAC,qBAAqB,EAC5B,aAAa,CAAC,MAAM,CACrB;iBACA,MAAM,EAAE;SACZ,CAAC;IACJ,CAAC;CACF,CAAC;AASF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM,CAAC,MAIN;QACC,OAAO,aAAa,CAAC,EAAE,EAAiB;aACrC,cAAc,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,CAAC;aACrD,YAAY,CAAC,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,CAAC;aAC3D,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,kBAAkB,CAAC;aAC7D,MAAM,EAAE,CAAC;IACd,CAAC;CACF,CAAC"}
@@ -1,8 +1,10 @@
1
- import { maybeSet } from "./lib.js";
1
+ import { ObjectBuilder } from "./lib.js";
2
2
  export const DeleteItemOutput = {
3
3
  decode,
4
4
  };
5
5
  function decode(output) {
6
- return maybeSet({}, "item", output, "Attributes");
6
+ return ObjectBuilder.of()
7
+ .setIfNotNull("item", output.Attributes)
8
+ .unwrap();
7
9
  }
8
10
  //# sourceMappingURL=delete-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/delete-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIpC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"delete-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/delete-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,aAAa,CAAC,EAAE,EAAuB;SAC3C,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC;SACvC,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -1,7 +1,9 @@
1
1
  import type { GetCommandOutput } from "@aws-sdk/lib-dynamodb";
2
2
  import type { Attributes } from "../../types.js";
3
+ import { ConsumedCapacity } from "./consumed-capacity.js";
3
4
  export type GetItemOutput<T extends Attributes = Attributes> = {
4
5
  item?: T;
6
+ consumedCapacity?: ConsumedCapacity;
5
7
  };
6
8
  export declare const GetItemOutput: {
7
9
  decode: typeof decode;
@@ -1,8 +1,12 @@
1
- import { maybeSet } from "./lib.js";
1
+ import { ConsumedCapacity } from "./consumed-capacity.js";
2
+ import { ObjectBuilder } from "./lib.js";
2
3
  export const GetItemOutput = {
3
4
  decode,
4
5
  };
5
6
  function decode(output) {
6
- return maybeSet({}, "item", output, "Item");
7
+ return ObjectBuilder.of()
8
+ .setIfNotNull("item", output.Item)
9
+ .mapIfNotNull("consumedCapacity", output.ConsumedCapacity, ConsumedCapacity.decode)
10
+ .unwrap();
7
11
  }
8
12
  //# sourceMappingURL=get-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/get-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIpC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"get-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/get-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOzC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,aAAa,CAAC,EAAE,EAAoB;SACxC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;SACjC,YAAY,CACX,kBAAkB,EAClB,MAAM,CAAC,gBAAgB,EACvB,gBAAgB,CAAC,MAAM,CACxB;SACA,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -1,3 +1,4 @@
1
+ export type { CapacityUnits, ConsumedCapacity } from "./consumed-capacity.js";
1
2
  export * from "./create-table.js";
2
3
  export * from "./delete-item.js";
3
4
  export * from "./delete-table.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/outputs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/outputs/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
@@ -1,3 +1,24 @@
1
- export declare function maybeSet<T, A extends Record<string, unknown>, AK extends string, S extends Record<string, unknown>, SK extends keyof S>(acc: A, accKey: AK, source: S, sourceKey: SK, transform?: (value: S[SK]) => T): A & {
2
- [k in AK]?: T;
1
+ import { type Nullable, type Transform } from "@infra-blocks/types";
2
+ export type ObjectBuilder<A extends Record<string, unknown>> = {
3
+ enforceNotNull<K extends keyof A, T>(key: K, value: T): ObjectBuilder<A & {
4
+ [key in K]: NonNullable<T>;
5
+ }>;
6
+ map<K extends keyof A, T, R>(key: K, value: T, transform: Transform<T, R>): ObjectBuilder<A & {
7
+ [key in K]: R;
8
+ }>;
9
+ mapValuesIfNotNull<K extends keyof A, T extends Record<string, unknown>, R>(key: K, value: Nullable<T>, transform: Transform<T[keyof T], R>): ObjectBuilder<A & {
10
+ [key in K]?: {
11
+ [subKey in keyof T]: R;
12
+ };
13
+ }>;
14
+ mapIfNotNull<K extends keyof A, T, R>(key: K, value: Nullable<T>, transform: Transform<T, R>): ObjectBuilder<A & {
15
+ [key in K]?: R;
16
+ }>;
17
+ setIfNotNull<K extends keyof A, T>(key: K, value: T): ObjectBuilder<A & {
18
+ [key in K]?: T;
19
+ }>;
20
+ unwrap(): A;
21
+ };
22
+ export declare const ObjectBuilder: {
23
+ of<A extends Record<string, unknown>>(): ObjectBuilder<Partial<A>>;
3
24
  };
@@ -1,9 +1,57 @@
1
+ import assert from "node:assert";
1
2
  import { trusted } from "@infra-blocks/types";
2
- export function maybeSet(acc, accKey, source, sourceKey, transform) {
3
- if (source[sourceKey] != null) {
4
- const newValue = transform != null ? transform(source[sourceKey]) : source[sourceKey];
5
- acc[accKey] = trusted(newValue);
3
+ export const ObjectBuilder = {
4
+ of() {
5
+ return wrap({});
6
+ },
7
+ };
8
+ function wrap(payload) {
9
+ return {
10
+ enforceNotNull(key, value) {
11
+ enforceNotNull(payload, key, value);
12
+ return trusted(this);
13
+ },
14
+ map(key, value, transform) {
15
+ map(payload, key, value, transform);
16
+ return trusted(this);
17
+ },
18
+ mapValuesIfNotNull(key, value, transform) {
19
+ mapValuesIfNotNull(payload, key, value, transform);
20
+ return trusted(this);
21
+ },
22
+ mapIfNotNull(key, value, transform) {
23
+ mapIfNotNull(payload, key, value, transform);
24
+ return trusted(this);
25
+ },
26
+ setIfNotNull(key, value) {
27
+ mapIfNotNull(payload, key, value, (v) => v);
28
+ return trusted(this);
29
+ },
30
+ unwrap: () => payload,
31
+ };
32
+ }
33
+ function mapValuesIfNotNull(acc, accKey, record, transform) {
34
+ if (record != null) {
35
+ acc[accKey] = {};
36
+ for (const [key, value] of Object.entries(record)) {
37
+ acc[accKey][key] = trusted(transform(trusted(value)));
38
+ }
39
+ }
40
+ return trusted(acc);
41
+ }
42
+ function mapIfNotNull(acc, accKey, value, transform) {
43
+ if (value != null) {
44
+ acc[accKey] = trusted(transform(value));
6
45
  }
7
46
  return trusted(acc);
8
47
  }
48
+ function map(acc, accKey, value, transform) {
49
+ acc[accKey] = trusted(transform(value));
50
+ return trusted(acc);
51
+ }
52
+ function enforceNotNull(acc, accKey, value) {
53
+ assert(value != null, "unexpected null value");
54
+ acc[accKey] = trusted(value);
55
+ return trusted(acc);
56
+ }
9
57
  //# sourceMappingURL=lib.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/outputs/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,UAAU,QAAQ,CAOtB,GAAM,EACN,MAAU,EACV,MAAS,EACT,SAAa,EACb,SAA+B;IAE/B,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,QAAQ,GACZ,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC"}
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../../src/commands/outputs/lib.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAiC,OAAO,EAA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GAAG,CAAC,MAAM,CAAC,GAAG,EAAW,CAAC;QAC1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,GAAG,CAAC,MAAM,CAAC,CAAC,GAAkB,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,YAAY,CAMnB,GAAM,EACN,MAAU,EACV,KAAkB,EAClB,SAA0B;IAE1B,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,GAAG,CACV,GAAM,EACN,MAAU,EACV,KAAQ,EACR,SAA0B;IAE1B,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,cAAc,CAIrB,GAAM,EAAE,MAAU,EAAE,KAAQ;IAC5B,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE,uBAAuB,CAAC,CAAC;IAC/C,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC"}
@@ -1,8 +1,10 @@
1
- import { maybeSet } from "./lib.js";
1
+ import { ObjectBuilder } from "./lib.js";
2
2
  export const PutItemOutput = {
3
3
  decode,
4
4
  };
5
5
  function decode(output) {
6
- return maybeSet({}, "item", output, "Attributes");
6
+ return ObjectBuilder.of()
7
+ .setIfNotNull("item", output.Attributes)
8
+ .unwrap();
7
9
  }
8
10
  //# sourceMappingURL=put-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"put-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/put-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKpC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"put-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/put-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAAwB;IAExB,OAAO,aAAa,CAAC,EAAE,EAAoB;SACxC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC;SACvC,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { trusted } from "@infra-blocks/types";
2
+ import { ObjectBuilder } from "./lib.js";
2
3
  export const QueryOutput = {
3
4
  decode,
4
5
  };
5
6
  function decode(output) {
6
- const items = (output.Items ?? []);
7
- return trusted({
8
- items,
9
- lastEvaluatedKey: output.LastEvaluatedKey,
10
- count: output.Count,
11
- scannedCount: output.ScannedCount,
12
- });
7
+ return ObjectBuilder.of()
8
+ .enforceNotNull("count", output.Count)
9
+ .enforceNotNull("scannedCount", output.ScannedCount)
10
+ .map("items", output.Items, (items) => (items ?? []))
11
+ .mapIfNotNull("lastEvaluatedKey", output.LastEvaluatedKey, (trusted))
12
+ .unwrap();
13
13
  }
14
14
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/outputs/query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAa9C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CAGb,MAA0B;IAC1B,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAa,CAAC;IAC/C,OAAO,OAAO,CAAC;QACb,KAAK;QACL,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../src/commands/outputs/query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAYzC,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CAGb,MAA0B;IAC1B,OAAO,aAAa,CAAC,EAAE,EAAe;SACnC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;SACrC,cAAc,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC;SACnD,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,CAAa,CAAC;SAChE,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAA,OAAU,CAAA,CAAC;SACrE,MAAM,EAAE,CAAC;AACd,CAAC"}
@@ -1,8 +1,10 @@
1
- import { maybeSet } from "./lib.js";
1
+ import { ObjectBuilder } from "./lib.js";
2
2
  export const UpdateItemOutput = {
3
3
  decode,
4
4
  };
5
5
  function decode(output) {
6
- return maybeSet({}, "attributes", output, "Attributes");
6
+ return ObjectBuilder.of()
7
+ .setIfNotNull("attributes", output.Attributes)
8
+ .unwrap();
7
9
  }
8
10
  //# sourceMappingURL=update-item.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/update-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAMpC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AAC1D,CAAC"}
1
+ {"version":3,"file":"update-item.js","sourceRoot":"","sources":["../../../../src/commands/outputs/update-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMzC,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;CACP,CAAC;AAEF,SAAS,MAAM,CACb,MAA2B;IAE3B,OAAO,aAAa,CAAC,EAAE,EAAuB;SAC3C,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC;SAC7C,MAAM,EAAE,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infra-blocks/aws-dynamodb",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
4
4
  "description": "A convenience wrapper over @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb.",
5
5
  "keywords": [
6
6
  "aws",
@@ -37,8 +37,8 @@
37
37
  "test": "npm run test:unit && npm run test:integration",
38
38
  "test:coverage": "c8 npm run test",
39
39
  "test:coverage:lcov": "c8 --reporter=lcov npm run test",
40
- "test:integration": "mocha --config test/integration/.mocharc.cjs 'test/integration/**/*.spec.ts'",
41
- "test:unit": "mocha --config test/unit/.mocharc.cjs 'test/unit/**/*.spec.ts'"
40
+ "test:integration": "node --import tsx --test 'test/integration/**/*.spec.ts'",
41
+ "test:unit": "node --import tsx --test 'test/unit/**/*.spec.ts'"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@aws-sdk/util-dynamodb": "^3.995.0",
@@ -47,16 +47,14 @@
47
47
  "@infra-blocks/node-console-logger": "^0.3.1",
48
48
  "@infra-blocks/test": "^0.7.0",
49
49
  "@smithy/types": "^4.12.0",
50
- "@types/mocha": "^10.0.10",
51
50
  "@types/node": "^24.0.10",
52
51
  "c8": "^10.1.3",
53
52
  "dotenv": "^17.0.1",
54
53
  "lefthook": "^1.11.16",
55
- "mocha": "^11.6.0",
56
54
  "radash": "^12.1.1",
57
55
  "tsx": "^4.20.3",
58
56
  "typescript": "^5.8.3",
59
- "zod": "^3.25.74"
57
+ "zod": "^4.3.6"
60
58
  },
61
59
  "engines": {
62
60
  "node": ">=22.0.0"