@mittwald/api-models 4.61.1 → 4.63.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.
Files changed (47) hide show
  1. package/dist/esm/article/Article/Article.js +79 -0
  2. package/dist/esm/article/Article/behaviors/api.js +22 -0
  3. package/dist/esm/article/Article/behaviors/index.js +2 -0
  4. package/dist/esm/article/Article/behaviors/types.js +1 -0
  5. package/dist/esm/article/Article/index.js +2 -0
  6. package/dist/esm/article/Article/types.js +1 -0
  7. package/dist/esm/article/index.js +1 -0
  8. package/dist/esm/base/Money.js +5 -0
  9. package/dist/esm/config/behaviors/api.js +6 -0
  10. package/dist/esm/config/config.js +3 -0
  11. package/dist/esm/contract/Contract/Contract.js +78 -0
  12. package/dist/esm/contract/Contract/behaviors/api.js +20 -0
  13. package/dist/esm/contract/Contract/behaviors/index.js +2 -0
  14. package/dist/esm/contract/Contract/behaviors/types.js +1 -0
  15. package/dist/esm/contract/Contract/index.js +2 -0
  16. package/dist/esm/contract/Contract/types.js +1 -0
  17. package/dist/esm/contract/ContractItem/ContractItem.js +31 -0
  18. package/dist/esm/contract/ContractItem/behaviors/api.js +13 -0
  19. package/dist/esm/contract/ContractItem/behaviors/index.js +2 -0
  20. package/dist/esm/contract/ContractItem/behaviors/types.js +1 -0
  21. package/dist/esm/contract/ContractItem/index.js +2 -0
  22. package/dist/esm/contract/ContractItem/types.js +1 -0
  23. package/dist/esm/contract/index.js +2 -0
  24. package/dist/types/app/AppInstallation/behaviors/types.d.ts +1 -1
  25. package/dist/types/article/Article/Article.d.ts +133 -0
  26. package/dist/types/article/Article/behaviors/api.d.ts +3 -0
  27. package/dist/types/article/Article/behaviors/index.d.ts +2 -0
  28. package/dist/types/article/Article/behaviors/types.d.ts +6 -0
  29. package/dist/types/article/Article/index.d.ts +2 -0
  30. package/dist/types/article/Article/types.d.ts +5 -0
  31. package/dist/types/article/index.d.ts +1 -0
  32. package/dist/types/base/Money.d.ts +3 -0
  33. package/dist/types/config/config.d.ts +6 -0
  34. package/dist/types/contract/Contract/Contract.d.ts +68 -0
  35. package/dist/types/contract/Contract/behaviors/api.d.ts +3 -0
  36. package/dist/types/contract/Contract/behaviors/index.d.ts +2 -0
  37. package/dist/types/contract/Contract/behaviors/types.d.ts +9 -0
  38. package/dist/types/contract/Contract/index.d.ts +2 -0
  39. package/dist/types/contract/Contract/types.d.ts +8 -0
  40. package/dist/types/contract/ContractItem/ContractItem.d.ts +64 -0
  41. package/dist/types/contract/ContractItem/behaviors/api.d.ts +3 -0
  42. package/dist/types/contract/ContractItem/behaviors/index.d.ts +2 -0
  43. package/dist/types/contract/ContractItem/behaviors/types.d.ts +4 -0
  44. package/dist/types/contract/ContractItem/index.d.ts +2 -0
  45. package/dist/types/contract/ContractItem/types.d.ts +2 -0
  46. package/dist/types/contract/index.d.ts +2 -0
  47. package/package.json +4 -2
