@luminix/core 0.3.8 → 0.4.1
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.
- package/babel.config.json +5 -0
- package/dist/core.js +759 -752
- package/package.json +9 -3
- package/types/contracts/Builder.d.ts +2 -2
- package/types/contracts/Relation/BelongsToMany.d.ts +3 -3
- package/types/contracts/Relation/HasMany.d.ts +2 -1
- package/types/contracts/Relation/MorphMany.d.ts +3 -2
- package/types/types/Builder.d.ts +5 -1
- package/types/types/Model.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luminix/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "> Projeto em desenvolvimento",
|
|
3
|
+
"version": "0.4.1",
|
|
5
4
|
"main": "dist/core.js",
|
|
6
5
|
"module": "dist/core.js",
|
|
7
6
|
"types": "types/index.d.ts",
|
|
@@ -18,19 +17,26 @@
|
|
|
18
17
|
},
|
|
19
18
|
"author": "",
|
|
20
19
|
"license": "MIT",
|
|
20
|
+
"description": "> Projeto em desenvolvimento",
|
|
21
21
|
"devDependencies": {
|
|
22
|
+
"@babel/core": "^7.26.0",
|
|
23
|
+
"@babel/preset-env": "^7.26.0",
|
|
22
24
|
"@types/jest": "^29.5.12",
|
|
25
|
+
"@types/lodash-es": "^4.17.12",
|
|
23
26
|
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
24
27
|
"@typescript-eslint/parser": "^7.1.0",
|
|
28
|
+
"babel-jest": "^29.7.0",
|
|
29
|
+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
|
25
30
|
"eslint": "^8.57.0",
|
|
26
31
|
"jest": "^29.7.0",
|
|
27
32
|
"jest-environment-jsdom": "^29.7.0",
|
|
33
|
+
"lodash-es": "^4.17.21",
|
|
28
34
|
"ts-jest": "^29.1.2",
|
|
29
35
|
"typescript": "^5.3.3",
|
|
30
36
|
"vite": "^5.0.12",
|
|
31
37
|
"vite-plugin-dts": "^4.0.0-beta.1"
|
|
32
38
|
},
|
|
33
39
|
"peerDependencies": {
|
|
34
|
-
"@luminix/support": "^0.4.
|
|
40
|
+
"@luminix/support": "^0.4.9"
|
|
35
41
|
}
|
|
36
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection, EventSource, JsonValue } from '@luminix/support';
|
|
2
|
-
import { BuilderEventMap as BuilderEvents, BuilderInterface as BuilderBase, ExtendedOperator } from '../types/Builder';
|
|
2
|
+
import { BuilderEventMap as BuilderEvents, BuilderInterface as BuilderBase, ExtendedOperator, BuilderGetOptions } from '../types/Builder';
|
|
3
3
|
import { Model, ModelPaginatedResponse, ModelQuery } from '../types/Model';
|
|
4
4
|
import { ModelFacade } from '../types/App';
|
|
5
5
|
import { RouteFacade } from '../types/Route';
|
|
@@ -37,7 +37,7 @@ declare class Builder extends EventSource<BuilderEventMap> implements BuilderInt
|
|
|
37
37
|
unset(key: string): this;
|
|
38
38
|
include(searchParams: URLSearchParams): this;
|
|
39
39
|
private exec;
|
|
40
|
-
get(
|
|
40
|
+
get(options?: BuilderGetOptions): Promise<ModelPaginatedResponse>;
|
|
41
41
|
first(): Promise<Model | null>;
|
|
42
42
|
find(id: string | number): Promise<Model | null>;
|
|
43
43
|
all(): Promise<Collection<Model>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection, JsonObject } from '@luminix/support';
|
|
2
2
|
import { default as Relation, RelationServices } from '../Relation';
|
|
3
3
|
import { Model, ModelPaginatedResponse, RelationMetaData } from '../../types/Model';
|
|
4
|
-
import { BuilderInterface as Builder } from '../../types/Builder';
|
|
4
|
+
import { BuilderInterface as Builder, BuilderGetOptions } from '../../types/Builder';
|
|
5
5
|
type BuilderInterface = Builder<Model, ModelPaginatedResponse>;
|
|
6
6
|
export default class BelongsToMany extends Relation {
|
|
7
7
|
protected services: RelationServices;
|
|
@@ -12,7 +12,7 @@ export default class BelongsToMany extends Relation {
|
|
|
12
12
|
isSingle(): boolean;
|
|
13
13
|
isMultiple(): boolean;
|
|
14
14
|
query(): BuilderInterface;
|
|
15
|
-
get(
|
|
15
|
+
get(options?: BuilderGetOptions): Promise<ModelPaginatedResponse>;
|
|
16
16
|
all(): Promise<Collection<Model>>;
|
|
17
17
|
first(): Promise<Model | null>;
|
|
18
18
|
find(id: string | number): Promise<Model | null>;
|
|
@@ -21,8 +21,8 @@ export default class BelongsToMany extends Relation {
|
|
|
21
21
|
detachQuietly(id: string | number): Promise<void>;
|
|
22
22
|
detach(id: string | number): Promise<void>;
|
|
23
23
|
syncQuietly(ids: (string | number | JsonObject)[]): Promise<void>;
|
|
24
|
-
syncWithPivotValuesQuietly(ids: (string | number)[], pivot: JsonObject): Promise<void>;
|
|
25
24
|
sync(ids: (string | number | JsonObject)[]): Promise<void>;
|
|
25
|
+
syncWithPivotValuesQuietly(ids: (string | number)[], pivot: JsonObject): Promise<void>;
|
|
26
26
|
syncWithPivotValues(ids: (string | number)[], pivot: JsonObject): Promise<void>;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
@@ -2,6 +2,7 @@ import { Collection } from '@luminix/support';
|
|
|
2
2
|
import { Model, RelationMetaData } from '../../types/Model';
|
|
3
3
|
import { default as HasOneOrMany } from './HasOneOrMany';
|
|
4
4
|
import { RelationServices } from '../Relation';
|
|
5
|
+
import { BuilderGetOptions } from '../../types/Builder';
|
|
5
6
|
export default class HasMany extends HasOneOrMany {
|
|
6
7
|
protected services: RelationServices;
|
|
7
8
|
protected meta: RelationMetaData;
|
|
@@ -10,7 +11,7 @@ export default class HasMany extends HasOneOrMany {
|
|
|
10
11
|
constructor(services: RelationServices, meta: RelationMetaData, parent: Model, items?: Collection<Model> | null);
|
|
11
12
|
isSingle(): boolean;
|
|
12
13
|
isMultiple(): boolean;
|
|
13
|
-
get(
|
|
14
|
+
get(options?: BuilderGetOptions): Promise<import('../../types/Model').ModelPaginatedResponse>;
|
|
14
15
|
all(): Promise<Collection<Model>>;
|
|
15
16
|
first(): Promise<Model | null>;
|
|
16
17
|
find(id: string | number): Promise<Model | null>;
|
|
@@ -2,6 +2,7 @@ import { Collection } from '@luminix/support';
|
|
|
2
2
|
import { Model, RelationMetaData } from '../../types/Model';
|
|
3
3
|
import { default as MorphOneOrMany } from './MorphOneOrMany';
|
|
4
4
|
import { RelationServices } from '../Relation';
|
|
5
|
+
import { BuilderGetOptions } from '../../types/Builder';
|
|
5
6
|
export default class MorphMany extends MorphOneOrMany {
|
|
6
7
|
protected services: RelationServices;
|
|
7
8
|
protected meta: RelationMetaData;
|
|
@@ -10,11 +11,11 @@ export default class MorphMany extends MorphOneOrMany {
|
|
|
10
11
|
constructor(services: RelationServices, meta: RelationMetaData, parent: Model, items?: Collection<Model> | null);
|
|
11
12
|
isSingle(): boolean;
|
|
12
13
|
isMultiple(): boolean;
|
|
13
|
-
get(
|
|
14
|
+
get(options?: BuilderGetOptions): Promise<import('../../types/Model').ModelPaginatedResponse>;
|
|
14
15
|
all(): Promise<Collection<Model>>;
|
|
15
16
|
first(): Promise<Model | null>;
|
|
16
17
|
find(id: string | number): Promise<Model | null>;
|
|
17
18
|
saveManyQuietly(models: Model[]): Promise<void>;
|
|
18
|
-
save(item: Model): Promise<void>;
|
|
19
19
|
saveMany(models: Model[]): Promise<void>;
|
|
20
|
+
save(item: Model): Promise<void>;
|
|
20
21
|
}
|
package/types/types/Builder.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { EventSource, Collection, PropertyBag, Operator, Event, PropertyBagEventMap, JsonObject, JsonValue } from '@luminix/support';
|
|
2
2
|
export type Scope<TSingle, TMany> = (builder: BuilderInterface<TSingle, TMany>) => BuilderInterface<TSingle, TMany> | void;
|
|
3
3
|
export type ExtendedOperator = Operator | 'like' | 'notLike' | 'between' | 'notBetween' | 'null' | 'notNull';
|
|
4
|
+
export type BuilderGetOptions = {
|
|
5
|
+
page?: number;
|
|
6
|
+
replaceLinks?: boolean;
|
|
7
|
+
};
|
|
4
8
|
export type BuilderInterface<TSingle, TMany = Collection<TSingle>> = EventSource<BuilderEventMap<TSingle, TMany>> & {
|
|
5
9
|
lock(path: string): void;
|
|
6
10
|
where(scope: Scope<TSingle, TMany>): BuilderInterface<TSingle, TMany>;
|
|
@@ -19,7 +23,7 @@ export type BuilderInterface<TSingle, TMany = Collection<TSingle>> = EventSource
|
|
|
19
23
|
minified(): BuilderInterface<TSingle, TMany>;
|
|
20
24
|
limit(value: number): BuilderInterface<TSingle, TMany>;
|
|
21
25
|
include(searchParams: URLSearchParams): BuilderInterface<TSingle, TMany>;
|
|
22
|
-
get(
|
|
26
|
+
get(options?: BuilderGetOptions): Promise<TMany>;
|
|
23
27
|
all(): Promise<Collection<TSingle>>;
|
|
24
28
|
first(): Promise<TSingle | null>;
|
|
25
29
|
find(id: string | number): Promise<TSingle | null>;
|
package/types/types/Model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventSource, Collection, Response, Event, Constructor, JsonObject, JsonValue, Client } from '@luminix/support';
|
|
2
2
|
import { RelationInterface as RawRelationInterface, BuilderInterface, Scope, ExtendedOperator } from './Relation';
|
|
3
3
|
import { RouteGenerator } from './Route';
|
|
4
|
+
import { BuilderGetOptions } from './Builder';
|
|
4
5
|
type RelationInterface = RawRelationInterface<Model, ModelPaginatedResponse>;
|
|
5
6
|
export type RelationRepository = Record<string, RelationInterface>;
|
|
6
7
|
export type ModelEvents = {
|
|
@@ -71,7 +72,7 @@ export declare class BaseModel extends EventSource<ModelEvents> {
|
|
|
71
72
|
static getSchemaName(): string;
|
|
72
73
|
static getSchema(): ModelSchemaAttributes;
|
|
73
74
|
static query(): BuilderInterface<Model, ModelPaginatedResponse>;
|
|
74
|
-
static get(
|
|
75
|
+
static get(options?: BuilderGetOptions): Promise<ModelPaginatedResponse>;
|
|
75
76
|
static find(id: number | string): Promise<Model | null>;
|
|
76
77
|
static first(): Promise<Model | null>;
|
|
77
78
|
static where(scope: Scope<Model, ModelPaginatedResponse>): BuilderInterface<Model, ModelPaginatedResponse>;
|