@h3ravel/arquebus 0.2.3 → 0.2.4

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/types/utils.ts ADDED
@@ -0,0 +1,69 @@
1
+ import type BModel from 'src/browser/model'
2
+ import type { Collection as BaseCollection } from 'collect.js'
3
+ import type Collection from 'src/collection'
4
+ import type { IBuilder } from './builder'
5
+ import type { IModel } from './modeling'
6
+ import type Model from 'src/model'
7
+ import type { TGeneric } from './generics'
8
+
9
+ export interface ICollection<T extends Model | BModel> extends BaseCollection<T> {
10
+ items?: T[];
11
+ load (...relations: T[]): Promise<ICollection<T>>;
12
+ loadAggregate (relations: T | T[], column: string, action?: string | null): Promise<this>;
13
+ loadCount (relation: T, column: string): Promise<this>;
14
+ loadMax (relation: T, column: string): Promise<this>;
15
+ loadMin (relation: T, column: string): Promise<this>;
16
+ loadSum (relation: T, column: string): Promise<this>;
17
+ loadAvg (relation: T, column: string): Promise<this>;
18
+ mapThen (callback: () => void): Promise<any>;
19
+ modelKeys (): string[] | number[];
20
+ contains (key: IModel | any, operator?: any, value?: any): boolean;
21
+ diff (items: ICollection<T> | any[]): ICollection<T>;
22
+ except (keys: any[]): ICollection<T>;
23
+ intersect (items: T[]): ICollection<T>;
24
+ unique (key?: any, strict?: boolean): ICollection<T>;
25
+ find (key: any, defaultValue?: any): any;
26
+ fresh (withs?: any[]): Promise<ICollection<T>>;
27
+ makeVisible (attributes: string | string[]): this;
28
+ makeHidden (attributes: string | string[]): this;
29
+ append (attributes: string[]): this;
30
+ only (keys: null | any[]): this;
31
+ getDictionary (items?: any[]): TGeneric;
32
+ toQuery (): IBuilder<T, any>;
33
+ toData (): any;
34
+ toJSON (): any;
35
+ toJson (): string;
36
+ toString (): string;
37
+ [key: string]: any;
38
+ [Symbol.iterator]: () => Iterator<T>;
39
+ }
40
+
41
+ export interface IPaginatorParams {
42
+ current_page: number,
43
+ data: any[],
44
+ per_page: number,
45
+ total: number,
46
+ last_page: number,
47
+ count: number,
48
+ }
49
+
50
+ export interface IPaginator<T extends Model | BModel, K extends IPaginatorParams = IPaginatorParams> {
51
+ formatter?(paginator: IPaginator<any>): any | null
52
+ setFormatter?(formatter: (paginator: IPaginator<any>) => any | null): void;
53
+ setItems (items: T[] | Collection<T>): void;
54
+ hasMorePages (): boolean;
55
+ get (index: number): T | null;
56
+ count (): number;
57
+ items (): Collection<T>;
58
+ map (callback: (value: T, index: number) => T): Collection<T>;
59
+ currentPage (): number;
60
+ perPage (): number;
61
+ lastPage (): number;
62
+ firstItem (): number | null;
63
+ lastItem (): number | null;
64
+ total (): number;
65
+ toData<U = K> (): U;
66
+ toJSON<U = K> (): U;
67
+ toJson (): string;
68
+ [Symbol.iterator]?(): { next: () => { value: T; done: boolean } };
69
+ }