diff --git a/packages/studiocms_core/package.json b/packages/studiocms_core/package.json
index e46cde43..82531944 100644
--- a/packages/studiocms_core/package.json
+++ b/packages/studiocms_core/package.json
@@ -47,6 +47,7 @@
"./sdk-utils/post": "./src/sdk-utils/post/index.ts",
"./sdk-utils/get": "./src/sdk-utils/get/index.ts",
"./sdk-utils/types": "./src/sdk-utils/types/index.ts",
+ "./sdk-utils/tables": "./src/sdk-utils/tables.ts",
"./sdk-utils/utils": "./src/sdk-utils/utils.ts"
},
"type": "module",
diff --git a/packages/studiocms_core/src/consts.ts b/packages/studiocms_core/src/consts.ts
index 28a58a92..4d37f93a 100644
--- a/packages/studiocms_core/src/consts.ts
+++ b/packages/studiocms_core/src/consts.ts
@@ -10,7 +10,7 @@ export const PLUGIN_INTEGRATION_ICON: string =
export const CMSSiteConfigId: number = 1;
/**
- * StudioCMS Site Config Table Entry ID
+ * StudioCMS Social Links Type
*/
export type StudioCMSSocials = {
github: string;
diff --git a/packages/studiocms_core/src/sdk-utils/get/getDatabase.ts b/packages/studiocms_core/src/sdk-utils/get/getDatabase.ts
index 930ebfbf..a02c7584 100644
--- a/packages/studiocms_core/src/sdk-utils/get/getDatabase.ts
+++ b/packages/studiocms_core/src/sdk-utils/get/getDatabase.ts
@@ -1,14 +1,8 @@
///
import { db, eq } from 'astro:db';
import { CMSSiteConfigId } from '../../consts';
-import { tsPageData, tsSiteConfig, tsUsers } from '../../db/tsTables';
-import type {
- CombinedPageData,
- CombinedUserData,
- GetDatabase,
- SimplifiedTables,
- SiteConfig,
-} from '../types';
+import { tsPageData, tsSiteConfig, tsUsers } from '../tables';
+import type { CombinedPageData, CombinedUserData, STUDIOCMS_SDK, SiteConfig } from '../types';
import { collectPageData, collectUserData } from '../utils';
/**
@@ -25,7 +19,9 @@ import { collectPageData, collectUserData } from '../utils';
*
* @throws Will throw an error if the specified database table is not recognized.
*/
-export async function getDatabase(database: SimplifiedTables): Promise {
+export async function getDatabase(
+ database: Parameters[0]
+): ReturnType {
switch (database) {
case 'users': {
const combinedUserData: CombinedUserData[] = [];
diff --git a/packages/studiocms_core/src/sdk-utils/get/getDatabaseEntry.ts b/packages/studiocms_core/src/sdk-utils/get/getDatabaseEntry.ts
index c59c4548..a255751c 100644
--- a/packages/studiocms_core/src/sdk-utils/get/getDatabaseEntry.ts
+++ b/packages/studiocms_core/src/sdk-utils/get/getDatabaseEntry.ts
@@ -1,12 +1,7 @@
///
import { and, db, eq } from 'astro:db';
-import { tsPageData, tsUsers } from '../../db/tsTables';
-import type {
- CombinedPageData,
- CombinedUserData,
- DatabaseEntryTables,
- GetDatabaseEntry,
-} from '../types';
+import { tsPageData, tsUsers } from '../tables';
+import type { STUDIOCMS_SDK } from '../types';
import { collectPageData, collectUserData } from '../utils';
/**
@@ -38,7 +33,9 @@ import { collectPageData, collectUserData } from '../utils';
* }
* ```
*/
-export function getDatabaseEntry(database: DatabaseEntryTables): GetDatabaseEntry {
+export function getDatabaseEntry(
+ database: Parameters[0]
+): ReturnType {
switch (database) {
case 'users': {
return {
@@ -64,7 +61,7 @@ export function getDatabaseEntry(database: DatabaseEntryTables): GetDatabaseEntr
* }
* ```
*/
- async byId(id: string): Promise {
+ async byId(id) {
const user = await db.select().from(tsUsers).where(eq(tsUsers.id, id)).get();
if (!user) return undefined;
@@ -93,7 +90,7 @@ export function getDatabaseEntry(database: DatabaseEntryTables): GetDatabaseEntr
* }
* ```
*/
- async byUsername(username: string): Promise {
+ async byUsername(username) {
const user = await db.select().from(tsUsers).where(eq(tsUsers.username, username)).get();
if (!user) return undefined;
@@ -121,7 +118,7 @@ export function getDatabaseEntry(database: DatabaseEntryTables): GetDatabaseEntr
* console.log('User not found');
* }
*/
- async byEmail(email: string): Promise {
+ async byEmail(email) {
const user = await db.select().from(tsUsers).where(eq(tsUsers.email, email)).get();
if (!user) return undefined;
@@ -158,7 +155,7 @@ export function getDatabaseEntry(database: DatabaseEntryTables): GetDatabaseEntr
* }
* ```
*/
- async byId(id: string): Promise {
+ async byId(id) {
const page = await db.select().from(tsPageData).where(eq(tsPageData.id, id)).get();
if (!page) return undefined;
@@ -192,7 +189,7 @@ export function getDatabaseEntry(database: DatabaseEntryTables): GetDatabaseEntr
* }
* ```
*/
- async bySlug(slug: string, pkg?: string): Promise {
+ async bySlug(slug, pkg?) {
const pkgToGet = pkg || 'studiocms';
const page = await db
diff --git a/packages/studiocms_core/src/sdk-utils/get/getDatabaseTable.ts b/packages/studiocms_core/src/sdk-utils/get/getDatabaseTable.ts
index dbf4c143..f786caa5 100644
--- a/packages/studiocms_core/src/sdk-utils/get/getDatabaseTable.ts
+++ b/packages/studiocms_core/src/sdk-utils/get/getDatabaseTable.ts
@@ -12,8 +12,8 @@ import {
tsSessionTable,
tsSiteConfig,
tsUsers,
-} from '../../db/tsTables';
-import type { CurrentTables, DatabaseTables } from '../types';
+} from '../tables';
+import type { STUDIOCMS_SDK } from '../types';
/**
* Retrieves raw data from the specified database table.
@@ -28,7 +28,9 @@ import type { CurrentTables, DatabaseTables } from '../types';
* console.log(users);
* ```
*/
-export async function getDatabaseTable(database: CurrentTables): Promise {
+export async function getDatabaseTable(
+ database: Parameters[0]
+): ReturnType {
switch (database) {
case 'users':
return await db.select().from(tsUsers);
diff --git a/packages/studiocms_core/src/sdk-utils/get/getPackagePages.ts b/packages/studiocms_core/src/sdk-utils/get/getPackagePages.ts
index 542a69f7..ea8db808 100644
--- a/packages/studiocms_core/src/sdk-utils/get/getPackagePages.ts
+++ b/packages/studiocms_core/src/sdk-utils/get/getPackagePages.ts
@@ -1,7 +1,7 @@
///
import { db, eq } from 'astro:db';
-import { tsPageData } from '../../db/tsTables';
-import type { CombinedPageData } from '../types';
+import { tsPageData } from '../tables';
+import type { CombinedPageData, STUDIOCMS_SDK } from '../types';
import { collectPageData } from '../utils';
/**
@@ -10,7 +10,9 @@ import { collectPageData } from '../utils';
* @param packageName - The name of the package for which to retrieve pages.
* @returns A promise that resolves to an array of CombinedPageData objects.
*/
-export async function getPackagePages(packageName: string): Promise {
+export async function getPackagePages(
+ packageName: Parameters[0]
+): ReturnType {
const pages: CombinedPageData[] = [];
const pagesRaw = await db.select().from(tsPageData).where(eq(tsPageData.package, packageName));
diff --git a/packages/studiocms_core/src/sdk-utils/get/getPermissionLists.ts b/packages/studiocms_core/src/sdk-utils/get/getPermissionLists.ts
index 5aae36ca..bfa0386d 100644
--- a/packages/studiocms_core/src/sdk-utils/get/getPermissionLists.ts
+++ b/packages/studiocms_core/src/sdk-utils/get/getPermissionLists.ts
@@ -1,7 +1,7 @@
///
import { db } from 'astro:db';
-import { tsPermissions, tsUsers } from '../../db/tsTables';
-import type { AvailableLists, PermissionsList } from '../types';
+import { tsPermissions, tsUsers } from '../tables';
+import type { STUDIOCMS_SDK } from '../types';
import { combineRanks, verifyRank } from '../utils';
/**
@@ -27,7 +27,9 @@ import { combineRanks, verifyRank } from '../utils';
* console.log(owners);
* ```
*/
-export async function getPermissionsLists(list: AvailableLists): Promise {
+export async function getPermissionsLists(
+ list: Parameters[0]
+): ReturnType {
switch (list) {
case 'all': {
const [currentPermittedUsers, existingUsers] = await db.batch([
diff --git a/packages/studiocms_core/src/sdk-utils/post/addDatabaseEntry.ts b/packages/studiocms_core/src/sdk-utils/post/addDatabaseEntry.ts
index 16c86b52..4158db4b 100644
--- a/packages/studiocms_core/src/sdk-utils/post/addDatabaseEntry.ts
+++ b/packages/studiocms_core/src/sdk-utils/post/addDatabaseEntry.ts
@@ -6,161 +6,144 @@ import {
tsPageDataCategories,
tsPageDataTags,
tsPermissions,
-} from '../../db/tsTables';
-import type { AddDatabaseEntry } from '../types';
+} from '../tables';
+import type { STUDIOCMS_SDK } from '../types';
import { generateRandomIDNumber } from '../utils';
-export const addDatabaseEntry: AddDatabaseEntry = {
- pages: {
- /**
- * Adds a new page entry to the database.
- *
- * @param pageData - An object containing the page metadata.
- * @param pageContent - An object containing the page content.
- *
- * @returns A promise that resolves to an object containing the newly inserted page data and content.
- *
- * @throws Will throw an error if there is an error during the insertion process.
- */
- insert: async (pageData, pageContent) => {
- const newContentID = crypto.randomUUID().toString();
+/**
+ * Utility functions for adding various entries to the database.
+ */
+export const addDatabaseEntry: STUDIOCMS_SDK['POST']['databaseEntry'] = {
+ pages: async (pageData, pageContent) => {
+ const newContentID = crypto.randomUUID().toString();
- const {
- title,
- slug,
- description,
- authorId = null,
- package: packageName = 'studiocms',
- contentLang = 'default',
- heroImage = '',
- showOnNav = false,
- showAuthor = false,
- showContributors = false,
- } = pageData;
+ const {
+ title,
+ slug,
+ description,
+ authorId = null,
+ package: packageName = 'studiocms',
+ contentLang = 'default',
+ heroImage = '',
+ showOnNav = false,
+ showAuthor = false,
+ showContributors = false,
+ } = pageData;
- const stringified = {
- categories: JSON.stringify(pageData.categories),
- tags: JSON.stringify(pageData.tags),
- contributorIds: JSON.stringify(pageData.contributorIds),
- };
+ const stringified = {
+ categories: JSON.stringify(pageData.categories),
+ tags: JSON.stringify(pageData.tags),
+ contributorIds: JSON.stringify(pageData.contributorIds),
+ };
- const contentData = {
- id: crypto.randomUUID().toString(),
- contentId: newContentID,
- contentLang: pageContent.contentLang || 'default',
- content: pageContent.content || '',
- };
+ const contentData = {
+ id: crypto.randomUUID().toString(),
+ contentId: newContentID,
+ contentLang: pageContent.contentLang || 'default',
+ content: pageContent.content || '',
+ };
- const NOW = new Date();
+ const NOW = new Date();
- const [newPageData, newPageContent] = await db
- .batch([
- db
- .insert(tsPageData)
- .values({
- id: newContentID,
- title,
- slug,
- description,
- authorId,
- contentLang,
- heroImage,
- showAuthor,
- showContributors,
- showOnNav,
- package: packageName,
- publishedAt: NOW,
- updatedAt: NOW,
- ...stringified,
- })
- .returning({ id: tsPageData.id }),
- db.insert(tsPageContent).values(contentData).returning({ id: tsPageContent.id }),
- ])
- .catch((error) => {
- throw new Error(error);
- });
+ const [newPageData, newPageContent] = await db
+ .batch([
+ db
+ .insert(tsPageData)
+ .values({
+ id: newContentID,
+ title,
+ slug,
+ description,
+ authorId,
+ contentLang,
+ heroImage,
+ showAuthor,
+ showContributors,
+ showOnNav,
+ package: packageName,
+ publishedAt: NOW,
+ updatedAt: NOW,
+ ...stringified,
+ })
+ .returning({ id: tsPageData.id }),
+ db.insert(tsPageContent).values(contentData).returning({ id: tsPageContent.id }),
+ ])
+ .catch((error) => {
+ throw new Error(error);
+ });
- return {
- pageData: newPageData,
- pageContent: newPageContent,
- };
- },
+ return {
+ pageData: newPageData,
+ pageContent: newPageContent,
+ };
},
- pageContent: {
- insert: async (pageId, pageContent) => {
- return await db
- .insert(tsPageContent)
- .values({
- id: crypto.randomUUID().toString(),
- contentId: pageId,
- contentLang: pageContent.contentLang || 'default',
- content: pageContent.content || '',
- })
- .returning({ id: tsPageContent.id })
- .catch((error) => {
- throw new Error(error);
- });
- },
+ pageContent: async (pageId, pageContent) => {
+ return await db
+ .insert(tsPageContent)
+ .values({
+ id: crypto.randomUUID().toString(),
+ contentId: pageId,
+ contentLang: pageContent.contentLang || 'default',
+ content: pageContent.content || '',
+ })
+ .returning({ id: tsPageContent.id })
+ .catch((error) => {
+ throw new Error(error);
+ });
},
- tags: {
- insert: async (tag) => {
- return await db
- .insert(tsPageDataTags)
- .values({
- name: tag.name,
- description: tag.description,
- slug: tag.slug,
- meta: JSON.stringify(tag.meta),
- id: generateRandomIDNumber(9),
- })
- .returning({ id: tsPageDataTags.id })
- .catch((error) => {
- throw new Error(error);
- });
- },
+ tags: async (tag) => {
+ return await db
+ .insert(tsPageDataTags)
+ .values({
+ name: tag.name,
+ description: tag.description,
+ slug: tag.slug,
+ meta: JSON.stringify(tag.meta),
+ id: generateRandomIDNumber(9),
+ })
+ .returning({ id: tsPageDataTags.id })
+ .catch((error) => {
+ throw new Error(error);
+ });
},
- categories: {
- insert: async (category) => {
- return await db
- .insert(tsPageDataCategories)
- .values({
- name: category.name,
- description: category.description,
- slug: category.slug,
- meta: JSON.stringify(category.meta),
- id: generateRandomIDNumber(9),
- })
- .returning({ id: tsPageDataCategories.id })
- .catch((error) => {
- throw new Error(error);
- });
- },
+ categories: async (category) => {
+ return await db
+ .insert(tsPageDataCategories)
+ .values({
+ name: category.name,
+ description: category.description,
+ slug: category.slug,
+ meta: JSON.stringify(category.meta),
+ id: generateRandomIDNumber(9),
+ })
+ .returning({ id: tsPageDataCategories.id })
+ .catch((error) => {
+ throw new Error(error);
+ });
},
- permissions: {
- insert: async (userId, rank) => {
- const userAlreadyExists = await db
- .select()
- .from(tsPermissions)
- .where(eq(tsPermissions.user, userId))
- .get();
+ permissions: async (userId, rank) => {
+ const userAlreadyExists = await db
+ .select()
+ .from(tsPermissions)
+ .where(eq(tsPermissions.user, userId))
+ .get();
- if (userAlreadyExists) {
- throw new Error(
- 'User already is already assigned a rank, please update the existing rank instead.'
- );
- }
+ if (userAlreadyExists) {
+ throw new Error(
+ 'User already is already assigned a rank, please update the existing rank instead.'
+ );
+ }
- return await db
- .insert(tsPermissions)
- .values({
- user: userId,
- rank,
- })
- .returning({ user: tsPermissions.user, rank: tsPermissions.rank })
- .catch((error) => {
- throw new Error(error);
- });
- },
+ return await db
+ .insert(tsPermissions)
+ .values({
+ user: userId,
+ rank,
+ })
+ .returning({ user: tsPermissions.user, rank: tsPermissions.rank })
+ .catch((error) => {
+ throw new Error(error);
+ });
},
};
diff --git a/packages/studiocms_core/src/sdk-utils/tables.ts b/packages/studiocms_core/src/sdk-utils/tables.ts
new file mode 100644
index 00000000..fe2c0a69
--- /dev/null
+++ b/packages/studiocms_core/src/sdk-utils/tables.ts
@@ -0,0 +1,76 @@
+import { asDrizzleTable } from '@astrojs/db/utils';
+import {
+ StudioCMSDiffTracking,
+ StudioCMSOAuthAccounts,
+ StudioCMSPageContent,
+ StudioCMSPageData,
+ StudioCMSPageDataCategories,
+ StudioCMSPageDataTags,
+ StudioCMSPermissions,
+ StudioCMSSessionTable,
+ StudioCMSSiteConfig,
+ StudioCMSUsers,
+} from '../db/tables';
+
+/**
+ * # StudioCMS - Page Content Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsPageContent = asDrizzleTable('StudioCMSPageContent', StudioCMSPageContent);
+
+/**
+ * # StudioCMS - Page Data Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsPageData = asDrizzleTable('StudioCMSPageData', StudioCMSPageData);
+
+/**
+ * # StudioCMS - Page Data Categories Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsPageDataCategories = asDrizzleTable(
+ 'StudioCMSPageDataCategories',
+ StudioCMSPageDataCategories
+);
+
+/**
+ * # StudioCMS - Page Data Tags Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsPageDataTags = asDrizzleTable('StudioCMSPageDataTags', StudioCMSPageDataTags);
+
+/**
+ * # StudioCMS - Permissions Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsPermissions = asDrizzleTable('StudioCMSPermissions', StudioCMSPermissions);
+
+/**
+ * # StudioCMS - Session Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsSessionTable = asDrizzleTable('StudioCMSSessionTable', StudioCMSSessionTable);
+
+/**
+ * # StudioCMS - Site Config Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsSiteConfig = asDrizzleTable('StudioCMSSiteConfig', StudioCMSSiteConfig);
+
+/**
+ * # StudioCMS - Users Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsUsers = asDrizzleTable('StudioCMSUsers', StudioCMSUsers);
+
+/**
+ * # StudioCMS - OAuth Accounts Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsOAuthAccounts = asDrizzleTable('StudioCMSOAuthAccounts', StudioCMSOAuthAccounts);
+
+/**
+ * # StudioCMS - Diff Tracking Table
+ * @description Exported TypeSafe Table definition for use in StudioCMS Integrations
+ */
+export const tsDiffTracking = asDrizzleTable('StudioCMSDiffTracking', StudioCMSDiffTracking);
diff --git a/packages/studiocms_core/src/sdk-utils/types/index.ts b/packages/studiocms_core/src/sdk-utils/types/index.ts
index 0ae3bee8..63cb3828 100644
--- a/packages/studiocms_core/src/sdk-utils/types/index.ts
+++ b/packages/studiocms_core/src/sdk-utils/types/index.ts
@@ -14,7 +14,7 @@ import type {
SimplifiedTables,
SingleRank,
SiteConfig,
-} from './tables.types';
+} from './tableDefs';
import type {
tsDiffTrackingSelect,
tsOAuthAccountsSelect,
@@ -28,12 +28,13 @@ import type {
tsPageDataTagsSelect,
tsPermissionsSelect,
tsSessionTableSelect,
+ tsSiteConfigInsert,
tsSiteConfigSelect,
tsUsersSelect,
-} from './tsAlias.types';
+} from './tsAlias';
export type {
- // tables.types.ts
+ // tables.ts
AvailableLists,
CombinedRank,
CurrentTables,
@@ -48,7 +49,7 @@ export type {
SimplifiedTables,
SingleRank,
SiteConfig,
- // tsAlias.types.ts
+ // tsAlias.ts
tsDiffTrackingSelect,
tsOAuthAccountsSelect,
tsPageContentInsert,
@@ -60,6 +61,7 @@ export type {
tsPageDataTagsInsert,
tsPageDataTagsSelect,
tsPermissionsSelect,
+ tsSiteConfigInsert,
tsSessionTableSelect,
tsSiteConfigSelect,
tsUsersSelect,
@@ -198,73 +200,6 @@ export type GetDatabaseEntry = GetDatabaseEntryUser | GetDatabaseEntryPage;
*/
export type GetDatabase = SiteConfig | CombinedUserData[] | CombinedPageData[] | undefined;
-/**
- * Interface representing the methods to add entries to various database tables.
- */
-export interface AddDatabaseEntry {
- /**
- * Methods related to the `pages` table.
- */
- pages: {
- /**
- * Inserts a new page entry into the database.
- * @param pageData - The data for the page to be inserted.
- * @param pageContent - The content for the page to be inserted.
- * @returns A promise that resolves to the result of the page insertion.
- */
- insert: (
- pageData: tsPageDataInsert,
- pageContent: tsPageContentInsert
- ) => Promise;
- };
- /**
- * Methods related to the `pageContent` table.
- */
- pageContent: {
- /**
- * Inserts new content for a specific page into the database.
- * @param pageId - The ID of the page to which the content belongs.
- * @param pageContent - The content to be inserted.
- * @returns A promise that resolves to an array of inserted content IDs.
- */
- insert: (pageId: string, pageContent: tsPageContentInsert) => Promise;
- };
- /**
- * Methods related to the `tags` table.
- */
- tags: {
- /**
- * Inserts a new tag into the database.
- * @param tag - The tag data to be inserted.
- * @returns A promise that resolves to an array of inserted tag responses.
- */
- insert: (tag: tsPageDataTagsInsert) => Promise;
- };
- /**
- * Methods related to the `categories` table.
- */
- categories: {
- /**
- * Inserts a new category into the database.
- * @param category - The category data to be inserted.
- * @returns A promise that resolves to an array of inserted category responses.
- */
- insert: (category: tsPageDataCategoriesInsert) => Promise;
- };
- /**
- * Methods related to the `permissions` table.
- */
- permissions: {
- /**
- * Inserts a new permission for a user into the database.
- * @param userId - The ID of the user to whom the permission is granted.
- * @param rank - The rank or level of the permission.
- * @returns A promise that resolves to an array of selected permissions.
- */
- insert: (userId: string, rank: string) => Promise;
- };
-}
-
/**
* Interface representing the STUDIOCMS SDK.
*/
@@ -373,8 +308,50 @@ export interface STUDIOCMS_SDK {
*/
POST: {
/**
- * Methods related to adding entries to the database.
+ * Utility functions for adding various entries to the database.
*/
- databaseEntry: AddDatabaseEntry;
+ databaseEntry: {
+ /**
+ * Inserts a new page entry into the database.
+ * @param pageData - The data for the page to be inserted.
+ * @param pageContent - The content for the page to be inserted.
+ * @returns A promise that resolves to the result of the page insertion.
+ */
+ pages: (
+ pageData: tsPageDataInsert,
+ pageContent: tsPageContentInsert
+ ) => Promise;
+ /**
+ * Inserts new content for a specific page into the database.
+ * @param pageId - The ID of the page to which the content belongs.
+ * @param pageContent - The content to be inserted.
+ * @returns A promise that resolves to an array of inserted content IDs.
+ */
+ pageContent: (
+ pageId: string,
+ pageContent: tsPageContentInsert
+ ) => Promise;
+ /**
+ * Inserts a new tag into the database.
+ * @param tag - The tag data to be inserted.
+ * @returns A promise that resolves to an array of inserted tag responses.
+ */
+ tags: (tag: tsPageDataTagsInsert) => Promise;
+ /**
+ * Inserts a new category into the database.
+ * @param category - The category data to be inserted.
+ * @returns A promise that resolves to an array of inserted category responses.
+ */
+ categories: (
+ category: tsPageDataCategoriesInsert
+ ) => Promise;
+ /**
+ * Inserts a new permission for a user into the database.
+ * @param userId - The ID of the user to whom the permission is granted.
+ * @param rank - The rank or level of the permission.
+ * @returns A promise that resolves to an array of selected permissions.
+ */
+ permissions: (userId: string, rank: string) => Promise;
+ };
};
}
diff --git a/packages/studiocms_core/src/sdk-utils/types/tables.types.ts b/packages/studiocms_core/src/sdk-utils/types/tableDefs.ts
similarity index 97%
rename from packages/studiocms_core/src/sdk-utils/types/tables.types.ts
rename to packages/studiocms_core/src/sdk-utils/types/tableDefs.ts
index f4bbc8a8..b5d5bb1d 100644
--- a/packages/studiocms_core/src/sdk-utils/types/tables.types.ts
+++ b/packages/studiocms_core/src/sdk-utils/types/tableDefs.ts
@@ -9,7 +9,7 @@ import type {
tsSessionTableSelect,
tsSiteConfigSelect,
tsUsersSelect,
-} from './tsAlias.types';
+} from './tsAlias';
/**
* Represents the possible table names in the current database schema.
@@ -68,7 +68,7 @@ export type SiteConfig = Omit;
/**
* Represents a stripped-down version of the `tsPageDataSelect` type,
- * excluding the properties 'catagories', 'categories', 'tags', and 'contributorIds'.
+ * excluding the properties 'categories', 'tags', and 'contributorIds'.
*/
export type PageDataStripped = Omit;
diff --git a/packages/studiocms_core/src/sdk-utils/types/tsAlias.types.ts b/packages/studiocms_core/src/sdk-utils/types/tsAlias.ts
similarity index 99%
rename from packages/studiocms_core/src/sdk-utils/types/tsAlias.types.ts
rename to packages/studiocms_core/src/sdk-utils/types/tsAlias.ts
index 158c00ba..c18b1067 100644
--- a/packages/studiocms_core/src/sdk-utils/types/tsAlias.types.ts
+++ b/packages/studiocms_core/src/sdk-utils/types/tsAlias.ts
@@ -9,7 +9,7 @@ import type {
tsSessionTable,
tsSiteConfig,
tsUsers,
-} from '../../db/tsTables';
+} from '../tables';
/**
* Type alias for the inferred select type of `tsUsers`.
diff --git a/packages/studiocms_core/src/sdk-utils/utils.ts b/packages/studiocms_core/src/sdk-utils/utils.ts
index e94121a3..bffcd0e5 100644
--- a/packages/studiocms_core/src/sdk-utils/utils.ts
+++ b/packages/studiocms_core/src/sdk-utils/utils.ts
@@ -7,7 +7,7 @@ import {
tsPageDataTags,
tsPermissions,
tsUsers,
-} from '../db/tsTables';
+} from './tables';
import type {
CombinedPageData,
CombinedRank,