@mittwald/api-models 4.44.0 → 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.
- package/dist/esm/app/AppInstallation/AppInstallation.js +1 -1
- package/dist/esm/customer/Customer/Customer.js +1 -1
- package/dist/esm/domain/Ingress/Ingress.js +1 -1
- package/dist/esm/lib/provideReact.js +11 -4
- package/dist/esm/project/Project/Project.js +1 -1
- package/dist/esm/server/Server/Server.js +17 -11
- package/dist/types/lib/provideReact.d.ts +1 -1
- package/dist/types/server/Server/Server.d.ts +48 -12
- package/package.json +2 -2
|
@@ -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) =>
|
|
3
|
-
|
|
4
|
-
|
|
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();
|
|
@@ -6,24 +6,24 @@ import assertObjectFound from "../../base/assertObjectFound.js";
|
|
|
6
6
|
import { Project } from "../../project/index.js";
|
|
7
7
|
import { provideReact } from "../../lib/provideReact.js";
|
|
8
8
|
export class Server extends ReferenceModel {
|
|
9
|
+
static ofId(id) {
|
|
10
|
+
return new Server(id);
|
|
11
|
+
}
|
|
9
12
|
static find = provideReact(async (id) => {
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
return new ServerDetailed(
|
|
13
|
+
const data = await config.behaviors.server.find(id);
|
|
14
|
+
if (data !== undefined) {
|
|
15
|
+
return new ServerDetailed(data);
|
|
13
16
|
}
|
|
14
17
|
});
|
|
15
18
|
static get = provideReact(async (id) => {
|
|
16
|
-
const server = await
|
|
19
|
+
const server = await this.find(id);
|
|
17
20
|
assertObjectFound(server, this, id);
|
|
18
21
|
return server;
|
|
19
22
|
});
|
|
20
23
|
static list = provideReact(async (query = {}) => {
|
|
21
24
|
const projectListData = await config.behaviors.server.list(query);
|
|
22
|
-
return projectListData.map((d) => new ServerListItem(
|
|
25
|
+
return projectListData.map((d) => new ServerListItem(d));
|
|
23
26
|
});
|
|
24
|
-
static ofId(id) {
|
|
25
|
-
return new Server(id);
|
|
26
|
-
}
|
|
27
27
|
async createProject(...parameters) {
|
|
28
28
|
return Project.create(this.id, ...parameters);
|
|
29
29
|
}
|
|
@@ -33,7 +33,7 @@ export class Server extends ReferenceModel {
|
|
|
33
33
|
serverId: this.id,
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
-
getDetailed = provideReact(() =>
|
|
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) {
|
|
@@ -41,7 +41,13 @@ class ServerCommon extends classes((DataModel), Server) {
|
|
|
41
41
|
super([data], [data.id]);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
export class ServerListItem extends classes(ServerCommon, (DataModel)) {
|
|
45
|
-
}
|
|
46
44
|
export class ServerDetailed extends classes(ServerCommon, (DataModel)) {
|
|
45
|
+
constructor(data) {
|
|
46
|
+
super([data], [data]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ServerListItem extends classes(ServerCommon, (DataModel)) {
|
|
50
|
+
constructor(data) {
|
|
51
|
+
super([data], [data]);
|
|
52
|
+
}
|
|
47
53
|
}
|
|
@@ -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
|
|
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> & {
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { ReferenceModel } from "../../base/ReferenceModel.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ServerData, ServerListItemData } from "./types.js";
|
|
3
3
|
import { DataModel } from "../../base/DataModel.js";
|
|
4
4
|
import { Project } from "../../project/index.js";
|
|
5
5
|
import { ParamsExceptFirst } from "../../lib/types.js";
|
|
6
6
|
export declare class Server extends ReferenceModel {
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
static ofId(id: string): Server;
|
|
8
|
+
static find: ((id: string) => Promise<ServerDetailed | undefined>) & {
|
|
9
|
+
asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<ServerDetailed | undefined>;
|
|
10
|
+
use: (id: string) => ServerDetailed | undefined;
|
|
10
11
|
};
|
|
11
|
-
static get: ((id: string) => Promise<
|
|
12
|
-
asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<
|
|
13
|
-
use: (id: string) =>
|
|
12
|
+
static get: ((id: string) => Promise<ServerDetailed>) & {
|
|
13
|
+
asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<ServerDetailed>;
|
|
14
|
+
use: (id: string) => ServerDetailed;
|
|
14
15
|
};
|
|
15
16
|
static list: ((query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query | undefined) => Promise<ServerListItem[]>) & {
|
|
16
17
|
asResource: (query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query | undefined) => import("@mittwald/react-use-promise").AsyncResource<ServerListItem[]>;
|
|
17
18
|
use: (query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query | undefined) => ServerListItem[];
|
|
18
19
|
};
|
|
19
|
-
static ofId(id: string): Server;
|
|
20
20
|
createProject(...parameters: ParamsExceptFirst<typeof Project.create>): ReturnType<typeof Project.create>;
|
|
21
21
|
listProjects: ((query?: Omit<import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query | undefined, "serverId"> | undefined) => Promise<readonly import("../../project/index.js").ProjectListItem[]>) & {
|
|
22
22
|
asResource: (query?: Omit<import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query | undefined, "serverId"> | undefined) => import("@mittwald/react-use-promise").AsyncResource<readonly import("../../project/index.js").ProjectListItem[]>;
|
|
@@ -63,10 +63,46 @@ declare const ServerCommon_base: import("polytype").Polytype.ClusteredConstructo
|
|
|
63
63
|
declare class ServerCommon extends ServerCommon_base {
|
|
64
64
|
constructor(data: ServerListItemData | ServerData);
|
|
65
65
|
}
|
|
66
|
-
declare const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
declare const ServerDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, {
|
|
67
|
+
new (data: {
|
|
68
|
+
clusterName: string;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
customerId: string;
|
|
71
|
+
description: string;
|
|
72
|
+
disabledReason?: "suspended" | undefined;
|
|
73
|
+
id: string;
|
|
74
|
+
imageRefId?: string | undefined;
|
|
75
|
+
isReady: boolean;
|
|
76
|
+
machineType: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectMachineType;
|
|
77
|
+
readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedServerReadinessStatus;
|
|
78
|
+
shortId: string;
|
|
79
|
+
statisticsBaseDomain?: string | undefined;
|
|
80
|
+
status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerStatus;
|
|
81
|
+
storage: string;
|
|
82
|
+
}): DataModel<{
|
|
83
|
+
clusterName: string;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
customerId: string;
|
|
86
|
+
description: string;
|
|
87
|
+
disabledReason?: "suspended" | undefined;
|
|
88
|
+
id: string;
|
|
89
|
+
imageRefId?: string | undefined;
|
|
90
|
+
isReady: boolean;
|
|
91
|
+
machineType: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectMachineType;
|
|
92
|
+
readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedServerReadinessStatus;
|
|
93
|
+
shortId: string;
|
|
94
|
+
statisticsBaseDomain?: string | undefined;
|
|
95
|
+
status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerStatus;
|
|
96
|
+
storage: string;
|
|
97
|
+
}>;
|
|
98
|
+
}]>;
|
|
70
99
|
export declare class ServerDetailed extends ServerDetailed_base {
|
|
100
|
+
constructor(data: ServerData);
|
|
101
|
+
}
|
|
102
|
+
declare const ServerListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, {
|
|
103
|
+
new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServer): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServer>;
|
|
104
|
+
}]>;
|
|
105
|
+
export declare class ServerListItem extends ServerListItem_base {
|
|
106
|
+
constructor(data: ServerListItemData);
|
|
71
107
|
}
|
|
72
108
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/api-models",
|
|
3
|
-
"version": "4.44.
|
|
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": "
|
|
74
|
+
"gitHead": "03d7df8f0a9037979a9ce2478a8137911afcff87"
|
|
75
75
|
}
|