@luminix/core 0.0.1-beta.1 → 0.0.1-beta.11

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.
@@ -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
  }
@@ -2,6 +2,7 @@ import { AppFacades, AppFacade, AppEvents } from '../types/App';
2
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';
5
6
 
6
7
  declare class App implements AppFacade {
7
8
  private facades;
@@ -13,19 +14,24 @@ declare class App implements AppFacade {
13
14
  bind<K extends keyof AppFacades>(key: K, facade: AppFacades[K]): void;
14
15
  plugins(): Plugin[];
15
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;
16
23
  on<E extends keyof AppEvents>(_: E, __: AppEvents[E]): Unsubscribe;
17
24
  once<E extends keyof AppEvents>(_: E, __: AppEvents[E]): void;
18
25
  emit<E extends keyof AppEvents>(_: E, __?: Omit<Parameters<AppEvents[E]>[0], 'source'>): void;
19
26
  }
20
27
  declare const _default: {
21
28
  new (...args: any[]): {
22
- "__#1@#emitter": import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
29
+ emitter: import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
23
30
  "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
24
31
  on<E extends keyof AppEvents>(event: E, callback: AppEvents[E]): Unsubscribe;
25
32
  once<E_1 extends keyof AppEvents>(event: E_1, callback: AppEvents[E_1]): void;
26
33
  emit<E_2 extends keyof AppEvents>(event: E_2, data?: Omit<Parameters<AppEvents[E_2]>[0], "source">): void;
27
34
  [Symbol.toStringTag]: string;
28
35
  };
29
- name: string;
30
36
  } & typeof App;
31
37
  export default _default;
@@ -7,7 +7,7 @@ import { Collection } from '../contracts/Collection';
7
7
  declare class ModelFacade implements ModelFacadeInterface {
8
8
  private readonly _schema;
9
9
  private _models;
10
- static name: string;
10
+ [Symbol.toStringTag]: string;
11
11
  constructor(_schema: ModelSchema);
12
12
  boot(app: AppFacade): void;
13
13
  schema(): ModelSchema;
@@ -30,13 +30,12 @@ declare class ModelFacade implements ModelFacadeInterface {
30
30
  }
31
31
  declare const _default: {
32
32
  new (...args: any[]): {
33
- "__#1@#emitter": import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
33
+ emitter: import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
34
34
  "__#1@#createNanoEvents"(): import('nanoevents').Emitter<import('../types/Event').EventSourceEvents>;
35
35
  on<E extends keyof GlobalModelEvents>(event: E, callback: GlobalModelEvents[E]): Unsubscribe;
36
36
  once<E_1 extends keyof GlobalModelEvents>(event: E_1, callback: GlobalModelEvents[E_1]): void;
37
37
  emit<E_2 extends keyof GlobalModelEvents>(event: E_2, data?: Omit<Parameters<GlobalModelEvents[E_2]>[0], "source">): void;
38
38
  [Symbol.toStringTag]: string;
39
39
  };
40
- name: string;
41
40
  } & typeof ModelFacade;
42
41
  export default _default;
@@ -1 +1,3 @@
1
- export default function (): import('..').AuthFacade;
1
+ import { AuthFacade } from '../types/Auth';
2
+
3
+ export default function (): AuthFacade;
@@ -1,5 +1,5 @@
1
1
  import { BaseModel, Model as ModelInterface } from '../types/Model';
2
- import { AppFacades } from '../types/App';
2
+ import { AppFacade, AppFacades } from '../types/App';
3
3
 
4
- export declare function BaseModelFactory(facades: AppFacades, abstract: string): typeof BaseModel;
4
+ export declare function BaseModelFactory(app: AppFacade, abstract: string): typeof BaseModel;
5
5
  export declare function ModelFactory(facades: AppFacades, abstract: string, CustomModel: typeof BaseModel): typeof ModelInterface;
@@ -5,12 +5,11 @@ import { Constructor } from '../types/Support';
5
5
  export declare function isEventSource<T>(value: T): value is T & EventSource<any>;
6
6
  export declare function HasEvents<T extends EventSourceEvents, U extends Constructor>(Base: U): {
7
7
  new (...args: any[]): {
8
- "__#1@#emitter": Emitter<EventSourceEvents>;
8
+ emitter: Emitter<EventSourceEvents>;
9
9
  "__#1@#createNanoEvents"(): Emitter<EventSourceEvents>;
10
10
  on<E extends keyof T>(event: E, callback: T[E]): import('nanoevents').Unsubscribe;
11
11
  once<E_1 extends keyof T>(event: E_1, callback: T[E_1]): void;
12
12
  emit<E_2 extends keyof T>(event: E_2, data?: Omit<Parameters<T[E_2]>[0], "source">): void;
13
13
  [Symbol.toStringTag]: string;
14
14
  };
15
- name: string;
16
15
  } & U;
@@ -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
+ import { Constructor } from './Support';
10
11
 
11
12
  type Plugin = PluginInterface<AppFacade, AppFacades>;
12
13
  export type GlobalModelEvents = {
@@ -48,6 +49,12 @@ export type AppExternal = {
48
49
  make<T extends keyof AppFacades>(key: T): AppFacades[T];
49
50
  plugins: () => Plugin[];
50
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;
51
58
  };
52
59
  export type AppFacade = AppExternal & {
53
60
  has(key: string): boolean;
@@ -12,6 +12,9 @@ export type BuilderInterface<R, C> = EventSource<BuilderEventMap<R, C>> & {
12
12
  where(key: string, value: JsonValue): BuilderInterface<R, C>;
13
13
  where(key: string, operator: ExtendedOperator, value: JsonValue): BuilderInterface<R, C>;
14
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>;
15
18
  whereNull(key: string): BuilderInterface<R, C>;
16
19
  whereNotNull(key: string): BuilderInterface<R, C>;
17
20
  whereBetween(key: string, value: [JsonValue, JsonValue]): BuilderInterface<R, C>;
@@ -20,6 +23,7 @@ export type BuilderInterface<R, C> = EventSource<BuilderEventMap<R, C>> & {
20
23
  searchBy(term: string): BuilderInterface<R, C>;
21
24
  minified(): BuilderInterface<R, C>;
22
25
  limit(value: number): BuilderInterface<R, C>;
26
+ include(searchParams: URLSearchParams): BuilderInterface<R, C>;
23
27
  get(page?: number, replaceLinksWith?: string): Promise<C>;
24
28
  all(): Promise<Collection<R>>;
25
29
  first(): Promise<R | null>;
@@ -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
+ import { RouteGenerator } from './Route';
6
7
 
7
8
  export type RelationRepository = Record<string, RelationInterface<Model, ModelPaginatedResponse>>;
8
9
  export type ModelEvents = {
@@ -41,22 +42,31 @@ export declare class BaseModel implements EventSource<ModelEvents> {
41
42
  get isDirty(): boolean;
42
43
  get casts(): ModelSchemaAttributes['casts'];
43
44
  exists: boolean;
45
+ wasRecentlyCreated: boolean;
44
46
  getAttribute(key: string): unknown;
45
47
  setAttribute(key: string, value: unknown): void;
46
48
  getKey(): string | number;
47
49
  getKeyName(): string;
48
- fill(attributes: JsonObject): void;
50
+ getLabel(): string;
51
+ fill(attributes: object): void;
49
52
  toJson(): JsonObject;
50
53
  diff(): JsonObject;
51
54
  getType(): string;
52
55
  dump(): void;
53
- save(options?: ModelSaveOptions): Promise<AxiosResponse<unknown, unknown>>;
56
+ save(options?: ModelSaveOptions): Promise<AxiosResponse | void>;
54
57
  update(attributes: JsonObject): Promise<void>;
55
- delete(): Promise<AxiosResponse<unknown, unknown>>;
56
- forceDelete(): Promise<AxiosResponse<unknown, unknown>>;
57
- restore(): Promise<AxiosResponse<unknown, unknown>>;
58
+ delete(): Promise<AxiosResponse>;
59
+ forceDelete(): Promise<AxiosResponse>;
60
+ restore(): Promise<AxiosResponse>;
58
61
  refresh(): Promise<void>;
59
62
  relation(relationName: string): RelationInterface<Model, ModelPaginatedResponse> | undefined;
63
+ getErrorBag(method: string): string;
64
+ getRouteForSave(): RouteGenerator;
65
+ getRouteForUpdate(): RouteGenerator;
66
+ getRouteForDelete(): RouteGenerator;
67
+ getRouteForRestore(): RouteGenerator;
68
+ getRouteForForceDelete(): RouteGenerator;
69
+ getRouteForRefresh(): RouteGenerator;
60
70
  static getSchemaName(): string;
61
71
  static getSchema(): ModelSchemaAttributes;
62
72
  static query(): BuilderInterface<Model, ModelPaginatedResponse>;
@@ -91,7 +101,7 @@ export declare class BaseModel implements EventSource<ModelEvents> {
91
101
  }
92
102
  export declare class Model extends BaseModel {
93
103
  [key: string]: any;
94
- static [key: string]: any;
104
+ [Symbol.toStringTag]: string;
95
105
  }
96
106
  export interface ModelSaveOptions {
97
107
  additionalPayload?: object;
@@ -107,6 +117,21 @@ export interface ModelTableColumnDefinition {
107
117
  sortable?: boolean;
108
118
  }
109
119
  export interface ModelSchemaAttributes {
120
+ attributes: {
121
+ appended: true | null;
122
+ cast: string | null;
123
+ default: string | null;
124
+ fillable: boolean;
125
+ hidden: boolean;
126
+ increments: boolean;
127
+ name: string;
128
+ nullable: boolean;
129
+ phpType: string | null;
130
+ primary: boolean;
131
+ type: string | null;
132
+ unique: boolean;
133
+ virtual: boolean;
134
+ }[];
110
135
  displayName: {
111
136
  singular: string;
112
137
  plural: string;
@@ -117,6 +142,7 @@ export interface ModelSchemaAttributes {
117
142
  primaryKey: string;
118
143
  timestamps: boolean;
119
144
  labeledBy: string;
145
+ [key: string]: any;
120
146
  }
121
147
  export interface RelationMetaData {
122
148
  model: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminix/core",
3
- "version": "0.0.1-beta.1",
3
+ "version": "0.0.1-beta.11",
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",
package/vite.config.js CHANGED
@@ -3,6 +3,8 @@ import { resolve } from 'path';
3
3
 
4
4
  import dts from 'vite-plugin-dts';
5
5
 
6
+ import packageJson from './package.json';
7
+
6
8
  export default defineConfig({
7
9
  plugins: [dts({ insertTypesEntry: true })],
8
10
  build: {
@@ -11,7 +13,7 @@ export default defineConfig({
11
13
  formats: ['es']
12
14
  },
13
15
  rollupOptions: {
14
- external: ['axios', 'lodash', 'immer']
16
+ external: Object.keys(packageJson.peerDependencies),
15
17
  }
16
18
  },
17
19
 
package/graph.png DELETED
Binary file