@mittwald/api-models 0.0.0-development-74e1fd1-20240611 → 0.0.0-development-e096ee7-20240924

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.
Files changed (53) hide show
  1. package/README.md +55 -11
  2. package/dist/esm/app/AppInstallation/AppInstallation.js +48 -4
  3. package/dist/esm/app/AppInstallation/behaviors/api.js +5 -2
  4. package/dist/esm/base/ListDataModel.js +8 -0
  5. package/dist/esm/base/ListQueryModel.js +9 -0
  6. package/dist/esm/base/index.js +5 -0
  7. package/dist/esm/config/behaviors/api.js +3 -0
  8. package/dist/esm/config/config.js +1 -0
  9. package/dist/esm/customer/Customer/Customer.js +59 -6
  10. package/dist/esm/customer/Customer/behaviors/api.js +12 -2
  11. package/dist/esm/domain/Ingress/Ingress.js +56 -6
  12. package/dist/esm/domain/Ingress/behaviors/api.js +7 -5
  13. package/dist/esm/project/Project/Project.js +57 -5
  14. package/dist/esm/project/Project/behaviors/api.js +5 -2
  15. package/dist/esm/project/Project/behaviors/inMem.js +5 -1
  16. package/dist/esm/react/MittwaldApiModelProvider.js +8 -8
  17. package/dist/esm/react/asyncResourceInvalidation.js +29 -0
  18. package/dist/esm/react/index.js +2 -1
  19. package/dist/esm/react/provideReact.js +24 -0
  20. package/dist/esm/react/provideReact.test-types.js +21 -0
  21. package/dist/esm/react/reactProvisionContext.js +2 -0
  22. package/dist/esm/server/Server/Server.js +68 -13
  23. package/dist/esm/server/Server/behaviors/api.js +5 -2
  24. package/dist/types/app/AppInstallation/AppInstallation.d.ts +26 -17
  25. package/dist/types/app/AppInstallation/behaviors/types.d.ts +3 -2
  26. package/dist/types/app/AppInstallation/types.d.ts +1 -1
  27. package/dist/types/base/ListDataModel.d.ts +5 -0
  28. package/dist/types/base/ListQueryModel.d.ts +5 -0
  29. package/dist/types/base/index.d.ts +5 -0
  30. package/dist/types/base/types.d.ts +4 -0
  31. package/dist/types/config/config.d.ts +1 -0
  32. package/dist/types/customer/Customer/Customer.d.ts +34 -21
  33. package/dist/types/customer/Customer/behaviors/types.d.ts +4 -2
  34. package/dist/types/customer/Customer/types.d.ts +2 -1
  35. package/dist/types/domain/Ingress/Ingress.d.ts +24 -17
  36. package/dist/types/domain/Ingress/behaviors/types.d.ts +3 -2
  37. package/dist/types/domain/Ingress/types.d.ts +5 -3
  38. package/dist/types/project/Project/Project.d.ts +78 -68
  39. package/dist/types/project/Project/behaviors/types.d.ts +3 -2
  40. package/dist/types/project/Project/types.d.ts +7 -1
  41. package/dist/types/react/MittwaldApiModelProvider.d.ts +6 -2
  42. package/dist/types/react/asyncResourceInvalidation.d.ts +4 -0
  43. package/dist/types/react/index.d.ts +3 -2
  44. package/dist/types/react/provideReact.d.ts +9 -0
  45. package/dist/types/react/provideReact.test-types.d.ts +1 -0
  46. package/dist/types/react/reactProvisionContext.d.ts +3 -0
  47. package/dist/types/react/reactUsePromise.d.ts +1 -0
  48. package/dist/types/server/Server/Server.d.ts +71 -28
  49. package/dist/types/server/Server/behaviors/types.d.ts +3 -2
  50. package/dist/types/server/Server/types.d.ts +5 -1
  51. package/package.json +26 -15
  52. package/dist/esm/lib/provideReact.js +0 -5
  53. package/dist/types/lib/provideReact.d.ts +0 -11
