@luminix/core 0.0.1-beta.0 → 0.0.1-beta.10

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 (66) hide show
  1. package/dist/contracts/Builder.d.ts +7 -3
  2. package/dist/contracts/Collection.d.ts +3 -4
  3. package/dist/contracts/ModelCollection.d.ts +2 -1
  4. package/dist/contracts/Plugin.d.ts +1 -0
  5. package/dist/contracts/PropertyBag.d.ts +4 -11
  6. package/dist/contracts/Relation/BelongsTo.d.ts +2 -1
  7. package/dist/contracts/Relation/BelongsToMany.d.ts +3 -2
  8. package/dist/contracts/Relation/HasMany.d.ts +3 -2
  9. package/dist/contracts/Relation/HasOne.d.ts +2 -1
  10. package/dist/contracts/Relation/HasOneOrMany.d.ts +2 -1
  11. package/dist/contracts/Relation/MorphMany.d.ts +3 -2
  12. package/dist/contracts/Relation/MorphOne.d.ts +2 -1
  13. package/dist/contracts/Relation/MorphOneOrMany.d.ts +2 -1
  14. package/dist/contracts/Relation/MorphTo.d.ts +2 -1
  15. package/dist/contracts/Relation/MorphToMany.d.ts +2 -1
  16. package/dist/contracts/Relation.d.ts +1 -0
  17. package/dist/core.js +1531 -1460
  18. package/dist/exceptions/AttributeNotFillableException.d.ts +1 -1
  19. package/dist/exceptions/FacadeNotFoundException.d.ts +1 -1
  20. package/dist/exceptions/MethodNotImplementedException.d.ts +1 -1
  21. package/dist/exceptions/ModelInvalidRelatedTypeException.d.ts +1 -1
  22. package/dist/exceptions/ModelNotFoundException.d.ts +1 -1
  23. package/dist/exceptions/ModelNotPersistedException.d.ts +1 -1
  24. package/dist/exceptions/ModelWithoutPrimaryKeyException.d.ts +1 -1
  25. package/dist/exceptions/NoEmbedException.d.ts +1 -1
  26. package/dist/exceptions/NoInverseRelationException.d.ts +1 -1
  27. package/dist/exceptions/NotModelException.d.ts +1 -1
  28. package/dist/exceptions/NotReducibleException.d.ts +1 -1
  29. package/dist/exceptions/ReducerOverrideException.d.ts +1 -1
  30. package/dist/exceptions/RouteNotFoundException.d.ts +1 -1
  31. package/dist/exceptions/UnsupportedRelationException.d.ts +1 -1
  32. package/dist/facades/App.d.ts +11 -4
  33. package/dist/facades/Auth.d.ts +1 -0
  34. package/dist/facades/Error.d.ts +2 -1
  35. package/dist/facades/Log.d.ts +1 -0
  36. package/dist/facades/Model.d.ts +4 -4
  37. package/dist/facades/Route.d.ts +6 -5
  38. package/dist/helpers/app.d.ts +1 -0
  39. package/dist/helpers/auth.d.ts +3 -1
  40. package/dist/helpers/collect.d.ts +1 -1
  41. package/dist/helpers/config.d.ts +1 -0
  42. package/dist/helpers/error.d.ts +1 -0
  43. package/dist/helpers/log.d.ts +1 -0
  44. package/dist/helpers/model.d.ts +1 -0
  45. package/dist/helpers/route.d.ts +1 -0
  46. package/dist/index.d.ts +11 -10
  47. package/dist/mixins/BaseModel.d.ts +3 -2
  48. package/dist/mixins/HasEvents.d.ts +3 -3
  49. package/dist/mixins/Reducible.d.ts +1 -0
  50. package/dist/support/collection.d.ts +1 -0
  51. package/dist/support/model.d.ts +1 -0
  52. package/dist/types/App.d.ts +8 -0
  53. package/dist/types/Auth.d.ts +1 -0
  54. package/dist/types/Builder.d.ts +7 -1
  55. package/dist/types/Collection.d.ts +1 -0
  56. package/dist/types/Config.d.ts +2 -1
  57. package/dist/types/Error.d.ts +3 -1
  58. package/dist/types/Event.d.ts +1 -0
  59. package/dist/types/Model.d.ts +32 -7
  60. package/dist/types/PropertyBag.d.ts +25 -0
  61. package/dist/types/Reducer.d.ts +1 -0
  62. package/dist/types/Relation.d.ts +1 -0
  63. package/dist/types/Route.d.ts +1 -0
  64. package/package.json +4 -3
  65. package/vite.config.js +3 -1
  66. package/graph.png +0 -0
