Skip to content

Commit

Permalink
feat(api-headless-cms): improve input types
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Sep 14, 2024
1 parent 70c249d commit 5d15934
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ interface MarkLockedFieldsParams {
}

export const markLockedFields = async (params: MarkLockedFieldsParams): Promise<void> => {
return;
const { model, context } = params;
/**
* If the model is registered via a plugin, we don't need do process anything.
Expand Down
7 changes: 4 additions & 3 deletions packages/api-headless-cms/src/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
UpdateCmsEntryOptionsInput
} from "./types";
import { CmsModel } from "./model";
import {GenericRecord} from "@webiny/api/types";

/**
* Cms Entry CRUD methods in the context.
Expand Down Expand Up @@ -120,7 +121,7 @@ export interface CmsEntryContext {
*/
createEntry: <T = CmsEntryValues>(
model: CmsModel,
input: CreateCmsEntryInput,
input: CreateCmsEntryInput<T>,
options?: CreateCmsEntryOptionsInput
) => Promise<CmsEntry<T>>;
/**
Expand All @@ -135,10 +136,10 @@ export interface CmsEntryContext {
/**
* Update existing entry.
*/
updateEntry: (
updateEntry: <TInput = CmsEntryValues>(
model: CmsModel,
id: string,
input: UpdateCmsEntryInput,
input: UpdateCmsEntryInput<TInput>,
meta?: Record<string, any>,
options?: UpdateCmsEntryOptionsInput
) => Promise<CmsEntry>;
Expand Down
12 changes: 4 additions & 8 deletions packages/api-headless-cms/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ export interface EntryBeforeListTopicParams {
* @category Context
* @category CmsEntry
*/
export interface CreateCmsEntryInput {
export type CreateCmsEntryInput<TValues = CmsEntryValues> = TValues & {
id?: string;
status?: CmsEntryStatus;

Expand Down Expand Up @@ -1419,9 +1419,7 @@ export interface CreateCmsEntryInput {
wbyAco_location?: {
folderId?: string | null;
};

[key: string]: any;
}
};

export interface CreateCmsEntryOptionsInput {
skipValidators?: string[];
Expand Down Expand Up @@ -1471,7 +1469,7 @@ export interface CreateRevisionCmsEntryOptionsInput {
* @category Context
* @category CmsEntry
*/
export interface UpdateCmsEntryInput {
export type UpdateCmsEntryInput<TValues = CmsEntryValues> = TValues & {
/**
* Revision-level meta fields. 👇
*/
Expand Down Expand Up @@ -1511,9 +1509,7 @@ export interface UpdateCmsEntryInput {
wbyAco_location?: {
folderId?: string | null;
};

[key: string]: any;
}
};

export interface UpdateCmsEntryOptionsInput {
skipValidators?: string[];
Expand Down

0 comments on commit 5d15934

Please sign in to comment.