@cascateer/core 2.4.20 → 2.4.22
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/package.json +6 -6
- package/src/api.ts +16 -17
- package/src/terminal.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cascateer/core",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.22",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cascateer/core.git"
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"@types/lodash": "^4.17.24",
|
|
22
22
|
"@types/object-hash": "^3.0.6",
|
|
23
23
|
"@types/react": "^19.2.17",
|
|
24
|
-
"globals": "^17.
|
|
24
|
+
"globals": "^17.7.0",
|
|
25
25
|
"typescript": "~6.0.3",
|
|
26
|
-
"typescript-eslint": "^8.
|
|
27
|
-
"vite": "^8.0
|
|
26
|
+
"typescript-eslint": "^8.62.0",
|
|
27
|
+
"vite": "^8.1.0",
|
|
28
28
|
"vitest": "^4.1.9"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@cascateer/lib": "^1.0.
|
|
31
|
+
"@cascateer/lib": "^1.0.36",
|
|
32
32
|
"lodash": "^4.18.1",
|
|
33
33
|
"object-hash": "^3.0.0",
|
|
34
34
|
"rxjs": "^7.8.2",
|
|
35
35
|
"ts-brand": "^0.2.0",
|
|
36
|
-
"uuid": "^14.0.
|
|
36
|
+
"uuid": "^14.0.1"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/api.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
asArray,
|
|
3
|
+
asFunction,
|
|
2
4
|
asObservable,
|
|
3
5
|
ExtendableDictionary,
|
|
4
6
|
MaybeArray,
|
|
7
|
+
MaybeFunction,
|
|
5
8
|
MaybeObservable,
|
|
6
9
|
} from "@cascateer/lib";
|
|
7
10
|
import {
|
|
8
|
-
constant,
|
|
9
11
|
Dictionary,
|
|
12
|
+
flow,
|
|
13
|
+
Function1,
|
|
14
|
+
Function2,
|
|
10
15
|
intersectionWith,
|
|
11
16
|
isEqual,
|
|
12
|
-
isFunction,
|
|
13
17
|
} from "lodash";
|
|
14
18
|
import {
|
|
15
19
|
combineLatest,
|
|
@@ -23,32 +27,27 @@ import {
|
|
|
23
27
|
shareReplay,
|
|
24
28
|
Subject,
|
|
25
29
|
tap,
|
|
26
|
-
UnaryFunction,
|
|
27
30
|
} from "rxjs";
|
|
28
31
|
import { memoize } from "./lib/memoize";
|
|
29
32
|
import { ProxyObservable } from "./observable";
|
|
30
33
|
import { Action, ProxyEffect } from "./types";
|
|
31
34
|
|
|
32
|
-
interface TagsConstructor<Args, Result> {
|
|
33
|
-
(args: Args, result: Result): string[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
35
|
interface MemoizableConfig<Args, Result> {
|
|
37
|
-
predicate:
|
|
38
|
-
tags?:
|
|
36
|
+
predicate: Function1<Args, MaybeObservable<Result>>;
|
|
37
|
+
tags?: MaybeFunction<[Args, Result], MaybeArray<string>>;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
class Memoizable<Args, Result> {
|
|
42
|
-
predicate:
|
|
43
|
-
tags:
|
|
41
|
+
predicate: Function1<Args, Observable<Result>>;
|
|
42
|
+
tags: Function2<Args, Result, string[]>;
|
|
44
43
|
|
|
45
|
-
subscribe:
|
|
44
|
+
subscribe: Function1<Observable<string[]>, ProxyEffect<Args, Result>>;
|
|
46
45
|
|
|
47
|
-
share:
|
|
46
|
+
share: Function1<NextObserver<string[]>, Action<Args, Result>>;
|
|
48
47
|
|
|
49
48
|
constructor({ predicate, tags }: MemoizableConfig<Args, Result>) {
|
|
50
49
|
this.predicate = (args) => asObservable(predicate(args));
|
|
51
|
-
this.tags =
|
|
50
|
+
this.tags = flow(asFunction(tags ?? []), asArray);
|
|
52
51
|
|
|
53
52
|
this.subscribe = (invalidatedTags) => {
|
|
54
53
|
const memoizedEffect: ProxyEffect<Args, Result> = memoize(
|
|
@@ -91,7 +90,7 @@ export interface ApiEffect<Args, Result> extends ProxyEffect<Args, Result> {}
|
|
|
91
90
|
|
|
92
91
|
type ApiAdapterPropertyConstructor<Source, Type extends "effect" | "action"> = {
|
|
93
92
|
[T in Type]: <Args, Result>(
|
|
94
|
-
config:
|
|
93
|
+
config: Function1<Source, MemoizableConfig<Args, Result>>,
|
|
95
94
|
) => T extends "effect" ? ApiEffect<Args, Result> : Action<Args, Result>;
|
|
96
95
|
}[Type];
|
|
97
96
|
|
|
@@ -130,7 +129,7 @@ export class ExtendableApiAdapter<
|
|
|
130
129
|
) {}
|
|
131
130
|
|
|
132
131
|
provideEffects<MoreEffects extends Dictionary<ApiEffect<any, any>>>(
|
|
133
|
-
effects:
|
|
132
|
+
effects: Function1<
|
|
134
133
|
{ effect: ApiAdapterPropertyConstructor<Source, "effect"> },
|
|
135
134
|
MoreEffects
|
|
136
135
|
>,
|
|
@@ -151,7 +150,7 @@ export class ExtendableApiAdapter<
|
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
provideActions<MoreActions extends Dictionary<Action<any, any>>>(
|
|
154
|
-
actions:
|
|
153
|
+
actions: Function1<
|
|
155
154
|
{ action: ApiAdapterPropertyConstructor<Source, "action"> },
|
|
156
155
|
MoreActions
|
|
157
156
|
>,
|
package/src/terminal.ts
CHANGED
|
@@ -115,6 +115,7 @@ export class ExtendableTerminalAdapter<
|
|
|
115
115
|
actions: StoreActions;
|
|
116
116
|
};
|
|
117
117
|
api: {
|
|
118
|
+
effect: ApiEffects;
|
|
118
119
|
actions: ApiActions;
|
|
119
120
|
};
|
|
120
121
|
terminal: {
|
|
@@ -142,6 +143,7 @@ export class ExtendableTerminalAdapter<
|
|
|
142
143
|
actions: this.context.store.actions,
|
|
143
144
|
},
|
|
144
145
|
api: {
|
|
146
|
+
effect: this.context.api.effects,
|
|
145
147
|
actions: this.context.api.actions,
|
|
146
148
|
},
|
|
147
149
|
terminal: {
|