@@ -1,44 +1,59 @@
1
- import { ProjectListItemData, ProjectData } from "./types.js";
1
+ import { ProjectData, ProjectListItemData, ProjectListQueryData, ProjectListQueryModelData } from "./types.js";
2
2
  import { DataModel } from "../../base/DataModel.js";
3
3
  import { Server } from "../../server/index.js";
4
+ import { AsyncResourceVariant } from "../../react/provideReact.js";
4
5
  import { Customer } from "../../customer/Customer/Customer.js";
5
6
  import { ReferenceModel } from "../../base/ReferenceModel.js";
6
- import { IngressListItem } from "../../domain/index.js";
7
+ import { IngressListItem, IngressListQuery } from "../../domain/index.js";
8
+ import { ListQueryModel } from "../../base/ListQueryModel.js";
9
+ import { ListDataModel } from "../../base/ListDataModel.js";
10
+ import { AppInstallationListQuery } from "../../app/index.js";
7
11
  export declare class Project extends ReferenceModel {
12
+ readonly ingresses: IngressListQuery;
13
+ readonly appInstallations: AppInstallationListQuery;
14
+ constructor(id: string);
8
15
  static ofId(id: string): Project;
9
- static find: ((id: string) => Promise<ProjectDetailed | undefined>) & {
10
- asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<ProjectDetailed | undefined>;
11
- use: (id: string) => ProjectDetailed | undefined;
12
- };
13
- static get: ((id: string) => Promise<ProjectDetailed>) & {
14
- asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<ProjectDetailed>;
15
- use: (id: string) => ProjectDetailed;
16
- };
17
- static list: ((query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query | undefined) => Promise<readonly ProjectListItem[]>) & {
18
- asResource: (query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query | undefined) => import("@mittwald/react-use-promise").AsyncResource<readonly ProjectListItem[]>;
19
- use: (query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query | undefined) => readonly ProjectListItem[];
20
- };
16
+ static find: AsyncResourceVariant<(id: string) => Promise<ProjectDetailed | undefined>>;
17
+ static get: AsyncResourceVariant<(id: string) => Promise<ProjectDetailed>>;
18
+ static query(query?: ProjectListQueryModelData): ProjectListQuery;
19
+ /** @deprecated: use query(), Customer.projects or Server.projects */
20
+ static list: AsyncResourceVariant<(query?: ProjectListQueryData) => Promise<Readonly<Array<ProjectListItem>>>>;
21
21
  static create(serverId: string, description: string): Promise<Project>;
22
- getDetailed: (() => Promise<ProjectDetailed>) & {
23
- asResource: () => import("@mittwald/react-use-promise").AsyncResource<ProjectDetailed>;
24
- use: () => ProjectDetailed;
25
- };
26
- listIngresses: (() => Promise<IngressListItem[]>) & {
27
- asResource: () => import("@mittwald/react-use-promise").AsyncResource<IngressListItem[]>;
28
- use: () => IngressListItem[];
29
- };
30
- getDefaultIngress: (() => Promise<IngressListItem>) & {
31
- asResource: () => import("@mittwald/react-use-promise").AsyncResource<IngressListItem>;
32
- use: () => IngressListItem;
33
- };
22
+ getDetailed: AsyncResourceVariant<() => Promise<ProjectDetailed>>;
23
+ findDetailed: AsyncResourceVariant<() => Promise<ProjectDetailed | undefined>>;
24
+ /** @deprecated: use ingresses property */
25
+ listIngresses: AsyncResourceVariant<() => Promise<readonly IngressListItem[]>>;
26
+ getDefaultIngress: AsyncResourceVariant<() => Promise<IngressListItem>>;
34
27
  updateDescription(description: string): Promise<void>;
35
28
  leave(): Promise<void>;
36
29
  delete(): Promise<void>;
37
30
  }
