@luminix/core 0.0.1-beta.14 → 0.0.1-beta.153

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 (102) hide show
  1. package/dist/core.js +1009 -1928
  2. package/package.json +5 -9
  3. package/types/contracts/Builder.d.ts +46 -0
  4. package/types/contracts/ModelCollection.d.ts +7 -0
  5. package/{dist → types}/contracts/Plugin.d.ts +3 -3
  6. package/{dist → types}/contracts/Relation/BelongsTo.d.ts +3 -5
  7. package/{dist → types}/contracts/Relation/BelongsToMany.d.ts +7 -9
  8. package/{dist → types}/contracts/Relation/HasMany.d.ts +6 -7
  9. package/{dist → types}/contracts/Relation/HasOne.d.ts +3 -4
  10. package/{dist → types}/contracts/Relation/HasOneOrMany.d.ts +0 -1
  11. package/{dist → types}/contracts/Relation/MorphMany.d.ts +6 -7
  12. package/{dist → types}/contracts/Relation/MorphOne.d.ts +3 -4
  13. package/{dist → types}/contracts/Relation/MorphOneOrMany.d.ts +0 -1
  14. package/{dist → types}/contracts/Relation/MorphTo.d.ts +0 -1
  15. package/types/contracts/Relation/MorphToMany.d.ts +8 -0
  16. package/{dist → types}/contracts/Relation.d.ts +12 -9
  17. package/types/extensions.d.ts +10 -0
  18. package/types/facades/App.d.ts +8 -0
  19. package/types/facades/Auth.d.ts +7 -0
  20. package/types/facades/Config.d.ts +7 -0
  21. package/types/facades/Error.d.ts +10 -0
  22. package/types/facades/Http.d.ts +8 -0
  23. package/types/facades/Log.d.ts +7 -0
  24. package/types/facades/Model.d.ts +8 -0
  25. package/types/facades/Route.d.ts +8 -0
  26. package/types/helpers/app.d.ts +4 -0
  27. package/{dist → types}/helpers/auth.d.ts +0 -1
  28. package/types/helpers/collect.d.ts +2 -0
  29. package/{dist → types}/helpers/config.d.ts +0 -1
  30. package/{dist → types}/helpers/error.d.ts +0 -1
  31. package/types/helpers/log.d.ts +5 -0
  32. package/{dist → types}/helpers/model.d.ts +2 -3
  33. package/{dist → types}/helpers/route.d.ts +2 -2
  34. package/types/index.d.ts +26 -0
  35. package/types/mixins/BaseModel.d.ts +7 -0
  36. package/types/providers/LuminixServiceProvider.d.ts +8 -0
  37. package/types/services/AuthService.d.ts +18 -0
  38. package/{dist/facades/Error.d.ts → types/services/ErrorService.d.ts} +2 -6
  39. package/types/services/HttpService.d.ts +21 -0
  40. package/{dist/facades/Log.d.ts → types/services/LogService.d.ts} +2 -4
  41. package/types/services/ModelService.d.ts +21 -0
  42. package/types/services/RouteService.d.ts +21 -0
  43. package/{dist → types}/support/model.d.ts +1 -1
  44. package/types/types/App.d.ts +88 -0
  45. package/{dist → types}/types/Auth.d.ts +0 -1
  46. package/types/types/Builder.d.ts +46 -0
  47. package/{dist → types}/types/Config.d.ts +4 -2
  48. package/types/types/Error.d.ts +17 -0
  49. package/types/types/Http.d.ts +20 -0
  50. package/{dist → types}/types/Model.d.ts +36 -30
  51. package/{dist → types}/types/Relation.d.ts +1 -3
  52. package/types/types/Route.d.ts +28 -0
  53. package/{dist → types}/types/Support.d.ts +3 -2
  54. package/.eslintignore +0 -3
  55. package/.eslintrc.cjs +0 -39
  56. package/dist/contracts/Builder.d.ts +0 -53
  57. package/dist/contracts/Collection.d.ts +0 -190
  58. package/dist/contracts/ModelCollection.d.ts +0 -9
  59. package/dist/contracts/PropertyBag.d.ts +0 -21
  60. package/dist/contracts/Relation/MorphToMany.d.ts +0 -16
  61. package/dist/facades/App.d.ts +0 -37
  62. package/dist/facades/Auth.d.ts +0 -14
  63. package/dist/facades/Model.d.ts +0 -41
  64. package/dist/facades/Route.d.ts +0 -32
  65. package/dist/helpers/app.d.ts +0 -5
  66. package/dist/helpers/collect.d.ts +0 -1
  67. package/dist/helpers/log.d.ts +0 -5
  68. package/dist/index.d.ts +0 -24
  69. package/dist/mixins/BaseModel.d.ts +0 -5
  70. package/dist/mixins/HasEvents.d.ts +0 -15
  71. package/dist/mixins/Reducible.d.ts +0 -17
  72. package/dist/support/collection.d.ts +0 -4
  73. package/dist/support/reader.d.ts +0 -2
  74. package/dist/support/searchParams.d.ts +0 -1
  75. package/dist/types/App.d.ts +0 -79
  76. package/dist/types/Builder.d.ts +0 -51
  77. package/dist/types/Collection.d.ts +0 -1804
  78. package/dist/types/Error.d.ts +0 -31
  79. package/dist/types/Event.d.ts +0 -14
  80. package/dist/types/PropertyBag.d.ts +0 -25
  81. package/dist/types/Reducer.d.ts +0 -17
  82. package/dist/types/Route.d.ts +0 -22
  83. package/index.html +0 -13
  84. package/jest.config.js +0 -15
  85. package/tsconfig.json +0 -25
  86. package/vite.config.js +0 -20
  87. /package/{dist → types}/exceptions/AttributeNotFillableException.d.ts +0 -0
  88. /package/{dist → types}/exceptions/FacadeNotFoundException.d.ts +0 -0
  89. /package/{dist → types}/exceptions/MethodNotImplementedException.d.ts +0 -0
  90. /package/{dist → types}/exceptions/ModelInvalidRelatedTypeException.d.ts +0 -0
  91. /package/{dist → types}/exceptions/ModelNotFoundException.d.ts +0 -0
  92. /package/{dist → types}/exceptions/ModelNotPersistedException.d.ts +0 -0
  93. /package/{dist → types}/exceptions/ModelWithoutPrimaryKeyException.d.ts +0 -0
  94. /package/{dist → types}/exceptions/NoEmbedException.d.ts +0 -0
  95. /package/{dist → types}/exceptions/NoInverseRelationException.d.ts +0 -0
  96. /package/{dist → types}/exceptions/NotModelException.d.ts +0 -0
  97. /package/{dist → types}/exceptions/NotReducibleException.d.ts +0 -0
  98. /package/{dist → types}/exceptions/ReducerOverrideException.d.ts +0 -0
  99. /package/{dist → types}/exceptions/RouteNotFoundException.d.ts +0 -0
  100. /package/{dist → types}/exceptions/UnsupportedRelationException.d.ts +0 -0
  101. /package/{dist → types}/types/Log.d.ts +0 -0
  102. /package/{dist → types}/types/Plugin.d.ts +0 -0
