ApiMutationContract
tipo Desde 1.2.0
Operaciones de escritura (POST, PUT, PATCH, DELETE) de un contrato de API indexadas por
ruta y método (["/api/notes"]["POST"]), a partir del manifiesto público. Es el tipo que recibe
UseApiMutation.
ts
import type { ApiMutationContract } from "@meekojs/meeko/framework";Código fuente src/app/composables/resources/engine.ts:361
Declaración #
ts
type ApiMutationContract<Manifest, Contract> = {
[P in MutationEndpoint<Manifest>['pathname']]: {
[E in Extract<MutationEndpoint<Manifest>, { readonly pathname: P }> as E['method']]: MethodOperation<Contract, E['clientKey'], E['method']>
}
}Parámetros de tipo #
-
Manifest Manifiesto público con los endpoints (
pathname,method,clientKey).-
Contract Contrato
ApiContractgenerado, indexado porclientKey.
Ejemplo #
ts
import type { ApiMutationContract, ApiOperation } from "@meekojs/meeko/framework";
type Contract = { notes: { post: ApiOperation<undefined, undefined, { text: string }, { id: string }> } };
declare const manifest: { readonly api: readonly [{ readonly clientKey: "notes"; readonly pathname: "/api/notes"; readonly method: "POST" }] };
// Mutations["/api/notes"]["POST"] es la operación de api.notes.post.
type Mutations = ApiMutationContract<typeof manifest, Contract>;