electrodb 1.10.0 → 1.10.1

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/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Entity } from './src/entity';
2
- export { Service } from './src/service';
1
+ export * from './src/entity';
2
+ export * from './src/service';
3
3
  export * from './src/types';
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "electrodb",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
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": {
7
7
  "test": "mocha ./test/offline**.spec.js",
8
8
  "test-ts": "mocha -r ts-node/register ./test/**.spec.ts",
9
9
  "test-all": "mocha ./test/**.spec.js",
10
- "test-all-local": "LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 node ./test/init.js && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 mocha ./test/**.spec.js && npm run test-types && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 npm run test-ts",
10
+ "test-all-local": "LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 node ./test/init.js && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 mocha ./test/**.spec.js && LOCAL_DYNAMO_ENDPOINT=http://localhost:8000 npm run test-ts && npm run test-types",
11
11
  "test-types": "tsd",
12
12
  "coverage": "nyc npm run test-all && nyc report --reporter=text-lcov | coveralls",
13
13
  "coverage-coveralls-local": "nyc npm run test-all-local && nyc report --reporter=text-lcov | coveralls",
package/src/entity.d.ts CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  import { ElectroEventListener } from './types/events';
34
34
  import { DocumentClient } from './types/client';
35
35
 
36
- export type Resolve<T> = T extends Function | string | number | boolean
36
+ type Resolve<T> = T extends Function | string | number | boolean
37
37
  ? T : {[Key in keyof T]: Resolve<T[Key]>}
38
38
 
