@luminix/core 0.0.1-beta.0

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 (76) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.cjs +39 -0
  3. package/README.md +31 -0
  4. package/dist/contracts/Builder.d.ts +49 -0
  5. package/dist/contracts/Collection.d.ts +191 -0
  6. package/dist/contracts/ModelCollection.d.ts +8 -0
  7. package/dist/contracts/Plugin.d.ts +7 -0
  8. package/dist/contracts/PropertyBag.d.ts +28 -0
  9. package/dist/contracts/Relation/BelongsTo.d.ts +19 -0
  10. package/dist/contracts/Relation/BelongsToMany.d.ts +30 -0
  11. package/dist/contracts/Relation/HasMany.d.ts +20 -0
  12. package/dist/contracts/Relation/HasOne.d.ts +14 -0
  13. package/dist/contracts/Relation/HasOneOrMany.d.ts +9 -0
  14. package/dist/contracts/Relation/MorphMany.d.ts +20 -0
  15. package/dist/contracts/Relation/MorphOne.d.ts +14 -0
  16. package/dist/contracts/Relation/MorphOneOrMany.d.ts +9 -0
  17. package/dist/contracts/Relation/MorphTo.d.ts +7 -0
  18. package/dist/contracts/Relation/MorphToMany.d.ts +15 -0
  19. package/dist/contracts/Relation.d.ts +43 -0
  20. package/dist/core.js +2482 -0
  21. package/dist/exceptions/AttributeNotFillableException.d.ts +4 -0
  22. package/dist/exceptions/FacadeNotFoundException.d.ts +4 -0
  23. package/dist/exceptions/MethodNotImplementedException.d.ts +4 -0
  24. package/dist/exceptions/ModelInvalidRelatedTypeException.d.ts +4 -0
  25. package/dist/exceptions/ModelNotFoundException.d.ts +4 -0
  26. package/dist/exceptions/ModelNotPersistedException.d.ts +4 -0
  27. package/dist/exceptions/ModelWithoutPrimaryKeyException.d.ts +4 -0
  28. package/dist/exceptions/NoEmbedException.d.ts +4 -0
  29. package/dist/exceptions/NoInverseRelationException.d.ts +4 -0
  30. package/dist/exceptions/NotModelException.d.ts +4 -0
  31. package/dist/exceptions/NotReducibleException.d.ts +4 -0
  32. package/dist/exceptions/ReducerOverrideException.d.ts +4 -0
  33. package/dist/exceptions/RouteNotFoundException.d.ts +4 -0
  34. package/dist/exceptions/UnsupportedRelationException.d.ts +4 -0
  35. package/dist/facades/App.d.ts +30 -0
  36. package/dist/facades/Auth.d.ts +13 -0
  37. package/dist/facades/Error.d.ts +14 -0
  38. package/dist/facades/Log.d.ts +13 -0
  39. package/dist/facades/Model.d.ts +41 -0
  40. package/dist/facades/Route.d.ts +31 -0
  41. package/dist/helpers/app.d.ts +4 -0
  42. package/dist/helpers/auth.d.ts +1 -0
  43. package/dist/helpers/collect.d.ts +1 -0
  44. package/dist/helpers/config.d.ts +4 -0
  45. package/dist/helpers/error.d.ts +3 -0
  46. package/dist/helpers/log.d.ts +4 -0
  47. package/dist/helpers/model.d.ts +5 -0
  48. package/dist/helpers/route.d.ts +4 -0
  49. package/dist/index.d.ts +23 -0
  50. package/dist/mixins/BaseModel.d.ts +4 -0
  51. package/dist/mixins/HasEvents.d.ts +15 -0
  52. package/dist/mixins/Reducible.d.ts +16 -0
  53. package/dist/support/collection.d.ts +3 -0
  54. package/dist/support/model.d.ts +2 -0
  55. package/dist/support/reader.d.ts +2 -0
  56. package/dist/support/searchParams.d.ts +1 -0
  57. package/dist/types/App.d.ts +71 -0
  58. package/dist/types/Auth.d.ts +12 -0
  59. package/dist/types/Builder.d.ts +45 -0
  60. package/dist/types/Collection.d.ts +1803 -0
  61. package/dist/types/Config.d.ts +28 -0
  62. package/dist/types/Error.d.ts +29 -0
  63. package/dist/types/Event.d.ts +13 -0
  64. package/dist/types/Log.d.ts +37 -0
  65. package/dist/types/Model.d.ts +164 -0
  66. package/dist/types/Plugin.d.ts +4 -0
  67. package/dist/types/Reducer.d.ts +16 -0
  68. package/dist/types/Relation.d.ts +29 -0
  69. package/dist/types/Route.d.ts +21 -0
  70. package/dist/types/Support.d.ts +7 -0
  71. package/graph.png +0 -0
  72. package/index.html +13 -0
  73. package/jest.config.js +15 -0
  74. package/package.json +38 -0
  75. package/tsconfig.json +25 -0
  76. package/vite.config.js +18 -0
