electrodb 1.7.1 → 1.7.2

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/CHANGELOG.md CHANGED
@@ -154,4 +154,9 @@ All notable changes to this project will be documented in this file. Breaking ch
154
154
 
155
155
  ## [1.7.1] - 2022-03-19
156
156
  ### Added
157
- - Adding support for the v3 DyanmoDBClient. This change also brings in a new ElectroDB dependency [@aws-sdk/lib-dynamodb](https://www.npmjs.com/package/@aws-sdk/client-dynamodb). [[read more](./README.md#aws-dynamodb-client)]
157
+ - Adding support for the v3 DyanmoDBClient. This change also brings in a new ElectroDB dependency [@aws-sdk/lib-dynamodb](https://www.npmjs.com/package/@aws-sdk/client-dynamodb). [[read more](./README.md#aws-dynamodb-client)]
158
+
159
+ ## [1.7.2] - 2022-03-27
160
+ ### Fixed
161
+ - Fixed issue#111, `update` method specific query option typing no longer lost when using a `where` method in a query chain
162
+ - Fixing incorrect typing for exposed `UpdateEntityItem` type. Exported type was missing composite key attributes
package/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ type Flatten<T> = T extends any[]
2
+ ? T
3
+ : T extends object
4
+ ? {[Key in keyof T]: Flatten<T[Key]>}
5
+ : T;
6
+
1
7
  declare const WhereSymbol: unique symbol;
2
8
  declare const UpdateDataSymbol: unique symbol;
3
9
 
@@ -987,6 +993,13 @@ interface UpdateQueryOptions extends QueryOptions {
987
993
  response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
988
994
  }
989
995
 
996
+ interface UpdateQueryParams {
997
+ response?: "default" | "none" | 'all_old' | 'updated_old' | 'all_new' | 'updated_new';
998
+ table?: string;
999
+ params?: object;
1000
+ originalErr?: boolean;
1001
+ }
1002
+
990
1003
  interface DeleteQueryOptions extends QueryOptions {
991
1004
  response?: "default" | "none" | 'all_old';
992
1005
  }
@@ -1042,7 +1055,13 @@ type SingleRecordOperationOptions<A extends string, F extends A, C extends strin
1042
1055
  type PutRecordOperationOptions<A extends string, F extends A, C extends string, S extends Schema<A,F,C>, ResponseType> = {
1043
1056
  go: GoRecord<ResponseType, PutQueryOptions>;
1044
1057
  params: ParamRecord<PutQueryOptions>;
1045
- where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,SingleRecordOperationOptions<A,F,C,S,ResponseType>>;
1058
+ where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
1059
+ };
1060
+
1061
+ type UpdateRecordOperationOptions<A extends string, F extends A, C extends string, S extends Schema<A,F,C>, ResponseType> = {
1062
+ go: GoRecord<ResponseType, UpdateQueryOptions>;
1063
+ params: ParamRecord<UpdateQueryParams>;
1064
+ where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
1046
1065
  };
1047
1066
 
1048
1067
  type DeleteRecordOperationOptions<A extends string, F extends A, C extends string, S extends Schema<A,F,C>, ResponseType> = {
@@ -1058,7 +1077,7 @@ type BulkRecordOperationOptions<A extends string, F extends A, C extends string,
1058
1077
 
1059
1078
  type SetRecordActionOptions<A extends string, F extends A, C extends string, S extends Schema<A,F,C>, SetAttr,IndexCompositeAttributes,TableItem> = {
1060
1079
  go: GoRecord<Partial<TableItem>, UpdateQueryOptions>;
1061
- params: ParamRecord<UpdateQueryOptions>;
1080
+ params: ParamRecord<UpdateQueryParams>;
1062
1081
  set: SetRecord<A,F,C,S, SetItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
1063
1082
  remove: SetRecord<A,F,C,S, Array<keyof SetItem<A,F,C,S>>,IndexCompositeAttributes,TableItem>;
1064
1083
  add: SetRecord<A,F,C,S, AddItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
@@ -1066,7 +1085,7 @@ type SetRecordActionOptions<A extends string, F extends A, C extends string, S e
1066
1085
  append: SetRecord<A,F,C,S, AppendItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
1067
1086
  delete: SetRecord<A,F,C,S, DeleteItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
1068
1087
  data: DataUpdateMethodRecord<A,F,C,S, Item<A,F,C,S,S["attributes"]>,IndexCompositeAttributes,TableItem>;
1069
- where: WhereClause<A,F,C,S, Item<A,F,C,S,S["attributes"]>,RecordsActionOptions<A,F,C,S,TableItem,IndexCompositeAttributes>>;
1088
+ where: WhereClause<A,F,C,S, Item<A,F,C,S,S["attributes"]>,SetRecordActionOptions<A,F,C,S,SetAttr,IndexCompositeAttributes,TableItem>>;
1070
1089
  }
1071
1090
 
1072
1091
  type SetRecord<A extends string, F extends A, C extends string, S extends Schema<A,F,C>, SetAttr, IndexCompositeAttributes, TableItem> = (properties: SetAttr) => SetRecordActionOptions<A,F,C,S, SetAttr, IndexCompositeAttributes, TableItem>;
@@ -1482,7 +1501,7 @@ export type CreateEntityItem<E extends Entity<any, any, any, any>> =
1482
1501
 
1483
1502
  export type UpdateEntityItem<E extends Entity<any, any, any, any>> =
1484
1503
  E extends Entity<infer A, infer F, infer C, infer S>
1485
- ? SetItem<A, F, C, S>
1504
+ ? Partial<ResponseItem<A,F,C,S>>
1486
1505
  : never;
1487
1506
 
1488
1507
  export type UpdateAddEntityItem<E extends Entity<any, any, any, any>> =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrodb",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
5
5
  "main": "index.js",
6
6
  "scripts": {