@@ -0,0 +1,21 @@
1
+ import { Client, Response } from '@luminix/support';
2
+ import { RouteDefinition, RouteTuple as RouteTuple, HttpMethod, RouteGenerator, RouteReducers } from '../types/Route';
3
+ import { ErrorFacade } from '../types/Error';
4
+ export declare class RouteService {
5
+ protected routes: RouteDefinition;
6
+ protected error: ErrorFacade;
7
+ protected http: () => Client;
8
+ protected appUrl: string;
9
+ constructor(routes: RouteDefinition, error: ErrorFacade, http: () => Client, appUrl?: string);
10
+ private isRouteTuple;
11
+ private extractGenerator;
12
+ get(name: string): RouteTuple;
13
+ url(generator: RouteGenerator): string;
14
+ methods(generator: RouteGenerator): HttpMethod[];
15
+ exists(name: string): boolean;
16
+ call<TResponse = any>(generator: RouteGenerator, tap?: (client: Client) => Client, errorBag?: string): Promise<Response<TResponse>>;
17
+ toString(): string;
18
+ [reducer: string]: unknown;
19
+ }
20
+ declare const _default: import('@luminix/support').ReducibleOf<typeof RouteService, RouteReducers>;
21
+ export default _default;
@@ -1,3 +1,3 @@
1
1
  import { Model } from '../types/Model';