@@ -1,4 +1,4 @@
1
1
  export default class AttributeNotFillableException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(abstract: string, attribute: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class FacadeNotFoundException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(name: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class MethodNotImplementedException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor();
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class ModelInvalidRelatedTypeException extends TypeError {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(caller: string, expectedType: string, relatedType: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class ModelNotFoundException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(model: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class ModelNotPersistedException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(model: string, operation: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class ModelWithoutPrimaryKeyException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(model: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class NoEmbedException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor();
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class NoInverseRelationException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(model: string, relation: string, related: string, relatedRelation: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class NotModelException extends TypeError {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(caller: string, expects?: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class NotReducibleException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(facade: unknown);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class ReducerOverrideException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(name: string, target: unknown);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class RouteNotFoundException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(route: string);
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export default class UnsupportedRelationException extends Error {
2
- static name: string;
2
+ [Symbol.toStringTag]: string;
3
3
  constructor(relation: string);
4
4
  }
@@ -1,7 +1,9 @@
1
1
  import { AppFacades, AppFacade, AppEvents } from '../types/App';
2
- import Plugin from '../contracts/Plugin';
2
+ import { default as Plugin } from '../contracts/Plugin';
3
3
  import { AppConfiguration } from '../types/Config';
4
4
  import { Unsubscribe } from 'nanoevents';
5
+ import { Constructor } from '../types/Support';
6
+
5
7
  declare class App implements AppFacade {
6
8
  private facades;
7
9
  private booted;
@@ -12,19 +14,24 @@ declare class App implements AppFacade {
12
14
  bind<K extends keyof AppFacades>(key: K, facade: AppFacades[K]): void;
13
15
  plugins(): Plugin[];
14
16
  boot(configObject?: AppConfiguration): Promise<AppFacades>;
17
+ environment(): string;
18
+ environment(...environments: string[]): boolean;
19
+ getPlugin<T extends Plugin>(abstract: Constructor<T>): T | undefined;
20
+ hasDebugModeEnabled(): boolean;
21
+ isLocal(): boolean;
22
+ isProduction(): boolean;
15
23
  on<E extends keyof AppEvents>(_: E, __: AppEvents[E]): Unsubscribe;
16
24
  once<E extends keyof AppEvents>(_: E, __: AppEvents[E]): void;
17
25
  emit<E extends keyof AppEvents>(_: E, __?: Omit<Parameters<AppEvents[E]>[0], 'source'>): void;
18
26
  }
19
27
  declare const _default: {
20
28
  new (...args: any[]): {
21
- "__#1@#emitter": import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
22
- "__#1@#createNanoEvents"(): import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
29
+ emitter: import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
30
+ "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
23
31
  on<E extends keyof AppEvents>(event: E, callback: AppEvents[E]): Unsubscribe;
24
32
  once<E_1 extends keyof AppEvents>(event: E_1, callback: AppEvents[E_1]): void;
25
33
  emit<E_2 extends keyof AppEvents>(event: E_2, data?: Omit<Parameters<AppEvents[E_2]>[0], "source">): void;
26
34
  [Symbol.toStringTag]: string;
27
35
  };
28
- name: string;
29
36
  } & typeof App;
30
37
  export default _default;
@@ -1,6 +1,7 @@
1
1
  import { AppFacade } from '../types/App';
2
2
  import { AuthCredentials, AuthFacade } from '../types/Auth';
3
3
  import { Model } from '../types/Model';
4
+
4
5
  export default class Auth implements AuthFacade {
5
6
  private readonly app;
6
7
  private _user;
@@ -1,5 +1,6 @@
1
- import PropertyBag from '../contracts/PropertyBag';
1
+ import { default as PropertyBag } from '../contracts/PropertyBag';
2
2
  import { ErrorFacade, ValidationError } from '../types/Error';
3
+
3
4
  export declare const isValidationError: (error: unknown) => error is ValidationError;
4
5
  declare class Error implements ErrorFacade {
5
6
  private bags;
@@ -1,4 +1,5 @@
1
1
  import { LogFacade } from '../types/Log';
2
+
2
3
  export default class Log implements LogFacade {
3
4
  private _debug;
4
5
  constructor(_debug: boolean);
@@ -3,10 +3,11 @@ import { AppFacade, GlobalModelEvents, ModelFacade as ModelFacadeInterface } fro
3
3
  import { Unsubscribe } from 'nanoevents';
4
4
  import { Reducer, ReducerCallback, Unsubscribe as UnsubscribeReducer } from '../types/Reducer';
5
5
  import { Collection } from '../contracts/Collection';
6
+
6
7
  declare class ModelFacade implements ModelFacadeInterface {
7
8
  private readonly _schema;
8
9
  private _models;
9
- static name: string;
10
+ [Symbol.toStringTag]: string;
10
11
  constructor(_schema: ModelSchema);
11
12
  boot(app: AppFacade): void;
12
13
  schema(): ModelSchema;
@@ -29,13 +30,12 @@ declare class ModelFacade implements ModelFacadeInterface {
29
30
  }
30
31
  declare const _default: {
31
32
  new (...args: any[]): {
32
- "__#1@#emitter": import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
33
- "__#1@#createNanoEvents"(): import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
33
+ emitter: import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
34
+ "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
34
35
  on<E extends keyof GlobalModelEvents>(event: E, callback: GlobalModelEvents[E]): Unsubscribe;
35
36
  once<E_1 extends keyof GlobalModelEvents>(event: E_1, callback: GlobalModelEvents[E_1]): void;
36
37
  emit<E_2 extends keyof GlobalModelEvents>(event: E_2, data?: Omit<Parameters<GlobalModelEvents[E_2]>[0], "source">): void;
37
38
  [Symbol.toStringTag]: string;
38
39
  };
39
- name: string;
40
40
  } & typeof ModelFacade;
41
41
  export default _default;
@@ -1,5 +1,6 @@
1
1
  import { RouteDefinition, RouteTuple as RouteTuple, HttpMethod, RouteGenerator, RouteCallConfig } from '../types/Route';
2
2
  import { ErrorFacade } from '../types/Error';
3
+
3
4
  declare class Route {
4
5
  private routes;
5
6
  private error;
@@ -11,18 +12,18 @@ declare class Route {
11
12
  url(generator: RouteGenerator): string;
12
13
  methods(generator: RouteGenerator): HttpMethod[];
13
14
  exists(name: string): boolean;
14
- call(generator: RouteGenerator, config?: RouteCallConfig): Promise<import("axios").AxiosResponse<any, any>>;
15
+ call(generator: RouteGenerator, config?: RouteCallConfig): Promise<import('axios').AxiosResponse<any, any>>;
15
16
  toString(): string;
16
17
  [reducer: string]: unknown;
17
18
  }
18
19
  declare const _default: {
19
20
  new (...args: any[]): {
20
21
  reducers: {
21
- [name: string]: import("../types/Collection").Collection<import("../types/Reducer").Reducer>;
22
+ [name: string]: import('../types/Collection').Collection<import('../types/Reducer').Reducer>;
22
23
  };
23
- reducer(name: string, callback: import("../types/Reducer").ReducerCallback, priority?: number): () => void;
24
- removeReducer(name: string, callback: import("../types/Reducer").ReducerCallback): void;
25
- getReducer(name: string): import("../types/Collection").Collection<import("../types/Reducer").Reducer>;
24
+ reducer(name: string, callback: import('../types/Reducer').ReducerCallback, priority?: number): () => void;
25
+ removeReducer(name: string, callback: import('../types/Reducer').ReducerCallback): void;
26
+ getReducer(name: string): import('../types/Collection').Collection<import('../types/Reducer').Reducer>;
26
27
  hasReducer(name: string): boolean;
27
28
  clearReducer(name: string): void;
28
29
  flushReducers(): void;
@@ -1,4 +1,5 @@
1
1
  import { AppExternal, AppFacades } from '../types/App';
2
+
2
3
  declare function app(): AppExternal;
3
4
  declare function app<T extends keyof AppFacades>(facade: T): AppFacades[T];
4
5
  export default app;
@@ -1 +1,3 @@
1
- export default function (): import("..").AuthFacade;
1
+ import { AuthFacade } from '../types/Auth';
2
+
3
+ export default function (): AuthFacade;
@@ -1 +1 @@
1
- export default function collect<T = unknown>(items: T[]): import("../types/Collection").Collection<T>;
1
+ export default function collect<T = unknown>(items: T[]): import('../types/Collection').Collection<T>;
@@ -1,4 +1,5 @@
1
1
  import { ConfigFacade } from '../types/Config';
2
+
2
3
  declare function config(): ConfigFacade;
3
4
  declare function config(path: string, defaultValue?: unknown): unknown;
4
5
  export default config;
@@ -1,3 +1,4 @@
1
1
  import { ErrorFacade } from '../types/Error';
2
+
2
3
  export default function error(): ErrorFacade;
3
4
  export default function error(key: string, bag?: string): string | null;
@@ -1,4 +1,5 @@
1
1
  import { LogFacade } from '../types/Log';
2
+
2
3
  declare function log(): LogFacade;
3
4
  declare function log(...data: any[]): void;
4
5
  export default log;
@@ -1,5 +1,6 @@
1
1
  import { Model } from '../types/Model';
2
2
  import { ModelFacade } from '../types/App';
3
+
3
4
  declare function model(): ModelFacade;
4
5
  declare function model(abstract: string): typeof Model;
5
6
  export default model;
@@ -1,4 +1,5 @@
1
1
  import { RouteFacade, RouteReplacer } from '../types/Route';
2
+
2
3
  declare function route(): RouteFacade;
3
4
  declare function route(name: string, parameters?: RouteReplacer): string;
4
5
  export default route;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,19 @@
1
- import app from './helpers/app';
2
- import auth from './helpers/auth';
3
- import collect from './helpers/collect';
4
- import config from './helpers/config';
5
- import error from './helpers/error';
6
- import log from './helpers/log';
7
- import model from './helpers/model';
8
- import route from './helpers/route';
1
+ import { default as app } from './helpers/app';
2
+ import { default as auth } from './helpers/auth';
3
+ import { default as collect } from './helpers/collect';
4
+ import { default as config } from './helpers/config';
5
+ import { default as error } from './helpers/error';
6
+ import { default as log } from './helpers/log';
7
+ import { default as model } from './helpers/model';
8
+ import { default as route } from './helpers/route';
9
9
  import { isValidationError } from './facades/Error';
10
- import Plugin from './contracts/Plugin';
11
- import PropertyBag from './contracts/PropertyBag';
10
+ import { default as Plugin } from './contracts/Plugin';
11
+ import { default as PropertyBag } from './contracts/PropertyBag';
12
12
  import { isModel } from './support/model';
13
13
  import { isCollection } from './support/collection';
14
14
  import { Reducible } from './mixins/Reducible';
15
15
  import { HasEvents } from './mixins/HasEvents';
16
+
16
17
  export { app, auth, collect, config, error, log, model, route, isCollection, isValidationError, isModel, Plugin, PropertyBag, Reducible, HasEvents, };
17
18
  export type { AppFacade } from './types/App';
18
19
  export type { AuthFacade } from './types/Auth';
@@ -1,4 +1,5 @@
1
1
  import { BaseModel, Model as ModelInterface } from '../types/Model';
2
- import { AppFacades } from '../types/App';
3
- export declare function BaseModelFactory(facades: AppFacades, abstract: string): typeof BaseModel;
2
+ import { AppFacade, AppFacades } from '../types/App';
3
+
4
+ export declare function BaseModelFactory(app: AppFacade, abstract: string): typeof BaseModel;
4
5
  export declare function ModelFactory(facades: AppFacades, abstract: string, CustomModel: typeof BaseModel): typeof ModelInterface;
@@ -1,15 +1,15 @@
1
1
  import { Emitter } from 'nanoevents';
2
2
  import { EventSourceEvents, EventSource } from '../types/Event';
3
3
  import { Constructor } from '../types/Support';
4
+
4
5
  export declare function isEventSource<T>(value: T): value is T & EventSource<any>;
5
6
  export declare function HasEvents<T extends EventSourceEvents, U extends Constructor>(Base: U): {
6
7
  new (...args: any[]): {
7
- "__#1@#emitter": Emitter<EventSourceEvents>;
8
+ emitter: Emitter<EventSourceEvents>;
8
9
  "__#1@#createNanoEvents"(): Emitter<EventSourceEvents>;
9
- on<E extends keyof T>(event: E, callback: T[E]): import("nanoevents").Unsubscribe;
10
+ on<E extends keyof T>(event: E, callback: T[E]): import('nanoevents').Unsubscribe;
10
11
  once<E_1 extends keyof T>(event: E_1, callback: T[E_1]): void;
11
12
  emit<E_2 extends keyof T>(event: E_2, data?: Omit<Parameters<T[E_2]>[0], "source">): void;
12
13
  [Symbol.toStringTag]: string;
13
14
  };
14
- name: string;
15
15
  } & U;
@@ -1,6 +1,7 @@
1
1
  import { ReducerCallback, Reducer } from '../types/Reducer';
2
2
  import { Constructor } from '../types/Support';
3
3
  import { Collection } from '../types/Collection';
4
+
4
5
  export declare function Reducible<T extends Constructor>(Base: T): {
5
6
  new (...args: any[]): {
6
7
  reducers: {
@@ -1,3 +1,4 @@
1
1
  import { Collection } from '../types/Collection';
2
+
2
3
  export declare function cartesian<T>(...arrays: T[][]): T[][];
3
4
  export declare function isCollection(instance: unknown): instance is Collection;
@@ -1,2 +1,3 @@
1
1
  import { Model } from '../types/Model';
2
+
2
3
  export declare function isModel(value: unknown): value is Model;
@@ -7,6 +7,8 @@ import { RouteFacade } from './Route';
7
7
  import { EventSource, Event } from './Event';
8
8
  import { ErrorFacade } from './Error';
9
9
  import { ReducibleInterface } from './Reducer';
10
+ import { Constructor } from './Support';
11
+
10
12
  type Plugin = PluginInterface<AppFacade, AppFacades>;
11
13
  export type GlobalModelEvents = {
12
14
  'save': (e: ModelGlobalEvent) => void;
@@ -47,6 +49,12 @@ export type AppExternal = {
47
49
  make<T extends keyof AppFacades>(key: T): AppFacades[T];
48
50
  plugins: () => Plugin[];
49
51
  on: EventSource<AppEvents>['once'];
52
+ environment(): string;
53
+ environment(...environments: string[]): boolean;
54
+ getPlugin<T extends Plugin>(abstract: Constructor<T>): T | undefined;
55
+ hasDebugModeEnabled(): boolean;
56
+ isLocal(): boolean;
57
+ isProduction(): boolean;
50
58
  };
51
59
  export type AppFacade = AppExternal & {
52
60
  has(key: string): boolean;
@@ -1,4 +1,5 @@
1
1
  import { Model } from './Model';
2
+
2
3
  export type AuthCredentials = {
3
4
  email: string;
4
5
  password: string;
@@ -1,7 +1,9 @@
1
- import PropertyBag, { PropertyBagEventMap } from '../contracts/PropertyBag';
1
+ import { default as PropertyBag } from '../contracts/PropertyBag';
2
2
  import { Event, EventSource } from './Event';
3
3
  import { JsonObject, JsonValue } from './Support';
4
4
  import { Operator, Collection } from './Collection';
5
+ import { PropertyBagEventMap } from './PropertyBag';
6
+
5
7
  export type Scope<R, C> = (builder: BuilderInterface<R, C>) => BuilderInterface<R, C> | void;
6
8
  export type ExtendedOperator = Operator | 'like' | 'notLike' | 'between' | 'notBetween' | 'isNull' | 'isNotNull';
7
9
  export type BuilderInterface<R, C> = EventSource<BuilderEventMap<R, C>> & {
@@ -10,6 +12,9 @@ export type BuilderInterface<R, C> = EventSource<BuilderEventMap<R, C>> & {
10
12
  where(key: string, value: JsonValue): BuilderInterface<R, C>;
11
13
  where(key: string, operator: ExtendedOperator, value: JsonValue): BuilderInterface<R, C>;
12
14
  where(key: string | Scope<R, C>, operatorOrValue?: ExtendedOperator | JsonValue, value?: JsonValue): BuilderInterface<R, C>;
15
+ with(relation: string | string[]): BuilderInterface<R, C>;
16
+ withOnly(relation: string | string[]): BuilderInterface<R, C>;
17
+ without(relation: string | string[]): BuilderInterface<R, C>;
13
18
  whereNull(key: string): BuilderInterface<R, C>;
14
19
  whereNotNull(key: string): BuilderInterface<R, C>;
15
20
  whereBetween(key: string, value: [JsonValue, JsonValue]): BuilderInterface<R, C>;
@@ -18,6 +23,7 @@ export type BuilderInterface<R, C> = EventSource<BuilderEventMap<R, C>> & {
18
23
  searchBy(term: string): BuilderInterface<R, C>;
19
24
  minified(): BuilderInterface<R, C>;
20
25
  limit(value: number): BuilderInterface<R, C>;
26
+ include(searchParams: URLSearchParams): BuilderInterface<R, C>;
21
27
  get(page?: number, replaceLinksWith?: string): Promise<C>;
22
28
  all(): Promise<Collection<R>>;
23
29
  first(): Promise<R | null>;
@@ -1,5 +1,6 @@
1
1
  import { Event, EventSource } from './Event';
2
2
  import { Constructor, TypeOf, JsonValue } from './Support';
3
+
3
4
  export type CollectionEvents<T = unknown> = {
4
5
  'change': (e: CollectionChangeEvent<T>) => void;
5
6
  };
@@ -1,6 +1,7 @@
1
- import { PropertyBag } from '..';
1
+ import { PropertyBag } from './PropertyBag';
2
2
  import { ModelSchema } from './Model';
3
3
  import { RouteDefinition } from './Route';
4
+
4
5
  export type AppConfiguration = {
5
6
  app?: {
6
7
  env?: string;
@@ -1,5 +1,7 @@
1
- import PropertyBag, { PropertyBagEventMap } from '../contracts/PropertyBag';
1
+ import { default as PropertyBag } from '../contracts/PropertyBag';
2
2
  import { Event, EventSource } from './Event';
3
+ import { PropertyBagEventMap } from './PropertyBag';
4
+
3
5
  export type ErrorEventMap = {
4
6
  change: (e: ErrorChangeEvent) => void;
5
7
  };
@@ -1,4 +1,5 @@
1
1
  import { Unsubscribe } from 'nanoevents';
2
+
2
3
  export type Event<S = any> = {
3
4
  source: S;
4
5
  };
@@ -3,6 +3,8 @@ import { EventSource, Event } from './Event';
3
3
  import { Collection } from './Collection';
4
4
  import { RelationInterface, BuilderInterface, Scope, ExtendedOperator } from './Relation';
5
5
  import { JsonObject, JsonValue } from './Support';
6
+ import { RouteGenerator } from './Route';
7
+
6
8
  export type RelationRepository = Record<string, RelationInterface<Model, ModelPaginatedResponse>>;
7
9
  export type ModelEvents = {
8
10
  'change': (e: ModelChangeEvent) => void;
@@ -44,18 +46,25 @@ export declare class BaseModel implements EventSource<ModelEvents> {
44
46
  setAttribute(key: string, value: unknown): void;
45
47
  getKey(): string | number;
46
48
  getKeyName(): string;
47
- fill(attributes: JsonObject): void;
49
+ fill(attributes: object): void;
48
50
  toJson(): JsonObject;
49
51
  diff(): JsonObject;
50
52
  getType(): string;
51
53
  dump(): void;
52
- save(options?: ModelSaveOptions): Promise<AxiosResponse<unknown, unknown>>;
54
+ save(options?: ModelSaveOptions): Promise<AxiosResponse | void>;
53
55
  update(attributes: JsonObject): Promise<void>;
54
- delete(): Promise<AxiosResponse<unknown, unknown>>;
55
- forceDelete(): Promise<AxiosResponse<unknown, unknown>>;
56
- restore(): Promise<AxiosResponse<unknown, unknown>>;
56
+ delete(): Promise<AxiosResponse>;
57
+ forceDelete(): Promise<AxiosResponse>;
58
+ restore(): Promise<AxiosResponse>;
57
59
  refresh(): Promise<void>;
58
60
  relation(relationName: string): RelationInterface<Model, ModelPaginatedResponse> | undefined;
61
+ getErrorBag(method: string): string;
62
+ getRouteForSave(): RouteGenerator;
63
+ getRouteForUpdate(): RouteGenerator;
64
+ getRouteForDelete(): RouteGenerator;
65
+ getRouteForRestore(): RouteGenerator;
66
+ getRouteForForceDelete(): RouteGenerator;
67
+ getRouteForRefresh(): RouteGenerator;
59
68
  static getSchemaName(): string;
60
69
  static getSchema(): ModelSchemaAttributes;
61
70
  static query(): BuilderInterface<Model, ModelPaginatedResponse>;
@@ -90,7 +99,7 @@ export declare class BaseModel implements EventSource<ModelEvents> {
90
99
  }
91
100
  export declare class Model extends BaseModel {
92
101
  [key: string]: any;
93
- static [key: string]: any;
102
+ [Symbol.toStringTag]: string;
94
103
  }
95
104
  export interface ModelSaveOptions {
96
105
  additionalPayload?: object;
@@ -106,6 +115,21 @@ export interface ModelTableColumnDefinition {
106
115
  sortable?: boolean;
107
116
  }
108
117
  export interface ModelSchemaAttributes {
118
+ attributes: {
119
+ appended: true | null;
120
+ cast: string | null;
121
+ default: string | null;
122
+ fillable: boolean;
123
+ hidden: boolean;
124
+ increments: boolean;
125
+ name: string;
126
+ nullable: boolean;
127
+ phpType: string | null;
128
+ primary: boolean;
129
+ type: string | null;
130
+ unique: boolean;
131
+ virtual: boolean;
132
+ }[];
109
133
  displayName: {
110
134
  singular: string;
111
135
  plural: string;
@@ -116,6 +140,7 @@ export interface ModelSchemaAttributes {
116
140
  primaryKey: string;
117
141
  timestamps: boolean;
118
142
  labeledBy: string;
143
+ [key: string]: any;
119
144
  }
120
145
  export interface RelationMetaData {
121
146
  model: string;
@@ -131,7 +156,7 @@ export type ModelQuery = JsonObject & {
131
156
  page?: number;
132
157
  per_page?: number;
133
158
  order_by?: string;
134
- filters?: JsonObject;
159
+ where?: JsonObject;
135
160
  tab?: string;
136
161
  minified?: boolean;
137
162
  };
@@ -0,0 +1,25 @@
1
+ import { Unsubscribe } from 'nanoevents';
2
+ import { Event } from './Event';
3
+
4
+ export type PropertyBagChangeEvent<T extends object> = Event<PropertyBag<T>> & {
5
+ path: string;
6
+ value: unknown;
7
+ type: 'set' | 'merge' | 'delete';
8
+ };
9
+ export type PropertyBagEventMap<T extends object = any> = {
10
+ 'change': (e: PropertyBagChangeEvent<T>) => void;
11
+ };
12
+ export type PropertyBag<T extends object> = {
13
+ get(path: string, defaultValue?: unknown): unknown;
14
+ set(path: string, value: unknown): void;
15
+ merge(path: string, value: unknown): void;
16
+ has(path: string): boolean;
17
+ delete(path: string): void;
18
+ lock(path: string): void;
19
+ clone(): PropertyBag<T>;
20
+ all(): T;
21
+ isEmpty(): boolean;
22
+ on<K extends keyof PropertyBagEventMap<T>>(event: K, callback: PropertyBagEventMap<T>[K]): Unsubscribe;
23
+ once<K extends keyof PropertyBagEventMap<T>>(event: K, callback: PropertyBagEventMap<T>[K]): void;
24
+ emit<K extends keyof PropertyBagEventMap<T>>(event: K, payload: Omit<Parameters<PropertyBagEventMap<T>[K]>[0], 'source'>): void;
25
+ };
@@ -1,4 +1,5 @@
1
1
  import { Collection } from './Collection';
2
+
2
3
  export type ReducerCallback = (value: any, ...params: any[]) => any;
3
4
  export interface Reducer {
4
5
  callback: ReducerCallback;
@@ -1,6 +1,7 @@
1
1
  import { BuilderInterface, ExtendedOperator, Scope } from './Builder';
2
2
  import { Collection } from './Collection';
3
3
  import { Constructor, JsonValue } from './Support';
4
+
4
5
  export type { BuilderInterface, ExtendedOperator, Scope, };
5
6
  export type RelationInterface<R, C> = {
6
7
  guessInverseRelation(): string;
@@ -1,5 +1,6 @@
1
1
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
2
  import { ReducibleInterface } from './Reducer';
3
+
3
4
  export type RouteReplacer = {
4
5
  [key: string]: string | number;
5
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminix/core",
3
- "version": "0.0.1-beta.0",
3
+ "version": "0.0.1-beta.10",
4
4
  "description": "> Projeto em desenvolvimento",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,8 @@
11
11
  "lint:fix": "eslint ./src ./tests --ext .ts --fix",
12
12
  "test": "jest",
13
13
  "test:coverage": "jest --coverage",
14
- "ci": "npm run lint && npm run test"
14
+ "ci": "npm run lint && npm run test",
15
+ "publish:beta": "npm run build && npm publish --tag beta"
15
16
  },
16
17
  "author": "",
17
18
  "license": "MIT",
@@ -28,7 +29,7 @@
28
29
  "ts-jest": "^29.1.2",
29
30
  "typescript": "^5.3.3",
30
31
  "vite": "^5.0.12",
31
- "vite-plugin-dts": "^3.7.2"
32
+ "vite-plugin-dts": "^4.0.0-beta.1"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "axios": "^1.6.4",