1 | import { DataType } from './data-types';
|
2 | import { Model, ModelCtor, ModelType, WhereOptions, Attributes } from './model';
|
3 | import { Optional } from './index';
|
4 |
|
5 | export type Primitive = 'string' | 'number' | 'boolean';
|
6 |
|
7 | export type DeepWriteable<T> = { -readonly [P in keyof T]: DeepWriteable<T[P]> };
|
8 |
|
9 | export interface Inflector {
|
10 | singularize(str: string): string;
|
11 | pluralize(str: string): string;
|
12 | }
|
13 |
|
14 | export function useInflection(inflection: Inflector): void;
|
15 |
|
16 | export function camelizeIf(string: string, condition?: boolean): string;
|
17 | export function underscoredIf(string: string, condition?: boolean): string;
|
18 | export function isPrimitive(val: unknown): val is Primitive;
|
19 |
|
20 |
|
21 | export function mergeDefaults<T>(a: T, b: Partial<T>): T;
|
22 | export function spliceStr(str: string, index: number, count: number, add: string): string;
|
23 | export function camelize(str: string): string;
|
24 | export function format(arr: string[], dialect: string): string;
|
25 | export function formatNamedParameters(sql: string, parameters: {
|
26 | [key: string]: string | number | boolean;
|
27 | }, dialect: string): string;
|
28 | export function cloneDeep<T>(obj: T, fn?: (el: unknown) => unknown): T;
|
29 |
|
30 | export interface OptionsForMapping<TAttributes> {
|
31 | attributes?: string[];
|
32 | where?: WhereOptions<TAttributes>;
|
33 | }
|
34 |
|
35 |
|
36 | export function mapFinderOptions<M extends Model, T extends OptionsForMapping<Attributes<M>>>(
|
37 | options: T,
|
38 | model: ModelCtor<M>
|
39 | ): T;
|
40 |
|
41 |
|
42 | export function mapOptionFieldNames<M extends Model, T extends OptionsForMapping<Attributes<M>>>(
|
43 | options: T, model: ModelCtor<M>
|
44 | ): T;
|
45 |
|
46 | export function mapWhereFieldNames(attributes: object, model: ModelType): object;
|
47 |
|
48 | export function mapValueFieldNames(dataValues: object, fields: string[], model: ModelType): object;
|
49 |
|
50 | export function isColString(value: string): boolean;
|
51 | export function canTreatArrayAsAnd(arr: unknown[]): boolean;
|
52 | export function combineTableNames(tableName1: string, tableName2: string): string;
|
53 |
|
54 | export function singularize(s: string): string;
|
55 | export function pluralize(s: string): string;
|
56 |
|
57 | export function toDefaultValue<T>(value: unknown): unknown;
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | export function defaultValueSchemable(hash: DataType): boolean;
|
66 | export function stack(): NodeJS.CallSite[];
|
67 | export function now(dialect: string): Date;
|
68 |
|
69 |
|
70 |
|
71 | export const TICK_CHAR: string;
|
72 | export function addTicks(s: string, tickChar?: string): string;
|
73 | export function removeTicks(s: string, tickChar?: string): string;
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | export function classToInvokable<T extends new (...args: any[]) => any>(ctor: T): T & {
|
80 | (...args: ConstructorParameters<T>): T;
|
81 | }
|
82 |
|
83 | export class SequelizeMethod {
|
84 |
|
85 | }
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | export class Fn extends SequelizeMethod {
|
92 | constructor(fn: string, args: unknown[]);
|
93 | public clone(): this;
|
94 | }
|
95 |
|
96 | export class Col extends SequelizeMethod {
|
97 | public col: string;
|
98 | constructor(col: string);
|
99 | }
|
100 |
|
101 | export class Cast extends SequelizeMethod {
|
102 | public val: unknown;
|
103 | public type: string;
|
104 | constructor(val: unknown, type?: string);
|
105 | }
|
106 |
|
107 | export class Literal extends SequelizeMethod {
|
108 | public val: unknown;
|
109 | constructor(val: unknown);
|
110 | }
|
111 |
|
112 | export class Json extends SequelizeMethod {
|
113 | public conditions: object;
|
114 | public path: string;
|
115 | public value: string | number | boolean;
|
116 | constructor(conditionsOrPath: string | object, value?: string | number | boolean);
|
117 | }
|
118 |
|
119 | export class Where extends SequelizeMethod {
|
120 | public attribute: object;
|
121 | public comparator: string;
|
122 | public logic: string | object;
|
123 | constructor(attr: object, comparator: string, logic: string | object);
|
124 | constructor(attr: object, logic: string | object);
|
125 | }
|
126 |
|
127 | export type AnyFunction = (...args: any[]) => any;
|
128 |
|
129 | /**
|
130 | * Returns all shallow properties that accept `undefined` or `null`.
|
131 | * Does not include Optional properties, only `undefined` or `null`.
|
132 | *
|
133 | * @example
|
134 | * type UndefinedProps = NullishPropertiesOf<{
|
135 | * id: number | undefined,
|
136 | * createdAt: string | undefined,
|
137 | * firstName: string | null, // nullable properties are included
|
138 | * lastName?: string, // optional properties are not included.
|
139 | * }>;
|
140 | *
|
141 | * // is equal to
|
142 | *
|
143 | * type UndefinedProps = 'id' | 'createdAt' | 'firstName';
|
144 | */
|
145 | export type NullishPropertiesOf<T> = {
|
146 | [P in keyof T]-?: undefined extends T[P] ? P
|
147 | : null extends T[P] ? P
|
148 | : never
|
149 | }[keyof T];
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | export type MakeNullishOptional<T extends object> = T extends any ? Optional<T, NullishPropertiesOf<T>> : never;
|