@mittwald/api-models 4.43.0 → 4.44.1

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.
@@ -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 serverData = await config.behaviors.server.find(id);
11
- if (serverData !== undefined) {
12
- return new ServerDetailed([serverData]);
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 ServerDetailed.find(id);
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([d]));
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(() => ServerDetailed.get(this.id));
36
+ getDetailed = provideReact(() => Server.get(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,22 +1,22 @@
1
1
  import { ReferenceModel } from "../../base/ReferenceModel.js";
2
- import { ServerListItemData, ServerData } from "./types.js";
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 find: ((id: string) => Promise<Server | undefined>) & {
8
- asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<Server | undefined>;
9
- use: (id: string) => Server | undefined;
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<Server>) & {
12
- asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<Server>;
13
- use: (id: string) => Server;
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 ServerListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, typeof DataModel<ServerListItemData>]>;
67
- export declare class ServerListItem extends ServerListItem_base {
68
- }
69
- declare const ServerDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, typeof DataModel<ServerData>]>;
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.43.0",
3
+ "version": "4.44.1",
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",
@@ -37,7 +37,7 @@
37
37
  "test": "node --experimental-vm-modules $(yarn bin jest)"
38
38
  },
39
39
  "dependencies": {
40
- "@mittwald/api-client": "^4.43.0",
40
+ "@mittwald/api-client": "^4.44.0",
41
41
  "another-deep-freeze": "^1.0.0",
42
42
  "polytype": "^0.17.0",
43
43
  "type-fest": "^4.12.0"
@@ -71,5 +71,5 @@
71
71
  "optional": true
72
72
  }
73
73
  },
74
- "gitHead": "aff65e8a4fb37e47e5fef4289d0dbde9911c7e58"
74
+ "gitHead": "47b29340f8470c3c7d9813895279baf61eecada2"
75
75
  }