2
-
2
+ /** @deprecated */
3
3
  export declare function isModel(value: unknown): value is Model;
@@ -0,0 +1,88 @@
1
+ import { EventSource, Event, ReducibleInterface, FacadeOf, HasFacadeAccessor, Application, MacroableInterface, Constructor } from '@luminix/support';
2
+ import { AppConfiguration, ConfigFacade } from './Config';
3
+ import { PluginInterface } from './Plugin';
4
+ import { LogFacade } from './Log';
5
+ import { BaseModel, Model, ModelPaginatedResponse, ModelReducers, ModelSchema, ModelSchemaAttributes } from './Model';
6
+ import { RouteFacade } from './Route';
7
+ import { ErrorFacade } from './Error';
8
+ import { RelationInterface } from './Relation';
9
+ import { AuthFacade } from './Auth';
10
+ import { HttpFacade } from './Http';
11
+ type Plugin = PluginInterface<AppFacade, AppContainers>;
12
+ export type GlobalModelEvents = {
13
+ 'save': (e: ModelGlobalEvent) => void;
14
+ 'delete': (e: ModelGlobalEvent) => void;
15
+ 'restore': (e: ModelGlobalEvent) => void;
16
+ 'create': (e: ModelGlobalEvent) => void;
17
+ 'update': (e: ModelGlobalEvent) => void;
18
+ 'fetch': (e: ModelGlobalEvent) => void;
19
+ 'error': (e: ModelGlobalErrorEvent) => void;
20
+ };
21
+ export type ModelGlobalEvent = Event<{
22
+ class: string;
23
+ model: BaseModel;
24
+ force?: boolean;
25
+ }, ModelFacade>;
26
+ export type ModelGlobalErrorEvent = ModelGlobalEvent & {
27
+ error: unknown;
28
+ operation: 'save' | 'delete' | 'restore' | 'forceDelete';
29
+ };
30
+ export type ModelFacade = EventSource<GlobalModelEvents> & ModelReducers & ReducibleInterface<ModelReducers> & {
31
+ schema(): ModelSchema;
32
+ schema(abstract: string): ModelSchemaAttributes;
33
+ make(): Record<string, typeof Model>;
34
+ make(abstract: string): typeof Model;
35
+ boot(app: AppFacade): void;
36
+ getRelationConstructors(abstract: string): Record<string, Constructor<RelationInterface<Model, ModelPaginatedResponse>>>;
37
+ };
38
+ /** @deprecated */
39
+ export type AppEvents = {
40
+ 'init': (e: InitEvent) => void;
41
+ 'booted': (e: Event<{}, AppFacade>) => void;
42
+ 'booting': (e: Event<{}, AppFacade>) => void;
43
+ };
44
+ export type InitEvent = Event<{
45
+ register(plugin: Plugin): void;
46
+ }, AppFacade>;
47
+ /** @deprecated */
48
+ export type AppExternal = {
49
+ boot: (config?: AppConfiguration) => Promise<AppContainers>;
50
+ /** @deprecated */
51
+ make(): AppContainers;
52
+ make<T extends keyof AppContainers>(key: T): AppContainers[T];
53
+ plugins: () => Plugin[];
54
+ on: EventSource<AppEvents>['once'];
55
+ environment(): string;
56
+ environment(...environments: string[]): boolean;
57
+ getPlugin<T extends Plugin>(abstract: Constructor<T>): T | undefined;
58
+ getLocale(): string;
59
+ hasDebugModeEnabled(): boolean;
60
+ isLocal(): boolean;
61
+ isProduction(): boolean;
62
+ setInstance(app: AppFacade): void;
63
+ };
64
+ export type AppFacade = FacadeOf<Application<AppContainers> & AppMacros & MacroableInterface<AppMacros>, HasFacadeAccessor> & {
65
+ down(): void;
66
+ };
67
+ export declare class AppContainers {
68
+ auth: FacadeOf<AuthFacade, HasFacadeAccessor>;
69
+ config: FacadeOf<ConfigFacade, HasFacadeAccessor>;
70
+ error: FacadeOf<ErrorFacade, HasFacadeAccessor>;
71
+ http: FacadeOf<HttpFacade, HasFacadeAccessor>;
72
+ log: FacadeOf<LogFacade, HasFacadeAccessor>;
73
+ model: FacadeOf<ModelFacade, HasFacadeAccessor>;
74
+ route: FacadeOf<RouteFacade, HasFacadeAccessor>;
75
+ [key: string]: any;
76
+ }
77
+ export type BootOptions = {
78
+ config?: AppConfiguration;
79
+ skipBootRequest?: boolean;
80
+ };
81
+ export type AppMacros = {
82
+ environment(...environments: string[]): string | boolean;
83
+ getLocale(): string;
84
+ hasDebugModeEnabled(): boolean;
85
+ isLocal(): boolean;
86
+ isProduction(): boolean;
87
+ };
88
+ export {};
@@ -1,5 +1,4 @@
1
1
  import { Model } from './Model';