package/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ vite.config.js
2
+ dist/
3
+ coverage/
package/.eslintrc.cjs ADDED
@@ -0,0 +1,39 @@
1
+ // eslint-disable-next-line no-undef
2
+ module.exports = {
3
+ 'env': {
4
+ 'browser': true,
5
+ 'es2021': true
6
+ },
7
+ 'extends': [
8
+ 'eslint:recommended',
9
+ 'plugin:@typescript-eslint/recommended'
10
+ ],
11
+ 'overrides': [
12
+ ],
13
+ 'parser': '@typescript-eslint/parser',
14
+ 'parserOptions': {
15
+ 'ecmaVersion': 'latest',
16
+ 'sourceType': 'module'
17
+ },
18
+ 'plugins': [
19
+ '@typescript-eslint'
20
+ ],
21
+ 'rules': {
22
+ 'indent': [
23
+ 'error',
24
+ 4
25
+ ],
26
+ 'linebreak-style': [
27
+ 'error',
28
+ 'unix'
29
+ ],
30
+ 'quotes': [
31
+ 'error',
32
+ 'single'
33
+ ],
34
+ 'semi': [
35
+ 'error',
36
+ 'always'
37
+ ]
38
+ }
39
+ };
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Luminix JS Core
2
+
3
+ > Projeto em desenvolvimento
4
+
5
+ [Site do Luminix CMS](https://luminix.arandutech.com.br)
6
+
7
+ Este pacote é parte do Luminix CMS, um sistema de gerenciamento de conteúdo para Laravel. Este pacote contém:
8
+ - comunicação com o backend do Luminix CMS;
9
+ - fornece classes para os Models definidos no backend para serem utilizadas no frontend;
10
+ - fornece um mecanismo de Macros para o frontend, inspirado nos hooks do WordPress;
11
+ - fornece funções helper, algumas análogas às funções do Laravel, e outras específicas do Luminix.
12
+
13
+ ## Instalação
14
+
15
+ ```bash
16
+ # Para o Backend
17
+ composer require luminix/cms
18
+ # Para o frontend
19
+ npm install @luminix/core
20
+ ```
21
+ > Verifique a documentação do `luminix/cms` para mais informações sobre a instalação do backend.
22
+
23
+ ## Documentação
24
+
25
+ - [Inicializando o `Luminix`](./docs/pt-BR/1-Inicializando-cms.md)
26
+ - [Definindo a configuração](./docs/pt-BR/1.1-Definindo-configuracao.md)
27
+ - [Registro de Macros](./docs/pt-BR/1.2-Registro-de-macros.md)
28
+ - [Instalando Plugins](./docs/pt-BR/1.3-Instalando-plugins.md)
29
+ - [Utilizando os Models](./docs/pt-BR/2-Utilizando-models.md)
30
+ - [Funções Helper](./docs/pt-BR/3-Funcoes-helper.md)
31
+ - [API](./docs/pt-BR/4-API.md)
@@ -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
+ type BuilderInterface = BuilderBase<Model, ModelPaginatedResponse>;
9
+ type BuilderEventMap = BuilderEvents<Model, ModelPaginatedResponse>;
10
+ declare class Builder implements BuilderInterface {
11
+ protected facades: AppFacades;
12
+ protected abstract: string;
13
+ protected query: ModelQuery;
14
+ private bag;
15
+ constructor(facades: AppFacades, abstract: string, query?: ModelQuery);
16
+ on<T extends keyof BuilderEventMap>(_: T, __: BuilderEventMap[T]): Unsubscribe;
17
+ once<T extends keyof BuilderEventMap>(_: T, __: BuilderEventMap[T]): void;
18
+ emit<T extends keyof BuilderEventMap>(_: T, __: EventData<BuilderEventMap, T>): void;
19
+ lock(path: string): void;
20
+ whereBetween(key: string, value: [JsonValue, JsonValue]): this;
21
+ whereNotBetween(key: string, value: [JsonValue, JsonValue]): this;
22
+ whereNull(key: string): this;
23
+ whereNotNull(key: string): this;
24
+ limit(value: number): this;
25
+ where(scope: (builder: BuilderInterface) => BuilderInterface | void): this;
26
+ where(key: string, value: JsonValue): this;
27
+ where(key: string, operator: ExtendedOperator, value: JsonValue): this;
28
+ orderBy(column: string, direction?: 'asc' | 'desc'): this;
29
+ searchBy(term: string): this;
30
+ minified(): this;
31
+ unset(key: string): this;
32
+ private exec;
33
+ get(page?: number, replaceLinksWith?: string): Promise<ModelPaginatedResponse>;
34
+ first(): Promise<Model | null>;
35
+ find(id: string | number): Promise<Model | null>;
36
+ all(): Promise<CollectionInterface<Model>>;
37
+ }
38
+ declare const _default: {
39
+ new (...args: any[]): {
40
+ "__#1@#emitter": import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
41
+ "__#1@#createNanoEvents"(): import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
42
+ on<E extends "change" | "submit" | "success" | "error">(event: E, callback: BuilderEventMap[E]): Unsubscribe;
43
+ once<E_1 extends "change" | "submit" | "success" | "error">(event: E_1, callback: BuilderEventMap[E_1]): void;
44
+ emit<E_2 extends "change" | "submit" | "success" | "error">(event: E_2, data?: Omit<Parameters<BuilderEventMap[E_2]>[0], "source">): void;
45
+ [Symbol.toStringTag]: string;
46
+ };
47
+ name: string;
48
+ } & typeof Builder;
49
+ export default _default;
@@ -0,0 +1,191 @@
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
+ export declare function collect<T = unknown, C extends typeof Collection<T> = typeof Collection<T>>(items?: T[], constructor?: C): CollectionInterface<T>;
5
+ export declare class Collection<T> implements CollectionInterface<T> {
6
+ #private;
7
+ static name: string;
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
+ name: string;
190
+ } & typeof Collection;
191
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { Collection } from './Collection';
2
+ import { Model } from '../types/Model';
3
+ import { Collection as CollectionInterface } from '../types/Collection';
4
+ declare class ModelCollection extends Collection<Model> {
5
+ static name: string;
6
+ intersect(values: Collection<Model> | Model[]): CollectionInterface<Model>;
7
+ }
8
+ export default ModelCollection;
@@ -0,0 +1,7 @@
1
+ import { AppFacade, AppFacades } from '../types/App';
2
+ export default abstract class Plugin {
3
+ readonly name?: string;
4
+ readonly version?: string;
5
+ register(_app: AppFacade): void;
6
+ boot(_facades: AppFacades): void;
7
+ }
@@ -0,0 +1,28 @@
1
+ import { Event } from '../types/Event';
2
+ import { Unsubscribe } from 'nanoevents';
3
+ export type PropertyBagEventMap<T extends object = any> = {
4
+ 'change': (e: PropertyBagChangeEvent<T>) => void;
5
+ };
6
+ export type PropertyBagChangeEvent<T extends object> = Event<PropertyBag<T>> & {
7
+ path: string;
8
+ value: unknown;
9
+ type: 'set' | 'merge' | 'delete';
10
+ };
11
+ declare class PropertyBag<T extends object> {
12
+ private bag;
13
+ private locked;
14
+ constructor(bag: T);
15
+ get(path: string, defaultValue?: unknown): unknown;
16
+ set(path: string, value: unknown): void;
17
+ merge(path: string, value: unknown): void;
18
+ has(path: string): boolean;
19
+ delete(path: string): void;
20
+ lock(path: string): void;
21
+ clone(): PropertyBag<T>;
22
+ all(): T;
23
+ isEmpty(): boolean;
24
+ on<K extends keyof PropertyBagEventMap<T>>(_: K, __: PropertyBagEventMap[K]): Unsubscribe;
25
+ once<K extends keyof PropertyBagEventMap<T>>(_: K, __: PropertyBagEventMap[K]): void;
26
+ emit<K extends keyof PropertyBagEventMap<T>>(_: K, __: Omit<Parameters<PropertyBagEventMap[K]>[0], 'source'>): void;
27
+ }
28
+ export default PropertyBag;
@@ -0,0 +1,19 @@
1
+ import 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
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
6
+ export default class BelongsTo extends Relation {
7
+ protected meta: RelationMetaData;
8
+ protected facades: AppFacades;
9
+ protected parent: Model;
10
+ protected items: Model | null;
11
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Model | null);
12
+ isSingle(): boolean;
13
+ isMultiple(): boolean;
14
+ query(): BuilderInterface;
15
+ get(): Promise<Model | null>;
16
+ associate(item: Model): Promise<void>;
17
+ dissociate(): Promise<void>;
18
+ }
19
+ export {};
@@ -0,0 +1,30 @@
1
+ import 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
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
8
+ export default class BelongsToMany extends Relation {
9
+ protected meta: RelationMetaData;
10
+ protected facades: AppFacades;
11
+ protected parent: Model;
12
+ protected items: CollectionInterface<Model> | null;
13
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: CollectionInterface<Model> | null);
14
+ isSingle(): boolean;
15
+ isMultiple(): boolean;
16
+ query(): BuilderInterface;
17
+ get(page?: number, replaceLinksWith?: string): Promise<ModelPaginatedResponse>;
18
+ all(): Promise<CollectionInterface<Model>>;
19
+ first(): Promise<Model | null>;
20
+ find(id: string | number): Promise<Model | null>;
21
+ attachQuietly(id: string | number, pivot?: JsonObject): Promise<import("axios").AxiosResponse<any, any>>;
22
+ attach(id: string | number, pivot?: JsonObject): Promise<void>;
23
+ detachQuietly(id: string | number): Promise<void>;
24
+ detach(id: string | number): Promise<void>;
25
+ syncQuietly(ids: (string | number | JsonObject)[]): Promise<void>;
26
+ syncWithPivotValuesQuietly(ids: (string | number)[], pivot: JsonObject): Promise<void>;
27
+ sync(ids: (string | number | JsonObject)[]): Promise<void>;
28
+ syncWithPivotValues(ids: (string | number)[], pivot: JsonObject): Promise<void>;
29
+ }
30
+ export {};
@@ -0,0 +1,20 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { Model, RelationMetaData } from '../../types/Model';
3
+ import HasOneOrMany from './HasOneOrMany';
4
+ import { Collection as CollectionInterface } from '../../types/Collection';
5
+ export default class HasMany extends HasOneOrMany {
6
+ protected meta: RelationMetaData;
7
+ protected facades: AppFacades;
8
+ protected parent: Model;
9
+ protected items: CollectionInterface<Model> | null;
10
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: CollectionInterface<Model> | null);
11
+ isSingle(): boolean;
12
+ isMultiple(): boolean;
13
+ get(page?: number, replaceLinksWith?: string): Promise<import("../../types/Model").ModelPaginatedResponse>;
14
+ all(): Promise<CollectionInterface<Model>>;
15
+ first(): Promise<Model | null>;
16
+ find(id: string | number): Promise<Model | null>;
17
+ saveManyQuietly(models: Model[]): Promise<void>;
18
+ saveMany(models: Model[]): Promise<void>;
19
+ save(item: Model): Promise<void>;
20
+ }
@@ -0,0 +1,14 @@
1
+ import { Model, RelationMetaData } from '../../types/Model';
2
+ import { AppFacades } from '../../types/App';
3
+ import HasOneOrMany from './HasOneOrMany';
4
+ export default class HasOne extends HasOneOrMany {
5
+ protected meta: RelationMetaData;
6
+ protected facades: AppFacades;
7
+ protected parent: Model;
8
+ protected items: Model | null;
9
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Model | null);
10
+ isSingle(): boolean;
11
+ isMultiple(): boolean;
12
+ get(): Promise<Model | null>;
13
+ save(item: Model): Promise<void>;
14
+ }
@@ -0,0 +1,9 @@
1
+ import { BuilderInterface as Builder } from '../../types/Builder';
2
+ import { Model, ModelPaginatedResponse } from '../../types/Model';
3
+ import Relation from '../Relation';
4
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
5
+ export default class HasOneOrMany extends Relation {
6
+ query(): BuilderInterface;
7
+ saveQuietly(item: Model): Promise<void>;
8
+ }
9
+ export {};
@@ -0,0 +1,20 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { Model, RelationMetaData } from '../../types/Model';
3
+ import MorphOneOrMany from './MorphOneOrMany';
4
+ import { Collection as CollectionInterface } from '../../types/Collection';
5
+ export default class MorphMany extends MorphOneOrMany {
6
+ protected meta: RelationMetaData;
7
+ protected facades: AppFacades;
8
+ protected parent: Model;
9
+ protected items: CollectionInterface<Model> | null;
10
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: CollectionInterface<Model> | null);
11
+ isSingle(): boolean;
12
+ isMultiple(): boolean;
13
+ get(page?: number, replaceLinksWith?: string): Promise<import("../../types/Model").ModelPaginatedResponse>;
14
+ all(): Promise<CollectionInterface<Model>>;
15
+ first(): Promise<Model | null>;
16
+ find(id: string | number): Promise<Model | null>;
17
+ saveManyQuietly(models: Model[]): Promise<void>;
18
+ save(item: Model): Promise<void>;
19
+ saveMany(models: Model[]): Promise<void>;
20
+ }
@@ -0,0 +1,14 @@
1
+ import { AppFacades } from '../../types/App';
2
+ import { Model, RelationMetaData } from '../../types/Model';
3
+ import MorphOneOrMany from './MorphOneOrMany';
4
+ export default class MorphOne extends MorphOneOrMany {
5
+ protected meta: RelationMetaData;
6
+ protected facades: AppFacades;
7
+ protected parent: Model;
8
+ protected items: Model | null;
9
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Model | null);
10
+ isSingle(): boolean;
11
+ isMultiple(): boolean;
12
+ get(): Promise<Model | null>;
13
+ save(item: Model): Promise<void>;
14
+ }
@@ -0,0 +1,9 @@
1
+ import { BuilderInterface as Builder } from '../../types/Builder';
2
+ import { Model, ModelPaginatedResponse } from '../../types/Model';
3
+ import HasOneOrMany from './HasOneOrMany';
4
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
5
+ export default class MorphOneOrMany extends HasOneOrMany {
6
+ query(): BuilderInterface;
7
+ saveQuietly(item: Model): Promise<void>;
8
+ }
9
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Model } from '../../types/Model';
2
+ import BelongsTo from './BelongsTo';
3
+ export default class MorphTo extends BelongsTo {
4
+ getRelated(): typeof Model;
5
+ associate(item: Model): Promise<void>;
6
+ dissociate(): Promise<void>;
7
+ }
@@ -0,0 +1,15 @@
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 BelongsToMany from './BelongsToMany';
6
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
7
+ export default class MorphToMany extends BelongsToMany {
8
+ protected meta: RelationMetaData;
9
+ protected facades: AppFacades;
10
+ protected parent: Model;
11
+ protected items: Collection<Model> | null;
12
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: Model, items?: Collection<Model> | null);
13
+ query(): BuilderInterface;
14
+ }
15
+ export {};
@@ -0,0 +1,43 @@
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
+ type RelationInterface = RelationBase<Model, ModelPaginatedResponse>;
8
+ type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
9
+ type Scope = ScopeBase<Model, ModelPaginatedResponse>;
10
+ export default class Relation implements RelationInterface {
11
+ protected meta: RelationMetaData;
12
+ protected facades: AppFacades;
13
+ protected parent: BaseModel;
14
+ protected items: Model | CollectionInterface<Model> | null;
15
+ private unsubscribeQuery;
16
+ constructor(meta: RelationMetaData, facades: AppFacades, parent: BaseModel, items?: Model | CollectionInterface<Model> | null);
17
+ make(data: JsonValue): void;
18
+ guessInverseRelation(): string;
19
+ set(items: Model | CollectionInterface<Model> | null): void;
20
+ getForeignKey(): string | null;
21
+ getName(): string;
22
+ getType(): "HasOne" | "HasMany" | "BelongsTo" | "BelongsToMany" | "MorphOne" | "MorphMany" | "MorphTo" | "MorphToMany" | "MorphedByMany";
23
+ getModel(): string;
24
+ getRelated(): typeof Model;
25
+ query(): Builder<Model, ModelPaginatedResponse>;
26
+ isLoaded(): boolean;
27
+ getLoadedItems(): Model | CollectionInterface<Model> | null;
28
+ isSingle(): boolean;
29
+ isMultiple(): boolean;
30
+ getParent(): BaseModel;
31
+ where(scope: Scope): BuilderInterface;
32
+ where(key: string, value: JsonValue): BuilderInterface;
33
+ where(key: string, operator: ExtendedOperator, value: JsonValue): BuilderInterface;
34
+ whereNull(key: string): Builder<Model, ModelPaginatedResponse>;
35
+ whereNotNull(key: string): Builder<Model, ModelPaginatedResponse>;
36
+ whereBetween(key: string, value: [JsonValue, JsonValue]): Builder<Model, ModelPaginatedResponse>;
37
+ whereNotBetween(key: string, value: [JsonValue, JsonValue]): Builder<Model, ModelPaginatedResponse>;
38
+ orderBy(column: string, direction?: 'asc' | 'desc'): Builder<Model, ModelPaginatedResponse>;
39
+ searchBy(term: string): Builder<Model, ModelPaginatedResponse>;
40
+ minified(): Builder<Model, ModelPaginatedResponse>;
41
+ limit(value: number): Builder<Model, ModelPaginatedResponse>;
42
+ }
43
+ export {};