Skip to content

Commit

Permalink
Refactor getDatabaseEntryUser and getDatabaseEntryPage interfaces to …
Browse files Browse the repository at this point in the history
…use object literal syntax for user and page selection
  • Loading branch information
Adammatthiesen committed Dec 11, 2024
1 parent cc5422f commit cc08ca8
Showing 1 changed file with 40 additions and 51 deletions.
91 changes: 40 additions & 51 deletions packages/studiocms_core/src/sdk-utils/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,55 +133,6 @@ export interface CombinedPageData extends PageDataStripped {
defaultContent: tsPageContentSelect | undefined;
}

/**
* Interface for retrieving user data from the database.
* Provides methods to fetch user data by different identifiers.
*/
interface GetDatabaseEntryUser {
/**
* Fetches user data by user ID.
* @param id - The unique identifier of the user.
* @returns A promise that resolves to the combined user data or undefined if not found.
*/
byId: (id: string) => Promise<CombinedUserData | undefined>;

/**
* Fetches user data by username.
* @param username - The username of the user.
* @returns A promise that resolves to the combined user data or undefined if not found.
*/
byUsername: (username: string) => Promise<CombinedUserData | undefined>;

/**
* Fetches user data by email.
* @param email - The email address of the user.
* @returns A promise that resolves to the combined user data or undefined if not found.
*/
byEmail: (email: string) => Promise<CombinedUserData | undefined>;
}

/**
* Interface representing methods to retrieve database entries for pages.
*/
interface GetDatabaseEntryPage {
/**
* Retrieves a page entry by its unique identifier.
*
* @param id - The unique identifier of the page.
* @returns A promise that resolves to the combined page data or undefined if not found.
*/
byId: (id: string) => Promise<CombinedPageData | undefined>;

/**
* Retrieves a page entry by its slug and package name.
*
* @param slug - The slug of the page.
* @param pkg - The package name associated with the page.
* @returns A promise that resolves to the combined page data or undefined if not found.
*/
bySlug: (slug: string, pkg: string) => Promise<CombinedPageData | undefined>;
}

/**
* Interface representing the STUDIOCMS SDK.
*/
Expand Down Expand Up @@ -253,12 +204,50 @@ export interface STUDIOCMS_SDK {
/**
* Provides methods to retrieve user data by different identifiers.
*/
users: GetDatabaseEntryUser;
users: {
/**
* Fetches user data by user ID.
* @param id - The unique identifier of the user.
* @returns A promise that resolves to the combined user data or undefined if not found.
*/
byId: (id: string) => Promise<CombinedUserData | undefined>;

/**
* Fetches user data by username.
* @param username - The username of the user.
* @returns A promise that resolves to the combined user data or undefined if not found.
*/
byUsername: (username: string) => Promise<CombinedUserData | undefined>;

/**
* Fetches user data by email.
* @param email - The email address of the user.
* @returns A promise that resolves to the combined user data or undefined if not found.
*/
byEmail: (email: string) => Promise<CombinedUserData | undefined>;
};

/**
* Provides methods to retrieve page data by different identifiers.
*/
pages: GetDatabaseEntryPage;
pages: {
/**
* Retrieves a page entry by its unique identifier.
*
* @param id - The unique identifier of the page.
* @returns A promise that resolves to the combined page data or undefined if not found.
*/
byId: (id: string) => Promise<CombinedPageData | undefined>;

/**
* Retrieves a page entry by its slug and package name.
*
* @param slug - The slug of the page.
* @param pkg - The package name associated with the page.
* @returns A promise that resolves to the combined page data or undefined if not found.
*/
bySlug: (slug: string, pkg: string) => Promise<CombinedPageData | undefined>;
};
};

/**
Expand Down

0 comments on commit cc08ca8

Please sign in to comment.