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

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 (50) hide show
  1. package/dist/contracts/Builder.d.ts +3 -2
  2. package/dist/contracts/Collection.d.ts +3 -3
  3. package/dist/contracts/ModelCollection.d.ts +1 -0
  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 +1317 -1322
  18. package/dist/facades/App.d.ts +4 -3
  19. package/dist/facades/Auth.d.ts +1 -0
  20. package/dist/facades/Error.d.ts +2 -1
  21. package/dist/facades/Log.d.ts +1 -0
  22. package/dist/facades/Model.d.ts +3 -2
  23. package/dist/facades/Route.d.ts +6 -5
  24. package/dist/helpers/app.d.ts +1 -0
  25. package/dist/helpers/auth.d.ts +3 -1
  26. package/dist/helpers/collect.d.ts +1 -1
  27. package/dist/helpers/config.d.ts +1 -0
  28. package/dist/helpers/error.d.ts +1 -0
  29. package/dist/helpers/log.d.ts +1 -0
  30. package/dist/helpers/model.d.ts +1 -0
  31. package/dist/helpers/route.d.ts +1 -0
  32. package/dist/index.d.ts +11 -10
  33. package/dist/mixins/BaseModel.d.ts +1 -0
  34. package/dist/mixins/HasEvents.d.ts +2 -1
  35. package/dist/mixins/Reducible.d.ts +1 -0
  36. package/dist/support/collection.d.ts +1 -0
  37. package/dist/support/model.d.ts +1 -0
  38. package/dist/types/App.d.ts +1 -0
  39. package/dist/types/Auth.d.ts +1 -0
  40. package/dist/types/Builder.d.ts +3 -1
  41. package/dist/types/Collection.d.ts +1 -0
  42. package/dist/types/Config.d.ts +2 -1
  43. package/dist/types/Error.d.ts +3 -1
  44. package/dist/types/Event.d.ts +1 -0
  45. package/dist/types/Model.d.ts +2 -1
  46. package/dist/types/PropertyBag.d.ts +25 -0
  47. package/dist/types/Reducer.d.ts +1 -0
  48. package/dist/types/Relation.d.ts +1 -0
  49. package/dist/types/Route.d.ts +1 -0
  50. package/package.json +2 -2
@@ -1,7 +1,8 @@
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
+
5
6
  declare class App implements AppFacade {
6
7
  private facades;
7
8
  private booted;
@@ -18,8 +19,8 @@ declare class App implements AppFacade {
18
19
  }
19
20
  declare const _default: {
20
21
  new (...args: any[]): {
21
- "__#1@#emitter": import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
22
- "__#1@#createNanoEvents"(): import("nanoevents").Emitter<import("../types/Event").EventSourceEvents>;
22
+ "__#1@#emitter": import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
23
+ "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
23
24
  on<E extends keyof AppEvents>(event: E, callback: AppEvents[E]): Unsubscribe;
24
25
  once<E_1 extends keyof AppEvents>(event: E_1, callback: AppEvents[E_1]): void;
25
26
  emit<E_2 extends keyof AppEvents>(event: E_2, data?: Omit<Parameters<AppEvents[E_2]>[0], "source">): void;
@@ -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,6 +3,7 @@ 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;
@@ -29,8 +30,8 @@ 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
+ "__#1@#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;
@@ -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
2
  import { AppFacades } from '../types/App';
3
+
3
4
  export declare function BaseModelFactory(facades: AppFacades, abstract: string): typeof BaseModel;
4
5
  export declare function ModelFactory(facades: AppFacades, abstract: string, CustomModel: typeof BaseModel): typeof ModelInterface;
@@ -1,12 +1,13 @@
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
8
  "__#1@#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;
@@ -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,7 @@ import { RouteFacade } from './Route';
7
7
  import { EventSource, Event } from './Event';
8
8
  import { ErrorFacade } from './Error';
9
9
  import { ReducibleInterface } from './Reducer';
10
+
10
11
  type Plugin = PluginInterface<AppFacade, AppFacades>;
11
12
  export type GlobalModelEvents = {
12
13
  'save': (e: ModelGlobalEvent) => void;
@@ -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>> & {
@@ -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,7 @@ 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
+
6
7
  export type RelationRepository = Record<string, RelationInterface<Model, ModelPaginatedResponse>>;
7
8
  export type ModelEvents = {
8
9
  'change': (e: ModelChangeEvent) => void;
@@ -131,7 +132,7 @@ export type ModelQuery = JsonObject & {
131
132
  page?: number;
132
133
  per_page?: number;
133
134
  order_by?: string;
134
- filters?: JsonObject;
135
+ where?: JsonObject;
135
136
  tab?: string;
136
137
  minified?: boolean;
137
138
  };
@@ -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.2",
4
4
  "description": "> Projeto em desenvolvimento",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "ts-jest": "^29.1.2",
29
29
  "typescript": "^5.3.3",
30
30
  "vite": "^5.0.12",
31
- "vite-plugin-dts": "^3.7.2"
31
+ "vite-plugin-dts": "^4.0.0-beta.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "axios": "^1.6.4",