38
31
  declare const ProjectCommon_base: import("polytype").Polytype.ClusteredConstructor<[{
39
32
  new (data: {
33
+ createdAt: string;
34
+ customerId: string;
35
+ customerMeta: {
36
+ id: string;
37
+ };
38
+ description: string;
39
+ disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason;
40
+ disabledAt?: string;
41
+ enabled: boolean;
42
+ id: string;
43
+ imageRefId?: string;
44
+ isReady: boolean;
45
+ projectHostingId?: string;
46
+ readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedProjectReadinessStatus;
47
+ serverId?: string;
48
+ shortId: string;
49
+ status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
50
+ statusSetAt: string;
51
+ webStorageUsageInBytes: number;
52
+ webStorageUsageInBytesSetAt: string;
53
+ } | {
40
54
  clusterDomain?: string | undefined;
41
55
  clusterID?: string | undefined;
56
+ clusterId?: string | undefined;
42
57
  createdAt: string;
43
58
  customerId: string;
44
59
  description: string;
@@ -56,36 +71,37 @@ declare const ProjectCommon_base: import("polytype").Polytype.ClusteredConstruct
56
71
  serverId?: string | undefined;
57
72
  serverShortId?: string | undefined;
58
73
  shortId: string;
59
- spec?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | undefined;
74
+ spec?: (import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec) | undefined;
60
75
  statisticsBaseDomain?: string | undefined;
61
76
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
62
77
  statusSetAt: string;
63
78
  webStorageUsageInBytes: number;
64
79
  webStorageUsageInBytesSetAt: string;
65
- } | {
80
+ }): DataModel<{
66
81
  createdAt: string;
67
82
  customerId: string;
68
83
  customerMeta: {
69
84
  id: string;
70
85
  };
71
86
  description: string;
72
- disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason | undefined;
73
- disabledAt?: string | undefined;
87
+ disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason;
88
+ disabledAt?: string;
74
89
  enabled: boolean;
75
90
  id: string;
76
- imageRefId?: string | undefined;
91
+ imageRefId?: string;
77
92
  isReady: boolean;
78
- projectHostingId?: string | undefined;
93
+ projectHostingId?: string;
79
94
  readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedProjectReadinessStatus;
80
- serverId?: string | undefined;
95
+ serverId?: string;
81
96
  shortId: string;
82
97
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
83
98
  statusSetAt: string;
84
99
  webStorageUsageInBytes: number;
85
100
  webStorageUsageInBytesSetAt: string;
86
- }): DataModel<{
101
+ } | {
87
102
  clusterDomain?: string | undefined;
88
103
  clusterID?: string | undefined;
104
+ clusterId?: string | undefined;
89
105
  createdAt: string;
90
106
  customerId: string;
91
107
  description: string;
@@ -103,33 +119,12 @@ declare const ProjectCommon_base: import("polytype").Polytype.ClusteredConstruct
103
119
  serverId?: string | undefined;
104
120
  serverShortId?: string | undefined;
105
121
  shortId: string;
106
- spec?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | undefined;
122
+ spec?: (import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec) | undefined;
107
123
  statisticsBaseDomain?: string | undefined;
108
124
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
109
125
  statusSetAt: string;
110
126
  webStorageUsageInBytes: number;
111
127
  webStorageUsageInBytesSetAt: string;
112
- } | {
113
- createdAt: string;
114
- customerId: string;
115
- customerMeta: {
116
- id: string;
117
- };
118
- description: string;
119
- disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason | undefined;
120
- disabledAt?: string | undefined;
121
- enabled: boolean;
122
- id: string;
123
- imageRefId?: string | undefined;
124
- isReady: boolean;
125
- projectHostingId?: string | undefined;
126
- readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedProjectReadinessStatus;
127
- serverId?: string | undefined;
128
- shortId: string;
129
- status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
130
- statusSetAt: string;
131
- webStorageUsageInBytes: number;
132
- webStorageUsageInBytesSetAt: string;
133
128
  }>;
134
129
  }, typeof Project]>;
