@mittwald/api-models 4.338.1 → 4.339.0
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 +89 -0
- package/dist/esm/app/AppInstallation/behaviors/api.js +24 -0
- package/dist/esm/app/AppInstallation/behaviors/index.js +2 -0
- package/dist/esm/app/AppInstallation/behaviors/types.js +1 -0
- package/dist/esm/app/AppInstallation/index.js +2 -0
- package/dist/esm/app/AppInstallation/types.js +1 -0
- package/dist/esm/app/index.js +1 -0
- package/dist/esm/article/Article/Article.js +79 -0
- package/dist/esm/article/Article/behaviors/api.js +22 -0
- package/dist/esm/article/Article/behaviors/index.js +2 -0
- package/dist/esm/article/Article/behaviors/types.js +1 -0
- package/dist/esm/article/Article/index.js +2 -0
- package/dist/esm/article/Article/types.js +1 -0
- package/dist/esm/article/index.js +1 -0
- package/dist/esm/base/DataModel.js +7 -0
- package/dist/esm/base/ListDataModel.js +8 -0
- package/dist/esm/base/ListQueryModel.js +11 -0
- package/dist/esm/base/Money.js +5 -0
- package/dist/esm/base/ReferenceModel.js +9 -0
- package/dist/esm/base/assertObjectFound.js +9 -0
- package/dist/esm/base/index.js +6 -0
- package/dist/esm/base/types.js +1 -0
- package/dist/esm/config/behaviors/api.js +51 -0
- package/dist/esm/config/behaviors/index.js +1 -0
- package/dist/esm/config/config.js +14 -0
- package/dist/esm/config/index.js +1 -0
- package/dist/esm/contract/Contract/Contract.js +78 -0
- package/dist/esm/contract/Contract/behaviors/api.js +20 -0
- package/dist/esm/contract/Contract/behaviors/index.js +2 -0
- package/dist/esm/contract/Contract/behaviors/types.js +1 -0
- package/dist/esm/contract/Contract/index.js +2 -0
- package/dist/esm/contract/Contract/types.js +1 -0
- package/dist/esm/contract/ContractItem/ContractItem.js +31 -0
- package/dist/esm/contract/ContractItem/behaviors/api.js +13 -0
- package/dist/esm/contract/ContractItem/behaviors/index.js +2 -0
- package/dist/esm/contract/ContractItem/behaviors/types.js +1 -0
- package/dist/esm/contract/ContractItem/index.js +2 -0
- package/dist/esm/contract/ContractItem/types.js +1 -0
- package/dist/esm/contract/index.js +2 -0
- package/dist/esm/customer/Customer/Customer.js +96 -0
- package/dist/esm/customer/Customer/behaviors/api.js +30 -0
- package/dist/esm/customer/Customer/behaviors/index.js +2 -0
- package/dist/esm/customer/Customer/behaviors/types.js +1 -0
- package/dist/esm/customer/Customer/index.js +2 -0
- package/dist/esm/customer/Customer/types.js +1 -0
- package/dist/esm/customer/index.js +1 -0
- package/dist/esm/domain/Ingress/Ingress.js +106 -0
- package/dist/esm/domain/Ingress/behaviors/api.js +25 -0
- package/dist/esm/domain/Ingress/behaviors/index.js +2 -0
- package/dist/esm/domain/Ingress/behaviors/types.js +1 -0
- package/dist/esm/domain/Ingress/index.js +2 -0
- package/dist/esm/domain/Ingress/types.js +1 -0
- package/dist/esm/domain/IngressPath/IngressPath.js +15 -0
- package/dist/esm/domain/IngressPath/IngressPath.test.js +16 -0
- package/dist/esm/domain/IngressPath/index.js +2 -0
- package/dist/esm/domain/IngressPath/types.js +1 -0
- package/dist/esm/domain/IngressTarget/IngressTarget.js +40 -0
- package/dist/esm/domain/IngressTarget/IngressTarget.test-types.js +10 -0
- package/dist/esm/domain/IngressTarget/index.js +2 -0
- package/dist/esm/domain/IngressTarget/types.js +1 -0
- package/dist/esm/domain/index.js +1 -0
- package/dist/esm/errors/ObjectNotFoundError.js +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/lib/deepFreeze.js +4 -0
- package/dist/esm/lib/joinedId.js +1 -0
- package/dist/esm/lib/types.js +1 -0
- package/dist/esm/marketplace/Contributor/Contributor.js +83 -0
- package/dist/esm/marketplace/Contributor/ContributorIncomingInvoice.js +53 -0
- package/dist/esm/marketplace/Contributor/behaviors/api.js +39 -0
- package/dist/esm/marketplace/Contributor/behaviors/index.js +2 -0
- package/dist/esm/marketplace/Contributor/behaviors/types.js +1 -0
- package/dist/esm/marketplace/Contributor/index.js +3 -0
- package/dist/esm/marketplace/Contributor/types.js +1 -0
- package/dist/esm/marketplace/index.js +1 -0
- package/dist/esm/project/Project/Project.js +121 -0
- package/dist/esm/project/Project/behaviors/api.js +58 -0
- package/dist/esm/project/Project/behaviors/inMem.js +27 -0
- package/dist/esm/project/Project/behaviors/index.js +3 -0
- package/dist/esm/project/Project/behaviors/types.js +1 -0
- package/dist/esm/project/Project/index.js +2 -0
- package/dist/esm/project/Project/types.js +1 -0
- package/dist/esm/project/index.js +1 -0
- package/dist/esm/react/MittwaldApiModelProvider.js +12 -0
- package/dist/esm/react/asyncResourceInvalidation.js +29 -0
- package/dist/esm/react/index.js +4 -0
- package/dist/esm/react/provideReact.js +27 -0
- package/dist/esm/react/provideReact.test-types.js +21 -0
- package/dist/esm/react/reactProvisionContext.js +2 -0
- package/dist/esm/react/reactUsePromise.js +17 -0
- package/dist/esm/react.js +1 -0
- package/dist/esm/server/Server/Server.js +102 -0
- package/dist/esm/server/Server/behaviors/api.js +22 -0
- package/dist/esm/server/Server/behaviors/index.js +2 -0
- package/dist/esm/server/Server/behaviors/types.js +1 -0
- package/dist/esm/server/Server/index.js +1 -0
- package/dist/esm/server/Server/types.js +1 -0
- package/dist/esm/server/index.js +1 -0
- package/dist/types/app/AppInstallation/AppInstallation.d.ts +142 -0
- package/dist/types/app/AppInstallation/behaviors/api.d.ts +3 -0
- package/dist/types/app/AppInstallation/behaviors/index.d.ts +2 -0
- package/dist/types/app/AppInstallation/behaviors/types.d.ts +6 -0
- package/dist/types/app/AppInstallation/index.d.ts +2 -0
- package/dist/types/app/AppInstallation/types.d.ts +4 -0
- package/dist/types/app/index.d.ts +1 -0
- package/dist/types/article/Article/Article.d.ts +133 -0
- package/dist/types/article/Article/behaviors/api.d.ts +3 -0
- package/dist/types/article/Article/behaviors/index.d.ts +2 -0
- package/dist/types/article/Article/behaviors/types.d.ts +6 -0
- package/dist/types/article/Article/index.d.ts +2 -0
- package/dist/types/article/Article/types.d.ts +5 -0
- package/dist/types/article/index.d.ts +1 -0
- package/dist/types/base/DataModel.d.ts +5 -0
- package/dist/types/base/ListDataModel.d.ts +5 -0
- package/dist/types/base/ListQueryModel.d.ts +9 -0
- package/dist/types/base/Money.d.ts +3 -0
- package/dist/types/base/ReferenceModel.d.ts +5 -0
- package/dist/types/base/assertObjectFound.d.ts +3 -0
- package/dist/types/base/index.d.ts +6 -0
- package/dist/types/base/types.d.ts +6 -0
- package/dist/types/config/behaviors/api.d.ts +12 -0
- package/dist/types/config/behaviors/index.d.ts +1 -0
- package/dist/types/config/config.d.ts +25 -0
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/contract/Contract/Contract.d.ts +68 -0
- package/dist/types/contract/Contract/behaviors/api.d.ts +3 -0
- package/dist/types/contract/Contract/behaviors/index.d.ts +2 -0
- package/dist/types/contract/Contract/behaviors/types.d.ts +9 -0
- package/dist/types/contract/Contract/index.d.ts +2 -0
- package/dist/types/contract/Contract/types.d.ts +8 -0
- package/dist/types/contract/ContractItem/ContractItem.d.ts +64 -0
- package/dist/types/contract/ContractItem/behaviors/api.d.ts +3 -0
- package/dist/types/contract/ContractItem/behaviors/index.d.ts +2 -0
- package/dist/types/contract/ContractItem/behaviors/types.d.ts +4 -0
- package/dist/types/contract/ContractItem/index.d.ts +2 -0
- package/dist/types/contract/ContractItem/types.d.ts +2 -0
- package/dist/types/contract/index.d.ts +2 -0
- package/dist/types/customer/Customer/Customer.d.ts +146 -0
- package/dist/types/customer/Customer/behaviors/api.d.ts +3 -0
- package/dist/types/customer/Customer/behaviors/index.d.ts +2 -0
- package/dist/types/customer/Customer/behaviors/types.d.ts +7 -0
- package/dist/types/customer/Customer/index.d.ts +2 -0
- package/dist/types/customer/Customer/types.d.ts +5 -0
- package/dist/types/customer/index.d.ts +1 -0
- package/dist/types/domain/Ingress/Ingress.d.ts +109 -0
- package/dist/types/domain/Ingress/behaviors/api.d.ts +3 -0
- package/dist/types/domain/Ingress/behaviors/index.d.ts +2 -0
- package/dist/types/domain/Ingress/behaviors/types.d.ts +6 -0
- package/dist/types/domain/Ingress/index.d.ts +2 -0
- package/dist/types/domain/Ingress/types.d.ts +8 -0
- package/dist/types/domain/IngressPath/IngressPath.d.ts +11 -0
- package/dist/types/domain/IngressPath/IngressPath.test.d.ts +1 -0
- package/dist/types/domain/IngressPath/index.d.ts +2 -0
- package/dist/types/domain/IngressPath/types.d.ts +2 -0
- package/dist/types/domain/IngressTarget/IngressTarget.d.ts +24 -0
- package/dist/types/domain/IngressTarget/IngressTarget.test-types.d.ts +1 -0
- package/dist/types/domain/IngressTarget/index.d.ts +2 -0
- package/dist/types/domain/IngressTarget/types.d.ts +6 -0
- package/dist/types/domain/index.d.ts +1 -0
- package/dist/types/errors/ObjectNotFoundError.d.ts +3 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/lib/deepFreeze.d.ts +5 -0
- package/dist/types/lib/joinedId.d.ts +1 -0
- package/dist/types/lib/types.d.ts +2 -0
- package/dist/types/marketplace/Contributor/Contributor.d.ts +49 -0
- package/dist/types/marketplace/Contributor/ContributorIncomingInvoice.d.ts +31 -0
- package/dist/types/marketplace/Contributor/behaviors/api.d.ts +3 -0
- package/dist/types/marketplace/Contributor/behaviors/index.d.ts +2 -0
- package/dist/types/marketplace/Contributor/behaviors/types.d.ts +10 -0
- package/dist/types/marketplace/Contributor/index.d.ts +3 -0
- package/dist/types/marketplace/Contributor/types.d.ts +6 -0
- package/dist/types/marketplace/index.d.ts +1 -0
- package/dist/types/project/Project/Project.d.ts +292 -0
- package/dist/types/project/Project/behaviors/api.d.ts +3 -0
- package/dist/types/project/Project/behaviors/inMem.d.ts +3 -0
- package/dist/types/project/Project/behaviors/index.d.ts +3 -0
- package/dist/types/project/Project/behaviors/types.d.ts +12 -0
- package/dist/types/project/Project/index.d.ts +2 -0
- package/dist/types/project/Project/types.d.ts +10 -0
- package/dist/types/project/index.d.ts +1 -0
- package/dist/types/react/MittwaldApiModelProvider.d.ts +6 -0
- package/dist/types/react/asyncResourceInvalidation.d.ts +4 -0
- package/dist/types/react/index.d.ts +5 -0
- package/dist/types/react/provideReact.d.ts +12 -0
- package/dist/types/react/provideReact.test-types.d.ts +1 -0
- package/dist/types/react/reactProvisionContext.d.ts +3 -0
- package/dist/types/react/reactUsePromise.d.ts +2 -0
- package/dist/types/react.d.ts +1 -0
- package/dist/types/server/Server/Server.d.ts +115 -0
- package/dist/types/server/Server/behaviors/api.d.ts +3 -0
- package/dist/types/server/Server/behaviors/index.d.ts +2 -0
- package/dist/types/server/Server/behaviors/types.d.ts +6 -0
- package/dist/types/server/Server/index.d.ts +1 -0
- package/dist/types/server/Server/types.d.ts +8 -0
- package/dist/types/server/index.d.ts +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,96 @@
|
|
|
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 { ReferenceModel } from "../../base/ReferenceModel.js";
|
|
6
|
+
import { provideReact, } from "../../react/provideReact.js";
|
|
7
|
+
import { ListQueryModel } from "../../base/ListQueryModel.js";
|
|
8
|
+
import { ListDataModel } from "../../base/ListDataModel.js";
|
|
9
|
+
import { ServerListQuery } from "../../server/index.js";
|
|
10
|
+
import { ProjectListQuery } from "../../project/index.js";
|
|
11
|
+
export class Customer extends ReferenceModel {
|
|
12
|
+
servers;
|
|
13
|
+
projects;
|
|
14
|
+
constructor(id) {
|
|
15
|
+
super(id);
|
|
16
|
+
this.servers = new ServerListQuery({
|
|
17
|
+
customer: this,
|
|
18
|
+
});
|
|
19
|
+
this.projects = new ProjectListQuery({
|
|
20
|
+
customer: this,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
static ofId(id) {
|
|
24
|
+
return new Customer(id);
|
|
25
|
+
}
|
|
26
|
+
static find = provideReact(async (id) => {
|
|
27
|
+
const data = await config.behaviors.customer.find(id);
|
|
28
|
+
if (data !== undefined) {
|
|
29
|
+
return new CustomerDetailed(data);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
static query(query = {}) {
|
|
33
|
+
return new CustomerListQuery(query);
|
|
34
|
+
}
|
|
35
|
+
/** @deprecated Use query() */
|
|
36
|
+
static list = provideReact(async (query = {}) => new CustomerListQuery(query).execute().then((res) => res.items));
|
|
37
|
+
static get = provideReact(async (id) => {
|
|
38
|
+
const customer = await this.find(id);
|
|
39
|
+
assertObjectFound(customer, this, id);
|
|
40
|
+
return customer;
|
|
41
|
+
});
|
|
42
|
+
getDetailed = provideReact(() => Customer.get(this.id), [this.id]);
|
|
43
|
+
findDetailed = provideReact(() => Customer.find(this.id), [this.id]);
|
|
44
|
+
async update(data) {
|
|
45
|
+
await config.behaviors.customer.update(this.id, data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Common class for future extension
|
|
49
|
+
class CustomerCommon extends classes((DataModel), Customer) {
|
|
50
|
+
constructor(data) {
|
|
51
|
+
super([data], [data.customerId]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class CustomerDetailed extends classes(CustomerCommon, (DataModel)) {
|
|
55
|
+
constructor(data) {
|
|
56
|
+
super([data], [data]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class CustomerListItem extends classes(CustomerCommon, (DataModel)) {
|
|
60
|
+
constructor(data) {
|
|
61
|
+
super([data], [data]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class CustomerListQuery extends ListQueryModel {
|
|
65
|
+
constructor(query = {}) {
|
|
66
|
+
super(query);
|
|
67
|
+
}
|
|
68
|
+
refine(query) {
|
|
69
|
+
return new CustomerListQuery({
|
|
70
|
+
...this.query,
|
|
71
|
+
...query,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
execute = provideReact(async () => {
|
|
75
|
+
const { items, totalCount } = await config.behaviors.customer.list({
|
|
76
|
+
limit: config.defaultPaginationLimit,
|
|
77
|
+
...this.query,
|
|
78
|
+
});
|
|
79
|
+
return new CustomerList(this.query, items.map((d) => new CustomerListItem(d)), totalCount);
|
|
80
|
+
}, [this.queryId]);
|
|
81
|
+
getTotalCount = provideReact(async () => {
|
|
82
|
+
const { totalCount } = await this.refine({ limit: 1 }).execute();
|
|
83
|
+
return totalCount;
|
|
84
|
+
}, [this.queryId]);
|
|
85
|
+
findOneAndOnly = provideReact(async () => {
|
|
86
|
+
const { items, totalCount } = await this.refine({ limit: 2 }).execute();
|
|
87
|
+
if (totalCount === 1) {
|
|
88
|
+
return items[0];
|
|
89
|
+
}
|
|
90
|
+
}, [this.queryId]);
|
|
91
|
+
}
|
|
92
|
+
export class CustomerList extends classes(CustomerListQuery, (ListDataModel)) {
|
|
93
|
+
constructor(query, customers, totalCount) {
|
|
94
|
+
super([query], [customers, totalCount]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { assertStatus, extractTotalCountHeader, } from "@mittwald/api-client";
|
|
2
|
+
import { assertOneOfStatus } from "@mittwald/api-client";
|
|
3
|
+
export const apiCustomerBehaviors = (client) => ({
|
|
4
|
+
find: async (id) => {
|
|
5
|
+
const response = await client.customer.getCustomer({
|
|
6
|
+
customerId: id,
|
|
7
|
+
});
|
|
8
|
+
if (response.status === 200) {
|
|
9
|
+
return response.data;
|
|
10
|
+
}
|
|
11
|
+
assertOneOfStatus(response, [404]);
|
|
12
|
+
},
|
|
13
|
+
list: async (query) => {
|
|
14
|
+
const response = await client.customer.listCustomers({
|
|
15
|
+
queryParameters: query,
|
|
16
|
+
});
|
|
17
|
+
assertStatus(response, 200);
|
|
18
|
+
return {
|
|
19
|
+
items: response.data,
|
|
20
|
+
totalCount: extractTotalCountHeader(response),
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
update: async (id, data) => {
|
|
24
|
+
const response = await client.customer.updateCustomer({
|
|
25
|
+
customerId: id,
|
|
26
|
+
data,
|
|
27
|
+
});
|
|
28
|
+
assertStatus(response, 200);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Customer/index.js";
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { ReferenceModel } from "../../base/ReferenceModel.js";
|
|
6
|
+
import { provideReact, } from "../../react/provideReact.js";
|
|
7
|
+
import { IngressPath } from "../IngressPath/IngressPath.js";
|
|
8
|
+
import { ListQueryModel } from "../../base/ListQueryModel.js";
|
|
9
|
+
import { ListDataModel } from "../../base/ListDataModel.js";
|
|
10
|
+
export class Ingress extends ReferenceModel {
|
|
11
|
+
static ofId(id) {
|
|
12
|
+
return new Ingress(id);
|
|
13
|
+
}
|
|
14
|
+
static ofHostname(hostname) {
|
|
15
|
+
return Ingress.ofId(hostname);
|
|
16
|
+
}
|
|
17
|
+
/** @deprecated: use query() or project.ingresses */
|
|
18
|
+
static list = provideReact(async (query = {}) => new IngressListQuery(query).execute().then((r) => r.items));
|
|
19
|
+
static find = provideReact(async (id) => {
|
|
20
|
+
const data = await config.behaviors.ingress.find(id);
|
|
21
|
+
if (data !== undefined) {
|
|
22
|
+
return new IngressDetailed(data);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
static get = provideReact(async (id) => {
|
|
26
|
+
const ingress = await this.find(id);
|
|
27
|
+
assertObjectFound(ingress, this, id);
|
|
28
|
+
return ingress;
|
|
29
|
+
});
|
|
30
|
+
getDetailed = provideReact(() => Ingress.get(this.id), [this.id]);
|
|
31
|
+
findDetailed = provideReact(() => Ingress.find(this.id), [this.id]);
|
|
32
|
+
}
|
|
33
|
+
export class IngressCommon extends classes((DataModel), Ingress) {
|
|
34
|
+
baseUrl;
|
|
35
|
+
paths;
|
|
36
|
+
defaultPath;
|
|
37
|
+
constructor(data) {
|
|
38
|
+
super([data], [data.id]);
|
|
39
|
+
this.baseUrl = `https://${data.hostname}`;
|
|
40
|
+
this.paths = Object.freeze(data.paths.map((p) => new IngressPath(this, p)));
|
|
41
|
+
const defaultPath = this.paths.find((p) => p.path === "/");
|
|
42
|
+
if (defaultPath === undefined) {
|
|
43
|
+
throw new Error(`Ingress ${this.describe()} has no default path.`);
|
|
44
|
+
}
|
|
45
|
+
this.defaultPath = defaultPath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class IngressDetailed extends classes(IngressCommon, (DataModel)) {
|
|
49
|
+
constructor(data) {
|
|
50
|
+
super([data], [data]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class IngressListItem extends classes(IngressCommon, (DataModel)) {
|
|
54
|
+
constructor(data) {
|
|
55
|
+
super([data], [data]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export class IngressListQuery extends ListQueryModel {
|
|
59
|
+
constructor(query = {}) {
|
|
60
|
+
super(query);
|
|
61
|
+
}
|
|
62
|
+
refine(query = {}) {
|
|
63
|
+
return new IngressListQuery({
|
|
64
|
+
...this.query,
|
|
65
|
+
...query,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
execute = provideReact(async () => {
|
|
69
|
+
const { project, ...query } = this.query;
|
|
70
|
+
const { items, totalCount } = await config.behaviors.ingress.list({
|
|
71
|
+
/** @todo: use this code when pagination is supported by API */
|
|
72
|
+
// limit: config.defaultPaginationLimit,
|
|
73
|
+
...query,
|
|
74
|
+
projectId: project?.id,
|
|
75
|
+
});
|
|
76
|
+
return new IngressList(this.query, items.map((d) => new IngressListItem(d)), totalCount);
|
|
77
|
+
}, [this.queryId]);
|
|
78
|
+
getTotalCount = provideReact(async () => {
|
|
79
|
+
/** @todo: use this code when pagination is supported by API */
|
|
80
|
+
// const { totalCount } = await this.refine({ limit: 1 }).execute();
|
|
81
|
+
// return totalCount;
|
|
82
|
+
const { items } = await this.refine({}).execute();
|
|
83
|
+
return items.length;
|
|
84
|
+
}, [this.queryId]);
|
|
85
|
+
findOneAndOnly = provideReact(async () => {
|
|
86
|
+
/** @todo: use this code when pagination is supported by API */
|
|
87
|
+
// const { items, totalCount } = await this.refine({ limit: 2 }).execute();
|
|
88
|
+
// if (totalCount === 1) {
|
|
89
|
+
// return items[0];
|
|
90
|
+
// }
|
|
91
|
+
const { items, totalCount } = await this.refine({}).execute();
|
|
92
|
+
if (totalCount === 1) {
|
|
93
|
+
return items[0];
|
|
94
|
+
}
|
|
95
|
+
}, [this.queryId]);
|
|
96
|
+
}
|
|
97
|
+
export class IngressList extends classes(IngressListQuery, (ListDataModel)) {
|
|
98
|
+
constructor(query, ingresses, totalCount) {
|
|
99
|
+
super([query], [ingresses, totalCount]);
|
|
100
|
+
}
|
|
101
|
+
getDefault() {
|
|
102
|
+
const defaultIngress = this.items.find((i) => i.data.isDefault);
|
|
103
|
+
assertObjectFound(defaultIngress, IngressListItem, "IngressList");
|
|
104
|
+
return defaultIngress;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { assertStatus } from "@mittwald/api-client";
|
|
2
|
+
import { assertOneOfStatus } from "@mittwald/api-client";
|
|
3
|
+
export const apiIngressBehaviors = (client) => ({
|
|
4
|
+
find: async (id) => {
|
|
5
|
+
const response = await client.domain.ingressGetIngress({
|
|
6
|
+
ingressId: id,
|
|
7
|
+
});
|
|
8
|
+
if (response.status === 200) {
|
|
9
|
+
return response.data;
|
|
10
|
+
}
|
|
11
|
+
assertOneOfStatus(response, [404]);
|
|
12
|
+
},
|
|
13
|
+
list: async (query = {}) => {
|
|
14
|
+
const response = await client.domain.ingressListIngresses({
|
|
15
|
+
queryParameters: query,
|
|
16
|
+
});
|
|
17
|
+
assertStatus(response, 200);
|
|
18
|
+
return {
|
|
19
|
+
items: response.data,
|
|
20
|
+
totalCount: response.data.length,
|
|
21
|
+
/** @todo: use this code when pagination is supported by API */
|
|
22
|
+
// totalCount: extractTotalCountHeader(response),
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataModel } from "../../base/DataModel.js";
|
|
2
|
+
import { ingressTargetFactory, } from "../IngressTarget/IngressTarget.js";
|
|
3
|
+
export class IngressPath extends DataModel {
|
|
4
|
+
ingress;
|
|
5
|
+
path;
|
|
6
|
+
url;
|
|
7
|
+
target;
|
|
8
|
+
constructor(ingress, data) {
|
|
9
|
+
super(data);
|
|
10
|
+
this.ingress = ingress;
|
|
11
|
+
this.path = data.path;
|
|
12
|
+
this.url = new URL(data.path, ingress.baseUrl);
|
|
13
|
+
this.target = ingressTargetFactory(this, data.target);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IngressPath } from "./IngressPath.js";
|
|
2
|
+
import { IngressDetailed } from "../Ingress/index.js";
|
|
3
|
+
const ingressData = {
|
|
4
|
+
id: "abc",
|
|
5
|
+
paths: [],
|
|
6
|
+
};
|
|
7
|
+
const corruptIngressTargetData = {};
|
|
8
|
+
const ingressPathData = {
|
|
9
|
+
path: "/",
|
|
10
|
+
target: corruptIngressTargetData,
|
|
11
|
+
};
|
|
12
|
+
test("Creating IngressPath with corrupt IngressTarget throws error", () => {
|
|
13
|
+
expect(() => {
|
|
14
|
+
new IngressPath(new IngressDetailed(ingressData), ingressPathData);
|
|
15
|
+
}).toThrowError("Ingress IngressDetailed@abc has no default path.");
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { DataModel } from "../../base/DataModel.js";
|
|
2
|
+
import { AppInstallation } from "../../app/AppInstallation/index.js";
|
|
3
|
+
class IngressTargetBase extends DataModel {
|
|
4
|
+
path;
|
|
5
|
+
constructor(path, data) {
|
|
6
|
+
super(data);
|
|
7
|
+
this.path = path;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class IngressRedirectTarget extends IngressTargetBase {
|
|
11
|
+
type = "redirect";
|
|
12
|
+
url;
|
|
13
|
+
constructor(path, data) {
|
|
14
|
+
super(path, data);
|
|
15
|
+
this.url = new URL(data.url);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class IngressAppInstallationTarget extends IngressTargetBase {
|
|
19
|
+
type = "appInstallation";
|
|
20
|
+
appInstallation;
|
|
21
|
+
constructor(path, data) {
|
|
22
|
+
super(path, data);
|
|
23
|
+
this.appInstallation = AppInstallation.ofId(data.installationId);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class IngressUndefinedTarget extends IngressTargetBase {
|
|
27
|
+
type = "undefined";
|
|
28
|
+
}
|
|
29
|
+
export const ingressTargetFactory = (path, data) => {
|
|
30
|
+
if ("url" in data) {
|
|
31
|
+
return new IngressRedirectTarget(path, data);
|
|
32
|
+
}
|
|
33
|
+
if ("installationId" in data) {
|
|
34
|
+
return new IngressAppInstallationTarget(path, data);
|
|
35
|
+
}
|
|
36
|
+
if ("useDefaultPage" in data) {
|
|
37
|
+
return new IngressUndefinedTarget(path, data);
|
|
38
|
+
}
|
|
39
|
+
throw new Error("Ingress target type is not supported.");
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Ingress/index.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
2
|
+
export * from "./config/index.js";
|
|
3
|
+
export * from "./project/index.js";
|
|
4
|
+
export * from "./server/index.js";
|
|
5
|
+
export * from "./domain/index.js";
|
|
6
|
+
export * from "./customer/index.js";
|
|
7
|
+
export * from "./base/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const joinedId = (...parts) => parts.join(" | ");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { ReferenceModel } from "../../base/ReferenceModel.js";
|
|
6
|
+
import { provideReact, } from "../../react/provideReact.js";
|
|
7
|
+
import { ListQueryModel } from "../../base/ListQueryModel.js";
|
|
8
|
+
import { ListDataModel } from "../../base/ListDataModel.js";
|
|
9
|
+
import { ContributorIncomingInvoiceListQuery } from "./ContributorIncomingInvoice.js";
|
|
10
|
+
export class Contributor extends ReferenceModel {
|
|
11
|
+
incomingInvoices;
|
|
12
|
+
constructor(id) {
|
|
13
|
+
super(id);
|
|
14
|
+
this.incomingInvoices = new ContributorIncomingInvoiceListQuery(this);
|
|
15
|
+
}
|
|
16
|
+
static ofId(id) {
|
|
17
|
+
return new Contributor(id);
|
|
18
|
+
}
|
|
19
|
+
static find = provideReact(async (id) => {
|
|
20
|
+
const data = await config.behaviors.contributor.find(id);
|
|
21
|
+
if (data !== undefined) {
|
|
22
|
+
return new ContributorDetailed(data);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
static query(query = {}) {
|
|
26
|
+
return new ContributorListQuery(query);
|
|
27
|
+
}
|
|
28
|
+
static get = provideReact(async (id) => {
|
|
29
|
+
const contributor = await this.find(id);
|
|
30
|
+
assertObjectFound(contributor, this, id);
|
|
31
|
+
return contributor;
|
|
32
|
+
});
|
|
33
|
+
getDetailed = provideReact(() => Contributor.get(this.id), [this.id]);
|
|
34
|
+
findDetailed = provideReact(() => Contributor.find(this.id), [this.id]);
|
|
35
|
+
}
|
|
36
|
+
class ContributorCommon extends classes((DataModel), Contributor) {
|
|
37
|
+
constructor(data) {
|
|
38
|
+
super([data], [data.id]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class ContributorDetailed extends classes(ContributorCommon, (DataModel)) {
|
|
42
|
+
constructor(data) {
|
|
43
|
+
super([data], [data]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export class ContributorListItem extends classes(ContributorCommon, (DataModel)) {
|
|
47
|
+
constructor(data) {
|
|
48
|
+
super([data], [data]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class ContributorListQuery extends ListQueryModel {
|
|
52
|
+
constructor(query = {}) {
|
|
53
|
+
super(query);
|
|
54
|
+
}
|
|
55
|
+
refine(query) {
|
|
56
|
+
return new ContributorListQuery({
|
|
57
|
+
...this.query,
|
|
58
|
+
...query,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
execute = provideReact(async () => {
|
|
62
|
+
const { items, totalCount } = await config.behaviors.contributor.list({
|
|
63
|
+
limit: config.defaultPaginationLimit,
|
|
64
|
+
...this.query,
|
|
65
|
+
});
|
|
66
|
+
return new ContributorList(this.query, items.map((d) => new ContributorListItem(d)), totalCount);
|
|
67
|
+
}, [this.queryId]);
|
|
68
|
+
getTotalCount = provideReact(async () => {
|
|
69
|
+
const { totalCount } = await this.refine({ limit: 1 }).execute();
|
|
70
|
+
return totalCount;
|
|
71
|
+
}, [this.queryId]);
|
|
72
|
+
findOneAndOnly = provideReact(async () => {
|
|
73
|
+
const { items, totalCount } = await this.refine({ limit: 2 }).execute();
|
|
74
|
+
if (totalCount === 1) {
|
|
75
|
+
return items[0];
|
|
76
|
+
}
|
|
77
|
+
}, [this.queryId]);
|
|
78
|
+
}
|
|
79
|
+
export class ContributorList extends classes(ContributorListQuery, (ListDataModel)) {
|
|
80
|
+
constructor(query, contributors, totalCount) {
|
|
81
|
+
super([query], [contributors, totalCount]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { classes } from "polytype";
|
|
2
|
+
import { ListQueryModel } from "../../base/ListQueryModel.js";
|
|
3
|
+
import { Money } from "../../base/Money.js";
|
|
4
|
+
import { provideReact } from "../../react.js";
|
|
5
|
+
import { DateTime } from "luxon";
|
|
6
|
+
import { ListDataModel } from "../../base/ListDataModel.js";
|
|
7
|
+
import { DataModel } from "../../base/DataModel.js";
|
|
8
|
+
import { config } from "../../config/config.js";
|
|
9
|
+
export class ContributorIncomingInvoice extends DataModel {
|
|
10
|
+
contributor;
|
|
11
|
+
id;
|
|
12
|
+
pdfId;
|
|
13
|
+
invoiceNumber;
|
|
14
|
+
date;
|
|
15
|
+
totalNet;
|
|
16
|
+
totalGross;
|
|
17
|
+
constructor(contributor, data) {
|
|
18
|
+
super(data);
|
|
19
|
+
this.contributor = contributor;
|
|
20
|
+
this.id = data.id;
|
|
21
|
+
this.pdfId = data.pdfId;
|
|
22
|
+
this.invoiceNumber = data.invoiceNumber;
|
|
23
|
+
this.date = DateTime.fromISO(data.date);
|
|
24
|
+
this.totalNet = Money({ amount: data.totalNet, currency: "EUR" });
|
|
25
|
+
this.totalGross = Money({ amount: data.totalGross, currency: "EUR" });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class ContributorIncomingInvoiceListQuery extends ListQueryModel {
|
|
29
|
+
contributor;
|
|
30
|
+
constructor(contributor, query = {}) {
|
|
31
|
+
super(query, { dependencies: [contributor.id] });
|
|
32
|
+
this.contributor = contributor;
|
|
33
|
+
}
|
|
34
|
+
refine(query) {
|
|
35
|
+
return new ContributorIncomingInvoiceListQuery(this.contributor, {
|
|
36
|
+
...this.query,
|
|
37
|
+
...query,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
execute = provideReact(async () => {
|
|
41
|
+
const { items, totalCount } = await config.behaviors.contributor.listIncomingInvoices(this.contributor.id, this.query);
|
|
42
|
+
return new ContributorIncomingInvoicesList(this.contributor, this.query, items.map((i) => new ContributorIncomingInvoice(this.contributor, i)), totalCount);
|
|
43
|
+
}, [this.queryId]);
|
|
44
|
+
getTotalCount = provideReact(async () => {
|
|
45
|
+
const result = await this.refine({ limit: 1, skip: 0 }).execute();
|
|
46
|
+
return result.totalCount;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export class ContributorIncomingInvoicesList extends classes(ContributorIncomingInvoiceListQuery, (ListDataModel)) {
|
|
50
|
+
constructor(contributor, query, invoices, totalCount) {
|
|
51
|
+
super([contributor, query], [invoices, totalCount]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { extractTotalCountHeader, assertStatus, } from "@mittwald/api-client";
|
|
2
|
+
export const apiContributorBehaviors = (client) => ({
|
|
3
|
+
find: async (contributorId) => {
|
|
4
|
+
const response = await client.marketplace.extensionGetContributor({
|
|
5
|
+
contributorId,
|
|
6
|
+
});
|
|
7
|
+
if (response.status === 200) {
|
|
8
|
+
return response.data;
|
|
9
|
+
}
|
|
10
|
+
assertStatus(response, 404);
|
|
11
|
+
},
|
|
12
|
+
list: async (query) => {
|
|
13
|
+
const response = await client.marketplace.extensionListContributors({
|
|
14
|
+
queryParameters: query,
|
|
15
|
+
});
|
|
16
|
+
assertStatus(response, 200);
|
|
17
|
+
return {
|
|
18
|
+
items: response.data,
|
|
19
|
+
totalCount: extractTotalCountHeader(response),
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
listIncomingInvoices: async (contributorId, queryParameters) => {
|
|
23
|
+
const response = await client.marketplace.contributorListIncomingInvoices({
|
|
24
|
+
contributorId,
|
|
25
|
+
queryParameters,
|
|
26
|
+
});
|
|
27
|
+
if (response.status === 200) {
|
|
28
|
+
return {
|
|
29
|
+
items: response.data,
|
|
30
|
+
totalCount: extractTotalCountHeader(response),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
assertStatus(response, 404);
|
|
34
|
+
return {
|
|
35
|
+
items: [],
|
|
36
|
+
totalCount: 0,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Contributor/index.js";
|