@mittwald/api-models 4.338.0 → 4.338.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.
Files changed (195) hide show
  1. package/package.json +3 -3
  2. package/dist/esm/app/AppInstallation/AppInstallation.js +0 -89
  3. package/dist/esm/app/AppInstallation/behaviors/api.js +0 -24
  4. package/dist/esm/app/AppInstallation/behaviors/index.js +0 -2
  5. package/dist/esm/app/AppInstallation/behaviors/types.js +0 -1
  6. package/dist/esm/app/AppInstallation/index.js +0 -2
  7. package/dist/esm/app/AppInstallation/types.js +0 -1
  8. package/dist/esm/app/index.js +0 -1
  9. package/dist/esm/article/Article/Article.js +0 -79
  10. package/dist/esm/article/Article/behaviors/api.js +0 -22
  11. package/dist/esm/article/Article/behaviors/index.js +0 -2
  12. package/dist/esm/article/Article/behaviors/types.js +0 -1
  13. package/dist/esm/article/Article/index.js +0 -2
  14. package/dist/esm/article/Article/types.js +0 -1
  15. package/dist/esm/article/index.js +0 -1
  16. package/dist/esm/base/DataModel.js +0 -7
  17. package/dist/esm/base/ListDataModel.js +0 -8
  18. package/dist/esm/base/ListQueryModel.js +0 -11
  19. package/dist/esm/base/Money.js +0 -5
  20. package/dist/esm/base/ReferenceModel.js +0 -9
  21. package/dist/esm/base/assertObjectFound.js +0 -9
  22. package/dist/esm/base/index.js +0 -6
  23. package/dist/esm/base/types.js +0 -1
  24. package/dist/esm/config/behaviors/api.js +0 -51
  25. package/dist/esm/config/behaviors/index.js +0 -1
  26. package/dist/esm/config/config.js +0 -14
  27. package/dist/esm/config/index.js +0 -1
  28. package/dist/esm/contract/Contract/Contract.js +0 -78
  29. package/dist/esm/contract/Contract/behaviors/api.js +0 -20
  30. package/dist/esm/contract/Contract/behaviors/index.js +0 -2
  31. package/dist/esm/contract/Contract/behaviors/types.js +0 -1
  32. package/dist/esm/contract/Contract/index.js +0 -2
  33. package/dist/esm/contract/Contract/types.js +0 -1
  34. package/dist/esm/contract/ContractItem/ContractItem.js +0 -31
  35. package/dist/esm/contract/ContractItem/behaviors/api.js +0 -13
  36. package/dist/esm/contract/ContractItem/behaviors/index.js +0 -2
  37. package/dist/esm/contract/ContractItem/behaviors/types.js +0 -1
  38. package/dist/esm/contract/ContractItem/index.js +0 -2
  39. package/dist/esm/contract/ContractItem/types.js +0 -1
  40. package/dist/esm/contract/index.js +0 -2
  41. package/dist/esm/customer/Customer/Customer.js +0 -96
  42. package/dist/esm/customer/Customer/behaviors/api.js +0 -30
  43. package/dist/esm/customer/Customer/behaviors/index.js +0 -2
  44. package/dist/esm/customer/Customer/behaviors/types.js +0 -1
  45. package/dist/esm/customer/Customer/index.js +0 -2
  46. package/dist/esm/customer/Customer/types.js +0 -1
  47. package/dist/esm/customer/index.js +0 -1
  48. package/dist/esm/domain/Ingress/Ingress.js +0 -106
  49. package/dist/esm/domain/Ingress/behaviors/api.js +0 -25
  50. package/dist/esm/domain/Ingress/behaviors/index.js +0 -2
  51. package/dist/esm/domain/Ingress/behaviors/types.js +0 -1
  52. package/dist/esm/domain/Ingress/index.js +0 -2
  53. package/dist/esm/domain/Ingress/types.js +0 -1
  54. package/dist/esm/domain/IngressPath/IngressPath.js +0 -15
  55. package/dist/esm/domain/IngressPath/IngressPath.test.js +0 -16
  56. package/dist/esm/domain/IngressPath/index.js +0 -2
  57. package/dist/esm/domain/IngressPath/types.js +0 -1
  58. package/dist/esm/domain/IngressTarget/IngressTarget.js +0 -40
  59. package/dist/esm/domain/IngressTarget/IngressTarget.test-types.js +0 -10
  60. package/dist/esm/domain/IngressTarget/index.js +0 -2
  61. package/dist/esm/domain/IngressTarget/types.js +0 -1
  62. package/dist/esm/domain/index.js +0 -1
  63. package/dist/esm/errors/ObjectNotFoundError.js +0 -7
  64. package/dist/esm/index.js +0 -7
  65. package/dist/esm/lib/deepFreeze.js +0 -4
  66. package/dist/esm/lib/joinedId.js +0 -1
  67. package/dist/esm/lib/types.js +0 -1
  68. package/dist/esm/marketplace/Contributor/Contributor.js +0 -83
  69. package/dist/esm/marketplace/Contributor/ContributorIncomingInvoice.js +0 -53
  70. package/dist/esm/marketplace/Contributor/behaviors/api.js +0 -39
  71. package/dist/esm/marketplace/Contributor/behaviors/index.js +0 -2
  72. package/dist/esm/marketplace/Contributor/behaviors/types.js +0 -1
  73. package/dist/esm/marketplace/Contributor/index.js +0 -3
  74. package/dist/esm/marketplace/Contributor/types.js +0 -1
  75. package/dist/esm/marketplace/index.js +0 -1
  76. package/dist/esm/project/Project/Project.js +0 -121
  77. package/dist/esm/project/Project/behaviors/api.js +0 -58
  78. package/dist/esm/project/Project/behaviors/inMem.js +0 -27
  79. package/dist/esm/project/Project/behaviors/index.js +0 -3
  80. package/dist/esm/project/Project/behaviors/types.js +0 -1
  81. package/dist/esm/project/Project/index.js +0 -2
  82. package/dist/esm/project/Project/types.js +0 -1
  83. package/dist/esm/project/index.js +0 -1
  84. package/dist/esm/react/MittwaldApiModelProvider.js +0 -12
  85. package/dist/esm/react/asyncResourceInvalidation.js +0 -29
  86. package/dist/esm/react/index.js +0 -4
  87. package/dist/esm/react/provideReact.js +0 -27
  88. package/dist/esm/react/provideReact.test-types.js +0 -21
  89. package/dist/esm/react/reactProvisionContext.js +0 -2
  90. package/dist/esm/react/reactUsePromise.js +0 -17
  91. package/dist/esm/react.js +0 -1
  92. package/dist/esm/server/Server/Server.js +0 -102
  93. package/dist/esm/server/Server/behaviors/api.js +0 -22
  94. package/dist/esm/server/Server/behaviors/index.js +0 -2
  95. package/dist/esm/server/Server/behaviors/types.js +0 -1
  96. package/dist/esm/server/Server/index.js +0 -1
  97. package/dist/esm/server/Server/types.js +0 -1
  98. package/dist/esm/server/index.js +0 -1
  99. package/dist/types/app/AppInstallation/AppInstallation.d.ts +0 -142
  100. package/dist/types/app/AppInstallation/behaviors/api.d.ts +0 -3
  101. package/dist/types/app/AppInstallation/behaviors/index.d.ts +0 -2
  102. package/dist/types/app/AppInstallation/behaviors/types.d.ts +0 -6
  103. package/dist/types/app/AppInstallation/index.d.ts +0 -2
  104. package/dist/types/app/AppInstallation/types.d.ts +0 -4
  105. package/dist/types/app/index.d.ts +0 -1
  106. package/dist/types/article/Article/Article.d.ts +0 -133
  107. package/dist/types/article/Article/behaviors/api.d.ts +0 -3
  108. package/dist/types/article/Article/behaviors/index.d.ts +0 -2
  109. package/dist/types/article/Article/behaviors/types.d.ts +0 -6
  110. package/dist/types/article/Article/index.d.ts +0 -2
  111. package/dist/types/article/Article/types.d.ts +0 -5
  112. package/dist/types/article/index.d.ts +0 -1
  113. package/dist/types/base/DataModel.d.ts +0 -5
  114. package/dist/types/base/ListDataModel.d.ts +0 -5
  115. package/dist/types/base/ListQueryModel.d.ts +0 -9
  116. package/dist/types/base/Money.d.ts +0 -3
  117. package/dist/types/base/ReferenceModel.d.ts +0 -5
  118. package/dist/types/base/assertObjectFound.d.ts +0 -3
  119. package/dist/types/base/index.d.ts +0 -6
  120. package/dist/types/base/types.d.ts +0 -6
  121. package/dist/types/config/behaviors/api.d.ts +0 -12
  122. package/dist/types/config/behaviors/index.d.ts +0 -1
  123. package/dist/types/config/config.d.ts +0 -25
  124. package/dist/types/config/index.d.ts +0 -1
  125. package/dist/types/contract/Contract/Contract.d.ts +0 -68
  126. package/dist/types/contract/Contract/behaviors/api.d.ts +0 -3
  127. package/dist/types/contract/Contract/behaviors/index.d.ts +0 -2
  128. package/dist/types/contract/Contract/behaviors/types.d.ts +0 -9
  129. package/dist/types/contract/Contract/index.d.ts +0 -2
  130. package/dist/types/contract/Contract/types.d.ts +0 -8
  131. package/dist/types/contract/ContractItem/ContractItem.d.ts +0 -64
  132. package/dist/types/contract/ContractItem/behaviors/api.d.ts +0 -3
  133. package/dist/types/contract/ContractItem/behaviors/index.d.ts +0 -2
  134. package/dist/types/contract/ContractItem/behaviors/types.d.ts +0 -4
  135. package/dist/types/contract/ContractItem/index.d.ts +0 -2
  136. package/dist/types/contract/ContractItem/types.d.ts +0 -2
  137. package/dist/types/contract/index.d.ts +0 -2
  138. package/dist/types/customer/Customer/Customer.d.ts +0 -146
  139. package/dist/types/customer/Customer/behaviors/api.d.ts +0 -3
  140. package/dist/types/customer/Customer/behaviors/index.d.ts +0 -2
  141. package/dist/types/customer/Customer/behaviors/types.d.ts +0 -7
  142. package/dist/types/customer/Customer/index.d.ts +0 -2
  143. package/dist/types/customer/Customer/types.d.ts +0 -5
  144. package/dist/types/customer/index.d.ts +0 -1
  145. package/dist/types/domain/Ingress/Ingress.d.ts +0 -109
  146. package/dist/types/domain/Ingress/behaviors/api.d.ts +0 -3
  147. package/dist/types/domain/Ingress/behaviors/index.d.ts +0 -2
  148. package/dist/types/domain/Ingress/behaviors/types.d.ts +0 -6
  149. package/dist/types/domain/Ingress/index.d.ts +0 -2
  150. package/dist/types/domain/Ingress/types.d.ts +0 -8
  151. package/dist/types/domain/IngressPath/IngressPath.d.ts +0 -11
  152. package/dist/types/domain/IngressPath/IngressPath.test.d.ts +0 -1
  153. package/dist/types/domain/IngressPath/index.d.ts +0 -2
  154. package/dist/types/domain/IngressPath/types.d.ts +0 -2
  155. package/dist/types/domain/IngressTarget/IngressTarget.d.ts +0 -24
  156. package/dist/types/domain/IngressTarget/IngressTarget.test-types.d.ts +0 -1
  157. package/dist/types/domain/IngressTarget/index.d.ts +0 -2
  158. package/dist/types/domain/IngressTarget/types.d.ts +0 -6
  159. package/dist/types/domain/index.d.ts +0 -1
  160. package/dist/types/errors/ObjectNotFoundError.d.ts +0 -3
  161. package/dist/types/index.d.ts +0 -7
  162. package/dist/types/lib/deepFreeze.d.ts +0 -5
  163. package/dist/types/lib/joinedId.d.ts +0 -1
  164. package/dist/types/lib/types.d.ts +0 -2
  165. package/dist/types/marketplace/Contributor/Contributor.d.ts +0 -49
  166. package/dist/types/marketplace/Contributor/ContributorIncomingInvoice.d.ts +0 -31
  167. package/dist/types/marketplace/Contributor/behaviors/api.d.ts +0 -3
  168. package/dist/types/marketplace/Contributor/behaviors/index.d.ts +0 -2
  169. package/dist/types/marketplace/Contributor/behaviors/types.d.ts +0 -10
  170. package/dist/types/marketplace/Contributor/index.d.ts +0 -3
  171. package/dist/types/marketplace/Contributor/types.d.ts +0 -6
  172. package/dist/types/marketplace/index.d.ts +0 -1
  173. package/dist/types/project/Project/Project.d.ts +0 -292
  174. package/dist/types/project/Project/behaviors/api.d.ts +0 -3
  175. package/dist/types/project/Project/behaviors/inMem.d.ts +0 -3
  176. package/dist/types/project/Project/behaviors/index.d.ts +0 -3
  177. package/dist/types/project/Project/behaviors/types.d.ts +0 -12
  178. package/dist/types/project/Project/index.d.ts +0 -2
  179. package/dist/types/project/Project/types.d.ts +0 -10
  180. package/dist/types/project/index.d.ts +0 -1
  181. package/dist/types/react/MittwaldApiModelProvider.d.ts +0 -6
  182. package/dist/types/react/asyncResourceInvalidation.d.ts +0 -4
  183. package/dist/types/react/index.d.ts +0 -5
  184. package/dist/types/react/provideReact.d.ts +0 -12
  185. package/dist/types/react/provideReact.test-types.d.ts +0 -1
  186. package/dist/types/react/reactProvisionContext.d.ts +0 -3
  187. package/dist/types/react/reactUsePromise.d.ts +0 -2
  188. package/dist/types/react.d.ts +0 -1
  189. package/dist/types/server/Server/Server.d.ts +0 -115
  190. package/dist/types/server/Server/behaviors/api.d.ts +0 -3
  191. package/dist/types/server/Server/behaviors/index.d.ts +0 -2
  192. package/dist/types/server/Server/behaviors/types.d.ts +0 -6
  193. package/dist/types/server/Server/index.d.ts +0 -1
  194. package/dist/types/server/Server/types.d.ts +0 -8
  195. package/dist/types/server/index.d.ts +0 -1