135
130
  declare class ProjectCommon extends ProjectCommon_base {
@@ -141,6 +136,7 @@ declare const ProjectDetailed_base: import("polytype").Polytype.ClusteredConstru
141
136
  new (data: {
142
137
  clusterDomain?: string | undefined;
143
138
  clusterID?: string | undefined;
139
+ clusterId?: string | undefined;
144
140
  createdAt: string;
145
141
  customerId: string;
146
142
  description: string;
@@ -158,7 +154,7 @@ declare const ProjectDetailed_base: import("polytype").Polytype.ClusteredConstru
158
154
  serverId?: string | undefined;
159
155
  serverShortId?: string | undefined;
160
156
  shortId: string;
161
- spec?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | undefined;
157
+ spec?: (import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec) | undefined;
162
158
  statisticsBaseDomain?: string | undefined;
163
159
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
164
160
  statusSetAt: string;
@@ -167,6 +163,7 @@ declare const ProjectDetailed_base: import("polytype").Polytype.ClusteredConstru
167
163
  }): DataModel<{
168
164
  clusterDomain?: string | undefined;
169
165
  clusterID?: string | undefined;
166
+ clusterId?: string | undefined;
170
167
  createdAt: string;
171
168
  customerId: string;
172
169
  description: string;
@@ -184,7 +181,7 @@ declare const ProjectDetailed_base: import("polytype").Polytype.ClusteredConstru
184
181
  serverId?: string | undefined;
185
182
  serverShortId?: string | undefined;
186
183
  shortId: string;
187
- spec?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | undefined;
184
+ spec?: (import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectVisitorSpec | import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectHardwareSpec) | undefined;
188
185
  statisticsBaseDomain?: string | undefined;
189
186
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
190
187
  statusSetAt: string;
@@ -203,15 +200,15 @@ declare const ProjectListItem_base: import("polytype").Polytype.ClusteredConstru
203
200
  id: string;
204
201
  };
205
202
  description: string;
206
- disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason | undefined;
207
- disabledAt?: string | undefined;
203
+ disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason;
204
+ disabledAt?: string;
208
205
  enabled: boolean;
209
206
  id: string;
210
- imageRefId?: string | undefined;
207
+ imageRefId?: string;
211
208
  isReady: boolean;
212
- projectHostingId?: string | undefined;
209
+ projectHostingId?: string;
213
210
  readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedProjectReadinessStatus;
214
- serverId?: string | undefined;
211
+ serverId?: string;
215
212
  shortId: string;
216
213
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
217
214
  statusSetAt: string;
@@ -224,15 +221,15 @@ declare const ProjectListItem_base: import("polytype").Polytype.ClusteredConstru
224
221
  id: string;
225
222
  };
226
223
  description: string;
227
- disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason | undefined;
228
- disabledAt?: string | undefined;
224
+ disableReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDisableReason;
225
+ disabledAt?: string;
229
226
  enabled: boolean;
230
227
  id: string;
231
- imageRefId?: string | undefined;
228
+ imageRefId?: string;
232
229
  isReady: boolean;
233
- projectHostingId?: string | undefined;
230
+ projectHostingId?: string;
234
231
  readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedProjectReadinessStatus;
235
- serverId?: string | undefined;
232
+ serverId?: string;
236
233
  shortId: string;
237
234
  status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectProjectStatus;
238
235
  statusSetAt: string;
@@ -243,4 +240,17 @@ declare const ProjectListItem_base: import("polytype").Polytype.ClusteredConstru
243
240
  export declare class ProjectListItem extends ProjectListItem_base {
244
241
  constructor(data: ProjectListItemData);
245
242
  }
243
+ export declare class ProjectListQuery extends ListQueryModel<ProjectListQueryModelData> {
244
+ constructor(query?: ProjectListQueryModelData);
245
+ refine(query: ProjectListQueryModelData): ProjectListQuery;
246
+ execute: AsyncResourceVariant<() => Promise<ProjectList>>;
247
+ getTotalCount: AsyncResourceVariant<() => Promise<number>>;
248
+ findOneAndOnly: AsyncResourceVariant<() => Promise<ProjectListItem | undefined>>;
249
+ }
250
+ declare const ProjectList_base: import("polytype").Polytype.ClusteredConstructor<[typeof ProjectListQuery, {
251
+ new (items: ProjectListItem[], totalCount: number): ListDataModel<ProjectListItem>;
252
+ }]>;
253
+ export declare class ProjectList extends ProjectList_base {
254
+ constructor(query: ProjectListQueryModelData, projects: ProjectListItem[], totalCount: number);
255
+ }
246
256
  export {};