39
39
  export type EntityConfiguration = {
package/src/entity.js CHANGED
@@ -702,14 +702,16 @@ class Entity {
702
702
  let pattern = `^${this._regexpEscape(prefix)}`;
703
703
  let labels = this.model.facets.labels[index][keyType] || [];
704
704
  for (let {name, label} of labels) {
705
- let { type } = this.model.schema.attributes[name];
706
- if (isCustom) {
707
- pattern += `${this._regexpEscape(label === undefined ? "" : label)}(.+)`;
708
- } else {
709
- pattern += `#${this._regexpEscape(label === undefined ? name : label)}_(.+)`;
705
+ let attr = this.model.schema.attributes[name];
706
+ if (attr) {
707
+ if (isCustom) {
708
+ pattern += `${this._regexpEscape(label === undefined ? "" : label)}(.+)`;
709
+ } else {
710
+ pattern += `#${this._regexpEscape(label === undefined ? name : label)}_(.+)`;
711
+ }
712
+ names.push(name);
713
+ types.push(attr.type);
710
714
  }
711
- names.push(name);
712
- types.push(type);
713
715
  }
714
716
  pattern += "$";
715
717
  let regex = RegExp(pattern);
@@ -1,4 +1,4 @@
1
- type DocumentClientMethod = (parameters: any) => {promise: () => Promise<any>};
1
+ export type DocumentClientMethod = (parameters: any) => {promise: () => Promise<any>};
2
2
 
3
3
  export type DocumentClient = {
4
4
  get: DocumentClientMethod;
@@ -15,7 +15,7 @@ import {
15
15
  WhereAttributeSymbol
16
16
  } from './where';
17
17
 
18
- type AllCollectionNames<E extends {[name: string]: Entity<any, any, any, any>}> = {
18
+ export type AllCollectionNames<E extends {[name: string]: Entity<any, any, any, any>}> = {
19
19
  [Name in keyof E]:
20
20
  E[Name] extends Entity<infer A, infer F, infer C, infer S>
21
21
  ? {
@@ -24,13 +24,13 @@ type AllCollectionNames<E extends {[name: string]: Entity<any, any, any, any>}>
24
24
  : never
25
25
  }[keyof E];
26
26
 
27
- type AllEntityAttributeNames<E extends {[name: string]: Entity<any, any, any, any>}> = {
27
+ export type AllEntityAttributeNames<E extends {[name: string]: Entity<any, any, any, any>}> = {
28
28
  [Name in keyof E]: {
29
29
  [A in keyof E[Name]["schema"]["attributes"]]: A
30
30
  }[keyof E[Name]["schema"]["attributes"]]
31
31
  }[keyof E];
32
32
 
33
- type AllEntityAttributes<E extends {[name: string]: Entity<any, any, any, any>}> = {
33
+ export type AllEntityAttributes<E extends {[name: string]: Entity<any, any, any, any>}> = {
34
34
  [Attr in AllEntityAttributeNames<E>]: {
35
35
  [Name in keyof E]: Attr extends keyof E[Name]["schema"]["attributes"]
36
36
  ? ItemAttribute<E[Name]["schema"]["attributes"][Attr]>
@@ -48,7 +48,7 @@ export type CollectionAssociations<E extends {[name: string]: Entity<any, any, a
48
48
  }[keyof E];
49
49
  }
50
50
 
51
- type CollectionAttributes<E extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<E>> = {
51
+ export type CollectionAttributes<E extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<E>> = {
52
52
  [Collection in keyof Collections]: {
53
53
  [EntityName in keyof E]: E[EntityName] extends Entity<infer A, infer F, infer C, infer S>
54
54
  ? EntityName extends Collections[Collection]
@@ -58,7 +58,7 @@ type CollectionAttributes<E extends {[name: string]: Entity<any, any, any, any>}
58
58
  }[keyof E]
59
59
  }
60
60
 
61
- interface CollectionWhereOperations {
61
+ export interface CollectionWhereOperations {
62
62
  eq: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
63
63
  ne: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
64
64
  gt: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
@@ -75,19 +75,19 @@ interface CollectionWhereOperations {
75
75
  name: <T, A extends WhereAttributeSymbol<T>>(attr: A) => string;
76
76
  }
77
77
 
78
- type CollectionWhereCallback<E extends {[name: string]: Entity<any, any, any, any>}, I extends Partial<AllEntityAttributes<E>>> =
78
+ export type CollectionWhereCallback<E extends {[name: string]: Entity<any, any, any, any>}, I extends Partial<AllEntityAttributes<E>>> =
79
79
  <W extends {[A in keyof I]: WhereAttributeSymbol<I[A]>}>(attributes: W, operations: CollectionWhereOperations) => string;
80
80
 
81
- type CollectionWhereClause<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, T> = (where: CollectionWhereCallback<E, I>) => T;
81
+ export type CollectionWhereClause<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, T> = (where: CollectionWhereCallback<E, I>) => T;
82
82
 
83
- interface WhereRecordsActionOptions<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, Items, IndexCompositeAttributes> {
83
+ export interface WhereRecordsActionOptions<E extends {[name: string]: Entity<any, any, any, any>}, A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Partial<AllEntityAttributes<E>>, Items, IndexCompositeAttributes> {
84
84
  go: GoRecord<Items>;
85
85
  params: ParamRecord;
86
86
  page: PageRecord<Items,IndexCompositeAttributes>;
87
87
  where: CollectionWhereClause<E,A,F,C,S,I, WhereRecordsActionOptions<E,A,F,C,S,I,Items,IndexCompositeAttributes>>;
88
88
  }
89
89
 
90
- type CollectionIndexKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
90
+ export type CollectionIndexKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
91
91
  [Collection in keyof Collections]: {
92
92
  [EntityResultName in Collections[Collection]]:
93
93
  EntityResultName extends keyof Entities
@@ -98,7 +98,7 @@ type CollectionIndexKeys<Entities extends {[name: string]: Entity<any, any, any,
98
98
  }[Collections[Collection]]
99
99
  }
100
100
 
101
- type CollectionPageKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
101
+ export type CollectionPageKeys<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
102
102
  [Collection in keyof Collections]: {
103
103
  [EntityResultName in Collections[Collection]]:
104
104
  EntityResultName extends keyof Entities
@@ -113,7 +113,7 @@ type CollectionPageKeys<Entities extends {[name: string]: Entity<any, any, any,
113
113
  }[Collections[Collection]]
114
114
  }
115
115
 
116
- type CollectionIndexAttributes<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
116
+ export type CollectionIndexAttributes<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
117
117
  [Collection in keyof CollectionIndexKeys<Entities, Collections>]: {
118
118
  [key in CollectionIndexKeys<Entities, Collections>[Collection]]:
119
119
  key extends keyof AllEntityAttributes<Entities>
@@ -122,7 +122,7 @@ type CollectionIndexAttributes<Entities extends {[name: string]: Entity<any, any
122
122
  }
123
123
  }
124
124
 
125
- type CollectionPageAttributes<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
125
+ export type CollectionPageAttributes<Entities extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<Entities>> = {
126
126
  [Collection in keyof CollectionPageKeys<Entities, Collections>]: {
127
127
  [key in CollectionPageKeys<Entities, Collections>[Collection]]:
128
128
  key extends keyof AllEntityAttributes<Entities>
@@ -131,17 +131,17 @@ type CollectionPageAttributes<Entities extends {[name: string]: Entity<any, any,
131
131
  }
132
132
  }
133
133
 
134
- type OptionalPropertyNames<T> =
134
+ export type OptionalPropertyNames<T> =
135
135
  { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T];
136
136
 
137
137
  // Common properties from L and R with undefined in R[K] replaced by type in L[K]
138
- type SpreadProperties<L, R, K extends keyof L & keyof R> =
138
+ export type SpreadProperties<L, R, K extends keyof L & keyof R> =
139
139
  { [P in K]: L[P] | Exclude<R[P], undefined> };
140
140
 
141
- type Id<T> = {[K in keyof T]: T[K]} // see note at bottom*
141
+ export type Id<T> = {[K in keyof T]: T[K]} // see note at bottom*
142
142
 
143
143
  // Type of { ...L, ...R }
144
- type Spread<L, R> = Id<
144
+ export type Spread<L, R> = Id<
145
145
  // Properties in L that don't exist in R
146
146
  & Pick<L, Exclude<keyof L, keyof R>>
147
147
  // Properties in R with types that exclude undefined
@@ -152,7 +152,7 @@ type Spread<L, R> = Id<
152
152
  & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>
153
153
  >;
154
154
 
155
- type RequiredProperties<T> = Pick<T, {[K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T]>
155
+ export type RequiredProperties<T> = Pick<T, {[K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T]>
156
156
 
157
157
  export type CollectionQueries<E extends {[name: string]: Entity<any, any, any, any>}, Collections extends CollectionAssociations<E>> = {
158
158
  [Collection in keyof Collections]: {
@@ -1,13 +1,13 @@
1
- type ElectroDBMethodTypes = "put" | "get" | "query" | "scan" | "update" | "delete" | "remove" | "patch" | "create" | "batchGet" | "batchWrite";
1
+ export type ElectroDBMethodTypes = "put" | "get" | "query" | "scan" | "update" | "delete" | "remove" | "patch" | "create" | "batchGet" | "batchWrite";
2
2
 
3
- interface ElectroQueryEvent<P extends any = any> {
3
+ export interface ElectroQueryEvent<P extends any = any> {
4
4
  type: 'query';
5
5
  method: ElectroDBMethodTypes;
6
6
  config: any;
7
7
  params: P;
8
8
  }
9
9
 
10
- interface ElectroResultsEvent<R extends any = any> {
10
+ export interface ElectroResultsEvent<R extends any = any> {
11
11
  type: 'results';
12
12
  method: ElectroDBMethodTypes;
13
13
  config: any;
@@ -15,11 +15,11 @@ interface ElectroResultsEvent<R extends any = any> {
15
15
  success: boolean;
16
16
  }
17
17
 
18
- type ElectroEvent =
18
+ export type ElectroEvent =
19
19
  ElectroQueryEvent
20
20
  | ElectroResultsEvent;
21
21
 
22
- type ElectroEventType = Pick<ElectroEvent, 'type'>;
22
+ export type ElectroEventType = Pick<ElectroEvent, 'type'>;
23
23
 
24
24
  export type ElectroEventListener = (event: ElectroEvent) => void;
25
25
 
@@ -3,8 +3,13 @@ import { ResponseItem, PutItem, AddItem, SubtractItem, AppendItem, RemoveItem, D
3
3
  import { Service } from '../service';
4
4
  import { CollectionAssociations } from './collections';
5
5
 
6
- export { WhereAttributeSymbol } from './where';
7
- export { Schema } from './schema';
6
+ export * from './where';
7
+ export * from './schema';
8
+ export * from './options';
9
+ export * from './client';
10
+ export * from './collections';
11
+ export * from './model';
12
+ export * from './events';
8
13
 
9
14
  export type EntityItem<E extends Entity<any, any, any, any>> =
10
15
  E extends Entity<infer A, infer F, infer C, infer S>
@@ -44,32 +44,32 @@ export interface SingleRecordOperationOptions<A extends string, F extends string
44
44
  go: GoRecord<ResponseType, QueryOptions>;
45
45
  params: ParamRecord<QueryOptions>;
46
46
  where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,SingleRecordOperationOptions<A,F,C,S,ResponseType>>;
47
- };
47
+ }
48
48
 
49
49
  export interface PutRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
50
50
  go: GoRecord<ResponseType, PutQueryOptions>;
51
51
  params: ParamRecord<PutQueryOptions>;
52
52
  where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
53
- };
53
+ }
54
54
 
55
55
  export interface UpdateRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
56
56
  go: GoRecord<ResponseType, UpdateQueryOptions>;
57
57
  params: ParamRecord<UpdateQueryParams>;
58
58
  where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,PutRecordOperationOptions<A,F,C,S,ResponseType>>;
59
- };
59
+ }
60
60
 
61
61
  export interface DeleteRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType> {
62
62
  go: GoRecord<ResponseType, DeleteQueryOptions>;
63
63
  params: ParamRecord<DeleteQueryOptions>;
64
64
  where: WhereClause<A,F,C,S,Item<A,F,C,S,S["attributes"]>,DeleteRecordOperationOptions<A,F,C,S,ResponseType>>;
65
- };
65
+ }
66
66
 
67
67
  export interface BulkRecordOperationOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, ResponseType, AlternateResponseType> {
68
68
  go: BatchGoRecord<ResponseType, AlternateResponseType>;
69
69
  params: ParamRecord<BulkOptions>;
70
- };
70
+ }
71
71
 
72
- interface SetRecordActionOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr,IndexCompositeAttributes,TableItem> {
72
+ export interface SetRecordActionOptions<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, SetAttr,IndexCompositeAttributes,TableItem> {
73
73
  go: GoRecord<Partial<TableItem>, UpdateQueryOptions>;
74
74
  params: ParamRecord<UpdateQueryParams>;
75
75
  set: SetRecord<A,F,C,S, SetItem<A,F,C,S>,IndexCompositeAttributes,TableItem>;
@@ -373,7 +373,7 @@ export interface NumberSetAttribute {
373
373
  readonly watch?: ReadonlyArray<string> | "*";
374
374
  }
375
375
 
376
- type Attribute =
376
+ export type Attribute =
377
377
  BooleanAttribute
378
378
  | NumberAttribute
379
379
  | StringAttribute
@@ -386,7 +386,7 @@ type Attribute =
386
386
  | NumberListAttribute
387
387
  | MapListAttribute;
388
388
 
389
- type NestedAttributes =
389
+ export type NestedAttributes =
390
390
  NestedBooleanAttribute
391
391
  | NestedNumberAttribute
392
392
  | NestedStringAttribute
@@ -407,7 +407,7 @@ export interface IndexWithSortKey {
407
407
  }
408
408
  }
409
409
 
410
- type AccessPatternCollection<C extends string> = C | ReadonlyArray<C>;
410
+ export type AccessPatternCollection<C extends string> = C | ReadonlyArray<C>;
411
411
 
412
412
  export interface Schema<A extends string, F extends string, C extends string> {
413
413
  readonly model: {
@@ -436,9 +436,9 @@ export interface Schema<A extends string, F extends string, C extends string> {
436
436
  }
437
437
  }
438
438
  }
439
- };
439
+ }
440
440
 
441
- type Attributes<A extends string> = Record<A, Attribute>
441
+ export type Attributes<A extends string> = Record<A, Attribute>
442
442
 
443
443
  export type IndexCollections<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = {
444
444
  [i in keyof S["indexes"]]: S["indexes"][i]["collection"] extends
@@ -464,7 +464,7 @@ export type EntityCollections<A extends string, F extends string, C extends stri
464
464
  declare const SkipSymbol: unique symbol;
465
465
  type SkipValue = typeof SkipSymbol;
466
466
 
467
- type DefinedKeys<T> = {
467
+ type DefinedKeys<T> = {
468
468
  [P in keyof T as
469
469
  [undefined] extends [T[P]]
470
470
  ? never
@@ -540,7 +540,7 @@ type FormattedPutMapAttributes<A extends MapAttribute> = {
540
540
  : false
541
541
  }
542
542
 
543
- type ReturnedAttribute<A extends Attribute> =
543
+ export type ReturnedAttribute<A extends Attribute> =
544
544
  A["type"] extends infer R
545
545
  ? R extends "string" ? string
546
546
  : R extends "number" ? number
@@ -612,7 +612,7 @@ type ReturnedAttribute<A extends Attribute> =
612
612
  : never
613
613
  : never
614
614
 
615
- type CreatedAttribute<A extends Attribute> =
615
+ export type CreatedAttribute<A extends Attribute> =
616
616
  A["type"] extends infer R
617
617
  ? R extends "string" ? string
618
618
  : R extends "number" ? number
@@ -692,7 +692,7 @@ export type CreatedItem<A extends string, F extends string, C extends string, S
692
692
  [a in keyof Attr]: CreatedAttribute<Attr[a]>
693
693
  }
694
694
 
695
- type EditableItemAttribute<A extends Attribute> =
695
+ export type EditableItemAttribute<A extends Attribute> =
696
696
  A extends ReadOnlyAttribute
697
697
  ? never
698
698
  : A["type"] extends infer R
@@ -735,7 +735,7 @@ type EditableItemAttribute<A extends Attribute> =
735
735
  : never
736
736
  : never
737
737
 
738
- type UpdatableItemAttribute<A extends Attribute> =
738
+ export type UpdatableItemAttribute<A extends Attribute> =
739
739
  A extends ReadOnlyAttribute
740
740
  ? never
741
741
  : A["type"] extends infer R
@@ -793,7 +793,7 @@ type UpdatableItemAttribute<A extends Attribute> =
793
793
  : never
794
794
  : never
795
795
 
796
- type RemovableItemAttribute<A extends Attribute> =
796
+ export type RemovableItemAttribute<A extends Attribute> =
797
797
  A extends ReadOnlyAttribute | RequiredAttribute
798
798
  ? never
799
799
  : A["type"] extends infer R
@@ -894,9 +894,9 @@ export type TableIndexPKCompositeAttributes<A extends string, F extends string,
894
894
 
895
895
  export type TableIndexSKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> = Pick<SKCompositeAttributes<A,F,C,S>, TableIndexName<A,F,C,S>>;
896
896
 
897
- type IndexPKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = Pick<PKCompositeAttributes<A,F,C,S>,I>;
897
+ export type IndexPKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = Pick<PKCompositeAttributes<A,F,C,S>,I>;
898
898
 
899
- type IndexSKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = Pick<SKCompositeAttributes<A,F,C,S>,I>;
899
+ export type IndexSKCompositeAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends keyof S["indexes"]> = Pick<SKCompositeAttributes<A,F,C,S>,I>;
900
900
 
901
901
  export type TableIndexPKAttributes<A extends string, F extends string, C extends string, S extends Schema<A,F,C>> =
902
902
  TableIndexName<A,F,C,S> extends keyof TableIndexPKCompositeAttributes<A,F,C,S>
@@ -1,7 +1,7 @@
1
1
  import {Schema, Item, UpdateData} from './schema';
2
2
 
3
- declare const WhereSymbol: unique symbol;
4
- declare const UpdateDataSymbol: unique symbol;
3
+ export declare const WhereSymbol: unique symbol;
4
+ export declare const UpdateDataSymbol: unique symbol;
5
5
 
6
6
  export type WhereAttributeSymbol<T extends any> =
7
7
  { [WhereSymbol]: void }
@@ -35,7 +35,7 @@ export type DataUpdateAttributeSymbol<T extends any> =
35
35
  ? never
36
36
  : T
37
37
 
38
- type DataUpdateAttributeValues<A extends DataUpdateAttributeSymbol<any>> =
38
+ export type DataUpdateAttributeValues<A extends DataUpdateAttributeSymbol<any>> =
39
39
  A extends DataUpdateAttributeSymbol<infer T>
40
40
  ? T extends string ? T
41
41
  : T extends number ? T
@@ -68,7 +68,7 @@ export interface WhereOperations<A extends string, F extends string, C extends s
68
68
  notContains: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: T) => string;
69
69
  value: <T, A extends WhereAttributeSymbol<T>>(attr: A, value: A extends WhereAttributeSymbol<infer V> ? V : never) => A extends WhereAttributeSymbol<infer V> ? V : never;
70
70
  name: <A extends WhereAttributeSymbol<any>>(attr: A) => string;
71
- };
71
+ }
72
72
 
73
73
  export interface DataUpdateOperations<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends UpdateData<A,F,C,S>> {
74
74
  set: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A>) => any;
@@ -81,7 +81,7 @@ export interface DataUpdateOperations<A extends string, F extends string, C exte
81
81
  value: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A>) => Required<DataUpdateAttributeValues<A>>;
82
82
  name: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A) => any;
83
83
  ifNotExists: <T, A extends DataUpdateAttributeSymbol<T>>(attr: A, value: DataUpdateAttributeValues<A>) => any;
84
- };
84
+ }
85
85
 
86
86
  export type WhereCallback<A extends string, F extends string, C extends string, S extends Schema<A,F,C>, I extends Item<A,F,C,S,S["attributes"]>> =
87
87
  <W extends WhereAttributes<A,F,C,S,I>>(attributes: W, operations: WhereOperations<A,F,C,S,I>) => string;
package/src/util.js CHANGED
@@ -133,14 +133,18 @@ class BatchGetOrderMaintainer {
133
133
 
134
134
  getOrder(item) {
135
135
  const key = this.keyFormatter(item);
136
- return this.batchIndexMap.get(key) ?? -1;
136
+ const value = this.batchIndexMap.get(key);
137
+ if (value === undefined) {
138
+ return -1;
139
+ }
140
+ return value;
137
141
  }
138
142
 
139
143
  defineOrder(parameters = []) {
140
144
  if (this.enabled) {
141
145
  for (let i = 0; i < parameters.length; i++) {
142
146
  const batchParams = parameters[i];
143
- const recordKeys = batchParams?.RequestItems?.[this.table]?.Keys ?? [];
147
+ const recordKeys = (batchParams && batchParams.RequestItems && batchParams.RequestItems[this.table] && batchParams.RequestItems[this.table].Keys) || [];
144
148
  for (const recordKey of recordKeys) {
145
149
  const indexMapKey = this.keyFormatter(recordKey);
146
150
  this.batchIndexMap.set(indexMapKey, this.currentSlot++);