@@ -0,0 +1,79 @@
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 { provideReact } from "../../react/provideReact.js";
7
+ import { ListQueryModel } from "../../base/ListQueryModel.js";
8
+ import { ListDataModel } from "../../base/ListDataModel.js";
9
+ import { Money } from "../../base/Money.js";
10
+ export class Article extends ReferenceModel {
11
+ static ofId(id) {
12
+ return new Article(id);
13
+ }
14
+ static find = provideReact(async (id) => {
15
+ const data = await config.behaviors.article.find(id);
16
+ if (data !== undefined) {
17
+ return new ArticleDetailed(data);
18
+ }
19
+ });
20
+ static get = provideReact(async (id) => {
21
+ const article = await this.find(id);
22
+ assertObjectFound(article, this, id);
23
+ return article;
24
+ });
25
+ static query(query = {}) {
26
+ return new ArticleListQuery(query);
27
+ }
28
+ }
29
+ class ArticleCommon extends classes((DataModel), Article) {
30
+ price;
31
+ constructor(data) {
32
+ super([data]);
33
+ this.price = Money({ amount: data.price, currency: "EUR" });
34
+ }
35
+ }
36
+ export class ArticleDetailed extends classes(ArticleCommon, (DataModel)) {
37
+ constructor(data) {
38
+ super([data], [data]);
39
+ }
40
+ }
41
+ export class ArticleListItem extends classes(ArticleCommon, (DataModel)) {
42
+ constructor(data) {
43
+ super([data]);
44
+ }
45
+ }
46
+ export class ArticleListQuery extends ListQueryModel {
47
+ constructor(query = {}) {
48
+ super(query);
49
+ }
50
+ refine(query) {
51
+ return new ArticleListQuery({
52
+ ...this.query,
53
+ ...query,
54
+ });
55
+ }
56
+ execute = provideReact(async () => {
57
+ const { ...query } = this.query;
58
+ const { items, totalCount } = await config.behaviors.article.list({
59
+ limit: config.defaultPaginationLimit,
60
+ ...query,
61
+ });
62
+ return new ArticleList(this.query, items.map((d) => new ArticleListItem(d)), totalCount);
63
+ }, [this.queryId]);
64
+ getTotalCount = provideReact(async () => {
65
+ const { totalCount } = await this.refine({ limit: 1 }).execute();
66
+ return totalCount;
67
+ }, [this.queryId]);
68
+ findOneAndOnly = provideReact(async () => {
69
+ const { items, totalCount } = await this.refine({ limit: 1 }).execute();
70
+ if (totalCount === 1) {
71
+ return items[0];
72
+ }
73
+ }, [this.queryId]);
74
+ }
75
+ export class ArticleList extends classes(ArticleListQuery, (ListDataModel)) {
76
+ constructor(query, articles, totalCount) {
77
+ super([query], [articles, totalCount]);
78
+ }
79
+ }
@@ -0,0 +1,22 @@
1
+ import { assertStatus, extractTotalCountHeader, } from "@mittwald/api-client";
2
+ export const apiArticleBehaviors = (client) => ({
3
+ find: async (id) => {
4
+ const response = await client.article.getArticle({
5
+ articleId: id,
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.article.listArticles({
14
+ queryParameters: query,
15
+ });
16
+ assertStatus(response, 200);
17
+ return {
18
+ items: response.data,
19
+ totalCount: extractTotalCountHeader(response),
20
+ };
21
+ },
22
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./Article.js";
2
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./Article/index.js";
@@ -0,0 +1,5 @@
1
+ import Dinero from "dinero.js";
2
+ export const Money = Dinero;
3
+ Money.defaultCurrency = "EUR";
4
+ Money.defaultPrecision = 2;
5
+ Money.globalLocale = "de-DE";
@@ -6,6 +6,9 @@ import { apiCustomerBehaviors } from "../../customer/Customer/behaviors/index.js
6
6
  import { apiIngressBehaviors } from "../../domain/Ingress/behaviors/index.js";
7
7
  import { apiAppInstallationBehaviors } from "../../app/AppInstallation/behaviors/index.js";
8
8
  import { addUrlTagToProvideReactCache } from "../../react/asyncResourceInvalidation.js";
9
+ import { apiArticleBehaviors } from "../../article/Article/behaviors/index.js";
10
+ import { apiContractBehaviors } from "../../contract/Contract/behaviors/index.js";
11
+ import { apiContractItemBehaviors } from "../../contract/ContractItem/behaviors/index.js";
9
12
  class ApiSetupState {
10
13
  _client;
11
14
  setupWithClient(client) {
@@ -15,11 +18,14 @@ class ApiSetupState {
15
18
  this._client = client;
16
19
  this._client.defaultRequestOptions.onBeforeRequest =
17
20
  addUrlTagToProvideReactCache;
21
+ config.behaviors.article = apiArticleBehaviors(client);
18
22
  config.behaviors.project = apiProjectBehaviors(client);
19
23
  config.behaviors.server = apiServerBehaviors(client);
20
24
  config.behaviors.customer = apiCustomerBehaviors(client);
21
25
  config.behaviors.ingress = apiIngressBehaviors(client);
22
26
  config.behaviors.appInstallation = apiAppInstallationBehaviors(client);
27
+ config.behaviors.contract = apiContractBehaviors(client);
28
+ config.behaviors.contractItem = apiContractItemBehaviors(client);
23
29
  }
24
30
  setupWithApiToken(apiToken) {
25
31
  return this.setupWithClient(MittwaldAPIV2Client.newWithToken(apiToken));
@@ -1,6 +1,9 @@
1
1
  export const config = {
2
2
  defaultPaginationLimit: 50,
3
3
  behaviors: {
4
+ contract: undefined,
5
+ contractItem: undefined,
6
+ article: undefined,
4
7
  project: undefined,
5
8
  server: undefined,
6
9
  customer: undefined,
@@ -0,0 +1,78 @@
1
+ import { DataModel, ListDataModel, ListQueryModel, ReferenceModel, } from "../../base/index.js";
2
+ import { provideReact } from "../../react/index.js";
3
+ import { config } from "../../config/config.js";
4
+ import { classes } from "polytype";
5
+ import assertObjectFound from "../../base/assertObjectFound.js";
6
+ export class Contract extends ReferenceModel {
7
+ static ofId(id) {
8
+ return new Contract(id);
9
+ }
10
+ static find = provideReact(async (id) => {
11
+ const data = await config.behaviors.contract.find(id);
12
+ if (data !== undefined) {
13
+ return new ContractDetailed(data);
14
+ }
15
+ });
16
+ static query(query) {
17
+ return new ContractListQuery(query);
18
+ }
19
+ static get = provideReact(async (id) => {
20
+ const customer = await this.find(id);
21
+ assertObjectFound(customer, this, id);
22
+ return customer;
23
+ });
24
+ }
25
+ class ContractCommon extends classes((DataModel), Contract) {
26
+ constructor(data) {
27
+ super([data], [data.customerId]);
28
+ }
29
+ }
30
+ export class ContractDetailed extends classes(ContractCommon, (DataModel)) {
31
+ constructor(data) {
32
+ super([data], [data]);
33
+ }
34
+ }
35
+ export class ContractListItem extends classes(ContractCommon, (DataModel)) {
36
+ constructor(data) {
37
+ super([data], [data]);
38
+ }
39
+ }
40
+ export class ContractListQuery extends ListQueryModel {
41
+ constructor(query) {
42
+ super(query);
43
+ }
44
+ refine(query) {
45
+ return new ContractListQuery({
46
+ ...this.query,
47
+ ...query,
48
+ });
49
+ }
50
+ execute = provideReact(async () => {
51
+ const { customer, ...query } = this.query;
52
+ const customerId = customer.id;
53
+ const request = {
54
+ customerId: customerId,
55
+ queryParameters: {
56
+ limit: config.defaultPaginationLimit,
57
+ ...query,
58
+ },
59
+ };
60
+ const { items, totalCount } = await config.behaviors.contract.list(request);
61
+ return new ContractList(this.query, items.map((d) => new ContractListItem(d)), totalCount);
62
+ }, [this.queryId]);
63
+ getTotalCount = provideReact(async () => {
64
+ const { totalCount } = await this.refine({ limit: 1 }).execute();
65
+ return totalCount;
66
+ }, [this.queryId]);
67
+ findOneAndOnly = provideReact(async () => {
68
+ const { items, totalCount } = await this.refine({ limit: 1 }).execute();
69
+ if (totalCount === 1) {
70
+ return items[0];
71
+ }
72
+ }, [this.queryId]);
73
+ }
74
+ export class ContractList extends classes(ContractListQuery, (ListDataModel)) {
75
+ constructor(query, contracts, totalCount) {
76
+ super([query], [contracts, totalCount]);
77
+ }
78
+ }
@@ -0,0 +1,20 @@
1
+ import { assertStatus, extractTotalCountHeader, } from "@mittwald/api-client";
2
+ export const apiContractBehaviors = (client) => ({
3
+ find: async (id) => {
4
+ const response = await client.contract.getDetailOfContract({
5
+ contractId: id,
6
+ });
7
+ if (response.status === 200) {
8
+ return response.data;
9
+ }
10
+ assertStatus(response, 404);
11
+ },
12
+ list: async (request) => {
13
+ const response = await client.contract.listContracts(request);
14
+ assertStatus(response, 200);
15
+ return {
16
+ items: response.data,
17
+ totalCount: extractTotalCountHeader(response),
18
+ };
19
+ },
20
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./Contract.js";
2
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { classes } from "polytype";
2
+ import { DataModel, ReferenceModel } from "../../base/index.js";
3
+ import { provideReact } from "../../react/index.js";
4
+ import { config } from "../../config/config.js";
5
+ import assertObjectFound from "../../base/assertObjectFound.js";
6
+ export class ContractItem extends ReferenceModel {
7
+ static ofId(contractId, id) {
8
+ return new ContractItem(contractId, id);
9
+ }
10
+ static find = provideReact(async (contractId, contractItemId) => {
11
+ const data = await config.behaviors.contractItem.find(contractId, contractItemId);
12
+ if (data !== undefined) {
13
+ return new ContractItemDetailed(contractId, data);
14
+ }
15
+ });
16
+ static get = provideReact(async (contractId, contractItemId) => {
17
+ const item = await this.find(contractId, contractItemId);
18
+ assertObjectFound(item, this, contractItemId);
19
+ return item;
20
+ });
21
+ contractId;
22
+ constructor(contractId, id) {
23
+ super(id);
24
+ this.contractId = contractId;
25
+ }
26
+ }
27
+ export class ContractItemDetailed extends classes((DataModel), ContractItem) {
28
+ constructor(contractId, data) {
29
+ super([data], [contractId, data.itemId]);
30
+ }
31
+ }
@@ -0,0 +1,13 @@
1
+ import { assertStatus } from "@mittwald/api-client";
2
+ export const apiContractItemBehaviors = (client) => ({
3
+ find: async (contractId, contractItemId) => {
4
+ const response = await client.contract.getDetailOfContractItem({
5
+ contractId,
6
+ contractItemId,
7
+ });
8
+ if (response.status === 200) {
9
+ return response.data;
10
+ }
11
+ assertStatus(response, 404);
12
+ },
13
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./ContractItem.js";
2
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./Contract/index.js";
2
+ export * from "./ContractItem/index.js";
@@ -1,4 +1,4 @@
1
- import { AppInstallationListItemData, AppInstallationData, AppInstallationListQueryData } from "../types.js";
1
+ import { AppInstallationData, AppInstallationListItemData, AppInstallationListQueryData } from "../types.js";
2
2
  import { QueryResponseData } from "../../../base/index.js";
3
3
  export interface AppInstallationBehaviors {
4
4
  find: (id: string) => Promise<AppInstallationData | undefined>;
@@ -0,0 +1,133 @@
1
+ import { ReferenceModel } from "../../base/ReferenceModel.js";
2
+ import { ArticleData, ArticleListItemData, ArticleListQueryData, ArticleListQueryModelData } from "./types.js";
3
+ import { DataModel } from "../../base/DataModel.js";
4
+ import { ListQueryModel } from "../../base/ListQueryModel.js";
5
+ import { ListDataModel } from "../../base/ListDataModel.js";
6
+ import { Money } from "../../base/Money.js";
7
+ export declare class Article extends ReferenceModel {
8
+ static ofId(id: string): Article;
9
+ static find: import("../../react/provideReact.js").AsyncResourceVariant<(id: string) => Promise<ArticleDetailed | undefined>>;
10
+ static get: import("../../react/provideReact.js").AsyncResourceVariant<(id: string) => Promise<ArticleDetailed>>;
11
+ static query(query?: ArticleListQueryModelData): ArticleListQuery;
12
+ }
13
+ declare const ArticleCommon_base: import("polytype").Polytype.ClusteredConstructor<[{
14
+ new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableArticle | {
15
+ addons?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAddons[] | undefined;
16
+ articleId: string;
17
+ attributes?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAttributes[] | undefined;
18
+ balanceAddonKey?: string | undefined;
19
+ contractDurationInMonth: number;
20
+ description?: string | undefined;
21
+ forcedInvoicingPeriodInMonth?: number | undefined;
22
+ hasIndependentContractPeriod?: boolean | undefined;
23
+ hideOnInvoice?: boolean | undefined;
24
+ machineType?: {
25
+ cpu: string;
26
+ memory: string;
27
+ name: string;
28
+ } | undefined;
29
+ modifierArticles?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableModifierArticleOptions[] | undefined;
30
+ name: string;
31
+ orderable: "forbidden" | "internal" | "beta_testing" | "full" | "deprecated";
32
+ possibleArticleChanges?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableChangeArticleOptions[] | undefined;
33
+ price?: number | undefined;
34
+ tags?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTag[] | undefined;
35
+ template: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTemplate;
36
+ }): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableArticle | {
37
+ addons?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAddons[] | undefined;
38
+ articleId: string;
39
+ attributes?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAttributes[] | undefined;
40
+ balanceAddonKey?: string | undefined;
41
+ contractDurationInMonth: number;
42
+ description?: string | undefined;
43
+ forcedInvoicingPeriodInMonth?: number | undefined;
44
+ hasIndependentContractPeriod?: boolean | undefined;
45
+ hideOnInvoice?: boolean | undefined;
46
+ machineType?: {
47
+ cpu: string;
48
+ memory: string;
49
+ name: string;
50
+ } | undefined;
51
+ modifierArticles?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableModifierArticleOptions[] | undefined;
52
+ name: string;
53
+ orderable: "forbidden" | "internal" | "beta_testing" | "full" | "deprecated";
54
+ possibleArticleChanges?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableChangeArticleOptions[] | undefined;
55
+ price?: number | undefined;
56
+ tags?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTag[] | undefined;
57
+ template: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTemplate;
58
+ }>;
59
+ }, typeof Article]>;
60
+ declare class ArticleCommon extends ArticleCommon_base {
61
+ readonly price: Money;
62
+ constructor(data: ArticleListItemData | ArticleData);
63
+ }
64
+ declare const ArticleDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof ArticleCommon, {
65
+ new (data: {
66
+ addons?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAddons[] | undefined;
67
+ articleId: string;
68
+ attributes?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAttributes[] | undefined;
69
+ balanceAddonKey?: string | undefined;
70
+ contractDurationInMonth: number;
71
+ description?: string | undefined;
72
+ forcedInvoicingPeriodInMonth?: number | undefined;
73
+ hasIndependentContractPeriod?: boolean | undefined;
74
+ hideOnInvoice?: boolean | undefined;
75
+ machineType?: {
76
+ cpu: string;
77
+ memory: string;
78
+ name: string;
79
+ } | undefined;
80
+ modifierArticles?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableModifierArticleOptions[] | undefined;
81
+ name: string;
82
+ orderable: "forbidden" | "internal" | "beta_testing" | "full" | "deprecated";
83
+ possibleArticleChanges?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableChangeArticleOptions[] | undefined;
84
+ price?: number | undefined;
85
+ tags?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTag[] | undefined;
86
+ template: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTemplate;
87
+ }): DataModel<{
88
+ addons?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAddons[] | undefined;
89
+ articleId: string;
90
+ attributes?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleAttributes[] | undefined;
91
+ balanceAddonKey?: string | undefined;
92
+ contractDurationInMonth: number;
93
+ description?: string | undefined;
94
+ forcedInvoicingPeriodInMonth?: number | undefined;
95
+ hasIndependentContractPeriod?: boolean | undefined;
96
+ hideOnInvoice?: boolean | undefined;
97
+ machineType?: {
98
+ cpu: string;
99
+ memory: string;
100
+ name: string;
101
+ } | undefined;
102
+ modifierArticles?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableModifierArticleOptions[] | undefined;
103
+ name: string;
104
+ orderable: "forbidden" | "internal" | "beta_testing" | "full" | "deprecated";
105
+ possibleArticleChanges?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableChangeArticleOptions[] | undefined;
106
+ price?: number | undefined;
107
+ tags?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTag[] | undefined;
108
+ template: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleArticleTemplate;
109
+ }>;
110
+ }]>;
111
+ export declare class ArticleDetailed extends ArticleDetailed_base {
112
+ constructor(data: ArticleData);
113
+ }
114
+ declare const ArticleListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof ArticleCommon, {
115
+ new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableArticle): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ArticleReadableArticle>;
116
+ }]>;
117
+ export declare class ArticleListItem extends ArticleListItem_base {
118
+ constructor(data: ArticleListItemData);
119
+ }
120
+ export declare class ArticleListQuery extends ListQueryModel<ArticleListQueryModelData> {
121
+ constructor(query?: ArticleListQueryModelData);
122
+ refine(query: ArticleListQueryModelData): ArticleListQuery;
123
+ execute: import("../../react/provideReact.js").AsyncResourceVariant<() => Promise<ArticleList>>;
124
+ getTotalCount: import("../../react/provideReact.js").AsyncResourceVariant<() => Promise<number>>;
125
+ findOneAndOnly: import("../../react/provideReact.js").AsyncResourceVariant<() => Promise<ArticleListItem | undefined>>;
126
+ }
127
+ declare const ArticleList_base: import("polytype").Polytype.ClusteredConstructor<[typeof ArticleListQuery, {
128
+ new (items: ArticleListItem[], totalCount: number): ListDataModel<ArticleListItem>;
129
+ }]>;
130
+ export declare class ArticleList extends ArticleList_base {
131
+ constructor(query: ArticleListQueryData, articles: ArticleListItem[], totalCount: number);
132
+ }
133
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ArticleBehaviors } from "./types.js";
2
+ import { MittwaldAPIV2Client } from "@mittwald/api-client";
3
+ export declare const apiArticleBehaviors: (client: MittwaldAPIV2Client) => ArticleBehaviors;
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
@@ -0,0 +1,6 @@
1
+ import { ArticleData, ArticleListItemData, ArticleListQueryData } from "../types.js";
2
+ import { QueryResponseData } from "../../../base/index.js";
3
+ export interface ArticleBehaviors {
4
+ find: (id: string) => Promise<ArticleData | undefined>;
5
+ list: (query?: ArticleListQueryData) => Promise<QueryResponseData<ArticleListItemData>>;
6
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Article.js";
2
+ export * from "./types.js";
@@ -0,0 +1,5 @@
1
+ import { MittwaldAPIV2 } from "@mittwald/api-client";
2
+ export type ArticleListQueryData = MittwaldAPIV2.Paths.V2Articles.Get.Parameters.Query;
3
+ export type ArticleData = MittwaldAPIV2.Operations.ArticleGetArticle.ResponseData;
4
+ export type ArticleListItemData = MittwaldAPIV2.Operations.ArticleListArticles.ResponseData[number];
5
+ export type ArticleListQueryModelData = ArticleListQueryData;
@@ -0,0 +1 @@
1
+ export * from "./Article/index.js";
@@ -0,0 +1,3 @@
1
+ import Dinero from "dinero.js";
2
+ export declare const Money: typeof Dinero;
3
+ export type Money = ReturnType<typeof Money>;
@@ -2,10 +2,16 @@ import { ProjectBehaviors } from "../project/Project/behaviors/index.js";
2
2
  import { ServerBehaviors } from "../server/Server/behaviors/index.js";
3
3
  import { CustomerBehaviors } from "../customer/Customer/behaviors/index.js";
4
4
  import { IngressBehaviors } from "../domain/Ingress/behaviors/index.js";
5
+ import { ContractBehaviors } from "../contract/Contract/behaviors/index.js";
5
6
  import { AppInstallationBehaviors } from "../app/AppInstallation/behaviors/index.js";
7
+ import { ContractItemBehaviors } from "../contract/ContractItem/behaviors/index.js";
8
+ import { ArticleBehaviors } from "../article/Article/behaviors/index.js";
6
9
  interface Config {
7
10
  defaultPaginationLimit: number;
8
11
  behaviors: {
12
+ contract: ContractBehaviors;
13
+ contractItem: ContractItemBehaviors;
14
+ article: ArticleBehaviors;
9
15
  project: ProjectBehaviors;
10
16
  server: ServerBehaviors;
11
17
  customer: CustomerBehaviors;
@@ -0,0 +1,68 @@
1
+ import { DataModel, ListDataModel, ListQueryModel, ReferenceModel } from "../../base/index.js";
2
+ import { ContractData, ContractListItemData, ContractListQueryData, ContractListQueryModelData } from "./types.js";
3
+ export declare class Contract extends ReferenceModel {
4
+ static ofId(id: string): Contract;
5
+ static find: import("../../react/provideReact.js").AsyncResourceVariant<(id: string) => Promise<ContractDetailed | undefined>>;
6
+ static query(query: ContractListQueryModelData): ContractListQuery;
7
+ static get: import("../../react/provideReact.js").AsyncResourceVariant<(id: string) => Promise<ContractDetailed>>;
8
+ }
9
+ declare const ContractCommon_base: import("polytype").Polytype.ClusteredConstructor<[{
10
+ new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContract | {
11
+ additionalItems?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem[] | undefined;
12
+ baseItem: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem;
13
+ contractId: string;
14
+ contractNumber: string;
15
+ customerId: string;
16
+ termination?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTermination | undefined;
17
+ }): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContract | {
18
+ additionalItems?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem[] | undefined;
19
+ baseItem: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem;
20
+ contractId: string;
21
+ contractNumber: string;
22
+ customerId: string;
23
+ termination?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTermination | undefined;
24
+ }>;
25
+ }, typeof Contract]>;
26
+ declare class ContractCommon extends ContractCommon_base {
27
+ constructor(data: ContractListItemData | ContractData);
28
+ }
29
+ declare const ContractDetailed_base: import("polytype").Polytype.ClusteredConstructor<[typeof ContractCommon, {
30
+ new (data: {
31
+ additionalItems?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem[] | undefined;
32
+ baseItem: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem;
33
+ contractId: string;
34
+ contractNumber: string;
35
+ customerId: string;
36
+ termination?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTermination | undefined;
37
+ }): DataModel<{
38
+ additionalItems?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem[] | undefined;
39
+ baseItem: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContractItem;
40
+ contractId: string;
41
+ contractNumber: string;
42
+ customerId: string;
43
+ termination?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTermination | undefined;
44
+ }>;
45
+ }]>;
46
+ export declare class ContractDetailed extends ContractDetailed_base {
47
+ constructor(data: ContractData);
48
+ }
49
+ declare const ContractListItem_base: import("polytype").Polytype.ClusteredConstructor<[typeof ContractCommon, {
50
+ new (data: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContract): DataModel<import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractContract>;
51
+ }]>;
52
+ export declare class ContractListItem extends ContractListItem_base {
53
+ constructor(data: ContractListItemData);
54
+ }
55
+ export declare class ContractListQuery extends ListQueryModel<ContractListQueryModelData> {
56
+ constructor(query: ContractListQueryModelData);
57
+ refine(query: ContractListQueryData): ContractListQuery;
58
+ execute: import("../../react/provideReact.js").AsyncResourceVariant<() => Promise<ContractList>>;
59
+ getTotalCount: import("../../react/provideReact.js").AsyncResourceVariant<() => Promise<number>>;
60
+ findOneAndOnly: import("../../react/provideReact.js").AsyncResourceVariant<() => Promise<ContractListItem | undefined>>;
61
+ }
62
+ declare const ContractList_base: import("polytype").Polytype.ClusteredConstructor<[typeof ContractListQuery, {
63
+ new (items: ContractListItem[], totalCount: number): ListDataModel<ContractListItem>;
64
+ }]>;
65
+ export declare class ContractList extends ContractList_base {
66
+ constructor(query: ContractListQueryModelData, contracts: ContractListItem[], totalCount: number);
67
+ }
68
+ export {};
@@ -0,0 +1,3 @@
1
+ import { MittwaldAPIV2Client } from "@mittwald/api-client";
2
+ import { ContractBehaviors } from "./types.js";
3
+ export declare const apiContractBehaviors: (client: MittwaldAPIV2Client) => ContractBehaviors;
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
@@ -0,0 +1,9 @@
1
+ import { ContractData, ContractListItemData, ContractListQueryData } from "../types.js";
2
+ import { QueryResponseData } from "../../../base/index.js";
3
+ export interface ContractBehaviors {
4
+ find: (id: string) => Promise<ContractData | undefined>;
5
+ list: (request: {
6
+ customerId: string;
7
+ queryParameters?: ContractListQueryData;
8
+ }) => Promise<QueryResponseData<ContractListItemData>>;
9
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Contract.js";
2
+ export * from "./types.js";
@@ -0,0 +1,8 @@
1
+ import { MittwaldAPIV2 } from "@mittwald/api-client";
2
+ import { Customer } from "../../customer/index.js";
3
+ export type ContractListQueryData = MittwaldAPIV2.Paths.V2ContractsContractId.Get.Parameters.Query;
4
+ export type ContractListQueryModelData = Omit<ContractListQueryData, "customerId"> & {
5
+ customer: Customer;
6
+ };
7
+ export type ContractData = MittwaldAPIV2.Operations.ContractGetDetailOfContract.ResponseData;
8
+ export type ContractListItemData = MittwaldAPIV2.Operations.ContractListContracts.ResponseData[number];
@@ -0,0 +1,64 @@
1
+ import { ContractItemData } from "./types.js";
2
+ import { DataModel, ReferenceModel } from "../../base/index.js";
3
+ export declare class ContractItem extends ReferenceModel {
4
+ static ofId(contractId: string, id: string): ContractItem;
5
+ static find: import("../../react/provideReact.js").AsyncResourceVariant<(contractId: string, contractItemId: string) => Promise<ContractItemDetailed | undefined>>;
6
+ static get: import("../../react/provideReact.js").AsyncResourceVariant<(contractId: string, contractItemId: string) => Promise<ContractItemDetailed>>;
7
+ readonly contractId: string;
8
+ constructor(contractId: string, id: string);
9
+ }
10
+ declare const ContractItemDetailed_base: import("polytype").Polytype.ClusteredConstructor<[{
11
+ new (data: {
12
+ activationDate?: string | undefined;
13
+ aggregateReference?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractAggregateReference | undefined;
14
+ articles: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractArticle[];
15
+ contractPeriod: number;
16
+ description: string;
17
+ freeTrialDays?: number | undefined;
18
+ groupByProjectId?: string | undefined;
19
+ invoiceStop?: string | undefined;
20
+ invoicingPeriod?: number | undefined;
21
+ isActivated: boolean;
22
+ isBaseItem: boolean;
23
+ isInFreeTrial?: boolean | undefined;
24
+ isInclusive?: boolean | undefined;
25
+ itemId: string;
26
+ nextPossibleDowngradeDate?: string | undefined;
27
+ nextPossibleTerminationDate?: string | undefined;
28
+ nextPossibleUpgradeDate?: string | undefined;
29
+ orderDate?: string | undefined;
30
+ orderId?: string | undefined;
31
+ replacedByItem?: string | undefined;
32
+ tariffChange?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTariffChange | undefined;
33
+ termination?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTermination | undefined;
34
+ totalPrice: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractPrice;
35
+ }): DataModel<{
36
+ activationDate?: string | undefined;
37
+ aggregateReference?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractAggregateReference | undefined;
38
+ articles: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractArticle[];
39
+ contractPeriod: number;
40
+ description: string;
41
+ freeTrialDays?: number | undefined;
42
+ groupByProjectId?: string | undefined;
43
+ invoiceStop?: string | undefined;
44
+ invoicingPeriod?: number | undefined;
45
+ isActivated: boolean;
46
+ isBaseItem: boolean;
47
+ isInFreeTrial?: boolean | undefined;
48
+ isInclusive?: boolean | undefined;
49
+ itemId: string;
50
+ nextPossibleDowngradeDate?: string | undefined;
51
+ nextPossibleTerminationDate?: string | undefined;
52
+ nextPossibleUpgradeDate?: string | undefined;
53
+ orderDate?: string | undefined;
54
+ orderId?: string | undefined;
55
+ replacedByItem?: string | undefined;
56
+ tariffChange?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTariffChange | undefined;
57
+ termination?: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractTermination | undefined;
58
+ totalPrice: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.ContractPrice;
59
+ }>;
60
+ }, typeof ContractItem]>;
61
+ export declare class ContractItemDetailed extends ContractItemDetailed_base {
62
+ constructor(contractId: string, data: ContractItemData);
63
+ }
64
+ export {};
@@ -0,0 +1,3 @@
1
+ import { MittwaldAPIV2Client } from "@mittwald/api-client";
2
+ import { ContractItemBehaviors } from "./types.js";
3
+ export declare const apiContractItemBehaviors: (client: MittwaldAPIV2Client) => ContractItemBehaviors;
@@ -0,0 +1,2 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
@@ -0,0 +1,4 @@
1
+ import { ContractItemData } from "../types.js";
2
+ export interface ContractItemBehaviors {
3
+ find: (contractId: string, contractItemId: string) => Promise<ContractItemData | undefined>;
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./ContractItem.js";
2
+ export * from "./types.js";
@@ -0,0 +1,2 @@
1
+ import { MittwaldAPIV2 } from "@mittwald/api-client";
2
+ export type ContractItemData = MittwaldAPIV2.Operations.ContractGetDetailOfContractItem.ResponseData;
@@ -0,0 +1,2 @@
1
+ export * from "./Contract/index.js";
2
+ export * from "./ContractItem/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/api-models",
3
- "version": "4.61.1",
3
+ "version": "4.63.0",
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",
@@ -42,6 +42,7 @@
42
42
  "@mittwald/api-client": "^4.61.1",
43
43
  "another-deep-freeze": "^1.0.0",
44
44
  "context": "^3.0.31",
45
+ "dinero.js": "^1.9.1",
45
46
  "object-code": "^1.3.3",
46
47
  "polytype": "^0.17.0",
47
48
  "tsd": "^0.31.2",
@@ -53,6 +54,7 @@
53
54
  "@testing-library/dom": "^10.4.0",
54
55
  "@testing-library/jest-dom": "^6.5.0",
55
56
  "@testing-library/react": "^16.0.1",
57
+ "@types/dinero.js": "^1",
56
58
  "@types/jest": "^29.5.12",
57
59
  "@types/react": "^18.3.3",
58
60
  "@types/react-dom": "^18",
@@ -82,5 +84,5 @@
82
84
  "optional": true
83
85
  }
84
86
  },
85
- "gitHead": "bb13260f2e6937312aeba5cf716ce7c3f8eb85a3"
87
+ "gitHead": "ab7742169cf0221128ed193c169d52c4bbb237de"
86
88
  }