2
-
3
2
  export type AuthCredentials = {
4
3
  email: string;
5
4
  password: string;
@@ -0,0 +1,46 @@
1
+ import { EventSource, Collection, PropertyBag, Operator, Event, PropertyBagEventMap, JsonObject, JsonValue } from '@luminix/support';
2
+ export type Scope<TSingle, TMany> = (builder: BuilderInterface<TSingle, TMany>) => BuilderInterface<TSingle, TMany> | void;
3
+ export type ExtendedOperator = Operator | 'like' | 'notLike' | 'between' | 'notBetween' | 'null' | 'notNull';
4
+ export type BuilderInterface<TSingle, TMany = Collection<TSingle>> = EventSource<BuilderEventMap<TSingle, TMany>> & {
5
+ lock(path: string): void;
6
+ where(scope: Scope<TSingle, TMany>): BuilderInterface<TSingle, TMany>;
7
+ where(key: string, value: JsonValue): BuilderInterface<TSingle, TMany>;
8
+ where(key: string, operator: ExtendedOperator, value: JsonValue): BuilderInterface<TSingle, TMany>;
9
+ where(key: string | Scope<TSingle, TMany>, operatorOrValue?: ExtendedOperator | JsonValue, value?: JsonValue): BuilderInterface<TSingle, TMany>;
10
+ with(relation: string | string[]): BuilderInterface<TSingle, TMany>;
11
+ withOnly(relation: string | string[]): BuilderInterface<TSingle, TMany>;
12
+ without(relation: string | string[]): BuilderInterface<TSingle, TMany>;
13
+ whereNull(key: string): BuilderInterface<TSingle, TMany>;
14
+ whereNotNull(key: string): BuilderInterface<TSingle, TMany>;
15
+ whereBetween(key: string, value: [JsonValue, JsonValue]): BuilderInterface<TSingle, TMany>;
16
+ whereNotBetween(key: string, value: [JsonValue, JsonValue]): BuilderInterface<TSingle, TMany>;
17
+ orderBy(column: string, direction?: 'asc' | 'desc'): BuilderInterface<TSingle, TMany>;
18
+ searchBy(term: string): BuilderInterface<TSingle, TMany>;
19
+ minified(): BuilderInterface<TSingle, TMany>;
20
+ limit(value: number): BuilderInterface<TSingle, TMany>;
21
+ include(searchParams: URLSearchParams): BuilderInterface<TSingle, TMany>;
22
+ get(page?: number, replaceLinksWith?: string): Promise<TMany>;
23
+ all(): Promise<Collection<TSingle>>;
24
+ first(): Promise<TSingle | null>;
25
+ find(id: string | number): Promise<TSingle | null>;
26
+ unset(key: string): BuilderInterface<TSingle, TMany>;
27
+ };
28
+ export type BuilderEventMap<TSingle, TMany> = PropertyBagEventMap & {
29
+ 'change': (e: BuilderChangeEvent<TSingle, TMany>) => void;
30
+ 'submit': (e: BuilderSubmitEvent<TSingle, TMany>) => void;
31
+ 'success': (e: BuilderSuccessEvent<TSingle, TMany>) => void;
32
+ 'error': (e: BuilderErrorEvent<TSingle, TMany>) => void;
33
+ };
34
+ export type BuilderChangeEvent<TSingle, TMany> = Event<{
35
+ data: PropertyBag<JsonObject>;
36
+ }, BuilderInterface<TSingle, TMany>>;
37
+ export type BuilderSubmitEvent<TSingle, TMany> = Event<{
38
+ data: PropertyBag<JsonObject>;
39
+ }, BuilderInterface<TSingle, TMany>>;
40
+ export type BuilderErrorEvent<TSingle, TMany> = Event<{
41
+ error: unknown;
42
+ }, BuilderInterface<TSingle, TMany>>;
43
+ export type BuilderSuccessEvent<TSingle, TMany> = Event<{
44
+ response: TMany;
45
+ items: TSingle | Collection<TSingle> | null;
46
+ }, BuilderInterface<TSingle, TMany>>;
@@ -1,13 +1,15 @@
1
- import { PropertyBag } from './PropertyBag';
1
+ import { PropertyBag } from '@luminix/support';
2
2
  import { ModelSchema } from './Model';
3
3
  import { RouteDefinition } from './Route';
4
-
5
4
  export type AppConfiguration = {
6
5
  app?: {
6
+ name?: string;
7
7
  env?: string;
8
8
  debug?: boolean;
9
9
  url?: string;
10
+ port?: string | number;
10
11
  bootUrl?: string | null | false;
12
+ /** @deprecated */
11
13
  enforceCamelCaseForModelAttributes?: boolean;
12
14
  [key: string]: unknown;
13
15
  };
@@ -0,0 +1,17 @@
1
+ import { PropertyBag } from '@luminix/support';
2
+ export type ErrorBag = PropertyBag<Record<string, string>>;
3
+ export type ErrorFacade = {
4
+ add(key: string, value: string, bag?: string): void;
5
+ set(errors: Record<string, string>, bag?: string): void;
6
+ get(key: string, bag?: string): string | null;
7
+ all(bag?: string): Record<string, string>;
8
+ clear(bag?: string): void;
9
+ bag(name?: string): ErrorBag;
10
+ };
11
+ /** @deprecated */
12
+ export type ValidationError = {
13
+ message: string;
14
+ errors: {
15
+ [key: string]: string[];
16
+ };
17
+ };
@@ -0,0 +1,20 @@
1
+ import { Client, MacroableInterface, RequestOptions, Response } from '@luminix/support';
2
+ export type HttpMacro = (...args: any) => Client;
3
+ export type HttpFacade = Record<string, HttpMacro> & MacroableInterface<Record<string, HttpMacro>> & {
4
+ getClient(): Client;
5
+ baseUrl(baseUrl: string): Client;
6
+ asForm(): Client;
7
+ accept(type: string): Client;
8
+ acceptJson(): Client;
9
+ withHeaders(headers: Record<string, string>): Client;
10
+ withOptions(options: RequestOptions): Client;
11
+ withData(data: object): Client;
12
+ withQueryParameters(params: string | object): Client;
13
+ withBasicAuth(username: string, password: string): Client;
14
+ withToken(token: string): Client;
15
+ get<TResponse = any>(url: string, query?: string | object): Promise<Response<TResponse>>;
16
+ post<TResponse = any, TData = any>(url: string, data?: TData): Promise<Response<TResponse>>;
17
+ put<TResponse = any, TData = any>(url: string, data?: TData): Promise<Response<TResponse>>;
18
+ patch<TResponse = any, TData = any>(url: string, data?: TData): Promise<Response<TResponse>>;
19
+ delete<TResponse = any>(url: string, query?: string | object): Promise<Response<TResponse>>;
20
+ };
@@ -1,11 +1,9 @@
1
- import { AxiosResponse } from 'axios';
2
- import { EventSource, Event } from './Event';
3
- import { Collection } from './Collection';
4
- import { RelationInterface, BuilderInterface, Scope, ExtendedOperator } from './Relation';
1
+ import { EventSource, Collection, Response, Event, Constructor } from '@luminix/support';
2
+ import { RelationInterface as RawRelationInterface, BuilderInterface, Scope, ExtendedOperator } from './Relation';
5
3
  import { JsonObject, JsonValue } from './Support';
6
4
  import { RouteGenerator } from './Route';
7
-
8
- export type RelationRepository = Record<string, RelationInterface<Model, ModelPaginatedResponse>>;
5
+ type RelationInterface = RawRelationInterface<Model, ModelPaginatedResponse>;
6
+ export type RelationRepository = Record<string, RelationInterface>;
9
7
  export type ModelEvents = {
10
8
  'change': (e: ModelChangeEvent) => void;
11
9
  'save': (e: ModelSaveEvent) => void;
@@ -15,23 +13,29 @@ export type ModelEvents = {
15
13
  'update': (e: ModelSaveEvent) => void;
16
14
  'error': (e: ModelErrorEvent) => void;
17
15
  };
18
- export type ModelChangeEvent = Event<BaseModel> & {
19
- value: JsonObject;
16
+ export type ModelReducers = {
17
+ model(constructor: typeof BaseModel, abstract: string): typeof BaseModel;
18
+ relationMap(relationMap: Record<string, Constructor<RelationInterface>>, abstract: string): Record<string, Constructor<RelationInterface>>;
19
+ guessInverseRelation(relationMap: Record<string, string[]>, parent: BaseModel, relationType: string, relatedClass: typeof BaseModel): Record<string, string[]>;
20
+ [key: string]: (value: any, ...params: any[]) => any;
20
21
  };
21
- export type ModelSaveEvent = Event<BaseModel> & {
22
+ export type ModelChangeEvent = Event<{
22
23
  value: JsonObject;
23
- };
24
- export type ModelDeleteEvent = Event<BaseModel> & {
24
+ }, BaseModel>;
25
+ export type ModelSaveEvent = Event<{
26
+ value: JsonObject;
27
+ }, BaseModel>;
28
+ export type ModelDeleteEvent = Event<{
25
29
  force: boolean;
26
- };
27
- export type ModelRestoreEvent = Event<BaseModel> & {
30
+ }, BaseModel>;
31
+ export type ModelRestoreEvent = Event<{
28
32
  value: JsonObject;
29
- };
30
- export type ModelErrorEvent = Event<BaseModel> & {
33
+ }, BaseModel>;
34
+ export type ModelErrorEvent = Event<{
31
35
  error: unknown;
32
36
  operation: 'save' | 'delete' | 'restore' | 'forceDelete';
33
- };
34
- export declare class BaseModel implements EventSource<ModelEvents> {
37
+ }, BaseModel>;
38
+ export declare class BaseModel extends EventSource<ModelEvents> {
35
39
  constructor(attributes?: JsonObject);
36
40
  get attributes(): JsonObject;
37
41
  get original(): JsonObject;
@@ -53,19 +57,17 @@ export declare class BaseModel implements EventSource<ModelEvents> {
53
57
  diff(): JsonObject;
54
58
  getType(): string;
55
59
  dump(): void;
56
- save(options?: ModelSaveOptions): Promise<AxiosResponse | void>;
60
+ save(options?: ModelSaveOptions): Promise<Response | void>;
57
61
  update(attributes: JsonObject): Promise<void>;
58
- delete(): Promise<AxiosResponse>;
59
- forceDelete(): Promise<AxiosResponse>;
60
- restore(): Promise<AxiosResponse>;
62
+ delete(): Promise<Response>;
63
+ forceDelete(): Promise<Response>;
64
+ restore(): Promise<Response>;
61
65
  refresh(): Promise<void>;
62
- relation(relationName: string): RelationInterface<Model, ModelPaginatedResponse> | undefined;
66
+ relation(relationName: string): RelationInterface | undefined;
63
67
  getErrorBag(method: string): string;
64
68
  getRouteForSave(): RouteGenerator;
65
69
  getRouteForUpdate(): RouteGenerator;
66
70
  getRouteForDelete(): RouteGenerator;
67
- getRouteForRestore(): RouteGenerator;
68
- getRouteForForceDelete(): RouteGenerator;
69
71
  getRouteForRefresh(): RouteGenerator;
70
72
  static getSchemaName(): string;
71
73
  static getSchema(): ModelSchemaAttributes;
@@ -87,12 +89,12 @@ export declare class BaseModel implements EventSource<ModelEvents> {
87
89
  static limit(value: number): BuilderInterface<Model, ModelPaginatedResponse>;
88
90
  static create(attributes: JsonObject): Promise<Model>;
89
91
  static update(id: number | string, attributes: JsonObject): Promise<Model>;
90
- static delete(id: number | string): Promise<AxiosResponse>;
91
- static delete(ids: Array<number | string>): Promise<AxiosResponse>;
92
- static restore(id: number | string): Promise<AxiosResponse>;
93
- static restore(ids: Array<number | string>): Promise<AxiosResponse>;
94
- static forceDelete(id: number | string): Promise<AxiosResponse>;
95
- static forceDelete(ids: Array<number | string>): Promise<AxiosResponse>;
92
+ static delete(id: number | string): Promise<Response>;
93
+ static delete(ids: Array<number | string>): Promise<Response>;
94
+ static restore(id: number | string): Promise<Response>;
95
+ static restore(ids: Array<number | string>): Promise<Response>;
96
+ static forceDelete(id: number | string): Promise<Response>;
97
+ static forceDelete(ids: Array<number | string>): Promise<Response>;
96
98
  static singular(): string;
97
99
  static plural(): string;
98
100
  on: EventSource<ModelEvents>['on'];
@@ -173,6 +175,9 @@ export type ModelPaginatedLink = {
173
175
  label: string;
174
176
  active: boolean;
175
177
  };
178
+ export type ModelRawPaginatedResponse = Omit<ModelPaginatedResponse, 'data'> & {
179
+ data: JsonObject[];
180
+ };
176
181
  export type ModelPaginatedResponse = {
177
182
  data: Collection<Model>;
178
183
  links: {
@@ -191,3 +196,4 @@ export type ModelPaginatedResponse = {
191
196
  links: Array<ModelPaginatedLink>;
192
197
  };
193
198
  };
199
+ export {};
@@ -1,7 +1,5 @@
1
+ import { Collection, Constructor, JsonValue } from '@luminix/support';
1
2
  import { BuilderInterface, ExtendedOperator, Scope } from './Builder';
2
- import { Collection } from './Collection';
3
- import { Constructor, JsonValue } from './Support';
4
-
5
3
  export type { BuilderInterface, ExtendedOperator, Scope, };
6
4
  export type RelationInterface<R, C> = {
7
5
  guessInverseRelation(): string;
@@ -0,0 +1,28 @@
1
+ import { ReducibleInterface, Response, Client, RequestOptions } from '@luminix/support';
2
+ export type RouteReplacer = {
3
+ [key: string]: string | number;
4
+ };
5
+ export declare class RouteReducers {
6
+ clientOptions(config: RequestOptions, routeName: string): RequestOptions;
7
+ clientError(errors: Record<string, string>, event: {
8
+ response: Response;
9
+ name?: string;
10
+ replace?: RouteReplacer;
11
+ client: Client;
12
+ }): Record<string, string>;
13
+ replaceRouteParams(url: string): string;
14
+ [reducer: string]: (...args: any[]) => any;
15
+ }
16
+ export type RouteFacade = ReducibleInterface<RouteReducers> & {
17
+ get(name: string): RouteTuple;
18
+ url(generator: RouteGenerator): string;
19
+ exists(name: string): boolean;
20
+ call<TResponse = unknown>(generator: RouteGenerator, tap?: (client: Client) => Client, errorBag?: string): Promise<Response<TResponse>>;
21
+ methods(generator: RouteGenerator): HttpMethod[];
22
+ };
23
+ export type RouteGenerator = string | [string, RouteReplacer];
24
+ export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
25
+ export type RouteTuple = [string, ...HttpMethod[]];
26
+ export type RouteDefinition = {
27
+ [routeName: string]: RouteTuple | RouteDefinition;
28
+ };
@@ -1,7 +1,8 @@
1
- export type TypeOf = 'string' | 'number' | 'boolean' | 'object' | 'undefined' | 'function' | 'symbol' | 'bigint';
1
+ /** @deprecated */
2
2
  export type Constructor<T = {}> = new (...args: any[]) => T;
3
- export type Operator = '=' | '!=' | '>' | '<' | '>=' | '<=';
3
+ /** @deprecated */
4
4
  export type JsonObject = {
5
5
  [key: string]: JsonValue;
6
6
  };
7
+ /** @deprecated */
7
8
  export type JsonValue = string | number | boolean | null | JsonObject | Array<string | number | boolean | null | JsonObject>;
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- vite.config.js
2
- dist/
3
- coverage/
package/.eslintrc.cjs DELETED
@@ -1,39 +0,0 @@
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
- };
@@ -1,53 +0,0 @@
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
- with(relation: string | string[]): this;
30
- withOnly(relation: string | string[]): this;
31
- without(relation: string | string[]): this;
32
- orderBy(column: string, direction?: 'asc' | 'desc'): this;
33
- searchBy(term: string): this;
34
- minified(): this;
35
- unset(key: string): this;
36
- include(searchParams: URLSearchParams): this;
37
- private exec;
38
- get(page?: number, replaceLinksWith?: string): Promise<ModelPaginatedResponse>;
39
- first(): Promise<Model | null>;
40
- find(id: string | number): Promise<Model | null>;
41
- all(): Promise<CollectionInterface<Model>>;
42
- }
43
- declare const _default: {
44
- new (...args: any[]): {
45
- emitter: import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
46
- "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
47
- on<E extends "change" | "submit" | "success" | "error">(event: E, callback: BuilderEventMap[E]): Unsubscribe;
48
- once<E_1 extends "change" | "submit" | "success" | "error">(event: E_1, callback: BuilderEventMap[E_1]): void;
49
- emit<E_2 extends "change" | "submit" | "success" | "error">(event: E_2, data?: Omit<Parameters<BuilderEventMap[E_2]>[0], "source">): void;
50
- [Symbol.toStringTag]: string;
51
- };
52
- } & typeof Builder;
53
- export default _default;