@luminix/core 0.0.1-beta.3 → 0.0.1-beta.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.
Files changed (70) hide show
  1. package/dist/contracts/Builder.d.ts +49 -0
  2. package/dist/contracts/Collection.d.ts +190 -0
  3. package/dist/contracts/ModelCollection.d.ts +9 -0
  4. package/dist/contracts/Plugin.d.ts +8 -0
  5. package/dist/contracts/PropertyBag.d.ts +21 -0
  6. package/dist/contracts/Relation/BelongsTo.d.ts +20 -0
  7. package/dist/contracts/Relation/BelongsToMany.d.ts +31 -0
  8. package/dist/contracts/Relation/HasMany.d.ts +21 -0
  9. package/dist/contracts/Relation/HasOne.d.ts +15 -0
  10. package/dist/contracts/Relation/HasOneOrMany.d.ts +10 -0
  11. package/dist/contracts/Relation/MorphMany.d.ts +21 -0
  12. package/dist/contracts/Relation/MorphOne.d.ts +15 -0
  13. package/dist/contracts/Relation/MorphOneOrMany.d.ts +10 -0
  14. package/dist/contracts/Relation/MorphTo.d.ts +8 -0
  15. package/dist/contracts/Relation/MorphToMany.d.ts +16 -0
  16. package/dist/contracts/Relation.d.ts +44 -0
  17. package/dist/core.js +678 -653
  18. package/dist/exceptions/AttributeNotFillableException.d.ts +4 -0
  19. package/dist/exceptions/FacadeNotFoundException.d.ts +4 -0
  20. package/dist/exceptions/MethodNotImplementedException.d.ts +4 -0
  21. package/dist/exceptions/ModelInvalidRelatedTypeException.d.ts +4 -0
  22. package/dist/exceptions/ModelNotFoundException.d.ts +4 -0
  23. package/dist/exceptions/ModelNotPersistedException.d.ts +4 -0
  24. package/dist/exceptions/ModelWithoutPrimaryKeyException.d.ts +4 -0
  25. package/dist/exceptions/NoEmbedException.d.ts +4 -0
  26. package/dist/exceptions/NoInverseRelationException.d.ts +4 -0
  27. package/dist/exceptions/NotModelException.d.ts +4 -0
  28. package/dist/exceptions/NotReducibleException.d.ts +4 -0
  29. package/dist/exceptions/ReducerOverrideException.d.ts +4 -0
  30. package/dist/exceptions/RouteNotFoundException.d.ts +4 -0
  31. package/dist/exceptions/UnsupportedRelationException.d.ts +4 -0
  32. package/dist/facades/App.d.ts +30 -0
  33. package/dist/facades/Auth.d.ts +14 -0
  34. package/dist/facades/Error.d.ts +15 -0
  35. package/dist/facades/Log.d.ts +14 -0
  36. package/dist/facades/Model.d.ts +41 -0
  37. package/dist/facades/Route.d.ts +32 -0
  38. package/dist/helpers/app.d.ts +5 -0
  39. package/dist/helpers/auth.d.ts +3 -0
  40. package/dist/helpers/collect.d.ts +1 -0
  41. package/dist/helpers/config.d.ts +5 -0
  42. package/dist/helpers/error.d.ts +4 -0
  43. package/dist/helpers/log.d.ts +5 -0
  44. package/dist/helpers/model.d.ts +6 -0
  45. package/dist/helpers/route.d.ts +5 -0
  46. package/dist/index.d.ts +24 -0
  47. package/dist/mixins/BaseModel.d.ts +5 -0
  48. package/dist/mixins/HasEvents.d.ts +15 -0
  49. package/dist/mixins/Reducible.d.ts +17 -0
  50. package/dist/support/collection.d.ts +4 -0
  51. package/dist/support/model.d.ts +3 -0
  52. package/dist/support/reader.d.ts +2 -0
  53. package/dist/support/searchParams.d.ts +1 -0
  54. package/dist/types/App.d.ts +72 -0
  55. package/dist/types/Auth.d.ts +13 -0
  56. package/dist/types/Builder.d.ts +47 -0
  57. package/dist/types/Collection.d.ts +1804 -0
  58. package/dist/types/Config.d.ts +29 -0
  59. package/dist/types/Error.d.ts +31 -0
  60. package/dist/types/Event.d.ts +14 -0
  61. package/dist/types/Log.d.ts +37 -0
  62. package/dist/types/Model.d.ts +165 -0
  63. package/dist/types/Plugin.d.ts +4 -0
  64. package/dist/types/PropertyBag.d.ts +25 -0
  65. package/dist/types/Reducer.d.ts +17 -0
  66. package/dist/types/Relation.d.ts +30 -0
  67. package/dist/types/Route.d.ts +22 -0
  68. package/dist/types/Support.d.ts +7 -0
  69. package/package.json +1 -1
  70. package/vite.config.js +2 -2
