@cascateer/core 2.4.19 → 2.4.21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascateer/core",
3
- "version": "2.4.19",
3
+ "version": "2.4.21",
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.6.0",
24
+ "globals": "^17.7.0",
25
25
  "typescript": "~6.0.3",
26
- "typescript-eslint": "^8.61.1",
27
- "vite": "^8.0.16",
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.21",
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.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: UnaryFunction<Args, MaybeObservable<Result>>;
38
- tags?: TagsConstructor<Args, Result> | MaybeArray<string>;
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: UnaryFunction<Args, Observable<Result>>;
43
- tags: TagsConstructor<Args, Result>;
41
+ predicate: Function1<Args, Observable<Result>>;
42
+ tags: Function2<Args, Result, string[]>;
44
43
 
45
- subscribe: UnaryFunction<Observable<string[]>, ProxyEffect<Args, Result>>;
44
+ subscribe: Function1<Observable<string[]>, ProxyEffect<Args, Result>>;
46
45
 
47
- share: UnaryFunction<NextObserver<string[]>, Action<Args, Result>>;
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 = isFunction(tags) ? tags : constant([tags ?? []].flat());
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: UnaryFunction<Source, MemoizableConfig<Args, Result>>,
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: UnaryFunction<
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: UnaryFunction<
153
+ actions: Function1<
155
154
  { action: ApiAdapterPropertyConstructor<Source, "action"> },
156
155
  MoreActions
157
156
  >,
@@ -2,6 +2,4 @@ import * as lodash from "lodash";
2
2
  import objectHash from "object-hash";
3
3
 
4
4
  export const memoize = <T extends (...args: any) => any>(func: T) =>
5
- lodash.memoize(func, (...args: Parameters<T>) =>
6
- lodash.tap(objectHash(args ?? null), (hash) => console.log({ hash, args })),
7
- );
5
+ lodash.memoize(func, (...args: Parameters<T>) => objectHash(args ?? null));