@@ -1,7 +1,8 @@
1
- import { ProjectListItemData, ProjectData, ProjectListQuery } from "../types.js";
1
+ import { ProjectListItemData, ProjectData, ProjectListQueryData } from "../types.js";
2
+ import { QueryResponseData } from "../../../base/index.js";
2
3
  export interface ProjectBehaviors {
3
4
  find: (id: string) => Promise<ProjectData | undefined>;
4
- list: (query?: ProjectListQuery) => Promise<ProjectListItemData[]>;
5
+ list: (query?: ProjectListQueryData) => Promise<QueryResponseData<ProjectListItemData>>;
5
6
  create: (serverId: string, description: string) => Promise<{
6
7
  id: string;
7
8
  }>;
@@ -1,4 +1,10 @@
1
1
  import { MittwaldAPIV2 } from "@mittwald/api-client";
2
- export type ProjectListQuery = MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query;
2
+ import { Server } from "../../server/index.js";
3
+ import { Customer } from "../../customer/index.js";
4
+ export type ProjectListQueryData = MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query;
5
+ export type ProjectListQueryModelData = Omit<ProjectListQueryData, "serverId" | "customerId"> & {
6
+ server?: Server;
7
+ customer?: Customer;
8
+ };
3
9
  export type ProjectData = MittwaldAPIV2.Operations.ProjectGetProject.ResponseData;
4
10
  export type ProjectListItemData = MittwaldAPIV2.Operations.ProjectListProjects.ResponseData[number];
@@ -1,2 +1,6 @@
1
- import { FC, PropsWithChildren } from "react";
2
- export declare const MittwaldApiModelProvider: FC<PropsWithChildren>;
1
+ import { FC, PropsWithChildren, ReactNode } from "react";
2
+ interface Props extends PropsWithChildren {
3
+ fallback?: ReactNode;
4
+ }
5
+ export declare const MittwaldApiModelProvider: FC<Props>;
6
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Commons } from "@mittwald/api-client";
2
+ export declare const refreshProvideReactCache: (tag: string) => void;
3
+ export declare const addTagToProvideReactCache: (tag: string) => void;
4
+ export declare const addUrlTagToProvideReactCache: Commons.RequestOptions["onBeforeRequest"];
@@ -1,4 +1,5 @@
1
+ export { refreshProvideReactCache, addTagToProvideReactCache, addUrlTagToProvideReactCache, } from "./asyncResourceInvalidation.js";
1
2
  export * from "./MittwaldApiModelProvider.js";
2
3
  export * from "./reactUsePromise.js";
3
- export { type AsyncResourceVariant } from "../lib/provideReact.js";
4
- export { provideReact } from "../lib/provideReact.js";
4
+ export { type AsyncResourceVariant } from "./provideReact.js";
5
+ export { provideReact } from "./provideReact.js";
@@ -0,0 +1,9 @@
1
+ import { AsyncResource } from "./reactUsePromise.js";
2
+ import { AsyncReturnType } from "type-fest";
3
+ type AsyncFn = (...args: any[]) => Promise<unknown>;
4
+ export declare const provideReact: <T extends AsyncFn>(loader: T, dependencies?: string[]) => AsyncResourceVariant<T>;
5
+ export type AsyncResourceVariant<T extends AsyncFn> = T & {
6
+ asResource: (...params: Parameters<T>) => AsyncResource<AsyncReturnType<T>>;
7
+ use: (...params: Parameters<T>) => AsyncReturnType<T>;
8
+ };
9
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const reactProvisionContext: import("context").CtxCascadeApi<{
2
+ id: string;
3
+ }>;
@@ -1 +1,2 @@
1
+ export type ReactUsePromiseModule = typeof import("@mittwald/react-use-promise");
1
2
  export type { AsyncResource, getAsyncResource, } from "@mittwald/react-use-promise";
@@ -1,31 +1,25 @@
1
1
  import { ReferenceModel } from "../../base/ReferenceModel.js";
