diff --git a/packages/models/src/ssl/Certificate/Certificate.ts b/packages/models/src/ssl/Certificate/Certificate.ts index 4f64e1a7..e6850672 100644 --- a/packages/models/src/ssl/Certificate/Certificate.ts +++ b/packages/models/src/ssl/Certificate/Certificate.ts @@ -8,6 +8,7 @@ import { import { CertificateData, CertificateListItemData, + CertificateListQueryData, CertificateListQueryModelData, } from "./types.js"; import { AsyncResourceVariant, provideReact } from "../../react/index.js"; @@ -37,6 +38,16 @@ export class Certificate extends ReferenceModel { }, ); + public static query = provideReact( + async ( + projectId: string, + query: CertificateListQueryData, + ): Promise>> => + new CertificateListQuery(Project.ofId(projectId), query) + .execute() + .then((r) => r.items), + ); + public getDetailed = provideReact(() => Certificate.get(this.id)); public findDetailed = provideReact(() => Certificate.find(this.id), diff --git a/packages/models/src/ssl/CertificateRequest/CertificateRequest.ts b/packages/models/src/ssl/CertificateRequest/CertificateRequest.ts index efd9855f..1917f38b 100644 --- a/packages/models/src/ssl/CertificateRequest/CertificateRequest.ts +++ b/packages/models/src/ssl/CertificateRequest/CertificateRequest.ts @@ -8,6 +8,7 @@ import { classes } from "polytype"; import { CertificateRequestData, CertificateRequestListItemData, + CertificateRequestListQueryData, CertificateRequestListQueryModelData, } from "./types.js"; import { CertificateListQueryModelData } from "../Certificate/types.js"; @@ -40,6 +41,16 @@ export class CertificateRequest extends ReferenceModel { }, ); + public static query = provideReact( + async ( + projectId: string, + query: CertificateRequestListQueryData, + ): Promise>> => + new CertificateRequestListQuery(Project.ofId(projectId), query) + .execute() + .then((r) => r.items), + ); + public getDetailed = provideReact(() => CertificateRequest.get(this.id)); public findDetailed = provideReact(() => CertificateRequest.find(this.id), diff --git a/packages/models/src/ssl/CertificateRequest/types.ts b/packages/models/src/ssl/CertificateRequest/types.ts index 75d0630c..be97fd7a 100644 --- a/packages/models/src/ssl/CertificateRequest/types.ts +++ b/packages/models/src/ssl/CertificateRequest/types.ts @@ -4,11 +4,11 @@ import { Project } from "../../project/index.js"; export type CertificateRequestData = MittwaldAPIV2.Operations.SslGetCertificateRequest.ResponseData; -export type CertificateRequestListQuery = +export type CertificateRequestListQueryData = MittwaldAPIV2.Paths.V2CertificateRequests.Get.Parameters.Query; export type CertificateRequestListQueryModelData = Omit< - CertificateRequestListQuery, + CertificateRequestListQueryData, "projectId" > & { project?: Project;