@mittwald/api-models 4.44.1 → 4.44.2

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.
@@ -23,7 +23,7 @@ export class AppInstallation extends ReferenceModel {
23
23
  const data = await config.behaviors.appInstallation.list(projectId, query);
24
24
  return data.map((d) => new AppInstallationListItem(d));
25
25
  });
26
- getDetailed = provideReact(() => AppInstallation.get(this.id));
26
+ getDetailed = provideReact(() => AppInstallation.get(this.id), [this.id]);
27
27
  }
28
28
  // Common class for future extension
29
29
  class AppInstallationCommon extends classes((DataModel), AppInstallation) {
@@ -23,7 +23,7 @@ export class Customer extends ReferenceModel {
23
23
  assertObjectFound(customer, this, id);
24
24
  return customer;
25
25
  });
26
- getDetailed = provideReact(() => Customer.get(this.id));
26
+ getDetailed = provideReact(() => Customer.get(this.id), [this.id]);
27
27
  }
28
28
  // Common class for future extension
29
29
  class CustomerCommon extends classes((DataModel), Customer) {
@@ -27,7 +27,7 @@ export class Ingress extends ReferenceModel {
27
27
  assertObjectFound(ingress, this, id);
28
28
  return ingress;
29
29
  });
30
- getDetailed = provideReact(() => Ingress.get(this.id));
30
+ getDetailed = provideReact(() => Ingress.get(this.id), [this.id]);
31
31
  }
32
32
  export class IngressCommon extends classes((DataModel), Ingress) {
33
33
  baseUrl;
@@ -1,5 +1,12 @@
1
1
  import { reactUsePromise } from "../react/reactUsePromise.js";
2
- export const provideReact = (loader) => Object.assign(loader, {
3
- asResource: (...params) => reactUsePromise.getAsyncResource(loader, params),
4
- use: (...params) => reactUsePromise.getAsyncResource(loader, params).use(),
5
- });
2
+ export const provideReact = (loader, dependencies) => {
3
+ const getAsyncResource = (params) => reactUsePromise.getAsyncResource(loader, params, {
4
+ // "stringify" dependencies to be used as loaderId
5
+ // see https://github.com/mittwald/react-use-promise?tab=readme-ov-file#loaderid
6
+ loaderId: dependencies ? dependencies.join("|") : undefined,
7
+ });
8
+ return Object.assign(loader, {
9
+ asResource: (...params) => getAsyncResource(params),
10
+ use: (...params) => getAsyncResource(params).use(),
11
+ });
12
+ };
@@ -30,7 +30,7 @@ export class Project extends ReferenceModel {
30
30
  const { id } = await config.behaviors.project.create(serverId, description);
31
31
  return new Project(id);
32
32
  }
33
- getDetailed = provideReact(() => Project.get(this.id));
33
+ getDetailed = provideReact(() => Project.get(this.id), [this.id]);
34
34
  listIngresses = provideReact(() => Ingress.list({ projectId: this.id }));
35
35
  getDefaultIngress = provideReact(async () => {
36
36
  const ingresses = await Project.ofId(this.id).listIngresses();
@@ -33,7 +33,7 @@ export class Server extends ReferenceModel {
33
33
  serverId: this.id,
34
34
  });
35
35
  });
36
- getDetailed = provideReact(() => Server.get(this.id));
36
+ getDetailed = provideReact(() => Server.get(this.id), [this.id]);
37
37
  }
38
38
  // Common class for future extension
39
39
  class ServerCommon extends classes((DataModel), Server) {
@@ -1,7 +1,7 @@
1
1
  import { AsyncResource } from "../react/reactUsePromise.js";
2
2
  type FnParameters = unknown[];
3
3
  type AsyncFn<TResult, TParams extends FnParameters> = (...args: TParams) => Promise<TResult>;
4
- export declare const provideReact: <TValue, TParams extends FnParameters>(loader: AsyncFn<TValue, TParams>) => AsyncResourceVariant<TValue, TParams>;
4
+ export declare const provideReact: <TValue, TParams extends FnParameters>(loader: AsyncFn<TValue, TParams>, dependencies?: string[]) => AsyncResourceVariant<TValue, TParams>;
5
5
  export type AsyncResourceVariant<TValue, TParams extends FnParameters> = TParams extends null ? AsyncFn<TValue, TParams> & {
6
6
  asResource: () => AsyncResource<TValue>;
7
7
  } : AsyncFn<TValue, TParams> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-models",
3
- "version": "4.44.1",
3
+ "version": "4.44.2",
4
4
  "author": "Mittwald CM Service GmbH & Co. KG <opensource@mittwald.de>",
5
5
  "type": "module",
6
6
  "description": "Collection of domain models for coherent interaction with the API",
@@ -71,5 +71,5 @@
71
71
  "optional": true
72
72
  }
73
73
  },
74
- "gitHead": "47b29340f8470c3c7d9813895279baf61eecada2"
74
+ "gitHead": "03d7df8f0a9037979a9ce2478a8137911afcff87"
75
75
  }