2
- import { ServerListItemData, ServerData } from "./types.js";
2
+ import { ServerData, ServerListItemData, ServerListQueryData, ServerListQueryModelData } from "./types.js";
3
3
  import { DataModel } from "../../base/DataModel.js";
4
- import { Project } from "../../project/index.js";
5
- import { ParamsExceptFirst } from "../../lib/types.js";
4
+ import { Project, ProjectListQuery } from "../../project/index.js";
5
+ import { FirstParameter, ParamsExceptFirst } from "../../lib/types.js";
6
+ import { AsyncResourceVariant } from "../../react/provideReact.js";
7
+ import { ListQueryModel } from "../../base/ListQueryModel.js";
8
+ import { ListDataModel } from "../../base/ListDataModel.js";
6
9
  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;
10
- };
11
- static get: ((id: string) => Promise<Server>) & {
12
- asResource: (id: string) => import("@mittwald/react-use-promise").AsyncResource<Server>;
13
- use: (id: string) => Server;
14
- };
15
- static list: ((query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query | undefined) => Promise<ServerListItem[]>) & {
16
- asResource: (query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query | undefined) => import("@mittwald/react-use-promise").AsyncResource<ServerListItem[]>;
17
- use: (query?: import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query | undefined) => ServerListItem[];
18
- };
10
+ readonly projects: ProjectListQuery;
11
+ constructor(id: string);
19
12
  static ofId(id: string): Server;
13
+ static find: AsyncResourceVariant<(id: string) => Promise<ServerDetailed | undefined>>;
14
+ static get: AsyncResourceVariant<(id: string) => Promise<ServerDetailed>>;
15
+ static query(query?: ServerListQueryModelData): ServerListQuery;
16
+ /** @deprecated: use query() or customer.servers */
17
+ static list: AsyncResourceVariant<(query?: ServerListQueryData) => Promise<Readonly<ServerListItem[]>>>;
20
18
  createProject(...parameters: ParamsExceptFirst<typeof Project.create>): ReturnType<typeof Project.create>;
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
- 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[]>;
23
- use: (query?: Omit<import("@mittwald/api-client").MittwaldAPIV2.Paths.V2Projects.Get.Parameters.Query | undefined, "serverId"> | undefined) => readonly import("../../project/index.js").ProjectListItem[];
24
- };
25
- getDetailed: (() => Promise<ServerDetailed>) & {
26
- asResource: () => import("@mittwald/react-use-promise").AsyncResource<ServerDetailed>;
27
- use: () => ServerDetailed;
28
- };
19
+ /** @deprecated Use Server.projects property */
20
+ listProjects: AsyncResourceVariant<(query?: Omit<FirstParameter<typeof Project.list>, "serverId">) => ReturnType<typeof Project.list>>;
21
+ getDetailed: AsyncResourceVariant<() => Promise<ServerDetailed>>;
22
+ findDetailed: AsyncResourceVariant<() => Promise<ServerDetailed | undefined>>;
29
23
  }
