1 | declare const OR: unique symbol;
|
2 | import { DynamoDB } from "aws-sdk";
|
3 | import { ObjectType } from "./General";
|
4 | export declare type ConditionFunction = (condition: Condition) => Condition;
|
5 | declare type ConditionStorageType = {
|
6 | [key: string]: ConditionsConditionStorageObject;
|
7 | } | typeof OR;
|
8 | export declare type ConditionStorageTypeNested = ConditionStorageType | Array<ConditionStorageTypeNested>;
|
9 | declare type ConditionStorageSettingsConditions = ConditionStorageTypeNested[];
|
10 | declare type ConditionRequestObjectResult = {
|
11 | ExpressionAttributeNames?: DynamoDB.Types.ExpressionAttributeNameMap;
|
12 | ExpressionAttributeValues?: DynamoDB.Types.ExpressionAttributeValueMap;
|
13 | };
|
14 | interface ConditionComparisonType {
|
15 | name: ConditionComparisonComparatorName;
|
16 | typeName: ConditionComparisonComparatorDynamoName;
|
17 | not?: ConditionComparisonComparatorDynamoName;
|
18 | multipleArguments?: boolean;
|
19 | }
|
20 | declare enum ConditionComparisonComparatorName {
|
21 | equals = "eq",
|
22 | lessThan = "lt",
|
23 | lessThanEquals = "le",
|
24 | greaterThan = "gt",
|
25 | greaterThanEquals = "ge",
|
26 | beginsWith = "beginsWith",
|
27 | contains = "contains",
|
28 | exists = "exists",
|
29 | in = "in",
|
30 | between = "between"
|
31 | }
|
32 | declare enum ConditionComparisonComparatorDynamoName {
|
33 | equals = "EQ",
|
34 | notEquals = "NE",
|
35 | lessThan = "LT",
|
36 | lessThanEquals = "LE",
|
37 | greaterThan = "GT",
|
38 | greaterThanEquals = "GE",
|
39 | beginsWith = "BEGINS_WITH",
|
40 | contains = "CONTAINS",
|
41 | notContains = "NOT_CONTAINS",
|
42 | exists = "EXISTS",
|
43 | notExists = "NOT_EXISTS",
|
44 | in = "IN",
|
45 | between = "BETWEEN"
|
46 | }
|
47 | export declare type ConditionInitalizer = Condition | ObjectType | string;
|
48 | export interface BasicOperators<T = Condition> {
|
49 | and: () => T;
|
50 | or: () => T;
|
51 | not: () => T;
|
52 | parenthesis: (value: Condition | ConditionFunction) => T;
|
53 | group: (value: Condition | ConditionFunction) => T;
|
54 | where: (key: string) => T;
|
55 | filter: (key: string) => T;
|
56 | attribute: (key: string) => T;
|
57 | eq: (value: any) => T;
|
58 | lt: (value: any) => T;
|
59 | le: (value: any) => T;
|
60 | gt: (value: any) => T;
|
61 | ge: (value: any) => T;
|
62 | beginsWith: (value: any) => T;
|
63 | contains: (value: any) => T;
|
64 | exists: () => T;
|
65 | in: (value: any) => T;
|
66 | between: (...values: any[]) => T;
|
67 | }
|
68 | export interface Condition extends BasicOperators {
|
69 | settings: {
|
70 | conditions: ConditionStorageSettingsConditions;
|
71 | pending: {
|
72 | key?: string;
|
73 | type?: ConditionComparisonType;
|
74 | value?: any;
|
75 | not?: boolean;
|
76 | };
|
77 | raw?: ConditionInitalizer;
|
78 | };
|
79 | and: () => Condition;
|
80 | or: () => Condition;
|
81 | not: () => Condition;
|
82 | parenthesis: (value: Condition | ConditionFunction) => Condition;
|
83 | group: (value: Condition | ConditionFunction) => Condition;
|
84 | where: (key: string) => Condition;
|
85 | filter: (key: string) => Condition;
|
86 | attribute: (key: string) => Condition;
|
87 | eq: (value: any) => Condition;
|
88 | lt: (value: any) => Condition;
|
89 | le: (value: any) => Condition;
|
90 | gt: (value: any) => Condition;
|
91 | ge: (value: any) => Condition;
|
92 | beginsWith: (value: any) => Condition;
|
93 | contains: (value: any) => Condition;
|
94 | exists: () => Condition;
|
95 | in: (value: any) => Condition;
|
96 | between: (...values: any[]) => Condition;
|
97 | requestObject: (settings?: ConditionRequestObjectSettings) => ConditionRequestObjectResult;
|
98 | }
|
99 | export declare class Condition {
|
100 | constructor(object?: ConditionInitalizer);
|
101 | }
|
102 | interface ConditionsConditionStorageObject {
|
103 | type: ConditionComparisonComparatorDynamoName;
|
104 | value: any;
|
105 | }
|
106 | interface ConditionRequestObjectSettings {
|
107 | conditionString: string;
|
108 | index?: {
|
109 | start: number;
|
110 | set: (newIndex: number) => void;
|
111 | };
|
112 | conditionStringType: "array" | "string";
|
113 | }
|
114 | export {};
|