@@ -1,121 +0,0 @@
1
- import { config } from "../../config/config.js";
2
- import { classes } from "polytype";
3
- import { DataModel } from "../../base/DataModel.js";
4
- import assertObjectFound from "../../base/assertObjectFound.js";
5
- import { Server } from "../../server/index.js";
6
- import { provideReact, } from "../../react/provideReact.js";
7
- import { Customer } from "../../customer/Customer/Customer.js";
8
- import { ReferenceModel } from "../../base/ReferenceModel.js";
9
- import { Ingress, IngressListItem, IngressListQuery, } from "../../domain/index.js";
10
- import { ListQueryModel } from "../../base/ListQueryModel.js";
11
- import { ListDataModel } from "../../base/ListDataModel.js";
12
- import { AppInstallationListQuery } from "../../app/index.js";
13
- export class Project extends ReferenceModel {
14
- ingresses;
15
- appInstallations;
16
- constructor(id) {
17
- super(id);
18
- this.ingresses = new IngressListQuery({
19
- project: this,
20
- });
21
- this.appInstallations = new AppInstallationListQuery(this);
22
- }
23
- static ofId(id) {
24
- return new Project(id);
25
- }
26
- static find = provideReact(async (id) => {
27
- const data = await config.behaviors.project.find(id);
28
- if (data !== undefined) {
29
- return new ProjectDetailed(data);
30
- }
31
- });
32
- static get = provideReact(async (id) => {
33
- const project = await this.find(id);
34
- assertObjectFound(project, this, id);
35
- return project;
36
- });
37
- static query(query = {}) {
38
- return new ProjectListQuery(query);
39
- }
40
- /** @deprecated: use query(), Customer.projects or Server.projects */
41
- static list = provideReact(async (query = {}) => {
42
- return new ProjectListQuery(query).execute().then((r) => r.items);
43
- });
44
- static async create(serverId, description) {
45
- const { id } = await config.behaviors.project.create(serverId, description);
46
- return new Project(id);
47
- }
48
- getDetailed = provideReact(() => Project.get(this.id), [this.id]);
49
- findDetailed = provideReact(() => Project.find(this.id), [this.id]);
50
- /** @deprecated: use ingresses property */
51
- listIngresses = provideReact(() => Ingress.list({ projectId: this.id }));
52
- getDefaultIngress = provideReact(async () => {
53
- const ingresses = await Project.ofId(this.id).listIngresses();
54
- const defaultIngress = ingresses.find((i) => i.data.isDefault);
55
- assertObjectFound(defaultIngress, IngressListItem, this);
56
- return defaultIngress;
57
- });
58
- async updateDescription(description) {
59
- await config.behaviors.project.updateDescription(this.id, description);
60
- }
61
- async leave() {
62
- await config.behaviors.project.leave(this.id);
63
- }
64
- async delete() {
65
- await config.behaviors.project.delete(this.id);
66
- }
67
- }
68
- class ProjectCommon extends classes((DataModel), Project) {
69
- server;
70
- customer;
71
- constructor(data) {
72
- super([data], [data.id]);
73
- this.server = data.serverId ? Server.ofId(data.serverId) : undefined;
74
- this.customer = Customer.ofId(data.customerId);
75
- }
76
- }
77
- export class ProjectDetailed extends classes(ProjectCommon, (DataModel)) {
78
- constructor(data) {
79
- super([data], [data]);
80
- }
81
- }
82
- export class ProjectListItem extends classes(ProjectCommon, (DataModel)) {
83
- constructor(data) {
84
- super([data], [data]);
85
- }
86
- }
87
- export class ProjectListQuery extends ListQueryModel {
88
- constructor(query = {}) {
89
- super(query);
90
- }
91
- refine(query) {
92
- return new ProjectListQuery({
93
- ...this.query,
94
- ...query,
95
- });
96
- }
97
- execute = provideReact(async () => {
98
- const { server, customer, ...query } = this.query;
99
- const { items, totalCount } = await config.behaviors.project.list({
100
- ...query,
101
- serverId: server?.id,
102
- customerId: customer?.id,
103
- });
104
- return new ProjectList(this.query, items.map((d) => new ProjectListItem(d)), totalCount);
105
- }, [this.queryId]);
106
- getTotalCount = provideReact(async () => {
107
- const { totalCount } = await this.refine({ limit: 1 }).execute();
108
- return totalCount;
109
- }, [this.queryId]);
110
- findOneAndOnly = provideReact(async () => {
111
- const { items, totalCount } = await this.refine({ limit: 2 }).execute();
112
- if (totalCount === 1) {
113
- return items[0];
114
- }
115
- }, [this.queryId]);
116
- }
117
- export class ProjectList extends classes(ProjectListQuery, (ListDataModel)) {
118
- constructor(query, projects, totalCount) {
119
- super([query], [projects, totalCount]);
120
- }
121
- }
@@ -1,58 +0,0 @@
1
- import { assertStatus, extractTotalCountHeader, } from "@mittwald/api-client";
2
- import { assertOneOfStatus } from "@mittwald/api-client";
3
- export const apiProjectBehaviors = (client) => ({
4
- find: async (id) => {
5
- const response = await client.project.getProject({
6
- projectId: id,
7
- });
8
- if (response.status === 200) {
9
- return response.data;
10
- }
11
- assertOneOfStatus(response, [403]);
12
- },
13
- list: async (query) => {
14
- const response = await client.project.listProjects({
15
- queryParameters: query,
16
- });
17
- assertStatus(response, 200);
18
- return {
19
- items: response.data,
20
- totalCount: extractTotalCountHeader(response),
21
- };
22
- },
23
- create: async (serverId, description) => {
24
- const response = await client.project.createProject({
25
- serverId,
26
- data: {
27
- description,
28
- },
29
- });
30
- assertStatus(response, 201);
31
- return response.data;
32
- },
33
- leave: async (id) => {
34
- const selfMembershipResponse = await client.project.getSelfMembershipForProject({
35
- projectId: id,
36
- });
37
- assertStatus(selfMembershipResponse, 200);
38
- const response = await client.project.deleteProjectMembership({
39
- projectMembershipId: selfMembershipResponse.data.id,
40
- });
41
- assertStatus(response, 204);
42
- },
43
- delete: async (id) => {
44
- const response = await client.project.deleteProject({
45
- projectId: id,
46
- });
47
- assertStatus(response, 204);
48
- },
49
- updateDescription: async (id, description) => {
50
- const response = await client.project.updateProjectDescription({
51
- projectId: id,
52
- data: {
53
- description,
54
- },
55
- });
56
- assertStatus(response, 204);
57
- },
58
- });
@@ -1,27 +0,0 @@
1
- export const inMemProjectBehaviors = (store) => ({
2
- find: async (id) => store.get(id),
3
- list: async () => {
4
- const items = Array.from(store.values()).map((detailedProject) => ({
5
- ...detailedProject,
6
- customerMeta: {
7
- id: detailedProject.customerId,
8
- },
9
- }));
10
- return {
11
- items,
12
- totalCount: items.length,
13
- };
14
- },
15
- create: async () => {
16
- throw new Error("Not implemented");
17
- },
18
- leave: async () => {
19
- throw new Error("Not implemented");
20
- },
21
- delete: async () => {
22
- throw new Error("Not implemented");
23
- },
24
- updateDescription: async () => {
25
- throw new Error("Not implemented");
26
- },
27
- });
@@ -1,3 +0,0 @@
1
- export * from "./api.js";
2
- export * from "./inMem.js";
3
- export * from "./types.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export * from "./Project.js";
2
- export * from "./types.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from "./Project/index.js";
@@ -1,12 +0,0 @@
1
- import { usePromise } from "@mittwald/react-use-promise";
2
- import { setModule } from "./reactUsePromise.js";
3
- export const MittwaldApiModelProvider = (props) => {
4
- const { fallback, children } = props;
5
- const module = usePromise(() => import("@mittwald/react-use-promise").then(setModule), [], {
6
- useSuspense: false,
7
- });
8
- if (!module.hasValue) {
9
- return fallback;
10
- }
11
- return children;
12
- };
@@ -1,29 +0,0 @@
1
- import { reactProvisionContext } from "./reactProvisionContext.js";
2
- import { refresh } from "@mittwald/react-use-promise";
3
- import { Store } from "@mittwald/react-use-promise/store";
4
- const cacheTagStore = new Store();
5
- export const refreshProvideReactCache = (tag) => {
6
- cacheTagStore.getAll(tag).forEach((ids) => {
7
- ids.forEach((id) => {
8
- refresh({
9
- tag: String(id),
10
- });
11
- });
12
- });
13
- };
14
- export const addTagToProvideReactCache = (tag) => {
15
- const context = reactProvisionContext.use();
16
- if (context) {
17
- const ids = cacheTagStore.get(tag) ?? new Set();
18
- ids.add(context.id);
19
- cacheTagStore.set(tag, () => ids, {
20
- tags: [tag],
21
- });
22
- }
23
- };
24
- export const addUrlTagToProvideReactCache = (request) => {
25
- const url = request.requestConfig.url;
26
- if (request.requestConfig.method === "GET" && url) {
27
- addTagToProvideReactCache(url);
28
- }
29
- };
@@ -1,4 +0,0 @@
1
- export { refreshProvideReactCache, addTagToProvideReactCache, addUrlTagToProvideReactCache, } from "./asyncResourceInvalidation.js";
2
- export * from "./MittwaldApiModelProvider.js";
3
- export * from "./reactUsePromise.js";
4
- export { provideReact } from "./provideReact.js";
@@ -1,27 +0,0 @@
1
- import { reactUsePromise } from "./reactUsePromise.js";
2
- import { hash } from "object-code";
3
- import { reactProvisionContext } from "./reactProvisionContext.js";
4
- import { joinedId } from "../lib/joinedId.js";
5
- export const provideReact = (loader, dependencies = []) => {
6
- const loaderHash = hash(loader);
7
- let cachedProvisionId;
8
- const getAsyncResource = (params) => {
9
- const provisionId = cachedProvisionId ??
10
- joinedId(loaderHash, ...dependencies
11
- .map((d) => (typeof d === "function" ? d() : d))
12
- .map((d) => hash(d)));
13
- cachedProvisionId = provisionId;
14
- const contextId = joinedId(provisionId, hash(params));
15
- const loaderWithContext = reactProvisionContext.bind({
16
- id: contextId,
17
- }, loader);
18
- return reactUsePromise.getAsyncResource(loaderWithContext, params, {
19
- loaderId: provisionId,
20
- tags: [contextId],
21
- });
22
- };
23
- return Object.assign(loader, {
24
- asResource: (...params) => getAsyncResource(params),
25
- use: (...params) => getAsyncResource(params).use(),
26
- });
27
- };
@@ -1,21 +0,0 @@
1
- import { provideReact } from "./provideReact.js";
2
- import { expectType } from "tsd";
3
- const reactProvided = provideReact(async (ignoredP1, ignoredP2) => Promise.resolve("foo"));
4
- function ignoredTestReturnTypesOfProvideReact() {
5
- const usedValue = reactProvided.use("foo");
6
- const asAsyncResource = reactProvided.asResource("foo");
7
- expectType(usedValue);
8
- expectType(asAsyncResource.use());
9
- }
10
- function ignoredTestParameterTypesOfProvideReact() {
11
- reactProvided.use("foo", true);
12
- reactProvided.asResource("foo", true);
13
- reactProvided.use("foo");
14
- reactProvided.asResource("foo");
15
- // @ts-expect-error Not assignable
16
- reactProvided.asResource(42);
17
- // @ts-expect-error Not assignable
18
- reactProvided.asResource("foo", 42);
19
- // @ts-expect-error Not assignable
20
- reactProvided.asResource("foo", true, 42);
21
- }
@@ -1,2 +0,0 @@
1
- import { createCascade } from "context";
2
- export const reactProvisionContext = createCascade();
@@ -1,17 +0,0 @@
1
- let module = undefined;
2
- /** @internal */
3
- export const reactUsePromise = new Proxy({}, {
4
- get: (_, prop) => {
5
- if (module === undefined) {
6
- // @todo Provide better error message
7
- throw new Error("ModelProvider not found");
8
- }
9
- if (prop in module) {
10
- return module[prop];
11
- }
12
- },
13
- });
14
- /** @internal */
15
- export const setModule = (theModule) => {
16
- module = theModule;
17
- };
package/dist/esm/react.js DELETED
@@ -1 +0,0 @@
1
- export * from "./react/index.js";
@@ -1,102 +0,0 @@
1
- import { ReferenceModel } from "../../base/ReferenceModel.js";
2
- import { config } from "../../config/config.js";
3
- import { classes } from "polytype";
4
- import { DataModel } from "../../base/DataModel.js";
5
- import assertObjectFound from "../../base/assertObjectFound.js";
6
- import { Project, ProjectListQuery } from "../../project/index.js";
7
- import { provideReact, } from "../../react/provideReact.js";
8
- import { ListQueryModel } from "../../base/ListQueryModel.js";
9
- import { ListDataModel } from "../../base/ListDataModel.js";
10
- export class Server extends ReferenceModel {
11
- projects;
12
- constructor(id) {
13
- super(id);
14
- this.projects = new ProjectListQuery({
15
- server: this,
16
- });
17
- }
18
- static ofId(id) {
19
- return new Server(id);
20
- }
21
- static find = provideReact(async (id) => {
22
- const data = await config.behaviors.server.find(id);
23
- if (data !== undefined) {
24
- return new ServerDetailed(data);
25
- }
26
- });
27
- static get = provideReact(async (id) => {
28
- const server = await this.find(id);
29
- assertObjectFound(server, this, id);
30
- return server;
31
- });
32
- static query(query = {}) {
33
- return new ServerListQuery(query);
34
- }
35
- /** @deprecated: use query() or customer.servers */
36
- static list = provideReact(async (query = {}) => {
37
- return new ServerListQuery(query).execute().then((r) => r.items);
38
- });
39
- async createProject(...parameters) {
40
- return Project.create(this.id, ...parameters);
41
- }
42
- /** @deprecated Use Server.projects property */
43
- listProjects = provideReact(async (query = {}) => {
44
- return Project.list({
45
- ...query,
46
- serverId: this.id,
47
- });
48
- });
49
- getDetailed = provideReact(() => Server.get(this.id), [this.id]);
50
- findDetailed = provideReact(() => Server.find(this.id), [this.id]);
51
- }
52
- // Common class for future extension
53
- class ServerCommon extends classes((DataModel), Server) {
54
- constructor(data) {
55
- super([data], [data.id]);
56
- }
57
- }
58
- export class ServerDetailed extends classes(ServerCommon, (DataModel)) {
59
- constructor(data) {
60
- super([data], [data]);
61
- }
62
- }
63
- export class ServerListItem extends classes(ServerCommon, (DataModel)) {
64
- constructor(data) {
65
- super([data], [data]);
66
- }
67
- }
68
- export class ServerListQuery extends ListQueryModel {
69
- constructor(query = {}) {
70
- super(query);
71
- }
72
- refine(query) {
73
- return new ServerListQuery({
74
- ...this.query,
75
- ...query,
76
- });
77
- }
78
- execute = provideReact(async () => {
79
- const { customer, ...query } = this.query;
80
- const { items, totalCount } = await config.behaviors.server.list({
81
- limit: config.defaultPaginationLimit,
82
- customerId: customer?.id,
83
- ...query,
84
- });
85
- return new ServerList(this.query, items.map((d) => new ServerListItem(d)), totalCount);
86
- }, [this.queryId]);
87
- getTotalCount = provideReact(async () => {
88
- const { totalCount } = await this.refine({ limit: 1 }).execute();
89
- return totalCount;
90
- }, [this.queryId]);
91
- findOneAndOnly = provideReact(async () => {
92
- const { items, totalCount } = await this.refine({ limit: 2 }).execute();
93
- if (totalCount === 1) {
94
- return items[0];
95
- }
96
- }, [this.queryId]);
97
- }
98
- export class ServerList extends classes(ServerListQuery, (ListDataModel)) {
99
- constructor(query, servers, totalCount) {
100
- super([query], [servers, totalCount]);
101
- }
102
- }
@@ -1,22 +0,0 @@
1
- import { assertStatus, assertOneOfStatus, extractTotalCountHeader, } from "@mittwald/api-client";
2
- export const apiServerBehaviors = (client) => ({
3
- find: async (id) => {
4
- const response = await client.project.getServer({
5
- serverId: id,
6
- });
7
- if (response.status === 200) {
8
- return response.data;
9
- }
10
- assertOneOfStatus(response, [403, 404]);
11
- },
12
- list: async (query) => {
13
- const response = await client.project.listServers({
14
- queryParameters: query,
15
- });
16
- assertStatus(response, 200);
17
- return {
18
- items: response.data,
19
- totalCount: extractTotalCountHeader(response),
20
- };
21
- },
22
- });
@@ -1,2 +0,0 @@
1
- export * from "./api.js";
2
- export * from "./types.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from "./Server.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from "./Server/index.js";
@@ -1,142 +0,0 @@
1
- import { DataModel } from "../../base/DataModel.js";
2
- import { ReferenceModel } from "../../base/ReferenceModel.js";
3
- import { AsyncResourceVariant } from "../../react/provideReact.js";
4
- import { AppInstallationData, AppInstallationListItemData, AppInstallationListQueryData } from "./types.js";
5
- import { ListQueryModel } from "../../base/ListQueryModel.js";
6
- import { ListDataModel } from "../../base/ListDataModel.js";
7
- import { Project } from "../../project/index.js";
8
- export declare class AppInstallation extends ReferenceModel {
9
- static find: AsyncResourceVariant<(id: string) => Promise<AppInstallationDetailed | undefined>>;
10
- static get: AsyncResourceVariant<(id: string) => Promise<AppInstallationDetailed>>;
11
- static ofId(id: string): AppInstallation;
12
- query(project: Project, query?: AppInstallationListQueryData): AppInstallationListQuery;
13
- /** @deprecated: use query() or project.appInstallations */
14
- static list: AsyncResourceVariant<(projectId: string, query?: AppInstallationListQueryData) => Promise<Readonly<Array<AppInstallationListItem>>>>;
15
- getDetailed: AsyncResourceVariant<() => Promise<AppInstallationDetailed>>;
16
- findDetailed: AsyncResourceVariant<() => Promise<AppInstallationDetailed | undefined>>;
17
- }
18
- declare const AppInstallationCommon_base: import("polytype").Polytype.ClusteredConstructor<[{
19
- new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppInstallation | {
20
- appId: string;
21
- appVersion: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppVersionStatus;
22
- createdAt: string;
23
- customDocumentRoot?: string | undefined;
24
- deletionRequested?: boolean | undefined;
25
- description: string;
26
- disabled: boolean;
27
- id: string;
28
- installationPath: string;
29
- lastError?: string | undefined;
30
- linkedDatabases: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLinkedDatabase[];
31
- lockedBy?: {
32
- [k: string]: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLockPurpose;
33
- } | undefined;
34
- phase: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppPhase;
35
- projectId: string;
36
- screenshotId?: string | undefined;
37
- screenshotRef?: string | undefined;
38
- shortId: string;
39
- systemSoftware: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppInstalledSystemSoftware[];
40
- updatePolicy: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppUpdatePolicy;
41
- userInputs: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppSavedUserInput[];
42
- }): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppInstallation | {
43
- appId: string;
44
- appVersion: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppVersionStatus;
45
- createdAt: string;
46
- customDocumentRoot?: string | undefined;
47
- deletionRequested?: boolean | undefined;
48
- description: string;
49
- disabled: boolean;
50
- id: string;
51
- installationPath: string;
52
- lastError?: string | undefined;
53
- linkedDatabases: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLinkedDatabase[];
54
- lockedBy?: {
55
- [k: string]: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLockPurpose;
56
- } | undefined;
57
- phase: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppPhase;
58
- projectId: string;
59
- screenshotId?: string | undefined;
60
- screenshotRef?: string | undefined;
61
- shortId: string;
62
- systemSoftware: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppInstalledSystemSoftware[];
63
- updatePolicy: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppUpdatePolicy;
64
- userInputs: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppSavedUserInput[];
65
- }>;
66
- }, typeof AppInstallation]>;
67
- declare class AppInstallationCommon extends AppInstallationCommon_base {
68
- constructor(data: AppInstallationListItemData | AppInstallationData);
69
- }
70
- declare const AppInstallationDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof AppInstallationCommon, {
71
- new (data: {
72
- appId: string;
73
- appVersion: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppVersionStatus;
74
- createdAt: string;
75
- customDocumentRoot?: string | undefined;
76
- deletionRequested?: boolean | undefined;
77
- description: string;
78
- disabled: boolean;
79
- id: string;
80
- installationPath: string;
81
- lastError?: string | undefined;
82
- linkedDatabases: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLinkedDatabase[];
83
- lockedBy?: {
84
- [k: string]: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLockPurpose;
85
- } | undefined;
86
- phase: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppPhase;
87
- projectId: string;
88
- screenshotId?: string | undefined;
89
- screenshotRef?: string | undefined;
90
- shortId: string;
91
- systemSoftware: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppInstalledSystemSoftware[];
92
- updatePolicy: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppUpdatePolicy;
93
- userInputs: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppSavedUserInput[];
94
- }): DataModel<{
95
- appId: string;
96
- appVersion: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppVersionStatus;
97
- createdAt: string;
98
- customDocumentRoot?: string | undefined;
99
- deletionRequested?: boolean | undefined;
100
- description: string;
101
- disabled: boolean;
102
- id: string;
103
- installationPath: string;
104
- lastError?: string | undefined;
105
- linkedDatabases: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLinkedDatabase[];
106
- lockedBy?: {
107
- [k: string]: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppLockPurpose;
108
- } | undefined;
109
- phase: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppPhase;
110
- projectId: string;
111
- screenshotId?: string | undefined;
112
- screenshotRef?: string | undefined;
113
- shortId: string;
114
- systemSoftware: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppInstalledSystemSoftware[];
115
- updatePolicy: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppUpdatePolicy;
116
- userInputs: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppSavedUserInput[];
117
- }>;
118
- }]>;
119
- export declare class AppInstallationDetailed extends AppInstallationDetailed_base {
120
- constructor(data: AppInstallationData);
121
- }
122
- declare const AppInstallationListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof AppInstallationCommon, {
123
- new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppInstallation): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.AppAppInstallation>;
124
- }]>;
125
- export declare class AppInstallationListItem extends AppInstallationListItem_base {
126
- constructor(data: AppInstallationListItemData);
127
- }
128
- export declare class AppInstallationListQuery extends ListQueryModel<AppInstallationListQueryData> {
129
- readonly project: Project;
130
- constructor(project: Project, query?: AppInstallationListQueryData);
131
- refine(query: AppInstallationListQueryData): AppInstallationListQuery;
132
- execute: AsyncResourceVariant<() => Promise<AppInstallationList>>;
133
- getTotalCount: AsyncResourceVariant<() => Promise<number>>;
134
- findOneAndOnly: AsyncResourceVariant<() => Promise<AppInstallationListItem | undefined>>;
135
- }
136
- declare const AppInstallationList_base: import("polytype").Polytype.ClusteredConstructor<[typeof AppInstallationListQuery, {
137
- new (items: AppInstallationListItem[], totalCount: number): ListDataModel<AppInstallationListItem>;
138
- }]>;
139
- export declare class AppInstallationList extends AppInstallationList_base {
140
- constructor(project: Project, query: AppInstallationListQueryData, appInstallations: AppInstallationListItem[], totalCount: number);
141
- }
142
- export {};
@@ -1,3 +0,0 @@
1
- import { MittwaldAPIV2Client } from "@mittwald/api-client";
2
- import { AppInstallationBehaviors } from "./types.js";
3
- export declare const apiAppInstallationBehaviors: (client: MittwaldAPIV2Client) => AppInstallationBehaviors;
@@ -1,2 +0,0 @@
1
- export * from "./api.js";
2
- export * from "./types.js";
@@ -1,6 +0,0 @@
1
- import { AppInstallationData, AppInstallationListItemData, AppInstallationListQueryData } from "../types.js";
2
- import { QueryResponseData } from "../../../base/index.js";
3
- export interface AppInstallationBehaviors {
4
- find: (id: string) => Promise<AppInstallationData | undefined>;
5
- list: (projectId: string, query?: AppInstallationListQueryData) => Promise<QueryResponseData<AppInstallationListItemData>>;
6
- }
@@ -1,2 +0,0 @@
1
- export * from "./AppInstallation.js";
2
- export * from "./types.js";