30
24
  declare const ServerCommon_base: import("polytype").Polytype.ClusteredConstructor<[{
31
25
  new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServer | {
@@ -33,7 +27,7 @@ declare const ServerCommon_base: import("polytype").Polytype.ClusteredConstructo
33
27
  createdAt: string;
34
28
  customerId: string;
35
29
  description: string;
36
- disabledReason?: "suspended" | undefined;
30
+ disabledReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerDisableReason | undefined;
37
31
  id: string;
38
32
  imageRefId?: string | undefined;
39
33
  isReady: boolean;
@@ -48,7 +42,7 @@ declare const ServerCommon_base: import("polytype").Polytype.ClusteredConstructo
48
42
  createdAt: string;
49
43
  customerId: string;
50
44
  description: string;
51
- disabledReason?: "suspended" | undefined;
45
+ disabledReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerDisableReason | undefined;
52
46
  id: string;
53
47
  imageRefId?: string | undefined;
54
48
  isReady: boolean;
@@ -63,10 +57,59 @@ declare const ServerCommon_base: import("polytype").Polytype.ClusteredConstructo
63
57
  declare class ServerCommon extends ServerCommon_base {
64
58
  constructor(data: ServerListItemData | ServerData);
65
59
  }
66
- declare const ServerListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, typeof DataModel<ServerListItemData>]>;
60
+ declare const ServerDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, {
61
+ new (data: {
62
+ clusterName: string;
63
+ createdAt: string;
64
+ customerId: string;
65
+ description: string;
66
+ disabledReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerDisableReason | undefined;
67
+ id: string;
68
+ imageRefId?: string | undefined;
69
+ isReady: boolean;
70
+ machineType: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectMachineType;
71
+ readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedServerReadinessStatus;
72
+ shortId: string;
73
+ statisticsBaseDomain?: string | undefined;
74
+ status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerStatus;
75
+ storage: string;
76
+ }): DataModel<{
77
+ clusterName: string;
78
+ createdAt: string;
79
+ customerId: string;
80
+ description: string;
81
+ disabledReason?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerDisableReason | undefined;
82
+ id: string;
83
+ imageRefId?: string | undefined;
84
+ isReady: boolean;
85
+ machineType: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectMachineType;
86
+ readiness: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectDeprecatedServerReadinessStatus;
87
+ shortId: string;
88
+ statisticsBaseDomain?: string | undefined;
89
+ status: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServerStatus;
90
+ storage: string;
91
+ }>;
92
+ }]>;
93
+ export declare class ServerDetailed extends ServerDetailed_base {
94
+ constructor(data: ServerData);
95
+ }
96
+ declare const ServerListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, {
97
+ new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServer): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ProjectServer>;
98
+ }]>;
67
99
  export declare class ServerListItem extends ServerListItem_base {
100
+ constructor(data: ServerListItemData);
68
101
  }
