@webiny/app-utils 6.3.0-beta.4 → 6.4.0-beta.0
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/features/List/FilterFeature.js +21 -20
- package/features/List/FilterFeature.js.map +1 -1
- package/features/List/ListQueryParamsRepository.js +62 -64
- package/features/List/ListQueryParamsRepository.js.map +1 -1
- package/features/List/LoadMoreFeature.js +21 -23
- package/features/List/LoadMoreFeature.js.map +1 -1
- package/features/List/LoadingRepository.js +41 -43
- package/features/List/LoadingRepository.js.map +1 -1
- package/features/List/SearchFeature.js +15 -12
- package/features/List/SearchFeature.js.map +1 -1
- package/features/List/SortFeature.js +18 -15
- package/features/List/SortFeature.js.map +1 -1
- package/features/List/abstractions.js +8 -31
- package/features/List/abstractions.js.map +1 -1
- package/features/List/feature.js +26 -30
- package/features/List/feature.js.map +1 -1
- package/fta/Domain/Models/Meta/Meta.js +17 -16
- package/fta/Domain/Models/Meta/Meta.js.map +1 -1
- package/fta/Domain/Models/Meta/MetaMapper.js +9 -8
- package/fta/Domain/Models/Meta/MetaMapper.js.map +1 -1
- package/fta/Domain/Models/Meta/index.js +0 -2
- package/fta/Domain/Models/Sorting/Sorting.js +9 -8
- package/fta/Domain/Models/Sorting/Sorting.js.map +1 -1
- package/fta/Domain/Models/Sorting/SortingMapper.js +27 -40
- package/fta/Domain/Models/Sorting/SortingMapper.js.map +1 -1
- package/fta/Domain/Models/Sorting/index.js +0 -2
- package/fta/Domain/Models/index.js +0 -2
- package/fta/Domain/Repositories/Loading/ILoadingRepository.js +0 -3
- package/fta/Domain/Repositories/Loading/LoadingRepository.js +39 -34
- package/fta/Domain/Repositories/Loading/LoadingRepository.js.map +1 -1
- package/fta/Domain/Repositories/Loading/LoadingRepositoryFactory.js +13 -12
- package/fta/Domain/Repositories/Loading/LoadingRepositoryFactory.js.map +1 -1
- package/fta/Domain/Repositories/Loading/index.js +0 -2
- package/fta/Domain/Repositories/Meta/IMetaRepository.js +0 -3
- package/fta/Domain/Repositories/Meta/MetaRepository.js +32 -38
- package/fta/Domain/Repositories/Meta/MetaRepository.js.map +1 -1
- package/fta/Domain/Repositories/Meta/MetaRepositoryFactory.js +13 -12
- package/fta/Domain/Repositories/Meta/MetaRepositoryFactory.js.map +1 -1
- package/fta/Domain/Repositories/Meta/index.js +0 -2
- package/fta/Domain/Repositories/Sorting/ISortingRepository.js +0 -3
- package/fta/Domain/Repositories/Sorting/SortingRepository.js +12 -11
- package/fta/Domain/Repositories/Sorting/SortingRepository.js.map +1 -1
- package/fta/Domain/Repositories/Sorting/SortingRepositoryFactory.js +13 -12
- package/fta/Domain/Repositories/Sorting/SortingRepositoryFactory.js.map +1 -1
- package/fta/Domain/Repositories/Sorting/index.js +0 -2
- package/fta/Domain/Repositories/index.js +0 -2
- package/fta/Domain/index.js +0 -2
- package/fta/index.js +0 -2
- package/index.js +0 -2
- package/package.json +6 -6
- package/fta/Domain/Models/Meta/index.js.map +0 -1
- package/fta/Domain/Models/Sorting/index.js.map +0 -1
- package/fta/Domain/Models/index.js.map +0 -1
- package/fta/Domain/Repositories/Loading/ILoadingRepository.js.map +0 -1
- package/fta/Domain/Repositories/Loading/index.js.map +0 -1
- package/fta/Domain/Repositories/Meta/IMetaRepository.js.map +0 -1
- package/fta/Domain/Repositories/Meta/index.js.map +0 -1
- package/fta/Domain/Repositories/Sorting/ISortingRepository.js.map +0 -1
- package/fta/Domain/Repositories/Sorting/index.js.map +0 -1
- package/fta/Domain/Repositories/index.js.map +0 -1
- package/fta/Domain/index.js.map +0 -1
- package/fta/index.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { FilterFeature
|
|
1
|
+
import { FilterFeature, ListQueryParamsRepository } from "./abstractions.js";
|
|
2
2
|
class FilterFeatureImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
}
|
|
3
|
+
constructor(queryParams){
|
|
4
|
+
this.queryParams = queryParams;
|
|
5
|
+
}
|
|
6
|
+
async setFilter(key, value) {
|
|
7
|
+
await this.queryParams.set((params)=>{
|
|
8
|
+
if (!params.filters) params.filters = {};
|
|
9
|
+
params.filters[key] = value;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async clearAllFilters() {
|
|
13
|
+
await this.queryParams.set((params)=>{
|
|
14
|
+
params.filters = {};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const FilterFeature_FilterFeature = FilterFeature.createImplementation({
|
|
19
|
+
implementation: FilterFeatureImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
ListQueryParamsRepository
|
|
22
|
+
]
|
|
23
23
|
});
|
|
24
|
+
export { FilterFeature_FilterFeature as FilterFeature };
|
|
24
25
|
|
|
25
26
|
//# sourceMappingURL=FilterFeature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/FilterFeature.js","sources":["../../../src/features/List/FilterFeature.ts"],"sourcesContent":["import {\n FilterFeature as Abstraction,\n type IFilterFeature,\n ListQueryParamsRepository,\n type BaseListParams\n} from \"./abstractions.js\";\n\nclass FilterFeatureImpl<TParams extends BaseListParams> implements IFilterFeature {\n constructor(private queryParams: ListQueryParamsRepository.Interface<TParams>) {}\n\n async setFilter(key: string, value: unknown): Promise<void> {\n await this.queryParams.set(params => {\n if (!params.filters) {\n params.filters = {};\n }\n params.filters[key] = value;\n });\n }\n\n async clearAllFilters(): Promise<void> {\n await this.queryParams.set(params => {\n params.filters = {};\n });\n }\n}\n\nexport const FilterFeature = Abstraction.createImplementation({\n implementation: FilterFeatureImpl,\n dependencies: [ListQueryParamsRepository]\n});\n"],"names":["FilterFeatureImpl","queryParams","key","value","params","FilterFeature","Abstraction","ListQueryParamsRepository"],"mappings":";AAOA,MAAMA;IACF,YAAoBC,WAAyD,CAAE;aAA3DA,WAAW,GAAXA;IAA4D;IAEhF,MAAM,UAAUC,GAAW,EAAEC,KAAc,EAAiB;QACxD,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAACC,CAAAA;YACvB,IAAI,CAACA,OAAO,OAAO,EACfA,OAAO,OAAO,GAAG,CAAC;YAEtBA,OAAO,OAAO,CAACF,IAAI,GAAGC;QAC1B;IACJ;IAEA,MAAM,kBAAiC;QACnC,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAACC,CAAAA;YACvBA,OAAO,OAAO,GAAG,CAAC;QACtB;IACJ;AACJ;AAEO,MAAMC,8BAAgBC,cAAAA,oBAAgC,CAAC;IAC1D,gBAAgBN;IAChB,cAAc;QAACO;KAA0B;AAC7C"}
|
|
@@ -1,70 +1,68 @@
|
|
|
1
1
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
2
|
-
import { ListQueryParamsRepository
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
2
|
+
import { ListQueryParamsRepository } from "./abstractions.js";
|
|
3
|
+
class ListQueryParamsRepositoryImpl {
|
|
4
|
+
constructor(){
|
|
5
|
+
this.listeners = new Set();
|
|
6
|
+
this.initial = {
|
|
7
|
+
search: "",
|
|
8
|
+
sort: [],
|
|
9
|
+
filters: {},
|
|
10
|
+
limit: 50
|
|
11
|
+
};
|
|
12
|
+
this.params = this.clone(this.initial);
|
|
13
|
+
makeAutoObservable(this, {
|
|
14
|
+
subscribe: false,
|
|
15
|
+
dispose: false
|
|
16
|
+
}, {
|
|
17
|
+
autoBind: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
get() {
|
|
21
|
+
return this.clone(this.params);
|
|
22
|
+
}
|
|
23
|
+
async set(updater) {
|
|
24
|
+
runInAction(()=>{
|
|
25
|
+
updater(this.params);
|
|
26
|
+
});
|
|
27
|
+
this.notify();
|
|
28
|
+
}
|
|
29
|
+
async replace(next) {
|
|
30
|
+
runInAction(()=>{
|
|
31
|
+
this.params = this.clone(next);
|
|
32
|
+
});
|
|
33
|
+
this.notify();
|
|
34
|
+
}
|
|
35
|
+
reset() {
|
|
36
|
+
runInAction(()=>{
|
|
37
|
+
this.params = this.clone(this.initial);
|
|
38
|
+
});
|
|
39
|
+
this.notify();
|
|
40
|
+
}
|
|
41
|
+
subscribe(listener) {
|
|
42
|
+
this.listeners.add(listener);
|
|
43
|
+
return ()=>{
|
|
44
|
+
this.listeners.delete(listener);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
dispose() {
|
|
48
|
+
this.listeners.clear();
|
|
49
|
+
}
|
|
50
|
+
notify() {
|
|
51
|
+
const snap = this.clone(this.params);
|
|
52
|
+
for (const listener of this.listeners)try {
|
|
53
|
+
listener(snap);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("Error in ListQueryParams listener:", error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
clone(value) {
|
|
59
|
+
return structuredClone ? structuredClone(value) : JSON.parse(JSON.stringify(value));
|
|
59
60
|
}
|
|
60
|
-
}
|
|
61
|
-
clone(value) {
|
|
62
|
-
return structuredClone ? structuredClone(value) : JSON.parse(JSON.stringify(value));
|
|
63
|
-
}
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const ListQueryParamsRepository_ListQueryParamsRepository = ListQueryParamsRepository.createImplementation({
|
|
63
|
+
implementation: ListQueryParamsRepositoryImpl,
|
|
64
|
+
dependencies: []
|
|
68
65
|
});
|
|
66
|
+
export { ListQueryParamsRepositoryImpl, ListQueryParamsRepository_ListQueryParamsRepository as ListQueryParamsRepository };
|
|
69
67
|
|
|
70
68
|
//# sourceMappingURL=ListQueryParamsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/ListQueryParamsRepository.js","sources":["../../../src/features/List/ListQueryParamsRepository.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport {\n ListQueryParamsRepository as Abstraction,\n type BaseListParams,\n type IListQueryParamsRepository\n} from \"./abstractions.js\";\n\nexport class ListQueryParamsRepositoryImpl<\n TParams extends BaseListParams\n> implements IListQueryParamsRepository<TParams> {\n private params: TParams;\n private readonly initial: TParams;\n private readonly listeners = new Set<(next: TParams) => void>();\n\n constructor() {\n this.initial = { search: \"\", sort: [], filters: {}, limit: 50 } as unknown as TParams;\n this.params = this.clone(this.initial) as unknown as TParams;\n\n makeAutoObservable(\n this,\n {\n subscribe: false,\n dispose: false\n },\n { autoBind: true }\n );\n }\n\n get(): TParams {\n return this.clone(this.params);\n }\n\n async set(updater: (params: TParams) => void): Promise<void> {\n runInAction(() => {\n updater(this.params);\n });\n this.notify();\n }\n\n async replace(next: TParams): Promise<void> {\n runInAction(() => {\n this.params = this.clone(next);\n });\n this.notify();\n }\n\n reset(): void {\n runInAction(() => {\n this.params = this.clone(this.initial);\n });\n this.notify();\n }\n\n subscribe(listener: (next: TParams) => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n dispose(): void {\n this.listeners.clear();\n }\n\n private notify(): void {\n const snap = this.clone(this.params);\n for (const listener of this.listeners) {\n try {\n listener(snap);\n } catch (error) {\n // Swallow listener errors to prevent cascading failures\n console.error(\"Error in ListQueryParams listener:\", error);\n }\n }\n }\n\n private clone(value: TParams): TParams {\n return structuredClone ? structuredClone(value) : JSON.parse(JSON.stringify(value));\n }\n}\n\nexport const ListQueryParamsRepository = Abstraction.createImplementation({\n implementation: ListQueryParamsRepositoryImpl,\n dependencies: []\n});\n"],"names":["ListQueryParamsRepositoryImpl","Set","makeAutoObservable","updater","runInAction","next","listener","snap","error","console","value","structuredClone","JSON","ListQueryParamsRepository","Abstraction"],"mappings":";;AAOO,MAAMA;IAOT,aAAc;aAFG,SAAS,GAAG,IAAIC;QAG7B,IAAI,CAAC,OAAO,GAAG;YAAE,QAAQ;YAAI,MAAM,EAAE;YAAE,SAAS,CAAC;YAAG,OAAO;QAAG;QAC9D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;QAErCC,mBACI,IAAI,EACJ;YACI,WAAW;YACX,SAAS;QACb,GACA;YAAE,UAAU;QAAK;IAEzB;IAEA,MAAe;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;IACjC;IAEA,MAAM,IAAIC,OAAkC,EAAiB;QACzDC,YAAY;YACRD,QAAQ,IAAI,CAAC,MAAM;QACvB;QACA,IAAI,CAAC,MAAM;IACf;IAEA,MAAM,QAAQE,IAAa,EAAiB;QACxCD,YAAY;YACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAACC;QAC7B;QACA,IAAI,CAAC,MAAM;IACf;IAEA,QAAc;QACVD,YAAY;YACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;QACzC;QACA,IAAI,CAAC,MAAM;IACf;IAEA,UAAUE,QAAiC,EAAc;QACrD,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA;QACnB,OAAO;YACH,IAAI,CAAC,SAAS,CAAC,MAAM,CAACA;QAC1B;IACJ;IAEA,UAAgB;QACZ,IAAI,CAAC,SAAS,CAAC,KAAK;IACxB;IAEQ,SAAe;QACnB,MAAMC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;QACnC,KAAK,MAAMD,YAAY,IAAI,CAAC,SAAS,CACjC,IAAI;YACAA,SAASC;QACb,EAAE,OAAOC,OAAO;YAEZC,QAAQ,KAAK,CAAC,sCAAsCD;QACxD;IAER;IAEQ,MAAME,KAAc,EAAW;QACnC,OAAOC,kBAAkBA,gBAAgBD,SAASE,KAAK,KAAK,CAACA,KAAK,SAAS,CAACF;IAChF;AACJ;AAEO,MAAMG,sDAA4BC,0BAAAA,oBAAgC,CAAC;IACtE,gBAAgBd;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListDataRepository, ListQueryParamsRepository, LoadMoreFeature, LoadingRepository } from "./abstractions.js";
|
|
2
2
|
class LoadMoreFeatureImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
async execute() {
|
|
9
|
-
if (!this.canLoadMore()) {
|
|
10
|
-
return;
|
|
3
|
+
constructor(repository, queryParams, loading){
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
this.queryParams = queryParams;
|
|
6
|
+
this.loading = loading;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
async execute() {
|
|
9
|
+
if (!this.canLoadMore()) return;
|
|
10
|
+
const params = this.queryParams.get();
|
|
11
|
+
await this.loading.runCallback(this.repository.append(params), "loadMore");
|
|
12
|
+
}
|
|
13
|
+
canLoadMore() {
|
|
14
|
+
if (this.loading.isLoading("loadMore")) return false;
|
|
15
|
+
return this.repository.hasMore();
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
// Check if repository has more items
|
|
22
|
-
return this.repository.hasMore();
|
|
23
|
-
}
|
|
24
17
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const LoadMoreFeature_LoadMoreFeature = LoadMoreFeature.createImplementation({
|
|
19
|
+
implementation: LoadMoreFeatureImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
ListDataRepository,
|
|
22
|
+
ListQueryParamsRepository,
|
|
23
|
+
LoadingRepository
|
|
24
|
+
]
|
|
28
25
|
});
|
|
26
|
+
export { LoadMoreFeature_LoadMoreFeature as LoadMoreFeature };
|
|
29
27
|
|
|
30
28
|
//# sourceMappingURL=LoadMoreFeature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/LoadMoreFeature.js","sources":["../../../src/features/List/LoadMoreFeature.ts"],"sourcesContent":["import {\n LoadMoreFeature as Abstraction,\n type ILoadMoreFeature,\n ListDataRepository,\n ListQueryParamsRepository,\n LoadingRepository,\n type BaseListParams\n} from \"./abstractions.js\";\n\nclass LoadMoreFeatureImpl<TItem, TParams extends BaseListParams> implements ILoadMoreFeature {\n constructor(\n private repository: ListDataRepository.Interface<TItem, TParams>,\n private queryParams: ListQueryParamsRepository.Interface<TParams>,\n private loading: LoadingRepository.Interface\n ) {}\n\n async execute(): Promise<void> {\n if (!this.canLoadMore()) {\n return;\n }\n\n const params = this.queryParams.get();\n\n await this.loading.runCallback(this.repository.append(params), \"loadMore\");\n }\n\n private canLoadMore(): boolean {\n // Don't allow load more if already loading\n if (this.loading.isLoading(\"loadMore\")) {\n return false;\n }\n\n // Check if repository has more items\n return this.repository.hasMore();\n }\n}\n\nexport const LoadMoreFeature = Abstraction.createImplementation({\n implementation: LoadMoreFeatureImpl,\n dependencies: [ListDataRepository, ListQueryParamsRepository, LoadingRepository]\n});\n"],"names":["LoadMoreFeatureImpl","repository","queryParams","loading","params","LoadMoreFeature","Abstraction","ListDataRepository","ListQueryParamsRepository","LoadingRepository"],"mappings":";AASA,MAAMA;IACF,YACYC,UAAwD,EACxDC,WAAyD,EACzDC,OAAoC,CAC9C;aAHUF,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,OAAO,GAAPA;IACT;IAEH,MAAM,UAAyB;QAC3B,IAAI,CAAC,IAAI,CAAC,WAAW,IACjB;QAGJ,MAAMC,SAAS,IAAI,CAAC,WAAW,CAAC,GAAG;QAEnC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA,SAAS;IACnE;IAEQ,cAAuB;QAE3B,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,aACvB,OAAO;QAIX,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;IAClC;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAAgC,CAAC;IAC5D,gBAAgBN;IAChB,cAAc;QAACO;QAAoBC;QAA2BC;KAAkB;AACpF"}
|
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
2
|
-
import { LoadingRepository
|
|
2
|
+
import { LoadingRepository } from "./abstractions.js";
|
|
3
3
|
class LoadingRepositoryImpl {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
4
|
+
constructor(){
|
|
5
|
+
this.loadingStates = {};
|
|
6
|
+
makeAutoObservable(this, {}, {
|
|
7
|
+
autoBind: true
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
get() {
|
|
11
|
+
return {
|
|
12
|
+
...this.loadingStates
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async set(action, isLoading = true) {
|
|
16
|
+
runInAction(()=>{
|
|
17
|
+
if (isLoading) this.loadingStates[action] = true;
|
|
18
|
+
else delete this.loadingStates[action];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async runCallback(callback, action) {
|
|
22
|
+
await this.set(action, true);
|
|
23
|
+
try {
|
|
24
|
+
const result = await callback;
|
|
25
|
+
await this.set(action, false);
|
|
26
|
+
return result;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
await this.set(action, false);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
isLoading(action) {
|
|
33
|
+
return true === this.loadingStates[action];
|
|
34
|
+
}
|
|
35
|
+
hasLoading() {
|
|
36
|
+
return Object.keys(this.loadingStates).length > 0;
|
|
37
|
+
}
|
|
38
|
+
isEmpty() {
|
|
39
|
+
return 0 === Object.keys(this.loadingStates).length;
|
|
33
40
|
}
|
|
34
|
-
}
|
|
35
|
-
isLoading(action) {
|
|
36
|
-
return this.loadingStates[action] === true;
|
|
37
|
-
}
|
|
38
|
-
hasLoading() {
|
|
39
|
-
return Object.keys(this.loadingStates).length > 0;
|
|
40
|
-
}
|
|
41
|
-
isEmpty() {
|
|
42
|
-
return Object.keys(this.loadingStates).length === 0;
|
|
43
|
-
}
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
const LoadingRepository_LoadingRepository = LoadingRepository.createImplementation({
|
|
43
|
+
implementation: LoadingRepositoryImpl,
|
|
44
|
+
dependencies: []
|
|
48
45
|
});
|
|
46
|
+
export { LoadingRepository_LoadingRepository as LoadingRepository };
|
|
49
47
|
|
|
50
48
|
//# sourceMappingURL=LoadingRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/LoadingRepository.js","sources":["../../../src/features/List/LoadingRepository.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from \"mobx\";\nimport { LoadingRepository as Abstraction, type ILoadingRepository } from \"./abstractions.js\";\n\nclass LoadingRepositoryImpl implements ILoadingRepository {\n private loadingStates: Record<string, boolean> = {};\n\n constructor() {\n makeAutoObservable(this, {}, { autoBind: true });\n }\n\n get(): Record<string, boolean> {\n return { ...this.loadingStates };\n }\n\n async set(action: string, isLoading: boolean = true): Promise<void> {\n runInAction(() => {\n if (isLoading) {\n this.loadingStates[action] = true;\n } else {\n delete this.loadingStates[action];\n }\n });\n }\n\n async runCallback<T>(callback: Promise<T>, action: string): Promise<T> {\n await this.set(action, true);\n try {\n const result = await callback;\n await this.set(action, false);\n return result;\n } catch (error) {\n await this.set(action, false);\n throw error;\n }\n }\n\n isLoading(action: string): boolean {\n return this.loadingStates[action] === true;\n }\n\n hasLoading(): boolean {\n return Object.keys(this.loadingStates).length > 0;\n }\n\n isEmpty(): boolean {\n return Object.keys(this.loadingStates).length === 0;\n }\n}\n\nexport const LoadingRepository = Abstraction.createImplementation({\n implementation: LoadingRepositoryImpl,\n dependencies: []\n});\n"],"names":["LoadingRepositoryImpl","makeAutoObservable","action","isLoading","runInAction","callback","result","error","Object","LoadingRepository","Abstraction"],"mappings":";;AAGA,MAAMA;IAGF,aAAc;aAFN,aAAa,GAA4B,CAAC;QAG9CC,mBAAmB,IAAI,EAAE,CAAC,GAAG;YAAE,UAAU;QAAK;IAClD;IAEA,MAA+B;QAC3B,OAAO;YAAE,GAAG,IAAI,CAAC,aAAa;QAAC;IACnC;IAEA,MAAM,IAAIC,MAAc,EAAEC,YAAqB,IAAI,EAAiB;QAChEC,YAAY;YACR,IAAID,WACA,IAAI,CAAC,aAAa,CAACD,OAAO,GAAG;iBAE7B,OAAO,IAAI,CAAC,aAAa,CAACA,OAAO;QAEzC;IACJ;IAEA,MAAM,YAAeG,QAAoB,EAAEH,MAAc,EAAc;QACnE,MAAM,IAAI,CAAC,GAAG,CAACA,QAAQ;QACvB,IAAI;YACA,MAAMI,SAAS,MAAMD;YACrB,MAAM,IAAI,CAAC,GAAG,CAACH,QAAQ;YACvB,OAAOI;QACX,EAAE,OAAOC,OAAO;YACZ,MAAM,IAAI,CAAC,GAAG,CAACL,QAAQ;YACvB,MAAMK;QACV;IACJ;IAEA,UAAUL,MAAc,EAAW;QAC/B,OAAO,AAA+B,SAA/B,IAAI,CAAC,aAAa,CAACA,OAAO;IACrC;IAEA,aAAsB;QAClB,OAAOM,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG;IACpD;IAEA,UAAmB;QACf,OAAOA,AAA2C,MAA3CA,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM;IACjD;AACJ;AAEO,MAAMC,sCAAoBC,kBAAAA,oBAAgC,CAAC;IAC9D,gBAAgBV;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListQueryParamsRepository, SearchFeature } from "./abstractions.js";
|
|
2
2
|
class SearchFeatureImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
constructor(queryParams){
|
|
4
|
+
this.queryParams = queryParams;
|
|
5
|
+
}
|
|
6
|
+
async setSearch(query) {
|
|
7
|
+
await this.queryParams.set((params)=>{
|
|
8
|
+
params.search = query;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const SearchFeature_SearchFeature = SearchFeature.createImplementation({
|
|
13
|
+
implementation: SearchFeatureImpl,
|
|
14
|
+
dependencies: [
|
|
15
|
+
ListQueryParamsRepository
|
|
16
|
+
]
|
|
15
17
|
});
|
|
18
|
+
export { SearchFeature_SearchFeature as SearchFeature };
|
|
16
19
|
|
|
17
20
|
//# sourceMappingURL=SearchFeature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/SearchFeature.js","sources":["../../../src/features/List/SearchFeature.ts"],"sourcesContent":["import {\n SearchFeature as Abstraction,\n type ISearchFeature,\n ListQueryParamsRepository,\n type BaseListParams\n} from \"./abstractions.js\";\n\nclass SearchFeatureImpl<TParams extends BaseListParams> implements ISearchFeature {\n constructor(private queryParams: ListQueryParamsRepository.Interface<TParams>) {}\n\n async setSearch(query: string): Promise<void> {\n await this.queryParams.set(params => {\n params.search = query;\n });\n }\n}\n\nexport const SearchFeature = Abstraction.createImplementation({\n implementation: SearchFeatureImpl,\n dependencies: [ListQueryParamsRepository]\n});\n"],"names":["SearchFeatureImpl","queryParams","query","params","SearchFeature","Abstraction","ListQueryParamsRepository"],"mappings":";AAOA,MAAMA;IACF,YAAoBC,WAAyD,CAAE;aAA3DA,WAAW,GAAXA;IAA4D;IAEhF,MAAM,UAAUC,KAAa,EAAiB;QAC1C,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAACC,CAAAA;YACvBA,OAAO,MAAM,GAAGD;QACpB;IACJ;AACJ;AAEO,MAAME,8BAAgBC,cAAAA,oBAAgC,CAAC;IAC1D,gBAAgBL;IAChB,cAAc;QAACM;KAA0B;AAC7C"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListQueryParamsRepository, SortFeature } from "./abstractions.js";
|
|
2
2
|
class SortFeatureImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
constructor(queryParams){
|
|
4
|
+
this.queryParams = queryParams;
|
|
5
|
+
}
|
|
6
|
+
async setSort(by, dir) {
|
|
7
|
+
await this.queryParams.set((params)=>{
|
|
8
|
+
params.sort = {
|
|
9
|
+
by,
|
|
10
|
+
dir
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const SortFeature_SortFeature = SortFeature.createImplementation({
|
|
16
|
+
implementation: SortFeatureImpl,
|
|
17
|
+
dependencies: [
|
|
18
|
+
ListQueryParamsRepository
|
|
19
|
+
]
|
|
18
20
|
});
|
|
21
|
+
export { SortFeature_SortFeature as SortFeature };
|
|
19
22
|
|
|
20
23
|
//# sourceMappingURL=SortFeature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/SortFeature.js","sources":["../../../src/features/List/SortFeature.ts"],"sourcesContent":["import {\n SortFeature as Abstraction,\n type ISortFeature,\n ListQueryParamsRepository,\n type BaseListParams\n} from \"./abstractions.js\";\n\nclass SortFeatureImpl<TParams extends BaseListParams> implements ISortFeature {\n constructor(private queryParams: ListQueryParamsRepository.Interface<TParams>) {}\n\n async setSort(by: string, dir: \"asc\" | \"desc\"): Promise<void> {\n await this.queryParams.set(params => {\n params.sort = { by, dir };\n });\n }\n}\n\nexport const SortFeature = Abstraction.createImplementation({\n implementation: SortFeatureImpl,\n dependencies: [ListQueryParamsRepository]\n});\n"],"names":["SortFeatureImpl","queryParams","by","dir","params","SortFeature","Abstraction","ListQueryParamsRepository"],"mappings":";AAOA,MAAMA;IACF,YAAoBC,WAAyD,CAAE;aAA3DA,WAAW,GAAXA;IAA4D;IAEhF,MAAM,QAAQC,EAAU,EAAEC,GAAmB,EAAiB;QAC1D,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAACC,CAAAA;YACvBA,OAAO,IAAI,GAAG;gBAAEF;gBAAIC;YAAI;QAC5B;IACJ;AACJ;AAEO,MAAME,0BAAcC,YAAAA,oBAAgC,CAAC;IACxD,gBAAgBN;IAChB,cAAc;QAACO;KAA0B;AAC7C"}
|
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const ListQueryParamsRepository = createAbstraction("ListQueryParamsRepository");
|
|
12
|
-
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// Loading Repository
|
|
15
|
-
// ============================================================================
|
|
16
|
-
|
|
17
|
-
export const LoadingRepository = createAbstraction("LoadingRepository");
|
|
18
|
-
|
|
19
|
-
// ============================================================================
|
|
20
|
-
// List Data Repository
|
|
21
|
-
// ============================================================================
|
|
22
|
-
|
|
23
|
-
export const ListDataRepository = createAbstraction("ListDataRepository");
|
|
24
|
-
|
|
25
|
-
// ============================================================================
|
|
26
|
-
// Features
|
|
27
|
-
// ============================================================================
|
|
28
|
-
|
|
29
|
-
export const SearchFeature = createAbstraction("SearchFeature");
|
|
30
|
-
export const FilterFeature = createAbstraction("FilterFeature");
|
|
31
|
-
export const SortFeature = createAbstraction("SortFeature");
|
|
32
|
-
export const LoadMoreFeature = createAbstraction("LoadMoreFeature");
|
|
2
|
+
const ListQueryParamsRepository = createAbstraction("ListQueryParamsRepository");
|
|
3
|
+
const LoadingRepository = createAbstraction("LoadingRepository");
|
|
4
|
+
const ListDataRepository = createAbstraction("ListDataRepository");
|
|
5
|
+
const SearchFeature = createAbstraction("SearchFeature");
|
|
6
|
+
const FilterFeature = createAbstraction("FilterFeature");
|
|
7
|
+
const SortFeature = createAbstraction("SortFeature");
|
|
8
|
+
const LoadMoreFeature = createAbstraction("LoadMoreFeature");
|
|
9
|
+
export { FilterFeature, ListDataRepository, ListQueryParamsRepository, LoadMoreFeature, LoadingRepository, SearchFeature, SortFeature };
|
|
33
10
|
|
|
34
11
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/List/abstractions.js","sources":["../../../src/features/List/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\n\n// ============================================================================\n// Base Types\n// ============================================================================\n\nexport interface BaseListParams {\n search?: string;\n sort?: { by: string; dir: \"asc\" | \"desc\" };\n filters?: Record<string, unknown>;\n limit?: number;\n}\n\n// ============================================================================\n// Query Params Repository\n// ============================================================================\n\nexport interface IListQueryParamsRepository<TParams extends BaseListParams> {\n get(): TParams;\n set(updater: (params: TParams) => void): Promise<void>;\n replace(next: TParams): Promise<void>;\n reset(): void;\n subscribe(listener: (next: TParams) => void): () => void;\n dispose(): void;\n}\n\nexport const ListQueryParamsRepository = createAbstraction<IListQueryParamsRepository<any>>(\n \"ListQueryParamsRepository\"\n);\n\nexport namespace ListQueryParamsRepository {\n export type Interface<TParams extends BaseListParams = BaseListParams> =\n IListQueryParamsRepository<TParams>;\n}\n\n// ============================================================================\n// Loading Repository\n// ============================================================================\n\nexport interface ILoadingRepository {\n get(): Record<string, boolean>;\n set(action: string, isLoading?: boolean): Promise<void>;\n runCallback<T>(callback: Promise<T>, action: string): Promise<T>;\n isLoading(action: string): boolean;\n hasLoading(): boolean;\n isEmpty(): boolean;\n}\n\nexport const LoadingRepository = createAbstraction<ILoadingRepository>(\"LoadingRepository\");\n\nexport namespace LoadingRepository {\n export type Interface = ILoadingRepository;\n}\n\n// ============================================================================\n// List Data Repository\n// ============================================================================\n\nexport interface IListDataRepository<TItem, TParams extends BaseListParams> {\n load(params: TParams): Promise<void>;\n append(params: TParams): Promise<void>;\n getAll(): TItem[];\n hasMore(): boolean;\n clear(): void;\n}\n\nexport const ListDataRepository =\n createAbstraction<IListDataRepository<any, any>>(\"ListDataRepository\");\n\nexport namespace ListDataRepository {\n export type Interface<\n TItem = any,\n TParams extends BaseListParams = BaseListParams\n > = IListDataRepository<TItem, TParams>;\n}\n\n// ============================================================================\n// Features\n// ============================================================================\n\nexport interface ISearchFeature {\n setSearch(query: string): Promise<void>;\n}\n\nexport const SearchFeature = createAbstraction<ISearchFeature>(\"SearchFeature\");\n\nexport namespace SearchFeature {\n export type Interface = ISearchFeature;\n}\n\nexport interface IFilterFeature {\n setFilter(key: string, value: unknown): Promise<void>;\n clearAllFilters(): Promise<void>;\n}\n\nexport const FilterFeature = createAbstraction<IFilterFeature>(\"FilterFeature\");\n\nexport namespace FilterFeature {\n export type Interface = IFilterFeature;\n}\n\nexport interface ISortFeature {\n setSort(by: string, dir: \"asc\" | \"desc\"): Promise<void>;\n}\n\nexport const SortFeature = createAbstraction<ISortFeature>(\"SortFeature\");\n\nexport namespace SortFeature {\n export type Interface = ISortFeature;\n}\n\nexport interface ILoadMoreFeature {\n execute(): Promise<void>;\n}\n\nexport const LoadMoreFeature = createAbstraction<ILoadMoreFeature>(\"LoadMoreFeature\");\n\nexport namespace LoadMoreFeature {\n export type Interface = ILoadMoreFeature;\n}\n"],"names":["ListQueryParamsRepository","createAbstraction","LoadingRepository","ListDataRepository","SearchFeature","FilterFeature","SortFeature","LoadMoreFeature"],"mappings":";AA0BO,MAAMA,4BAA4BC,kBACrC;AAqBG,MAAMC,oBAAoBD,kBAAsC;AAkBhE,MAAME,qBACTF,kBAAiD;AAiB9C,MAAMG,gBAAgBH,kBAAkC;AAWxD,MAAMI,gBAAgBJ,kBAAkC;AAUxD,MAAMK,cAAcL,kBAAgC;AAUpD,MAAMM,kBAAkBN,kBAAoC"}
|