All files / types/backend dynamo.ts

0% Statements 0/0
0% Branches 1/1
0% Functions 1/1
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106                                                                                                                                                                                                                   
import {
  DeleteCommandInput,
  DeleteCommandOutput,
  GetCommandInput,
  GetCommandOutput,
  PutCommandInput,
  PutCommandOutput,
  QueryCommandInput,
  QueryCommandOutput,
  ScanCommandInput,
  ScanCommandOutput,
  UpdateCommandInput, UpdateCommandOutput
} from '@aws-sdk/lib-dynamodb';
 
type RequiredKeys<T extends object> = {
  [key in keyof T]: undefined extends T[key] ? never : key;
}[keyof T];
 
type StringExcept<K extends string> = string extends K ? never : string;
 
type ExpressionAttributeValues<T extends object> = {
  [key in StringExcept<Extract<keyof T, string>> as `:${key}`]: any; // eslint-disable-line
} & {
  [key in Extract<keyof T, string> as `:${key}`]?: T[key];
};
 
type ExpressionAttributeNames<T extends object> = {
  [key in StringExcept<Extract<keyof T, string>> as `#${key}`]: string;
} & {
  [key in Extract<keyof T, string> as `#${key}`]?: key;
};
 
export interface TypedUpdateInput<
  T extends object
> extends UpdateCommandInput {
  ExpressionAttributeNames: ExpressionAttributeNames<T>;
  ExpressionAttributeValues?: ExpressionAttributeValues<T>;
  Key: {
    [key in RequiredKeys<T>]: T[key];
  };
}
export interface TypedUpdateOutput<
  T extends object
> extends UpdateCommandOutput {
  Attributes?: Partial<T>;
}
 
export interface TypedGetInput<T extends object> extends GetCommandInput {
  Key: {
    [key in RequiredKeys<T>]: T[key];
  };
}
export interface TypedGetOutput<
  T extends object
> extends GetCommandOutput {
  Item?: T;
}
 
export interface TypedQueryInput<T extends object> extends QueryCommandInput {
  ExpressionAttributeNames?: ExpressionAttributeNames<T>;
  ExpressionAttributeValues?: ExpressionAttributeValues<T>;
}
export interface TypedQueryOutput<
  T extends object
> extends QueryCommandOutput {
  Items?: T[];
}
 
export interface TypedScanInput<T extends object> extends ScanCommandInput {
  ExpressionAttributeNames?: ExpressionAttributeNames<T>;
  ExpressionAttributeValues?: ExpressionAttributeValues<T>;
}
export interface TypedScanOutput<T extends object> extends ScanCommandOutput {
  Items?: T[];
}
 
export interface TypedFullQueryScanOutput<T extends object> {
  Runs: number;
  LastEvaluatedKey: Record<string, any> | null, // eslint-disable-line @typescript-eslint/no-explicit-any,@stylistic/max-len
  Items: T[];
}
 
export interface TypedDeleteItemInput<
  T extends object
> extends DeleteCommandInput {
  Key: {
    [key in RequiredKeys<T>]: T[key];
  };
}
export interface TypedDeleteItemOutput<
  T extends object
> extends DeleteCommandOutput {
  Attributes?: Partial<T>;
}
 
export interface TypedPutItemInput<
  T extends object
> extends PutCommandInput {
  Item: T;
}
export interface TypedPutItemOutput<
  T extends object
> extends PutCommandOutput {
  Attributes?: Partial<T>;
}