69
- declare const ServerDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerCommon, typeof DataModel<ServerData>]>;
70
- export declare class ServerDetailed extends ServerDetailed_base {
102
+ export declare class ServerListQuery extends ListQueryModel<ServerListQueryModelData> {
103
+ constructor(query?: ServerListQueryModelData);
104
+ refine(query: ServerListQueryModelData): ServerListQuery;
105
+ execute: AsyncResourceVariant<() => Promise<ServerList>>;
106
+ getTotalCount: AsyncResourceVariant<() => Promise<number>>;
107
+ findOneAndOnly: AsyncResourceVariant<() => Promise<ServerListItem | undefined>>;
108
+ }
109
+ declare const ServerList_base: import("polytype").Polytype.ClusteredConstructor<[typeof ServerListQuery, {
110
+ new (items: ServerListItem[], totalCount: number): ListDataModel<ServerListItem>;
111
+ }]>;
112
+ export declare class ServerList extends ServerList_base {
113
+ constructor(query: ServerListQueryData, servers: ServerListItem[], totalCount: number);
71
114
  }
72
115
  export {};
@@ -1,5 +1,6 @@
1
- import { ServerListItemData, ServerData, ServerListQuery } from "../types.js";
1
+ import { ServerListItemData, ServerData, ServerListQueryData } from "../types.js";
2
+ import { QueryResponseData } from "../../../base/index.js";
2
3
  export interface ServerBehaviors {
3
4
  find: (id: string) => Promise<ServerData | undefined>;
4
- list: (query?: ServerListQuery) => Promise<ServerListItemData[]>;
5
+ list: (query?: ServerListQueryData) => Promise<QueryResponseData<ServerListItemData>>;
5
6
  }
@@ -1,4 +1,8 @@
1
1
  import { MittwaldAPIV2 } from "@mittwald/api-client";
2
- export type ServerListQuery = MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query;
2
+ import { Customer } from "../../customer/index.js";
3
+ export type ServerListQueryData = MittwaldAPIV2.Paths.V2Servers.Get.Parameters.Query;
4
+ export type ServerListQueryModelData = Omit<ServerListQueryData, "customerId"> & {
5
+ customer?: Customer;
6
+ };
3
7
  export type ServerData = MittwaldAPIV2.Operations.ProjectGetServer.ResponseData;
4
8
  export type ServerListItemData = MittwaldAPIV2.Operations.ProjectListServers.ResponseData[number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-models",
3
- "version": "0.0.0-development-74e1fd1-20240611",
3
+ "version": "0.0.0-development-e096ee7-20240924",
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",
@@ -34,31 +34,42 @@
34
34
  "build": "run build:clean && run tsc",
35
35
  "build:clean": "rimraf dist",
36
36
  "lint": "run eslint .",
37
- "test": "node --experimental-vm-modules $(yarn bin jest)"
37
+ "test": "",
38
+ "test:compile": "run tsc --noEmit",
39
+ "test:unit": "node --experimental-vm-modules $(yarn bin jest)"
38
40
  },
39
41
  "dependencies": {
40
- "@mittwald/api-client": "^0.0.0-development-74e1fd1-20240611",
42
+ "@mittwald/api-client": "^0.0.0-development-e096ee7-20240924",
41
43
  "another-deep-freeze": "^1.0.0",
44
+ "context": "^3.0.31",
45
+ "object-code": "^1.3.3",
42
46
  "polytype": "^0.17.0",
43
- "type-fest": "^4.12.0"
47
+ "tsd": "^0.31.2",
48
+ "type-fest": "^4.23.0"
44
49
  },
45
50
  "devDependencies": {
46
51
  "@jest/globals": "^29.7.0",
47
- "@mittwald/react-use-promise": "^2.3.12",
52
+ "@mittwald/react-use-promise": "^2.5.0",
53
+ "@testing-library/dom": "^10.4.0",
54
+ "@testing-library/jest-dom": "^6.5.0",
55
+ "@testing-library/react": "^16.0.1",
48
56
  "@types/jest": "^29.5.12",
49
- "@types/react": "^18.2.64",
50
- "@typescript-eslint/eslint-plugin": "^7.1.1",
51
- "@typescript-eslint/parser": "^7.1.1",
57
+ "@types/react": "^18.3.3",
58
+ "@types/react-dom": "^18",
59
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
60
+ "@typescript-eslint/parser": "^7.18.0",
52
61
  "eslint": "^8.57.0",
53
62
  "eslint-config-prettier": "^9.1.0",
54
63
  "eslint-plugin-json": "^3.1.0",
55
- "eslint-plugin-prettier": "^5.1.3",
64
+ "eslint-plugin-prettier": "^5.2.1",
56
65
  "jest": "^29.7.0",
57
- "prettier": "^3.2.5",
58
- "react": "^18.2.0",
59
- "rimraf": "^5.0.5",
60
- "ts-jest": "^29.1.2",
61
- "typescript": "^5.4.2"
66
+ "jest-environment-jsdom": "^29.7.0",
67
+ "prettier": "^3.3.3",
68
+ "react": "^18.3.1",
69
+ "react-dom": "^18.3.1",
70
+ "rimraf": "^5.0.10",
71
+ "ts-jest": "^29.2.4",
72
+ "typescript": "^5.5.4"
62
73
  },
63
74
  "peerDependencies": {
64
75
  "@mittwald/react-use-promise": "^2.3.12"
@@ -71,5 +82,5 @@
71
82
  "optional": true
72
83
  }
73
84
  },
74
- "gitHead": "1cf903cbfe7720456fdf81dfe0cfed006debe130"
85
+ "gitHead": "e93211612e230da1167088de10ad01bde7ede483"
75
86
  }
@@ -1,5 +0,0 @@
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
- });
@@ -1,11 +0,0 @@
1
- import { AsyncResource } from "../react/reactUsePromise.js";
2
- type FnParameters = unknown[];
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>;
5
- export type AsyncResourceVariant<TValue, TParams extends FnParameters> = TParams extends null ? AsyncFn<TValue, TParams> & {
6
- asResource: () => AsyncResource<TValue>;
7
- } : AsyncFn<TValue, TParams> & {
8
- asResource: (...params: TParams) => AsyncResource<TValue>;
9
- use: (...params: TParams) => TValue;
10
- };
11
- export {};