Skip to content

Commit b241d72

Browse files
committed
chore: mixins cleanups
1 parent 497e9b1 commit b241d72

File tree

4 files changed

+18
-42
lines changed

4 files changed

+18
-42
lines changed

dist/js/entity/set.d.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
import { InMemoryEntity } from "./in_memory";
2-
declare const InMemoryEntitySet_base: typeof InMemoryEntity & import("./set/InMemoryEntitySetBaseMixin").InMemoryEntitySetBaseConstructor & (new (...args: any[]) => {
3-
inSet: import("./set/InMemoryEntityInSetMixin").InSet[];
4-
}) & (new (...args: any[]) => {
5-
getInSetFilteredByCls(cls: string): {
6-
_id: string;
7-
cls?: string;
8-
slug?: string;
9-
type?: string;
10-
index?: number;
11-
}[];
12-
readonly parentEntitySetReference: {
13-
_id: string;
14-
cls?: string;
15-
slug?: string;
16-
type?: string;
17-
index?: number;
18-
} | undefined;
19-
}) & import("./set/InMemoryEntitySetMixin").InMemoryEntitySetConstructor;
2+
declare const InMemoryEntitySet_base: typeof InMemoryEntity & import("./set/InMemoryEntitySetBaseMixin").InMemoryEntitySetBaseConstructor & import("./set/InMemoryEntityInSetMixin").InMemoryEntityInSetConstructor & import("./set/InMemoryEntitySetMixin").InMemoryEntitySetConstructor;
203
export declare class InMemoryEntitySet extends InMemoryEntitySet_base {
214
}
225
export {};

dist/js/entity/set/InMemoryEntityInSetMixin.d.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,25 @@ import type { Constructor } from "../../utils/types";
33
import { type InMemoryEntity } from "../in_memory";
44
export type SystemInSet = Required<SystemInSetSchema>;
55
export type InSet = SystemInSet["inSet"][0];
6-
declare function schemaMixin<E extends InMemoryEntity>(item: E): {
7-
inSet: InSet[];
8-
};
9-
declare function propertiesMixin<E extends InMemoryEntity>(item: E & InMemoryEntityInSetSchema): {
6+
export declare function inMemoryEntityInSetMixin<E extends InMemoryEntity>(item: E): {
107
getInSetFilteredByCls(cls: string): {
118
_id: string;
129
cls?: string;
1310
slug?: string;
1411
type?: string;
1512
index?: number;
1613
}[];
17-
readonly parentEntitySetReference: {
14+
parentEntitySetReference: {
1815
_id: string;
1916
cls?: string;
2017
slug?: string;
2118
type?: string;
2219
index?: number;
2320
} | undefined;
21+
inSet: InSet[];
2422
};
25-
export declare function inMemoryEntityInSetMixin<E extends InMemoryEntity>(item: E): void;
26-
type InMemoryEntityInSetSchema = ReturnType<typeof schemaMixin>;
27-
type InMemoryEntityInSetSchemaConstructor = Constructor<InMemoryEntityInSetSchema>;
28-
type InMemoryEntityInSetProperties = ReturnType<typeof propertiesMixin>;
29-
type InMemoryEntityInSetPropertiesConstructor = Constructor<InMemoryEntityInSetProperties>;
30-
export type InMemoryEntityInSet = InMemoryEntityInSetSchema & InMemoryEntityInSetProperties;
31-
export type InMemoryEntityInSetConstructor = InMemoryEntityInSetSchemaConstructor & InMemoryEntityInSetPropertiesConstructor;
23+
export type InMemoryEntityInSet = ReturnType<typeof inMemoryEntityInSetMixin>;
24+
export type InMemoryEntityInSetConstructor = Constructor<InMemoryEntityInSet>;
3225
type Base = Constructor<InMemoryEntity>;
3326
export default function InMemoryEntityInSetMixin<S extends Base = Base>(superclass: S): S & InMemoryEntityInSetConstructor;
3427
export {};

dist/js/entity/set/InMemoryEntityInSetMixin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ function propertiesMixin(item) {
2929
return properties;
3030
}
3131
function inMemoryEntityInSetMixin(item) {
32-
schemaMixin(item);
33-
propertiesMixin(item);
32+
return {
33+
...schemaMixin(item),
34+
...propertiesMixin(item),
35+
};
3436
}
3537
function InMemoryEntityInSetMixin(superclass) {
3638
class InMemoryEntityInSetMixin extends superclass {

src/js/entity/set/InMemoryEntityInSetMixin.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { type InMemoryEntity } from "../in_memory";
77
export type SystemInSet = Required<SystemInSetSchema>;
88
export type InSet = SystemInSet["inSet"][0];
99

10+
type InMemoryEntityInSetSchema = ReturnType<typeof schemaMixin>;
11+
1012
function schemaMixin<E extends InMemoryEntity>(item: E) {
1113
const schema = {
1214
get inSet() {
@@ -42,18 +44,14 @@ function propertiesMixin<E extends InMemoryEntity>(item: E & InMemoryEntityInSet
4244
}
4345

4446
export function inMemoryEntityInSetMixin<E extends InMemoryEntity>(item: E) {
45-
schemaMixin(item);
46-
propertiesMixin(item as E & InMemoryEntityInSetSchema);
47+
return {
48+
...schemaMixin(item),
49+
...propertiesMixin(item as E & InMemoryEntityInSetSchema),
50+
};
4751
}
4852

49-
type InMemoryEntityInSetSchema = ReturnType<typeof schemaMixin>;
50-
type InMemoryEntityInSetSchemaConstructor = Constructor<InMemoryEntityInSetSchema>;
51-
type InMemoryEntityInSetProperties = ReturnType<typeof propertiesMixin>;
52-
type InMemoryEntityInSetPropertiesConstructor = Constructor<InMemoryEntityInSetProperties>;
53-
54-
export type InMemoryEntityInSet = InMemoryEntityInSetSchema & InMemoryEntityInSetProperties;
55-
export type InMemoryEntityInSetConstructor = InMemoryEntityInSetSchemaConstructor &
56-
InMemoryEntityInSetPropertiesConstructor;
53+
export type InMemoryEntityInSet = ReturnType<typeof inMemoryEntityInSetMixin>;
54+
export type InMemoryEntityInSetConstructor = Constructor<InMemoryEntityInSet>;
5755

5856
type Base = Constructor<InMemoryEntity>;
5957

0 commit comments

Comments
 (0)