@@ -0,0 +1,49 @@
1
+ import { Unsubscribe } from 'nanoevents';
2
+ import { AppFacades } from '../types/App';
3
+ import { BuilderEventMap as BuilderEvents, BuilderInterface as BuilderBase, ExtendedOperator } from '../types/Builder';
4
+ import { EventData } from '../types/Event';
5
+ import { Model, ModelPaginatedResponse, ModelQuery } from '../types/Model';
6
+ import { JsonValue } from '../types/Support';
7
+ import { Collection as CollectionInterface } from '../types/Collection';
8
+
9
+ type BuilderInterface = BuilderBase<Model, ModelPaginatedResponse>;
10
+ type BuilderEventMap = BuilderEvents<Model, ModelPaginatedResponse>;
11
+ declare class Builder implements BuilderInterface {
12
+ protected facades: AppFacades;
13
+ protected abstract: string;
14
+ protected query: ModelQuery;
15
+ private bag;
16
+ constructor(facades: AppFacades, abstract: string, query?: ModelQuery);
17
+ on<T extends keyof BuilderEventMap>(_: T, __: BuilderEventMap[T]): Unsubscribe;
18
+ once<T extends keyof BuilderEventMap>(_: T, __: BuilderEventMap[T]): void;
19
+ emit<T extends keyof BuilderEventMap>(_: T, __: EventData<BuilderEventMap, T>): void;
20
+ lock(path: string): void;
21
+ whereBetween(key: string, value: [JsonValue, JsonValue]): this;
22
+ whereNotBetween(key: string, value: [JsonValue, JsonValue]): this;
23
+ whereNull(key: string): this;
24
+ whereNotNull(key: string): this;
25
+ limit(value: number): this;
26
+ where(scope: (builder: BuilderInterface) => BuilderInterface | void): this;
27
+ where(key: string, value: JsonValue): this;
28
+ where(key: string, operator: ExtendedOperator, value: JsonValue): this;
29
+ orderBy(column: string, direction?: 'asc' | 'desc'): this;
30
+ searchBy(term: string): this;
31
+ minified(): this;
32
+ unset(key: string): this;
33
+ private exec;
34
+ get(page?: number, replaceLinksWith?: string): Promise<ModelPaginatedResponse>;
35
+ first(): Promise<Model | null>;
36
+ find(id: string | number): Promise<Model | null>;
37
+ all(): Promise<CollectionInterface<Model>>;
38
+ }
39
+ declare const _default: {
40
+ new (...args: any[]): {
41
+ "__#1@#emitter": import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
42
+ "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
43
+ on<E extends "change" | "submit" | "success" | "error">(event: E, callback: BuilderEventMap[E]): Unsubscribe;
44
+ once<E_1 extends "change" | "submit" | "success" | "error">(event: E_1, callback: BuilderEventMap[E_1]): void;
45
+ emit<E_2 extends "change" | "submit" | "success" | "error">(event: E_2, data?: Omit<Parameters<BuilderEventMap[E_2]>[0], "source">): void;
46
+ [Symbol.toStringTag]: string;
47
+ };
48
+ } & typeof Builder;
49
+ export default _default;
@@ -0,0 +1,190 @@
1
+ import { CollectionEvents, Operator, Collection as CollectionInterface, CollectionIteratorCallback, CollectionPipeCallback, CollectionSortCallback } from '../types/Collection';
2
+ import { JsonValue, Constructor, TypeOf } from '../types/Support';
3
+ import { Unsubscribe } from 'nanoevents';
4
+
5
+ export declare function collect<T = unknown, C extends typeof Collection<T> = typeof Collection<T>>(items?: T[], constructor?: C): CollectionInterface<T>;
6
+ export declare class Collection<T> implements CollectionInterface<T> {
7
+ #private;
8
+ constructor(items?: Array<T>);
9
+ get items(): T[];
10
+ [Symbol.iterator](): IterableIterator<T>;
11
+ [Symbol.toStringTag]: string;
12
+ all(): T[];
13
+ average(): number;
14
+ average<K extends keyof T>(key: K): number;
15
+ avg(): number;
16
+ avg<K extends keyof T>(key: K): number;
17
+ chunk(size: number): CollectionInterface<CollectionInterface<T>>;
18
+ chunkWhile(callback: CollectionIteratorCallback<T, boolean>): CollectionInterface<CollectionInterface<T>>;
19
+ collapse(): CollectionInterface<unknown>;
20
+ collect(): CollectionInterface<T>;
21
+ combine(values: CollectionInterface<JsonValue> | JsonValue[]): Record<string, JsonValue>;
22
+ concat(collection: CollectionInterface<unknown> | unknown[]): CollectionInterface<unknown>;
23
+ contains(value: T): boolean;
24
+ contains(key: keyof T, value: T): boolean;
25
+ contains(callback: CollectionIteratorCallback<T, boolean>): boolean;
26
+ containsOneItem(): boolean;
27
+ containsStrict(value: T): boolean;
28
+ containsStrict(key: keyof T, value: T): boolean;
29
+ containsStrict(callback: CollectionIteratorCallback<T, boolean>): boolean;
30
+ count(): number;
31
+ countBy(callback?: CollectionIteratorCallback<T, string | number>): Record<string | number, number>;
32
+ crossJoin<V>(...collections: (CollectionInterface<V> | V[])[]): CollectionInterface<Array<V | T>>;
33
+ diff(collection: CollectionInterface<T> | T[]): CollectionInterface<T>;
34
+ doesntContain(value: T): boolean;
35
+ doesntContain(key: keyof T, value: T): boolean;
36
+ doesntContain(callback: CollectionIteratorCallback<T, boolean>): boolean;
37
+ dump(): void;
38
+ duplicates(): CollectionInterface<T>;
39
+ duplicates<K extends keyof T>(key: K): CollectionInterface<T[K]>;
40
+ duplicatesStrict(): CollectionInterface<T>;
41
+ duplicatesStrict<K extends keyof T>(key: K): CollectionInterface<T[K]>;
42
+ each(callback: CollectionIteratorCallback<T, void | false>): this;
43
+ eachSpread(callback: (...args: unknown[]) => void | false): this;
44
+ ensure(type: TypeOf | Constructor | (TypeOf | Constructor)[]): this;
45
+ every(callback: CollectionIteratorCallback<T, boolean>): boolean;
46
+ except(indexes: Array<number>): CollectionInterface<T>;
47
+ filter(callback?: CollectionIteratorCallback<T, boolean>): CollectionInterface<T>;
48
+ first(callback?: CollectionIteratorCallback<T, boolean>): T | null;
49
+ firstOrFail(callback?: CollectionIteratorCallback<T, boolean>): T;
50
+ firstWhere(key: keyof T): T | null;
51
+ firstWhere(key: keyof T, value: T): T | null;
52
+ firstWhere(key: keyof T, operator: Operator, value: T): T | null;
53
+ flatMap<R>(callback: CollectionIteratorCallback<T, R | R[]>): CollectionInterface<R>;
54
+ forget(key: number): this;
55
+ forPage(page: number, perPage: number): CollectionInterface<T>;
56
+ get(key: number): T | null;
57
+ get<R>(key: number, defaultValue: R): T | R;
58
+ get<R>(key: number, defaultValue: () => R): T | R;
59
+ groupBy(key: keyof T): Record<string, T[]>;
60
+ groupBy(callback: CollectionIteratorCallback<T, string | string[]>): Record<string, T[]>;
61
+ groupBy(keys: (keyof T | CollectionIteratorCallback<T, string | string[]>)[]): Record<string, unknown>;
62
+ has(index: number): boolean;
63
+ hasAny(indexes: number[]): boolean;
64
+ implode(glue: string): string;
65
+ implode(key: keyof T, glue: string): string;
66
+ implode(callback: CollectionIteratorCallback<T, string>, glue: string): string;
67
+ intersect(values: Collection<T> | T[]): CollectionInterface<T>;
68
+ isEmpty(): boolean;
69
+ isNotEmpty(): boolean;
70
+ join(glue: string): string;
71
+ join(glue: string, final: string): string;
72
+ keyBy(key: keyof T): Record<string, T>;
73
+ keyBy(callback: CollectionIteratorCallback<T, string>): Record<string, T>;
74
+ last(callback?: CollectionIteratorCallback<T, boolean> | undefined): T | null;
75
+ map<R>(callback: CollectionIteratorCallback<T, R>): CollectionInterface<R>;
76
+ mapInto<R extends Constructor<InstanceType<R>>>(constructor: R): CollectionInterface<InstanceType<R>>;
77
+ mapSpread<R>(callback: (...args: unknown[]) => R): CollectionInterface<R>;
78
+ mapToGroups<R>(callback: CollectionIteratorCallback<T, Record<string, R>>): Record<string, R[]>;
79
+ mapWithKeys<R>(callback: CollectionIteratorCallback<T, Record<string, R>>): Record<string, R>;
80
+ max(): T | null;
81
+ max<K extends keyof T>(key: K): T[K] | null;
82
+ median(): T | null;
83
+ median<K extends keyof T>(key: K): T[K] | null;
84
+ merge(values: CollectionInterface<T> | T[]): CollectionInterface<T>;
85
+ merge<R>(values: CollectionInterface<R> | R[]): CollectionInterface<T | R>;
86
+ min(): T | null;
87
+ min<K extends keyof T>(key: K): T[K] | null;
88
+ mode(): T[];
89
+ mode<K extends keyof T>(key: K): T[K][];
90
+ nth(n: number, offset?: number): CollectionInterface<T>;
91
+ only(indexes: Array<number>): CollectionInterface<T>;
92
+ pad<R>(size: number, value?: R | null): CollectionInterface<T | R | null>;
93
+ partition(callback: CollectionIteratorCallback<T, boolean>): [CollectionInterface<T>, CollectionInterface<T>];
94
+ percentage(callback: CollectionIteratorCallback<T, boolean>, precision?: number): number;
95
+ pipe<R>(callback: CollectionPipeCallback<T, R>): R;
96
+ pipeInto<R extends Constructor<InstanceType<R>>>(constructor: R): InstanceType<R>;
97
+ pipeThrough<R>(pipeline: CollectionPipeCallback<unknown, CollectionInterface<unknown> | R>[]): R;
98
+ pluck<K extends keyof T>(key: K): CollectionInterface<T[K]>;
99
+ pop(): T | null;
100
+ pop(amount: number): CollectionInterface<T>;
101
+ prepend(value: T): number;
102
+ pull(index: number): T | null;
103
+ push(...items: T[]): number;
104
+ put(index: number, value: T): this;
105
+ random(): T | null;
106
+ random(amount: number): CollectionInterface<T>;
107
+ reduce<R>(callback: (carry: R | null, item: T, index: number, collection: this) => R, initialValue?: R | null): R | null;
108
+ reject(callback: CollectionIteratorCallback<T, boolean>): CollectionInterface<T>;
109
+ replace(data: Record<number, T>): CollectionInterface<T>;
110
+ reverse(): CollectionInterface<T>;
111
+ search(value: T): number | false;
112
+ search(value: T, strict: boolean): number | false;
113
+ search(callback: CollectionIteratorCallback<T, boolean>): number | false;
114
+ select<K extends Array<keyof T>>(keys: K): CollectionInterface<Pick<T, K[number]>>;
115
+ shift(): T | null;
116
+ shift(count: number): CollectionInterface<T>;
117
+ shuffle(): CollectionInterface<T>;
118
+ skip(amount: number): CollectionInterface<T>;
119
+ skipUntil(callback: CollectionIteratorCallback<T, boolean>): CollectionInterface<T>;
120
+ skipUntil(value: T): CollectionInterface<T>;
121
+ skipWhile(callback: CollectionIteratorCallback<T, boolean>): CollectionInterface<T>;
122
+ skipWhile(value: T): CollectionInterface<T>;
123
+ slice(start?: number, size?: number): CollectionInterface<T>;
124
+ sliding(size: number, step?: number): CollectionInterface<CollectionInterface<T>>;
125
+ sole(): T | null;
126
+ sole<K extends keyof T>(key: K, value: T[K]): T | null;
127
+ sole(callback: CollectionIteratorCallback<T, boolean>): T | null;
128
+ some(value: T): boolean;
129
+ some(key: keyof T, value: T): boolean;
130
+ some(callback: CollectionIteratorCallback<T, boolean>): boolean;
131
+ sort(compareFn?: CollectionSortCallback<T>): CollectionInterface<T>;
132
+ sortBy<K extends keyof T>(key: K, order?: 'asc' | 'desc'): CollectionInterface<T>;
133
+ sortBy<K extends keyof T>(columns: [K, 'asc' | 'desc'][]): CollectionInterface<T>;
134
+ sortBy(callback: CollectionIteratorCallback<T, number>): CollectionInterface<T>;
135
+ sortBy(stack: ((a: T, b: T) => number)[]): CollectionInterface<T>;
136
+ sortDesc(): CollectionInterface<T>;
137
+ splice(start: number): CollectionInterface<T>;
138
+ splice(start: number, deleteCount: number): CollectionInterface<T>;
139
+ splice(start: number, deleteCount: number, ...items: T[]): CollectionInterface<T>;
140
+ split(groups: number): CollectionInterface<CollectionInterface<T>>;
141
+ splitIn(groups: number): CollectionInterface<CollectionInterface<T>>;
142
+ sum(): number;
143
+ sum<K extends keyof T>(key: K): number;
144
+ take(amount: number): CollectionInterface<T>;
145
+ takeUntil(value: T): CollectionInterface<T>;
146
+ takeUntil(callback: CollectionIteratorCallback<T, boolean>): CollectionInterface<T>;
147
+ takeWhile(value: T): CollectionInterface<T>;
148
+ takeWhile(callback: CollectionIteratorCallback<T, boolean>): CollectionInterface<T>;
149
+ tap(callback: CollectionPipeCallback<T, void>): this;
150
+ toArray(): T[];
151
+ toJson(): string;
152
+ transform<R>(callback: CollectionIteratorCallback<T, R>): CollectionInterface<T | R>;
153
+ unique(): CollectionInterface<T>;
154
+ unique<K extends keyof T>(key: K): CollectionInterface<T>;
155
+ uniqueStrict(): CollectionInterface<T>;
156
+ uniqueStrict<K extends keyof T>(key: K): CollectionInterface<T>;
157
+ unless(condition: boolean, callback: CollectionPipeCallback<T, void>, otherwise?: CollectionPipeCallback<T, void>): this;
158
+ unlessEmpty(callback: CollectionPipeCallback<T, void>, otherwise?: CollectionPipeCallback<T, void>): this;
159
+ unlessNotEmpty(callback: CollectionPipeCallback<T, void>, otherwise?: CollectionPipeCallback<T, void>): this;
160
+ value<K extends keyof T>(key: K): T[K] | null;
161
+ when(condition: boolean, callback: CollectionPipeCallback<T, void>, otherwise?: CollectionPipeCallback<T, void>): this;
162
+ whenEmpty(callback: CollectionPipeCallback<T, void>, otherwise?: CollectionPipeCallback<T, void>): this;
163
+ whenNotEmpty(callback: CollectionPipeCallback<T, void>, otherwise?: CollectionPipeCallback<T, void>): this;
164
+ where<K extends keyof T>(key: K, value: T[K]): CollectionInterface<T>;
165
+ where<K extends keyof T>(key: K, operator: Operator, value: T[K]): CollectionInterface<T>;
166
+ whereStrict<K extends keyof T>(key: K, value: T[K]): CollectionInterface<T>;
167
+ whereStrict<K extends keyof T>(key: K, operator: Operator, value: T[K]): CollectionInterface<T>;
168
+ whereBetween<K extends keyof T>(key: K, [min, max]: [T[K], T[K]]): CollectionInterface<T>;
169
+ whereIn<K extends keyof T>(key: K, values: T[K][]): CollectionInterface<T>;
170
+ whereInstanceOf<R extends Constructor<T>>(constructor: R): CollectionInterface<T>;
171
+ whereNotBetween<K extends keyof T>(key: K, [min, max]: [T[K], T[K]]): CollectionInterface<T>;
172
+ whereNotIn<K extends keyof T>(key: K, values: T[K][]): CollectionInterface<T>;
173
+ whereNotNull<K extends keyof T>(key: K): CollectionInterface<T>;
174
+ whereNull<K extends keyof T>(key: K): CollectionInterface<T>;
175
+ zip<R>(items: CollectionInterface<R> | R[]): CollectionInterface<[T, R | null]>;
176
+ on<K extends keyof CollectionEvents<T>>(_: K, __: CollectionEvents<T>[K]): Unsubscribe;
177
+ once<K extends keyof CollectionEvents<T>>(_: K, __: CollectionEvents<T>[K]): void;
178
+ emit<K extends keyof CollectionEvents<T>>(_: K, __?: Omit<Parameters<CollectionEvents<T>[K]>[0], 'source'>): void;
179
+ }
180
+ declare const _default: {
181
+ new (...args: any[]): {
182
+ "__#1@#emitter": import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
183
+ "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
184
+ on<E extends "change">(event: E, callback: CollectionEvents<unknown>[E]): Unsubscribe;
185
+ once<E_1 extends "change">(event: E_1, callback: CollectionEvents<unknown>[E_1]): void;
186
+ emit<E_2 extends "change">(event: E_2, data?: Omit<Parameters<CollectionEvents<unknown>[E_2]>[0], "source">): void;
187
+ [Symbol.toStringTag]: string;
188
+ };
189
+ } & typeof Collection;
190
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { Collection } from './Collection';
2
+ import { Model } from '../types/Model';
3
+ import { Collection as CollectionInterface } from '../types/Collection';
4
+
5
+ declare class ModelCollection extends Collection<Model> {
6
+ [Symbol.toStringTag]: string;
7
+ intersect(values: Collection<Model> | Model[]): CollectionInterface<Model>;
8
+ }
9
+ export default ModelCollection;
@@ -0,0 +1,8 @@
1
+ import { AppFacade, AppFacades } from '../types/App';
2
+
3
+ export default abstract class Plugin {
4
+ readonly name?: string;
5
+ readonly version?: string;
6
+ register(_app: AppFacade): void;
7
+ boot(_facades: AppFacades): void;
8
+ }
@@ -0,0 +1,21 @@
1
+ import { PropertyBag as PropertyBagInterface, PropertyBagEventMap } from '../types/PropertyBag';
2
+ import { Unsubscribe } from 'nanoevents';
3
+
4
+ declare class PropertyBag<T extends object> implements PropertyBagInterface<T> {
5
+ private bag;
6
+ private locked;
7
+ constructor(bag: T);
8
+ get(path: string, defaultValue?: unknown): unknown;
9
+ set(path: string, value: unknown): void;
10
+ merge(path: string, value: unknown): void;
11
+ has(path: string): boolean;
12
+ delete(path: string): void;
13
+ lock(path: string): void;
14
+ clone(): PropertyBagInterface<T>;
15
+ all(): T;
16
+ isEmpty(): boolean;
17
+ on<K extends keyof PropertyBagEventMap<T>>(_: K, __: PropertyBagEventMap[K]): Unsubscribe;
18
+ once<K extends keyof PropertyBagEventMap<T>>(_: K, __: PropertyBagEventMap[K]): void;
19
+ emit<K extends keyof PropertyBagEventMap<T>>(_: K, __: Omit<Parameters<PropertyBagEventMap[K]>[0], 'source'>): void;
20
+ }
21
+ export default PropertyBag;
@@ -0,0 +1,20 @@
1
+ import { default as Relation } from '../Relation';
2
+ import { Model, ModelPaginatedResponse, RelationMetaData } from '../../types/Model';
3
+ import { AppFacades } from '../../types/App';
4
+ import { BuilderInterface as Builder } from '../../types/Builder';
5
+
6
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
7
+ export default class BelongsTo extends Relation {
8
+ protected meta: RelationMetaData;
9
+ protected facades: AppFacades;
10
+ protected parent: Model;
11
+ protected items: Model | null;
12
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Model | null);
13
+ isSingle(): boolean;
14
+ isMultiple(): boolean;
15
+ query(): BuilderInterface;
16
+ get(): Promise<Model | null>;
17
+ associate(item: Model): Promise<void>;
18
+ dissociate(): Promise<void>;
19
+ }
20
+ export {};
@@ -0,0 +1,31 @@
1
+ import { default as Relation } from '../Relation';
2
+ import { Model, ModelPaginatedResponse, RelationMetaData } from '../../types/Model';
3
+ import { AppFacades } from '../../types/App';
4
+ import { BuilderInterface as Builder } from '../../types/Builder';
5
+ import { Collection as CollectionInterface } from '../../types/Collection';
6
+ import { JsonObject } from '../../types/Support';
7
+
8
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
9
+ export default class BelongsToMany extends Relation {
10
+ protected meta: RelationMetaData;
11
+ protected facades: AppFacades;
12
+ protected parent: Model;
13
+ protected items: CollectionInterface<Model> | null;
14
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: CollectionInterface<Model> | null);
15
+ isSingle(): boolean;
16
+ isMultiple(): boolean;
17
+ query(): BuilderInterface;
18
+ get(page?: number, replaceLinksWith?: string): Promise<ModelPaginatedResponse>;
19
+ all(): Promise<CollectionInterface<Model>>;
20
+ first(): Promise<Model | null>;
21
+ find(id: string | number): Promise<Model | null>;
22
+ attachQuietly(id: string | number, pivot?: JsonObject): Promise<import('axios').AxiosResponse<any, any>>;
23
+ attach(id: string | number, pivot?: JsonObject): Promise<void>;
24
+ detachQuietly(id: string | number): Promise<void>;
25
+ detach(id: string | number): Promise<void>;
26
+ syncQuietly(ids: (string | number | JsonObject)[]): Promise<void>;
27
+ syncWithPivotValuesQuietly(ids: (string | number)[], pivot: JsonObject): Promise<void>;
28
+ sync(ids: (string | number | JsonObject)[]): Promise<void>;
29
+ syncWithPivotValues(ids: (string | number)[], pivot: JsonObject): Promise<void>;
30
+ }
31
+ export {};
@@ -0,0 +1,21 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { Model, RelationMetaData } from '../../types/Model';
3
+ import { default as HasOneOrMany } from './HasOneOrMany';
4
+ import { Collection as CollectionInterface } from '../../types/Collection';
5
+
6
+ export default class HasMany extends HasOneOrMany {
7
+ protected meta: RelationMetaData;
8
+ protected facades: AppFacades;
9
+ protected parent: Model;
10
+ protected items: CollectionInterface<Model> | null;
11
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: CollectionInterface<Model> | null);
12
+ isSingle(): boolean;
13
+ isMultiple(): boolean;
14
+ get(page?: number, replaceLinksWith?: string): Promise<import('../../types/Model').ModelPaginatedResponse>;
15
+ all(): Promise<CollectionInterface<Model>>;
16
+ first(): Promise<Model | null>;
17
+ find(id: string | number): Promise<Model | null>;
18
+ saveManyQuietly(models: Model[]): Promise<void>;
19
+ saveMany(models: Model[]): Promise<void>;
20
+ save(item: Model): Promise<void>;
21
+ }
@@ -0,0 +1,15 @@
1
+ import { Model, RelationMetaData } from '../../types/Model';
2
+ import { AppFacades } from '../../types/App';
3
+ import { default as HasOneOrMany } from './HasOneOrMany';
4
+
5
+ export default class HasOne extends HasOneOrMany {
6
+ protected meta: RelationMetaData;
7
+ protected facades: AppFacades;
8
+ protected parent: Model;
9
+ protected items: Model | null;
10
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Model | null);
11
+ isSingle(): boolean;
12
+ isMultiple(): boolean;
13
+ get(): Promise<Model | null>;
14
+ save(item: Model): Promise<void>;
15
+ }
@@ -0,0 +1,10 @@
1
+ import { BuilderInterface as Builder } from '../../types/Builder';
2
+ import { Model, ModelPaginatedResponse } from '../../types/Model';
3
+ import { default as Relation } from '../Relation';
4
+
5
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
6
+ export default class HasOneOrMany extends Relation {
7
+ query(): BuilderInterface;
8
+ saveQuietly(item: Model): Promise<void>;
9
+ }
10
+ export {};
@@ -0,0 +1,21 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { Model, RelationMetaData } from '../../types/Model';
3
+ import { default as MorphOneOrMany } from './MorphOneOrMany';
4
+ import { Collection as CollectionInterface } from '../../types/Collection';
5
+
6
+ export default class MorphMany extends MorphOneOrMany {
7
+ protected meta: RelationMetaData;
8
+ protected facades: AppFacades;
9
+ protected parent: Model;
10
+ protected items: CollectionInterface<Model> | null;
11
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: CollectionInterface<Model> | null);
12
+ isSingle(): boolean;
13
+ isMultiple(): boolean;
14
+ get(page?: number, replaceLinksWith?: string): Promise<import('../../types/Model').ModelPaginatedResponse>;
15
+ all(): Promise<CollectionInterface<Model>>;
16
+ first(): Promise<Model | null>;
17
+ find(id: string | number): Promise<Model | null>;
18
+ saveManyQuietly(models: Model[]): Promise<void>;
19
+ save(item: Model): Promise<void>;
20
+ saveMany(models: Model[]): Promise<void>;
21
+ }
@@ -0,0 +1,15 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { Model, RelationMetaData } from '../../types/Model';
3
+ import { default as MorphOneOrMany } from './MorphOneOrMany';
4
+
5
+ export default class MorphOne extends MorphOneOrMany {
6
+ protected meta: RelationMetaData;
7
+ protected facades: AppFacades;
8
+ protected parent: Model;
9
+ protected items: Model | null;
10
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Model | null);
11
+ isSingle(): boolean;
12
+ isMultiple(): boolean;
13
+ get(): Promise<Model | null>;
14
+ save(item: Model): Promise<void>;
15
+ }
@@ -0,0 +1,10 @@
1
+ import { BuilderInterface as Builder } from '../../types/Builder';
2
+ import { Model, ModelPaginatedResponse } from '../../types/Model';
3
+ import { default as HasOneOrMany } from './HasOneOrMany';
4
+
5
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
6
+ export default class MorphOneOrMany extends HasOneOrMany {
7
+ query(): BuilderInterface;
8
+ saveQuietly(item: Model): Promise<void>;
9
+ }
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Model } from '../../types/Model';
2
+ import { default as BelongsTo } from './BelongsTo';
3
+
4
+ export default class MorphTo extends BelongsTo {
5
+ getRelated(): typeof Model;
6
+ associate(item: Model): Promise<void>;
7
+ dissociate(): Promise<void>;
8
+ }
@@ -0,0 +1,16 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { BuilderInterface as Builder } from '../../types/Builder';
3
+ import { Model, ModelPaginatedResponse, RelationMetaData } from '../../types/Model';
4
+ import { Collection } from '../../types/Collection';
5
+ import { default as BelongsToMany } from './BelongsToMany';
6
+
7
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
8
+ export default class MorphToMany extends BelongsToMany {
9
+ protected meta: RelationMetaData;
10
+ protected facades: AppFacades;
11
+ protected parent: Model;
12
+ protected items: Collection<Model> | null;
13
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Collection<Model> | null);
14
+ query(): BuilderInterface;
15
+ }
16
+ export {};
@@ -0,0 +1,44 @@
1
+ import { AppFacades } from '../types/App';
2
+ import { BaseModel, Model, ModelPaginatedResponse, RelationMetaData } from '../types/Model';
3
+ import { BuilderInterface as Builder, Scope as ScopeBase, ExtendedOperator } from '../types/Builder';
4
+ import { Collection as CollectionInterface } from '../types/Collection';
5
+ import { RelationInterface as RelationBase } from '../types/Relation';
6
+ import { JsonValue } from '../types/Support';
7
+
8
+ type RelationInterface = RelationBase<Model, ModelPaginatedResponse>;
9
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
10
+ type Scope = ScopeBase<Model, ModelPaginatedResponse>;
11
+ export default class Relation implements RelationInterface {
12
+ protected meta: RelationMetaData;
13
+ protected facades: AppFacades;
14
+ protected parent: BaseModel;
15
+ protected items: Model | CollectionInterface<Model> | null;
16
+ private unsubscribeQuery;
17
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: BaseModel, items?: Model | CollectionInterface<Model> | null);
18
+ make(data: JsonValue): void;
19
+ guessInverseRelation(): string;
20
+ set(items: Model | CollectionInterface<Model> | null): void;
21
+ getForeignKey(): string | null;
22
+ getName(): string;
23
+ getType(): "HasOne" | "HasMany" | "BelongsTo" | "BelongsToMany" | "MorphOne" | "MorphMany" | "MorphTo" | "MorphToMany" | "MorphedByMany";
24
+ getModel(): string;
25
+ getRelated(): typeof Model;
26
+ query(): Builder<Model, ModelPaginatedResponse>;
27
+ isLoaded(): boolean;
28
+ getLoadedItems(): Model | CollectionInterface<Model> | null;
29
+ isSingle(): boolean;
30
+ isMultiple(): boolean;
31
+ getParent(): BaseModel;
32
+ where(scope: Scope): BuilderInterface;
33
+ where(key: string, value: JsonValue): BuilderInterface;
34
+ where(key: string, operator: ExtendedOperator, value: JsonValue): BuilderInterface;
35
+ whereNull(key: string): Builder<Model, ModelPaginatedResponse>;
36
+ whereNotNull(key: string): Builder<Model, ModelPaginatedResponse>;
37
+ whereBetween(key: string, value: [JsonValue, JsonValue]): Builder<Model, ModelPaginatedResponse>;
38
+ whereNotBetween(key: string, value: [JsonValue, JsonValue]): Builder<Model, ModelPaginatedResponse>;
39
+ orderBy(column: string, direction?: 'asc' | 'desc'): Builder<Model, ModelPaginatedResponse>;
40
+ searchBy(term: string): Builder<Model, ModelPaginatedResponse>;
41
+ minified(): Builder<Model, ModelPaginatedResponse>;
42
+ limit(value: number): Builder<Model, ModelPaginatedResponse>;
43
+ }
44
+ export {};